(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{1873:(J,G,N)=>{"use strict";J.exports=N(4729)},4729:(J,G,N)=>{"use strict";var h=G;function u(){h.util._configure(),h.Writer._configure(h.BufferWriter),h.Reader._configure(h.BufferReader)}h.build="minimal",h.Writer=N(3542),h.BufferWriter=N(989),h.Reader=N(6913),h.BufferReader=N(1872),h.util=N(6138),h.rpc=N(9852),h.roots=N(935),h.configure=u,u()},6913:(J,G,N)=>{"use strict";J.exports=v;var u,h=N(6138),g=h.LongBits,b=h.utf8;function w(E,y){return RangeError("index out of range: "+E.pos+" + "+(y||1)+" > "+E.len)}function v(E){this.buf=E,this.pos=0,this.len=E.length}var y,l=typeof Uint8Array<"u"?function(y){if(y instanceof Uint8Array||Array.isArray(y))return new v(y);throw Error("illegal buffer")}:function(y){if(Array.isArray(y))return new v(y);throw Error("illegal buffer")},p=function(){return h.Buffer?function(f){return(v.create=function(A){return h.Buffer.isBuffer(A)?new u(A):l(A)})(f)}:l};function d(){var E=new g(0,0),y=0;if(!(this.len-this.pos>4)){for(;y<3;++y){if(this.pos>=this.len)throw w(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*y)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*y)>>>0,E}for(;y<4;++y)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*y)>>>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(y=0,this.len-this.pos>4){for(;y<5;++y)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*y+3)>>>0,this.buf[this.pos++]<128)return E}else for(;y<5;++y){if(this.pos>=this.len)throw w(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*y+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function _(E,y){return(E[y-4]|E[y-3]<<8|E[y-2]<<16|E[y-1]<<24)>>>0}function I(){if(this.pos+8>this.len)throw w(this,8);return new g(_(this.buf,this.pos+=4),_(this.buf,this.pos+=4))}v.create=p(),v.prototype._slice=h.Array.prototype.subarray||h.Array.prototype.slice,v.prototype.uint32=(y=4294967295,function(){if(y=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(y=(y|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(y=(y|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(y=(y|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(y=(y|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return y;if((this.pos+=5)>this.len)throw this.pos=this.len,w(this,10);return y}),v.prototype.int32=function(){return 0|this.uint32()},v.prototype.sint32=function(){var y=this.uint32();return y>>>1^-(1&y)|0},v.prototype.bool=function(){return 0!==this.uint32()},v.prototype.fixed32=function(){if(this.pos+4>this.len)throw w(this,4);return _(this.buf,this.pos+=4)},v.prototype.sfixed32=function(){if(this.pos+4>this.len)throw w(this,4);return 0|_(this.buf,this.pos+=4)},v.prototype.float=function(){if(this.pos+4>this.len)throw w(this,4);var y=h.float.readFloatLE(this.buf,this.pos);return this.pos+=4,y},v.prototype.double=function(){if(this.pos+8>this.len)throw w(this,4);var y=h.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,y},v.prototype.bytes=function(){var y=this.uint32(),f=this.pos,C=this.pos+y;if(C>this.len)throw w(this,y);return this.pos+=y,Array.isArray(this.buf)?this.buf.slice(f,C):f===C?new this.buf.constructor(0):this._slice.call(this.buf,f,C)},v.prototype.string=function(){var y=this.bytes();return b.read(y,0,y.length)},v.prototype.skip=function(y){if("number"==typeof y){if(this.pos+y>this.len)throw w(this,y);this.pos+=y}else do{if(this.pos>=this.len)throw w(this)}while(128&this.buf[this.pos++]);return this},v.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},v._configure=function(E){u=E,v.create=p(),u._configure();var y=h.Long?"toLong":"toNumber";h.merge(v.prototype,{int64:function(){return d.call(this)[y](!1)},uint64:function(){return d.call(this)[y](!0)},sint64:function(){return d.call(this).zzDecode()[y](!1)},fixed64:function(){return I.call(this)[y](!0)},sfixed64:function(){return I.call(this)[y](!1)}})}},1872:(J,G,N)=>{"use strict";J.exports=g;var h=N(6913);(g.prototype=Object.create(h.prototype)).constructor=g;var u=N(6138);function g(b){h.call(this,b)}g._configure=function(){u.Buffer&&(g.prototype._slice=u.Buffer.prototype.slice)},g.prototype.string=function(){var w=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+w,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+w,this.len))},g._configure()},935:J=>{"use strict";J.exports={}},9852:(J,G,N)=>{"use strict";G.Service=N(3939)},3939:(J,G,N)=>{"use strict";J.exports=u;var h=N(6138);function u(g,b,w){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");h.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(b),this.responseDelimited=Boolean(w)}(u.prototype=Object.create(h.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function g(b,w,v,l,p){if(!l)throw TypeError("request must be specified");var d=this;if(!p)return h.asPromise(g,d,b,w,v,l);if(d.rpcImpl)try{return d.rpcImpl(b,w[d.requestDelimited?"encodeDelimited":"encode"](l).finish(),function(I,E){if(I)return d.emit("error",I,b),p(I);if(null!==E){if(!(E instanceof v))try{E=v[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(y){return d.emit("error",y,b),p(y)}return d.emit("data",E,b),p(null,E)}d.end(!0)})}catch(_){return d.emit("error",_,b),void setTimeout(function(){p(_)},0)}else setTimeout(function(){p(Error("already ended"))},0)},u.prototype.end=function(b){return this.rpcImpl&&(b||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6723:(J,G,N)=>{"use strict";J.exports=u;var h=N(6138);function u(v,l){this.lo=v>>>0,this.hi=l>>>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 b=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(l){if(0===l)return g;var p=l<0;p&&(l=-l);var d=l>>>0,_=(l-d)/4294967296>>>0;return p&&(_=~_>>>0,d=~d>>>0,++d>4294967295&&(d=0,++_>4294967295&&(_=0))),new u(d,_)},u.from=function(l){if("number"==typeof l)return u.fromNumber(l);if(h.isString(l)){if(!h.Long)return u.fromNumber(parseInt(l,10));l=h.Long.fromString(l)}return l.low||l.high?new u(l.low>>>0,l.high>>>0):g},u.prototype.toNumber=function(l){if(!l&&this.hi>>>31){var p=1+~this.lo>>>0,d=~this.hi>>>0;return p||(d=d+1>>>0),-(p+4294967296*d)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(l){return h.Long?new h.Long(0|this.lo,0|this.hi,Boolean(l)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(l)}};var w=String.prototype.charCodeAt;u.fromHash=function(l){return l===b?g:new u((w.call(l,0)|w.call(l,1)<<8|w.call(l,2)<<16|w.call(l,3)<<24)>>>0,(w.call(l,4)|w.call(l,5)<<8|w.call(l,6)<<16|w.call(l,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 l=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^l)>>>0,this.lo=(this.lo<<1^l)>>>0,this},u.prototype.zzDecode=function(){var l=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^l)>>>0,this.hi=(this.hi>>>1^l)>>>0,this},u.prototype.length=function(){var l=this.lo,p=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===p?l<16384?l<128?1:2:l<2097152?3:4:p<16384?p<128?5:6:p<2097152?7:8:d<128?9:10}},6138:function(J,G,N){"use strict";var h=G;function u(b,w,v){for(var l=Object.keys(w),p=0;p0)},h.Buffer=function(){try{var b=h.inquire("buffer").Buffer;return b.prototype.utf8Write?b:null}catch{return null}}(),h._Buffer_from=null,h._Buffer_allocUnsafe=null,h.newBuffer=function(w){return"number"==typeof w?h.Buffer?h._Buffer_allocUnsafe(w):new h.Array(w):h.Buffer?h._Buffer_from(w):typeof Uint8Array>"u"?w:new Uint8Array(w)},h.Array=typeof Uint8Array<"u"?Uint8Array:Array,h.Long=h.global.dcodeIO&&h.global.dcodeIO.Long||h.global.Long||h.inquire("long"),h.key2Re=/^true|false|0|1$/,h.key32Re=/^-?(?:0|[1-9][0-9]*)$/,h.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,h.longToHash=function(w){return w?h.LongBits.from(w).toHash():h.LongBits.zeroHash},h.longFromHash=function(w,v){var l=h.LongBits.fromHash(w);return h.Long?h.Long.fromBits(l.lo,l.hi,v):l.toNumber(Boolean(v))},h.merge=u,h.lcFirst=function(w){return w.charAt(0).toLowerCase()+w.substring(1)},h.newError=g,h.ProtocolError=g("ProtocolError"),h.oneOfGetter=function(w){for(var v={},l=0;l-1;--d)if(1===v[p[d]]&&null!=this[p[d]])return p[d]}},h.oneOfSetter=function(w){return function(v){for(var l=0;l{"use strict";J.exports=d;var u,h=N(6138),g=h.LongBits,b=h.base64,w=h.utf8;function v(P,D,x){this.fn=P,this.len=D,this.next=void 0,this.val=x}function l(){}function p(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 v(l,0,0),this.tail=this.head,this.states=null}var _=function(){return h.Buffer?function(){return(d.create=function(){return new u})()}:function(){return new d}};function I(P,D,x){D[x]=255&P}function y(P,D){this.len=P,this.next=void 0,this.val=D}function f(P,D,x){for(;P.hi;)D[x++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[x++]=127&P.lo|128,P.lo=P.lo>>>7;D[x++]=P.lo}function C(P,D,x){D[x]=255&P,D[x+1]=P>>>8&255,D[x+2]=P>>>16&255,D[x+3]=P>>>24}d.create=_(),d.alloc=function(D){return new h.Array(D)},h.Array!==Array&&(d.alloc=h.pool(d.alloc,h.Array.prototype.subarray)),d.prototype._push=function(D,x,M){return this.tail=this.tail.next=new v(D,x,M),this.len+=x,this},(y.prototype=Object.create(v.prototype)).fn=function E(P,D,x){for(;P>127;)D[x++]=127&P|128,P>>>=7;D[x]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new y((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(f,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 x=g.from(D);return this._push(f,x.length(),x)},d.prototype.sint64=function(D){var x=g.from(D).zzEncode();return this._push(f,x.length(),x)},d.prototype.bool=function(D){return this._push(I,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(C,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var x=g.from(D);return this._push(C,4,x.lo)._push(C,4,x.hi)},d.prototype.float=function(D){return this._push(h.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(h.float.writeDoubleLE,8,D)};var A=h.Array.prototype.set?function(D,x,M){x.set(D,M)}:function(D,x,M){for(var B=0;B>>0;if(!x)return this._push(I,1,0);if(h.isString(D)){var M=d.alloc(x=b.length(D));b.decode(D,M,0),D=M}return this.uint32(x)._push(A,x,D)},d.prototype.string=function(D){var x=w.length(D);return x?this.uint32(x)._push(w.write,x,D):this._push(I,1,0)},d.prototype.fork=function(){return this.states=new p(this),this.head=this.tail=new v(l,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 v(l,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,x=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=x,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,x=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,x,M),M+=D.len,D=D.next;return x},d._configure=function(P){u=P,d.create=_(),u._configure()}},989:(J,G,N)=>{"use strict";J.exports=g;var h=N(3542);(g.prototype=Object.create(h.prototype)).constructor=g;var u=N(6138);function g(){h.call(this)}function b(w,v,l){w.length<40?u.utf8.write(w,v,l):v.utf8Write?v.utf8Write(w,l):v.write(w,l)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(v,l,p){l.set(v,p)}:function(v,l,p){if(v.copy)v.copy(l,p,0,v.length);else for(var d=0;d>>0;return this.uint32(l),l&&this._push(g.writeBytesBuffer,l,v),this},g.prototype.string=function(v){var l=u.Buffer.byteLength(v);return this.uint32(l),l&&this._push(b,l,v),this},g._configure()},623:(J,G,N)=>{"use strict";var h={};N.r(h),N.d(h,{identity:()=>cF});var u={};N.r(u),N.d(u,{base2:()=>uF});var g={};N.r(g),N.d(g,{base8:()=>lF});var b={};N.r(b),N.d(b,{base10:()=>fF});var w={};N.r(w),N.d(w,{base16:()=>dF,base16upper:()=>hF});var v={};N.r(v),N.d(v,{base32:()=>Ro,base32hex:()=>mF,base32hexpad:()=>EF,base32hexpadupper:()=>wF,base32hexupper:()=>vF,base32pad:()=>gF,base32padupper:()=>yF,base32upper:()=>pF,base32z:()=>bF});var l={};N.r(l),N.d(l,{base36:()=>_F,base36upper:()=>DF});var p={};N.r(p),N.d(p,{base58btc:()=>Ci,base58flickr:()=>SF});var d={};N.r(d),N.d(d,{base64:()=>Lh,base64pad:()=>IF,base64url:()=>CF,base64urlpad:()=>TF});var _={};N.r(_),N.d(_,{base256emoji:()=>NF});var I={};N.r(I),N.d(I,{sha256:()=>Li,sha512:()=>JF});var E={};N.r(E),N.d(E,{identity:()=>gu});var y={};N.r(y),N.d(y,{code:()=>nU,decode:()=>iU,encode:()=>rU,name:()=>tU});var f={};N.r(f),N.d(f,{code:()=>cU,decode:()=>lU,encode:()=>uU,name:()=>aU});var C={};N.r(C),N.d(C,{RsaPrivateKey:()=>qh,RsaPublicKey:()=>Ym,fromJwk:()=>eV,generateKeyPair:()=>tV,unmarshalRsaPrivateKey:()=>XU,unmarshalRsaPublicKey:()=>JU});var A={};N.r(A),N.d(A,{Ed25519PrivateKey:()=>ff,Ed25519PublicKey:()=>mv,generateKeyPair:()=>CV,generateKeyPairFromSeed:()=>TV,unmarshalEd25519PrivateKey:()=>SV,unmarshalEd25519PublicKey:()=>IV});var P={};function D(n){return"function"==typeof n}function x(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}N.r(P),N.d(P,{Secp256k1PrivateKey:()=>Dv,Secp256k1PublicKey:()=>_v,generateKeyPair:()=>kV,unmarshalSecp256k1PrivateKey:()=>OV,unmarshalSecp256k1PublicKey:()=>LV});const M=x(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 B(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)&&B(t,e)}remove(e){const{_finalizers:t}=this;t&&B(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const z=F.EMPTY;function S(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 H={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 j(n){L.setTimeout(()=>{const{onUnhandledError:e}=H;if(!e)throw n;e(n)})}function re(){}const $=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(H.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,S(e)&&e.add(this)):this.destination=Ce}static create(e,t,r){return new we(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($,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 ke=Function.prototype.bind;function Se(n,e){return ke.call(n,e)}class Pe{constructor(e){this.partialObserver=e}next(e){const{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){$e(r)}}error(e){const{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){$e(r)}else $e(e)}complete(){const{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){$e(t)}}}class we 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&&H.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 Pe(i)}}function $e(n){H.useDeprecatedSynchronousErrorHandling?function de(n){H.useDeprecatedSynchronousErrorHandling&&ne&&(ne.errorThrown=!0,ne.error=n)}(n):j(n)}function Ee(n,e){const{onStoppedNotification:t}=H;t&&L.setTimeout(()=>t(n,e))}const Ce={closed:!0,next:re,error:function K(n){throw n},complete:re},xe="function"==typeof Symbol&&Symbol.observable||"@@observable";function Ke(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 Dt(n){return n&&n instanceof pe||function pt(n){return n&&D(n.next)&&D(n.error)&&D(n.complete)}(n)&&S(n)}(t)?t:new we(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=Ot(r))((i,s)=>{const o=new we({next:a=>{try{t(a)}catch(c){s(c),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?Ke:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=Ot(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function Ot(n){var e;return null!==(e=n??H.Promise)&&void 0!==e?e:Promise}const Wr=x(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let Sr=(()=>{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 ni(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Wr}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?z:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,B(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 ni(e,t),n})();class ni extends Sr{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:z}}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(c){e.error(c)}}:super._next,this._error=i?function(a){try{i(a)}catch(c){e.error(c)}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 yn(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(k){r[k]&&(i[k]=function(U){return new Promise(function(Q,X){s.push([k,U,Q,X])>1||a(k,U)})})}function a(k,U){try{!function c(k){k.value instanceof Bt?Promise.resolve(k.value.v).then(m,T):R(s[0][2],k)}(r[k](U))}catch(Q){R(s[0][3],Q)}}function m(k){a("next",k)}function T(k){a("throw",k)}function R(k,U){k(U),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,c){!function i(s,o,a,c){Promise.resolve(c).then(function(m){s({value:m,done:a})},o)}(a,c,(o=n[s](o)).done,o.value)})}}}const bn=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function vr(n){return D(n?.then)}function rr(n){return D(n[xe])}function _n(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 ut(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function ve(n){return D(n?.[ce])}function yt(n){return yn(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 St(n){return D(n?.getReader)}function mn(n){if(n instanceof Xe)return n;if(null!=n){if(rr(n))return function Ge(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(bn(n))return function Qe(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,j)})}(n);if(_n(n))return ht(n);if(ve(n))return function ze(n){return new Xe(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(St(n))return function Et(n){return ht(yt(n))}(n)}throw Ft(n)}function ht(n){return new Xe(e=>{(function lt(n,e){var t,r,i,s;return function ge(n,e,t,r){return new(t||(t=Promise))(function(s,o){function a(T){try{m(r.next(T))}catch(R){o(R)}}function c(T){try{m(r.throw(T))}catch(R){o(R)}}function m(T){T.done?s(T.value):function i(s){return s instanceof t?s:new t(function(o){o(s)})}(T.value).then(a,c)}m((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 It(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))(mn(n(r,i))),t):("number"==typeof e&&(t=e),fe((r,i)=>function jt(n,e,t,r,i,s,o,a){const c=[];let m=0,T=0,R=!1;const k=()=>{R&&!c.length&&!m&&e.complete()},U=X=>m{s&&e.next(X),m++;let ae=!1;mn(t(X,T++)).subscribe(ye(e,he=>{i?.(he),s?U(he):e.next(he)},()=>{ae=!0},void 0,()=>{if(ae)try{for(m--;c.length&&mQ(he)):Q(he)}k()}catch(he){e.error(he)}}))};return n.subscribe(ye(e,U,()=>{R=!0,k()})),()=>{a?.()}}(r,i,n,t)))}const Tn=new Xe(n=>n.complete());function Zo(n){return n[n.length-1]}function Y(n,e=0){return fe((t,r)=>{t.subscribe(ye(r,i=>It(r,n,()=>r.next(i),e),()=>It(r,n,()=>r.complete(),e),i=>It(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=>{It(t,e,()=>{const r=n[Symbol.asyncIterator]();It(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function mi(...n){const e=function ka(n){return function La(n){return n&&D(n.schedule)}(Zo(n))?n.pop():void 0}(n),t=function W(n,e){return"number"==typeof Zo(n)?n.pop():e}(n,1/0),r=n;return r.length?1===r.length?mn(r[0]):function Nn(n=1/0){return Ut(Ke,n)}(t)(function Ri(n,e){return e?function Ir(n,e){if(null!=n){if(rr(n))return function le(n,e){return mn(n).pipe(ee(e),Y(e))}(n,e);if(bn(n))return function He(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(vr(n))return function Oe(n,e){return mn(n).pipe(ee(e),Y(e))}(n,e);if(_n(n))return Ze(n,e);if(ve(n))return function tt(n,e){return new Xe(t=>{let r;return It(t,e,()=>{r=n[ce](),It(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(St(n))return function on(n,e){return Ze(yt(n),e)}(n,e)}throw Ft(n)}(n,e):mn(n)}(r,e)):Tn}function Xo(n,e,...t){if(!0===e)return void n();if(!1===e)return;const r=new we({next:()=>{r.unsubscribe(),n()}});return e(...t).subscribe(r)}function Xt(n){for(let e in n)if(n[e]===Xt)return e;throw Error("Could not find renamed property on target object.")}function Dn(n){if("string"==typeof n)return n;if(Array.isArray(n))return"["+n.map(Dn).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 ns(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const el=Xt({__forward_ref__:Xt});function ag(n){return n.__forward_ref__=ag,n.toString=function(){return Dn(this())},n}function Nt(n){return function cg(n){return"function"==typeof n&&n.hasOwnProperty(el)&&n.__forward_ref__===ag}(n)?n():n}class xt extends Error{constructor(e,t){super(function Yf(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 Zf(n,e){throw new xt(-201,!1)}function Ki(n,e){null==n&&function Mn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function Jn(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function vc(n){return{providers:n.providers||[],imports:n.imports||[]}}function Xf(n){return bb(n,Jf)||bb(n,Db)}function bb(n,e){return n.hasOwnProperty(e)?n[e]:null}function _b(n){return n&&(n.hasOwnProperty(ug)||n.hasOwnProperty(bP))?n[ug]:null}const Jf=Xt({\u0275prov:Xt}),ug=Xt({\u0275inj:Xt}),Db=Xt({ngInjectableDef:Xt}),bP=Xt({ngInjectorDef:Xt});var Lt=(()=>((Lt=Lt||{})[Lt.Default=0]="Default",Lt[Lt.Host=1]="Host",Lt[Lt.Self=2]="Self",Lt[Lt.SkipSelf=4]="SkipSelf",Lt[Lt.Optional=8]="Optional",Lt))();let lg;function rs(n){const e=lg;return lg=n,e}function Sb(n,e,t){const r=Xf(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&Lt.Optional?null:void 0!==e?e:void Zf(Dn(n))}function Jo(n){return{toString:n}.toString()}var _s=(()=>((_s=_s||{})[_s.OnPush=0]="OnPush",_s[_s.Default=1]="Default",_s))(),zs=(()=>{return(n=zs||(zs={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",zs;var n})();const jn=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),Ec={},xn=[],ed=Xt({\u0275cmp:Xt}),fg=Xt({\u0275dir:Xt}),dg=Xt({\u0275pipe:Xt}),Ib=Xt({\u0275mod:Xt}),po=Xt({\u0275fac:Xt}),tl=Xt({__NG_ELEMENT_ID__:Xt});let DP=0;function td(n){return Jo(()=>{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===_s.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||xn,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||zs.Emulated,id:"c"+DP++,styles:n.styles||xn,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=Ab(n.inputs,r),i.outputs=Ab(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(Cb).filter(Tb):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(wi).filter(Tb):null,i})}function Cb(n){return kn(n)||Ei(n)}function Tb(n){return null!==n}function nl(n){return Jo(()=>({type:n.type,bootstrap:n.bootstrap||xn,declarations:n.declarations||xn,imports:n.imports||xn,exports:n.exports||xn,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function Ab(n,e){if(null==n)return Ec;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 is=td;function kn(n){return n[ed]||null}function Ei(n){return n[fg]||null}function wi(n){return n[dg]||null}function Ni(n){return Array.isArray(n)&&"object"==typeof n[1]}function Ss(n){return Array.isArray(n)&&!0===n[1]}function gg(n){return 0!=(8&n.flags)}function sd(n){return 2==(2&n.flags)}function od(n){return 1==(1&n.flags)}function Is(n){return null!==n.template}function xP(n){return 0!=(256&n[2])}function Ha(n,e){return n.hasOwnProperty(po)?n[po]:null}class NP{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function Pb(n){return n.type.prototype.ngOnChanges&&(n.setInput=OP),MP}function MP(){const n=Mb(this),e=n?.current;if(e){const t=n.previous;if(t===Ec)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function OP(n,e,t,r){const i=Mb(n)||function LP(n,e){return n[Nb]=e}(n,{previous:Ec,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],c=o[a];s[a]=new NP(c&&c.currentValue,e,o===Ec),n[r]=e}const Nb="__ngSimpleChanges__";function Mb(n){return n[Nb]||null}function Cr(n){for(;Array.isArray(n);)n=n[0];return n}function as(n,e){return Cr(e[n.index])}function wg(n,e){return n.data[e]}function Gi(n,e){const t=e[n];return Ni(t)?t:t[0]}function ud(n){return 64==(64&n[2])}function ea(n,e){return null==e?null:n[e]}function Lb(n){n[18]=0}function bg(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:$b(null),bindingsEnabled:!0};function Bb(){return kt.bindingsEnabled}function Ve(){return kt.lFrame.lView}function pn(){return kt.lFrame.tView}function Lr(){let n=Fb();for(;null!==n&&64===n.type;)n=n.parent;return n}function Fb(){return kt.lFrame.currentTNode}function Ws(n,e){const t=kt.lFrame;t.currentTNode=n,t.isParent=e}function _g(){return kt.lFrame.isParent}function Ic(){return kt.lFrame.bindingIndex++}function ZP(n,e){const t=kt.lFrame;t.bindingIndex=t.bindingRootIndex=n,Sg(e)}function Sg(n){kt.lFrame.currentDirectiveIndex=n}function Cg(n){kt.lFrame.currentQueryIndex=n}function JP(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function Kb(n,e,t){if(t&Lt.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&Lt.Host||(i=JP(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=kt.lFrame=jb();return r.currentTNode=e,r.lView=n,!0}function Tg(n){const e=jb(),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 jb(){const n=kt.lFrame,e=null===n?null:n.child;return null===e?$b(n):e}function $b(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 Gb(){const n=kt.lFrame;return kt.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const zb=Gb;function Ag(){const n=Gb();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 _i(){return kt.lFrame.selectedIndex}function ta(n){kt.lFrame.selectedIndex=n}function fd(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[c]<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 cl{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function pd(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 Pg=!0;function yd(n){const e=Pg;return Pg=n,e}let pN=0;const qs={};function ll(n,e){const t=Mg(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Ng(r.data,n),Ng(e,null),Ng(r.blueprint,null));const i=md(n,e),s=n.injectorIndex;if(Zb(i)){const o=Cc(i),a=Tc(i,e),c=a[1].data;for(let m=0;m<8;m++)e[s+m]=a[o+m]|c[o+m]}return e[s+8]=i,s}function Ng(n,e){n.push(0,0,0,0,0,0,0,0,e)}function Mg(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function md(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=o_(i),null===r)return-1;if(t++,i=i[15],-1!==r.injectorIndex)return r.injectorIndex|t<<16}return-1}function vd(n,e,t){!function gN(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(tl)&&(r=t[tl]),null==r&&(r=t[tl]=pN++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:EN:e}(t);if("function"==typeof s){if(!Kb(e,n,r))return r&Lt.Host?e_(i,0,r):t_(e,t,r,i);try{const o=s(r);if(null!=o||r&Lt.Optional)return o;Zf()}finally{zb()}}else if("number"==typeof s){let o=null,a=Mg(n,e),c=-1,m=r&Lt.Host?e[16][6]:null;for((-1===a||r&Lt.SkipSelf)&&(c=-1===a?md(n,e):e[a+8],-1!==c&&s_(r,!1)?(o=e[1],a=Cc(c),e=Tc(c,e)):a=-1);-1!==a;){const T=e[1];if(i_(s,a,T.data)){const R=mN(a,e,t,o,r,m);if(R!==qs)return R}c=e[a+8],-1!==c&&s_(r,e[1].data[a+8]===m)&&i_(s,a,e)?(o=T,a=Cc(c),e=Tc(c,e)):a=-1}}return i}function mN(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],T=function Ed(n,e,t,r,i){const s=n.providerIndexes,o=e.data,a=1048575&s,c=n.directiveStart,T=s>>20,k=i?a+T:n.directiveEnd;for(let U=r?a:a+T;U=c&&Q.type===t)return U}if(i){const U=o[c];if(U&&Is(U)&&U.type===t)return c}return null}(a,o,t,null==r?sd(a)&&Pg:r!=o&&0!=(3&a.type),i&Lt.Host&&s===a);return null!==T?fl(e,o,T,a):qs}function fl(n,e,t,r){let i=n[t];const s=e.data;if(function uN(n){return n instanceof cl}(i)){const o=i;o.resolving&&function pP(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new xt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function An(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=yd(o.canSeeViewProviders);o.resolving=!0;const c=o.injectImpl?rs(o.injectImpl):null;Kb(n,r,Lt.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function aN(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=Pb(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!==c&&rs(c),yd(a),o.resolving=!1,zb()}}return i}function i_(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function kg(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(c,m,T){const R=c.hasOwnProperty(Rc)?c[Rc]:Object.defineProperty(c,Rc,{value:[]})[Rc];for(;R.length<=T;)R.push(null);return(R[T]=R[T]||[]).push(o),c}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}class an{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=Jn({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function mo(n,e){n.forEach(t=>Array.isArray(t)?mo(t,e):e(t))}function c_(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function wd(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const gl={},Vg="__NG_DI_FLAG__",_d="ngTempTokenPath",MN=/\n/gm,d_="__source";let yl;function Oc(n){const e=yl;return yl=n,e}function LN(n,e=Lt.Default){if(void 0===yl)throw new xt(-203,!1);return null===yl?Sb(n,void 0,e):yl.get(n,e&Lt.Optional?null:void 0,e)}function On(n,e=Lt.Default){return(function _P(){return lg}()||LN)(Nt(n),e)}function Hg(n){const e=[];for(let t=0;t{const o=s;Yg(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&V_(i,t),t}function V_(n,e){for(let t=0;t{e.push(s)})}}function Yg(n,e,t,r){if(!(n=Nt(n)))return!1;let i=null,s=_b(n);const o=!s&&kn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const c=n.ngModule;if(s=_b(c),!s)return!1;i=c}const a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){const c="function"==typeof o.dependencies?o.dependencies():o.dependencies;for(const m of c)Yg(m,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let m;r.add(i);try{mo(s.imports,T=>{Yg(T,e,t,r)&&(m||(m=[]),m.push(T))})}finally{}void 0!==m&&V_(m,e)}if(!a){const m=Ha(i)||(()=>new i);e.push({provide:i,useFactory:m,deps:xn},{provide:B_,useValue:i,multi:!0},{provide:L_,useValue:()=>On(i),multi:!0})}const c=s.providers;null==c||a||mo(c,T=>{e.push(T)})}}return i!==n&&void 0!==n.providers}const _M=Xt({provide:String,useValue:Xt});function Zg(n){return null!==n&&"object"==typeof n&&_M in n}function Ka(n){return"function"==typeof n}const Xg=new an("Set Injector scope."),Pd={},SM={};let Jg;function Nd(){return void 0===Jg&&(Jg=new F_),Jg}class Bc{}class j_ extends Bc{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,ty(e,o=>this.processProvider(o)),this.records.set(k_,Fc(void 0,this)),i.has("environment")&&this.records.set(Bc,Fc(void 0,this));const s=this.records.get(Xg);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(B_.multi,xn,Lt.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=Oc(this),r=rs(void 0);try{return e()}finally{Oc(t),rs(r)}}get(e,t=gl,r=Lt.Default){this.assertNotDestroyed();const i=Oc(this),s=rs(void 0);try{if(!(r&Lt.SkipSelf)){let a=this.records.get(e);if(void 0===a){const c=function xM(n){return"function"==typeof n||"object"==typeof n&&n instanceof an}(e)&&Xf(e);a=c&&this.injectableDefInScope(c)?Fc(ey(e),Pd):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&Lt.Self?Nd():this.parent).get(e,t=r&Lt.Optional&&t===gl?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[_d]=o[_d]||[]).unshift(Dn(e)),i)throw o;return function FN(n,e,t,r){const i=n[_d];throw e[d_]&&i.unshift(e[d_]),n.message=function UN(n,e,t,r=null){n=n&&"\n"===n.charAt(0)&&"\u0275"==n.charAt(1)?n.slice(2):n;let i=Dn(e);if(Array.isArray(e))i=e.map(Dn).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):Dn(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(MN,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[_d]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{rs(s),Oc(i)}}resolveInjectorInitializers(){const e=Oc(this),t=rs(void 0);try{const r=this.get(L_.multi,xn,Lt.Self);for(const i of r)i()}finally{Oc(e),rs(t)}}toString(){const e=[],t=this.records;for(const r of t.keys())e.push(Dn(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new xt(205,!1)}processProvider(e){let t=Ka(e=Nt(e))?e:Nt(e&&e.provide);const r=function CM(n){return Zg(n)?Fc(void 0,n.useValue):Fc(function $_(n,e,t){let r;if(Ka(n)){const i=Nt(n);return Ha(i)||ey(i)}if(Zg(n))r=()=>Nt(n.useValue);else if(function K_(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...Hg(n.deps||[]));else if(function H_(n){return!(!n||!n.useExisting)}(n))r=()=>On(Nt(n.useExisting));else{const i=Nt(n&&(n.useClass||n.provide));if(!function TM(n){return!!n.deps}(n))return Ha(i)||ey(i);r=()=>new i(...Hg(n.deps))}return r}(n),Pd)}(e);if(Ka(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=Fc(void 0,Pd,!0),i.factory=()=>Hg(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===Pd&&(t.value=SM,t.value=t.factory()),"object"==typeof t.value&&t.value&&function AM(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=Nt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function ey(n){const e=Xf(n),t=null!==e?e.factory:Ha(n);if(null!==t)return t;if(n instanceof an)throw new xt(204,!1);if(n instanceof Function)return function IM(n){const e=n.length;if(e>0)throw function pl(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new xt(204,!1)}function Fc(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function RM(n){return!!n.\u0275providers}function ty(n,e){for(const t of n)Array.isArray(t)?ty(t,e):RM(t)?ty(t.\u0275providers,e):e(t)}class G_{}class MM{resolveComponentFactory(e){throw function NM(n){const e=Error(`No component factory found for ${Dn(n)}. Did you add it to @NgModule.entryComponents?`);return e.ngComponent=n,e}(e)}}let Md=(()=>{class n{}return n.NULL=new MM,n})();function OM(){return Uc(Lr(),Ve())}function Uc(n,e){return new Vc(as(n,e))}let Vc=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=OM,n})();class W_{}let BM=(()=>{class n{}return n.\u0275prov=Jn({token:n,providedIn:"root",factory:()=>null}),n})();class ny{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const FM=new ny("14.2.0"),ry={};function cy(n){return n.ngOriginalError}class Hc{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&&cy(e);for(;t&&cy(t);)t=cy(t);return t||null}}const uy=new Map;let YM=0;const fy="__ngContext__";function si(n,e){Ni(e)?(n[fy]=e[20],function XM(n){uy.set(n[20],n)}(e)):n[fy]=e}function Dl(n){const e=n[fy];return"number"==typeof e?function e1(n){return uy.get(n)||null}(e):e||null}function dy(n){const e=Dl(n);return e?Ni(e)?e:e.lView:null}var Mi=(()=>((Mi=Mi||{})[Mi.Important=1]="Important",Mi[Mi.DashCase=2]="DashCase",Mi))();function py(n,e){return undefined(n,e)}function Sl(n){const e=n[3];return Ss(e)?e[3]:e}function gy(n){return a1(n[13])}function yy(n){return a1(n[4])}function a1(n){for(;null!==n&&!Ss(n);)n=n[4];return n}function jc(n,e,t,r,i){if(null!=r){let s,o=!1;Ss(r)?s=r:Ni(r)&&(o=!0,r=r[0]);const a=Cr(r);0===n&&null!==t?null==i?h1(e,t,a):ja(e,t,a,i||null,!0):1===n&&null!==t?ja(e,t,a,i||null,!0):2===n?function w1(n,e,t){const r=Od(n,e);r&&function I3(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function A3(n,e,t,r,i){const s=t[7];s!==Cr(t)&&jc(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=wd(n,10+e);!function m3(n,e){Il(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 l1(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&Il(n,e,t,3,null,null),function w3(n){let e=n[13];if(!e)return wy(n[1],n);for(;e;){let t=null;if(Ni(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)Ni(e)&&wy(e[1],e),e=e[3];null===e&&(e=n),Ni(e)&&wy(e[1],e),t=e&&e[4]}e=t}}(e)}}function wy(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function S3(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=m]():r[i=-m].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[R+1].toLowerCase();const U=8&r?k:null;if(U&&-1!==D1(U,m,0)||2&r&&m!==k){if(Cs(r))return!1;o=!0}}}}else{if(!o&&!Cs(r)&&!Cs(c))return!1;if(o&&Cs(c))continue;o=!1,r=c|1&r}}return Cs(r)||o}function Cs(n){return 0==(1&n)}function M3(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&&!Cs(o)&&(e+=T1(s,i),i=""),r=o,s=s||!Cs(r);t++}return""!==i&&(e+=T1(s,i)),e}const Ht={};function Cl(n){A1(pn(),Ve(),_i()+n,!1)}function A1(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&dd(e,s,t)}else{const s=n.preOrderHooks;null!==s&&hd(e,s,0,t)}ta(t)}function N1(n,e=null,t=null,r){const i=M1(n,e,t,r);return i.resolveInjectorInitializers(),i}function M1(n,e=null,t=null,r,i=new Set){const s=[t||xn,bM(n)];return r=r||("object"==typeof n?void 0:Dn(n)),new j_(s,e||Nd(),r||null,i)}let $a=(()=>{class n{static create(t,r){if(Array.isArray(t))return N1({name:""},r,t,"");{const i=t.name??"";return N1({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=gl,n.NULL=new F_,n.\u0275prov=Jn({token:n,providedIn:"any",factory:()=>On(k_)}),n.__NG_ELEMENT_ID__=-1,n})();function qt(n,e=Lt.Default){const t=Ve();return null===t?On(n,e):n_(Lr(),t,Nt(n),e)}function Y1(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&A1(n,e,22,!1),t(r,i)}finally{ta(s)}}function Vy(n,e,t){!Bb()||(function TO(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||ll(t,e),si(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)!=c&&a.push(c),a.push(r,i,o)}}function sD(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function oD(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function PO(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Gy(t)}}function Gy(n){for(let r=gy(n);null!==r;r=yy(r))for(let i=10;i0&&Gy(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Gy(i)}}function FO(n,e){const t=Gi(e,n),r=t[1];(function UO(n,e){for(let t=e.length;t-1&&(Ey(e,r),wd(t,r))}this._attachedToViewContainer=!1}l1(this._lView[1],this._lView)}onDestroy(e){!function eD(n,e,t,r){const i=fD(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&dD(n).push(r,i.length-1))}(this._lView[1],this._lView,null,e)}markForCheck(){zy(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-65}reattach(){this._lView[2]|=64}detectChanges(){!function Wy(n,e,t){const r=e[10];r.begin&&r.begin();try{Tl(n,e,n.template,t)}catch(i){throw pD(e,i),i}finally{r.end&&r.end()}}(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new xt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function E3(n,e){Il(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new xt(902,!1);this._appRef=e}}class HO extends Al{constructor(e){super(e),this._view=e}detectChanges(){!function lD(n){!function VO(n){for(let e=0;e0&&Sy(m,R,Re.join(" "))}if(he=wg(Q,22),void 0!==t){const ue=he.projection=[];for(let Re=0;Rea(Cr(Le[r.index])):r.index;let Re=null;if(!a&&c&&(Re=function pL(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;sc?a[c]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==Re)(Re.__ngLastListenerFn__||Re).__ngNextListenerFn__=s,Re.__ngLastListenerFn__=s,U=!1;else{s=OD(r,e,R,s,!1);const Le=t.listen(he,i,s);k.push(s,Le),T&&T.push(i,ue,Ae,Ae+1)}}else s=OD(r,e,R,s,!1);const Q=r.outputs;let X;if(U&&null!==Q&&(X=Q[i])){const ae=X.length;if(ae)for(let he=0;het()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class y0 extends class n4{}{constructor(e){super(),this.moduleType=e}create(e){return new ZS(this.moduleType,e)}}function v0(n){return e=>{setTimeout(n,void 0,e)}}const Do=class M4 extends Sr{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 c=e;i=c.next?.bind(c),s=c.error?.bind(c),o=c.complete?.bind(c)}this.__isAsync&&(s=v0(s),i&&(i=v0(i)),o&&(o=v0(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let So=(()=>{class n{}return n.__NG_ELEMENT_ID__=B4,n})();const L4=So,k4=class extends L4{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=Hd(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)),Kd(r,i,e),new Al(i)}};function B4(){return function th(n,e){return 4&n.type?new k4(e,n,Uc(n,e)):null}(Lr(),Ve())}let eo=(()=>{class n{}return n.__NG_ELEMENT_ID__=F4,n})();function F4(){return function dI(n,e){let t;const r=e[n.index];if(Ss(r))t=r;else{let i;if(8&n.type)i=Cr(r);else{const s=e[11];i=s.createComment("");const o=as(n,e);ja(s,Od(s,o),i,function C3(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=uD(r,e,i,n),jd(e,t)}return new lI(t,n,e)}(Lr(),Ve())}const U4=eo,lI=class extends U4{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 Ac(this._hostTNode,this._hostLView)}get parentInjector(){const e=md(this._hostTNode,this._hostLView);if(Zb(e)){const t=Tc(e,this._hostLView),r=Cc(e);return new Ac(t[1].data[r+8],t)}return new Ac(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=fI(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 hl(n){return"function"==typeof n}(e);let a;if(o)a=t;else{const R=t||{};a=R.index,r=R.injector,i=R.projectableNodes,s=R.environmentInjector||R.ngModuleRef}const c=o?e:new xl(kn(e)),m=r||this.parentInjector;if(!s&&null==c.ngModule){const k=(o?m:this.parentInjector).get(Bc,null);k&&(s=k)}const T=c.create(m,i,void 0,s);return this.insert(T.hostView,a),T}insert(e,t){const r=e._lView,i=r[1];if(function HP(n){return Ss(n[3])}(r)){const T=this.indexOf(e);if(-1!==T)this.detach(T);else{const R=r[3],k=new lI(R,R[6],R[3]);k.detach(k.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function b3(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=rh,this.reject=rh,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:c})});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)(On(kI,8))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const Vl=new an("AppId",{providedIn:"root",factory:function BI(){return`${R0()}${R0()}${R0()}`}});function R0(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const FI=new an("Platform Initializer"),UI=new an("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),vk=new an("appBootstrapListener"),Io=new an("LocaleId",{providedIn:"root",factory:()=>function kN(n,e=Lt.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),On(n,e)}(Io,Lt.Optional|Lt.SkipSelf)||function Ek(){return typeof $localize<"u"&&$localize.locale||su}()}),Sk=(()=>Promise.resolve(0))();function P0(n){typeof Zone>"u"?Sk.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class ai{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new Do(!1),this.onMicrotaskEmpty=new Do(!1),this.onStable=new Do(!1),this.onError=new Do(!1),typeof Zone>"u")throw new xt(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 Ik(){let n=jn.requestAnimationFrame,e=jn.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 Ak(n){const e=()=>{!function Tk(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(jn,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,M0(n),n.isCheckStableRunning=!0,N0(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),M0(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return KI(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),jI(n)}},onInvoke:(t,r,i,s,o,a,c)=>{try{return KI(n),t.invoke(i,s,o,a,c)}finally{n.shouldCoalesceRunChangeDetection&&e(),jI(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,M0(n),N0(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(!ai.isInAngularZone())throw new xt(909,!1)}static assertNotInAngularZone(){if(ai.isInAngularZone())throw new xt(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,Ck,rh,rh);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 Ck={};function N0(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 M0(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function KI(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function jI(n){n._nesting--,N0(n)}class xk{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new Do,this.onMicrotaskEmpty=new Do,this.onStable=new Do,this.onError=new Do}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 $I=new an(""),sh=new an("");let k0,O0=(()=>{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,k0||(function Rk(n){k0=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:()=>{ai.assertNotInAngularZone(),P0(()=>{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())P0(()=>{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)(On(ai),On(L0),On(sh))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac}),n})(),L0=(()=>{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 k0?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Jn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),oa=null;const GI=new an("AllowMultipleToken"),B0=new an("PlatformDestroyListeners");function WI(n,e,t=[]){const r=`Platform: ${e}`,i=new an(r);return(s=[])=>{let o=F0();if(!o||o.injector.get(GI,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function Mk(n){if(oa&&!oa.get(GI,!1))throw new xt(400,!1);oa=n;const e=n.get(QI);(function zI(n){const e=n.get(FI,null);e&&e.forEach(t=>t())})(n)}(function qI(n=[],e){return $a.create({name:e,providers:[{provide:Xg,useValue:"platform"},{provide:B0,useValue:new Set([()=>oa=null])},...n]})}(a,r))}return function Lk(n){const e=F0();if(!e)throw new xt(401,!1);return e}()}}function F0(){return oa?.get(QI)??null}let QI=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function ZI(n,e){let t;return t="noop"===n?new xk:("zone.js"===n?void 0:n)||new ai(e),t}(r?.ngZone,function YI(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:ai,useValue:i}];return i.run(()=>{const o=$a.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),c=a.injector.get(Hc,null);if(!c)throw new xt(402,!1);return i.runOutsideAngular(()=>{const m=i.onError.subscribe({next:T=>{c.handleError(T)}});a.onDestroy(()=>{oh(this._modules,a),m.unsubscribe()})}),function XI(n,e,t){try{const r=t();return r0(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}(c,i,()=>{const m=a.injector.get(ih);return m.runInitializers(),m.donePromise.then(()=>(function CS(n){Ki(n,"Expected localeId to be defined"),"string"==typeof n&&(IS=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(Io,su)||su),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=JI({},r);return function Pk(n,e,t){const r=new y0(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get(U0);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new xt(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 xt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(B0,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)(On($a))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function JI(n,e){return Array.isArray(e)?e.reduce(JI,n):{...n,...e}}let U0=(()=>{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 c;this._zone.runOutsideAngular(()=>{c=this._zone.onStable.subscribe(()=>{ai.assertNotInAngularZone(),P0(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const m=this._zone.onUnstable.subscribe(()=>{ai.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{c.unsubscribe(),m.unsubscribe()}});this.isStable=mi(s,o.pipe(function bs(n={}){const{connector:e=(()=>new Sr),resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,c,m=0,T=!1,R=!1;const k=()=>{a?.unsubscribe(),a=void 0},U=()=>{k(),o=c=void 0,T=R=!1},Q=()=>{const X=o;U(),X?.unsubscribe()};return fe((X,ae)=>{m++,!R&&!T&&k();const he=c=c??e();ae.add(()=>{m--,0===m&&!R&&!T&&(a=Xo(Q,i))}),he.subscribe(ae),!o&&m>0&&(o=new we({next:Ae=>he.next(Ae),error:Ae=>{R=!0,k(),a=Xo(U,t,Ae),he.error(Ae)},complete:()=>{T=!0,k(),a=Xo(U,r),he.complete()}}),mn(X).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof G_;if(!this._injector.get(ih).done)throw!i&&function rl(n){const e=kn(n)||Ei(n)||wi(n);return null!==e&&e.standalone}(t),new xt(405,false);let o;o=i?t:this._injector.get(Md).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function Nk(n){return n.isBoundToModule}(o)?void 0:this._injector.get(au),m=o.create($a.NULL,[],r||o.selector,a),T=m.location.nativeElement,R=m.injector.get($I,null);return R?.registerApplication(T),m.onDestroy(()=>{this.detachView(m.hostView),oh(this.components,m),R?.unregisterApplication(T)}),this._loadComponent(m),m}tick(){if(this._runningTick)throw new xt(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;oh(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(vk,[]).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),()=>oh(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new xt(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)(On(ai),On(Bc),On(Hc))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function oh(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let tC=!0;class oC{constructor(){}supports(e){return Rl(e)}create(e){return new zk(e)}}const Gk=(n,e)=>e;class zk{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||Gk}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 Wk(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 aC),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 aC),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 Wk{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 qk{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 aC{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new qk,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 cC(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||lC()),deps:[[n,new Sd,new Dd]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new xt(901,!1)}}return n.\u0275prov=Jn({token:n,providedIn:"root",factory:lC}),n})();const Jk=WI(null,"core",[]);let e6=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(On(U0))},n.\u0275mod=nl({type:n}),n.\u0275inj=vc({}),n})(),lh=null;function Kl(){return lh}const To=new an("DocumentToken");class G6{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 DC=(()=>{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 G6(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),SC(a,i)}});for(let i=0,s=r.length;i{SC(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(qt(eo),qt(So),qt(uh))},n.\u0275dir=is({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function SC(n,e){n.context.$implicit=e.item}let bB=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=nl({type:n}),n.\u0275inj=vc({}),n})();class sm extends class $B extends class r6{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function n6(n){lh||(lh=n)}(new sm)}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 GB(){return zl=zl||document.querySelector("base"),zl?zl.getAttribute("href"):null}();return null==t?null:function zB(n){bh=bh||document.createElement("a"),bh.setAttribute("href",n);const e=bh.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){zl=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function K6(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 bh,zl=null;const MC=new an("TRANSITION_ID"),qB=[{provide:kI,useFactory:function WB(n,e,t){return()=>{t.get(ih).donePromise.then(()=>{const r=Kl(),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=Jn({token:n,factory:n.\u0275fac}),n})();const _h=new an("EventManagerPlugins");let Dh=(()=>{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=Jn({token:n,factory:n.\u0275fac}),n})(),Wl=(()=>{class n extends LC{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(kC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(kC))}}return n.\u0275fac=function(t){return new(t||n)(On(To))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac}),n})();function kC(n){Kl().remove(n)}const om={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/"},am=/%COMP%/g;function Sh(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let cm=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new um(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case zs.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new n5(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case zs.ShadowDom:return new r5(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=Sh(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)(On(Dh),On(Wl),On(Vl))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac}),n})();class um{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(om[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(HC(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(HC(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=om[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=om[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&(Mi.DashCase|Mi.Important)?e.style.setProperty(t,r,i&Mi.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&Mi.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,UC(r)):this.eventManager.addEventListener(e,t,UC(r))}}function HC(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class n5 extends um{constructor(e,t,r,i){super(e),this.component=r;const s=Sh(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function JB(n){return"_ngcontent-%COMP%".replace(am,n)}(i+"-"+r.id),this.hostAttr=function e5(n){return"_nghost-%COMP%".replace(am,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 r5 extends um{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=Sh(i.id,i.styles,[]);for(let o=0;o{class n extends OC{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)(On(To))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac}),n})();const KC=["alt","control","meta","shift"],s5={"\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"},o5={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let a5=(()=>{class n extends OC{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(()=>Kl().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."),KC.forEach(m=>{const T=r.indexOf(m);T>-1&&(r.splice(T,1),o+=m+".")}),o+=s,0!=r.length||0===s.length)return null;const c={};return c.domEventName=i,c.fullKey=o,c}static matchEventFullKeyCode(t,r){let i=s5[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"),KC.forEach(o=>{o!==i&&(0,o5[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)(On(To))},n.\u0275prov=Jn({token:n,factory:n.\u0275fac}),n})();const $C=[{provide:UI,useValue:"browser"},{provide:FI,useValue:function c5(){sm.makeCurrent()},multi:!0},{provide:To,useFactory:function l5(){return function QN(n){jg=n}(document),document},deps:[]}],f5=WI(Jk,"browser",$C),GC=new an(""),zC=[{provide:sh,useClass:class QB{addToWindow(e){jn.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},jn.getAllAngularTestabilities=()=>e.getAllTestabilities(),jn.getAllAngularRootElements=()=>e.getAllRootElements(),jn.frameworkStabilizers||(jn.frameworkStabilizers=[]),jn.frameworkStabilizers.push(r=>{const i=jn.getAllAngularTestabilities();let s=i.length,o=!1;const a=function(c){o=o||c,s--,0==s&&r(o)};i.forEach(function(c){c.whenStable(a)})})}findTestabilityInTree(e,t,r){return null==t?null:e.getTestability(t)??(r?Kl().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:$I,useClass:O0,deps:[ai,L0,sh]},{provide:O0,useClass:O0,deps:[ai,L0,sh]}],WC=[{provide:Xg,useValue:"root"},{provide:Hc,useFactory:function u5(){return new Hc},deps:[]},{provide:_h,useClass:i5,multi:!0,deps:[To,ai,UI]},{provide:_h,useClass:a5,multi:!0,deps:[To]},{provide:cm,useClass:cm,deps:[Dh,Wl,Vl]},{provide:W_,useExisting:cm},{provide:LC,useExisting:Wl},{provide:Wl,useClass:Wl,deps:[To]},{provide:Dh,useClass:Dh,deps:[_h,ai]},{provide:class CB{},useClass:YB,deps:[]},[]];let d5=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:Vl,useValue:t.appId},{provide:MC,useExisting:Vl},qB]}}}return n.\u0275fac=function(t){return new(t||n)(On(GC,12))},n.\u0275mod=nl({type:n}),n.\u0275inj=vc({providers:[...WC,...zC],imports:[bB,e6]}),n})();typeof window<"u"&&window;class _5 extends Sr{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 YC(n,e,t,r,i,s,o){try{var a=n[s](o),c=a.value}catch(m){return void t(m)}a.done?e(c):Promise.resolve(c).then(r,i)}function V(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(c){YC(s,r,i,o,a,"next",c)}function a(c){YC(s,r,i,o,a,"throw",c)}o(void 0)})}}function ZC(n){this.wrapped=n}function ql(n){var e,t;function i(o,a){try{var c=n[o](a),m=c.value,T=m instanceof ZC;Promise.resolve(T?m.wrapped:m).then(function(R){T?i("return"===o?"return":"next",R):s(c.done?"return":"normal",R)},function(R){i("throw",R)})}catch(R){s("throw",R)}}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(c,m){var T={key:o,arg:a,resolve:c,reject:m,next:null};t?t=t.next=T:(e=t=T,i(o,a))})},"function"!=typeof n.return&&(this.return=void 0)}function un(n){return function(){return new ql(n.apply(this,arguments))}}function ct(n){return new ZC(n)}function Tt(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 Ih(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function Ih(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(Ih=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 Ih(n)}function jr(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 ca(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(n):new Uint8Array(n)}function xo(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}function or(n,e){e||(e=n.reduce((i,s)=>i+s.length,0));const t=xo(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return t}function $r(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(!dm(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(!dm(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=JC(this.bufs,e);return t.buf[t.index]}set(e,t){const r=JC(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 or(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:or(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new $n;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=c)continue;const m=e>=a&&ea&&t<=c;if(m&&T){if(e===a&&t===c){r.push(o);break}const R=e-a;r.push(o.subarray(R,R+(t-e)));break}if(m){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(T){if(t===c){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=xo(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=ca(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=ca(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=ca(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=xo(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=ca(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=ca(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=ca(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=ca(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=ca(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}equals(e){if(null==e||!(e instanceof $n)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class e2{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 hm{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new e2(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 e2(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 lu(n={}){return t2(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 t2(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new hm;const a=function(){var X=V(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((ae,he)=>{s=Ae=>{s=null,r.push(Ae);try{ae(n(r))}catch(ue){he(ue)}return i}}):n(r)});return function(){return X.apply(this,arguments)}}(),c=X=>null!=s?s(X):(r.push(X),i),T=X=>{if(o)return i;if(!0!==e?.objectMode&&null==X?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:X})},R=X=>o?i:(o=!0,null!=X?(X=>(r=new hm,null!=s?s({error:X}):(r.push({error:X}),i)))(X):c({done:!0}));if(i={[Symbol.asyncIterator](){return this},next:a,return:()=>(r=new hm,R(),{done:!0}),throw:X=>(R(X),{done:!0}),push:T,end:R,get readableLength(){return r.size}},null==t)return i;const Q=i;return i={[Symbol.asyncIterator](){return this},next:()=>Q.next(),throw:X=>(Q.throw(X),null!=t&&(t(X),t=void 0),{done:!0}),return:()=>(Q.return(),null!=t&&(t(),t=void 0),{done:!0}),push:T,end:X=>(Q.end(X),null!=t&&(t(X),t=void 0),i),get readableLength(){return Q.readableLength}},i}function pm(){const n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}function Ch(n){const e=lu(),t=function D5(n){const e=un(function*(){let t=yield,r=new $n;var o,i=!1,s=!1;try{for(var c,a=Tt(n);i=!(c=yield ct(a.next())).done;i=!1){const m=c.value;if(null!=t)for(r.append(m);r.length>=t;){const T=r.sublist(0,t);if(r.consume(t),t=yield T,null==t){r.length>0&&(t=yield r,r=new $n);break}}else r.append(m),t=yield r,r=new $n}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield ct(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=pm();let i;const s=n.sink(un(function*(){yield*jr(Tt(e),ct);const a=yield ct(r.promise);yield*jr(Tt(a),ct)})());s.catch(a=>{i=a});const o={sink:(a=V(function*(c){return null!=i?yield Promise.reject(i):(r.resolve(c),yield s)}),function(m){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=V(function*(){const c=yield t.next();if(null!=c.value)return c.value});return function(){return a.apply(this,arguments)}}()}}function gm(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 n2=4294967296;class qr{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 qr((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new qr(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=gm(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 qr;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>n2&&(i=0,++r>n2&&(r=0))),new qr(r,i)}static fromNumber(e){if(0===e)return new qr;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 qr(i,r)}static fromBytes(e,t=0){const r=gm(e),i=new qr;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 I5=Math.pow(2,7),C5=Math.pow(2,14),T5=Math.pow(2,21),A5=Math.pow(2,28),x5=Math.pow(2,35),R5=Math.pow(2,42),P5=Math.pow(2,49),N5=Math.pow(2,56),M5=Math.pow(2,63),Qt={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=xo(Qt.encodingLength(n))),qr.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>qr.fromBytes(n,e).toNumber(!0)},Th={encodingLength:n=>n<0?10:Qt.encodingLength(n),encode:(n,e,t)=>(null==e&&(e=xo(Th.encodingLength(n))),n<0?(qr.fromNumber(n).toBytes(e,t),e):Qt.encode(n,e,t)),decode:(n,e=0)=>qr.fromBytes(n,e).toNumber(!1)},ym={encodingLength:n=>Qt.encodingLength(n>=0?2*n:-2*n-1),encode:(n,e,t)=>Qt.encode(n=n>=0?2*n:-2*n-1,e,t),decode(n,e=0){const t=Qt.decode(n,e);return 0!=(1&t)?(t+1)/-2:t/2}},Ah=n=>{const e=Qt.encodingLength(n),t=function O5(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Qt.encode(n,t),Ah.bytes=e,t};function to(n){const e=(n=n??{}).lengthEncoder??Ah;return function(){var r=un(function*(i){var a,s=!1,o=!1;try{for(var m,c=Tt(i);s=!(m=yield ct(c.next())).done;s=!1){const T=m.value,R=e(T.byteLength);R instanceof Uint8Array?yield R:yield*jr(Tt(R),ct),T instanceof Uint8Array?yield T:yield*jr(Tt(T),ct)}}catch(T){o=!0,a=T}finally{try{s&&null!=c.return&&(yield ct(c.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Ah.bytes=0,to.single=(n,e)=>new $n(((e=e??{}).lengthEncoder??Ah)(n.byteLength),n);var se=N(2535),ua=(()=>{return(n=ua||(ua={}))[n.LENGTH=0]="LENGTH",n[n.DATA=1]="DATA",ua;var n})();const mm=n=>{const e=Qt.decode(n);return mm.bytes=Qt.encodingLength(e),e};function Ms(n){return function(){var t=un(function*(r){const i=new $n;let s=ua.LENGTH,o=-1;const a=n?.lengthDecoder??mm,c=n?.maxLengthLength??8,m=n?.maxDataLength??4194304;var k,T=!1,R=!1;try{for(var Q,U=Tt(r);T=!(Q=yield ct(U.next())).done;T=!1)for(i.append(Q.value);i.byteLength>0;){if(s===ua.LENGTH)try{if(o=a(i),o<0)throw se(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>m)throw se(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");i.consume(a.bytes),null!=n?.onLength&&n.onLength(o),s=ua.DATA}catch(ae){if(ae instanceof RangeError){if(i.byteLength>c)throw se(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw ae}if(s===ua.DATA){if(i.byteLength0)throw se(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function r2(n,e={}){const t=Ch(n),r=Ms.fromReader(t.reader,e),i={read:(s=V(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=V(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=V(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const c=a instanceof Uint8Array?a:a.slice();return o.decode(c)});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(to.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=V(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 i2(){const n=pm();let e=!1;return{sink:(t=V(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:un(function*(){const t=yield ct(n.promise);yield*jr(Tt(t),ct)})()};var t}mm.bytes=0,Ms.fromReader=(n,e)=>{let t=1;const r=un(function*(){for(;;)try{const{done:s,value:o}=yield ct(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 Ms({...e??{},onLength:s=>{t=s}})(r)};var xh=N(5061);const s2=n=>null!=n&&("function"==typeof n[Symbol.asyncIterator]||"function"==typeof n[Symbol.iterator]||"function"==typeof n.next),vm=n=>null!=n&&"function"==typeof n.sink&&s2(n.source),U5=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=lu({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),xh(r,function(){var s=un(function*(){yield*jr(Tt(n.source),ct),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function Ln(n,...e){if(vm(n)){const r=n;n=()=>r.source}else if(s2(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&vm(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 Ql=65535,V5=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);var H5=N(5705),Em=N(5006),a2=N(893),c2=N(5876);const K5={hashSHA256:n=>(0,a2.vp)(n),getHKDF(n,e){const i=new H5.t(a2.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=Em.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=Em._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>Em.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new c2.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new c2.OK(r).open(e,n,t)},Rh=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};Rh.bytes=2;const Ph=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)};function u2(n){return or([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}function l2(n){return or([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}function wm(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)}}function bm(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)}}Ph.bytes=2;var _m=N(3863),Dm=N.n(_m);const Sm=_m.Reader;function ui(n,e){const t=Sm.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=Sm.prototype[n];Sm.prototype[n]=function(){return BigInt(e.call(this).toString())}});const Im=_m.Writer;function li(n,e){const t=Im.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=Im.prototype[n];Im.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 f2(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Nh(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return f2("enum",Yl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function fi(n,e){return f2("message",Yl.LENGTH_DELIMITED,n,e)}var fu,du,dr=(()=>{return(n=dr||(dr={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",dr;var n})(),Mh=(()=>{return(n=Mh||(Mh={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",Mh;var n})();(dr||(dr={})).codec=()=>Nh(Mh),function(n){let e;n.codec=()=>(null==e&&(e=fi((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),dr.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:dr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=dr.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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(fu||(fu={})),function(n){let e;n.codec=()=>(null==e&&(e=fi((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),dr.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:dr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=dr.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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(du||(du={})),N(7791),N(2158);var Gn=N(8659);const Z5=function q5(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(Ae);Q[X];){var Re=t[Q.charCodeAt(X)];if(255===Re)return;for(var Le=0,Fe=Ae-1;(0!==Re||Le>>0)%256>>>0,Re=Re/256>>>0;if(0!==Re)throw new Error("Non-zero carry");he=Le,X++}if(" "!==Q[X]){for(var wt=Ae-he;wt!==Ae&&0===ue[wt];)wt++;for(var mt=new Uint8Array(ae+(Ae-wt)),Zt=ae;wt!==Ae;)mt[Zt++]=ue[wt++];return mt}}}return{encode:function R(Q){if(Q instanceof Uint8Array||(ArrayBuffer.isView(Q)?Q=new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength):Array.isArray(Q)&&(Q=Uint8Array.from(Q))),!(Q instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===Q.length)return"";for(var X=0,ae=0,he=0,Ae=Q.length;he!==Ae&&0===Q[he];)he++,X++;for(var ue=(Ae-he)*T+1>>>0,Re=new Uint8Array(ue);he!==Ae;){for(var Le=Q[he],Fe=0,wt=ue-1;(0!==Le||Fe>>0)%a>>>0,Le=Le/a>>>0;if(0!==Le)throw new Error("Non-zero carry");ae=Fe,he++}for(var mt=ue-ae;mt!==ue&&0===Re[mt];)mt++;for(var Zt=c.repeat(X);mt{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 nF{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 rF{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 d2(this,e)}}class iF{constructor(e){this.decoders=e}or(e){return d2(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 d2=(n,e)=>new iF({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class sF{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new nF(e,t,r),this.decoder=new rF(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Oh=({name:n,prefix:e,encode:t,decode:r})=>new sF(n,e,t,r),Zl=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=Z5(t,e);return Oh({prefix:n,name:e,encode:r,decode:s=>hu(i(s))})},Qr=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>Oh({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 T=0;T=8&&(a-=8,o[m++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),cF=Oh({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),uF=Qr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),lF=Qr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),fF=Zl({prefix:"9",name:"base10",alphabet:"0123456789"}),dF=Qr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hF=Qr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Ro=Qr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pF=Qr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gF=Qr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yF=Qr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mF=Qr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vF=Qr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),EF=Qr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wF=Qr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),bF=Qr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),_F=Zl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),DF=Zl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Ci=Zl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),SF=Zl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Lh=Qr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),IF=Qr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),CF=Qr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),TF=Qr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),h2=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}"),AF=h2.reduce((n,e,t)=>(n[t]=e,n),[]),xF=h2.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),NF=Oh({prefix:"\u{1f680}",name:"base256emoji",encode:function RF(n){return n.reduce((e,t)=>e+AF[t],"")},decode:function PF(n){const e=[];for(const t of n){const r=xF[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var kF=Math.pow(2,31),UF=Math.pow(2,7),VF=Math.pow(2,14),HF=Math.pow(2,21),KF=Math.pow(2,28),jF=Math.pow(2,35),$F=Math.pow(2,42),GF=Math.pow(2,49),zF=Math.pow(2,56),WF=Math.pow(2,63),QF={encode:function g2(n,e,t){e=e||[];for(var r=t=t||0;n>=kF;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,g2.bytes=t-r+1,e},decode:function Cm(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw Cm.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return Cm.bytes=s-r,t},encodingLength:function(n){return n[kh.decode(n),kh.decode.bytes],Bh=(n,e,t=0)=>(kh.encode(n,e,t),e),Fh=n=>kh.encodingLength(n),pu=(n,e)=>{const t=e.byteLength,r=Fh(n),i=r+Fh(t),s=new Uint8Array(i+t);return Bh(n,s,0),Bh(t,s,r),s.set(e,i),new Am(n,t,e,s)},Uh=n=>{const e=hu(n),[t,r]=Tm(e),[i,s]=Tm(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new Am(t,i,o,e)};class Am{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const m2=({name:n,code:e,encode:t})=>new XF(n,e,t);class XF{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?pu(this.code,t):t.then(r=>pu(this.code,r))}throw Error("Unknown type, must be binary type")}}const v2=n=>function(){var e=V(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),Li=m2({name:"sha2-256",code:18,encode:v2("SHA-256")}),JF=m2({name:"sha2-512",code:19,encode:v2("SHA-512")}),w2=hu,gu={code:0,name:"identity",encode:w2,digest:n=>pu(0,w2(n))},tU="raw",nU=85,rU=n=>hu(n),iU=n=>hu(n),sU=new TextEncoder,oU=new TextDecoder,aU="json",cU=512,uU=n=>sU.encode(JSON.stringify(n)),lU=n=>JSON.parse(oU.decode(n));class Rr{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:Hh,byteLength:Hh,code:Vh,version:Vh,multihash:Vh,bytes:Vh,_baseCache:Hh,asCID:Hh})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==Xl)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==pU)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Rr.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=pu(e,t);return Rr.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[R,k]=Tm(e.subarray(t));return t+=k,R};let i=r(),s=Xl;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(),c=r(),m=t+c;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:m-o,size:m}}static parse(e,t){const[r,i]=fU(e,t),s=Rr.decode(i);return s._baseCache.set(r,e),s}}const fU=(n,e)=>{switch(n[0]){case"Q":return[Ci.prefix,(e||Ci).decode(`${Ci.prefix}${n}`)];case Ci.prefix:return[Ci.prefix,(e||Ci).decode(n)];case Ro.prefix:return[Ro.prefix,(e||Ro).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)]}},dU=(n,e,t)=>{const{prefix:r}=t;if(r!==Ci.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},hU=(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},Xl=112,pU=18,b2=(n,e,t)=>{const r=Fh(n),i=r+Fh(e),s=new Uint8Array(i+t.byteLength);return Bh(n,s,0),Bh(e,s,r),s.set(t,i),s},_2=Symbol.for("@ipld/js-cid/CID"),Vh={writable:!1,configurable:!1,enumerable:!0},Hh={writable:!1,enumerable:!1,configurable:!1},yU=(n,e)=>{if(!n.test("0.0.0-dev"))throw new Error(e);console.warn(e)},mU="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",Jl={...h,...u,...g,...b,...w,...v,...l,...p,...d,..._};function D2(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const S2=D2("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),xm=D2("ascii","a",n=>{let e="a";for(let t=0;t{const e=xo((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=or([new Uint8Array(e-t.length),t])}return Mt(t,"base64url")}function Os(n){const e=function bU(n,e){let t=_t(n,"base64urlpad");if(null!=e){if(t.length>e)throw new Error("byte array longer than desired length");t=or([new Uint8Array(e-t.length),t])}return t}(n);return new Gn.jsbn.BigInteger(Mt(e,"base16"),16)}N(730);function R2(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=no.get();function m(){return(m=V(function*(U,Q){const X=a.getRandomValues(new Uint8Array(s)),ae=a.getRandomValues(new Uint8Array(r)),he={name:e,iv:ae};"string"==typeof Q&&(Q=_t(Q));const Ae={name:"PBKDF2",salt:X,iterations:o,hash:{name:i}},ue=yield a.subtle.importKey("raw",Q,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Re=yield a.subtle.deriveKey(Ae,ue,{name:e,length:t},!0,["encrypt"]),Le=yield a.subtle.encrypt(he,Re,U);return or([X,he.iv,new Uint8Array(Le)])})).apply(this,arguments)}function R(){return(R=V(function*(U,Q){const X=U.slice(0,s),ae=U.slice(s,s+r),he=U.slice(s+r),Ae={name:e,iv:ae};"string"==typeof Q&&(Q=_t(Q));const ue={name:"PBKDF2",salt:X,iterations:o,hash:{name:i}},Re=yield a.subtle.importKey("raw",Q,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Le=yield a.subtle.deriveKey(ue,Re,{name:e,length:t},!0,["decrypt"]),Fe=yield a.subtle.decrypt(Ae,Le,he);return new Uint8Array(Fe)})).apply(this,arguments)}return t*=8,{encrypt:function c(U,Q){return m.apply(this,arguments)},decrypt:function T(U,Q){return R.apply(this,arguments)}}}function SU(n,e){return Om.apply(this,arguments)}function Om(){return(Om=V(function*(n,e){const t=Lh.decode(n);return yield R2().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),N(8985);var IU=N(5856),CU=N.t(IU,2);const gn=BigInt(0),Un=BigInt(1),br=BigInt(2),ef=BigInt(3),TU=BigInt(8),Lm=br**BigInt(256),Sn={a:gn,b:BigInt(7),P:Lm-br**BigInt(32)-BigInt(977),n:Lm-BigInt("432420386565659656852420866394968145599"),h:Un,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")};function P2(n){const{a:e,b:t}=Sn,r=it(n*n),i=it(r*n);return it(i+e*n+t)}const Kh=Sn.a===gn;class Bn{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof dn))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Bn(e.x,e.y,Un)}static toAffineBatch(e){const t=function PU(n,e=Sn.P){const t=new Array(n.length),i=Eu(n.reduce((s,o,a)=>o===gn?s:(t[a]=s,it(s*o,e)),Un),e);return n.reduceRight((s,o,a)=>o===gn?s:(t[a]=it(s*t[a],e),it(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return Bn.toAffineBatch(e).map(Bn.fromAffine)}equals(e){if(!(e instanceof Bn))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,c=it(i**br),m=it(a**br),T=it(t*m),R=it(s*c),k=it(it(r*a)*m),U=it(it(o*i)*c);return T===R&&k===U}negate(){return new Bn(this.x,it(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=it(e**br),s=it(t**br),o=it(s**br),a=it(br*(it((e+s)**br)-i-o)),c=it(ef*i),m=it(c**br),T=it(m-br*a),R=it(c*(a-T)-TU*o),k=it(br*t*r);return new Bn(T,R,k)}add(e){if(!(e instanceof Bn))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===gn||o===gn)return this;if(t===gn||r===gn)return e;const c=it(i**br),m=it(a**br),T=it(t*m),R=it(s*c),k=it(it(r*a)*m),U=it(it(o*i)*c),Q=it(R-T),X=it(U-k);if(Q===gn)return X===gn?this.double():Bn.ZERO;const ae=it(Q**br),he=it(Q*ae),Ae=it(T*ae),ue=it(X**br-he-br*Ae),Re=it(X*(Ae-ue)-k*he),Le=it(i*a*Q);return new Bn(ue,Re,Le)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Bn.ZERO;if("bigint"==typeof e&&e===gn)return t;let r=O2(e);if(r===Un)return this;if(!Kh){let R=t,k=this;for(;r>gn;)r&Un&&(R=R.add(k)),k=k.double(),r>>=Un;return R}let{k1neg:i,k1:s,k2neg:o,k2:a}=k2(r),c=t,m=t,T=this;for(;s>gn||a>gn;)s&Un&&(c=c.add(T)),a&Un&&(m=m.add(T)),T=T.double(),s>>=Un,a>>=Un;return i&&(c=c.negate()),o&&(m=m.negate()),m=new Bn(it(m.x*Sn.beta),m.y,m.z),c.add(m)}precomputeWindow(e){const t=Kh?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=R,Q>c&&(Q-=T,e+=Un),0===Q){let X=i[U];k%2&&(X=X.negate()),o=o.add(X)}else{let X=i[U+Math.abs(Q)-1];Q<0&&(X=X.negate()),s=s.add(X)}}return{p:s,f:o}}multiply(e,t){let i,s,r=O2(e);if(Kh){const{k1neg:o,k1:a,k2neg:c,k2:m}=k2(r);let{p:T,f:R}=this.wNAF(a,t),{p:k,f:U}=this.wNAF(m,t);o&&(T=T.negate()),c&&(k=k.negate()),k=new Bn(it(k.x*Sn.beta),k.y,k.z),i=T.add(k),s=R.add(U)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return Bn.normalizeZ([i,s])[0]}toAffine(e=Eu(this.z)){const{x:t,y:r,z:i}=this,s=e,o=it(s*s),a=it(o*s),c=it(t*o),m=it(r*a);if(it(i*s)!==Un)throw new Error("invZ was invalid");return new dn(c,m)}}Bn.BASE=new Bn(Sn.Gx,Sn.Gy,Un),Bn.ZERO=new Bn(gn,Un,gn);const km=new WeakMap;class dn{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,km.delete(this)}static fromCompressedHex(e){const t=32===e.length,r=Ti(t?e:e.subarray(1));if(!Gh(r))throw new Error("Point is not on curve");let s=function RU(n){const{P:e}=Sn,t=BigInt(6),r=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),c=n*n*n%e,m=c*c*n%e,T=fs(m,ef)*m%e,R=fs(T,ef)*m%e,k=fs(R,br)*c%e,U=fs(k,r)*k%e,Q=fs(U,i)*U%e,X=fs(Q,o)*Q%e,ae=fs(X,a)*X%e,he=fs(ae,o)*Q%e,Ae=fs(he,ef)*m%e,ue=fs(Ae,s)*U%e,Re=fs(ue,t)*c%e;return fs(Re,br)}(P2(r));const o=(s&Un)===Un;t?o&&(s=it(-s)):1==(1&e[0])!==o&&(s=it(-s));const a=new dn(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=Ti(e.subarray(1,33)),r=Ti(e.subarray(33,65)),i=new dn(t,r);return i.assertValidity(),i}static fromHex(e){const t=Ls(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 dn.BASE.multiply(io(e))}static fromSignature(e,t,r){const i=B2(e=Ls(e)),{r:s,s:o}=V2(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const c=dn.fromHex((1&r?"03":"02")+No(s)),{n:m}=Sn,T=Eu(s,m),R=it(-i*T,m),k=it(o*T,m),U=dn.BASE.multiplyAndAddUnsafe(c,R,k);if(!U)throw new Error("Cannot recover signature: point at infinify");return U.assertValidity(),U}toRawBytes(e=!1){return Mo(this.toHex(e))}toHex(e=!1){const t=No(this.x);return e?`${this.y&Un?"03":"02"}${t}`:`04${t}${No(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(!Gh(t)||!Gh(r))throw new Error(e);const i=it(r*r);if(it(i-P2(t))!==gn)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new dn(this.x,it(-this.y))}double(){return Bn.fromAffine(this).double().toAffine()}add(e){return Bn.fromAffine(this).add(Bn.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Bn.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const i=Bn.fromAffine(this),s=t===gn||t===Un||this!==dn.BASE?i.multiplyUnsafe(t):i.multiply(t),o=Bn.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(Bn.ZERO)?void 0:a.toAffine()}}function N2(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function M2(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${mu(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:Ti(t),left:n.subarray(e+2)}}dn.BASE=new dn(Sn.Gx,Sn.Gy),dn.ZERO=new dn(gn,gn);class Po{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=tf(e),r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const i=t?mu(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new Po(jh(i.slice(0,64)),jh(i.slice(64,128)))}static fromDER(e){const t=tf(e);if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:i}=function AU(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${mu(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=M2(n.subarray(2)),{data:r,left:i}=M2(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${mu(i)}`);return{r:e,s:r}}(t?e:Mo(e));return new Po(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!wu(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!wu(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>Sn.n>>Un}normalizeS(){return this.hasHighS()?new Po(this.r,Sn.n-this.s):this}toDERRawBytes(e=!1){return Mo(this.toDERHex(e))}toDERHex(e=!1){const t=N2(nf(this.s));if(e)return t;const r=N2(nf(this.r)),i=nf(r.length/2),s=nf(t.length/2);return`30${nf(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Mo(this.toCompactHex())}toCompactHex(){return No(this.r)+No(this.s)}}function yu(...n){if(!n.every(tf))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 mu(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;tLm)throw new Error("Expected number < 2^256");return n.toString(16).padStart(64,"0")}function vu(n){return Mo(No(n))}function nf(n){const e=n.toString(16);return 1&e.length?`0${e}`:e}function jh(n){if("string"!=typeof n)throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function Mo(n){if("string"!=typeof n)throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&wu(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function it(n,e=Sn.P){const t=n%e;return t>=gn?t:e+t}function fs(n,e){const{P:t}=Sn;let r=n;for(;e-- >gn;)r*=r,r%=t;return r}function Eu(n,e=Sn.P){if(n===gn||e<=gn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=it(n,e),r=e,i=gn,s=Un,o=Un,a=gn;for(;t!==gn;){const m=r/t,T=r%t,R=i-o*m,k=s-a*m;r=t,t=T,i=o,s=a,o=R,a=k}if(r!==Un)throw new Error("invert: does not exist");return it(i,e)}const L2=(n,e)=>(n+e/br)/e,$h=br**BigInt(128);function k2(n){const{n:e}=Sn,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Un*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=t,o=L2(s*n,e),a=L2(-r*n,e);let c=it(n-o*t-a*i,e),m=it(-o*r-a*s,e);const T=c>$h,R=m>$h;if(T&&(c=e-c),R&&(m=e-m),c>$h||m>$h)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:T,k1:c,k2neg:R,k2:m}}function B2(n){const{n:e}=Sn,r=8*n.length-256;let i=Ti(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}class F2{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return er.hmacSha256(this.k,...e)}hmacSync(...e){if("function"!=typeof er.hmacSha256Sync)throw new Error("utils.hmacSha256Sync is undefined, you need to set it");const t=er.hmacSha256Sync(this.k,...e);if(t instanceof Promise)throw new Error("To use sync sign(), ensure utils.hmacSha256 is sync");return t}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 V(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.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 V(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.incr(),this.v=this.hmacSync(this.v),this.v}}function wu(n){return gn0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=jh(n)}else{if(!tf(n))throw new TypeError("Expected valid private key");if(32!==n.length)throw new Error("Expected 32 bytes of private key");e=Ti(n)}if(!wu(e))throw new Error("Expected private key: 0 < key < n");return e}function Bm(n){return n instanceof dn?(n.assertValidity(),n):dn.fromHex(n)}function V2(n){if(n instanceof Po)return n.assertValidity(),n;try{return Po.fromDER(n)}catch{return Po.fromCompact(n)}}function rf(n,e=!1){return dn.fromPrivateKey(n).toRawBytes(e)}function H2(n){const e=tf(n),t="string"==typeof n,r=(e||t)&&n.length;return e?33===r||65===r:t?66===r||130===r:n instanceof dn}function K2(n){return Ti(n.length>32?n.slice(0,32):n)}function OU(n){const e=K2(n),t=it(e,Sn.n);return j2(tvu(it(io(n)+io(e),Sn.n)),privateNegate:n=>{const e=io(n);return vu(Sn.n-e)},pointAddScalar:(n,e,t)=>{const r=dn.fromHex(n),i=io(e),s=dn.BASE.multiplyAndAddUnsafe(r,i,Un);if(!s)throw new Error("Tweaked point at infinity");return s.toRawBytes(t)},pointMultiply:(n,e,t)=>{const r=dn.fromHex(n),i=Ti(Ls(e));return r.multiply(i).toRawBytes(t)},hashToPrivateKey:n=>{if((n=Ls(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return vu(it(Ti(n),Sn.n-Un)+Un)},randomBytes:(n=32)=>{if(Qi.web)return Qi.web.getRandomValues(new Uint8Array(n));if(Qi.node){const{randomBytes:e}=Qi.node;return Uint8Array.from(e(n))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>er.hashToPrivateKey(er.randomBytes(40)),bytesToHex:mu,hexToBytes:Mo,concatBytes:yu,mod:it,invert:Eu,sha256:(n=V(function*(...e){if(Qi.web){const t=yield Qi.web.subtle.digest("SHA-256",yu(...e));return new Uint8Array(t)}if(Qi.node){const{createHash:t}=Qi.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=V(function*(e,...t){if(Qi.web){const r=yield Qi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=yu(...t),s=yield Qi.web.subtle.sign("HMAC",r,i);return new Uint8Array(s)}if(Qi.node){const{createHmac:r}=Qi.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=V(function*(e,...t){let r=Wh[e];if(void 0===r){const i=yield er.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=yu(i,i),Wh[e]=r}return er.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof er.sha256Sync)throw new Error("utils.sha256Sync is undefined, you need to set it");let t=Wh[n];if(void 0===t){const r=er.sha256Sync(Uint8Array.from(n,i=>i.charCodeAt(0)));t=yu(r,r),Wh[n]=t}return er.sha256Sync(t,...e)},precompute(n=8,e=dn.BASE){const t=e===dn.BASE?e:new dn(e.x,e.y);return t._setWindowSize(n),t.multiply(ef),t}};var n;function sf(n){if(isNaN(n)||n<=0)throw se(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return er.randomBytes(n)}function VU(n){const e=Gn.asn1.fromDer(Mt(n,"ascii")),t=Gn.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:ro(t.n),e:ro(t.e),d:ro(t.d),p:ro(t.p),q:ro(t.q),dp:ro(t.dP),dq:ro(t.dQ),qi:ro(t.qInv),alg:"RS256"}}function tT(n,e){return e.map(t=>Os(n[t]))}function zU(n){return Km.apply(this,arguments)}function Km(){return Km=V(function*(n){const e=yield no.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 rT(e);return{privateKey:t[0],publicKey:t[1]}}),Km.apply(this,arguments)}function nT(n){return jm.apply(this,arguments)}function jm(){return jm=V(function*(n){const t=[yield no.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield QU(n)],r=yield rT({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),jm.apply(this,arguments)}function $m(){return $m=V(function*(n,e){const t=yield no.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield no.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),$m.apply(this,arguments)}function Gm(){return Gm=V(function*(n,e,t){const r=yield no.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield no.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),Gm.apply(this,arguments)}function rT(n){return zm.apply(this,arguments)}function zm(){return zm=V(function*(n){if(null==n.privateKey||null==n.publicKey)throw se(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return yield Promise.all([no.get().subtle.exportKey("jwk",n.privateKey),no.get().subtle.exportKey("jwk",n.publicKey)])}),zm.apply(this,arguments)}function QU(n){return Wm.apply(this,arguments)}function Wm(){return Wm=V(function*(n){return yield no.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),Wm.apply(this,arguments)}function iT(n,e,t,r){const i=e?function GU(n){return Gn.pki.setRsaPublicKey(...tT(n,["n","e"]))}(n):function $U(n){return Gn.pki.setRsaPrivateKey(...tT(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return _t(r(Mt(Uint8Array.from(t),"ascii"),i),"ascii")}function qm(n,e){return Qm.apply(this,arguments)}function Qm(){return Qm=V(function*(n,e){const r=yield R2().encrypt(n,e);return Lh.encode(r)}),Qm.apply(this,arguments)}N(5517);class Ym{constructor(e){this._key=e}verify(e,t){var r=this;return V(function*(){return yield function qU(n,e,t){return Gm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function jU(n){if(null==n.n||null==n.e)throw se(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Gn.pki.publicKeyToAsn1({n:Os(n.n),e:Os(n.e)});return _t(Gn.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return fu.encode({Type:dr.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function YU(n,e){return iT(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return $r(this.bytes,e.bytes)}hash(){var e=this;return V(function*(){const{bytes:t}=yield Li.digest(e.bytes);return t})()}}class qh{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return sf(16)}sign(e){var t=this;return V(function*(){return yield function WU(n,e){return $m.apply(this,arguments)}(t._key,e)})()}get public(){if(null==this._publicKey)throw se(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Ym(this._publicKey)}decrypt(e){return function ZU(n,e){return iT(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function HU(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 se(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Gn.pki.privateKeyToAsn1({n:Os(n.n),e:Os(n.e),d:Os(n.d),p:Os(n.p),q:Os(n.q),dP:Os(n.dp),dQ:Os(n.dq),qInv:Os(n.qi)});return _t(Gn.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return du.encode({Type:dr.RSA,Data:this.marshal()}).subarray()}equals(e){return $r(this.bytes,e.bytes)}hash(){var e=this;return V(function*(){const{bytes:t}=yield Li.digest(e.bytes);return t})()}id(){var e=this;return V(function*(){return Mt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return V(function*(){if("pkcs-8"===t){const i=new Gn.util.ByteBuffer(r.marshal()),s=Gn.asn1.fromDer(i),o=Gn.pki.privateKeyFromAsn1(s);return Gn.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield qm(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function XU(n){return Zm.apply(this,arguments)}function Zm(){return Zm=V(function*(n){const e=VU(n),t=yield nT(e);return new qh(t.privateKey,t.publicKey)}),Zm.apply(this,arguments)}function JU(n){const e=function KU(n){const e=Gn.asn1.fromDer(Mt(n,"ascii")),t=Gn.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:ro(t.n),e:ro(t.e)}}(n);return new Ym(e)}function eV(n){return Xm.apply(this,arguments)}function Xm(){return Xm=V(function*(n){const e=yield nT(n);return new qh(e.privateKey,e.publicKey)}),Xm.apply(this,arguments)}function tV(n){return Jm.apply(this,arguments)}function Jm(){return Jm=V(function*(n){const e=yield zU(n);return new qh(e.privateKey,e.publicKey)}),Jm.apply(this,arguments)}var nV=N(7420),rV=N.t(nV,2);const mr=BigInt(0),nn=BigInt(1),Yr=BigInt(2),sT=BigInt(255),oT=Yr**BigInt(252)+BigInt("27742317777372353535851937790883648493"),zn=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:Yr**sT-BigInt(19),l:oT,n:oT,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),aT=Yr**BigInt(256),of=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),iV=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),sV=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),oV=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),aV=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class In{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof hr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(hr.ZERO)?In.ZERO:new In(e.x,e.y,nn,Me(e.x*e.y))}static toAffineBatch(e){const t=function uV(n,e=zn.P){const t=new Array(n.length),i=Qh(n.reduce((s,o,a)=>o===mr?s:(t[a]=s,Me(s*o,e)),nn),e);return n.reduceRight((s,o,a)=>o===mr?s:(t[a]=Me(s*t[a],e),Me(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){cT(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,c=Me(t*a),m=Me(s*i),T=Me(r*a),R=Me(o*i);return c===m&&T===R}negate(){return new In(Me(-this.x),this.y,this.z,Me(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=zn,s=Me(e**Yr),o=Me(t**Yr),a=Me(Yr*Me(r**Yr)),c=Me(i*s),m=Me(Me((e+t)**Yr)-s-o),T=c+o,R=T-a,k=c-o,U=Me(m*R),Q=Me(T*k),X=Me(m*k),ae=Me(R*T);return new In(U,Q,ae,X)}add(e){cT(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:c,t:m}=e,T=Me((r-t)*(a+o)),R=Me((r+t)*(a-o)),k=Me(R-T);if(k===mr)return this.double();const U=Me(i*Yr*m),Q=Me(s*Yr*c),X=Q+U,ae=R+T,he=Q-U,Ae=Me(X*k),ue=Me(ae*he),Re=Me(X*he),Le=Me(k*ae);return new In(Ae,ue,Le,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>=R,Q>c&&(Q-=T,e+=nn),0===Q){let X=i[U];k%2&&(X=X.negate()),o=o.add(X)}else{let X=i[U+Math.abs(Q)-1];Q<0&&(X=X.negate()),s=s.add(X)}}return In.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Iu(e,zn.l),t)}multiplyUnsafe(e){let t=Iu(e,zn.l,!1);const r=In.BASE,i=In.ZERO;if(t===mr)return i;if(this.equals(i)||t===nn)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>mr;)t&nn&&(s=s.add(o)),o=o.double(),t>>=nn;return s}isSmallOrder(){return this.multiplyUnsafe(zn.h).equals(In.ZERO)}isTorsionFree(){return this.multiplyUnsafe(zn.l).equals(In.ZERO)}toAffine(e=Qh(this.z)){const{x:t,y:r,z:i}=this,s=Me(t*e),o=Me(r*e);if(Me(i*e)!==nn)throw new Error("invZ was invalid");return new hr(s,o)}fromRistrettoBytes(){tv()}toRistrettoBytes(){tv()}fromRistrettoHash(){tv()}}function cT(n){if(!(n instanceof In))throw new TypeError("ExtendedPoint expected")}function ev(n){if(!(n instanceof ds))throw new TypeError("RistrettoPoint expected")}function tv(){throw new Error("Legacy method: switch to RistrettoPoint")}In.BASE=new In(zn.Gx,zn.Gy,nn,Me(zn.Gx*zn.Gy)),In.ZERO=new In(mr,nn,nn,mr);class ds{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=zn,r=Me(of*e*e),i=Me((r+nn)*oV);let s=BigInt(-1);const o=Me((s-t*r)*Me(r+t));let{isValid:a,value:c}=sv(i,o),m=Me(c*e);fa(m)||(m=Me(-m)),a||(c=m),a||(s=r);const T=Me(s*(r-nn)*aV-o),R=c*c,k=Me((c+c)*o),U=Me(T*iV),Q=Me(nn-R),X=Me(nn+R);return new In(Me(k*X),Me(Q*U),Me(U*X),Me(k*Q))}static hashToCurve(e){const t=iv((e=Bs(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=iv(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new ds(r.add(s))}static fromHex(e){e=Bs(e,32);const{a:t,d:r}=zn,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=iv(e);if(!function lV(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>=aT)throw new Error("Expected 0 < hex < 2**256");const a=Me(o*o),c=Me(a-nn),m=Me(r*a+nn);let{isValid:T,value:R}=sv(c,m);if(!T)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((R&nn)===nn)&&(R=Me(-R)),new hr(R,o)}static fromPrivateKey(e){return V(function*(){return(yield uf(e)).point})()}toRawBytes(){const e=Du(this.y);return e[31]|=this.x&nn?128:0,e}toHex(){return af(this.toRawBytes())}toX25519(){const{y:e}=this;return Du(Me((nn+e)*Qh(nn-e)))}isTorsionFree(){return In.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new hr(Me(-this.x),this.y)}add(e){return In.fromAffine(this).add(In.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return In.fromAffine(this).multiply(e,this).toAffine()}}hr.BASE=new hr(zn.Gx,zn.Gy),hr.ZERO=new hr(mr,nn);class _u{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=Bs(e,64),r=hr.fromHex(t.slice(0,32),!1),i=Qa(t.slice(32,64));return new _u(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof hr))throw new Error("Expected Point instance");return Iu(t,zn.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Du(this.s),32),e}toHex(){return af(this.toRawBytes())}}function uT(...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 af(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=mr?t:e+t}function Qh(n,e=zn.P){if(n===mr||e<=mr)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Me(n,e),r=e,i=mr,s=nn,o=nn,a=mr;for(;t!==mr;){const m=r/t,T=r%t,R=i-o*m,k=s-a*m;r=t,t=T,i=o,s=a,o=R,a=k}if(r!==nn)throw new Error("invert: does not exist");return Me(i,e)}function ks(n,e){const{P:t}=zn;let r=n;for(;e-- >mr;)r*=r,r%=t;return r}function sv(n,e){const t=Me(e*e*e),r=Me(t*t*e);let s=Me(n*t*function fT(n){const{P:e}=zn,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),c=n*n%e*n%e,m=ks(c,Yr)*c%e,T=ks(m,nn)*n%e,R=ks(T,t)*T%e,k=ks(R,r)*R%e,U=ks(k,i)*k%e,Q=ks(U,s)*U%e,X=ks(Q,o)*Q%e,ae=ks(X,o)*Q%e,he=ks(ae,r)*R%e;return{pow_p_5_8:ks(he,Yr)*n%e,b2:c}}(n*r).pow_p_5_8);const o=Me(e*s*s),a=s,c=Me(s*of),m=o===n,T=o===Me(-n),R=o===Me(-n*of);return m&&(s=a),(T||R)&&(s=c),fa(s)&&(s=Me(-s)),{isValid:m||T,value:s}}function dT(n){return sv(nn,n)}function Su(n){return Me(Qa(n),zn.l)}function Bs(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):rv(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Iu(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=Bs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Me(Qa(n),zn.l-nn)+nn},randomBytes:(n=32)=>{if(da.web)return da.web.getRandomValues(new Uint8Array(n));if(da.node){const{randomBytes:e}=da.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Ya.randomBytes(32),sha512:function(){var n=V(function*(...e){const t=uT(...e);if(da.web){const r=yield da.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(da.node)return Uint8Array.from(da.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=hr.BASE){const t=e.equals(hr.BASE)?e:new hr(e.x,e.y);return t._setWindowSize(n),t.multiply(Yr),t},sha512Sync:void 0};function wV(){return hv.apply(this,arguments)}function hv(){return hv=V(function*(){const n=Ya.randomPrivateKey(),e=yield yT(n);return{privateKey:ET(n,e),publicKey:e}}),hv.apply(this,arguments)}function bV(n){return pv.apply(this,arguments)}function pv(){return pv=V(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 yT(e);return{privateKey:ET(e,t),publicKey:t}}),pv.apply(this,arguments)}function gv(){return gv=V(function*(n,e){const t=n.slice(0,32);return yield hV(e,t)}),gv.apply(this,arguments)}function yv(){return yv=V(function*(n,e,t){return yield gV(e,t,n)}),yv.apply(this,arguments)}function ET(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(Ya,{sha512Sync:{configurable:!1,get:()=>cf,set(n){cf||(cf=n)}}});class mv{constructor(e){this._key=Cu(e,32)}verify(e,t){var r=this;return V(function*(){return yield function DV(n,e,t){return yv.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return fu.encode({Type:dr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return $r(this.bytes,e.bytes)}hash(){var e=this;return V(function*(){const{bytes:t}=yield Li.digest(e.bytes);return t})()}}class ff{constructor(e,t){this._key=Cu(e,64),this._publicKey=Cu(t,32)}sign(e){var t=this;return V(function*(){return yield function _V(n,e){return gv.apply(this,arguments)}(t._key,e)})()}get public(){return new mv(this._publicKey)}marshal(){return this._key}get bytes(){return du.encode({Type:dr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return $r(this.bytes,e.bytes)}hash(){var e=this;return V(function*(){const{bytes:t}=yield Li.digest(e.bytes);return t})()}id(){var e=this;return V(function*(){const t=yield gu.digest(e.public.bytes);return Ci.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return V(function*(){if("libp2p-key"===t)return yield qm(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function SV(n){if(n.length>64){const r=(n=Cu(n,96)).slice(0,64),i=n.slice(64,n.length);return new ff(r,i)}const e=(n=Cu(n,64)).slice(0,64),t=n.slice(32);return new ff(e,t)}function IV(n){return n=Cu(n,32),new mv(n)}function CV(){return vv.apply(this,arguments)}function vv(){return vv=V(function*(){const{privateKey:n,publicKey:e}=yield wV();return new ff(n,e)}),vv.apply(this,arguments)}function TV(n){return Ev.apply(this,arguments)}function Ev(){return Ev=V(function*(n){const{privateKey:e,publicKey:t}=yield bV(n);return new ff(e,t)}),Ev.apply(this,arguments)}function Cu(n,e){if((n=Uint8Array.from(n??[])).length!==e)throw se(new Error(`Key must be a Uint8Array of length ${e}, got ${n.length}`),"ERR_INVALID_KEY_TYPE");return n}function AV(){return er.randomPrivateKey()}function wv(){return wv=V(function*(n,e){const{digest:t}=yield Li.digest(e);try{return yield z2(t,n)}catch(r){throw se(r,"ERR_INVALID_INPUT")}}),wv.apply(this,arguments)}function bv(){return bv=V(function*(n,e,t){try{const{digest:r}=yield Li.digest(t);return kU(e,r,n)}catch(r){throw se(r,"ERR_INVALID_INPUT")}}),bv.apply(this,arguments)}function wT(n){try{dn.fromHex(n)}catch(e){throw se(e,"ERR_INVALID_PUBLIC_KEY")}}class _v{constructor(e){wT(e),this._key=e}verify(e,t){var r=this;return V(function*(){return yield function RV(n,e,t){return bv.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function PV(n){return dn.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return fu.encode({Type:dr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return $r(this.bytes,e.bytes)}hash(){var e=this;return V(function*(){const{bytes:t}=yield Li.digest(e.bytes);return t})()}}class Dv{constructor(e,t){this._key=e,this._publicKey=t??function MV(n){try{return rf(n,!0)}catch(e){throw se(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function NV(n){try{rf(n,!0)}catch(e){throw se(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),wT(this._publicKey)}sign(e){var t=this;return V(function*(){return yield function xV(n,e){return wv.apply(this,arguments)}(t._key,e)})()}get public(){return new _v(this._publicKey)}marshal(){return this._key}get bytes(){return du.encode({Type:dr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return $r(this.bytes,e.bytes)}hash(){var e=this;return V(function*(){const{bytes:t}=yield Li.digest(e.bytes);return t})()}id(){var e=this;return V(function*(){return Mt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return V(function*(){if("libp2p-key"===t)return yield qm(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function OV(n){return new Dv(n)}function LV(n){return new _v(n)}function kV(){return Sv.apply(this,arguments)}function Sv(){return Sv=V(function*(){const n=yield AV();return new Dv(n)}),Sv.apply(this,arguments)}const Oo={rsa:C,ed25519:A,secp256k1:P};function Iv(n){const e=Object.keys(Oo).join(" / ");return se(new Error(`invalid or unsupported key type ${n}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function Cv(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return Oo[n];throw Iv(n)}function bT(n,e){return Tv.apply(this,arguments)}function Tv(){return Tv=V(function*(n,e){return yield Cv(n).generateKeyPair(e??2048)}),Tv.apply(this,arguments)}function Tu(n){const e=fu.decode(n),t=e.Data;switch(e.Type){case dr.RSA:return Oo.rsa.unmarshalRsaPublicKey(t);case dr.Ed25519:return Oo.ed25519.unmarshalEd25519PublicKey(t);case dr.Secp256k1:return Oo.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Iv(e.Type)}}function BV(n,e){return Cv(e=(e??"rsa").toLowerCase()),n.bytes}function Au(n){return xv.apply(this,arguments)}function xv(){return xv=V(function*(n){const e=du.decode(n),t=e.Data;switch(e.Type){case dr.RSA:return yield Oo.rsa.unmarshalRsaPrivateKey(t);case dr.Ed25519:return Oo.ed25519.unmarshalEd25519PrivateKey(t);case dr.Secp256k1:return Oo.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Iv(e.Type)}}),xv.apply(this,arguments)}function FV(n,e){return Cv(e=(e??"rsa").toLowerCase()),n.bytes}function Rv(n,e){return Pv.apply(this,arguments)}function Pv(){return Pv=V(function*(n,e){try{const i=yield SU(n,e);return yield Au(i)}catch{}const t=Gn.pki.decryptRsaPrivateKey(n,e);if(null===t)throw se(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let r=Gn.asn1.toDer(Gn.pki.privateKeyToAsn1(t));return r=_t(r.getBytes(),"ascii"),yield Oo.rsa.unmarshalRsaPrivateKey(r)}),Pv.apply(this,arguments)}const _T=Symbol.for("@libp2p/peer-id");function DT(n){return null!=n&&Boolean(n[_T])}const ST=Object.values(Jl).map(n=>n.decoder).reduce((n,e)=>n.or(e),Jl.identity.decoder);class Jh{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[_T](){return!0}toString(){return null==this.string&&(this.string=Ci.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Rr.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return $r(this.multihash.bytes,e);if("string"==typeof e)return _r(e).equals(this);if(null!=e?.multihash?.bytes)return $r(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class df extends Jh{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class hf extends Jh{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class pf extends Jh{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Zr(n){if("RSA"===n.type)return new df(n);if("Ed25519"===n.type)return new hf(n);if("secp256k1"===n.type)return new pf(n);throw se(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function _r(n,e){if(e=e??ST,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=Uh(Ci.decode(`z${n}`));return n.startsWith("12D")?new hf({multihash:t}):n.startsWith("16U")?new pf({multihash:t}):new df({multihash:t})}return pa(ST.decode(n))}function pa(n){try{const e=Uh(n);if(e.code===gu.code){if(36===e.digest.length)return new hf({multihash:e});if(37===e.digest.length)return new pf({multihash:e})}if(e.code===Li.code)return new df({multihash:e})}catch{return function UV(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===Li.code)return new df({multihash:n.multihash});if(e.code===gu.code){if(36===e.digest.length)return new hf({multihash:n.multihash});if(37===e.digest.length)return new pf({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(Rr.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function xu(n,e){return Ov.apply(this,arguments)}function Ov(){return Ov=V(function*(n,e){return 36===n.length?new hf({multihash:pu(gu.code,n),privateKey:e}):37===n.length?new pf({multihash:pu(gu.code,n),privateKey:e}):new df({multihash:yield Li.digest(n),publicKey:n,privateKey:e})}),Ov.apply(this,arguments)}function CT(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}var tr=(()=>(function(n){n[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"}(tr||(tr={})),tr))();function di(n,e,t,r,i){return{name:n,type:e,encode:t,decode:r,encodingLength:i}}di("bool",tr.VARINT,function(e){return Uint8Array.from([e?1:0])},function(e,t){return e.get(t)>0},function(){return 1});const Lv=di("bytes",tr.LENGTH_DELIMITED,function(e){return new $n(Qt.encode(e.byteLength),e)},function(e,t){const r=Qt.decode(e,t);return t+=Qt.encodingLength(r),e.subarray(t,t+r)},function(e){const t=e.byteLength;return Qt.encodingLength(t)+t});di("double",tr.BIT64,function(e){const t=new $n(new Uint8Array(8));return t.setFloat64(0,e,!0),t},function(e,t){return e.getFloat64(t,!0)},function(){return 8});const xT=(di("fixed32",tr.BIT32,function(e){const t=new $n(new Uint8Array(4));return t.setInt32(0,e,!0),t},function(e,t){return e.getInt32(t,!0)},function(){return 4}),function(e){return 8}),RT=(di("fixed64",tr.BIT64,function(e){const t=new $n(new Uint8Array(8));return t.setBigInt64(0,e,!0),t},function(e,t){return e.getBigInt64(t,!0)},xT),function(){return 4}),PT=(di("float",tr.BIT32,function(e){const t=new $n(new Uint8Array(4));return t.setFloat32(0,e,!0),t},function(e,t){return e.getFloat32(t,!0)},RT),function(e){return e<0?10:Th.encodingLength(e)}),NT=(di("int32",tr.VARINT,function(e){const t=new Uint8Array(PT(e));return Th.encode(e,t)},function(e,t){return 0|Th.decode(e,t)},PT),0x7fn),Za={encodingLength(n){let e=0;for(;n>=0x80n;e++)n>>=7n;return e+1},encode(n,e,t=0){null==e&&(e=xo(Za.encodingLength(n)));const r=gm(e);for(;NT>=7n;return r.set(t,Number(n)),e},decode:(n,e=0)=>qr.fromBytes(n,e).toBigInt(!0)},ep={encodingLength:n=>n<0n?10:Za.encodingLength(n),encode:(n,e,t)=>(null==e&&(e=xo(ep.encodingLength(n))),n<0n?(qr.fromBigInt(n).toBytes(e,t),e):Za.encode(n,e,t)),decode:(n,e=0)=>qr.fromBytes(n,e).toBigInt(!1)},tp={encodingLength:n=>Za.encodingLength(n>=0?2n*n:-2n*n-1n),encode:(n,e,t)=>(null==e&&(e=xo(tp.encodingLength(n))),qr.fromBigInt(n).zzEncode().toBytes(e,t),e),decode:(n,e=0)=>qr.fromBytes(n,e).zzDecode().toBigInt(!1)},MT=function(e){return e<0n?10:ep.encodingLength(e)};di("int64",tr.VARINT,function(e){const t=new Uint8Array(MT(e));return ep.encode(e,t)},function(e,t){return 0n|ep.decode(e,t)},MT);const LT=(di("sfixed32",tr.BIT32,function(e){const t=new $n(new Uint8Array(4));return t.setInt32(0,e,!0),t},function(e,t){return e.getInt32(t,!0)},function(){return 4}),function(){return 8});var kv;di("sfixed64",tr.BIT64,function(e){const t=new $n(new Uint8Array(8));return t.setBigInt64(0,e,!0),t},function(e,t){return e.getBigInt64(t,!0)},LT),di("sint32",tr.VARINT,function(e){return ym.encode(e)},function(e,t){return ym.decode(e,t)},function(e){return ym.encodingLength(e)}),di("sint64",tr.VARINT,function(e){return tp.encode(e)},function(e,t){return tp.decode(e,t)},function(e){return tp.encodingLength(e)}),di("string",tr.LENGTH_DELIMITED,function(e){const t=_t(e);return new $n(Qt.encode(t.byteLength),t)},function(e,t){const r=Qt.decode(e,t);return t+=Qt.encodingLength(r),Mt(e.subarray(t,t+r))},function(e){const t=_t(e).byteLength;return Qt.encodingLength(t)+t}),di("uint32",tr.VARINT,function(e){return Qt.encode(e)},function(e,t){return Qt.decode(e,t)},function(e){return Qt.encodingLength(e)}),di("uint64",tr.VARINT,function(e){return Za.encode(e)},function(e,t){return Za.decode(e,t)},function(e){return Za.encodingLength(e)}),function(n){let e;var t;(t=e=n.NoiseHandshakePayload||(n.NoiseHandshakePayload={})).codec=()=>function o7(n){return di("message",tr.LENGTH_DELIMITED,function(s){const o=new $n;function a(m,T,R){if(null==m){if(!0===R.optional)return;throw new Error(`Non optional field "${R.name}" was ${null===m?"null":"undefined"}`)}const k=T<<3|R.codec.type,U=CT(Qt.encodingLength(k));Qt.encode(k,U);const Q=R.codec.encode(m);o.append(U),o.append(Q)}for(const[m,T]of Object.entries(n)){const R=parseInt(m);if(!0===T.repeats){if(!Array.isArray(s[T.name]))throw new Error(`Repeating field "${T.name}" was not an array`);for(const k of s[T.name])a(k,R,T)}else a(s[T.name],R,T)}const c=Qt.encode(o.length);return new $n(c,o)},function(s,o){const a=Qt.decode(s,o),c=(o+=Qt.encodingLength(a))+a,m={};for(;o>3];let Q=0;if(R===tr.VARINT)if(null!=U){const X=U.codec.decode(s,o);Q=U.codec.encodingLength(X)}else{const X=Qt.decode(s,o);Q=Qt.encodingLength(X)}else if(R===tr.BIT64)Q=8;else if(R===tr.LENGTH_DELIMITED){const X=Qt.decode(s,o);Q=X+Qt.encodingLength(X)}else if(R===tr.BIT32)Q=4;else{if(R===tr.START_GROUP)throw new Error("Unsupported wire type START_GROUP");if(R===tr.END_GROUP)throw new Error("Unsupported wire type END_GROUP")}if(null!=U){const X=U.codec.decode(s,o);!0===U.repeats?(null==m[U.name]&&(m[U.name]=[]),m[U.name].push(X)):m[U.name]=X}o+=Q}for(const T of Object.values(n))!0===T.repeats&&null==m[T.name]&&(m[T.name]=[]);return m},function(s){let o=0;for(const a of Object.values(n))o+=a.codec.encodingLength(s[a.name]);return Qt.encodingLength(o)+o})}({1:{name:"identityKey",codec:Lv},2:{name:"identitySig",codec:Lv},3:{name:"data",codec:Lv}}),t.encode=r=>function HV(n,e){const t=e.encode(n),r=Qt.encodingLength(Qt.decode(t));return t instanceof Uint8Array?new $n(t.subarray(r)):t.sublist(r)}(r,t.codec()),t.decode=r=>function VV(n,e){const t=CT(Qt.encodingLength(n.byteLength));return Qt.encode(n.byteLength,t),e.decode(new $n(t,n),0)}(r,t.codec())}(kv||(kv={}));const kT=kv.NoiseHandshakePayload;function Bv(){return Bv=V(function*(n,e,t){const r=yield A7(n,BT(e)),i=t??new Uint8Array(0);if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return T7(n.publicKey,r,i)}),Bv.apply(this,arguments)}function T7(n,e,t){return kT.encode({identityKey:n,identitySig:e,data:t??new Uint8Array(0)}).subarray()}function A7(n,e){return Fv.apply(this,arguments)}function Fv(){return Fv=V(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Au(n.privateKey)).sign(e)}),Fv.apply(this,arguments)}function gf(n){return Uv.apply(this,arguments)}function Uv(){return Uv=V(function*(n){return yield xu(n.identityKey)}),Uv.apply(this,arguments)}function yf(n){return kT.decode(n)}function BT(n){const e=_t("noise-libp2p-static-key:");return or([e,n],e.length+n.length)}function mf(n,e,t){return Vv.apply(this,arguments)}function Vv(){return Vv=V(function*(n,e,t){const r=yield xu(e.identityKey);if(!r.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");const i=BT(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 Tu(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Vv.apply(this,arguments)}function Xa(n){return!(!(n instanceof Uint8Array)||32!==n.length)}var Ur=N(1455);function Gt(n){return Object.assign(Ur(n),{error:Ur(`${n}:error`),trace:Ur(`${n}:trace`)})}Ur.formatters.b=n=>null==n?"undefined":Ci.baseEncode(n),Ur.formatters.t=n=>null==n?"undefined":Ro.baseEncode(n),Ur.formatters.m=n=>null==n?"undefined":Lh.baseEncode(n),Ur.formatters.p=n=>null==n?"undefined":n.toString(),Ur.formatters.c=n=>null==n?"undefined":n.toString(),Ur.formatters.k=n=>null==n?"undefined":n.toString();const ln=Gt("libp2p:noise");let hs;function FT(n){hs(`LOCAL_STATIC_PUBLIC_KEY ${Mt(n.publicKey,"hex")}`),hs(`LOCAL_STATIC_PRIVATE_KEY ${Mt(n.privateKey,"hex")}`)}function vf(n){n?(hs(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Mt(n.publicKey,"hex")}`),hs(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Mt(n.privateKey,"hex")}`)):hs("Missing local ephemeral keys.")}function Hv(n){hs(`REMOTE_STATIC_PUBLIC_KEY ${Mt(n,"hex")}`)}function Ru(n){hs(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Mt(n,"hex")}`)}function UT(n){n.cs1&&n.cs2?(hs(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Mt(n.cs1.k,"hex")}`),hs(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Mt(n.cs2.k,"hex")}`)):hs("Missing cipher state.")}hs=V5?ln:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class N7{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 VT{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 e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){return $r(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 ln(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(or([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 N7}}initializeSymmetric(e){const t=_t(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)}}class M7 extends VT{initSession(e,t,r,i){const s=this.createEmptyKey();let o;return o=e?this.initializeInitiator(t,r,i,s):this.initializeResponder(t,r,i,s),{hs:o,i:e,mc:0}}sendMessage(e,t){let r;if(0===e.mc)r=this.writeMessageA(e.hs,t);else if(1===e.mc){const{messageBuffer:i,h:s,cs1:o,cs2:a}=this.writeMessageB(e.hs,t);r=i,e.h=s,e.cs1=o,e.cs2=a}else{if(!(e.mc>1))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");r=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");r=this.writeMessageRegular(e.cs2,t)}}return e.mc++,r}recvMessage(e,t){let r=new Uint8Array(0),i=!1;if(0===e.mc&&({plaintext:r,valid:i}=this.readMessageA(e.hs,t)),1===e.mc){const{plaintext:s,valid:o,h:a,cs1:c,cs2:m}=this.readMessageB(e.hs,t);r=s,i=o,e.h=a,e.cs1=c,e.cs2=m}return e.mc++,{plaintext:r,valid:i}}writeMessageA(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.rs));const s=this.encryptAndHash(e.ss,e.s.publicKey);return this.mixKey(e.ss,this.dh(e.s.privateKey,e.rs)),{ne:r,ns:s,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)),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const i=this.encryptAndHash(e.ss,t),o={ne:r,ns:this.createEmptyKey(),ciphertext:i},{cs1:a,cs2:c}=this.split(e.ss);return{messageBuffer:o,cs1:a,cs2:c,h:e.ss.h}}readMessageA(e,t){Xa(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&Xa(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.s.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageB(e,t){if(Xa(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state should contain ephemeral key by now.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re)),this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:s,cs2:o}=this.split(e.ss);return{h:e.ss.h,valid:i,plaintext:r,cs1:s,cs2:o}}initializeInitiator(e,t,r,i){const o=this.initializeSymmetric("Noise_IK_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),this.mixHash(o,r),{ss:o,s:t,rs:r,re:new Uint8Array(32),psk:i}}initializeResponder(e,t,r,i){const o=this.initializeSymmetric("Noise_IK_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),this.mixHash(o,t.publicKey),{ss:o,s:t,rs:r,re:new Uint8Array(32),psk:i}}}class HT extends Error{constructor(e,t){super(t),this.initialMsg=e,this.name="FailedIKhandshake"}}class O7{constructor(e,t,r,i,s,o,a,c,m){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,c&&(this.remotePeer=c),this.ik=m??new M7(i),this.session=this.ik.initSession(this.isInitiator,this.prologue,this.staticKeypair,a),this.remoteEarlyData=new Uint8Array}stage0(){var e=this;return V(function*(){if(FT(e.session.hs.s),Hv(e.session.hs.rs),e.isInitiator){ln("IK Stage 0 - Initiator sending message...");const t=e.ik.sendMessage(e.session,e.payload);e.connection.writeLP(l2(t)),ln("IK Stage 0 - Initiator sent message."),vf(e.session.hs.e)}else{ln("IK Stage 0 - Responder receiving message...");const t=yield e.connection.readLP();try{const r=bm(t.slice()),{plaintext:i,valid:s}=e.ik.recvMessage(e.session,r);if(!s)throw new Error("ik handshake stage 0 decryption validation fail");ln("IK Stage 0 - Responder got message, going to verify payload.");const o=yf(i);e.remotePeer=e.remotePeer||(yield gf(o)),yield mf(e.session.hs.rs,o,e.remotePeer),e.setRemoteEarlyData(o.data),ln("IK Stage 0 - Responder successfully verified payload!"),Ru(e.session.hs.re)}catch(r){const i=r;throw ln("Responder breaking up with IK handshake in stage 0."),new HT(t.slice(),`Error occurred while verifying initiator's signed payload: ${i.message}`)}}})()}stage1(){var e=this;return V(function*(){if(e.isInitiator){ln("IK Stage 1 - Initiator receiving message...");const t=(yield e.connection.readLP()).slice(),r=wm(t),{plaintext:i,valid:s}=e.ik.recvMessage(e.session,r);ln("IK Stage 1 - Initiator got message, going to verify payload.");try{if(!s)throw new Error("ik stage 1 decryption validation fail");const o=yf(i);e.remotePeer=e.remotePeer||(yield gf(o)),yield mf(r.ns.slice(0,32),o,e.remotePeer),e.setRemoteEarlyData(o.data),ln("IK Stage 1 - Initiator successfully verified payload!"),Ru(e.session.hs.re)}catch(o){const a=o;throw ln("Initiator breaking up with IK handshake in stage 1."),new HT(t,`Error occurred while verifying responder's signed payload: ${a.message}`)}}else{ln("IK Stage 1 - Responder sending message...");const t=e.ik.sendMessage(e.session,e.payload);e.connection.writeLP(u2(t)),ln("IK Stage 1 - Responder sent message..."),vf(e.session.hs.e)}UT(e.session)})()}decrypt(e,t){const r=this.getCS(t,!1);return this.ik.decryptWithAd(r,new Uint8Array(0),e)}encrypt(e,t){const r=this.getCS(t);return this.ik.encryptWithAd(r,new Uint8Array(0),e)}getLocalEphemeralKeys(){if(!this.session.hs.e)throw new Error("Ephemeral keys do not exist.");return this.session.hs.e}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Error("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 np extends Error{constructor(e="Unexpected Peer"){super(e),this.code=np.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class Pu extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Pu.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;class L7 extends VT{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:c,cs2:m}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:c,cs2:m}}readMessageA(e,t){return Xa(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(Xa(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&&Xa(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&&Xa(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:c}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:c}}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:c}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=c}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:c,cs2:m}=this.readMessageC(e.hs,t);r=o,i=a,e.h=s,e.cs1=c,e.cs2=m}return e.mc++,{plaintext:r,valid:i}}}class jT{constructor(e,t,r,i,s,o,a,c){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=c??new L7(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}propose(){var e=this;return V(function*(){if(FT(e.session.hs.s),e.isInitiator){ln("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(u2(t)),ln("Stage 0 - Initiator finished sending first message."),vf(e.session.hs.e)}else{ln("Stage 0 - Responder waiting to receive first message...");const t=wm((yield e.connection.readLP()).subarray()),{valid:r}=e.xx.recvMessage(e.session,t);if(!r)throw new Pu("xx handshake stage 0 validation fail");ln("Stage 0 - Responder received first message."),Ru(e.session.hs.re)}})()}exchange(){var e=this;return V(function*(){if(e.isInitiator){ln("Stage 1 - Initiator waiting to receive first message from responder...");const t=bm((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Pu("xx handshake stage 1 validation fail");ln("Stage 1 - Initiator received the message."),Ru(e.session.hs.re),Hv(e.session.hs.rs),ln("Initiator going to check remote's signature...");try{const s=yf(r);e.remotePeer=e.remotePeer||(yield gf(s)),yield mf(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new np(`Error occurred while verifying signed payload: ${s.message}`)}ln("All good with the signature!")}else{ln("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(l2(t)),ln("Stage 1 - Responder sent the second handshake message with signed payload."),vf(e.session.hs.e)}})()}finish(){var e=this;return V(function*(){if(e.isInitiator){ln("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function z5(n){return or([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),ln("Stage 2 - Initiator sent message with signed payload.")}else{ln("Stage 2 - Responder waiting for third handshake message...");const t=function W5(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 Pu("xx handshake stage 2 validation fail");ln("Stage 2 - Responder received the message, finished handshake.");try{const s=yf(r);e.remotePeer=e.remotePeer||(yield gf(s)),yield mf(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new np(`Error occurred while verifying signed payload: ${s.message}`)}}UT(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 Pu("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 k7 extends jT{constructor(e,t,r,i,s,o,a,c,m,T){super(e,t,r,i,s,o,c,T),m&&(this.ephemeralKeys=m),this.initialMsg=a}propose(){var e=this;return V(function*(){if(e.isInitiator)e.xx.sendMessage(e.session,new Uint8Array(0),e.ephemeralKeys),ln("XX Fallback Stage 0 - Initialized state as the first message was sent by initiator."),vf(e.session.hs.e);else{ln("XX Fallback Stage 0 - Responder decoding initial msg from IK.");const t=wm(e.initialMsg),{valid:r}=e.xx.recvMessage(e.session,{ne:t.ne,ns:new Uint8Array(0),ciphertext:new Uint8Array(0)});if(!r)throw new Error("xx fallback stage 0 decryption validation fail");ln("XX Fallback Stage 0 - Responder used received message from IK."),Ru(e.session.hs.re)}})()}exchange(){var e=()=>super.exchange,t=this;return V(function*(){if(t.isInitiator){const r=bm(t.initialMsg),{plaintext:i,valid:s}=t.xx.recvMessage(t.session,r);if(!s)throw new Error("xx fallback stage 1 decryption validation fail");ln("XX Fallback Stage 1 - Initiator used received message from IK."),Ru(t.session.hs.re),Hv(t.session.hs.rs),ln("Initiator going to check remote's signature...");try{const o=yf(i);t.remotePeer=t.remotePeer||(yield gf(o)),yield mf(t.session.hs.rs,o,t.remotePeer),t.setRemoteEarlyData(o.data)}catch(o){throw new Error(`Error occurred while verifying signed payload from responder: ${o.message}`)}ln("All good with the signature!")}else ln("XX Fallback Stage 1 - Responder start"),yield e().call(t),ln("XX Fallback Stage 1 - Responder end")})()}}function rp(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 $T{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 rp(this.map.entries(),e=>[_r(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,_r(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 rp(this.map.keys(),e=>_r(e))}values(){return this.map.values()}get size(){return this.map.size}}class B7{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 rp(this.set.entries(),e=>{const t=_r(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=_r(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return rp(this.set.values(),e=>_r(e))}}Symbol;const jv=new class F7{constructor(){this.storage=new $T}store(e,t){this.storage.set(e,t)}load(e){return e?this.storage.get(e)??null:null}resetStorage(){this.storage.clear()}};class GT{constructor(e,t,r=K5){this.protocol="/noise",this.prologue=new Uint8Array(0),this.earlyData=t??new Uint8Array(0),this.useNoisePipes=!1,this.crypto=r,this.staticKeys=e?this.crypto.generateX25519KeyPairFromSeed(e):this.crypto.generateX25519KeyPair()}secureOutbound(e,t,r){var i=this;return V(function*(){const s=r2(t,{lengthEncoder:Rh,lengthDecoder:Ph,maxDataLength:Ql}),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 V(function*(){const s=r2(t,{lengthEncoder:Rh,lengthDecoder:Ph,maxDataLength:Ql}),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 V(function*(){const r=yield function C7(n,e,t){return Bv.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.earlyData);let i=t.useNoisePipes;if(e.isInitiator&&null===jv.load(e.remotePeer)&&(i=!1),!i)return yield t.performXXHandshake(e,r);{const{remotePeer:s,connection:o,isInitiator:a}=e,c=new O7(a,r,t.prologue,t.crypto,t.staticKeys,o,jv.load(e.remotePeer)??new Uint8Array(32),s);try{return yield t.performIKHandshake(c)}catch(m){const T=m;let R;return e.isInitiator&&(R=c.getLocalEphemeralKeys()),yield t.performXXFallbackHandshake(e,r,T.initialMsg,R)}}})()}performXXFallbackHandshake(e,t,r,i){var s=this;return V(function*(){const{isInitiator:o,remotePeer:a,connection:c}=e,m=new k7(o,t,s.prologue,s.crypto,s.staticKeys,c,r,a,i);try{yield m.propose(),yield m.exchange(),yield m.finish()}catch(T){const R=T;throw R.message=`Error occurred during XX Fallback handshake: ${R.message}`,ln(R),R}return m})()}performXXHandshake(e,t){var r=this;return V(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new jT(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish(),r.useNoisePipes&&a.remotePeer&&jv.store(a.remotePeer,a.getRemoteStaticKey())}catch(c){if(c instanceof Error)throw c.message=`Error occurred during XX handshake: ${c.message}`,c}return a})()}performIKHandshake(e){return V(function*(){return yield e.stage0(),yield e.stage1(),e})()}createSecureConnection(e,t){return V(function*(){const[r,i]=function B5(){const n=i2(),e=i2();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),s=e.unwrap();return yield Ln(r,function j5(n){return function(){var e=un(function*(t){var s,r=!1,i=!1;try{for(var a,o=Tt(t);r=!(a=yield ct(o.next())).done;r=!1){const c=a.value;for(let m=0;mc.length&&(T=c.length),yield n.encrypt(c.subarray(m,T),n.session)}}}catch(c){i=!0,s=c}finally{try{r&&null!=o.return&&(yield ct(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),to({lengthEncoder:Rh}),s,Ms({lengthDecoder:Ph}),function $5(n){return function(){var e=un(function*(t){var s,r=!1,i=!1;try{for(var a,o=Tt(t);r=!(a=yield ct(o.next())).done;r=!1){const c=a.value;for(let m=0;mc.length&&(T=c.length);const{plaintext:R,valid:k}=yield ct(n.decrypt(c.subarray(m,T),n.session));if(!k)throw new Error("Failed to validate decrypted chunk");yield R}}}catch(c){i=!0,s=c}finally{try{r&&null!=o.return&&(yield ct(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),r),i})()}}function Lo(n){return null!=n&&"function"==typeof n.start&&"function"==typeof n.stop}function hi(n){return null!=n&&"function"==typeof n.init}new GT;class ko{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 V(function*(){yield Promise.all(Object.values(e).filter(t=>Lo(t)).map(function(){var t=V(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return V(function*(){yield Promise.all(Object.values(e).filter(t=>Lo(t)).map(function(){var t=V(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e.started=!0})()}afterStart(){var e=this;return V(function*(){yield Promise.all(Object.values(e).filter(t=>Lo(t)).map(function(){var t=V(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return V(function*(){yield Promise.all(Object.values(e).filter(t=>Lo(t)).map(function(){var t=V(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return V(function*(){yield Promise.all(Object.values(e).filter(t=>Lo(t)).map(function(){var t=V(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e.started=!1})()}afterStop(){var e=this;return V(function*(){yield Promise.all(Object.values(e).filter(t=>Lo(t)).map(function(){var t=V(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 se(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,hi(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,hi(e)&&e.init(this),e}getAddressManager(){if(null==this.addressManager)throw se(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,hi(e)&&e.init(this),e}getPeerStore(){if(null==this.peerStore)throw se(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,hi(e)&&e.init(this),e}getUpgrader(){if(null==this.upgrader)throw se(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,hi(e)&&e.init(this),e}getRegistrar(){if(null==this.registrar)throw se(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,hi(e)&&e.init(this),e}getConnectionManager(){if(null==this.connectionManager)throw se(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,hi(e)&&e.init(this),e}getTransportManager(){if(null==this.transportManager)throw se(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,hi(e)&&e.init(this),e}getConnectionGater(){if(null==this.connectionGater)throw se(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,hi(e)&&e.init(this),e}getContentRouting(){if(null==this.contentRouting)throw se(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,hi(e)&&e.init(this),e}getPeerRouting(){if(null==this.peerRouting)throw se(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,hi(e)&&e.init(this),e}getDatastore(){if(null==this.datastore)throw se(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,hi(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,hi(e)&&e.init(this),e}getDHT(){if(null==this.dht)throw se(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,hi(e)&&e.init(this),e}getPubSub(){if(null==this.pubsub)throw se(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}}class zT extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function Fs(n,e,t){const r=t??{},i=function U7(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=un(function*(){let a;const c=()=>{a?.()};for(e.addEventListener("abort",c);;){let m;try{if(e.aborted){const{abortMessage:R,abortCode:k}=r;throw new zT(R,k)}const T=new Promise((R,k)=>{a=()=>{const{abortMessage:U,abortCode:Q}=r;k(new zT(U,Q))}});m=yield ct(Promise.race([T,i.next()])),a=null}catch(T){e.removeEventListener("abort",c);const R="aborted"===T.type&&e.aborted;if(R&&null!=r.onAbort&&(yield ct(r.onAbort(n))),"function"==typeof i.return)try{const k=i.return();k instanceof Promise&&k.catch(U=>{null!=r.onReturnError&&r.onReturnError(U)})}catch(k){null!=r.onReturnError&&r.onReturnError(k)}if(R&&!0===r.returnOnAbort)return;throw T}if(!0===m.done)break;yield m.value}e.removeEventListener("abort",c)})).apply(this,arguments)}return function s(){return o.apply(this,arguments)}()}function V7(n,e,t){return r=>n(Fs(r,e,t))}function ga(n,e,t){return{sink:V7(n.sink,e,{...t,onAbort:void 0}),source:Fs(n.source,e,t)}}var Vn=N(1732);function WT(n){return new Uint8Array(n)}var Jt=(()=>(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"}(Jt||(Jt={})),Jt))();const qT=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),QT=Object.freeze({NEW_STREAM:Jt.NEW_STREAM,MESSAGE:Jt.MESSAGE_INITIATOR,CLOSE:Jt.CLOSE_INITIATOR,RESET:Jt.RESET_INITIATOR}),H7=Object.freeze({MESSAGE:Jt.MESSAGE_RECEIVER,CLOSE:Jt.CLOSE_RECEIVER,RESET:Jt.RESET_RECEIVER}),YT=new class K7{constructor(){this._pool=WT(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;Vn.encode(e.id<<3|e.type,t,r),r+=Vn.encode.bytes,Vn.encode(e.type!==Jt.NEW_STREAM&&e.type!==Jt.MESSAGE_INITIATOR&&e.type!==Jt.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=Vn.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=WT(10240),this._poolOffset=0):this._poolOffset=r,e.type!==Jt.NEW_STREAM&&e.type!==Jt.MESSAGE_INITIATOR&&e.type!==Jt.MESSAGE_RECEIVER||null==e.data?[i]:[i,e.data instanceof Uint8Array?e.data:e.data.subarray()]}};function Wv(){return Wv=un(function*(n){var r,e=!1,t=!1;try{for(var s,i=Tt(n);e=!(s=yield ct(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*jr(Tt(YT.write(a)),ct);else yield*jr(Tt(YT.write(o)),ct)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield ct(i.return()))}finally{if(t)throw r}}}),Wv.apply(this,arguments)}class $7{constructor(){this._buffer=new $n,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 XT(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 z7(n){return qv.apply(this,arguments)}function qv(){return qv=un(function*(n){const e=new $7;var i,t=!1,r=!1;try{for(var o,s=Tt(n);t=!(o=yield ct(s.next())).done;t=!1){const c=e.write(o.value);c.length>0&&(yield c)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield ct(s.return()))}finally{if(r)throw i}}}),qv.apply(this,arguments)}const JT=1<<20;var ip=N(772);const Us=Gt("libp2p:mplex:stream"),Qv="ERR_STREAM_RESET";class X7 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 Ef(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new X7({system:e,component:t,metric:r,metrics:i}):new Map,s}const so=Gt("libp2p:mplex");function eA(n){const e={...n,type:`${qT[n.type]} (${n.type})`};return n.type===Jt.NEW_STREAM&&(e.data=Mt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===Jt.MESSAGE_INITIATOR||n.type===Jt.MESSAGE_RECEIVER)&&(e.data=Mt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class n9{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:Ef({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:Ef({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}init(e){}get streams(){const e=[];return this._streams.initiators.forEach(t=>{e.push(t)}),this._streams.receivers.forEach(t=>{e.push(t)}),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(so("new %s stream %s %s",i,t,r),"initiator"===i&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw se(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 c=function Z7(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=JT}=n,a=new AbortController,c=new AbortController,m=new AbortController,T="initiator"===s?QT:H7,R="initiator"===s?`i${e}`:`r${e}`,k=`${t??e}`;let ae,U=!1,Q=!1,X=!1;const he={open:Date.now()},ue=Le=>{Q||(Q=!0,Us.trace("%s stream %s sink end - err: %o",s,k,Le),null!=Le&&null==ae&&(ae=Le),U&&(he.close=Date.now(),i?.(ae)))},Re={close:()=>{Us.trace("%s stream %s close",s,k),Re.closeRead(),Re.closeWrite()},closeRead:()=>{Us.trace("%s stream %s closeRead",s,k),!U&&Re.source.end()},closeWrite:()=>{if(Us.trace("%s stream %s closeWrite",s,k),!Q){m.abort();try{r({id:e,type:T.CLOSE})}catch(Le){Us.trace("%s stream %s error sending close",s,t,Le)}ue()}},abort:Le=>{Us.trace("%s stream %s abort",s,k,Le),Re.source.end(Le),a.abort(),ue(Le)},reset:()=>{const Le=se(new Error("stream reset"),Qv);c.abort(),Re.source.end(Le),ue(Le)},sink:(Le=V(function*(Fe){if(X)throw se(new Error("sink already called on stream"),"ERR_DOUBLE_SINK");if(X=!0,Q)throw se(new Error("stream closed for writing"),"ERR_SINK_ENDED");Fe=Fs(Fe,(0,ip.anySignal)([a.signal,c.signal,m.signal]));try{"initiator"===s&&r({id:e,type:QT.NEW_STREAM,data:_t(k)});const Rn=new $n;var Zt,wt=!1,mt=!1;try{for(var zr,wn=Tt(Fe);wt=!(zr=yield wn.next()).done;wt=!1)for(Rn.append(zr.value);0!==Rn.length;){if(Rn.length<=o){r({id:e,type:T.MESSAGE,data:Rn.subarray()}),Rn.consume(Rn.length);break}const Ju=Rn.length-o;r({id:e,type:T.MESSAGE,data:Rn.subarray(0,Ju)}),Rn.consume(Ju)}}catch(Yo){mt=!0,Zt=Yo}finally{try{wt&&null!=wn.return&&(yield wn.return())}finally{if(mt)throw Zt}}}catch(Rn){if("aborted"===Rn.type&&"The operation was aborted"===Rn.message){if(m.signal.aborted)return;c.signal.aborted&&(Rn.message="stream reset",Rn.code=Qv),a.signal.aborted&&(Rn.message="stream aborted",Rn.code="ERR_STREAM_ABORT")}if(Rn.code===Qv)Us.trace("%s stream %s reset",s,t);else{Us.trace("%s stream %s error",s,t,Rn);try{r({id:e,type:T.RESET})}catch(Yo){Us.trace("%s stream %s error sending reset",s,t,Yo)}}return Re.source.end(Rn),void ue(Rn)}try{r({id:e,type:T.CLOSE})}catch(Rn){Us.trace("%s stream %s error sending close",s,t,Rn)}ue()}),function(wt){return Le.apply(this,arguments)}),source:lu({onEnd:Le=>{U||(U=!0,Us.trace("%s stream %s source end - err: %o",s,k,Le),null!=Le&&null==ae&&(ae=Le),Q&&(Re.stat.timeline.close=Date.now(),i?.(ae)))}}),stat:{direction:"initiator"===s?"outbound":"inbound",timeline:he},metadata:{},id:R};var Le;return Re}({id:t,name:r,send:m=>{so.enabled&&so.trace("%s stream %s send",i,t,eA(m)),(m.type===Jt.NEW_STREAM||m.type===Jt.MESSAGE_INITIATOR||m.type===Jt.MESSAGE_RECEIVER)&&(m.data=m.data instanceof Uint8Array?m.data:m.data.subarray()),this._source.push(m)},type:i,onEnd:()=>{so("%s stream %s ended",i,t,r),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(c)},maxMsgSize:this._init.maxMsgSize});return s.set(t,c),c}_createSink(){var e=this;return function(){var r=V(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=Fs(i,ip(s));try{yield Ln(i,z7,function W7(n){const e=n??JT,t=r=>{if((r.type===Jt.NEW_STREAM||r.type===Jt.MESSAGE_INITIATOR||r.type===Jt.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=un(function*(){var c,o=!1,a=!1;try{for(var T,m=Tt(r);o=!(T=yield ct(m.next())).done;o=!1){const R=T.value;Array.isArray(R)?(R.forEach(t),yield*jr(Tt(R),ct)):(t(R),yield R)}}catch(R){a=!0,c=R}finally{try{o&&null!=m.return&&(yield ct(m.return()))}finally{if(a)throw c}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=V(function*(a){var T,c=!1,m=!1;try{for(var k,R=Tt(a);c=!(k=yield R.next()).done;c=!1)e._handleIncoming(k.value)}catch(U){m=!0,T=U}finally{try{c&&null!=R.return&&(yield R.return())}finally{if(m)throw T}}});return function(a){return o.apply(this,arguments)}}()),e._source.end()}catch(o){so("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function S5(n={}){return t2(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 j7(n){return Wv.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){const{id:t,type:r}=e;if(so.enabled&&so.trace("incoming message",eA(e)),e.type===Jt.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??1024))return so.error("Too many inbound streams open"),void this._source.push({id:t,type:Jt.RESET_RECEIVER});const a=this._newReceiverStream({id:t,name:Mt(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=this._init.onIncomingStream&&this._init.onIncomingStream(a))}const s=(1==(1&r)?this._streams.initiators:this._streams.receivers).get(t);if(null==s)return void so("missing stream %s",t);const o=this._init.maxStreamBufferSize??4194304;switch(r){case Jt.MESSAGE_INITIATOR:case Jt.MESSAGE_RECEIVER:if(s.source.readableLength>o){this._source.push({id:e.id,type:r===Jt.MESSAGE_INITIATOR?Jt.RESET_RECEIVER:Jt.RESET_INITIATOR});const a=se(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");return void s.abort(a)}s.source.push(e.data.subarray());break;case Jt.CLOSE_INITIATOR:case Jt.CLOSE_RECEIVER:s.closeRead();break;case Jt.RESET_INITIATOR:case Jt.RESET_RECEIVER:s.reset();break;default:so("unknown message type %s",r)}}}class r9{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new ko,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new n9(this.components,{...e,...this._init})}}const i9=WebSocket;var s9=N(3676);function tA(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const o9=n=>{n.binaryType="arraybuffer";const e=function(){var s=V(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const c=R=>{n.removeEventListener("open",m),n.removeEventListener("error",T),R()},m=()=>c(o),T=R=>{c(()=>a(R.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",m),n.addEventListener("error",T)})});return function(){return s.apply(this,arguments)}}(),t=un(function*(){const s=new s9.zN(({push:R,stop:k,fail:U})=>{const Q=ae=>{let he=null;"string"==typeof ae.data&&(he=_t(ae.data)),tA(ae.data)&&(he=new Uint8Array(ae.data)),ae.data instanceof Uint8Array&&(he=ae.data),null!=he&&R(he)},X=ae=>U(ae.error??new Error("Socket error"));return n.addEventListener("message",Q),n.addEventListener("error",X),n.addEventListener("close",k),()=>{n.removeEventListener("message",Q),n.removeEventListener("error",X),n.removeEventListener("close",k)}},{highWaterMark:1/0});yield ct(e());var c,o=!1,a=!1;try{for(var T,m=Tt(s);o=!(T=yield ct(m.next())).done;o=!1){const R=T.value;yield tA(R)?new Uint8Array(R):R}}catch(R){a=!0,c=R}finally{try{o&&null!=m.return&&(yield ct(m.return()))}finally{if(a)throw c}}})();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})},a9=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)})},c9=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=V(function*(i){var a,s=!1,o=!1;try{for(var m,c=Tt(i);s=!(m=yield c.next()).done;s=!1){const T=m.value;try{yield a9(n)}catch(R){if("socket closed"===R.message)break;throw R}n.send(T)}}catch(T){o=!0,a=T}finally{try{s&&null!=c.return&&(yield c.return())}finally{if(o)throw a}}if(null!=e.closeOnEnd&&n.readyState<=1)return yield new Promise((T,R)=>{n.addEventListener("close",k=>{if(k.wasClean||1006===k.code)T();else{const U=Object.assign(new Error("ws error"),{event:k});R(U)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),u9=(n,e)=>{e=e??{};const t=o9(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:c9(n,e),source:t,connected:(o=V(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=V(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 l9=N(8596);const f9={http:"ws",https:"wss"};const nA="[a-fA-F\\d:]",ya=n=>n&&n.includeBoundaries?`(?:(?<=\\s|^)(?=${nA})|(?<=${nA})(?=\\s|$))`:"",Vs="(?: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}",Pr="[a-fA-F\\d]{1,4}",sp=`\n(?:\n(?:${Pr}:){7}(?:${Pr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${Pr}:){6}(?:${Vs}|:${Pr}|:)| // 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(?:${Pr}:){5}(?::${Vs}|(?::${Pr}){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(?:${Pr}:){4}(?:(?::${Pr}){0,1}:${Vs}|(?::${Pr}){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(?:${Pr}:){3}(?:(?::${Pr}){0,2}:${Vs}|(?::${Pr}){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(?:${Pr}:){2}(?:(?::${Pr}){0,3}:${Vs}|(?::${Pr}){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(?:${Pr}:){1}(?:(?::${Pr}){0,4}:${Vs}|(?::${Pr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${Pr}){0,5}:${Vs}|(?::${Pr}){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(),g9=new RegExp(`(?:^${Vs}$)|(?:^${sp}$)`),y9=new RegExp(`^${Vs}$`),m9=new RegExp(`^${sp}$`),Yv=n=>n&&n.exact?g9:new RegExp(`(?:${ya(n)}${Vs}${ya(n)})|(?:${ya(n)}${sp}${ya(n)})`,"g");Yv.v4=n=>n&&n.exact?y9:new RegExp(`${ya(n)}${Vs}${ya(n)}`,"g"),Yv.v6=n=>n&&n.exact?m9:new RegExp(`${ya(n)}${sp}${ya(n)}`,"g");const Zv=Yv,{toString:w9}=Object.prototype,rA={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Xv(n,e,{}={}){try{return function v9(n){const e=(...t)=>n(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${n.name||""})`,configurable:!0}),e}(()=>function _9(n,e={}){if(!function b9(n){return"[object RegExp]"===w9.call(n)}(n))throw new TypeError("Expected a RegExp instance");const t=Object.keys(rA).map(i=>("boolean"==typeof e[i]?e[i]:n[i])?rA[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 Jv={timeout:400};function eE(n){return Xv(Zv({exact:!0}),n.slice(0,45),Jv)}const aA=function S9(n){return Xv(Zv.v4({exact:!0}),n.slice(0,15),Jv)},I9=function oA(n){return Xv(Zv.v6({exact:!0}),n.slice(0,45),Jv)},cA=function(n){let t,e=0;if(aA(n))t=new Uint8Array(e+4),n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)});else if(I9(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 Error("Invalid ip address: "+n);return t},Hs=-1,op={},tE={};function Nr(n){if("number"==typeof n){if(null!=tE[n])return tE[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=op[n])return op[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}function uA(n,e){switch(Nr(n).code){case 4:case 41:return function x9(n){const e=function(n,e,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=rE(r);return or([t,i],t.length+i.length)}(e);case 445:return function B9(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=Ro.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=rE(r);return or([t,i],t.length+i.length)}(e);case 466:return function M9(n){const e=A9.decode(n),t=Uint8Array.from(Vn.encode(e.length));return or([t,e],t.length+e.length)}(e);default:return _t(e,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,Hs,"ip6zone"],[53,Hs,"dns",!0],[54,Hs,"dns4",!0],[55,Hs,"dns6",!0],[56,Hs,"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,Hs,"unix",!1,!0],[421,Hs,"ipfs"],[421,Hs,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,Hs,"garlic64"],[460,0,"quic"],[466,Hs,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,Hs,"memory"]].forEach(n=>{const e=function T9(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);tE[e.code]=e,op[e.name]=e});const nE=Object.values(Jl).map(n=>n.decoder),A9=function(){let n=nE[0].or(nE[1]);return nE.slice(2).forEach(e=>n=n.or(e)),n}();function rE(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function dA(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function pA(n){return n.map(e=>{const t=cp(e);return null!=e[1]?[t.code,uA(t.code,e[1])]:[t.code]})}function gA(n){return sE(or(n.map(e=>{const t=cp(e);let r=Uint8Array.from(Vn.encode(t.code));return e.length>1&&null!=e[1]&&(r=or([r,e[1]])),r})))}function yA(n,e){return n.size>0?n.size/8:0===n.size?0:Vn.decode(e)+Vn.decode.bytes}function ap(n){const e=[];let t=0;for(;tn.length)throw vA("Invalid address Uint8Array: "+Mt(n,"base16"));e.push([r,a])}return e}function iE(n){return function U9(n){const e=[];return n.map(t=>{const r=cp(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),oE(e.join("/"))}(pA(ap(n)))}function sE(n){const e=function mA(n){try{ap(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function oE(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function vA(n){return new Error("Error parsing address: "+n)}function cp(n){return Nr(n[0])}const j9=Symbol.for("nodejs.util.inspect.custom"),EA=[Nr("dns").code,Nr("dns4").code,Nr("dns6").code,Nr("dnsaddr").code],$9=[Nr("p2p").code,Nr("ipfs").code],wA=new Map,bA=Symbol.for("@multiformats/js-multiaddr/multiaddr");let vn=(()=>{class n{constructor(t){if(null==t&&(t=""),Object.defineProperty(this,bA,{value:!0}),t instanceof Uint8Array)this.bytes=sE(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 K9(n){return function H9(n){const e=function F9(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw vA("invalid address: "+n);if(!0===s.path){e.push([i,oE(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=oE(n)),t=function V9(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=cp(e);return e.length>1?[t.code,lA(t.code,e[1])]:[t.code]})}(e);return gA(t)}(n)}(t)}else{if(!n.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=sE(t.bytes)}}toString(){return iE(this.bytes)}toJSON(){return this.toString()}toOptions(){const t=this.protoCodes(),r=this.toString().split("/").slice(1);let i,s;if(r.length>2)EA.includes(t[0])&&$9.includes(t[1])?(i=Nr("tcp").name,s=443):(i=Nr(r[2]).name,s=parseInt(r[3]));else{if(!EA.includes(t[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');i=Nr("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({},Nr(t)))}protoCodes(){const t=[],r=this.bytes;let i=0;for(;it.name)}tuples(){return ap(this.bytes)}stringTuples(){return pA(ap(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(gA(r.slice(0,i)));return this}getPeerId(){try{const r=this.stringTuples().filter(i=>i[0]===op.ipfs.code).pop();if(null!=r?.[1]){const i=r[1];return Mt("Q"===i[0]||"1"===i[0]?Ci.decode(`z${i}`):Rr.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>!0===Nr(r[0]).path)[0][1],null==t&&(t=null)}catch{t=null}return t}equals(t){return $r(this.bytes,t.bytes)}resolve(t){var r=this;return V(function*(){const i=r.protos().find(a=>a.resolvable);if(null==i)return[r];const s=wA.get(i.name);if(null==s)throw se(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?.[bA])}[j9](){return""}inspect(){return""}}return n.resolvers=wA,n})();const up=(n,e)=>e,W9={ip4:up,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:up,dns4:up,dns6:up,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 Q9=N(9456);const aE="object"==typeof window&&"object"==typeof document&&9===document.nodeType,lp=Q9(),fp=aE&&!lp,Y9=lp&&!aE,Z9=lp&&aE,X9=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!lp,_A="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,J9=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class iH extends Error{constructor(e){super(e),this.name="TimeoutError"}}class sH extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const IA=n=>void 0===globalThis.DOMException?new sH(n):new DOMException(n),CA=n=>{const e=void 0===n.reason?IA("This operation was aborted."):n.reason;return e instanceof Error?e:IA(e)},TA=Gt("libp2p:websockets:socket");const cH=At("dns4"),uH=At("dns6"),lH=At("dnsaddr"),Ja=pi(At("dns"),lH,cH,uH),dp=pi(At("ip4"),At("ip6")),wf=pi(en(dp,At("tcp")),en(Ja,At("tcp"))),AA=en(dp,At("udp")),fH=en(AA,At("utp")),dH=en(AA,At("quic")),Mu=pi(en(wf,At("ws")),en(Ja,At("ws"))),ec=pi(en(wf,At("wss")),en(Ja,At("wss"))),cE=pi(en(wf,At("http")),en(dp,At("http")),en(Ja,At("http"))),uE=pi(en(wf,At("https")),en(dp,At("https")),en(Ja,At("https"))),xA=pi(en(Mu,At("p2p-webrtc-star"),At("p2p")),en(ec,At("p2p-webrtc-star"),At("p2p")),en(Mu,At("p2p-webrtc-star")),en(ec,At("p2p-webrtc-star"))),RA=(pi(en(Mu,At("p2p-websocket-star"),At("p2p")),en(ec,At("p2p-websocket-star"),At("p2p")),en(Mu,At("p2p-websocket-star")),en(ec,At("p2p-websocket-star"))),pi(en(cE,At("p2p-webrtc-direct"),At("p2p")),en(uE,At("p2p-webrtc-direct"),At("p2p")),en(cE,At("p2p-webrtc-direct")),en(uE,At("p2p-webrtc-direct")))),bf=pi(Mu,ec,cE,uE,xA,RA,wf,fH,dH,Ja),ma=(pi(en(bf,At("p2p-stardust"),At("p2p")),en(bf,At("p2p-stardust"))),pi(en(bf,At("p2p")),xA,RA,At("p2p"))),PA=pi(en(ma,At("p2p-circuit"),ma),en(ma,At("p2p-circuit")),en(At("p2p-circuit"),ma),en(bf,At("p2p-circuit")),en(At("p2p-circuit"),bf),At("p2p-circuit")),NA=()=>pi(en(PA,NA),PA),Ou=NA();function MA(n){return function e(t){let r;try{r=new vn(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:MA(e),partialMatch:e}}function pi(...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:MA(e),partialMatch:e}}function At(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=new vn(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 OA(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Mu.matches(t)||ec.matches(t)})}pi(en(Ou,ma,Ou),en(ma,Ou),en(Ou,ma),Ou,ma);const lE=Symbol.for("@libp2p/transport"),va=Gt("libp2p:websockets");class pH{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[lE](){return!0}dial(e,t){var r=this;return V(function*(){va("dialing %s",e),t=t??{};const s=function aH(n,e,t){const r={sink:i=>V(function*(){null!=t?.signal&&(i=Fs(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&TA.error(s)}})(),source:null!=(t=t??{}).signal?Fs(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>V(function*(){const i=Date.now();try{yield function oH(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((c,m)=>{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:T}=e;T.aborted&&m(CA(T)),T.addEventListener("abort",()=>{m(CA(T))})}o=s.setTimeout.call(void 0,()=>{if(r){try{c(r())}catch(k){m(k)}return}const R=i instanceof Error?i:new iH("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),m(R)},t),V(function*(){try{c(yield n)}catch(T){m(T)}finally{s.clearTimeout.call(void 0,o)}})()}else c(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();TA("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);va("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return va("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return V(function*(){if(!0===t?.signal?.aborted)throw new Nu;const i=e.toOptions();va("dialing %s:%s",i.host,i.port);const s=pm(),o=T=>{va.error("connection error:",T),s.reject(T)},a=function p9(n,e){e=e??{};const r=((n,e)=>(0,l9.relative)(n,e,f9,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new i9(r,e.websocket);return u9(i,e)}(function q9(n,e){const t=new vn(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 c=W9[s.protocol];if(null==c)throw new Error(`Unsupported protocol ${s.protocol}`);return c(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]),va("connected %s",e),a;let c;const m=new Promise((T,R)=>{if(c=()=>{R(new Nu),setTimeout(()=>{a.close().catch(k=>{va.error("error closing raw socket",k)})})},!0===t?.signal?.aborted)return c();t?.signal?.addEventListener("abort",c)});try{yield Promise.race([m,s.promise,a.connected()])}finally{null!=c&&t?.signal?.removeEventListener("abort",c)}return va("connected %s",e),a})()}createListener(e){return function eH(){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):fp||_A?function hH(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return ec.matches(t)&&Ja.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):OA(e)}}var Bo,tc=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 ki extends EventTarget{constructor(){super(...arguments),Bo.set(this,new Map)}listenerCount(e){const t=tc(this,Bo,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=tc(this,Bo,"f").get(e);null==i&&(i=[],tc(this,Bo,"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=tc(this,Bo,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),tc(this,Bo,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=tc(this,Bo,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),tc(this,Bo,"f").set(e.type,r)),t}}Bo=new WeakMap;class gH extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const rn=globalThis.CustomEvent??gH;var Ea=N(5357);const LA=(n,e)=>un(function*(){const t=yield ct(Ea(n));yield*jr(Tt(t.sort(e)),ct)})();var wa=N(7414),Ks=N(6225),kA=N(0);const Fo="/",BA=(new TextEncoder).encode(Fo),hp=BA[0];class Xr{constructor(e,t){if("string"==typeof e)this._buf=_t(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]!==hp)throw new Error("Invalid key")}toString(e="utf8"){return Mt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Xr(e.join(Fo))}static random(){return new Xr(((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 Xr(e):"function"==typeof e.uint8Array?new Xr(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=BA),this._buf[0]!==hp){const e=new Uint8Array(this._buf.byteLength+1);e.fill(hp,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===hp;)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 _H(n){return[].concat(...n)}class SH extends class yH{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 un(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(e);i=!(c=yield ct(a.next())).done;i=!1){const{key:m,value:T}=c.value;yield ct(r.put(m,T,t)),yield{key:m,value:T}}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield ct(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return un(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(e);i=!(c=yield ct(a.next())).done;i=!1){const m=c.value;yield r.get(m,t)}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield ct(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return un(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(e);i=!(c=yield ct(a.next())).done;i=!1){const m=c.value;yield ct(r.delete(m,t)),yield m}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield ct(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=V(function*(s){yield wa(e.putMany(t,s)),t=[],yield wa(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return un(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return un(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=Ks(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ks(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>LA(i,s),r)),null!=e.offset){let i=0;r=Ks(r,()=>i++>=e.offset)}return null!=e.limit&&(r=kA(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=Ks(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ks(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>LA(i,s),r)),null!=e.offset){let i=0;r=Ks(r,()=>i++>=e.offset)}return null!=e.limit&&(r=kA(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return V(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return V(function*(){if(!(yield t.has(e)))throw function DH(n){return n=n||new Error("Not Found"),se(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return V(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return V(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return un(function*(){yield*jr(Tt(Object.entries(e.data).map(([t,r])=>({key:new Xr(t),value:r}))),ct)})()}_allKeys(){var e=this;return un(function*(){yield*jr(Tt(Object.entries(e.data).map(([t])=>new Xr(t))),ct)})()}}var Cn=(()=>(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"}(Cn||(Cn={})),Cn))(),Ie=(()=>(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"}(Ie||(Ie={})),Ie))(),fE=N(6930);function dE(n,e){return hE.apply(this,arguments)}function hE(){return hE=un(function*(n,e){yield*jr(Tt(fE(n,function(){var t=V(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),ct)}),hE.apply(this,arguments)}function FA(n){const e=new Set;return Ks(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function UA(n){return pE.apply(this,arguments)}function pE(){return pE=un(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=Tt(n);r=!(a=yield ct(o.next())).done;r=!1){const c=a.value;t++,yield c}}catch(c){i=!0,s=c}finally{try{r&&null!=o.return&&(yield ct(o.return()))}finally{if(i)throw s}}if(tun(function*(){try{yield yield ct(s.findPeer(e,t))}catch(o){VA.error(o)}})())),s=>Ks(s,Boolean),s=>dE(s,r.components.getPeerStore()),function(){var s=V(function*(o){return yield nc(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw se(new Error(Cn.NOT_FOUND),Ie.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return un(function*(){if(0===r.routers.length)throw se(new Error("No peer routers available"),Ie.ERR_NO_ROUTERS_AVAILABLE);yield*jr(Tt(Ln(xh(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>dE(i,r.components.getPeerStore()),i=>FA(i),i=>UA(i))),ct)})()}}class CH{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return V(function*(){e.started=!0})()}stop(){var e=this;return V(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return un(function*(){if(0===r.routers.length)throw se(new Error("No content this.routers available"),Ie.ERR_NO_ROUTERS_AVAILABLE);yield*jr(Tt(Ln(xh(...r.routers.map(i=>i.findProviders(e,t))),i=>dE(i,r.components.getPeerStore()),i=>FA(i),i=>UA(i))),ct)})()}provide(e,t={}){var r=this;return V(function*(){if(0===r.routers.length)throw se(new Error("No content routers available"),Ie.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=V(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return V(function*(){if(!i.isStarted())throw se(new Error(Cn.NOT_STARTED_YET),Ie.DHT_NOT_STARTED);const s=i.components.getDHT();null!=s&&(yield wa(s.put(e,t,r)))})()}get(e,t){var r=this;return V(function*(){if(!r.isStarted())throw se(new Error(Cn.NOT_STARTED_YET),Ie.DHT_NOT_STARTED);const i=r.components.getDHT();if(null!=i){var a,s=!1,o=!1;try{for(var m,c=Tt(i.get(e,t));s=!(m=yield c.next()).done;s=!1){const T=m.value;if("VALUE"===T.name)return T.value}}catch(T){o=!0,a=T}finally{try{s&&null!=c.return&&(yield c.return())}finally{if(o)throw a}}}throw se(new Error(Cn.NOT_FOUND),Ie.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return un(function*(){if(!i.isStarted())throw se(new Error(Cn.NOT_STARTED_YET),Ie.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.getDHT();if(null!=o){var m,a=!1,c=!1;try{for(var R,T=Tt(o.get(e,r));a=!(R=yield ct(T.next())).done;a=!1){const k=R.value;if("VALUE"===k.name&&(yield{from:k.from,val:k.value},s++,s===t))break}}catch(k){c=!0,m=k}finally{try{a&&null!=T.return&&(yield ct(T.return()))}finally{if(c)throw m}}}if(0===s)throw se(new Error(Cn.NOT_FOUND),Ie.ERR_NOT_FOUND)})()}}function _f(n){if(DT(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=new vn(n)),vn.isMultiaddr(n)&&(e=n,n=function TH(n){const e=n.getPeerId();if(null==e)throw se(new Error(`${n.toString()} does not have a valid peer type`),Ie.ERR_INVALID_MULTIADDR);try{return _r(e)}catch{throw se(new Error(`${n.toString()} is not a valid peer type`),Ie.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const AH=n=>n;class xH extends ki{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??AH}getListenAddrs(){return Array.from(this.listen).map(e=>new vn(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new vn(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new vn(e))}addObservedAddr(e){let t=new vn(e);const r=t.getPeerId();null!=r&&_r(r).equals(this.components.getPeerId())&&(t=t.decapsulate(new vn(`/p2p/${this.components.getPeerId().toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new rn("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 vn(r))).map(r=>r.getPeerId()===this.components.getPeerId().toString()?r:r.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}}const Df=N(7820),HA=Gt("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class PH extends ki{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"?HA("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];HA(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new rn("visibilityChange",{detail:e}))}}const Uo=Gt("libp2p:connection-manager:latency-monitor");class NH extends ki{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,Uo("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?Uo("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):Uo("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(Uo("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?(Uo("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(Uo("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function MH(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new PH,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 rn("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(),Uo.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,Uo.trace("MS: %s Data: %O",i,this.latencyData)};Uo.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 Sf=N(2502);const jA="CLOSING",gE="CLOSED";var OH=N(8614);const $A=Gt("libp2p:dialer:dial-request");class LH{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 V(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw se(new Error("No dial tokens available"),Ie.ERR_NO_DIAL_TOKENS);const i=new OH;for(const c of r)i.push(c).catch(m=>{$A.error(m)});const s=t.addrs.map(()=>{const c=new AbortController;try{(0,Jr.setMaxListeners)?.(1/0,c.signal)}catch{}return c});if(null!=e.signal)try{(0,Jr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var c=V(function*(m,T){const R=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(R),1)[0]),se(new Error("dialAction already succeeded"),Ie.ERR_ALREADY_SUCCEEDED);const k=s[T];if(null==k)throw se(new Error("dialAction did not come with an AbortController"),Ie.ERR_INVALID_PARAMETERS);let U;try{const Q=k.signal;U=yield t.dialAction(m,{...e,signal:null!=e.signal?(0,ip.anySignal)([Q,e.signal]):Q}),s[T]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(R).catch(Q=>{$A.error(Q)}):t.dialer.releaseToken(r.splice(r.indexOf(R),1)[0])}if(null==U)throw se(new Error("dialAction led to empty object"),Ie.ERR_TRANSPORT_DIAL_FAILED);return a=!0,U});return function(m,T){return c.apply(this,arguments)}}()))}finally{s.forEach(c=>{void 0!==c&&c.abort()}),r.forEach(c=>t.dialer.releaseToken(c))}})()}}var GA=N(4108);function zA(n){const{address:e}=n.nodeAddress();return Boolean(GA(e))}function yE(n,e){const t=zA(n.multiaddr),r=zA(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}var mE=N(4297);const js=Gt("libp2p:dialer"),YA="dialler";class HH{constructor(e={}){this.components=new ko,this.started=!1,this.addressSorter=e.addressSorter??yE,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=Ef({component:YA,metric:"pending-dials",metrics:e.metrics}),this.pendingDialTargets=Ef({component:YA,metric:"pending-dial-targets",metrics:e.metrics});for(const[t,r]of Object.entries(e.resolvers??{}))vn.resolvers.set(t,r)}init(e){this.components=e}isStarted(){return this.started}start(){var e=this;return V(function*(){e.started=!0})()}stop(){var e=this;return V(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){js.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 V(function*(){const{id:i,multiaddrs:s}=_f(e);if(r.components.getPeerId().equals(i))throw se(new Error("Tried to dial self"),Ie.ERR_DIALED_SELF);if(js("check multiaddrs %p",i),null!=s&&s.length>0&&(js("storing multiaddrs %p",i,s),yield r.components.getPeerStore().addressBook.add(i,s)),yield r.components.getConnectionGater().denyDialPeer(i))throw se(new Error("The dial request is blocked by gater.allowDialPeer"),Ie.ERR_PEER_DIAL_INTERCEPTED);js("creating dial target for %p",i);const o=yield r._createCancellableDialTarget(i,t);if(0===o.addrs.length)throw se(new Error("The dial request has no valid addresses"),Ie.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const c=yield a.promise;return js("dial succeeded to %s",o.id),c}catch(c){throw js("dial failed to %s",o.id,c),a.controller.signal.aborted&&(c.code=Ie.ERR_TIMEOUT),js.error(c),c}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return V(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 V(function*(){const i=yield Ln(yield r.components.getPeerStore().addressBook.get(e),a=>Ks(a,function(){var c=V(function*(m){return!(yield r.components.getConnectionGater().denyDialMultiaddr(e,m.multiaddr))});return function(m){return c.apply(this,arguments)}}()),a=>mE(a,r.addressSorter),a=>fE(a,c=>{const m=c.multiaddr;return e.toString()===m.getPeerId()?m:m.encapsulate(`/p2p/${e.toString()}`)}),function(){var a=V(function*(c){return yield Ea(c)});return function(c){return a.apply(this,arguments)}}()),s=[];for(const a of i)(yield r._resolve(a,t)).forEach(m=>s.push(m));const o=s.filter(a=>r.components.getTransportManager().transportForMultiaddr(a));if(o.length>r.maxAddrsToDial)throw yield r.components.getPeerStore().delete(e),se(new Error("dial with more addresses than allowed"),Ie.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:o}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var T=V(function*(R,k={}){if(!0===k.signal?.aborted)throw se(new Error("already aborted"),Ie.ERR_ALREADY_ABORTED);return yield r.components.getTransportManager().dial(R,k).catch(U=>{throw js.error("dial to %s failed",R,U),U})});return function(k){return T.apply(this,arguments)}}(),s=new LH({addrs:e.addrs,dialAction:i,dialer:this}),o=new Bi.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const c=(0,ip.anySignal)(a);try{(0,Jr.setMaxListeners)?.(1/0,c)}catch{}const m={dialRequest:s,controller:o,promise:s.run({...t,signal:c}),destroy:()=>{o.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,m),m}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return js("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(js("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return V(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var c=V(function*(m){return yield r._resolve(m,t)});return function(m){return c.apply(this,arguments)}}()))).flat().reduce((c,m)=>(null==c.find(T=>T.equals(m))&&c.push(m),c),[])})()}_resolveRecord(e,t){return V(function*(){try{return e=new vn(e.toString()),yield e.resolve(t)}catch(r){return js.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}const gi=Gt("libp2p:connection-manager"),jH={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},vE="libp2p",EE="connection-manager";class GH extends ki{constructor(e){if(super(),this.components=new ko,this.opts=Df.call({ignoreUndefined:!0},jH,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:vE,component:EE,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:vE,component:EE,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 c=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[c]=(o[c]??0)+1}for(const[a,c]of Object.entries(o))t[a]=t[a]??[],t[a].push(c)}const r={};for(let[i,s]of Object.entries(t)){s=s.sort((a,c)=>a-c);const o=Math.floor(.9*s.length);r[i]=s[o]}return r}})}isStarted(){return this.started}start(){var e=this;return V(function*(){null!=e.components.getMetrics()&&(e.timer=e.timer??Sf(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,gi("started")})()}afterStart(){var e=this;return V(function*(){e.components.getUpgrader().addEventListener("connection",e.onConnect),e.components.getUpgrader().addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then(V(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,Jr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=V(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{gi.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{gi.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return V(function*(){e.connectOnStartupController?.abort(),e.components.getUpgrader().removeEventListener("connection",e.onConnect),e.components.getUpgrader().removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return V(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),yield e.dialer.stop(),e.started=!1,yield e._close(),gi("stopped")})()}_close(){var e=this;return V(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push(V(function*(){try{yield i.close()}catch(s){gi.error(s)}})());gi("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return V(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),gi.trace("metrics update",o)}finally{e.timer=Sf(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{gi.error(t)})}_onConnect(e){var t=this;return V(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,c=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,c),t.dispatchEvent(new rn("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 rn("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 V(function*(){gi("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return gi("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,Jr.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 c=!1;for(const m of a)m.id===o.id&&(c=!0);return c||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return V(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=V(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!DT(e))throw se(new Error("peerId must be an instance of peer-id"),Ie.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=>{gi.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return V(function*(){const s=i.opts[e];gi.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(gi("%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 V(function*(){const r=t.getConnections();if(r.length<=t.opts.minConnections||e<1)return;const i=new $T;for(const a of r){const c=a.remotePeer;if(i.has(c))continue;const m=yield t.components.getPeerStore().getTags(c);i.set(c,m.reduce((T,R)=>T+R.value,0))}const s=r.sort((a,c)=>{const m=i.get(a.remotePeer)??0,T=i.get(c.remotePeer)??0;return m>T?1:m{ba.error("could start autodial",t)}),ba("started")):ba("not enabled")})()}stop(){var e=this;return V(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),ba("stopped")):ba("not enabled")})()}_autoDial(){var e=this;return V(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.getConnectionManager().getConnections().length>=t)return void(e.autoDialTimeout=Sf(e._autoDial,e.options.autoDialInterval));const r=yield e.components.getPeerStore().all(),i=yield Ln(r.sort(()=>Math.random()>.5?1:-1),s=>Ks(s,o=>!o.id.equals(e.components.getPeerId())),s=>mE(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=V(function*(o){return yield Ea(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sNh(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=()=>Nh(i)}(r=n.Type||(n.Type={})),function(a){let c;a.codec=()=>(null==c&&(c=fi((m,T,R={})=>{if(!1!==R.lengthDelimited&&T.fork(),null==m.id)throw new Error('Protocol error: required field "id" was not found in object');if(T.uint32(10),T.bytes(m.id),null==m.addrs)throw new Error('Protocol error: required field "addrs" was not found in object');for(const k of m.addrs)T.uint32(18),T.bytes(k);!1!==R.lengthDelimited&&T.ldelim()},(m,T)=>{const R={},k=null==T?m.len:m.pos+T;for(;m.pos>>3){case 1:R.id=m.bytes();break;case 2:R.addrs=R.addrs??[],R.addrs.push(m.bytes());break;default:m.skipType(7&U)}}if(R.addrs=R.addrs??[],null==R.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(null==R.addrs)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return R})),c),a.encode=m=>li(m,a.codec()),a.decode=m=>ui(m,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=fi((a,c,m={})=>{!1!==m.lengthDelimited&&c.fork(),null!=a.type&&(c.uint32(8),n.Type.codec().encode(a.type,c)),null!=a.srcPeer&&(c.uint32(18),n.Peer.codec().encode(a.srcPeer,c)),null!=a.dstPeer&&(c.uint32(26),n.Peer.codec().encode(a.dstPeer,c)),null!=a.code&&(c.uint32(32),n.Status.codec().encode(a.code,c)),!1!==m.lengthDelimited&&c.ldelim()},(a,c)=>{const m={},T=null==c?a.len:a.pos+c;for(;a.pos>>3){case 1:m.type=n.Type.codec().decode(a);break;case 2:m.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:m.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:m.code=n.Status.codec().decode(a);break;default:a.skipType(7&R)}}return m})),o),n.encode=a=>li(a,n.codec()),n.decode=a=>ui(a,n.codec())}(sn||(sn={}));const qH=Gt("libp2p:stream:converter");function ZA(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=un(function*(){var k,T=!1,R=!1;try{for(var Q,U=Tt(s);T=!(Q=yield ct(U.next())).done;T=!1){const X=Q.value;yield*jr(Tt(X),ct)}}catch(X){R=!0,k=X}finally{try{T&&null!=U.return&&(yield ct(U.return()))}finally{if(R)throw k}}})(),a={sink:T=>V(function*(){null!=e.signal&&(T=Fs(T,e.signal));try{yield i(T),yield c()}catch(R){"aborted"!==R.type&&qH(R)}})(),source:null!=e.signal?Fs(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>V(function*(){yield i(un(function*(){yield new Uint8Array(0)})()),yield c()})()};function c(){return m.apply(this,arguments)}function m(){return(m=V(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const If="/libp2p/circuit/relay/0.1.0";function XA(n,e){n.write({type:sn.Type.STATUS,code:e})}function JA(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>new vn(t))}catch(t){throw XA(e,n.type===sn.Type.HOP?sn.Status.HOP_DST_MULTIADDR_INVALID:sn.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>new vn(t))}catch(t){throw XA(e,n.type===sn.Type.HOP?sn.Status.HOP_SRC_MULTIADDR_INVALID:sn.Status.STOP_SRC_MULTIADDR_INVALID),t}}const Cf=Gt("libp2p:circuit:stream-handler");class gp{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=Ch(this.stream),this.decoder=Ms.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return V(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=sn.decode(t.value);return Cf("read message type",r.type),r}Cf("read received no value, closing stream"),e.close()})()}write(e){Cf("write message type %s",e.type),this.shake.write(to.single(sn.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Cf("closing the stream"),this.rest().sink([]).catch(e=>{Cf.error(e)})}}const Tf=Gt("libp2p:circuit:stop");function ZH(n){return wE.apply(this,arguments)}function wE(){return wE=V(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(If,{signal:r});Tf("starting stop request to %p",e.remotePeer);const s=new gp({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===sn.Status.SUCCESS?(Tf("stop request to %p was successful",e.remotePeer),s.rest()):(Tf("stop request failed with code %d",o.code),void s.close());s.close()}),wE.apply(this,arguments)}const ps=Gt("libp2p:circuit:hop");function bE(){return bE=V(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return ps("HOP request received but we are not acting as a relay"),r.end({type:sn.Type.STATUS,code:sn.Status.HOP_CANT_SPEAK_RELAY});try{JA(t,r)}catch(R){return void ps.error("invalid hop request via peer %p %o",e.remotePeer,R)}if(null==t.dstPeer)return void ps("HOP request received but we do not receive a dstPeer");const o=pa(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return ps("HOP request received but we are not connected to the destination peer"),r.end({type:sn.Type.STATUS,code:sn.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return ps("did not have connection to remote peer"),r.end({type:sn.Type.STATUS,code:sn.Status.HOP_NO_CONN_TO_DST});const c={type:sn.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let m;try{ps("performing STOP request");const R=yield ZH({connection:a[0],request:c});if(null==R)throw new Error("Could not stop");m=R}catch(R){return void ps.error(R)}ps("hop request from %p is valid",e.remotePeer),r.write({type:sn.Type.STATUS,code:sn.Status.SUCCESS});const T=r.rest();return ps("creating related connections"),yield Ln(T,m,T)}),bE.apply(this,arguments)}function _E(){return _E=V(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(If,{signal:r}),s=new gp({stream:i});s.write(t);const o=yield s.read();if(null==o)throw se(new Error("HOP request had no response"),Ie.ERR_HOP_REQUEST_FAILED);if(o.code===sn.Status.SUCCESS)return ps("hop request was successful"),s.rest();throw ps("hop request failed with code %d, closing stream",o.code),s.close(),se(new Error(`HOP request failed with code "${o.code??"unknown"}"`),Ie.ERR_HOP_REQUEST_FAILED)}),_E.apply(this,arguments)}function DE(){return DE=V(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream(If,{signal:t}),i=new gp({stream:r});i.write({type:sn.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==sn.Status.SUCCESS)}),DE.apply(this,arguments)}const gs=Gt("libp2p:circuit");class nK{constructor(e){this.components=new ko,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle(If,t=>{this._onProtocol(t).catch(r=>{gs.error(r)})}).catch(t=>{gs.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[lE](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return V(function*(){const{connection:r,stream:i}=e,s=new Bi.TimeoutController(t._init.hop.timeout);try{(0,Jr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=ga(i,s.signal),a=new gp({stream:{...i,...o}}),c=yield a.read();if(null==c)return gs("request was invalid, could not read from stream"),a.write({type:sn.Type.STATUS,code:sn.Status.MALFORMED_MESSAGE}),void a.close();let m;switch(c.type){case sn.Type.CAN_HOP:gs("received CAN_HOP request from %p",r.remotePeer),yield function tK(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();ps("can hop (%s) request from %p",i,e.remotePeer),t.end({type:sn.Type.STATUS,code:i?sn.Status.SUCCESS:sn.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case sn.Type.HOP:gs("received HOP request from %p",r.remotePeer),yield function XH(n){return bE.apply(this,arguments)}({connection:r,request:c,streamHandler:a,circuit:t,connectionManager:t.components.getConnectionManager()});break;case sn.Type.STOP:gs("received STOP request from %p",r.remotePeer),m=yield function YH(n){const{connection:e,request:t,streamHandler:r}=n;try{JA(t,r)}catch(i){return void Tf.error("invalid stop request via peer %p %o",e.remotePeer,i)}return Tf("stop request is valid"),r.write({type:sn.Type.STATUS,code:sn.Status.SUCCESS}),r.rest()}({connection:r,request:c,streamHandler:a});break;default:return gs("Request of type %s not supported",c.type),a.write({type:sn.Type.STATUS,code:sn.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=m){const k=ZA({stream:m,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(new vn(c.dstPeer?.addrs[0])),localAddr:new vn(c.srcPeer?.addrs[0])}),U=c.type===sn.Type.HOP?"relay":"inbound";gs("new %s connection %s",U,k.remoteAddr);const Q=yield t.components.getUpgrader().upgradeInbound(k);gs("%s connection %s upgraded",U,k.remoteAddr),null!=t.handler&&t.handler(Q)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return V(function*(){const i=e.toString().split("/p2p-circuit"),s=new vn(i[0]),o=new vn(i[i.length-1]),a=s.getPeerId(),c=o.getPeerId();if(null==a||null==c){const Q="Circuit relay dial failed as addresses did not have peer id";throw gs.error(Q),se(new Error(Q),Ie.ERR_RELAYED_DIAL)}const m=_r(a),T=_r(c);let R=!1,U=r.components.getConnectionManager().getConnections(m)[0];null==U&&(yield r.components.getPeerStore().addressBook.add(m,[s]),U=yield r.components.getConnectionManager().openConnection(m,t),R=!0);try{const Q=yield function JH(n){return _E.apply(this,arguments)}({...t,connection:U,request:{type:sn.Type.HOP,srcPeer:{id:r.components.getPeerId().toBytes(),addrs:r.components.getAddressManager().getAddresses().map(he=>he.bytes)},dstPeer:{id:T.toBytes(),addrs:[new vn(o).bytes]}}}),X=s.encapsulate(`/p2p-circuit/p2p/${r.components.getPeerId().toString()}`),ae=ZA({stream:Q,remoteAddr:e,localAddr:X});return gs("new outbound connection %s",ae.remoteAddr),yield r.components.getUpgrader().upgradeOutbound(ae)}catch(Q){throw gs.error("Circuit relay dial failed",Q),R&&(yield U.close()),Q}})()}createListener(e){return this.handler=e.handler,function QH(n){const e=new Map;function r(){return(r=V(function*(o){const a=o.toString().split("/p2p-circuit").find(U=>""!==U),c=new vn(a),m=c.getPeerId();if(null==m)throw new Error("Could not determine relay peer from multiaddr");const T=_r(m);yield n.peerStore.addressBook.add(T,[c]);const R=yield n.connectionManager.openConnection(T),k=R.remoteAddr.encapsulate("/p2p-circuit");e.set(R.remotePeer.toString(),k),s.dispatchEvent(new rn("listening"))})).apply(this,arguments)}const s=Object.assign(new ki,{close:(o=V(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 rn("close"))}),s}({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>Ou.matches(t))}}function ex(n){return SE.apply(this,arguments)}function SE(){return SE=V(function*(n){const e=(new TextEncoder).encode(n),t=yield Li.digest(e);return Rr.createV0(t)}),SE.apply(this,arguments)}const nx="hop_relay",ix="/libp2p/relay",Af=Gt("libp2p:auto-relay"),oK=()=>{};class aK{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??yE,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??oK,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{Af.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return V(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===If)){if(!t.listenRelays.has(s))try{const a=t.components.getConnectionManager().getConnections(r);if(0===a.length)return;const c=a[0];if(c.remoteAddr.protoCodes().includes(290))return void Af(`relayed connection to ${s} will not be used to hop on`);(yield function eK(n){return DE.apply(this,arguments)}({connection:c}))&&(yield t.components.getPeerStore().metadataBook.setValue(r,nx,_t("true")),yield t._addListenRelay(c,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=>{Af.error(s)})}_addListenRelay(e,t){var r=this;return V(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield Ln(yield r.components.getPeerStore().addressBook.get(e.remotePeer),o=>mE(o,r.addressSorter),function(){var o=V(function*(a){return yield Ea(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=V(function*(a){try{let c=a.multiaddr;return null==c.getPeerId()&&(c=c.encapsulate(`/p2p/${e.remotePeer.toString()}`)),c=c.encapsulate("/p2p-circuit"),yield r.components.getTransportManager().listen([c]),!0}catch(c){Af.error("error listening on circuit address",c),r.onError(c)}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 V(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return V(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.getPeerStore().all();for(const{id:T,metadata:R}of i){const k=T.toString();if(t.listenRelays.has(k)||e.includes(k))continue;const U=R.get(nx);if(null==U||"true"!==Mt(U))continue;const Q=t.components.getConnectionManager().getConnections(T);if(0!==Q.length){if(yield t._addListenRelay(Q[0],k),t.listenRelays.size>=t.maxListeners)return}else r.push(T)}for(const T of r)if(yield t._tryToListenOnRelay(T),t.listenRelays.size>=t.maxListeners)return;try{const T=yield ex(ix);var a,s=!1,o=!1;try{for(var m,c=Tt(t.components.getContentRouting().findProviders(T));s=!(m=yield c.next()).done;s=!1){const R=m.value;if(0===R.multiaddrs.length)continue;const k=R.id;if(!k.equals(t.components.getPeerId())&&(yield t.components.getPeerStore().addressBook.add(k,R.multiaddrs),yield t._tryToListenOnRelay(k),t.listenRelays.size>=t.maxListeners))return}}catch(R){o=!0,a=R}finally{try{s&&null!=c.return&&(yield c.return())}finally{if(o)throw a}}}catch(T){t.onError(T)}})()}_tryToListenOnRelay(e){var t=this;return V(function*(){try{const r=yield t.components.getConnectionManager().openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){Af.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const sx=Gt("libp2p:relay");class cK{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new aK(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 V(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,pp.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return V(function*(){null!=e.timeout&&(0,pp.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return V(function*(){try{const t=yield ex(ix);yield e.components.getContentRouting().provide(t)}catch(t){t.code===Ie.ERR_NO_ROUTERS_AVAILABLE?(sx.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):sx.error(t)}})()}}var uK=N(9014);N(422),N(5911);const ox=Gn.pki;function IE(){return IE=V(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),IE.apply(this,arguments)}const dK=Gt("libp2p:keychain:cms"),CE=new WeakMap;class hK{constructor(e,t){if(null==e)throw se(new Error("keychain is required"),Ie.ERR_KEYCHAIN_REQUIRED);this.keychain=e,CE.set(this,{dek:t})}encrypt(e,t){var r=this;return V(function*(){if(!(t instanceof Uint8Array))throw se(new Error("Plain data must be a Uint8Array"),Ie.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=CE.get(r);if(null==o)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const c=Gn.pki.decryptRsaPrivateKey(s,o.dek),m=yield((n,e)=>{const t=ox.rsa.setPublicKey(e.n,e.e),r=ox.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,c),T=Gn.pkcs7.createEnvelopedData();return T.addRecipient(m),T.content=Gn.util.createBuffer(t),T.encrypt(),_t(Gn.asn1.toDer(T.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return V(function*(){if(!(e instanceof Uint8Array))throw se(new Error("CMS data is required"),Ie.ERR_INVALID_PARAMETERS);let r;try{const R=Gn.util.createBuffer(Mt(e,"ascii")),k=Gn.asn1.fromDer(R);r=Gn.pkcs7.messageFromAsn1(k)}catch(R){throw dK.error(R),se(new Error("Invalid CMS"),Ie.ERR_INVALID_CMS)}const i=r.recipients.filter(R=>R.issuer.find(k=>"O"===k.shortName&&"ipfs"===k.value)).filter(R=>R.issuer.find(k=>"CN"===k.shortName)).map(R=>({recipient:R,keyId:R.issuer.find(k=>"CN"===k.shortName).value})),s=yield function fK(n,e){return IE.apply(this,arguments)}(i,function(){var R=V(function*(k){try{if(null!=(yield t.keychain.findKeyById(k.keyId)))return!0}catch{return!1}return!1});return function(k){return R.apply(this,arguments)}}());if(null==s){const R=i.map(k=>k.keyId);throw se(new Error(`Decryption needs one of the key(s): ${R.join(", ")}`),Ie.ERR_MISSING_KEYS,{missingKeys:R})}const o=yield t.keychain.findKeyById(s.keyId);if(null==o)throw se(new Error("No key available to decrypto"),Ie.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),c=CE.get(t);if(null==c)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const T=Gn.pki.decryptRsaPrivateKey(a,c.dek);return r.decrypt(s.recipient,T),_t(r.content.getBytes(),"ascii")})()}}N(1298);var pK=N(7949);const cx={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function ux(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(cx).join(" / ");throw se(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=pK(n,e,t,r,cx[i]);return wU.encode64(o,null)}const yp=Gt("libp2p:keychain"),_a=new WeakMap,AE={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function Vo(n){return null!=n&&"string"==typeof n&&n===uK(n.trim())&&n.length>0}function Hn(){return xE.apply(this,arguments)}function xE(){return(xE=V(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function oo(n){return new Xr("/pkcs8/"+n)}function Ho(n){return new Xr("/info/"+n)}class fx{constructor(e,t){if(this.components=e,this.init=Df(AE,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?ux(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";_a.set(this,{dek:r}),this.started=!1}isStarted(){return this.started}start(){var e=this;return V(function*(){const t=Ho("self");(yield e.components.getDatastore().has(t))||(yield e.importPeer("self",e.components.getPeerId())),e.started=!0})()}stop(){this.started=!1}get cms(){const e=_a.get(this);if(null==e)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);return new hK(this,e.dek)}static generateOptions(){const e=Object.assign({},AE),t=3*Math.ceil(16/3);return e.dek.salt=Mt(sf(t),"base64"),e}static get options(){return AE}createKey(e,t,r=2048){var i=this;return V(function*(){if(!Vo(e)||"self"===e)throw yield Hn(),se(new Error("Invalid key name"),Ie.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield Hn(),se(new Error("Invalid key type"),Ie.ERR_INVALID_KEY_TYPE);const s=oo(e);if(yield i.components.getDatastore().has(s))throw yield Hn(),se(new Error("Key name already exists"),Ie.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield Hn(),se(new Error("Invalid RSA key size"),Ie.ERR_INVALID_KEY_SIZE);let a;try{const c=yield bT(t,r),m=yield c.id(),T=_a.get(i);if(null==T)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const R=T.dek,k=yield c.export(R);a={name:e,id:m};const U=i.components.getDatastore().batch();U.put(s,_t(k)),U.put(Ho(e),_t(JSON.stringify(a))),yield U.commit()}catch(c){throw yield Hn(),c}return a})()}listKeys(){var e=this;return V(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var c,a=Tt(e.components.getDatastore().query(t));i=!(c=yield a.next()).done;i=!1)r.push(JSON.parse(Mt(c.value.value)))}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return V(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield Hn(),r}})()}findKeyByName(e){var t=this;return V(function*(){if(!Vo(e))throw yield Hn(),se(new Error(`Invalid key name '${e}'`),Ie.ERR_INVALID_KEY_NAME);const r=Ho(e);try{const i=yield t.components.getDatastore().get(r);return JSON.parse(Mt(i))}catch(i){throw yield Hn(),yp.error(i),se(new Error(`Key '${e}' does not exist.`),Ie.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return V(function*(){if(!Vo(e)||"self"===e)throw yield Hn(),se(new Error(`Invalid key name '${e}'`),Ie.ERR_INVALID_KEY_NAME);const r=oo(e),i=yield t.findKeyByName(e),s=t.components.getDatastore().batch();return s.delete(r),s.delete(Ho(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return V(function*(){if(!Vo(e)||"self"===e)throw yield Hn(),se(new Error(`Invalid old key name '${e}'`),Ie.ERR_OLD_KEY_NAME_INVALID);if(!Vo(t)||"self"===t)throw yield Hn(),se(new Error(`Invalid new key name '${t}'`),Ie.ERR_NEW_KEY_NAME_INVALID);const i=oo(e),s=oo(t),o=Ho(e),a=Ho(t);if(yield r.components.getDatastore().has(s))throw yield Hn(),se(new Error(`Key '${t}' already exists`),Ie.ERR_KEY_ALREADY_EXISTS);try{const m=yield r.components.getDatastore().get(i),T=yield r.components.getDatastore().get(o),R=JSON.parse(Mt(T));R.name=t;const k=r.components.getDatastore().batch();return k.put(s,m),k.put(a,_t(JSON.stringify(R))),k.delete(i),k.delete(o),yield k.commit(),R}catch(m){throw yield Hn(),m}})()}exportKey(e,t){var r=this;return V(function*(){if(!Vo(e))throw yield Hn(),se(new Error(`Invalid key name '${e}'`),Ie.ERR_INVALID_KEY_NAME);if(null==t)throw yield Hn(),se(new Error("Password is required"),Ie.ERR_PASSWORD_REQUIRED);const i=oo(e);try{const o=Mt(yield r.components.getDatastore().get(i)),a=_a.get(r);if(null==a)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const c=a.dek;return yield(yield Rv(o,c)).export(t)}catch(s){throw yield Hn(),s}})()}importKey(e,t,r){var i=this;return V(function*(){if(!Vo(e)||"self"===e)throw yield Hn(),se(new Error(`Invalid key name '${e}'`),Ie.ERR_INVALID_KEY_NAME);if(null==t)throw yield Hn(),se(new Error("PEM encoded key is required"),Ie.ERR_PEM_REQUIRED);const s=oo(e);if(yield i.components.getDatastore().has(s))throw yield Hn(),se(new Error(`Key '${e}' already exists`),Ie.ERR_KEY_ALREADY_EXISTS);let a,c;try{a=yield Rv(t,r)}catch{throw yield Hn(),se(new Error("Cannot read the key, most likely the password is wrong"),Ie.ERR_CANNOT_READ_KEY)}try{c=yield a.id();const R=_a.get(i);if(null==R)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const k=R.dek;t=yield a.export(k)}catch(R){throw yield Hn(),R}const m={name:e,id:c},T=i.components.getDatastore().batch();return T.put(s,_t(t)),T.put(Ho(e),_t(JSON.stringify(m))),yield T.commit(),m})()}importPeer(e,t){var r=this;return V(function*(){try{if(!Vo(e))throw se(new Error(`Invalid key name '${e}'`),Ie.ERR_INVALID_KEY_NAME);if(null==t)throw se(new Error("PeerId is required"),Ie.ERR_MISSING_PRIVATE_KEY);if(null==t.privateKey)throw se(new Error("PeerId.privKey is required"),Ie.ERR_MISSING_PRIVATE_KEY);const i=yield Au(t.privateKey),s=oo(e);if(yield r.components.getDatastore().has(s))throw yield Hn(),se(new Error(`Key '${e}' already exists`),Ie.ERR_KEY_ALREADY_EXISTS);const a=_a.get(r);if(null==a)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const c=a.dek,m=yield i.export(c),T={name:e,id:t.toString()},R=r.components.getDatastore().batch();return R.put(s,_t(m)),R.put(Ho(e),_t(JSON.stringify(T))),yield R.commit(),T}catch(i){throw yield Hn(),i}})()}getPrivateKey(e){var t=this;return V(function*(){if(!Vo(e))throw yield Hn(),se(new Error(`Invalid key name '${e}'`),Ie.ERR_INVALID_KEY_NAME);try{const r=oo(e);return Mt(yield t.components.getDatastore().get(r))}catch(r){throw yield Hn(),yp.error(r),se(new Error(`Key '${e}' does not exist.`),Ie.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return V(function*(){if("string"!=typeof e)throw yield Hn(),se(new Error(`Invalid old pass type '${typeof e}'`),Ie.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield Hn(),se(new Error(`Invalid new pass type '${typeof t}'`),Ie.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield Hn(),se(new Error(`Invalid pass length ${t.length}`),Ie.ERR_INVALID_PASS_LENGTH);yp("recreating keychain");const i=_a.get(r);if(null==i)throw se(new Error("dek missing"),Ie.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?ux(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";_a.set(r,{dek:o});const a=yield r.listKeys();for(const c of a){const T=Mt(yield r.components.getDatastore().get(oo(c.name))),R=yield Rv(T,s),k=o.toString(),U=yield R.export(k),Q=r.components.getDatastore().batch(),X={name:c.name,id:c.id};Q.put(oo(c.name),_t(U)),Q.put(Ho(c.name),_t(JSON.stringify(X))),yield Q.commit()}yp("keychain reconstructed")})()}}var RE=N(1349),yK=N(5550);class mK{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 dx(n){return new mK(n)}class PE extends ki{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=Sf(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 rn("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 c=this.movingAverageIntervals;for(let m=0;ms: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=EK[i];let a=this.forPeer(t);if(null==a){const c=new PE(this.statsInit);this.peerStats.set(t.toString(),c),a=c}if(a.push(o,s),this.globalStats.push(o,s),null!=r){let c=this.forProtocol(r);if(null==c){const m=new PE(this.statsInit);this.protocolStats.set(r,m),c=m}c.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 bK(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=RE(r.source,c=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:c.byteLength}));const a=r.sink;r.sink=function(){var c=V(function*(m){return yield Ln(m,T=>RE(T,R=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:R.byteLength})}),a)});return function(m){return c.apply(this,arguments)}}()}}function NE(n){return ME.apply(this,arguments)}function ME(){return ME=V(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),ME.apply(this,arguments)}function OE(n,e,t){(function _K(n,e){if(e.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object")})(n,e),e.set(n,t)}function hx(n,e,t){if(!e.has(n))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(n)}function Ko(n,e,t){return function DK(n,e,t){if(e.set)e.set.call(n,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}(n,hx(n,e,"set"),t),t}function Da(n,e){return function SK(n,e){return e.get?e.get.call(n):e.value}(n,hx(n,e,"get"))}function px(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let gx;class IK{constructor(e){px(this,"value",void 0),px(this,"next",void 0),this.value=e}}var Sa=new WeakMap,xf=new WeakMap,ic=new WeakMap;gx=Symbol.iterator;class CK{constructor(){OE(this,Sa,{writable:!0,value:void 0}),OE(this,xf,{writable:!0,value:void 0}),OE(this,ic,{writable:!0,value:void 0}),this.clear()}enqueue(e){var t;const i=new IK(e);Da(this,Sa)?(Da(this,xf).next=i,Ko(this,xf,i)):(Ko(this,Sa,i),Ko(this,xf,i)),Ko(this,ic,(t=Da(this,ic),++t))}dequeue(){var e;const r=Da(this,Sa);if(r)return Ko(this,Sa,Da(this,Sa).next),Ko(this,ic,(e=Da(this,ic),--e)),r.value}clear(){Ko(this,Sa,void 0),Ko(this,xf,void 0),Ko(this,ic,0)}get size(){return Da(this,ic)}*[gx](){let e=Da(this,Sa);for(;e;)yield e.value,e=e.next}}function TK(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 CK;let t=0;const i=function(){var a=V(function*(c,m,T){t++;const R=V(function*(){return c(...T)})();m(R);try{yield R}catch{}t--,e.size>0&&e.dequeue()()});return function(m,T,R){return a.apply(this,arguments)}}(),o=(a,...c)=>new Promise(m=>{((a,c,m)=>{e.enqueue(i.bind(void 0,a,c,m)),V(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,m,c)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function AK(n){return LE.apply(this,arguments)}function LE(){return LE=V(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=TK(t);return Promise.all(n.map(i=>NE(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),LE.apply(this,arguments)}const sc=Gt("libp2p:transports");class xK extends ki{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=Ef({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??oc.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw se(new Error("Transport must have a valid tag"),Ie.ERR_INVALID_KEY);if(this.transports.has(t))throw se(new Error("There is already a transport with this tag"),Ie.ERR_DUPLICATE_TRANSPORT);sc("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 V(function*(){const t=e.components.getAddressManager().getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return V(function*(){const t=[];for(const[r,i]of e.listeners)for(sc("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),sc("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return V(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw se(new Error(`No transport available for address ${String(e)}`),Ie.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.getUpgrader()})}catch(s){throw null==s.code&&(s.code=Ie.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 V(function*(){if(null==e||0===e.length)return void sc("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 T of o){sc("creating listener for %s on %s",i,T);const R=s.createListener({upgrader:t.components.getUpgrader()});let k=t.listeners.get(i);null==k&&(k=[],t.listeners.set(i,k)),k.push(R),R.addEventListener("listening",()=>{t.dispatchEvent(new rn("listener:listening",{detail:R}))}),R.addEventListener("close",()=>{t.dispatchEvent(new rn("listener:close",{detail:R}))}),a.push(R.listen(T))}if(0!==a.length){if(null==(yield AK(a)).find(T=>T.isFulfilled)&&t.faultTolerance!==oc.NO_FATAL)throw se(new Error(`Transport (${i}) could not listen on any available address`),Ie.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===oc.FATAL_ALL)throw se(new Error(i),Ie.ERR_NO_VALID_ADDRESSES);sc(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return V(function*(){sc("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 V(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var oc=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(oc||(oc={})),oc))();const Lu="/multistream/1.0.0",yx=_t("\n");function kE(n){const e=new $n(n,yx);return to.single(e)}function Rf(n,e,t={}){const r=kE(e);n.push(!0===t.writeBytes?r.subarray():r)}function RK(n,e,t={}){const r=new $n;for(const i of e)r.append(kE(i));n.push(!0===t.writeBytes?r.subarray():r)}function PK(n,e){return BE.apply(this,arguments)}function BE(){return BE=V(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=V(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=Fs(r,e.signal));const o=yield Ln(i,Ms({onLength:a=>{t=a}}),function(){var a=V(function*(c){return yield nc(c)});return function(c){return a.apply(this,arguments)}}());if(null==o)throw se(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==yx[0])throw se(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),BE.apply(this,arguments)}function mp(n,e){return FE.apply(this,arguments)}function FE(){return FE=V(function*(n,e){return Mt((yield PK(n,e)).subarray())}),FE.apply(this,arguments)}const Pf=Gt("libp2p:mss:select");function UE(n,e){return VE.apply(this,arguments)}function VE(){return VE=V(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=Ch(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");Pf('select: write ["%s", "%s"]',Lu,a),RK(i,[_t(Lu),_t(a)],t);let T=yield mp(r,t);if(Pf('select: read "%s"',T),T===Lu&&(T=yield mp(r,t),Pf('select: read "%s"',T)),T===a)return s(),{stream:o,protocol:a};for(const R of e){Pf('select: write "%s"',R),Rf(i,_t(R),t);const k=yield mp(r,t);if(Pf('select: read "%s" for "%s"',k,R),k===R)return s(),{stream:o,protocol:R}}throw s(),se(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}),VE.apply(this,arguments)}const Nf=Gt("libp2p:mss:handle");function HE(n,e,t){return KE.apply(this,arguments)}function KE(){return KE=V(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=Ch(n);for(;;){const a=yield mp(i,t);if(Nf('read "%s"',a),a!==Lu){if(e.includes(a))return Rf(r,_t(a),t),Nf('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(Rf(r,_t("na"),t),Nf('respond with "na" for "%s"',a)):(Rf(r,new $n(...e.map(c=>kE(_t(c)))),t),Nf('respond with "%s" for %s',e,a))}else Nf('respond with "%s" for "%s"',Lu,a),Rf(r,_t(Lu),t)}}),KE.apply(this,arguments)}var mx=N(344);const vx=Symbol.for("@libp2p/connection"),NK=Gt("libp2p:connection");class MK{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[vx](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return V(function*(){if(r.stat.status===jA)throw se(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===gE)throw se(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 V(function*(){if(e.stat.status!==gE&&!e._closing){e.stat.status=jA;try{e.streams.forEach(t=>t.close())}catch(t){NK.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=gE}})()}}const jE=Symbol.for("@libp2p/topology"),Ex=Gt("libp2p:registrar");class kK{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 se(new Error(`No handler registered for protocol ${e}`),Ie.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 V(function*(){if(i.handlers.has(e))throw se(new Error(`Handler already registered for protocol ${e}`),Ie.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Df.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 V(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 V(function*(){if(!function LK(n){return null!=n&&Boolean(n[jE])}(t))throw Ex.error("topology must be an instance of interfaces/topology"),se(new Error("topology must be an instance of interfaces/topology"),Ie.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=>{Ex.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 c=this.topologies.get(a);if(null!=c)for(const m of c.values())m.onDisconnect(t)}for(const a of o){const c=this.topologies.get(a);if(null!=c)for(const m of c.values()){const T=this.components.getConnectionManager().getConnections(t)[0];null!=T&&m.onConnect(t,T)}}}}const Zn=Gt("libp2p:upgrader");function _x(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class UK extends ki{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 V(function*(){let r,i,s,o,a,c,m;const T=t.components.getMetrics(),R=new Bi.TimeoutController(t.inboundUpgradeTimeout);try{(0,Jr.setMaxListeners)?.(1/0,R.signal)}catch{}try{const k=ga(e,R.signal);if(e.source=k.source,e.sink=k.sink,yield t.components.getConnectionGater().denyInboundConnection(e))throw se(new Error("The multiaddr connection is blocked by gater.acceptConnection"),Ie.ERR_CONNECTION_INTERCEPTED);if(null!=T){({setTarget:c,proxy:m}=mx());const X=`${(1e9*Math.random()).toString(36)}${Date.now()}`;c({toString:()=>X}),T.trackStream({stream:e,remotePeer:m})}Zn("starting the inbound connection upgrade");let U=e;const Q=t.components.getConnectionProtector();null!=Q&&(Zn("protecting the inbound connection"),U=yield Q.protect(e));try{if(({conn:r,remotePeer:i,protocol:a}=yield t._encryptInbound(U)),yield t.components.getConnectionGater().denyInboundEncryptedConnection(i,{...U,...r}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ie.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const X=yield t._multiplexInbound({...U,...r},t.muxers);o=X.muxerFactory,s=X.stream}else s=r}catch(X){throw Zn.error("Failed to upgrade inbound connection",X),yield e.close(X),X}if(yield t.components.getConnectionGater().denyInboundUpgradedConnection(i,{...U,...r}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ie.ERR_CONNECTION_INTERCEPTED);return null!=T&&(T.updatePlaceholder(m,i),c(i)),Zn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{R.clear()}})()}upgradeOutbound(e){var t=this;return V(function*(){const r=e.remoteAddr.getPeerId();if(null==r)throw se(new Error("outbound connection must have a peer id"),Ie.ERR_INVALID_MULTIADDR);const i=_r(r);if(yield t.components.getConnectionGater().denyOutboundConnection(i,e))throw se(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),Ie.ERR_CONNECTION_INTERCEPTED);let s,o,a,c,m,T,R;const k=t.components.getMetrics();if(null!=k){({setTarget:T,proxy:R}=mx());const X=`${(1e9*Math.random()).toString(36)}${Date.now()}`;T({toB58String:()=>X}),k.trackStream({stream:e,remotePeer:R})}Zn("Starting the outbound connection upgrade");let U=e;const Q=t.components.getConnectionProtector();null!=Q&&(U=yield Q.protect(e));try{if(({conn:s,remotePeer:o,protocol:c}=yield t._encryptOutbound(U,i)),yield t.components.getConnectionGater().denyOutboundEncryptedConnection(o,{...U,...s}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ie.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const X=yield t._multiplexOutbound({...U,...s},t.muxers);m=X.muxerFactory,a=X.stream}else a=s}catch(X){throw Zn.error("Failed to upgrade outbound connection",X),yield e.close(X),X}if(yield t.components.getConnectionGater().denyOutboundUpgradedConnection(o,{...U,...s}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ie.ERR_CONNECTION_INTERCEPTED);return null!=k&&(k.updatePlaceholder(R,o),T(o)),Zn("Successfully upgraded outbound connection"),t._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:m,remotePeer:o})})()}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:i,maConn:s,upgradedConn:o,remotePeer:a,muxerFactory:c}=e;let m,T,R;null!=c&&(m=c.createStreamMuxer({direction:i,onIncomingStream:Q=>{null!=R&&Promise.resolve().then(V(function*(){const X=t.components.getRegistrar().getProtocols(),{stream:ae,protocol:he}=yield HE(Q,X);if(Zn("%s: incoming stream opened on %s",i,he),t.components.getMetrics()?.trackStream({stream:ae,remotePeer:a,protocol:he}),null==R)return;const ue=function BK(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==Ie.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(he,t.components.getRegistrar());_x(he,"inbound",R)!==ue?(Q.stat.protocol=he,t.components.getPeerStore().protoBook.add(a,[he]).catch(Le=>Zn.error(Le)),R.addStream(Q),t._onStream({connection:R,stream:{...Q,...ae},protocol:he})):Q.abort(se(new Error(`Too many inbound protocol streams for protocol "${he}" - limit ${ue}`),Ie.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(X=>{Zn.error(X),null==Q.stat.timeline.close&&Q.close()})},onStreamEnd:Q=>{R?.removeStream(Q.id)}}),hi(m)&&m.init(this.components),T=function(){var Q=V(function*(X,ae={}){if(null==m)throw se(new Error("Stream is not multiplexed"),Ie.ERR_MUXER_UNAVAILABLE);Zn("%s: starting new stream on %s",i,X);const he=m.newStream(),Ae=t.components.getMetrics();let ue;try{if(null==ae.signal){Zn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",X),ue=new Bi.TimeoutController(3e4),ae.signal=ue.signal;try{(0,Jr.setMaxListeners)?.(1/0,ue.signal)}catch{}}const{stream:Re,protocol:Le}=yield UE(he,X,ae);Ae?.trackStream({stream:Re,remotePeer:a,protocol:Le});const Fe=function FK(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==Ie.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}(Le,t.components.getRegistrar());if(_x(Le,"outbound",R)===Fe){const mt=se(new Error(`Too many outbound protocol streams for protocol "${Le}" - limit ${Fe}`),Ie.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw he.abort(mt),mt}return he.stat.protocol=Le,t.components.getPeerStore().protoBook.add(a,[Le]).catch(mt=>Zn.error(mt)),{...he,...Re,stat:{...he.stat,protocol:Le}}}catch(Re){throw Zn.error("could not create new stream",Re),null==he.stat.timeline.close&&he.close(),null!=Re.code?Re:se(Re,Ie.ERR_UNSUPPORTED_PROTOCOL)}finally{ue?.clear()}});return function(ae){return Q.apply(this,arguments)}}(),Ln(o,m,o).catch(Zn.error));const k=s.timeline;s.timeline=new Proxy(k,{set:(...Q)=>(null!=R&&"close"===Q[1]&&null!=Q[2]&&null==k.close&&V(function*(){try{"OPEN"===R.stat.status&&(yield R.close())}catch(X){Zn.error(X)}finally{t.dispatchEvent(new rn("connectionEnd",{detail:R}))}})().catch(X=>{Zn.error(X)}),Reflect.set(...Q))}),s.timeline.upgraded=Date.now();const U=()=>{throw se(new Error("connection is not multiplexed"),Ie.ERR_CONNECTION_NOT_MULTIPLEXED)};return R=function OK(n){return new MK(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:m?.protocol,encryption:r},newStream:T??U,getStreams:()=>null!=m?m.streams:U(),close:(Q=V(function*(){yield s.close(),m?.close()}),function(){return Q.apply(this,arguments)})}),this.dispatchEvent(new rn("connection",{detail:R})),R;var Q}_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 V(function*(){const r=Array.from(t.connectionEncryption.keys());Zn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield HE(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 se(i,Ie.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return V(function*(){const i=Array.from(r.connectionEncryption.keys());Zn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield UE(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 se(s,Ie.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return V(function*(){const r=Array.from(t.keys());Zn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield UE(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),se(i,Ie.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return V(function*(){const r=Array.from(t.keys());Zn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield HE(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw Zn.error("error multiplexing inbound stream",i),se(i,Ie.ERR_MUXER_UNAVAILABLE)}})()}}var ac;!function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(ac||(ac={}));var vp;!function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(vp||(vp={}));class Yi{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=vp.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return $r(this.marshal(),e.marshal())}validate(e){var t=this;return V(function*(){const r=Dx(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Tu(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}Yi.createFromProtobuf=function(){var n=V(function*(e){const t=vp.decode(e),r=yield xu(t.publicKey);return new Yi({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),Yi.seal=function(){var n=V(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=Dx(r,i,s),c=yield(yield Au(t.privateKey)).sign(o.subarray());return new Yi({peerId:t,payloadType:i,payload:s,signature:c})});return function(e,t){return n.apply(this,arguments)}}(),Yi.openAndCertify=function(){var n=V(function*(e,t){const r=yield Yi.createFromProtobuf(e);if(!(yield r.validate(t)))throw se(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 Dx=(n,e,t)=>{const r=_t(n),i=Qt.encode(r.byteLength),s=Qt.encode(e.length),o=Qt.encode(t.length);return new $n(i,r,s,e,o,t)};var Ep;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=fi((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)},c=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&m)}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=>li(s,r.codec()),r.decode=s=>ui(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=fi((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=>li(r,n.codec()),n.decode=r=>ui(r,n.codec())}(Ep||(Ep={}));const $K=Uint8Array.from([3,1]);let ku=(()=>{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=Ep.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 KK(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=Ep.decode(e),r=pa(t.peerId),i=(t.addresses??[]).map(o=>new vn(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=$K,n})();const Ix="js-libp2p/0.0.0",Wn=Gt("libp2p:identify");class $E{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(Wn.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Wn.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Wn.error(s))})}isStarted(){return this.started}start(){var e=this;return V(function*(){e.started||(yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"AgentVersion",_t(e.host.agentVersion)),yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"ProtocolVersion",_t(e.host.protocolVersion)),yield e.components.getRegistrar().handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{Wn.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.getRegistrar().handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{Wn.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return V(function*(){yield e.components.getRegistrar().unhandle(e.identifyProtocolStr),yield e.components.getRegistrar().unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return V(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=V(function*(c){let m;const T=new Bi.TimeoutController(t.init.timeout);try{(0,Jr.setMaxListeners)?.(1/0,T.signal)}catch{}try{m=yield c.newStream([t.identifyPushProtocolStr],{signal:T.signal});const R=ga(m,T.signal);yield Ln([ac.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],to(),R,wa)}catch(R){Wn.error("could not push identify update to peer",R)}finally{m?.close(),T.clear()}});return function(c){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return V(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 V(function*(){let i,o,s=t.signal;if(null==s){i=new Bi.TimeoutController(r.init.timeout),s=i.signal;try{(0,Jr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=ga(o,s),c=yield Ln([],a,Ms({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var m=V(function*(T){return yield nc(T)});return function(T){return m.apply(this,arguments)}}());if(null==c)throw se(new Error("No data could be retrieved"),Ie.ERR_CONNECTION_ENDED);try{return ac.decode(c)}catch(m){throw se(m,Ie.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return V(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:c,signedPeerRecord:m,agentVersion:T,protocolVersion:R}=i;if(null==s)throw se(new Error("public key was missing from identify message"),Ie.ERR_MISSING_PUBLIC_KEY);const k=yield xu(s);if(!e.remotePeer.equals(k))throw se(new Error("identified peer does not match the expected peer"),Ie.ERR_INVALID_PEER);if(r.components.getPeerId().equals(k))throw se(new Error("identified peer is our own peer id?"),Ie.ERR_INVALID_PEER);const U=$E.getCleanMultiaddr(c);if(null!=m){Wn("received signed peer record from %p",k);try{const Q=yield Yi.openAndCertify(m,ku.DOMAIN);if(!Q.peerId.equals(k))throw se(new Error("identified peer does not match the expected peer"),Ie.ERR_INVALID_PEER);if(yield r.components.getPeerStore().addressBook.consumePeerRecord(Q))return yield r.components.getPeerStore().protoBook.set(k,a),null!=T&&(yield r.components.getPeerStore().metadataBook.setValue(k,"AgentVersion",_t(T))),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(k,"ProtocolVersion",_t(R))),void Wn("identify completed for peer %p and protocols %o",k,a)}catch(Q){Wn("received invalid envelope, discard it and fallback to listenAddrs is available",Q)}}else Wn("no signed peer record received from %p",k);Wn("falling back to legacy addresses from %p",k);try{yield r.components.getPeerStore().addressBook.set(k,o.map(Q=>new vn(Q)))}catch(Q){Wn.error("received invalid addrs",Q)}yield r.components.getPeerStore().protoBook.set(k,a),null!=T&&(yield r.components.getPeerStore().metadataBook.setValue(k,"AgentVersion",_t(T))),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(k,"ProtocolVersion",_t(R))),Wn("identify completed for peer %p and protocols %o",k,a),Wn("received observed address of %s",U?.toString())})()}_handleIdentify(e){var t=this;return V(function*(){const{connection:r,stream:i}=e,s=new Bi.TimeoutController(t.init.timeout);try{(0,Jr.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()),c=t.components.getAddressManager().getAddresses().map(k=>k.decapsulateCode(Nr("p2p").code));let m=a.peerRecordEnvelope;if(c.length>0&&null==m){const k=new ku({peerId:t.components.getPeerId(),multiaddrs:c}),U=yield Yi.seal(k,t.components.getPeerId());yield t.components.getPeerStore().addressBook.consumePeerRecord(U),m=U.marshal().subarray()}const T=ac.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:c.map(k=>k.bytes),signedPeerRecord:m,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),R=ga(i,s.signal);yield Ln([T],to(),R,wa)}catch(o){Wn.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return V(function*(){const{connection:r,stream:i}=e,s=new Bi.TimeoutController(t.init.timeout);try{(0,Jr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const c=ga(i,s.signal),m=yield Ln([],c,Ms({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var T=V(function*(R){return yield nc(R)});return function(R){return T.apply(this,arguments)}}());null!=m&&(o=ac.decode(m))}catch(c){return Wn.error("received invalid message",c)}finally{i.close(),s.clear()}if(null==o)return Wn.error("received invalid message");const a=r.remotePeer;if(t.components.getPeerId().equals(a))Wn("received push from ourselves?");else{if(Wn("received push from %p",a),null!=o.signedPeerRecord){Wn("received signedPeerRecord in push");try{const c=yield Yi.openAndCertify(o.signedPeerRecord,ku.DOMAIN);if(yield t.components.getPeerStore().addressBook.consumePeerRecord(c))return Wn("consumed signedPeerRecord sent in push"),void(yield t.components.getPeerStore().protoBook.set(a,o.protocols));Wn("failed to consume signedPeerRecord sent in push")}catch(c){Wn("received invalid envelope, discard it and fallback to listenAddrs is available",c)}}else Wn("did not receive signedPeerRecord in push");try{yield t.components.getPeerStore().addressBook.set(a,o.listenAddrs.map(c=>new vn(c)))}catch(c){Wn.error("received invalid addrs",c)}try{yield t.components.getPeerStore().protoBook.set(a,o.protocols)}catch(c){Wn.error("received invalid protocols",c)}Wn("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return new vn(e)}catch{}}}var wp,ao;!function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(wp||(wp={})),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=()=>Nh(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=fi((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&c)}}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=>li(i,n.codec()),n.decode=i=>ui(i,n.codec())}(ao||(ao={}));const Tx=Gt("libp2p:fetch");class tj{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 V(function*(){yield e.components.getRegistrar().handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{Tx.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return V(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return V(function*(){Tx("dialing %s to %p",i.protocol,e);const s=yield i.components.getConnectionManager().openConnection(e,r);let o,c,a=r.signal;if(null==a){o=new Bi.TimeoutController(i.init.timeout),a=o.signal;try{(0,Jr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{c=yield s.newStream([i.protocol],{signal:a});const m=ga(c,a);return(yield Ln([wp.encode({identifier:t})],to(),m,Ms(),function(){var R=V(function*(k){const U=yield nc(k);if(null==U)throw se(new Error("No data received"),Ie.ERR_INVALID_MESSAGE);const Q=ao.decode(U);switch(Q.status){case ao.StatusCode.OK:return Q.data;case ao.StatusCode.NOT_FOUND:return null;case ao.StatusCode.ERROR:{const X=(new TextDecoder).decode(Q.data);throw se(new Error("Error in fetch protocol response: "+X),Ie.ERR_INVALID_PARAMETERS)}default:throw se(new Error("Unknown response status"),Ie.ERR_INVALID_MESSAGE)}});return function(k){return R.apply(this,arguments)}}()))??null}finally{o?.clear(),c?.close()}})()}handleMessage(e){var t=this;return V(function*(){const{stream:r}=e,i=t;yield Ln(r,Ms(),function(){var s=un(function*(o){const a=yield ct(nc(o));if(null==a)throw se(new Error("No data received"),Ie.ERR_INVALID_MESSAGE);const c=wp.decode(a);let m;const T=i._getLookupFunction(c.identifier);if(null!=T){const R=yield ct(T(c.identifier));m=null!=R?{status:ao.StatusCode.OK,data:R}:{status:ao.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{const R=(new TextEncoder).encode("No lookup function registered for key: "+c.identifier);m={status:ao.StatusCode.ERROR,data:R}}yield ao.encode(m)});return function(o){return s.apply(this,arguments)}}(),to(),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 se(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),Ie.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const Ax=Gt("libp2p:ping");class sj{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 V(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 V(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;Ln(t,t).catch(r=>{Ax.error(r)})}ping(e,t={}){var r=this;return V(function*(){Ax("dialing %s to %p",r.protocol,e);const i=Date.now(),s=sf(32),o=yield r.components.getConnectionManager().openConnection(e,t);let a,m,c=t.signal;if(null==c){a=new Bi.TimeoutController(r.init.timeout),c=a.signal;try{(0,Jr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{m=yield o.newStream([r.protocol],{signal:c});const T=ga(m,c),R=yield Ln([s],T,function(){var U=V(function*(Q){return yield nc(Q)});return function(Q){return U.apply(this,arguments)}}()),k=Date.now();if(null==R||!$r(s,R.subarray()))throw se(new Error("Received wrong ping ack"),Ie.ERR_WRONG_PING_ACK);return k-i}finally{a?.clear(),m?.close()}})()}}function GE(){return(GE=V(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function cj(n){const{address:e}=n.nodeAddress();return function aj(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const WE=Gt("libp2p:nat");function uj(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class lj{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 se(new Error("NatManager ttl should be at least 7200 seconds"),Ie.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){fp||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{WE.error(e)}))}_start(){var e=this;return V(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||cj(r)||4!==i)continue;const c=yield e._getClient(),m=e.externalAddress??(yield c.externalIp());if(GA(m))throw new Error(`${m} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const T=uj();WE(`opening uPnP connection from ${m}:${T} to ${s}:${o}`),yield c.map({publicPort:T,localPort:o,localAddress:e.localAddress,protocol:"TCP"===a.toUpperCase()?"TCP":"UDP"}),e.components.getAddressManager().addObservedAddr(vn.fromNodeAddress({family:4,address:m,port:T},a))}})()}_getClient(){var e=this;return V(function*(){return null!=e.client||(e.client=yield function oj(){return GE.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return V(function*(){if(!fp&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){WE.error(t)}})()}}const fj=Gt("libp2p:peer-record-updater");class dj{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return V(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 V(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(V(function*(){const t=new ku({peerId:e.components.getPeerId(),multiaddrs:e.components.getAddressManager().getAddresses().map(i=>i.decapsulateCode(Nr("p2p").code))}),r=yield Yi.seal(t,e.components.getPeerId());yield e.components.getPeerStore().addressBook.consumePeerRecord(r)})).catch(t=>{fj.error("Could not update self peer record: %o",t)})}}class hj{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return V(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(r.dht.findPeer(e,t));i=!(c=yield a.next()).done;i=!1){const m=c.value;if("FINAL_PEER"===m.name)return m.peer}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw se(new Error(Cn.NOT_FOUND),Ie.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return un(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(r.dht.getClosestPeers(e,t));i=!(c=yield ct(a.next())).done;i=!1){const m=c.value;"PEER_RESPONSE"===m.name&&(yield*jr(Tt(m.closer),ct))}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield ct(a.return()))}finally{if(s)throw o}}})()}}const Kn=Gt("libp2p:peer-store:address-book"),bp="change:multiaddrs";function pj(){return QE.apply(this,arguments)}function QE(){return(QE=V(function*(){return!0})).apply(this,arguments)}class gj{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??pj}consumePeerRecord(e){var t=this;return V(function*(){Kn.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Kn.trace("consumePeerRecord got write lock");try{let a;try{a=ku.createFromProtobuf(e.payload)}catch{return Kn.error("invalid peer record received"),!1}i=a.peerId;const c=a.multiaddrs;if(!i.equals(e.peerId))return Kn("signing key does not match PeerId in the PeerRecord"),!1;if(null==c||0===c.length)return!1;if((yield t.store.has(i))&&(s=yield t.store.load(i),null!=s.peerRecordEnvelope)){const T=yield Yi.createFromProtobuf(s.peerRecordEnvelope),R=ku.createFromProtobuf(T.payload);if(R.seqNumber>=a.seqNumber)return Kn("sequence number was lower or equal to existing sequence number - stored: %d received: %d",R.seqNumber,a.seqNumber),!1}const m=yield YE(i,c,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:m,peerRecordEnvelope:e.marshal().subarray()}),Kn("stored provided peer record for %p",a.peerId)}finally{Kn.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new rn(bp,{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 V(function*(){Kn.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Kn.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Kn.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return V(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield Yi.createFromProtobuf(r)})()}get(e){var t=this;return V(function*(){e=Zr(e),Kn.trace("get wait for read lock");const r=yield t.store.lock.readLock();Kn.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Kn.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return V(function*(){if(e=Zr(e),!Array.isArray(t))throw Kn.error("multiaddrs must be an array of Multiaddrs"),se(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Kn.trace("set await write lock");const i=yield r.store.lock.writeLock();Kn.trace("set got write lock");let o,a,s=!1;try{const c=yield YE(e,t,r.addressFilter);if(0===c.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...c.map(({multiaddr:m})=>m.toString()),...o.addresses.map(({multiaddr:m})=>m.toString())]).size===o.addresses.length&&c.length===o.addresses.length)return}catch(m){if("ERR_NOT_FOUND"!==m.code)throw m}a=yield r.store.patchOrCreate(e,{addresses:c}),Kn("set multiaddrs for %p",e)}finally{Kn.trace("set multiaddrs for %p",e),Kn("set release write lock"),i()}r.dispatchEvent(new rn(bp,{detail:{peerId:e,multiaddrs:a.addresses.map(c=>c.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:c})=>c)}})),s||r.dispatchEvent(new rn("peer",{detail:{id:e,multiaddrs:a.addresses.map(c=>c.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return V(function*(){if(e=Zr(e),!Array.isArray(t))throw Kn.error("multiaddrs must be an array of Multiaddrs"),se(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Kn.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Kn.trace("add got write lock");try{const c=yield YE(e,t,r.addressFilter);if(0===c.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...c.map(({multiaddr:m})=>m.toString()),...o.addresses.map(({multiaddr:m})=>m.toString())]).size===o.addresses.length)return}catch(m){if("ERR_NOT_FOUND"!==m.code)throw m}a=yield r.store.mergeOrCreate(e,{addresses:c}),Kn("added multiaddrs for %p",e)}finally{Kn.trace("set release write lock"),i()}r.dispatchEvent(new rn(bp,{detail:{peerId:e,multiaddrs:a.addresses.map(c=>c.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:c})=>c)}})),!0===s&&r.dispatchEvent(new rn("peer",{detail:{id:e,multiaddrs:a.addresses.map(c=>c.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return V(function*(){e=Zr(e),Kn.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Kn.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{Kn.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new rn(bp,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function YE(n,e,t){return ZE.apply(this,arguments)}function ZE(){return ZE=V(function*(n,e,t,r=!1){return yield Ln(e,i=>RE(i,s=>{if(!vn.isMultiaddr(s))throw Kn.error("multiaddr must be an instance of Multiaddr"),se(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>Ks(i,function(){var s=V(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>fE(i,s=>({multiaddr:new vn(s.toString()),isCertified:r})),function(){var i=V(function*(s){return yield Ea(s)});return function(s){return i.apply(this,arguments)}}())}),ZE.apply(this,arguments)}const co=Gt("libp2p:peer-store:key-book"),xx="change:pubkey";class yj{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return V(function*(){if(e=Zr(e),!(t instanceof Uint8Array))throw co.error("publicKey must be an instance of Uint8Array to store data"),se(new Error("publicKey must be an instance of PublicKey"),"ERR_INVALID_PARAMETERS");co.trace("set await write lock");const i=yield r.store.lock.writeLock();co.trace("set got write lock");let o,s=!1;try{try{if(o=yield r.store.load(e),null!=o.pubKey&&$r(o.pubKey,t))return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}yield r.store.patchOrCreate(e,{pubKey:t}),s=!0}finally{co.trace("set release write lock"),i()}s&&r.dispatchEvent(new rn(xx,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return V(function*(){e=Zr(e),co.trace("get await write lock");const r=yield t.store.lock.readLock();co.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{co("get release write lock"),r()}})()}delete(e){var t=this;return V(function*(){e=Zr(e),co.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;co.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{co.trace("delete release write lock"),r()}t.dispatchEvent(new rn(xx,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const Mr=Gt("libp2p:peer-store:metadata-book"),_p="change:metadata";class mj{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return V(function*(){e=Zr(e),Mr.trace("get await read lock");const r=yield t.store.lock.readLock();Mr.trace("get got read lock");try{return(yield t.store.load(e)).metadata}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Mr.trace("get release read lock"),r()}return new Map})()}getValue(e,t){var r=this;return V(function*(){e=Zr(e),Mr.trace("getValue await read lock");const i=yield r.store.lock.readLock();Mr.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{Mr.trace("getValue release write lock"),i()}})()}set(e,t){var r=this;return V(function*(){if(e=Zr(e),!(t instanceof Map))throw Mr.error("valid metadata must be provided to store data"),se(new Error("valid metadata must be provided"),"ERR_INVALID_PARAMETERS");Mr.trace("set await write lock");const i=yield r.store.lock.writeLock();let s;Mr.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{Mr.trace("set release write lock"),i()}r.dispatchEvent(new rn(_p,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return V(function*(){if(e=Zr(e),"string"!=typeof t||!(r instanceof Uint8Array))throw Mr.error("valid key and value must be provided to store data"),se(new Error("valid key and value must be provided"),"ERR_INVALID_PARAMETERS");Mr.trace("setValue await write lock");const s=yield i.store.lock.writeLock();let o,a;Mr.trace("setValue got write lock");try{try{o=yield i.store.load(e);const c=o.metadata.get(t);if(null!=c&&$r(r,c))return}catch(c){if("ERR_NOT_FOUND"!==c.code)throw c}a=yield i.store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{Mr.trace("setValue release write lock"),s()}i.dispatchEvent(new rn(_p,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return V(function*(){e=Zr(e),Mr.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Mr.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{Mr.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new rn(_p,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return V(function*(){e=Zr(e),Mr.trace("deleteValue await write lock");const i=yield r.store.lock.writeLock();let s,o;Mr.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{Mr.trace("deleteValue release write lock"),i()}null!=s&&r.dispatchEvent(new rn(_p,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const Or=Gt("libp2p:peer-store:proto-book"),Dp="change:protocols";class vj{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return V(function*(){Or.trace("get wait for read lock");const r=yield t.store.lock.readLock();Or.trace("get got read lock");try{return(yield t.store.load(e)).protocols}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Or.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return V(function*(){if(e=Zr(e),!Array.isArray(t))throw Or.error("protocols must be provided to store data"),se(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Or.trace("set await write lock");const i=yield r.store.lock.writeLock();let s,o;Or.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}),Or("stored provided protocols for %p",e)}finally{Or.trace("set release write lock"),i()}r.dispatchEvent(new rn(Dp,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return V(function*(){if(e=Zr(e),!Array.isArray(t))throw Or.error("protocols must be provided to store data"),se(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Or.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o;Or.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}),Or("added provided protocols for %p",e)}finally{Or.trace("add release write lock"),i()}r.dispatchEvent(new rn(Dp,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return V(function*(){if(e=Zr(e),!Array.isArray(t))throw Or.error("protocols must be provided to store data"),se(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Or.trace("remove await write lock");const i=yield r.store.lock.writeLock();let s,o;Or.trace("remove got write lock");try{try{s=yield r.store.load(e);const a=new Set(s.protocols);for(const c of t)a.delete(c);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{Or.trace("remove release write lock"),i()}r.dispatchEvent(new rn(Dp,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return V(function*(){e=Zr(e),Or.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Or.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{Or.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new rn(Dp,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Sp,Ip,Cp;!function(n){let e;n.codec=()=>(null==e&&(e=fi((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),Ip.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),Cp.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(Ip.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(Cp.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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(Sp||(Sp={})),function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(Ip||(Ip={})),function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(Cp||(Cp={}));var Ej=N(2005);class Rx extends Error{constructor(e){super(e),this.name="TimeoutError"}}class wj extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Px=n=>void 0===globalThis.DOMException?new wj(n):new DOMException(n),Nx=n=>{const e=void 0===n.reason?Px("This operation was aborted."):n.reason;return e instanceof Error?e:Px(e)};function Mx(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:c}=r;c.aborted&&a(Nx(c)),c.addEventListener("abort",()=>{a(Nx(c))})}i=r.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof t){try{o(t())}catch(T){a(T)}return}const m=t instanceof Error?t:new Rx("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(m)},e),V(function*(){try{o(yield n)}catch(c){a(c)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var jo,cc=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 _j{constructor(){jo.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&cc(this,jo,"f")[this.size-1].priority>=t.priority)return void cc(this,jo,"f").push(r);const i=function bj(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}(cc(this,jo,"f"),r,(s,o)=>o.priority-s.priority);cc(this,jo,"f").splice(i,0,r)}dequeue(){return cc(this,jo,"f").shift()?.run}filter(e){return cc(this,jo,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return cc(this,jo,"f").length}}jo=new WeakMap;var Dr,Mf,Of,Ia,Tp,Lf,Ap,$s,kf,Zi,xp,Xi,Bf,Ca,Rp,Ox,Lx,kx,Bx,Fx,Ux,Pp,XE,JE,Np,Mp,pr=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 Dj=new Rx;class Sj extends Error{}class Vx extends Ej{constructor(e){var t,r,i,s;if(super(),Dr.add(this),Mf.set(this,void 0),Of.set(this,void 0),Ia.set(this,0),Tp.set(this,void 0),Lf.set(this,void 0),Ap.set(this,0),$s.set(this,void 0),kf.set(this,void 0),Zi.set(this,void 0),xp.set(this,void 0),Xi.set(this,0),Bf.set(this,void 0),Ca.set(this,void 0),Rp.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:_j,...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})`);pr(this,Mf,e.carryoverConcurrencyCount,"f"),pr(this,Of,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),pr(this,Tp,e.intervalCap,"f"),pr(this,Lf,e.interval,"f"),pr(this,Zi,new e.queueClass,"f"),pr(this,xp,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,pr(this,Rp,!0===e.throwOnTimeout,"f"),pr(this,Ca,!1===e.autoStart,"f")}get concurrency(){return gt(this,Bf,"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})`);pr(this,Bf,e,"f"),gt(this,Dr,"m",Np).call(this)}add(e,t={}){var r=this;return V(function*(){return new Promise((i,s)=>{const o=function(){var a=V(function*(){var c,m,T;pr(r,Xi,(m=gt(r,Xi,"f"),++m),"f"),pr(r,Ia,(T=gt(r,Ia,"f"),++T),"f");try{if(null!==(c=t.signal)&&void 0!==c&&c.aborted)return void s(new Sj("The task was aborted."));const k=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):Mx(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?gt(r,Rp,"f"):t.throwOnTimeout)&&s(Dj)});i(k),r.emit("completed",k)}catch(R){s(R),r.emit("error",R)}gt(r,Dr,"m",kx).call(r)});return function(){return a.apply(this,arguments)}}();gt(r,Zi,"f").enqueue(o,t),gt(r,Dr,"m",Pp).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return V(function*(){return Promise.all(e.map(function(){var i=V(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return gt(this,Ca,"f")?(pr(this,Ca,!1,"f"),gt(this,Dr,"m",Np).call(this),this):this}pause(){pr(this,Ca,!0,"f")}clear(){pr(this,Zi,new(gt(this,xp,"f")),"f")}onEmpty(){var e=this;return V(function*(){0!==gt(e,Zi,"f").size&&(yield gt(e,Dr,"m",Mp).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return V(function*(){gt(t,Zi,"f").sizegt(t,Zi,"f").size{gt(this,Dr,"m",Fx).call(this)},t),"f"),!0;pr(this,Ia,gt(this,Mf,"f")?gt(this,Xi,"f"):0,"f")}return!1},Pp=function(){if(0===gt(this,Zi,"f").size)return gt(this,$s,"f")&&clearInterval(gt(this,$s,"f")),pr(this,$s,void 0,"f"),gt(this,Dr,"m",Bx).call(this),!1;if(!gt(this,Ca,"f")){const e=!gt(this,Dr,"a",Ux);if(gt(this,Dr,"a",Ox)&>(this,Dr,"a",Lx)){const t=gt(this,Zi,"f").dequeue();return!!t&&(this.emit("active"),t(),e&>(this,Dr,"m",XE).call(this),!0)}}return!1},XE=function(){gt(this,Of,"f")||void 0!==gt(this,$s,"f")||(pr(this,$s,setInterval(()=>{gt(this,Dr,"m",JE).call(this)},gt(this,Lf,"f")),"f"),pr(this,Ap,Date.now()+gt(this,Lf,"f"),"f"))},JE=function(){0===gt(this,Ia,"f")&&0===gt(this,Xi,"f")&>(this,$s,"f")&&(clearInterval(gt(this,$s,"f")),pr(this,$s,void 0,"f")),pr(this,Ia,gt(this,Mf,"f")?gt(this,Xi,"f"):0,"f"),gt(this,Dr,"m",Np).call(this)},Np=function(){for(;gt(this,Dr,"m",Pp).call(this););},Mp=function(){var n=V(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 Ij extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Cj extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Hx=n=>void 0===globalThis.DOMException?new Cj(n):new DOMException(n),Kx=n=>{const e=void 0===n.reason?Hx("This operation was aborted."):n.reason;return e instanceof Error?e:Hx(e)};function Tj(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((c,m)=>{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:T}=e;T.aborted&&m(Kx(T)),T.addEventListener("abort",()=>{m(Kx(T))})}o=s.setTimeout.call(void 0,()=>{if(r){try{c(r())}catch(k){m(k)}return}const R=i instanceof Error?i:new Ij("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),m(R)},t),V(function*(){try{c(yield n)}catch(T){m(T)}finally{s.clearTimeout.call(void 0,o)}})()}else c(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const jx="lock:worker:request-read",$x="lock:worker:release-read",Gx="lock:master:grant-read",zx="lock:worker:request-write",Wx="lock:worker:release-write",qx="lock:master:grant-write",Ta={},Bu=n=>{n.addEventListener("message",e=>{Bu.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{Bu.dispatchEvent("message",n,e)})};Bu.addEventListener=(n,e)=>{null==Ta[n]&&(Ta[n]=[]),Ta[n].push(e)},Bu.removeEventListener=(n,e)=>{null!=Ta[n]&&(Ta[n]=Ta[n].filter(t=>t===e))},Bu.dispatchEvent=function(n,e,t){null!=Ta[n]&&Ta[n].forEach(r=>r(e,t))};const Qx=Bu,Yx=(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 c;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(c=V(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(m=>{const T=R=>{null!=R&&null!=R.data&&R.data.type===r&&R.data.identifier===a.identifier&&(s.removeEventListener("message",T),m())};s.addEventListener("message",T)})}),function(){return c.apply(this,arguments)})}}))},Zx=(n,e,t,r)=>V(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)})}),Pj={singleProcess:!1},uc={};let Aa;function ew(n,e){return tw.apply(this,arguments)}function tw(){return tw=V(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add(V(function*(){return yield Tj(V(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),tw.apply(this,arguments)}const Oj={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const Xx=Gt("libp2p:peer-store:store"),Jx="/peers/";class kj{constructor(){this.components=new ko,this.lock=function Lj(n){const e=Object.assign({},Oj,n);return null==Aa&&(Aa=(n=>{if(n=Object.assign({},Pj,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return Qx.addEventListener("message",Yx(t,"requestReadLock",jx,$x,Gx)),Qx.addEventListener("message",Yx(t,"requestWriteLock",zx,Wx,qx)),t}return{isWorker:!0,readLock:t=>Zx(t,jx,Gx,$x),writeLock:t=>Zx(t,zx,qx,Wx)}})(e),!0!==Aa.isWorker&&(Aa.addEventListener("requestReadLock",t=>{null!=uc[t.data.name]&&uc[t.data.name].readLock().then(function(){var r=V(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),Aa.addEventListener("requestWriteLock",function(){var t=V(function*(r){null!=uc[r.data.name]&&uc[r.data.name].writeLock().then(function(){var i=V(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==uc[e.name]&&(uc[e.name]=((n,e)=>{if(!0===Aa.isWorker)return{readLock:Aa.readLock(n,e),writeLock:Aa.writeLock(n,e)};const t=new Vx({concurrency:1});let r;return{readLock:()=>V(function*(){if(null!=r)return yield ew(r,e);r=new Vx({concurrency:e.concurrency,autoStart:!1});const i=r,s=ew(r,e);return t.add(V(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>V(function*(){return r=null,yield ew(t,e)})()}})(e.name,e)),uc[e.name]}({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(null==e.type)throw Xx.error("peerId must be an instance of peer-id to store data"),se(new Error("peerId must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");const t=e.toCID().toString();return new Xr(`${Jx}${t}`)}has(e){var t=this;return V(function*(){return yield t.components.getDatastore().has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return V(function*(){yield t.components.getDatastore().delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return V(function*(){const r=yield t.components.getDatastore().get(t._peerIdToDatastoreKey(e)),i=Sp.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 vn(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return V(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!$r(e.pubKey,e.id.publicKey))throw Xx.error("peer publicKey bytes do not match peer id publicKey bytes"),se(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,c)=>a.multiaddr.toString().localeCompare(c.multiaddr.toString())).map(({multiaddr:a,isCertified:c})=>({multiaddr:a.bytes,isCertified:c})),s=[];[...e.metadata.keys()].sort().forEach(a=>{const c=e.metadata.get(a);null!=c&&s.push({key:a,value:c})});const o=Sp.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 V(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return V(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 V(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return V(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return V(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 V(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(),m=Boolean(s.get(a))||o.isCertified;s.set(a,m)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:new vn(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 un(function*(){var i,t=!1,r=!1;try{for(var o,s=Tt(e.components.getDatastore().queryKeys({prefix:Jx}));t=!(o=yield ct(s.next())).done;t=!1){const c=o.value.toString().split("/")[2],m=Ro.decode(c);yield e.load(pa(m))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield ct(s.return()))}finally{if(r)throw i}}})()}}var xa,Op;!function(n){let e;n.codec=()=>(null==e&&(e=fi((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),Op.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(Op.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(xa||(xa={})),function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(Op||(Op={}));const ys=Gt("libp2p:peer-store");class Bj extends ki{constructor(e={}){super(),this.components=new ko,this.store=new kj,this.addressBook=new gj(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new yj(this.dispatchEvent.bind(this),this.store),this.metadataBook=new mj(this.dispatchEvent.bind(this),this.store),this.protoBook=new vj(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}forEach(e){var t=this;return V(function*(){ys.trace("getPeers await read lock");const r=yield t.store.lock.readLock();ys.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var c,a=Tt(t.store.all());i=!(c=yield a.next()).done;i=!1){const m=c.value;m.id.equals(t.components.getPeerId())||e(m)}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{ys.trace("getPeers release read lock"),r()}})()}all(){var e=this;return V(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return V(function*(){ys.trace("delete await write lock");const r=yield t.store.lock.writeLock();ys.trace("delete got write lock");try{yield t.store.delete(e)}finally{ys.trace("delete release write lock"),r()}})()}get(e){var t=this;return V(function*(){ys.trace("get await read lock");const r=yield t.store.lock.readLock();ys.trace("get got read lock");try{return yield t.store.load(e)}finally{ys.trace("get release read lock"),r()}})()}has(e){var t=this;return V(function*(){ys.trace("has await read lock");const r=yield t.store.lock.readLock();ys.trace("has got read lock");try{return yield t.store.has(e)}finally{ys.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return V(function*(){const s=r.value??0,o=Math.round(s),a=r.ttl??void 0;if(o!==s||o<0||o>100)throw se(new Error("Tag value must be between 0-100"),"ERR_TAG_VALUE_OUT_OF_BOUNDS");const c=yield i.metadataBook.getValue(e,"tags");let m=[];null!=c&&(m=xa.decode(c).tags);for(const T of m)if(T.name===t)throw se(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");m.push({name:t,value:o,expiry:null==a?void 0:BigInt(Date.now()+a)}),yield i.metadataBook.setValue(e,"tags",xa.encode({tags:m}).subarray())})()}unTagPeer(e,t){var r=this;return V(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=xa.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",xa.encode({tags:s}).subarray())})()}getTags(e){var t=this;return V(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=xa.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",xa.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class Fj{constructor(e){this.dht=e}provide(e){var t=this;return V(function*(){yield wa(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return un(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(r.dht.findProviders(e,t));i=!(c=yield ct(a.next())).done;i=!1){const m=c.value;"PROVIDER"===m.name&&(yield*jr(Tt(m.providers),ct))}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield ct(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return V(function*(){yield wa(i.dht.put(e,t,r))})()}get(e,t){var r=this;return V(function*(){var o,i=!1,s=!1;try{for(var c,a=Tt(r.dht.get(e,t));i=!(c=yield a.next()).done;i=!1){const m=c.value;if("VALUE"===m.name)return m.value}}catch(m){s=!0,o=m}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw se(new Error("Not found"),"ERR_NOT_FOUND")})()}}const eR=Gt("libp2p:dialer:auto-dialer");class Uj{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){eR("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);const o=new Bi.TimeoutController(this.dialTimeout);try{(0,Jr.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{eR.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}var tR=N(4033);const Vj=globalThis.fetch,Hj=globalThis.Headers;function nw(n,e,t){return`${n}?name=${e}&type=${t}`}function Kj(n,e){return rw.apply(this,arguments)}function rw(){return rw=V(function*(n,e){return yield(yield Vj(n,{headers:new Hj({accept:"application/dns-json"}),signal:e})).json()}),rw.apply(this,arguments)}function Fu(n,e){return`${e}_${n}`}globalThis,globalThis;const iw=Object.assign(Ur("dns-over-http-resolver"),{error:Ur("dns-over-http-resolver:error")}),$j=class jj{constructor(e={}){this._cache=new tR({max:e?.maxCache??100}),this._TXTcache=new tR({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??Kj,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 V(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 V(function*(){const i=t._cache.get(Fu(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 c=yield t._request(nw(o,e,"A"),a.signal),m=c.Answer.map(R=>R.data),T=Math.min(...c.Answer.map(R=>R.TTL));return t._cache.set(Fu(e,"A"),m,{ttl:T}),m}catch{a.signal.aborted&&(s=!0),iw.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(c=>c!==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 V(function*(){const r="AAAA",i=t._cache.get(Fu(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 c=yield t._request(nw(o,e,r),a.signal),m=c.Answer.map(R=>R.data),T=Math.min(...c.Answer.map(R=>R.TTL));return t._cache.set(Fu(e,r),m,{ttl:T}),m}catch{a.signal.aborted&&(s=!0),iw.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(c=>c!==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 V(function*(){const r="TXT",i=t._TXTcache.get(Fu(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 c=yield t._request(nw(o,e,r),a.signal),m=c.Answer.map(R=>[R.data.replace(/['"]+/g,"")]),T=Math.min(...c.Answer.map(R=>R.TTL));return t._TXTcache.set(Fu(e,r),m,{ttl:T}),m}catch{a.signal.aborted&&(s=!0),iw.error(`${o} could not resolve ${e} record TXT`)}finally{t._abortControllers=t._abortControllers.filter(c=>c!==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:Gj}=Nr("dnsaddr");function sw(){return sw=V(function*(n,e={}){const t=new $j;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===Gj)??[];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}),sw.apply(this,arguments)}const Wj={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 zj(n){return sw.apply(this,arguments)}},addressSorter:yE},connectionGater:{},transportManager:{faultTolerance:oc.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:Ix},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 qj(n){const e=Df(Wj,n);if(null==e.transports||e.transports.length<1)throw se(new Error(Cn.ERR_TRANSPORTS_REQUIRED),Ie.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw se(new Error(Cn.CONN_ENCRYPTION_REQUIRED),Ie.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw se(new Error(Cn.ERR_PROTECTOR_REQUIRED),Ie.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===Ix&&(X9||Y9?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(fp||_A||Z9||J9)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var nR;!function(n){let e;n.codec=()=>(null==e&&(e=fi((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=>li(t,n.codec()),n.decode=t=>ui(t,n.codec())}(nR||(nR={}));const Qj=function(){var n=V(function*(){const e=yield bT("Ed25519"),t=yield function rR(n){return aw.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 aw(){return aw=V(function*(n){return yield xu(BV(n.public),FV(n))}),aw.apply(this,arguments)}const fw=Symbol.for("@libp2p/peer-discovery");class Zj extends ki{get[fw](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}get lan(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}get(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}findProviders(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}findPeer(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}getClosestPeers(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}provide(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}put(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)}getMode(){return V(function*(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)})()}setMode(){return V(function*(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)})()}refreshRoutingTable(){return V(function*(){throw se(new Error(Cn.DHT_DISABLED),Ie.DHT_DISABLED)})()}}class Xj extends ki{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}get multicodecs(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}getPeers(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}getTopics(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}subscribe(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}unsubscribe(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}getSubscribers(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)}publish(){return V(function*(){throw se(new Error(Cn.PUBSUB_DISABLED),Ie.ERR_PUBSUB_DISABLED)})()}}const $o=Gt("libp2p");class Jj extends ki{constructor(e){var o;super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new ko({peerId:e.peerId,datastore:e.datastore??new SH,connectionGater:{denyDialPeer:(o=V(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=V(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=V(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}}),this.components.setPeerStore(new Bj({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new wK(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new rn("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new UK(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 GH(e.connectionManager)),this.registrar=this.components.setRegistrar(new kK(this.components)),this.components.setTransportManager(new xK(this.components,e.transportManager)),this.components.setAddressManager(new xH(this.components,e.addresses)),this.configureComponent(new dj(this.components)),this.configureComponent(new WH(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const t=fx.generateOptions();this.keychain=this.configureComponent(new fx(this.components,{...t,...e.keychain})),this.services.push(new lj(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 $E(this.components,{...e.identify}),this.configureComponent(this.identifyService)),this.dht=null!=e.dht?this.components.setDHT(e.dht):new Zj,this.pubsub=null!=e.pubsub?this.components.setPubSub(e.pubsub):new Xj;const r=(e.peerRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&(r.push(this.configureComponent(new hj(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new IH(this.components,{...e.peerRouting,routers:r})));const i=(e.contentRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&i.push(this.configureComponent(new Fj(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new CH(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new nK(e.relay))),this.configureComponent(new cK(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new tj(this.components,{...e.fetch})),this.pingService=this.configureComponent(new sj(this.components,{...e.ping}));const s=this.configureComponent(new Uj(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 Lo(e)&&this.services.push(e),hi(e)&&this.initializables.push(e),e}start(){var e=this;return V(function*(){if(!e.started){e.started=!0,$o("libp2p is starting");try{e.initializables.forEach(t=>{t.init(e.components)}),yield Promise.all(e.services.map(function(){var t=V(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=V(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),$o("libp2p has started")}catch(t){throw $o.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return V(function*(){!e.started||($o("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=V(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=V(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),$o("libp2p has stopped"))})()}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){const e=new B7;for(const t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return V(function*(){const{id:i,multiaddrs:s}=_f(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 V(function*(){if(null==t)throw se(new Error("no protocols were provided to open a stream"),Ie.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw se(new Error("no protocols were provided to open a stream"),Ie.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 V(function*(){const{id:r}=_f(e);yield t.components.getConnectionManager().closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return V(function*(){if($o("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 se(new Error("Public key was not in the peer store and the DHT is not enabled"),Ie.ERR_NO_ROUTERS_AVAILABLE);const s=or([_t("/pk/"),e.multihash.digest]);var c,o=!1,a=!1;try{for(var T,m=Tt(r.dht.get(s,t));o=!(T=yield m.next()).done;o=!1){const R=T.value;if("VALUE"===R.name){const k=Tu(R.value);return yield r.peerStore.keyBook.set(e,R.value),k.bytes}}}catch(R){a=!0,c=R}finally{try{o&&null!=m.return&&(yield m.return())}finally{if(a)throw c}}throw se(new Error(`Node not responding with its public key: ${e.toString()}`),Ie.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return V(function*(){const{id:s,multiaddrs:o}=_f(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 V(function*(){const{id:i,multiaddrs:s}=_f(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 V(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=V(function*(o){yield i.components.getRegistrar().handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return V(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=V(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=>$o.error(r)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(r=>$o.error(r)),this.dispatchEvent(new rn("peer:discovery",{detail:t}))):$o.error(new Error(Ie.ERR_DISCOVERED_SELF))}}function e$(n){return dw.apply(this,arguments)}function dw(){return dw=V(function*(n){return null==n.peerId&&(n.peerId=yield Qj()),new Jj(qj(n))}),dw.apply(this,arguments)}function t$(n){return hw.apply(this,arguments)}function hw(){return hw=V(function*(n){return yield e$(n)}),hw.apply(this,arguments)}function sR(n,e){return n.length<=e||n.length<=1?n:function r$(n){if(n.length<=1)return n;for(let t=0;t{class n extends ki{constructor(t,r){super(),this.interval=r?.interval??n.DefaultInterval;const i=r?.maxPeers??t?.length,s=t.map(o=>"string"==typeof o?new vn(o):o);this.peers=function n$(n){return n.map(e=>{const t=e.getPeerId();return{id:t?_r(t):null,multiaddrs:[e.decapsulateCode(421)],protocols:[]}}).filter(e=>null!==e.id)}(sR(s,i)),oR("Use provided list of peers (reduced to maxPeers)",this.peers.map(o=>o.toString()))}start(){this._startTimer()}_startTimer(){if(this.peers){if(oR("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 rn("peer",{detail:t}))})}stop(){null!=this.timer&&clearInterval(this.timer),this.timer=void 0}get[fw](){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 pw_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"}}},aR=Symbol.for("@achingbrain/uint8arraylist");function cR(n,e,t){if(null==e||e<0||e>=t)throw new RangeError("index is out of bounds");let r=0;for(const i of n){const s=r+i.byteLength;if(e0;){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 or(r,i)}subarray(e,t){const{bufs:r}=this._subList(e,t),i=new Vr;return i.appendAll(r),i}_subList(e,t){if(null==e&&null==t)return{bufs:this.bufs,length:this.length};if((e=e??0)<0&&(e=this.length+e),(t=t??(this.length>0?this.length:0))<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index out of bounds");if(e===t)return{bufs:[],length:0};const r=[];let i=0;for(const s of this.bufs){const o=i,a=o+s.byteLength,m=t>o&&t<=a;let R,k;if(i=a,e>=o&&e=a&&(R=0,k=s.byteLength),null!=R&&null!=k&&r.push(s.subarray(R,k)),m)break}return{bufs:r,length:t-e}}getInt8(e){const t=this.slice(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=new Uint8Array(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.slice(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const i=new Uint8Array(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,r),this.write(i,e)}getInt32(e,t){const r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const i=new Uint8Array(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,r),this.write(i,e)}getBigInt64(e,t){const r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const i=new Uint8Array(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,r),this.write(i,e)}getUint8(e){const t=this.slice(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=new Uint8Array(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.slice(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const i=new Uint8Array(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,r),this.write(i,e)}getUint32(e,t){const r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const i=new Uint8Array(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,r),this.write(i,e)}getBigUint64(e,t){const r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const i=new Uint8Array(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,r),this.write(i,e)}getFloat32(e,t){const r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const i=new Uint8Array(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,r),this.write(i,e)}getFloat64(e,t){const r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const i=new Uint8Array(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}}const Lp=(n,e,t)=>{const r=Vn.encode(n,e,t);return Lp.bytes=Vn.encode.bytes,e??Uint8Array.from(r)};function Ff(n){n=n??{};const e=Math.max(n.poolSize??10240,n.minPoolSize??8),t=n.lengthEncoder??Lp;return function(){var i=un(function*(s){let o=new Uint8Array(e),a=0;var T,c=!1,m=!1;try{for(var k,R=Tt(s);c=!(k=yield ct(R.next())).done;c=!1){const U=k.value;t(U.length,o,a);const Q=o.slice(a,a+t.bytes);a+=t.bytes,o.length-a<8&&(o=new Uint8Array(e),a=0),yield or([Q,U.slice()],Q.length+U.length)}}catch(U){m=!0,T=U}finally{try{c&&null!=R.return&&(yield ct(R.return()))}finally{if(m)throw T}}});return function(o){return i.apply(this,arguments)}}()}Lp.bytes=0,Ff.single=(n,e)=>new Vr(((e=e??{}).lengthEncoder??Lp)(n.length),n.slice());const gw=n=>{const e=Vn.decode(n);return gw.bytes=Vn.decode.bytes,e};gw.bytes=0;const l$=new Vr,f$={readLength:(n,e,t,r)=>{const i=r?.lengthDecoder??gw,s=r?.maxLengthLength??8,o=r?.maxDataLength??4194304;let a;e.append(n);try{a=i(e.slice())}catch(c){if(e.length>s)throw se(new Error("message length too long"),"ERR_MSG_LENGTH_TOO_LONG");if(c instanceof RangeError)return{mode:"readLength",buffer:e,chunk:void 0,state:void 0,data:void 0};throw c}if(a>o)throw se(new Error("message data too long"),"ERR_MSG_DATA_TOO_LONG");return n=e.subarray(i.bytes),e=new Vr,null!=r?.onLength&&r.onLength(a),a<=0?{mode:"readLength",chunk:n,buffer:e,data:l$}:{mode:"readData",chunk:n,buffer:e,state:{dataLength:a},data:void 0}},readData:(n,e,t,r)=>{if(e.append(n),null==t)throw new Error("state is required");if(e.lengthi?e.subarray(i):void 0,buffer:e=new Vr,state:void 0,data:s}}};function Vu(n){return function(){var t=un(function*(r){let o,i=new Vr,s="readLength";var m,a=!1,c=!1;try{for(var R,T=Tt(r);a=!(R=yield ct(T.next())).done;a=!1){let U=new Vr(R.value);for(;null!=U;){const Q=f$[s](U,i,o,n);if(s=Q.mode,U=Q.chunk,i=Q.buffer,o=Q.state,null!=Q.data){const X=Q.data.slice();null!=n?.onData&&n.onData(X),yield X}}}}catch(k){c=!0,m=k}finally{try{a&&null!=T.return&&(yield ct(T.return()))}finally{if(c)throw m}}if(i.length>0)throw se(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}Vu.fromReader=(n,e)=>{let t=1;const r=un(function*(){for(;;)try{const{done:s,value:o}=yield ct(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 Vu({...e??{},onLength:s=>{t=s}})(r)};const kp="/waku/2/default-waku/proto";var lc=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(lc||(lc={})),lc))();function yw(n){return mw.apply(this,arguments)}function mw(){return mw=V(function*(n){if(0!==n.length)return n[Math.round(Math.random()*(n.length-1))]}),mw.apply(this,arguments)}function vw(n,e){return Ew.apply(this,arguments)}function Ew(){return Ew=V(function*(n,e){const t=[];return yield n.peerStore.forEach(r=>{for(let i=0;is+o.length,0),r=new Uint8Array(t);let i=0;for(const s of n)r.set(s,i),i+=s.length;return r}function Hu(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 fR=4294967296;class Fi{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(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)}zzDecode(){const e=-(1&this.lo);return new Fi((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new Fi(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=Hu(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 Fi;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>fR&&(i=0,++r>fR&&(r=0))),new Fi(r,i)}static fromNumber(e){if(0===e)return new Fi;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 Fi(i,r)}static fromBytes(e,t){const r=Hu(e),i=new Fi;let s=0;if(!(e.length-t>4)){for(;s<3;++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}return i.lo=(i.lo|(127&r.get(t++))<<7*s)>>>0,i}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;if(s=0,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 for(;s<5;++s){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 Error("invalid varint encoding")}}const v$=Math.pow(2,31),E$=Math.pow(2,7),w$=Math.pow(2,14),b$=Math.pow(2,21),_$=Math.pow(2,28),D$=Math.pow(2,35),S$=Math.pow(2,42),I$=Math.pow(2,49),C$=Math.pow(2,56),T$=Math.pow(2,63),Yt={encodingLength:n=>n=v$;)r.set(t++,255&n|128),n/=128;for(;(-128&n)>0;)r.set(t++,255&n|128),n>>>=7;r.set(t,0|n)},decode(n,e=0){const t=Hu(n);let r=4294967295;if(r=(127&t.get(e))>>>0,t.get(e++)<128||(r=(r|(127&t.get(e))<<7)>>>0,t.get(e++)<128)||(r=(r|(127&t.get(e))<<14)>>>0,t.get(e++)<128)||(r=(r|(127&t.get(e))<<21)>>>0,t.get(e++)<128)||(r=(r|(15&t.get(e))<<28)>>>0,t.get(e++)<128))return r;if((e+=5)>n.length)throw RangeError(`index out of range: ${e} > ${n.length}`);return r}},ww={encodingLength:n=>n<0?10:Yt.encodingLength(n),encode(n,e){if(n<0){let t=0;const r=Hu(e),i=Fi.fromNumber(n);for(;i.hi>0;)r.set(t++,127&i.lo|128),i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)r.set(t++,127&i.lo|128),i.lo=i.lo>>>7;r.set(t++,i.lo)}else Yt.encode(n,e)},decode:(n,e=0)=>0|Yt.decode(n,e)},bw={encodingLength:n=>Yt.encodingLength(n=(n<<1^n>>31)>>>0),encode:(n,e,t=0)=>Yt.encode(n=(n<<1^n>>31)>>>0,e),decode(n,e=0){const t=Yt.decode(n,e);return t>>>1^-(1&t)|0}};function ar(n,e){const t=new Uint8Array(Yt.encodingLength(n.length));return Yt.encode(n.length,t),e.decode(new Vr(t,n),0)}function cr(n,e){const t=e.encode(n),r=Yt.encodingLength(Yt.decode(t));return t.slice(r)}var Xn=(()=>(function(n){n[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"}(Xn||(Xn={})),Xn))();function ei(n,e,t,r,i){return{name:n,type:e,encode:t,decode:r,encodingLength:i}}const hR=ei("bool",Xn.VARINT,function(e){return Uint8Array.from([e?1:0])},function(e,t){return e.get(t)>0},function(){return 1}),fc=ei("bytes",Xn.LENGTH_DELIMITED,function(e){const t=new Uint8Array(Yt.encodingLength(e.byteLength));return Yt.encode(e.byteLength,t),new Vr(t,e)},function(e,t){const r=Yt.decode(e,t);return t+=Yt.encodingLength(r),e.slice(t,t+r)},function(e){const t=e.byteLength;return Yt.encodingLength(t)+t}),Go=ei("double",Xn.BIT64,function(e){const t=new Vr(new Uint8Array(8));return t.setFloat64(0,e,!0),t},function(e,t){return e.getFloat64(t,!0)},function(){return 8});function Bp(n){function e(s){if(null==n[s.toString()])throw new Error("Invalid enum value");return"number"==typeof s?s:n[s]}return ei("enum",Xn.VARINT,function(o){const a=e(o),c=new Uint8Array(Yt.encodingLength(a));return Yt.encode(a,c),c},function(o,a){const m=Yt.decode(o,a).toString();if(null==n[m])throw new Error("Invalid enum value");return n[m]},function(o){return Yt.encodingLength(e(o))})}const yR=(ei("fixed32",Xn.BIT32,function(e){const t=new Vr(new Uint8Array(4));return t.setInt32(0,e,!0),t},function(e,t){return e.getInt32(t,!0)},function(){return 4}),function(e){return 8}),mR=(ei("fixed64",Xn.BIT64,function(e){const t=new Vr(new Uint8Array(8));return t.setBigInt64(0,e,!0),t},function(e,t){return e.getBigInt64(t,!0)},yR),function(){return 4}),vR=(ei("float",Xn.BIT32,function(e){const t=new Vr(new Uint8Array(4));return t.setFloat32(0,e,!0),t},function(e,t){return e.getFloat32(t,!0)},mR),function(e){return ww.encodingLength(e)}),ER=(ei("int32",Xn.VARINT,function(e){const t=new Uint8Array(vR(e));return ww.encode(e,t),t},function(e,t){return ww.decode(e,t)},vR),0x7fn),dc={encodingLength(n){let e=0;for(;n>=0x80n;e++)n>>=7n;return e+1},encode(n,e){const t=Hu(e);let r=0;for(;ER>=7n;t.set(r,Number(n))},decode:(n,e=0)=>Fi.fromBytes(n,e).toBigInt(!0)},_w={encodingLength:n=>n<0n?10:dc.encodingLength(n),encode(n,e,t=0){if(!(n<0n))return dc.encode(n,e);Fi.fromBigInt(n).toBytes(e,t)},decode:(n,e=0)=>Fi.fromBytes(n,e).toBigInt(!1)},Dw={encodingLength:n=>dc.encodingLength(n>=0?2n*n:-2n*n-1n),encode(n,e,t=0){Fi.fromBigInt(n).zzEncode().toBytes(e,t)},decode:(n,e=0)=>Fi.fromBytes(n,e).zzDecode().toBigInt(!1)},wR=function(e){return _w.encodingLength(e)};function ur(n){return ei("message",Xn.LENGTH_DELIMITED,function(s){const o=new Vr;function a(m,T,R){if(null==m){if(!0===R.optional)return;throw new Error(`Non optional field "${R.name}" was ${null===m?"null":"undefined"}`)}const k=T<<3|R.codec.type,U=new Uint8Array(Yt.encodingLength(k));Yt.encode(k,U);const Q=R.codec.encode(m);o.append(U),o.append(Q)}for(const[m,T]of Object.entries(n)){const R=parseInt(m);if(!0===T.repeats){if(!Array.isArray(s[T.name]))throw new Error(`Repeating field "${T.name}" was not an array`);for(const k of s[T.name])a(k,R,T)}else a(s[T.name],R,T)}const c=new Uint8Array(Yt.encodingLength(o.length));return Yt.encode(o.length,c),new Vr(c,o)},function(s,o){const a=Yt.decode(s,o),c=(o+=Yt.encodingLength(a))+a,m={};for(;o>3];let Q=0;if(R===Xn.VARINT)if(null!=U){const X=U.codec.decode(s,o);Q=U.codec.encodingLength(X)}else{const X=Yt.decode(s,o);Q=Yt.encodingLength(X)}else if(R===Xn.BIT64)Q=8;else if(R===Xn.LENGTH_DELIMITED){const X=Yt.decode(s,o);Q=X+Yt.encodingLength(X)}else if(R===Xn.BIT32)Q=4;else{if(R===Xn.START_GROUP)throw new Error("Unsupported wire type START_GROUP");if(R===Xn.END_GROUP)throw new Error("Unsupported wire type END_GROUP")}if(null!=U){const X=U.codec.decode(s,o);!0===U.repeats?(null==m[U.name]&&(m[U.name]=[]),m[U.name].push(X)):m[U.name]=X}o+=Q}for(const T of Object.values(n))!0===T.repeats&&null==m[T.name]&&(m[T.name]=[]);return m},function(s){let o=0;for(const a of Object.values(n))o+=a.codec.encodingLength(s[a.name]);return Yt.encodingLength(o)+o})}ei("int64",Xn.VARINT,function(e){const t=new Uint8Array(wR(e));return _w.encode(e,t),t},function(e,t){return 0n|_w.decode(e,t)},wR);const _R=(ei("sfixed32",Xn.BIT32,function(e){const t=new Vr(new Uint8Array(4));return t.setInt32(0,e,!0),t},function(e,t){return e.getInt32(t,!0)},function(){return 4}),function(){return 8}),DR=(ei("sfixed64",Xn.BIT64,function(e){const t=new Vr(new Uint8Array(8));return t.setBigInt64(0,e,!0),t},function(e,t){return e.getBigInt64(t,!0)},_R),function(e){return bw.encodingLength(e)}),SR=(ei("sint32",Xn.VARINT,function(e){const t=new Uint8Array(DR(e));return bw.encode(e,t),t},function(e,t){return bw.decode(e,t)},DR),function(e){return Dw.encodingLength(e)}),zo=ei("sint64",Xn.VARINT,function(e){const t=new Uint8Array(SR(e));return Dw.encode(e,t),t},function(e,t){return Dw.decode(e,t)},SR),Gr=ei("string",Xn.LENGTH_DELIMITED,function(e){const t=_t(e),r=new Uint8Array(Yt.encodingLength(t.byteLength));return Yt.encode(t.length,r),new Vr(r,t)},function(e,t){const r=Yt.decode(e,t);return t+=Yt.encodingLength(r),Mt(e.slice(t,t+r))},function(e){const t=_t(e).byteLength;return Yt.encodingLength(t)+t}),IR=function(e){return Yt.encodingLength(e)},Uf=ei("uint32",Xn.VARINT,function(e){const t=new Uint8Array(IR(e));return Yt.encode(e,t),t},function(e,t){return Yt.decode(e,t)},IR),CR=ei("uint64",Xn.VARINT,function(e){const t=new Uint8Array(dc.encodingLength(e));return dc.encode(e,t),t},function(e,t){return dc.decode(e,t)},function(e){return dc.encodingLength(e)});var Vf=(()=>(function(n){n.codec=()=>ur({1:{name:"payload",codec:fc,optional:!0},2:{name:"contentTopic",codec:Gr,optional:!0},3:{name:"version",codec:Uf,optional:!0},4:{name:"timestampDeprecated",codec:Go,optional:!0},10:{name:"timestamp",codec:zo,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Vf||(Vf={})),Vf))(),cG=N(6577),uG=N(4237);const Ku_algorithm={name:"AES-GCM",length:128},Fp={node:cG,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0};function ms(){if(Fp.web)return Fp.web.subtle;if(Fp.node)return Fp.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 ju=er.randomBytes,Sw=er.sha256;function lG(n,e){return Iw.apply(this,arguments)}function Iw(){return Iw=V(function*(n,e){const[t,r]=yield z2(n,e,{recovered:!0,der:!1});return Ji([t,new Uint8Array([r])],t.length+1)}),Iw.apply(this,arguments)}function Cw(n){return new Uint8Array(uG.keccak256.arrayBuffer(n))}function TR(n,e){let t=1,r=0,i=Promise.resolve(new Uint8Array);for(;r>24,t>>16,t>>8,t]),o=Ji([s,n],s.length+n.length),a=Sw(o);i=i.then(c=>a.then(m=>{const T=new Uint8Array(m);return Ji([c,T],c.length+T.length)})),r+=32,t+=1}return i}function fG(n,e,t){return ms().importKey("raw",e,"AES-CTR",!1,["encrypt"]).then(r=>ms().encrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function dG(n,e,t){return ms().importKey("raw",e,"AES-CTR",!1,["decrypt"]).then(r=>ms().decrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function hG(n,e){const t={name:"HMAC",hash:{name:"SHA-256"}};return ms().importKey("raw",n,t,!1,["sign"]).then(r=>ms().sign(t,r,e)).then(r=>new Uint8Array(r))}function pG(n,e,t){const r={name:"HMAC",hash:{name:"SHA-256"}};return ms().importKey("raw",n,r,!1,["verify"]).then(s=>ms().verify(r,s,t,e))}function AR(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 MU(n,e,t=!1){if(H2(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!H2(e))throw new TypeError("getSharedSecret: second arg must be public key");const r=Bm(e);return r.assertValidity(),r.multiply(io(n)).toRawBytes(t)}(n,e,!0);return new Uint8Array(Gs(t).slice(1))}}function gG(n,e){return Tw.apply(this,arguments)}function Tw(){return Tw=V(function*(n,e){const t=ju(32),r=yield AR(t,n),i=yield TR(r,32),s=ju(16),o=i.slice(0,16),a=yield fG(s,o,e),c=Ji([s,a],s.length+a.length),m=yield Sw(i.slice(16)),T=yield hG(m,c),R=rf(t,!1);return Ji([R,c,T],R.length+c.length+T.length)}),Tw.apply(this,arguments)}function yG(n,e){return xw.apply(this,arguments)}function xw(){return xw=V(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),c=AR(n,t),m=yield TR(c,32),[T,R]=yield Sw(m.slice(16)).then(k=>[m.slice(0,16),k]);if(!(yield pG(R,s,a)))throw new Error("Incorrect MAC");return dG(i,T,o)}}),xw.apply(this,arguments)}function mG(n,e,t){return Rw.apply(this,arguments)}function Rw(){return Rw=V(function*(n,e,t){return ms().importKey("raw",e,Ku_algorithm,!1,["encrypt"]).then(r=>ms().encrypt({iv:n,...Ku_algorithm},r,t)).then(r=>new Uint8Array(r))}),Rw.apply(this,arguments)}function vG(n,e,t){return Pw.apply(this,arguments)}function Pw(){return Pw=V(function*(n,e,t){return ms().importKey("raw",e,Ku_algorithm,!1,["decrypt"]).then(r=>ms().decrypt({iv:n,...Ku_algorithm},r,t)).then(r=>new Uint8Array(r))}),Pw.apply(this,arguments)}function EG(){return ju(12)}function RR(n,e){return Ow.apply(this,arguments)}function Ow(){return Ow=V(function*(n,e){let t=new Uint8Array([0]);t=AG(t,n),t=Ji([t,n]);let r=1+MR(n)+n.length;e&&(r+=65);const s=256-r%256,o=ju(s);if(!xG(o,s))throw new Error("failed to generate random padding of size "+s);let a;if(t=Ji([t,o]),e){t[0]|=4;const c=Cw(t),m=yield lG(c,e);t=Ji([t,m]),a={signature:m,publicKey:rf(e,!1)}}return{payload:t,sig:a}}),Ow.apply(this,arguments)}function Lw(){return Lw=V(function*(n,e){return gG(Gs(e),n)}),Lw.apply(this,arguments)}function PR(n,e){return kw.apply(this,arguments)}function kw(){return kw=V(function*(n,e){return yG(e,n)}),kw.apply(this,arguments)}function Bw(){return Bw=V(function*(n,e){const t=EG();return Ji([yield mG(t,Gs(e),n),t])}),Bw.apply(this,arguments)}function NR(n,e){return Fw.apply(this,arguments)}function Fw(){return Fw=V(function*(n,e){const t=n.length-12,r=n.slice(0,t);return vG(n.slice(t),Gs(e),r)}),Fw.apply(this,arguments)}function AG(n,e){const t=MR(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e.length,!0),r=r.slice(0,t),(n=Ji([n,r]))[0]|=t,n}function MR(n){let e=1;for(let t=n.length;t>=256;t/=256)e++;return e}function xG(n,e){return n.length===e&&(e<=3||-1!==n.findIndex(t=>0!==t))}const Pa=Ur("waku:message"),OR=BigInt(1e6);var Hf=(()=>(function(n){n.Asymmetric="asymmetric",n.Symmetric="symmetric"}(Hf||(Hf={})),Hf))();class uo{constructor(e,t,r){this.proto=e,this._signaturePublicKey=t,this._signature=r}static fromUtf8String(e,t,r){return V(function*(){const i=(n=>_t(n,"utf8"))(e);return uo.fromBytes(i,t,r)})()}static fromBytes(e,t,r){return V(function*(){const{timestamp:i,encPublicKey:s,symKey:o,sigPrivKey:a}=Object.assign({timestamp:new Date},r||{});let T,c=e,m=0;if(s&&o)throw"Pass either `encPublicKey` or `symKey`, not both.";if(s){const R=yield RR(c,a);c=yield function CG(n,e){return Lw.apply(this,arguments)}(R.payload,s),T=R.sig,m=1}else if(o){const R=yield RR(c,a);c=yield function TG(n,e){return Bw.apply(this,arguments)}(R.payload,o),T=R.sig,m=1}return new uo({payload:c,timestampDeprecated:i.valueOf()/1e3,timestamp:BigInt(i.valueOf())*OR,version:m,contentTopic:t},T?.publicKey,T?.signature)})()}static decode(e,t){return V(function*(){const r=Vf.decode(e);return uo.decodeProto(r,t)})()}static decodeProto(e,t){return V(function*(){const r=e.payload;let i,s;if(1===e.version&&r){if(void 0===t)return void Pa("Payload is encrypted but no private keys have been provided.");const o=yield Promise.all(t.map(function(){var R=V(function*({key:k,method:U,contentTopics:Q}){if(!Q||e.contentTopic&&Q.includes(e.contentTopic))switch(U){case Hf.Asymmetric:try{return yield PR(r,k)}catch(X){return void Pa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",X)}case Hf.Symmetric:try{return yield NR(r,k)}catch(X){return void Pa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",X)}default:try{return yield NR(r,k)}catch(X){Pa("Failed to decrypt message using symmetric encryption",X);try{return yield PR(r,k)}catch(ae){return void Pa("Failed to decrypt message using asymmetric encryption",ae)}}}});return function(k){return R.apply(this,arguments)}}())),c=o.filter(R=>!!R);if(0===c.length)return void Pa("Failed to decrypt payload.");const m=c[0],T=yield function _G(n){const e=function DG(n){return 3&new DataView(n.buffer).getUint8(0)}(n);if(0===e)return;const t=function SG(n,e){let t=n.slice(1,1+e);return e<4&&(t=Ji([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 IG(n){return 4==(4&new DataView(n.buffer).getUint8(0))}(n);let o;if(s){const a=function RG(n){return n.slice(n.length-65,n.length)}(n),c=function PG(n,e){return Cw(e?n.slice(0,n.length-65):n)}(n,s),m=function NG(n,e){const r=new DataView(e.slice(64).buffer).getUint8(0);return function NU(n,e,t,r=!1){return dn.fromSignature(n,e,t).toRawBytes(r)}(n,Po.fromCompact(e.slice(0,64)),r,!1)}(c,a);o={signature:a,publicKey:m}}return{payload:i,sig:o}}(m);if(!T)return void Pa("Failed to decode payload.");Object.assign(e,{payload:T.payload}),i=T.sig?.publicKey,s=T.sig?.signature}return new uo(e,i,s)})()}encode(){return Vf.encode(this.proto)}get payloadAsUtf8(){if(!this.payload)return"";try{return(n=>Mt(this.payload,"utf8"))()}catch(e){return Pa("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/OR));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get signaturePublicKey(){return this._signaturePublicKey}get signature(){return this._signature}}var Up,OG=new Uint8Array(16);function LG(){if(!Up&&!(Up=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Up(OG)}const kG=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,FG=function BG(n){return"string"==typeof n&&kG.test(n)};for(var ti=[],Uw=0;Uw<256;++Uw)ti.push((Uw+256).toString(16).substr(1));const Vp=function HG(n,e,t){var r=(n=n||{}).random||(n.rng||LG)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,e){t=t||0;for(var i=0;i<16;++i)e[t+i]=r[i];return e}return function UG(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=(ti[n[e+0]]+ti[n[e+1]]+ti[n[e+2]]+ti[n[e+3]]+"-"+ti[n[e+4]]+ti[n[e+5]]+"-"+ti[n[e+6]]+ti[n[e+7]]+"-"+ti[n[e+8]]+ti[n[e+9]]+"-"+ti[n[e+10]]+ti[n[e+11]]+ti[n[e+12]]+ti[n[e+13]]+ti[n[e+14]]+ti[n[e+15]]).toLowerCase();if(!FG(t))throw TypeError("Stringified UUID is invalid");return t}(r)};var Vw;!function(n){let e;var t;(t=e=n.ContentFilter||(n.ContentFilter={})).codec=()=>ur({1:{name:"contentTopic",codec:Gr,optional:!0}}),t.encode=r=>cr(r,t.codec()),t.decode=r=>ar(r,t.codec()),n.codec=()=>ur({1:{name:"subscribe",codec:hR,optional:!0},2:{name:"topic",codec:Gr,optional:!0},3:{name:"contentFilters",codec:n.ContentFilter.codec(),repeats:!0}}),n.encode=t=>cr(t,n.codec()),n.decode=t=>ar(t,n.codec())}(Vw||(Vw={}));var Hp=(()=>(function(n){n.codec=()=>ur({1:{name:"messages",codec:Kp.codec(),repeats:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Hp||(Hp={})),Hp))(),Kf=(()=>(function(n){n.codec=()=>ur({1:{name:"requestId",codec:Gr,optional:!0},2:{name:"request",codec:Vw.codec(),optional:!0},3:{name:"push",codec:Hp.codec(),optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Kf||(Kf={})),Kf))(),Kp=(()=>(function(n){n.codec=()=>ur({1:{name:"payload",codec:fc,optional:!0},2:{name:"contentTopic",codec:Gr,optional:!0},3:{name:"version",codec:Uf,optional:!0},4:{name:"timestampDeprecated",codec:Go,optional:!0},10:{name:"timestamp",codec:zo,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Kp||(Kp={})),Kp))();class $u{constructor(e){this.proto=e}static createRequest(e,t,r,i=!0){return new $u({requestId:r||Vp(),request:{subscribe:i,topic:e,contentFilters:t},push:void 0})}static decode(e){const t=Kf.decode(e);return new $u(t)}encode(){return Kf.encode(this.proto)}get push(){return this.proto.push}get requestId(){return this.proto.requestId}}const jf="/vac/waku/filter/2.0.0-beta1",lo=Ur("waku:filter");class KG{constructor(e,t){this.libp2p=e,this.subscriptions=new Map,this.decryptionKeys=new Map,this.pubSubTopic=t?.pubSubTopic??kp,this.libp2p.handle(jf,this.onRequest.bind(this)).catch(r=>lo("Failed to register filter protocol",r))}subscribe(e,t,r){var i=this;return V(function*(){const s=r?.pubsubTopic??i.pubSubTopic,o=t.map(R=>({contentTopic:R})),a=$u.createRequest(s,o,void 0,!0),c=a.requestId;if(!c)throw new Error("Internal error: createRequest expected to set `requestId`");const m=yield i.getPeer(r?.peerId),T=yield i.newStream(m);try{const R=yield Ln([a.encode()],Ff(),T,Vu(),function(){var k=V(function*(U){return yield Ea(U)});return function(U){return k.apply(this,arguments)}}());lo("response",R)}catch(R){throw lo("Error subscribing to peer ",m.id.toString(),"for content topics",t,": ",R),R}return i.addCallback(c,e),V(function*(){yield i.unsubscribe(s,o,c,m),i.removeCallback(c)})})()}onRequest(e){var t=this;lo("Receiving message push");try{Ln(e.stream,Vu(),function(){var r=V(function*(i){var a,s=!1,o=!1;try{for(var m,c=Tt(i);s=!(m=yield c.next()).done;s=!1){const R=$u.decode(m.value.slice());R.requestId&&R.push?.messages?.length&&(yield t.pushMessages(R.requestId,R.push.messages))}}catch(T){o=!0,a=T}finally{try{s&&null!=c.return&&(yield c.return())}finally{if(o)throw a}}});return function(i){return r.apply(this,arguments)}}()).then(()=>{lo("Receiving pipe closed.")},r=>{lo("Error with receiving pipe",r)})}catch(r){lo("Error decoding message",r)}}pushMessages(e,t){var r=this;return V(function*(){const i=r.subscriptions.get(e);if(!i)return void lo(`No callback registered for request ID ${e}`);const s=Array.from(r.decryptionKeys).map(([o,{method:a,contentTopics:c}])=>({key:o,method:a,contentTopics:c}));for(const o of t){const a=yield uo.decodeProto(o,s);a?i(a):lo("Not able to decode message")}})()}addCallback(e,t){this.subscriptions.set(e,t)}removeCallback(e){this.subscriptions.delete(e)}unsubscribe(e,t,r,i){var s=this;return V(function*(){const o=$u.createRequest(e,t,r,!1),a=yield s.newStream(i);try{yield Ln([o.encode()],Ff(),a.sink)}catch(c){throw lo("Error unsubscribing",c),c}})()}newStream(e){var t=this;return V(function*(){const r=t.libp2p.connectionManager.getConnections(e.id);if(!r)throw new Error("Failed to get a connection to the peer");return r[0].newStream(jf)})()}getPeer(e){var t=this;return V(function*(){let r;if(e){if(r=yield t.libp2p.peerStore.get(e),!r)throw new Error(`Failed to retrieve connection details for provided peer in peer store: ${e.toString()}`)}else if(r=yield t.randomPeer(),!r)throw new Error("Failed to find known peer that registers waku filter protocol");return r})()}addDecryptionKey(e,t){this.decryptionKeys.set(Gs(e),t??{})}deleteDecryptionKey(e){this.decryptionKeys.delete(Gs(e))}peers(){var e=this;return V(function*(){return vw(e.libp2p,[jf])})()}randomPeer(){var e=this;return V(function*(){return yw(yield e.peers())})()}}var jp=(()=>(function(n){n.codec=()=>ur({1:{name:"pubSubTopic",codec:Gr,optional:!0},2:{name:"message",codec:Gp.codec(),optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(jp||(jp={})),jp))(),$p=(()=>(function(n){n.codec=()=>ur({1:{name:"isSuccess",codec:hR,optional:!0},2:{name:"info",codec:Gr,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}($p||($p={})),$p))(),$f=(()=>(function(n){n.codec=()=>ur({1:{name:"requestId",codec:Gr,optional:!0},2:{name:"request",codec:jp.codec(),optional:!0},3:{name:"response",codec:$p.codec(),optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}($f||($f={})),$f))(),Gp=(()=>(function(n){n.codec=()=>ur({1:{name:"payload",codec:fc,optional:!0},2:{name:"contentTopic",codec:Gr,optional:!0},3:{name:"version",codec:Uf,optional:!0},4:{name:"timestampDeprecated",codec:Go,optional:!0},10:{name:"timestamp",codec:zo,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Gp||(Gp={})),Gp))();class Gf{constructor(e){this.proto=e}static createRequest(e,t){return new Gf({requestId:Vp(),request:{message:e.proto,pubSubTopic:t},response:void 0})}static decode(e){const t=$f.decode(e);return new Gf(t)}encode(){return $f.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const zf="/vac/waku/lightpush/2.0.0-beta1";class jG{constructor(e,t){this.libp2p=e,this.pubSubTopic=t?.pubSubTopic??kp}push(e,t){var r=this;return V(function*(){let i;if(t?.peerId){if(i=yield r.libp2p.peerStore.get(t.peerId),!i)throw"Peer is unknown"}else i=yield r.randomPeer();if(!i)throw"No peer available";if(!i.protocols.includes(zf))throw"Peer does not register waku light push protocol";const s=r.libp2p.connectionManager.getConnections(i.id);if(!s)throw"Failed to get a connection to the peer";const o=yield s[0].newStream(zf);try{const c=Gf.createRequest(e,t?.pubSubTopic?t.pubSubTopic:r.pubSubTopic),m=yield Ln([c.encode()],Ff(),o,Vu(),function(){var T=V(function*(R){return yield Ea(R)});return function(R){return T.apply(this,arguments)}}());try{const T=Ji(m);return Gf.decode(T).response||(console.log("No response in PushRPC"),null)}catch(T){console.log("Failed to decode push reply",T)}}catch(a){console.log("Failed to send waku light push request",a)}return null})()}peers(){var e=this;return V(function*(){return vw(e.libp2p,[zf])})()}randomPeer(){var e=this;return V(function*(){return yw(yield e.peers())})()}}const Hw=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];var hc,zp=(()=>(function(n){n.codec=()=>ur({1:{name:"digest",codec:fc,optional:!0},2:{name:"receivedTime",codec:zo,optional:!0},3:{name:"senderTime",codec:zo,optional:!0},4:{name:"pubsubTopic",codec:Gr,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(zp||(zp={})),zp))();!function(n){let e;var r;let t;(r=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",r.DIRECTION_FORWARD="DIRECTION_FORWARD",function(r){r[r.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",r[r.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(r){r.codec=()=>Bp(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>ur({1:{name:"pageSize",codec:CR,optional:!0},2:{name:"cursor",codec:zp.codec(),optional:!0},3:{name:"direction",codec:n.Direction.codec(),optional:!0}}),n.encode=r=>cr(r,n.codec()),n.decode=r=>ar(r,n.codec())}(hc||(hc={}));var Qp,Wp=(()=>(function(n){n.codec=()=>ur({1:{name:"contentTopic",codec:Gr,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Wp||(Wp={})),Wp))(),qp=(()=>(function(n){n.codec=()=>ur({2:{name:"pubSubTopic",codec:Gr,optional:!0},3:{name:"contentFilters",codec:Wp.codec(),repeats:!0},4:{name:"pagingInfo",codec:hc.codec(),optional:!0},5:{name:"startTime",codec:zo,optional:!0},6:{name:"endTime",codec:zo,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(qp||(qp={})),qp))();!function(n){let e;var r;let t;(r=e=n.Error||(n.Error={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",r.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(r){r[r.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",r[r.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(r){r.codec=()=>Bp(t)}(e=n.Error||(n.Error={})),n.codec=()=>ur({2:{name:"messages",codec:Zp.codec(),repeats:!0},3:{name:"pagingInfo",codec:hc.codec(),optional:!0},4:{name:"error",codec:n.Error.codec(),optional:!0}}),n.encode=r=>cr(r,n.codec()),n.decode=r=>ar(r,n.codec())}(Qp||(Qp={}));var Jp,Yp=(()=>(function(n){n.codec=()=>ur({1:{name:"requestId",codec:Gr,optional:!0},2:{name:"query",codec:qp.codec(),optional:!0},3:{name:"response",codec:Qp.codec(),optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Yp||(Yp={})),Yp))(),Zp=(()=>(function(n){n.codec=()=>ur({1:{name:"payload",codec:fc,optional:!0},2:{name:"contentTopic",codec:Gr,optional:!0},3:{name:"version",codec:Uf,optional:!0},4:{name:"timestampDeprecated",codec:Go,optional:!0},10:{name:"timestamp",codec:zo,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Zp||(Zp={})),Zp))(),Xp=(()=>(function(n){n.codec=()=>ur({1:{name:"digest",codec:fc,optional:!0},2:{name:"receivedTime",codec:Go,optional:!0},3:{name:"senderTime",codec:Go,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(Xp||(Xp={})),Xp))();!function(n){let e;var r;let t;(r=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",r.DIRECTION_FORWARD="DIRECTION_FORWARD",function(r){r[r.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",r[r.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(r){r.codec=()=>Bp(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>ur({1:{name:"pageSize",codec:CR,optional:!0},2:{name:"cursor",codec:Xp.codec(),optional:!0},3:{name:"direction",codec:n.Direction.codec(),optional:!0}}),n.encode=r=>cr(r,n.codec()),n.decode=r=>ar(r,n.codec())}(Jp||(Jp={}));var Kw,eg=(()=>(function(n){n.codec=()=>ur({1:{name:"contentTopic",codec:Gr,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(eg||(eg={})),eg))(),tg=(()=>(function(n){n.codec=()=>ur({2:{name:"pubSubTopic",codec:Gr,optional:!0},3:{name:"contentFilters",codec:eg.codec(),repeats:!0},4:{name:"pagingInfo",codec:Jp.codec(),optional:!0},5:{name:"startTime",codec:Go,optional:!0},6:{name:"endTime",codec:Go,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(tg||(tg={})),tg))();!function(n){let e;var r;let t;(r=e=n.Error||(n.Error={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",r.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(r){r[r.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",r[r.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(r){r.codec=()=>Bp(t)}(e=n.Error||(n.Error={})),n.codec=()=>ur({2:{name:"messages",codec:rg.codec(),repeats:!0},3:{name:"pagingInfo",codec:Jp.codec(),optional:!0},4:{name:"error",codec:n.Error.codec(),optional:!0}}),n.encode=r=>cr(r,n.codec()),n.decode=r=>ar(r,n.codec())}(Kw||(Kw={}));var ng=(()=>(function(n){n.codec=()=>ur({1:{name:"requestId",codec:Gr,optional:!0},2:{name:"query",codec:tg.codec(),optional:!0},3:{name:"response",codec:Kw.codec(),optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(ng||(ng={})),ng))(),rg=(()=>(function(n){n.codec=()=>ur({1:{name:"payload",codec:fc,optional:!0},2:{name:"contentTopic",codec:Gr,optional:!0},3:{name:"version",codec:Uf,optional:!0},4:{name:"timestampDeprecated",codec:Go,optional:!0},10:{name:"timestamp",codec:zo,optional:!0}}),n.encode=e=>cr(e,n.codec()),n.decode=e=>ar(e,n.codec())}(rg||(rg={})),rg))(),Na=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(Na||(Na={})),Na))();const LR=BigInt(1e6);var Gu=(()=>(function(n){n.BACKWARD="backward",n.FORWARD="forward"}(Gu||(Gu={})),Gu))();class Wf{constructor(e,t){switch(this.proto=e,this.storeCodec=t,t){case Na.V2Beta3:this.historyRpc=ng;break;case Na.V2Beta4:this.historyRpc=Yp;break;default:throw`Internal Error: Unexpected store codec value received in constructor: ${t}`}}get query(){return this.proto.query}get response(){return this.proto.response}static createQuery(e){const t=e.storeCodec??Na.V2Beta4,r=e.contentTopics.map(s=>({contentTopic:s})),i=function GG(n){switch(n){case Gu.BACKWARD:return hc.Direction.DIRECTION_BACKWARD_UNSPECIFIED;case Gu.FORWARD:return hc.Direction.DIRECTION_FORWARD;default:return hc.Direction.DIRECTION_BACKWARD_UNSPECIFIED}}(e.pageDirection);switch(t){case Na.V2Beta3:return(()=>{const s={pageSize:BigInt(e.pageSize),cursor:e.cursor,direction:i};let o,a;return e.startTime&&(o=e.startTime.valueOf()/1e3),e.endTime&&(a=e.endTime.valueOf()/1e3),new Wf({requestId:Vp(),query:{pubSubTopic:e.pubSubTopic,contentFilters:r,pagingInfo:s,startTime:o,endTime:a},response:void 0},t)})();case Na.V2Beta4:return(()=>{const s={pageSize:BigInt(e.pageSize),cursor:e.cursor,direction:i};let o,a;return e.startTime&&(o=BigInt(e.startTime.valueOf())*LR),e.endTime&&(a=BigInt(e.endTime.valueOf())*LR),new Wf({requestId:Vp(),query:{pubSubTopic:e.pubSubTopic,contentFilters:r,pagingInfo:s,startTime:o,endTime:a},response:void 0},t)})();default:throw`Internal Error: Unexpected store codec value received in createQuery: ${t}`}}decode(e){const t=this.historyRpc.decode(e);return new Wf(t,this.storeCodec)}encode(){return this.historyRpc.encode(this.proto)}}var zG=Qp.Error;const pc=Ur("waku:store");class qG{constructor(e,t){this.libp2p=e,this.pubSubTopic=t?.pubSubTopic??kp,this.decryptionKeys=new Map}queryHistory(e,t){var r=this;return V(function*(){let i,s;t?.timeFilter&&(i=t.timeFilter.startTime,s=t.timeFilter.endTime);const o=Object.assign({pubSubTopic:r.pubSubTopic,pageDirection:Gu.BACKWARD,pageSize:10},t,{contentTopics:e,startTime:i,endTime:s});let a;if(pc("Querying history with the following options",{peerId:t?.peerId?.toString(),...t}),o.peerId){if(a=yield r.libp2p.peerStore.get(o.peerId),!a)throw`Failed to retrieve connection details for provided peer in peer store: ${o.peerId.toString()}`}else if(a=yield r.randomPeer(),!a)throw"Failed to find known peer that registers waku store protocol";let c="";for(const U of Object.values(lc))a.protocols.includes(U)&&(c=U);if(pc(`Use store codec ${c}`),!c)throw`Peer does not register waku store protocol: ${a.id.toString()}`;Object.assign(o,{storeCodec:c});const m=r.libp2p.connectionManager.getConnections(a.id);if(!m||!m.length)throw"Failed to get a connection to the peer";const T=Array.from(r.decryptionKeys).map(([U,{method:Q,contentTopics:X}])=>({key:U,method:Q,contentTopics:X}));o.decryptionKeys&&o.decryptionKeys.forEach(U=>{T.push({key:Gs(U),contentTopics:e.length?e:void 0,method:void 0})});const R=[];let k;for(;;){const U=yield m[0].newStream(c),Q=Object.assign(o,{cursor:k}),X=Wf.createQuery(Q);pc("Querying store peer",m[0].remoteAddr.toString());const ae=yield Ln([X.encode()],Ff(),U,Vu(),function(){var mt=V(function*(Zt){return yield Ea(Zt)});return function(Zt){return mt.apply(this,arguments)}}()),he=Ji(ae),Ae=X.decode(he);if(!Ae.response)return pc("No message returned from store: `response` field missing"),R;const ue=Ae.response;if(ue.error&&ue.error!==zG.ERROR_NONE_UNSPECIFIED)throw"History response contains an Error: "+ue.error;if(!ue.messages||!ue.messages.length)return pc("No message returned from store: `messages` array empty"),R;pc(`${ue.messages.length} messages retrieved for (${o.pubSubTopic})`,e);const Re=[];yield Promise.all(ue.messages.map(function(){var mt=V(function*(Zt){const wn=yield uo.decodeProto(Zt,T);wn&&(R.push(wn),Re.push(wn))});return function(Zt){return mt.apply(this,arguments)}}()));let Le=!1;o.callback&&(Le=Boolean(o.callback(Re)));const Fe=ue.pagingInfo?.pageSize,wt=X.query?.pagingInfo?.pageSize;if(Le||Fe&&wt&&Fe(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(es||(es={})),es))();class ZG{constructor(e,t,r,i,s){this.libp2p=t,this.relay=t.pubsub,this.store=r,this.filter=s,this.lightPush=i,this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const o=e.pingKeepAlive||0,a=e.relayKeepAlive||300;t.connectionManager.addEventListener("peer:connect",c=>{this.startKeepAlive(c.detail.remotePeer,o,a)}),t.connectionManager.addEventListener("peer:disconnect",c=>{this.stopKeepAlive(c.detail.remotePeer)}),e?.decryptionKeys?.forEach(c=>{this.addDecryptionKey(c)})}dial(e,t){var r=this;return V(function*(){const i=t??[es.Relay],s=[];if(i.includes(es.Relay)&&Hw.forEach(o=>s.push(o)),i.includes(es.Store))for(const o of Object.values(lc))s.push(o);return i.includes(es.LightPush)&&s.push(zf),i.includes(es.Filter)&&s.push(jf),r.libp2p.dialProtocol(e,s)})()}addPeerToAddressBook(e,t){let r;r="string"==typeof e?_r(e):e;const i=t.map(s=>"string"==typeof s?function G9(n){return new vn(n)}(s):s);this.libp2p.peerStore.addressBook.set(r,i)}start(){var e=this;return V(function*(){yield e.libp2p.start()})()}stop(){var e=this;return V(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}addDecryptionKey(e,t){this.relay.addDecryptionKey(e,t),this.store.addDecryptionKey(e,t),this.filter.addDecryptionKey(e,t)}deleteDecryptionKey(e){this.relay.deleteDecryptionKey(e),this.store.deleteDecryptionKey(e),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(s=>{kR(`Ping failed (${i})`,s)})},1e3*t)),0!==r&&(this.relayKeepAliveTimers[i]=setInterval(()=>{kR("Sending Waku Relay ping message"),uo.fromBytes(new Uint8Array,"/relay-ping/1/ping/null").then(s=>this.relay.send(s))},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 BR=Symbol.for("@achingbrain/uint8arraylist");function FR(n,e,t){if(null==e||e<0||e>=t)throw new RangeError("index is out of bounds");let r=0;for(const i of n){const s=r+i.byteLength;if(e0;){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 or(r,i)}subarray(e,t){const{bufs:r}=this._subList(e,t),i=new ts;return i.appendAll(r),i}_subList(e,t){if(null==e&&null==t)return{bufs:this.bufs,length:this.length};if((e=e??0)<0&&(e=this.length+e),(t=t??(this.length>0?this.length:0))<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index out of bounds");if(e===t)return{bufs:[],length:0};const r=[];let i=0;for(const s of this.bufs){const o=i,a=o+s.byteLength,m=t>o&&t<=a;let R,k;if(i=a,e>=o&&e=a&&(R=0,k=s.byteLength),null!=R&&null!=k&&r.push(s.subarray(R,k)),m)break}return{bufs:r,length:t-e}}getInt8(e){const t=this.slice(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=new Uint8Array(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.slice(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const i=new Uint8Array(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,r),this.write(i,e)}getInt32(e,t){const r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const i=new Uint8Array(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,r),this.write(i,e)}getBigInt64(e,t){const r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const i=new Uint8Array(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,r),this.write(i,e)}getUint8(e){const t=this.slice(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=new Uint8Array(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.slice(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const i=new Uint8Array(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,r),this.write(i,e)}getUint32(e,t){const r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const i=new Uint8Array(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,r),this.write(i,e)}getBigUint64(e,t){const r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const i=new Uint8Array(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,r),this.write(i,e)}getFloat32(e,t){const r=this.slice(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const i=new Uint8Array(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,r),this.write(i,e)}getFloat64(e,t){const r=this.slice(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const i=new Uint8Array(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}}function zu(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 VR=4294967296;class Ui{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(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)}zzDecode(){const e=-(1&this.lo);return new Ui((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new Ui(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=zu(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 Ui;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>VR&&(i=0,++r>VR&&(r=0))),new Ui(r,i)}static fromNumber(e){if(0===e)return new Ui;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 Ui(i,r)}static fromBytes(e,t){const r=zu(e),i=new Ui;let s=0;if(!(e.length-t>4)){for(;s<3;++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}return i.lo=(i.lo|(127&r.get(t++))<<7*s)>>>0,i}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;if(s=0,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 for(;s<5;++s){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 Error("invalid varint encoding")}}const ez=Math.pow(2,31),tz=Math.pow(2,7),nz=Math.pow(2,14),rz=Math.pow(2,21),iz=Math.pow(2,28),sz=Math.pow(2,35),oz=Math.pow(2,42),az=Math.pow(2,49),cz=Math.pow(2,56),uz=Math.pow(2,63),fn={encodingLength:n=>n=ez;)r.set(t++,255&n|128),n/=128;for(;(-128&n)>0;)r.set(t++,255&n|128),n>>>=7;r.set(t,0|n)},decode(n,e=0){const t=zu(n);let r=4294967295;if(r=(127&t.get(e))>>>0,t.get(e++)<128||(r=(r|(127&t.get(e))<<7)>>>0,t.get(e++)<128)||(r=(r|(127&t.get(e))<<14)>>>0,t.get(e++)<128)||(r=(r|(127&t.get(e))<<21)>>>0,t.get(e++)<128)||(r=(r|(15&t.get(e))<<28)>>>0,t.get(e++)<128))return r;if((e+=5)>n.length)throw RangeError(`index out of range: ${e} > ${n.length}`);return r}},jw={encodingLength:n=>n<0?10:fn.encodingLength(n),encode(n,e){if(n<0){let t=0;const r=zu(e),i=Ui.fromNumber(n);for(;i.hi>0;)r.set(t++,127&i.lo|128),i.lo=(i.lo>>>7|i.hi<<25)>>>0,i.hi>>>=7;for(;i.lo>127;)r.set(t++,127&i.lo|128),i.lo=i.lo>>>7;r.set(t++,i.lo)}else fn.encode(n,e)},decode:(n,e=0)=>0|fn.decode(n,e)},$w={encodingLength:n=>fn.encodingLength(n=(n<<1^n>>31)>>>0),encode:(n,e,t=0)=>fn.encode(n=(n<<1^n>>31)>>>0,e),decode(n,e=0){const t=fn.decode(n,e);return t>>>1^-(1&t)|0}};function Gw(n,e){const t=new Uint8Array(fn.encodingLength(n.length));return fn.encode(n.length,t),e.decode(new ts(t,n),0)}function zw(n,e){const t=e.encode(n),r=fn.encodingLength(fn.decode(t));return t.slice(r)}var nr=(()=>(function(n){n[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"}(nr||(nr={})),nr))();function yi(n,e,t,r,i){return{name:n,type:e,encode:t,decode:r,encodingLength:i}}yi("bool",nr.VARINT,function(e){return Uint8Array.from([e?1:0])},function(e,t){return e.get(t)>0},function(){return 1});const Wu=yi("bytes",nr.LENGTH_DELIMITED,function(e){const t=new Uint8Array(fn.encodingLength(e.byteLength));return fn.encode(e.byteLength,t),new ts(t,e)},function(e,t){const r=fn.decode(e,t);return t+=fn.encodingLength(r),e.slice(t,t+r)},function(e){const t=e.byteLength;return fn.encodingLength(t)+t});yi("double",nr.BIT64,function(e){const t=new ts(new Uint8Array(8));return t.setFloat64(0,e,!0),t},function(e,t){return e.getFloat64(t,!0)},function(){return 8});const $R=(yi("fixed32",nr.BIT32,function(e){const t=new ts(new Uint8Array(4));return t.setInt32(0,e,!0),t},function(e,t){return e.getInt32(t,!0)},function(){return 4}),function(e){return 8}),GR=(yi("fixed64",nr.BIT64,function(e){const t=new ts(new Uint8Array(8));return t.setBigInt64(0,e,!0),t},function(e,t){return e.getBigInt64(t,!0)},$R),function(){return 4}),zR=(yi("float",nr.BIT32,function(e){const t=new ts(new Uint8Array(4));return t.setFloat32(0,e,!0),t},function(e,t){return e.getFloat32(t,!0)},GR),function(e){return jw.encodingLength(e)}),WR=(yi("int32",nr.VARINT,function(e){const t=new Uint8Array(zR(e));return jw.encode(e,t),t},function(e,t){return jw.decode(e,t)},zR),0x7fn),gc={encodingLength(n){let e=0;for(;n>=0x80n;e++)n>>=7n;return e+1},encode(n,e){const t=zu(e);let r=0;for(;WR>=7n;t.set(r,Number(n))},decode:(n,e=0)=>Ui.fromBytes(n,e).toBigInt(!0)},Ww={encodingLength:n=>n<0n?10:gc.encodingLength(n),encode(n,e,t=0){if(!(n<0n))return gc.encode(n,e);Ui.fromBigInt(n).toBytes(e,t)},decode:(n,e=0)=>Ui.fromBytes(n,e).toBigInt(!1)},qw={encodingLength:n=>gc.encodingLength(n>=0?2n*n:-2n*n-1n),encode(n,e,t=0){Ui.fromBigInt(n).zzEncode().toBytes(e,t)},decode:(n,e=0)=>Ui.fromBytes(n,e).zzDecode().toBigInt(!1)},qR=function(e){return Ww.encodingLength(e)};function Qw(n){return yi("message",nr.LENGTH_DELIMITED,function(s){const o=new ts;function a(m,T,R){if(null==m){if(!0===R.optional)return;throw new Error(`Non optional field "${R.name}" was ${null===m?"null":"undefined"}`)}const k=T<<3|R.codec.type,U=new Uint8Array(fn.encodingLength(k));fn.encode(k,U);const Q=R.codec.encode(m);o.append(U),o.append(Q)}for(const[m,T]of Object.entries(n)){const R=parseInt(m);if(!0===T.repeats){if(!Array.isArray(s[T.name]))throw new Error(`Repeating field "${T.name}" was not an array`);for(const k of s[T.name])a(k,R,T)}else a(s[T.name],R,T)}const c=new Uint8Array(fn.encodingLength(o.length));return fn.encode(o.length,c),new ts(c,o)},function(s,o){const a=fn.decode(s,o),c=(o+=fn.encodingLength(a))+a,m={};for(;o>3];let Q=0;if(R===nr.VARINT)if(null!=U){const X=U.codec.decode(s,o);Q=U.codec.encodingLength(X)}else{const X=fn.decode(s,o);Q=fn.encodingLength(X)}else if(R===nr.BIT64)Q=8;else if(R===nr.LENGTH_DELIMITED){const X=fn.decode(s,o);Q=X+fn.encodingLength(X)}else if(R===nr.BIT32)Q=4;else{if(R===nr.START_GROUP)throw new Error("Unsupported wire type START_GROUP");if(R===nr.END_GROUP)throw new Error("Unsupported wire type END_GROUP")}if(null!=U){const X=U.codec.decode(s,o);!0===U.repeats?(null==m[U.name]&&(m[U.name]=[]),m[U.name].push(X)):m[U.name]=X}o+=Q}for(const T of Object.values(n))!0===T.repeats&&null==m[T.name]&&(m[T.name]=[]);return m},function(s){let o=0;for(const a of Object.values(n))o+=a.codec.encodingLength(s[a.name]);return fn.encodingLength(o)+o})}yi("int64",nr.VARINT,function(e){const t=new Uint8Array(qR(e));return Ww.encode(e,t),t},function(e,t){return 0n|Ww.decode(e,t)},qR);const YR=(yi("sfixed32",nr.BIT32,function(e){const t=new ts(new Uint8Array(4));return t.setInt32(0,e,!0),t},function(e,t){return e.getInt32(t,!0)},function(){return 4}),function(){return 8}),ZR=(yi("sfixed64",nr.BIT64,function(e){const t=new ts(new Uint8Array(8));return t.setBigInt64(0,e,!0),t},function(e,t){return e.getBigInt64(t,!0)},YR),function(e){return $w.encodingLength(e)}),XR=(yi("sint32",nr.VARINT,function(e){const t=new Uint8Array(ZR(e));return $w.encode(e,t),t},function(e,t){return $w.decode(e,t)},ZR),function(e){return qw.encodingLength(e)}),JR=(yi("sint64",nr.VARINT,function(e){const t=new Uint8Array(XR(e));return qw.encode(e,t),t},function(e,t){return qw.decode(e,t)},XR),yi("string",nr.LENGTH_DELIMITED,function(e){const t=_t(e),r=new Uint8Array(fn.encodingLength(t.byteLength));return fn.encode(t.length,r),new ts(r,t)},function(e,t){const r=fn.decode(e,t);return t+=fn.encodingLength(r),Mt(e.slice(t,t+r))},function(e){const t=_t(e).byteLength;return fn.encodingLength(t)+t}),function(e){return fn.encodingLength(e)}),$z=(yi("uint32",nr.VARINT,function(e){const t=new Uint8Array(JR(e));return fn.encode(e,t),t},function(e,t){return fn.decode(e,t)},JR),yi("uint64",nr.VARINT,function(e){const t=new Uint8Array(gc.encodingLength(e));return gc.encode(e,t),t},function(e,t){return gc.decode(e,t)},function(e){return gc.encodingLength(e)}));var qf=(()=>(function(n){n.codec=()=>Qw({1:{name:"publicKey",codec:Wu},2:{name:"payloadType",codec:Wu},3:{name:"payload",codec:Wu},5:{name:"signature",codec:Wu}}),n.encode=e=>zw(e,n.codec()),n.decode=e=>Gw(e,n.codec())}(qf||(qf={})),qf))();class Ma{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=qf.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload,signature:this.signature})),this.marshaled}equals(e){return $r(this.marshal(),e.marshal())}validate(e){var t=this;return V(function*(){const r=eP(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Tu(t.peerId.publicKey).verify(r,t.signature)})()}}Ma.createFromProtobuf=function(){var n=V(function*(e){const t=qf.decode(e),r=yield xu(t.publicKey);return new Ma({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),Ma.seal=function(){var n=V(function*(e,t){const r=e.domain,i=e.codec,s=e.marshal(),o=eP(r,i,s);if(null==t.privateKey)throw new Error("Missing private key");const c=yield(yield Au(t.privateKey)).sign(o);return new Ma({peerId:t,payloadType:i,payload:s,signature:c})});return function(e,t){return n.apply(this,arguments)}}(),Ma.openAndCertify=function(){var n=V(function*(e,t){const r=yield Ma.createFromProtobuf(e);if(!(yield r.validate(t)))throw se(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 eP=(n,e,t)=>{const r=_t(n),i=Vn.encode(r.byteLength),s=Vn.encode(e.length),o=Vn.encode(t.length);return or([new Uint8Array(i),r,new Uint8Array(s),e,new Uint8Array(o),t])};var tP;!function(n){let e;var t;(t=e=n.AddressInfo||(n.AddressInfo={})).codec=()=>Qw({1:{name:"multiaddr",codec:Wu}}),t.encode=r=>zw(r,t.codec()),t.decode=r=>Gw(r,t.codec()),n.codec=()=>Qw({1:{name:"peerId",codec:Wu},2:{name:"seq",codec:$z},3:{name:"addresses",codec:n.AddressInfo.codec(),repeats:!0}}),n.encode=t=>zw(t,n.codec()),n.decode=t=>Gw(t,n.codec())}(tP||(tP={})),Uint8Array.from([3,1]);const nP=()=>{};class zz{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??nP,this.onDisconnect=e.onDisconnect??nP}get[Symbol.toStringTag](){return jE.toString()}get[jE](){return!0}setRegistrar(e){var t=this;return V(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class qz{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 Qz=N(8479);const{RPC:ig}=Qz,rP="/floodsub/1.0.0",iP="/meshsub/1.0.0",Zw="/meshsub/1.1.0",Qu=5e3;function Wo(n=[],e){return{subscriptions:[],messages:n,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}function qo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(og||(og={})),og))(),Oa=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Author=1]="Author",n[n.Anonymous=2]="Anonymous"}(Oa||(Oa={})),Oa))(),fo=(()=>(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}(fo||(fo={})),fo))(),vs=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(vs||(vs={})),vs))(),Ai=(()=>(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"}(Ai||(Ai={})),Ai))(),Es=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(Es||(Es={})),Es))();function oP(n){switch(n){case fo.Ignore:return vs.Ignore;case fo.Reject:return vs.Reject}}function Jw(){return Jw=V(function*(n,e){switch(n){case sg:{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 Au(e.privateKey);return{type:Oa.Signing,author:e,key:e.publicKey,privateKey:t}}case Xw:return{type:Oa.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),Jw.apply(this,arguments)}const qn="ERR_INVALID_PEER_SCORE_PARAMS",AW={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},xW={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 RW(n={}){return{...AW,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function PW(n={}){return{...xW,...n}}(r),e),{}):{}}}function MW(n){if(n.topicWeight<0)throw se(new Error("invalid topic weight; must be >= 0"),qn);if(0===n.timeInMeshQuantum)throw se(new Error("invalid TimeInMeshQuantum; must be non zero"),qn);if(n.timeInMeshWeight<0)throw se(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),qn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw se(new Error("invalid TimeInMeshQuantum; must be positive"),qn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw se(new Error("invalid TimeInMeshCap; must be positive"),qn);if(n.firstMessageDeliveriesWeight<0)throw se(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),qn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw se(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),qn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw se(new Error("invalid FirstMessageDeliveriesCap; must be positive"),qn);if(n.meshMessageDeliveriesWeight>0)throw se(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),qn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw se(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),qn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw se(new Error("invalid MeshMessageDeliveriesCap; must be positive"),qn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw se(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),qn);if(n.meshMessageDeliveriesWindow<0)throw se(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),qn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw se(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),qn);if(n.meshFailurePenaltyWeight>0)throw se(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),qn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw se(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),qn);if(n.invalidMessageDeliveriesWeight>0)throw se(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),qn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw se(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),qn)}const OW={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function LW(n={}){return{...OW,...n}}function kW(n,e,t,r){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{const c=t.topics[o];if(void 0===c)return;let m=0;if(a.inMesh){let U=a.meshTime/c.timeInMeshQuantum;U>c.timeInMeshCap&&(U=c.timeInMeshCap),m+=U*c.timeInMeshWeight}let T=a.firstMessageDeliveries;if(T>c.firstMessageDeliveriesCap&&(T=c.firstMessageDeliveriesCap),m+=T*c.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),c=a?a.size:0;if(c>t.IPColocationFactorThreshold){const m=c-t.IPColocationFactorThreshold;i+=m*m*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){const o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}var BW=N(1807),xi=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(xi||(xi={})),xi))();class FW{constructor(){this.records=new Map,this.queue=new BW}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:xi.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 se(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),qn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw se(new Error("invalid IPColocationFactorThreshold; must be at least 1"),qn);if(n.behaviourPenaltyWeight>0)throw se(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),qn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw se(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),qn);if(n.decayInterval<1e3)throw se(new Error("invalid DecayInterval; must be at least 1s"),qn);if(n.decayToZero<=0||n.decayToZero>=1)throw se(new Error("invalid DecayToZero; must be between 0 and 1"),qn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??kW}init(e){this.components=e}get size(){return this.peerStats.size}start(){this._backgroundInterval?Yu("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),Yu("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),Yu("stopped")):Yu("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)})):Yu("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,xi[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case vs.Error:return void this.markInvalidMessageDelivery(e,r);case vs.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===xi.unknown)return i===vs.Ignore?(s.status=xi.ignored,void s.peers.clear()):(s.status=xi.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());Yu("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,xi[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case xi.unknown:i.peers.add(e);break;case xi.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case xi.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 m=s-r,T=m>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,m,T),T)return}o.meshMessageDeliveries=Math.min(a.meshMessageDeliveriesCap,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(_r(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 VW{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 Qo=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(Qo||(Qo={})),Qo))(),yc=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(yc||(yc={})),yc))(),Zu=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(Zu||(Zu={})),Zu))(),Xu=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(Xu||(Xu={})),Xu))(),mc=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(mc||(mc={})),mc))();const aP=_t("libp2p-pubsub:");function tb(){return tb=V(function*(n,e,t){switch(n.type){case Oa.Signing:{const r={from:n.author.toBytes(),data:t,seqno:sf(8),topic:e,signature:void 0,key:void 0},i=or([aP,ig.Message.encode(r).finish()]);return r.signature=yield n.privateKey.sign(i),r.key=n.key,r}case Oa.Author:return{from:n.author.toBytes(),data:t,seqno:sf(8),topic:e,signature:void 0,key:void 0};case Oa.Anonymous:return{from:void 0,data:t,seqno:void 0,topic:e,signature:void 0,key:void 0}}}),tb.apply(this,arguments)}function nb(){return nb=V(function*(n,e){switch(n){case Xw:return null!=e.signature?{valid:!1,error:Ai.SignaturePresent}:null!=e.seqno?{valid:!1,error:Ai.SeqnoPresent}:null!=e.key?{valid:!1,error:Ai.FromPresent}:{valid:!0,fromPeerId:null};case sg:{if(null==e.seqno)return{valid:!1,error:Ai.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:Ai.InvalidSeqno};if(null==e.signature)return{valid:!1,error:Ai.InvalidSignature};if(null==e.from)return{valid:!1,error:Ai.InvalidPeerId};let t,r;try{t=pa(e.from)}catch{return{valid:!1,error:Ai.InvalidPeerId}}if(e.key){if(r=Tu(e.key),void 0!==t.publicKey&&!$r(r.bytes,t.publicKey))return{valid:!1,error:Ai.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:Ai.InvalidPeerId};r=Tu(t.publicKey)}const s=or([aP,ig.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,fromPeerId:t}:{valid:!1,error:Ai.InvalidSignature}}}}),nb.apply(this,arguments)}function WW(n){if(null==n.sequenceNumber)throw Error("missing seqno field");return((n,e)=>{const t=_t(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 qW(n){return rb.apply(this,arguments)}function rb(){return rb=V(function*(n){return yield Li.encode(n.data)}),rb.apply(this,arguments)}function QW(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([k,U])=>{const Q=i.get(k)??"unknown",X=t.topics[k];if(void 0===X)return;let ae=o.get(Q);ae||(ae={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(Q,ae));let he=0,Ae=0,ue=0,Re=0,Le=0;U.inMesh&&(he+=Math.max(U.meshTime/X.timeInMeshQuantum,X.timeInMeshCap)*X.timeInMeshWeight);let Fe=U.firstMessageDeliveries;if(Fe>X.firstMessageDeliveriesCap&&(Fe=X.firstMessageDeliveriesCap),Ae+=Fe*X.firstMessageDeliveriesWeight,U.meshMessageDeliveriesActive&&U.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const k=t.topicScoreCap/s;for(const U of o.values())U.p1w*=k,U.p2w*=k,U.p3w*=k,U.p3bw*=k,U.p4w*=k}let a=0,c=0,m=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(k=>{if(t.IPColocationFactorWhitelist.has(k))return;const U=r.get(k),Q=U?U.size:0;if(Q>t.IPColocationFactorThreshold){const X=Q-t.IPColocationFactorThreshold;c+=X*X*t.IPColocationFactorWeight}}),m+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+c+m,{byTopic:o,p5w:a,p6w:c,p7w:m,score:s}}function ib(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 XW{constructor(e,t){this.rawStream=e,this.pushable=lu(),this.closeController=new AbortController,Ln(Fs(this.pushable,this.closeController.signal,{returnOnAbort:!0}),to(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}class JW{constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=Fs(Ln(this.rawStream,Ms()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var Vi=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(Vi||(Vi={})),Vi))();class cP extends ki{constructor(e={}){super(),this.multicodecs=[Zw,iP],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=lu({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 ko,this.directPeerInitial=null,this.status={code:Vi.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===Vi.started){clearTimeout(this.status.heartbeatTimeout);let i=(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:RW(e.scoreParams),scoreThresholds:LW(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??sg,t.fallbackToFloodsub&&this.multicodecs.push(rP),this.log=Gt(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(r=>r.id.toString())),this.seenCache=new eb({validityMs:t.seenTTL}),this.publishedMessageIds=new eb({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case sg:this.msgIdFn=WW;break;case Xw:this.msgIdFn=qW}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new eb({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??CW,this.mcache=e.messageCache||new qz(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 HW(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===vs.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,c=r.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),c>0&&this.rpcSentPrune.inc(c),(s>0||o>0||a>0||c>0)&&this.rpcSentControl.inc(1)}},registerScores(r,i){let s=0,o=0,a=0,c=0;for(const m of r)m>=i.graylistThreshold&&s++,m>=i.publishThreshold&&o++,m>=i.gossipThreshold&&a++,m>=0&&c++;this.peersByScoreThreshold.set({threshold:mc.graylist},s),this.peersByScoreThreshold.set({threshold:mc.publish},o),this.peersByScoreThreshold.set({threshold:mc.gossip},a),this.peersByScoreThreshold.set({threshold:mc.mesh},c),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 c=this.topicStrToLabel.get(a)??"unknown";let m=s.get(c);m||(m=new Set,s.set(c,m)),o.forEach(T=>m?.add(T))});for(const[o,a]of s){const c=[];a.forEach(m=>{c.push(i.get(m)??0)}),this.scorePerMesh.set({topic:o},c)}}}}(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 VW(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new UW(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>_r(e))}isStarted(){return this.status.code===Vi.started}init(e){var t=this;return V(function*(){t.components=e,t.score.init(e)})()}start(){var e=this;return V(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function TW(n,e){return Jw.apply(this,arguments)}(e.globalSignaturePolicy,e.components.getPeerId()),e.outboundInflightQueue=lu({objectMode:!0}),Ln(e.outboundInflightQueue,function(){var o=V(function*(a){var T,c=!1,m=!1;try{for(var k,R=Tt(a);c=!(k=yield R.next()).done;c=!1){const{peerId:U,connection:Q}=k.value;yield e.createOutboundStream(U,Q)}}catch(U){m=!0,T=U}finally{try{c&&null!=R.return&&(yield R.return())}finally{if(m)throw T}}});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=V(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 Wz(n){return new zz(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:Vi.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then(V(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=V(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 V(function*(){if(e.log("stopping"),e.status.code!==Vi.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:Vi.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 V(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new XW(yield t.newStream(r.multicodecs),a=>r.log.error("outbound pipe error",a));r.log("create outbound stream %p",e),r.streamsOutbound.set(i,s);const o=s.protocol;o===rP&&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 V(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 JW(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,yc.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===Vi.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=>_r(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return V(function*(){try{yield Ln(t,function(){var i=V(function*(s){var c,o=!1,a=!1;try{for(var T,m=Tt(s);o=!(T=yield m.next()).done;o=!1){const R=T.value;try{const k=R.subarray(),U=ig.decode(k);r.metrics?.onRpcRecv(U,k.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,U):r.handleReceivedRpc(e,U).catch(Q=>r.log(Q))}catch(k){r.log(k)}}}catch(R){a=!0,c=R}finally{try{o&&null!=m.return&&(yield m.return())}finally{if(a)throw c}}});return function(s){return i.apply(this,arguments)}}())}catch(i){r.log.error(i),r.onPeerDisconnected(e)}})()}handleReceivedRpc(e,t){var r=this;return V(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 rn("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 V(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 rn("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new rn("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return V(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 jW(n,e){return nb.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:Es.invalid,reason:vs.Error,error:o.error};let a;try{const U=t.data??new Uint8Array(0);a=r.dataTransform?r.dataTransform.inboundTransform(t.topic,U):U}catch(U){return r.log("Invalid message, transform failed",U),{code:Es.invalid,reason:vs.Error,error:Ai.TransformFailed}}const c={from:null==t.from?void 0:pa(t.from),data:a,sequenceNumber:null==t.seqno?void 0:BigInt(`0x${Mt(t.seqno,"base16")}`),topic:t.topic},m=yield r.msgIdFn(c),T=r.msgIdToStrFn(m),R={msgId:m,msgIdStr:T};if(i&&r.fastMsgIdCache?.put(i,T),r.seenCache.has(T))return{code:Es.duplicate,msgIdStr:T};r.seenCache.put(T);const k=r.topicValidators.get(t.topic);if(null!=k){let U;try{U=yield k(c.topic,c,e)}catch(Q){const X=Q.code;"ERR_TOPIC_VALIDATOR_IGNORE"===X&&(U=fo.Ignore),U="ERR_TOPIC_VALIDATOR_REJECT"===X?fo.Reject:fo.Ignore}if(U!==fo.Accept)return{code:Es.invalid,reason:oP(U),msgIdStr:T}}return{code:Es.valid,messageId:R,msg:c}})()}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 V(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,Wo(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:Xu.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=Qu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:Xu.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:m,messageIDs:T})=>{if(!m||!T||!this.mesh.has(m))return;let R=0;T.forEach(k=>{const U=this.msgIdToStrFn(k);this.seenCache.has(U)||(o.set(U,k),R++)}),this.metrics?.onIhaveRcv(m,T.length,R)}),!o.size)return[];let a=o.size;a+s>Qu&&(a=Qu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let c=Array.from(o.values());return qo(c),c=c.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,c),[{messageIDs:c}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(c=>{const m=this.msgIdToStrFn(c),T=this.mcache.getWithIWantCount(m,e);null!=T?(s.set(T.msg.topic,1+(s.get(T.msg.topic)??0)),T.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,c):i.set(m,T.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 V(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:c})=>{if(!c)return;const m=r.mesh.get(c);if(!m)return void(a=!1);if(m.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(c),void(a=!1);const T=r.backoff.get(c)?.get(e);return"number"==typeof T&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(c),void r.addBackoff(e,c)):(r.log("GRAFT: Add mesh link from %s in %s",e,c),r.score.graft(e,c),m.add(e),void r.metrics?.onAddToMesh(c,Qo.Subscribed,1))}),i.length?yield Promise.all(i.map(c=>r.makePrune(e,c,a))):[]})()}handlePrune(e,t){var r=this;return V(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const c=r.mesh.get(s);if(!c)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),c.has(e)&&(c.delete(e),r.metrics?.onRemoveFromMesh(s,yc.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,Zu.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=V(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return V(function*(){e.length>t.opts.prunePeers&&(qo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=V(function*(s){if(!s.peerID)return;const o=pa(s.peerID).toString();if(!t.peers.has(o)){if(!s.signedPeerRecord)return void r.push(o);try{const a=yield Ma.openAndCertify(s.signedPeerRecord,"libp2p-peer-record"),c=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",c,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=V(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return V(function*(){t.log("Initiating connection with %s",e);const r=_r(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!==Vi.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!==Vi.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!==Vi.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,Qo.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,Qo.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 V(function*(){if(t.status.code!==Vi.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=V(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,c=>this.score.score(c)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(c=>{t.add(c),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=Wo([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 V(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const o=yield function KW(n,e,t){return tb.apply(this,arguments)}(i.publishConfig,e,s),a={from:o.from?pa(o.from):void 0,data:t,sequenceNumber:null==o.seqno?void 0:BigInt(`0x${Mt(o.seqno,"base16")}`),topic:e,signature:o.signature??void 0,key:o.key??void 0},c=yield i.msgIdFn(a),m=i.msgIdToStrFn(c);if(i.seenCache.has(m))throw Error("PublishError.Duplicate");const{tosend:T,tosendCount:R}=i.selectPeersToPublish(o.topic),k=!0===i.opts.emitSelf&&i.subscriptions.has(e);if(0===T.size&&!i.opts.allowPublishToZeroPeers&&!k)throw Error("PublishError.InsufficientPeers");i.seenCache.put(m),i.mcache.put({msgId:c,msgIdStr:m},o,!0),i.publishedMessageIds.put(m);const U=Wo([o]);for(const Q of T)i.sendRpc(Q,U)||T.delete(Q);return i.metrics?.onPublishMsg(e,R,T.size,null!=o.data?o.data.length:0),k&&(T.add(i.components.getPeerId().toString()),r().call(i,new rn("gossipsub:message",{detail:{propagationSource:i.components.getPeerId(),msgId:m,msg:a}})),r().call(i,new rn("message",{detail:a}))),{recipients:Array.from(T.values()).map(Q=>_r(Q))}})()}reportMessageValidationResult(e,t,r){if(r===fo.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=oP(r),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(const c of a)this.score.rejectMessage(c,e,o.topic,s);this.metrics?.onReportValidation(o.topic,r)}}}sendGraft(e,t){const i=Wo([],{graft:[{topicID:t}]});this.sendRpc(e,i)}sendPrune(e,t){var r=this;return V(function*(){const s=Wo([],{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=ig.encode(t).finish();return r.push(o),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 V(function*(){const s=i.opts.doPX;for(const[o,a]of e){const c=a.map(k=>({topicID:k}));let m=[];const T=t.get(o);T&&(m=yield Promise.all(T.map(function(){var k=V(function*(U){return yield i.makePrune(o,U,s&&!r.get(o))});return function(U){return k.apply(this,arguments)}}())),t.delete(o));const R=Wo([],{graft:c,prune:m});i.sendRpc(o,R)}for(const[o,a]of t){const c=yield Promise.all(a.map(function(){var T=V(function*(R){return yield i.makePrune(o,R,s&&!r.get(o))});return function(R){return T.apply(this,arguments)}}())),m=Wo([],{prune:c});i.sendRpc(o,m)}})()}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||(qo(r),r.length>Qu&&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=qo(Array.from(o)).slice(0,i),o.forEach(a=>{let c=r;r.length>Qu&&(c=qo(c.slice()).slice(0,Qu)),this.pushGossip(a,{topicID:e,messageIDs:c})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,Wo([],{ihave:t}));for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,Wo([],{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 V(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===iP)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,c=>c!==e&&i.score.score(c)>=0),a=yield Promise.all(Array.from(o).map(function(){var c=V(function*(m){const T=_r(m);return{peerID:T.toBytes(),signedPeerRecord:yield i.components.getPeerStore().addressBook.getRawEnvelope(T)}});return function(m){return c.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return V(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const c=new Map,m=X=>{let ae=c.get(X);return void 0===ae&&(ae=e.score.score(X),c.set(X,ae)),ae},T=new Map,R=new Map,k=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 U=new Map;e.mesh.forEach((X,ae)=>{const he=e.topics.get(ae),Ae=new Set,ue=new Set;if(U.set(ae,ue),he){const Fe=qo(Array.from(he)),wt=e.backoff.get(ae);for(const mt of Fe){const Zt=e.streamsOutbound.get(mt);if(Zt&&e.multicodecs.includes(Zt.protocol)&&!X.has(mt)&&!e.direct.has(mt)){const wn=m(mt);(!wt||!wt.has(mt))&&wn>=0&&Ae.add(mt),wn>=e.opts.scoreThresholds.gossipThreshold&&ue.add(mt)}}}const Re=(Fe,wt)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",Fe,ae),e.addBackoff(Fe,ae),X.delete(Fe),m(Fe)>=e.opts.scoreThresholds.gossipThreshold&&ue.add(Fe),e.metrics?.onRemoveFromMesh(ae,wt,1);const mt=R.get(Fe);mt?mt.push(ae):R.set(Fe,[ae])},Le=(Fe,wt)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",Fe,ae),e.score.graft(Fe,ae),X.add(Fe),ue.delete(Fe),e.metrics?.onAddToMesh(ae,wt,1);const mt=T.get(Fe);mt?mt.push(ae):T.set(Fe,[ae])};if(X.forEach(Fe=>{const wt=m(Fe);wt<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",Fe,wt,ae),Re(Fe,yc.BadScore),k.set(Fe,!0))}),X.size!0)}(Ae,t-X.size).forEach(mt=>{Le(mt,Qo.NotEnough)}),X.size>i){let Fe=Array.from(X);Fe.sort((mt,Zt)=>m(Zt)-m(mt)),Fe=Fe.slice(0,s).concat(qo(Fe.slice(s)));let wt=0;if(Fe.slice(0,t).forEach(mt=>{e.outbound.get(mt)&&wt++}),wt{const zr=Fe[wn];for(let Rn=wn;Rn>0;Rn--)Fe[Rn]=Fe[Rn-1];Fe[0]=zr};if(wt>0){let wn=wt;for(let zr=1;zr0;zr++)e.outbound.get(Fe[zr])&&(mt(zr),wn--)}let Zt=t-wt;for(let wn=t;wn0;wn++)e.outbound.get(Fe[wn])&&(mt(wn),Zt--)}Fe.slice(t).forEach(mt=>{Re(mt,yc.Excess)})}if(X.size>=r){let Fe=0;X.forEach(wt=>{e.outbound.get(wt)&&Fe++}),Fe!0===e.outbound.get(Zt)).forEach(Zt=>{Le(Zt,Qo.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&X.size>1){const Fe=Array.from(X).sort((Zt,wn)=>m(Zt)-m(wn)),wt=Math.floor(X.size/2),mt=m(Fe[wt]);if(mtm(zr)>mt);for(const zr of wn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",zr,ae),Le(zr,Qo.Opportunistic)}}});const Q=Date.now();e.fanoutLastpub.forEach((X,ae)=>{X+a{const he=e.topics.get(ae);X.forEach(Le=>{(!he.has(Le)||m(Le)=e.opts.scoreThresholds.publishThreshold&&ue.push(Fe),mt>=e.opts.scoreThresholds.gossipThreshold&&Re.add(Fe)}}}X.size{X.add(Fe),Re?.delete(Fe)})}),e.emitGossip(U),yield e.sendGraftPrune(T,R,k),e.flush(),e.mcache.shift(),e.dispatchEvent(new rn("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=qo(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 YW(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 c=QW(o,a,t,r,i);for(const[m,T]of c.byTopic){let R=s.byTopic.get(m);R||(R={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(m,R)),R.p1w.push(T.p1w),R.p2w.push(T.p2w),R.p3w.push(T.p3w),R.p3bw.push(T.p3bw),R.p4w.push(T.p4w)}s.p5w.push(c.p5w),s.p6w.push(c.p6w),s.p7w.push(c.p7w),s.score.push(c.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)}}cP.multicodec=Zw;const sb=Ur("waku:relay");class uP extends cP{constructor(e){super(e=Object.assign(e??{},{globalSignaturePolicy:og.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=Hw,this.observers={},this.decryptionKeys=new Map,this.pubSubTopic=e?.pubSubTopic??kp,e?.decryptionKeys?.forEach(t=>{this.addDecryptionKey(t)})}start(){var e=()=>super.start,t=this;return V(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e){var t=this;return V(function*(){const r=e.encode();yield t.publish(t.pubSubTopic,r)})()}addDecryptionKey(e,t){this.decryptionKeys.set(Gs(e),t??{})}deleteDecryptionKey(e){this.decryptionKeys.delete(Gs(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}));sb(`Message received on ${e}`),uo.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)})):sb("Failed to decode Waku Message")}).catch(i=>{sb("Failed to decode Waku Message",i)})}}),super.subscribe(e)}getMeshPeers(e){return super.getMeshPeers(e??this.pubSubTopic)}}function ob(){return ob=V(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(tq()),Object.assign(e,{peerDiscovery:t}));const r=yield nq(new uP(n),e),i=new qG(r,n),s=new jG(r,n),o=new KG(r,n);return new ZG(n??{},r,i,s,o)}),ob.apply(this,arguments)}function tq(){return new i$(function o$(n=Uu.Prod,e=1){if(e<=0)return[];let t;switch(n){case Uu.Prod:t=pw_fleets["wakuv2.prod"]["waku-websocket"];break;case Uu.Test:t=pw_fleets["wakuv2.test"]["waku-websocket"];break;default:t=pw_fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),t=t.map(r=>new vn(r)),sR(t,e)}())}function nq(n,e){return ab.apply(this,arguments)}function ab(){return ab=V(function*(n,e){return t$(Object.assign({transports:[new pH({filter:OA})],streamMuxers:[new r9],connectionEncryption:[new GT]},{pubsub:n},e??{}))}),ab.apply(this,arguments)}uP.multicodec=Hw[0];function iq(n,e,t){"function"==typeof t&&(t={filter:t});const r=function rq(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(),c=[],{addListener:m,removeListener:T}=(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),R=(...U)=>{const Q=t.multiArgs?U:U[0];t.filter&&!t.filter(Q)||(c.push(Q),t.count===c.length&&(r(),s(c)))},k=U=>{r(),o(U)};r=()=>{for(const U of a)T(U,R);for(const U of t.rejectionEvents)T(U,k)};for(const U of a)m(U,R);for(const U of t.rejectionEvents)m(U,k);t.resolveImmediately&&s(c)});if(i.cancel=r,"number"==typeof t.timeout){const s=Mx(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 fP=Ur("waku:wait-for-remote-peer");function cb(){return cb=V(function*(n,e,t){if(e=e??[es.Relay],!n.isStarted())return Promise.reject("Waku node is not started");const r=[];e.includes(es.Relay)&&r.push(oq(n.relay)),e.includes(es.Store)&&r.push(ub(n.store,Object.values(lc))),e.includes(es.LightPush)&&r.push(ub(n.lightPush,[zf])),e.includes(es.Filter)&&r.push(ub(n.filter,[jf])),t?yield cq(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),cb.apply(this,arguments)}function ub(n,e){return lb.apply(this,arguments)}function lb(){return lb=V(function*(n,e){const t=yield n.peers();t.length?fP(`${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)){fP("Resolving for",o,s.detail.protocols),n.libp2p.peerStore.removeEventListener("change:protocols",i),r();break}};n.libp2p.peerStore.addEventListener("change:protocols",i)})}),lb.apply(this,arguments)}function oq(n){return fb.apply(this,arguments)}function fb(){return fb=V(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield iq(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),fb.apply(this,arguments)}const aq=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function cq(n,e,t){return db.apply(this,arguments)}function db(){return db=V(function*(n,e,t){yield Promise.race([n,aq(e,t)])}),db.apply(this,arguments)}let dP=(()=>{class n{constructor(){this.wakuSubject=new Sr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new _5(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function eq(n){return ob.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function sq(n,e,t){return cb.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Jn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function lq(n,e){if(1&n&&(bo(0,"li")(1,"span"),ru(2),_o()()),2&n){const t=e.$implicit;Cl(2),u0("",t.timestamp," ",t.text,"")}}Ur("waku:enr");const vb=new(Dm().Type)("ChatMessage").add(new(Dm().Field)("timestamp",1,"uint32")).add(new(Dm().Field)("text",2,"string"));let fq=(()=>{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}=vb.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=vb.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=vb.encode(r).finish();uo.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)(qt(dP))},n.\u0275cmp=td({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(bo(0,"button",0),s0("click",function(){return r.sendMessage()}),ru(1,"Send Message"),_o(),bo(2,"h2"),ru(3,"Messages"),_o(),bo(4,"ul",1),function AD(n,e,t,r,i,s,o,a){const c=Ve(),m=pn(),T=n+22,R=m.firstCreatePass?function aL(n,e,t,r,i,s,o,a,c){const m=e.consts,T=Gc(e,n,4,o||null,ea(m,a));jy(e,t,T,ea(m,c)),fd(e,T);const R=T.tViews=Ky(2,T,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,m);return null!==e.queries&&(e.queries.template(e,T),R.queries=e.queries.embeddedTView(T)),T}(T,m,c,e,t,r,i,s,o):m.data[T];Ws(R,!1);const k=c[11].createComment("");Ld(m,c,k,R),si(k,c),jd(c,c[T]=uD(k,c,k,R)),od(R)&&Vy(m,c,R),null!=o&&Hy(c,R,a)}(5,lq,3,2,"li",2),_o()),2&t&&(qd("disabled","Connected"!==r.wakuStatus),Cl(5),qd("ngForOf",r.messages))},dependencies:[DC]}),n})(),dq=(()=>{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)(qt(dP))},n.\u0275cmp=td({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(bo(0,"h1"),ru(1),_o(),bo(2,"p"),ru(3),_o(),e0(4,"app-messages")),2&t&&(Cl(1),c0(r.title),Cl(2),Yd("Waku node's status: ",r.wakuStatus,""))},dependencies:[fq],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})(),hq=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=nl({type:n,bootstrap:[dq]}),n.\u0275inj=vc({imports:[d5]}),n})();N(8583),function Bk(){tC=!1}(),f5().bootstrapModule(hq).catch(n=>console.error(n))},1280:J=>{"use strict";J.exports=function G(N,h){for(var u=new Array(arguments.length-1),g=0,b=2,w=!0;b{"use strict";var N=G;N.length=function(v){var l=v.length;if(!l)return 0;for(var p=0;--l%4>1&&"="===v.charAt(l);)++p;return Math.ceil(3*v.length)/4-p};for(var h=new Array(64),u=new Array(123),g=0;g<64;)u[h[g]=g<26?g+65:g<52?g+71:g<62?g-4:g-59|43]=g++;N.encode=function(v,l,p){for(var y,d=null,_=[],I=0,E=0;l>2],y=(3&f)<<4,E=1;break;case 1:_[I++]=h[y|f>>4],y=(15&f)<<2,E=2;break;case 2:_[I++]=h[y|f>>6],_[I++]=h[63&f],E=0}I>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,_)),I=0)}return E&&(_[I++]=h[y],_[I++]=61,1===E&&(_[I++]=61)),d?(I&&d.push(String.fromCharCode.apply(String,_.slice(0,I))),d.join("")):String.fromCharCode.apply(String,_.slice(0,I))};var b="invalid encoding";N.decode=function(v,l,p){for(var I,d=p,_=0,E=0;E1)break;if(void 0===(y=u[y]))throw Error(b);switch(_){case 0:I=y,_=1;break;case 1:l[p++]=I<<2|(48&y)>>4,I=y,_=2;break;case 2:l[p++]=(15&I)<<4|(60&y)>>2,I=y,_=3;break;case 3:l[p++]=(3&I)<<6|y,_=0}}if(1===_)throw Error(b);return p-d},N.test=function(v){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(v)}},9749:J=>{"use strict";function G(N,h){"string"==typeof N&&(h=N,N=void 0);var u=[];function g(w){if("string"!=typeof w){var v=b();if(G.verbose&&console.log("codegen: "+v),v="return "+v,w){for(var l=Object.keys(w),p=new Array(l.length+1),d=new Array(l.length),_=0;_{"use strict";function G(){this._listeners={}}J.exports=G,G.prototype.on=function(h,u,g){return(this._listeners[h]||(this._listeners[h]=[])).push({fn:u,ctx:g||this}),this},G.prototype.off=function(h,u){if(void 0===h)this._listeners={};else if(void 0===u)this._listeners[h]=[];else for(var g=this._listeners[h],b=0;b{"use strict";J.exports=b;var h=N(1280),g=N(716)("fs");function b(w,v,l){return"function"==typeof v?(l=v,v={}):v||(v={}),l?!v.xhr&&g&&g.readFile?g.readFile(w,function(d,_){return d&&typeof XMLHttpRequest<"u"?b.xhr(w,v,l):d?l(d):l(null,v.binary?_:_.toString("utf8"))}):b.xhr(w,v,l):h(b,this,w,v)}b.xhr=function(v,l,p){var d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState){if(0!==d.status&&200!==d.status)return p(Error("status "+d.status));if(l.binary){var I=d.response;if(!I){I=[];for(var E=0;E{"use strict";function G(b){return typeof Float32Array<"u"?function(){var w=new Float32Array([-0]),v=new Uint8Array(w.buffer),l=128===v[3];function p(E,y,f){w[0]=E,y[f]=v[0],y[f+1]=v[1],y[f+2]=v[2],y[f+3]=v[3]}function d(E,y,f){w[0]=E,y[f]=v[3],y[f+1]=v[2],y[f+2]=v[1],y[f+3]=v[0]}function _(E,y){return v[0]=E[y],v[1]=E[y+1],v[2]=E[y+2],v[3]=E[y+3],w[0]}function I(E,y){return v[3]=E[y],v[2]=E[y+1],v[1]=E[y+2],v[0]=E[y+3],w[0]}b.writeFloatLE=l?p:d,b.writeFloatBE=l?d:p,b.readFloatLE=l?_:I,b.readFloatBE=l?I:_}():function(){function w(l,p,d,_){var I=p<0?1:0;if(I&&(p=-p),0===p)l(1/p>0?0:2147483648,d,_);else if(isNaN(p))l(2143289344,d,_);else if(p>34028234663852886e22)l((I<<31|2139095040)>>>0,d,_);else if(p<11754943508222875e-54)l((I<<31|Math.round(p/1401298464324817e-60))>>>0,d,_);else{var E=Math.floor(Math.log(p)/Math.LN2);l((I<<31|E+127<<23|8388607&Math.round(p*Math.pow(2,-E)*8388608))>>>0,d,_)}}function v(l,p,d){var _=l(p,d),I=2*(_>>31)+1,E=_>>>23&255,y=8388607&_;return 255===E?y?NaN:I*(1/0):0===E?1401298464324817e-60*I*y:I*Math.pow(2,E-150)*(y+8388608)}b.writeFloatLE=w.bind(null,N),b.writeFloatBE=w.bind(null,h),b.readFloatLE=v.bind(null,u),b.readFloatBE=v.bind(null,g)}(),typeof Float64Array<"u"?function(){var w=new Float64Array([-0]),v=new Uint8Array(w.buffer),l=128===v[7];function p(E,y,f){w[0]=E,y[f]=v[0],y[f+1]=v[1],y[f+2]=v[2],y[f+3]=v[3],y[f+4]=v[4],y[f+5]=v[5],y[f+6]=v[6],y[f+7]=v[7]}function d(E,y,f){w[0]=E,y[f]=v[7],y[f+1]=v[6],y[f+2]=v[5],y[f+3]=v[4],y[f+4]=v[3],y[f+5]=v[2],y[f+6]=v[1],y[f+7]=v[0]}function _(E,y){return v[0]=E[y],v[1]=E[y+1],v[2]=E[y+2],v[3]=E[y+3],v[4]=E[y+4],v[5]=E[y+5],v[6]=E[y+6],v[7]=E[y+7],w[0]}function I(E,y){return v[7]=E[y],v[6]=E[y+1],v[5]=E[y+2],v[4]=E[y+3],v[3]=E[y+4],v[2]=E[y+5],v[1]=E[y+6],v[0]=E[y+7],w[0]}b.writeDoubleLE=l?p:d,b.writeDoubleBE=l?d:p,b.readDoubleLE=l?_:I,b.readDoubleBE=l?I:_}():function(){function w(l,p,d,_,I,E){var y=_<0?1:0;if(y&&(_=-_),0===_)l(0,I,E+p),l(1/_>0?0:2147483648,I,E+d);else if(isNaN(_))l(0,I,E+p),l(2146959360,I,E+d);else if(_>17976931348623157e292)l(0,I,E+p),l((y<<31|2146435072)>>>0,I,E+d);else{var f;if(_<22250738585072014e-324)l((f=_/5e-324)>>>0,I,E+p),l((y<<31|f/4294967296)>>>0,I,E+d);else{var C=Math.floor(Math.log(_)/Math.LN2);1024===C&&(C=1023),l(4503599627370496*(f=_*Math.pow(2,-C))>>>0,I,E+p),l((y<<31|C+1023<<20|1048576*f&1048575)>>>0,I,E+d)}}}function v(l,p,d,_,I){var E=l(_,I+p),y=l(_,I+d),f=2*(y>>31)+1,C=y>>>20&2047,A=4294967296*(1048575&y)+E;return 2047===C?A?NaN:f*(1/0):0===C?5e-324*f*A:f*Math.pow(2,C-1075)*(A+4503599627370496)}b.writeDoubleLE=w.bind(null,N,0,4),b.writeDoubleBE=w.bind(null,h,4,0),b.readDoubleLE=v.bind(null,u,0,4),b.readDoubleBE=v.bind(null,g,4,0)}(),b}function N(b,w,v){w[v]=255&b,w[v+1]=b>>>8&255,w[v+2]=b>>>16&255,w[v+3]=b>>>24}function h(b,w,v){w[v]=b>>>24,w[v+1]=b>>>16&255,w[v+2]=b>>>8&255,w[v+3]=255&b}function u(b,w){return(b[w]|b[w+1]<<8|b[w+2]<<16|b[w+3]<<24)>>>0}function g(b,w){return(b[w]<<24|b[w+1]<<16|b[w+2]<<8|b[w+3])>>>0}J.exports=G(G)},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(J){}return null}module.exports=inquire},1311:(J,G)=>{"use strict";var N=G,h=N.isAbsolute=function(b){return/^(?:\/|\w+:)/.test(b)},u=N.normalize=function(b){var w=(b=b.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),v=h(b),l="";v&&(l=w.shift()+"/");for(var p=0;p0&&".."!==w[p-1]?w.splice(--p,2):v?w.splice(p,1):++p:"."===w[p]?w.splice(p,1):++p;return l+w.join("/")};N.resolve=function(b,w,v){return v||(w=u(w)),h(w)?w:(v||(b=u(b)),(b=b.replace(/(?:\/|^)[^/]+$/,"")).length?u(b+"/"+w):w)}},4479:J=>{"use strict";J.exports=function G(N,h,u){var g=u||8192,b=g>>>1,w=null,v=g;return function(p){if(p<1||p>b)return N(p);v+p>g&&(w=N(g),v=0);var d=h.call(w,v,v+=p);return 7&v&&(v=1+(7|v)),d}}},7768:(J,G)=>{"use strict";var N=G;N.length=function(u){for(var g=0,b=0,w=0;w191&&d<224?l[p++]=(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,l[p++]=55296+(d>>10),l[p++]=56320+(1023&d)):l[p++]=(15&d)<<12|(63&u[g++])<<6|63&u[g++],p>8191&&((v||(v=[])).push(String.fromCharCode.apply(String,l)),p=0);return v?(p&&v.push(String.fromCharCode.apply(String,l.slice(0,p))),v.join("")):String.fromCharCode.apply(String,l.slice(0,p))},N.write=function(u,g,b){for(var v,l,w=b,p=0;p>6|192,g[b++]=63&v|128):55296==(64512&v)&&56320==(64512&(l=u.charCodeAt(p+1)))?(++p,g[b++]=(v=65536+((1023&v)<<10)+(1023&l))>>18|240,g[b++]=v>>12&63|128,g[b++]=v>>6&63|128,g[b++]=63&v|128):(g[b++]=v>>12|224,g[b++]=v>>6&63|128,g[b++]=63&v|128);return b-w}},4502:(J,G,N)=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});var h=N(8046);function v(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 l(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 p(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 _(Z,q){return void 0===q&&(q=0),Z[q+3]<<24|Z[q+2]<<16|Z[q+1]<<8|Z[q]}function I(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 y(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 x(Z,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),y(Z>>>0,q,ne),y(Z/4294967296>>>0,q,ne+4),q}G.readInt16BE=function u(Z,q){return void 0===q&&(q=0),(Z[q+0]<<8|Z[q+1])<<16>>16},G.readUint16BE=function g(Z,q){return void 0===q&&(q=0),(Z[q+0]<<8|Z[q+1])>>>0},G.readInt16LE=function b(Z,q){return void 0===q&&(q=0),(Z[q+1]<<8|Z[q])<<16>>16},G.readUint16LE=function w(Z,q){return void 0===q&&(q=0),(Z[q+1]<<8|Z[q])>>>0},G.writeUint16BE=v,G.writeInt16BE=v,G.writeUint16LE=l,G.writeInt16LE=l,G.readInt32BE=p,G.readUint32BE=d,G.readInt32LE=_,G.readUint32LE=I,G.writeUint32BE=E,G.writeInt32BE=E,G.writeUint32LE=y,G.writeInt32LE=y,G.readInt64BE=function f(Z,q){void 0===q&&(q=0);var ne=p(Z,q),oe=p(Z,q+4);return 4294967296*ne+oe-4294967296*(oe>>31)},G.readUint64BE=function C(Z,q){return void 0===q&&(q=0),4294967296*d(Z,q)+d(Z,q+4)},G.readInt64LE=function A(Z,q){void 0===q&&(q=0);var ne=_(Z,q);return 4294967296*_(Z,q+4)+ne-4294967296*(ne>>31)},G.readUint64LE=function P(Z,q){void 0===q&&(q=0);var ne=I(Z,q);return 4294967296*I(Z,q+4)+ne},G.writeUint64BE=D,G.writeInt64BE=D,G.writeUint64LE=x,G.writeInt64LE=x,G.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 oe=0,de=1,pe=Z/8+ne-1;pe>=ne;pe--)oe+=q[pe]*de,de*=256;return oe},G.readUintLE=function B(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 oe=0,de=1,pe=ne;pe=oe;pe--)ne[pe]=q/de&255,de*=256;return ne},G.writeUintLE=function z(Z,q,ne,oe){if(void 0===ne&&(ne=new Uint8Array(Z/8)),void 0===oe&&(oe=0),Z%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!h.isSafeInteger(q))throw new Error("writeUintLE value must be an integer");for(var de=1,pe=oe;pe{"use strict";Object.defineProperty(G,"__esModule",{value:!0});var h=N(4502),u=N(9815);function b(p,d,_){for(var I=1634760805,E=857760878,y=2036477234,f=1797285236,C=_[3]<<24|_[2]<<16|_[1]<<8|_[0],A=_[7]<<24|_[6]<<16|_[5]<<8|_[4],P=_[11]<<24|_[10]<<16|_[9]<<8|_[8],D=_[15]<<24|_[14]<<16|_[13]<<8|_[12],x=_[19]<<24|_[18]<<16|_[17]<<8|_[16],M=_[23]<<24|_[22]<<16|_[21]<<8|_[20],B=_[27]<<24|_[26]<<16|_[25]<<8|_[24],F=_[31]<<24|_[30]<<16|_[29]<<8|_[28],z=d[3]<<24|d[2]<<16|d[1]<<8|d[0],S=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],H=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=I,j=E,re=y,$=f,te=C,Z=A,q=P,ne=D,oe=x,de=M,pe=B,ke=F,Se=z,Pe=S,we=O,$e=H,K=0;K<20;K+=2)te=(te^=oe=oe+(Se=(Se^=L=L+te|0)>>>16|Se<<16)|0)>>>20|te<<12,Z=(Z^=de=de+(Pe=(Pe^=j=j+Z|0)>>>16|Pe<<16)|0)>>>20|Z<<12,q=(q^=pe=pe+(we=(we^=re=re+q|0)>>>16|we<<16)|0)>>>20|q<<12,ne=(ne^=ke=ke+($e=($e^=$=$+ne|0)>>>16|$e<<16)|0)>>>20|ne<<12,q=(q^=pe=pe+(we=(we^=re=re+q|0)>>>24|we<<8)|0)>>>25|q<<7,ne=(ne^=ke=ke+($e=($e^=$=$+ne|0)>>>24|$e<<8)|0)>>>25|ne<<7,Z=(Z^=de=de+(Pe=(Pe^=j=j+Z|0)>>>24|Pe<<8)|0)>>>25|Z<<7,te=(te^=oe=oe+(Se=(Se^=L=L+te|0)>>>24|Se<<8)|0)>>>25|te<<7,Z=(Z^=pe=pe+($e=($e^=L=L+Z|0)>>>16|$e<<16)|0)>>>20|Z<<12,q=(q^=ke=ke+(Se=(Se^=j=j+q|0)>>>16|Se<<16)|0)>>>20|q<<12,ne=(ne^=oe=oe+(Pe=(Pe^=re=re+ne|0)>>>16|Pe<<16)|0)>>>20|ne<<12,te=(te^=de=de+(we=(we^=$=$+te|0)>>>16|we<<16)|0)>>>20|te<<12,ne=(ne^=oe=oe+(Pe=(Pe^=re=re+ne|0)>>>24|Pe<<8)|0)>>>25|ne<<7,te=(te^=de=de+(we=(we^=$=$+te|0)>>>24|we<<8)|0)>>>25|te<<7,q=(q^=ke=ke+(Se=(Se^=j=j+q|0)>>>24|Se<<8)|0)>>>25|q<<7,Z=(Z^=pe=pe+($e=($e^=L=L+Z|0)>>>24|$e<<8)|0)>>>25|Z<<7;h.writeUint32LE(L+I|0,p,0),h.writeUint32LE(j+E|0,p,4),h.writeUint32LE(re+y|0,p,8),h.writeUint32LE($+f|0,p,12),h.writeUint32LE(te+C|0,p,16),h.writeUint32LE(Z+A|0,p,20),h.writeUint32LE(q+P|0,p,24),h.writeUint32LE(ne+D|0,p,28),h.writeUint32LE(oe+x|0,p,32),h.writeUint32LE(de+M|0,p,36),h.writeUint32LE(pe+B|0,p,40),h.writeUint32LE(ke+F|0,p,44),h.writeUint32LE(Se+z|0,p,48),h.writeUint32LE(Pe+S|0,p,52),h.writeUint32LE(we+O|0,p,56),h.writeUint32LE($e+H|0,p,60)}function w(p,d,_,I,E){if(void 0===E&&(E=0),32!==p.length)throw new Error("ChaCha: key size must be 32 bytes");if(I.length<_.length)throw new Error("ChaCha: destination is shorter than source");var y,f;if(0===E){if(8!==d.length&&12!==d.length)throw new Error("ChaCha nonce must be 8 or 12 bytes");(y=new Uint8Array(16)).set(d,f=y.length-d.length)}else{if(16!==d.length)throw new Error("ChaCha nonce with counter must be 16 bytes");y=d,f=E}for(var C=new Uint8Array(64),A=0;A<_.length;A+=64){b(C,y,p);for(var P=A;P>>=8,d++;if(I>0)throw new Error("ChaCha: counter overflow")}G.streamXOR=w,G.stream=function v(p,d,_,I){return void 0===I&&(I=0),u.wipe(_),w(p,d,_,_,I)}},5876:(J,G,N)=>{"use strict";var u=N(4484),g=N(314),b=N(9815),w=N(4502),v=N(9976);G.Cv=32,G.WH=12,G.pg=16;var l=new Uint8Array(16),p=function(){function d(_){if(this.nonceLength=G.WH,this.tagLength=G.pg,_.length!==G.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(_)}return d.prototype.seal=function(_,I,E,y){if(_.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var f=new Uint8Array(16);f.set(_,f.length-_.length);var C=new Uint8Array(32);u.stream(this._key,f,C,4);var P,A=I.length+this.tagLength;if(y){if(y.length!==A)throw new Error("ChaCha20Poly1305: incorrect destination length");P=y}else P=new Uint8Array(A);return u.streamXOR(this._key,f,I,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),C,P.subarray(0,P.length-this.tagLength),E),b.wipe(f),P},d.prototype.open=function(_,I,E,y){if(_.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(I.length0&&f.update(l.subarray(y.length%16))),f.update(E),E.length%16>0&&f.update(l.subarray(E.length%16));var C=new Uint8Array(8);y&&w.writeUint64LE(y.length,C),f.update(C),w.writeUint64LE(E.length,C),f.update(C);for(var A=f.digest(),P=0;P{"use strict";function u(b,w){if(b.length!==w.length)return 0;for(var v=0,l=0;l>>8}Object.defineProperty(G,"__esModule",{value:!0}),G.select=function N(b,w,v){return~(b-1)&w|b-1&v},G.lessOrEqual=function h(b,w){return(0|b)-(0|w)-1>>>31&1},G.compare=u,G.equal=function g(b,w){return 0!==b.length&&0!==w.length&&0!==u(b,w)}},5571:(J,G)=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.isSerializableHash=function N(h){return typeof h.saveState<"u"&&typeof h.restoreState<"u"&&typeof h.cleanSavedState<"u"}},5705:(J,G,N)=>{"use strict";var u=N(4193),g=N(9815),b=function(){function w(v,l,p,d){void 0===p&&(p=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=v,this._info=d;var _=u.hmac(this._hash,p,l);this._hmac=new u.HMAC(v,_),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return w.prototype._fillBuffer=function(){this._counter[0]++;var v=this._counter[0];if(0===v)throw new Error("hkdf: cannot expand more");this._hmac.reset(),v>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},w.prototype.expand=function(v){for(var l=new Uint8Array(v),p=0;p{"use strict";Object.defineProperty(G,"__esModule",{value:!0});var h=N(5571),u=N(9976),g=N(9815),b=function(){function v(l,p){this._finished=!1,this._inner=new l,this._outer=new l,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);p.length>this.blockSize?this._inner.update(p).finish(d).clean():d.set(p);for(var _=0;_{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.mul=Math.imul||function N(v,l){var d=65535&v,I=65535&l;return d*I+((v>>>16&65535)*I+d*(l>>>16&65535)<<16>>>0)|0},G.add=function h(v,l){return v+l|0},G.sub=function u(v,l){return v-l|0},G.rotl=function g(v,l){return v<>>32-l},G.rotr=function b(v,l){return v<<32-l|v>>>l},G.isInteger=Number.isInteger||function w(v){return"number"==typeof v&&isFinite(v)&&Math.floor(v)===v},G.MAX_SAFE_INTEGER=9007199254740991,G.isSafeInteger=function(v){return G.isInteger(v)&&v>=-G.MAX_SAFE_INTEGER&&v<=G.MAX_SAFE_INTEGER}},314:(J,G,N)=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});var h=N(9976),u=N(9815);G.DIGEST_LENGTH=16;var g=function(){function v(l){this.digestLength=G.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 p=l[0]|l[1]<<8;this._r[0]=8191&p;var d=l[2]|l[3]<<8;this._r[1]=8191&(p>>>13|d<<3);var _=l[4]|l[5]<<8;this._r[2]=7939&(d>>>10|_<<6);var I=l[6]|l[7]<<8;this._r[3]=8191&(_>>>7|I<<9);var E=l[8]|l[9]<<8;this._r[4]=255&(I>>>4|E<<12),this._r[5]=E>>>1&8190;var y=l[10]|l[11]<<8;this._r[6]=8191&(E>>>14|y<<2);var f=l[12]|l[13]<<8;this._r[7]=8065&(y>>>11|f<<5);var C=l[14]|l[15]<<8;this._r[8]=8191&(f>>>8|C<<8),this._r[9]=C>>>5&127,this._pad[0]=l[16]|l[17]<<8,this._pad[1]=l[18]|l[19]<<8,this._pad[2]=l[20]|l[21]<<8,this._pad[3]=l[22]|l[23]<<8,this._pad[4]=l[24]|l[25]<<8,this._pad[5]=l[26]|l[27]<<8,this._pad[6]=l[28]|l[29]<<8,this._pad[7]=l[30]|l[31]<<8}return v.prototype._blocks=function(l,p,d){for(var _=this._fin?0:2048,I=this._h[0],E=this._h[1],y=this._h[2],f=this._h[3],C=this._h[4],A=this._h[5],P=this._h[6],D=this._h[7],x=this._h[8],M=this._h[9],B=this._r[0],F=this._r[1],z=this._r[2],S=this._r[3],O=this._r[4],H=this._r[5],L=this._r[6],j=this._r[7],re=this._r[8],$=this._r[9];d>=16;){var te=l[p+0]|l[p+1]<<8,Z=l[p+2]|l[p+3]<<8,q=l[p+4]|l[p+5]<<8,ne=l[p+6]|l[p+7]<<8,oe=l[p+8]|l[p+9]<<8,de=l[p+10]|l[p+11]<<8,pe=l[p+12]|l[p+13]<<8,ke=l[p+14]|l[p+15]<<8,Se=0,Pe=Se;Pe+=(I+=8191&te)*B,Pe+=(E+=8191&(te>>>13|Z<<3))*(5*$),Pe+=(y+=8191&(Z>>>10|q<<6))*(5*re),Pe+=(f+=8191&(q>>>7|ne<<9))*(5*j),Se=(Pe+=(C+=8191&(ne>>>4|oe<<12))*(5*L))>>>13,Pe&=8191,Pe+=(A+=oe>>>1&8191)*(5*H),Pe+=(P+=8191&(oe>>>14|de<<2))*(5*O),Pe+=(D+=8191&(de>>>11|pe<<5))*(5*S),Pe+=(x+=8191&(pe>>>8|ke<<8))*(5*z);var we=Se+=(Pe+=(M+=ke>>>5|_)*(5*F))>>>13;we+=I*F,we+=E*B,we+=y*(5*$),we+=f*(5*re),Se=(we+=C*(5*j))>>>13,we&=8191,we+=A*(5*L),we+=P*(5*H),we+=D*(5*O),we+=x*(5*S),Se+=(we+=M*(5*z))>>>13,we&=8191;var $e=Se;$e+=I*z,$e+=E*F,$e+=y*B,$e+=f*(5*$),Se=($e+=C*(5*re))>>>13,$e&=8191,$e+=A*(5*j),$e+=P*(5*L),$e+=D*(5*H),$e+=x*(5*O);var K=Se+=($e+=M*(5*S))>>>13;K+=I*S,K+=E*z,K+=y*F,K+=f*B,Se=(K+=C*(5*$))>>>13,K&=8191,K+=A*(5*re),K+=P*(5*j),K+=D*(5*L),K+=x*(5*H);var Ee=Se+=(K+=M*(5*O))>>>13;Ee+=I*O,Ee+=E*S,Ee+=y*z,Ee+=f*F,Se=(Ee+=C*B)>>>13,Ee&=8191,Ee+=A*(5*$),Ee+=P*(5*re),Ee+=D*(5*j),Ee+=x*(5*L);var Ce=Se+=(Ee+=M*(5*H))>>>13;Ce+=I*H,Ce+=E*O,Ce+=y*S,Ce+=f*z,Se=(Ce+=C*F)>>>13,Ce&=8191,Ce+=A*B,Ce+=P*(5*$),Ce+=D*(5*re),Ce+=x*(5*j);var xe=Se+=(Ce+=M*(5*L))>>>13;xe+=I*L,xe+=E*H,xe+=y*O,xe+=f*S,Se=(xe+=C*z)>>>13,xe&=8191,xe+=A*F,xe+=P*B,xe+=D*(5*$),xe+=x*(5*re);var Ke=Se+=(xe+=M*(5*j))>>>13;Ke+=I*j,Ke+=E*L,Ke+=y*H,Ke+=f*O,Se=(Ke+=C*S)>>>13,Ke&=8191,Ke+=A*z,Ke+=P*F,Ke+=D*B,Ke+=x*(5*$);var We=Se+=(Ke+=M*(5*re))>>>13;We+=I*re,We+=E*j,We+=y*L,We+=f*H,Se=(We+=C*O)>>>13,We&=8191,We+=A*S,We+=P*z,We+=D*F,We+=x*B;var Je=Se+=(We+=M*(5*$))>>>13;Je+=I*$,Je+=E*re,Je+=y*j,Je+=f*L,Se=(Je+=C*H)>>>13,Je&=8191,Je+=A*O,Je+=P*S,Je+=D*z,Je+=x*F,I=Pe=8191&(Se=(Se=((Se+=(Je+=M*B)>>>13)<<2)+Se|0)+(Pe&=8191)|0),E=we+=Se>>>=13,y=$e&=8191,f=K&=8191,C=Ee&=8191,A=Ce&=8191,P=xe&=8191,D=Ke&=8191,x=We&=8191,M=Je&=8191,p+=16,d-=16}this._h[0]=I,this._h[1]=E,this._h[2]=y,this._h[3]=f,this._h[4]=C,this._h[5]=A,this._h[6]=P,this._h[7]=D,this._h[8]=x,this._h[9]=M},v.prototype.finish=function(l,p){void 0===p&&(p=0);var _,I,E,y,d=new Uint16Array(10);if(this._leftover){for(y=this._leftover,this._buffer[y++]=1;y<16;y++)this._buffer[y]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(_=this._h[1]>>>13,this._h[1]&=8191,y=2;y<10;y++)this._h[y]+=_,_=this._h[y]>>>13,this._h[y]&=8191;for(this._h[0]+=5*_,_=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=_,_=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=_,d[0]=this._h[0]+5,_=d[0]>>>13,d[0]&=8191,y=1;y<10;y++)d[y]=this._h[y]+_,_=d[y]>>>13,d[y]&=8191;for(d[9]-=8192,I=(1^_)-1,y=0;y<10;y++)d[y]&=I;for(I=~I,y=0;y<10;y++)this._h[y]=this._h[y]&I|d[y];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]),y=1;y<8;y++)this._h[y]=65535&(E=(this._h[y]+this._pad[y]|0)+(E>>>16)|0);return l[p+0]=this._h[0]>>>0,l[p+1]=this._h[0]>>>8,l[p+2]=this._h[1]>>>0,l[p+3]=this._h[1]>>>8,l[p+4]=this._h[2]>>>0,l[p+5]=this._h[2]>>>8,l[p+6]=this._h[3]>>>0,l[p+7]=this._h[3]>>>8,l[p+8]=this._h[4]>>>0,l[p+9]=this._h[4]>>>8,l[p+10]=this._h[5]>>>0,l[p+11]=this._h[5]>>>8,l[p+12]=this._h[6]>>>0,l[p+13]=this._h[6]>>>8,l[p+14]=this._h[7]>>>0,l[p+15]=this._h[7]>>>8,this._finished=!0,this},v.prototype.update=function(l){var _,p=0,d=l.length;if(this._leftover){(_=16-this._leftover)>d&&(_=d);for(var I=0;I<_;I++)this._buffer[this._leftover+I]=l[p+I];if(d-=_,p+=_,this._leftover+=_,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(d>=16&&(this._blocks(l,p,_=d-d%16),p+=_,d-=_),d){for(I=0;I{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.randomStringForEntropy=G.randomString=G.randomUint32=G.randomBytes=G.defaultRandomSource=void 0;const h=N(9753),u=N(4502),g=N(9815);function b(d,_=G.defaultRandomSource){return _.randomBytes(d)}G.defaultRandomSource=new h.SystemRandomSource,G.randomBytes=b,G.randomUint32=function w(d=G.defaultRandomSource){const _=b(4,d),I=(0,u.readUint32LE)(_);return(0,g.wipe)(_),I};const v="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function l(d,_=v,I=G.defaultRandomSource){if(_.length<2)throw new Error("randomString charset is too short");if(_.length>256)throw new Error("randomString charset is too long");let E="";const y=_.length,f=256-256%y;for(;d>0;){const C=b(Math.ceil(256*d/f),I);for(let A=0;A0;A++){const P=C[A];P{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.BrowserRandomSource=void 0,G.BrowserRandomSource=class h{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 b=new Uint8Array(g);for(let w=0;w{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.NodeRandomSource=void 0;const h=N(9815);G.NodeRandomSource=class u{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const b=N(5883);b&&b.randomBytes&&(this._crypto=b,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(b){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let w=this._crypto.randomBytes(b);if(w.length!==b)throw new Error("NodeRandomSource: got fewer bytes than requested");const v=new Uint8Array(b);for(let l=0;l{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.SystemRandomSource=void 0;const h=N(7170),u=N(1382);G.SystemRandomSource=class g{constructor(){return this.isAvailable=!1,this.name="",this._source=new h.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(w){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(w)}}},893:(J,G,N)=>{"use strict";var u=N(4502),g=N(9815);G.k=32,G.cn=64;var b=function(){function p(){this.digestLength=G.k,this.blockSize=G.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 p.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},p.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},p.prototype.clean=function(){g.wipe(this._buffer),g.wipe(this._temp),this.reset()},p.prototype.update=function(d,_){if(void 0===_&&(_=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var I=0;if(this._bytesHashed+=_,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[I++],_--;this._bufferLength===this.blockSize&&(v(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(_>=this.blockSize&&(I=v(this._temp,this._state,d,I,_),_%=this.blockSize);_>0;)this._buffer[this._bufferLength++]=d[I++],_--;return this},p.prototype.finish=function(d){if(!this._finished){var _=this._bytesHashed,I=this._bufferLength,E=_/536870912|0,y=_<<3,f=_%64<56?64:128;this._buffer[I]=128;for(var C=I+1;C0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},p.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},p.prototype.cleanSavedState=function(d){g.wipe(d.state),d.buffer&&g.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},p}();G.mE=b;var w=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 v(p,d,_,I,E){for(;E>=64;){for(var y=d[0],f=d[1],C=d[2],A=d[3],P=d[4],D=d[5],x=d[6],M=d[7],B=0;B<16;B++)p[B]=u.readUint32BE(_,I+4*B);for(B=16;B<64;B++){var z=p[B-2];p[B]=((S=(z>>>17|z<<15)^(z>>>19|z<<13)^z>>>10)+p[B-7]|0)+((O=((z=p[B-15])>>>7|z<<25)^(z>>>18|z<<14)^z>>>3)+p[B-16]|0)}for(B=0;B<64;B++){var S=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&D^~P&x)|0)+(M+(w[B]+p[B]|0)|0)|0,O=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&f^y&C^f&C)|0;M=x,x=D,D=P,P=A+S|0,A=C,C=f,f=y,y=S+O|0}d[0]+=y,d[1]+=f,d[2]+=C,d[3]+=A,d[4]+=P,d[5]+=D,d[6]+=x,d[7]+=M,I+=64,E-=64}return I}G.vp=function l(p){var d=new b;d.update(p);var _=d.digest();return d.clean(),_}},9815:(J,G)=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0}),G.wipe=function N(h){for(var u=0;u{"use strict";G.gi=G.Au=G._w=G.KS=G.kz=void 0;const u=N(5784),g=N(9815);function b(B){const F=new Float64Array(16);if(B)for(let z=0;z=0;--ne){const oe=z[ne>>>3]>>>(7&ne)&1;p(O,H,oe),p(L,j,oe),I(re,O,L),E(O,O,L),I(L,H,j),E(H,H,j),f(j,re),f($,O),y(O,L,O),y(L,H,re),I(re,O,L),E(O,O,L),f(H,O),E(L,j,$),y(O,L,v),I(O,O,j),y(L,L,O),y(O,j,$),y(j,H,S),f(H,re),p(O,H,oe),p(L,j,oe)}for(let ne=0;ne<16;ne++)S[ne+16]=O[ne],S[ne+32]=L[ne],S[ne+48]=H[ne],S[ne+64]=j[ne];const te=S.subarray(32),Z=S.subarray(16);(function C(B,F){const z=b();for(let S=0;S<16;S++)z[S]=F[S];for(let S=253;S>=0;S--)f(z,z),2!==S&&4!==S&&y(z,z,F);for(let S=0;S<16;S++)B[S]=z[S]})(te,te),y(Z,Z,te);const q=new Uint8Array(32);return function d(B,F){const z=b(),S=b();for(let O=0;O<16;O++)S[O]=F[O];l(S),l(S),l(S);for(let O=0;O<2;O++){z[0]=S[0]-65517;for(let L=1;L<15;L++)z[L]=S[L]-65535-(z[L-1]>>16&1),z[L-1]&=65535;z[15]=S[15]-32767-(z[14]>>16&1);const H=z[15]>>16&1;z[14]&=65535,p(S,z,1-H)}for(let O=0;O<16;O++)B[2*O]=255&S[O],B[2*O+1]=S[O]>>8}(q,Z),q}function P(B){return A(B,w)}function D(B){if(B.length!==G.KS)throw new Error(`x25519: seed must be ${G.KS} bytes`);const F=new Uint8Array(B);return{publicKey:P(F),secretKey:F}}G._w=D,G.Au=function x(B){const F=(0,u.randomBytes)(32,B),z=D(F);return(0,g.wipe)(F),z},G.gi=function M(B,F,z=!1){if(B.length!==G.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==G.kz)throw new Error("X25519: incorrect public key length");const S=A(B,F);if(z){let O=0;for(let H=0;H{function G(N){const h=new globalThis.AbortController;function u(){h.abort();for(const g of N)!g||!g.removeEventListener||g.removeEventListener("abort",u)}for(const g of N)if(g&&g.addEventListener){if(g.aborted){u();break}g.addEventListener("abort",u)}return h.signal}J.exports=G,J.exports.anySignal=G},3210:J=>{var G=1e3,N=60*G,h=60*N,u=24*h;function p(d,_,I,E){var y=_>=1.5*I;return Math.round(d/I)+" "+E+(y?"s":"")}J.exports=function(d,_){_=_||{};var I=typeof d;if("string"===I&&d.length>0)return function w(d){if(!((d=String(d)).length>100)){var _=/^(-?(?:\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(_){var I=parseFloat(_[1]);switch((_[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*I;case"weeks":case"week":case"w":return 6048e5*I;case"days":case"day":case"d":return I*u;case"hours":case"hour":case"hrs":case"hr":case"h":return I*h;case"minutes":case"minute":case"mins":case"min":case"m":return I*N;case"seconds":case"second":case"secs":case"sec":case"s":return I*G;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return I;default:return}}}}(d);if("number"===I&&isFinite(d))return _.long?function l(d){var _=Math.abs(d);return _>=u?p(d,_,u,"day"):_>=h?p(d,_,h,"hour"):_>=N?p(d,_,N,"minute"):_>=G?p(d,_,G,"second"):d+" ms"}(d):function v(d){var _=Math.abs(d);return _>=u?Math.round(d/u)+"d":_>=h?Math.round(d/h)+"h":_>=N?Math.round(d/N)+"m":_>=G?Math.round(d/G)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1455:(J,G,N)=>{G.formatArgs=function u(l){if(l[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+l[0]+(this.useColors?"%c ":" ")+"+"+J.exports.humanize(this.diff),!this.useColors)return;const p="color: "+this.color;l.splice(1,0,p,"color: inherit");let d=0,_=0;l[0].replace(/%[a-zA-Z%]/g,I=>{"%%"!==I&&(d++,"%c"===I&&(_=d))}),l.splice(_,0,p)},G.save=function g(l){try{l?G.storage.setItem("debug",l):G.storage.removeItem("debug")}catch{}},G.load=function b(){let l;try{l=G.storage.getItem("debug")}catch{}return!l&&typeof process<"u"&&"env"in process&&(l=process.env.DEBUG),l},G.useColors=function h(){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+)/))},G.storage=function w(){try{return localStorage}catch{}}(),G.destroy=(()=>{let l=!1;return()=>{l||(l=!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`."))}})(),G.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"],G.log=console.debug||console.log||(()=>{}),J.exports=N(3283)(G);const{formatters:v}=J.exports;v.j=function(l){try{return JSON.stringify(l)}catch(p){return"[UnexpectedJSONParseError]: "+p.message}}},3283:(J,G,N)=>{J.exports=function h(u){function b(E){let y,C,A,f=null;function P(...D){if(!P.enabled)return;const x=P,M=Number(new Date);x.diff=M-(y||M),x.prev=y,x.curr=M,y=M,D[0]=b.coerce(D[0]),"string"!=typeof D[0]&&D.unshift("%O");let F=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(S,O)=>{if("%%"===S)return"%";F++;const H=b.formatters[O];return"function"==typeof H&&(S=H.call(x,D[F]),D.splice(F,1),F--),S}),b.formatArgs.call(x,D),(x.log||b.log).apply(x,D)}return P.namespace=E,P.useColors=b.useColors(),P.color=b.selectColor(E),P.extend=w,P.destroy=b.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==f?f:(C!==b.namespaces&&(C=b.namespaces,A=b.enabled(E)),A),set:D=>{f=D}}),"function"==typeof b.init&&b.init(P),P}function w(E,y){const f=b(this.namespace+(typeof y>"u"?":":y)+E);return f.log=this.log,f}function d(E){return E.toString().substring(2,E.toString().length-2).replace(/\.\*\?$/,"*")}return b.debug=b,b.default=b,b.coerce=function _(E){return E instanceof Error?E.stack||E.message:E},b.disable=function l(){const E=[...b.names.map(d),...b.skips.map(d).map(y=>"-"+y)].join(",");return b.enable(""),E},b.enable=function v(E){let y;b.save(E),b.namespaces=E,b.names=[],b.skips=[];const f=("string"==typeof E?E:"").split(/[\s,]+/),C=f.length;for(y=0;y{b[E]=u[E]}),b.names=[],b.skips=[],b.formatters={},b.selectColor=function g(E){let y=0;for(let f=0;f{"use strict";function G(N,u){u=u||{},this._head=0,this._tail=0,this._capacity=u.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(N)&&this._fromArray(N)}G.prototype.peekAt=function(h){var u=h;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]}},G.prototype.get=function(h){return this.peekAt(h)},G.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},G.prototype.peekFront=function(){return this.peek()},G.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(G.prototype,"length",{get:function(){return this.size()}}),G.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}},G.prototype.push=function(h){if(void 0===h)return this.size();var u=this._tail;return this._list[u]=h,this._tail=u+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&h<=u>>>2&&this._shrinkArray(),g}},G.prototype.removeOne=function(h){var u=h;if(u===(0|u)&&this._head!==this._tail){var g=this.size(),b=this._list.length;if(!(u>=g||u<-g)){u<0&&(u+=g);var v,w=this._list[u=this._head+u&this._capacityMask];if(h0;v--)this._list[u]=this._list[u=u-1+b&this._capacityMask];this._list[u]=void 0,this._head=this._head+1+b&this._capacityMask}else{for(v=g-1-h;v>0;v--)this._list[u]=this._list[u=u+1+b&this._capacityMask];this._list[u]=void 0,this._tail=this._tail-1+b&this._capacityMask}return w}}},G.prototype.remove=function(h,u){var b,g=h,w=u;if(g===(0|g)&&this._head!==this._tail){var v=this.size(),l=this._list.length;if(!(g>=v||g<-v||u<1)){if(g<0&&(g+=v),1===u||!u)return(b=new Array(1))[0]=this.removeOne(g),b;if(0===g&&g+u>=v)return b=this.toArray(),this.clear(),b;var p;for(g+u>v&&(u=v-g),b=new Array(u),p=0;p0;p--)this._list[g=g+1+l&this._capacityMask]=void 0;return b}if(0===h){for(this._head=this._head+u+l&this._capacityMask,p=u-1;p>0;p--)this._list[g=g+1+l&this._capacityMask]=void 0;return b}if(g0;p--)this.unshift(this._list[g=g-1+l&this._capacityMask]);for(g=this._head-1+l&this._capacityMask;w>0;)this._list[g=g-1+l&this._capacityMask]=void 0,w--;h<0&&(this._tail=g)}else{for(this._tail=g,g=g+u+l&this._capacityMask,p=v-(u+h);p>0;p--)this.push(this._list[g++]);for(g=this._tail;w>0;)this._list[g=g+1+l&this._capacityMask]=void 0,w--}return this._head<2&&this._tail>1e4&&this._tail<=l>>>2&&this._shrinkArray(),b}}},G.prototype.splice=function(h,u){var g=h;if(g===(0|g)){var b=this.size();if(g<0&&(g+=b),!(g>b)){if(arguments.length>2){var w,v,l,p=arguments.length,d=this._list.length,_=2;if(!b||g0&&(this._head=this._head+g+d&this._capacityMask)):(l=this.remove(g,u),this._head=this._head+g+d&this._capacityMask);p>_;)this.unshift(arguments[--p]);for(w=g;w>0;w--)this.unshift(v[w-1])}else{var I=(v=new Array(b-(g+u))).length;for(w=0;wthis._tail){for(w=this._head;w>>=1,this._capacityMask>>>=1},J.exports=G},2535:J=>{"use strict";function G(h,u){for(const g in u)Object.defineProperty(h,g,{value:u[g],enumerable:!0,configurable:!0});return h}J.exports=function N(h,u,g){if(!h||"string"==typeof h)throw new TypeError("Please pass an Error to err-code");g||(g={}),"object"==typeof u&&(g=u,u=""),u&&(g.code=u);try{return G(h,g)}catch{g.message=h.message,g.stack=h.stack;const w=function(){};return w.prototype=Object.create(Object.getPrototypeOf(h)),G(new w,g)}}},3676:(J,G,N)=>{"use strict";const u=N(649);G.zN=u.EventIterator},649:(J,G)=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});class N{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(g){if(this.isStopped)return;const b={value:g,done:!1};if(this.pullQueue.length){const w=this.pullQueue.shift();w&&w.resolve(b)}else this.pushQueue.push(Promise.resolve(b)),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 b of this.pullQueue)b.reject(g);this.pullQueue.length=0}else{const b=Promise.reject(g);b.catch(()=>{}),this.pushQueue.push(b)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:g=>{const b=this.pushQueue.shift();return b?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),b):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((w,v)=>{this.pullQueue.push({resolve:w,reject:v})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class h{constructor(g,{highWaterMark:b=100,lowWaterMark:w=1}={}){const v=new N;v.highWaterMark=b,v.lowWaterMark=w,v.removeCallback=g({push:l=>v.push(l),stop:()=>v.stop(),fail:l=>v.fail(l),on:(l,p)=>{v.eventHandlers[l]=p}})||(()=>{}),this[Symbol.asyncIterator]=()=>v[Symbol.asyncIterator](),Object.freeze(this)}}G.EventIterator=h,G.default=h},2005:J=>{"use strict";var G=Object.prototype.hasOwnProperty,N="~";function h(){}function u(v,l,p){this.fn=v,this.context=l,this.once=p||!1}function g(v,l,p,d,_){if("function"!=typeof p)throw new TypeError("The listener must be a function");var I=new u(p,d||v,_),E=N?N+l:l;return v._events[E]?v._events[E].fn?v._events[E]=[v._events[E],I]:v._events[E].push(I):(v._events[E]=I,v._eventsCount++),v}function b(v,l){0==--v._eventsCount?v._events=new h:delete v._events[l]}function w(){this._events=new h,this._eventsCount=0}Object.create&&(h.prototype=Object.create(null),(new h).__proto__||(N=!1)),w.prototype.eventNames=function(){var p,d,l=[];if(0===this._eventsCount)return l;for(d in p=this._events)G.call(p,d)&&l.push(N?d.slice(1):d);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(p)):l},w.prototype.listeners=function(l){var d=this._events[N?N+l:l];if(!d)return[];if(d.fn)return[d.fn];for(var _=0,I=d.length,E=new Array(I);_{"use strict";var h,G="object"==typeof Reflect?Reflect:null,N=G&&"function"==typeof G.apply?G.apply:function(M,B,F){return Function.prototype.apply.call(M,B,F)};h=G&&"function"==typeof G.ownKeys?G.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 b(){b.init.call(this)}J.exports=b,J.exports.once=function A(x,M){return new Promise(function(B,F){function z(O){x.removeListener(M,S),F(O)}function S(){"function"==typeof x.removeListener&&x.removeListener("error",z),B([].slice.call(arguments))}D(x,M,S,{once:!0}),"error"!==M&&function P(x,M,B){"function"==typeof x.on&&D(x,"error",M,B)}(x,z,{once:!0})})},b.EventEmitter=b,b.prototype._events=void 0,b.prototype._eventsCount=0,b.prototype._maxListeners=void 0;var w=10;function v(x){if("function"!=typeof x)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof x)}function l(x){return void 0===x._maxListeners?b.defaultMaxListeners:x._maxListeners}function p(x,M,B,F){var z,S,O;if(v(B),void 0===(S=x._events)?(S=x._events=Object.create(null),x._eventsCount=0):(void 0!==S.newListener&&(x.emit("newListener",M,B.listener?B.listener:B),S=x._events),O=S[M]),void 0===O)O=S[M]=B,++x._eventsCount;else if("function"==typeof O?O=S[M]=F?[B,O]:[O,B]:F?O.unshift(B):O.push(B),(z=l(x))>0&&O.length>z&&!O.warned){O.warned=!0;var H=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");H.name="MaxListenersExceededWarning",H.emitter=x,H.type=M,H.count=O.length,function u(x){console&&console.warn&&console.warn(x)}(H)}return x}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 _(x,M,B){var F={fired:!1,wrapFn:void 0,target:x,type:M,listener:B},z=d.bind(F);return z.listener=B,F.wrapFn=z,z}function I(x,M,B){var F=x._events;if(void 0===F)return[];var z=F[M];return void 0===z?[]:"function"==typeof z?B?[z.listener||z]:[z]:B?function C(x){for(var M=new Array(x.length),B=0;B0&&(O=B[0]),O instanceof Error)throw O;var H=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw H.context=O,H}var L=S[M];if(void 0===L)return!1;if("function"==typeof L)N(L,this,B);else{var j=L.length,re=y(L,j);for(F=0;F=0;O--)if(F[O]===B||F[O].listener===B){H=F[O].listener,S=O;break}if(S<0)return this;0===S?F.shift():function f(x,M){for(;M+1=0;z--)this.removeListener(M,B[z]);return this},b.prototype.listeners=function(M){return I(this,M,!0)},b.prototype.rawListeners=function(M){return I(this,M,!1)},b.listenerCount=function(x,M){return"function"==typeof x.listenerCount?x.listenerCount(M):E.call(x,M)},b.prototype.listenerCount=E,b.prototype.eventNames=function(){return this._eventsCount>0?h(this._events):[]}},3111:J=>{J.exports=class{constructor(N){if(!(N>0)||0!=(N-1&N))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(N),this.mask=N-1,this.top=0,this.btm=0,this.next=null}push(N){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=N,this.top=this.top+1&this.mask,!0)}shift(){const N=this.buffer[this.btm];if(void 0!==N)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,N}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},1159:(J,G,N)=>{const h=N(3111);J.exports=class{constructor(g){this.hwm=g||16,this.head=new h(this.hwm),this.tail=this.head}push(g){this.head.push(g)||(this.head=this.head.next=new h(2*this.head.buffer.length),this.head.push(g))}shift(){const g=this.tail.shift();if(void 0===g&&this.tail.next){const b=this.tail.next;return this.tail.next=null,this.tail=b,this.tail.shift()}return g}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},5550:J=>{J.exports=function(G){if(!G)throw Error("hashlru must have a max value, of type number, greater than 0");var N=0,h=Object.create(null),u=Object.create(null);function g(b,w){h[b]=w,++N>=G&&(N=0,u=h,h=Object.create(null))}return{has:function(b){return void 0!==h[b]||void 0!==u[b]},remove:function(b){void 0!==h[b]&&(h[b]=void 0),void 0!==u[b]&&(u[b]=void 0)},get:function(b){var w=h[b];return void 0!==w?w:void 0!==(w=u[b])?(g(b,w),w):void 0},set:function(b,w){void 0!==h[b]?h[b]=w:g(b,w)},clear:function(){h=Object.create(null),u=Object.create(null)}}}},4066:J=>{"use strict";const G="[a-fA-F\\d:]",N=p=>p&&p.includeBoundaries?`(?:(?<=\\s|^)(?=${G})|(?<=${G})(?=\\s|$))`:"",h="(?: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}(?:${h}|:${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}(?::${h}|(?::${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}:${h}|(?::${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}:${h}|(?::${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}:${h}|(?::${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}:${h}|(?::${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}:${h}|(?::${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(),b=new RegExp(`(?:^${h}$)|(?:^${g}$)`),w=new RegExp(`^${h}$`),v=new RegExp(`^${g}$`),l=p=>p&&p.exact?b:new RegExp(`(?:${N(p)}${h}${N(p)})|(?:${N(p)}${g}${N(p)})`,"g");l.v4=p=>p&&p.exact?w:new RegExp(`${N(p)}${h}${N(p)}`,"g"),l.v6=p=>p&&p.exact?v:new RegExp(`${N(p)}${g}${N(p)}`,"g"),J.exports=l},1396:function(J){!function(G){"use strict";const N="(0?\\d+|0x[a-f0-9]+)",h={fourOctet:new RegExp(`^${N}\\.${N}\\.${N}\\.${N}$`,"i"),threeOctet:new RegExp(`^${N}\\.${N}\\.${N}$`,"i"),twoOctet:new RegExp(`^${N}\\.${N}$`,"i"),longValue:new RegExp(`^${N}$`,"i")},u=new RegExp("^0[0-7]+$","i"),g=new RegExp("^0x[a-f0-9]+$","i"),b="%[0-9a-z]{1,}",w="(?:[0-9a-f]+::?)+",v={zoneIndex:new RegExp(b,"i"),native:new RegExp(`^(::)?(${w})?([0-9a-f]+)?(::)?(${b})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${N}\\.${N}\\.${N}\\.${N}(${b})?)$`,"i"),transitional:new RegExp(`^((?:${w})|(?:::)(?:${w})?)${N}\\.${N}\\.${N}\\.${N}(${b})?$`,"i")};function l(E,y){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let P,D,f=0,C=-1,A=(E.match(v.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(C=E.indexOf(":",C+1))>=0;)f++;if("::"===E.substr(0,2)&&f--,"::"===E.substr(-2,2)&&f--,f>y)return null;for(D=y-f,P=":";D--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:y=function(){const x=E.split(":"),M=[];for(let B=0;B0;){if(P=f-C,P<0&&(P=0),E[A]>>P!=y[A]>>P)return!1;C-=f,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 _(E,y){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in C))return null;if(D=C[P],f&&0!==D)return null;8!==D&&(f=!0),y+=D}return 32-y},E.prototype.range=function(){return I.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return I.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),I.IPv4.broadcastAddressFromCIDR=function(E){try{const y=this.parseCIDR(E),f=y[0].toByteArray(),C=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(f[P],10)|255^parseInt(C[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},I.IPv4.isIPv4=function(E){return null!==this.parser(E)},I.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},I.IPv4.isValidFourPartDecimal=function(E){return!(!I.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},I.IPv4.networkAddressFromCIDR=function(E){let y,f,C,A,P;try{for(y=this.parseCIDR(E),C=y[0].toByteArray(),P=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),A=[],f=0;f<4;)A.push(parseInt(C[f],10)&parseInt(P[f],10)),f++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},I.IPv4.parse=function(E){const y=this.parser(E);if(null===y)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(y)},I.IPv4.parseCIDR=function(E){let y;if(y=E.match(/^(.+)\/(\d+)$/)){const f=parseInt(y[2]);if(f>=0&&f<=32){const C=[this.parse(y[1]),f];return Object.defineProperty(C,"toString",{value:function(){return this.join("/")}}),C}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},I.IPv4.parser=function(E){let y,f,C;if(y=E.match(h.fourOctet))return function(){const A=y.slice(1,6),P=[];for(let D=0;D4294967295||C<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(C>>P&255);return A}().reverse()}return(y=E.match(h.twoOctet))?function(){const A=y.slice(1,4),P=[];if(C=d(A[1]),C>16777215||C<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(C>>16&255),P.push(C>>8&255),P.push(255&C),P}():(y=E.match(h.threeOctet))?function(){const A=y.slice(1,5),P=[];if(C=d(A[2]),C>65535||C<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(C>>8&255),P.push(255&C),P}():null},I.IPv4.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const y=[0,0,0,0];let f=0;const C=Math.floor(E/8);for(;f=0;D-=1){if(A=this.parts[D],!(A in C))return null;if(P=C[A],f&&0!==P)return null;16!==P&&(f=!0),y+=P}return 128-y},E.prototype.range=function(){return I.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let y;const f=[],C=this.parts;for(let A=0;A>8),f.push(255&y);return f},E.prototype.toFixedLengthString=function(){const y=function(){const C=[];for(let A=0;A>8,255&f,C>>8,255&C])},E.prototype.toNormalizedString=function(){const y=function(){const C=[];for(let A=0;AA&&(C=P.index,A=P[0].length);return A<0?f:`${f.substring(0,C)}::${f.substring(C+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),I.IPv6.broadcastAddressFromCIDR=function(E){try{const y=this.parseCIDR(E),f=y[0].toByteArray(),C=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(f[P],10)|255^parseInt(C[P],10)),P++;return new this(A)}catch(y){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${y})`)}},I.IPv6.isIPv6=function(E){return null!==this.parser(E)},I.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const y=this.parser(E);return new this(y.parts,y.zoneId),!0}catch{return!1}},I.IPv6.networkAddressFromCIDR=function(E){let y,f,C,A,P;try{for(y=this.parseCIDR(E),C=y[0].toByteArray(),P=this.subnetMaskFromPrefixLength(y[1]).toByteArray(),A=[],f=0;f<16;)A.push(parseInt(C[f],10)&parseInt(P[f],10)),f++;return new this(A)}catch(D){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${D})`)}},I.IPv6.parse=function(E){const y=this.parser(E);if(null===y.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(y.parts,y.zoneId)},I.IPv6.parseCIDR=function(E){let y,f,C;if((f=E.match(/^(.+)\/(\d+)$/))&&(y=parseInt(f[2]),y>=0&&y<=128))return C=[this.parse(f[1]),y],Object.defineProperty(C,"toString",{value:function(){return this.join("/")}}),C;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},I.IPv6.parser=function(E){let y,f,C,A,P,D;if(C=E.match(v.deprecatedTransitional))return this.parser(`::ffff:${C[1]}`);if(v.native.test(E))return l(E,8);if((C=E.match(v.transitional))&&(D=C[6]||"",y=l(C[1].slice(0,-1)+D,6),y.parts)){for(P=[parseInt(C[2]),parseInt(C[3]),parseInt(C[4]),parseInt(C[5])],f=0;f128)throw new Error("ipaddr: invalid IPv6 prefix length");const y=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let f=0;const C=Math.floor(E/8);for(;f{J.exports=function G(){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}},6599:(J,G,N)=>{"use strict";const h=N(4066),u=g=>h({exact:!0}).test(g);u.v4=g=>h.v4({exact:!0}).test(g),u.v6=g=>h.v6({exact:!0}).test(g),u.version=g=>u(g)?u.v4(g)?4:6:void 0,J.exports=u},7494:J=>{"use strict";J.exports=G=>{if("[object Object]"!==Object.prototype.toString.call(G))return!1;const N=Object.getPrototypeOf(G);return null===N||N===Object.prototype}},8596:(J,G,N)=>{"use strict";const{URLWithLegacySupport:h,format:u,URLSearchParams:g,defaultBase:b}=N(5695),w=N(340);J.exports={URL:h,URLSearchParams:g,format:u,relative:w,defaultBase:b}},340:(J,G,N)=>{"use strict";const{URLWithLegacySupport:h,format:u}=N(5695);J.exports=(g,b={},w={},v)=>{let p,l=b.protocol?b.protocol.replace(":",""):"http";l=(w[l]||v||l)+":";try{p=new h(g)}catch{p={}}const d=Object.assign({},b,{protocol:l||p.protocol,host:b.host||p.host});return new h(g,u(d)).toString()}},5695:J=>{"use strict";const G=typeof navigator<"u"&&"ReactNative"===navigator.product,h=self.URL,u=function N(){return G?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}();J.exports={URLWithLegacySupport:class g{constructor(v="",l=u){this.super=new h(v,l),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(v){this.super.hash=v}set host(v){this.super.host=v}set hostname(v){this.super.hostname=v}set href(v){this.super.href=v}set password(v){this.super.password=v}set pathname(v){this.super.pathname=v}set port(v){this.super.port=v}set protocol(v){this.super.protocol=v}set search(v){this.super.search=v}set username(v){this.super.username=v}static createObjectURL(v){return h.createObjectURL(v)}static revokeObjectURL(v){h.revokeObjectURL(v)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:u,format:function b(w){if("string"==typeof w)return new h(w).toString();if(!(w instanceof h)){const l=w.auth?w.auth+"@":"",p=w.port?":"+w.port:"",I=w.hostname||"",E=w.search||(w.query?"?"+w.query:""),f=w.pathname||"";return`${w.protocol?w.protocol+"//":""}${(w.username&&w.password?`${w.username}:${w.password}@`:"")||l}${w.host||I+p}${w.path||f+E}${w.hash||""}`}}}},5357:(J,G,N)=>{"use strict";var h=N(7156).default,u=N(8237).default;J.exports=function(){var b=h(function*(w){const v=[];var d,l=!1,p=!1;try{for(var I,_=u(w);l=!(I=yield _.next()).done;l=!1)v.push(I.value)}catch(E){p=!0,d=E}finally{try{l&&null!=_.return&&(yield _.return())}finally{if(p)throw d}}return v});return function(v){return b.apply(this,arguments)}}()},7414:(J,G,N)=>{"use strict";var h=N(7156).default,u=N(8237).default;J.exports=function(){var b=h(function*(w){var p,v=!1,l=!1;try{for(var d=u(w);v=!(yield d.next()).done;v=!1);}catch(I){l=!0,p=I}finally{try{v&&null!=d.return&&(yield d.return())}finally{if(l)throw p}}});return function(v){return b.apply(this,arguments)}}()},6225:(J,G,N)=>{"use strict";var h=N(6737).default,u=N(8186).default,g=N(8237).default;J.exports=function(){var w=u(function*(v,l){var _,p=!1,d=!1;try{for(var E,I=g(v);p=!(E=yield h(I.next())).done;p=!1){const y=E.value;(yield h(l(y)))&&(yield y)}}catch(y){d=!0,_=y}finally{try{p&&null!=I.return&&(yield h(I.return()))}finally{if(d)throw _}}});return function(l,p){return w.apply(this,arguments)}}()},4943:(J,G,N)=>{"use strict";var h=N(7156).default,u=N(8237).default;J.exports=function(){var b=h(function*(w){var p,v=!1,l=!1;try{for(var _,d=u(w);v=!(_=yield d.next()).done;v=!1)return _.value}catch(I){l=!0,p=I}finally{try{v&&null!=d.return&&(yield d.return())}finally{if(l)throw p}}});return function(v){return b.apply(this,arguments)}}()},1349:(J,G,N)=>{"use strict";var h=N(6737).default,u=N(8186).default,g=N(8237).default;J.exports=function(){var w=u(function*(v,l){var _,p=!1,d=!1;try{for(var E,I=g(v);p=!(E=yield h(I.next())).done;p=!1){const y=E.value;yield h(l(y)),yield y}}catch(y){d=!0,_=y}finally{try{p&&null!=I.return&&(yield h(I.return()))}finally{if(d)throw _}}});return function(l,p){return w.apply(this,arguments)}}()},6930:(J,G,N)=>{"use strict";var h=N(6737).default,u=N(8186).default,g=N(8237).default;J.exports=function(){var w=u(function*(v,l){var _,p=!1,d=!1;try{for(var E,I=g(v);p=!(E=yield h(I.next())).done;p=!1){const y=E.value;yield l(y)}}catch(y){d=!0,_=y}finally{try{p&&null!=I.return&&(yield h(I.return()))}finally{if(d)throw _}}});return function(l,p){return w.apply(this,arguments)}}()},5061:(J,G,N)=>{"use strict";var h=N(7156).default,u=N(8186).default,g=N(6737).default,b=N(8237).default,w=N(8131).default;const v=N(6343);J.exports=function(){var p=u(function*(...d){const _=v();setTimeout(h(function*(){try{yield Promise.all(d.map(function(){var I=h(function*(E){var C,y=!1,f=!1;try{for(var P,A=b(E);y=!(P=yield A.next()).done;y=!1)_.push(P.value)}catch(D){f=!0,C=D}finally{try{y&&null!=A.return&&(yield A.return())}finally{if(f)throw C}}});return function(E){return I.apply(this,arguments)}}())),_.end()}catch(I){_.end(I)}}),0),yield*w(b(_),g)});return function(){return p.apply(this,arguments)}}()},6343:(J,G,N)=>{const h=N(1159);J.exports=u=>{let g;"function"==typeof(u=u||{})?(g=u,u={}):g=u.onEnd;let w,v,l,b=new h;const d=A=>v?v(A):(b.push(A),w),I=A=>l?w:d({done:!1,value:A}),E=A=>l?w:(l=!0,A?(A=>(b=new h,v?v({error:A}):(b.push({error:A}),w)))(A):d({done:!0}));if(w={[Symbol.asyncIterator](){return this},next:()=>{if(!b.isEmpty()){if(u.writev){let P;const D=[];for(;!b.isEmpty();){if(P=b.shift(),P.error)throw P.error;D.push(P.value)}return{done:P.done,value:D}}const A=b.shift();if(A.error)throw A.error;return A}return l?{done:!0}:new Promise((A,P)=>{v=D=>(v=null,D.error?P(D.error):A(u.writev&&!D.done?{done:D.done,value:[D.value]}:D),w)})},return:()=>(b=new h,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:I,end:E},!g)return w;const C=w;return w={[Symbol.asyncIterator](){return this},next:()=>C.next(),throw:A=>(C.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(C.return(),g&&(g(),g=null),{done:!0}),push:I,end:A=>(C.end(A),g&&(g(A),g=null),w)},w}},4297:(J,G,N)=>{"use strict";var h=N(8186).default,u=N(6737).default,g=N(8237).default,b=N(8131).default;const w=N(5357);J.exports=function(){var l=h(function*(p,d){const _=yield u(w(p));yield*b(g(_.sort(d)),u)});return function(d,_){return l.apply(this,arguments)}}()},0:(J,G,N)=>{"use strict";var h=N(6737).default,u=N(8186).default,g=N(8237).default;J.exports=function(){var w=u(function*(v,l){let p=0;if(!(l<1)){var I,d=!1,_=!1;try{for(var y,E=g(v);d=!(y=yield h(E.next())).done;d=!1)if(yield y.value,p++,p===l)return}catch(f){_=!0,I=f}finally{try{d&&null!=E.return&&(yield h(E.return()))}finally{if(_)throw I}}}});return function(l,p){return w.apply(this,arguments)}}()},4237:(J,G,N)=>{var h;!function(){"use strict";var u="input is invalid type",b="object"==typeof window,w=b?window:{};w.JS_SHA3_NO_WINDOW&&(b=!1);var v=!b&&"object"==typeof self;!w.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?w=global:v&&(w=self);var p=!w.JS_SHA3_NO_COMMON_JS&&J.exports,d=N.amdO,_=!w.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",I="0123456789abcdef".split(""),y=[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],x=[128,256],M=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(w.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(K){return"[object Array]"===Object.prototype.toString.call(K)}),_&&(w.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(K){return"object"==typeof K&&K.buffer&&K.buffer.constructor===ArrayBuffer});for(var F=function(K,Ee,Ce){return function(xe){return new Pe(K,Ee,K).update(xe)[Ce]()}},z=function(K,Ee,Ce){return function(xe,Ke){return new Pe(K,Ee,Ke).update(xe)[Ce]()}},S=function(K,Ee,Ce){return function(xe,Ke,We,Je){return Z["cshake"+K].update(xe,Ke,We,Je)[Ce]()}},O=function(K,Ee,Ce){return function(xe,Ke,We,Je){return Z["kmac"+K].update(xe,Ke,We,Je)[Ce]()}},H=function(K,Ee,Ce,xe){for(var Ke=0;Ke>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Ce>>5,this.extraBytes=(31&Ce)>>3;for(var xe=0;xe<50;++xe)this.s[xe]=0}function we(K,Ee,Ce){Pe.call(this,K,Ee,Ce)}Pe.prototype.update=function(K){if(this.finalized)throw new Error("finalize already called");var Ee,Ce=typeof K;if("string"!==Ce){if("object"!==Ce)throw new Error(u);if(null===K)throw new Error(u);if(_&&K.constructor===ArrayBuffer)K=new Uint8Array(K);else if(!(Array.isArray(K)||_&&ArrayBuffer.isView(K)))throw new Error(u);Ee=!0}for(var pt,Dt,xe=this.blocks,Ke=this.byteCount,We=K.length,Je=this.blockCount,Xe=0,Ot=this.s;Xe>2]|=K[Xe]<>2]|=Dt<>2]|=(192|Dt>>6)<>2]|=(128|63&Dt)<=57344?(xe[pt>>2]|=(224|Dt>>12)<>2]|=(128|Dt>>6&63)<>2]|=(128|63&Dt)<>2]|=(240|Dt>>18)<>2]|=(128|Dt>>12&63)<>2]|=(128|Dt>>6&63)<>2]|=(128|63&Dt)<=Ke){for(this.start=pt-Ke,this.block=xe[Je],pt=0;pt>=8);Ce>0;)Ke.unshift(Ce),Ce=255&(K>>=8),++xe;return Ee?Ke.push(xe):Ke.unshift(xe),this.update(Ke),Ke.length},Pe.prototype.encodeString=function(K){var Ee,Ce=typeof K;if("string"!==Ce){if("object"!==Ce)throw new Error(u);if(null===K)throw new Error(u);if(_&&K.constructor===ArrayBuffer)K=new Uint8Array(K);else if(!(Array.isArray(K)||_&&ArrayBuffer.isView(K)))throw new Error(u);Ee=!0}var xe=0;if(Ee)xe=K.length;else for(var We=0;We=57344?xe+=3:(Je=65536+((1023&Je)<<10|1023&K.charCodeAt(++We)),xe+=4)}return xe+=this.encode(8*xe),this.update(K),xe},Pe.prototype.bytepad=function(K,Ee){for(var Ce=this.encode(Ee),xe=0;xe>2]|=this.padding[3&Ee],this.lastByteIndex===this.byteCount)for(K[0]=K[Ce],Ee=1;Ee>4&15]+I[15&Xe]+I[Xe>>12&15]+I[Xe>>8&15]+I[Xe>>20&15]+I[Xe>>16&15]+I[Xe>>28&15]+I[Xe>>24&15];We%K==0&&($e(Ee),Ke=0)}return xe&&(Je+=I[(Xe=Ee[Ke])>>4&15]+I[15&Xe],xe>1&&(Je+=I[Xe>>12&15]+I[Xe>>8&15]),xe>2&&(Je+=I[Xe>>20&15]+I[Xe>>16&15])),Je},Pe.prototype.buffer=Pe.prototype.arrayBuffer=function(){this.finalize();var Xe,K=this.blockCount,Ee=this.s,Ce=this.outputBlocks,xe=this.extraBytes,Ke=0,We=0,Je=this.outputBits>>3;Xe=xe?new ArrayBuffer(Ce+1<<2):new ArrayBuffer(Je);for(var Ot=new Uint32Array(Xe);We>8&255,Je[Xe+2]=Ot>>16&255,Je[Xe+3]=Ot>>24&255;We%K==0&&$e(Ee)}return xe&&(Je[Xe=We<<2]=255&(Ot=Ee[Ke]),xe>1&&(Je[Xe+1]=Ot>>8&255),xe>2&&(Je[Xe+2]=Ot>>16&255)),Je},(we.prototype=new Pe).finalize=function(){return this.encode(this.outputBits,!0),Pe.prototype.finalize.call(this)};var $e=function(K){var Ee,Ce,xe,Ke,We,Je,Xe,Ot,pt,Dt,Wr,Sr,ni,ie,fe,ye,me,_e,Ne,Ye,qe,st,nt,je,be,ge,De,Ue,Be,dt,Pt,vt,et,Pn,Bt,yn,tn,ft,hn,ot,Kt,bt,lr,Hr,Fn,bn,vr,rr,_n,Ft,ut,ce,ve,yt,St,mn,Ge,Qe,Te,ze,ht,Et,lt;for(xe=0;xe<48;xe+=2)Ke=K[0]^K[10]^K[20]^K[30]^K[40],We=K[1]^K[11]^K[21]^K[31]^K[41],Ot=K[4]^K[14]^K[24]^K[34]^K[44],pt=K[5]^K[15]^K[25]^K[35]^K[45],Dt=K[6]^K[16]^K[26]^K[36]^K[46],Wr=K[7]^K[17]^K[27]^K[37]^K[47],Ce=(ni=K[9]^K[19]^K[29]^K[39]^K[49])^((Xe=K[3]^K[13]^K[23]^K[33]^K[43])<<1|(Je=K[2]^K[12]^K[22]^K[32]^K[42])>>>31),K[0]^=Ee=(Sr=K[8]^K[18]^K[28]^K[38]^K[48])^(Je<<1|Xe>>>31),K[1]^=Ce,K[10]^=Ee,K[11]^=Ce,K[20]^=Ee,K[21]^=Ce,K[30]^=Ee,K[31]^=Ce,K[40]^=Ee,K[41]^=Ce,Ce=We^(pt<<1|Ot>>>31),K[2]^=Ee=Ke^(Ot<<1|pt>>>31),K[3]^=Ce,K[12]^=Ee,K[13]^=Ce,K[22]^=Ee,K[23]^=Ce,K[32]^=Ee,K[33]^=Ce,K[42]^=Ee,K[43]^=Ce,Ce=Xe^(Wr<<1|Dt>>>31),K[4]^=Ee=Je^(Dt<<1|Wr>>>31),K[5]^=Ce,K[14]^=Ee,K[15]^=Ce,K[24]^=Ee,K[25]^=Ce,K[34]^=Ee,K[35]^=Ce,K[44]^=Ee,K[45]^=Ce,Ce=pt^(ni<<1|Sr>>>31),K[6]^=Ee=Ot^(Sr<<1|ni>>>31),K[7]^=Ce,K[16]^=Ee,K[17]^=Ce,K[26]^=Ee,K[27]^=Ce,K[36]^=Ee,K[37]^=Ce,K[46]^=Ee,K[47]^=Ce,Ce=Wr^(We<<1|Ke>>>31),K[8]^=Ee=Dt^(Ke<<1|We>>>31),K[9]^=Ce,K[18]^=Ee,K[19]^=Ce,K[28]^=Ee,K[29]^=Ce,K[38]^=Ee,K[39]^=Ce,K[48]^=Ee,K[49]^=Ce,fe=K[1],bn=K[11]<<4|K[10]>>>28,vr=K[10]<<4|K[11]>>>28,Ue=K[20]<<3|K[21]>>>29,Be=K[21]<<3|K[20]>>>29,ze=K[31]<<9|K[30]>>>23,ht=K[30]<<9|K[31]>>>23,bt=K[40]<<18|K[41]>>>14,lr=K[41]<<18|K[40]>>>14,Pn=K[2]<<1|K[3]>>>31,Bt=K[3]<<1|K[2]>>>31,me=K[12]<<12|K[13]>>>20,rr=K[22]<<10|K[23]>>>22,_n=K[23]<<10|K[22]>>>22,dt=K[33]<<13|K[32]>>>19,Pt=K[32]<<13|K[33]>>>19,Et=K[42]<<2|K[43]>>>30,lt=K[43]<<2|K[42]>>>30,yt=K[5]<<30|K[4]>>>2,St=K[4]<<30|K[5]>>>2,yn=K[14]<<6|K[15]>>>26,tn=K[15]<<6|K[14]>>>26,Ne=K[24]<<11|K[25]>>>21,Ft=K[34]<<15|K[35]>>>17,ut=K[35]<<15|K[34]>>>17,vt=K[45]<<29|K[44]>>>3,et=K[44]<<29|K[45]>>>3,je=K[6]<<28|K[7]>>>4,be=K[7]<<28|K[6]>>>4,mn=K[17]<<23|K[16]>>>9,Ge=K[16]<<23|K[17]>>>9,ft=K[26]<<25|K[27]>>>7,hn=K[27]<<25|K[26]>>>7,Ye=K[36]<<21|K[37]>>>11,qe=K[37]<<21|K[36]>>>11,ce=K[47]<<24|K[46]>>>8,ve=K[46]<<24|K[47]>>>8,Hr=K[8]<<27|K[9]>>>5,Fn=K[9]<<27|K[8]>>>5,ge=K[18]<<20|K[19]>>>12,De=K[19]<<20|K[18]>>>12,Qe=K[29]<<7|K[28]>>>25,Te=K[28]<<7|K[29]>>>25,ot=K[38]<<8|K[39]>>>24,Kt=K[39]<<8|K[38]>>>24,st=K[48]<<14|K[49]>>>18,nt=K[49]<<14|K[48]>>>18,K[0]=(ie=K[0])^~(ye=K[13]<<12|K[12]>>>20)&(_e=K[25]<<11|K[24]>>>21),K[1]=fe^~me&Ne,K[10]=je^~ge&Ue,K[11]=be^~De&Be,K[20]=Pn^~yn&ft,K[21]=Bt^~tn&hn,K[30]=Hr^~bn&rr,K[31]=Fn^~vr&_n,K[40]=yt^~mn&Qe,K[41]=St^~Ge&Te,K[2]=ye^~_e&Ye,K[3]=me^~Ne&qe,K[12]=ge^~Ue&dt,K[13]=De^~Be&Pt,K[22]=yn^~ft&ot,K[23]=tn^~hn&Kt,K[32]=bn^~rr&Ft,K[33]=vr^~_n&ut,K[42]=mn^~Qe&ze,K[43]=Ge^~Te&ht,K[4]=_e^~Ye&st,K[5]=Ne^~qe&nt,K[14]=Ue^~dt&vt,K[15]=Be^~Pt&et,K[24]=ft^~ot&bt,K[25]=hn^~Kt&lr,K[34]=rr^~Ft&ce,K[35]=_n^~ut&ve,K[44]=Qe^~ze&Et,K[45]=Te^~ht<,K[6]=Ye^~st&ie,K[7]=qe^~nt&fe,K[16]=dt^~vt&je,K[17]=Pt^~et&be,K[26]=ot^~bt&Pn,K[27]=Kt^~lr&Bt,K[36]=Ft^~ce&Hr,K[37]=ut^~ve&Fn,K[46]=ze^~Et&yt,K[47]=ht^~lt&St,K[8]=st^~ie&ye,K[9]=nt^~fe&me,K[18]=vt^~je&ge,K[19]=et^~be&De,K[28]=bt^~Pn&yn,K[29]=lr^~Bt&tn,K[38]=ce^~Hr&bn,K[39]=ve^~Fn&vr,K[48]=Et^~yt&mn,K[49]=lt^~St&Ge,K[0]^=P[xe],K[1]^=P[xe+1]};if(p)J.exports=Z;else{for(ne=0;neObject.defineProperty(f,C,{value:A,writable:!0,enumerable:!0,configurable:!0}),w=this,v={concatArrays:!1,ignoreUndefined:!1},l=f=>{const C=[];for(const A in f)u.call(f,A)&&C.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(f);for(const P of A)g.call(f,P)&&C.push(P)}return C};function p(f){return Array.isArray(f)?function d(f){const C=f.slice(0,0);return l(f).forEach(A=>{b(C,A,p(f[A]))}),C}(f):h(f)?function _(f){const C=null===Object.getPrototypeOf(f)?Object.create(null):{};return l(f).forEach(A=>{b(C,A,p(f[A]))}),C}(f):f}const I=(f,C,A,P)=>(A.forEach(D=>{typeof C[D]>"u"&&P.ignoreUndefined||(D in f&&f[D]!==Object.getPrototypeOf(f)?b(f,D,y(f[D],C[D],P)):b(f,D,p(C[D])))}),f);function y(f,C,A){return A.concatArrays&&Array.isArray(f)&&Array.isArray(C)?((f,C,A)=>{let P=f.slice(0,0),D=0;return[f,C].forEach(x=>{const M=[];for(let B=0;B!M.includes(B)),A)}),P})(f,C,A):h(C)&&h(f)?I(f,C,l(C),A):p(C)}J.exports=function(...f){const C=y(p(v),this!==w&&this||{},v);let A={_:{}};for(const P of f)if(void 0!==P){if(!h(P))throw new TypeError("`"+P+"` is not an Option Object");A=y(A,{_:P},C)}return A._}},4366:J=>{var G=1e3,N=60*G,h=60*N,u=24*h;function p(d,_,I,E){var y=_>=1.5*I;return Math.round(d/I)+" "+E+(y?"s":"")}J.exports=function(d,_){_=_||{};var I=typeof d;if("string"===I&&d.length>0)return function w(d){if(!((d=String(d)).length>100)){var _=/^(-?(?:\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(_){var I=parseFloat(_[1]);switch((_[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*I;case"weeks":case"week":case"w":return 6048e5*I;case"days":case"day":case"d":return I*u;case"hours":case"hour":case"hrs":case"hr":case"h":return I*h;case"minutes":case"minute":case"mins":case"min":case"m":return I*N;case"seconds":case"second":case"secs":case"sec":case"s":return I*G;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return I;default:return}}}}(d);if("number"===I&&isFinite(d))return _.long?function l(d){var _=Math.abs(d);return _>=u?p(d,_,u,"day"):_>=h?p(d,_,h,"hour"):_>=N?p(d,_,N,"minute"):_>=G?p(d,_,G,"second"):d+" ms"}(d):function v(d){var _=Math.abs(d);return _>=u?Math.round(d/u)+"d":_>=h?Math.round(d/h)+"h":_>=N?Math.round(d/N)+"m":_>=G?Math.round(d/G)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},344:J=>{"use strict";function G(N){if(Array.isArray(N)){for(var h=0,u=Array(N.length);h>>24,(p&255<<16)>>>16,(65280&p)>>>8,255&p].join(".")},v=function(p){var d,I,E,y,f;for(d=[],I=E=0;E<=3&&0!==p.length;I=++E){if(I>0){if("."!==p[0])throw new Error("Invalid IP");p=p.substring(1)}y=(f=h(p))[0],p=p.substring(f[1]),d.push(y)}if(0!==p.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(p){return p.charCodeAt(0)})("0"),w=u("a"),b=u("A"),h=function(p){var d,_,I,E,y;for(E=0,d=10,_="9",I=0,p.length>1&&"0"===p[I]&&("x"===p[I+1]||"X"===p[I+1]?(I+=2,d=16):"0"<=p[I+1]&&p[I+1]<="9"&&(I++,d=8,_="7")),y=I;I>>0;else{if(16!==d)break;if("a"<=p[I]&&p[I]<="f")E=E*d+(10+u(p[I])-w)>>>0;else{if(!("A"<=p[I]&&p[I]<="F"))break;E=E*d+(10+u(p[I])-b)>>>0}}if(E>4294967295)throw new Error("too large");I++}if(I===y)throw new Error("empty octet");return[E,I]},N=function(){function p(d,_){var E,y,f;if("string"!=typeof d)throw new Error("Missing `net' parameter");if(_||(f=d.split("/",2),d=f[0],_=f[1]),_||(_=32),"string"==typeof _&&_.indexOf(".")>-1){try{this.maskLong=v(_)}catch(C){throw new Error("Invalid mask: "+_)}for(E=y=32;y>=0;E=--y)if(this.maskLong===4294967295<<32-E>>>0){this.bitmask=E;break}}else{if(!_&&0!==_)throw new Error("Invalid mask: empty");this.bitmask=parseInt(_,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(v(d)&this.maskLong)>>>0}catch(C){throw new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+_);this.size=Math.pow(2,32-this.bitmask),this.base=l(this.netLong),this.mask=l(this.maskLong),this.hostmask=l(~this.maskLong),this.first=this.bitmask<=30?l(this.netLong+1):this.base,this.last=l(this.bitmask<=30?this.netLong+this.size-2:this.netLong+this.size-1),this.broadcast=this.bitmask<=30?l(this.netLong+this.size-1):void 0}return p.prototype.contains=function(d){return"string"==typeof d&&(d.indexOf("/")>0||4!==d.split(".").length)&&(d=new p(d)),d instanceof p?this.contains(d.base)&&this.contains(d.broadcast||d.last):(v(d)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},p.prototype.next=function(d){return null==d&&(d=1),new p(l(this.netLong+this.size*d),this.mask)},p.prototype.forEach=function(d){var _,I,E;for(E=v(this.first),I=v(this.last),_=0;E<=I;)d(l(E),E,_),_++,E++},p.prototype.toString=function(){return this.base+"/"+this.bitmask},p}(),G.ip2long=v,G.long2ip=l,G.Netmask=N}).call(this)},1298:(J,G,N)=>{var h=N(8659);function u(f,C){h.cipher.registerAlgorithm(f,function(){return new h.aes.Algorithm(f,C)})}N(3311),N(3481),N(4747),J.exports=h.aes=h.aes||{},h.aes.startEncrypting=function(f,C,A,P){var D=y({key:f,output:A,decrypt:!1,mode:P});return D.start(C),D},h.aes.createEncryptionCipher=function(f,C){return y({key:f,output:null,decrypt:!1,mode:C})},h.aes.startDecrypting=function(f,C,A,P){var D=y({key:f,output:A,decrypt:!0,mode:P});return D.start(C),D},h.aes.createDecryptionCipher=function(f,C){return y({key:f,output:null,decrypt:!0,mode:C})},h.aes.Algorithm=function(f,C){g||_();var A=this;A.name=f,A.mode=new C({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},h.aes.Algorithm.prototype.initialize=function(f){if(!this._init){var A,C=f.key;if("string"!=typeof C||16!==C.length&&24!==C.length&&32!==C.length){if(h.util.isArray(C)&&(16===C.length||24===C.length||32===C.length)){A=C,C=h.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&B^99,v[B]=A,z=(F=f[B])<<24^B<<16^B<<8^B^F,S=((D=f[A])^(x=f[D])^(M=f[x]))<<24^(A^M)<<16^(A^x^M)<<8^A^D^M;for(var O=0;O<4;++O)p[O][A]=z,d[O][B]=S,z=z<<24|z>>>8,S=S<<24|S>>>8;0===A?A=P=1:(A=D^f[f[f[D^M]]],P^=f[f[P]])}}function I(f,C){for(var P,A=f.slice(0),D=1,x=A.length,B=4*(x+6+1),F=x;F>>16&255]<<24^w[P>>>8&255]<<16^w[255&P]<<8^w[P>>>24]^l[D]<<24,D++):x>6&&F%x==4&&(P=w[P>>>24]<<24^w[P>>>16&255]<<16^w[P>>>8&255]<<8^w[255&P]),A[F]=A[F-x]^P;if(C){for(var z,S=d[0],O=d[1],H=d[2],L=d[3],j=A.slice(0),re=(F=0,(B=A.length)-4);F>>24]]^O[w[z>>>16&255]]^H[w[z>>>8&255]]^L[w[255&z]];A=j}return A}function E(f,C,A,P){var x,M,B,F,z,S,O,H,L,j,re,$,D=f.length/4-1;P?(x=d[0],M=d[1],B=d[2],F=d[3],z=v):(x=p[0],M=p[1],B=p[2],F=p[3],z=w),S=C[0]^f[0],O=C[P?3:1]^f[1],H=C[2]^f[2],L=C[P?1:3]^f[3];for(var te=3,Z=1;Z>>24]^M[O>>>16&255]^B[H>>>8&255]^F[255&L]^f[++te],re=x[O>>>24]^M[H>>>16&255]^B[L>>>8&255]^F[255&S]^f[++te],$=x[H>>>24]^M[L>>>16&255]^B[S>>>8&255]^F[255&O]^f[++te],L=x[L>>>24]^M[S>>>16&255]^B[O>>>8&255]^F[255&H]^f[++te],S=j,O=re,H=$;A[0]=z[S>>>24]<<24^z[O>>>16&255]<<16^z[H>>>8&255]<<8^z[255&L]^f[++te],A[P?3:1]=z[O>>>24]<<24^z[H>>>16&255]<<16^z[L>>>8&255]<<8^z[255&S]^f[++te],A[2]=z[H>>>24]<<24^z[L>>>16&255]<<16^z[S>>>8&255]<<8^z[255&O]^f[++te],A[P?1:3]=z[L>>>24]<<24^z[S>>>16&255]<<16^z[O>>>8&255]<<8^z[255&H]^f[++te]}function y(f){var P,A="AES-"+((f=f||{}).mode||"CBC").toUpperCase(),D=(P=f.decrypt?h.cipher.createDecipher(A,f.key):h.cipher.createCipher(A,f.key)).start;return P.start=function(x,M){var B=null;M instanceof h.util.ByteBuffer&&(B=M,M={}),(M=M||{}).output=B,M.iv=x,D.call(P,M)},P}},7791:(J,G,N)=>{var h=N(8659);N(4747),N(6078);var u=J.exports=h.asn1=h.asn1||{};function g(l,p,d){if(d>p){var _=new Error("Too few bytes to parse DER.");throw _.available=l.length(),_.remaining=p,_.requested=d,_}}function w(l,p,d,_){var I;g(l,p,2);var E=l.getByte();p--;var y=192&E,f=31&E;I=l.length();var C=function(l,p){var d=l.getByte();if(p--,128!==d){var _;if(128&d){var E=127&d;g(l,p,E),_=l.getInt(E<<3)}else _=d;if(_<0)throw new Error("Negative length: "+_);return _}}(l,p);if(p-=I-l.length(),void 0!==C&&C>p){if(_.strict){var A=new Error("Too few bytes to read ASN.1 value.");throw A.available=l.length(),A.remaining=p,A.requested=C,A}C=p}var P,D,x=32==(32&E);if(x)if(P=[],void 0===C)for(;;){if(g(l,p,2),l.bytes(2)===String.fromCharCode(0,0)){l.getBytes(2),p-=2;break}I=l.length(),P.push(w(l,p,d+1,_)),p-=I-l.length()}else for(;C>0;)I=l.length(),P.push(w(l,C,d+1,_)),p-=I-l.length(),C-=I-l.length();if(void 0===P&&y===u.Class.UNIVERSAL&&f===u.Type.BITSTRING&&(D=l.bytes(C)),void 0===P&&_.decodeBitStrings&&y===u.Class.UNIVERSAL&&f===u.Type.BITSTRING&&C>1){var M=l.read,B=p,F=0;if(f===u.Type.BITSTRING&&(g(l,p,1),F=l.getByte(),p--),0===F)try{I=l.length();var S=w(l,p,d+1,{strict:!0,decodeBitStrings:!0}),O=I-l.length();p-=O,f==u.Type.BITSTRING&&O++;var H=S.tagClass;O===C&&(H===u.Class.UNIVERSAL||H===u.Class.CONTEXT_SPECIFIC)&&(P=[S])}catch{}void 0===P&&(l.read=M,p=B)}if(void 0===P){if(void 0===C){if(_.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");C=p}if(f===u.Type.BMPSTRING)for(P="";C>0;C-=2)g(l,p,2),P+=String.fromCharCode(l.getInt16()),p-=2;else P=l.getBytes(C),p-=C}return u.create(y,f,x,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(l,p,d,_,I){if(h.util.isArray(_)){for(var E=[],y=0;y<_.length;++y)void 0!==_[y]&&E.push(_[y]);_=E}var f={tagClass:l,type:p,constructed:d,composed:d||h.util.isArray(_),value:_};return I&&"bitStringContents"in I&&(f.bitStringContents=I.bitStringContents,f.original=u.copy(f)),f},u.copy=function(l,p){var d;if(h.util.isArray(l)){d=[];for(var _=0;_1&&(0===l.value.charCodeAt(0)&&0==(128&l.value.charCodeAt(1))||255===l.value.charCodeAt(0)&&128==(128&l.value.charCodeAt(1)))?_.putBytes(l.value.substr(1)):_.putBytes(l.value);if(p.putByte(d),_.length()<=127)p.putByte(127&_.length());else{var y=_.length(),f="";do{f+=String.fromCharCode(255&y),y>>>=8}while(y>0);for(p.putByte(128|f.length),E=f.length-1;E>=0;--E)p.putByte(f.charCodeAt(E))}return p.putBuffer(_),p},u.oidToDer=function(l){var p=l.split("."),d=h.util.createBuffer();d.putByte(40*parseInt(p[0],10)+parseInt(p[1],10));for(var _,I,E,y,f=2;f>>=7,_||(y|=128),I.push(y),_=!1}while(E>0);for(var C=I.length-1;C>=0;--C)d.putByte(I[C])}return d},u.derToOid=function(l){var p;"string"==typeof l&&(l=h.util.createBuffer(l));var d=l.getByte();p=Math.floor(d/40)+"."+d%40;for(var _=0;l.length()>0;)_<<=7,128&(d=l.getByte())?_+=127&d:(p+="."+(_+d),_=0);return p},u.utcTimeToDate=function(l){var p=new Date,d=parseInt(l.substr(0,2),10);d=d>=50?1900+d:2e3+d;var _=parseInt(l.substr(2,2),10)-1,I=parseInt(l.substr(4,2),10),E=parseInt(l.substr(6,2),10),y=parseInt(l.substr(8,2),10),f=0;if(l.length>11){var C=l.charAt(10),A=10;"+"!==C&&"-"!==C&&(f=parseInt(l.substr(10,2),10),A+=2)}if(p.setUTCFullYear(d,_,I),p.setUTCHours(E,y,f,0),A&&("+"===(C=l.charAt(A))||"-"===C)){var x=60*parseInt(l.substr(A+1,2),10)+parseInt(l.substr(A+4,2),10);x*=6e4,p.setTime("+"===C?+p-x:+p+x)}return p},u.generalizedTimeToDate=function(l){var p=new Date,d=parseInt(l.substr(0,4),10),_=parseInt(l.substr(4,2),10)-1,I=parseInt(l.substr(6,2),10),E=parseInt(l.substr(8,2),10),y=parseInt(l.substr(10,2),10),f=parseInt(l.substr(12,2),10),C=0,A=0,P=!1;"Z"===l.charAt(l.length-1)&&(P=!0);var D=l.length-5,x=l.charAt(D);return"+"!==x&&"-"!==x||(A=60*parseInt(l.substr(D+1,2),10)+parseInt(l.substr(D+4,2),10),A*=6e4,"+"===x&&(A*=-1),P=!0),"."===l.charAt(14)&&(C=1e3*parseFloat(l.substr(14),10)),P?(p.setUTCFullYear(d,_,I),p.setUTCHours(E,y,f,C),p.setTime(+p+A)):(p.setFullYear(d,_,I),p.setHours(E,y,f,C)),p},u.dateToUtcTime=function(l){if("string"==typeof l)return l;var p="",d=[];d.push((""+l.getUTCFullYear()).substr(2)),d.push(""+(l.getUTCMonth()+1)),d.push(""+l.getUTCDate()),d.push(""+l.getUTCHours()),d.push(""+l.getUTCMinutes()),d.push(""+l.getUTCSeconds());for(var _=0;_=-128&&l<128)return p.putSignedInt(l,8);if(l>=-32768&&l<32768)return p.putSignedInt(l,16);if(l>=-8388608&&l<8388608)return p.putSignedInt(l,24);if(l>=-2147483648&&l<2147483648)return p.putSignedInt(l,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=l,d},u.derToInteger=function(l){"string"==typeof l&&(l=h.util.createBuffer(l));var p=8*l.length();if(p>32)throw new Error("Integer too large; max is 32-bits.");return l.getSignedInt(p)},u.validate=function(l,p,d,_){var I=!1;if((l.tagClass===p.tagClass||typeof p.tagClass>"u")&&(l.type===p.type||typeof p.type>"u"))if(l.constructed===p.constructed||typeof p.constructed>"u"){if(I=!0,p.value&&h.util.isArray(p.value))for(var E=0,y=0;I&&y0&&(_+="\n");for(var I="",E=0;E1?"0x"+h.util.bytesToHex(l.value.slice(1)):"(none)",l.value.length>0){var A=l.value.charCodeAt(0);1==A?_+=" (1 unused bit shown)":A>1&&(_+=" ("+A+" unused bits shown)")}}else if(l.type===u.Type.OCTETSTRING)v.test(l.value)||(_+="("+l.value+") "),_+="0x"+h.util.bytesToHex(l.value);else if(l.type===u.Type.UTF8)try{_+=h.util.decodeUtf8(l.value)}catch(P){if("URI malformed"!==P.message)throw P;_+="0x"+h.util.bytesToHex(l.value)+" (malformed UTF8)"}else l.type===u.Type.PRINTABLESTRING||l.type===u.Type.IA5String?_+=l.value:v.test(l.value)?_+="0x"+h.util.bytesToHex(l.value):_+=0===l.value.length?"[null]":l.value}return _}},2020:J=>{var G={};J.exports=G;var N={};G.encode=function(u,g,b){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==b&&"number"!=typeof b)throw new TypeError('"maxline" must be a number.');var w="";if(u instanceof Uint8Array){var v=0,l=g.length,p=g.charAt(0),d=[0];for(v=0;v0;)d.push(I%l),I=I/l|0}for(v=0;0===u[v]&&v=0;--v)w+=g[d[v]]}else w=function h(u,g){var b=0,w=g.length,v=g.charAt(0),l=[0];for(b=0;b0;)l.push(d%w),d=d/w|0}var _="";for(b=0;0===u.at(b)&&b=0;--b)_+=g[l[b]];return _}(u,g);if(b){var E=new RegExp(".{1,"+b+"}","g");w=w.match(E).join("\r\n")}return w},G.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 b=N[g];if(!b){b=N[g]=[];for(var w=0;w>=8;for(;I>0;)p.push(255&I),I>>=8}for(var E=0;u[E]===l&&E{var h=N(8659);N(4747),J.exports=h.cipher=h.cipher||{},h.cipher.algorithms=h.cipher.algorithms||{},h.cipher.createCipher=function(g,b){var w=g;if("string"==typeof w&&(w=h.cipher.getAlgorithm(w))&&(w=w()),!w)throw new Error("Unsupported algorithm: "+g);return new h.cipher.BlockCipher({algorithm:w,key:b,decrypt:!1})},h.cipher.createDecipher=function(g,b){var w=g;if("string"==typeof w&&(w=h.cipher.getAlgorithm(w))&&(w=w()),!w)throw new Error("Unsupported algorithm: "+g);return new h.cipher.BlockCipher({algorithm:w,key:b,decrypt:!0})},h.cipher.registerAlgorithm=function(g,b){g=g.toUpperCase(),h.cipher.algorithms[g]=b},h.cipher.getAlgorithm=function(g){return(g=g.toUpperCase())in h.cipher.algorithms?h.cipher.algorithms[g]:null};var u=h.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 b={};for(var w in g)b[w]=g[w];b.decrypt=this._decrypt,this._finish=!1,this._input=h.util.createBuffer(),this.output=g.output||h.util.createBuffer(),this.mode.start(b)},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(w){return g(this.blockSize,w,!1)},this.mode.unpad=function(w){return g(this.blockSize,w,!0)});var b={};return b.decrypt=this._decrypt,b.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,b)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,b))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,b))}},3481:(J,G,N)=>{var h=N(8659);N(4747),h.cipher=h.cipher||{};var u=J.exports=h.cipher.modes=h.cipher.modes||{};function g(v,l){if("string"==typeof v&&(v=h.util.createBuffer(v)),h.util.isArray(v)&&v.length>4){var p=v;v=h.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var p=v.length(),d=v.at(p-1);return!(d>this.blockSize<<2||(v.truncate(d),0))},u.cbc=function(v){v=v||{},this.name="CBC",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},u.cbc.prototype.start=function(v){if(null===v.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=g(v.iv,this.blockSize),this._prev=this._iv.slice(0)}},u.cbc.prototype.encrypt=function(v,l,p){if(v.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var p=v.length(),d=v.at(p-1);return!(d>this.blockSize<<2||(v.truncate(d),0))},u.cfb=function(v){v=v||{},this.name="CFB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=h.util.createBuffer(),this._partialBytes=0},u.cfb.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=g(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.cfb.prototype.encrypt=function(v,l,p){var d=v.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var _=0;_0&&(I=this.blockSize-I),this._partialOutput.clear(),_=0;_0)v.read-=this.blockSize;else for(_=0;_0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!p)return l.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;l.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.cfb.prototype.decrypt=function(v,l,p){var d=v.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var _=0;_0&&(I=this.blockSize-I),this._partialOutput.clear(),_=0;_0)v.read-=this.blockSize;else for(_=0;_0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!p)return l.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;l.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb=function(v){v=v||{},this.name="OFB",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=h.util.createBuffer(),this._partialBytes=0},u.ofb.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=g(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ofb.prototype.encrypt=function(v,l,p){var d=v.length();if(0===v.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var _=0;_0&&(I=this.blockSize-I),this._partialOutput.clear(),_=0;_0)v.read-=this.blockSize;else for(_=0;_0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!p)return l.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;l.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb.prototype.decrypt=u.ofb.prototype.encrypt,u.ctr=function(v){v=v||{},this.name="CTR",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=h.util.createBuffer(),this._partialBytes=0},u.ctr.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");this._iv=g(v.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ctr.prototype.encrypt=function(v,l,p){var d=v.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var _=0;_0&&(I=this.blockSize-I),this._partialOutput.clear(),_=0;_0&&(v.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!p)return l.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;l.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}b(this._inBlock)},u.ctr.prototype.decrypt=u.ctr.prototype.encrypt,u.gcm=function(v){v=v||{},this.name="GCM",this.cipher=v.cipher,this.blockSize=v.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=h.util.createBuffer(),this._partialBytes=0,this._R=3774873600},u.gcm.prototype.start=function(v){if(!("iv"in v))throw new Error("Invalid IV parameter.");var p,l=h.util.createBuffer(v.iv);if(this._cipherLength=0,p="additionalData"in v?h.util.createBuffer(v.additionalData):h.util.createBuffer(),this._tagLength="tagLength"in v?v.tagLength:128,this._tag=null,v.decrypt&&(this._tag=h.util.createBuffer(v.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=l.length();if(12===d)this._j0=[l.getInt32(),l.getInt32(),l.getInt32(),1];else{for(this._j0=[0,0,0,0];l.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[l.getInt32(),l.getInt32(),l.getInt32(),l.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(w(8*d)))}this._inBlock=this._j0.slice(0),b(this._inBlock),this._partialBytes=0,p=h.util.createBuffer(p),this._aDataLength=w(8*p.length());var _=p.length()%this.blockSize;for(_&&p.fillWithByte(0,this.blockSize-_),this._s=[0,0,0,0];p.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[p.getInt32(),p.getInt32(),p.getInt32(),p.getInt32()])},u.gcm.prototype.encrypt=function(v,l,p){var d=v.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var _=0;_0&&(I=this.blockSize-I),this._partialOutput.clear(),_=0;_0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!p)return v.read-=this.blockSize,l.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;l.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),b(this._inBlock)},u.gcm.prototype.decrypt=function(v,l,p){var d=v.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),b(this._inBlock),this._hashBlock[0]=v.getInt32(),this._hashBlock[1]=v.getInt32(),this._hashBlock[2]=v.getInt32(),this._hashBlock[3]=v.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var _=0;_0;--d)l[d]=v[d]>>>1|(1&v[d-1])<<31;l[0]=v[0]>>>1,p&&(l[0]^=this._R)},u.gcm.prototype.tableMultiply=function(v){for(var l=[0,0,0,0],p=0;p<32;++p){var I=this._m[p][v[p/8|0]>>>4*(7-p%8)&15];l[0]^=I[0],l[1]^=I[1],l[2]^=I[2],l[3]^=I[3]}return l},u.gcm.prototype.ghash=function(v,l,p){return l[0]^=p[0],l[1]^=p[1],l[2]^=p[2],l[3]^=p[3],this.tableMultiply(l)},u.gcm.prototype.generateHashTable=function(v,l){for(var p=8/l,d=4*p,_=16*p,I=new Array(_),E=0;E<_;++E){var y=[0,0,0,0];y[E/d|0]=1<>>1,_=new Array(p);_[d]=v.slice(0);for(var I=d>>>1;I>0;)this.pow(_[2*I],_[I]=[]),I>>=1;for(I=2;I{var h=N(8659);function u(f,C){h.cipher.registerAlgorithm(f,function(){return new h.des.Algorithm(f,C)})}N(3311),N(3481),N(4747),J.exports=h.des=h.des||{},h.des.startEncrypting=function(f,C,A,P){var D=y({key:f,output:A,decrypt:!1,mode:P||(null===C?"ECB":"CBC")});return D.start(C),D},h.des.createEncryptionCipher=function(f,C){return y({key:f,output:null,decrypt:!1,mode:C})},h.des.startDecrypting=function(f,C,A,P){var D=y({key:f,output:A,decrypt:!0,mode:P||(null===C?"ECB":"CBC")});return D.start(C),D},h.des.createDecryptionCipher=function(f,C){return y({key:f,output:null,decrypt:!0,mode:C})},h.des.Algorithm=function(f,C){var A=this;A.name=f,A.mode=new C({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},h.des.Algorithm.prototype.initialize=function(f){if(!this._init){var C=h.util.createBuffer(f.key);if(0===this.name.indexOf("3DES")&&24!==C.length())throw new Error("Invalid Triple-DES key size: "+8*C.length());this._keys=function I(f){for(var q,C=[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],x=[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],B=[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],z=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],S=[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],H=[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],j=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],re=f.length()>8?3:1,$=[],te=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],Z=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 ke=C[(oe&=-15)>>>28]|A[oe>>>24&15]|P[oe>>>20&15]|D[oe>>>16&15]|x[oe>>>12&15]|M[oe>>>8&15]|B[oe>>>4&15],Se=F[(de&=-15)>>>28]|z[de>>>24&15]|S[de>>>20&15]|O[de>>>16&15]|H[de>>>12&15]|L[de>>>8&15]|j[de>>>4&15];$[Z++]=ke^(q=65535&(Se>>>16^ke)),$[Z++]=Se^q<<16}}return $}(C),this._init=!0}},u("DES-ECB",h.cipher.modes.ecb),u("DES-CBC",h.cipher.modes.cbc),u("DES-CFB",h.cipher.modes.cfb),u("DES-OFB",h.cipher.modes.ofb),u("DES-CTR",h.cipher.modes.ctr),u("3DES-ECB",h.cipher.modes.ecb),u("3DES-CBC",h.cipher.modes.cbc),u("3DES-CFB",h.cipher.modes.cfb),u("3DES-OFB",h.cipher.modes.ofb),u("3DES-CTR",h.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],b=[-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],w=[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],v=[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],l=[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],p=[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],_=[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(f,C,A,P){var x,D=32===f.length?3:9;x=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,B=C[0],F=C[1];B^=(M=252645135&(B>>>4^F))<<4,B^=(M=65535&(B>>>16^(F^=M)))<<16,B^=M=858993459&((F^=M)>>>2^B),B^=M=16711935&((F^=M<<2)>>>8^B),B=(B^=(M=1431655765&(B>>>1^(F^=M<<8)))<<1)<<1|B>>>31,F=(F^=M)<<1|F>>>31;for(var z=0;z>>4|F<<28)^f[H+1];M=B,B=F,F=M^(b[L>>>24&63]|v[L>>>16&63]|p[L>>>8&63]|_[63&L]|g[j>>>24&63]|w[j>>>16&63]|l[j>>>8&63]|d[63&j])}M=B,B=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((B=B>>>1|B<<31)>>>1^F),F^=(M=16711935&(F>>>8^(B^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(B^=M)))<<2,F^=M=65535&((B^=M)>>>16^F),F^=M=252645135&((B^=M<<16)>>>4^F),A[0]=B^=M<<4,A[1]=F}function y(f){var P,A="DES-"+((f=f||{}).mode||"CBC").toUpperCase(),D=(P=f.decrypt?h.cipher.createDecipher(A,f.key):h.cipher.createCipher(A,f.key)).start;return P.start=function(x,M){var B=null;M instanceof h.util.ByteBuffer&&(B=M,M={}),(M=M||{}).output=B,M.iv=x,D.call(P,M)},P}},8659:J=>{J.exports={options:{usePureJavaScript:!1}}},9032:(J,G,N)=>{var h=N(8659);N(979),N(4747),(J.exports=h.hmac=h.hmac||{}).create=function(){var g=null,b=null,w=null,v=null,l={start:function(p,d){if(null!==p)if("string"==typeof p){if(!((p=p.toLowerCase())in h.md.algorithms))throw new Error('Unknown hash algorithm "'+p+'"');b=h.md.algorithms[p].create()}else b=p;if(null===d)d=g;else{if("string"==typeof d)d=h.util.createBuffer(d);else if(h.util.isArray(d)){var _=d;d=h.util.createBuffer();for(var I=0;I<_.length;++I)d.putByte(_[I])}var E=d.length();for(E>b.blockLength&&(b.start(),b.update(d.bytes()),d=b.digest()),w=h.util.createBuffer(),v=h.util.createBuffer(),E=d.length(),I=0;I{var u,h=N(8659);function w(W,Y,ee){this.data=[],null!=W&&("number"==typeof W?this.fromNumber(W,Y,ee):this.fromString(W,null==Y&&"string"!=typeof W?256:Y))}function v(){return new w(null)}function d(W,Y,ee,le,Oe,He){for(var tt=16383&Y,Ze=Y>>14;--He>=0;){var on=16383&this.data[W],Ir=this.data[W++]>>14,Ri=Ze*on+Ir*tt;Oe=((on=tt*on+((16383&Ri)<<14)+ee.data[le]+Oe)>>28)+(Ri>>14)+Ze*Ir,ee.data[le++]=268435455&on}return Oe}J.exports=h.jsbn=h.jsbn||{},h.jsbn.BigInteger=w,typeof navigator>"u"?(w.prototype.am=d,u=28):"Microsoft Internet Explorer"==navigator.appName?(w.prototype.am=function p(W,Y,ee,le,Oe,He){for(var tt=32767&Y,Ze=Y>>15;--He>=0;){var on=32767&this.data[W],Ir=this.data[W++]>>15,Ri=Ze*on+Ir*tt;Oe=((on=tt*on+((32767&Ri)<<15)+ee.data[le]+(1073741823&Oe))>>>30)+(Ri>>>15)+Ze*Ir+(Oe>>>30),ee.data[le++]=1073741823&on}return Oe},u=30):"Netscape"!=navigator.appName?(w.prototype.am=function l(W,Y,ee,le,Oe,He){for(;--He>=0;){var tt=Y*this.data[W++]+ee.data[le]+Oe;Oe=Math.floor(tt/67108864),ee.data[le++]=67108863&tt}return Oe},u=26):(w.prototype.am=d,u=28),w.prototype.DB=u,w.prototype.DM=(1<>>16)&&(W=ee,Y+=16),0!=(ee=W>>8)&&(W=ee,Y+=8),0!=(ee=W>>4)&&(W=ee,Y+=4),0!=(ee=W>>2)&&(W=ee,Y+=2),0!=(ee=W>>1)&&(W=ee,Y+=1),Y}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,Y+=16),0==(255&W)&&(W>>=8,Y+=8),0==(15&W)&&(W>>=4,Y+=4),0==(3&W)&&(W>>=2,Y+=2),0==(1&W)&&++Y,Y}function tn(W){for(var Y=0;0!=W;)W&=W-1,++Y;return Y}function ve(){}function yt(W){return W}function ze(W){this.r2=v(),this.q3=v(),w.ONE.dlShiftTo(2*W.t,this.r2),this.mu=this.r2.divide(W),this.m=W}pe.prototype.convert=function ke(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 Pe(W){W.divRemTo(this.m,null,W)},pe.prototype.mulTo=function we(W,Y,ee){W.multiplyTo(Y,ee),this.reduce(ee)},pe.prototype.sqrTo=function $e(W,Y){W.squareTo(Y),this.reduce(Y)},Ee.prototype.convert=function Ce(W){var Y=v();return W.abs().dlShiftTo(this.m.t,Y),Y.divRemTo(this.m,null,Y),W.s<0&&Y.compareTo(w.ZERO)>0&&this.m.subTo(Y,Y),Y},Ee.prototype.revert=function xe(W){var Y=v();return W.copyTo(Y),this.reduce(Y),Y},Ee.prototype.reduce=function Ke(W){for(;W.t<=this.mt2;)W.data[W.t++]=0;for(var Y=0;Y>15)*this.mpl&this.um)<<15)&W.DM;for(W.data[ee=Y+this.m.t]+=this.m.am(0,le,W,Y,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,Y,ee){W.multiplyTo(Y,ee),this.reduce(ee)},Ee.prototype.sqrTo=function We(W,Y){W.squareTo(Y),this.reduce(Y)},w.prototype.copyTo=function P(W){for(var Y=this.t-1;Y>=0;--Y)W.data[Y]=this.data[Y];W.t=this.t,W.s=this.s},w.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},w.prototype.fromString=function M(W,Y){var ee;if(16==Y)ee=4;else if(8==Y)ee=3;else if(256==Y)ee=8;else if(2==Y)ee=1;else if(32==Y)ee=5;else{if(4!=Y)return void this.fromRadix(W,Y);ee=2}this.t=0,this.s=0;for(var le=W.length,Oe=!1,He=0;--le>=0;){var tt=8==ee?255&W[le]:A(W,le);tt<0?"-"==W.charAt(le)&&(Oe=!0):(Oe=!1,0==He?this.data[this.t++]=tt:He+ee>this.DB?(this.data[this.t-1]|=(tt&(1<>this.DB-He):this.data[this.t-1]|=tt<=this.DB&&(He-=this.DB))}8==ee&&0!=(128&W[0])&&(this.s=-1,He>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==W;)--this.t},w.prototype.dlShiftTo=function j(W,Y){var ee;for(ee=this.t-1;ee>=0;--ee)Y.data[ee+W]=this.data[ee];for(ee=W-1;ee>=0;--ee)Y.data[ee]=0;Y.t=this.t+W,Y.s=this.s},w.prototype.drShiftTo=function re(W,Y){for(var ee=W;ee=0;--Ze)Y.data[Ze+He+1]=this.data[Ze]>>le|tt,tt=(this.data[Ze]&Oe)<=0;--Ze)Y.data[Ze]=0;Y.data[He]=tt,Y.t=this.t+He+1,Y.s=this.s,Y.clamp()},w.prototype.rShiftTo=function te(W,Y){Y.s=this.s;var ee=Math.floor(W/this.DB);if(ee>=this.t)Y.t=0;else{var le=W%this.DB,Oe=this.DB-le,He=(1<>le;for(var tt=ee+1;tt>le;le>0&&(Y.data[this.t-ee-1]|=(this.s&He)<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le-=W.s}Y.s=le<0?-1:0,le<-1?Y.data[ee++]=this.DV+le:le>0&&(Y.data[ee++]=le),Y.t=ee,Y.clamp()},w.prototype.multiplyTo=function q(W,Y){var ee=this.abs(),le=W.abs(),Oe=ee.t;for(Y.t=Oe+le.t;--Oe>=0;)Y.data[Oe]=0;for(Oe=0;Oe=0;)W.data[ee]=0;for(ee=0;ee=Y.DV&&(W.data[ee+Y.t]-=Y.DV,W.data[ee+Y.t+1]=1)}W.t>0&&(W.data[W.t-1]+=Y.am(ee,Y.data[ee],W,2*ee,0,1)),W.s=0,W.clamp()},w.prototype.divRemTo=function oe(W,Y,ee){var le=W.abs();if(!(le.t<=0)){var Oe=this.abs();if(Oe.t0?(le.lShiftTo(on,He),Oe.lShiftTo(on,ee)):(le.copyTo(He),Oe.copyTo(ee));var Ir=He.t,Ri=He.data[Ir-1];if(0!=Ri){var mi=Ri*(1<1?He.data[Ir-2]>>this.F2:0),bs=this.FV/mi,Xo=(1<=0&&(ee.data[ee.t++]=1,ee.subTo(ns,ee)),w.ONE.dlShiftTo(Ir,ns),ns.subTo(He,He);He.t=0;){var el=ee.data[--vi]==Ri?this.DM:Math.floor(ee.data[vi]*bs+(ee.data[vi-1]+Xt)*Xo);if((ee.data[vi]+=He.am(0,el,ee,Dn,0,Ir))0&&ee.rShiftTo(on,ee),tt<0&&w.ZERO.subTo(ee,ee)}}},w.prototype.invDigit=function K(){if(this.t<1)return 0;var W=this.data[0];if(0==(1&W))return 0;var Y=3&W;return(Y=(Y=(Y=(Y=Y*(2-(15&W)*Y)&15)*(2-(255&W)*Y)&255)*(2-((65535&W)*Y&65535))&65535)*(2-W*Y%this.DV)%this.DV)>0?this.DV-Y:-Y},w.prototype.isEven=function Xe(){return 0==(this.t>0?1&this.data[0]:this.s)},w.prototype.exp=function Ot(W,Y){if(W>4294967295||W<1)return w.ONE;var ee=v(),le=v(),Oe=Y.convert(this),He=H(W)-1;for(Oe.copyTo(ee);--He>=0;)if(Y.sqrTo(ee,le),(W&1<0)Y.mulTo(le,Oe,ee);else{var tt=ee;ee=le,le=tt}return Y.revert(ee)},w.prototype.toString=function F(W){if(this.s<0)return"-"+this.negate().toString(W);var Y;if(16==W)Y=4;else if(8==W)Y=3;else if(2==W)Y=1;else if(32==W)Y=5;else{if(4!=W)return this.toRadix(W);Y=2}var le,ee=(1<0)for(Ze>Ze)>0&&(Oe=!0,He=C(le));tt>=0;)Ze>(Ze+=this.DB-Y)):(le=this.data[tt]>>(Ze-=Y)&ee,Ze<=0&&(Ze+=this.DB,--tt)),le>0&&(Oe=!0),Oe&&(He+=C(le));return Oe?He:"0"},w.prototype.negate=function z(){var W=v();return w.ZERO.subTo(this,W),W},w.prototype.abs=function S(){return this.s<0?this.negate():this},w.prototype.compareTo=function O(W){var Y=this.s-W.s;if(0!=Y)return Y;var ee=this.t;if(0!=(Y=ee-W.t))return this.s<0?-Y:Y;for(;--ee>=0;)if(0!=(Y=this.data[ee]-W.data[ee]))return Y;return 0},w.prototype.bitLength=function L(){return this.t<=0?0:this.DB*(this.t-1)+H(this.data[this.t-1]^this.s&this.DM)},w.prototype.mod=function de(W){var Y=v();return this.abs().divRemTo(W,null,Y),this.s<0&&Y.compareTo(w.ZERO)>0&&W.subTo(Y,Y),Y},w.prototype.modPowInt=function pt(W,Y){var ee;return ee=W<256||Y.isEven()?new pe(Y):new Ee(Y),this.exp(W,ee)},w.ZERO=x(0),w.ONE=x(1),ve.prototype.convert=yt,ve.prototype.revert=yt,ve.prototype.mulTo=function St(W,Y,ee){W.multiplyTo(Y,ee)},ve.prototype.sqrTo=function mn(W,Y){W.squareTo(Y)},ze.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 Y=v();return W.copyTo(Y),this.reduce(Y),Y},ze.prototype.revert=function Et(W){return W},ze.prototype.reduce=function lt(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)},ze.prototype.mulTo=function jt(W,Y,ee){W.multiplyTo(Y,ee),this.reduce(ee)},ze.prototype.sqrTo=function It(W,Y){W.squareTo(Y),this.reduce(Y)};var ir=[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],La=(1<<26)/ir[ir.length-1];w.prototype.chunkSize=function ie(W){return Math.floor(Math.LN2*this.DB/Math.log(W))},w.prototype.toRadix=function ye(W){if(null==W&&(W=10),0==this.signum()||W<2||W>36)return"0";var Y=this.chunkSize(W),ee=Math.pow(W,Y),le=x(ee),Oe=v(),He=v(),tt="";for(this.divRemTo(le,Oe,He);Oe.signum()>0;)tt=(ee+He.intValue()).toString(W).substr(1)+tt,Oe.divRemTo(le,Oe,He);return He.intValue().toString(W)+tt},w.prototype.fromRadix=function me(W,Y){this.fromInt(0),null==Y&&(Y=10);for(var ee=this.chunkSize(Y),le=Math.pow(Y,ee),Oe=!1,He=0,tt=0,Ze=0;Ze=ee&&(this.dMultiply(le),this.dAddOffset(tt,0),He=0,tt=0))}He>0&&(this.dMultiply(Math.pow(Y,He)),this.dAddOffset(tt,0)),Oe&&w.ZERO.subTo(this,this)},w.prototype.fromNumber=function _e(W,Y,ee){if("number"==typeof Y)if(W<2)this.fromInt(1);else for(this.fromNumber(W,ee),this.testBit(W-1)||this.bitwiseTo(w.ONE.shiftLeft(W-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(Y);)this.dAddOffset(2,0),this.bitLength()>W&&this.subTo(w.ONE.shiftLeft(W-1),this);else{var le=new Array,Oe=7&W;le.length=1+(W>>3),Y.nextBytes(le),Oe>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}Y.s=le<0?-1:0,le>0?Y.data[ee++]=le:le<-1&&(Y.data[ee++]=this.DV+le),Y.t=ee,Y.clamp()},w.prototype.dMultiply=function ut(W){this.data[this.t]=this.am(0,W-1,this,0,0,this.t),++this.t,this.clamp()},w.prototype.dAddOffset=function ce(W,Y){if(0!=W){for(;this.t<=Y;)this.data[this.t++]=0;for(this.data[Y]+=W;this.data[Y]>=this.DV;)this.data[Y]-=this.DV,++Y>=this.t&&(this.data[this.t++]=0),++this.data[Y]}},w.prototype.multiplyLowerTo=function Qe(W,Y,ee){var Oe,le=Math.min(this.t+W.t,Y);for(ee.s=0,ee.t=le;le>0;)ee.data[--le]=0;for(Oe=ee.t-this.t;le=0;)ee.data[le]=0;for(le=Math.max(Y-this.t,0);le0)if(0==Y)ee=this.data[0]%W;else for(var le=this.t-1;le>=0;--le)ee=(Y*ee+this.data[le])%W;return ee},w.prototype.millerRabin=function Qf(W){var Y=this.subtract(w.ONE),ee=Y.getLowestSetBit();if(ee<=0)return!1;for(var He,le=Y.shiftRight(ee),Oe=function ka(){return{nextBytes:function(W){for(var Y=0;Y=0);var Ze=He.modPow(le,this);if(0!=Ze.compareTo(w.ONE)&&0!=Ze.compareTo(Y)){for(var on=1;on++>24},w.prototype.shortValue=function ni(){return 0==this.t?this.s:this.data[0]<<16>>16},w.prototype.signum=function fe(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},w.prototype.toByteArray=function Ne(){var W=this.t,Y=new Array;Y[0]=this.s;var le,ee=this.DB-W*this.DB%8,Oe=0;if(W-- >0)for(ee>ee)!=(this.s&this.DM)>>ee&&(Y[Oe++]=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==Oe&&(128&this.s)!=(128&le)&&++Oe,(Oe>0||le!=this.s)&&(Y[Oe++]=le);return Y},w.prototype.equals=function Ye(W){return 0==this.compareTo(W)},w.prototype.min=function qe(W){return this.compareTo(W)<0?this:W},w.prototype.max=function st(W){return this.compareTo(W)>0?this:W},w.prototype.and=function be(W){var Y=v();return this.bitwiseTo(W,je,Y),Y},w.prototype.or=function De(W){var Y=v();return this.bitwiseTo(W,ge,Y),Y},w.prototype.xor=function Be(W){var Y=v();return this.bitwiseTo(W,Ue,Y),Y},w.prototype.andNot=function Pt(W){var Y=v();return this.bitwiseTo(W,dt,Y),Y},w.prototype.not=function vt(){for(var W=v(),Y=0;Y=this.t?0!=this.s:0!=(this.data[Y]&1<1){var Ri=v();for(He.sqrTo(tt[1],Ri);Ze<=Ir;)tt[Ze]=v(),He.mulTo(Ri,tt[Ze-2],tt[Ze]),Ze+=2}var bs,vi,mi=W.t-1,Xo=!0,Xt=v();for(ee=H(W.data[mi])-1;mi>=0;){for(ee>=on?bs=W.data[mi]>>ee-on&Ir:(bs=(W.data[mi]&(1<0&&(bs|=W.data[mi-1]>>this.DB+ee-on)),Ze=le;0==(1&bs);)bs>>=1,--Ze;if((ee-=Ze)<0&&(ee+=this.DB,--mi),Xo)tt[bs].copyTo(Oe),Xo=!1;else{for(;Ze>1;)He.sqrTo(Oe,Xt),He.sqrTo(Xt,Oe),Ze-=2;Ze>0?He.sqrTo(Oe,Xt):(vi=Oe,Oe=Xt,Xt=vi),He.mulTo(Xt,tt[bs],Oe)}for(;mi>=0&&0==(W.data[mi]&1<=0?(ee.subTo(le,ee),Y&&Oe.subTo(tt,Oe),He.subTo(Ze,He)):(le.subTo(ee,le),Y&&tt.subTo(Oe,tt),Ze.subTo(He,Ze))}return 0!=le.compareTo(w.ONE)?w.ZERO:Ze.compareTo(W)>=0?Ze.subtract(W):Ze.signum()<0?(Ze.addTo(W,Ze),Ze.signum()<0?Ze.add(W):Ze):Ze},w.prototype.pow=function Ge(W){return this.exp(W,new ve)},w.prototype.gcd=function Nn(W){var Y=this.s<0?this.negate():this.clone(),ee=W.s<0?W.negate():W.clone();if(Y.compareTo(ee)<0){var le=Y;Y=ee,ee=le}var Oe=Y.getLowestSetBit(),He=ee.getLowestSetBit();if(He<0)return Y;for(Oe0&&(Y.rShiftTo(He,Y),ee.rShiftTo(He,ee));Y.signum()>0;)(Oe=Y.getLowestSetBit())>0&&Y.rShiftTo(Oe,Y),(Oe=ee.getLowestSetBit())>0&&ee.rShiftTo(Oe,ee),Y.compareTo(ee)>=0?(Y.subTo(ee,Y),Y.rShiftTo(1,Y)):(ee.subTo(Y,ee),ee.rShiftTo(1,ee));return He>0&&ee.lShiftTo(He,ee),ee},w.prototype.isProbablePrime=function Zo(W){var Y,ee=this.abs();if(1==ee.t&&ee.data[0]<=ir[ir.length-1]){for(Y=0;Y{var h=N(8659);J.exports=h.md=h.md||{},h.md.algorithms=h.md.algorithms||{}},9386:(J,G,N)=>{var h=N(8659);N(8449),J.exports=h.mgf=h.mgf||{},h.mgf.mgf1=h.mgf1},8449:(J,G,N)=>{var h=N(8659);N(4747),h.mgf=h.mgf||{},(J.exports=h.mgf.mgf1=h.mgf1=h.mgf1||{}).create=function(g){return{generate:function(w,v){for(var l=new h.util.ByteBuffer,p=Math.ceil(v/g.digestLength),d=0;d{var h=N(8659);h.pki=h.pki||{};var u=J.exports=h.pki.oids=h.oids=h.oids||{};function g(w,v){u[w]=v,u[v]=w}function b(w,v){u[w]=v}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"),b("2.5.29.1","authorityKeyIdentifier"),b("2.5.29.2","keyAttributes"),b("2.5.29.3","certificatePolicies"),b("2.5.29.4","keyUsageRestriction"),b("2.5.29.5","policyMapping"),b("2.5.29.6","subtreesConstraint"),b("2.5.29.7","subjectAltName"),b("2.5.29.8","issuerAltName"),b("2.5.29.9","subjectDirectoryAttributes"),b("2.5.29.10","basicConstraints"),b("2.5.29.11","nameConstraints"),b("2.5.29.12","policyConstraints"),b("2.5.29.13","basicConstraints"),g("2.5.29.14","subjectKeyIdentifier"),g("2.5.29.15","keyUsage"),b("2.5.29.16","privateKeyUsagePeriod"),g("2.5.29.17","subjectAltName"),g("2.5.29.18","issuerAltName"),g("2.5.29.19","basicConstraints"),b("2.5.29.20","cRLNumber"),b("2.5.29.21","cRLReason"),b("2.5.29.22","expirationDate"),b("2.5.29.23","instructionCode"),b("2.5.29.24","invalidityDate"),b("2.5.29.25","cRLDistributionPoints"),b("2.5.29.26","issuingDistributionPoint"),b("2.5.29.27","deltaCRLIndicator"),b("2.5.29.28","issuingDistributionPoint"),b("2.5.29.29","certificateIssuer"),b("2.5.29.30","nameConstraints"),g("2.5.29.31","cRLDistributionPoints"),g("2.5.29.32","certificatePolicies"),b("2.5.29.33","policyMappings"),b("2.5.29.34","policyConstraints"),g("2.5.29.35","authorityKeyIdentifier"),b("2.5.29.36","policyConstraints"),g("2.5.29.37","extKeyUsage"),b("2.5.29.46","freshestCRL"),b("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:(J,G,N)=>{var h=N(8659);if(N(1298),N(7791),N(279),N(979),N(6078),N(7949),N(8604),N(8365),N(209),N(5517),N(4747),typeof u>"u")var u=h.jsbn.BigInteger;var g=h.asn1,b=h.pki=h.pki||{};J.exports=b.pbe=h.pbe=h.pbe||{};var w=b.oids,v={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"}]},l={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"}]}]},p={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(y,f){return y.start().update(f).digest().getBytes()}function _(y){var f;if(y){if(!(f=b.oids[g.derToOid(y)])){var C=new Error("Unsupported PRF OID.");throw C.oid=y,C.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],C}}else f="hmacWithSHA1";return I(f)}function I(y){var f=h.md;switch(y){case"hmacWithSHA224":f=h.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":y=y.substr(8).toLowerCase();break;default:var C=new Error("Unsupported PRF algorithm.");throw C.algorithm=y,C.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],C}if(!f||!(y in f))throw new Error("Unknown hash algorithm: "+y);return f[y].create()}b.encryptPrivateKeyInfo=function(y,f,C){(C=C||{}).saltSize=C.saltSize||8,C.count=C.count||2048,C.algorithm=C.algorithm||"aes128",C.prfAlgorithm=C.prfAlgorithm||"sha1";var x,M,B,A=h.random.getBytesSync(C.saltSize),P=C.count,D=g.integerToDer(P);if(0===C.algorithm.indexOf("aes")||"des"===C.algorithm){var F,z,S;switch(C.algorithm){case"aes128":x=16,F=16,z=w["aes128-CBC"],S=h.aes.createEncryptionCipher;break;case"aes192":x=24,F=16,z=w["aes192-CBC"],S=h.aes.createEncryptionCipher;break;case"aes256":x=32,F=16,z=w["aes256-CBC"],S=h.aes.createEncryptionCipher;break;case"des":x=8,F=8,z=w.desCBC,S=h.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=C.algorithm,O}var H="hmacWith"+C.prfAlgorithm.toUpperCase(),L=I(H),j=h.pkcs5.pbkdf2(f,A,P,x,L),re=h.random.getBytesSync(F);($=S(j)).start(re),$.update(g.toDer(y)),$.finish(),B=$.output.getBytes();var te=function E(y,f,C,A){var P=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,y),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,f.getBytes())]);return"hmacWithSHA1"!==A&&P.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,h.util.hexToBytes(C.toString(16))),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(b.oids[A]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])),P}(A,D,x,H);M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w.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(w.pkcs5PBKDF2).getBytes()),te]),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(z).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,re)])])])}else{var O;if("3des"!==C.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=C.algorithm,O;x=24;var $,Z=new h.util.ByteBuffer(A);j=b.pbe.generatePkcs12Key(f,Z,1,P,x),re=b.pbe.generatePkcs12Key(f,Z,2,P,x),($=h.des.createEncryptionCipher(j)).start(re),$.update(g.toDer(y)),$.finish(),B=$.output.getBytes(),M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w["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,B)])},b.decryptPrivateKeyInfo=function(y,f){var C=null,A={},P=[];if(!g.validate(y,v,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 x=g.derToOid(A.encryptionOid),M=b.pbe.getCipher(x,A.encryptionParams,f),B=h.util.createBuffer(A.encryptedData);return M.update(B),M.finish()&&(C=g.fromDer(M.output)),C},b.encryptedPrivateKeyToPem=function(y,f){var C={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(y).getBytes()};return h.pem.encode(C,{maxline:f})},b.encryptedPrivateKeyFromPem=function(y){var f=h.pem.decode(y)[0];if("ENCRYPTED PRIVATE KEY"!==f.type){var C=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw C.headerType=f.type,C}if(f.procType&&"ENCRYPTED"===f.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return g.fromDer(f.body)},b.encryptRsaPrivateKey=function(y,f,C){if(!(C=C||{}).legacy){var A=b.wrapRsaPrivateKey(b.privateKeyToAsn1(y));return A=b.encryptPrivateKeyInfo(A,f,C),b.encryptedPrivateKeyToPem(A)}var P,D,x,M;switch(C.algorithm){case"aes128":P="AES-128-CBC",x=16,D=h.random.getBytesSync(16),M=h.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",x=24,D=h.random.getBytesSync(16),M=h.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",x=32,D=h.random.getBytesSync(16),M=h.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",x=24,D=h.random.getBytesSync(8),M=h.des.createEncryptionCipher;break;case"des":P="DES-CBC",x=8,D=h.random.getBytesSync(8),M=h.des.createEncryptionCipher;break;default:var B=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+C.algorithm+'".');throw B.algorithm=C.algorithm,B}var z=M(h.pbe.opensslDeriveBytes(f,D.substr(0,8),x));z.start(D),z.update(g.toDer(b.privateKeyToAsn1(y))),z.finish();var S={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:h.util.bytesToHex(D).toUpperCase()},body:z.output.getBytes()};return h.pem.encode(S)},b.decryptRsaPrivateKey=function(y,f){var C=null,A=h.pem.decode(y)[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,x;switch(A.dekInfo.algorithm){case"DES-CBC":D=8,x=h.des.createDecryptionCipher;break;case"DES-EDE3-CBC":D=24,x=h.des.createDecryptionCipher;break;case"AES-128-CBC":D=16,x=h.aes.createDecryptionCipher;break;case"AES-192-CBC":D=24,x=h.aes.createDecryptionCipher;break;case"AES-256-CBC":D=32,x=h.aes.createDecryptionCipher;break;case"RC2-40-CBC":D=5,x=function(S){return h.rc2.createDecryptionCipher(S,40)};break;case"RC2-64-CBC":D=8,x=function(S){return h.rc2.createDecryptionCipher(S,64)};break;case"RC2-128-CBC":D=16,x=function(S){return h.rc2.createDecryptionCipher(S,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=h.util.hexToBytes(A.dekInfo.parameters),F=x(h.pbe.opensslDeriveBytes(f,M.substr(0,8),D));if(F.start(M),F.update(h.util.createBuffer(A.body)),!F.finish())return C;C=F.output.getBytes()}else C=A.body;return null!==(C="ENCRYPTED PRIVATE KEY"===A.type?b.decryptPrivateKeyInfo(g.fromDer(C),f):g.fromDer(C))&&(C=b.privateKeyFromAsn1(C)),C},b.pbe.generatePkcs12Key=function(y,f,C,A,P,D){var x,M;if(typeof D>"u"||null===D){if(!("sha1"in h.md))throw new Error('"sha1" hash algorithm unavailable.');D=h.md.sha1.create()}var B=D.digestLength,F=D.blockLength,z=new h.util.ByteBuffer,S=new h.util.ByteBuffer;if(null!=y){for(M=0;M=0;M--)we>>=8,we+=pe.at(M)+Pe.at(M),Pe.setAt(M,255&we);Se.putBuffer(Pe)}Z=Se,z.putBuffer(oe)}return z.truncate(z.length()-P),z},b.pbe.getCipher=function(y,f,C){switch(y){case b.oids.pkcs5PBES2:return b.pbe.getCipherForPBES2(y,f,C);case b.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case b.oids["pbewithSHAAnd40BitRC2-CBC"]:return b.pbe.getCipherForPKCS12PBE(y,f,C);default:var A=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw A.oid=y,A.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],A}},b.pbe.getCipherForPBES2=function(y,f,C){var D,A={},P=[];if(!g.validate(f,l,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((y=g.derToOid(A.kdfOid))!==b.oids.pkcs5PBKDF2)throw(D=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=y,D.supportedOids=["pkcs5PBKDF2"],D;if((y=g.derToOid(A.encOid))!==b.oids["aes128-CBC"]&&y!==b.oids["aes192-CBC"]&&y!==b.oids["aes256-CBC"]&&y!==b.oids["des-EDE3-CBC"]&&y!==b.oids.desCBC)throw(D=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=y,D.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],D;var B,F,x=A.kdfSalt,M=h.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),b.oids[y]){case"aes128-CBC":B=16,F=h.aes.createDecryptionCipher;break;case"aes192-CBC":B=24,F=h.aes.createDecryptionCipher;break;case"aes256-CBC":B=32,F=h.aes.createDecryptionCipher;break;case"des-EDE3-CBC":B=24,F=h.des.createDecryptionCipher;break;case"desCBC":B=8,F=h.des.createDecryptionCipher}var z=_(A.prfOid),S=h.pkcs5.pbkdf2(C,x,M,B,z),O=A.encIv,H=F(S);return H.start(O),H},b.pbe.getCipherForPKCS12PBE=function(y,f,C){var A={},P=[];if(!g.validate(f,p,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 B,F,z,x=h.util.createBuffer(A.salt),M=h.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),y){case b.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:B=24,F=8,z=h.des.startDecrypting;break;case b.oids["pbewithSHAAnd40BitRC2-CBC"]:B=5,F=8,z=function(j,re){var $=h.rc2.createDecryptionCipher(j,40);return $.start(re,null),$};break;default:var D;throw(D=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=y,D}var S=_(A.prfOid),O=b.pbe.generatePkcs12Key(C,x,1,M,B,S);return S.start(),z(O,b.pbe.generatePkcs12Key(C,x,2,M,F,S))},b.pbe.opensslDeriveBytes=function(y,f,C,A){if(typeof A>"u"||null===A){if(!("md5"in h.md))throw new Error('"md5" hash algorithm unavailable.');A=h.md.md5.create()}null===f&&(f="");for(var P=[d(A,y+f)],D=16,x=1;D{var h=N(8659);N(9032),N(979),N(4747);var g,u=h.pkcs5=h.pkcs5||{};h.util.isNodejs&&!h.options.usePureJavaScript&&(g=N(5819)),J.exports=h.pbkdf2=u.pbkdf2=function(b,w,v,l,p,d){if("function"==typeof p&&(d=p,p=null),h.util.isNodejs&&!h.options.usePureJavaScript&&g.pbkdf2&&(null===p||"object"!=typeof p)&&(g.pbkdf2Sync.length>4||!p||"sha1"===p))return"string"!=typeof p&&(p="sha1"),b=Buffer.from(b,"binary"),w=Buffer.from(w,"binary"),d?4===g.pbkdf2Sync.length?g.pbkdf2(b,w,v,l,function(z,S){if(z)return d(z);d(null,S.toString("binary"))}):g.pbkdf2(b,w,v,l,p,function(z,S){if(z)return d(z);d(null,S.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(b,w,v,l).toString("binary"):g.pbkdf2Sync(b,w,v,l,p).toString("binary");if((typeof p>"u"||null===p)&&(p="sha1"),"string"==typeof p){if(!(p in h.md.algorithms))throw new Error("Unknown hash algorithm: "+p);p=h.md[p].create()}var _=p.digestLength;if(l>4294967295*_){var I=new Error("Derived key is too long.");if(d)return d(I);throw I}var E=Math.ceil(l/_),y=l-(E-1)*_,f=h.hmac.create();f.start(p,b);var A,P,D,C="";if(!d){for(var x=1;x<=E;++x){f.start(null,null),f.update(w),f.update(h.util.int32ToBytes(x)),A=D=f.digest().getBytes();for(var M=2;M<=v;++M)f.start(null,null),f.update(D),P=f.digest().getBytes(),A=h.util.xorBytes(A,P,_),D=P;C+=xE)return d(null,C);f.start(null,null),f.update(w),f.update(h.util.int32ToBytes(x)),A=D=f.digest().getBytes(),M=2,F()}function F(){if(M<=v)return f.start(null,null),f.update(D),P=f.digest().getBytes(),A=h.util.xorBytes(A,P,_),D=P,++M,h.util.setImmediate(F);C+=x{var h=N(8659);N(4747);var u=J.exports=h.pem=h.pem||{};function g(w){for(var v=w.name+": ",l=[],p=function(y,f){return" "+f},d=0;d65&&-1!==I){var E=v[I];","===E?(++I,v=v.substr(0,I)+"\r\n "+v.substr(I)):v=v.substr(0,I)+"\r\n"+E+v.substr(I+1),_=d-I-1,I=-1,++d}else(" "===v[d]||"\t"===v[d]||","===v[d])&&(I=d);return v}function b(w){return w.replace(/^\s+/,"")}u.encode=function(w,v){v=v||{};var p,l="-----BEGIN "+w.type+"-----\r\n";if(w.procType&&(l+=g(p={name:"Proc-Type",values:[String(w.procType.version),w.procType.type]})),w.contentDomain&&(l+=g(p={name:"Content-Domain",values:[w.contentDomain]})),w.dekInfo&&(p={name:"DEK-Info",values:[w.dekInfo.algorithm]},w.dekInfo.parameters&&p.values.push(w.dekInfo.parameters),l+=g(p)),w.headers)for(var d=0;d{var h=N(8659);N(4747),N(8365),N(7690);var u=J.exports=h.pkcs1=h.pkcs1||{};function g(b,w,v){v||(v=h.md.sha1.create());for(var l="",p=Math.ceil(w/v.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);v.start(),v.update(b+_),l+=v.digest().getBytes()}return l.substring(0,w)}u.encode_rsa_oaep=function(b,w,v){var l,p,d,_;"string"==typeof v?(l=v,p=arguments[3]||void 0,d=arguments[4]||void 0):v&&(l=v.label||void 0,p=v.seed||void 0,d=v.md||void 0,v.mgf1&&v.mgf1.md&&(_=v.mgf1.md)),d?d.start():d=h.md.sha1.create(),_||(_=d);var I=Math.ceil(b.n.bitLength()/8),E=I-2*d.digestLength-2;if(w.length>E)throw(y=new Error("RSAES-OAEP input message length is too long.")).length=w.length,y.maxLength=E,y;l||(l=""),d.update(l,"raw");for(var f=d.digest(),C="",A=E-w.length,P=0;P{var h=N(8659);N(1298),N(7791),N(279),N(6078),N(8604),N(4957),N(8365),N(4747),N(5911);var u=h.asn1,g=J.exports=h.pkcs7=h.pkcs7||{};function b(A){var P={},D=[];if(!u.validate(A,g.asn1.recipientInfoValidator,P,D)){var x=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw x.errors=D,x}return{version:P.version.charCodeAt(0),issuer:h.pki.RDNAttributesAsArray(P.issuer),serialNumber:h.util.createBuffer(P.serial).toHex(),encryptedContent:{algorithm:u.derToOid(P.encAlgorithm),parameter:P.encParameter?P.encParameter.value:void 0,content:P.encKey}}}function w(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,[h.pki.distinguishedNameToAsn1({attributes:A.issuer}),u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,h.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 l(A){for(var P=[],D=0;D0){for(var D=u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[]),x=0;x=D&&M0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,x)),B.length>0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,B)),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(x){var M=x.issuer,B=x.serialNumber;if(x.certificate){var F=x.certificate;"string"==typeof F&&(F=h.pki.certificateFromPem(F)),M=F.issuer.attributes,B=F.serialNumber}var z=x.key;if(!z)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof z&&(z=h.pki.privateKeyFromPem(z));var S=x.digestAlgorithm||h.pki.oids.sha1;switch(S){case h.pki.oids.sha1:case h.pki.oids.sha256:case h.pki.oids.sha384:case h.pki.oids.sha512:case h.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+S)}var O=x.authenticatedAttributes||[];if(O.length>0){for(var H=!1,L=!1,j=0;j{var h=N(8659);N(7791),N(4747);var u=h.asn1,g=J.exports=h.pkcs7asn1=h.pkcs7asn1||{};h.pkcs7=h.pkcs7||{},h.pkcs7.asn1=g;var b={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=b;var w={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(w)},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(w)},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"},b,{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:(J,G,N)=>{var h=N(8659);N(4747),N(730),N(8365),function(){if(h.prime)J.exports=h.prime;else{var u=J.exports=h.prime=h.prime||{},g=h.jsbn.BigInteger,b=[6,4,2,4,2,4,6,2],w=new g(null);w.fromInt(30);var v=function(y,f){return y|f};u.generateProbablePrime=function(y,f,C){"function"==typeof f&&(C=f,f={});var A=(f=f||{}).algorithm||"PRIMEINC";"string"==typeof A&&(A={name:A}),A.options=A.options||{};var P=f.prng||h.random;if("PRIMEINC"===A.name)return function l(y,f,C,A){return"workers"in C?function _(y,f,C,A){if(typeof Worker>"u")return p(y,f,C,A);var P=I(y,f),D=C.workers,x=C.workLoad||100,M=30*x/8,B=C.workerScript||"forge/prime.worker.js";if(-1===D)return h.util.estimateCores(function(z,S){z&&(S=2),D=S-1,F()});function F(){D=Math.max(1,D);for(var z=[],S=0;Sy&&(P=I(y,f));var te=P.toString(16);j.target.postMessage({hex:te,workLoad:x}),P.dAddOffset(M,0)}}}F()}(y,f,C,A):p(y,f,C,A)}(y,{nextBytes:function(x){for(var M=P.getBytesSync(x.length),B=0;Bf&&(y=I(f,C)),y.isProbablePrime(P))return x(null,y);y.dAddOffset(b[A++%8],0)}while(D<0||+new Date-M{var h=N(8659);N(4747);var u=null;h.util.isNodejs&&!h.options.usePureJavaScript&&!process.versions["node-webkit"]&&(u=N(5819)),(J.exports=h.prng=h.prng||{}).create=function(b){for(var w={plugin:b,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},v=b.md,l=new Array(32),p=0;p<32;++p)l[p]=v.create();function _(){if(w.pools[0].messageLength>=32)return I();w.collect(w.seedFileSync(32-w.pools[0].messageLength<<5)),I()}function I(){w.reseeds=4294967295===w.reseeds?0:w.reseeds+1;var y=w.plugin.md.create();y.update(w.keyBytes);for(var f=1,C=0;C<32;++C)w.reseeds%f==0&&(y.update(w.pools[C].digest().getBytes()),w.pools[C].start()),f<<=1;w.keyBytes=y.digest().getBytes(),y.start(),y.update(w.keyBytes);var A=y.digest().getBytes();w.key=w.plugin.formatKey(w.keyBytes),w.seed=w.plugin.formatSeed(A),w.generated=0}function E(y){var f=null,C=h.util.globalScope,A=C.crypto||C.msCrypto;A&&A.getRandomValues&&(f=function(O){return A.getRandomValues(O)});var P=h.util.createBuffer();if(f)for(;P.length()>16)))<<16,S=4294967295&(F=(2147483647&(F+=B>>15))+(F>>31)),M=0;M<3;++M)z=S>>>(M<<3),z^=Math.floor(256*Math.random()),P.putByte(255&z);return P.getBytes(y)}return w.pools=l,w.pool=0,w.generate=function(y,f){if(!f)return w.generateSync(y);var C=w.plugin.cipher,A=w.plugin.increment,P=w.plugin.formatKey,D=w.plugin.formatSeed,x=h.util.createBuffer();w.key=null,function M(B){if(B)return f(B);if(x.length()>=y)return f(null,x.getBytes(y));if(w.generated>1048575&&(w.key=null),null===w.key)return h.util.nextTick(function(){!function d(y){if(w.pools[0].messageLength>=32)return I(),y();w.seedFile(32-w.pools[0].messageLength<<5,function(C,A){if(C)return y(C);w.collect(A),I(),y()})}(M)});var F=C(w.key,w.seed);w.generated+=F.length,x.putBytes(F),w.key=P(C(w.key,A(w.seed))),w.seed=D(C(w.key,w.seed)),h.util.setImmediate(M)}()},w.generateSync=function(y){var f=w.plugin.cipher,C=w.plugin.increment,A=w.plugin.formatKey,P=w.plugin.formatSeed;w.key=null;for(var D=h.util.createBuffer();D.length()1048575&&(w.key=null),null===w.key&&_();var x=f(w.key,w.seed);w.generated+=x.length,D.putBytes(x),w.key=A(f(w.key,C(w.seed))),w.seed=P(f(w.key,w.seed))}return D.getBytes(y)},u?(w.seedFile=function(y,f){u.randomBytes(y,function(C,A){if(C)return f(C);f(null,A.toString())})},w.seedFileSync=function(y){return u.randomBytes(y).toString()}):(w.seedFile=function(y,f){try{f(null,E(y))}catch(C){f(C)}},w.seedFileSync=E),w.collect=function(y){for(var f=y.length,C=0;C>A&255);w.collect(C)},w.registerWorker=function(y){y===self?w.seedFile=function(C,A){self.addEventListener("message",function P(D){var x=D.data;x.forge&&x.forge.prng&&(self.removeEventListener("message",P),A(x.forge.prng.err,x.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:C}}})}:y.addEventListener("message",function(C){var A=C.data;A.forge&&A.forge.prng&&w.seedFile(A.forge.prng.needed,function(P,D){y.postMessage({forge:{prng:{err:P,bytes:D}}})})})},w}},7256:(J,G,N)=>{var h=N(8659);N(8365),N(4747),(J.exports=h.pss=h.pss||{}).create=function(g){3===arguments.length&&(g={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var p,b=g.md,w=g.mgf,v=b.digestLength,l=g.salt||null;if("string"==typeof l&&(l=h.util.createBuffer(l)),"saltLength"in g)p=g.saltLength;else{if(null===l)throw new Error("Salt length not specified or specific salt not given.");p=l.length()}if(null!==l&&l.length()!==p)throw new Error("Given salt length does not match length of given salt.");var d=g.prng||h.random,_={encode:function(I,E){var y,P,f=E-1,C=Math.ceil(f/8),A=I.digest().getBytes();if(C>8*C-f&255;return(S=String.fromCharCode(S.charCodeAt(0)&~O)+S.substr(1))+x+String.fromCharCode(188)},verify:function(I,E,y){var f,C=y-1,A=Math.ceil(C/8);if(E=E.substr(-A),A>8*A-C&255;if(0!=(D.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var B=w.generate(x,P),F="";for(f=0;f{var h=N(8659);N(1298),N(1594),N(4473),N(4747),h.random&&h.random.getBytes?J.exports=h.random:function(u){var g={},b=new Array(4),w=h.util.createBuffer();function v(){var y=h.prng.create(g);return y.getBytes=function(f,C){return y.generate(f,C)},y.getBytesSync=function(f){return y.generate(f)},y}g.formatKey=function(y){var f=h.util.createBuffer(y);return(y=new Array(4))[0]=f.getInt32(),y[1]=f.getInt32(),y[2]=f.getInt32(),y[3]=f.getInt32(),h.aes._expandKey(y,!1)},g.formatSeed=function(y){var f=h.util.createBuffer(y);return(y=new Array(4))[0]=f.getInt32(),y[1]=f.getInt32(),y[2]=f.getInt32(),y[3]=f.getInt32(),y},g.cipher=function(y,f){return h.aes._updateBlock(y,f,b,!1),w.putInt32(b[0]),w.putInt32(b[1]),w.putInt32(b[2]),w.putInt32(b[3]),w.getBytes()},g.increment=function(y){return++y[3],y},g.md=h.md.sha256;var l=v(),p=null,d=h.util.globalScope,_=d.crypto||d.msCrypto;if(_&&_.getRandomValues&&(p=function(y){return _.getRandomValues(y)}),h.options.usePureJavaScript||!h.util.isNodejs&&!p){if(typeof window>"u"||window,l.collectInt(+new Date,32),typeof navigator<"u"){var I="";for(var E in navigator)try{"string"==typeof navigator[E]&&(I+=navigator[E])}catch{}l.collect(I),I=null}u&&(u().mousemove(function(y){l.collectInt(y.clientX,16),l.collectInt(y.clientY,16)}),u().keypress(function(y){l.collectInt(y.charCode,8)}))}if(h.random)for(var E in l)h.random[E]=l[E];else h.random=l;h.random.createInstance=v,J.exports=h.random}(typeof jQuery<"u"?jQuery:null)},209:(J,G,N)=>{var h=N(8659);N(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],b=function(l,p){return l<>16-p},w=function(l,p){return(65535&l)>>p|l<<16-p&65535};J.exports=h.rc2=h.rc2||{},h.rc2.expandKey=function(l,p){"string"==typeof l&&(l=h.util.createBuffer(l)),p=p||128;var f,d=l,_=l.length(),I=p,E=Math.ceil(I/8),y=255>>(7&I);for(f=_;f<128;f++)d.putByte(u[d.at(f-1)+d.at(f-_)&255]);for(d.setAt(128-E,u[d.at(128-E)&y]),f=127-E;f>=0;f--)d.setAt(f,u[d.at(f+1)^d.at(f+E)]);return d};var v=function(l,p,d){var f,C,A,P,_=!1,I=null,E=null,y=null,D=[];for(l=h.rc2.expandKey(l,p),A=0;A<64;A++)D.push(l.getInt16Le());d?(f=function(B){for(A=0;A<4;A++)B[A]+=D[P]+(B[(A+3)%4]&B[(A+2)%4])+(~B[(A+3)%4]&B[(A+1)%4]),B[A]=b(B[A],g[A]),P++},C=function(B){for(A=0;A<4;A++)B[A]+=D[63&B[(A+3)%4]]}):(f=function(B){for(A=3;A>=0;A--)B[A]=w(B[A],g[A]),B[A]-=D[P]+(B[(A+3)%4]&B[(A+2)%4])+(~B[(A+3)%4]&B[(A+1)%4]),P--},C=function(B){for(A=3;A>=0;A--)B[A]-=D[63&B[(A+3)%4]]});var x=function(B){var F=[];for(A=0;A<4;A++){var z=I.getInt16Le();null!==y&&(d?z^=y.getInt16Le():y.putInt16Le(z)),F.push(65535&z)}P=d?0:63;for(var S=0;S=8;)x([[5,f],[1,C],[6,f],[1,C],[5,f]])},finish:function(B){var F=!0;if(d)if(B)F=B(8,I,!d);else{var z=8===I.length()?8:8-I.length();I.fillWithByte(z,z)}if(F&&(_=!0,M.update()),!d&&(F=0===I.length()))if(B)F=B(8,E,!d);else{var S=E.length(),O=E.at(S-1);O>S?F=!1:E.truncate(O)}return F}}};h.rc2.startEncrypting=function(l,p,d){var _=h.rc2.createEncryptionCipher(l,128);return _.start(p,d),_},h.rc2.createEncryptionCipher=function(l,p){return v(l,p,!0)},h.rc2.startDecrypting=function(l,p,d){var _=h.rc2.createDecryptionCipher(l,128);return _.start(p,d),_},h.rc2.createDecryptionCipher=function(l,p){return v(l,p,!1)}},5517:(J,G,N)=>{var h=N(8659);if(N(7791),N(730),N(6078),N(7246),N(9709),N(8365),N(4747),typeof u>"u")var u=h.jsbn.BigInteger;var g=h.util.isNodejs?N(5819):null,b=h.asn1,w=h.util;h.pki=h.pki||{},J.exports=h.pki.rsa=h.rsa=h.rsa||{};var v=h.pki,l=[6,4,2,4,2,4,6,2],p={name:"PrivateKeyInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},_={name:"RSAPublicKey",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:b.Class.UNIVERSAL,type:b.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},I=h.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:b.Class.UNIVERSAL,type:b.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},E={name:"DigestInfo",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:b.Class.UNIVERSAL,type:b.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:b.Class.UNIVERSAL,type:b.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:b.Class.UNIVERSAL,type:b.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:b.Class.UNIVERSAL,type:b.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},y=function(L){if(!(L.algorithm in v.oids)){var re=new Error("Unknown message digest algorithm.");throw re.algorithm=L.algorithm,re}var $=b.oidToDer(v.oids[L.algorithm]).getBytes(),te=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]),Z=b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[]);Z.value.push(b.create(b.Class.UNIVERSAL,b.Type.OID,!1,$)),Z.value.push(b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,""));var q=b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,L.digest().getBytes());return te.value.push(Z),te.value.push(q),b.toDer(te).getBytes()},f=function(L,j,re){if(re)return L.modPow(j.e,j.n);if(!j.p||!j.q)return L.modPow(j.d,j.n);var $;j.dP||(j.dP=j.d.mod(j.p.subtract(u.ONE))),j.dQ||(j.dQ=j.d.mod(j.q.subtract(u.ONE))),j.qInv||(j.qInv=j.q.modInverse(j.p));do{$=new u(h.util.bytesToHex(h.random.getBytes(j.n.bitLength()/8)),16)}while($.compareTo(j.n)>=0||!$.gcd(j.n).equals(u.ONE));for(var te=(L=L.multiply($.modPow(j.e,j.n)).mod(j.n)).mod(j.p).modPow(j.dP,j.p),Z=L.mod(j.q).modPow(j.dQ,j.q);te.compareTo(Z)<0;)te=te.add(j.p);var q=te.subtract(Z).multiply(j.qInv).mod(j.p).multiply(j.q).add(Z);return q.multiply($.modInverse(j.n)).mod(j.n)};function C(L,j,re){var $=h.util.createBuffer(),te=Math.ceil(j.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}$.putByte(0),$.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=h.random.getBytes(q);for(oe=0;oe"u")throw new Error("Encryption block is invalid.");var oe=0;if(0===ne){oe=te-3-$;for(var de=0;de1;){if(255!==Z.getByte()){--Z.read;break}++oe}else if(2===ne)for(oe=0;Z.length()>1;){if(0===Z.getByte()){--Z.read;break}++oe}if(0!==Z.getByte()||oe!==te-3-Z.length())throw new Error("Encryption block is invalid.");return Z.getBytes()}function P(L,j,re){"function"==typeof j&&(re=j,j={});var $={algorithm:{name:(j=j||{}).algorithm||"PRIMEINC",options:{workers:j.workers||2,workLoad:j.workLoad||100,workerScript:j.workerScript}}};function te(){Z(L.pBits,function(ne,oe){return ne?re(ne):(L.p=oe,null!==L.q?q(ne,L.q):void Z(L.qBits,q))})}function Z(ne,oe){h.prime.generateProbablePrime(ne,$,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 Z(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 Z(L.qBits,q);var pe=L.e.modInverse(L.phi);L.keys={privateKey:v.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:v.rsa.setPublicKey(L.n,L.e)},re(null,L.keys)}"prng"in j&&($.prng=j.prng),te()}function D(L){var j=L.toString(16);j[0]>="8"&&(j="00"+j);var re=h.util.hexToBytes(j);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 x(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 h.util.isNodejs&&"function"==typeof g[L]}function B(L){return typeof w.globalScope<"u"&&"object"==typeof w.globalScope.crypto&&"object"==typeof w.globalScope.crypto.subtle&&"function"==typeof w.globalScope.crypto.subtle[L]}function F(L){return typeof w.globalScope<"u"&&"object"==typeof w.globalScope.msCrypto&&"object"==typeof w.globalScope.msCrypto.subtle&&"function"==typeof w.globalScope.msCrypto.subtle[L]}function z(L){for(var j=h.util.hexToBytes(L.toString(16)),re=new Uint8Array(j.length),$=0;$0;)de.putByte(0),--pe;return de.putBytes(h.util.hexToBytes(oe)),de.getBytes()},v.rsa.decrypt=function(L,j,re,$){var te=Math.ceil(j.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 u(h.util.createBuffer(L).toHex(),16);if(q.compareTo(j.n)>=0)throw new Error("Encrypted message is invalid.");for(var oe=f(q,j,re).toString(16),de=h.util.createBuffer(),pe=te-Math.ceil(oe.length/2);pe>0;)de.putByte(0),--pe;return de.putBytes(h.util.hexToBytes(oe)),!1!==$?A(de.getBytes(),j,re):de.getBytes()},v.rsa.createKeyPairGenerationState=function(L,j,re){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var q,$=(re=re||{}).prng||h.random,te={nextBytes:function(ne){for(var oe=$.getBytesSync(ne.length),de=0;de>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(q.eInt),q},v.rsa.stepKeyPairGenerationState=function(L,j){"algorithm"in L||(L.algorithm="PRIMEINC");var re=new u(null);re.fromInt(30);for(var q,$=0,te=function(ke,Se){return ke|Se},Z=+new Date,ne=0;null===L.keys&&(j<=0||neoe?L.pqState=0:L.num.isProbablePrime(x(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(l[$++%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:v.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:v.rsa.setPublicKey(L.n,L.e)}}ne+=(q=+new Date)-Z,Z=q}return null!==L.keys},v.rsa.generateKeyPair=function(L,j,re,$){if(1===arguments.length?"object"==typeof L?(re=L,L=void 0):"function"==typeof L&&($=L,L=void 0):2===arguments.length?"number"==typeof L?"function"==typeof j?($=j,j=void 0):"number"!=typeof j&&(re=j,j=void 0):(re=L,$=j,L=void 0,j=void 0):3===arguments.length&&("number"==typeof j?"function"==typeof re&&($=re,re=void 0):($=re,re=j,j=void 0)),re=re||{},void 0===L&&(L=re.bits||2048),void 0===j&&(j=re.e||65537),!h.options.usePureJavaScript&&!re.prng&&L>=256&&L<=16384&&(65537===j||3===j))if($){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:j,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(ne,oe,de){if(ne)return $(ne);$(null,{privateKey:v.privateKeyFromPem(de),publicKey:v.publicKeyFromPem(oe)})});if(B("generateKey")&&B("exportKey"))return w.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:z(j),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(ne){return w.globalScope.crypto.subtle.exportKey("pkcs8",ne.privateKey)}).then(void 0,function(ne){$(ne)}).then(function(ne){if(ne){var oe=v.privateKeyFromAsn1(b.fromDer(h.util.createBuffer(ne)));$(null,{privateKey:oe,publicKey:v.setRsaPublicKey(oe.n,oe.e)})}});if(F("generateKey")&&F("exportKey")){var te=w.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:z(j),hash:{name:"SHA-256"}},!0,["sign","verify"]);return te.oncomplete=function(ne){var de=w.globalScope.msCrypto.subtle.exportKey("pkcs8",ne.target.result.privateKey);de.oncomplete=function(pe){var Se=v.privateKeyFromAsn1(b.fromDer(h.util.createBuffer(pe.target.result)));$(null,{privateKey:Se,publicKey:v.setRsaPublicKey(Se.n,Se.e)})},de.onerror=function(pe){$(pe)}},void(te.onerror=function(ne){$(ne)})}}else if(M("generateKeyPairSync")){var Z=g.generateKeyPairSync("rsa",{modulusLength:L,publicExponent:j,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:v.privateKeyFromPem(Z.privateKey),publicKey:v.publicKeyFromPem(Z.publicKey)}}var q=v.rsa.createKeyPairGenerationState(L,j,re);if(!$)return v.rsa.stepKeyPairGenerationState(q,0),q.keys;P(q,re,$)},v.setRsaPublicKey=v.rsa.setPublicKey=function(L,j){var re={n:L,e:j,encrypt:function($,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,oe,de){return C(ne,oe,2).getBytes()}};else if("RSA-OAEP"===te||"RSAES-OAEP"===te)te={encode:function(ne,oe){return h.pkcs1.encode_rsa_oaep(oe,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($,re,!0);return v.rsa.encrypt(q,re,!0)},verify:function($,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(oe,de){de=A(de,re,!0);var pe=b.fromDer(de,{parseAllBytes:q._parseAllDigestBytes}),ke={},Se=[];if(!b.validate(pe,E,ke,Se))throw(Pe=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=Se,Pe;var Pe,we=b.derToOid(ke.algorithmIdentifier);if(we!==h.oids.md2&&we!==h.oids.md5&&we!==h.oids.sha1&&we!==h.oids.sha224&&we!==h.oids.sha256&&we!==h.oids.sha384&&we!==h.oids.sha512&&we!==h.oids["sha512-224"]&&we!==h.oids["sha512-256"])throw(Pe=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=we,Pe;if((we===h.oids.md2||we===h.oids.md5)&&!("parameters"in ke))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return oe===ke.digest}}:("NONE"===Z||"NULL"===Z||null===Z)&&(Z={verify:function(oe,de){return oe===A(de,re,!0)}});var ne=v.rsa.decrypt(te,re,!0,!1);return Z.verify($,ne,re.n.bitLength())}};return re},v.setRsaPrivateKey=v.rsa.setPrivateKey=function(L,j,re,$,te,Z,q,ne){var oe={n:L,e:j,d:re,p:$,q:te,dP:Z,dQ:q,qInv:ne,decrypt:function(de,pe,ke){"string"==typeof pe?pe=pe.toUpperCase():void 0===pe&&(pe="RSAES-PKCS1-V1_5");var Se=v.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(Pe,we){return h.pkcs1.decode_rsa_oaep(we,Pe,ke)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(pe))throw new Error('Unsupported encryption scheme: "'+pe+'".');pe={decode:function(Pe){return Pe}}}return pe.decode(Se,oe,!1)},sign:function(de,pe){var ke=!1;"string"==typeof pe&&(pe=pe.toUpperCase()),void 0===pe||"RSASSA-PKCS1-V1_5"===pe?(pe={encode:y},ke=1):("NONE"===pe||"NULL"===pe||null===pe)&&(pe={encode:function(){return de}},ke=1);var Se=pe.encode(de,oe.n.bitLength());return v.rsa.encrypt(Se,oe,ke)}};return oe},v.wrapRsaPrivateKey=function(L){return b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,b.integerToDer(0).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(v.oids.rsaEncryption).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,"")]),b.create(b.Class.UNIVERSAL,b.Type.OCTETSTRING,!1,b.toDer(L).getBytes())])},v.privateKeyFromAsn1=function(L){var te,Z,q,ne,oe,de,pe,ke,j={},re=[];if(b.validate(L,p,j,re)&&(L=b.fromDer(h.util.createBuffer(j.privateKey))),!b.validate(L,d,j={},re=[])){var $=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw $.errors=re,$}return te=h.util.createBuffer(j.privateKeyModulus).toHex(),Z=h.util.createBuffer(j.privateKeyPublicExponent).toHex(),q=h.util.createBuffer(j.privateKeyPrivateExponent).toHex(),ne=h.util.createBuffer(j.privateKeyPrime1).toHex(),oe=h.util.createBuffer(j.privateKeyPrime2).toHex(),de=h.util.createBuffer(j.privateKeyExponent1).toHex(),pe=h.util.createBuffer(j.privateKeyExponent2).toHex(),ke=h.util.createBuffer(j.privateKeyCoefficient).toHex(),v.setRsaPrivateKey(new u(te,16),new u(Z,16),new u(q,16),new u(ne,16),new u(oe,16),new u(de,16),new u(pe,16),new u(ke,16))},v.privateKeyToAsn1=v.privateKeyToRSAPrivateKey=function(L){return b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,b.integerToDer(0).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.n)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.e)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.d)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.p)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.q)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.dP)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.dQ)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.qInv))])},v.publicKeyFromAsn1=function(L){var j={},re=[];if(b.validate(L,I,j,re)){var te,$=b.derToOid(j.publicKeyOid);if($!==v.oids.rsaEncryption)throw(te=new Error("Cannot read public key. Unknown OID.")).oid=$,te;L=j.rsaPublicKey}if(!b.validate(L,_,j,re=[]))throw(te=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=re,te;var Z=h.util.createBuffer(j.publicKeyModulus).toHex(),q=h.util.createBuffer(j.publicKeyExponent).toHex();return v.setRsaPublicKey(new u(Z,16),new u(q,16))},v.publicKeyToAsn1=v.publicKeyToSubjectPublicKeyInfo=function(L){return b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.OID,!1,b.oidToDer(v.oids.rsaEncryption).getBytes()),b.create(b.Class.UNIVERSAL,b.Type.NULL,!1,"")]),b.create(b.Class.UNIVERSAL,b.Type.BITSTRING,!1,[v.publicKeyToRSAPublicKey(L)])])},v.publicKeyToRSAPublicKey=function(L){return b.create(b.Class.UNIVERSAL,b.Type.SEQUENCE,!0,[b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.n)),b.create(b.Class.UNIVERSAL,b.Type.INTEGER,!1,D(L.e))])}},7690:(J,G,N)=>{var h=N(8659);N(979),N(4747);var u=J.exports=h.sha1=h.sha1||{};h.md.sha1=h.md.algorithms.sha1=u,u.create=function(){b||function w(){g=String.fromCharCode(128),g+=h.util.fillString(String.fromCharCode(0),64),b=!0}();var l=null,p=h.util.createBuffer(),d=new Array(80),_={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){_.messageLength=0,_.fullMessageLength=_.messageLength64=[];for(var I=_.messageLengthSize/4,E=0;E>>0,y>>>0];for(var f=_.fullMessageLength.length-1;f>=0;--f)_.fullMessageLength[f]+=y[1],y[1]=y[0]+(_.fullMessageLength[f]/4294967296>>>0),_.fullMessageLength[f]=_.fullMessageLength[f]>>>0,y[0]=y[1]/4294967296>>>0;return p.putBytes(I),v(l,d,p),(p.read>2048||0===p.length())&&p.compact(),_},_.digest=function(){var I=h.util.createBuffer();I.putBytes(p.bytes()),I.putBytes(g.substr(0,_.blockLength-(_.fullMessageLength[_.fullMessageLength.length-1]+_.messageLengthSize&_.blockLength-1)));for(var f,A=8*_.fullMessageLength[0],P=0;P<_.fullMessageLength.length-1;++P)I.putInt32((A+=(f=8*_.fullMessageLength[P+1])/4294967296>>>0)>>>0),A=f>>>0;I.putInt32(A);var D={h0:l.h0,h1:l.h1,h2:l.h2,h3:l.h3,h4:l.h4};v(D,d,I);var x=h.util.createBuffer();return x.putInt32(D.h0),x.putInt32(D.h1),x.putInt32(D.h2),x.putInt32(D.h3),x.putInt32(D.h4),x},_};var g=null,b=!1;function v(l,p,d){for(var _,I,E,y,f,C,P,D=d.length();D>=64;){for(I=l.h0,E=l.h1,y=l.h2,f=l.h3,C=l.h4,P=0;P<16;++P)_=d.getInt32(),p[P]=_,_=(I<<5|I>>>27)+(f^E&(y^f))+C+1518500249+_,C=f,f=y,y=(E<<30|E>>>2)>>>0,E=I,I=_;for(;P<20;++P)p[P]=_=(_=p[P-3]^p[P-8]^p[P-14]^p[P-16])<<1|_>>>31,_=(I<<5|I>>>27)+(f^E&(y^f))+C+1518500249+_,C=f,f=y,y=(E<<30|E>>>2)>>>0,E=I,I=_;for(;P<32;++P)p[P]=_=(_=p[P-3]^p[P-8]^p[P-14]^p[P-16])<<1|_>>>31,_=(I<<5|I>>>27)+(E^y^f)+C+1859775393+_,C=f,f=y,y=(E<<30|E>>>2)>>>0,E=I,I=_;for(;P<40;++P)p[P]=_=(_=p[P-6]^p[P-16]^p[P-28]^p[P-32])<<2|_>>>30,_=(I<<5|I>>>27)+(E^y^f)+C+1859775393+_,C=f,f=y,y=(E<<30|E>>>2)>>>0,E=I,I=_;for(;P<60;++P)p[P]=_=(_=p[P-6]^p[P-16]^p[P-28]^p[P-32])<<2|_>>>30,_=(I<<5|I>>>27)+(E&y|f&(E^y))+C+2400959708+_,C=f,f=y,y=(E<<30|E>>>2)>>>0,E=I,I=_;for(;P<80;++P)p[P]=_=(_=p[P-6]^p[P-16]^p[P-28]^p[P-32])<<2|_>>>30,_=(I<<5|I>>>27)+(E^y^f)+C+3395469782+_,C=f,f=y,y=(E<<30|E>>>2)>>>0,E=I,I=_;l.h0=l.h0+I|0,l.h1=l.h1+E|0,l.h2=l.h2+y|0,l.h3=l.h3+f|0,l.h4=l.h4+C|0,D-=64}}},1594:(J,G,N)=>{var h=N(8659);N(979),N(4747);var u=J.exports=h.sha256=h.sha256||{};h.md.sha256=h.md.algorithms.sha256=u,u.create=function(){b||function v(){g=String.fromCharCode(128),g+=h.util.fillString(String.fromCharCode(0),64),w=[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],b=!0}();var p=null,d=h.util.createBuffer(),_=new Array(64),I={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){I.messageLength=0,I.fullMessageLength=I.messageLength64=[];for(var E=I.messageLengthSize/4,y=0;y>>0,f>>>0];for(var C=I.fullMessageLength.length-1;C>=0;--C)I.fullMessageLength[C]+=f[1],f[1]=f[0]+(I.fullMessageLength[C]/4294967296>>>0),I.fullMessageLength[C]=I.fullMessageLength[C]>>>0,f[0]=f[1]/4294967296>>>0;return d.putBytes(E),l(p,_,d),(d.read>2048||0===d.length())&&d.compact(),I},I.digest=function(){var E=h.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,I.blockLength-(I.fullMessageLength[I.fullMessageLength.length-1]+I.messageLengthSize&I.blockLength-1)));for(var C,P=8*I.fullMessageLength[0],D=0;D>>0)>>>0),P=C>>>0;E.putInt32(P);var x={h0:p.h0,h1:p.h1,h2:p.h2,h3:p.h3,h4:p.h4,h5:p.h5,h6:p.h6,h7:p.h7};l(x,_,E);var M=h.util.createBuffer();return M.putInt32(x.h0),M.putInt32(x.h1),M.putInt32(x.h2),M.putInt32(x.h3),M.putInt32(x.h4),M.putInt32(x.h5),M.putInt32(x.h6),M.putInt32(x.h7),M},I};var g=null,b=!1,w=null;function l(p,d,_){for(var I,E,A,P,D,x,M,B,F,z,S,O,H=_.length();H>=64;){for(P=0;P<16;++P)d[P]=_.getInt32();for(;P<64;++P)d[P]=(I=((I=d[P-2])>>>17|I<<15)^(I>>>19|I<<13)^I>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(D=p.h0,x=p.h1,M=p.h2,B=p.h3,F=p.h4,z=p.h5,S=p.h6,O=p.h7,P=0;P<64;++P)A=D&x|M&(D^x),I=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(S^F&(z^S))+w[P]+d[P],O=S,S=z,z=F,F=B+I>>>0,B=M,M=x,x=D,D=I+(E=((D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10))+A)>>>0;p.h0=p.h0+D|0,p.h1=p.h1+x|0,p.h2=p.h2+M|0,p.h3=p.h3+B|0,p.h4=p.h4+F|0,p.h5=p.h5+z|0,p.h6=p.h6+S|0,p.h7=p.h7+O|0,H-=64}}},8985:(J,G,N)=>{var h=N(8659);N(979),N(4747);var u=J.exports=h.sha512=h.sha512||{};h.md.sha512=h.md.algorithms.sha512=u;var g=h.sha384=h.sha512.sha384=h.sha512.sha384||{};g.create=function(){return u.create("SHA-384")},h.md.sha384=h.md.algorithms.sha384=g,h.sha512.sha256=h.sha512.sha256||{create:function(){return u.create("SHA-512/256")}},h.md["sha512/256"]=h.md.algorithms["sha512/256"]=h.sha512.sha256,h.sha512.sha224=h.sha512.sha224||{create:function(){return u.create("SHA-512/224")}},h.md["sha512/224"]=h.md.algorithms["sha512/224"]=h.sha512.sha224,u.create=function(_){if(w||function p(){b=String.fromCharCode(128),b+=h.util.fillString(String.fromCharCode(0),128),v=[[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]],(l={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],l["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],l["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],l["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],w=!0}(),typeof _>"u"&&(_="SHA-512"),!(_ in l))throw new Error("Invalid SHA-512 algorithm: "+_);for(var I=l[_],E=null,y=h.util.createBuffer(),f=new Array(80),C=0;C<80;++C)f[C]=new Array(2);var A=64;switch(_){case"SHA-384":A=48;break;case"SHA-512/256":A=32;break;case"SHA-512/224":A=28}var P={algorithm:_.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,x=0;x>>0,M>>>0];for(var B=P.fullMessageLength.length-1;B>=0;--B)P.fullMessageLength[B]+=M[1],M[1]=M[0]+(P.fullMessageLength[B]/4294967296>>>0),P.fullMessageLength[B]=P.fullMessageLength[B]>>>0,M[0]=M[1]/4294967296>>>0;return y.putBytes(D),d(E,f,y),(y.read>2048||0===y.length())&&y.compact(),P},P.digest=function(){var D=h.util.createBuffer();D.putBytes(y.bytes()),D.putBytes(b.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var B,z=8*P.fullMessageLength[0],S=0;S>>0)>>>0),z=B>>>0;D.putInt32(z);var O=new Array(E.length);for(S=0;S=128;){for(we=0;we<16;++we)I[we][0]=E.getInt32()>>>0,I[we][1]=E.getInt32()>>>0;for(;we<80;++we)f=((($e=(Ee=I[we-2])[0])<<13|(K=Ee[1])>>>19)^(K<<3|$e>>>29)^($e<<26|K>>>6))>>>0,I[we][0]=(y=(($e>>>19|K<<13)^(K>>>29|$e<<3)^$e>>>6)>>>0)+(Ce=I[we-7])[0]+(C=((($e=(xe=I[we-15])[0])>>>1|(K=xe[1])<<31)^($e>>>8|K<<24)^$e>>>7)>>>0)+(Ke=I[we-16])[0]+((K=f+Ce[1]+(A=(($e<<31|K>>>1)^($e<<24|K>>>8)^($e<<25|K>>>7))>>>0)+Ke[1])/4294967296>>>0)>>>0,I[we][1]=K>>>0;for(O=_[0][0],H=_[0][1],L=_[1][0],j=_[1][1],re=_[2][0],$=_[2][1],te=_[3][0],Z=_[3][1],q=_[4][0],ne=_[4][1],oe=_[5][0],de=_[5][1],pe=_[6][0],ke=_[6][1],Se=_[7][0],Pe=_[7][1],we=0;we<80;++we)y=Se+(((q>>>14|ne<<18)^(q>>>18|ne<<14)^(ne>>>9|q<<23))>>>0)+((pe^q&(oe^pe))>>>0)+v[we][0]+I[we][0]+((K=Pe+(((q<<18|ne>>>14)^(q<<14|ne>>>18)^(ne<<23|q>>>9))>>>0)+((ke^ne&(de^ke))>>>0)+v[we][1]+I[we][1])/4294967296>>>0)>>>0,f=K>>>0,C=(((O>>>28|H<<4)^(H>>>2|O<<30)^(H>>>7|O<<25))>>>0)+((O&L|re&(O^L))>>>0)+((K=(((O<<4|H>>>28)^(H<<30|O>>>2)^(H<<25|O>>>7))>>>0)+((H&j|$&(H^j))>>>0))/4294967296>>>0)>>>0,A=K>>>0,Se=pe,Pe=ke,pe=oe,ke=de,oe=q,de=ne,q=te+y+((K=Z+f)/4294967296>>>0)>>>0,ne=K>>>0,te=re,Z=$,re=L,$=j,L=O,j=H,O=y+C+((K=f+A)/4294967296>>>0)>>>0,H=K>>>0;_[0][0]=_[0][0]+O+((K=_[0][1]+H)/4294967296>>>0)>>>0,_[0][1]=K>>>0,_[1][0]=_[1][0]+L+((K=_[1][1]+j)/4294967296>>>0)>>>0,_[1][1]=K>>>0,_[2][0]=_[2][0]+re+((K=_[2][1]+$)/4294967296>>>0)>>>0,_[2][1]=K>>>0,_[3][0]=_[3][0]+te+((K=_[3][1]+Z)/4294967296>>>0)>>>0,_[3][1]=K>>>0,_[4][0]=_[4][0]+q+((K=_[4][1]+ne)/4294967296>>>0)>>>0,_[4][1]=K>>>0,_[5][0]=_[5][0]+oe+((K=_[5][1]+de)/4294967296>>>0)>>>0,_[5][1]=K>>>0,_[6][0]=_[6][0]+pe+((K=_[6][1]+ke)/4294967296>>>0)>>>0,_[6][1]=K>>>0,_[7][0]=_[7][0]+Se+((K=_[7][1]+Pe)/4294967296>>>0)>>>0,_[7][1]=K>>>0,We-=128}}},4747:(J,G,N)=>{var h=N(8659),u=N(2020),g=J.exports=h.util=h.util||{};function b(D){if(8!==D&&16!==D&&24!==D&&32!==D)throw new Error("Only 8, 16, 24, or 32 bits supported: "+D)}function w(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 x=new Uint8Array(D);try{this.data=String.fromCharCode.apply(null,x)}catch{for(var M=0;M15?(M=Date.now(),z(H)):(x.push(H),1===x.length&&F.setAttribute("a",B=!B))}}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=w,g.ByteStringBuffer=w,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,x){D=String.fromCharCode(D);for(var M=this.data;x>0;)1&x&&(M+=D),(x>>>=1)>0&&(D+=D);return this.data=M,this._optimizeConstructedString(x),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,x){b(x);var M="";do{x-=8,M+=String.fromCharCode(D>>x&255)}while(x>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(D,x){return D<0&&(D+=2<0);return x},g.ByteStringBuffer.prototype.getSignedInt=function(D){var x=this.getInt(D),M=2<=M&&(x-=M<<1),x},g.ByteStringBuffer.prototype.getBytes=function(D){var x;return D?(D=Math.min(this.length(),D),x=this.data.slice(this.read,this.read+D),this.read+=D):0===D?x="":(x=0===this.read?this.data:this.data.slice(this.read),this.clear()),x},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,x){return this.data=this.data.substr(0,this.read+D)+String.fromCharCode(x)+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 x=Math.max(0,this.length()-D);return this.data=this.data.substr(this.read,x),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var D="",x=this.read;x=D)return this;x=Math.max(x||this.growSize,D);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),B=new Uint8Array(this.length()+x);return B.set(M),this.data=new DataView(B.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,x){this.accommodate(x);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,x){b(x),this.accommodate(x/8);do{x-=8,this.data.setInt8(this.write++,D>>x&255)}while(x>0);return this},g.DataBuffer.prototype.putSignedInt=function(D,x){return b(x),this.accommodate(x/8),D<0&&(D+=2<0);return x},g.DataBuffer.prototype.getSignedInt=function(D){var x=this.getInt(D),M=2<=M&&(x-=M<<1),x},g.DataBuffer.prototype.getBytes=function(D){var x;return D?(D=Math.min(this.length(),D),x=this.data.slice(this.read,this.read+D),this.read+=D):0===D?x="":(x=0===this.read?this.data:this.data.slice(this.read),this.clear()),x},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,x){return this.data.setUint8(D,x),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),x=new Uint8Array(D.byteLength);x.set(D),this.data=new DataView(x),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="",x=this.read;x0;)1&x&&(M+=D),(x>>>=1)>0&&(D+=D);return M},g.xorBytes=function(D,x,M){for(var B="",F="",z="",S=0,O=0;M>0;--M,++S)F=D.charCodeAt(S)^x.charCodeAt(S),O>=10&&(B+=z,z="",O=0),z+=String.fromCharCode(F),++O;return B+z},g.hexToBytes=function(D){var x="",M=0;for(!0&D.length&&(M=1,x+=String.fromCharCode(parseInt(D[0],16)));M>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D)};var p="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],_="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";g.encode64=function(D,x){for(var F,z,S,M="",B="",O=0;O>2),M+=p.charAt((3&F)<<4|z>>4),isNaN(z)?M+="==":(M+=p.charAt((15&z)<<2|S>>6),M+=isNaN(S)?"=":p.charAt(63&S)),x&&M.length>x&&(B+=M.substr(0,x)+"\r\n",M=M.substr(x));return B+M},g.decode64=function(D){D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,B,F,z,x="",S=0;S>4),64!==F&&(x+=String.fromCharCode((15&B)<<4|F>>2),64!==z&&(x+=String.fromCharCode((3&F)<<6|z)));return x},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,x,M){var B=x;B||(B=new Uint8Array(D.length));for(var F=M=M||0,z=0;z>2),M+=p.charAt((3&F)<<4|z>>4),isNaN(z)?M+="==":(M+=p.charAt((15&z)<<2|S>>6),M+=isNaN(S)?"=":p.charAt(63&S)),x&&M.length>x&&(B+=M.substr(0,x)+"\r\n",M=M.substr(x));return B+M},g.binary.base64.decode=function(D,x,M){var B=x;B||(B=new Uint8Array(3*Math.ceil(D.length/4))),D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,z,S,O,H=0,L=M=M||0;H>4,64!==S&&(B[L++]=(15&z)<<4|S>>2,64!==O&&(B[L++]=(3&S)<<6|O));return x?L-M:B.subarray(0,L)},g.binary.base58.encode=function(D,x){return g.binary.baseN.encode(D,_,x)},g.binary.base58.decode=function(D,x){return g.binary.baseN.decode(D,_,x)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(D,x,M){D=g.encodeUtf8(D);var B=x;B||(B=new Uint8Array(D.length));for(var F=M=M||0,z=0;z"u"&&(M=["web","flash"]);var F,z=!1,S=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===x[0])throw new Error("Flash local storage not available.");B=D.apply(this,x),z="flash"===F}("web"===F||"both"===F)&&(x[0]=localStorage,B=D.apply(this,x),z=!0)}catch(H){S=H}if(z)break}if(!z)throw S;return B};g.setItem=function(D,x,M,B,F){P(y,arguments,F)},g.getItem=function(D,x,M,B){return P(f,arguments,B)},g.removeItem=function(D,x,M,B){P(C,arguments,B)},g.clearItems=function(D,x,M){P(A,arguments,M)},g.isEmpty=function(D){for(var x in D)if(D.hasOwnProperty(x))return!1;return!0},g.format=function(D){for(var M,B,x=/%./g,F=0,z=[],S=0;M=x.exec(D);){(B=D.substring(S,x.lastIndex-2)).length>0&&z.push(B),S=x.lastIndex;var O=M[0][1];switch(O){case"s":case"o":z.push(F");break;case"%":z.push("%");break;default:z.push("<%"+O+"?>")}}return z.push(D.substring(S)),z.join("")},g.formatNumber=function(D,x,M,B){var F=D,z=isNaN(x=Math.abs(x))?2:x,S=void 0===M?",":M,O=void 0===B?".":B,H=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed(z),10)+"",j=L.length>3?L.length%3:0;return H+(j?L.substr(0,j)+O:"")+L.substr(j).replace(/(\d{3})(?=\d)/g,"$1"+O)+(z?S+Math.abs(F-L).toFixed(z).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 x=g.createBuffer(),M=0;MM[B].end-M[B].start&&(B=M.length-1)):M.push({start:O,end:O})}x.push(z)}if(M.length>0){var H=M[B];H.end-H.start>0&&(x.splice(H.start,H.end-H.start+1,""),0===H.start&&x.unshift(""),7===H.end&&x.push(""))}return x.join(":")},g.estimateCores=function(D,x){if("function"==typeof D&&(x=D,D={}),D=D||{},"cores"in g&&!D.update)return x(null,g.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return g.cores=navigator.hardwareConcurrency,x(null,g.cores);if(typeof Worker>"u")return g.cores=1,x(null,g.cores);if(typeof Blob>"u")return g.cores=2,x(null,g.cores);var M=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(S){for(var O=Date.now(),H=O+4;Date.now()te.st&&j.stj.st&&te.st{var h=N(8659);N(1298),N(7791),N(279),N(979),N(9386),N(6078),N(8604),N(7256),N(5517),N(4747);var u=h.asn1,g=J.exports=h.pki=h.pki||{},b=g.oids,w={};w.CN=b.commonName,w.commonName="CN",w.C=b.countryName,w.countryName="C",w.L=b.localityName,w.localityName="L",w.ST=b.stateOrProvinceName,w.stateOrProvinceName="ST",w.O=b.organizationName,w.organizationName="O",w.OU=b.organizationalUnitName,w.organizationalUnitName="OU",w.E=b.emailAddress,w.emailAddress="E";var v=h.pki.rsa.publicKeyValidator,l={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"},v,{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"}]},p={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"}]}]},_={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"},v,{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 I(S,O){"string"==typeof O&&(O={shortName:O});for(var L,H=null,j=0;null===H&&j"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in w&&(O.name=g.oids[w[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 w&&(O.shortName=w[O.name]),O.type===b.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=u.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var j=0;j"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function D(S,O){if(O=O||{},typeof S.name>"u"&&S.id&&S.id in g.oids&&(S.name=g.oids[S.id]),typeof S.id>"u"){if(!S.name||!(S.name in g.oids))throw(H=new Error("Extension ID not specified.")).extension=S,H;S.id=g.oids[S.name]}if(typeof S.value<"u")return S;if("keyUsage"===S.name){var L=0,j=0,re=0;S.digitalSignature&&(j|=128,L=7),S.nonRepudiation&&(j|=64,L=6),S.keyEncipherment&&(j|=32,L=5),S.dataEncipherment&&(j|=16,L=4),S.keyAgreement&&(j|=8,L=3),S.keyCertSign&&(j|=4,L=2),S.cRLSign&&(j|=2,L=1),S.encipherOnly&&(j|=1,L=0),S.decipherOnly&&(re|=128,L=7);var $=String.fromCharCode(L);0!==re?$+=String.fromCharCode(j)+String.fromCharCode(re):0!==j&&($+=String.fromCharCode(j)),S.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,$)}else if("basicConstraints"===S.name)S.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),S.cA&&S.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in S&&S.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(S.pathLenConstraint).getBytes()));else if("extKeyUsage"===S.name){S.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);var te=S.value.value;for(var Z in S)!0===S[Z]&&(Z in b?te.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(b[Z]).getBytes())):-1!==Z.indexOf(".")&&te.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(Z).getBytes())))}else if("nsCertType"===S.name)L=0,j=0,S.client&&(j|=128,L=7),S.server&&(j|=64,L=6),S.email&&(j|=32,L=5),S.objsign&&(j|=16,L=4),S.reserved&&(j|=8,L=3),S.sslCA&&(j|=4,L=2),S.emailCA&&(j|=2,L=1),S.objCA&&(j|=1,L=0),$=String.fromCharCode(L),0!==j&&($+=String.fromCharCode(j)),S.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,$);else if("subjectAltName"===S.name||"issuerAltName"===S.name){S.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);for(var ne=0;ne128)throw new Error('Invalid "nsComment" content.');S.value=u.create(u.Class.UNIVERSAL,u.Type.IA5STRING,!1,S.comment)}else if("subjectKeyIdentifier"===S.name&&O.cert){var oe=O.cert.generateSubjectKeyIdentifier();S.subjectKeyIdentifier=oe.toHex(),S.value=u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,oe.getBytes())}else if("authorityKeyIdentifier"===S.name&&O.cert){if(S.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),te=S.value.value,S.keyIdentifier){var de=!0===S.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():S.keyIdentifier;te.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!1,de))}if(S.authorityCertIssuer){var pe=[u.create(u.Class.CONTEXT_SPECIFIC,4,!0,[C(!0===S.authorityCertIssuer?O.cert.issuer:S.authorityCertIssuer)])];te.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,pe))}if(S.serialNumber){var ke=h.util.hexToBytes(!0===S.serialNumber?O.cert.serialNumber:S.serialNumber);te.push(u.create(u.Class.CONTEXT_SPECIFIC,2,!1,ke))}}else if("cRLDistributionPoints"===S.name){S.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),te=S.value.value;var q,Se=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),Pe=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);for(ne=0;ne"u")throw(H=new Error("Extension value not specified.")).extension=S,H;return S}function x(S,O){if(S===b["RSASSA-PSS"]){var H=[];return void 0!==O.hash.algorithmOid&&H.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&&H.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&&H.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,H)}return u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")}function M(S){var O=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===S.attributes.length)return O;for(var H=S.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($.validity.notBefore=Z[0],$.validity.notAfter=Z[1],$.tbsCertificate=H.tbsCertificate,O){$.md=y({signatureOid:$.signatureOid,type:"certificate"});var q=u.toDer($.tbsCertificate);$.md.update(q.getBytes())}var ne=h.md.sha1.create(),oe=u.toDer(H.certIssuer);ne.update(oe.getBytes()),$.issuer.getField=function(ke){return I($.issuer,ke)},$.issuer.addField=function(ke){P([ke]),$.issuer.attributes.push(ke)},$.issuer.attributes=g.RDNAttributesAsArray(H.certIssuer),H.certIssuerUniqueId&&($.issuer.uniqueId=H.certIssuerUniqueId),$.issuer.hash=ne.digest().toHex();var de=h.md.sha1.create(),pe=u.toDer(H.certSubject);return de.update(pe.getBytes()),$.subject.getField=function(ke){return I($.subject,ke)},$.subject.addField=function(ke){P([ke]),$.subject.attributes.push(ke)},$.subject.attributes=g.RDNAttributesAsArray(H.certSubject),H.certSubjectUniqueId&&($.subject.uniqueId=H.certSubjectUniqueId),$.subject.hash=de.digest().toHex(),$.extensions=H.certExtensions?g.certificateExtensionsFromAsn1(H.certExtensions):[],$.publicKey=g.publicKeyFromAsn1(H.subjectPublicKeyInfo),$},g.certificateExtensionsFromAsn1=function(S){for(var O=[],H=0;H1&&(L=H.value.charCodeAt(1),j=H.value.length>2?H.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&j)}else if("basicConstraints"===O.name){var H=u.fromDer(O.value);O.cA=H.value.length>0&&H.value[0].type===u.Type.BOOLEAN&&0!==H.value[0].value.charCodeAt(0);var re=null;H.value.length>0&&H.value[0].type===u.Type.INTEGER?re=H.value[0].value:H.value.length>1&&(re=H.value[1].value),null!==re&&(O.pathLenConstraint=u.derToInteger(re))}else if("extKeyUsage"===O.name){H=u.fromDer(O.value);for(var $=0;$1&&(L=H.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=[],H=u.fromDer(O.value);for(var Z,q=0;q=B&&S0&&L.value.push(g.certificateExtensionsToAsn1(S.extensions)),L},g.getCertificationRequestInfo=function(S){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(S.version).getBytes()),C(S.subject),g.publicKeyToAsn1(S.publicKey),M(S)])},g.distinguishedNameToAsn1=function(S){return C(S)},g.certificateToAsn1=function(S){var O=S.tbsCertificate||g.getTBSCertificate(S);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(S.signatureOid).getBytes()),x(S.signatureOid,S.signatureParameters)]),u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,String.fromCharCode(0)+S.signature)])},g.certificateExtensionsToAsn1=function(S){var O=u.create(u.Class.CONTEXT_SPECIFIC,3,!0,[]),H=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);O.value.push(H);for(var L=0;L"u"&&(j=new Date);var re=!0,$=null,te=0;do{var Z=O.shift(),q=null,ne=!1;if(j&&(jZ.validity.notAfter)&&($={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:Z.validity.notBefore,notAfter:Z.validity.notAfter,now:j}),null===$){if(null===(q=O[0]||S.getIssuer(Z))&&Z.isIssuer(Z)&&(ne=!0,q=Z),q){var oe=q;h.util.isArray(oe)||(oe=[oe]);for(var de=!1;!de&&oe.length>0;){q=oe.shift();try{de=q.verify(Z)}catch{}}de||($={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===$&&(!q||ne)&&!S.hasCertificate(Z)&&($={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===$&&q&&!Z.isIssuer(q)&&($={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===$)for(var pe={keyUsage:!0,basicConstraints:!0},ke=0;null===$&&kePe.pathLenConstraint&&($={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var K=null===$||$.error,Ee=H.verify?H.verify(K,te,L):K;if(!0!==Ee)throw!0===K&&($={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate}),(Ee||0===Ee)&&("object"!=typeof Ee||h.util.isArray(Ee)?"string"==typeof Ee&&($.error=Ee):(Ee.message&&($.message=Ee.message),Ee.error&&($.error=Ee.error))),$;$=null,re=!1,++te}while(O.length>0);return!0}},8614:(J,G,N)=>{const h=N(1159),u=N(281);J.exports=class{constructor(){this._buffer=new h,this._waitingConsumers=new h}push(b){const{promise:w,resolve:v}=u();return this._buffer.push({chunk:b,resolve:v}),this._consume(),w}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const b=this._waitingConsumers.shift(),w=this._buffer.shift();b.resolve(w.chunk),w.resolve()}}shift(){const{promise:b,resolve:w}=u();return this._waitingConsumers.push({resolve:w}),this._consume(),b}isEmpty(){return this._buffer.isEmpty()}}},281:J=>{"use strict";J.exports=()=>{const N={};return N.promise=new Promise((h,u)=>{N.resolve=h,N.reject=u}),N}},4108:(J,G,N)=>{"use strict";J.exports=N(8777).default},8777:function(J,G,N){"use strict";var h=this&&this.__importDefault||function(_){return _&&_.__esModule?_:{default:_}};Object.defineProperty(G,"__esModule",{value:!0});const u=N(7910),g=h(N(4066)),b=h(N(6599)),w=N(1396),l=["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(_=>new u.Netmask(_));function d(_){return/^::$/.test(_)||/^::1$/.test(_)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(_)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(_)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(_)||/^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(_)||/^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(_)||/^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(_)||/^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(_)||/^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(_)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(_)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(_)||/^ff([0-9a-fA-F]{2,2}):/i.test(_)}G.default=_=>{if((0,w.isValid)(_)){const I=(0,w.parse)(_);if("ipv4"===I.kind())return function p(_){for(let I of l)if(I.contains(_))return!0;return!1}(I.toNormalizedString());if("ipv6"===I.kind())return d(_)}else if((0,b.default)(_)&&g.default.v6().test(_))return d(_)}},3863:(J,G,N)=>{"use strict";J.exports=N(2540)},4599:J=>{"use strict";J.exports=N;var h,G=/\/|\./;function N(u,g){G.test(u)||(u="google/protobuf/"+u+".proto",g={nested:{google:{nested:{protobuf:{nested:g}}}}}),N[u]=g}N("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),N("duration",{Duration:h={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),N("timestamp",{Timestamp:h}),N("empty",{Empty:{fields:{}}}),N("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}}}}),N("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}}}}),N("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),N.get=function(g){return N[g]||null}},6533:(J,G,N)=>{"use strict";var h=G,u=N(4269),g=N(8572);function b(v,l,p,d){if(l.resolvedType)if(l.resolvedType instanceof u){v("switch(d%s){",d);for(var _=l.resolvedType.values,I=Object.keys(_),E=0;E>>0",d,d);break;case"int32":case"sint32":case"sfixed32":v("m%s=d%s|0",d,d);break;case"uint64":y=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":v("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,y)('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,y?"true":"");break;case"bytes":v('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":v("m%s=String(d%s)",d,d);break;case"bool":v("m%s=Boolean(d%s)",d,d)}}return v}function w(v,l,p,d){if(l.resolvedType)l.resolvedType instanceof u?v("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,p,d,d,p,d,d):v("d%s=types[%i].toObject(m%s,o)",d,p,d);else{var _=!1;switch(l.type){case"double":case"float":v("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":_=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":v('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,_?"true":"",d);break;case"bytes":v("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:v("d%s=m%s",d,d)}}return v}h.fromObject=function(l){var p=l.fieldsArray,d=g.codegen(["d"],l.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!p.length)return d("return new this.ctor");d("var m=new this.ctor");for(var _=0;_{"use strict";J.exports=function w(v){var l=g.codegen(["r","l"],v.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(v.fieldsArray.filter(function(y){return y.map}).length?",k,value":""))("while(r.pos>>3){");for(var p=0;p>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===u.basic[_]?l("value=types[%i].decode(r,r.uint32())",p):l("value=r.%s()",_),l("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),l(void 0!==u.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",I)):d.repeated?(l("if(!(%s&&%s.length))",I,I)("%s=[]",I),void 0!==u.packed[_]&&l("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";J.exports=function w(v){for(var d,l=g.codegen(["m","w"],v.name+"$encode")("if(!w)")("w=Writer.create()"),_=v.fieldsArray.slice().sort(g.compareFieldsById),p=0;p<_.length;++p){var I=_[p].resolve(),E=v._fieldsArray.indexOf(I),y=I.resolvedType instanceof h?"int32":I.type,f=u.basic[y];d="m"+g.safeProp(I.name),I.map?(l("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",d,I.name)("for(var ks=Object.keys(%s),i=0;i>>0,8|u.mapKey[I.keyType],I.keyType),void 0===f?l("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",E,d):l(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|f,y,d),l("}")("}")):I.repeated?(l("if(%s!=null&&%s.length){",d,d),I.packed&&void 0!==u.packed[y]?l("w.uint32(%i).fork()",(I.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",d)("w.%s(%s[i])",y,d)("w.ldelim()"):(l("for(var i=0;i<%s.length;++i)",d),void 0===f?b(l,I,E,d+"[i]"):l("w.uint32(%i).%s(%s[i])",(I.id<<3|f)>>>0,y,d)),l("}")):(I.optional&&l("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,I.name),void 0===f?b(l,I,E,d):l("w.uint32(%i).%s(%s)",(I.id<<3|f)>>>0,y,d))}return l("return w")};var h=N(4269),u=N(688),g=N(8572);function b(v,l,p,d){return l.resolvedType.group?v("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",p,d,(l.id<<3|3)>>>0,(l.id<<3|4)>>>0):v("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",p,d,(l.id<<3|2)>>>0)}},4269:(J,G,N)=>{"use strict";J.exports=b;var h=N(9487);((b.prototype=Object.create(h.prototype)).constructor=b).className="Enum";var u=N(326),g=N(8572);function b(w,v,l,p,d,_){if(h.call(this,w,l),v&&"object"!=typeof v)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=p,this.comments=d||{},this.valuesOptions=_,this.reserved=void 0,v)for(var I=Object.keys(v),E=0;E{"use strict";J.exports=l;var h=N(9487);((l.prototype=Object.create(h.prototype)).constructor=l).className="Field";var w,u=N(4269),g=N(688),b=N(8572),v=/^required|optional|repeated$/;function l(p,d,_,I,E,y,f){if(b.isObject(I)?(f=E,y=I,I=E=void 0):b.isObject(E)&&(f=y,y=E,E=void 0),h.call(this,p,y),!b.isInteger(d)||d<0)throw TypeError("id must be a non-negative integer");if(!b.isString(_))throw TypeError("type must be a string");if(void 0!==I&&!v.test(I=I.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==E&&!b.isString(E))throw TypeError("extend must be a string");"proto3_optional"===I&&(I="optional"),this.rule=I&&"optional"!==I?I:void 0,this.type=_,this.id=d,this.extend=E||void 0,this.required="required"===I,this.optional=!this.required,this.repeated="repeated"===I,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!b.Long&&void 0!==g.long[_],this.bytes="bytes"===_,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=f}l.fromJSON=function(d,_){return new l(d,_.id,_.type,_.rule,_.extend,_.options,_.comment)},Object.defineProperty(l.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),l.prototype.setOption=function(d,_,I){return"packed"===d&&(this._packed=null),h.prototype.setOption.call(this,d,_,I)},l.prototype.toJSON=function(d){var _=!!d&&Boolean(d.keepComments);return b.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",_?this.comment:void 0])},l.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 w?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=b.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;b.base64.test(this.typeDefault)?b.base64.decode(this.typeDefault,d=b.newBuffer(b.base64.length(this.typeDefault)),0):b.utf8.write(this.typeDefault,d=b.newBuffer(b.utf8.length(this.typeDefault)),0),this.typeDefault=d}return this.defaultValue=this.map?b.emptyObject:this.repeated?b.emptyArray:this.typeDefault,this.parent instanceof w&&(this.parent.ctor.prototype[this.name]=this.defaultValue),h.prototype.resolve.call(this)},l.d=function(d,_,I,E){return"function"==typeof _?_=b.decorateType(_).name:_&&"object"==typeof _&&(_=b.decorateEnum(_).name),function(f,C){b.decorateType(f.constructor).add(new l(C,d,_,I,{default:E}))}},l._configure=function(d){w=d}},5803:(J,G,N)=>{"use strict";var h=J.exports=N(95);h.build="light",h.load=function u(b,w,v){return"function"==typeof w?(v=w,w=new h.Root):w||(w=new h.Root),w.load(b,v)},h.loadSync=function g(b,w){return w||(w=new h.Root),w.loadSync(b)},h.encoder=N(133),h.decoder=N(225),h.verifier=N(8617),h.converter=N(6533),h.ReflectionObject=N(9487),h.Namespace=N(326),h.Root=N(5257),h.Enum=N(4269),h.Type=N(7845),h.Field=N(2986),h.OneOf=N(7397),h.MapField=N(9455),h.Service=N(9630),h.Method=N(1618),h.Message=N(1413),h.wrappers=N(761),h.types=N(688),h.util=N(8572),h.ReflectionObject._configure(h.Root),h.Namespace._configure(h.Type,h.Service,h.Enum),h.Root._configure(h.Type),h.Field._configure(h.Type)},95:(J,G,N)=>{"use strict";var h=G;function u(){h.util._configure(),h.Writer._configure(h.BufferWriter),h.Reader._configure(h.BufferReader)}h.build="minimal",h.Writer=N(1650),h.BufferWriter=N(813),h.Reader=N(7270),h.BufferReader=N(4354),h.util=N(7211),h.rpc=N(7830),h.roots=N(6671),h.configure=u,u()},2540:(J,G,N)=>{"use strict";var h=J.exports=N(5803);h.build="full",h.tokenize=N(691),h.parse=N(8992),h.common=N(4599),h.Root._configure(h.Type,h.parse,h.common)},9455:(J,G,N)=>{"use strict";J.exports=b;var h=N(2986);((b.prototype=Object.create(h.prototype)).constructor=b).className="MapField";var u=N(688),g=N(8572);function b(w,v,l,p,d,_){if(h.call(this,w,v,p,void 0,void 0,d,_),!g.isString(l))throw TypeError("keyType must be a string");this.keyType=l,this.resolvedKeyType=null,this.map=!0}b.fromJSON=function(v,l){return new b(v,l.id,l.keyType,l.type,l.options,l.comment)},b.prototype.toJSON=function(v){var l=!!v&&Boolean(v.keepComments);return g.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",l?this.comment:void 0])},b.prototype.resolve=function(){if(this.resolved)return this;if(void 0===u.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return h.prototype.resolve.call(this)},b.d=function(v,l,p){return"function"==typeof p?p=g.decorateType(p).name:p&&"object"==typeof p&&(p=g.decorateEnum(p).name),function(_,I){g.decorateType(_.constructor).add(new b(I,v,l,p))}}},1413:(J,G,N)=>{"use strict";J.exports=u;var h=N(7211);function u(g){if(g)for(var b=Object.keys(g),w=0;w{"use strict";J.exports=g;var h=N(9487);((g.prototype=Object.create(h.prototype)).constructor=g).className="Method";var u=N(8572);function g(b,w,v,l,p,d,_,I,E){if(u.isObject(p)?(_=p,p=d=void 0):u.isObject(d)&&(_=d,d=void 0),void 0!==w&&!u.isString(w))throw TypeError("type must be a string");if(!u.isString(v))throw TypeError("requestType must be a string");if(!u.isString(l))throw TypeError("responseType must be a string");h.call(this,b,_),this.type=w||"rpc",this.requestType=v,this.requestStream=!!p||void 0,this.responseType=l,this.responseStream=!!d||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=I,this.parsedOptions=E}g.fromJSON=function(w,v){return new g(w,v.type,v.requestType,v.responseType,v.requestStream,v.responseStream,v.options,v.comment,v.parsedOptions)},g.prototype.toJSON=function(w){var v=!!w&&Boolean(w.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",v?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),h.prototype.resolve.call(this))}},326:(J,G,N)=>{"use strict";J.exports=d;var h=N(9487);((d.prototype=Object.create(h.prototype)).constructor=d).className="Namespace";var w,v,l,u=N(2986),g=N(8572),b=N(7397);function p(I,E){if(I&&I.length){for(var y={},f=0;fy)return!0;return!1},d.isReservedName=function(E,y){if(E)for(var f=0;f0;){var C=E.shift();if(f.nested&&f.nested[C]){if(!((f=f.nested[C])instanceof d))throw Error("path conflicts with non-namespace objects")}else f.add(f=new d(C))}return y&&f.addJSON(y),f},d.prototype.resolveAll=function(){for(var E=this.nestedArray,y=0;y-1)return C}else if(C instanceof d&&(C=C.lookup(E.slice(1),y,!0)))return C}else for(var A=0;A{"use strict";J.exports=g,g.className="ReflectionObject";var u,h=N(8572);function g(b,w){if(!h.isString(b))throw TypeError("name must be a string");if(w&&!h.isObject(w))throw TypeError("options must be an object");this.options=w,this.parsedOptions=null,this.name=b,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(g.prototype,{root:{get:function(){for(var b=this;null!==b.parent;)b=b.parent;return b}},fullName:{get:function(){for(var b=[this.name],w=this.parent;w;)b.unshift(w.name),w=w.parent;return b.join(".")}}}),g.prototype.toJSON=function(){throw Error()},g.prototype.onAdd=function(w){this.parent&&this.parent!==w&&this.parent.remove(this),this.parent=w,this.resolved=!1;var v=w.root;v instanceof u&&v._handleAdd(this)},g.prototype.onRemove=function(w){var v=w.root;v instanceof u&&v._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(w){if(this.options)return this.options[w]},g.prototype.setOption=function(w,v,l){return(!l||!this.options||void 0===this.options[w])&&((this.options||(this.options={}))[w]=v),this},g.prototype.setParsedOption=function(w,v,l){this.parsedOptions||(this.parsedOptions=[]);var p=this.parsedOptions;if(l){var d=p.find(function(E){return Object.prototype.hasOwnProperty.call(E,w)});d?h.setProperty(d[w],l,v):((d={})[w]=h.setProperty({},l,v),p.push(d))}else{var I={};I[w]=v,p.push(I)}return this},g.prototype.setOptions=function(w,v){if(w)for(var l=Object.keys(w),p=0;p{"use strict";J.exports=b;var h=N(9487);((b.prototype=Object.create(h.prototype)).constructor=b).className="OneOf";var u=N(2986),g=N(8572);function b(v,l,p,d){if(Array.isArray(l)||(p=l,l=void 0),h.call(this,v,p),void 0!==l&&!Array.isArray(l))throw TypeError("fieldNames must be an Array");this.oneof=l||[],this.fieldsArray=[],this.comment=d}function w(v){if(v.parent)for(var l=0;l-1&&this.oneof.splice(p,1),l.partOf=null,this},b.prototype.onAdd=function(l){h.prototype.onAdd.call(this,l);for(var d=0;d{"use strict";J.exports=F,F.filename=null,F.defaults={keepCase:!1};var h=N(691),u=N(5257),g=N(7845),b=N(2986),w=N(9455),v=N(7397),l=N(4269),p=N(9630),d=N(1618),_=N(688),I=N(8572),E=/^[1-9][0-9]*$/,y=/^-?[1-9][0-9]*$/,f=/^0[x][0-9a-fA-F]+$/,C=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,D=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,x=/^[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]*)*$/,B=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F(z,S,O){S instanceof u||(O=S,S=new u),O||(O=F.defaults);var ne,oe,de,pe,je,H=O.preferTrailingComment||!1,L=h(z,O.alternateCommentMode||!1),j=L.next,re=L.push,$=L.peek,te=L.skip,Z=L.cmnt,q=!0,ke=!1,Se=S,Pe=O.keepCase?function(be){return be}:I.camelCase;function we(be,ge,De){var Ue=F.filename;return De||(F.filename=null),Error("illegal "+(ge||"token")+" '"+be+"' ("+(Ue?Ue+", ":"")+"line "+L.line+")")}function $e(){var ge,be=[];do{if('"'!==(ge=j())&&"'"!==ge)throw we(ge);be.push(j()),te(ge),ge=$()}while('"'===ge||"'"===ge);return be.join("")}function K(be){var ge=j();switch(ge){case"'":case'"':return re(ge),$e();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Ce(be,ge){var De=1;switch("-"===be.charAt(0)&&(De=-1,be=be.substring(1)),be){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(be))return De*parseInt(be,10);if(f.test(be))return De*parseInt(be,16);if(A.test(be))return De*parseInt(be,8);if(D.test(be))return De*parseFloat(be);throw we(be,"number",ge)}(ge,!0)}catch{if(be&&M.test(ge))return ge;throw we(ge,"value")}}function Ee(be,ge){var De,Ue;do{!ge||'"'!==(De=$())&&"'"!==De?be.push([Ue=xe(j()),te("to",!0)?xe(j()):Ue]):be.push($e())}while(te(",",!0));te(";")}function xe(be,ge){switch(be){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!ge&&"-"===be.charAt(0))throw we(be,"id");if(y.test(be))return parseInt(be,10);if(C.test(be))return parseInt(be,16);if(P.test(be))return parseInt(be,8);throw we(be,"id")}function Ke(){if(void 0!==ne)throw we("package");if(ne=j(),!M.test(ne))throw we(ne,"name");Se=Se.define(ne),te(";")}function We(){var ge,be=$();switch(be){case"weak":ge=de||(de=[]),j();break;case"public":j();default:ge=oe||(oe=[])}be=$e(),te(";"),ge.push(be)}function Je(){if(te("="),pe=$e(),!(ke="proto3"===pe)&&"proto2"!==pe)throw we(pe,"syntax");te(";")}function Xe(be,ge){switch(ge){case"option":return ye(be,ge),te(";"),!0;case"message":return pt(be,ge),!0;case"enum":return ie(be,ge),!0;case"service":return function qe(be,ge){if(!x.test(ge=j()))throw we(ge,"service name");var De=new p(ge);Ot(De,function(Be){if(!Xe(De,Be)){if("rpc"!==Be)throw we(Be);!function st(be,ge){var De=Z(),Ue=ge;if(!x.test(ge=j()))throw we(ge,"name");var dt,Pt,vt,et,Be=ge;if(te("("),te("stream",!0)&&(Pt=!0),!M.test(ge=j())||(dt=ge,te(")"),te("returns"),te("("),te("stream",!0)&&(et=!0),!M.test(ge=j())))throw we(ge);vt=ge,te(")");var Pn=new d(Be,Ue,dt,vt,Pt,et);Pn.comment=De,Ot(Pn,function(yn){if("option"!==yn)throw we(yn);ye(Pn,yn),te(";")}),be.add(Pn)}(De,Be)}}),be.add(De)}(be,ge),!0;case"extend":return function nt(be,ge){if(!M.test(ge=j()))throw we(ge,"reference");var De=ge;Ot(null,function(Be){switch(Be){case"required":case"repeated":Dt(be,Be,De);break;case"optional":Dt(be,ke?"proto3_optional":"optional",De);break;default:if(!ke||!M.test(Be))throw we(Be);re(Be),Dt(be,"optional",De)}})}(be,ge),!0}return!1}function Ot(be,ge,De){var Ue=L.line;if(be&&("string"!=typeof be.comment&&(be.comment=Z()),be.filename=F.filename),te("{",!0)){for(var Be;"}"!==(Be=j());)ge(Be);te(";",!0)}else De&&De(),te(";"),be&&("string"!=typeof be.comment||H)&&(be.comment=Z(Ue)||be.comment)}function pt(be,ge){if(!x.test(ge=j()))throw we(ge,"type name");var De=new g(ge);Ot(De,function(Be){if(!Xe(De,Be))switch(Be){case"map":!function Sr(be){te("<");var ge=j();if(void 0===_.mapKey[ge])throw we(ge,"type");te(",");var De=j();if(!M.test(De))throw we(De,"type");te(">");var Ue=j();if(!x.test(Ue))throw we(Ue,"name");te("=");var Be=new w(Pe(Ue),xe(j()),ge,De);Ot(Be,function(Pt){if("option"!==Pt)throw we(Pt);ye(Be,Pt),te(";")},function(){Ye(Be)}),be.add(Be)}(De);break;case"required":case"repeated":Dt(De,Be);break;case"optional":Dt(De,ke?"proto3_optional":"optional");break;case"oneof":!function ni(be,ge){if(!x.test(ge=j()))throw we(ge,"name");var De=new v(Pe(ge));Ot(De,function(Be){"option"===Be?(ye(De,Be),te(";")):(re(Be),Dt(De,"optional"))}),be.add(De)}(De,Be);break;case"extensions":Ee(De.extensions||(De.extensions=[]));break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:if(!ke||!M.test(Be))throw we(Be);re(Be),Dt(De,"optional")}}),be.add(De)}function Dt(be,ge,De){var Ue=j();if("group"!==Ue){if(!M.test(Ue))throw we(Ue,"type");var Be=j();if(!x.test(Be))throw we(Be,"name");Be=Pe(Be),te("=");var dt=new b(Be,xe(j()),Ue,ge,De);if(Ot(dt,function(et){if("option"!==et)throw we(et);ye(dt,et),te(";")},function(){Ye(dt)}),"proto3_optional"===ge){var Pt=new v("_"+Be);dt.setOption("proto3_optional",!0),Pt.add(dt),be.add(Pt)}else be.add(dt);!ke&&dt.repeated&&(void 0!==_.packed[Ue]||void 0===_.basic[Ue])&&dt.setOption("packed",!1,!0)}else!function Wr(be,ge){var De=j();if(!x.test(De))throw we(De,"name");var Ue=I.lcFirst(De);De===Ue&&(De=I.ucFirst(De)),te("=");var Be=xe(j()),dt=new g(De);dt.group=!0;var Pt=new b(Ue,Be,De,ge);Pt.filename=F.filename,Ot(dt,function(et){switch(et){case"option":ye(dt,et),te(";");break;case"required":case"repeated":Dt(dt,et);break;case"optional":Dt(dt,ke?"proto3_optional":"optional");break;case"message":pt(dt,et);break;case"enum":ie(dt,et);break;default:throw we(et)}}),be.add(dt).add(Pt)}(be,ge)}function ie(be,ge){if(!x.test(ge=j()))throw we(ge,"name");var De=new l(ge);Ot(De,function(Be){switch(Be){case"option":ye(De,Be),te(";");break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:!function fe(be,ge){if(!x.test(ge))throw we(ge,"name");te("=");var De=xe(j(),!0),Ue={options:void 0,setOption:function(Be,dt){void 0===this.options&&(this.options={}),this.options[Be]=dt}};Ot(Ue,function(dt){if("option"!==dt)throw we(dt);ye(Ue,dt),te(";")},function(){Ye(Ue)}),be.add(ge,De,Ue.comment,Ue.options)}(De,Be)}}),be.add(De)}function ye(be,ge){var De=te("(",!0);if(!M.test(ge=j()))throw we(ge,"name");var dt,Ue=ge,Be=Ue;De&&(te(")"),Be=Ue="("+Ue+")",ge=$(),B.test(ge)&&(dt=ge.slice(1),Ue+=ge,j())),te("="),function Ne(be,ge,De,Ue){be.setParsedOption&&be.setParsedOption(ge,De,Ue)}(be,Be,me(be,Ue),dt)}function me(be,ge){if(te("{",!0)){for(var De={};!te("}",!0);){if(!x.test(je=j()))throw we(je,"name");var Ue,Be=je;if(te(":",!0),"{"===$())Ue=me(be,ge+"."+je);else if("["===$()){var dt;if(Ue=[],te("[",!0)){do{dt=K(!0),Ue.push(dt)}while(te(",",!0));te("]"),typeof dt<"u"&&_e(be,ge+"."+je,dt)}}else Ue=K(!0),_e(be,ge+"."+je,Ue);var Pt=De[Be];Pt&&(Ue=[].concat(Pt).concat(Ue)),De[Be]=Ue,te(",",!0),te(";",!0)}return De}var vt=K(!0);return _e(be,ge,vt),vt}function _e(be,ge,De){be.setOption&&be.setOption(ge,De)}function Ye(be){if(te("[",!0)){do{ye(be,"option")}while(te(",",!0));te("]")}return be}for(;null!==(je=j());)switch(je){case"package":if(!q)throw we(je);Ke();break;case"import":if(!q)throw we(je);We();break;case"syntax":if(!q)throw we(je);Je();break;case"option":ye(Se,je),te(";");break;default:if(Xe(Se,je)){q=!1;continue}throw we(je)}return F.filename=null,{package:ne,imports:oe,weakImports:de,syntax:pe,root:S}}},7270:(J,G,N)=>{"use strict";J.exports=v;var u,h=N(7211),g=h.LongBits,b=h.utf8;function w(E,y){return RangeError("index out of range: "+E.pos+" + "+(y||1)+" > "+E.len)}function v(E){this.buf=E,this.pos=0,this.len=E.length}var y,l=typeof Uint8Array<"u"?function(y){if(y instanceof Uint8Array||Array.isArray(y))return new v(y);throw Error("illegal buffer")}:function(y){if(Array.isArray(y))return new v(y);throw Error("illegal buffer")},p=function(){return h.Buffer?function(f){return(v.create=function(A){return h.Buffer.isBuffer(A)?new u(A):l(A)})(f)}:l};function d(){var E=new g(0,0),y=0;if(!(this.len-this.pos>4)){for(;y<3;++y){if(this.pos>=this.len)throw w(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*y)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*y)>>>0,E}for(;y<4;++y)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*y)>>>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(y=0,this.len-this.pos>4){for(;y<5;++y)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*y+3)>>>0,this.buf[this.pos++]<128)return E}else for(;y<5;++y){if(this.pos>=this.len)throw w(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*y+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function _(E,y){return(E[y-4]|E[y-3]<<8|E[y-2]<<16|E[y-1]<<24)>>>0}function I(){if(this.pos+8>this.len)throw w(this,8);return new g(_(this.buf,this.pos+=4),_(this.buf,this.pos+=4))}v.create=p(),v.prototype._slice=h.Array.prototype.subarray||h.Array.prototype.slice,v.prototype.uint32=(y=4294967295,function(){if(y=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(y=(y|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(y=(y|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(y=(y|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(y=(y|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return y;if((this.pos+=5)>this.len)throw this.pos=this.len,w(this,10);return y}),v.prototype.int32=function(){return 0|this.uint32()},v.prototype.sint32=function(){var y=this.uint32();return y>>>1^-(1&y)|0},v.prototype.bool=function(){return 0!==this.uint32()},v.prototype.fixed32=function(){if(this.pos+4>this.len)throw w(this,4);return _(this.buf,this.pos+=4)},v.prototype.sfixed32=function(){if(this.pos+4>this.len)throw w(this,4);return 0|_(this.buf,this.pos+=4)},v.prototype.float=function(){if(this.pos+4>this.len)throw w(this,4);var y=h.float.readFloatLE(this.buf,this.pos);return this.pos+=4,y},v.prototype.double=function(){if(this.pos+8>this.len)throw w(this,4);var y=h.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,y},v.prototype.bytes=function(){var y=this.uint32(),f=this.pos,C=this.pos+y;if(C>this.len)throw w(this,y);return this.pos+=y,Array.isArray(this.buf)?this.buf.slice(f,C):f===C?new this.buf.constructor(0):this._slice.call(this.buf,f,C)},v.prototype.string=function(){var y=this.bytes();return b.read(y,0,y.length)},v.prototype.skip=function(y){if("number"==typeof y){if(this.pos+y>this.len)throw w(this,y);this.pos+=y}else do{if(this.pos>=this.len)throw w(this)}while(128&this.buf[this.pos++]);return this},v.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},v._configure=function(E){u=E,v.create=p(),u._configure();var y=h.Long?"toLong":"toNumber";h.merge(v.prototype,{int64:function(){return d.call(this)[y](!1)},uint64:function(){return d.call(this)[y](!0)},sint64:function(){return d.call(this).zzDecode()[y](!1)},fixed64:function(){return I.call(this)[y](!0)},sfixed64:function(){return I.call(this)[y](!1)}})}},4354:(J,G,N)=>{"use strict";J.exports=g;var h=N(7270);(g.prototype=Object.create(h.prototype)).constructor=g;var u=N(7211);function g(b){h.call(this,b)}g._configure=function(){u.Buffer&&(g.prototype._slice=u.Buffer.prototype.slice)},g.prototype.string=function(){var w=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+w,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+w,this.len))},g._configure()},5257:(J,G,N)=>{"use strict";J.exports=d;var h=N(326);((d.prototype=Object.create(h.prototype)).constructor=d).className="Root";var v,l,p,u=N(2986),g=N(4269),b=N(7397),w=N(8572);function d(y){h.call(this,"",y),this.deferred=[],this.files=[]}function _(){}d.fromJSON=function(f,C){return C||(C=new d),f.options&&C.setOptions(f.options),C.addJSON(f.nested)},d.prototype.resolvePath=w.path.resolve,d.prototype.fetch=w.fetch,d.prototype.load=function y(f,C,A){"function"==typeof C&&(A=C,C=void 0);var P=this;if(!A)return w.asPromise(y,P,f,C);var D=A===_;function x(H,L){if(A){var j=A;if(A=null,D)throw H;j(H,L)}}function M(H){var L=H.lastIndexOf("google/protobuf/");if(L>-1){var j=H.substring(L);if(j in p)return j}return null}function B(H,L){try{if(w.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),w.isString(L)){l.filename=H;var re,j=l(L,P,C),$=0;if(j.imports)for(;$-1)){if(P.files.push(H),H in p)return void(D?B(H,p[H]):(++z,setTimeout(function(){--z,B(H,p[H])})));if(D){var j;try{j=w.fs.readFileSync(H).toString("utf8")}catch(re){return void(L||x(re))}B(H,j)}else++z,P.fetch(H,function(re,$){if(--z,A){if(re)return void(L?z||x(null,P):x(re));B(H,$)}})}}var z=0;w.isString(f)&&(f=[f]);for(var O,S=0;S-1&&this.deferred.splice(C,1)}}else if(f instanceof g)I.test(f.name)&&delete f.parent[f.name];else if(f instanceof h){for(var A=0;A{"use strict";J.exports={}},7830:(J,G,N)=>{"use strict";G.Service=N(6346)},6346:(J,G,N)=>{"use strict";J.exports=u;var h=N(7211);function u(g,b,w){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");h.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(b),this.responseDelimited=Boolean(w)}(u.prototype=Object.create(h.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function g(b,w,v,l,p){if(!l)throw TypeError("request must be specified");var d=this;if(!p)return h.asPromise(g,d,b,w,v,l);if(d.rpcImpl)try{return d.rpcImpl(b,w[d.requestDelimited?"encodeDelimited":"encode"](l).finish(),function(I,E){if(I)return d.emit("error",I,b),p(I);if(null!==E){if(!(E instanceof v))try{E=v[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(y){return d.emit("error",y,b),p(y)}return d.emit("data",E,b),p(null,E)}d.end(!0)})}catch(_){return d.emit("error",_,b),void setTimeout(function(){p(_)},0)}else setTimeout(function(){p(Error("already ended"))},0)},u.prototype.end=function(b){return this.rpcImpl&&(b||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},9630:(J,G,N)=>{"use strict";J.exports=w;var h=N(326);((w.prototype=Object.create(h.prototype)).constructor=w).className="Service";var u=N(1618),g=N(8572),b=N(7830);function w(l,p){h.call(this,l,p),this.methods={},this._methodsArray=null}function v(l){return l._methodsArray=null,l}w.fromJSON=function(p,d){var _=new w(p,d.options);if(d.methods)for(var I=Object.keys(d.methods),E=0;E{"use strict";J.exports=d;var G=/[\s{}=;:[\],'"()<>]/g,N=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,h=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,u=/^ *[*/]+ */,g=/^\s*\*?\/*/,b=/\n/g,w=/\s/,v=/\\(.?)/g,l={0:"\0",r:"\r",n:"\n",t:"\t"};function p(_){return _.replace(v,function(I,E){switch(E){case"\\":case"":return E;default:return l[E]||""}})}function d(_,I){_=_.toString();var E=0,y=_.length,f=1,C=0,A={},P=[],D=null;function x($){return Error("illegal "+$+" (line "+f+")")}function B($){return _.charAt($)}function F($,te,Z){var de,q={type:_.charAt($++),lineEmpty:!1,leading:Z},oe=$-(I?2:3);do{if(--oe<0||"\n"===(de=_.charAt(oe))){q.lineEmpty=!0;break}}while(" "===de||"\t"===de);for(var pe=_.substring($,te).split(b),ke=0;ke0)return P.shift();if(D)return function M(){var $="'"===D?h:N;$.lastIndex=E-1;var te=$.exec(_);if(!te)throw x("string");return E=$.lastIndex,H(D),D=null,p(te[1])}();var $,te,Z,q,ne,oe=0===E;do{if(E===y)return null;for($=!1;w.test(Z=B(E));)if("\n"===Z&&(oe=!0,++f),++E===y)return null;if("/"===B(E)){if(++E===y)throw x("comment");if("/"===B(E))if(I){if(q=E,ne=!1,z(E)){ne=!0;do{if((E=S(E))===y||(E++,!oe))break}while(z(E))}else E=Math.min(y,S(E)+1);ne&&(F(q,E,oe),oe=!0),f++,$=!0}else{for(ne="/"===B(q=E+1);"\n"!==B(++E);)if(E===y)return null;++E,ne&&(F(q,E-1,oe),oe=!0),++f,$=!0}else{if("*"!==(Z=B(E)))return"/";q=E+1,ne=I||"*"===B(q);do{if("\n"===Z&&++f,++E===y)throw x("comment");te=Z,Z=B(E)}while("*"!==te||"/"!==Z);++E,ne&&(F(q,E-2,oe),oe=!0),$=!0}}}while($);var de=E;if(G.lastIndex=0,!G.test(B(de++)))for(;de{"use strict";J.exports=A;var h=N(326);((A.prototype=Object.create(h.prototype)).constructor=A).className="Type";var u=N(4269),g=N(7397),b=N(2986),w=N(9455),v=N(9630),l=N(1413),p=N(7270),d=N(1650),_=N(8572),I=N(133),E=N(225),y=N(8617),f=N(6533),C=N(761);function A(D,x){h.call(this,D,x),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),x=0;x{"use strict";var h=G,u=N(8572),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function b(w,v){var l=0,p={};for(v|=0;l{"use strict";var g,b,h=J.exports=N(7211),u=N(6671);h.codegen=N(9749),h.fetch=N(8832),h.path=N(1311),h.fs=h.inquire("fs"),h.toArray=function(_){if(_){for(var I=Object.keys(_),E=new Array(I.length),y=0;y0)f[P]=y(f[P]||{},C,A);else{var D=f[P];D&&(A=[].concat(D).concat(A)),f[P]=A}return f}(_,I=I.split("."),E)},Object.defineProperty(h,"decorateRoot",{get:function(){return u.decorated||(u.decorated=new(N(5257)))}})},942:(J,G,N)=>{"use strict";J.exports=u;var h=N(7211);function u(v,l){this.lo=v>>>0,this.hi=l>>>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 b=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(l){if(0===l)return g;var p=l<0;p&&(l=-l);var d=l>>>0,_=(l-d)/4294967296>>>0;return p&&(_=~_>>>0,d=~d>>>0,++d>4294967295&&(d=0,++_>4294967295&&(_=0))),new u(d,_)},u.from=function(l){if("number"==typeof l)return u.fromNumber(l);if(h.isString(l)){if(!h.Long)return u.fromNumber(parseInt(l,10));l=h.Long.fromString(l)}return l.low||l.high?new u(l.low>>>0,l.high>>>0):g},u.prototype.toNumber=function(l){if(!l&&this.hi>>>31){var p=1+~this.lo>>>0,d=~this.hi>>>0;return p||(d=d+1>>>0),-(p+4294967296*d)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(l){return h.Long?new h.Long(0|this.lo,0|this.hi,Boolean(l)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(l)}};var w=String.prototype.charCodeAt;u.fromHash=function(l){return l===b?g:new u((w.call(l,0)|w.call(l,1)<<8|w.call(l,2)<<16|w.call(l,3)<<24)>>>0,(w.call(l,4)|w.call(l,5)<<8|w.call(l,6)<<16|w.call(l,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 l=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^l)>>>0,this.lo=(this.lo<<1^l)>>>0,this},u.prototype.zzDecode=function(){var l=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^l)>>>0,this.hi=(this.hi>>>1^l)>>>0,this},u.prototype.length=function(){var l=this.lo,p=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===p?l<16384?l<128?1:2:l<2097152?3:4:p<16384?p<128?5:6:p<2097152?7:8:d<128?9:10}},7211:function(J,G,N){"use strict";var h=G;function u(b,w,v){for(var l=Object.keys(w),p=0;pb,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),w}h.asPromise=N(1280),h.base64=N(9039),h.EventEmitter=N(9889),h.float=N(530),h.inquire=N(716),h.utf8=N(7768),h.pool=N(4479),h.LongBits=N(942),h.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),h.global=h.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,h.emptyArray=Object.freeze?Object.freeze([]):[],h.emptyObject=Object.freeze?Object.freeze({}):{},h.isInteger=Number.isInteger||function(w){return"number"==typeof w&&isFinite(w)&&Math.floor(w)===w},h.isString=function(w){return"string"==typeof w||w instanceof String},h.isObject=function(w){return w&&"object"==typeof w},h.isset=h.isSet=function(w,v){var l=w[v];return!(null==l||!w.hasOwnProperty(v))&&("object"!=typeof l||(Array.isArray(l)?l.length:Object.keys(l).length)>0)},h.Buffer=function(){try{var b=h.inquire("buffer").Buffer;return b.prototype.utf8Write?b:null}catch{return null}}(),h._Buffer_from=null,h._Buffer_allocUnsafe=null,h.newBuffer=function(w){return"number"==typeof w?h.Buffer?h._Buffer_allocUnsafe(w):new h.Array(w):h.Buffer?h._Buffer_from(w):typeof Uint8Array>"u"?w:new Uint8Array(w)},h.Array=typeof Uint8Array<"u"?Uint8Array:Array,h.Long=h.global.dcodeIO&&h.global.dcodeIO.Long||h.global.Long||h.inquire("long"),h.key2Re=/^true|false|0|1$/,h.key32Re=/^-?(?:0|[1-9][0-9]*)$/,h.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,h.longToHash=function(w){return w?h.LongBits.from(w).toHash():h.LongBits.zeroHash},h.longFromHash=function(w,v){var l=h.LongBits.fromHash(w);return h.Long?h.Long.fromBits(l.lo,l.hi,v):l.toNumber(Boolean(v))},h.merge=u,h.lcFirst=function(w){return w.charAt(0).toLowerCase()+w.substring(1)},h.newError=g,h.ProtocolError=g("ProtocolError"),h.oneOfGetter=function(w){for(var v={},l=0;l-1;--d)if(1===v[p[d]]&&null!=this[p[d]])return p[d]}},h.oneOfSetter=function(w){return function(v){for(var l=0;l{"use strict";J.exports=function v(l){var p=u.codegen(["m"],l.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),_={};l.oneofsArray.length&&p("var p={}");for(var I=0;I{"use strict";var h=G,u=N(1413);h[".google.protobuf.Any"]={fromObject:function(g){if(g&&g["@type"]){var b=g["@type"].substring(g["@type"].lastIndexOf("/")+1),w=this.lookup(b);if(w){var v="."===g["@type"].charAt(0)?g["@type"].slice(1):g["@type"];return-1===v.indexOf("/")&&(v="/"+v),this.create({type_url:v,value:w.encode(w.fromObject(g)).finish()})}}return this.fromObject(g)},toObject:function(g,b){var v="",l="";if(b&&b.json&&g.type_url&&g.value){l=g.type_url.substring(g.type_url.lastIndexOf("/")+1),v=g.type_url.substring(0,g.type_url.lastIndexOf("/")+1);var p=this.lookup(l);p&&(g=p.decode(g.value))}if(!(g instanceof this.ctor)&&g instanceof u){var d=g.$type.toObject(g,b),_="."===g.$type.fullName[0]?g.$type.fullName.slice(1):g.$type.fullName;return""===v&&(v="type.googleapis.com/"),d["@type"]=l=v+_,d}return this.toObject(g,b)}}},1650:(J,G,N)=>{"use strict";J.exports=d;var u,h=N(7211),g=h.LongBits,b=h.base64,w=h.utf8;function v(P,D,x){this.fn=P,this.len=D,this.next=void 0,this.val=x}function l(){}function p(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 v(l,0,0),this.tail=this.head,this.states=null}var _=function(){return h.Buffer?function(){return(d.create=function(){return new u})()}:function(){return new d}};function I(P,D,x){D[x]=255&P}function y(P,D){this.len=P,this.next=void 0,this.val=D}function f(P,D,x){for(;P.hi;)D[x++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[x++]=127&P.lo|128,P.lo=P.lo>>>7;D[x++]=P.lo}function C(P,D,x){D[x]=255&P,D[x+1]=P>>>8&255,D[x+2]=P>>>16&255,D[x+3]=P>>>24}d.create=_(),d.alloc=function(D){return new h.Array(D)},h.Array!==Array&&(d.alloc=h.pool(d.alloc,h.Array.prototype.subarray)),d.prototype._push=function(D,x,M){return this.tail=this.tail.next=new v(D,x,M),this.len+=x,this},(y.prototype=Object.create(v.prototype)).fn=function E(P,D,x){for(;P>127;)D[x++]=127&P|128,P>>>=7;D[x]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new y((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(f,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 x=g.from(D);return this._push(f,x.length(),x)},d.prototype.sint64=function(D){var x=g.from(D).zzEncode();return this._push(f,x.length(),x)},d.prototype.bool=function(D){return this._push(I,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(C,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var x=g.from(D);return this._push(C,4,x.lo)._push(C,4,x.hi)},d.prototype.float=function(D){return this._push(h.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(h.float.writeDoubleLE,8,D)};var A=h.Array.prototype.set?function(D,x,M){x.set(D,M)}:function(D,x,M){for(var B=0;B>>0;if(!x)return this._push(I,1,0);if(h.isString(D)){var M=d.alloc(x=b.length(D));b.decode(D,M,0),D=M}return this.uint32(x)._push(A,x,D)},d.prototype.string=function(D){var x=w.length(D);return x?this.uint32(x)._push(w.write,x,D):this._push(I,1,0)},d.prototype.fork=function(){return this.states=new p(this),this.head=this.tail=new v(l,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 v(l,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,x=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=x,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,x=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,x,M),M+=D.len,D=D.next;return x},d._configure=function(P){u=P,d.create=_(),u._configure()}},813:(J,G,N)=>{"use strict";J.exports=g;var h=N(1650);(g.prototype=Object.create(h.prototype)).constructor=g;var u=N(7211);function g(){h.call(this)}function b(w,v,l){w.length<40?u.utf8.write(w,v,l):v.utf8Write?v.utf8Write(w,l):v.write(w,l)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(v,l,p){l.set(v,p)}:function(v,l,p){if(v.copy)v.copy(l,p,0,v.length);else for(var d=0;d>>0;return this.uint32(l),l&&this._push(g.writeBytesBuffer,l,v),this},g.prototype.string=function(v){var l=u.Buffer.byteLength(v);return this.uint32(l),l&&this._push(b,l,v),this},g._configure()},4033:(J,G,N)=>{"use strict";J.exports=w;var h=N(4366),u=w.prototype,g=new Date%1e9;function w(v){this.id=(v=v||{}).id||function b(){return(1e9*Math.random()>>>0)+g++}(),this.max=v.max||1/0,this.items=v.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(v.lastModified||new Date);for(var l,p,d=this.items.length;d--;)l=this.items[d],p=new Date(l.expires)-new Date,this._lookup[l.key]=l,p>0?this.expire(l.key,p):p<=0&&this.delete(l.key)}u.has=function(v){return v in this._lookup},u.get=function(v){if(!this.has(v))return null;var l=this._lookup[v];return l.refresh&&this.expire(v,l.refresh),this.items.splice(this.items.indexOf(l),1),this.items.push(l),l.value},u.meta=function(v){if(!this.has(v))return null;var l=this._lookup[v];return"meta"in l?l.meta:null},u.set=function(v,l,p){var d=this._lookup[v],_=this._lookup[v]={key:v,value:l};return this.lastModified=new Date,d?(clearTimeout(d.timeout),this.items.splice(this.items.indexOf(d),1,_)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(_),this.size++),p&&("ttl"in p&&this.expire(v,p.ttl),"meta"in p&&(_.meta=p.meta),p.refresh&&(_.refresh=p.ttl)),this},u.delete=function(v){var l=this._lookup[v];return!!l&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(l),1),clearTimeout(l.timeout),delete this._lookup[v],this.size--,this)},u.expire=function(v,l){var p=l||0,d=this._lookup[v];if(!d)return this;if("string"==typeof p&&(p=h(l)),"number"!=typeof p)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(d.timeout),d.timeout=setTimeout(this.delete.bind(this,d.key),p),d.expires=Number(new Date)+p,this},u.clear=function(){for(var v=this.items.length;v--;)this.delete(this.items[v].key);return this},u.toJSON=function(){for(var l,v=new Array(this.items.length),p=v.length;p--;)v[p]={key:(l=this.items[p]).key,meta:l.meta,value:l.value,expires:l.expires,refresh:l.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:v}}},2502:(J,G,N)=>{"use strict";const h=N(7806);class u{constructor(w,v,l){const p=this;this._started=h(),this._rescheduled=0,this._scheduled=v,this._args=l,this._triggered=!1,this._timerWrapper=()=>{p._rescheduled>0?(p._scheduled=p._rescheduled-(h()-p._started),p._schedule(p._scheduled)):(p._triggered=!0,w.apply(null,p._args))},this._timer=setTimeout(this._timerWrapper,v)}reschedule(w){w||(w=this._scheduled);const v=h();v+w-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(w)):this._triggered?this._schedule(w):(this._started=v,this._rescheduled=w)}_schedule(w){this._triggered=!1,this._started=h(),this._rescheduled=0,this._scheduled=w,this._timer=setTimeout(this._timerWrapper,w)}clear(){clearTimeout(this._timer)}}J.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let b;if(arguments.length>0){b=new Array(arguments.length-2);for(var w=0;w{"use strict";J.exports=function(){return Date.now()}},9014:(J,G,N)=>{"use strict";var h=N(9942),u=/[\/\?<>\\:\*\|"]/g,g=/[\x00-\x1f\x80-\x9f]/g,b=/^\.+$/,w=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,v=/[\. ]+$/;function l(p,d){if("string"!=typeof p)throw new Error("Input must be string");var _=p.replace(u,d).replace(g,d).replace(b,d).replace(w,d).replace(v,d);return h(_,255)}J.exports=function(p,d){var _=d&&d.replacement||"",I=l(p,_);return""===_?I:l(I,"")}},1466:(J,G,N)=>{"use strict";var h=N(7156).default;const u=new Map;function w(){return(w=h(function*(p,d,_){for(;u.get(_);){try{yield p()}catch(I){setTimeout(()=>{throw I},1);break}if(!u.get(_))break;yield new Promise(I=>{const E=setTimeout(I,d);u.set(_,E)})}})).apply(this,arguments)}J.exports={setDelayedInterval:function v(p,d,_){_=_||d;const I=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function b(p,d,_){w.apply(this,arguments)}(p,d,I)},_);return u.set(I,E),I},clearDelayedInterval:function l(p){const d=u.get(p);d&&(clearTimeout(d),u.delete(p))}}},1420:(J,G,N)=>{"use strict";const{AbortController:h}=globalThis,u=N(2502);class g extends h{constructor(w){super(),this._ms=w,this._timer=u(()=>this.abort(),w),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)}}J.exports={TimeoutController:g}},9942:(J,G,N)=>{"use strict";var h=N(8831),u=N(8871);J.exports=h.bind(null,u)},8831:J=>{"use strict";function N(h){return h>=56320&&h<=57343}J.exports=function(u,g,b){if("string"!=typeof g)throw new Error("Input must be string");for(var l,p,w=g.length,v=0,d=0;d=55296&&h<=56319&&N(g.charCodeAt(d+1))&&(p+=g[d+=1]),(v+=u(p))===b)return g.slice(0,d+1);if(v>b)return g.slice(0,d-p.length+1)}var h;return g}},8871:J=>{"use strict";function G(h){return h>=55296&&h<=56319}J.exports=function(u){if("string"!=typeof u)throw new Error("Input must be string");for(var g=u.length,b=0,w=null,v=null,l=0;l=56320&&h<=57343?null!=v&&G(v)?b+=1:b+=3:w<=127?b+=1:w>=128&&w<=2047?b+=2:w>=2048&&w<=65535&&(b+=3),v=w;var h;return b}},3004:J=>{J.exports=function h(u,w){var p,b=0,v=0,l=w=w||0,d=u.length;do{if(l>=d||v>49)throw h.bytes=0,new RangeError("Could not decode varint");p=u[l++],b+=v<28?(127&p)<=128);return h.bytes=l-w,b}},5723:J=>{J.exports=function g(b,w,v){if(Number.MAX_SAFE_INTEGER&&b>Number.MAX_SAFE_INTEGER)throw g.bytes=0,new RangeError("Could not encode varint");w=w||[];for(var l=v=v||0;b>=u;)w[v++]=255&b|128,b/=128;for(;-128&b;)w[v++]=255&b|128,b>>>=7;return w[v]=0|b,g.bytes=v-l+1,w};var u=Math.pow(2,31)},1732:(J,G,N)=>{J.exports={encode:N(5723),decode:N(3004),encodingLength:N(4036)}},4036:J=>{var G=Math.pow(2,7),N=Math.pow(2,14),h=Math.pow(2,21),u=Math.pow(2,28),g=Math.pow(2,35),b=Math.pow(2,42),w=Math.pow(2,49),v=Math.pow(2,56),l=Math.pow(2,63);J.exports=function(p){return p{"use strict";!function(ie){const fe=ie.performance;function ye(Ft){fe&&fe.mark&&fe.mark(Ft)}function me(Ft,ut){fe&&fe.measure&&fe.measure(Ft,ut)}ye("Zone");const _e=ie.__Zone_symbol_prefix||"__zone_symbol__";function Ne(Ft){return _e+Ft}const Ye=!0===ie[Ne("forceDuplicateZoneCheck")];if(ie.Zone){if(Ye||"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!==Hr.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 bn.zone}static get currentTask(){return vr}static __load_patch(ce,ve,yt=!1){if(Hr.hasOwnProperty(ce)){if(!yt&&Ye)throw Error("Already loaded patch: "+ce)}else if(!ie["__Zone_disable_"+ce]){const St="Zone:"+ce;ye(St),Hr[ce]=ve(ie,Ft,Fn),me(St,St)}}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 yt=this._zoneDelegate.intercept(this,ce,ve),St=this;return function(){return St.runGuarded(yt,this,arguments,ve)}}run(ce,ve,yt,St){bn={parent:bn,zone:this};try{return this._zoneDelegate.invoke(this,ce,ve,yt,St)}finally{bn=bn.parent}}runGuarded(ce,ve=null,yt,St){bn={parent:bn,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,ve,yt,St)}catch(mn){if(this._zoneDelegate.handleError(this,mn))throw mn}}finally{bn=bn.parent}}runTask(ce,ve,yt){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||Pn).name+"; Execution: "+this.name+")");if(ce.state===Bt&&(ce.type===lr||ce.type===bt))return;const St=ce.state!=ft;St&&ce._transitionTo(ft,tn),ce.runCount++;const mn=vr;vr=ce,bn={parent:bn,zone:this};try{ce.type==bt&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,ve,yt)}catch(Ge){if(this._zoneDelegate.handleError(this,Ge))throw Ge}}finally{ce.state!==Bt&&ce.state!==ot&&(ce.type==lr||ce.data&&ce.data.isPeriodic?St&&ce._transitionTo(tn,ft):(ce.runCount=0,this._updateTaskCount(ce,-1),St&&ce._transitionTo(Bt,ft,Bt))),bn=bn.parent,vr=mn}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let yt=this;for(;yt;){if(yt===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);yt=yt.parent}}ce._transitionTo(yn,Bt);const ve=[];ce._zoneDelegates=ve,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(yt){throw ce._transitionTo(ot,yn,Bt),this._zoneDelegate.handleError(this,yt),yt}return ce._zoneDelegates===ve&&this._updateTaskCount(ce,1),ce.state==yn&&ce._transitionTo(tn,yn),ce}scheduleMicroTask(ce,ve,yt,St){return this.scheduleTask(new je(Kt,ce,ve,yt,St,void 0))}scheduleMacroTask(ce,ve,yt,St,mn){return this.scheduleTask(new je(bt,ce,ve,yt,St,mn))}scheduleEventTask(ce,ve,yt,St,mn){return this.scheduleTask(new je(lr,ce,ve,yt,St,mn))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||Pn).name+"; Execution: "+this.name+")");ce._transitionTo(hn,tn,ft);try{this._zoneDelegate.cancelTask(this,ce)}catch(ve){throw ce._transitionTo(ot,hn),this._zoneDelegate.handleError(this,ve),ve}return this._updateTaskCount(ce,-1),ce._transitionTo(Bt,hn),ce.runCount=0,ce}_updateTaskCount(ce,ve){const yt=ce._zoneDelegates;-1==ve&&(ce._zoneDelegates=null);for(let St=0;StFt.hasTask(ce,ve),onScheduleTask:(Ft,ut,ce,ve)=>Ft.scheduleTask(ce,ve),onInvokeTask:(Ft,ut,ce,ve,yt,St)=>Ft.invokeTask(ce,ve,yt,St),onCancelTask:(Ft,ut,ce,ve)=>Ft.cancelTask(ce,ve)};class nt{constructor(ut,ce,ve){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=ut,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 yt=ve&&ve.onHasTask;(yt||ce&&ce._hasTaskZS)&&(this._hasTaskZS=yt?ve:st,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=ut,ve.onScheduleTask||(this._scheduleTaskZS=st,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),ve.onInvokeTask||(this._invokeTaskZS=st,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),ve.onCancelTask||(this._cancelTaskZS=st,this._cancelTaskDlgt=ce,this._cancelTaskCurrZone=this.zone))}fork(ut,ce){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,ut,ce):new qe(ut,ce)}intercept(ut,ce,ve){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,ut,ce,ve):ce}invoke(ut,ce,ve,yt,St){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,ut,ce,ve,yt,St):ce.apply(ve,yt)}handleError(ut,ce){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,ut,ce)}scheduleTask(ut,ce){let ve=ce;if(this._scheduleTaskZS)this._hasTaskZS&&ve._zoneDelegates.push(this._hasTaskDlgtOwner),ve=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,ut,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(ut,ce,ve,yt){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,ut,ce,ve,yt):ce.callback.apply(ve,yt)}cancelTask(ut,ce){let ve;if(this._cancelTaskZS)ve=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,ut,ce);else{if(!ce.cancelFn)throw Error("Task is not cancelable");ve=ce.cancelFn(ce)}return ve}hasTask(ut,ce){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,ut,ce)}catch(ve){this.handleError(ut,ve)}}_updateTaskCount(ut,ce){const ve=this._taskCounts,yt=ve[ut],St=ve[ut]=yt+ce;if(St<0)throw new Error("More tasks executed then were scheduled.");0!=yt&&0!=St||this.hasTask(this.zone,{microTask:ve.microTask>0,macroTask:ve.macroTask>0,eventTask:ve.eventTask>0,change:ut})}}class je{constructor(ut,ce,ve,yt,St,mn){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=ut,this.source=ce,this.data=yt,this.scheduleFn=St,this.cancelFn=mn,!ve)throw new Error("callback is not defined");this.callback=ve;const Ge=this;this.invoke=ut===lr&&yt&&yt.useG?je.invokeTask:function(){return je.invokeTask.call(ie,Ge,this,arguments)}}static invokeTask(ut,ce,ve){ut||(ut=this),rr++;try{return ut.runCount++,ut.zone.runTask(ut,ce,ve)}finally{1==rr&&et(),rr--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(Bt,yn)}_transitionTo(ut,ce,ve){if(this._state!==ce&&this._state!==ve)throw new Error(`${this.type} '${this.source}': can not transition to '${ut}', expecting state '${ce}'${ve?" or '"+ve+"'":""}, was '${this._state}'.`);this._state=ut,ut==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 be=Ne("setTimeout"),ge=Ne("Promise"),De=Ne("then");let dt,Ue=[],Be=!1;function Pt(Ft){if(dt||ie[ge]&&(dt=ie[ge].resolve(0)),dt){let ut=dt[De];ut||(ut=dt.then),ut.call(dt,Ft)}else ie[be](Ft,0)}function vt(Ft){0===rr&&0===Ue.length&&Pt(et),Ft&&Ue.push(Ft)}function et(){if(!Be){for(Be=!0;Ue.length;){const Ft=Ue;Ue=[];for(let ut=0;utbn,onUnhandledError:_n,microtaskDrainDone:_n,scheduleMicroTask:vt,showUncaughtError:()=>!qe[Ne("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:_n,patchMethod:()=>_n,bindArguments:()=>[],patchThen:()=>_n,patchMacroTask:()=>_n,patchEventPrototype:()=>_n,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>_n,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>_n,wrapWithCurrentZone:()=>_n,filterProperties:()=>[],attachOriginToPatched:()=>_n,_redefineProperty:()=>_n,patchCallbacks:()=>_n,nativeScheduleMicroTask:Pt};let bn={parent:null,zone:new qe(null,null)},vr=null,rr=0;function _n(){}me("Zone","Zone"),ie.Zone=qe}(typeof window<"u"&&window||typeof self<"u"&&self||global);const J=Object.getOwnPropertyDescriptor,G=Object.defineProperty,N=Object.getPrototypeOf,h=Object.create,u=Array.prototype.slice,g="addEventListener",b="removeEventListener",w=Zone.__symbol__(g),v=Zone.__symbol__(b),l="true",p="false",d=Zone.__symbol__("");function _(ie,fe){return Zone.current.wrap(ie,fe)}function I(ie,fe,ye,me,_e){return Zone.current.scheduleMacroTask(ie,fe,ye,me,_e)}const E=Zone.__symbol__,y=typeof window<"u",f=y?window:void 0,C=y&&f||"object"==typeof self&&self||global;function P(ie,fe){for(let ye=ie.length-1;ye>=0;ye--)"function"==typeof ie[ye]&&(ie[ye]=_(ie[ye],fe+"_"+ye));return ie}function x(ie){return!ie||!1!==ie.writable&&!("function"==typeof ie.get&&typeof ie.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,B=!("nw"in C)&&typeof C.process<"u"&&"[object process]"==={}.toString.call(C.process),F=!B&&!M&&!(!y||!f.HTMLElement),z=typeof C.process<"u"&&"[object process]"==={}.toString.call(C.process)&&!M&&!(!y||!f.HTMLElement),S={},O=function(ie){if(!(ie=ie||C.event))return;let fe=S[ie.type];fe||(fe=S[ie.type]=E("ON_PROPERTY"+ie.type));const ye=this||ie.target||C,me=ye[fe];let _e;if(F&&ye===f&&"error"===ie.type){const Ne=ie;_e=me&&me.call(this,Ne.message,Ne.filename,Ne.lineno,Ne.colno,Ne.error),!0===_e&&ie.preventDefault()}else _e=me&&me.apply(this,arguments),null!=_e&&!_e&&ie.preventDefault();return _e};function H(ie,fe,ye){let me=J(ie,fe);if(!me&&ye&&J(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 Ne=me.get,Ye=me.set,qe=fe.slice(2);let st=S[qe];st||(st=S[qe]=E("ON_PROPERTY"+qe)),me.set=function(nt){let je=this;!je&&ie===C&&(je=C),je&&("function"==typeof je[st]&&je.removeEventListener(qe,O),Ye&&Ye.call(je,null),je[st]=nt,"function"==typeof nt&&je.addEventListener(qe,O,!1))},me.get=function(){let nt=this;if(!nt&&ie===C&&(nt=C),!nt)return null;const je=nt[st];if(je)return je;if(Ne){let be=Ne.call(this);if(be)return me.set.call(this,be),"function"==typeof nt.removeAttribute&&nt.removeAttribute(fe),be}return null},G(ie,fe,me),ie[_e]=!0}function L(ie,fe,ye){if(fe)for(let me=0;mefunction(Ye,qe){const st=ye(Ye,qe);return st.cbIdx>=0&&"function"==typeof qe[st.cbIdx]?I(st.name,qe[st.cbIdx],st,_e):Ne.apply(Ye,qe)})}function Z(ie,fe){ie[E("OriginalDelegate")]=fe}let q=!1,ne=!1;function de(){if(q)return ne;q=!0;try{const ie=f.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,Ye=ye.symbol,qe=[],st=!0===ie[Ye("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],nt=Ye("Promise"),je=Ye("then");ye.onUnhandledError=Ge=>{if(ye.showUncaughtError()){const Qe=Ge&&Ge.rejection;Qe?console.error("Unhandled Promise rejection:",Qe instanceof Error?Qe.message:Qe,"; Zone:",Ge.zone.name,"; Task:",Ge.task&&Ge.task.source,"; Value:",Qe,Qe instanceof Error?Qe.stack:void 0):console.error(Ge)}},ye.microtaskDrainDone=()=>{for(;qe.length;){const Ge=qe.shift();try{Ge.zone.runGuarded(()=>{throw Ge.throwOriginal?Ge.rejection:Ge})}catch(Qe){De(Qe)}}};const ge=Ye("unhandledPromiseRejectionHandler");function De(Ge){ye.onUnhandledError(Ge);try{const Qe=fe[ge];"function"==typeof Qe&&Qe.call(this,Ge)}catch{}}function Ue(Ge){return Ge&&Ge.then}function Be(Ge){return Ge}function dt(Ge){return ce.reject(Ge)}const Pt=Ye("state"),vt=Ye("value"),et=Ye("finally"),Pn=Ye("parentPromiseValue"),Bt=Ye("parentPromiseState"),tn=null,hn=!1;function Kt(Ge,Qe){return Te=>{try{Fn(Ge,Qe,Te)}catch(ze){Fn(Ge,!1,ze)}}}const bt=function(){let Ge=!1;return function(Te){return function(){Ge||(Ge=!0,Te.apply(null,arguments))}}},Hr=Ye("currentTaskTrace");function Fn(Ge,Qe,Te){const ze=bt();if(Ge===Te)throw new TypeError("Promise resolved with itself");if(Ge[Pt]===tn){let ht=null;try{("object"==typeof Te||"function"==typeof Te)&&(ht=Te&&Te.then)}catch(Et){return ze(()=>{Fn(Ge,!1,Et)})(),Ge}if(Qe!==hn&&Te instanceof ce&&Te.hasOwnProperty(Pt)&&Te.hasOwnProperty(vt)&&Te[Pt]!==tn)vr(Te),Fn(Ge,Te[Pt],Te[vt]);else if(Qe!==hn&&"function"==typeof ht)try{ht.call(Te,ze(Kt(Ge,Qe)),ze(Kt(Ge,!1)))}catch(Et){ze(()=>{Fn(Ge,!1,Et)})()}else{Ge[Pt]=Qe;const Et=Ge[vt];if(Ge[vt]=Te,Ge[et]===et&&!0===Qe&&(Ge[Pt]=Ge[Bt],Ge[vt]=Ge[Pn]),Qe===hn&&Te instanceof Error){const lt=fe.currentTask&&fe.currentTask.data&&fe.currentTask.data.__creationTrace__;lt&&_e(Te,Hr,{configurable:!0,enumerable:!1,writable:!0,value:lt})}for(let lt=0;lt{try{const It=Ge[vt],jt=!!Te&&et===Te[et];jt&&(Te[Pn]=It,Te[Bt]=Et);const Ut=Qe.run(lt,void 0,jt&<!==dt&<!==Be?[]:[It]);Fn(Te,!0,Ut)}catch(It){Fn(Te,!1,It)}},Te)}const Ft=function(){},ut=ie.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Qe){return Fn(new this(null),!0,Qe)}static reject(Qe){return Fn(new this(null),hn,Qe)}static any(Qe){if(!Qe||"function"!=typeof Qe[Symbol.iterator])return Promise.reject(new ut([],"All promises were rejected"));const Te=[];let ze=0;try{for(let lt of Qe)ze++,Te.push(ce.resolve(lt))}catch{return Promise.reject(new ut([],"All promises were rejected"))}if(0===ze)return Promise.reject(new ut([],"All promises were rejected"));let ht=!1;const Et=[];return new ce((lt,It)=>{for(let jt=0;jt{ht||(ht=!0,lt(Ut))},Ut=>{Et.push(Ut),ze--,0===ze&&(ht=!0,It(new ut(Et,"All promises were rejected")))})})}static race(Qe){let Te,ze,ht=new this((It,jt)=>{Te=It,ze=jt});function Et(It){Te(It)}function lt(It){ze(It)}for(let It of Qe)Ue(It)||(It=this.resolve(It)),It.then(Et,lt);return ht}static all(Qe){return ce.allWithCallback(Qe)}static allSettled(Qe){return(this&&this.prototype instanceof ce?this:ce).allWithCallback(Qe,{thenCallback:ze=>({status:"fulfilled",value:ze}),errorCallback:ze=>({status:"rejected",reason:ze})})}static allWithCallback(Qe,Te){let ze,ht,Et=new this((Ut,Nn)=>{ze=Ut,ht=Nn}),lt=2,It=0;const jt=[];for(let Ut of Qe){Ue(Ut)||(Ut=this.resolve(Ut));const Nn=It;try{Ut.then(Tn=>{jt[Nn]=Te?Te.thenCallback(Tn):Tn,lt--,0===lt&&ze(jt)},Tn=>{Te?(jt[Nn]=Te.errorCallback(Tn),lt--,0===lt&&ze(jt)):ht(Tn)})}catch(Tn){ht(Tn)}lt++,It++}return lt-=2,0===lt&&ze(jt),Et}constructor(Qe){const Te=this;if(!(Te instanceof ce))throw new Error("Must be an instanceof Promise.");Te[Pt]=tn,Te[vt]=[];try{const ze=bt();Qe&&Qe(ze(Kt(Te,!0)),ze(Kt(Te,hn)))}catch(ze){Fn(Te,!1,ze)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return ce}then(Qe,Te){var ze;let ht=null===(ze=this.constructor)||void 0===ze?void 0:ze[Symbol.species];(!ht||"function"!=typeof ht)&&(ht=this.constructor||ce);const Et=new ht(Ft),lt=fe.current;return this[Pt]==tn?this[vt].push(lt,Et,Qe,Te):rr(this,lt,Et,Qe,Te),Et}catch(Qe){return this.then(null,Qe)}finally(Qe){var Te;let ze=null===(Te=this.constructor)||void 0===Te?void 0:Te[Symbol.species];(!ze||"function"!=typeof ze)&&(ze=ce);const ht=new ze(Ft);ht[et]=et;const Et=fe.current;return this[Pt]==tn?this[vt].push(Et,ht,Qe,Qe):rr(this,Et,ht,Qe,Qe),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 yt=Ye("thenPatched");function St(Ge){const Qe=Ge.prototype,Te=me(Qe,"then");if(Te&&(!1===Te.writable||!Te.configurable))return;const ze=Qe.then;Qe[je]=ze,Ge.prototype.then=function(ht,Et){return new ce((It,jt)=>{ze.call(this,It,jt)}).then(ht,Et)},Ge[yt]=!0}return ye.patchThen=St,ve&&(St(ve),$(ie,"fetch",Ge=>function mn(Ge){return function(Qe,Te){let ze=Ge.apply(Qe,Te);if(ze instanceof ce)return ze;let ht=ze.constructor;return ht[yt]||St(ht),ze}}(Ge))),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"),Ne=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 je=ie[me];if(je)return fe.call(je)}if(this===Error){const je=ie[_e];if(je)return fe.call(je)}}return fe.call(this)};Ne[ye]=fe,Function.prototype.toString=Ne;const Ye=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":Ye.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 ke={useG:!0},Se={},Pe={},we=new RegExp("^"+d+"(\\w+)(true|false)$"),$e=E("propagationStopped");function K(ie,fe){const ye=(fe?fe(ie):ie)+p,me=(fe?fe(ie):ie)+l,_e=d+ye,Ne=d+me;Se[ie]={},Se[ie][p]=_e,Se[ie][l]=Ne}function Ee(ie,fe,ye,me){const _e=me&&me.add||g,Ne=me&&me.rm||b,Ye=me&&me.listeners||"eventListeners",qe=me&&me.rmAll||"removeAllListeners",st=E(_e),nt="."+_e+":",ge=function(vt,et,Pn){if(vt.isRemoved)return;const Bt=vt.callback;let yn;"object"==typeof Bt&&Bt.handleEvent&&(vt.callback=ft=>Bt.handleEvent(ft),vt.originalDelegate=Bt);try{vt.invoke(vt,et,[Pn])}catch(ft){yn=ft}const tn=vt.options;return tn&&"object"==typeof tn&&tn.once&&et[Ne].call(et,Pn.type,vt.originalDelegate?vt.originalDelegate:vt.callback,tn),yn};function De(vt,et,Pn){if(!(et=et||ie.event))return;const Bt=vt||et.target||ie,yn=Bt[Se[et.type][Pn?l:p]];if(yn){const tn=[];if(1===yn.length){const ft=ge(yn[0],Bt,et);ft&&tn.push(ft)}else{const ft=yn.slice();for(let hn=0;hn{throw hn})}}}const Ue=function(vt){return De(this,vt,!1)},Be=function(vt){return De(this,vt,!0)};function dt(vt,et){if(!vt)return!1;let Pn=!0;et&&void 0!==et.useG&&(Pn=et.useG);const Bt=et&&et.vh;let yn=!0;et&&void 0!==et.chkDup&&(yn=et.chkDup);let tn=!1;et&&void 0!==et.rt&&(tn=et.rt);let ft=vt;for(;ft&&!ft.hasOwnProperty(_e);)ft=N(ft);if(!ft&&vt[_e]&&(ft=vt),!ft||ft[st])return!1;const hn=et&&et.eventNameToString,ot={},Kt=ft[st]=ft[_e],bt=ft[E(Ne)]=ft[Ne],lr=ft[E(Ye)]=ft[Ye],Hr=ft[E(qe)]=ft[qe];let Fn;function bn(Te,ze){return!pe&&"object"==typeof Te&&Te?!!Te.capture:pe&&ze?"boolean"==typeof Te?{capture:Te,passive:!0}:Te?"object"==typeof Te&&!1!==Te.passive?Object.assign(Object.assign({},Te),{passive:!0}):Te:{passive:!0}:Te}et&&et.prepend&&(Fn=ft[E(et.prepend)]=ft[et.prepend]);const ce=Pn?function(Te){if(!ot.isExisting)return Kt.call(ot.target,ot.eventName,ot.capture?Be:Ue,ot.options)}:function(Te){return Kt.call(ot.target,ot.eventName,Te.invoke,ot.options)},ve=Pn?function(Te){if(!Te.isRemoved){const ze=Se[Te.eventName];let ht;ze&&(ht=ze[Te.capture?l:p]);const Et=ht&&Te.target[ht];if(Et)for(let lt=0;ltfunction(_e,Ne){_e[$e]=!0,me&&me.apply(_e,Ne)})}function Ke(ie,fe,ye,me,_e){const Ne=Zone.__symbol__(me);if(fe[Ne])return;const Ye=fe[Ne]=fe[me];fe[me]=function(qe,st,nt){return st&&st.prototype&&_e.forEach(function(je){const be=`${ye}.${me}::`+je,ge=st.prototype;try{if(ge.hasOwnProperty(je)){const De=ie.ObjectGetOwnPropertyDescriptor(ge,je);De&&De.value?(De.value=ie.wrapWithCurrentZone(De.value,be),ie._redefineProperty(st.prototype,je,De)):ge[je]&&(ge[je]=ie.wrapWithCurrentZone(ge[je],be))}else ge[je]&&(ge[je]=ie.wrapWithCurrentZone(ge[je],be))}catch{}}),Ye.call(fe,qe,st,nt)},ie.attachOriginToPatched(fe[me],Ye)}function We(ie,fe,ye){if(!ye||0===ye.length)return fe;const me=ye.filter(Ne=>Ne.target===ie);if(!me||0===me.length)return fe;const _e=me[0].ignoreProperties;return fe.filter(Ne=>-1===_e.indexOf(Ne))}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=$,ye.bindArguments=P,ye.patchMacroTask=te;const _e=fe.__symbol__("BLACK_LISTED_EVENTS"),Ne=fe.__symbol__("UNPATCHED_EVENTS");ie[Ne]&&(ie[_e]=ie[Ne]),ie[_e]&&(fe[_e]=fe[Ne]=ie[_e]),ye.patchEventPrototype=xe,ye.patchEventTarget=Ee,ye.isIEOrEdge=de,ye.ObjectDefineProperty=G,ye.ObjectGetOwnPropertyDescriptor=J,ye.ObjectCreate=h,ye.ArraySlice=u,ye.patchClass=re,ye.wrapWithCurrentZone=_,ye.filterProperties=We,ye.attachOriginToPatched=Z,ye._redefineProperty=Object.defineProperty,ye.patchCallbacks=Ke,ye.getGlobalObjects=()=>({globalSources:Pe,zoneSymbolEventNames:Se,eventNames:me,isBrowser:F,isMix:z,isNode:B,TRUE_STR:l,FALSE_STR:p,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:b})});const pt=E("zoneTask");function Dt(ie,fe,ye,me){let _e=null,Ne=null;ye+=me;const Ye={};function qe(nt){const je=nt.data;return je.args[0]=function(){return nt.invoke.apply(this,arguments)},je.handleId=_e.apply(ie,je.args),nt}function st(nt){return Ne.call(ie,nt.data.handleId)}_e=$(ie,fe+=me,nt=>function(je,be){if("function"==typeof be[0]){const ge={isPeriodic:"Interval"===me,delay:"Timeout"===me||"Interval"===me?be[1]||0:void 0,args:be},De=be[0];be[0]=function(){try{return De.apply(this,arguments)}finally{ge.isPeriodic||("number"==typeof ge.handleId?delete Ye[ge.handleId]:ge.handleId&&(ge.handleId[pt]=null))}};const Ue=I(fe,be[0],ge,qe,st);if(!Ue)return Ue;const Be=Ue.data.handleId;return"number"==typeof Be?Ye[Be]=Ue:Be&&(Be[pt]=Ue),Be&&Be.ref&&Be.unref&&"function"==typeof Be.ref&&"function"==typeof Be.unref&&(Ue.ref=Be.ref.bind(Be),Ue.unref=Be.unref.bind(Be)),"number"==typeof Be||Be?Be:Ue}return nt.apply(ie,be)}),Ne=$(ie,ye,nt=>function(je,be){const ge=be[0];let De;"number"==typeof ge?De=Ye[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 Ye[ge]:ge&&(ge[pt]=null),De.zone.cancelTask(De)):nt.apply(ie,be)})}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,Ne){fe.current.scheduleMicroTask("queueMicrotask",Ne[0])})}),Zone.__load_patch("timers",ie=>{const ye="clear";Dt(ie,"set",ye,"Timeout"),Dt(ie,"set",ye,"Interval"),Dt(ie,"set",ye,"Immediate")}),Zone.__load_patch("requestAnimationFrame",ie=>{Dt(ie,"request","cancel","AnimationFrame"),Dt(ie,"mozRequest","mozCancel","AnimationFrame"),Dt(ie,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(ie,fe)=>{const ye=["alert","prompt","confirm"];for(let me=0;mefunction(st,nt){return fe.current.run(Ne,ie,nt,qe)})}),Zone.__load_patch("EventTarget",(ie,fe,ye)=>{(function ni(ie,fe){fe.patchEventPrototype(ie,fe)})(ie,ye),function Sr(ie,fe){if(Zone[fe.symbol("patchEventTarget")])return;const{eventNames:ye,zoneSymbolEventNames:me,TRUE_STR:_e,FALSE_STR:Ne,ZONE_SYMBOL_PREFIX:Ye}=fe.getGlobalObjects();for(let st=0;st{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 Ot(ie,fe){if(B&&!z||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 Ne=function oe(){try{const ie=f.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(Ne),N(_e))}me=me.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let _e=0;_e{!function Wr(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 st(nt){const je=nt.XMLHttpRequest;if(!je)return;const be=je.prototype;let De=be[w],Ue=be[v];if(!De){const ot=nt.XMLHttpRequestEventTarget;if(ot){const Kt=ot.prototype;De=Kt[w],Ue=Kt[v]}}const Be="readystatechange",dt="scheduled";function Pt(ot){const Kt=ot.data,bt=Kt.target;bt[Ne]=!1,bt[qe]=!1;const lr=bt[_e];De||(De=bt[w],Ue=bt[v]),lr&&Ue.call(bt,Be,lr);const Hr=bt[_e]=()=>{if(bt.readyState===bt.DONE)if(!Kt.aborted&&bt[Ne]&&ot.state===dt){const bn=bt[fe.__symbol__("loadfalse")];if(0!==bt.status&&bn&&bn.length>0){const vr=ot.invoke;ot.invoke=function(){const rr=bt[fe.__symbol__("loadfalse")];for(let _n=0;_nfunction(ot,Kt){return ot[me]=0==Kt[2],ot[Ye]=Kt[1],Pn.apply(ot,Kt)}),yn=E("fetchTaskAborting"),tn=E("fetchTaskScheduling"),ft=$(be,"send",()=>function(ot,Kt){if(!0===fe.current[tn]||ot[me])return ft.apply(ot,Kt);{const bt={target:ot,url:ot[Ye],isPeriodic:!1,args:Kt,aborted:!1},lr=I("XMLHttpRequest.send",vt,bt,Pt,et);ot&&!0===ot[qe]&&!bt.aborted&&lr.state===dt&&lr.invoke()}}),hn=$(be,"abort",()=>function(ot,Kt){const bt=function ge(ot){return ot[ye]}(ot);if(bt&&"string"==typeof bt.type){if(null==bt.cancelFn||bt.data&&bt.data.aborted)return;bt.zone.cancelTask(bt)}else if(!0===fe.current[yn])return hn.apply(ot,Kt)})}(ie);const ye=E("xhrTask"),me=E("xhrSync"),_e=E("xhrListener"),Ne=E("xhrScheduled"),Ye=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 st=function(){return qe.apply(this,P(arguments,ye+"."+_e))};return Z(st,qe),st})(Ne)}}}(ie.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(ie,fe)=>{function ye(me){return function(_e){Ce(ie,me).forEach(Ye=>{const qe=ie.PromiseRejectionEvent;if(qe){const st=new qe(me,{promise:_e.promise,reason:_e.rejection});Ye.invoke(st)}})}}ie.PromiseRejectionEvent&&(fe[E("unhandledPromiseRejectionHandler")]=ye("unhandledrejection"),fe[E("rejectionHandledHandler")]=ye("rejectionhandled"))})},7420:()=>{},5856:()=>{},5883:()=>{},6577:()=>{},5819:()=>{},8479:function(J,G,N){"use strict";var u,g;u=[N(1873)],void 0!==(g=function(b){var w=b.Reader,v=b.Writer,l=b.util,p=b.roots.default||(b.roots.default={});return p.RPC=function(){function d(I){if(this.subscriptions=[],this.messages=[],I)for(var E=Object.keys(I),y=0;y>>3){case 1:C.subscriptions&&C.subscriptions.length||(C.subscriptions=[]),C.subscriptions.push(p.RPC.SubOpts.decode(E,E.uint32()));break;case 2:C.messages&&C.messages.length||(C.messages=[]),C.messages.push(p.RPC.Message.decode(E,E.uint32()));break;case 3:C.control=p.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return C},d.fromObject=function(E){if(E instanceof p.RPC)return E;var y=new p.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");y.subscriptions=[];for(var f=0;f>>3){case 1:P.subscribe=f.bool();break;case 2:P.topic=f.string();break;default:f.skipType(7&D)}}return P},I.fromObject=function(f){if(f instanceof p.RPC.SubOpts)return f;var C=new p.RPC.SubOpts;return null!=f.subscribe&&(C.subscribe=Boolean(f.subscribe)),null!=f.topic&&(C.topic=String(f.topic)),C},I.toObject=function(f,C){C||(C={});var A={};return null!=f.subscribe&&f.hasOwnProperty("subscribe")&&(A.subscribe=f.subscribe,C.oneofs&&(A._subscribe="subscribe")),null!=f.topic&&f.hasOwnProperty("topic")&&(A.topic=f.topic,C.oneofs&&(A._topic="topic")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,b.util.toJSONOptions)},I}(),d.Message=function(){function I(y){if(y)for(var f=Object.keys(y),C=0;C>>3){case 1:P.from=f.bytes();break;case 2:P.data=f.bytes();break;case 3:P.seqno=f.bytes();break;case 4:P.topic=f.string();break;case 5:P.signature=f.bytes();break;case 6:P.key=f.bytes();break;default:f.skipType(7&D)}}if(!P.hasOwnProperty("topic"))throw l.ProtocolError("missing required 'topic'",{instance:P});return P},I.fromObject=function(f){if(f instanceof p.RPC.Message)return f;var C=new p.RPC.Message;return null!=f.from&&("string"==typeof f.from?l.base64.decode(f.from,C.from=l.newBuffer(l.base64.length(f.from)),0):f.from.length&&(C.from=f.from)),null!=f.data&&("string"==typeof f.data?l.base64.decode(f.data,C.data=l.newBuffer(l.base64.length(f.data)),0):f.data.length&&(C.data=f.data)),null!=f.seqno&&("string"==typeof f.seqno?l.base64.decode(f.seqno,C.seqno=l.newBuffer(l.base64.length(f.seqno)),0):f.seqno.length&&(C.seqno=f.seqno)),null!=f.topic&&(C.topic=String(f.topic)),null!=f.signature&&("string"==typeof f.signature?l.base64.decode(f.signature,C.signature=l.newBuffer(l.base64.length(f.signature)),0):f.signature.length&&(C.signature=f.signature)),null!=f.key&&("string"==typeof f.key?l.base64.decode(f.key,C.key=l.newBuffer(l.base64.length(f.key)),0):f.key.length&&(C.key=f.key)),C},I.toObject=function(f,C){C||(C={});var A={};return C.defaults&&(A.topic=""),null!=f.from&&f.hasOwnProperty("from")&&(A.from=C.bytes===String?l.base64.encode(f.from,0,f.from.length):C.bytes===Array?Array.prototype.slice.call(f.from):f.from,C.oneofs&&(A._from="from")),null!=f.data&&f.hasOwnProperty("data")&&(A.data=C.bytes===String?l.base64.encode(f.data,0,f.data.length):C.bytes===Array?Array.prototype.slice.call(f.data):f.data,C.oneofs&&(A._data="data")),null!=f.seqno&&f.hasOwnProperty("seqno")&&(A.seqno=C.bytes===String?l.base64.encode(f.seqno,0,f.seqno.length):C.bytes===Array?Array.prototype.slice.call(f.seqno):f.seqno,C.oneofs&&(A._seqno="seqno")),null!=f.topic&&f.hasOwnProperty("topic")&&(A.topic=f.topic),null!=f.signature&&f.hasOwnProperty("signature")&&(A.signature=C.bytes===String?l.base64.encode(f.signature,0,f.signature.length):C.bytes===Array?Array.prototype.slice.call(f.signature):f.signature,C.oneofs&&(A._signature="signature")),null!=f.key&&f.hasOwnProperty("key")&&(A.key=C.bytes===String?l.base64.encode(f.key,0,f.key.length):C.bytes===Array?Array.prototype.slice.call(f.key):f.key,C.oneofs&&(A._key="key")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,b.util.toJSONOptions)},I}(),d.ControlMessage=function(){function I(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var y=Object.keys(E),f=0;f>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(p.RPC.ControlIHave.decode(y,y.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(p.RPC.ControlIWant.decode(y,y.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(p.RPC.ControlGraft.decode(y,y.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(p.RPC.ControlPrune.decode(y,y.uint32()));break;default:y.skipType(7&P)}}return A},I.fromObject=function(y){if(y instanceof p.RPC.ControlMessage)return y;var f=new p.RPC.ControlMessage;if(y.ihave){if(!Array.isArray(y.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");f.ihave=[];for(var C=0;C>>3){case 1:P.topicID=f.string();break;case 2:P.messageIDs&&P.messageIDs.length||(P.messageIDs=[]),P.messageIDs.push(f.bytes());break;default:f.skipType(7&D)}}return P},I.fromObject=function(f){if(f instanceof p.RPC.ControlIHave)return f;var C=new p.RPC.ControlIHave;if(null!=f.topicID&&(C.topicID=String(f.topicID)),f.messageIDs){if(!Array.isArray(f.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");C.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(y.bytes())):y.skipType(7&P)}return A},I.fromObject=function(y){if(y instanceof p.RPC.ControlIWant)return y;var f=new p.RPC.ControlIWant;if(y.messageIDs){if(!Array.isArray(y.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");f.messageIDs=[];for(var C=0;C>>3==1?P.topicID=f.string():f.skipType(7&D)}return P},I.fromObject=function(f){if(f instanceof p.RPC.ControlGraft)return f;var C=new p.RPC.ControlGraft;return null!=f.topicID&&(C.topicID=String(f.topicID)),C},I.toObject=function(f,C){C||(C={});var A={};return null!=f.topicID&&f.hasOwnProperty("topicID")&&(A.topicID=f.topicID,C.oneofs&&(A._topicID="topicID")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,b.util.toJSONOptions)},I}(),d.ControlPrune=function(){function I(y){if(this.peers=[],y)for(var f=Object.keys(y),C=0;C>>3){case 1:P.topicID=f.string();break;case 2:P.peers&&P.peers.length||(P.peers=[]),P.peers.push(p.RPC.PeerInfo.decode(f,f.uint32()));break;case 3:P.backoff=f.uint64();break;default:f.skipType(7&D)}}return P},I.fromObject=function(f){if(f instanceof p.RPC.ControlPrune)return f;var C=new p.RPC.ControlPrune;if(null!=f.topicID&&(C.topicID=String(f.topicID)),f.peers){if(!Array.isArray(f.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");C.peers=[];for(var A=0;A>>0,f.backoff.high>>>0).toNumber(!0))),C},I.toObject=function(f,C){C||(C={});var A={};if((C.arrays||C.defaults)&&(A.peers=[]),null!=f.topicID&&f.hasOwnProperty("topicID")&&(A.topicID=f.topicID,C.oneofs&&(A._topicID="topicID")),f.peers&&f.peers.length){A.peers=[];for(var P=0;P>>0,f.backoff.high>>>0).toNumber(!0):f.backoff,C.oneofs&&(A._backoff="backoff")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,b.util.toJSONOptions)},I}(),d.PeerInfo=function(){function I(y){if(y)for(var f=Object.keys(y),C=0;C>>3){case 1:P.peerID=f.bytes();break;case 2:P.signedPeerRecord=f.bytes();break;default:f.skipType(7&D)}}return P},I.fromObject=function(f){if(f instanceof p.RPC.PeerInfo)return f;var C=new p.RPC.PeerInfo;return null!=f.peerID&&("string"==typeof f.peerID?l.base64.decode(f.peerID,C.peerID=l.newBuffer(l.base64.length(f.peerID)),0):f.peerID.length&&(C.peerID=f.peerID)),null!=f.signedPeerRecord&&("string"==typeof f.signedPeerRecord?l.base64.decode(f.signedPeerRecord,C.signedPeerRecord=l.newBuffer(l.base64.length(f.signedPeerRecord)),0):f.signedPeerRecord.length&&(C.signedPeerRecord=f.signedPeerRecord)),C},I.toObject=function(f,C){C||(C={});var A={};return null!=f.peerID&&f.hasOwnProperty("peerID")&&(A.peerID=C.bytes===String?l.base64.encode(f.peerID,0,f.peerID.length):C.bytes===Array?Array.prototype.slice.call(f.peerID):f.peerID,C.oneofs&&(A._peerID="peerID")),null!=f.signedPeerRecord&&f.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=C.bytes===String?l.base64.encode(f.signedPeerRecord,0,f.signedPeerRecord.length):C.bytes===Array?Array.prototype.slice.call(f.signedPeerRecord):f.signedPeerRecord,C.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,b.util.toJSONOptions)},I}(),d}(),p}.apply(G,u))&&(J.exports=g)},4642:(J,G,N)=>{var h=N(9805);function u(g){var b,w;function l(d,_){try{var I=g[d](_),E=I.value,y=E instanceof h;Promise.resolve(y?E.wrapped:E).then(function(f){y?l("return"===d?"return":"next",f):p(I.done?"return":"normal",f)},function(f){l("throw",f)})}catch(f){p("throw",f)}}function p(d,_){switch(d){case"return":b.resolve({value:_,done:!0});break;case"throw":b.reject(_);break;default:b.resolve({value:_,done:!1})}(b=b.next)?l(b.key,b.arg):w=null}this._invoke=function v(d,_){return new Promise(function(I,E){var y={key:d,arg:_,resolve:I,reject:E,next:null};w?w=w.next=y:(b=w=y,l(d,_))})},"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)},J.exports=u,J.exports.__esModule=!0,J.exports.default=J.exports},9805:J=>{J.exports=function G(N){this.wrapped=N},J.exports.__esModule=!0,J.exports.default=J.exports},8131:J=>{J.exports=function G(N,h){var u={},g=!1;function b(w,v){return g=!0,v=new Promise(function(l){l(N[w](v))}),{done:!1,value:h(v)}}return u[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},u.next=function(w){return g?(g=!1,w):b("next",w)},"function"==typeof N.throw&&(u.throw=function(w){if(g)throw g=!1,w;return b("throw",w)}),"function"==typeof N.return&&(u.return=function(w){return g?(g=!1,w):b("return",w)}),u},J.exports.__esModule=!0,J.exports.default=J.exports},8237:J=>{function N(h){function u(g){if(Object(g)!==g)return Promise.reject(new TypeError(g+" is not an object."));var b=g.done;return Promise.resolve(g.value).then(function(w){return{value:w,done:b}})}return(N=function(b){this.s=b,this.n=b.next}).prototype={s:null,n:null,next:function(){return u(this.n.apply(this.s,arguments))},return:function(b){var w=this.s.return;return void 0===w?Promise.resolve({value:b,done:!0}):u(w.apply(this.s,arguments))},throw:function(b){var w=this.s.return;return void 0===w?Promise.reject(b):u(w.apply(this.s,arguments))}},new N(h)}J.exports=function G(h){var u,g,b,w=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,b=Symbol.iterator);w--;){if(g&&null!=(u=h[g]))return u.call(h);if(b&&null!=(u=h[b]))return new N(u.call(h));g="@@asyncIterator",b="@@iterator"}throw new TypeError("Object is not async iterable")},J.exports.__esModule=!0,J.exports.default=J.exports},7156:J=>{function G(h,u,g,b,w,v,l){try{var p=h[v](l),d=p.value}catch(_){return void g(_)}p.done?u(d):Promise.resolve(d).then(b,w)}J.exports=function N(h){return function(){var u=this,g=arguments;return new Promise(function(b,w){var v=h.apply(u,g);function l(d){G(v,b,w,l,p,"next",d)}function p(d){G(v,b,w,l,p,"throw",d)}l(void 0)})}},J.exports.__esModule=!0,J.exports.default=J.exports},6737:(J,G,N)=>{var h=N(9805);J.exports=function u(g){return new h(g)},J.exports.__esModule=!0,J.exports.default=J.exports},8186:(J,G,N)=>{var h=N(4642);J.exports=function u(g){return function(){return new h(g.apply(this,arguments))}},J.exports.__esModule=!0,J.exports.default=J.exports}},J=>{J(J.s=623)}]);