(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{7497:(Q,K,x)=>{"use strict";var y={};x.r(y),x.d(y,{identity:()=>SB});var u={};x.r(u),x.d(u,{base2:()=>CB});var g={};x.r(g),x.d(g,{base8:()=>IB});var w={};x.r(w),x.d(w,{base10:()=>TB});var m={};x.r(m),x.d(m,{base16:()=>AB,base16upper:()=>xB});var h={};x.r(h),x.d(h,{base32:()=>so,base32hex:()=>MB,base32hexpad:()=>kB,base32hexpadupper:()=>LB,base32hexupper:()=>OB,base32pad:()=>PB,base32padupper:()=>NB,base32upper:()=>RB,base32z:()=>BB});var c={};x.r(c),x.d(c,{base36:()=>FB,base36upper:()=>UB});var f={};x.r(f),x.d(f,{base58btc:()=>si,base58flickr:()=>VB});var d={};x.r(d),x.d(d,{base64:()=>Ud,base64pad:()=>HB,base64url:()=>KB,base64urlpad:()=>$B});var b={};x.r(b),x.d(b,{base256emoji:()=>qB});var S={};x.r(S),x.d(S,{sha256:()=>hi,sha512:()=>gF});var E={};x.r(E),x.d(E,{identity:()=>Lc});var v={};x.r(v),x.d(v,{code:()=>vF,decode:()=>bF,encode:()=>EF,name:()=>mF});var p={};x.r(p),x.d(p,{code:()=>SF,decode:()=>IF,encode:()=>CF,name:()=>DF});var I={};x.r(I),x.d(I,{RsaPrivateKey:()=>Xd,RsaPublicKey:()=>W0,fromJwk:()=>m6,generateKeyPair:()=>v6,unmarshalRsaPrivateKey:()=>g6,unmarshalRsaPublicKey:()=>y6});var A={};x.r(A),x.d(A,{Ed25519PrivateKey:()=>_l,Ed25519PublicKey:()=>pm,generateKeyPair:()=>j6,generateKeyPairFromSeed:()=>G6,unmarshalEd25519PrivateKey:()=>K6,unmarshalEd25519PublicKey:()=>$6});var P={};function D(n){return"function"==typeof n}function T(n){const t=n(r=>{Error.call(r),r.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}x.r(P),x.d(P,{Secp256k1PrivateKey:()=>bm,Secp256k1PublicKey:()=>Em,generateKeyPair:()=>e5,unmarshalSecp256k1PrivateKey:()=>X6,unmarshalSecp256k1PublicKey:()=>J6});const M=T(n=>function(t){n(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t});function k(n,e){if(n){const t=n.indexOf(e);0<=t&&n.splice(t,1)}}class F{constructor(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let e;if(!this.closed){this.closed=!0;const{_parentage:t}=this;if(t)if(this._parentage=null,Array.isArray(t))for(const s of t)s.remove(this);else t.remove(this);const{initialTeardown:r}=this;if(D(r))try{r()}catch(s){e=s instanceof M?s.errors:[s]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const s of i)try{O(s)}catch(o){e=e??[],o instanceof M?e=[...e,...o.errors]:e.push(o)}}if(e)throw new M(e)}}add(e){var t;if(e&&e!==this)if(this.closed)O(e);else{if(e instanceof F){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(t=this._finalizers)&&void 0!==t?t:[]).push(e)}}_hasParent(e){const{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){const{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){const{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&k(t,e)}remove(e){const{_finalizers:t}=this;t&&k(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const $=F.EMPTY;function C(n){return n instanceof F||n&&"closed"in n&&D(n.remove)&&D(n.add)&&D(n.unsubscribe)}function O(n){D(n)?n():n.unsubscribe()}const U={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 H(n){L.setTimeout(()=>{const{onUnhandledError:e}=U;if(!e)throw n;e(n)})}function ne(){}const G=W("C",void 0,void 0);function W(n,e,t){return{kind:n,value:e,error:t}}let te=null;function oe(n){if(U.useDeprecatedSynchronousErrorHandling){const e=!te;if(e&&(te={errorThrown:!1,error:null}),n(),e){const{errorThrown:t,error:r}=te;if(te=null,t)throw r}}else n()}class he extends F{constructor(e){super(),this.isStopped=!1,e?(this.destination=e,C(e)&&e.add(this)):this.destination=Pt}static create(e,t,r){return new ve(e,t,r)}next(e){this.isStopped?nt(function Z(n){return W("N",n,void 0)}(e),this):this._next(e)}error(e){this.isStopped?nt(function ee(n){return W("E",void 0,n)}(e),this):(this.isStopped=!0,this._error(e))}complete(){this.isStopped?nt(G,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(e){this.destination.next(e)}_error(e){try{this.destination.error(e)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}}const Pe=Function.prototype.bind;function De(n,e){return Pe.call(n,e)}class Be{constructor(e){this.partialObserver=e}next(e){const{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){He(r)}}error(e){const{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){He(r)}else He(e)}complete(){const{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){He(t)}}}class ve extends he{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&&U.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&De(e.next,s),error:e.error&&De(e.error,s),complete:e.complete&&De(e.complete,s)}):i=e}this.destination=new Be(i)}}function He(n){U.useDeprecatedSynchronousErrorHandling?function de(n){U.useDeprecatedSynchronousErrorHandling&&te&&(te.errorThrown=!0,te.error=n)}(n):H(n)}function nt(n,e){const{onStoppedNotification:t}=U;t&&L.setTimeout(()=>t(n,e))}const Pt={closed:!0,next:ne,error:function ke(n){throw n},complete:ne},_t="function"==typeof Symbol&&Symbol.observable||"@@observable";function Vt(n){return n}let cn=(()=>{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 _n(n){return n&&n instanceof he||function Tr(n){return n&&D(n.next)&&D(n.error)&&D(n.complete)}(n)&&C(n)}(t)?t:new ve(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=$n(r))((i,s)=>{const o=new ve({next:a=>{try{t(a)}catch(l){s(l),o.unsubscribe()}},error:s,complete:i});this.subscribe(o)})}_subscribe(t){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(t)}[_t](){return this}pipe(...t){return function nn(n){return 0===n.length?Vt:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=$n(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function $n(n){var e;return null!==(e=n??U.Promise)&&void 0!==e?e:Promise}const Oi=T(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let Qr=(()=>{class n extends cn{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){const r=new es(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Oi}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?$:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,k(s,t)}))}_checkFinalizedStatuses(t){const{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){const t=new cn;return t.source=this,t}}return n.create=(e,t)=>new es(e,t),n})();class es extends Qr{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:$}}function le(n){return e=>{if(function re(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 ge(n,e,t,r,i){return new ye(n,e,t,r,i)}class ye extends he{constructor(e,t,r,i,s,o){super(e),this.onFinalize=s,this.shouldUnsubscribe=o,this._next=t?function(a){try{t(a)}catch(l){e.error(l)}}:super._next,this._error=i?function(a){try{i(a)}catch(l){e.error(l)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){e.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:t}=this;super.unsubscribe(),!t&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}}}function $t(n){return this instanceof $t?(this.v=n,this):new $t(n)}function Tn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=t.apply(n,e||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(B){r[B]&&(i[B]=function(V){return new Promise(function(Y,X){s.push([B,V,Y,X])>1||a(B,V)})})}function a(B,V){try{!function l(B){B.value instanceof $t?Promise.resolve(B.value.v).then(_,R):N(s[0][2],B)}(r[B](V))}catch(Y){N(s[0][3],Y)}}function _(B){a("next",B)}function R(B){a("throw",B)}function N(B,V){B(V),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ot(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 at(n){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&"number"==typeof n.length)return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,l){!function i(s,o,a,l){Promise.resolve(l).then(function(_){s({value:_,done:a})},o)}(a,l,(o=n[s](o)).done,o.value)})}}}const Nn=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function Br(n){return D(n?.then)}function _r(n){return D(n[_t])}function Mn(n){return Symbol.asyncIterator&&D(n?.[Symbol.asyncIterator])}function jt(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 rt(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function me(n){return D(n?.[ce])}function lt(n){return Tn(this,arguments,function*(){const t=n.getReader();try{for(;;){const{value:r,done:i}=yield $t(t.read());if(i)return yield $t(void 0);yield yield $t(r)}}finally{t.releaseLock()}})}function Dt(n){return D(n?.getReader)}function An(n){if(n instanceof cn)return n;if(null!=n){if(_r(n))return function Ve(n){return new cn(e=>{const t=n[_t]();if(D(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(n);if(Nn(n))return function Ge(n){return new cn(e=>{for(let t=0;t{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,H)})}(n);if(Mn(n))return ct(n);if(me(n))return function Ke(n){return new cn(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(Dt(n))return function ht(n){return ct(lt(n))}(n)}throw jt(n)}function ct(n){return new cn(e=>{(function it(n,e){var t,r,i,s;return function pe(n,e,t,r){return new(t||(t=Promise))(function(s,o){function a(R){try{_(r.next(R))}catch(N){o(N)}}function l(R){try{_(r.throw(R))}catch(N){o(N)}}function _(R){R.done?s(R.value):function i(s){return s instanceof t?s:new t(function(o){o(s)})}(R.value).then(a,l)}_((r=r.apply(n,e||[])).next())})}(this,void 0,void 0,function*(){try{for(t=ot(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 pt(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 It(n,e,t=1/0){return D(e)?It((r,i)=>function be(n,e){return le((t,r)=>{let i=0;t.subscribe(ge(r,s=>{r.next(n.call(e,s,i++))}))})}((s,o)=>e(r,s,i,o))(An(n(r,i))),t):("number"==typeof e&&(t=e),le((r,i)=>function Mt(n,e,t,r,i,s,o,a){const l=[];let _=0,R=0,N=!1;const B=()=>{N&&!l.length&&!_&&e.complete()},V=X=>_{s&&e.next(X),_++;let ie=!1;An(t(X,R++)).subscribe(ge(e,fe=>{i?.(fe),s?V(fe):e.next(fe)},()=>{ie=!0},void 0,()=>{if(ie)try{for(_--;l.length&&_Y(fe)):Y(fe)}B()}catch(fe){e.error(fe)}}))};return n.subscribe(ge(e,V,()=>{N=!0,B()})),()=>{a?.()}}(r,i,n,t)))}const gn=new cn(n=>n.complete());function wo(n){return n[n.length-1]}function q(n,e=0){return le((t,r)=>{t.subscribe(ge(r,i=>pt(r,n,()=>r.next(i),e),()=>pt(r,n,()=>r.complete(),e),i=>pt(r,n,()=>r.error(i),e)))})}function J(n,e=0){return le((t,r)=>{r.add(n.schedule(()=>t.subscribe(r),e))})}function $e(n,e){if(!n)throw new Error("Iterable cannot be null");return new cn(t=>{pt(t,e,()=>{const r=n[Symbol.asyncIterator]();pt(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function Yr(...n){const e=function sa(n){return function ia(n){return n&&D(n.schedule)}(wo(n))?n.pop():void 0}(n),t=function z(n,e){return"number"==typeof wo(n)?n.pop():e}(n,1/0),r=n;return r.length?1===r.length?An(r[0]):function En(n=1/0){return It(Vt,n)}(t)(function ci(n,e){return e?function fr(n,e){if(null!=n){if(_r(n))return function ue(n,e){return An(n).pipe(J(e),q(e))}(n,e);if(Nn(n))return function Oe(n,e){return new cn(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}(n,e);if(Br(n))return function Re(n,e){return An(n).pipe(J(e),q(e))}(n,e);if(Mn(n))return $e(n,e);if(me(n))return function We(n,e){return new cn(t=>{let r;return pt(t,e,()=>{r=n[ce](),pt(t,e,()=>{let i,s;try{({value:i,done:s}=r.next())}catch(o){return void t.error(o)}s?t.complete():t.next(i)},0,!0)}),()=>D(r?.return)&&r.return()})}(n,e);if(Dt(n))return function Zt(n,e){return $e(lt(n),e)}(n,e)}throw jt(n)}(n,e):An(n)}(r,e)):gn}function _o(n,e,...t){if(!0===e)return void n();if(!1===e)return;const r=new ve({next:()=>{r.unsubscribe(),n()}});return e(...t).subscribe(r)}function Gt(n){for(let e in n)if(n[e]===Gt)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 ki(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const pu=Gt({__forward_ref__:Gt});function cp(n){return n.__forward_ref__=cp,n.toString=function(){return dn(this())},n}function bt(n){return function up(n){return"function"==typeof n&&n.hasOwnProperty(pu)&&n.__forward_ref__===cp}(n)?n():n}class mt extends Error{constructor(e,t){super(function ef(n,e){return`NG0${Math.abs(n)}${e?": "+e.trim():""}`}(e,t)),this.code=e}}function Tt(n){return"string"==typeof n?n:null==n?"":String(n)}function tf(n,e){throw new mt(-201,!1)}function Di(n,e){null==n&&function bn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function Gn(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function Ba(n){return{providers:n.providers||[],imports:n.imports||[]}}function nf(n){return UE(n,rf)||UE(n,HE)}function UE(n,e){return n.hasOwnProperty(e)?n[e]:null}function VE(n){return n&&(n.hasOwnProperty(fp)||n.hasOwnProperty(MA))?n[fp]:null}const rf=Gt({\u0275prov:Gt}),fp=Gt({\u0275inj:Gt}),HE=Gt({ngInjectableDef:Gt}),MA=Gt({ngInjectorDef:Gt});var St=(()=>((St=St||{})[St.Default=0]="Default",St[St.Host=1]="Host",St[St.Self=2]="Self",St[St.SkipSelf=4]="SkipSelf",St[St.Optional=8]="Optional",St))();let dp;function Li(n){const e=dp;return dp=n,e}function KE(n,e,t){const r=nf(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&St.Optional?null:void 0!==e?e:void tf(dn(n))}function Do(n){return{toString:n}.toString()}var rs=(()=>((rs=rs||{})[rs.OnPush=0]="OnPush",rs[rs.Default=1]="Default",rs))(),Cs=(()=>{return(n=Cs||(Cs={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",Cs;var n})();const On=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),Fa={},mn=[],sf=Gt({\u0275cmp:Gt}),hp=Gt({\u0275dir:Gt}),pp=Gt({\u0275pipe:Gt}),$E=Gt({\u0275mod:Gt}),js=Gt({\u0275fac:Gt}),gu=Gt({__NG_ELEMENT_ID__:Gt});let kA=0;function of(n){return Do(()=>{const t=!0===n.standalone,r={},i={type:n.type,providersResolver:null,decls:n.decls,vars:n.vars,factory:null,template:n.template||null,consts:n.consts||null,ngContentSelectors:n.ngContentSelectors,hostBindings:n.hostBindings||null,hostVars:n.hostVars||0,hostAttrs:n.hostAttrs||null,contentQueries:n.contentQueries||null,declaredInputs:r,inputs:null,outputs:null,exportAs:n.exportAs||null,onPush:n.changeDetection===rs.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||mn,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||Cs.Emulated,id:"c"+kA++,styles:n.styles||mn,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=zE(n.inputs,r),i.outputs=zE(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(jE).filter(GE):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(Jr).filter(GE):null,i})}function jE(n){return Sn(n)||Xr(n)}function GE(n){return null!==n}function yu(n){return Do(()=>({type:n.type,bootstrap:n.bootstrap||mn,declarations:n.declarations||mn,imports:n.imports||mn,exports:n.exports||mn,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function zE(n,e){if(null==n)return Fa;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 Bi=of;function Sn(n){return n[sf]||null}function Xr(n){return n[hp]||null}function Jr(n){return n[pp]||null}function li(n){return Array.isArray(n)&&"object"==typeof n[1]}function ss(n){return Array.isArray(n)&&!0===n[1]}function mp(n){return 0!=(8&n.flags)}function lf(n){return 2==(2&n.flags)}function ff(n){return 1==(1&n.flags)}function os(n){return null!==n.template}function HA(n){return 0!=(256&n[2])}function la(n,e){return n.hasOwnProperty(js)?n[js]:null}class jA{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function QE(n){return n.type.prototype.ngOnChanges&&(n.setInput=zA),GA}function GA(){const n=ZE(this),e=n?.current;if(e){const t=n.previous;if(t===Fa)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function zA(n,e,t,r){const i=ZE(n)||function WA(n,e){return n[YE]=e}(n,{previous:Fa,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],l=o[a];s[a]=new jA(l&&l.currentValue,e,o===Fa),n[r]=e}const YE="__ngSimpleChanges__";function ZE(n){return n[YE]||null}function dr(n){for(;Array.isArray(n);)n=n[0];return n}function Vi(n,e){return dr(e[n.index])}function _p(n,e){return n.data[e]}function Ii(n,e){const t=e[n];return li(t)?t:t[0]}function pf(n){return 64==(64&n[2])}function So(n,e){return null==e?null:n[e]}function JE(n){n[18]=0}function Dp(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 Ct={lFrame:cb(null),bindingsEnabled:!0};function tb(){return Ct.bindingsEnabled}function Me(){return Ct.lFrame.lView}function sn(){return Ct.lFrame.tView}function Dr(){let n=nb();for(;null!==n&&64===n.type;)n=n.parent;return n}function nb(){return Ct.lFrame.currentTNode}function Is(n,e){const t=Ct.lFrame;t.currentTNode=n,t.isParent=e}function Sp(){return Ct.lFrame.isParent}function ja(){return Ct.lFrame.bindingIndex++}function ux(n,e){const t=Ct.lFrame;t.bindingIndex=t.bindingRootIndex=n,Ip(e)}function Ip(n){Ct.lFrame.currentDirectiveIndex=n}function Ap(n){Ct.lFrame.currentQueryIndex=n}function fx(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function ob(n,e,t){if(t&St.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&St.Host||(i=fx(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=Ct.lFrame=ab();return r.currentTNode=e,r.lView=n,!0}function xp(n){const e=ab(),t=n[1];Ct.lFrame=e,e.currentTNode=t.firstChild,e.lView=n,e.tView=t,e.contextLView=n,e.bindingIndex=t.bindingStartIndex,e.inI18n=!1}function ab(){const n=Ct.lFrame,e=null===n?null:n.child;return null===e?cb(n):e}function cb(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 ub(){const n=Ct.lFrame;return Ct.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const lb=ub;function Rp(){const n=ub();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 ti(){return Ct.lFrame.selectedIndex}function Co(n){Ct.lFrame.selectedIndex=n}function yf(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[l]<0&&(n[18]+=65536),(a>11>16&&(3&n[2])===e){n[2]+=2048;try{s.call(a)}finally{}}}else try{s.call(a)}finally{}}class _u{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function Ef(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 Mp=!0;function wf(n){const e=Mp;return Mp=n,e}let Ix=0;const Ts={};function Su(n,e){const t=kp(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Op(r.data,n),Op(e,null),Op(r.blueprint,null));const i=_f(n,e),s=n.injectorIndex;if(gb(i)){const o=Ga(i),a=za(i,e),l=a[1].data;for(let _=0;_<8;_++)e[s+_]=a[o+_]|l[o+_]}return e[s+8]=i,s}function Op(n,e){n.push(0,0,0,0,0,0,0,0,e)}function kp(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function _f(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=Sb(i),null===r)return-1;if(t++,i=i[15],-1!==r.injectorIndex)return r.injectorIndex|t<<16}return-1}function Df(n,e,t){!function Tx(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(gu)&&(r=t[gu]),null==r&&(r=t[gu]=Ix++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:Px:e}(t);if("function"==typeof s){if(!ob(e,n,r))return r&St.Host?vb(i,0,r):Eb(e,t,r,i);try{const o=s(r);if(null!=o||r&St.Optional)return o;tf()}finally{lb()}}else if("number"==typeof s){let o=null,a=kp(n,e),l=-1,_=r&St.Host?e[16][6]:null;for((-1===a||r&St.SkipSelf)&&(l=-1===a?_f(n,e):e[a+8],-1!==l&&Db(r,!1)?(o=e[1],a=Ga(l),e=za(l,e)):a=-1);-1!==a;){const R=e[1];if(_b(s,a,R.data)){const N=xx(a,e,t,o,r,_);if(N!==Ts)return N}l=e[a+8],-1!==l&&Db(r,e[1].data[a+8]===_)&&_b(s,a,e)?(o=R,a=Ga(l),e=za(l,e)):a=-1}}return i}function xx(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],R=function Sf(n,e,t,r,i){const s=n.providerIndexes,o=e.data,a=1048575&s,l=n.directiveStart,R=s>>20,B=i?a+R:n.directiveEnd;for(let V=r?a:a+R;V=l&&Y.type===t)return V}if(i){const V=o[l];if(V&&os(V)&&V.type===t)return l}return null}(a,o,t,null==r?lf(a)&&Mp:r!=o&&0!=(3&a.type),i&St.Host&&s===a);return null!==R?Cu(e,o,R,a):Ts}function Cu(n,e,t,r){let i=n[t];const s=e.data;if(function wx(n){return n instanceof _u}(i)){const o=i;o.resolving&&function IA(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new mt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function yn(n){return"function"==typeof n?n.name||n.toString():"object"==typeof n&&null!=n&&"function"==typeof n.type?n.type.name||n.type.toString():Tt(n)}(s[t]));const a=wf(o.canSeeViewProviders);o.resolving=!0;const l=o.injectImpl?Li(o.injectImpl):null;ob(n,r,St.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function Ex(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=QE(e);(t.preOrderHooks||(t.preOrderHooks=[])).push(n,o),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,o)}i&&(t.preOrderHooks||(t.preOrderHooks=[])).push(0-n,i),s&&((t.preOrderHooks||(t.preOrderHooks=[])).push(n,s),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,s))}(t,s[t],e)}finally{null!==l&&Li(l),wf(a),o.resolving=!1,lb()}}return i}function _b(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function Fp(n){return function(...t){if(n){const r=n(...t);for(const i in r)this[i]=r[i]}}}(e);function i(...s){if(this instanceof i)return r.apply(this,s),this;const o=new i(...s);return a.annotation=o,a;function a(l,_,R){const N=l.hasOwnProperty(Qa)?l[Qa]:Object.defineProperty(l,Qa,{value:[]})[Qa];for(;N.length<=R;)N.push(null);return(N[R]=N[R]||[]).push(o),l}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}class Xt{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=Gn({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function Ws(n,e){n.forEach(t=>Array.isArray(t)?Ws(t,e):e(t))}function Ib(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function Cf(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const xu={},Kp="__NG_DI_FLAG__",Tf="ngTempTokenPath",Gx=/\n/gm,Rb="__source";let Ru;function Ja(n){const e=Ru;return Ru=n,e}function Wx(n,e=St.Default){if(void 0===Ru)throw new mt(-203,!1);return null===Ru?KE(n,void 0,e):Ru.get(n,e&St.Optional?null:void 0,e)}function wn(n,e=St.Default){return(function OA(){return dp}()||Wx)(bt(n),e)}function $p(n){const e=[];for(let t=0;t{const o=s;Xp(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&iw(i,t),t}function iw(n,e){for(let t=0;t{e.push(s)})}}function Xp(n,e,t,r){if(!(n=bt(n)))return!1;let i=null,s=VE(n);const o=!s&&Sn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const l=n.ngModule;if(s=VE(l),!s)return!1;i=l}const a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){const l="function"==typeof o.dependencies?o.dependencies():o.dependencies;for(const _ of l)Xp(_,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let _;r.add(i);try{Ws(s.imports,R=>{Xp(R,e,t,r)&&(_||(_=[]),_.push(R))})}finally{}void 0!==_&&iw(_,e)}if(!a){const _=la(i)||(()=>new i);e.push({provide:i,useFactory:_,deps:mn},{provide:tw,useValue:i,multi:!0},{provide:Jb,useValue:()=>wn(i),multi:!0})}const l=s.providers;null==l||a||Ws(l,R=>{e.push(R)})}}return i!==n&&void 0!==n.providers}const OR=Gt({provide:String,useValue:Gt});function Jp(n){return null!==n&&"object"==typeof n&&OR in n}function fa(n){return"function"==typeof n}const eg=new Xt("Set Injector scope."),Lf={},LR={};let tg;function Bf(){return void 0===tg&&(tg=new nw),tg}class nc{}class aw extends nc{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,rg(e,o=>this.processProvider(o)),this.records.set(ew,rc(void 0,this)),i.has("environment")&&this.records.set(nc,rc(void 0,this));const s=this.records.get(eg);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(tw.multi,mn,St.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=Ja(this),r=Li(void 0);try{return e()}finally{Ja(t),Li(r)}}get(e,t=xu,r=St.Default){this.assertNotDestroyed();const i=Ja(this),s=Li(void 0);try{if(!(r&St.SkipSelf)){let a=this.records.get(e);if(void 0===a){const l=function HR(n){return"function"==typeof n||"object"==typeof n&&n instanceof Xt}(e)&&nf(e);a=l&&this.injectableDefInScope(l)?rc(ng(e),Lf):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&St.Self?Bf():this.parent).get(e,t=r&St.Optional&&t===xu?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[Tf]=o[Tf]||[]).unshift(dn(e)),i)throw o;return function Yx(n,e,t,r){const i=n[Tf];throw e[Rb]&&i.unshift(e[Rb]),n.message=function Zx(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(Gx,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[Tf]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{Li(s),Ja(i)}}resolveInjectorInitializers(){const e=Ja(this),t=Li(void 0);try{const r=this.get(Jb.multi,mn,St.Self);for(const i of r)i()}finally{Ja(e),Li(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 mt(205,!1)}processProvider(e){let t=fa(e=bt(e))?e:bt(e&&e.provide);const r=function FR(n){return Jp(n)?rc(void 0,n.useValue):rc(function cw(n,e,t){let r;if(fa(n)){const i=bt(n);return la(i)||ng(i)}if(Jp(n))r=()=>bt(n.useValue);else if(function ow(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...$p(n.deps||[]));else if(function sw(n){return!(!n||!n.useExisting)}(n))r=()=>wn(bt(n.useExisting));else{const i=bt(n&&(n.useClass||n.provide));if(!function UR(n){return!!n.deps}(n))return la(i)||ng(i);r=()=>new i(...$p(n.deps))}return r}(n),Lf)}(e);if(fa(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=rc(void 0,Lf,!0),i.factory=()=>$p(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===Lf&&(t.value=LR,t.value=t.factory()),"object"==typeof t.value&&t.value&&function VR(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=bt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function ng(n){const e=nf(n),t=null!==e?e.factory:la(n);if(null!==t)return t;if(n instanceof Xt)throw new mt(204,!1);if(n instanceof Function)return function BR(n){const e=n.length;if(e>0)throw function Au(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new mt(204,!1)}function rc(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function KR(n){return!!n.\u0275providers}function rg(n,e){for(const t of n)Array.isArray(t)?rg(t,e):KR(t)?rg(t.\u0275providers,e):e(t)}class uw{}class GR{resolveComponentFactory(e){throw function jR(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 Ff=(()=>{class n{}return n.NULL=new GR,n})();function zR(){return ic(Dr(),Me())}function ic(n,e){return new sc(Vi(n,e))}let sc=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=zR,n})();class fw{}let QR=(()=>{class n{}return n.\u0275prov=Gn({token:n,providedIn:"root",factory:()=>null}),n})();class ig{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const YR=new ig("14.2.0"),sg={};function lg(n){return n.ngOriginalError}class oc{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&&lg(e);for(;t&&lg(t);)t=lg(t);return t||null}}const fg=new Map;let cP=0;const hg="__ngContext__";function Vr(n,e){li(e)?(n[hg]=e[20],function lP(n){fg.set(n[20],n)}(e)):n[hg]=e}function Bu(n){const e=n[hg];return"number"==typeof e?function vw(n){return fg.get(n)||null}(e):e||null}function pg(n){const e=Bu(n);return e?li(e)?e:e.lView:null}var fi=(()=>((fi=fi||{})[fi.Important=1]="Important",fi[fi.DashCase=2]="DashCase",fi))();function yg(n,e){return undefined(n,e)}function Fu(n){const e=n[3];return ss(e)?e[3]:e}function mg(n){return Cw(n[13])}function vg(n){return Cw(n[4])}function Cw(n){for(;null!==n&&!ss(n);)n=n[4];return n}function cc(n,e,t,r,i){if(null!=r){let s,o=!1;ss(r)?s=r:li(r)&&(o=!0,r=r[0]);const a=dr(r);0===n&&null!==t?null==i?Pw(e,t,a):da(e,t,a,i||null,!0):1===n&&null!==t?da(e,t,a,i||null,!0):2===n?function Fw(n,e,t){const r=Uf(n,e);r&&function BP(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function VP(n,e,t,r,i){const s=t[7];s!==dr(t)&&cc(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=Cf(n,10+e);!function xP(n,e){Uu(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 Aw(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&Uu(n,e,t,3,null,null),function NP(n){let e=n[13];if(!e)return _g(n[1],n);for(;e;){let t=null;if(li(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)li(e)&&_g(e[1],e),e=e[3];null===e&&(e=n),li(e)&&_g(e[1],e),t=e&&e[4]}e=t}}(e)}}function _g(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function LP(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=_]():r[i=-_].unsubscribe(),s+=2}else{const o=r[i=t[s+1]];t[s].call(o)}if(null!==r){for(let s=i+1;ss?"":i[N+1].toLowerCase();const V=8&r?B:null;if(V&&-1!==Hw(V,_,0)||2&r&&_!==B){if(as(r))return!1;o=!0}}}}else{if(!o&&!as(r)&&!as(l))return!1;if(o&&as(l))continue;o=!1,r=l|1&r}}return as(r)||o}function as(n){return 0==(1&n)}function GP(n,e,t,r){if(null===e)return-1;let i=0;if(r||!t){let s=!1;for(;i-1)for(t++;t0?'="'+a+'"':"")+"]"}else 8&r?i+="."+o:4&r&&(i+=" "+o);else""!==i&&!as(o)&&(e+=Gw(s,i),i=""),r=o,s=s||!as(r);t++}return""!==i&&(e+=Gw(s,i)),e}const At={};function Vu(n){zw(sn(),Me(),ti()+n,!1)}function zw(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&mf(e,s,t)}else{const s=n.preOrderHooks;null!==s&&vf(e,s,0,t)}Co(t)}function Yw(n,e=null,t=null,r){const i=Zw(n,e,t,r);return i.resolveInjectorInitializers(),i}function Zw(n,e=null,t=null,r,i=new Set){const s=[t||mn,MR(n)];return r=r||("object"==typeof n?void 0:dn(n)),new aw(s,e||Bf(),r||null,i)}let ha=(()=>{class n{static create(t,r){if(Array.isArray(t))return Yw({name:""},r,t,"");{const i=t.name??"";return Yw({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=xu,n.NULL=new nw,n.\u0275prov=Gn({token:n,providedIn:"any",factory:()=>wn(ew)}),n.__NG_ELEMENT_ID__=-1,n})();function Kt(n,e=St.Default){const t=Me();return null===t?wn(n,e):bb(Dr(),t,bt(n),e)}function p_(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&zw(n,e,22,!1),t(r,i)}finally{Co(s)}}function Kg(n,e,t){!tb()||(function UN(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||Su(t,e),Vr(r,e);const o=t.initialInputs;for(let a=i;a0;){const t=n[--e];if("number"==typeof t&&t<0)return t}return 0})(a)!=l&&a.push(l),a.push(r,i,o)}}function D_(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function S_(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function $N(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Wg(t)}}function Wg(n){for(let r=mg(n);null!==r;r=vg(r))for(let i=10;i0&&Wg(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Wg(i)}}function YN(n,e){const t=Ii(e,n),r=t[1];(function ZN(n,e){for(let t=e.length;t-1&&(wg(e,r),Cf(t,r))}this._attachedToViewContainer=!1}Aw(this._lView[1],this._lView)}onDestroy(e){!function v_(n,e,t,r){const i=x_(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&R_(n).push(r,i.length-1))}(this._lView[1],this._lView,null,e)}markForCheck(){qg(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-65}reattach(){this._lView[2]|=64}detectChanges(){!function Qg(n,e,t){const r=e[10];r.begin&&r.begin();try{Hu(n,e,n.template,t)}catch(i){throw N_(e,i),i}finally{r.end&&r.end()}}(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new mt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function PP(n,e){Uu(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new mt(902,!1);this._appRef=e}}class JN extends Ku{constructor(e){super(e),this._view=e}detectChanges(){!function A_(n){!function XN(n){for(let e=0;e0&&Ig(_,N,Ie.join(" "))}if(fe=_p(Y,22),void 0!==t){const ae=fe.projection=[];for(let Ie=0;Iea(dr(Fe[r.index])):r.index;let Ie=null;if(!a&&l&&(Ie=function IM(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;sl?a[l]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==Ie)(Ie.__ngLastListenerFn__||Ie).__ngNextListenerFn__=s,Ie.__ngLastListenerFn__=s,V=!1;else{s=X_(r,e,N,s,!1);const Fe=t.listen(fe,i,s);B.push(s,Fe),R&&R.push(i,ae,Se,Se+1)}}else s=X_(r,e,N,s,!1);const Y=r.outputs;let X;if(V&&null!==Y&&(X=Y[i])){const ie=X.length;if(ie)for(let fe=0;fet()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class my extends class p3{}{constructor(e){super(),this.moduleType=e}create(e){return new gD(this.moduleType,e)}}function Ey(n){return e=>{setTimeout(n,void 0,e)}}const Js=class j3 extends Qr{constructor(e=!1){super(),this.__isAsync=e}emit(e){super.next(e)}subscribe(e,t,r){let i=e,s=t||(()=>null),o=r;if(e&&"object"==typeof e){const l=e;i=l.next?.bind(l),s=l.error?.bind(l),o=l.complete?.bind(l)}this.__isAsync&&(s=Ey(s),i&&(i=Ey(i)),o&&(o=Ey(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let eo=(()=>{class n{}return n.__NG_ELEMENT_ID__=q3,n})();const z3=eo,W3=class extends z3{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=zf(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)),Wf(r,i,e),new Ku(i)}};function q3(){return function od(n,e){return 4&n.type?new W3(e,n,ic(n,e)):null}(Dr(),Me())}let Ms=(()=>{class n{}return n.__NG_ELEMENT_ID__=Q3,n})();function Q3(){return function RD(n,e){let t;const r=e[n.index];if(ss(r))t=r;else{let i;if(8&n.type)i=dr(r);else{const s=e[11];i=s.createComment("");const o=Vi(n,e);da(s,Uf(s,o),i,function FP(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=T_(r,e,i,n),qf(e,t)}return new AD(t,n,e)}(Dr(),Me())}const Y3=Ms,AD=class extends Y3{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return ic(this._hostTNode,this._hostLView)}get injector(){return new Wa(this._hostTNode,this._hostLView)}get parentInjector(){const e=_f(this._hostTNode,this._hostLView);if(gb(e)){const t=za(e,this._hostLView),r=Ga(e);return new Wa(t[1].data[r+8],t)}return new Wa(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=xD(this._lContainer);return null!==t&&t[e]||null}get length(){return this._lContainer.length-10}createEmbeddedView(e,t,r){let i,s;"number"==typeof r?i=r:null!=r&&(i=r.index,s=r.injector);const o=e.createEmbeddedView(t||{},s);return this.insert(o,i),o}createComponent(e,t,r,i,s){const o=e&&!function Tu(n){return"function"==typeof n}(e);let a;if(o)a=t;else{const N=t||{};a=N.index,r=N.injector,i=N.projectableNodes,s=N.environmentInjector||N.ngModuleRef}const l=o?e:new $u(Sn(e)),_=r||this.parentInjector;if(!s&&null==l.ngModule){const B=(o?_:this.parentInjector).get(nc,null);B&&(s=B)}const R=l.create(_,i,void 0,s);return this.insert(R.hostView,a),R}insert(e,t){const r=e._lView,i=r[1];if(function JA(n){return ss(n[3])}(r)){const R=this.indexOf(e);if(-1!==R)this.detach(R);else{const N=r[3],B=new AD(N,N[6],N[3]);B.detach(B.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function MP(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=cd,this.reject=cd,this.initialized=!1,this.done=!1,this.donePromise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}runInitializers(){if(this.initialized)return;const t=[],r=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let i=0;i{s.subscribe({complete:a,error:l})});t.push(o)}}Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),0===t.length&&r(),this.initialized=!0}}return n.\u0275fac=function(t){return new(t||n)(wn(eS,8))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const el=new Xt("AppId",{providedIn:"root",factory:function tS(){return`${Py()}${Py()}${Py()}`}});function Py(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const nS=new Xt("Platform Initializer"),rS=new Xt("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),xk=new Xt("appBootstrapListener"),to=new Xt("LocaleId",{providedIn:"root",factory:()=>function qx(n,e=St.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),wn(n,e)}(to,St.Optional|St.SkipSelf)||function Rk(){return typeof $localize<"u"&&$localize.locale||Sc}()}),kk=(()=>Promise.resolve(0))();function Ny(n){typeof Zone>"u"?kk.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class Kr{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new Js(!1),this.onMicrotaskEmpty=new Js(!1),this.onStable=new Js(!1),this.onError=new Js(!1),typeof Zone>"u")throw new mt(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 Lk(){let n=On.requestAnimationFrame,e=On.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 Uk(n){const e=()=>{!function Fk(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(On,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,Oy(n),n.isCheckStableRunning=!0,My(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),Oy(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return oS(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),aS(n)}},onInvoke:(t,r,i,s,o,a,l)=>{try{return oS(n),t.invoke(i,s,o,a,l)}finally{n.shouldCoalesceRunChangeDetection&&e(),aS(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,Oy(n),My(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(!Kr.isInAngularZone())throw new mt(909,!1)}static assertNotInAngularZone(){if(Kr.isInAngularZone())throw new mt(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,Bk,cd,cd);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 Bk={};function My(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 Oy(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function oS(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function aS(n){n._nesting--,My(n)}class Vk{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new Js,this.onMicrotaskEmpty=new Js,this.onStable=new Js,this.onError=new Js}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 cS=new Xt(""),ld=new Xt("");let By,ky=(()=>{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,By||(function Hk(n){By=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:()=>{Kr.assertNotInAngularZone(),Ny(()=>{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())Ny(()=>{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)(wn(Kr),wn(Ly),wn(ld))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac}),n})(),Ly=(()=>{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 By?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Gn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),Ro=null;const uS=new Xt("AllowMultipleToken"),Fy=new Xt("PlatformDestroyListeners");function fS(n,e,t=[]){const r=`Platform: ${e}`,i=new Xt(r);return(s=[])=>{let o=Uy();if(!o||o.injector.get(uS,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function jk(n){if(Ro&&!Ro.get(uS,!1))throw new mt(400,!1);Ro=n;const e=n.get(hS);(function lS(n){const e=n.get(nS,null);e&&e.forEach(t=>t())})(n)}(function dS(n=[],e){return ha.create({name:e,providers:[{provide:eg,useValue:"platform"},{provide:Fy,useValue:new Set([()=>Ro=null])},...n]})}(a,r))}return function zk(n){const e=Uy();if(!e)throw new mt(401,!1);return e}()}}function Uy(){return Ro?.get(hS)??null}let hS=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function gS(n,e){let t;return t="noop"===n?new Vk:("zone.js"===n?void 0:n)||new Kr(e),t}(r?.ngZone,function pS(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:Kr,useValue:i}];return i.run(()=>{const o=ha.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),l=a.injector.get(oc,null);if(!l)throw new mt(402,!1);return i.runOutsideAngular(()=>{const _=i.onError.subscribe({next:R=>{l.handleError(R)}});a.onDestroy(()=>{fd(this._modules,a),_.unsubscribe()})}),function yS(n,e,t){try{const r=t();return sy(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}(l,i,()=>{const _=a.injector.get(ud);return _.runInitializers(),_.donePromise.then(()=>(function j1(n){Di(n,"Expected localeId to be defined"),"string"==typeof n&&($1=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(to,Sc)||Sc),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=mS({},r);return function Kk(n,e,t){const r=new my(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get(Vy);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new mt(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 mt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(Fy,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)(wn(ha))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function mS(n,e){return Array.isArray(e)?e.reduce(mS,n):{...n,...e}}let Vy=(()=>{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 cn(a=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{a.next(this._stable),a.complete()})}),o=new cn(a=>{let l;this._zone.runOutsideAngular(()=>{l=this._zone.onStable.subscribe(()=>{Kr.assertNotInAngularZone(),Ny(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const _=this._zone.onUnstable.subscribe(()=>{Kr.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{l.unsubscribe(),_.unsubscribe()}});this.isStable=Yr(s,o.pipe(function ns(n={}){const{connector:e=(()=>new Qr),resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,l,_=0,R=!1,N=!1;const B=()=>{a?.unsubscribe(),a=void 0},V=()=>{B(),o=l=void 0,R=N=!1},Y=()=>{const X=o;V(),X?.unsubscribe()};return le((X,ie)=>{_++,!N&&!R&&B();const fe=l=l??e();ie.add(()=>{_--,0===_&&!N&&!R&&(a=_o(Y,i))}),fe.subscribe(ie),!o&&_>0&&(o=new ve({next:Se=>fe.next(Se),error:Se=>{N=!0,B(),a=_o(V,t,Se),fe.error(Se)},complete:()=>{R=!0,B(),a=_o(V,r),fe.complete()}}),An(X).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof uw;if(!this._injector.get(ud).done)throw!i&&function mu(n){const e=Sn(n)||Xr(n)||Jr(n);return null!==e&&e.standalone}(t),new mt(405,false);let o;o=i?t:this._injector.get(Ff).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function $k(n){return n.isBoundToModule}(o)?void 0:this._injector.get(Ic),_=o.create(ha.NULL,[],r||o.selector,a),R=_.location.nativeElement,N=_.injector.get(cS,null);return N?.registerApplication(R),_.onDestroy(()=>{this.detachView(_.hostView),fd(this.components,_),N?.unregisterApplication(R)}),this._loadComponent(_),_}tick(){if(this._runningTick)throw new mt(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;fd(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(xk,[]).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),()=>fd(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new mt(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)(wn(Kr),wn(nc),wn(oc))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function fd(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let ES=!0;class SS{constructor(){}supports(e){return ju(e)}create(e){return new rL(e)}}const nL=(n,e)=>e;class rL{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||nL}forEachItem(e){let t;for(t=this._itHead;null!==t;t=t._next)e(t)}forEachOperation(e){let t=this._itHead,r=this._removalsHead,i=0,s=null;for(;t||r;){const o=!r||t&&t.currentIndex{o=this._trackByFn(i,a),null!==t&&Object.is(t.trackById,o)?(r&&(t=this._verifyReinsertion(t,a,o,i)),Object.is(t.item,a)||this._addIdentityChange(t,a)):(t=this._mismatch(t,a,o,i),r=!0),t=t._next,i++}),this.length=i;return this._truncate(t),this.collection=e,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;null!==e;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;null!==e;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,t,r,i){let s;return null===e?s=this._itTail:(s=e._prev,this._remove(e)),null!==(e=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._reinsertAfter(e,s,i)):null!==(e=null===this._linkedRecords?null:this._linkedRecords.get(r,i))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._moveAfter(e,s,i)):e=this._addAfter(new iL(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 CS),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 CS),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 iL{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 sL{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 CS{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new sL,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 IS(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||AS()),deps:[[n,new xf,new Af]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new mt(901,!1)}}return n.\u0275prov=Gn({token:n,providedIn:"root",factory:AS}),n})();const lL=fS(null,"core",[]);let fL=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(wn(Vy))},n.\u0275mod=yu({type:n}),n.\u0275inj=Ba({}),n})(),gd=null;function nl(){return gd}const ro=new Xt("DocumentToken");class n8{constructor(e,t,r,i){this.$implicit=e,this.ngForOf=t,this.index=r,this.count=i}get first(){return 0===this.index}get last(){return this.index===this.count-1}get even(){return this.index%2==0}get odd(){return!this.even}}let HS=(()=>{class n{constructor(t,r,i){this._viewContainer=t,this._template=r,this._differs=i,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForOf(t){this._ngForOf=t,this._ngForOfDirty=!0}set ngForTrackBy(t){this._trackByFn=t}get ngForTrackBy(){return this._trackByFn}set ngForTemplate(t){t&&(this._template=t)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;const t=this._ngForOf;!this._differ&&t&&(this._differ=this._differs.find(t).create(this.ngForTrackBy))}if(this._differ){const t=this._differ.diff(this._ngForOf);t&&this._applyChanges(t)}}_applyChanges(t){const r=this._viewContainer;t.forEachOperation((i,s,o)=>{if(null==i.previousIndex)r.createEmbeddedView(this._template,new n8(i.item,this._ngForOf,-1,-1),null===o?void 0:o);else if(null==o)r.remove(null===s?void 0:s);else if(null!==s){const a=r.get(s);r.move(a,o),KS(a,i)}});for(let i=0,s=r.length;i{KS(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(Kt(Ms),Kt(eo),Kt(pd))},n.\u0275dir=Bi({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function KS(n,e){n.context.$implicit=e.item}let N8=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=yu({type:n}),n.\u0275inj=Ba({}),n})();class a0 extends class t4 extends class pL{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function hL(n){gd||(gd=n)}(new a0)}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 n4(){return ol=ol||document.querySelector("base"),ol?ol.getAttribute("href"):null}();return null==t?null:function r4(n){Id=Id||document.createElement("a"),Id.setAttribute("href",n);const e=Id.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){ol=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function JL(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 Id,ol=null;const ZS=new Xt("TRANSITION_ID"),s4=[{provide:eS,useFactory:function i4(n,e,t){return()=>{t.get(ud).donePromise.then(()=>{const r=nl(),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=Gn({token:n,factory:n.\u0275fac}),n})();const Td=new Xt("EventManagerPlugins");let Ad=(()=>{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=Gn({token:n,factory:n.\u0275fac}),n})(),al=(()=>{class n extends JS{constructor(t){super(),this._doc=t,this._hostNodes=new Map,this._hostNodes.set(t.head,[])}_addStylesToHost(t,r,i){t.forEach(s=>{const o=this._doc.createElement("style");o.textContent=s,i.push(r.appendChild(o))})}addHost(t){const r=[];this._addStylesToHost(this._stylesSet,t,r),this._hostNodes.set(t,r)}removeHost(t){const r=this._hostNodes.get(t);r&&r.forEach(eC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(eC))}}return n.\u0275fac=function(t){return new(t||n)(wn(ro))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac}),n})();function eC(n){nl().remove(n)}const c0={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/"},u0=/%COMP%/g;function xd(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let l0=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new f0(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case Cs.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new h4(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case Cs.ShadowDom:return new p4(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=xd(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)(wn(Ad),wn(al),wn(el))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac}),n})();class f0{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(c0[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(sC(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(sC(e)?e.content:e).insertBefore(t,r)}removeChild(e,t){e&&e.removeChild(t)}selectRootElement(e,t){let r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error(`The selector "${e}" did not match any elements`);return t||(r.textContent=""),r}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,t,r,i){if(i){t=i+":"+t;const s=c0[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=c0[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&(fi.DashCase|fi.Important)?e.style.setProperty(t,r,i&fi.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&fi.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,rC(r)):this.eventManager.addEventListener(e,t,rC(r))}}function sC(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class h4 extends f0{constructor(e,t,r,i){super(e),this.component=r;const s=xd(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function l4(n){return"_ngcontent-%COMP%".replace(u0,n)}(i+"-"+r.id),this.hostAttr=function f4(n){return"_nghost-%COMP%".replace(u0,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 p4 extends f0{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=xd(i.id,i.styles,[]);for(let o=0;o{class n extends XS{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)(wn(ro))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac}),n})();const oC=["alt","control","meta","shift"],y4={"\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"},m4={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let v4=(()=>{class n extends XS{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(()=>nl().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."),oC.forEach(_=>{const R=r.indexOf(_);R>-1&&(r.splice(R,1),o+=_+".")}),o+=s,0!=r.length||0===s.length)return null;const l={};return l.domEventName=i,l.fullKey=o,l}static matchEventFullKeyCode(t,r){let i=y4[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"),oC.forEach(o=>{o!==i&&(0,m4[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)(wn(ro))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac}),n})();const cC=[{provide:rS,useValue:"browser"},{provide:nS,useValue:function E4(){a0.makeCurrent()},multi:!0},{provide:ro,useFactory:function w4(){return function aR(n){Gp=n}(document),document},deps:[]}],_4=fS(lL,"browser",cC),uC=new Xt(""),lC=[{provide:ld,useClass:class o4{addToWindow(e){On.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},On.getAllAngularTestabilities=()=>e.getAllTestabilities(),On.getAllAngularRootElements=()=>e.getAllRootElements(),On.frameworkStabilizers||(On.frameworkStabilizers=[]),On.frameworkStabilizers.push(r=>{const i=On.getAllAngularTestabilities();let s=i.length,o=!1;const a=function(l){o=o||l,s--,0==s&&r(o)};i.forEach(function(l){l.whenStable(a)})})}findTestabilityInTree(e,t,r){return null==t?null:e.getTestability(t)??(r?nl().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:cS,useClass:ky,deps:[Kr,Ly,ld]},{provide:ky,useClass:ky,deps:[Kr,Ly,ld]}],fC=[{provide:eg,useValue:"root"},{provide:oc,useFactory:function b4(){return new oc},deps:[]},{provide:Td,useClass:g4,multi:!0,deps:[ro,Kr,rS]},{provide:Td,useClass:v4,multi:!0,deps:[ro]},{provide:l0,useClass:l0,deps:[Ad,al,el]},{provide:fw,useExisting:l0},{provide:JS,useExisting:al},{provide:al,useClass:al,deps:[ro]},{provide:Ad,useClass:Ad,deps:[Td,Kr]},{provide:class B8{},useClass:a4,deps:[]},[]];let D4=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:el,useValue:t.appId},{provide:ZS,useExisting:el},s4]}}}return n.\u0275fac=function(t){return new(t||n)(wn(uC,12))},n.\u0275mod=yu({type:n}),n.\u0275inj=Ba({providers:[...fC,...lC],imports:[N8,fL]}),n})();typeof window<"u"&&window;class M4 extends Qr{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 pC(n,e,t,r,i,s,o){try{var a=n[s](o),l=a.value}catch(_){return void t(_)}a.done?e(l):Promise.resolve(l).then(r,i)}function j(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(l){pC(s,r,i,o,a,"next",l)}function a(l){pC(s,r,i,o,a,"throw",l)}o(void 0)})}}var O4=x(6883),p0=x(6685),gC=x(3857),yC=x(5749);const k4={hashSHA256:n=>(0,gC.vp)(n),getHKDF(n,e){const i=new O4.t(gC.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=p0.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=p0._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>p0.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new yC.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new yC.OK(r).open(e,n,t)};function mC(n){this.wrapped=n}function cl(n){var e,t;function i(o,a){try{var l=n[o](a),_=l.value,R=_ instanceof mC;Promise.resolve(R?_.wrapped:_).then(function(N){R?i("return"===o?"return":"next",N):s(l.done?"return":"normal",N)},function(N){i("throw",N)})}catch(N){s("throw",N)}}function s(o,a){switch(o){case"return":e.resolve({value:a,done:!0});break;case"throw":e.reject(a);break;default:e.resolve({value:a,done:!1})}(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function r(o,a){return new Promise(function(l,_){var R={key:o,arg:a,resolve:l,reject:_,next:null};t?t=t.next=R:(e=t=R,i(o,a))})},"function"!=typeof n.return&&(this.return=void 0)}function on(n){return function(){return new cl(n.apply(this,arguments))}}function tt(n){return new mC(n)}function wt(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 Rd(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function Rd(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(Rd=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 Rd(n)}function Rr(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 No(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(n):new Uint8Array(n)}function xc(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}function yr(n,e){e||(e=n.reduce((i,s)=>i+s.length,0));const t=xc(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return t}function Pr(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(!g0(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(!g0(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=EC(this.bufs,e);return t.buf[t.index]}set(e,t){const r=EC(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 yr(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:yr(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new jr;return s.length=i,s.bufs=r,s}_subList(e,t){if((e=e??0)<0&&(e=this.length+e),(t=t??this.length)<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:[...this.bufs],length:this.length};const r=[];let i=0;for(let s=0;s=l)continue;const _=e>=a&&ea&&t<=l;if(_&&R){if(e===a&&t===l){r.push(o);break}const N=e-a;r.push(o.subarray(N,N+(t-e)));break}if(_){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(R){if(t===l){r.push(o);break}r.push(o.subarray(0,t-a));break}r.push(o)}}return{bufs:r,length:t-e}}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=xc(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=No(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=No(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=No(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=xc(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=No(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=No(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=No(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=No(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=No(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}equals(e){if(null==e||!(e instanceof jr)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class bC{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 y0{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new bC(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 bC(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 Rc(n={}){return wC(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 wC(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new y0;const a=function(){var X=j(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((ie,fe)=>{s=Se=>{s=null,r.push(Se);try{ie(n(r))}catch(ae){fe(ae)}return i}}):n(r)});return function(){return X.apply(this,arguments)}}(),l=X=>null!=s?s(X):(r.push(X),i),R=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 l({done:!1,value:X})},N=X=>o?i:(o=!0,null!=X?(X=>(r=new y0,null!=s?s({error:X}):(r.push({error:X}),i)))(X):l({done:!0}));if(i={[Symbol.asyncIterator](){return this},next:a,return:()=>(r=new y0,N(),{done:!0}),throw:X=>(N(X),{done:!0}),push:R,end:N,get readableLength(){return r.size}},null==t)return i;const Y=i;return i={[Symbol.asyncIterator](){return this},next:()=>Y.next(),throw:X=>(Y.throw(X),null!=t&&(t(X),t=void 0),{done:!0}),return:()=>(Y.return(),null!=t&&(t(),t=void 0),{done:!0}),push:R,end:X=>(Y.end(X),null!=t&&(t(X),t=void 0),i),get readableLength(){return Y.readableLength}},i}function m0(){const n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}function Pd(n){const e=Rc(),t=function L4(n){const e=on(function*(){let t=yield,r=new jr;var o,i=!1,s=!1;try{for(var l,a=wt(n);i=!(l=yield tt(a.next())).done;i=!1){const _=l.value;if(null!=t)for(r.append(_);r.length>=t;){const R=r.sublist(0,t);if(r.consume(t),t=yield R,null==t){r.length>0&&(t=yield r,r=new jr);break}}else r.append(_),t=yield r,r=new jr}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield tt(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=m0();let i;const s=n.sink(on(function*(){yield*Rr(wt(e),tt);const a=yield tt(r.promise);yield*Rr(wt(a),tt)})());s.catch(a=>{i=a});const o={sink:(a=j(function*(l){return null!=i?yield Promise.reject(i):(r.resolve(l),yield s)}),function(_){return a.apply(this,arguments)}),source:t};var a;return{reader:t,writer:e,stream:o,rest:()=>e.end(),write:e.push,read:function(){var a=j(function*(){const l=yield t.next();if(null!=l.value)return l.value});return function(){return a.apply(this,arguments)}}()}}function _C(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 DC=4294967296;class ji{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 ji((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new ji(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=_C(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 ji;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>DC&&(i=0,++r>DC&&(r=0))),new ji(r,i)}static fromNumber(e){if(0===e)return new ji;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 ji(i,r)}static fromBytes(e,t=0){const r=_C(e),i=new ji;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 F4=Math.pow(2,7),U4=Math.pow(2,14),V4=Math.pow(2,21),H4=Math.pow(2,28),K4=Math.pow(2,35),$4=Math.pow(2,42),j4=Math.pow(2,49),G4=Math.pow(2,56),z4=Math.pow(2,63),Ri={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=xc(Ri.encodingLength(n))),ji.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>ji.fromBytes(n,e).toNumber(!0)},Nd=n=>{const e=Ri.encodingLength(n),t=function q4(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Ri.encode(n,t),Nd.bytes=e,t};function Os(n){const e=(n=n??{}).lengthEncoder??Nd;return function(){var r=on(function*(i){var a,s=!1,o=!1;try{for(var _,l=wt(i);s=!(_=yield tt(l.next())).done;s=!1){const R=_.value,N=e(R.byteLength);N instanceof Uint8Array?yield N:yield*Rr(wt(N),tt),R instanceof Uint8Array?yield R:yield*Rr(wt(R),tt)}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield tt(l.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Nd.bytes=0,Os.single=(n,e)=>new jr(((e=e??{}).lengthEncoder??Nd)(n.byteLength),n);var se=x(8798),Mo=(()=>{return(n=Mo||(Mo={}))[n.LENGTH=0]="LENGTH",n[n.DATA=1]="DATA",Mo;var n})();const v0=n=>{const e=Ri.decode(n);return v0.bytes=Ri.encodingLength(e),e};function ps(n){return function(){var t=on(function*(r){const i=new jr;let s=Mo.LENGTH,o=-1;const a=n?.lengthDecoder??v0,l=n?.maxLengthLength??8,_=n?.maxDataLength??4194304;var B,R=!1,N=!1;try{for(var Y,V=wt(r);R=!(Y=yield tt(V.next())).done;R=!1)for(i.append(Y.value);i.byteLength>0;){if(s===Mo.LENGTH)try{if(o=a(i),o<0)throw se(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>_)throw se(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");i.consume(a.bytes),null!=n?.onLength&&n.onLength(o),s=Mo.DATA}catch(ie){if(ie instanceof RangeError){if(i.byteLength>l)throw se(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw ie}if(s===Mo.DATA){if(i.byteLength0)throw se(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function SC(n,e={}){const t=Pd(n),r=ps.fromReader(t.reader,e),i={read:(s=j(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=j(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=j(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const l=a instanceof Uint8Array?a:a.slice();return o.decode(l)});return function(a){return s.apply(this,arguments)}}(),write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(Os.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=j(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 CC(){const n=m0();let e=!1;return{sink:(t=j(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:on(function*(){const t=yield tt(n.promise);yield*Rr(wt(t),tt)})()};var t}v0.bytes=0,ps.fromReader=(n,e)=>{let t=1;const r=on(function*(){for(;;)try{const{done:s,value:o}=yield tt(n.next(t));if(!0===s)return;null!=o&&(yield o)}catch(s){if("ERR_UNDER_READ"===s.code)return{done:!0,value:null};throw s}finally{t=1}})();return ps({...e??{},onLength:s=>{t=s}})(r)};var Md=x(901);const IC=n=>null!=n&&("function"==typeof n[Symbol.asyncIterator]||"function"==typeof n[Symbol.iterator]||"function"==typeof n.next),E0=n=>null!=n&&"function"==typeof n.sink&&IC(n.source),J4=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=Rc({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),Md(r,function(){var s=on(function*(){yield*Rr(wt(n.source),tt),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function zn(n,...e){if(E0(n)){const r=n;n=()=>r.source}else if(IC(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&E0(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 ul=65535,eB=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS),Od=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};Od.bytes=2;const kd=n=>{if(n.length<2)throw RangeError("Could not decode int16BE");return n instanceof Uint8Array?new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,!1):n.getUint16(0)};kd.bytes=2;class Ld extends Error{constructor(e="Unexpected Peer"){super(e),this.code=Ld.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class Pc extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Pc.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;var b0=x(7981),w0=x.n(b0);const _0=b0.Reader;function kt(n,e){const t=_0.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=_0.prototype[n];_0.prototype[n]=function(){return BigInt(e.call(this).toString())}});const D0=b0.Writer;function Lt(n,e){const t=D0.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=D0.prototype[n];D0.prototype[n]=function(t){return e.call(this,t.toString())}});var ll=(()=>{return(n=ll||(ll={}))[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",ll;var n})();function xC(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Oo(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return xC("enum",ll.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function Bt(n,e){return xC("message",ll.LENGTH_DELIMITED,n,e)}var Nc,Mc,Xn=(()=>{return(n=Xn||(Xn={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",Xn;var n})(),Bd=(()=>{return(n=Bd||(Bd={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",Bd;var n})();(Xn||(Xn={})).codec=()=>Oo(Bd),function(n){let e;n.codec=()=>(null==e&&(e=Bt((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),Xn.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:Xn.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=Xn.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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Nc||(Nc={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((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),Xn.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:Xn.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=Xn.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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Mc||(Mc={})),x(607),x(4291);var kn=x(340);const hB=function lB(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,ae=new Uint8Array(Se);Y[X];){var Ie=t[Y.charCodeAt(X)];if(255===Ie)return;for(var Fe=0,Te=Se-1;(0!==Ie||Fe>>0)%256>>>0,Ie=Ie/256>>>0;if(0!==Ie)throw new Error("Non-zero carry");fe=Fe,X++}if(" "!==Y[X]){for(var dt=Se-fe;dt!==Se&&0===ae[dt];)dt++;for(var ut=new Uint8Array(ie+(Se-dt)),an=ie;dt!==Se;)ut[an++]=ae[dt++];return ut}}}return{encode:function N(Y){if(Y instanceof Uint8Array||(ArrayBuffer.isView(Y)?Y=new Uint8Array(Y.buffer,Y.byteOffset,Y.byteLength):Array.isArray(Y)&&(Y=Uint8Array.from(Y))),!(Y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===Y.length)return"";for(var X=0,ie=0,fe=0,Se=Y.length;fe!==Se&&0===Y[fe];)fe++,X++;for(var ae=(Se-fe)*R+1>>>0,Ie=new Uint8Array(ae);fe!==Se;){for(var Fe=Y[fe],Te=0,dt=ae-1;(0!==Fe||Te>>0)%a>>>0,Fe=Fe/a>>>0;if(0!==Fe)throw new Error("Non-zero carry");ie=Te,fe++}for(var ut=ae-ie;ut!==ae&&0===Ie[ut];)ut++;for(var an=l.repeat(X);ut{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 vB{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 EB{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 RC(this,e)}}class bB{constructor(e){this.decoders=e}or(e){return RC(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 RC=(n,e)=>new bB({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class wB{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new vB(e,t,r),this.decoder=new EB(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Fd=({name:n,prefix:e,encode:t,decode:r})=>new wB(n,e,t,r),fl=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=hB(t,e);return Fd({prefix:n,name:e,encode:r,decode:s=>Oc(i(s))})},Nr=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>Fd({prefix:e,name:n,encode:i=>((n,e,t)=>{const r="="===e[e.length-1],i=(1<t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<((n,e,t,r)=>{const i={};for(let R=0;R=8&&(a-=8,o[_++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),SB=Fd({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),CB=Nr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),IB=Nr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),TB=fl({prefix:"9",name:"base10",alphabet:"0123456789"}),AB=Nr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xB=Nr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),so=Nr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),RB=Nr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),PB=Nr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),NB=Nr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),MB=Nr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),OB=Nr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),kB=Nr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),LB=Nr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),BB=Nr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),FB=fl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),UB=fl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),si=fl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),VB=fl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Ud=Nr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),HB=Nr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),KB=Nr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$B=Nr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),PC=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}"),jB=PC.reduce((n,e,t)=>(n[t]=e,n),[]),GB=PC.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),qB=Fd({prefix:"\u{1f680}",name:"base256emoji",encode:function zB(n){return n.reduce((e,t)=>e+jB[t],"")},decode:function WB(n){const e=[];for(const t of n){const r=GB[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var XB=Math.pow(2,31),tF=Math.pow(2,7),nF=Math.pow(2,14),rF=Math.pow(2,21),iF=Math.pow(2,28),sF=Math.pow(2,35),oF=Math.pow(2,42),aF=Math.pow(2,49),cF=Math.pow(2,56),uF=Math.pow(2,63),fF={encode:function MC(n,e,t){e=e||[];for(var r=t=t||0;n>=XB;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,MC.bytes=t-r+1,e},decode:function S0(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw S0.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return S0.bytes=s-r,t},encodingLength:function(n){return n[Vd.decode(n),Vd.decode.bytes],Hd=(n,e,t=0)=>(Vd.encode(n,e,t),e),Kd=n=>Vd.encodingLength(n),kc=(n,e)=>{const t=e.byteLength,r=Kd(n),i=r+Kd(t),s=new Uint8Array(i+t);return Hd(n,s,0),Hd(t,s,r),s.set(e,i),new I0(n,t,e,s)},$d=n=>{const e=Oc(n),[t,r]=C0(e),[i,s]=C0(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new I0(t,i,o,e)};class I0{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const kC=({name:n,code:e,encode:t})=>new pF(n,e,t);class pF{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?kc(this.code,t):t.then(r=>kc(this.code,r))}throw Error("Unknown type, must be binary type")}}const LC=n=>function(){var e=j(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),hi=kC({name:"sha2-256",code:18,encode:LC("SHA-256")}),gF=kC({name:"sha2-512",code:19,encode:LC("SHA-512")}),FC=Oc,Lc={code:0,name:"identity",encode:FC,digest:n=>kc(0,FC(n))},mF="raw",vF=85,EF=n=>Oc(n),bF=n=>Oc(n),wF=new TextEncoder,_F=new TextDecoder,DF="json",SF=512,CF=n=>wF.encode(JSON.stringify(n)),IF=n=>JSON.parse(_F.decode(n));class mr{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:Gd,byteLength:Gd,code:jd,version:jd,multihash:jd,bytes:jd,_baseCache:Gd,asCID:Gd})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==dl)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==RF)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return mr.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=kc(e,t);return mr.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((n,e)=>n===e||n.code===e.code&&n.size===e.size&&((n,e)=>{if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t{const[N,B]=C0(e.subarray(t));return t+=B,N};let i=r(),s=dl;if(18===i?(i=0,t=0):1===i&&(s=r()),0!==i&&1!==i)throw new RangeError(`Invalid CID version ${i}`);const o=t,a=r(),l=r(),_=t+l;return{version:i,codec:s,multihashCode:a,digestSize:l,multihashSize:_-o,size:_}}static parse(e,t){const[r,i]=TF(e,t),s=mr.decode(i);return s._baseCache.set(r,e),s}}const TF=(n,e)=>{switch(n[0]){case"Q":return[si.prefix,(e||si).decode(`${si.prefix}${n}`)];case si.prefix:return[si.prefix,(e||si).decode(n)];case so.prefix:return[so.prefix,(e||so).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)]}},AF=(n,e,t)=>{const{prefix:r}=t;if(r!==si.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},xF=(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},dl=112,RF=18,UC=(n,e,t)=>{const r=Kd(n),i=r+Kd(e),s=new Uint8Array(i+t.byteLength);return Hd(n,s,0),Hd(e,s,r),s.set(t,i),s},VC=Symbol.for("@ipld/js-cid/CID"),jd={writable:!1,configurable:!1,enumerable:!0},Gd={writable:!1,enumerable:!1,configurable:!1},NF=(n,e)=>{if(!n.test("0.0.0-dev"))throw new Error(e);console.warn(e)},MF="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",hl={...y,...u,...g,...w,...m,...h,...c,...f,...d,...b};function HC(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const KC=HC("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),T0=HC("ascii","a",n=>{let e="a";for(let t=0;t{const e=xc((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=yr([new Uint8Array(e-t.length),t])}return Rt(t,"base64url")}function gs(n){const e=function BF(n,e){let t=xt(n,"base64urlpad");if(null!=e){if(t.length>e)throw new Error("byte array longer than desired length");t=yr([new Uint8Array(e-t.length),t])}return t}(n);return new kn.jsbn.BigInteger(Rt(e,"base16"),16)}x(3823);function qC(n){const e=n?.algorithm??"AES-GCM";let t=n?.keyLength??16;const r=n?.nonceLength??12,i=n?.digest??"SHA-256",s=n?.saltLength??16,o=n?.iterations??32767,a=ks.get();function _(){return(_=j(function*(V,Y){const X=a.getRandomValues(new Uint8Array(s)),ie=a.getRandomValues(new Uint8Array(r)),fe={name:e,iv:ie};"string"==typeof Y&&(Y=xt(Y));const Se={name:"PBKDF2",salt:X,iterations:o,hash:{name:i}},ae=yield a.subtle.importKey("raw",Y,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Ie=yield a.subtle.deriveKey(Se,ae,{name:e,length:t},!0,["encrypt"]),Fe=yield a.subtle.encrypt(fe,Ie,V);return yr([X,fe.iv,new Uint8Array(Fe)])})).apply(this,arguments)}function N(){return(N=j(function*(V,Y){const X=V.slice(0,s),ie=V.slice(s,s+r),fe=V.slice(s+r),Se={name:e,iv:ie};"string"==typeof Y&&(Y=xt(Y));const ae={name:"PBKDF2",salt:X,iterations:o,hash:{name:i}},Ie=yield a.subtle.importKey("raw",Y,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Fe=yield a.subtle.deriveKey(ae,Ie,{name:e,length:t},!0,["decrypt"]),Te=yield a.subtle.decrypt(Se,Fe,fe);return new Uint8Array(Te)})).apply(this,arguments)}return t*=8,{encrypt:function l(V,Y){return _.apply(this,arguments)},decrypt:function R(V,Y){return N.apply(this,arguments)}}}function VF(n,e){return N0.apply(this,arguments)}function N0(){return(N0=j(function*(n,e){const t=Ud.decode(n);return yield qC().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),x(9578);var HF=x(4490),KF=x.t(HF,2);const rn=BigInt(0),Wn=BigInt(1),ko=BigInt(2),pl=BigInt(3),$F=BigInt(8),Cn=Object.freeze({a:rn,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Wn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function QC(n){const{a:e,b:t}=Cn,r=Ze(n*n),i=Ze(r*n);return Ze(i+e*n+t)}const zd=Cn.a===rn;class M0 extends Error{constructor(e){super(e)}}class In{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof vn))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new In(e.x,e.y,Wn)}static toAffineBatch(e){const t=function qF(n,e=Cn.P){const t=new Array(n.length),i=Vc(n.reduce((s,o,a)=>o===rn?s:(t[a]=s,Ze(s*o,e)),Wn),e);return n.reduceRight((s,o,a)=>o===rn?s:(t[a]=Ze(s*t[a],e),Ze(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return In.toAffineBatch(e).map(In.fromAffine)}equals(e){if(!(e instanceof In))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,l=Ze(i*i),_=Ze(a*a),R=Ze(t*_),N=Ze(s*l),B=Ze(Ze(r*a)*_),V=Ze(Ze(o*i)*l);return R===N&&B===V}negate(){return new In(this.x,Ze(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=Ze(e*e),s=Ze(t*t),o=Ze(s*s),a=e+s,l=Ze(ko*(Ze(a*a)-i-o)),_=Ze(pl*i),R=Ze(_*_),N=Ze(R-ko*l),B=Ze(_*(l-N)-$F*o),V=Ze(ko*t*r);return new In(N,B,V)}add(e){if(!(e instanceof In))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===rn||o===rn)return this;if(t===rn||r===rn)return e;const l=Ze(i*i),_=Ze(a*a),R=Ze(t*_),N=Ze(s*l),B=Ze(Ze(r*a)*_),V=Ze(Ze(o*i)*l),Y=Ze(N-R),X=Ze(V-B);if(Y===rn)return X===rn?this.double():In.ZERO;const ie=Ze(Y*Y),fe=Ze(Y*ie),Se=Ze(R*ie),ae=Ze(X*X-fe-ko*Se),Ie=Ze(X*(Se-ae)-B*fe),Fe=Ze(i*a*Y);return new In(ae,Ie,Fe)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=In.ZERO;if("bigint"==typeof e&&e===rn)return t;let r=XC(e);if(r===Wn)return this;if(!zd){let N=t,B=this;for(;r>rn;)r&Wn&&(N=N.add(B)),B=B.double(),r>>=Wn;return N}let{k1neg:i,k1:s,k2neg:o,k2:a}=eI(r),l=t,_=t,R=this;for(;s>rn||a>rn;)s&Wn&&(l=l.add(R)),a&Wn&&(_=_.add(R)),R=R.double(),s>>=Wn,a>>=Wn;return i&&(l=l.negate()),o&&(_=_.negate()),_=new In(Ze(_.x*Cn.beta),_.y,_.z),l.add(_)}precomputeWindow(e){const t=zd?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=N,Y>l&&(Y-=R,e+=Wn),0===Y){let X=i[V];B%2&&(X=X.negate()),o=o.add(X)}else{let X=i[V+Math.abs(Y)-1];Y<0&&(X=X.negate()),s=s.add(X)}}return{p:s,f:o}}multiply(e,t){let i,s,r=XC(e);if(zd){const{k1neg:o,k1:a,k2neg:l,k2:_}=eI(r);let{p:R,f:N}=this.wNAF(a,t),{p:B,f:V}=this.wNAF(_,t);o&&(R=R.negate()),l&&(B=B.negate()),B=new In(Ze(B.x*Cn.beta),B.y,B.z),i=R.add(B),s=N.add(V)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return In.normalizeZ([i,s])[0]}toAffine(e=Vc(this.z)){const{x:t,y:r,z:i}=this,s=e,o=Ze(s*s),a=Ze(o*s),l=Ze(t*o),_=Ze(r*a);if(Ze(i*s)!==Wn)throw new Error("invZ was invalid");return new vn(l,_)}}In.BASE=new In(Cn.Gx,Cn.Gy,Wn),In.ZERO=new In(rn,Wn,rn);const O0=new WeakMap;class vn{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,O0.delete(this)}hasEvenY(){return this.y%ko===rn}static fromCompressedHex(e){const t=32===e.length,r=pi(t?e:e.subarray(1));if(!qd(r))throw new Error("Point is not on curve");let s=function WF(n){const{P:e}=Cn,t=BigInt(6),r=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),l=n*n*n%e,_=l*l*n%e,R=Gi(_,pl)*_%e,N=Gi(R,pl)*_%e,B=Gi(N,ko)*l%e,V=Gi(B,r)*B%e,Y=Gi(V,i)*V%e,X=Gi(Y,o)*Y%e,ie=Gi(X,a)*X%e,fe=Gi(ie,o)*Y%e,Se=Gi(fe,pl)*_%e,ae=Gi(Se,s)*V%e,Ie=Gi(ae,t)*l%e;return Gi(Ie,ko)}(QC(r));const o=(s&Wn)===Wn;t?o&&(s=Ze(-s)):1==(1&e[0])!==o&&(s=Ze(-s));const a=new vn(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=pi(e.subarray(1,33)),r=pi(e.subarray(33,65)),i=new vn(t,r);return i.assertValidity(),i}static fromHex(e){const t=Bs(e),r=t.length,i=t[0];if(32===r||33===r&&(2===i||3===i))return this.fromCompressedHex(t);if(65===r&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return vn.BASE.multiply(va(e))}static fromSignature(e,t,r){const i=tI(e=Bs(e)),{r:s,s:o}=iI(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const l=vn.fromHex((1&r?"03":"02")+Bo(s)),{n:_}=Cn,R=Vc(s,_),N=Ze(-i*R,_),B=Ze(o*R,_),V=vn.BASE.multiplyAndAddUnsafe(l,N,B);if(!V)throw new Error("Cannot recover signature: point at infinify");return V.assertValidity(),V}toRawBytes(e=!1){return Fo(this.toHex(e))}toHex(e=!1){const t=Bo(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Bo(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(!qd(t)||!qd(r))throw new Error(e);const i=Ze(r*r);if(Ze(i-QC(t))!==rn)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new vn(this.x,Ze(-this.y))}double(){return In.fromAffine(this).double().toAffine()}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()}multiplyAndAddUnsafe(e,t,r){const i=In.fromAffine(this),s=t===rn||t===Wn||this!==vn.BASE?i.multiplyUnsafe(t):i.multiply(t),o=In.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(In.ZERO)?void 0:a.toAffine()}}function YC(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function ZC(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${Fc(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:pi(t),left:n.subarray(e+2)}}vn.BASE=new vn(Cn.Gx,Cn.Gy),vn.ZERO=new vn(rn,rn);class Lo{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const i=t?Fc(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new Lo(Wd(i.slice(0,64)),Wd(i.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:i}=function jF(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${Fc(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=ZC(n.subarray(2)),{data:r,left:i}=ZC(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Fc(i)}`);return{r:e,s:r}}(t?e:Fo(e));return new Lo(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Kc(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Kc(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>Cn.n>>Wn}normalizeS(){return this.hasHighS()?new Lo(this.r,Cn.n-this.s):this}toDERRawBytes(e=!1){return Fo(this.toDERHex(e))}toDERHex(e=!1){const t=YC(gl(this.s));if(e)return t;const r=YC(gl(this.r)),i=gl(r.length/2),s=gl(t.length/2);return`30${gl(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Fo(this.toCompactHex())}toCompactHex(){return Bo(this.r)+Bo(this.s)}}function Bc(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Fc(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&Kc(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Ze(n,e=Cn.P){const t=n%e;return t>=rn?t:e+t}function Gi(n,e){const{P:t}=Cn;let r=n;for(;e-- >rn;)r*=r,r%=t;return r}function Vc(n,e=Cn.P){if(n===rn||e<=rn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Ze(n,e),r=e,i=rn,s=Wn,o=Wn,a=rn;for(;t!==rn;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==Wn)throw new Error("invert: does not exist");return Ze(i,e)}const JC=(n,e)=>(n+e/ko)/e,QF={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-Wn*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function eI(n){const{n:e}=Cn,{a1:t,b1:r,a2:i,b2:s,POW_2_128:o}=QF,a=JC(s*n,e),l=JC(-r*n,e);let _=Ze(n-a*t-l*i,e),R=Ze(-a*r-l*s,e);const N=_>o,B=R>o;if(N&&(_=e-_),B&&(R=e-R),_>o||R>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:N,k1:_,k2neg:B,k2:R}}function tI(n){const{n:e}=Cn,r=8*n.length-256;let i=pi(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}let Hc,yl;class nI{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return gi.hmacSha256(this.k,...e)}hmacSync(...e){return yl(this.k,...e)}checkSync(){if("function"!=typeof yl)throw new M0("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}reseed(e=new Uint8Array){var t=this;return j(function*(){t.k=yield t.hmac(t.v,Uint8Array.from([0]),e),t.v=yield t.hmac(t.v),0!==e.length&&(t.k=yield t.hmac(t.v,Uint8Array.from([1]),e),t.v=yield t.hmac(t.v))})()}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}generate(){var e=this;return j(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}function Kc(n){return rn0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=Wd(n)}else{if(!(n instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==n.length)throw new Error("Expected 32 bytes of private key");e=pi(n)}if(!Kc(e))throw new Error("Expected private key: 0 < key < n");return e}function iI(n){if(n instanceof Lo)return n.assertValidity(),n;try{return Lo.fromDER(n)}catch{return Lo.fromCompact(n)}}function sI(n,e=!1){return vn.fromPrivateKey(n).toRawBytes(e)}function aI(n){return pi(n.length>32?n.slice(0,32):n)}function YF(n){const e=aI(n),t=Ze(e,Cn.n);return cI(t{if((n=Bs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Uc(Ze(pi(n),Cn.n-Wn)+Wn)},randomBytes:(n=32)=>{if(Pi.web)return Pi.web.getRandomValues(new Uint8Array(n));if(Pi.node){const{randomBytes:e}=Pi.node;return Uint8Array.from(e(n))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>gi.hashToPrivateKey(gi.randomBytes(40)),sha256:(n=j(function*(...e){if(Pi.web){const t=yield Pi.web.subtle.digest("SHA-256",Bc(...e));return new Uint8Array(t)}if(Pi.node){const{createHash:t}=Pi.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=j(function*(e,...t){if(Pi.web){const r=yield Pi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=Bc(...t),s=yield Pi.web.subtle.sign("HMAC",r,i);return new Uint8Array(s)}if(Pi.node){const{createHmac:r}=Pi.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=j(function*(e,...t){let r=Yd[e];if(void 0===r){const i=yield gi.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=Bc(i,i),Yd[e]=r}return gi.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof Hc)throw new M0("sha256Sync is undefined, you need to set it");let t=Yd[n];if(void 0===t){const r=Hc(Uint8Array.from(n,i=>i.charCodeAt(0)));t=Bc(r,r),Yd[n]=t}return Hc(t,...e)},precompute(n=8,e=vn.BASE){const t=e===vn.BASE?e:new vn(e.x,e.y);return t._setWindowSize(n),t.multiply(pl),t}};var n;function Zd(n){if(isNaN(n)||n<=0)throw se(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return gi.randomBytes(n)}function r6(n){const e=kn.asn1.fromDer(Rt(n,"ascii")),t=kn.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e),d:Ls(t.d),p:Ls(t.p),q:Ls(t.q),dp:Ls(t.dP),dq:Ls(t.dQ),qi:Ls(t.qInv),alg:"RS256"}}function yI(n,e){return e.map(t=>gs(n[t]))}function u6(n){return U0.apply(this,arguments)}function U0(){return U0=j(function*(n){const e=yield ks.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=yield vI(e);return{privateKey:t[0],publicKey:t[1]}}),U0.apply(this,arguments)}function mI(n){return V0.apply(this,arguments)}function V0(){return V0=j(function*(n){const t=[yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield d6(n)],r=yield vI({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),V0.apply(this,arguments)}function H0(){return H0=j(function*(n,e){const t=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield ks.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),H0.apply(this,arguments)}function K0(){return K0=j(function*(n,e,t){const r=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield ks.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),K0.apply(this,arguments)}function vI(n){return $0.apply(this,arguments)}function $0(){return $0=j(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([ks.get().subtle.exportKey("jwk",n.privateKey),ks.get().subtle.exportKey("jwk",n.publicKey)])}),$0.apply(this,arguments)}function d6(n){return j0.apply(this,arguments)}function j0(){return j0=j(function*(n){return yield ks.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),j0.apply(this,arguments)}function EI(n,e,t,r){const i=e?function c6(n){return kn.pki.setRsaPublicKey(...yI(n,["n","e"]))}(n):function a6(n){return kn.pki.setRsaPrivateKey(...yI(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return xt(r(Rt(Uint8Array.from(t),"ascii"),i),"ascii")}function G0(n,e){return z0.apply(this,arguments)}function z0(){return z0=j(function*(n,e){const r=yield qC().encrypt(n,e);return Ud.encode(r)}),z0.apply(this,arguments)}Object.defineProperties(gi,{sha256Sync:{configurable:!1,get:()=>Hc,set(n){Hc||(Hc=n)}},hmacSha256Sync:{configurable:!1,get:()=>yl,set(n){yl||(yl=n)}}}),x(4571);class W0{constructor(e){this._key=e}verify(e,t){var r=this;return j(function*(){return yield function f6(n,e,t){return K0.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function o6(n){if(null==n.n||null==n.e)throw se(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=kn.pki.publicKeyToAsn1({n:gs(n.n),e:gs(n.e)});return xt(kn.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Nc.encode({Type:Xn.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function h6(n,e){return EI(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return Pr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield hi.digest(e.bytes);return t})()}}class Xd{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Zd(16)}sign(e){var t=this;return j(function*(){return yield function l6(n,e){return H0.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 W0(this._publicKey)}decrypt(e){return function p6(n,e){return EI(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function i6(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=kn.pki.privateKeyToAsn1({n:gs(n.n),e:gs(n.e),d:gs(n.d),p:gs(n.p),q:gs(n.q),dP:gs(n.dp),dQ:gs(n.dq),qInv:gs(n.qi)});return xt(kn.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Mc.encode({Type:Xn.RSA,Data:this.marshal()}).subarray()}equals(e){return Pr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield hi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){return Rt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return j(function*(){if("pkcs-8"===t){const i=new kn.util.ByteBuffer(r.marshal()),s=kn.asn1.fromDer(i),o=kn.pki.privateKeyFromAsn1(s);return kn.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield G0(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function g6(n){return q0.apply(this,arguments)}function q0(){return q0=j(function*(n){const e=r6(n),t=yield mI(e);return new Xd(t.privateKey,t.publicKey)}),q0.apply(this,arguments)}function y6(n){const e=function s6(n){const e=kn.asn1.fromDer(Rt(n,"ascii")),t=kn.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e)}}(n);return new W0(e)}function m6(n){return Q0.apply(this,arguments)}function Q0(){return Q0=j(function*(n){const e=yield mI(n);return new Xd(e.privateKey,e.publicKey)}),Q0.apply(this,arguments)}function v6(n){return Y0.apply(this,arguments)}function Y0(){return Y0=j(function*(n){const e=yield u6(n);return new Xd(e.privateKey,e.publicKey)}),Y0.apply(this,arguments)}var E6=x(9572),b6=x.t(E6,2);const rr=BigInt(0),en=BigInt(1),jc=BigInt(2),bI=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Ln=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:bI,n:bI,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),wI=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),ml=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),w6=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),_6=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),D6=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),S6=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class hn{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof Jn))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(Jn.ZERO)?hn.ZERO:new hn(e.x,e.y,en,Ae(e.x*e.y))}static toAffineBatch(e){const t=function T6(n,e=Ln.P){const t=new Array(n.length),i=Jd(n.reduce((s,o,a)=>o===rr?s:(t[a]=s,Ae(s*o,e)),en),e);return n.reduceRight((s,o,a)=>o===rr?s:(t[a]=Ae(s*t[a],e),Ae(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){_I(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,l=Ae(t*a),_=Ae(s*i),R=Ae(r*a),N=Ae(o*i);return l===_&&R===N}negate(){return new hn(Ae(-this.x),this.y,this.z,Ae(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=Ln,s=Ae(e*e),o=Ae(t*t),a=Ae(jc*Ae(r*r)),l=Ae(i*s),_=e+t,R=Ae(Ae(_*_)-s-o),N=l+o,B=N-a,V=l-o,Y=Ae(R*B),X=Ae(N*V),ie=Ae(R*V),fe=Ae(B*N);return new hn(Y,X,fe,ie)}add(e){_I(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:l,t:_}=e,R=Ae((r-t)*(a+o)),N=Ae((r+t)*(a-o)),B=Ae(N-R);if(B===rr)return this.double();const V=Ae(i*jc*_),Y=Ae(s*jc*l),X=Y+V,ie=N+R,fe=Y-V,Se=Ae(X*B),ae=Ae(ie*fe),Ie=Ae(X*fe),Fe=Ae(B*ie);return new hn(Se,ae,Fe,Ie)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let i=this,s=i;for(let o=0;o>=N,Y>l&&(Y-=R,e+=en),0===Y){let X=i[V];B%2&&(X=X.negate()),o=o.add(X)}else{let X=i[V+Math.abs(Y)-1];Y<0&&(X=X.negate()),s=s.add(X)}}return hn.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(qc(e,Ln.l),t)}multiplyUnsafe(e){let t=qc(e,Ln.l,!1);const r=hn.BASE,i=hn.ZERO;if(t===rr)return i;if(this.equals(i)||t===en)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>rr;)t&en&&(s=s.add(o)),o=o.double(),t>>=en;return s}isSmallOrder(){return this.multiplyUnsafe(Ln.h).equals(hn.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Ln.l).equals(hn.ZERO)}toAffine(e=Jd(this.z)){const{x:t,y:r,z:i}=this,s=Ae(t*e),o=Ae(r*e);if(Ae(i*e)!==en)throw new Error("invZ was invalid");return new Jn(s,o)}fromRistrettoBytes(){X0()}toRistrettoBytes(){X0()}fromRistrettoHash(){X0()}}function _I(n){if(!(n instanceof hn))throw new TypeError("ExtendedPoint expected")}function Z0(n){if(!(n instanceof zi))throw new TypeError("RistrettoPoint expected")}function X0(){throw new Error("Legacy method: switch to RistrettoPoint")}hn.BASE=new hn(Ln.Gx,Ln.Gy,en,Ae(Ln.Gx*Ln.Gy)),hn.ZERO=new hn(rr,en,en,rr);class zi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=Ln,r=Ae(ml*e*e),i=Ae((r+en)*D6);let s=BigInt(-1);const o=Ae((s-t*r)*Ae(r+t));let{isValid:a,value:l}=nm(i,o),_=Ae(l*e);Vo(_)||(_=Ae(-_)),a||(l=_),a||(s=r);const R=Ae(s*(r-en)*S6-o),N=l*l,B=Ae((l+l)*o),V=Ae(R*w6),Y=Ae(en-N),X=Ae(en+N);return new hn(Ae(B*X),Ae(Y*V),Ae(V*X),Ae(B*Y))}static hashToCurve(e){const t=tm((e=ms(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=tm(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new zi(r.add(s))}static fromHex(e){e=ms(e,32);const{a:t,d:r}=Ln,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=tm(e);if(!function A6(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>=wI)throw new Error("Expected 0 < hex < 2**256");const a=Ae(o*o),l=Ae(a-en),_=Ae(r*a+en);let{isValid:R,value:N}=nm(l,_);if(!R)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((N&en)===en)&&(N=Ae(-N)),new Jn(N,o)}static fromPrivateKey(e){return j(function*(){return(yield bl(e)).point})()}toRawBytes(){const e=zc(this.y);return e[31]|=this.x&en?128:0,e}toHex(){return vl(this.toRawBytes())}toX25519(){const{y:e}=this;return zc(Ae((en+e)*Jd(en-e)))}isTorsionFree(){return hn.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Jn(Ae(-this.x),this.y)}add(e){return hn.fromAffine(this).add(hn.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return hn.fromAffine(this).multiply(e,this).toAffine()}}Jn.BASE=new Jn(Ln.Gx,Ln.Gy),Jn.ZERO=new Jn(rr,en);class Gc{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=ms(e,64),r=Jn.fromHex(t.slice(0,32),!1),i=Ea(t.slice(32,64));return new Gc(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof Jn))throw new Error("Expected Point instance");return qc(t,Ln.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(zc(this.s),32),e}toHex(){return vl(this.toRawBytes())}}function DI(...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 vl(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=rr?t:e+t}function Jd(n,e=Ln.P){if(n===rr||e<=rr)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Ae(n,e),r=e,i=rr,s=en,o=en,a=rr;for(;t!==rr;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==en)throw new Error("invert: does not exist");return Ae(i,e)}function ys(n,e){const{P:t}=Ln;let r=n;for(;e-- >rr;)r*=r,r%=t;return r}function nm(n,e){const t=Ae(e*e*e),r=Ae(t*t*e);let s=Ae(n*t*function CI(n){const{P:e}=Ln,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),l=n*n%e*n%e,_=ys(l,jc)*l%e,R=ys(_,en)*n%e,N=ys(R,t)*R%e,B=ys(N,r)*N%e,V=ys(B,i)*B%e,Y=ys(V,s)*V%e,X=ys(Y,o)*Y%e,ie=ys(X,o)*Y%e,fe=ys(ie,r)*N%e;return{pow_p_5_8:ys(fe,jc)*n%e,b2:l}}(n*r).pow_p_5_8);const o=Ae(e*s*s),a=s,l=Ae(s*ml),_=o===n,R=o===Ae(-n),N=o===Ae(-n*ml);return _&&(s=a),(R||N)&&(s=l),Vo(s)&&(s=Ae(-s)),{isValid:_||R,value:s}}function II(n){return nm(en,n)}function Wc(n){return Ae(Ea(n),Ln.l)}function ms(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):em(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function qc(n,e,t=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof n&&Number.isSafeInteger(n)&&(n=BigInt(n)),"bigint"==typeof n&&n{if((n=ms(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Ae(Ea(n),Ln.l-en)+en},randomBytes:(n=32)=>{if(Ho.web)return Ho.web.getRandomValues(new Uint8Array(n));if(Ho.node){const{randomBytes:e}=Ho.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ba.randomBytes(32),sha512:function(){var n=j(function*(...e){const t=DI(...e);if(Ho.web){const r=yield Ho.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(Ho.node)return Uint8Array.from(Ho.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=Jn.BASE){const t=e.equals(Jn.BASE)?e:new Jn(e.x,e.y);return t._setWindowSize(n),t.multiply(jc),t},sha512Sync:void 0};function F6(){return lm.apply(this,arguments)}function lm(){return lm=j(function*(){const n=ba.randomPrivateKey(),e=yield RI(n);return{privateKey:MI(n,e),publicKey:e}}),lm.apply(this,arguments)}function U6(n){return fm.apply(this,arguments)}function fm(){return fm=j(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 RI(e);return{privateKey:MI(e,t),publicKey:t}}),fm.apply(this,arguments)}function dm(){return dm=j(function*(n,e){const t=n.slice(0,32);return yield P6(e,t)}),dm.apply(this,arguments)}function hm(){return hm=j(function*(n,e,t){return yield M6(e,t,n)}),hm.apply(this,arguments)}function MI(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(ba,{sha512Sync:{configurable:!1,get:()=>El,set(n){El||(El=n)}}});class pm{constructor(e){this._key=Qc(e,32)}verify(e,t){var r=this;return j(function*(){return yield function H6(n,e,t){return hm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return Nc.encode({Type:Xn.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Pr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield hi.digest(e.bytes);return t})()}}class _l{constructor(e,t){this._key=Qc(e,64),this._publicKey=Qc(t,32)}sign(e){var t=this;return j(function*(){return yield function V6(n,e){return dm.apply(this,arguments)}(t._key,e)})()}get public(){return new pm(this._publicKey)}marshal(){return this._key}get bytes(){return Mc.encode({Type:Xn.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Pr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield hi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){const t=yield Lc.digest(e.public.bytes);return si.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return j(function*(){if("libp2p-key"===t)return yield G0(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function K6(n){if(n.length>64){const r=(n=Qc(n,96)).slice(0,64),i=n.slice(64,n.length);return new _l(r,i)}const e=(n=Qc(n,64)).slice(0,64),t=n.slice(32);return new _l(e,t)}function $6(n){return n=Qc(n,32),new pm(n)}function j6(){return gm.apply(this,arguments)}function gm(){return gm=j(function*(){const{privateKey:n,publicKey:e}=yield F6();return new _l(n,e)}),gm.apply(this,arguments)}function G6(n){return ym.apply(this,arguments)}function ym(){return ym=j(function*(n){const{privateKey:e,publicKey:t}=yield U6(n);return new _l(e,t)}),ym.apply(this,arguments)}function Qc(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 z6(){return gi.randomPrivateKey()}function mm(){return mm=j(function*(n,e){const{digest:t}=yield hi.digest(e);try{return yield ZF(t,n)}catch(r){throw se(r,"ERR_INVALID_INPUT")}}),mm.apply(this,arguments)}function vm(){return vm=j(function*(n,e,t){try{const{digest:r}=yield hi.digest(t);return JF(e,r,n)}catch(r){throw se(r,"ERR_INVALID_INPUT")}}),vm.apply(this,arguments)}function OI(n){try{vn.fromHex(n)}catch(e){throw se(e,"ERR_INVALID_PUBLIC_KEY")}}class Em{constructor(e){OI(e),this._key=e}verify(e,t){var r=this;return j(function*(){return yield function q6(n,e,t){return vm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function Q6(n){return vn.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return Nc.encode({Type:Xn.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Pr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield hi.digest(e.bytes);return t})()}}class bm{constructor(e,t){this._key=e,this._publicKey=t??function Z6(n){try{return sI(n,!0)}catch(e){throw se(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function Y6(n){try{sI(n,!0)}catch(e){throw se(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),OI(this._publicKey)}sign(e){var t=this;return j(function*(){return yield function W6(n,e){return mm.apply(this,arguments)}(t._key,e)})()}get public(){return new Em(this._publicKey)}marshal(){return this._key}get bytes(){return Mc.encode({Type:Xn.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Pr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield hi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){return Rt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return j(function*(){if("libp2p-key"===t)return yield G0(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function X6(n){return new bm(n)}function J6(n){return new Em(n)}function e5(){return wm.apply(this,arguments)}function wm(){return wm=j(function*(){const n=yield z6();return new bm(n)}),wm.apply(this,arguments)}const oo={rsa:I,ed25519:A,secp256k1:P};function _m(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 Dm(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return oo[n];throw _m(n)}function kI(n,e){return Sm.apply(this,arguments)}function Sm(){return Sm=j(function*(n,e){return yield Dm(n).generateKeyPair(e??2048)}),Sm.apply(this,arguments)}function Dl(n){const e=Nc.decode(n),t=e.Data;switch(e.Type){case Xn.RSA:return oo.rsa.unmarshalRsaPublicKey(t);case Xn.Ed25519:return oo.ed25519.unmarshalEd25519PublicKey(t);case Xn.Secp256k1:return oo.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw _m(e.Type)}}function LI(n,e){return Dm(e=(e??"rsa").toLowerCase()),n.bytes}function Sl(n){return Im.apply(this,arguments)}function Im(){return Im=j(function*(n){const e=Mc.decode(n),t=e.Data;switch(e.Type){case Xn.RSA:return yield oo.rsa.unmarshalRsaPrivateKey(t);case Xn.Ed25519:return oo.ed25519.unmarshalEd25519PrivateKey(t);case Xn.Secp256k1:return oo.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw _m(e.Type)}}),Im.apply(this,arguments)}function t5(n,e){return Dm(e=(e??"rsa").toLowerCase()),n.bytes}function Tm(n,e){return Am.apply(this,arguments)}function Am(){return Am=j(function*(n,e){try{const i=yield VF(n,e);return yield Sl(i)}catch{}const t=kn.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=kn.asn1.toDer(kn.pki.privateKeyToAsn1(t));return r=xt(r.getBytes(),"ascii"),yield oo.rsa.unmarshalRsaPrivateKey(r)}),Am.apply(this,arguments)}const BI=Symbol.for("@libp2p/peer-id");function FI(n){return null!=n&&Boolean(n[BI])}const UI=Object.values(hl).map(n=>n.decoder).reduce((n,e)=>n.or(e),hl.identity.decoder);class rh{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[BI](){return!0}toString(){return null==this.string&&(this.string=si.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return mr.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Pr(this.multihash.bytes,e);if("string"==typeof e)return ar(e).equals(this);if(null!=e?.multihash?.bytes)return Pr(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class Cl extends rh{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class Il extends rh{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class Tl extends rh{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Mr(n){if("RSA"===n.type)return new Cl(n);if("Ed25519"===n.type)return new Il(n);if("secp256k1"===n.type)return new Tl(n);throw se(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function ar(n,e){if(e=e??UI,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=$d(si.decode(`z${n}`));return n.startsWith("12D")?new Il({multihash:t}):n.startsWith("16U")?new Tl({multihash:t}):new Cl({multihash:t})}return Yc(UI.decode(n))}function Yc(n){try{const e=$d(n);if(e.code===Lc.code){if(36===e.digest.length)return new Il({multihash:e});if(37===e.digest.length)return new Tl({multihash:e})}if(e.code===hi.code)return new Cl({multihash:e})}catch{return function n5(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===hi.code)return new Cl({multihash:n.multihash});if(e.code===Lc.code){if(36===e.digest.length)return new Il({multihash:n.multihash});if(37===e.digest.length)return new Tl({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(mr.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function Al(n,e){return Pm.apply(this,arguments)}function Pm(){return Pm=j(function*(n,e){return 36===n.length?new Il({multihash:kc(Lc.code,n),privateKey:e}):37===n.length?new Tl({multihash:kc(Lc.code,n),privateKey:e}):new Cl({multihash:yield hi.digest(n),publicKey:n,privateKey:e})}),Pm.apply(this,arguments)}var Nm;!function(n){let e;!function(t){let r;t.codec=()=>(null==r&&(r=Bt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.identityKey)throw new Error('Protocol error: required field "identityKey" was not found in object');if(s.uint32(10),s.bytes(i.identityKey),null==i.identitySig)throw new Error('Protocol error: required field "identitySig" was not found in object');if(s.uint32(18),s.bytes(i.identitySig),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(26),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0),data:new Uint8Array(0)},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.identityKey=i.bytes();break;case 2:o.identitySig=i.bytes();break;case 3:o.data=i.bytes();break;default:i.skipType(7&l)}}if(null==o.identityKey)throw new Error('Protocol error: value for required field "identityKey" was not found in protobuf');if(null==o.identitySig)throw new Error('Protocol error: value for required field "identitySig" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),t.encode=i=>Lt(i,t.codec()),t.decode=i=>kt(i,t.codec())}(e=n.NoiseHandshakePayload||(n.NoiseHandshakePayload={}))}(Nm||(Nm={}));const HI=Nm.NoiseHandshakePayload;function Mm(){return Mm=j(function*(n,e,t){const r=yield s5(n,jI(e)),i=t??new Uint8Array(0);if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return i5(n.publicKey,r,i)}),Mm.apply(this,arguments)}function i5(n,e,t){return HI.encode({identityKey:n,identitySig:e,data:t??new Uint8Array(0)}).subarray()}function s5(n,e){return Om.apply(this,arguments)}function Om(){return Om=j(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Sl(n.privateKey)).sign(e)}),Om.apply(this,arguments)}function KI(n){return km.apply(this,arguments)}function km(){return km=j(function*(n){return yield Al(n.identityKey)}),km.apply(this,arguments)}function $I(n){return HI.decode(n)}function jI(n){const e=xt("noise-libp2p-static-key:");return yr([e,n],e.length+n.length)}function GI(n,e,t){return Lm.apply(this,arguments)}function Lm(){return Lm=j(function*(n,e,t){const r=yield Al(e.identityKey);if(!r.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");const i=jI(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 Dl(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Lm.apply(this,arguments)}function ih(n){return!(!(n instanceof Uint8Array)||32!==n.length)}var cr=x(4823);function Ft(n){return Object.assign(cr(n),{error:cr(`${n}:error`),trace:cr(`${n}:trace`)})}cr.formatters.b=n=>null==n?"undefined":si.baseEncode(n),cr.formatters.t=n=>null==n?"undefined":so.baseEncode(n),cr.formatters.m=n=>null==n?"undefined":Ud.baseEncode(n),cr.formatters.p=n=>null==n?"undefined":n.toString(),cr.formatters.c=n=>null==n?"undefined":n.toString(),cr.formatters.k=n=>null==n?"undefined":n.toString();const Gr=Ft("libp2p:noise");let Wi;function zI(n){n?(Wi(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Rt(n.publicKey,"hex")}`),Wi(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Rt(n.privateKey,"hex")}`)):Wi("Missing local ephemeral keys.")}function WI(n){Wi(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Rt(n,"hex")}`)}Wi=eB?Gr:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class d5{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 p5 extends class h5{constructor(e){this.crypto=e}encryptWithAd(e,t,r){const i=this.encrypt(e.k,e.n,t,r);return e.n.increment(),i}decryptWithAd(e,t,r){const{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,r);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){return Pr(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 Gr(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(yr([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 d5}}initializeSymmetric(e){const t=xt(e,"utf-8"),r=this.hashProtocolName(t),i=r,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:i,h:r}}hashProtocolName(e){if(e.length<=32){const t=new Uint8Array(32);return t.set(e),t}return this.getHash(e,new Uint8Array(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,new Uint8Array(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,new Uint8Array(0),t);return{ne:this.createEmptyKey(),ns:new Uint8Array(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}}{initializeInitiator(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}initializeResponder(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}writeMessageA(e,t,r){const i=new Uint8Array(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const s=e.e.publicKey;return this.mixHash(e.ss,s),{ne:s,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const s=this.encryptAndHash(e.ss,e.s.publicKey);return this.mixKey(e.ss,this.dh(e.s.privateKey,e.re)),{ne:r,ns:s,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const i=this.encryptAndHash(e.ss,e.s.publicKey);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const s=this.encryptAndHash(e.ss,t),a={ne:this.createEmptyKey(),ns:i,ciphertext:s},{cs1:l,cs2:_}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:l,cs2:_}}readMessageA(e,t){return ih(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(ih(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&&ih(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&&ih(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:l}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:l}}initSession(e,t,r){const i=this.createEmptyKey(),s=new Uint8Array(32);let o;return o=e?this.initializeInitiator(t,r,s,i):this.initializeResponder(t,r,s,i),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let i;if(0===e.mc)i=this.writeMessageA(e.hs,t,r);else if(1===e.mc)i=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:s,messageBuffer:o,cs1:a,cs2:l}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=l}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}}return e.mc++,i}recvMessage(e,t){let r=new Uint8Array(0),i=!1;if(0===e.mc)({plaintext:r,valid:i}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:i}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:s,plaintext:o,valid:a,cs1:l,cs2:_}=this.readMessageC(e.hs,t);r=o,i=a,e.h=s,e.cs1=l,e.cs2=_}return e.mc++,{plaintext:r,valid:i}}}class g5{constructor(e,t,r,i,s,o,a,l){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=l??new p5(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}propose(){var e=this;return j(function*(){if(function o5(n){Wi(`LOCAL_STATIC_PUBLIC_KEY ${Rt(n.publicKey,"hex")}`),Wi(`LOCAL_STATIC_PRIVATE_KEY ${Rt(n.privateKey,"hex")}`)}(e.session.hs.s),e.isInitiator){Gr("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(function iB(n){return yr([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}(t)),Gr("Stage 0 - Initiator finished sending first message."),zI(e.session.hs.e)}else{Gr("Stage 0 - Responder waiting to receive first message...");const t=function aB(n){if(n.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:n.subarray(0,32),ciphertext:n.subarray(32,n.length),ns:new Uint8Array(0)}}((yield e.connection.readLP()).subarray()),{valid:r}=e.xx.recvMessage(e.session,t);if(!r)throw new Pc("xx handshake stage 0 validation fail");Gr("Stage 0 - Responder received first message."),WI(e.session.hs.re)}})()}exchange(){var e=this;return j(function*(){if(e.isInitiator){Gr("Stage 1 - Initiator waiting to receive first message from responder...");const t=function cB(n){if(n.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:n.subarray(0,32),ns:n.subarray(32,80),ciphertext:n.subarray(80,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Pc("xx handshake stage 1 validation fail");Gr("Stage 1 - Initiator received the message."),WI(e.session.hs.re),function a5(n){Wi(`REMOTE_STATIC_PUBLIC_KEY ${Rt(n,"hex")}`)}(e.session.hs.rs),Gr("Initiator going to check remote's signature...");try{const s=$I(r);e.remotePeer=e.remotePeer||(yield KI(s)),yield GI(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Ld(`Error occurred while verifying signed payload: ${s.message}`)}Gr("All good with the signature!")}else{Gr("Stage 1 - Responder sending out first message with signed payload and static key.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function sB(n){return yr([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}(t)),Gr("Stage 1 - Responder sent the second handshake message with signed payload."),zI(e.session.hs.e)}})()}finish(){var e=this;return j(function*(){if(e.isInitiator){Gr("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function oB(n){return yr([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),Gr("Stage 2 - Initiator sent message with signed payload.")}else{Gr("Stage 2 - Responder waiting for third handshake message...");const t=function uB(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 Pc("xx handshake stage 2 validation fail");Gr("Stage 2 - Responder received the message, finished handshake.");try{const s=$I(r);e.remotePeer=e.remotePeer||(yield KI(s)),yield GI(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Ld(`Error occurred while verifying signed payload: ${s.message}`)}}!function c5(n){n.cs1&&n.cs2?(Wi(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Rt(n.cs1.k,"hex")}`),Wi(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Rt(n.cs2.k,"hex")}`)):Wi("Missing cipher state.")}(e.session)})()}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,new Uint8Array(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Pc("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 y5{constructor(e,t,r=k4,i){this.protocol="/noise",this.earlyData=t??new Uint8Array(0),this.crypto=r,this.staticKeys=e?this.crypto.generateX25519KeyPairFromSeed(e):this.crypto.generateX25519KeyPair(),this.prologue=i??new Uint8Array(0)}secureOutbound(e,t,r){var i=this;return j(function*(){const s=SC(t,{lengthEncoder:Od,lengthDecoder:kd,maxDataLength:ul}),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 j(function*(){const s=SC(t,{lengthEncoder:Od,lengthDecoder:kd,maxDataLength:ul}),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 j(function*(){const r=yield function r5(n,e,t){return Mm.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.earlyData);return yield t.performXXHandshake(e,r)})()}performXXHandshake(e,t){var r=this;return j(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new g5(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish()}catch(l){if(l instanceof Error)throw l.message=`Error occurred during XX handshake: ${l.message}`,l}return a})()}createSecureConnection(e,t){return j(function*(){const[r,i]=function Z4(){const n=CC(),e=CC();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),s=e.unwrap();return yield zn(r,function tB(n){return function(){var e=on(function*(t){var s,r=!1,i=!1;try{for(var a,o=wt(t);r=!(a=yield tt(o.next())).done;r=!1){const l=a.value;for(let _=0;_l.length&&(R=l.length),yield n.encrypt(l.subarray(_,R),n.session)}}}catch(l){i=!0,s=l}finally{try{r&&null!=o.return&&(yield tt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),Os({lengthEncoder:Od}),s,ps({lengthDecoder:kd}),function nB(n){return function(){var e=on(function*(t){var s,r=!1,i=!1;try{for(var a,o=wt(t);r=!(a=yield tt(o.next())).done;r=!1){const l=a.value;for(let _=0;_l.length&&(R=l.length);const{plaintext:N,valid:B}=yield tt(n.decrypt(l.subarray(_,R),n.session));if(!B)throw new Error("Failed to validate decrypted chunk");yield N}}}catch(l){i=!0,s=l}finally{try{r&&null!=o.return&&(yield tt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),r),i})()}}function ao(n){return null!=n&&"function"==typeof n.start&&"function"==typeof n.stop}function Or(n){return null!=n&&"function"==typeof n.init}class co{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 j(function*(){yield Promise.all(Object.values(e).filter(t=>ao(t)).map(function(){var t=j(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>ao(t)).map(function(){var t=j(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e.started=!0})()}afterStart(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>ao(t)).map(function(){var t=j(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>ao(t)).map(function(){var t=j(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>ao(t)).map(function(){var t=j(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e.started=!1})()}afterStop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>ao(t)).map(function(){var t=j(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,Or(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,Or(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,Or(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,Or(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,Or(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,Or(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,Or(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,Or(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,Or(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,Or(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,Or(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,Or(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,Or(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,Or(e)&&e.init(this),e}getPubSub(){if(null==this.pubsub)throw se(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,Or(e)&&e.init(this),e}getDialer(){if(null==this.dialer)throw se(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}}class qI extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function vs(n,e,t){const r=t??{},i=function m5(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=on(function*(){let a;const l=()=>{a?.()};for(e.addEventListener("abort",l);;){let _;try{if(e.aborted){const{abortMessage:N,abortCode:B}=r;throw new qI(N,B)}const R=new Promise((N,B)=>{a=()=>{const{abortMessage:V,abortCode:Y}=r;B(new qI(V,Y))}});_=yield tt(Promise.race([R,i.next()])),a=null}catch(R){e.removeEventListener("abort",l);const N="aborted"===R.type&&e.aborted;if(N&&null!=r.onAbort&&(yield tt(r.onAbort(n))),"function"==typeof i.return)try{const B=i.return();B instanceof Promise&&B.catch(V=>{null!=r.onReturnError&&r.onReturnError(V)})}catch(B){null!=r.onReturnError&&r.onReturnError(B)}if(N&&!0===r.returnOnAbort)return;throw R}if(!0===_.done)break;yield _.value}e.removeEventListener("abort",l)})).apply(this,arguments)}return function s(){return o.apply(this,arguments)}()}function v5(n,e,t){return r=>n(vs(r,e,t))}function $o(n,e,t){return{sink:v5(n.sink,e,{...t,onAbort:void 0}),source:vs(n.source,e,t)}}var ur=x(398);function QI(n){return new Uint8Array(n)}var tn=(()=>(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"}(tn||(tn={})),tn))();const Um=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),YI=Object.freeze({NEW_STREAM:tn.NEW_STREAM,MESSAGE:tn.MESSAGE_INITIATOR,CLOSE:tn.CLOSE_INITIATOR,RESET:tn.RESET_INITIATOR}),E5=Object.freeze({MESSAGE:tn.MESSAGE_RECEIVER,CLOSE:tn.CLOSE_RECEIVER,RESET:tn.RESET_RECEIVER}),ZI=new class b5{constructor(){this._pool=QI(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;ur.encode(e.id<<3|e.type,t,r),r+=ur.encode.bytes,ur.encode(e.type!==tn.NEW_STREAM&&e.type!==tn.MESSAGE_INITIATOR&&e.type!==tn.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=ur.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=QI(10240),this._poolOffset=0):this._poolOffset=r,e.type!==tn.NEW_STREAM&&e.type!==tn.MESSAGE_INITIATOR&&e.type!==tn.MESSAGE_RECEIVER||null==e.data?[i]:[i,...e.data instanceof Uint8Array?[e.data]:e.data]}};function Hm(){return Hm=on(function*(n){var r,e=!1,t=!1;try{for(var s,i=wt(n);e=!(s=yield tt(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*Rr(wt(ZI.write(a)),tt);else yield*Rr(wt(ZI.write(o)),tt)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield tt(i.return()))}finally{if(t)throw r}}}),Hm.apply(this,arguments)}class _5{constructor(){this._buffer=new jr,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 JI(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 S5(n){return Km.apply(this,arguments)}function Km(){return Km=on(function*(n){const e=new _5;var i,t=!1,r=!1;try{for(var o,s=wt(n);t=!(o=yield tt(s.next())).done;t=!1){const l=e.write(o.value);l.length>0&&(yield l)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield tt(s.return()))}finally{if(r)throw i}}}),Km.apply(this,arguments)}const eT=1<<20;var sh=x(6449);const Es=Ft("libp2p:mplex:stream"),$m="ERR_STREAM_RESET";class R5 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 xl(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new R5({system:e,component:t,metric:r,metrics:i}):new Map,s}var P5=x(9652);const bs=Ft("libp2p:mplex");function tT(n){const e={...n,type:`${Um[n.type]} (${n.type})`};return n.type===tn.NEW_STREAM&&(e.data=Rt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===tn.MESSAGE_INITIATOR||n.type===tn.MESSAGE_RECEIVER)&&(e.data=Rt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class L5{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:xl({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:xl({metrics:e.getMetrics(),component:"mplex",metric:"receiverStreams"})},this._init=t,this.sink=this._createSink();const r=this._createSource();this._source=r,this.source=r,this.closeController=new AbortController,this.rateLimiter=new P5.RateLimiterMemory({points:t.disconnectThreshold??5,duration:1})}init(e){}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;return e=null==e?t.toString():e.toString(),this._newStream({id:t,name:e,type:"initiator",registry:this._streams.initiators})}close(e){this.closeController.signal.aborted||(this.streams.forEach(null!=e?t=>t.abort(e):t=>t.close()),this.closeController.abort())}_newReceiverStream(e){const{id:t,name:r}=e;return this._newStream({id:t,name:r,type:"receiver",registry:this._streams.receivers})}_newStream(e){const{id:t,name:r,type:i,registry:s}=e;if(bs("new %s stream %s %s",i,t),"initiator"===i&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw 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 l=function x5(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=eT}=n,a=new AbortController,l=new AbortController,_=new AbortController,R="initiator"===s?YI:E5,N="initiator"===s?`i${e}`:`r${e}`,B=`${t??e}`;let ie,V=!1,Y=!1,X=!1;const fe={open:Date.now()},ae=Te=>{Y||(Y=!0,Es.trace("%s stream %s sink end - err: %o",s,B,Te),null!=Te&&null==ie&&(ie=Te),V&&(fe.close=Date.now(),i?.(ie)))},Ie=Rc({onEnd:Te=>{V||(V=!0,Es.trace("%s stream %s source end - err: %o",s,B,Te),null!=Te&&null==ie&&(ie=Te),Y&&(Fe.stat.timeline.close=Date.now(),i?.(ie)))}}),Fe={close:()=>{Es.trace("%s stream %s close",s,B),Fe.closeRead(),Fe.closeWrite()},closeRead:()=>{Es.trace("%s stream %s closeRead",s,B),!V&&Ie.end()},closeWrite:()=>{if(Es.trace("%s stream %s closeWrite",s,B),!Y){_.abort();try{r({id:e,type:R.CLOSE})}catch(Te){Es.trace("%s stream %s error sending close",s,t,Te)}ae()}},abort:Te=>{Es.trace("%s stream %s abort",s,B,Te),Ie.end(Te),a.abort(),ae(Te)},reset:()=>{const Te=se(new Error("stream reset"),$m);l.abort(),Ie.end(Te),ae(Te)},sink:(Te=j(function*(dt){if(X)throw se(new Error("sink already called on stream"),"ERR_DOUBLE_SINK");if(X=!0,Y)throw se(new Error("stream closed for writing"),"ERR_SINK_ENDED");dt=vs(dt,(0,sh.anySignal)([a.signal,l.signal,_.signal]));try{"initiator"===s&&r({id:e,type:YI.NEW_STREAM,data:new jr(xt(B))});const Kn=new jr;var Pn,ut=!1,an=!1;try{for(var bi,ir=wt(dt);ut=!(bi=yield ir.next()).done;ut=!1)for(Kn.append(bi.value);0!==Kn.length;){if(Kn.length<=o){r({id:e,type:R.MESSAGE,data:Kn.sublist()}),Kn.consume(Kn.length);break}const hu=Kn.length-o;r({id:e,type:R.MESSAGE,data:Kn.sublist(0,hu)}),Kn.consume(hu)}}catch(bo){an=!0,Pn=bo}finally{try{ut&&null!=ir.return&&(yield ir.return())}finally{if(an)throw Pn}}}catch(Kn){if("aborted"===Kn.type&&"The operation was aborted"===Kn.message){if(_.signal.aborted)return;l.signal.aborted&&(Kn.message="stream reset",Kn.code=$m),a.signal.aborted&&(Kn.message="stream aborted",Kn.code="ERR_STREAM_ABORT")}if(Kn.code===$m)Es.trace("%s stream %s reset",s,t);else{Es.trace("%s stream %s error",s,t,Kn);try{r({id:e,type:R.RESET})}catch(bo){Es.trace("%s stream %s error sending reset",s,t,bo)}}return Ie.end(Kn),void ae(Kn)}try{r({id:e,type:R.CLOSE})}catch(Kn){Es.trace("%s stream %s error sending close",s,t,Kn)}ae()}),function(ut){return Te.apply(this,arguments)}),source:Ie,sourcePush:Te=>{Ie.push(Te)},sourceReadableLength:()=>Ie.readableLength,stat:{direction:"initiator"===s?"outbound":"inbound",timeline:fe},metadata:{},id:N};var Te;return Fe}({id:t,name:r,send:_=>{bs.enabled&&bs.trace("%s stream %s send",i,t,tT(_)),this._source.push(_)},type:i,onEnd:()=>{bs("%s stream with id %s and protocol %s ended",i,t,l.stat.protocol),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(l)},maxMsgSize:this._init.maxMsgSize});return s.set(t,l),l}_createSink(){var e=this;return function(){var r=j(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=vs(i,sh(s));try{yield zn(i,S5,function C5(n){const e=n??eT,t=r=>{if((r.type===tn.NEW_STREAM||r.type===tn.MESSAGE_INITIATOR||r.type===tn.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=on(function*(){var l,o=!1,a=!1;try{for(var R,_=wt(r);o=!(R=yield tt(_.next())).done;o=!1){const N=R.value;Array.isArray(N)?(N.forEach(t),yield*Rr(wt(N),tt)):(t(N),yield N)}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield tt(_.return()))}finally{if(a)throw l}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=j(function*(a){var R,l=!1,_=!1;try{for(var B,N=wt(a);l=!(B=yield N.next()).done;l=!1){const V=B.value;yield e._handleIncoming(V)}}catch(V){_=!0,R=V}finally{try{l&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()),e._source.end()}catch(o){bs("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function B4(n={}){return wC(t=>{let r;const i=[];for(;!t.isEmpty()&&(r=t.shift(),null!=r);){if(null!=r.error)throw r.error;!1===r.done&&i.push(r.value)}return null==r?{done:!0}:{done:!0===r.done,value:i}},n)}({objectMode:!0,onEnd:r=>{this.close(r)}});return Object.assign(function w5(n){return Hm.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){var t=this;return j(function*(){const{id:r,type:i}=e;if(bs.enabled&&bs.trace("incoming message",tT(e)),e.type===tn.NEW_STREAM){if(t._streams.receivers.size===(t._init.maxInboundStreams??1024)){bs("too many inbound streams open"),t._source.push({id:r,type:tn.RESET_RECEIVER});try{yield t.rateLimiter.consume("new-stream",1)}catch{return bs("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void t._source.end(new Error("Too many open streams"))}return}const l=t._newReceiverStream({id:r,name:Rt(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=t._init.onIncomingStream&&t._init.onIncomingStream(l))}const o=(1==(1&i)?t._streams.initiators:t._streams.receivers).get(r);if(null==o)return void bs("missing stream %s for message type %s",r,Um[i]);const a=t._init.maxStreamBufferSize??4194304;switch(i){case tn.MESSAGE_INITIATOR:case tn.MESSAGE_RECEIVER:if(o.sourceReadableLength()>a){t._source.push({id:e.id,type:i===tn.MESSAGE_INITIATOR?tn.RESET_RECEIVER:tn.RESET_INITIATOR});const l=se(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");return void o.abort(l)}o.sourcePush(e.data);break;case tn.CLOSE_INITIATOR:case tn.CLOSE_RECEIVER:o.closeRead();break;case tn.RESET_INITIATOR:case tn.RESET_RECEIVER:o.reset();break;default:bs("unknown message type %s",i)}})()}}class B5{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new co,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new L5(this.components,{...e,...this._init})}}const F5=WebSocket;var U5=x(5083);function nT(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const V5=n=>{n.binaryType="arraybuffer";const e=function(){var s=j(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const l=N=>{n.removeEventListener("open",_),n.removeEventListener("error",R),N()},_=()=>l(o),R=N=>{l(()=>a(N.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",_),n.addEventListener("error",R)})});return function(){return s.apply(this,arguments)}}(),t=on(function*(){const s=new U5.zN(({push:N,stop:B,fail:V})=>{const Y=ie=>{let fe=null;"string"==typeof ie.data&&(fe=xt(ie.data)),nT(ie.data)&&(fe=new Uint8Array(ie.data)),ie.data instanceof Uint8Array&&(fe=ie.data),null!=fe&&N(fe)},X=ie=>V(ie.error??new Error("Socket error"));return n.addEventListener("message",Y),n.addEventListener("error",X),n.addEventListener("close",B),()=>{n.removeEventListener("message",Y),n.removeEventListener("error",X),n.removeEventListener("close",B)}},{highWaterMark:1/0});yield tt(e());var l,o=!1,a=!1;try{for(var R,_=wt(s);o=!(R=yield tt(_.next())).done;o=!1){const N=R.value;yield nT(N)?new Uint8Array(N):N}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield tt(_.return()))}finally{if(a)throw l}}})();let i,r=1===n.readyState;return n.addEventListener("open",()=>{r=!0,i=null}),n.addEventListener("close",()=>{r=!1,i=null}),n.addEventListener("error",s=>{r||(i=s.error??new Error(`connect ECONNREFUSED ${n.url}`))}),Object.assign(t,{connected:e})},H5=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)})},K5=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=j(function*(i){var a,s=!1,o=!1;try{for(var _,l=wt(i);s=!(_=yield l.next()).done;s=!1){const R=_.value;try{yield H5(n)}catch(N){if("socket closed"===N.message)break;throw N}n.send(R)}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}if(null!=e.closeOnEnd&&n.readyState<=1)return yield new Promise((R,N)=>{n.addEventListener("close",B=>{if(B.wasClean||1006===B.code)R();else{const V=Object.assign(new Error("ws error"),{event:B});N(V)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),$5=(n,e)=>{e=e??{};const t=V5(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:K5(n,e),source:t,connected:(o=j(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=j(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 j5=x(9966);const G5={http:"ws",https:"wss"};const rT="[a-fA-F\\d:]",jo=n=>n&&n.includeBoundaries?`(?:(?<=\\s|^)(?=${rT})|(?<=${rT})(?=\\s|$))`:"",ws="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",vr="[a-fA-F\\d]{1,4}",oh=`\n(?:\n(?:${vr}:){7}(?:${vr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${vr}:){6}(?:${ws}|:${vr}|:)| // 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(?:${vr}:){5}(?::${ws}|(?::${vr}){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(?:${vr}:){4}(?:(?::${vr}){0,1}:${ws}|(?::${vr}){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(?:${vr}:){3}(?:(?::${vr}){0,2}:${ws}|(?::${vr}){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(?:${vr}:){2}(?:(?::${vr}){0,3}:${ws}|(?::${vr}){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(?:${vr}:){1}(?:(?::${vr}){0,4}:${ws}|(?::${vr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${vr}){0,5}:${ws}|(?::${vr}){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(),Q5=new RegExp(`(?:^${ws}$)|(?:^${oh}$)`),Y5=new RegExp(`^${ws}$`),Z5=new RegExp(`^${oh}$`),jm=n=>n&&n.exact?Q5:new RegExp(`(?:${jo(n)}${ws}${jo(n)})|(?:${jo(n)}${oh}${jo(n)})`,"g");jm.v4=n=>n&&n.exact?Y5:new RegExp(`${jo(n)}${ws}${jo(n)}`,"g"),jm.v6=n=>n&&n.exact?Z5:new RegExp(`${jo(n)}${oh}${jo(n)}`,"g");const Gm=jm,{toString:eU}=Object.prototype,iT={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function zm(n,e,{}={}){try{return function X5(n){const e=(...t)=>n(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${n.name||""})`,configurable:!0}),e}(()=>function nU(n,e={}){if(!function tU(n){return"[object RegExp]"===eU.call(n)}(n))throw new TypeError("Expected a RegExp instance");const t=Object.keys(iT).map(i=>("boolean"==typeof e[i]?e[i]:n[i])?iT[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 Wm={timeout:400};function qm(n){return zm(Gm({exact:!0}),n.slice(0,45),Wm)}const cT=function iU(n){return zm(Gm.v4({exact:!0}),n.slice(0,15),Wm)},sU=function aT(n){return zm(Gm.v6({exact:!0}),n.slice(0,45),Wm)},uT=function(n){let t,e=0;if(cT(n))t=new Uint8Array(e+4),n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)});else if(sU(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},_s=-1,ah={},Qm={};function Er(n){if("number"==typeof n){if(null!=Qm[n])return Qm[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=ah[n])return ah[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}function lT(n,e){switch(Er(n).code){case 4:case 41:return function uU(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=Zm(r);return yr([t,i],t.length+i.length)}(e);case 445:return function mU(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=so.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=Zm(r);return yr([t,i],t.length+i.length)}(e);case 466:return function hU(n){const e=cU.decode(n),t=Uint8Array.from(ur.encode(e.length));return yr([t,e],t.length+e.length)}(e);default:return xt(e,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,_s,"ip6zone"],[53,_s,"dns",!0],[54,_s,"dns4",!0],[55,_s,"dns6",!0],[56,_s,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,_s,"unix",!1,!0],[421,_s,"ipfs"],[421,_s,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,_s,"garlic64"],[460,0,"quic"],[466,_s,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,_s,"memory"]].forEach(n=>{const e=function aU(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);Qm[e.code]=e,ah[e.name]=e});const Ym=Object.values(hl).map(n=>n.decoder),cU=function(){let n=Ym[0].or(Ym[1]);return Ym.slice(2).forEach(e=>n=n.or(e)),n}();function Zm(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function hT(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function gT(n){return n.map(e=>{const t=uh(e);return null!=e[1]?[t.code,lT(t.code,e[1])]:[t.code]})}function yT(n){return Jm(yr(n.map(e=>{const t=uh(e);let r=Uint8Array.from(ur.encode(t.code));return e.length>1&&null!=e[1]&&(r=yr([r,e[1]])),r})))}function mT(n,e){return n.size>0?n.size/8:0===n.size?0:ur.decode(e)+ur.decode.bytes}function ch(n){const e=[];let t=0;for(;tn.length)throw ET("Invalid address Uint8Array: "+Rt(n,"base16"));e.push([r,a])}return e}function Xm(n){return function EU(n){const e=[];return n.map(t=>{const r=uh(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),ev(e.join("/"))}(gT(ch(n)))}function Jm(n){const e=function vT(n){try{ch(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function ev(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function ET(n){return new Error("Error parsing address: "+n)}function uh(n){return Er(n[0])}const DU=Symbol.for("nodejs.util.inspect.custom"),bT=[Er("dns").code,Er("dns4").code,Er("dns6").code,Er("dnsaddr").code],SU=[Er("p2p").code,Er("ipfs").code],wT=new Map,_T=Symbol.for("@multiformats/js-multiaddr/multiaddr");let ln=(()=>{class n{constructor(t){if(null==t&&(t=""),Object.defineProperty(this,_T,{value:!0}),t instanceof Uint8Array)this.bytes=Jm(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 _U(n){return function wU(n){const e=function vU(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw ET("invalid address: "+n);if(!0===s.path){e.push([i,ev(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=ev(n)),t=function bU(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=uh(e);return e.length>1?[t.code,fT(t.code,e[1])]:[t.code]})}(e);return yT(t)}(n)}(t)}else{if(!n.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=Jm(t.bytes)}}toString(){return Xm(this.bytes)}toJSON(){return this.toString()}toOptions(){const t=this.protoCodes(),r=this.toString().split("/").slice(1);let i,s;if(r.length>2)bT.includes(t[0])&&SU.includes(t[1])?(i=Er("tcp").name,s=443):(i=Er(r[2]).name,s=parseInt(r[3]));else{if(!bT.includes(t[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');i=Er("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({},Er(t)))}protoCodes(){const t=[],r=this.bytes;let i=0;for(;it.name)}tuples(){return ch(this.bytes)}stringTuples(){return gT(ch(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(yT(r.slice(0,i)));return this}getPeerId(){try{const r=this.stringTuples().filter(i=>i[0]===ah.ipfs.code).pop();if(null!=r?.[1]){const i=r[1];return Rt("Q"===i[0]||"1"===i[0]?si.decode(`z${i}`):mr.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>!0===Er(r[0]).path)[0][1],null==t&&(t=null)}catch{t=null}return t}equals(t){return Pr(this.bytes,t.bytes)}resolve(t){var r=this;return j(function*(){const i=r.protos().find(a=>a.resolvable);if(null==i)return[r];const s=wT.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?.[_T])}[DU](){return""}inspect(){return""}}return n.resolvers=wT,n})();const lh=(n,e)=>e,TU={ip4:lh,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:lh,dns4:lh,dns6:lh,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 Zc extends Error{constructor(e="The operation was aborted"){super(e),this.code=Zc.code,this.type=Zc.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}}var xU=x(8404);const tv="object"==typeof window&&"object"==typeof document&&9===document.nodeType,fh=xU(),dh=tv&&!fh,RU=fh&&!tv,PU=fh&&tv,NU=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!fh,DT="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,MU=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class FU extends Error{constructor(e){super(e),this.name="TimeoutError"}}class UU extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const IT=n=>void 0===globalThis.DOMException?new UU(n):new DOMException(n),TT=n=>{const e=void 0===n.reason?IT("This operation was aborted."):n.reason;return e instanceof Error?e:IT(e)};function AT(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((l,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(TT(R)),R.addEventListener("abort",()=>{_(TT(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{l(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new FU("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),j(function*(){try{l(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else l(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const xT=Ft("libp2p:websockets:socket"),HU=yt("dns4"),KU=yt("dns6"),$U=yt("dnsaddr"),wa=zr(yt("dns"),$U,HU,KU),hh=zr(yt("ip4"),yt("ip6")),Rl=zr(zt(hh,yt("tcp")),zt(wa,yt("tcp"))),RT=zt(hh,yt("udp")),jU=zt(RT,yt("utp")),GU=zt(RT,yt("quic")),Xc=zr(zt(Rl,yt("ws")),zt(wa,yt("ws"))),_a=zr(zt(Rl,yt("wss")),zt(wa,yt("wss"))),nv=zr(zt(Rl,yt("http")),zt(hh,yt("http")),zt(wa,yt("http"))),rv=zr(zt(Rl,yt("https")),zt(hh,yt("https")),zt(wa,yt("https"))),PT=zr(zt(Xc,yt("p2p-webrtc-star"),yt("p2p")),zt(_a,yt("p2p-webrtc-star"),yt("p2p")),zt(Xc,yt("p2p-webrtc-star")),zt(_a,yt("p2p-webrtc-star"))),NT=(zr(zt(Xc,yt("p2p-websocket-star"),yt("p2p")),zt(_a,yt("p2p-websocket-star"),yt("p2p")),zt(Xc,yt("p2p-websocket-star")),zt(_a,yt("p2p-websocket-star"))),zr(zt(nv,yt("p2p-webrtc-direct"),yt("p2p")),zt(rv,yt("p2p-webrtc-direct"),yt("p2p")),zt(nv,yt("p2p-webrtc-direct")),zt(rv,yt("p2p-webrtc-direct")))),Pl=zr(Xc,_a,nv,rv,PT,NT,Rl,jU,GU,wa),Go=(zr(zt(Pl,yt("p2p-stardust"),yt("p2p")),zt(Pl,yt("p2p-stardust"))),zr(zt(Pl,yt("p2p")),PT,NT,yt("p2p"))),MT=zr(zt(Go,yt("p2p-circuit"),Go),zt(Go,yt("p2p-circuit")),zt(yt("p2p-circuit"),Go),zt(Pl,yt("p2p-circuit")),zt(yt("p2p-circuit"),Pl),yt("p2p-circuit")),OT=()=>zr(zt(MT,OT),MT),Jc=OT();function kT(n){return function e(t){let r;try{r=new ln(t)}catch{return!1}const i=n(r.protoNames());return null!==i&&(!0===i||!1===i?i:0===i.length)}}function zt(...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:kT(e),partialMatch:e}}function zr(...n){function e(r){let i=null;return n.some(s=>{const o="function"==typeof s?s().partialMatch(r):s.partialMatch(r);return null!=o&&(i=o,!0)}),i}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:kT(e),partialMatch:e}}function yt(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=new ln(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 LT(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Xc.matches(t)||_a.matches(t)})}zr(zt(Jc,Go,Jc),zt(Go,Jc),zt(Jc,Go),Jc,Go);const iv=Symbol.for("@libp2p/transport"),zo=Ft("libp2p:websockets");class WU{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[iv](){return!0}dial(e,t){var r=this;return j(function*(){zo("dialing %s",e),t=t??{};const s=function VU(n,e,t){const r={sink:i=>j(function*(){null!=t?.signal&&(i=vs(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&xT.error(s)}})(),source:null!=(t=t??{}).signal?vs(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>j(function*(){const i=Date.now();try{yield AT(n.close(),{milliseconds:2e3})}catch{const{host:o,port:a}=r.remoteAddr.toOptions();xT("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);zo("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return zo("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return j(function*(){if(!0===t?.signal?.aborted)throw new Zc;const i=e.toOptions();zo("dialing %s:%s",i.host,i.port);const s=m0(),o=R=>{zo.error("connection error:",R),s.reject(R)},a=function q5(n,e){e=e??{};const r=((n,e)=>(0,j5.relative)(n,e,G5,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new F5(r,e.websocket);return $5(i,e)}(function AU(n,e){const t=new ln(n),r=n.toString().split("/").slice(1);return t.tuples().map(i=>({protocol:r.shift()??"",content:null!=i[1]?r.shift()??"":""})).reduce((i,s,o,a)=>{const l=TU[s.protocol];if(null==l)throw new Error(`Unsupported protocol ${s.protocol}`);return l(i,s.content,o,a,e)},"")}(e),r.init);if(null!=a.socket.on?a.socket.on("error",o):a.socket.onerror=o,null==t.signal)return yield Promise.race([a.connected(),s.promise]),zo("connected %s",e),a;let l;const _=new Promise((R,N)=>{if(l=()=>{N(new Zc),setTimeout(()=>{a.close().catch(B=>{zo.error("error closing raw socket",B)})})},!0===t?.signal?.aborted)return l();t?.signal?.addEventListener("abort",l)});try{yield Promise.race([_,s.promise,a.connected()])}finally{null!=l&&t?.signal?.removeEventListener("abort",l)}return zo("connected %s",e),a})()}createListener(e){return function OU(){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):dh||DT?function zU(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return _a.matches(t)&&wa.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):LT(e)}}var uo,Da=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 yi extends EventTarget{constructor(){super(...arguments),uo.set(this,new Map)}listenerCount(e){const t=Da(this,uo,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=Da(this,uo,"f").get(e);null==i&&(i=[],Da(this,uo,"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=Da(this,uo,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),Da(this,uo,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=Da(this,uo,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),Da(this,uo,"f").set(e.type,r)),t}}uo=new WeakMap;class qU extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const qt=globalThis.CustomEvent??qU;var Nl=x(4773);const BT=(n,e)=>on(function*(){const t=yield tt(Nl(n));yield*Rr(wt(t.sort(e)),tt)})();var Wo=x(5671),Ds=x(9759),FT=x(5478);const lo="/",UT=(new TextEncoder).encode(lo),ph=UT[0];class kr{constructor(e,t){if("string"==typeof e)this._buf=xt(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]!==ph)throw new Error("Invalid key")}toString(e="utf8"){return Rt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new kr(e.join(lo))}static random(){return new kr(((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 kr(e):"function"==typeof e.uint8Array?new kr(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=UT),this._buf[0]!==ph){const e=new Uint8Array(this._buf.byteLength+1);e.fill(ph,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===ph;)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 tV(n){return[].concat(...n)}class rV extends class QU{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 on(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(e);i=!(l=yield tt(a.next())).done;i=!1){const{key:_,value:R}=l.value;yield tt(r.put(_,R,t)),yield{key:_,value:R}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield tt(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return on(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(e);i=!(l=yield tt(a.next())).done;i=!1){const _=l.value;yield r.get(_,t)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield tt(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return on(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(e);i=!(l=yield tt(a.next())).done;i=!1){const _=l.value;yield tt(r.delete(_,t)),yield _}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield tt(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=j(function*(s){yield Wo(e.putMany(t,s)),t=[],yield Wo(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return on(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return on(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>BT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=FT(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>BT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=FT(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return j(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return j(function*(){if(!(yield t.has(e)))throw function nV(n){return n=n||new Error("Not Found"),se(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return j(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return j(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return on(function*(){yield*Rr(wt(Object.entries(e.data).map(([t,r])=>({key:new kr(t),value:r}))),tt)})()}_allKeys(){var e=this;return on(function*(){yield*Rr(wt(Object.entries(e.data).map(([t])=>new kr(t))),tt)})()}}var pn=(()=>(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"}(pn||(pn={})),pn))(),we=(()=>(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"}(we||(we={})),we))(),sv=x(9458);function ov(n,e){return av.apply(this,arguments)}function av(){return av=on(function*(n,e){yield*Rr(wt(sv(n,function(){var t=j(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),tt)}),av.apply(this,arguments)}function VT(n){const e=new Set;return Ds(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function HT(n){return cv.apply(this,arguments)}function cv(){return cv=on(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=wt(n);r=!(a=yield tt(o.next())).done;r=!1){const l=a.value;t++,yield l}}catch(l){i=!0,s=l}finally{try{r&&null!=o.return&&(yield tt(o.return()))}finally{if(i)throw s}}if(ton(function*(){try{yield yield tt(s.findPeer(e,t))}catch(o){KT.error(o)}})())),s=>Ds(s,Boolean),s=>ov(s,r.components.getPeerStore()),function(){var s=j(function*(o){return yield Sa(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw se(new Error(pn.NOT_FOUND),we.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return on(function*(){if(0===r.routers.length)throw se(new Error("No peer routers available"),we.ERR_NO_ROUTERS_AVAILABLE);yield*Rr(wt(zn(Md(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>ov(i,r.components.getPeerStore()),i=>VT(i),i=>HT(i))),tt)})()}}class sV{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0})()}stop(){var e=this;return j(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return on(function*(){if(0===r.routers.length)throw se(new Error("No content this.routers available"),we.ERR_NO_ROUTERS_AVAILABLE);yield*Rr(wt(zn(Md(...r.routers.map(i=>i.findProviders(e,t))),i=>ov(i,r.components.getPeerStore()),i=>VT(i),i=>HT(i))),tt)})()}provide(e,t={}){var r=this;return j(function*(){if(0===r.routers.length)throw se(new Error("No content routers available"),we.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=j(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return j(function*(){if(!i.isStarted())throw se(new Error(pn.NOT_STARTED_YET),we.DHT_NOT_STARTED);const s=i.components.getDHT();null!=s&&(yield Wo(s.put(e,t,r)))})()}get(e,t){var r=this;return j(function*(){if(!r.isStarted())throw se(new Error(pn.NOT_STARTED_YET),we.DHT_NOT_STARTED);const i=r.components.getDHT();if(null!=i){var a,s=!1,o=!1;try{for(var _,l=wt(i.get(e,t));s=!(_=yield l.next()).done;s=!1){const R=_.value;if("VALUE"===R.name)return R.value}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}}throw se(new Error(pn.NOT_FOUND),we.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return on(function*(){if(!i.isStarted())throw se(new Error(pn.NOT_STARTED_YET),we.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.getDHT();if(null!=o){var _,a=!1,l=!1;try{for(var N,R=wt(o.get(e,r));a=!(N=yield tt(R.next())).done;a=!1){const B=N.value;if("VALUE"===B.name&&(yield{from:B.from,val:B.value},s++,s===t))break}}catch(B){l=!0,_=B}finally{try{a&&null!=R.return&&(yield tt(R.return()))}finally{if(l)throw _}}}if(0===s)throw se(new Error(pn.NOT_FOUND),we.ERR_NOT_FOUND)})()}}function Ml(n){if(FI(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=new ln(n)),ln.isMultiaddr(n)&&(e=n,n=function oV(n){const e=n.getPeerId();if(null==e)throw se(new Error(`${n.toString()} does not have a valid peer type`),we.ERR_INVALID_MULTIADDR);try{return ar(e)}catch{throw se(new Error(`${n.toString()} is not a valid peer type`),we.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const aV=n=>n;class cV extends yi{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??aV}getListenAddrs(){return Array.from(this.listen).map(e=>new ln(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new ln(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new ln(e))}addObservedAddr(e){let t=new ln(e);const r=t.getPeerId();null!=r&&ar(r).equals(this.components.getPeerId())&&(t=t.decapsulate(new ln(`/p2p/${this.components.getPeerId().toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new qt("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 ln(r))).map(r=>r.getPeerId()===this.components.getPeerId().toString()?r:r.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}}const Ol=x(8261),$T=Ft("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class lV extends yi{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"?$T("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];$T(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new qt("visibilityChange",{detail:e}))}}const fo=Ft("libp2p:connection-manager:latency-monitor");class fV extends yi{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,fo("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?fo("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):fo("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(fo("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?(fo("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(fo("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function dV(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new lV,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 qt("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(),fo.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,fo.trace("MS: %s Data: %O",i,this.latencyData)};fo.trace("localData: %O",t),this.checkLatencyID=setTimeout(()=>{null!=this.asyncTestFn?(t.deltaOffset=0,t.startTime=this.now(),this.asyncTestFn(r)):(t.deltaOffset-=1,r())},t.deltaOffset),"function"==typeof this.checkLatencyID.unref&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}var kl=x(1953);const GT="CLOSING",uv="CLOSED";var hV=x(3904);const zT=Ft("libp2p:dialer:dial-request");class pV{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 j(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw se(new Error("No dial tokens available"),we.ERR_NO_DIAL_TOKENS);const i=new hV;for(const l of r)i.push(l).catch(_=>{zT.error(_)});const s=t.addrs.map(()=>{const l=new AbortController;try{(0,Lr.setMaxListeners)?.(1/0,l.signal)}catch{}return l});if(null!=e.signal)try{(0,Lr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var l=j(function*(_,R){const N=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0]),se(new Error("dialAction already succeeded"),we.ERR_ALREADY_SUCCEEDED);const B=s[R];if(null==B)throw se(new Error("dialAction did not come with an AbortController"),we.ERR_INVALID_PARAMETERS);let V;try{const Y=B.signal;V=yield t.dialAction(_,{...e,signal:null!=e.signal?(0,sh.anySignal)([Y,e.signal]):Y}),s[R]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(N).catch(Y=>{zT.error(Y)}):t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0])}if(null==V)throw se(new Error("dialAction led to empty object"),we.ERR_TRANSPORT_DIAL_FAILED);return a=!0,V});return function(_,R){return l.apply(this,arguments)}}()))}finally{s.forEach(l=>{void 0!==l&&l.abort()}),r.forEach(l=>t.dialer.releaseToken(l))}})()}}var WT=x(6216);function qT(n){const{address:e}=n.nodeAddress();return Boolean(WT(e))}function lv(n,e){const t=qT(n.multiaddr),r=qT(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}var fv=x(7640);const Fs=Ft("libp2p:dialer"),XT="dialler";class bV{constructor(e={}){this.components=new co,this.started=!1,this.addressSorter=e.addressSorter??lv,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=xl({component:XT,metric:"pending-dials",metrics:e.metrics}),this.pendingDialTargets=xl({component:XT,metric:"pending-dial-targets",metrics:e.metrics});for(const[t,r]of Object.entries(e.resolvers??{}))ln.resolvers.set(t,r)}init(e){this.components=e}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0})()}stop(){var e=this;return j(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){Fs.error(r)}e.pendingDials.clear();for(const t of e.pendingDialTargets.values())t.reject(new Zc("Dialer was destroyed"));e.pendingDialTargets.clear()})()}dial(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Ml(e);if(r.components.getPeerId().equals(i))throw se(new Error("Tried to dial self"),we.ERR_DIALED_SELF);if(Fs("check multiaddrs %p",i),null!=s&&s.length>0&&(Fs("storing multiaddrs %p",i,s),yield r.components.getPeerStore().addressBook.add(i,s)),yield r.components.getConnectionGater().denyDialPeer(i))throw se(new Error("The dial request is blocked by gater.allowDialPeer"),we.ERR_PEER_DIAL_INTERCEPTED);Fs("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"),we.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const l=yield a.promise;return Fs("dial succeeded to %s",o.id),l}catch(l){throw Fs("dial failed to %s",o.id,l),a.controller.signal.aborted&&(l.code=we.ERR_TIMEOUT),Fs.error(l),l}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return j(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 j(function*(){const i=yield zn(yield r.components.getPeerStore().addressBook.get(e),a=>Ds(a,function(){var l=j(function*(_){return!(yield r.components.getConnectionGater().denyDialMultiaddr(e,_.multiaddr))});return function(_){return l.apply(this,arguments)}}()),a=>fv(a,r.addressSorter),a=>sv(a,l=>{const _=l.multiaddr;return e.toString()===_.getPeerId()?_:_.encapsulate(`/p2p/${e.toString()}`)}),function(){var a=j(function*(l){return yield Nl(l)});return function(l){return a.apply(this,arguments)}}()),s=[];for(const a of i)(yield r._resolve(a,t)).forEach(_=>s.push(_));const o=s.filter(a=>r.components.getTransportManager().transportForMultiaddr(a));if(o.length>r.maxAddrsToDial)throw yield r.components.getPeerStore().delete(e),se(new Error("dial with more addresses than allowed"),we.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:o}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var R=j(function*(N,B={}){if(!0===B.signal?.aborted)throw se(new Error("already aborted"),we.ERR_ALREADY_ABORTED);return yield r.components.getTransportManager().dial(N,B)});return function(B){return R.apply(this,arguments)}}(),s=new pV({addrs:e.addrs,dialAction:i,dialer:this}),o=new mi.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const l=(0,sh.anySignal)(a);try{(0,Lr.setMaxListeners)?.(1/0,l)}catch{}const _={dialRequest:s,controller:o,promise:s.run({...t,signal:l}),destroy:()=>{o.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,_),_}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return Fs("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(Fs("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return j(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var l=j(function*(_){return yield r._resolve(_,t)});return function(_){return l.apply(this,arguments)}}()))).flat().reduce((l,_)=>(null==l.find(R=>R.equals(_))&&l.push(_),l),[])})()}_resolveRecord(e,t){return j(function*(){try{return e=new ln(e.toString()),yield e.resolve(t)}catch(r){return Fs.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}function yh(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 wV{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 yh(this.map.entries(),e=>[ar(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,ar(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 yh(this.map.keys(),e=>ar(e))}values(){return this.map.values()}get size(){return this.map.size}}class _V{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 yh(this.set.entries(),e=>{const t=ar(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=ar(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return yh(this.set.values(),e=>ar(e))}}Symbol;const Wr=Ft("libp2p:connection-manager"),SV={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},hv="libp2p",pv="connection-manager";class IV extends yi{constructor(e){if(super(),this.components=new co,this.opts=Ol.call({ignoreUndefined:!0},SV,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:hv,component:pv,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:hv,component:pv,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{const t={};for(const i of this.connections.values())for(const s of i){const o={};for(const a of s.streams){const l=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[l]=(o[l]??0)+1}for(const[a,l]of Object.entries(o))t[a]=t[a]??[],t[a].push(l)}const r={};for(let[i,s]of Object.entries(t)){s=s.sort((a,l)=>a-l);const o=Math.floor(.9*s.length);r[i]=s[o]}return r}})}isStarted(){return this.started}start(){var e=this;return j(function*(){null!=e.components.getMetrics()&&(e.timer=e.timer??kl(e._checkMetrics,e.opts.pollInterval)),e.latencyMonitor.start(),e._onLatencyMeasure=e._onLatencyMeasure.bind(e),e.latencyMonitor.addEventListener("data",e._onLatencyMeasure),yield e.dialer.start(),e.started=!0,Wr("started")})()}afterStart(){var e=this;return j(function*(){e.components.getUpgrader().addEventListener("connection",e.onConnect),e.components.getUpgrader().addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then(j(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 mi.TimeoutController(e.startupReconnectTimeout);try{(0,Lr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=j(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{Wr.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{Wr.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return j(function*(){e.connectOnStartupController?.abort(),e.components.getUpgrader().removeEventListener("connection",e.onConnect),e.components.getUpgrader().removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return j(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),yield e.dialer.stop(),e.started=!1,yield e._close(),Wr("stopped")})()}_close(){var e=this;return j(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push(j(function*(){try{yield i.close()}catch(s){Wr.error(s)}})());Wr("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return j(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),Wr.trace("metrics update",o)}finally{e.timer=kl(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{Wr.error(t)})}_onConnect(e){var t=this;return j(function*(){const{detail:r}=e;if(!t.started)return void(yield r.close());const i=r.remotePeer,s=i.toString(),o=t.connections.get(s);null!=o?o.push(r):t.connections.set(s,[r]),null!=i.publicKey&&(yield t.components.getPeerStore().keyBook.set(i,i.publicKey));const a=t.getConnections().length,l=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,l),t.dispatchEvent(new qt("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 qt("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 j(function*(){Wr("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return Wr("had an existing connection to %p",e),i[0];let s;if(null==t?.signal){s=new mi.TimeoutController(r.dialTimeout),t.signal=s.signal;try{(0,Lr.setMaxListeners)?.(1/0,s.signal)}catch{}}try{const o=yield r.dialer.dial(e,t);let a=r.connections.get(e.toString());null==a&&(a=[],r.connections.set(e.toString(),a));let l=!1;for(const _ of a)_.id===o.id&&(l=!0);return l||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return j(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=j(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!FI(e))throw se(new Error("peerId must be an instance of peer-id"),we.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=>{Wr.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return j(function*(){const s=i.opts[e];Wr.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(Wr("%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 j(function*(){const r=t.getConnections();if(r.length<=t.opts.minConnections||e<1)return;const i=new wV;for(const a of r){const l=a.remotePeer;if(i.has(l))continue;const _=yield t.components.getPeerStore().getTags(l);i.set(l,_.reduce((R,N)=>R+N.value,0))}const s=r.sort((a,l)=>{const _=i.get(a.remotePeer)??0,R=i.get(l.remotePeer)??0;return _>R?1:_{qo.error("could start autodial",t)}),qo("started")):qo("not enabled")})()}stop(){var e=this;return j(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),qo("stopped")):qo("not enabled")})()}_autoDial(){var e=this;return j(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.getConnectionManager().getConnections().length>=t)return void(e.autoDialTimeout=kl(e._autoDial,e.options.autoDialInterval));const r=yield e.components.getPeerStore().all(),i=yield zn(r.sort(()=>Math.random()>.5?1:-1),s=>Ds(s,o=>!o.id.equals(e.components.getPeerId())),s=>fv(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=j(function*(o){return yield Nl(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sOo(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=()=>Oo(i)}(r=n.Type||(n.Type={})),function(a){let l;a.codec=()=>(null==l&&(l=Bt((_,R,N={})=>{if(!1!==N.lengthDelimited&&R.fork(),null==_.id)throw new Error('Protocol error: required field "id" was not found in object');if(R.uint32(10),R.bytes(_.id),null==_.addrs)throw new Error('Protocol error: required field "addrs" was not found in object');for(const B of _.addrs)R.uint32(18),R.bytes(B);!1!==N.lengthDelimited&&R.ldelim()},(_,R)=>{const N={},B=null==R?_.len:_.pos+R;for(;_.pos>>3){case 1:N.id=_.bytes();break;case 2:N.addrs=N.addrs??[],N.addrs.push(_.bytes());break;default:_.skipType(7&V)}}if(N.addrs=N.addrs??[],null==N.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(null==N.addrs)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return N})),l),a.encode=_=>Lt(_,a.codec()),a.decode=_=>kt(_,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=Bt((a,l,_={})=>{!1!==_.lengthDelimited&&l.fork(),null!=a.type&&(l.uint32(8),n.Type.codec().encode(a.type,l)),null!=a.srcPeer&&(l.uint32(18),n.Peer.codec().encode(a.srcPeer,l)),null!=a.dstPeer&&(l.uint32(26),n.Peer.codec().encode(a.dstPeer,l)),null!=a.code&&(l.uint32(32),n.Status.codec().encode(a.code,l)),!1!==_.lengthDelimited&&l.ldelim()},(a,l)=>{const _={},R=null==l?a.len:a.pos+l;for(;a.pos>>3){case 1:_.type=n.Type.codec().decode(a);break;case 2:_.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:_.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:_.code=n.Status.codec().decode(a);break;default:a.skipType(7&N)}}return _})),o),n.encode=a=>Lt(a,n.codec()),n.decode=a=>kt(a,n.codec())}(Qt||(Qt={}));const xV=Ft("libp2p:stream:converter");function JT(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=on(function*(){var B,R=!1,N=!1;try{for(var Y,V=wt(s);R=!(Y=yield tt(V.next())).done;R=!1){const X=Y.value;yield*Rr(wt(X),tt)}}catch(X){N=!0,B=X}finally{try{R&&null!=V.return&&(yield tt(V.return()))}finally{if(N)throw B}}})(),a={sink:R=>j(function*(){null!=e.signal&&(R=vs(R,e.signal));try{yield i(R),yield l()}catch(N){"aborted"!==N.type&&xV(N)}})(),source:null!=e.signal?vs(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>j(function*(){yield i(on(function*(){yield new Uint8Array(0)})()),yield l()})()};function l(){return _.apply(this,arguments)}function _(){return(_=j(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const Ll="/libp2p/circuit/relay/0.1.0";function e2(n,e){n.write({type:Qt.Type.STATUS,code:e})}function t2(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>new ln(t))}catch(t){throw e2(e,n.type===Qt.Type.HOP?Qt.Status.HOP_DST_MULTIADDR_INVALID:Qt.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>new ln(t))}catch(t){throw e2(e,n.type===Qt.Type.HOP?Qt.Status.HOP_SRC_MULTIADDR_INVALID:Qt.Status.STOP_SRC_MULTIADDR_INVALID),t}}const Bl=Ft("libp2p:circuit:stream-handler");class mh{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=Pd(this.stream),this.decoder=ps.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return j(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=Qt.decode(t.value);return Bl("read message type",r.type),r}Bl("read received no value, closing stream"),e.close()})()}write(e){Bl("write message type %s",e.type),this.shake.write(Os.single(Qt.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Bl("closing the stream"),this.rest().sink([]).catch(e=>{Bl.error(e)})}}const Fl=Ft("libp2p:circuit:stop");function NV(n){return gv.apply(this,arguments)}function gv(){return gv=j(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(Ll,{signal:r});Fl("starting stop request to %p",e.remotePeer);const s=new mh({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===Qt.Status.SUCCESS?(Fl("stop request to %p was successful",e.remotePeer),s.rest()):(Fl("stop request failed with code %d",o.code),void s.close());s.close()}),gv.apply(this,arguments)}const qi=Ft("libp2p:circuit:hop");function yv(){return yv=j(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return qi("HOP request received but we are not acting as a relay"),r.end({type:Qt.Type.STATUS,code:Qt.Status.HOP_CANT_SPEAK_RELAY});try{t2(t,r)}catch(N){return void qi.error("invalid hop request via peer %p %o",e.remotePeer,N)}if(null==t.dstPeer)return void qi("HOP request received but we do not receive a dstPeer");const o=Yc(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return qi("HOP request received but we are not connected to the destination peer"),r.end({type:Qt.Type.STATUS,code:Qt.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return qi("did not have connection to remote peer"),r.end({type:Qt.Type.STATUS,code:Qt.Status.HOP_NO_CONN_TO_DST});const l={type:Qt.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let _;try{qi("performing STOP request");const N=yield NV({connection:a[0],request:l});if(null==N)throw new Error("Could not stop");_=N}catch(N){return void qi.error(N)}qi("hop request from %p is valid",e.remotePeer),r.write({type:Qt.Type.STATUS,code:Qt.Status.SUCCESS});const R=r.rest();return qi("creating related connections"),yield zn(R,_,R)}),yv.apply(this,arguments)}function mv(){return mv=j(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(Ll,{signal:r}),s=new mh({stream:i});s.write(t);const o=yield s.read();if(null==o)throw se(new Error("HOP request had no response"),we.ERR_HOP_REQUEST_FAILED);if(o.code===Qt.Status.SUCCESS)return qi("hop request was successful"),s.rest();throw qi("hop request failed with code %d, closing stream",o.code),s.close(),se(new Error(`HOP request failed with code "${o.code??"unknown"}"`),we.ERR_HOP_REQUEST_FAILED)}),mv.apply(this,arguments)}function vv(){return vv=j(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream(Ll,{signal:t}),i=new mh({stream:r});i.write({type:Qt.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==Qt.Status.SUCCESS)}),vv.apply(this,arguments)}const Qi=Ft("libp2p:circuit");class BV{constructor(e){this.components=new co,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle(Ll,t=>{this._onProtocol(t).catch(r=>{Qi.error(r)})}).catch(t=>{Qi.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[iv](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new mi.TimeoutController(t._init.hop.timeout);try{(0,Lr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=$o(i,s.signal),a=new mh({stream:{...i,...o}}),l=yield a.read();if(null==l)return Qi("request was invalid, could not read from stream"),a.write({type:Qt.Type.STATUS,code:Qt.Status.MALFORMED_MESSAGE}),void a.close();let _;switch(l.type){case Qt.Type.CAN_HOP:Qi("received CAN_HOP request from %p",r.remotePeer),yield function LV(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();qi("can hop (%s) request from %p",i,e.remotePeer),t.end({type:Qt.Type.STATUS,code:i?Qt.Status.SUCCESS:Qt.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case Qt.Type.HOP:Qi("received HOP request from %p",r.remotePeer),yield function MV(n){return yv.apply(this,arguments)}({connection:r,request:l,streamHandler:a,circuit:t,connectionManager:t.components.getConnectionManager()});break;case Qt.Type.STOP:Qi("received STOP request from %p",r.remotePeer),_=yield function PV(n){const{connection:e,request:t,streamHandler:r}=n;try{t2(t,r)}catch(i){return void Fl.error("invalid stop request via peer %p %o",e.remotePeer,i)}return Fl("stop request is valid"),r.write({type:Qt.Type.STATUS,code:Qt.Status.SUCCESS}),r.rest()}({connection:r,request:l,streamHandler:a});break;default:return Qi("Request of type %s not supported",l.type),a.write({type:Qt.Type.STATUS,code:Qt.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=_){const B=JT({stream:_,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(new ln(l.dstPeer?.addrs[0])),localAddr:new ln(l.srcPeer?.addrs[0])}),V=l.type===Qt.Type.HOP?"relay":"inbound";Qi("new %s connection %s",V,B.remoteAddr);const Y=yield t.components.getUpgrader().upgradeInbound(B);Qi("%s connection %s upgraded",V,B.remoteAddr),null!=t.handler&&t.handler(Y)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return j(function*(){const i=e.toString().split("/p2p-circuit"),s=new ln(i[0]),o=new ln(i[i.length-1]),a=s.getPeerId(),l=o.getPeerId();if(null==a||null==l){const Y="Circuit relay dial failed as addresses did not have peer id";throw Qi.error(Y),se(new Error(Y),we.ERR_RELAYED_DIAL)}const _=ar(a),R=ar(l);let N=!1,V=r.components.getConnectionManager().getConnections(_)[0];null==V&&(yield r.components.getPeerStore().addressBook.add(_,[s]),V=yield r.components.getConnectionManager().openConnection(_,t),N=!0);try{const Y=yield function OV(n){return mv.apply(this,arguments)}({...t,connection:V,request:{type:Qt.Type.HOP,srcPeer:{id:r.components.getPeerId().toBytes(),addrs:r.components.getAddressManager().getAddresses().map(fe=>fe.bytes)},dstPeer:{id:R.toBytes(),addrs:[new ln(o).bytes]}}}),X=s.encapsulate(`/p2p-circuit/p2p/${r.components.getPeerId().toString()}`),ie=JT({stream:Y,remoteAddr:e,localAddr:X});return Qi("new outbound connection %s",ie.remoteAddr),yield r.components.getUpgrader().upgradeOutbound(ie)}catch(Y){throw Qi.error("Circuit relay dial failed",Y),N&&(yield V.close()),Y}})()}createListener(e){return this.handler=e.handler,function RV(n){const e=new Map;function r(){return(r=j(function*(o){const a=o.toString().split("/p2p-circuit").find(V=>""!==V),l=new ln(a),_=l.getPeerId();if(null==_)throw new Error("Could not determine relay peer from multiaddr");const R=ar(_);yield n.peerStore.addressBook.add(R,[l]);const N=yield n.connectionManager.openConnection(R),B=N.remoteAddr.encapsulate("/p2p-circuit");e.set(N.remotePeer.toString(),B),s.dispatchEvent(new qt("listening"))})).apply(this,arguments)}const s=Object.assign(new yi,{close:(o=j(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 qt("close"))}),s}({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>Jc.matches(t))}}function n2(n){return Ev.apply(this,arguments)}function Ev(){return Ev=j(function*(n){const e=(new TextEncoder).encode(n),t=yield hi.digest(e);return mr.createV0(t)}),Ev.apply(this,arguments)}const i2="hop_relay",o2="/libp2p/relay",Ul=Ft("libp2p:auto-relay"),HV=()=>{};class KV{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??lv,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??HV,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{Ul.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return j(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===Ll)){if(!t.listenRelays.has(s))try{const a=t.components.getConnectionManager().getConnections(r);if(0===a.length)return;const l=a[0];if(l.remoteAddr.protoCodes().includes(290))return void Ul(`relayed connection to ${s} will not be used to hop on`);(yield function kV(n){return vv.apply(this,arguments)}({connection:l}))&&(yield t.components.getPeerStore().metadataBook.setValue(r,i2,xt("true")),yield t._addListenRelay(l,s))}catch(a){t.onError(a)}}else t.listenRelays.has(s)&&(yield t._removeListenRelay(s))})()}_onPeerDisconnected(e){const i=e.detail.remotePeer.toString();!this.listenRelays.has(i)||this._removeListenRelay(i).catch(s=>{Ul.error(s)})}_addListenRelay(e,t){var r=this;return j(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield zn(yield r.components.getPeerStore().addressBook.get(e.remotePeer),o=>fv(o,r.addressSorter),function(){var o=j(function*(a){return yield Nl(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=j(function*(a){try{let l=a.multiaddr;return null==l.getPeerId()&&(l=l.encapsulate(`/p2p/${e.remotePeer.toString()}`)),l=l.encapsulate("/p2p-circuit"),yield r.components.getTransportManager().listen([l]),!0}catch(l){Ul.error("error listening on circuit address",l),r.onError(l)}return!1});return function(a){return o.apply(this,arguments)}}()))).includes(!0)&&r.listenRelays.add(t)}catch(i){r.onError(i),r.listenRelays.delete(t)}})()}_removeListenRelay(e){var t=this;return j(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return j(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.getPeerStore().all();for(const{id:R,metadata:N}of i){const B=R.toString();if(t.listenRelays.has(B)||e.includes(B))continue;const V=N.get(i2);if(null==V||"true"!==Rt(V))continue;const Y=t.components.getConnectionManager().getConnections(R);if(0!==Y.length){if(yield t._addListenRelay(Y[0],B),t.listenRelays.size>=t.maxListeners)return}else r.push(R)}for(const R of r)if(yield t._tryToListenOnRelay(R),t.listenRelays.size>=t.maxListeners)return;try{const R=yield n2(o2);var a,s=!1,o=!1;try{for(var _,l=wt(t.components.getContentRouting().findProviders(R));s=!(_=yield l.next()).done;s=!1){const N=_.value;if(0===N.multiaddrs.length)continue;const B=N.id;if(yield t.components.getPeerStore().addressBook.add(B,N.multiaddrs),yield t._tryToListenOnRelay(B),t.listenRelays.size>=t.maxListeners)return}}catch(N){o=!0,a=N}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}}catch(R){t.onError(R)}})()}_tryToListenOnRelay(e){var t=this;return j(function*(){try{const r=yield t.components.getConnectionManager().openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){Ul.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const a2=Ft("libp2p:relay");class $V{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new KV(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 j(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,gh.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return j(function*(){null!=e.timeout&&(0,gh.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return j(function*(){try{const t=yield n2(o2);yield e.components.getContentRouting().provide(t)}catch(t){t.code===we.ERR_NO_ROUTERS_AVAILABLE?(a2.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):a2.error(t)}})()}}var jV=x(8353);x(6826),x(3911);const c2=kn.pki;function bv(){return bv=j(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),bv.apply(this,arguments)}const WV=Ft("libp2p:keychain:cms"),wv=new WeakMap;class qV{constructor(e,t){if(null==e)throw se(new Error("keychain is required"),we.ERR_KEYCHAIN_REQUIRED);this.keychain=e,wv.set(this,{dek:t})}encrypt(e,t){var r=this;return j(function*(){if(!(t instanceof Uint8Array))throw se(new Error("Plain data must be a Uint8Array"),we.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=wv.get(r);if(null==o)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const l=kn.pki.decryptRsaPrivateKey(s,o.dek),_=yield((n,e)=>{const t=c2.rsa.setPublicKey(e.n,e.e),r=c2.createCertificate();r.publicKey=t,r.serialNumber="01",r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+10);const i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:n.id}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),r.sign(e),r})(i,l),R=kn.pkcs7.createEnvelopedData();return R.addRecipient(_),R.content=kn.util.createBuffer(t),R.encrypt(),xt(kn.asn1.toDer(R.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return j(function*(){if(!(e instanceof Uint8Array))throw se(new Error("CMS data is required"),we.ERR_INVALID_PARAMETERS);let r;try{const N=kn.util.createBuffer(Rt(e,"ascii")),B=kn.asn1.fromDer(N);r=kn.pkcs7.messageFromAsn1(B)}catch(N){throw WV.error(N),se(new Error("Invalid CMS"),we.ERR_INVALID_CMS)}const i=r.recipients.filter(N=>N.issuer.find(B=>"O"===B.shortName&&"ipfs"===B.value)).filter(N=>N.issuer.find(B=>"CN"===B.shortName)).map(N=>({recipient:N,keyId:N.issuer.find(B=>"CN"===B.shortName).value})),s=yield function zV(n,e){return bv.apply(this,arguments)}(i,function(){var N=j(function*(B){try{if(null!=(yield t.keychain.findKeyById(B.keyId)))return!0}catch{return!1}return!1});return function(B){return N.apply(this,arguments)}}());if(null==s){const N=i.map(B=>B.keyId);throw se(new Error(`Decryption needs one of the key(s): ${N.join(", ")}`),we.ERR_MISSING_KEYS,{missingKeys:N})}const o=yield t.keychain.findKeyById(s.keyId);if(null==o)throw se(new Error("No key available to decrypto"),we.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),l=wv.get(t);if(null==l)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const R=kn.pki.decryptRsaPrivateKey(a,l.dek);return r.decrypt(s.recipient,R),xt(r.content.getBytes(),"ascii")})()}}x(3859);var QV=x(9015);const l2={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function f2(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(l2).join(" / ");throw se(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=QV(n,e,t,r,l2[i]);return LF.encode64(o,null)}const vh=Ft("libp2p:keychain"),Qo=new WeakMap,Dv={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function ho(n){return null!=n&&"string"==typeof n&&n===jV(n.trim())&&n.length>0}function xn(){return Sv.apply(this,arguments)}function Sv(){return(Sv=j(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function Us(n){return new kr("/pkcs8/"+n)}function Yo(n){return new kr("/info/"+n)}class h2{constructor(e,t){if(this.components=e,this.init=Ol(Dv,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?f2(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Qo.set(this,{dek:r})}get cms(){const e=Qo.get(this);if(null==e)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);return new qV(this,e.dek)}static generateOptions(){const e=Object.assign({},Dv),t=3*Math.ceil(16/3);return e.dek.salt=Rt(Zd(t),"base64"),e}static get options(){return Dv}createKey(e,t,r=2048){var i=this;return j(function*(){if(!ho(e)||"self"===e)throw yield xn(),se(new Error("Invalid key name"),we.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield xn(),se(new Error("Invalid key type"),we.ERR_INVALID_KEY_TYPE);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield xn(),se(new Error("Key name already exists"),we.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield xn(),se(new Error("Invalid RSA key size"),we.ERR_INVALID_KEY_SIZE);let a;try{const l=yield kI(t,r),_=yield l.id(),R=Qo.get(i);if(null==R)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const N=R.dek,B=yield l.export(N);a={name:e,id:_};const V=i.components.getDatastore().batch();V.put(s,xt(B)),V.put(Yo(e),xt(JSON.stringify(a))),yield V.commit()}catch(l){throw yield xn(),l}return a})()}listKeys(){var e=this;return j(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var l,a=wt(e.components.getDatastore().query(t));i=!(l=yield a.next()).done;i=!1)r.push(JSON.parse(Rt(l.value.value)))}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return j(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield xn(),r}})()}findKeyByName(e){var t=this;return j(function*(){if(!ho(e))throw yield xn(),se(new Error(`Invalid key name '${e}'`),we.ERR_INVALID_KEY_NAME);const r=Yo(e);try{const i=yield t.components.getDatastore().get(r);return JSON.parse(Rt(i))}catch(i){throw yield xn(),vh.error(i),se(new Error(`Key '${e}' does not exist.`),we.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return j(function*(){if(!ho(e)||"self"===e)throw yield xn(),se(new Error(`Invalid key name '${e}'`),we.ERR_INVALID_KEY_NAME);const r=Us(e),i=yield t.findKeyByName(e),s=t.components.getDatastore().batch();return s.delete(r),s.delete(Yo(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return j(function*(){if(!ho(e)||"self"===e)throw yield xn(),se(new Error(`Invalid old key name '${e}'`),we.ERR_OLD_KEY_NAME_INVALID);if(!ho(t)||"self"===t)throw yield xn(),se(new Error(`Invalid new key name '${t}'`),we.ERR_NEW_KEY_NAME_INVALID);const i=Us(e),s=Us(t),o=Yo(e),a=Yo(t);if(yield r.components.getDatastore().has(s))throw yield xn(),se(new Error(`Key '${t}' already exists`),we.ERR_KEY_ALREADY_EXISTS);try{const _=yield r.components.getDatastore().get(i),R=yield r.components.getDatastore().get(o),N=JSON.parse(Rt(R));N.name=t;const B=r.components.getDatastore().batch();return B.put(s,_),B.put(a,xt(JSON.stringify(N))),B.delete(i),B.delete(o),yield B.commit(),N}catch(_){throw yield xn(),_}})()}exportKey(e,t){var r=this;return j(function*(){if(!ho(e))throw yield xn(),se(new Error(`Invalid key name '${e}'`),we.ERR_INVALID_KEY_NAME);if(null==t)throw yield xn(),se(new Error("Password is required"),we.ERR_PASSWORD_REQUIRED);const i=Us(e);try{const o=Rt(yield r.components.getDatastore().get(i)),a=Qo.get(r);if(null==a)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const l=a.dek;return yield(yield Tm(o,l)).export(t)}catch(s){throw yield xn(),s}})()}importKey(e,t,r){var i=this;return j(function*(){if(!ho(e)||"self"===e)throw yield xn(),se(new Error(`Invalid key name '${e}'`),we.ERR_INVALID_KEY_NAME);if(null==t)throw yield xn(),se(new Error("PEM encoded key is required"),we.ERR_PEM_REQUIRED);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield xn(),se(new Error(`Key '${e}' already exists`),we.ERR_KEY_ALREADY_EXISTS);let a,l;try{a=yield Tm(t,r)}catch{throw yield xn(),se(new Error("Cannot read the key, most likely the password is wrong"),we.ERR_CANNOT_READ_KEY)}try{l=yield a.id();const N=Qo.get(i);if(null==N)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const B=N.dek;t=yield a.export(B)}catch(N){throw yield xn(),N}const _={name:e,id:l},R=i.components.getDatastore().batch();return R.put(s,xt(t)),R.put(Yo(e),xt(JSON.stringify(_))),yield R.commit(),_})()}importPeer(e,t){var r=this;return j(function*(){try{if(!ho(e))throw se(new Error(`Invalid key name '${e}'`),we.ERR_INVALID_KEY_NAME);if(null==t||null==t.privateKey)throw se(new Error("Peer.privKey is required"),we.ERR_MISSING_PRIVATE_KEY);const i=yield Sl(t.privateKey),s=Us(e);if(yield r.components.getDatastore().has(s))throw yield xn(),se(new Error(`Key '${e}' already exists`),we.ERR_KEY_ALREADY_EXISTS);const a=Qo.get(r);if(null==a)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const l=a.dek,_=yield i.export(l),R={name:e,id:t.toString()},N=r.components.getDatastore().batch();return N.put(s,xt(_)),N.put(Yo(e),xt(JSON.stringify(R))),yield N.commit(),R}catch(i){throw yield xn(),i}})()}getPrivateKey(e){var t=this;return j(function*(){if(!ho(e))throw yield xn(),se(new Error(`Invalid key name '${e}'`),we.ERR_INVALID_KEY_NAME);try{const r=Us(e);return Rt(yield t.components.getDatastore().get(r))}catch(r){throw yield xn(),vh.error(r),se(new Error(`Key '${e}' does not exist.`),we.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return j(function*(){if("string"!=typeof e)throw yield xn(),se(new Error(`Invalid old pass type '${typeof e}'`),we.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield xn(),se(new Error(`Invalid new pass type '${typeof t}'`),we.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield xn(),se(new Error(`Invalid pass length ${t.length}`),we.ERR_INVALID_PASS_LENGTH);vh("recreating keychain");const i=Qo.get(r);if(null==i)throw se(new Error("dek missing"),we.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?f2(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";Qo.set(r,{dek:o});const a=yield r.listKeys();for(const l of a){const R=Rt(yield r.components.getDatastore().get(Us(l.name))),N=yield Tm(R,s),B=o.toString(),V=yield N.export(B),Y=r.components.getDatastore().batch(),X={name:l.name,id:l.id};Y.put(Us(l.name),xt(V)),Y.put(Yo(l.name),xt(JSON.stringify(X))),yield Y.commit()}vh("keychain reconstructed")})()}}var Cv=x(3153),ZV=x(4835);class XV{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 p2(n){return new XV(n)}class Iv extends yi{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t0&&this._resetComputeTimeout()}stop(){null!=this.timeout&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=kl(this._update,this._nextTimeout())}_nextTimeout(){return Math.max(this.computeThrottleTimeout*(1-this.queue.length/this.computeThrottleMaxQueueSize),0)}_update(){if(this.timeout=null,this.queue.length>0){let e=["",0,0];for(e of this.queue)this._applyOp(e);this.queue=[],e.length>2&&""!==e[0]&&this._updateFrequency(e[2]),this.dispatchEvent(new qt("update",{detail:this.stats}))}}_updateFrequency(e){const t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;const o=i/(t??1)*1e3;let a=this.movingAverages[e];null==a&&(a=this.movingAverages[e]=[]);const l=this.movingAverageIntervals;for(let _=0;_s:s})}forPeer(e){const t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){const t=e.toString(),r=this.peerStats.get(t);null!=r&&(r.stop(),this.peerStats.delete(t),this.oldPeers.set(t,r))}_onMessage(e){if(!this.running)return;const{remotePeer:t,protocol:r,direction:i,dataLength:s}=e,o=e9[i];let a=this.forPeer(t);if(null==a){const l=new Iv(this.statsInit);this.peerStats.set(t.toString(),l),a=l}if(a.push(o,s),this.globalStats.push(o,s),null!=r){let l=this.forProtocol(r);if(null==l){const _=new Iv(this.statsInit);this.protocolStats.set(r,_),l=_}l.push(o,s)}}updatePlaceholder(e,t){if(!this.running)return;const r=e.toString(),i=this.peerStats.get(r)??this.oldPeers.get(r),s=t.toString(),o=this.peerStats.get(s)??this.oldPeers.get(s);let a=i;null!=o&&(a=function n9(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=Cv(r.source,l=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:l.byteLength}));const a=r.sink;r.sink=function(){var l=j(function*(_){return yield zn(_,R=>Cv(R,N=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:N.byteLength})}),a)});return function(_){return l.apply(this,arguments)}}()}}function Tv(n){return Av.apply(this,arguments)}function Av(){return Av=j(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),Av.apply(this,arguments)}function xv(n,e,t){(function r9(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 g2(n,e,t){if(!e.has(n))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(n)}function po(n,e,t){return function i9(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,g2(n,e,"set"),t),t}function Zo(n,e){return function s9(n,e){return e.get?e.get.call(n):e.value}(n,g2(n,e,"get"))}function y2(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let m2;class o9{constructor(e){y2(this,"value",void 0),y2(this,"next",void 0),this.value=e}}var Xo=new WeakMap,Vl=new WeakMap,Ia=new WeakMap;m2=Symbol.iterator;class a9{constructor(){xv(this,Xo,{writable:!0,value:void 0}),xv(this,Vl,{writable:!0,value:void 0}),xv(this,Ia,{writable:!0,value:void 0}),this.clear()}enqueue(e){var t;const i=new o9(e);Zo(this,Xo)?(Zo(this,Vl).next=i,po(this,Vl,i)):(po(this,Xo,i),po(this,Vl,i)),po(this,Ia,(t=Zo(this,Ia),++t))}dequeue(){var e;const r=Zo(this,Xo);if(r)return po(this,Xo,Zo(this,Xo).next),po(this,Ia,(e=Zo(this,Ia),--e)),r.value}clear(){po(this,Xo,void 0),po(this,Vl,void 0),po(this,Ia,0)}get size(){return Zo(this,Ia)}*[m2](){let e=Zo(this,Xo);for(;e;)yield e.value,e=e.next}}function c9(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 a9;let t=0;const i=function(){var a=j(function*(l,_,R){t++;const N=j(function*(){return l(...R)})();_(N);try{yield N}catch{}t--,e.size>0&&e.dequeue()()});return function(_,R,N){return a.apply(this,arguments)}}(),o=(a,...l)=>new Promise(_=>{((a,l,_)=>{e.enqueue(i.bind(void 0,a,l,_)),j(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,_,l)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function u9(n){return Rv.apply(this,arguments)}function Rv(){return Rv=j(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=c9(t);return Promise.all(n.map(i=>Tv(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),Rv.apply(this,arguments)}const Ta=Ft("libp2p:transports");class l9 extends yi{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=xl({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??Aa.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw se(new Error("Transport must have a valid tag"),we.ERR_INVALID_KEY);if(this.transports.has(t))throw se(new Error("There is already a transport with this tag"),we.ERR_DUPLICATE_TRANSPORT);Ta("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 j(function*(){const t=e.components.getAddressManager().getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return j(function*(){const t=[];for(const[r,i]of e.listeners)for(Ta("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),Ta("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return j(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw se(new Error(`No transport available for address ${String(e)}`),we.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.getUpgrader()})}catch(s){throw null==s.code&&(s.code=we.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 j(function*(){if(null==e||0===e.length)return void Ta("no addresses were provided for listening, this node is dial only");const r=[];for(const[i,s]of t.transports.entries()){const o=s.filter(e),a=[];for(const R of o){Ta("creating listener for %s on %s",i,R);const N=s.createListener({upgrader:t.components.getUpgrader()});let B=t.listeners.get(i);null==B&&(B=[],t.listeners.set(i,B)),B.push(N),N.addEventListener("listening",()=>{t.dispatchEvent(new qt("listener:listening",{detail:N}))}),N.addEventListener("close",()=>{t.dispatchEvent(new qt("listener:close",{detail:N}))}),a.push(N.listen(R))}if(0!==a.length){if(null==(yield u9(a)).find(R=>R.isFulfilled)&&t.faultTolerance!==Aa.NO_FATAL)throw se(new Error(`Transport (${i}) could not listen on any available address`),we.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===Aa.FATAL_ALL)throw se(new Error(i),we.ERR_NO_VALID_ADDRESSES);Ta(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return j(function*(){Ta("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 j(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var Aa=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(Aa||(Aa={})),Aa))();const eu="/multistream/1.0.0",v2=xt("\n");function Pv(n){const e=new jr(n,v2);return Os.single(e)}function Hl(n,e,t={}){const r=Pv(e);n.push(!0===t.writeBytes?r.subarray():r)}function f9(n,e,t={}){const r=new jr;for(const i of e)r.append(Pv(i));n.push(!0===t.writeBytes?r.subarray():r)}function d9(n,e){return Nv.apply(this,arguments)}function Nv(){return Nv=j(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=j(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=vs(r,e.signal));const o=yield zn(i,ps({onLength:a=>{t=a}}),function(){var a=j(function*(l){return yield Sa(l)});return function(l){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)!==v2[0])throw se(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),Nv.apply(this,arguments)}function Eh(n,e){return Mv.apply(this,arguments)}function Mv(){return Mv=j(function*(n,e){return Rt((yield d9(n,e)).subarray())}),Mv.apply(this,arguments)}const Kl=Ft("libp2p:mss:select");function Ov(n,e){return kv.apply(this,arguments)}function kv(){return kv=j(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=Pd(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");Kl('select: write ["%s", "%s"]',eu,a),f9(i,[xt(eu),xt(a)],t);let R=yield Eh(r,t);if(Kl('select: read "%s"',R),R===eu&&(R=yield Eh(r,t),Kl('select: read "%s"',R)),R===a)return s(),{stream:o,protocol:a};for(const N of e){Kl('select: write "%s"',N),Hl(i,xt(N),t);const B=yield Eh(r,t);if(Kl('select: read "%s" for "%s"',B,N),B===N)return s(),{stream:o,protocol:N}}throw s(),se(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}),kv.apply(this,arguments)}const $l=Ft("libp2p:mss:handle");function Lv(n,e,t){return Bv.apply(this,arguments)}function Bv(){return Bv=j(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=Pd(n);for(;;){const a=yield Eh(i,t);if($l('read "%s"',a),a!==eu){if(e.includes(a))return Hl(r,xt(a),t),$l('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(Hl(r,xt("na"),t),$l('respond with "na" for "%s"',a)):(Hl(r,new jr(...e.map(l=>Pv(xt(l)))),t),$l('respond with "%s" for %s',e,a))}else $l('respond with "%s" for "%s"',eu,a),Hl(r,xt(eu),t)}}),Bv.apply(this,arguments)}var E2=x(6058);const b2=Symbol.for("@libp2p/connection"),h9=Ft("libp2p:connection");class p9{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[b2](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return j(function*(){if(r.stat.status===GT)throw se(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===uv)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 j(function*(){if(e.stat.status!==uv&&!e._closing){e.stat.status=GT;try{e.streams.forEach(t=>t.close())}catch(t){h9.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=uv}})()}}const Fv=Symbol.for("@libp2p/topology"),w2=Ft("libp2p:registrar");class m9{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}`),we.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 j(function*(){if(i.handlers.has(e))throw se(new Error(`Handler already registered for protocol ${e}`),we.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Ol.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 j(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 j(function*(){if(!function y9(n){return null!=n&&Boolean(n[Fv])}(t))throw w2.error("topology must be an instance of interfaces/topology"),se(new Error("topology must be an instance of interfaces/topology"),we.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=>{w2.error(r)})}_onProtocolChange(e){const{peerId:t,protocols:r,oldProtocols:i}=e.detail,s=i.filter(a=>!r.includes(a)),o=r.filter(a=>!i.includes(a));for(const a of s){const l=this.topologies.get(a);if(null!=l)for(const _ of l.values())_.onDisconnect(t)}for(const a of o){const l=this.topologies.get(a);if(null!=l)for(const _ of l.values()){const R=this.components.getConnectionManager().getConnections(t)[0];null!=R&&_.onConnect(t,R)}}}}const Hn=Ft("libp2p:upgrader");function S2(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class b9 extends yi{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 j(function*(){let r,i,s,o,a,l,_;const R=t.components.getMetrics(),N=new mi.TimeoutController(t.inboundUpgradeTimeout);try{(0,Lr.setMaxListeners)?.(1/0,N.signal)}catch{}try{const B=$o(e,N.signal);if(e.source=B.source,e.sink=B.sink,yield t.components.getConnectionGater().denyInboundConnection(e))throw se(new Error("The multiaddr connection is blocked by gater.acceptConnection"),we.ERR_CONNECTION_INTERCEPTED);if(null!=R){({setTarget:l,proxy:_}=E2());const X=`${(1e9*Math.random()).toString(36)}${Date.now()}`;l({toString:()=>X}),R.trackStream({stream:e,remotePeer:_})}Hn("starting the inbound connection upgrade");let V=e;const Y=t.components.getConnectionProtector();null!=Y&&(Hn("protecting the inbound connection"),V=yield Y.protect(e));try{if(({conn:r,remotePeer:i,protocol:a}=yield t._encryptInbound(V)),yield t.components.getConnectionGater().denyInboundEncryptedConnection(i,{...V,...r}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),we.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const X=yield t._multiplexInbound({...V,...r},t.muxers);o=X.muxerFactory,s=X.stream}else s=r}catch(X){throw Hn.error("Failed to upgrade inbound connection",X),yield e.close(X),X}if(yield t.components.getConnectionGater().denyInboundUpgradedConnection(i,{...V,...r}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),we.ERR_CONNECTION_INTERCEPTED);return null!=R&&(R.updatePlaceholder(_,i),l(i)),Hn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{N.clear()}})()}upgradeOutbound(e){var t=this;return j(function*(){const r=e.remoteAddr.getPeerId();if(null==r)throw se(new Error("outbound connection must have a peer id"),we.ERR_INVALID_MULTIADDR);const i=ar(r);if(yield t.components.getConnectionGater().denyOutboundConnection(i,e))throw se(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),we.ERR_CONNECTION_INTERCEPTED);let s,o,a,l,_,R,N;const B=t.components.getMetrics();if(null!=B){({setTarget:R,proxy:N}=E2());const X=`${(1e9*Math.random()).toString(36)}${Date.now()}`;R({toB58String:()=>X}),B.trackStream({stream:e,remotePeer:N})}Hn("Starting the outbound connection upgrade");let V=e;const Y=t.components.getConnectionProtector();null!=Y&&(V=yield Y.protect(e));try{if(({conn:s,remotePeer:o,protocol:l}=yield t._encryptOutbound(V,i)),yield t.components.getConnectionGater().denyOutboundEncryptedConnection(o,{...V,...s}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),we.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const X=yield t._multiplexOutbound({...V,...s},t.muxers);_=X.muxerFactory,a=X.stream}else a=s}catch(X){throw Hn.error("Failed to upgrade outbound connection",X),yield e.close(X),X}if(yield t.components.getConnectionGater().denyOutboundUpgradedConnection(o,{...V,...s}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),we.ERR_CONNECTION_INTERCEPTED);return null!=B&&(B.updatePlaceholder(N,o),R(o)),Hn("Successfully upgraded outbound connection"),t._createConnection({cryptoProtocol:l,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:_,remotePeer:o})})()}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:i,maConn:s,upgradedConn:o,remotePeer:a,muxerFactory:l}=e;let _,R,N;null!=l&&(_=l.createStreamMuxer({direction:i,onIncomingStream:Y=>{null!=N&&Promise.resolve().then(j(function*(){const X=t.components.getRegistrar().getProtocols(),{stream:ie,protocol:fe}=yield Lv(Y,X);if(Hn("%s: incoming stream opened on %s",i,fe),t.components.getMetrics()?.trackStream({stream:ie,remotePeer:a,protocol:fe}),null==N)return;const ae=function v9(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==we.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(fe,t.components.getRegistrar());S2(fe,"inbound",N)!==ae?(Y.stat.protocol=fe,t.components.getPeerStore().protoBook.add(a,[fe]).catch(Fe=>Hn.error(Fe)),N.addStream(Y),t._onStream({connection:N,stream:{...Y,...ie},protocol:fe})):Y.abort(se(new Error(`Too many inbound protocol streams for protocol "${fe}" - limit ${ae}`),we.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(X=>{Hn.error(X),null==Y.stat.timeline.close&&Y.close()})},onStreamEnd:Y=>{N?.removeStream(Y.id)}}),Or(_)&&_.init(this.components),R=function(){var Y=j(function*(X,ie={}){if(null==_)throw se(new Error("Stream is not multiplexed"),we.ERR_MUXER_UNAVAILABLE);Hn("%s: starting new stream on %s",i,X);const fe=_.newStream(),Se=t.components.getMetrics();let ae;try{if(null==ie.signal){Hn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",X),ae=new mi.TimeoutController(3e4),ie.signal=ae.signal;try{(0,Lr.setMaxListeners)?.(1/0,ae.signal)}catch{}}const{stream:Ie,protocol:Fe}=yield Ov(fe,X,ie);Se?.trackStream({stream:Ie,remotePeer:a,protocol:Fe});const Te=function E9(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==we.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}(Fe,t.components.getRegistrar());if(S2(Fe,"outbound",N)===Te){const ut=se(new Error(`Too many outbound protocol streams for protocol "${Fe}" - limit ${Te}`),we.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw fe.abort(ut),ut}return fe.stat.protocol=Fe,t.components.getPeerStore().protoBook.add(a,[Fe]).catch(ut=>Hn.error(ut)),{...fe,...Ie,stat:{...fe.stat,protocol:Fe}}}catch(Ie){throw Hn.error("could not create new stream",Ie),null==fe.stat.timeline.close&&fe.close(),null!=Ie.code?Ie:se(Ie,we.ERR_UNSUPPORTED_PROTOCOL)}finally{ae?.clear()}});return function(ie){return Y.apply(this,arguments)}}(),zn(o,_,o).catch(Hn.error));const B=s.timeline;s.timeline=new Proxy(B,{set:(...Y)=>(null!=N&&"close"===Y[1]&&null!=Y[2]&&null==B.close&&j(function*(){try{"OPEN"===N.stat.status&&(yield N.close())}catch(X){Hn.error(X)}finally{t.dispatchEvent(new qt("connectionEnd",{detail:N}))}})().catch(X=>{Hn.error(X)}),Reflect.set(...Y))}),s.timeline.upgraded=Date.now();const V=()=>{throw se(new Error("connection is not multiplexed"),we.ERR_CONNECTION_NOT_MULTIPLEXED)};return N=function g9(n){return new p9(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:_?.protocol,encryption:r},newStream:R??V,getStreams:()=>null!=_?_.streams:V(),close:(Y=j(function*(){yield s.close(),_?.close()}),function(){return Y.apply(this,arguments)})}),this.dispatchEvent(new qt("connection",{detail:N})),N;var Y}_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 j(function*(){const r=Array.from(t.connectionEncryption.keys());Hn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield Lv(e,r,{writeBytes:!0}),o=t.connectionEncryption.get(s);if(null==o)throw new Error(`no crypto module found for ${s}`);return Hn("encrypting inbound connection..."),{...yield o.secureInbound(t.components.getPeerId(),i),protocol:s}}catch(i){throw se(i,we.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return j(function*(){const i=Array.from(r.connectionEncryption.keys());Hn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield Ov(e,i,{writeBytes:!0}),a=r.connectionEncryption.get(o);if(null==a)throw new Error(`no crypto module found for ${o}`);return Hn("encrypting outbound connection to %p",t),{...yield a.secureOutbound(r.components.getPeerId(),s,t),protocol:o}}catch(s){throw se(s,we.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return j(function*(){const r=Array.from(t.keys());Hn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield Ov(e,r,{writeBytes:!0});return Hn("%s selected as muxer protocol",s),{stream:i,muxerFactory:t.get(s)}}catch(i){throw Hn.error("error multiplexing outbound stream",i),se(i,we.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return j(function*(){const r=Array.from(t.keys());Hn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield Lv(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw Hn.error("error multiplexing inbound stream",i),se(i,we.ERR_MUXER_UNAVAILABLE)}})()}}var xa;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(xa||(xa={}));var bh;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(bh||(bh={}));class vi{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=bh.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return Pr(this.marshal(),e.marshal())}validate(e){var t=this;return j(function*(){const r=C2(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Dl(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}vi.createFromProtobuf=function(){var n=j(function*(e){const t=bh.decode(e),r=yield Al(t.publicKey);return new vi({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),vi.seal=function(){var n=j(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=C2(r,i,s),l=yield(yield Sl(t.privateKey)).sign(o.subarray());return new vi({peerId:t,payloadType:i,payload:s,signature:l})});return function(e,t){return n.apply(this,arguments)}}(),vi.openAndCertify=function(){var n=j(function*(e,t){const r=yield vi.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 C2=(n,e,t)=>{const r=xt(n),i=Ri.encode(r.byteLength),s=Ri.encode(e.length),o=Ri.encode(t.length);return new jr(i,r,s,e,o,t)};var wh;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Bt((s,o,a={})=>{if(!1!==a.lengthDelimited&&o.fork(),null==s.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');o.uint32(10),o.bytes(s.multiaddr),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={multiaddr:new Uint8Array(0)},l=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&_)}if(null==a.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return a})),i),r.encode=s=>Lt(s,r.codec()),r.decode=s=>kt(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=Bt((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=>Lt(r,n.codec()),n.decode=r=>kt(r,n.codec())}(wh||(wh={}));const C9=Uint8Array.from([3,1]);let tu=(()=>{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=wh.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 D9(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=wh.decode(e),r=Yc(t.peerId),i=(t.addresses??[]).map(o=>new ln(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=C9,n})();const T2="js-libp2p/0.0.0",Bn=Ft("libp2p:identify");class Uv{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(Bn.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Bn.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Bn.error(s))})}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started||(yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"AgentVersion",xt(e.host.agentVersion)),yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"ProtocolVersion",xt(e.host.protocolVersion)),yield e.components.getRegistrar().handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{Bn.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.getRegistrar().handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{Bn.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.identifyProtocolStr),yield e.components.getRegistrar().unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return j(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=j(function*(l){let _;const R=new mi.TimeoutController(t.init.timeout);try{(0,Lr.setMaxListeners)?.(1/0,R.signal)}catch{}try{_=yield l.newStream([t.identifyPushProtocolStr],{signal:R.signal});const N=$o(_,R.signal);yield zn([xa.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],Os(),N,Wo)}catch(N){Bn.error("could not push identify update to peer",N)}finally{_?.close(),R.clear()}});return function(l){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return j(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 j(function*(){let i,o,s=t.signal;if(null==s){i=new mi.TimeoutController(r.init.timeout),s=i.signal;try{(0,Lr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=$o(o,s),l=yield zn([],a,ps({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var _=j(function*(R){return yield Sa(R)});return function(R){return _.apply(this,arguments)}}());if(null==l)throw se(new Error("No data could be retrieved"),we.ERR_CONNECTION_ENDED);try{return xa.decode(l)}catch(_){throw se(_,we.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return j(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:l,signedPeerRecord:_,agentVersion:R,protocolVersion:N}=i;if(null==s)throw se(new Error("public key was missing from identify message"),we.ERR_MISSING_PUBLIC_KEY);const B=yield Al(s);if(!e.remotePeer.equals(B))throw se(new Error("identified peer does not match the expected peer"),we.ERR_INVALID_PEER);if(r.components.getPeerId().equals(B))throw se(new Error("identified peer is our own peer id?"),we.ERR_INVALID_PEER);const V=Uv.getCleanMultiaddr(l);if(null!=_){Bn("received signed peer record from %p",B);try{const Y=yield vi.openAndCertify(_,tu.DOMAIN);if(!Y.peerId.equals(B))throw se(new Error("identified peer does not match the expected peer"),we.ERR_INVALID_PEER);if(yield r.components.getPeerStore().addressBook.consumePeerRecord(Y))return yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",xt(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",xt(N))),void Bn("identify completed for peer %p and protocols %o",B,a)}catch(Y){Bn("received invalid envelope, discard it and fallback to listenAddrs is available",Y)}}else Bn("no signed peer record received from %p",B);Bn("falling back to legacy addresses from %p",B);try{yield r.components.getPeerStore().addressBook.set(B,o.map(Y=>new ln(Y)))}catch(Y){Bn.error("received invalid addrs",Y)}yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",xt(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",xt(N))),Bn("identify completed for peer %p and protocols %o",B,a),Bn("received observed address of %s",V?.toString())})()}_handleIdentify(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new mi.TimeoutController(t.init.timeout);try{(0,Lr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=t.components.getPeerId().publicKey??new Uint8Array(0),a=yield t.components.getPeerStore().get(t.components.getPeerId()),l=t.components.getAddressManager().getAddresses().map(B=>B.decapsulateCode(Er("p2p").code));let _=a.peerRecordEnvelope;if(l.length>0&&null==_){const B=new tu({peerId:t.components.getPeerId(),multiaddrs:l}),V=yield vi.seal(B,t.components.getPeerId());yield t.components.getPeerStore().addressBook.consumePeerRecord(V),_=V.marshal().subarray()}const R=xa.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:l.map(B=>B.bytes),signedPeerRecord:_,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),N=$o(i,s.signal);yield zn([R],Os(),N,Wo)}catch(o){Bn.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new mi.TimeoutController(t.init.timeout);try{(0,Lr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const l=$o(i,s.signal),_=yield zn([],l,ps({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var R=j(function*(N){return yield Sa(N)});return function(N){return R.apply(this,arguments)}}());null!=_&&(o=xa.decode(_))}catch(l){return Bn.error("received invalid message",l)}finally{i.close(),s.clear()}if(null==o)return Bn.error("received invalid message");const a=r.remotePeer;if(t.components.getPeerId().equals(a))Bn("received push from ourselves?");else{if(Bn("received push from %p",a),null!=o.signedPeerRecord){Bn("received signedPeerRecord in push");try{const l=yield vi.openAndCertify(o.signedPeerRecord,tu.DOMAIN);if(yield t.components.getPeerStore().addressBook.consumePeerRecord(l))return Bn("consumed signedPeerRecord sent in push"),void(yield t.components.getPeerStore().protoBook.set(a,o.protocols));Bn("failed to consume signedPeerRecord sent in push")}catch(l){Bn("received invalid envelope, discard it and fallback to listenAddrs is available",l)}}else Bn("did not receive signedPeerRecord in push");try{yield t.components.getPeerStore().addressBook.set(a,o.listenAddrs.map(l=>new ln(l)))}catch(l){Bn.error("received invalid addrs",l)}try{yield t.components.getPeerStore().protoBook.set(a,o.protocols)}catch(l){Bn.error("received invalid protocols",l)}Bn("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return new ln(e)}catch{}}}var _h,Vs;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(_h||(_h={})),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=()=>Oo(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=Bt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.status)throw new Error('Protocol error: required field "status" was not found in object');if(s.uint32(8),n.StatusCode.codec().encode(i.status,s),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(18),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.status=n.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(7&l)}}if(null==o.status)throw new Error('Protocol error: value for required field "status" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),n.encode=i=>Lt(i,n.codec()),n.decode=i=>kt(i,n.codec())}(Vs||(Vs={}));const x2=Ft("libp2p:fetch");class L9{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 j(function*(){yield e.components.getRegistrar().handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{x2.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return j(function*(){x2("dialing %s to %p",i.protocol,e);const s=yield i.components.getConnectionManager().openConnection(e,r);let o,l,a=r.signal;if(null==a){o=new mi.TimeoutController(i.init.timeout),a=o.signal;try{(0,Lr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{l=yield s.newStream([i.protocol],{signal:a});const _=$o(l,a);return(yield zn([_h.encode({identifier:t})],Os(),_,ps(),function(){var N=j(function*(B){const V=yield Sa(B);if(null==V)throw se(new Error("No data received"),we.ERR_INVALID_MESSAGE);const Y=Vs.decode(V);switch(Y.status){case Vs.StatusCode.OK:return Y.data;case Vs.StatusCode.NOT_FOUND:return null;case Vs.StatusCode.ERROR:{const X=(new TextDecoder).decode(Y.data);throw se(new Error("Error in fetch protocol response: "+X),we.ERR_INVALID_PARAMETERS)}default:throw se(new Error("Unknown response status"),we.ERR_INVALID_MESSAGE)}});return function(B){return N.apply(this,arguments)}}()))??null}finally{o?.clear(),l?.close()}})()}handleMessage(e){var t=this;return j(function*(){const{stream:r}=e,i=t;yield zn(r,ps(),function(){var s=on(function*(o){const a=yield tt(Sa(o));if(null==a)throw se(new Error("No data received"),we.ERR_INVALID_MESSAGE);const l=_h.decode(a);let _;const R=i._getLookupFunction(l.identifier);if(null!=R){const N=yield tt(R(l.identifier));_=null!=N?{status:Vs.StatusCode.OK,data:N}:{status:Vs.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{const N=(new TextEncoder).encode("No lookup function registered for key: "+l.identifier);_={status:Vs.StatusCode.ERROR,data:N}}yield Vs.encode(_)});return function(o){return s.apply(this,arguments)}}(),Os(),r)})()}_getLookupFunction(e){for(const t of this.lookupFunctions.keys())if(e.startsWith(t))return this.lookupFunctions.get(t)}registerLookupFunction(e,t){if(this.lookupFunctions.has(e))throw se(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),we.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const R2=Ft("libp2p:ping");class V9{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 j(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 j(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;zn(t,t).catch(r=>{R2.error(r)})}ping(e,t={}){var r=this;return j(function*(){R2("dialing %s to %p",r.protocol,e);const i=Date.now(),s=Zd(32),o=yield r.components.getConnectionManager().openConnection(e,t);let a,_,l=t.signal;if(null==l){a=new mi.TimeoutController(r.init.timeout),l=a.signal;try{(0,Lr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{_=yield o.newStream([r.protocol],{signal:l});const R=$o(_,l),N=yield zn([s],R,function(){var V=j(function*(Y){return yield Sa(Y)});return function(Y){return V.apply(this,arguments)}}()),B=Date.now();if(null==N||!Pr(s,N.subarray()))throw se(new Error("Received wrong ping ack"),we.ERR_WRONG_PING_ACK);return B-i}finally{a?.clear(),_?.close()}})()}}function Vv(){return(Vv=j(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function $9(n){const{address:e}=n.nodeAddress();return function K9(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const Kv=Ft("libp2p:nat");function j9(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class G9{constructor(e,t){if(this.components=e,this.started=!1,this.enabled=t.enabled,this.externalAddress=t.externalAddress,this.localAddress=t.localAddress,this.description=t.description??`libp2p@0.0.0 ${this.components.getPeerId().toString()}`,this.ttl=t.ttl??7200,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<7200)throw se(new Error("NatManager ttl should be at least 7200 seconds"),we.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){dh||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{Kv.error(e)}))}_start(){var e=this;return j(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||$9(r)||4!==i)continue;const l=yield e._getClient(),_=e.externalAddress??(yield l.externalIp());if(WT(_))throw new Error(`${_} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const R=j9();Kv(`opening uPnP connection from ${_}:${R} to ${s}:${o}`),yield l.map({publicPort:R,localPort:o,localAddress:e.localAddress,protocol:"TCP"===a.toUpperCase()?"TCP":"UDP"}),e.components.getAddressManager().addObservedAddr(ln.fromNodeAddress({family:4,address:_,port:R},a))}})()}_getClient(){var e=this;return j(function*(){return null!=e.client||(e.client=yield function H9(){return Vv.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return j(function*(){if(!dh&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){Kv.error(t)}})()}}const z9=Ft("libp2p:peer-record-updater");class W9{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return j(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 j(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(j(function*(){const t=new tu({peerId:e.components.getPeerId(),multiaddrs:e.components.getAddressManager().getAddresses().map(i=>i.decapsulateCode(Er("p2p").code))}),r=yield vi.seal(t,e.components.getPeerId());yield e.components.getPeerStore().addressBook.consumePeerRecord(r)})).catch(t=>{z9.error("Could not update self peer record: %o",t)})}}class q9{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return j(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(r.dht.findPeer(e,t));i=!(l=yield a.next()).done;i=!1){const _=l.value;if("FINAL_PEER"===_.name)return _.peer}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw se(new Error(pn.NOT_FOUND),we.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return on(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(r.dht.getClosestPeers(e,t));i=!(l=yield tt(a.next())).done;i=!1){const _=l.value;"PEER_RESPONSE"===_.name&&(yield*Rr(wt(_.closer),tt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield tt(a.return()))}finally{if(s)throw o}}})()}}const Rn=Ft("libp2p:peer-store:address-book"),Dh="change:multiaddrs";function Q9(){return jv.apply(this,arguments)}function jv(){return(jv=j(function*(){return!0})).apply(this,arguments)}class Y9{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??Q9}consumePeerRecord(e){var t=this;return j(function*(){Rn.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Rn.trace("consumePeerRecord got write lock");try{let a;try{a=tu.createFromProtobuf(e.payload)}catch{return Rn.error("invalid peer record received"),!1}i=a.peerId;const l=a.multiaddrs;if(!i.equals(e.peerId))return Rn("signing key does not match PeerId in the PeerRecord"),!1;if(null==l||0===l.length)return!1;if((yield t.store.has(i))&&(s=yield t.store.load(i),null!=s.peerRecordEnvelope)){const R=yield vi.createFromProtobuf(s.peerRecordEnvelope),N=tu.createFromProtobuf(R.payload);if(N.seqNumber>=a.seqNumber)return Rn("sequence number was lower or equal to existing sequence number - stored: %d received: %d",N.seqNumber,a.seqNumber),!1}const _=yield Gv(i,l,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:_,peerRecordEnvelope:e.marshal().subarray()}),Rn("stored provided peer record for %p",a.peerId)}finally{Rn.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new qt(Dh,{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 j(function*(){Rn.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Rn.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Rn.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return j(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield vi.createFromProtobuf(r)})()}get(e){var t=this;return j(function*(){e=Mr(e),Rn.trace("get wait for read lock");const r=yield t.store.lock.readLock();Rn.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Rn.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return j(function*(){if(e=Mr(e),!Array.isArray(t))throw Rn.error("multiaddrs must be an array of Multiaddrs"),se(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Rn.trace("set await write lock");const i=yield r.store.lock.writeLock();Rn.trace("set got write lock");let o,a,s=!1;try{const l=yield Gv(e,t,r.addressFilter);if(0===l.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...l.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length&&l.length===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.patchOrCreate(e,{addresses:l}),Rn("set multiaddrs for %p",e)}finally{Rn.trace("set multiaddrs for %p",e),Rn("set release write lock"),i()}r.dispatchEvent(new qt(Dh,{detail:{peerId:e,multiaddrs:a.addresses.map(l=>l.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:l})=>l)}})),s||r.dispatchEvent(new qt("peer",{detail:{id:e,multiaddrs:a.addresses.map(l=>l.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return j(function*(){if(e=Mr(e),!Array.isArray(t))throw Rn.error("multiaddrs must be an array of Multiaddrs"),se(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Rn.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Rn.trace("add got write lock");try{const l=yield Gv(e,t,r.addressFilter);if(0===l.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...l.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.mergeOrCreate(e,{addresses:l}),Rn("added multiaddrs for %p",e)}finally{Rn.trace("set release write lock"),i()}r.dispatchEvent(new qt(Dh,{detail:{peerId:e,multiaddrs:a.addresses.map(l=>l.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:l})=>l)}})),!0===s&&r.dispatchEvent(new qt("peer",{detail:{id:e,multiaddrs:a.addresses.map(l=>l.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return j(function*(){e=Mr(e),Rn.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Rn.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{Rn.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new qt(Dh,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function Gv(n,e,t){return zv.apply(this,arguments)}function zv(){return zv=j(function*(n,e,t,r=!1){return yield zn(e,i=>Cv(i,s=>{if(!ln.isMultiaddr(s))throw Rn.error("multiaddr must be an instance of Multiaddr"),se(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>Ds(i,function(){var s=j(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>sv(i,s=>({multiaddr:new ln(s.toString()),isCertified:r})),function(){var i=j(function*(s){return yield Nl(s)});return function(s){return i.apply(this,arguments)}}())}),zv.apply(this,arguments)}const Hs=Ft("libp2p:peer-store:key-book"),P2="change:pubkey";class Z9{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return j(function*(){if(e=Mr(e),!(t instanceof Uint8Array))throw Hs.error("publicKey must be an instance of Uint8Array to store data"),se(new Error("publicKey must be an instance of PublicKey"),"ERR_INVALID_PARAMETERS");Hs.trace("set await write lock");const i=yield r.store.lock.writeLock();Hs.trace("set got write lock");let o,s=!1;try{try{if(o=yield r.store.load(e),null!=o.pubKey&&Pr(o.pubKey,t))return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}yield r.store.patchOrCreate(e,{pubKey:t}),s=!0}finally{Hs.trace("set release write lock"),i()}s&&r.dispatchEvent(new qt(P2,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return j(function*(){e=Mr(e),Hs.trace("get await write lock");const r=yield t.store.lock.readLock();Hs.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Hs("get release write lock"),r()}})()}delete(e){var t=this;return j(function*(){e=Mr(e),Hs.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Hs.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{pubKey:void 0})}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Hs.trace("delete release write lock"),r()}t.dispatchEvent(new qt(P2,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const br=Ft("libp2p:peer-store:metadata-book"),Sh="change:metadata";class X9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return j(function*(){e=Mr(e),br.trace("get await read lock");const r=yield t.store.lock.readLock();br.trace("get got read lock");try{return(yield t.store.load(e)).metadata}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{br.trace("get release read lock"),r()}return new Map})()}getValue(e,t){var r=this;return j(function*(){e=Mr(e),br.trace("getValue await read lock");const i=yield r.store.lock.readLock();br.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{br.trace("getValue release write lock"),i()}})()}set(e,t){var r=this;return j(function*(){if(e=Mr(e),!(t instanceof Map))throw br.error("valid metadata must be provided to store data"),se(new Error("valid metadata must be provided"),"ERR_INVALID_PARAMETERS");br.trace("set await write lock");const i=yield r.store.lock.writeLock();let s;br.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{br.trace("set release write lock"),i()}r.dispatchEvent(new qt(Sh,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return j(function*(){if(e=Mr(e),"string"!=typeof t||!(r instanceof Uint8Array))throw br.error("valid key and value must be provided to store data"),se(new Error("valid key and value must be provided"),"ERR_INVALID_PARAMETERS");br.trace("setValue await write lock");const s=yield i.store.lock.writeLock();let o,a;br.trace("setValue got write lock");try{try{o=yield i.store.load(e);const l=o.metadata.get(t);if(null!=l&&Pr(r,l))return}catch(l){if("ERR_NOT_FOUND"!==l.code)throw l}a=yield i.store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{br.trace("setValue release write lock"),s()}i.dispatchEvent(new qt(Sh,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return j(function*(){e=Mr(e),br.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;br.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{br.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new qt(Sh,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return j(function*(){e=Mr(e),br.trace("deleteValue await write lock");const i=yield r.store.lock.writeLock();let s,o;br.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{br.trace("deleteValue release write lock"),i()}null!=s&&r.dispatchEvent(new qt(Sh,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const wr=Ft("libp2p:peer-store:proto-book"),Ch="change:protocols";class J9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return j(function*(){wr.trace("get wait for read lock");const r=yield t.store.lock.readLock();wr.trace("get got read lock");try{return(yield t.store.load(e)).protocols}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{wr.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return j(function*(){if(e=Mr(e),!Array.isArray(t))throw wr.error("protocols must be provided to store data"),se(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");wr.trace("set await write lock");const i=yield r.store.lock.writeLock();let s,o;wr.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}),wr("stored provided protocols for %p",e)}finally{wr.trace("set release write lock"),i()}r.dispatchEvent(new qt(Ch,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return j(function*(){if(e=Mr(e),!Array.isArray(t))throw wr.error("protocols must be provided to store data"),se(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");wr.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o;wr.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}),wr("added provided protocols for %p",e)}finally{wr.trace("add release write lock"),i()}r.dispatchEvent(new qt(Ch,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return j(function*(){if(e=Mr(e),!Array.isArray(t))throw wr.error("protocols must be provided to store data"),se(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");wr.trace("remove await write lock");const i=yield r.store.lock.writeLock();let s,o;wr.trace("remove got write lock");try{try{s=yield r.store.load(e);const a=new Set(s.protocols);for(const l of t)a.delete(l);if(s.protocols.length===a.size)return;t=Array.from(a)}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t})}finally{wr.trace("remove release write lock"),i()}r.dispatchEvent(new qt(Ch,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return j(function*(){e=Mr(e),wr.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;wr.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{wr.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new qt(Ch,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Ih,Th,Ah;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((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),Th.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),Ah.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(Th.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(Ah.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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Ih||(Ih={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Th||(Th={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Ah||(Ah={}));var e7=x(6313);class N2 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class t7 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const M2=n=>void 0===globalThis.DOMException?new t7(n):new DOMException(n),O2=n=>{const e=void 0===n.reason?M2("This operation was aborted."):n.reason;return e instanceof Error?e:M2(e)};function k2(n,e,t,r){let i;const s=new Promise((o,a)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:l}=r;l.aborted&&a(O2(l)),l.addEventListener("abort",()=>{a(O2(l))})}i=r.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof t){try{o(t())}catch(R){a(R)}return}const _=t instanceof Error?t:new N2("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(_)},e),j(function*(){try{o(yield n)}catch(l){a(l)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var go,Ra=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 r7{constructor(){go.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Ra(this,go,"f")[this.size-1].priority>=t.priority)return void Ra(this,go,"f").push(r);const i=function n7(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}(Ra(this,go,"f"),r,(s,o)=>o.priority-s.priority);Ra(this,go,"f").splice(i,0,r)}dequeue(){return Ra(this,go,"f").shift()?.run}filter(e){return Ra(this,go,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ra(this,go,"f").length}}go=new WeakMap;var lr,jl,Gl,Jo,xh,zl,Rh,Ss,Wl,Ni,Ph,Mi,ql,ea,Nh,L2,B2,F2,U2,V2,H2,Mh,Wv,qv,Oh,kh,er=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},st=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 i7=new N2;class s7 extends Error{}class K2 extends e7{constructor(e){var t,r,i,s;if(super(),lr.add(this),jl.set(this,void 0),Gl.set(this,void 0),Jo.set(this,0),xh.set(this,void 0),zl.set(this,void 0),Rh.set(this,0),Ss.set(this,void 0),Wl.set(this,void 0),Ni.set(this,void 0),Ph.set(this,void 0),Mi.set(this,0),ql.set(this,void 0),ea.set(this,void 0),Nh.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:r7,...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})`);er(this,jl,e.carryoverConcurrencyCount,"f"),er(this,Gl,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),er(this,xh,e.intervalCap,"f"),er(this,zl,e.interval,"f"),er(this,Ni,new e.queueClass,"f"),er(this,Ph,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,er(this,Nh,!0===e.throwOnTimeout,"f"),er(this,ea,!1===e.autoStart,"f")}get concurrency(){return st(this,ql,"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})`);er(this,ql,e,"f"),st(this,lr,"m",Oh).call(this)}add(e,t={}){var r=this;return j(function*(){return new Promise((i,s)=>{const o=function(){var a=j(function*(){var l,_,R;er(r,Mi,(_=st(r,Mi,"f"),++_),"f"),er(r,Jo,(R=st(r,Jo,"f"),++R),"f");try{if(null!==(l=t.signal)&&void 0!==l&&l.aborted)return void s(new s7("The task was aborted."));const B=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):k2(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?st(r,Nh,"f"):t.throwOnTimeout)&&s(i7)});i(B),r.emit("completed",B)}catch(N){s(N),r.emit("error",N)}st(r,lr,"m",F2).call(r)});return function(){return a.apply(this,arguments)}}();st(r,Ni,"f").enqueue(o,t),st(r,lr,"m",Mh).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return j(function*(){return Promise.all(e.map(function(){var i=j(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return st(this,ea,"f")?(er(this,ea,!1,"f"),st(this,lr,"m",Oh).call(this),this):this}pause(){er(this,ea,!0,"f")}clear(){er(this,Ni,new(st(this,Ph,"f")),"f")}onEmpty(){var e=this;return j(function*(){0!==st(e,Ni,"f").size&&(yield st(e,lr,"m",kh).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return j(function*(){st(t,Ni,"f").sizest(t,Ni,"f").size{st(this,lr,"m",V2).call(this)},t),"f"),!0;er(this,Jo,st(this,jl,"f")?st(this,Mi,"f"):0,"f")}return!1},Mh=function(){if(0===st(this,Ni,"f").size)return st(this,Ss,"f")&&clearInterval(st(this,Ss,"f")),er(this,Ss,void 0,"f"),st(this,lr,"m",U2).call(this),!1;if(!st(this,ea,"f")){const e=!st(this,lr,"a",H2);if(st(this,lr,"a",L2)&&st(this,lr,"a",B2)){const t=st(this,Ni,"f").dequeue();return!!t&&(this.emit("active"),t(),e&&st(this,lr,"m",Wv).call(this),!0)}}return!1},Wv=function(){st(this,Gl,"f")||void 0!==st(this,Ss,"f")||(er(this,Ss,setInterval(()=>{st(this,lr,"m",qv).call(this)},st(this,zl,"f")),"f"),er(this,Rh,Date.now()+st(this,zl,"f"),"f"))},qv=function(){0===st(this,Jo,"f")&&0===st(this,Mi,"f")&&st(this,Ss,"f")&&(clearInterval(st(this,Ss,"f")),er(this,Ss,void 0,"f")),er(this,Jo,st(this,jl,"f")?st(this,Mi,"f"):0,"f"),st(this,lr,"m",Oh).call(this)},Oh=function(){for(;st(this,lr,"m",Mh).call(this););},kh=function(){var n=j(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)}}();const $2="lock:worker:request-read",j2="lock:worker:release-read",G2="lock:master:grant-read",z2="lock:worker:request-write",W2="lock:worker:release-write",q2="lock:master:grant-write",ta={},nu=n=>{n.addEventListener("message",e=>{nu.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{nu.dispatchEvent("message",n,e)})};nu.addEventListener=(n,e)=>{null==ta[n]&&(ta[n]=[]),ta[n].push(e)},nu.removeEventListener=(n,e)=>{null!=ta[n]&&(ta[n]=ta[n].filter(t=>t===e))},nu.dispatchEvent=function(n,e,t){null!=ta[n]&&ta[n].forEach(r=>r(e,t))};const Q2=nu,Y2=(n,e,t,r,i)=>(s,o)=>{if(o.data.type!==t)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};var l;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(l=j(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(_=>{const R=N=>{null!=N&&null!=N.data&&N.data.type===r&&N.data.identifier===a.identifier&&(s.removeEventListener("message",R),_())};s.addEventListener("message",R)})}),function(){return l.apply(this,arguments)})}}))},Z2=(n,e,t,r)=>j(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)})}),u7={singleProcess:!1},Pa={};let na;function Qv(n,e){return Yv.apply(this,arguments)}function Yv(){return Yv=j(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add(j(function*(){return yield AT(j(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),Yv.apply(this,arguments)}const d7={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const X2=Ft("libp2p:peer-store:store"),J2="/peers/";class p7{constructor(){this.components=new co,this.lock=function h7(n){const e=Object.assign({},d7,n);return null==na&&(na=(n=>{if(n=Object.assign({},u7,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return Q2.addEventListener("message",Y2(t,"requestReadLock",$2,j2,G2)),Q2.addEventListener("message",Y2(t,"requestWriteLock",z2,W2,q2)),t}return{isWorker:!0,readLock:t=>Z2(t,$2,G2,j2),writeLock:t=>Z2(t,z2,q2,W2)}})(e),!0!==na.isWorker&&(na.addEventListener("requestReadLock",t=>{null!=Pa[t.data.name]&&Pa[t.data.name].readLock().then(function(){var r=j(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),na.addEventListener("requestWriteLock",function(){var t=j(function*(r){null!=Pa[r.data.name]&&Pa[r.data.name].writeLock().then(function(){var i=j(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==Pa[e.name]&&(Pa[e.name]=((n,e)=>{if(!0===na.isWorker)return{readLock:na.readLock(n,e),writeLock:na.writeLock(n,e)};const t=new K2({concurrency:1});let r;return{readLock:()=>j(function*(){if(null!=r)return yield Qv(r,e);r=new K2({concurrency:e.concurrency,autoStart:!1});const i=r,s=Qv(r,e);return t.add(j(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>j(function*(){return r=null,yield Qv(t,e)})()}})(e.name,e)),Pa[e.name]}({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(null==e.type)throw X2.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 kr(`${J2}${t}`)}has(e){var t=this;return j(function*(){return yield t.components.getDatastore().has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return j(function*(){yield t.components.getDatastore().delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return j(function*(){const r=yield t.components.getDatastore().get(t._peerIdToDatastoreKey(e)),i=Ih.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 ln(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return j(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!Pr(e.pubKey,e.id.publicKey))throw X2.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,l)=>a.multiaddr.toString().localeCompare(l.multiaddr.toString())).map(({multiaddr:a,isCertified:l})=>({multiaddr:a.bytes,isCertified:l})),s=[];[...e.metadata.keys()].sort().forEach(a=>{const l=e.metadata.get(a);null!=l&&s.push({key:a,value:l})});const o=Ih.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 j(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return j(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 j(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return j(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return j(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 j(function*(){const s=new Map;return r.addresses.forEach(o=>{s.set(o.multiaddr.toString(),o.isCertified)}),(t.addresses??[]).forEach(o=>{const a=o.multiaddr.toString(),_=Boolean(s.get(a))||o.isCertified;s.set(a,_)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:new ln(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 on(function*(){var i,t=!1,r=!1;try{for(var o,s=wt(e.components.getDatastore().queryKeys({prefix:J2}));t=!(o=yield tt(s.next())).done;t=!1){const l=o.value.toString().split("/")[2],_=so.decode(l);yield e.load(Yc(_))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield tt(s.return()))}finally{if(r)throw i}}})()}}var ra,Lh;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((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),Lh.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(Lh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(ra||(ra={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Lh||(Lh={}));const Yi=Ft("libp2p:peer-store");class g7 extends yi{constructor(e={}){super(),this.components=new co,this.store=new p7,this.addressBook=new Y9(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new Z9(this.dispatchEvent.bind(this),this.store),this.metadataBook=new X9(this.dispatchEvent.bind(this),this.store),this.protoBook=new J9(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}forEach(e){var t=this;return j(function*(){Yi.trace("getPeers await read lock");const r=yield t.store.lock.readLock();Yi.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var l,a=wt(t.store.all());i=!(l=yield a.next()).done;i=!1){const _=l.value;_.id.equals(t.components.getPeerId())||e(_)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{Yi.trace("getPeers release read lock"),r()}})()}all(){var e=this;return j(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return j(function*(){Yi.trace("delete await write lock");const r=yield t.store.lock.writeLock();Yi.trace("delete got write lock");try{yield t.store.delete(e)}finally{Yi.trace("delete release write lock"),r()}})()}get(e){var t=this;return j(function*(){Yi.trace("get await read lock");const r=yield t.store.lock.readLock();Yi.trace("get got read lock");try{return yield t.store.load(e)}finally{Yi.trace("get release read lock"),r()}})()}has(e){var t=this;return j(function*(){Yi.trace("has await read lock");const r=yield t.store.lock.readLock();Yi.trace("has got read lock");try{return yield t.store.has(e)}finally{Yi.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return j(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 l=yield i.metadataBook.getValue(e,"tags");let _=[];null!=l&&(_=ra.decode(l).tags);for(const R of _)if(R.name===t)throw se(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");_.push({name:t,value:o,expiry:null==a?void 0:BigInt(Date.now()+a)}),yield i.metadataBook.setValue(e,"tags",ra.encode({tags:_}).subarray())})()}unTagPeer(e,t){var r=this;return j(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=ra.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",ra.encode({tags:s}).subarray())})()}getTags(e){var t=this;return j(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=ra.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",ra.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class y7{constructor(e){this.dht=e}provide(e){var t=this;return j(function*(){yield Wo(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return on(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(r.dht.findProviders(e,t));i=!(l=yield tt(a.next())).done;i=!1){const _=l.value;"PROVIDER"===_.name&&(yield*Rr(wt(_.providers),tt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield tt(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return j(function*(){yield Wo(i.dht.put(e,t,r))})()}get(e,t){var r=this;return j(function*(){var o,i=!1,s=!1;try{for(var l,a=wt(r.dht.get(e,t));i=!(l=yield a.next()).done;i=!1){const _=l.value;if("VALUE"===_.name)return _.value}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw se(new Error("Not found"),"ERR_NOT_FOUND")})()}}const eA=Ft("libp2p:dialer:auto-dialer");class m7{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){eA("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);const o=new mi.TimeoutController(this.dialTimeout);try{(0,Lr.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{eA.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}var tA=x(2185);const v7=globalThis.fetch,E7=globalThis.Headers;function Zv(n,e,t){return`${n}?name=${e}&type=${t}`}function b7(n,e){return Xv.apply(this,arguments)}function Xv(){return Xv=j(function*(n,e){return yield(yield v7(n,{headers:new E7({accept:"application/dns-json"}),signal:e})).json()}),Xv.apply(this,arguments)}function ru(n,e){return`${e}_${n}`}globalThis,globalThis;const Jv=Object.assign(cr("dns-over-http-resolver"),{error:cr("dns-over-http-resolver:error")}),_7=class w7{constructor(e={}){this._cache=new tA({max:e?.maxCache??100}),this._TXTcache=new tA({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??b7,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 j(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 j(function*(){const i=t._cache.get(ru(e,"A"));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const l=yield t._request(Zv(o,e,"A"),a.signal),_=l.Answer.map(N=>N.data),R=Math.min(...l.Answer.map(N=>N.TTL));return t._cache.set(ru(e,"A"),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),Jv.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record A`)})()}resolve6(e){var t=this;return j(function*(){const r="AAAA",i=t._cache.get(ru(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const l=yield t._request(Zv(o,e,r),a.signal),_=l.Answer.map(N=>N.data),R=Math.min(...l.Answer.map(N=>N.TTL));return t._cache.set(ru(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),Jv.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record AAAA`)})()}resolveTxt(e){var t=this;return j(function*(){const r="TXT",i=t._TXTcache.get(ru(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const l=yield t._request(Zv(o,e,r),a.signal),_=l.Answer.map(N=>[N.data.replace(/['"]+/g,"")]),R=Math.min(...l.Answer.map(N=>N.TTL));return t._TXTcache.set(ru(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),Jv.error(`${o} could not resolve ${e} record TXT`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record TXT`)})()}clearCache(){this._cache.clear(),this._TXTcache.clear()}},{code:D7}=Er("dnsaddr");function eE(){return eE=j(function*(n,e={}){const t=new _7;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===D7)??[];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}),eE.apply(this,arguments)}const C7={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 S7(n){return eE.apply(this,arguments)}},addressSorter:lv},connectionGater:{},transportManager:{faultTolerance:Aa.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:T2},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 I7(n){const e=Ol(C7,n);if(null==e.transports||e.transports.length<1)throw se(new Error(pn.ERR_TRANSPORTS_REQUIRED),we.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw se(new Error(pn.CONN_ENCRYPTION_REQUIRED),we.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw se(new Error(pn.ERR_PROTECTOR_REQUIRED),we.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===T2&&(NU||RU?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(dh||DT||PU||MU)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var nA;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((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=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(nA||(nA={}));const T7=function(){var n=j(function*(){const e=yield kI("Ed25519"),t=yield function rA(n){return nE.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 nE(){return nE=j(function*(n){return yield Al(LI(n.public),t5(n))}),nE.apply(this,arguments)}const oE=Symbol.for("@libp2p/peer-discovery");class x7 extends yi{get[oE](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}get lan(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}get(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}findProviders(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}findPeer(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}getClosestPeers(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}provide(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}put(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)}getMode(){return j(function*(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)})()}setMode(){return j(function*(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)})()}refreshRoutingTable(){return j(function*(){throw se(new Error(pn.DHT_DISABLED),we.DHT_DISABLED)})()}}class R7 extends yi{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}get multicodecs(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}getPeers(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}getTopics(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}subscribe(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}unsubscribe(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}getSubscribers(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)}publish(){return j(function*(){throw se(new Error(pn.PUBSUB_DISABLED),we.ERR_PUBSUB_DISABLED)})()}}const yo=Ft("libp2p");class P7 extends yi{constructor(e){var o;super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new co({peerId:e.peerId,datastore:e.datastore??new rV,connectionGater:{denyDialPeer:(o=j(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=j(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}}),this.components.setPeerStore(new g7({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new t9(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new qt("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new b9(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 IV(e.connectionManager)),this.registrar=this.components.setRegistrar(new m9(this.components)),this.components.setTransportManager(new l9(this.components,e.transportManager)),this.components.setAddressManager(new cV(this.components,e.addresses)),this.configureComponent(new W9(this.components)),this.configureComponent(new AV(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const t=h2.generateOptions();this.keychain=this.configureComponent(new h2(this.components,{...t,...e.keychain})),this.services.push(new G9(this.components,e.nat)),e.transports.forEach(o=>{this.components.getTransportManager().add(this.configureComponent(o))}),null!=e.streamMuxers&&e.streamMuxers.length>0&&(this.identifyService=new Uv(this.components,{...e.identify}),this.configureComponent(this.identifyService)),this.dht=null!=e.dht?this.components.setDHT(e.dht):new x7,this.pubsub=null!=e.pubsub?this.components.setPubSub(e.pubsub):new R7;const r=(e.peerRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&(r.push(this.configureComponent(new q9(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new iV(this.components,{...e.peerRouting,routers:r})));const i=(e.contentRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&i.push(this.configureComponent(new y7(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new sV(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new BV(e.relay))),this.configureComponent(new $V(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new L9(this.components,{...e.fetch})),this.pingService=this.configureComponent(new V9(this.components,{...e.ping}));const s=this.configureComponent(new m7(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 ao(e)&&this.services.push(e),Or(e)&&this.initializables.push(e),e}start(){var e=this;return j(function*(){if(!e.started){e.started=!0,yo("libp2p is starting");try{e.initializables.forEach(t=>{t.init(e.components)}),yield Promise.all(e.services.map(function(){var t=j(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=j(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),yo("libp2p has started")}catch(t){throw yo.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return j(function*(){!e.started||(yo("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=j(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=j(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),yo("libp2p has stopped"))})()}loadKeychain(){var e=this;return j(function*(){if(null!=e.keychain)try{yield e.keychain.findKeyByName("self")}catch{yield e.keychain.importPeer("self",e.peerId)}})()}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){const e=new _V;for(const t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Ml(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 j(function*(){if(null==t)throw se(new Error("no protocols were provided to open a stream"),we.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"),we.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 j(function*(){const{id:r}=Ml(e);yield t.components.getConnectionManager().closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return j(function*(){if(yo("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"),we.ERR_NO_ROUTERS_AVAILABLE);const s=yr([xt("/pk/"),e.multihash.digest]);var l,o=!1,a=!1;try{for(var R,_=wt(r.dht.get(s,t));o=!(R=yield _.next()).done;o=!1){const N=R.value;if("VALUE"===N.name){const B=Dl(N.value);return yield r.peerStore.keyBook.set(e,N.value),B.bytes}}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw l}}throw se(new Error(`Node not responding with its public key: ${e.toString()}`),we.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return j(function*(){const{id:s,multiaddrs:o}=Ml(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 j(function*(){const{id:i,multiaddrs:s}=Ml(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 j(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=j(function*(o){yield i.components.getRegistrar().handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return j(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=j(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=>yo.error(r)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(r=>yo.error(r)),this.dispatchEvent(new qt("peer:discovery",{detail:t}))):yo.error(new Error(we.ERR_DISCOVERED_SELF))}}function N7(n){return aE.apply(this,arguments)}function aE(){return aE=j(function*(n){return null==n.peerId&&(n.peerId=yield T7()),new P7(I7(n))}),aE.apply(this,arguments)}function M7(n){return cE.apply(this,arguments)}function cE(){return cE=j(function*(n){return yield N7(n)}),cE.apply(this,arguments)}function sA(n,e){return n.length<=e||n.length<=1?n:function k7(n){if(n.length<=1)return n;for(let t=0;t{class n extends yi{constructor(t,r){super(),this.interval=r?.interval??n.DefaultInterval;const i=r?.maxPeers??t?.length,s=t.map(o=>"string"==typeof o?new ln(o):o);this.peers=function O7(n){return n.map(e=>{const t=e.getPeerId();return{id:t?ar(t):null,multiaddrs:[e.decapsulateCode(421)],protocols:[]}}).filter(e=>null!==e.id)}(sA(s,i)),oA("Use provided list of peers (reduced to maxPeers)",this.peers.map(o=>o.toString()))}start(){this._startTimer()}_startTimer(){if(this.peers){if(oA("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 qt("peer",{detail:t}))})}stop(){null!=this.timer&&clearInterval(this.timer),this.timer=void 0}get[oE](){return!0}get[Symbol.toStringTag](){return"@waku/peer-discovery-static-list"}}return n.DefaultInterval=200,n})();var iu=(()=>(function(n){n.Prod="prod",n.Test="test"}(iu||(iu={})),iu))();const uE_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"}}};var Fh,Uh,aA,Vh;cr("waku:select-peer"),function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Bt((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),null!=s.contentTopic&&(o.uint32(10),o.string(s.contentTopic)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={},l=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.contentTopic=s.string():s.skipType(7&_)}return a})),i),r.encode=s=>Lt(s,r.codec()),r.decode=s=>kt(s,r.codec())}(e=n.ContentFilter||(n.ContentFilter={})),n.codec=()=>(null==t&&(t=Bt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null!=r.subscribe&&(i.uint32(8),i.bool(r.subscribe)),null!=r.topic&&(i.uint32(18),i.string(r.topic)),null==r.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const o of r.contentFilters)i.uint32(26),n.ContentFilter.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={contentFilters:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.subscribe=r.bool();break;case 2:s.topic=r.string();break;case 3:s.contentFilters.push(n.ContentFilter.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>Lt(r,n.codec()),n.decode=r=>kt(r,n.codec())}(Fh||(Fh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const s of t.messages)r.uint32(10),Vh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.messages.push(Vh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Uh||(Uh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Fh.codec().encode(t.request,r)),null!=t.push&&(r.uint32(26),Uh.codec().encode(t.push,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Fh.codec().decode(t,t.uint32());break;case 3:i.push=Uh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(aA||(aA={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Vh||(Vh={}));const Na="/vac/waku/filter/2.0.0-beta1";var Hh,Kh,cA,$h;cr("waku:filter"),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(10),r.string(t.pubSubTopic)),null!=t.message&&(r.uint32(18),$h.codec().encode(t.message,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.pubSubTopic=t.string();break;case 2:i.message=$h.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Hh||(Hh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.isSuccess&&(r.uint32(8),r.bool(t.isSuccess)),null!=t.info&&(r.uint32(18),r.string(t.info)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.isSuccess=t.bool();break;case 2:i.info=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Kh||(Kh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Hh.codec().encode(t.request,r)),null!=t.response&&(r.uint32(26),Kh.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Hh.codec().decode(t,t.uint32());break;case 3:i.response=Kh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(cA||(cA={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}($h||($h={})),cr("waku:light-push");const Ql="/vac/waku/lightpush/2.0.0-beta1";var Gh;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Gh||(Gh={}));const uA=cr("waku:message:version-0"),lA=BigInt(1e6);class H7{constructor(e){this.proto=e}get _rawPayload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get payload(){return this._rawPayload}get contentTopic(){return this.proto.contentTopic}get _rawTimestamp(){return this.proto.timestamp}get timestamp(){try{if(this.proto.timestamp)return new Date(Number(this.proto.timestamp/lA));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get version(){return this.proto.version??0}}class fA{constructor(e){this.contentTopic=e}encode(e){var t=this;return j(function*(){return Gh.encode(yield t.encodeProto(e))})()}encodeProto(e){var t=this;return j(function*(){const r=e.timestamp??new Date;return{payload:e.payload,version:0,contentTopic:e.contentTopic??t.contentTopic,timestamp:BigInt(r.valueOf())*lA}})()}}class K7{constructor(e){this.contentTopic=e}decodeProto(e){const t=Gh.decode(e);return uA("Message decoded",t),Promise.resolve(t)}decode(e){return j(function*(){return void 0===e.version&&(e.version=0),0!==e.version?(uA("Failed to decode due to incorrect version, expected:",0,", actual:",e.version),Promise.resolve(void 0)):new H7(e)})()}}const Ma=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];var zh,su,Wh,qh,Yl,dA,Qh;!function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(16),r.sint64(t.receivedTime)),null!=t.senderTime&&(r.uint32(24),r.sint64(t.senderTime)),null!=t.pubsubTopic&&(r.uint32(34),r.string(t.pubsubTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.sint64();break;case 3:i.senderTime=t.sint64();break;case 4:i.pubsubTopic=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(zh||(zh={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Oo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Bt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),zh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=zh.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>Lt(i,n.codec()),n.decode=i=>kt(i,n.codec())}(su||(su={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Wh||(Wh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),Wh.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),su.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(40),r.sint64(t.startTime)),null!=t.endTime&&(r.uint32(48),r.sint64(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Wh.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=su.codec().decode(t,t.uint32());break;case 5:i.startTime=t.sint64();break;case 6:i.endTime=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(qh||(qh={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Oo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Bt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),Qh.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),su.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(Qh.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=su.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>Lt(i,n.codec()),n.decode=i=>kt(i,n.codec())}(Yl||(Yl={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),qh.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),Yl.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=qh.codec().decode(t,t.uint32());break;case 3:i.response=Yl.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(dA||(dA={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Qh||(Qh={}));var Yh,ou,Zh,Xh,Jh,hA,ep,Zl=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(Zl||(Zl={})),Zl))();!function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(17),r.double(t.receivedTime)),null!=t.senderTime&&(r.uint32(25),r.double(t.senderTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.double();break;case 3:i.senderTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Yh||(Yh={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Oo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Bt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),Yh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=Yh.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>Lt(i,n.codec()),n.decode=i=>kt(i,n.codec())}(ou||(ou={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Zh||(Zh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),Zh.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),ou.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(41),r.double(t.startTime)),null!=t.endTime&&(r.uint32(49),r.double(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Zh.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=ou.codec().decode(t,t.uint32());break;case 5:i.startTime=t.double();break;case 6:i.endTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(Xh||(Xh={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Oo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Bt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),ep.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),ou.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(ep.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=ou.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>Lt(i,n.codec()),n.decode=i=>kt(i,n.codec())}(Jh||(Jh={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),Xh.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),Jh.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=Xh.codec().decode(t,t.uint32());break;case 3:i.response=Jh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(hA||(hA={})),function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(ep||(ep={})),BigInt(1e6),cr("waku:store");const np=cr("waku:waku");var qr=(()=>(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(qr||(qr={})),qr))();class X7{constructor(e,t,r,i,s){this.libp2p=t,this.store=r,this.filter=s,this.lightPush=i,function J7(n){if(n)try{return n.multicodecs.includes(Ma[Ma.length-1])}catch{}return!1}(t.pubsub)&&(this.relay=t.pubsub),np("Waku node created",this.libp2p.peerId.toString(),`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`),this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const o=e.pingKeepAlive||0,a=this.relay?e.relayKeepAlive||300:0;t.connectionManager.addEventListener("peer:connect",l=>{this.startKeepAlive(l.detail.remotePeer,o,a)}),t.connectionManager.addEventListener("peer:disconnect",l=>{this.stopKeepAlive(l.detail.remotePeer)})}dial(e,t){var r=this;return j(function*(){const i=t??[qr.Relay],s=[];if(i.includes(qr.Relay)&&Ma.forEach(o=>s.push(o)),i.includes(qr.Store))for(const o of Object.values(Zl))s.push(o);return i.includes(qr.LightPush)&&s.push(Ql),i.includes(qr.Filter)&&s.push(Na),r.libp2p.dialProtocol(e,s)})()}addPeerToAddressBook(e,t){var r=this;return j(function*(){let i;i="string"==typeof e?ar(e):e;const s=t.map(o=>"string"==typeof o?function CU(n){return new ln(n)}(o):o);yield r.libp2p.peerStore.addressBook.set(i,s)})()}start(){var e=this;return j(function*(){yield e.libp2p.start()})()}stop(){var e=this;return j(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find(t=>t.toString().match(/127\.0\.0\.1/));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}startKeepAlive(e,t,r){this.stopKeepAlive(e);const i=e.toString();0!==t&&(this.pingKeepAliveTimers[i]=setInterval(()=>{this.libp2p.ping(e).catch(o=>{np(`Ping failed (${i})`,o)})},1e3*t));const s=this.relay;if(s&&0!==r){const o=new fA("/relay-ping/1/ping/null");this.relayKeepAliveTimers[i]=setInterval(()=>{np("Sending Waku Relay ping message"),s.send(o,{payload:new Uint8Array}).catch(a=>np("Failed to send relay ping",a))},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 yA=()=>{};class eH{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??yA,this.onDisconnect=e.onDisconnect??yA}get[Symbol.toStringTag](){return Fv.toString()}get[Fv](){return!0}setRegistrar(e){var t=this;return j(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class nH{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 rH=x(7602);const{RPC:rp}=rH,mA="/floodsub/1.0.0",vA="/meshsub/1.0.0",mE="/meshsub/1.1.0",uu=5e3;function mo(n=[],e){return{subscriptions:[],messages:n,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}function vo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(sp||(sp={})),sp))(),Oa=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Anonymous=1]="Anonymous"}(Oa||(Oa={})),Oa))(),Ks=(()=>(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}(Ks||(Ks={})),Ks))(),Xi=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(Xi||(Xi={})),Xi))(),oi=(()=>(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"}(oi||(oi={})),oi))(),Ji=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(Ji||(Ji={})),Ji))();function bA(n){switch(n){case Ks.Ignore:return Xi.Ignore;case Ks.Reject:return Xi.Reject}}function EE(){return EE=j(function*(n,e){switch(n){case ip:{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 Sl(e.privateKey);return{type:Oa.Signing,author:e,key:e.publicKey,privateKey:t}}case vE:return{type:Oa.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),EE.apply(this,arguments)}const Fn="ERR_INVALID_PEER_SCORE_PARAMS",LH={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},BH={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 FH(n={}){return{...LH,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function UH(n={}){return{...BH,...n}}(r),e),{}):{}}}function HH(n){if(n.topicWeight<0)throw se(new Error("invalid topic weight; must be >= 0"),Fn);if(0===n.timeInMeshQuantum)throw se(new Error("invalid TimeInMeshQuantum; must be non zero"),Fn);if(n.timeInMeshWeight<0)throw se(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Fn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw se(new Error("invalid TimeInMeshQuantum; must be positive"),Fn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw se(new Error("invalid TimeInMeshCap; must be positive"),Fn);if(n.firstMessageDeliveriesWeight<0)throw se(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Fn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw se(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Fn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw se(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Fn);if(n.meshMessageDeliveriesWeight>0)throw se(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Fn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw se(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Fn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw se(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Fn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw se(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Fn);if(n.meshMessageDeliveriesWindow<0)throw se(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Fn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw se(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Fn);if(n.meshFailurePenaltyWeight>0)throw se(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Fn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw se(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Fn);if(n.invalidMessageDeliveriesWeight>0)throw se(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Fn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw se(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Fn)}const KH={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function $H(n={}){return{...KH,...n}}function jH(n,e,t,r){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{const l=t.topics[o];if(void 0===l)return;let _=0;if(a.inMesh){let V=a.meshTime/l.timeInMeshQuantum;V>l.timeInMeshCap&&(V=l.timeInMeshCap),_+=V*l.timeInMeshWeight}let R=a.firstMessageDeliveries;if(R>l.firstMessageDeliveriesCap&&(R=l.firstMessageDeliveriesCap),_+=R*l.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(o=>{if(t.IPColocationFactorWhitelist.has(o))return;const a=r.get(o),l=a?a.size:0;if(l>t.IPColocationFactorThreshold){const _=l-t.IPColocationFactorThreshold;i+=_*_*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){const o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}var GH=x(4555),ai=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(ai||(ai={})),ai))();class zH{constructor(){this.records=new Map,this.queue=new GH}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:ai.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)"),Fn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw se(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Fn);if(n.behaviourPenaltyWeight>0)throw se(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Fn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw se(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Fn);if(n.decayInterval<1e3)throw se(new Error("invalid DecayInterval; must be at least 1s"),Fn);if(n.decayToZero<=0||n.decayToZero>=1)throw se(new Error("invalid DecayToZero; must be between 0 and 1"),Fn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??jH}init(e){this.components=e}get size(){return this.peerStats.size}start(){this._backgroundInterval?lu("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),lu("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),lu("stopped")):lu("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)})):lu("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,ai[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case Xi.Error:return void this.markInvalidMessageDelivery(e,r);case Xi.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===ai.unknown)return i===Xi.Ignore?(s.status=ai.ignored,void s.peers.clear()):(s.status=ai.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());lu("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,ai[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case ai.unknown:i.peers.add(e);break;case ai.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case ai.invalid:this.markInvalidMessageDelivery(e,r)}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);i&&(i.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);if(i){let s=this.params.topics[t].firstMessageDeliveriesCap;i.firstMessageDeliveries=Math.min(s,i.firstMessageDeliveries+1),i.inMesh&&(s=this.params.topics[t].meshMessageDeliveriesCap,i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const i=this.peerStats.get(e);if(i){const s=void 0!==r?Date.now():0,o=this.getPtopicStats(i,t);if(o&&o.inMesh){const a=this.params.topics[t];if(void 0!==r){const _=s-r,R=_>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,_,R),R)return}o.meshMessageDeliveries=Math.min(a.meshMessageDeliveriesCap,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(ar(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 qH{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 Eo=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(Eo||(Eo={})),Eo))(),ka=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(ka||(ka={})),ka))(),fu=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(fu||(fu={})),fu))(),du=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(du||(du={})),du))(),La=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(La||(La={})),La))();const wA=xt("libp2p-pubsub:");function wE(){return wE=j(function*(n,e,t,r){switch(n.type){case Oa.Signing:{const i={from:n.author.toBytes(),data:r,seqno:Zd(8),topic:e,signature:void 0,key:void 0},s=yr([wA,rp.Message.encode(i).finish()]);return i.signature=yield n.privateKey.sign(s),i.key=n.key,{raw:i,msg:{type:"signed",from:n.author,data:t,sequenceNumber:BigInt(`0x${Rt(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key}}}case Oa.Anonymous:return{raw:{from:void 0,data:r,seqno:void 0,topic:e,signature:void 0,key:void 0},msg:{type:"unsigned",data:t,topic:e}}}}),wE.apply(this,arguments)}function _E(){return _E=j(function*(n,e){switch(n){case vE:return null!=e.signature?{valid:!1,error:oi.SignaturePresent}:null!=e.seqno?{valid:!1,error:oi.SeqnoPresent}:null!=e.key?{valid:!1,error:oi.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case ip:{if(null==e.seqno)return{valid:!1,error:oi.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:oi.InvalidSeqno};if(null==e.signature)return{valid:!1,error:oi.InvalidSignature};if(null==e.from)return{valid:!1,error:oi.InvalidPeerId};let t,r;try{t=Yc(e.from)}catch{return{valid:!1,error:oi.InvalidPeerId}}if(e.key){if(r=Dl(e.key),void 0!==t.publicKey&&!Pr(r.bytes,t.publicKey))return{valid:!1,error:oi.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:oi.InvalidPeerId};r=Dl(t.publicKey)}const s=yr([wA,rp.Message.encode({from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0}).finish()]);return(yield r.verify(s,e.signature))?{valid:!0,message:{type:"signed",from:t,data:e.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${Rt(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??LI(r)}}:{valid:!1,error:oi.InvalidSignature}}}}),_E.apply(this,arguments)}function tK(n){if("signed"!==n.type)throw new Error("expected signed message type");if(null==n.sequenceNumber)throw Error("missing seqno field");return((n,e)=>{const t=xt(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 nK(n){return DE.apply(this,arguments)}function DE(){return DE=j(function*(n){return yield hi.encode(n.data)}),DE.apply(this,arguments)}function rK(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([B,V])=>{const Y=i.get(B)??"unknown",X=t.topics[B];if(void 0===X)return;let ie=o.get(Y);ie||(ie={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(Y,ie));let fe=0,Se=0,ae=0,Ie=0,Fe=0;V.inMesh&&(fe+=Math.max(V.meshTime/X.timeInMeshQuantum,X.timeInMeshCap)*X.timeInMeshWeight);let Te=V.firstMessageDeliveries;if(Te>X.firstMessageDeliveriesCap&&(Te=X.firstMessageDeliveriesCap),Se+=Te*X.firstMessageDeliveriesWeight,V.meshMessageDeliveriesActive&&V.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const B=t.topicScoreCap/s;for(const V of o.values())V.p1w*=B,V.p2w*=B,V.p3w*=B,V.p3bw*=B,V.p4w*=B}let a=0,l=0,_=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(B=>{if(t.IPColocationFactorWhitelist.has(B))return;const V=r.get(B),Y=V?V.size:0;if(Y>t.IPColocationFactorThreshold){const X=Y-t.IPColocationFactorThreshold;l+=X*X*t.IPColocationFactorWeight}}),_+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+l+_,{byTopic:o,p5w:a,p6w:l,p7w:_,score:s}}function SE(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 oK{constructor(e,t,r){this.rawStream=e,this.pushable=Rc({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,zn(vs(this.pushable,this.closeController.signal,{returnOnAbort:!0}),Os(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}class aK{constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=vs(zn(this.rawStream,ps()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var CE,Ei=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(Ei||(Ei={})),Ei))();class _A extends yi{constructor(e={}){super(),this.multicodecs=[mE,vA],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=Rc({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 co,this.directPeerInitial=null,this.status={code:Ei.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===Ei.started){clearTimeout(this.status.heartbeatTimeout);let i=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;i<.25*this.opts.heartbeatInterval&&(i+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,i)}})};const t={fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...e,scoreParams:FH(e.scoreParams),scoreThresholds:$H(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??ip,t.fallbackToFloodsub&&this.multicodecs.push(mA),this.log=Ft(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(r=>r.id.toString())),this.seenCache=new bE({validityMs:t.seenTTL}),this.publishedMessageIds=new bE({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case ip:this.msgIdFn=tK;break;case vE:this.msgIdFn=nK}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new bE({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??OH,this.mcache=e.messageCache||new nH(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 QH(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===Xi.Error?i.error:i.reason},1)},onDuplicateMsgDelivery(r,i,s){if(this.duplicateMsgDeliveryDelay.observe(i/1e3),s){const o=this.toTopic(r);this.duplicateMsgLateDelivery.inc({topic:o},1)}},onRpcRecv(r,i){this.rpcRecvBytes.inc(i),this.rpcRecvCount.inc(1),r.subscriptions&&this.rpcRecvSubscription.inc(r.subscriptions.length),r.messages&&this.rpcRecvMessage.inc(r.messages.length),r.control&&(this.rpcRecvControl.inc(1),r.control.ihave&&this.rpcRecvIHave.inc(r.control.ihave.length),r.control.iwant&&this.rpcRecvIWant.inc(r.control.iwant.length),r.control.graft&&this.rpcRecvGraft.inc(r.control.graft.length),r.control.prune&&this.rpcRecvPrune.inc(r.control.prune.length))},onRpcSent(r,i){if(this.rpcSentBytes.inc(i),this.rpcSentCount.inc(1),r.subscriptions&&this.rpcSentSubscription.inc(r.subscriptions.length),r.messages&&this.rpcSentMessage.inc(r.messages.length),r.control){const s=r.control.ihave?.length??0,o=r.control.iwant?.length??0,a=r.control.graft?.length??0,l=r.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),l>0&&this.rpcSentPrune.inc(l),(s>0||o>0||a>0||l>0)&&this.rpcSentControl.inc(1)}},registerScores(r,i){let s=0,o=0,a=0,l=0;for(const _ of r)_>=i.graylistThreshold&&s++,_>=i.publishThreshold&&o++,_>=i.gossipThreshold&&a++,_>=0&&l++;this.peersByScoreThreshold.set({threshold:La.graylist},s),this.peersByScoreThreshold.set({threshold:La.publish},o),this.peersByScoreThreshold.set({threshold:La.gossip},a),this.peersByScoreThreshold.set({threshold:La.mesh},l),this.score.set(r)},registerScoreWeights(r){for(const[i,s]of r.byTopic)this.scoreWeights.set({topic:i,p:"p1"},s.p1w),this.scoreWeights.set({topic:i,p:"p2"},s.p2w),this.scoreWeights.set({topic:i,p:"p3"},s.p3w),this.scoreWeights.set({topic:i,p:"p3b"},s.p3bw),this.scoreWeights.set({topic:i,p:"p4"},s.p4w);this.scoreWeights.set({p:"p5"},r.p5w),this.scoreWeights.set({p:"p6"},r.p6w),this.scoreWeights.set({p:"p7"},r.p7w)},registerScorePerMesh(r,i){const s=new Map;r.forEach((o,a)=>{const l=this.topicStrToLabel.get(a)??"unknown";let _=s.get(l);_||(_=new Set,s.set(l,_)),o.forEach(R=>_?.add(R))});for(const[o,a]of s){const l=[];a.forEach(_=>{l.push(i.get(_)??0)}),this.scorePerMesh.set({topic:o},l)}}}}(e.metricsRegister,e.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:t.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:r/1e3});i.mcacheSize.addCollect(()=>this.onScrapeMetrics(i));for(const s of this.multicodecs)i.protocolsEnabled.set({protocol:s},1);this.metrics=i}else this.metrics=null;this.gossipTracer=new qH(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new WH(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>ar(e))}isStarted(){return this.status.code===Ei.started}init(e){var t=this;return j(function*(){t.components=e,t.score.init(e)})()}start(){var e=this;return j(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function kH(n,e){return EE.apply(this,arguments)}(e.globalSignaturePolicy,e.components.getPeerId()),e.outboundInflightQueue=Rc({objectMode:!0}),zn(e.outboundInflightQueue,function(){var o=j(function*(a){var R,l=!1,_=!1;try{for(var B,N=wt(a);l=!(B=yield N.next()).done;l=!1){const{peerId:V,connection:Y}=B.value;yield e.createOutboundStream(V,Y)}}catch(V){_=!0,R=V}finally{try{l&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()).catch(o=>e.log.error("outbound inflight queue error",o)),yield Promise.all(e.opts.directPeers.map(function(){var o=j(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 tH(n){return new eH(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:Ei.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then(j(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=j(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 j(function*(){if(e.log("stopping"),e.status.code!==Ei.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:Ei.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 j(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new oK(yield t.newStream(r.multicodecs),a=>r.log.error("outbound pipe error",a),{maxBufferSize:r.opts.maxOutboundBufferSize});r.log("create outbound stream %p",e),r.streamsOutbound.set(i,s);const o=s.protocol;o===mA&&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 j(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 aK(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,ka.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===Ei.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=>ar(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return j(function*(){try{yield zn(t,function(){var i=j(function*(s){var l,o=!1,a=!1;try{for(var R,_=wt(s);o=!(R=yield _.next()).done;o=!1){const N=R.value;try{const B=N.subarray(),V=rp.decode(B);r.metrics?.onRpcRecv(V,B.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,V):r.handleReceivedRpc(e,V).catch(Y=>r.log(Y))}catch(B){r.log(B)}}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw l}}});return function(s){return i.apply(this,arguments)}}())}catch(i){r.log.error(i),r.onPeerDisconnected(e)}})()}handleReceivedRpc(e,t){var r=this;return j(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 qt("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 j(function*(){i.metrics?.onMsgRecvPreValidation(t.topic);const s=yield i.validateReceivedMessage(e,t);switch(i.metrics?.onMsgRecvResult(t.topic,s.code),s.code){case Ji.duplicate:return i.score.duplicateMessage(e.toString(),s.msgIdStr,t.topic),void i.mcache.observeDuplicate(s.msgIdStr,e.toString());case Ji.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 Ji.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 qt("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new qt("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return j(function*(){const i=r.fastMsgIdFn?.(t),s=i?r.fastMsgIdCache?.get(i):void 0;if(s)return{code:Ji.duplicate,msgIdStr:s};const o=yield function ZH(n,e){return _E.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:Ji.invalid,reason:Xi.Error,error:o.error};const a=o.message;try{r.dataTransform&&(a.data=r.dataTransform.inboundTransform(t.topic,a.data))}catch(B){return r.log("Invalid message, transform failed",B),{code:Ji.invalid,reason:Xi.Error,error:oi.TransformFailed}}const l=yield r.msgIdFn(a),_=r.msgIdToStrFn(l),R={msgId:l,msgIdStr:_};if(i&&r.fastMsgIdCache?.put(i,_),r.seenCache.has(_))return{code:Ji.duplicate,msgIdStr:_};r.seenCache.put(_);const N=r.topicValidators.get(t.topic);if(null!=N){let B;try{B=yield N(a.topic,a,e)}catch(V){const Y=V.code;"ERR_TOPIC_VALIDATOR_IGNORE"===Y&&(B=Ks.Ignore),B="ERR_TOPIC_VALIDATOR_REJECT"===Y?Ks.Reject:Ks.Ignore}if(B!==Ks.Accept)return{code:Ji.invalid,reason:bA(B),msgIdStr:_}}return{code:Ji.valid,messageId:R,msg:a}})()}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map(i=>({topic:i,subscribe:r})),messages:[]})}handleControlMessage(e,t){var r=this;return j(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,mo(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:du.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=uu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:du.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:_,messageIDs:R})=>{if(!_||!R||!this.mesh.has(_))return;let N=0;R.forEach(B=>{const V=this.msgIdToStrFn(B);this.seenCache.has(V)||(o.set(V,B),N++)}),this.metrics?.onIhaveRcv(_,R.length,N)}),!o.size)return[];let a=o.size;a+s>uu&&(a=uu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let l=Array.from(o.values());return vo(l),l=l.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,l),[{messageIDs:l}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(l=>{const _=this.msgIdToStrFn(l),R=this.mcache.getWithIWantCount(_,e);null!=R?(s.set(R.msg.topic,1+(s.get(R.msg.topic)??0)),R.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,l):i.set(_,R.msg)):o++})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}handleGraft(e,t){var r=this;return j(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:l})=>{if(!l)return;const _=r.mesh.get(l);if(!_)return void(a=!1);if(_.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(l),void(a=!1);const R=r.backoff.get(l)?.get(e);return"number"==typeof R&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(l),void r.addBackoff(e,l)):(r.log("GRAFT: Add mesh link from %s in %s",e,l),r.score.graft(e,l),_.add(e),void r.metrics?.onAddToMesh(l,Eo.Subscribed,1))}),i.length?yield Promise.all(i.map(l=>r.makePrune(e,l,a))):[]})()}handlePrune(e,t){var r=this;return j(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const l=r.mesh.get(s);if(!l)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),l.has(e)&&(l.delete(e),r.metrics?.onRemoveFromMesh(s,ka.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,fu.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=j(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return j(function*(){e.length>t.opts.prunePeers&&(vo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=j(function*(s){if(!s.peerID)return;const o=Yc(s.peerID).toString();if(!t.peers.has(o)){if(!s.signedPeerRecord)return void r.push(o);try{const a=yield vi.openAndCertify(s.signedPeerRecord,"libp2p-peer-record"),l=a.peerId;if(!a.peerId.equals(o))return void t.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",l,o);if(!(yield t.components.getPeerStore().addressBook.consumePeerRecord(a)))return void t.log("bogus peer record obtained through px: could not add peer record to address book");r.push(o)}catch{t.log("bogus peer record obtained through px: invalid signature or not a peer record")}}});return function(s){return i.apply(this,arguments)}}())),r.length&&(yield Promise.all(r.map(function(){var i=j(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return j(function*(){t.log("Initiating connection with %s",e);const r=ar(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!==Ei.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!==Ei.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!==Ei.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,Eo.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,Eo.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 j(function*(){if(t.status.code!==Ei.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=j(function*(s){return t.log("LEAVE: Remove mesh link to %s in %s",s,e),yield t.sendPrune(s,e)});return function(s){return i.apply(this,arguments)}}())),t.mesh.delete(e))})()}selectPeersToForward(e,t,r){const i=new Set,s=this.topics.get(e);s&&(this.direct.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&i.add(a)}),this.floodsubPeers.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&this.score.score(a)>=this.opts.scoreThresholds.publishThreshold&&i.add(a)}));const o=this.mesh.get(e);return o&&o.size>0&&o.forEach(a=>{t!==a&&!r?.has(a)&&i.add(a)}),i}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach(s=>{this.direct.has(s)?(t.add(s),r.direct++):this.score.score(s)>=this.opts.scoreThresholds.publishThreshold&&(t.add(s),r.floodsub++)});else{this.direct.forEach(o=>{i.has(o)&&(t.add(o),r.direct++)}),this.floodsubPeers.forEach(o=>{i.has(o)&&this.score.score(o)>=this.opts.scoreThresholds.publishThreshold&&(t.add(o),r.floodsub++)});const s=this.mesh.get(e);if(s&&s.size>0)s.forEach(o=>{t.add(o),r.mesh++});else{const o=this.fanout.get(e);if(o&&o.size>0)o.forEach(a=>{t.add(a),r.fanout++});else{const a=this.getRandomGossipPeers(e,this.opts.D,l=>this.score.score(l)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(l=>{t.add(l),r.fanout++}))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,i){r&&this.score.deliverMessage(r,e,t.topic);const s=this.selectPeersToForward(t.topic,r,i),o=mo([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 j(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const{raw:o,msg:a}=yield function YH(n,e,t,r){return wE.apply(this,arguments)}(i.publishConfig,e,t,s),l=yield i.msgIdFn(a),_=i.msgIdToStrFn(l);if(i.seenCache.has(_))throw Error("PublishError.Duplicate");const{tosend:R,tosendCount:N}=i.selectPeersToPublish(e),B=!0===i.opts.emitSelf&&i.subscriptions.has(e);if(0===R.size&&!i.opts.allowPublishToZeroPeers&&!B)throw Error("PublishError.InsufficientPeers");i.seenCache.put(_),i.mcache.put({msgId:l,msgIdStr:_},o,!0),i.publishedMessageIds.put(_);const V=mo([o]);for(const Y of R)i.sendRpc(Y,V)||R.delete(Y);return i.metrics?.onPublishMsg(e,N,R.size,null!=o.data?o.data.length:0),B&&(R.add(i.components.getPeerId().toString()),r().call(i,new qt("gossipsub:message",{detail:{propagationSource:i.components.getPeerId(),msgId:_,msg:a}})),r().call(i,new qt("message",{detail:a}))),{recipients:Array.from(R.values()).map(Y=>ar(Y))}})()}reportMessageValidationResult(e,t,r){if(r===Ks.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=bA(r),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(const l of a)this.score.rejectMessage(l,e,o.topic,s);this.metrics?.onReportValidation(o.topic,r)}}}sendGraft(e,t){const i=mo([],{graft:[{topicID:t}]});this.sendRpc(e,i)}sendPrune(e,t){var r=this;return j(function*(){const s=mo([],{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=rp.encode(t).finish();try{r.push(o)}catch(a){return this.log.error(`Cannot send rpc to ${e}`,a),i&&this.control.set(e,i),s&&this.gossip.set(e,s),!1}return this.metrics?.onRpcSent(t,o.length),!0}piggybackControl(e,t,r){const i=(r.graft||[]).filter(({topicID:o})=>(o&&this.mesh.get(o)||new Set).has(e)),s=(r.prune||[]).filter(({topicID:o})=>!(o&&this.mesh.get(o)||new Set).has(e));!i.length&&!s.length||(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(s)):t.control={graft:i,prune:s,ihave:[],iwant:[]})}piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}sendGraftPrune(e,t,r){var i=this;return j(function*(){const s=i.opts.doPX;for(const[o,a]of e){const l=a.map(B=>({topicID:B}));let _=[];const R=t.get(o);R&&(_=yield Promise.all(R.map(function(){var B=j(function*(V){return yield i.makePrune(o,V,s&&!r.get(o))});return function(V){return B.apply(this,arguments)}}())),t.delete(o));const N=mo([],{graft:l,prune:_});i.sendRpc(o,N)}for(const[o,a]of t){const l=yield Promise.all(a.map(function(){var R=j(function*(N){return yield i.makePrune(o,N,s&&!r.get(o))});return function(N){return R.apply(this,arguments)}}())),_=mo([],{prune:l});i.sendRpc(o,_)}})()}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[r,i]of e)this.doEmitGossip(r,i,t.get(r)??[])}doEmitGossip(e,t,r){if(!r.length||(vo(r),r.length>uu&&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=vo(Array.from(o)).slice(0,i),o.forEach(a=>{let l=r;r.length>uu&&(l=vo(l.slice()).slice(0,uu)),this.pushGossip(a,{topicID:e,messageIDs:l})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,mo([],{ihave:t}));for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,mo([],{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 j(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===vA)return{topicID:t,peers:[]};const s=i.opts.pruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:s};const o=i.getRandomGossipPeers(t,i.opts.prunePeers,l=>l!==e&&i.score.score(l)>=0),a=yield Promise.all(Array.from(o).map(function(){var l=j(function*(_){const R=ar(_);return{peerID:R.toBytes(),signedPeerRecord:yield i.components.getPeerStore().addressBook.getRawEnvelope(R)}});return function(_){return l.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return j(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const l=new Map,_=X=>{let ie=l.get(X);return void 0===ie&&(ie=e.score.score(X),l.set(X,ie)),ie},R=new Map,N=new Map,B=new Map;e.clearBackoff(),e.peerhave.clear(),e.metrics?.cacheSize.set({cache:"iasked"},e.iasked.size),e.iasked.clear(),e.applyIwantPenalties(),e.heartbeatTicks%e.opts.directConnectTicks==0&&(yield e.directConnect()),e.fastMsgIdCache?.prune(),e.seenCache.prune(),e.gossipTracer.prune(),e.publishedMessageIds.prune();const V=new Map;e.mesh.forEach((X,ie)=>{const fe=e.topics.get(ie),Se=new Set,ae=new Set;if(V.set(ie,ae),fe){const Te=vo(Array.from(fe)),dt=e.backoff.get(ie);for(const ut of Te){const an=e.streamsOutbound.get(ut);if(an&&e.multicodecs.includes(an.protocol)&&!X.has(ut)&&!e.direct.has(ut)){const Pn=_(ut);(!dt||!dt.has(ut))&&Pn>=0&&Se.add(ut),Pn>=e.opts.scoreThresholds.gossipThreshold&&ae.add(ut)}}}const Ie=(Te,dt)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",Te,ie),e.addBackoff(Te,ie),X.delete(Te),_(Te)>=e.opts.scoreThresholds.gossipThreshold&&ae.add(Te),e.metrics?.onRemoveFromMesh(ie,dt,1);const ut=N.get(Te);ut?ut.push(ie):N.set(Te,[ie])},Fe=(Te,dt)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",Te,ie),e.score.graft(Te,ie),X.add(Te),ae.delete(Te),e.metrics?.onAddToMesh(ie,dt,1);const ut=R.get(Te);ut?ut.push(ie):R.set(Te,[ie])};if(X.forEach(Te=>{const dt=_(Te);dt<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",Te,dt,ie),Ie(Te,ka.BadScore),B.set(Te,!0))}),X.size!0)}(Se,t-X.size).forEach(ut=>{Fe(ut,Eo.NotEnough)}),X.size>i){let Te=Array.from(X);Te.sort((ut,an)=>_(an)-_(ut)),Te=Te.slice(0,s).concat(vo(Te.slice(s)));let dt=0;if(Te.slice(0,t).forEach(ut=>{e.outbound.get(ut)&&dt++}),dt{const ir=Te[Pn];for(let bi=Pn;bi>0;bi--)Te[bi]=Te[bi-1];Te[0]=ir};if(dt>0){let Pn=dt;for(let ir=1;ir0;ir++)e.outbound.get(Te[ir])&&(ut(ir),Pn--)}let an=t-dt;for(let Pn=t;Pn0;Pn++)e.outbound.get(Te[Pn])&&(ut(Pn),an--)}Te.slice(t).forEach(ut=>{Ie(ut,ka.Excess)})}if(X.size>=r){let Te=0;X.forEach(dt=>{e.outbound.get(dt)&&Te++}),Te!0===e.outbound.get(an)).forEach(an=>{Fe(an,Eo.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&X.size>1){const Te=Array.from(X).sort((an,Pn)=>_(an)-_(Pn)),dt=Math.floor(X.size/2),ut=_(Te[dt]);if(ut_(ir)>ut);for(const ir of Pn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",ir,ie),Fe(ir,Eo.Opportunistic)}}});const Y=Date.now();e.fanoutLastpub.forEach((X,ie)=>{X+a{const fe=e.topics.get(ie);X.forEach(Fe=>{(!fe.has(Fe)||_(Fe)=e.opts.scoreThresholds.publishThreshold&&ae.push(Te),ut>=e.opts.scoreThresholds.gossipThreshold&&Ie.add(Te)}}}X.size{X.add(Te),Ie?.delete(Te)})}),e.emitGossip(V),yield e.sendGraftPrune(R,N,B),e.flush(),e.mcache.shift(),e.dispatchEvent(new qt("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=vo(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 iK(n,e,t,r,i){const s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const o of n){const a=e.get(o);if(a){const l=rK(o,a,t,r,i);for(const[_,R]of l.byTopic){let N=s.byTopic.get(_);N||(N={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(_,N)),N.p1w.push(R.p1w),N.p2w.push(R.p2w),N.p3w.push(R.p3w),N.p3bw.push(R.p3bw),N.p4w.push(R.p4w)}s.p5w.push(l.p5w),s.p6w.push(l.p6w),s.p7w.push(l.p7w),s.score.push(l.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}}_A.multicodec=mE,function(n){let e;n.codec=()=>(null==e&&(e=Bt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==2?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>Lt(t,n.codec()),n.decode=t=>kt(t,n.codec())}(CE||(CE={}));const uK=cr("waku:message:topic-only");class lK{constructor(e){this.proto=e}get contentTopic(){return this.proto.contentTopic??""}}class fK{constructor(){this.contentTopic=""}decodeProto(e){const t=CE.decode(e);return uK("Message decoded",t),Promise.resolve(t)}decode(e){return j(function*(){return new lK(e)})()}}const Xl=cr("waku:relay");class IE extends _A{constructor(e){super(e=Object.assign(e??{},{globalSignaturePolicy:sp.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=Ma,this.observers=new Map,this.pubSubTopic=e?.pubSubTopic??"/waku/2/default-waku/proto",this.defaultDecoder=new fK}start(){var e=()=>super.start,t=this;return j(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e,t){var r=this;return j(function*(){const i=yield e.encode(t);return i?r.publish(r.pubSubTopic,i):(Xl("Failed to encode message, aborting publish"),{recipients:[]})})()}addObserver(e,t){const r={decoder:e,callback:t};return function cK(n,e,t){let r=n.get(e);typeof r>"u"&&(n.set(e,new Set),r=n.get(e)),r.add(t)}(this.observers,e.contentTopic,r),()=>{const i=this.observers.get(e.contentTopic);i&&i.delete(r)}}subscribe(e){var t=this;this.addEventListener("gossipsub:message",function(){var r=j(function*(i){if(i.detail.msg.topic!==e)return;Xl(`Message received on ${e}`);const s=yield t.defaultDecoder.decodeProto(i.detail.msg.data);if(!s||!s.contentTopic)return void Xl("Message does not have a content topic, skipping");const o=t.observers.get(s.contentTopic);!o||(yield Promise.all(Array.from(o).map(function(){var a=j(function*({decoder:l,callback:_}){const R=yield l.decodeProto(i.detail.msg.data);if(!R)return void Xl("Internal error: message previously decoded failed on 2nd pass.");const N=yield l.decode(R);N?_(N):Xl("Failed to decode messages on",s.contentTopic)});return function(l){return a.apply(this,arguments)}}())))});return function(i){return r.apply(this,arguments)}}()),super.subscribe(e)}getMeshPeers(e){return super.getMeshPeers(e??this.pubSubTopic)}}function AE(){return AE=j(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(op()),Object.assign(e,{peerDiscovery:t}));const r=yield ap(new IE(n),e);return new X7(n??{},r)}),AE.apply(this,arguments)}function op(){return new L7(function F7(n=iu.Prod,e=1){if(e<=0)return[];let t;switch(n){case iu.Prod:t=uE_fleets["wakuv2.prod"]["waku-websocket"];break;case iu.Test:t=uE_fleets["wakuv2.test"]["waku-websocket"];break;default:t=uE_fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),t=t.map(r=>new ln(r)),sA(t,e)}())}function ap(n,e){return PE.apply(this,arguments)}function PE(){return PE=j(function*(n,e){return M7(Object.assign({transports:[new WU({filter:LT})],streamMuxers:[new B5],connectionEncryption:[new y5]},n?{pubsub:n}:{},e??{}))}),PE.apply(this,arguments)}IE.multicodec=Ma[0],IE.multicodec=Ma[Ma.length-1];function pK(n,e,t){"function"==typeof t&&(t={filter:t});const r=function hK(n,e,t){let r;const i=new Promise((s,o)=>{if(!((t={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...t}).count>=0)||t.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(t.count))throw new TypeError("The `count` option should be at least 0 or more");const a=[e].flat(),l=[],{addListener:_,removeListener:R}=(n=>{const e=n.on||n.addListener||n.addEventListener,t=n.off||n.removeListener||n.removeEventListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(n),removeListener:t.bind(n)}})(n),N=(...V)=>{const Y=t.multiArgs?V:V[0];t.filter&&!t.filter(Y)||(l.push(Y),t.count===l.length&&(r(),s(l)))},B=V=>{r(),o(V)};r=()=>{for(const V of a)R(V,N);for(const V of t.rejectionEvents)R(V,B)};for(const V of a)_(V,N);for(const V of t.rejectionEvents)_(V,B);t.resolveImmediately&&s(l)});if(i.cancel=r,"number"==typeof t.timeout){const s=k2(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 SA=cr("waku:wait-for-remote-peer");function NE(){return NE=j(function*(n,e,t){if(e=e??EK(n),!n.isStarted())return Promise.reject("Waku node is not started");const r=[];if(e.includes(qr.Relay)){if(!n.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(yK(n.relay))}if(e.includes(qr.Store)){if(!n.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(ME(n.store,Object.values(Zl)))}if(e.includes(qr.LightPush)){if(!n.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(ME(n.lightPush,[Ql]))}if(e.includes(qr.Filter)){if(!n.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(ME(n.filter,[Na]))}t?yield vK(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),NE.apply(this,arguments)}function ME(n,e){return OE.apply(this,arguments)}function OE(){return OE=j(function*(n,e){const t=yield n.peers();t.length?SA(`${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)){SA("Resolving for",o,s.detail.protocols),n.libp2p.peerStore.removeEventListener("change:protocols",i),r();break}};n.libp2p.peerStore.addEventListener("change:protocols",i)})}),OE.apply(this,arguments)}function yK(n){return kE.apply(this,arguments)}function kE(){return kE=j(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield pK(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),kE.apply(this,arguments)}const mK=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function vK(n,e,t){return LE.apply(this,arguments)}function LE(){return LE=j(function*(n,e,t){yield Promise.race([n,mK(e,t)])}),LE.apply(this,arguments)}function EK(n){const e=[];return n.relay&&e.push(qr.Relay),n.filter&&e.push(qr.Filter),n.store&&e.push(qr.Store),n.lightPush&&e.push(qr.LightPush),e}let CA=(()=>{class n{constructor(){this.wakuSubject=new Qr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new M4(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function dK(n){return AE.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function gK(n,e,t){return NE.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Gn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function bK(n,e){if(1&n&&(Zs(0,"li")(1,"span"),_c(2),Xs()()),2&n){const t=e.$implicit;Vu(2),ly("",t.timestamp," ",t.text,"")}}const BE=new(w0().Type)("ChatMessage").add(new(w0().Field)("timestamp",1,"uint32")).add(new(w0().Field)("text",2,"string"));let wK=(()=>{class n{constructor(t){this.wakuService=t,this.contentTopic="/js-waku-examples/1/chat/proto",this.messages=[],this.messageCount=0,this.processIncomingMessages=r=>{if(!r.payload)return;const{text:i,timestamp:s}=BE.decode(r.payload),o=new Date;o.setTime(Number(s)),this.messages.push({text:i,timestamp:o})},this.decoder=new K7(this.contentTopic),this.encoder=new fA(this.contentTopic)}ngOnInit(){this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t}),this.wakuService.waku.subscribe(t=>{this.waku=t,this.deleteObserver=this.waku.relay.addObserver(this.decoder,this.processIncomingMessages)}),window.onbeforeunload=()=>this.ngOnDestroy()}ngOnDestroy(){this.deleteObserver&&this.deleteObserver()}sendMessage(){const t=(new Date).getTime(),r=BE.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=BE.encode(r).finish();this.waku.relay.send(this.encoder,{payload:i}).then(()=>{console.log(`Message #${this.messageCount} sent`),this.messageCount+=1})}}return n.\u0275fac=function(t){return new(t||n)(Kt(CA))},n.\u0275cmp=of({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(Zs(0,"button",0),oy("click",function(){return r.sendMessage()}),_c(1,"Send Message"),Xs(),Zs(2,"h2"),_c(3,"Messages"),Xs(),Zs(4,"ul",1),function z_(n,e,t,r,i,s,o,a){const l=Me(),_=sn(),R=n+22,N=_.firstCreatePass?function EM(n,e,t,r,i,s,o,a,l){const _=e.consts,R=lc(e,n,4,o||null,So(_,a));Gg(e,t,R,So(_,l)),yf(e,R);const N=R.tViews=jg(2,R,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,_);return null!==e.queries&&(e.queries.template(e,R),N.queries=e.queries.embeddedTView(R)),R}(R,_,l,e,t,r,i,s,o):_.data[R];Is(N,!1);const B=l[11].createComment("");Vf(_,l,B,N),Vr(B,l),qf(l,l[R]=T_(B,l,B,N)),ff(N)&&Kg(_,l,N),null!=o&&$g(l,N,a)}(5,bK,3,2,"li",2),Xs()),2&t&&(Jf("disabled","Connected"!==r.wakuStatus),Vu(5),Jf("ngForOf",r.messages))},dependencies:[HS]}),n})(),_K=(()=>{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)(Kt(CA))},n.\u0275cmp=of({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(Zs(0,"h1"),_c(1),Xs(),Zs(2,"p"),_c(3),Xs(),ny(4,"app-messages")),2&t&&(Vu(1),uy(r.title),Vu(2),td("Waku node's status: ",r.wakuStatus,""))},dependencies:[wK],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})(),DK=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=yu({type:n,bootstrap:[_K]}),n.\u0275inj=Ba({imports:[D4]}),n})();x(5332),function qk(){ES=!1}(),_4().bootstrapModule(DK).catch(n=>console.error(n))},253:Q=>{"use strict";Q.exports=function K(x,y){for(var u=new Array(arguments.length-1),g=0,w=2,m=!0;w{"use strict";var x=K;x.length=function(h){var c=h.length;if(!c)return 0;for(var f=0;--c%4>1&&"="===h.charAt(c);)++f;return Math.ceil(3*h.length)/4-f};for(var y=new Array(64),u=new Array(123),g=0;g<64;)u[y[g]=g<26?g+65:g<52?g+71:g<62?g-4:g-59|43]=g++;x.encode=function(h,c,f){for(var v,d=null,b=[],S=0,E=0;c>2],v=(3&p)<<4,E=1;break;case 1:b[S++]=y[v|p>>4],v=(15&p)<<2,E=2;break;case 2:b[S++]=y[v|p>>6],b[S++]=y[63&p],E=0}S>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,b)),S=0)}return E&&(b[S++]=y[v],b[S++]=61,1===E&&(b[S++]=61)),d?(S&&d.push(String.fromCharCode.apply(String,b.slice(0,S))),d.join("")):String.fromCharCode.apply(String,b.slice(0,S))};var w="invalid encoding";x.decode=function(h,c,f){for(var S,d=f,b=0,E=0;E1)break;if(void 0===(v=u[v]))throw Error(w);switch(b){case 0:S=v,b=1;break;case 1:c[f++]=S<<2|(48&v)>>4,S=v,b=2;break;case 2:c[f++]=(15&S)<<4|(60&v)>>2,S=v,b=3;break;case 3:c[f++]=(3&S)<<6|v,b=0}}if(1===b)throw Error(w);return f-d},x.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9810:Q=>{"use strict";function K(x,y){"string"==typeof x&&(y=x,x=void 0);var u=[];function g(m){if("string"!=typeof m){var h=w();if(K.verbose&&console.log("codegen: "+h),h="return "+h,m){for(var c=Object.keys(m),f=new Array(c.length+1),d=new Array(c.length),b=0;b{"use strict";function K(){this._listeners={}}Q.exports=K,K.prototype.on=function(y,u,g){return(this._listeners[y]||(this._listeners[y]=[])).push({fn:u,ctx:g||this}),this},K.prototype.off=function(y,u){if(void 0===y)this._listeners={};else if(void 0===u)this._listeners[y]=[];else for(var g=this._listeners[y],w=0;w{"use strict";Q.exports=w;var y=x(253),g=x(4343)("fs");function w(m,h,c){return"function"==typeof h?(c=h,h={}):h||(h={}),c?!h.xhr&&g&&g.readFile?g.readFile(m,function(d,b){return d&&typeof XMLHttpRequest<"u"?w.xhr(m,h,c):d?c(d):c(null,h.binary?b:b.toString("utf8"))}):w.xhr(m,h,c):y(w,this,m,h)}w.xhr=function(h,c,f){var d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState){if(0!==d.status&&200!==d.status)return f(Error("status "+d.status));if(c.binary){var S=d.response;if(!S){S=[];for(var E=0;E{"use strict";function K(w){return typeof Float32Array<"u"?function(){var m=new Float32Array([-0]),h=new Uint8Array(m.buffer),c=128===h[3];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3]}function d(E,v,p){m[0]=E,v[p]=h[3],v[p+1]=h[2],v[p+2]=h[1],v[p+3]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],m[0]}function S(E,v){return h[3]=E[v],h[2]=E[v+1],h[1]=E[v+2],h[0]=E[v+3],m[0]}w.writeFloatLE=c?f:d,w.writeFloatBE=c?d:f,w.readFloatLE=c?b:S,w.readFloatBE=c?S:b}():function(){function m(c,f,d,b){var S=f<0?1:0;if(S&&(f=-f),0===f)c(1/f>0?0:2147483648,d,b);else if(isNaN(f))c(2143289344,d,b);else if(f>34028234663852886e22)c((S<<31|2139095040)>>>0,d,b);else if(f<11754943508222875e-54)c((S<<31|Math.round(f/1401298464324817e-60))>>>0,d,b);else{var E=Math.floor(Math.log(f)/Math.LN2);c((S<<31|E+127<<23|8388607&Math.round(f*Math.pow(2,-E)*8388608))>>>0,d,b)}}function h(c,f,d){var b=c(f,d),S=2*(b>>31)+1,E=b>>>23&255,v=8388607&b;return 255===E?v?NaN:S*(1/0):0===E?1401298464324817e-60*S*v:S*Math.pow(2,E-150)*(v+8388608)}w.writeFloatLE=m.bind(null,x),w.writeFloatBE=m.bind(null,y),w.readFloatLE=h.bind(null,u),w.readFloatBE=h.bind(null,g)}(),typeof Float64Array<"u"?function(){var m=new Float64Array([-0]),h=new Uint8Array(m.buffer),c=128===h[7];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3],v[p+4]=h[4],v[p+5]=h[5],v[p+6]=h[6],v[p+7]=h[7]}function d(E,v,p){m[0]=E,v[p]=h[7],v[p+1]=h[6],v[p+2]=h[5],v[p+3]=h[4],v[p+4]=h[3],v[p+5]=h[2],v[p+6]=h[1],v[p+7]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],h[4]=E[v+4],h[5]=E[v+5],h[6]=E[v+6],h[7]=E[v+7],m[0]}function S(E,v){return h[7]=E[v],h[6]=E[v+1],h[5]=E[v+2],h[4]=E[v+3],h[3]=E[v+4],h[2]=E[v+5],h[1]=E[v+6],h[0]=E[v+7],m[0]}w.writeDoubleLE=c?f:d,w.writeDoubleBE=c?d:f,w.readDoubleLE=c?b:S,w.readDoubleBE=c?S:b}():function(){function m(c,f,d,b,S,E){var v=b<0?1:0;if(v&&(b=-b),0===b)c(0,S,E+f),c(1/b>0?0:2147483648,S,E+d);else if(isNaN(b))c(0,S,E+f),c(2146959360,S,E+d);else if(b>17976931348623157e292)c(0,S,E+f),c((v<<31|2146435072)>>>0,S,E+d);else{var p;if(b<22250738585072014e-324)c((p=b/5e-324)>>>0,S,E+f),c((v<<31|p/4294967296)>>>0,S,E+d);else{var I=Math.floor(Math.log(b)/Math.LN2);1024===I&&(I=1023),c(4503599627370496*(p=b*Math.pow(2,-I))>>>0,S,E+f),c((v<<31|I+1023<<20|1048576*p&1048575)>>>0,S,E+d)}}}function h(c,f,d,b,S){var E=c(b,S+f),v=c(b,S+d),p=2*(v>>31)+1,I=v>>>20&2047,A=4294967296*(1048575&v)+E;return 2047===I?A?NaN:p*(1/0):0===I?5e-324*p*A:p*Math.pow(2,I-1075)*(A+4503599627370496)}w.writeDoubleLE=m.bind(null,x,0,4),w.writeDoubleBE=m.bind(null,y,4,0),w.readDoubleLE=h.bind(null,u,0,4),w.readDoubleBE=h.bind(null,g,4,0)}(),w}function x(w,m,h){m[h]=255&w,m[h+1]=w>>>8&255,m[h+2]=w>>>16&255,m[h+3]=w>>>24}function y(w,m,h){m[h]=w>>>24,m[h+1]=w>>>16&255,m[h+2]=w>>>8&255,m[h+3]=255&w}function u(w,m){return(w[m]|w[m+1]<<8|w[m+2]<<16|w[m+3]<<24)>>>0}function g(w,m){return(w[m]<<24|w[m+1]<<16|w[m+2]<<8|w[m+3])>>>0}Q.exports=K(K)},4343: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(Q){}return null}module.exports=inquire},2175:(Q,K)=>{"use strict";var x=K,y=x.isAbsolute=function(w){return/^(?:\/|\w+:)/.test(w)},u=x.normalize=function(w){var m=(w=w.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),h=y(w),c="";h&&(c=m.shift()+"/");for(var f=0;f0&&".."!==m[f-1]?m.splice(--f,2):h?m.splice(f,1):++f:"."===m[f]?m.splice(f,1):++f;return c+m.join("/")};x.resolve=function(w,m,h){return h||(m=u(m)),y(m)?m:(h||(w=u(w)),(w=w.replace(/(?:\/|^)[^/]+$/,"")).length?u(w+"/"+m):m)}},4352:Q=>{"use strict";Q.exports=function K(x,y,u){var g=u||8192,w=g>>>1,m=null,h=g;return function(f){if(f<1||f>w)return x(f);h+f>g&&(m=x(g),h=0);var d=y.call(m,h,h+=f);return 7&h&&(h=1+(7|h)),d}}},9865:(Q,K)=>{"use strict";var x=K;x.length=function(u){for(var g=0,w=0,m=0;m191&&d<224?c[f++]=(31&d)<<6|63&u[g++]:d>239&&d<365?(d=((7&d)<<18|(63&u[g++])<<12|(63&u[g++])<<6|63&u[g++])-65536,c[f++]=55296+(d>>10),c[f++]=56320+(1023&d)):c[f++]=(15&d)<<12|(63&u[g++])<<6|63&u[g++],f>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,c)),f=0);return h?(f&&h.push(String.fromCharCode.apply(String,c.slice(0,f))),h.join("")):String.fromCharCode.apply(String,c.slice(0,f))},x.write=function(u,g,w){for(var h,c,m=w,f=0;f>6|192,g[w++]=63&h|128):55296==(64512&h)&&56320==(64512&(c=u.charCodeAt(f+1)))?(++f,g[w++]=(h=65536+((1023&h)<<10)+(1023&c))>>18|240,g[w++]=h>>12&63|128,g[w++]=h>>6&63|128,g[w++]=63&h|128):(g[w++]=h>>12|224,g[w++]=h>>6&63|128,g[w++]=63&h|128);return w-m}},5345:(Q,K,x)=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});var y=x(6559);function h(Z,W,te){return void 0===W&&(W=new Uint8Array(2)),void 0===te&&(te=0),W[te+0]=Z>>>8,W[te+1]=Z>>>0,W}function c(Z,W,te){return void 0===W&&(W=new Uint8Array(2)),void 0===te&&(te=0),W[te+0]=Z>>>0,W[te+1]=Z>>>8,W}function f(Z,W){return void 0===W&&(W=0),Z[W]<<24|Z[W+1]<<16|Z[W+2]<<8|Z[W+3]}function d(Z,W){return void 0===W&&(W=0),(Z[W]<<24|Z[W+1]<<16|Z[W+2]<<8|Z[W+3])>>>0}function b(Z,W){return void 0===W&&(W=0),Z[W+3]<<24|Z[W+2]<<16|Z[W+1]<<8|Z[W]}function S(Z,W){return void 0===W&&(W=0),(Z[W+3]<<24|Z[W+2]<<16|Z[W+1]<<8|Z[W])>>>0}function E(Z,W,te){return void 0===W&&(W=new Uint8Array(4)),void 0===te&&(te=0),W[te+0]=Z>>>24,W[te+1]=Z>>>16,W[te+2]=Z>>>8,W[te+3]=Z>>>0,W}function v(Z,W,te){return void 0===W&&(W=new Uint8Array(4)),void 0===te&&(te=0),W[te+0]=Z>>>0,W[te+1]=Z>>>8,W[te+2]=Z>>>16,W[te+3]=Z>>>24,W}function D(Z,W,te){return void 0===W&&(W=new Uint8Array(8)),void 0===te&&(te=0),E(Z/4294967296>>>0,W,te),E(Z>>>0,W,te+4),W}function T(Z,W,te){return void 0===W&&(W=new Uint8Array(8)),void 0===te&&(te=0),v(Z>>>0,W,te),v(Z/4294967296>>>0,W,te+4),W}K.readInt16BE=function u(Z,W){return void 0===W&&(W=0),(Z[W+0]<<8|Z[W+1])<<16>>16},K.readUint16BE=function g(Z,W){return void 0===W&&(W=0),(Z[W+0]<<8|Z[W+1])>>>0},K.readInt16LE=function w(Z,W){return void 0===W&&(W=0),(Z[W+1]<<8|Z[W])<<16>>16},K.readUint16LE=function m(Z,W){return void 0===W&&(W=0),(Z[W+1]<<8|Z[W])>>>0},K.writeUint16BE=h,K.writeInt16BE=h,K.writeUint16LE=c,K.writeInt16LE=c,K.readInt32BE=f,K.readUint32BE=d,K.readInt32LE=b,K.readUint32LE=S,K.writeUint32BE=E,K.writeInt32BE=E,K.writeUint32LE=v,K.writeInt32LE=v,K.readInt64BE=function p(Z,W){void 0===W&&(W=0);var te=f(Z,W),oe=f(Z,W+4);return 4294967296*te+oe-4294967296*(oe>>31)},K.readUint64BE=function I(Z,W){return void 0===W&&(W=0),4294967296*d(Z,W)+d(Z,W+4)},K.readInt64LE=function A(Z,W){void 0===W&&(W=0);var te=b(Z,W);return 4294967296*b(Z,W+4)+te-4294967296*(te>>31)},K.readUint64LE=function P(Z,W){void 0===W&&(W=0);var te=S(Z,W);return 4294967296*S(Z,W+4)+te},K.writeUint64BE=D,K.writeInt64BE=D,K.writeUint64LE=T,K.writeInt64LE=T,K.readUintBE=function M(Z,W,te){if(void 0===te&&(te=0),Z%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(Z/8>W.length-te)throw new Error("readUintBE: array is too short for the given bitLength");for(var oe=0,de=1,he=Z/8+te-1;he>=te;he--)oe+=W[he]*de,de*=256;return oe},K.readUintLE=function k(Z,W,te){if(void 0===te&&(te=0),Z%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(Z/8>W.length-te)throw new Error("readUintLE: array is too short for the given bitLength");for(var oe=0,de=1,he=te;he=oe;he--)te[he]=W/de&255,de*=256;return te},K.writeUintLE=function $(Z,W,te,oe){if(void 0===te&&(te=new Uint8Array(Z/8)),void 0===oe&&(oe=0),Z%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!y.isSafeInteger(W))throw new Error("writeUintLE value must be an integer");for(var de=1,he=oe;he{"use strict";var u=x(6237),g=x(1192),w=x(1296),m=x(5345),h=x(7294);K.Cv=32,K.WH=12,K.pg=16;var c=new Uint8Array(16),f=function(){function d(b){if(this.nonceLength=K.WH,this.tagLength=K.pg,b.length!==K.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return d.prototype.seal=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var p=new Uint8Array(16);p.set(b,p.length-b.length);var I=new Uint8Array(32);u.stream(this._key,p,I,4);var P,A=S.length+this.tagLength;if(v){if(v.length!==A)throw new Error("ChaCha20Poly1305: incorrect destination length");P=v}else P=new Uint8Array(A);return u.streamXOR(this._key,p,S,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),I,P.subarray(0,P.length-this.tagLength),E),w.wipe(p),P},d.prototype.open=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(S.length0&&p.update(c.subarray(v.length%16))),p.update(E),E.length%16>0&&p.update(c.subarray(E.length%16));var I=new Uint8Array(8);v&&m.writeUint64LE(v.length,I),p.update(I),m.writeUint64LE(E.length,I),p.update(I);for(var A=p.digest(),P=0;P{"use strict";Object.defineProperty(K,"__esModule",{value:!0});var y=x(5345),u=x(1296);function w(f,d,b){for(var S=1634760805,E=857760878,v=2036477234,p=1797285236,I=b[3]<<24|b[2]<<16|b[1]<<8|b[0],A=b[7]<<24|b[6]<<16|b[5]<<8|b[4],P=b[11]<<24|b[10]<<16|b[9]<<8|b[8],D=b[15]<<24|b[14]<<16|b[13]<<8|b[12],T=b[19]<<24|b[18]<<16|b[17]<<8|b[16],M=b[23]<<24|b[22]<<16|b[21]<<8|b[20],k=b[27]<<24|b[26]<<16|b[25]<<8|b[24],F=b[31]<<24|b[30]<<16|b[29]<<8|b[28],$=d[3]<<24|d[2]<<16|d[1]<<8|d[0],C=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],U=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=S,H=E,ne=v,G=p,ee=I,Z=A,W=P,te=D,oe=T,de=M,he=k,Pe=F,De=$,Be=C,ve=O,He=U,ke=0;ke<20;ke+=2)ee=(ee^=oe=oe+(De=(De^=L=L+ee|0)>>>16|De<<16)|0)>>>20|ee<<12,Z=(Z^=de=de+(Be=(Be^=H=H+Z|0)>>>16|Be<<16)|0)>>>20|Z<<12,W=(W^=he=he+(ve=(ve^=ne=ne+W|0)>>>16|ve<<16)|0)>>>20|W<<12,te=(te^=Pe=Pe+(He=(He^=G=G+te|0)>>>16|He<<16)|0)>>>20|te<<12,W=(W^=he=he+(ve=(ve^=ne=ne+W|0)>>>24|ve<<8)|0)>>>25|W<<7,te=(te^=Pe=Pe+(He=(He^=G=G+te|0)>>>24|He<<8)|0)>>>25|te<<7,Z=(Z^=de=de+(Be=(Be^=H=H+Z|0)>>>24|Be<<8)|0)>>>25|Z<<7,ee=(ee^=oe=oe+(De=(De^=L=L+ee|0)>>>24|De<<8)|0)>>>25|ee<<7,Z=(Z^=he=he+(He=(He^=L=L+Z|0)>>>16|He<<16)|0)>>>20|Z<<12,W=(W^=Pe=Pe+(De=(De^=H=H+W|0)>>>16|De<<16)|0)>>>20|W<<12,te=(te^=oe=oe+(Be=(Be^=ne=ne+te|0)>>>16|Be<<16)|0)>>>20|te<<12,ee=(ee^=de=de+(ve=(ve^=G=G+ee|0)>>>16|ve<<16)|0)>>>20|ee<<12,te=(te^=oe=oe+(Be=(Be^=ne=ne+te|0)>>>24|Be<<8)|0)>>>25|te<<7,ee=(ee^=de=de+(ve=(ve^=G=G+ee|0)>>>24|ve<<8)|0)>>>25|ee<<7,W=(W^=Pe=Pe+(De=(De^=H=H+W|0)>>>24|De<<8)|0)>>>25|W<<7,Z=(Z^=he=he+(He=(He^=L=L+Z|0)>>>24|He<<8)|0)>>>25|Z<<7;y.writeUint32LE(L+S|0,f,0),y.writeUint32LE(H+E|0,f,4),y.writeUint32LE(ne+v|0,f,8),y.writeUint32LE(G+p|0,f,12),y.writeUint32LE(ee+I|0,f,16),y.writeUint32LE(Z+A|0,f,20),y.writeUint32LE(W+P|0,f,24),y.writeUint32LE(te+D|0,f,28),y.writeUint32LE(oe+T|0,f,32),y.writeUint32LE(de+M|0,f,36),y.writeUint32LE(he+k|0,f,40),y.writeUint32LE(Pe+F|0,f,44),y.writeUint32LE(De+$|0,f,48),y.writeUint32LE(Be+C|0,f,52),y.writeUint32LE(ve+O|0,f,56),y.writeUint32LE(He+U|0,f,60)}function m(f,d,b,S,E){if(void 0===E&&(E=0),32!==f.length)throw new Error("ChaCha: key size must be 32 bytes");if(S.length>>=8,d++;if(S>0)throw new Error("ChaCha: counter overflow")}K.streamXOR=m,K.stream=function h(f,d,b,S){return void 0===S&&(S=0),u.wipe(b),m(f,d,b,b,S)}},7294:(Q,K)=>{"use strict";function u(w,m){if(w.length!==m.length)return 0;for(var h=0,c=0;c>>8}Object.defineProperty(K,"__esModule",{value:!0}),K.select=function x(w,m,h){return~(w-1)&m|w-1&h},K.lessOrEqual=function y(w,m){return(0|w)-(0|m)-1>>>31&1},K.compare=u,K.equal=function g(w,m){return 0!==w.length&&0!==m.length&&0!==u(w,m)}},883:(Q,K)=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.isSerializableHash=function x(y){return typeof y.saveState<"u"&&typeof y.restoreState<"u"&&typeof y.cleanSavedState<"u"}},6883:(Q,K,x)=>{"use strict";var u=x(9605),g=x(1296),w=function(){function m(h,c,f,d){void 0===f&&(f=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=h,this._info=d;var b=u.hmac(this._hash,f,c);this._hmac=new u.HMAC(h,b),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return m.prototype._fillBuffer=function(){this._counter[0]++;var h=this._counter[0];if(0===h)throw new Error("hkdf: cannot expand more");this._hmac.reset(),h>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},m.prototype.expand=function(h){for(var c=new Uint8Array(h),f=0;f{"use strict";Object.defineProperty(K,"__esModule",{value:!0});var y=x(883),u=x(7294),g=x(1296),w=function(){function h(c,f){this._finished=!1,this._inner=new c,this._outer=new c,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);f.length>this.blockSize?this._inner.update(f).finish(d).clean():d.set(f);for(var b=0;b{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.mul=Math.imul||function x(h,c){var d=65535&h,S=65535&c;return d*S+((h>>>16&65535)*S+d*(c>>>16&65535)<<16>>>0)|0},K.add=function y(h,c){return h+c|0},K.sub=function u(h,c){return h-c|0},K.rotl=function g(h,c){return h<>>32-c},K.rotr=function w(h,c){return h<<32-c|h>>>c},K.isInteger=Number.isInteger||function m(h){return"number"==typeof h&&isFinite(h)&&Math.floor(h)===h},K.MAX_SAFE_INTEGER=9007199254740991,K.isSafeInteger=function(h){return K.isInteger(h)&&h>=-K.MAX_SAFE_INTEGER&&h<=K.MAX_SAFE_INTEGER}},1192:(Q,K,x)=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});var y=x(7294),u=x(1296);K.DIGEST_LENGTH=16;var g=function(){function h(c){this.digestLength=K.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=8191&f;var d=c[2]|c[3]<<8;this._r[1]=8191&(f>>>13|d<<3);var b=c[4]|c[5]<<8;this._r[2]=7939&(d>>>10|b<<6);var S=c[6]|c[7]<<8;this._r[3]=8191&(b>>>7|S<<9);var E=c[8]|c[9]<<8;this._r[4]=255&(S>>>4|E<<12),this._r[5]=E>>>1&8190;var v=c[10]|c[11]<<8;this._r[6]=8191&(E>>>14|v<<2);var p=c[12]|c[13]<<8;this._r[7]=8065&(v>>>11|p<<5);var I=c[14]|c[15]<<8;this._r[8]=8191&(p>>>8|I<<8),this._r[9]=I>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return h.prototype._blocks=function(c,f,d){for(var b=this._fin?0:2048,S=this._h[0],E=this._h[1],v=this._h[2],p=this._h[3],I=this._h[4],A=this._h[5],P=this._h[6],D=this._h[7],T=this._h[8],M=this._h[9],k=this._r[0],F=this._r[1],$=this._r[2],C=this._r[3],O=this._r[4],U=this._r[5],L=this._r[6],H=this._r[7],ne=this._r[8],G=this._r[9];d>=16;){var ee=c[f+0]|c[f+1]<<8,Z=c[f+2]|c[f+3]<<8,W=c[f+4]|c[f+5]<<8,te=c[f+6]|c[f+7]<<8,oe=c[f+8]|c[f+9]<<8,de=c[f+10]|c[f+11]<<8,he=c[f+12]|c[f+13]<<8,Pe=c[f+14]|c[f+15]<<8,De=0,Be=De;Be+=(S+=8191&ee)*k,Be+=(E+=8191&(ee>>>13|Z<<3))*(5*G),Be+=(v+=8191&(Z>>>10|W<<6))*(5*ne),Be+=(p+=8191&(W>>>7|te<<9))*(5*H),De=(Be+=(I+=8191&(te>>>4|oe<<12))*(5*L))>>>13,Be&=8191,Be+=(A+=oe>>>1&8191)*(5*U),Be+=(P+=8191&(oe>>>14|de<<2))*(5*O),Be+=(D+=8191&(de>>>11|he<<5))*(5*C),Be+=(T+=8191&(he>>>8|Pe<<8))*(5*$);var ve=De+=(Be+=(M+=Pe>>>5|b)*(5*F))>>>13;ve+=S*F,ve+=E*k,ve+=v*(5*G),ve+=p*(5*ne),De=(ve+=I*(5*H))>>>13,ve&=8191,ve+=A*(5*L),ve+=P*(5*U),ve+=D*(5*O),ve+=T*(5*C),De+=(ve+=M*(5*$))>>>13,ve&=8191;var He=De;He+=S*$,He+=E*F,He+=v*k,He+=p*(5*G),De=(He+=I*(5*ne))>>>13,He&=8191,He+=A*(5*H),He+=P*(5*L),He+=D*(5*U),He+=T*(5*O);var ke=De+=(He+=M*(5*C))>>>13;ke+=S*C,ke+=E*$,ke+=v*F,ke+=p*k,De=(ke+=I*(5*G))>>>13,ke&=8191,ke+=A*(5*ne),ke+=P*(5*H),ke+=D*(5*L),ke+=T*(5*U);var nt=De+=(ke+=M*(5*O))>>>13;nt+=S*O,nt+=E*C,nt+=v*$,nt+=p*F,De=(nt+=I*k)>>>13,nt&=8191,nt+=A*(5*G),nt+=P*(5*ne),nt+=D*(5*H),nt+=T*(5*L);var Pt=De+=(nt+=M*(5*U))>>>13;Pt+=S*U,Pt+=E*O,Pt+=v*C,Pt+=p*$,De=(Pt+=I*F)>>>13,Pt&=8191,Pt+=A*k,Pt+=P*(5*G),Pt+=D*(5*ne),Pt+=T*(5*H);var _t=De+=(Pt+=M*(5*L))>>>13;_t+=S*L,_t+=E*U,_t+=v*O,_t+=p*C,De=(_t+=I*$)>>>13,_t&=8191,_t+=A*F,_t+=P*k,_t+=D*(5*G),_t+=T*(5*ne);var Vt=De+=(_t+=M*(5*H))>>>13;Vt+=S*H,Vt+=E*L,Vt+=v*U,Vt+=p*O,De=(Vt+=I*C)>>>13,Vt&=8191,Vt+=A*$,Vt+=P*F,Vt+=D*k,Vt+=T*(5*G);var Yt=De+=(Vt+=M*(5*ne))>>>13;Yt+=S*ne,Yt+=E*H,Yt+=v*L,Yt+=p*U,De=(Yt+=I*O)>>>13,Yt&=8191,Yt+=A*C,Yt+=P*$,Yt+=D*F,Yt+=T*k;var nn=De+=(Yt+=M*(5*G))>>>13;nn+=S*G,nn+=E*ne,nn+=v*H,nn+=p*L,De=(nn+=I*U)>>>13,nn&=8191,nn+=A*O,nn+=P*C,nn+=D*$,nn+=T*F,S=Be=8191&(De=(De=((De+=(nn+=M*k)>>>13)<<2)+De|0)+(Be&=8191)|0),E=ve+=De>>>=13,v=He&=8191,p=ke&=8191,I=nt&=8191,A=Pt&=8191,P=_t&=8191,D=Vt&=8191,T=Yt&=8191,M=nn&=8191,f+=16,d-=16}this._h[0]=S,this._h[1]=E,this._h[2]=v,this._h[3]=p,this._h[4]=I,this._h[5]=A,this._h[6]=P,this._h[7]=D,this._h[8]=T,this._h[9]=M},h.prototype.finish=function(c,f){void 0===f&&(f=0);var b,S,E,v,d=new Uint16Array(10);if(this._leftover){for(v=this._leftover,this._buffer[v++]=1;v<16;v++)this._buffer[v]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,v=2;v<10;v++)this._h[v]+=b,b=this._h[v]>>>13,this._h[v]&=8191;for(this._h[0]+=5*b,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,d[0]=this._h[0]+5,b=d[0]>>>13,d[0]&=8191,v=1;v<10;v++)d[v]=this._h[v]+b,b=d[v]>>>13,d[v]&=8191;for(d[9]-=8192,S=(1^b)-1,v=0;v<10;v++)d[v]&=S;for(S=~S,v=0;v<10;v++)this._h[v]=this._h[v]&S|d[v];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),this._h[0]=65535&(E=this._h[0]+this._pad[0]),v=1;v<8;v++)this._h[v]=65535&(E=(this._h[v]+this._pad[v]|0)+(E>>>16)|0);return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},h.prototype.update=function(c){var b,f=0,d=c.length;if(this._leftover){(b=16-this._leftover)>d&&(b=d);for(var S=0;S=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(S=0;S{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.randomStringForEntropy=K.randomString=K.randomUint32=K.randomBytes=K.defaultRandomSource=void 0;const y=x(3518),u=x(5345),g=x(1296);function w(d,b=K.defaultRandomSource){return b.randomBytes(d)}K.defaultRandomSource=new y.SystemRandomSource,K.randomBytes=w,K.randomUint32=function m(d=K.defaultRandomSource){const b=w(4,d),S=(0,u.readUint32LE)(b);return(0,g.wipe)(b),S};const h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(d,b=h,S=K.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let E="";const v=b.length,p=256-256%v;for(;d>0;){const I=w(Math.ceil(256*d/p),S);for(let A=0;A0;A++){const P=I[A];P{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.BrowserRandomSource=void 0,K.BrowserRandomSource=class y{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const g=typeof self<"u"?self.crypto||self.msCrypto:null;g&&void 0!==g.getRandomValues&&(this._crypto=g,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(g){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const w=new Uint8Array(g);for(let m=0;m{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.NodeRandomSource=void 0;const y=x(1296);K.NodeRandomSource=class u{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const w=x(985);w&&w.randomBytes&&(this._crypto=w,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(w){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let m=this._crypto.randomBytes(w);if(m.length!==w)throw new Error("NodeRandomSource: got fewer bytes than requested");const h=new Uint8Array(w);for(let c=0;c{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.SystemRandomSource=void 0;const y=x(1006),u=x(2486);K.SystemRandomSource=class g{constructor(){return this.isAvailable=!1,this.name="",this._source=new y.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new u.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(m){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(m)}}},3857:(Q,K,x)=>{"use strict";var u=x(5345),g=x(1296);K.k=32,K.cn=64;var w=function(){function f(){this.digestLength=K.k,this.blockSize=K.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){g.wipe(this._buffer),g.wipe(this._temp),this.reset()},f.prototype.update=function(d,b){if(void 0===b&&(b=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var S=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[S++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(S=h(this._temp,this._state,d,S,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=d[S++],b--;return this},f.prototype.finish=function(d){if(!this._finished){var b=this._bytesHashed,S=this._bufferLength,E=b/536870912|0,v=b<<3,p=b%64<56?64:128;this._buffer[S]=128;for(var I=S+1;I0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(d){g.wipe(d.state),d.buffer&&g.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},f}();K.mE=w;var m=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function h(f,d,b,S,E){for(;E>=64;){for(var v=d[0],p=d[1],I=d[2],A=d[3],P=d[4],D=d[5],T=d[6],M=d[7],k=0;k<16;k++)f[k]=u.readUint32BE(b,S+4*k);for(k=16;k<64;k++){var $=f[k-2];f[k]=((C=($>>>17|$<<15)^($>>>19|$<<13)^$>>>10)+f[k-7]|0)+((O=(($=f[k-15])>>>7|$<<25)^($>>>18|$<<14)^$>>>3)+f[k-16]|0)}for(k=0;k<64;k++){var C=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&D^~P&T)|0)+(M+(m[k]+f[k]|0)|0)|0,O=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&p^v&I^p&I)|0;M=T,T=D,D=P,P=A+C|0,A=I,I=p,p=v,v=C+O|0}d[0]+=v,d[1]+=p,d[2]+=I,d[3]+=A,d[4]+=P,d[5]+=D,d[6]+=T,d[7]+=M,S+=64,E-=64}return S}K.vp=function c(f){var d=new w;d.update(f);var b=d.digest();return d.clean(),b}},1296:(Q,K)=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0}),K.wipe=function x(y){for(var u=0;u{"use strict";K.gi=K.Au=K._w=K.KS=K.kz=void 0;const u=x(7365),g=x(1296);function w(k){const F=new Float64Array(16);if(k)for(let $=0;$=0;--te){const oe=$[te>>>3]>>>(7&te)&1;f(O,U,oe),f(L,H,oe),S(ne,O,L),E(O,O,L),S(L,U,H),E(U,U,H),p(H,ne),p(G,O),v(O,L,O),v(L,U,ne),S(ne,O,L),E(O,O,L),p(U,O),E(L,H,G),v(O,L,h),S(O,O,H),v(L,L,O),v(O,H,G),v(H,U,C),p(U,ne),f(O,U,oe),f(L,H,oe)}for(let te=0;te<16;te++)C[te+16]=O[te],C[te+32]=L[te],C[te+48]=U[te],C[te+64]=H[te];const ee=C.subarray(32),Z=C.subarray(16);(function I(k,F){const $=w();for(let C=0;C<16;C++)$[C]=F[C];for(let C=253;C>=0;C--)p($,$),2!==C&&4!==C&&v($,$,F);for(let C=0;C<16;C++)k[C]=$[C]})(ee,ee),v(Z,Z,ee);const W=new Uint8Array(32);return function d(k,F){const $=w(),C=w();for(let O=0;O<16;O++)C[O]=F[O];c(C),c(C),c(C);for(let O=0;O<2;O++){$[0]=C[0]-65517;for(let L=1;L<15;L++)$[L]=C[L]-65535-($[L-1]>>16&1),$[L-1]&=65535;$[15]=C[15]-32767-($[14]>>16&1);const U=$[15]>>16&1;$[14]&=65535,f(C,$,1-U)}for(let O=0;O<16;O++)k[2*O]=255&C[O],k[2*O+1]=C[O]>>8}(W,Z),W}function P(k){return A(k,m)}function D(k){if(k.length!==K.KS)throw new Error(`x25519: seed must be ${K.KS} bytes`);const F=new Uint8Array(k);return{publicKey:P(F),secretKey:F}}K._w=D,K.Au=function T(k){const F=(0,u.randomBytes)(32,k),$=D(F);return(0,g.wipe)(F),$},K.gi=function M(k,F,$=!1){if(k.length!==K.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==K.kz)throw new Error("X25519: incorrect public key length");const C=A(k,F);if($){let O=0;for(let U=0;U{function K(x){const y=new globalThis.AbortController;function u(){y.abort();for(const g of x)!g||!g.removeEventListener||g.removeEventListener("abort",u)}for(const g of x)if(g&&g.addEventListener){if(g.aborted){u();break}g.addEventListener("abort",u)}return y.signal}Q.exports=K,Q.exports.anySignal=K},4823:(Q,K,x)=>{K.formatArgs=function u(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+Q.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;c.splice(1,0,f,"color: inherit");let d=0,b=0;c[0].replace(/%[a-zA-Z%]/g,S=>{"%%"!==S&&(d++,"%c"===S&&(b=d))}),c.splice(b,0,f)},K.save=function g(c){try{c?K.storage.setItem("debug",c):K.storage.removeItem("debug")}catch{}},K.load=function w(){let c;try{c=K.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c},K.useColors=function y(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},K.storage=function m(){try{return localStorage}catch{}}(),K.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),K.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"],K.log=console.debug||console.log||(()=>{}),Q.exports=x(6759)(K);const{formatters:h}=Q.exports;h.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}},6759:(Q,K,x)=>{Q.exports=function y(u){function w(E){let v,I,A,p=null;function P(...D){if(!P.enabled)return;const T=P,M=Number(new Date);T.diff=M-(v||M),T.prev=v,T.curr=M,v=M,D[0]=w.coerce(D[0]),"string"!=typeof D[0]&&D.unshift("%O");let F=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(C,O)=>{if("%%"===C)return"%";F++;const U=w.formatters[O];return"function"==typeof U&&(C=U.call(T,D[F]),D.splice(F,1),F--),C}),w.formatArgs.call(T,D),(T.log||w.log).apply(T,D)}return P.namespace=E,P.useColors=w.useColors(),P.color=w.selectColor(E),P.extend=m,P.destroy=w.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==p?p:(I!==w.namespaces&&(I=w.namespaces,A=w.enabled(E)),A),set:D=>{p=D}}),"function"==typeof w.init&&w.init(P),P}function m(E,v){const p=w(this.namespace+(typeof v>"u"?":":v)+E);return p.log=this.log,p}function d(E){return E.toString().substring(2,E.toString().length-2).replace(/\.\*\?$/,"*")}return w.debug=w,w.default=w,w.coerce=function b(E){return E instanceof Error?E.stack||E.message:E},w.disable=function c(){const E=[...w.names.map(d),...w.skips.map(d).map(v=>"-"+v)].join(",");return w.enable(""),E},w.enable=function h(E){let v;w.save(E),w.namespaces=E,w.names=[],w.skips=[];const p=("string"==typeof E?E:"").split(/[\s,]+/),I=p.length;for(v=0;v{w[E]=u[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p{"use strict";function K(x,u){u=u||{},this._head=0,this._tail=0,this._capacity=u.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(x)&&this._fromArray(x)}K.prototype.peekAt=function(y){var u=y;if(u===(0|u)){var g=this.size();if(!(u>=g||u<-g))return u<0&&(u+=g),this._list[u=this._head+u&this._capacityMask]}},K.prototype.get=function(y){return this.peekAt(y)},K.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},K.prototype.peekFront=function(){return this.peek()},K.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(K.prototype,"length",{get:function(){return this.size()}}),K.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}},K.prototype.push=function(y){if(void 0===y)return this.size();var u=this._tail;return this._list[u]=y,this._tail=u+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&y<=u>>>2&&this._shrinkArray(),g}},K.prototype.removeOne=function(y){var u=y;if(u===(0|u)&&this._head!==this._tail){var g=this.size(),w=this._list.length;if(!(u>=g||u<-g)){u<0&&(u+=g);var h,m=this._list[u=this._head+u&this._capacityMask];if(y0;h--)this._list[u]=this._list[u=u-1+w&this._capacityMask];this._list[u]=void 0,this._head=this._head+1+w&this._capacityMask}else{for(h=g-1-y;h>0;h--)this._list[u]=this._list[u=u+1+w&this._capacityMask];this._list[u]=void 0,this._tail=this._tail-1+w&this._capacityMask}return m}}},K.prototype.remove=function(y,u){var w,g=y,m=u;if(g===(0|g)&&this._head!==this._tail){var h=this.size(),c=this._list.length;if(!(g>=h||g<-h||u<1)){if(g<0&&(g+=h),1===u||!u)return(w=new Array(1))[0]=this.removeOne(g),w;if(0===g&&g+u>=h)return w=this.toArray(),this.clear(),w;var f;for(g+u>h&&(u=h-g),w=new Array(u),f=0;f0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(0===y){for(this._head=this._head+u+c&this._capacityMask,f=u-1;f>0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(g0;f--)this.unshift(this._list[g=g-1+c&this._capacityMask]);for(g=this._head-1+c&this._capacityMask;m>0;)this._list[g=g-1+c&this._capacityMask]=void 0,m--;y<0&&(this._tail=g)}else{for(this._tail=g,g=g+u+c&this._capacityMask,f=h-(u+y);f>0;f--)this.push(this._list[g++]);for(g=this._tail;m>0;)this._list[g=g+1+c&this._capacityMask]=void 0,m--}return this._head<2&&this._tail>1e4&&this._tail<=c>>>2&&this._shrinkArray(),w}}},K.prototype.splice=function(y,u){var g=y;if(g===(0|g)){var w=this.size();if(g<0&&(g+=w),!(g>w)){if(arguments.length>2){var m,h,c,f=arguments.length,d=this._list.length,b=2;if(!w||g0&&(this._head=this._head+g+d&this._capacityMask)):(c=this.remove(g,u),this._head=this._head+g+d&this._capacityMask);f>b;)this.unshift(arguments[--f]);for(m=g;m>0;m--)this.unshift(h[m-1])}else{var S=(h=new Array(w-(g+u))).length;for(m=0;mthis._tail){for(m=this._head;m>>=1,this._capacityMask>>>=1},Q.exports=K},8798:Q=>{"use strict";function K(y,u){for(const g in u)Object.defineProperty(y,g,{value:u[g],enumerable:!0,configurable:!0});return y}Q.exports=function x(y,u,g){if(!y||"string"==typeof y)throw new TypeError("Please pass an Error to err-code");g||(g={}),"object"==typeof u&&(g=u,u=""),u&&(g.code=u);try{return K(y,g)}catch{g.message=y.message,g.stack=y.stack;const m=function(){};return m.prototype=Object.create(Object.getPrototypeOf(y)),K(new m,g)}}},5083:(Q,K,x)=>{"use strict";const u=x(8555);K.zN=u.EventIterator},8555:(Q,K)=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});class x{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(g){if(this.isStopped)return;const w={value:g,done:!1};if(this.pullQueue.length){const m=this.pullQueue.shift();m&&m.resolve(w)}else this.pushQueue.push(Promise.resolve(w)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const g of this.pullQueue)g.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(g){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const w of this.pullQueue)w.reject(g);this.pullQueue.length=0}else{const w=Promise.reject(g);w.catch(()=>{}),this.pushQueue.push(w)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:g=>{const w=this.pushQueue.shift();return w?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),w):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((m,h)=>{this.pullQueue.push({resolve:m,reject:h})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class y{constructor(g,{highWaterMark:w=100,lowWaterMark:m=1}={}){const h=new x;h.highWaterMark=w,h.lowWaterMark=m,h.removeCallback=g({push:c=>h.push(c),stop:()=>h.stop(),fail:c=>h.fail(c),on:(c,f)=>{h.eventHandlers[c]=f}})||(()=>{}),this[Symbol.asyncIterator]=()=>h[Symbol.asyncIterator](),Object.freeze(this)}}K.EventIterator=y,K.default=y},6313:Q=>{"use strict";var K=Object.prototype.hasOwnProperty,x="~";function y(){}function u(h,c,f){this.fn=h,this.context=c,this.once=f||!1}function g(h,c,f,d,b){if("function"!=typeof f)throw new TypeError("The listener must be a function");var S=new u(f,d||h,b),E=x?x+c:c;return h._events[E]?h._events[E].fn?h._events[E]=[h._events[E],S]:h._events[E].push(S):(h._events[E]=S,h._eventsCount++),h}function w(h,c){0==--h._eventsCount?h._events=new y:delete h._events[c]}function m(){this._events=new y,this._eventsCount=0}Object.create&&(y.prototype=Object.create(null),(new y).__proto__||(x=!1)),m.prototype.eventNames=function(){var f,d,c=[];if(0===this._eventsCount)return c;for(d in f=this._events)K.call(f,d)&&c.push(x?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(f)):c},m.prototype.listeners=function(c){var d=this._events[x?x+c:c];if(!d)return[];if(d.fn)return[d.fn];for(var b=0,S=d.length,E=new Array(S);b{"use strict";var y,K="object"==typeof Reflect?Reflect:null,x=K&&"function"==typeof K.apply?K.apply:function(M,k,F){return Function.prototype.apply.call(M,k,F)};y=K&&"function"==typeof K.ownKeys?K.ownKeys:Object.getOwnPropertySymbols?function(M){return Object.getOwnPropertyNames(M).concat(Object.getOwnPropertySymbols(M))}:function(M){return Object.getOwnPropertyNames(M)};var g=Number.isNaN||function(M){return M!=M};function w(){w.init.call(this)}Q.exports=w,Q.exports.once=function A(T,M){return new Promise(function(k,F){function $(O){T.removeListener(M,C),F(O)}function C(){"function"==typeof T.removeListener&&T.removeListener("error",$),k([].slice.call(arguments))}D(T,M,C,{once:!0}),"error"!==M&&function P(T,M,k){"function"==typeof T.on&&D(T,"error",M,k)}(T,$,{once:!0})})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var m=10;function h(T){if("function"!=typeof T)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}function c(T){return void 0===T._maxListeners?w.defaultMaxListeners:T._maxListeners}function f(T,M,k,F){var $,C,O;if(h(k),void 0===(C=T._events)?(C=T._events=Object.create(null),T._eventsCount=0):(void 0!==C.newListener&&(T.emit("newListener",M,k.listener?k.listener:k),C=T._events),O=C[M]),void 0===O)O=C[M]=k,++T._eventsCount;else if("function"==typeof O?O=C[M]=F?[k,O]:[O,k]:F?O.unshift(k):O.push(k),($=c(T))>0&&O.length>$&&!O.warned){O.warned=!0;var U=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");U.name="MaxListenersExceededWarning",U.emitter=T,U.type=M,U.count=O.length,function u(T){console&&console.warn&&console.warn(T)}(U)}return T}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(T,M,k){var F={fired:!1,wrapFn:void 0,target:T,type:M,listener:k},$=d.bind(F);return $.listener=k,F.wrapFn=$,$}function S(T,M,k){var F=T._events;if(void 0===F)return[];var $=F[M];return void 0===$?[]:"function"==typeof $?k?[$.listener||$]:[$]:k?function I(T){for(var M=new Array(T.length),k=0;k0&&(O=k[0]),O instanceof Error)throw O;var U=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw U.context=O,U}var L=C[M];if(void 0===L)return!1;if("function"==typeof L)x(L,this,k);else{var H=L.length,ne=v(L,H);for(F=0;F=0;O--)if(F[O]===k||F[O].listener===k){U=F[O].listener,C=O;break}if(C<0)return this;0===C?F.shift():function p(T,M){for(;M+1=0;$--)this.removeListener(M,k[$]);return this},w.prototype.listeners=function(M){return S(this,M,!0)},w.prototype.rawListeners=function(M){return S(this,M,!1)},w.listenerCount=function(T,M){return"function"==typeof T.listenerCount?T.listenerCount(M):E.call(T,M)},w.prototype.listenerCount=E,w.prototype.eventNames=function(){return this._eventsCount>0?y(this._events):[]}},3614:Q=>{Q.exports=class{constructor(x){if(!(x>0)||0!=(x-1&x))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(x),this.mask=x-1,this.top=0,this.btm=0,this.next=null}push(x){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=x,this.top=this.top+1&this.mask,!0)}shift(){const x=this.buffer[this.btm];if(void 0!==x)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,x}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},8317:(Q,K,x)=>{const y=x(3614);Q.exports=class{constructor(g){this.hwm=g||16,this.head=new y(this.hwm),this.tail=this.head}push(g){this.head.push(g)||(this.head=this.head.next=new y(2*this.head.buffer.length),this.head.push(g))}shift(){const g=this.tail.shift();if(void 0===g&&this.tail.next){const w=this.tail.next;return this.tail.next=null,this.tail=w,this.tail.shift()}return g}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},4835:Q=>{Q.exports=function(K){if(!K)throw Error("hashlru must have a max value, of type number, greater than 0");var x=0,y=Object.create(null),u=Object.create(null);function g(w,m){y[w]=m,++x>=K&&(x=0,u=y,y=Object.create(null))}return{has:function(w){return void 0!==y[w]||void 0!==u[w]},remove:function(w){void 0!==y[w]&&(y[w]=void 0),void 0!==u[w]&&(u[w]=void 0)},get:function(w){var m=y[w];return void 0!==m?m:void 0!==(m=u[w])?(g(w,m),m):void 0},set:function(w,m){void 0!==y[w]?y[w]=m:g(w,m)},clear:function(){y=Object.create(null),u=Object.create(null)}}}},8035:Q=>{"use strict";const K="[a-fA-F\\d:]",x=f=>f&&f.includeBoundaries?`(?:(?<=\\s|^)(?=${K})|(?<=${K})(?=\\s|$))`:"",y="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",u="[a-fA-F\\d]{1,4}",g=`\n(?:\n(?:${u}:){7}(?:${u}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${u}:){6}(?:${y}|:${u}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4\n(?:${u}:){5}(?::${y}|(?::${u}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4\n(?:${u}:){4}(?:(?::${u}){0,1}:${y}|(?::${u}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4\n(?:${u}:){3}(?:(?::${u}){0,2}:${y}|(?::${u}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4\n(?:${u}:){2}(?:(?::${u}){0,3}:${y}|(?::${u}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${u}:){1}(?:(?::${u}){0,4}:${y}|(?::${u}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${u}){0,5}:${y}|(?::${u}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),w=new RegExp(`(?:^${y}$)|(?:^${g}$)`),m=new RegExp(`^${y}$`),h=new RegExp(`^${g}$`),c=f=>f&&f.exact?w:new RegExp(`(?:${x(f)}${y}${x(f)})|(?:${x(f)}${g}${x(f)})`,"g");c.v4=f=>f&&f.exact?m:new RegExp(`${x(f)}${y}${x(f)}`,"g"),c.v6=f=>f&&f.exact?h:new RegExp(`${x(f)}${g}${x(f)}`,"g"),Q.exports=c},8399:function(Q){!function(K){"use strict";const x="(0?\\d+|0x[a-f0-9]+)",y={fourOctet:new RegExp(`^${x}\\.${x}\\.${x}\\.${x}$`,"i"),threeOctet:new RegExp(`^${x}\\.${x}\\.${x}$`,"i"),twoOctet:new RegExp(`^${x}\\.${x}$`,"i"),longValue:new RegExp(`^${x}$`,"i")},u=new RegExp("^0[0-7]+$","i"),g=new RegExp("^0x[a-f0-9]+$","i"),w="%[0-9a-z]{1,}",m="(?:[0-9a-f]+::?)+",h={zoneIndex:new RegExp(w,"i"),native:new RegExp(`^(::)?(${m})?([0-9a-f]+)?(::)?(${w})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${x}\\.${x}\\.${x}\\.${x}(${w})?)$`,"i"),transitional:new RegExp(`^((?:${m})|(?:::)(?:${m})?)${x}\\.${x}\\.${x}\\.${x}(${w})?$`,"i")};function c(E,v){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let P,D,p=0,I=-1,A=(E.match(h.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(I=E.indexOf(":",I+1))>=0;)p++;if("::"===E.substr(0,2)&&p--,"::"===E.substr(-2,2)&&p--,p>v)return null;for(D=v-p,P=":";D--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:v=function(){const T=E.split(":"),M=[];for(let k=0;k0;){if(P=p-I,P<0&&(P=0),E[A]>>P!=v[A]>>P)return!1;I-=p,A+=1}return!0}function d(E){if(g.test(E))return parseInt(E,16);if("0"===E[0]&&!isNaN(parseInt(E[1],10))){if(u.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function b(E,v){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in I))return null;if(D=I[P],p&&0!==D)return null;8!==D&&(p=!0),v+=D}return 32-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return S.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),S.IPv4.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.isIPv4=function(E){return null!==this.parser(E)},S.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},S.IPv4.isValidFourPartDecimal=function(E){return!(!S.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},S.IPv4.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<4;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.parse=function(E){const v=this.parser(E);if(null===v)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(v)},S.IPv4.parseCIDR=function(E){let v;if(v=E.match(/^(.+)\/(\d+)$/)){const p=parseInt(v[2]);if(p>=0&&p<=32){const I=[this.parse(v[1]),p];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},S.IPv4.parser=function(E){let v,p,I;if(v=E.match(y.fourOctet))return function(){const A=v.slice(1,6),P=[];for(let D=0;D4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(I>>P&255);return A}().reverse()}return(v=E.match(y.twoOctet))?function(){const A=v.slice(1,4),P=[];if(I=d(A[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(I>>16&255),P.push(I>>8&255),P.push(255&I),P}():(v=E.match(y.threeOctet))?function(){const A=v.slice(1,5),P=[];if(I=d(A[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(I>>8&255),P.push(255&I),P}():null},S.IPv4.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const v=[0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p=0;D-=1){if(A=this.parts[D],!(A in I))return null;if(P=I[A],p&&0!==P)return null;16!==P&&(p=!0),v+=P}return 128-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let v;const p=[],I=this.parts;for(let A=0;A>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const I=[];for(let A=0;A>8,255&p,I>>8,255&I])},E.prototype.toNormalizedString=function(){const v=function(){const I=[];for(let A=0;AA&&(I=P.index,A=P[0].length);return A<0?p:`${p.substring(0,I)}::${p.substring(I+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),S.IPv6.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},S.IPv6.isIPv6=function(E){return null!==this.parser(E)},S.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const v=this.parser(E);return new this(v.parts,v.zoneId),!0}catch{return!1}},S.IPv6.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<16;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch(D){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${D})`)}},S.IPv6.parse=function(E){const v=this.parser(E);if(null===v.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(v.parts,v.zoneId)},S.IPv6.parseCIDR=function(E){let v,p,I;if((p=E.match(/^(.+)\/(\d+)$/))&&(v=parseInt(p[2]),v>=0&&v<=128))return I=[this.parse(p[1]),v],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},S.IPv6.parser=function(E){let v,p,I,A,P,D;if(I=E.match(h.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(h.native.test(E))return c(E,8);if((I=E.match(h.transitional))&&(D=I[6]||"",v=c(I[1].slice(0,-1)+D,6),v.parts)){for(P=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],p=0;p128)throw new Error("ipaddr: invalid IPv6 prefix length");const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p{Q.exports=function K(){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}},9809:(Q,K,x)=>{"use strict";const y=x(8035),u=g=>y({exact:!0}).test(g);u.v4=g=>y.v4({exact:!0}).test(g),u.v6=g=>y.v6({exact:!0}).test(g),u.version=g=>u(g)?u.v4(g)?4:6:void 0,Q.exports=u},9023:Q=>{"use strict";Q.exports=K=>{if("[object Object]"!==Object.prototype.toString.call(K))return!1;const x=Object.getPrototypeOf(K);return null===x||x===Object.prototype}},9966:(Q,K,x)=>{"use strict";const{URLWithLegacySupport:y,format:u,URLSearchParams:g,defaultBase:w}=x(7630),m=x(5899);Q.exports={URL:y,URLSearchParams:g,format:u,relative:m,defaultBase:w}},5899:(Q,K,x)=>{"use strict";const{URLWithLegacySupport:y,format:u}=x(7630);Q.exports=(g,w={},m={},h)=>{let f,c=w.protocol?w.protocol.replace(":",""):"http";c=(m[c]||h||c)+":";try{f=new y(g)}catch{f={}}const d=Object.assign({},w,{protocol:c||f.protocol,host:w.host||f.host});return new y(g,u(d)).toString()}},7630:Q=>{"use strict";const K=typeof navigator<"u"&&"ReactNative"===navigator.product,y=self.URL,u=function x(){return K?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}();Q.exports={URLWithLegacySupport:class g{constructor(h="",c=u){this.super=new y(h,c),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(h){this.super.hash=h}set host(h){this.super.host=h}set hostname(h){this.super.hostname=h}set href(h){this.super.href=h}set password(h){this.super.password=h}set pathname(h){this.super.pathname=h}set port(h){this.super.port=h}set protocol(h){this.super.protocol=h}set search(h){this.super.search=h}set username(h){this.super.username=h}static createObjectURL(h){return y.createObjectURL(h)}static revokeObjectURL(h){y.revokeObjectURL(h)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:u,format:function w(m){if("string"==typeof m)return new y(m).toString();if(!(m instanceof y)){const c=m.auth?m.auth+"@":"",f=m.port?":"+m.port:"",S=m.hostname||"",E=m.search||(m.query?"?"+m.query:""),p=m.pathname||"";return`${m.protocol?m.protocol+"//":""}${(m.username&&m.password?`${m.username}:${m.password}@`:"")||c}${m.host||S+f}${m.path||p+E}${m.hash||""}`}}}},4773:(Q,K,x)=>{"use strict";var y=x(411).default,u=x(2508).default;Q.exports=function(){var w=y(function*(m){const h=[];var d,c=!1,f=!1;try{for(var S,b=u(m);c=!(S=yield b.next()).done;c=!1)h.push(S.value)}catch(E){f=!0,d=E}finally{try{c&&null!=b.return&&(yield b.return())}finally{if(f)throw d}}return h});return function(h){return w.apply(this,arguments)}}()},5671:(Q,K,x)=>{"use strict";var y=x(411).default,u=x(2508).default;Q.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var d=u(m);h=!(yield d.next()).done;h=!1);}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},9759:(Q,K,x)=>{"use strict";var y=x(2449).default,u=x(3683).default,g=x(2508).default;Q.exports=function(){var m=u(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;(yield y(c(v)))&&(yield v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},7420:(Q,K,x)=>{"use strict";var y=x(411).default,u=x(2508).default;Q.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var b,d=u(m);h=!(b=yield d.next()).done;h=!1)return b.value}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},3153:(Q,K,x)=>{"use strict";var y=x(2449).default,u=x(3683).default,g=x(2508).default;Q.exports=function(){var m=u(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield y(c(v)),yield v}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},9458:(Q,K,x)=>{"use strict";var y=x(2449).default,u=x(3683).default,g=x(2508).default;Q.exports=function(){var m=u(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield c(v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},901:(Q,K,x)=>{"use strict";var y=x(411).default,u=x(3683).default,g=x(2449).default,w=x(2508).default,m=x(4670).default;const h=x(6277);Q.exports=function(){var f=u(function*(...d){const b=h();setTimeout(y(function*(){try{yield Promise.all(d.map(function(){var S=y(function*(E){var I,v=!1,p=!1;try{for(var P,A=w(E);v=!(P=yield A.next()).done;v=!1)b.push(P.value)}catch(D){p=!0,I=D}finally{try{v&&null!=A.return&&(yield A.return())}finally{if(p)throw I}}});return function(E){return S.apply(this,arguments)}}())),b.end()}catch(S){b.end(S)}}),0),yield*m(w(b),g)});return function(){return f.apply(this,arguments)}}()},6277:(Q,K,x)=>{const y=x(8317);Q.exports=u=>{let g;"function"==typeof(u=u||{})?(g=u,u={}):g=u.onEnd;let m,h,c,w=new y;const d=A=>h?h(A):(w.push(A),m),S=A=>c?m:d({done:!1,value:A}),E=A=>c?m:(c=!0,A?(A=>(w=new y,h?h({error:A}):(w.push({error:A}),m)))(A):d({done:!0}));if(m={[Symbol.asyncIterator](){return this},next:()=>{if(!w.isEmpty()){if(u.writev){let P;const D=[];for(;!w.isEmpty();){if(P=w.shift(),P.error)throw P.error;D.push(P.value)}return{done:P.done,value:D}}const A=w.shift();if(A.error)throw A.error;return A}return c?{done:!0}:new Promise((A,P)=>{h=D=>(h=null,D.error?P(D.error):A(u.writev&&!D.done?{done:D.done,value:[D.value]}:D),m)})},return:()=>(w=new y,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:S,end:E},!g)return m;const I=m;return m={[Symbol.asyncIterator](){return this},next:()=>I.next(),throw:A=>(I.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(I.return(),g&&(g(),g=null),{done:!0}),push:S,end:A=>(I.end(A),g&&(g(A),g=null),m)},m}},7640:(Q,K,x)=>{"use strict";var y=x(3683).default,u=x(2449).default,g=x(2508).default,w=x(4670).default;const m=x(4773);Q.exports=function(){var c=y(function*(f,d){const b=yield u(m(f));yield*w(g(b.sort(d)),u)});return function(d,b){return c.apply(this,arguments)}}()},5478:(Q,K,x)=>{"use strict";var y=x(2449).default,u=x(3683).default,g=x(2508).default;Q.exports=function(){var m=u(function*(h,c){let f=0;if(!(c<1)){var S,d=!1,b=!1;try{for(var v,E=g(h);d=!(v=yield y(E.next())).done;d=!1)if(yield v.value,f++,f===c)return}catch(p){b=!0,S=p}finally{try{d&&null!=E.return&&(yield y(E.return()))}finally{if(b)throw S}}}});return function(c,f){return m.apply(this,arguments)}}()},8261:function(Q,K,x){"use strict";const y=x(9023),{hasOwnProperty:u}=Object.prototype,{propertyIsEnumerable:g}=Object,w=(p,I,A)=>Object.defineProperty(p,I,{value:A,writable:!0,enumerable:!0,configurable:!0}),m=this,h={concatArrays:!1,ignoreUndefined:!1},c=p=>{const I=[];for(const A in p)u.call(p,A)&&I.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(p);for(const P of A)g.call(p,P)&&I.push(P)}return I};function f(p){return Array.isArray(p)?function d(p){const I=p.slice(0,0);return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):y(p)?function b(p){const I=null===Object.getPrototypeOf(p)?Object.create(null):{};return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):p}const S=(p,I,A,P)=>(A.forEach(D=>{typeof I[D]>"u"&&P.ignoreUndefined||(D in p&&p[D]!==Object.getPrototypeOf(p)?w(p,D,v(p[D],I[D],P)):w(p,D,f(I[D])))}),p);function v(p,I,A){return A.concatArrays&&Array.isArray(p)&&Array.isArray(I)?((p,I,A)=>{let P=p.slice(0,0),D=0;return[p,I].forEach(T=>{const M=[];for(let k=0;k!M.includes(k)),A)}),P})(p,I,A):y(I)&&y(p)?S(p,I,c(I),A):f(I)}Q.exports=function(...p){const I=v(f(h),this!==m&&this||{},h);let A={_:{}};for(const P of p)if(void 0!==P){if(!y(P))throw new TypeError("`"+P+"` is not an Option Object");A=v(A,{_:P},I)}return A._}},4564:Q=>{var K=1e3,x=60*K,y=60*x,u=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Q.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*u;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*K;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=u?f(d,b,u,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=K?f(d,b,K,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=u?Math.round(d/u)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=K?Math.round(d/K)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},4948:Q=>{var K=1e3,x=60*K,y=60*x,u=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Q.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*u;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*K;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=u?f(d,b,u,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=K?f(d,b,K,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=u?Math.round(d/u)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=K?Math.round(d/K)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},6058:Q=>{"use strict";function K(x){if(Array.isArray(x)){for(var y=0,u=Array(x.length);y>>24,(f&255<<16)>>>16,(65280&f)>>>8,255&f].join(".")},h=function(f){var d,S,E,v,p;for(d=[],S=E=0;E<=3&&0!==f.length;S=++E){if(S>0){if("."!==f[0])throw new Error("Invalid IP");f=f.substring(1)}v=(p=y(f))[0],f=f.substring(p[1]),d.push(v)}if(0!==f.length)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},g=(u=function(f){return f.charCodeAt(0)})("0"),m=u("a"),w=u("A"),y=function(f){var d,b,S,E,v;for(E=0,d=10,b="9",S=0,f.length>1&&"0"===f[S]&&("x"===f[S+1]||"X"===f[S+1]?(S+=2,d=16):"0"<=f[S+1]&&f[S+1]<="9"&&(S++,d=8,b="7")),v=S;S>>0;else{if(16!==d)break;if("a"<=f[S]&&f[S]<="f")E=E*d+(10+u(f[S])-m)>>>0;else{if(!("A"<=f[S]&&f[S]<="F"))break;E=E*d+(10+u(f[S])-w)>>>0}}if(E>4294967295)throw new Error("too large");S++}if(S===v)throw new Error("empty octet");return[E,S]},x=function(){function f(d,b){var E,v,p;if("string"!=typeof d)throw new Error("Missing `net' parameter");if(b||(p=d.split("/",2),d=p[0],b=p[1]),b||(b=32),"string"==typeof b&&b.indexOf(".")>-1){try{this.maskLong=h(b)}catch(I){throw new Error("Invalid mask: "+b)}for(E=v=32;v>=0;E=--v)if(this.maskLong===4294967295<<32-E>>>0){this.bitmask=E;break}}else{if(!b&&0!==b)throw new Error("Invalid mask: empty");this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(h(d)&this.maskLong)>>>0}catch(I){throw new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=c(this.bitmask<=30?this.netLong+this.size-2:this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return f.prototype.contains=function(d){return"string"==typeof d&&(d.indexOf("/")>0||4!==d.split(".").length)&&(d=new f(d)),d instanceof f?this.contains(d.base)&&this.contains(d.broadcast||d.last):(h(d)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},f.prototype.next=function(d){return null==d&&(d=1),new f(c(this.netLong+this.size*d),this.mask)},f.prototype.forEach=function(d){var b,S,E;for(E=h(this.first),S=h(this.last),b=0;E<=S;)d(c(E),E,b),b++,E++},f.prototype.toString=function(){return this.base+"/"+this.bitmask},f}(),K.ip2long=h,K.long2ip=c,K.Netmask=x}).call(this)},3859:(Q,K,x)=>{var y=x(340);function u(p,I){y.cipher.registerAlgorithm(p,function(){return new y.aes.Algorithm(p,I)})}x(6168),x(5710),x(1558),Q.exports=y.aes=y.aes||{},y.aes.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P});return D.start(I),D},y.aes.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.aes.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P});return D.start(I),D},y.aes.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.aes.Algorithm=function(p,I){g||b();var A=this;A.name=p,A.mode=new I({blockSize:16,cipher:{encrypt:function(P,D){return E(A._w,P,D,!1)},decrypt:function(P,D){return E(A._w,P,D,!0)}}}),A._init=!1},y.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var A,I=p.key;if("string"!=typeof I||16!==I.length&&24!==I.length&&32!==I.length){if(y.util.isArray(I)&&(16===I.length||24===I.length||32===I.length)){A=I,I=y.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&k^99,h[k]=A,$=(F=p[k])<<24^k<<16^k<<8^k^F,C=((D=p[A])^(T=p[D])^(M=p[T]))<<24^(A^M)<<16^(A^T^M)<<8^A^D^M;for(var O=0;O<4;++O)f[O][A]=$,d[O][k]=C,$=$<<24|$>>>8,C=C<<24|C>>>8;0===A?A=P=1:(A=D^p[p[p[D^M]]],P^=p[p[P]])}}function S(p,I){for(var P,A=p.slice(0),D=1,T=A.length,k=4*(T+6+1),F=T;F>>16&255]<<24^m[P>>>8&255]<<16^m[255&P]<<8^m[P>>>24]^c[D]<<24,D++):T>6&&F%T==4&&(P=m[P>>>24]<<24^m[P>>>16&255]<<16^m[P>>>8&255]<<8^m[255&P]),A[F]=A[F-T]^P;if(I){for(var $,C=d[0],O=d[1],U=d[2],L=d[3],H=A.slice(0),ne=(F=0,(k=A.length)-4);F>>24]]^O[m[$>>>16&255]]^U[m[$>>>8&255]]^L[m[255&$]];A=H}return A}function E(p,I,A,P){var T,M,k,F,$,C,O,U,L,H,ne,G,D=p.length/4-1;P?(T=d[0],M=d[1],k=d[2],F=d[3],$=h):(T=f[0],M=f[1],k=f[2],F=f[3],$=m),C=I[0]^p[0],O=I[P?3:1]^p[1],U=I[2]^p[2],L=I[P?1:3]^p[3];for(var ee=3,Z=1;Z>>24]^M[O>>>16&255]^k[U>>>8&255]^F[255&L]^p[++ee],ne=T[O>>>24]^M[U>>>16&255]^k[L>>>8&255]^F[255&C]^p[++ee],G=T[U>>>24]^M[L>>>16&255]^k[C>>>8&255]^F[255&O]^p[++ee],L=T[L>>>24]^M[C>>>16&255]^k[O>>>8&255]^F[255&U]^p[++ee],C=H,O=ne,U=G;A[0]=$[C>>>24]<<24^$[O>>>16&255]<<16^$[U>>>8&255]<<8^$[255&L]^p[++ee],A[P?3:1]=$[O>>>24]<<24^$[U>>>16&255]<<16^$[L>>>8&255]<<8^$[255&C]^p[++ee],A[2]=$[U>>>24]<<24^$[L>>>16&255]<<16^$[C>>>8&255]<<8^$[255&O]^p[++ee],A[P?1:3]=$[L>>>24]<<24^$[C>>>16&255]<<16^$[O>>>8&255]<<8^$[255&U]^p[++ee]}function v(p){var P,A="AES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},607:(Q,K,x)=>{var y=x(340);x(1558),x(6169);var u=Q.exports=y.asn1=y.asn1||{};function g(c,f,d){if(d>f){var b=new Error("Too few bytes to parse DER.");throw b.available=c.length(),b.remaining=f,b.requested=d,b}}function m(c,f,d,b){var S;g(c,f,2);var E=c.getByte();f--;var v=192&E,p=31&E;S=c.length();var I=function(c,f){var d=c.getByte();if(f--,128!==d){var b;if(128&d){var E=127&d;g(c,f,E),b=c.getInt(E<<3)}else b=d;if(b<0)throw new Error("Negative length: "+b);return b}}(c,f);if(f-=S-c.length(),void 0!==I&&I>f){if(b.strict){var A=new Error("Too few bytes to read ASN.1 value.");throw A.available=c.length(),A.remaining=f,A.requested=I,A}I=f}var P,D,T=32==(32&E);if(T)if(P=[],void 0===I)for(;;){if(g(c,f,2),c.bytes(2)===String.fromCharCode(0,0)){c.getBytes(2),f-=2;break}S=c.length(),P.push(m(c,f,d+1,b)),f-=S-c.length()}else for(;I>0;)S=c.length(),P.push(m(c,I,d+1,b)),f-=S-c.length(),I-=S-c.length();if(void 0===P&&v===u.Class.UNIVERSAL&&p===u.Type.BITSTRING&&(D=c.bytes(I)),void 0===P&&b.decodeBitStrings&&v===u.Class.UNIVERSAL&&p===u.Type.BITSTRING&&I>1){var M=c.read,k=f,F=0;if(p===u.Type.BITSTRING&&(g(c,f,1),F=c.getByte(),f--),0===F)try{S=c.length();var C=m(c,f,d+1,{strict:!0,decodeBitStrings:!0}),O=S-c.length();f-=O,p==u.Type.BITSTRING&&O++;var U=C.tagClass;O===I&&(U===u.Class.UNIVERSAL||U===u.Class.CONTEXT_SPECIFIC)&&(P=[C])}catch{}void 0===P&&(c.read=M,f=k)}if(void 0===P){if(void 0===I){if(b.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");I=f}if(p===u.Type.BMPSTRING)for(P="";I>0;I-=2)g(c,f,2),P+=String.fromCharCode(c.getInt16()),f-=2;else P=c.getBytes(I),f-=I}return u.create(v,p,T,P,void 0===D?null:{bitStringContents:D})}u.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},u.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},u.create=function(c,f,d,b,S){if(y.util.isArray(b)){for(var E=[],v=0;v1&&(0===c.value.charCodeAt(0)&&0==(128&c.value.charCodeAt(1))||255===c.value.charCodeAt(0)&&128==(128&c.value.charCodeAt(1)))?b.putBytes(c.value.substr(1)):b.putBytes(c.value);if(f.putByte(d),b.length()<=127)f.putByte(127&b.length());else{var v=b.length(),p="";do{p+=String.fromCharCode(255&v),v>>>=8}while(v>0);for(f.putByte(128|p.length),E=p.length-1;E>=0;--E)f.putByte(p.charCodeAt(E))}return f.putBuffer(b),f},u.oidToDer=function(c){var f=c.split("."),d=y.util.createBuffer();d.putByte(40*parseInt(f[0],10)+parseInt(f[1],10));for(var b,S,E,v,p=2;p>>=7,b||(v|=128),S.push(v),b=!1}while(E>0);for(var I=S.length-1;I>=0;--I)d.putByte(S[I])}return d},u.derToOid=function(c){var f;"string"==typeof c&&(c=y.util.createBuffer(c));var d=c.getByte();f=Math.floor(d/40)+"."+d%40;for(var b=0;c.length()>0;)b<<=7,128&(d=c.getByte())?b+=127&d:(f+="."+(b+d),b=0);return f},u.utcTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,2),10);d=d>=50?1900+d:2e3+d;var b=parseInt(c.substr(2,2),10)-1,S=parseInt(c.substr(4,2),10),E=parseInt(c.substr(6,2),10),v=parseInt(c.substr(8,2),10),p=0;if(c.length>11){var I=c.charAt(10),A=10;"+"!==I&&"-"!==I&&(p=parseInt(c.substr(10,2),10),A+=2)}if(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,0),A&&("+"===(I=c.charAt(A))||"-"===I)){var T=60*parseInt(c.substr(A+1,2),10)+parseInt(c.substr(A+4,2),10);T*=6e4,f.setTime("+"===I?+f-T:+f+T)}return f},u.generalizedTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,4),10),b=parseInt(c.substr(4,2),10)-1,S=parseInt(c.substr(6,2),10),E=parseInt(c.substr(8,2),10),v=parseInt(c.substr(10,2),10),p=parseInt(c.substr(12,2),10),I=0,A=0,P=!1;"Z"===c.charAt(c.length-1)&&(P=!0);var D=c.length-5,T=c.charAt(D);return"+"!==T&&"-"!==T||(A=60*parseInt(c.substr(D+1,2),10)+parseInt(c.substr(D+4,2),10),A*=6e4,"+"===T&&(A*=-1),P=!0),"."===c.charAt(14)&&(I=1e3*parseFloat(c.substr(14),10)),P?(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,I),f.setTime(+f+A)):(f.setFullYear(d,b,S),f.setHours(E,v,p,I)),f},u.dateToUtcTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push((""+c.getUTCFullYear()).substr(2)),d.push(""+(c.getUTCMonth()+1)),d.push(""+c.getUTCDate()),d.push(""+c.getUTCHours()),d.push(""+c.getUTCMinutes()),d.push(""+c.getUTCSeconds());for(var b=0;b=-128&&c<128)return f.putSignedInt(c,8);if(c>=-32768&&c<32768)return f.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return f.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return f.putSignedInt(c,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=c,d},u.derToInteger=function(c){"string"==typeof c&&(c=y.util.createBuffer(c));var f=8*c.length();if(f>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(f)},u.validate=function(c,f,d,b){var S=!1;if((c.tagClass===f.tagClass||typeof f.tagClass>"u")&&(c.type===f.type||typeof f.type>"u"))if(c.constructed===f.constructed||typeof f.constructed>"u"){if(S=!0,f.value&&y.util.isArray(f.value))for(var E=0,v=0;S&&v0&&(b+="\n");for(var S="",E=0;E1?"0x"+y.util.bytesToHex(c.value.slice(1)):"(none)",c.value.length>0){var A=c.value.charCodeAt(0);1==A?b+=" (1 unused bit shown)":A>1&&(b+=" ("+A+" unused bits shown)")}}else if(c.type===u.Type.OCTETSTRING)h.test(c.value)||(b+="("+c.value+") "),b+="0x"+y.util.bytesToHex(c.value);else if(c.type===u.Type.UTF8)try{b+=y.util.decodeUtf8(c.value)}catch(P){if("URI malformed"!==P.message)throw P;b+="0x"+y.util.bytesToHex(c.value)+" (malformed UTF8)"}else c.type===u.Type.PRINTABLESTRING||c.type===u.Type.IA5String?b+=c.value:h.test(c.value)?b+="0x"+y.util.bytesToHex(c.value):b+=0===c.value.length?"[null]":c.value}return b}},9391:Q=>{var K={};Q.exports=K;var x={};K.encode=function(u,g,w){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==w&&"number"!=typeof w)throw new TypeError('"maxline" must be a number.');var m="";if(u instanceof Uint8Array){var h=0,c=g.length,f=g.charAt(0),d=[0];for(h=0;h0;)d.push(S%c),S=S/c|0}for(h=0;0===u[h]&&h=0;--h)m+=g[d[h]]}else m=function y(u,g){var w=0,m=g.length,h=g.charAt(0),c=[0];for(w=0;w0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===u.at(w)&&w=0;--w)b+=g[c[w]];return b}(u,g);if(w){var E=new RegExp(".{1,"+w+"}","g");m=m.match(E).join("\r\n")}return m},K.decode=function(u,g){if("string"!=typeof u)throw new TypeError('"input" must be a string.');if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');var w=x[g];if(!w){w=x[g]=[];for(var m=0;m>=8;for(;S>0;)f.push(255&S),S>>=8}for(var E=0;u[E]===c&&E{var y=x(340);x(1558),Q.exports=y.cipher=y.cipher||{},y.cipher.algorithms=y.cipher.algorithms||{},y.cipher.createCipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!1})},y.cipher.createDecipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!0})},y.cipher.registerAlgorithm=function(g,w){g=g.toUpperCase(),y.cipher.algorithms[g]=w},y.cipher.getAlgorithm=function(g){return(g=g.toUpperCase())in y.cipher.algorithms?y.cipher.algorithms[g]:null};var u=y.cipher.BlockCipher=function(g){this.algorithm=g.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=g.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=g.decrypt,this.algorithm.initialize(g)};u.prototype.start=function(g){g=g||{};var w={};for(var m in g)w[m]=g[m];w.decrypt=this._decrypt,this._finish=!1,this._input=y.util.createBuffer(),this.output=g.output||y.util.createBuffer(),this.mode.start(w)},u.prototype.update=function(g){for(g&&this._input.putBuffer(g);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},u.prototype.finish=function(g){g&&("ECB"===this.mode.name||"CBC"===this.mode.name)&&(this.mode.pad=function(m){return g(this.blockSize,m,!1)},this.mode.unpad=function(m){return g(this.blockSize,m,!0)});var w={};return w.decrypt=this._decrypt,w.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,w)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,w))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,w))}},5710:(Q,K,x)=>{var y=x(340);x(1558),y.cipher=y.cipher||{};var u=Q.exports=y.cipher.modes=y.cipher.modes||{};function g(h,c){if("string"==typeof h&&(h=y.util.createBuffer(h)),y.util.isArray(h)&&h.length>4){var f=h;h=y.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},u.cbc=function(h){h=h||{},this.name="CBC",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},u.cbc.prototype.start=function(h){if(null===h.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._prev=this._iv.slice(0)}},u.cbc.prototype.encrypt=function(h,c,f){if(h.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},u.cfb=function(h){h=h||{},this.name="CFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.cfb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.cfb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.cfb.prototype.decrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb=function(h){h=h||{},this.name="OFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.ofb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ofb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===h.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb.prototype.decrypt=u.ofb.prototype.encrypt,u.ctr=function(h){h=h||{},this.name="CTR",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.ctr.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ctr.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&(h.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}w(this._inBlock)},u.ctr.prototype.decrypt=u.ctr.prototype.encrypt,u.gcm=function(h){h=h||{},this.name="GCM",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0,this._R=3774873600},u.gcm.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");var f,c=y.util.createBuffer(h.iv);if(this._cipherLength=0,f="additionalData"in h?y.util.createBuffer(h.additionalData):y.util.createBuffer(),this._tagLength="tagLength"in h?h.tagLength:128,this._tag=null,h.decrypt&&(this._tag=y.util.createBuffer(h.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var d=c.length();if(12===d)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(m(8*d)))}this._inBlock=this._j0.slice(0),w(this._inBlock),this._partialBytes=0,f=y.util.createBuffer(f),this._aDataLength=m(8*f.length());var b=f.length()%this.blockSize;for(b&&f.fillWithByte(0,this.blockSize-b),this._s=[0,0,0,0];f.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()])},u.gcm.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return h.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),w(this._inBlock)},u.gcm.prototype.decrypt=function(h,c,f){var d=h.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),w(this._inBlock),this._hashBlock[0]=h.getInt32(),this._hashBlock[1]=h.getInt32(),this._hashBlock[2]=h.getInt32(),this._hashBlock[3]=h.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var b=0;b0;--d)c[d]=h[d]>>>1|(1&h[d-1])<<31;c[0]=h[0]>>>1,f&&(c[0]^=this._R)},u.gcm.prototype.tableMultiply=function(h){for(var c=[0,0,0,0],f=0;f<32;++f){var S=this._m[f][h[f/8|0]>>>4*(7-f%8)&15];c[0]^=S[0],c[1]^=S[1],c[2]^=S[2],c[3]^=S[3]}return c},u.gcm.prototype.ghash=function(h,c,f){return c[0]^=f[0],c[1]^=f[1],c[2]^=f[2],c[3]^=f[3],this.tableMultiply(c)},u.gcm.prototype.generateHashTable=function(h,c){for(var f=8/c,d=4*f,b=16*f,S=new Array(b),E=0;E>>1,b=new Array(f);b[d]=h.slice(0);for(var S=d>>>1;S>0;)this.pow(b[2*S],b[S]=[]),S>>=1;for(S=2;S{var y=x(340);function u(p,I){y.cipher.registerAlgorithm(p,function(){return new y.des.Algorithm(p,I)})}x(6168),x(5710),x(1558),Q.exports=y.des=y.des||{},y.des.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.des.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.des.Algorithm=function(p,I){var A=this;A.name=p,A.mode=new I({blockSize:8,cipher:{encrypt:function(P,D){return E(A._keys,P,D,!1)},decrypt:function(P,D){return E(A._keys,P,D,!0)}}}),A._init=!1},y.des.Algorithm.prototype.initialize=function(p){if(!this._init){var I=y.util.createBuffer(p.key);if(0===this.name.indexOf("3DES")&&24!==I.length())throw new Error("Invalid Triple-DES key size: "+8*I.length());this._keys=function S(p){for(var W,I=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],A=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],P=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],D=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],T=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],M=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],k=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],F=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],$=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],C=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],O=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],U=[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],H=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],ne=p.length()>8?3:1,G=[],ee=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],Z=0,te=0;te>>4^de))<<4,oe^=W=65535&((de^=W)>>>-16^oe),oe^=(W=858993459&(oe>>>2^(de^=W<<-16)))<<2,oe^=W=65535&((de^=W)>>>-16^oe),oe^=(W=1431655765&(oe>>>1^(de^=W<<-16)))<<1,oe^=W=16711935&((de^=W)>>>8^oe),W=(oe^=(W=1431655765&(oe>>>1^(de^=W<<8)))<<1)<<8|(de^=W)>>>20&240,oe=de<<24|de<<8&16711680|de>>>8&65280|de>>>24&240,de=W;for(var he=0;he>>26,de=de<<2|de>>>26):(oe=oe<<1|oe>>>27,de=de<<1|de>>>27);var Pe=I[(oe&=-15)>>>28]|A[oe>>>24&15]|P[oe>>>20&15]|D[oe>>>16&15]|T[oe>>>12&15]|M[oe>>>8&15]|k[oe>>>4&15],De=F[(de&=-15)>>>28]|$[de>>>24&15]|C[de>>>20&15]|O[de>>>16&15]|U[de>>>12&15]|L[de>>>8&15]|H[de>>>4&15];G[Z++]=Pe^(W=65535&(De>>>16^Pe)),G[Z++]=De^W<<16}}return G}(I),this._init=!0}},u("DES-ECB",y.cipher.modes.ecb),u("DES-CBC",y.cipher.modes.cbc),u("DES-CFB",y.cipher.modes.cfb),u("DES-OFB",y.cipher.modes.ofb),u("DES-CTR",y.cipher.modes.ctr),u("3DES-ECB",y.cipher.modes.ecb),u("3DES-CBC",y.cipher.modes.cbc),u("3DES-CFB",y.cipher.modes.cfb),u("3DES-OFB",y.cipher.modes.ofb),u("3DES-CTR",y.cipher.modes.ctr);var g=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],w=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],m=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],h=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],d=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],b=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function E(p,I,A,P){var T,D=32===p.length?3:9;T=3===D?P?[30,-2,-2]:[0,32,2]:P?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var M,k=I[0],F=I[1];k^=(M=252645135&(k>>>4^F))<<4,k^=(M=65535&(k>>>16^(F^=M)))<<16,k^=M=858993459&((F^=M)>>>2^k),k^=M=16711935&((F^=M<<2)>>>8^k),k=(k^=(M=1431655765&(k>>>1^(F^=M<<8)))<<1)<<1|k>>>31,F=(F^=M)<<1|F>>>31;for(var $=0;$>>4|F<<28)^p[U+1];M=k,k=F,F=M^(w[L>>>24&63]|h[L>>>16&63]|f[L>>>8&63]|b[63&L]|g[H>>>24&63]|m[H>>>16&63]|c[H>>>8&63]|d[63&H])}M=k,k=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((k=k>>>1|k<<31)>>>1^F),F^=(M=16711935&(F>>>8^(k^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(k^=M)))<<2,F^=M=65535&((k^=M)>>>16^F),F^=M=252645135&((k^=M<<16)>>>4^F),A[0]=k^=M<<4,A[1]=F}function v(p){var P,A="DES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},340:Q=>{Q.exports={options:{usePureJavaScript:!1}}},8828:(Q,K,x)=>{var y=x(340);x(1877),x(1558),(Q.exports=y.hmac=y.hmac||{}).create=function(){var g=null,w=null,m=null,h=null,c={start:function(f,d){if(null!==f)if("string"==typeof f){if(!((f=f.toLowerCase())in y.md.algorithms))throw new Error('Unknown hash algorithm "'+f+'"');w=y.md.algorithms[f].create()}else w=f;if(null===d)d=g;else{if("string"==typeof d)d=y.util.createBuffer(d);else if(y.util.isArray(d)){var b=d;d=y.util.createBuffer();for(var S=0;Sw.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),S=0;S{var u,y=x(340);function m(z,q,J){this.data=[],null!=z&&("number"==typeof z?this.fromNumber(z,q,J):this.fromString(z,null==q&&"string"!=typeof z?256:q))}function h(){return new m(null)}function d(z,q,J,ue,Re,Oe){for(var We=16383&q,$e=q>>14;--Oe>=0;){var Zt=16383&this.data[z],fr=this.data[z++]>>14,ci=$e*Zt+fr*We;Re=((Zt=We*Zt+((16383&ci)<<14)+J.data[ue]+Re)>>28)+(ci>>14)+$e*fr,J.data[ue++]=268435455&Zt}return Re}Q.exports=y.jsbn=y.jsbn||{},y.jsbn.BigInteger=m,typeof navigator>"u"?(m.prototype.am=d,u=28):"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function f(z,q,J,ue,Re,Oe){for(var We=32767&q,$e=q>>15;--Oe>=0;){var Zt=32767&this.data[z],fr=this.data[z++]>>15,ci=$e*Zt+fr*We;Re=((Zt=We*Zt+((32767&ci)<<15)+J.data[ue]+(1073741823&Re))>>>30)+(ci>>>15)+$e*fr+(Re>>>30),J.data[ue++]=1073741823&Zt}return Re},u=30):"Netscape"!=navigator.appName?(m.prototype.am=function c(z,q,J,ue,Re,Oe){for(;--Oe>=0;){var We=q*this.data[z++]+J.data[ue]+Re;Re=Math.floor(We/67108864),J.data[ue++]=67108863&We}return Re},u=26):(m.prototype.am=d,u=28),m.prototype.DB=u,m.prototype.DM=(1<>>16)&&(z=J,q+=16),0!=(J=z>>8)&&(z=J,q+=8),0!=(J=z>>4)&&(z=J,q+=4),0!=(J=z>>2)&&(z=J,q+=2),0!=(J=z>>1)&&(z=J,q+=1),q}function he(z){this.m=z}function nt(z){this.m=z,this.mp=z.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,q+=16),0==(255&z)&&(z>>=8,q+=8),0==(15&z)&&(z>>=4,q+=4),0==(3&z)&&(z>>=2,q+=2),0==(1&z)&&++q,q}function un(z){for(var q=0;0!=z;)z&=z-1,++q;return q}function me(){}function lt(z){return z}function Ke(z){this.r2=h(),this.q3=h(),m.ONE.dlShiftTo(2*z.t,this.r2),this.mu=this.r2.divide(z),this.m=z}he.prototype.convert=function Pe(z){return z.s<0||z.compareTo(this.m)>=0?z.mod(this.m):z},he.prototype.revert=function De(z){return z},he.prototype.reduce=function Be(z){z.divRemTo(this.m,null,z)},he.prototype.mulTo=function ve(z,q,J){z.multiplyTo(q,J),this.reduce(J)},he.prototype.sqrTo=function He(z,q){z.squareTo(q),this.reduce(q)},nt.prototype.convert=function Pt(z){var q=h();return z.abs().dlShiftTo(this.m.t,q),q.divRemTo(this.m,null,q),z.s<0&&q.compareTo(m.ZERO)>0&&this.m.subTo(q,q),q},nt.prototype.revert=function _t(z){var q=h();return z.copyTo(q),this.reduce(q),q},nt.prototype.reduce=function Vt(z){for(;z.t<=this.mt2;)z.data[z.t++]=0;for(var q=0;q>15)*this.mpl&this.um)<<15)&z.DM;for(z.data[J=q+this.m.t]+=this.m.am(0,ue,z,q,0,this.m.t);z.data[J]>=z.DV;)z.data[J]-=z.DV,z.data[++J]++}z.clamp(),z.drShiftTo(this.m.t,z),z.compareTo(this.m)>=0&&z.subTo(this.m,z)},nt.prototype.mulTo=function nn(z,q,J){z.multiplyTo(q,J),this.reduce(J)},nt.prototype.sqrTo=function Yt(z,q){z.squareTo(q),this.reduce(q)},m.prototype.copyTo=function P(z){for(var q=this.t-1;q>=0;--q)z.data[q]=this.data[q];z.t=this.t,z.s=this.s},m.prototype.fromInt=function D(z){this.t=1,this.s=z<0?-1:0,z>0?this.data[0]=z:z<-1?this.data[0]=z+this.DV:this.t=0},m.prototype.fromString=function M(z,q){var J;if(16==q)J=4;else if(8==q)J=3;else if(256==q)J=8;else if(2==q)J=1;else if(32==q)J=5;else{if(4!=q)return void this.fromRadix(z,q);J=2}this.t=0,this.s=0;for(var ue=z.length,Re=!1,Oe=0;--ue>=0;){var We=8==J?255&z[ue]:A(z,ue);We<0?"-"==z.charAt(ue)&&(Re=!0):(Re=!1,0==Oe?this.data[this.t++]=We:Oe+J>this.DB?(this.data[this.t-1]|=(We&(1<>this.DB-Oe):this.data[this.t-1]|=We<=this.DB&&(Oe-=this.DB))}8==J&&0!=(128&z[0])&&(this.s=-1,Oe>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==z;)--this.t},m.prototype.dlShiftTo=function H(z,q){var J;for(J=this.t-1;J>=0;--J)q.data[J+z]=this.data[J];for(J=z-1;J>=0;--J)q.data[J]=0;q.t=this.t+z,q.s=this.s},m.prototype.drShiftTo=function ne(z,q){for(var J=z;J=0;--$e)q.data[$e+Oe+1]=this.data[$e]>>ue|We,We=(this.data[$e]&Re)<=0;--$e)q.data[$e]=0;q.data[Oe]=We,q.t=this.t+Oe+1,q.s=this.s,q.clamp()},m.prototype.rShiftTo=function ee(z,q){q.s=this.s;var J=Math.floor(z/this.DB);if(J>=this.t)q.t=0;else{var ue=z%this.DB,Re=this.DB-ue,Oe=(1<>ue;for(var We=J+1;We>ue;ue>0&&(q.data[this.t-J-1]|=(this.s&Oe)<>=this.DB;if(z.t>=this.DB;ue+=this.s}else{for(ue+=this.s;J>=this.DB;ue-=z.s}q.s=ue<0?-1:0,ue<-1?q.data[J++]=this.DV+ue:ue>0&&(q.data[J++]=ue),q.t=J,q.clamp()},m.prototype.multiplyTo=function W(z,q){var J=this.abs(),ue=z.abs(),Re=J.t;for(q.t=Re+ue.t;--Re>=0;)q.data[Re]=0;for(Re=0;Re=0;)z.data[J]=0;for(J=0;J=q.DV&&(z.data[J+q.t]-=q.DV,z.data[J+q.t+1]=1)}z.t>0&&(z.data[z.t-1]+=q.am(J,q.data[J],z,2*J,0,1)),z.s=0,z.clamp()},m.prototype.divRemTo=function oe(z,q,J){var ue=z.abs();if(!(ue.t<=0)){var Re=this.abs();if(Re.t0?(ue.lShiftTo(Zt,Oe),Re.lShiftTo(Zt,J)):(ue.copyTo(Oe),Re.copyTo(J));var fr=Oe.t,ci=Oe.data[fr-1];if(0!=ci){var Yr=ci*(1<1?Oe.data[fr-2]>>this.F2:0),ns=this.FV/Yr,_o=(1<=0&&(J.data[J.t++]=1,J.subTo(ki,J)),m.ONE.dlShiftTo(fr,ki),ki.subTo(Oe,Oe);Oe.t=0;){var pu=J.data[--Zr]==ci?this.DM:Math.floor(J.data[Zr]*ns+(J.data[Zr-1]+Gt)*_o);if((J.data[Zr]+=Oe.am(0,pu,J,dn,0,fr))0&&J.rShiftTo(Zt,J),We<0&&m.ZERO.subTo(J,J)}}},m.prototype.invDigit=function ke(){if(this.t<1)return 0;var z=this.data[0];if(0==(1&z))return 0;var q=3&z;return(q=(q=(q=(q=q*(2-(15&z)*q)&15)*(2-(255&z)*q)&255)*(2-((65535&z)*q&65535))&65535)*(2-z*q%this.DV)%this.DV)>0?this.DV-q:-q},m.prototype.isEven=function cn(){return 0==(this.t>0?1&this.data[0]:this.s)},m.prototype.exp=function $n(z,q){if(z>4294967295||z<1)return m.ONE;var J=h(),ue=h(),Re=q.convert(this),Oe=U(z)-1;for(Re.copyTo(J);--Oe>=0;)if(q.sqrTo(J,ue),(z&1<0)q.mulTo(ue,Re,J);else{var We=J;J=ue,ue=We}return q.revert(J)},m.prototype.toString=function F(z){if(this.s<0)return"-"+this.negate().toString(z);var q;if(16==z)q=4;else if(8==z)q=3;else if(2==z)q=1;else if(32==z)q=5;else{if(4!=z)return this.toRadix(z);q=2}var ue,J=(1<0)for($e>$e)>0&&(Re=!0,Oe=I(ue));We>=0;)$e>($e+=this.DB-q)):(ue=this.data[We]>>($e-=q)&J,$e<=0&&($e+=this.DB,--We)),ue>0&&(Re=!0),Re&&(Oe+=I(ue));return Re?Oe:"0"},m.prototype.negate=function $(){var z=h();return m.ZERO.subTo(this,z),z},m.prototype.abs=function C(){return this.s<0?this.negate():this},m.prototype.compareTo=function O(z){var q=this.s-z.s;if(0!=q)return q;var J=this.t;if(0!=(q=J-z.t))return this.s<0?-q:q;for(;--J>=0;)if(0!=(q=this.data[J]-z.data[J]))return q;return 0},m.prototype.bitLength=function L(){return this.t<=0?0:this.DB*(this.t-1)+U(this.data[this.t-1]^this.s&this.DM)},m.prototype.mod=function de(z){var q=h();return this.abs().divRemTo(z,null,q),this.s<0&&q.compareTo(m.ZERO)>0&&z.subTo(q,q),q},m.prototype.modPowInt=function Tr(z,q){var J;return J=z<256||q.isEven()?new he(q):new nt(q),this.exp(z,J)},m.ZERO=T(0),m.ONE=T(1),me.prototype.convert=lt,me.prototype.revert=lt,me.prototype.mulTo=function Dt(z,q,J){z.multiplyTo(q,J)},me.prototype.sqrTo=function An(z,q){z.squareTo(q)},Ke.prototype.convert=function ct(z){if(z.s<0||z.t>2*this.m.t)return z.mod(this.m);if(z.compareTo(this.m)<0)return z;var q=h();return z.copyTo(q),this.reduce(q),q},Ke.prototype.revert=function ht(z){return z},Ke.prototype.reduce=function it(z){for(z.drShiftTo(this.m.t-1,this.r2),z.t>this.m.t+1&&(z.t=this.m.t+1,z.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);z.compareTo(this.r2)<0;)z.dAddOffset(1,this.m.t+1);for(z.subTo(this.r2,z);z.compareTo(this.m)>=0;)z.subTo(this.m,z)},Ke.prototype.mulTo=function Mt(z,q,J){z.multiplyTo(q,J),this.reduce(J)},Ke.prototype.sqrTo=function pt(z,q){z.squareTo(q),this.reduce(q)};var qn=[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],ia=(1<<26)/qn[qn.length-1];m.prototype.chunkSize=function re(z){return Math.floor(Math.LN2*this.DB/Math.log(z))},m.prototype.toRadix=function ge(z){if(null==z&&(z=10),0==this.signum()||z<2||z>36)return"0";var q=this.chunkSize(z),J=Math.pow(z,q),ue=T(J),Re=h(),Oe=h(),We="";for(this.divRemTo(ue,Re,Oe);Re.signum()>0;)We=(J+Oe.intValue()).toString(z).substr(1)+We,Re.divRemTo(ue,Re,Oe);return Oe.intValue().toString(z)+We},m.prototype.fromRadix=function ye(z,q){this.fromInt(0),null==q&&(q=10);for(var J=this.chunkSize(q),ue=Math.pow(q,J),Re=!1,Oe=0,We=0,$e=0;$e=J&&(this.dMultiply(ue),this.dAddOffset(We,0),Oe=0,We=0))}Oe>0&&(this.dMultiply(Math.pow(q,Oe)),this.dAddOffset(We,0)),Re&&m.ZERO.subTo(this,this)},m.prototype.fromNumber=function be(z,q,J){if("number"==typeof q)if(z<2)this.fromInt(1);else for(this.fromNumber(z,J),this.testBit(z-1)||this.bitwiseTo(m.ONE.shiftLeft(z-1),pe,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(q);)this.dAddOffset(2,0),this.bitLength()>z&&this.subTo(m.ONE.shiftLeft(z-1),this);else{var ue=new Array,Re=7&z;ue.length=1+(z>>3),q.nextBytes(ue),Re>0?ue[0]&=(1<>=this.DB;if(z.t>=this.DB;ue+=this.s}else{for(ue+=this.s;J>=this.DB;ue+=z.s}q.s=ue<0?-1:0,ue>0?q.data[J++]=ue:ue<-1&&(q.data[J++]=this.DV+ue),q.t=J,q.clamp()},m.prototype.dMultiply=function rt(z){this.data[this.t]=this.am(0,z-1,this,0,0,this.t),++this.t,this.clamp()},m.prototype.dAddOffset=function ce(z,q){if(0!=z){for(;this.t<=q;)this.data[this.t++]=0;for(this.data[q]+=z;this.data[q]>=this.DV;)this.data[q]-=this.DV,++q>=this.t&&(this.data[this.t++]=0),++this.data[q]}},m.prototype.multiplyLowerTo=function Ge(z,q,J){var Re,ue=Math.min(this.t+z.t,q);for(J.s=0,J.t=ue;ue>0;)J.data[--ue]=0;for(Re=J.t-this.t;ue=0;)J.data[ue]=0;for(ue=Math.max(q-this.t,0);ue0)if(0==q)J=this.data[0]%z;else for(var ue=this.t-1;ue>=0;--ue)J=(q*J+this.data[ue])%z;return J},m.prototype.millerRabin=function Jl(z){var q=this.subtract(m.ONE),J=q.getLowestSetBit();if(J<=0)return!1;for(var Oe,ue=q.shiftRight(J),Re=function sa(){return{nextBytes:function(z){for(var q=0;q=0);var $e=Oe.modPow(ue,this);if(0!=$e.compareTo(m.ONE)&&0!=$e.compareTo(q)){for(var Zt=1;Zt++>24},m.prototype.shortValue=function es(){return 0==this.t?this.s:this.data[0]<<16>>16},m.prototype.signum=function le(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},m.prototype.toByteArray=function xe(){var z=this.t,q=new Array;q[0]=this.s;var ue,J=this.DB-z*this.DB%8,Re=0;if(z-- >0)for(J>J)!=(this.s&this.DM)>>J&&(q[Re++]=ue|this.s<=0;)J<8?(ue=(this.data[z]&(1<>(J+=this.DB-8)):(ue=this.data[z]>>(J-=8)&255,J<=0&&(J+=this.DB,--z)),0!=(128&ue)&&(ue|=-256),0==Re&&(128&this.s)!=(128&ue)&&++Re,(Re>0||ue!=this.s)&&(q[Re++]=ue);return q},m.prototype.equals=function ze(z){return 0==this.compareTo(z)},m.prototype.min=function je(z){return this.compareTo(z)<0?this:z},m.prototype.max=function Je(z){return this.compareTo(z)>0?this:z},m.prototype.and=function Ee(z){var q=h();return this.bitwiseTo(z,Ue,q),q},m.prototype.or=function _e(z){var q=h();return this.bitwiseTo(z,pe,q),q},m.prototype.xor=function Ne(z){var q=h();return this.bitwiseTo(z,Le,q),q},m.prototype.andNot=function Nt(z){var q=h();return this.bitwiseTo(z,at,q),q},m.prototype.not=function ft(){for(var z=h(),q=0;q=this.t?0!=this.s:0!=(this.data[q]&1<1){var ci=h();for(Oe.sqrTo(We[1],ci);$e<=fr;)We[$e]=h(),Oe.mulTo(ci,We[$e-2],We[$e]),$e+=2}var ns,Zr,Yr=z.t-1,_o=!0,Gt=h();for(J=U(z.data[Yr])-1;Yr>=0;){for(J>=Zt?ns=z.data[Yr]>>J-Zt&fr:(ns=(z.data[Yr]&(1<0&&(ns|=z.data[Yr-1]>>this.DB+J-Zt)),$e=ue;0==(1&ns);)ns>>=1,--$e;if((J-=$e)<0&&(J+=this.DB,--Yr),_o)We[ns].copyTo(Re),_o=!1;else{for(;$e>1;)Oe.sqrTo(Re,Gt),Oe.sqrTo(Gt,Re),$e-=2;$e>0?Oe.sqrTo(Re,Gt):(Zr=Re,Re=Gt,Gt=Zr),Oe.mulTo(Gt,We[ns],Re)}for(;Yr>=0&&0==(z.data[Yr]&1<=0?(J.subTo(ue,J),q&&Re.subTo(We,Re),Oe.subTo($e,Oe)):(ue.subTo(J,ue),q&&We.subTo(Re,We),$e.subTo(Oe,$e))}return 0!=ue.compareTo(m.ONE)?m.ZERO:$e.compareTo(z)>=0?$e.subtract(z):$e.signum()<0?($e.addTo(z,$e),$e.signum()<0?$e.add(z):$e):$e},m.prototype.pow=function Ve(z){return this.exp(z,new me)},m.prototype.gcd=function En(z){var q=this.s<0?this.negate():this.clone(),J=z.s<0?z.negate():z.clone();if(q.compareTo(J)<0){var ue=q;q=J,J=ue}var Re=q.getLowestSetBit(),Oe=J.getLowestSetBit();if(Oe<0)return q;for(Re0&&(q.rShiftTo(Oe,q),J.rShiftTo(Oe,J));q.signum()>0;)(Re=q.getLowestSetBit())>0&&q.rShiftTo(Re,q),(Re=J.getLowestSetBit())>0&&J.rShiftTo(Re,J),q.compareTo(J)>=0?(q.subTo(J,q),q.rShiftTo(1,q)):(J.subTo(q,J),J.rShiftTo(1,J));return Oe>0&&J.lShiftTo(Oe,J),J},m.prototype.isProbablePrime=function wo(z){var q,J=this.abs();if(1==J.t&&J.data[0]<=qn[qn.length-1]){for(q=0;q{var y=x(340);Q.exports=y.md=y.md||{},y.md.algorithms=y.md.algorithms||{}},9339:(Q,K,x)=>{var y=x(340);x(4601),Q.exports=y.mgf=y.mgf||{},y.mgf.mgf1=y.mgf1},4601:(Q,K,x)=>{var y=x(340);x(1558),y.mgf=y.mgf||{},(Q.exports=y.mgf.mgf1=y.mgf1=y.mgf1||{}).create=function(g){return{generate:function(m,h){for(var c=new y.util.ByteBuffer,f=Math.ceil(h/g.digestLength),d=0;d{var y=x(340);y.pki=y.pki||{};var u=Q.exports=y.pki.oids=y.oids=y.oids||{};function g(m,h){u[m]=h,u[h]=m}function w(m,h){u[m]=h}g("1.2.840.113549.1.1.1","rsaEncryption"),g("1.2.840.113549.1.1.4","md5WithRSAEncryption"),g("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),g("1.2.840.113549.1.1.7","RSAES-OAEP"),g("1.2.840.113549.1.1.8","mgf1"),g("1.2.840.113549.1.1.9","pSpecified"),g("1.2.840.113549.1.1.10","RSASSA-PSS"),g("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),g("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),g("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),g("1.3.101.112","EdDSA25519"),g("1.2.840.10040.4.3","dsa-with-sha1"),g("1.3.14.3.2.7","desCBC"),g("1.3.14.3.2.26","sha1"),g("1.3.14.3.2.29","sha1WithRSASignature"),g("2.16.840.1.101.3.4.2.1","sha256"),g("2.16.840.1.101.3.4.2.2","sha384"),g("2.16.840.1.101.3.4.2.3","sha512"),g("2.16.840.1.101.3.4.2.4","sha224"),g("2.16.840.1.101.3.4.2.5","sha512-224"),g("2.16.840.1.101.3.4.2.6","sha512-256"),g("1.2.840.113549.2.2","md2"),g("1.2.840.113549.2.5","md5"),g("1.2.840.113549.1.7.1","data"),g("1.2.840.113549.1.7.2","signedData"),g("1.2.840.113549.1.7.3","envelopedData"),g("1.2.840.113549.1.7.4","signedAndEnvelopedData"),g("1.2.840.113549.1.7.5","digestedData"),g("1.2.840.113549.1.7.6","encryptedData"),g("1.2.840.113549.1.9.1","emailAddress"),g("1.2.840.113549.1.9.2","unstructuredName"),g("1.2.840.113549.1.9.3","contentType"),g("1.2.840.113549.1.9.4","messageDigest"),g("1.2.840.113549.1.9.5","signingTime"),g("1.2.840.113549.1.9.6","counterSignature"),g("1.2.840.113549.1.9.7","challengePassword"),g("1.2.840.113549.1.9.8","unstructuredAddress"),g("1.2.840.113549.1.9.14","extensionRequest"),g("1.2.840.113549.1.9.20","friendlyName"),g("1.2.840.113549.1.9.21","localKeyId"),g("1.2.840.113549.1.9.22.1","x509Certificate"),g("1.2.840.113549.1.12.10.1.1","keyBag"),g("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),g("1.2.840.113549.1.12.10.1.3","certBag"),g("1.2.840.113549.1.12.10.1.4","crlBag"),g("1.2.840.113549.1.12.10.1.5","secretBag"),g("1.2.840.113549.1.12.10.1.6","safeContentsBag"),g("1.2.840.113549.1.5.13","pkcs5PBES2"),g("1.2.840.113549.1.5.12","pkcs5PBKDF2"),g("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),g("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),g("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),g("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),g("1.2.840.113549.2.7","hmacWithSHA1"),g("1.2.840.113549.2.8","hmacWithSHA224"),g("1.2.840.113549.2.9","hmacWithSHA256"),g("1.2.840.113549.2.10","hmacWithSHA384"),g("1.2.840.113549.2.11","hmacWithSHA512"),g("1.2.840.113549.3.7","des-EDE3-CBC"),g("2.16.840.1.101.3.4.1.2","aes128-CBC"),g("2.16.840.1.101.3.4.1.22","aes192-CBC"),g("2.16.840.1.101.3.4.1.42","aes256-CBC"),g("2.5.4.3","commonName"),g("2.5.4.4","surname"),g("2.5.4.5","serialNumber"),g("2.5.4.6","countryName"),g("2.5.4.7","localityName"),g("2.5.4.8","stateOrProvinceName"),g("2.5.4.9","streetAddress"),g("2.5.4.10","organizationName"),g("2.5.4.11","organizationalUnitName"),g("2.5.4.12","title"),g("2.5.4.13","description"),g("2.5.4.15","businessCategory"),g("2.5.4.17","postalCode"),g("2.5.4.42","givenName"),g("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),g("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),g("2.16.840.1.113730.1.1","nsCertType"),g("2.16.840.1.113730.1.13","nsComment"),w("2.5.29.1","authorityKeyIdentifier"),w("2.5.29.2","keyAttributes"),w("2.5.29.3","certificatePolicies"),w("2.5.29.4","keyUsageRestriction"),w("2.5.29.5","policyMapping"),w("2.5.29.6","subtreesConstraint"),w("2.5.29.7","subjectAltName"),w("2.5.29.8","issuerAltName"),w("2.5.29.9","subjectDirectoryAttributes"),w("2.5.29.10","basicConstraints"),w("2.5.29.11","nameConstraints"),w("2.5.29.12","policyConstraints"),w("2.5.29.13","basicConstraints"),g("2.5.29.14","subjectKeyIdentifier"),g("2.5.29.15","keyUsage"),w("2.5.29.16","privateKeyUsagePeriod"),g("2.5.29.17","subjectAltName"),g("2.5.29.18","issuerAltName"),g("2.5.29.19","basicConstraints"),w("2.5.29.20","cRLNumber"),w("2.5.29.21","cRLReason"),w("2.5.29.22","expirationDate"),w("2.5.29.23","instructionCode"),w("2.5.29.24","invalidityDate"),w("2.5.29.25","cRLDistributionPoints"),w("2.5.29.26","issuingDistributionPoint"),w("2.5.29.27","deltaCRLIndicator"),w("2.5.29.28","issuingDistributionPoint"),w("2.5.29.29","certificateIssuer"),w("2.5.29.30","nameConstraints"),g("2.5.29.31","cRLDistributionPoints"),g("2.5.29.32","certificatePolicies"),w("2.5.29.33","policyMappings"),w("2.5.29.34","policyConstraints"),g("2.5.29.35","authorityKeyIdentifier"),w("2.5.29.36","policyConstraints"),g("2.5.29.37","extKeyUsage"),w("2.5.29.46","freshestCRL"),w("2.5.29.54","inhibitAnyPolicy"),g("1.3.6.1.4.1.11129.2.4.2","timestampList"),g("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),g("1.3.6.1.5.5.7.3.1","serverAuth"),g("1.3.6.1.5.5.7.3.2","clientAuth"),g("1.3.6.1.5.5.7.3.3","codeSigning"),g("1.3.6.1.5.5.7.3.4","emailProtection"),g("1.3.6.1.5.5.7.3.8","timeStamping")},4291:(Q,K,x)=>{var y=x(340);if(x(3859),x(607),x(2718),x(1877),x(6169),x(9015),x(4088),x(9111),x(1552),x(4571),x(1558),typeof u>"u")var u=y.jsbn.BigInteger;var g=y.asn1,w=y.pki=y.pki||{};Q.exports=w.pbe=y.pbe=y.pbe||{};var m=w.oids,h={name:"EncryptedPrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},c={name:"PBES2Algorithms",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"iterations"}]};function d(v,p){return v.start().update(p).digest().getBytes()}function b(v){var p;if(v){if(!(p=w.oids[g.derToOid(v)])){var I=new Error("Unsupported PRF OID.");throw I.oid=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}}else p="hmacWithSHA1";return S(p)}function S(v){var p=y.md;switch(v){case"hmacWithSHA224":p=y.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":v=v.substr(8).toLowerCase();break;default:var I=new Error("Unsupported PRF algorithm.");throw I.algorithm=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}if(!p||!(v in p))throw new Error("Unknown hash algorithm: "+v);return p[v].create()}w.encryptPrivateKeyInfo=function(v,p,I){(I=I||{}).saltSize=I.saltSize||8,I.count=I.count||2048,I.algorithm=I.algorithm||"aes128",I.prfAlgorithm=I.prfAlgorithm||"sha1";var T,M,k,A=y.random.getBytesSync(I.saltSize),P=I.count,D=g.integerToDer(P);if(0===I.algorithm.indexOf("aes")||"des"===I.algorithm){var F,$,C;switch(I.algorithm){case"aes128":T=16,F=16,$=m["aes128-CBC"],C=y.aes.createEncryptionCipher;break;case"aes192":T=24,F=16,$=m["aes192-CBC"],C=y.aes.createEncryptionCipher;break;case"aes256":T=32,F=16,$=m["aes256-CBC"],C=y.aes.createEncryptionCipher;break;case"des":T=8,F=8,$=m.desCBC,C=y.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O}var U="hmacWith"+I.prfAlgorithm.toUpperCase(),L=S(U),H=y.pkcs5.pbkdf2(p,A,P,T,L),ne=y.random.getBytesSync(F);(G=C(H)).start(ne),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes();var ee=function E(v,p,I,A){var P=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,v),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,p.getBytes())]);return"hmacWithSHA1"!==A&&P.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,y.util.hexToBytes(I.toString(16))),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w.oids[A]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])),P}(A,D,T,U);M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBES2).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBKDF2).getBytes()),ee]),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer($).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,ne)])])])}else{var O;if("3des"!==I.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O;T=24;var G,Z=new y.util.ByteBuffer(A);H=w.pbe.generatePkcs12Key(p,Z,1,P,T),ne=w.pbe.generatePkcs12Key(p,Z,2,P,T),(G=y.des.createEncryptionCipher(H)).start(ne),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes(),M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,A),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,D.getBytes())])])}return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[M,g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,k)])},w.decryptPrivateKeyInfo=function(v,p){var I=null,A={},P=[];if(!g.validate(v,h,A,P)){var D=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw D.errors=P,D}var T=g.derToOid(A.encryptionOid),M=w.pbe.getCipher(T,A.encryptionParams,p),k=y.util.createBuffer(A.encryptedData);return M.update(k),M.finish()&&(I=g.fromDer(M.output)),I},w.encryptedPrivateKeyToPem=function(v,p){var I={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(v).getBytes()};return y.pem.encode(I,{maxline:p})},w.encryptedPrivateKeyFromPem=function(v){var p=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==p.type){var I=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw I.headerType=p.type,I}if(p.procType&&"ENCRYPTED"===p.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return g.fromDer(p.body)},w.encryptRsaPrivateKey=function(v,p,I){if(!(I=I||{}).legacy){var A=w.wrapRsaPrivateKey(w.privateKeyToAsn1(v));return A=w.encryptPrivateKeyInfo(A,p,I),w.encryptedPrivateKeyToPem(A)}var P,D,T,M;switch(I.algorithm){case"aes128":P="AES-128-CBC",T=16,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",T=24,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",T=32,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",T=24,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;case"des":P="DES-CBC",T=8,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;default:var k=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+I.algorithm+'".');throw k.algorithm=I.algorithm,k}var $=M(y.pbe.opensslDeriveBytes(p,D.substr(0,8),T));$.start(D),$.update(g.toDer(w.privateKeyToAsn1(v))),$.finish();var C={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:y.util.bytesToHex(D).toUpperCase()},body:$.output.getBytes()};return y.pem.encode(C)},w.decryptRsaPrivateKey=function(v,p){var I=null,A=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==A.type&&"PRIVATE KEY"!==A.type&&"RSA PRIVATE KEY"!==A.type)throw(P=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=P,P;if(A.procType&&"ENCRYPTED"===A.procType.type){var D,T;switch(A.dekInfo.algorithm){case"DES-CBC":D=8,T=y.des.createDecryptionCipher;break;case"DES-EDE3-CBC":D=24,T=y.des.createDecryptionCipher;break;case"AES-128-CBC":D=16,T=y.aes.createDecryptionCipher;break;case"AES-192-CBC":D=24,T=y.aes.createDecryptionCipher;break;case"AES-256-CBC":D=32,T=y.aes.createDecryptionCipher;break;case"RC2-40-CBC":D=5,T=function(C){return y.rc2.createDecryptionCipher(C,40)};break;case"RC2-64-CBC":D=8,T=function(C){return y.rc2.createDecryptionCipher(C,64)};break;case"RC2-128-CBC":D=16,T=function(C){return y.rc2.createDecryptionCipher(C,128)};break;default:var P;throw(P=new Error('Could not decrypt private key; unsupported encryption algorithm "'+A.dekInfo.algorithm+'".')).algorithm=A.dekInfo.algorithm,P}var M=y.util.hexToBytes(A.dekInfo.parameters),F=T(y.pbe.opensslDeriveBytes(p,M.substr(0,8),D));if(F.start(M),F.update(y.util.createBuffer(A.body)),!F.finish())return I;I=F.output.getBytes()}else I=A.body;return null!==(I="ENCRYPTED PRIVATE KEY"===A.type?w.decryptPrivateKeyInfo(g.fromDer(I),p):g.fromDer(I))&&(I=w.privateKeyFromAsn1(I)),I},w.pbe.generatePkcs12Key=function(v,p,I,A,P,D){var T,M;if(typeof D>"u"||null===D){if(!("sha1"in y.md))throw new Error('"sha1" hash algorithm unavailable.');D=y.md.sha1.create()}var k=D.digestLength,F=D.blockLength,$=new y.util.ByteBuffer,C=new y.util.ByteBuffer;if(null!=v){for(M=0;M=0;M--)ve>>=8,ve+=he.at(M)+Be.at(M),Be.setAt(M,255&ve);De.putBuffer(Be)}Z=De,$.putBuffer(oe)}return $.truncate($.length()-P),$},w.pbe.getCipher=function(v,p,I){switch(v){case w.oids.pkcs5PBES2:return w.pbe.getCipherForPBES2(v,p,I);case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case w.oids["pbewithSHAAnd40BitRC2-CBC"]:return w.pbe.getCipherForPKCS12PBE(v,p,I);default:var A=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw A.oid=v,A.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],A}},w.pbe.getCipherForPBES2=function(v,p,I){var D,A={},P=[];if(!g.validate(p,c,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;if((v=g.derToOid(A.kdfOid))!==w.oids.pkcs5PBKDF2)throw(D=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=v,D.supportedOids=["pkcs5PBKDF2"],D;if((v=g.derToOid(A.encOid))!==w.oids["aes128-CBC"]&&v!==w.oids["aes192-CBC"]&&v!==w.oids["aes256-CBC"]&&v!==w.oids["des-EDE3-CBC"]&&v!==w.oids.desCBC)throw(D=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=v,D.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],D;var k,F,T=A.kdfSalt,M=y.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),w.oids[v]){case"aes128-CBC":k=16,F=y.aes.createDecryptionCipher;break;case"aes192-CBC":k=24,F=y.aes.createDecryptionCipher;break;case"aes256-CBC":k=32,F=y.aes.createDecryptionCipher;break;case"des-EDE3-CBC":k=24,F=y.des.createDecryptionCipher;break;case"desCBC":k=8,F=y.des.createDecryptionCipher}var $=b(A.prfOid),C=y.pkcs5.pbkdf2(I,T,M,k,$),O=A.encIv,U=F(C);return U.start(O),U},w.pbe.getCipherForPKCS12PBE=function(v,p,I){var A={},P=[];if(!g.validate(p,f,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;var k,F,$,T=y.util.createBuffer(A.salt),M=y.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),v){case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24,F=8,$=y.des.startDecrypting;break;case w.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5,F=8,$=function(H,ne){var G=y.rc2.createDecryptionCipher(H,40);return G.start(ne,null),G};break;default:var D;throw(D=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=v,D}var C=b(A.prfOid),O=w.pbe.generatePkcs12Key(I,T,1,M,k,C);return C.start(),$(O,w.pbe.generatePkcs12Key(I,T,2,M,F,C))},w.pbe.opensslDeriveBytes=function(v,p,I,A){if(typeof A>"u"||null===A){if(!("md5"in y.md))throw new Error('"md5" hash algorithm unavailable.');A=y.md.md5.create()}null===p&&(p="");for(var P=[d(A,v+p)],D=16,T=1;D{var y=x(340);x(8828),x(1877),x(1558);var g,u=y.pkcs5=y.pkcs5||{};y.util.isNodejs&&!y.options.usePureJavaScript&&(g=x(9437)),Q.exports=y.pbkdf2=u.pbkdf2=function(w,m,h,c,f,d){if("function"==typeof f&&(d=f,f=null),y.util.isNodejs&&!y.options.usePureJavaScript&&g.pbkdf2&&(null===f||"object"!=typeof f)&&(g.pbkdf2Sync.length>4||!f||"sha1"===f))return"string"!=typeof f&&(f="sha1"),w=Buffer.from(w,"binary"),m=Buffer.from(m,"binary"),d?4===g.pbkdf2Sync.length?g.pbkdf2(w,m,h,c,function($,C){if($)return d($);d(null,C.toString("binary"))}):g.pbkdf2(w,m,h,c,f,function($,C){if($)return d($);d(null,C.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(w,m,h,c).toString("binary"):g.pbkdf2Sync(w,m,h,c,f).toString("binary");if((typeof f>"u"||null===f)&&(f="sha1"),"string"==typeof f){if(!(f in y.md.algorithms))throw new Error("Unknown hash algorithm: "+f);f=y.md[f].create()}var b=f.digestLength;if(c>4294967295*b){var S=new Error("Derived key is too long.");if(d)return d(S);throw S}var E=Math.ceil(c/b),v=c-(E-1)*b,p=y.hmac.create();p.start(f,w);var A,P,D,I="";if(!d){for(var T=1;T<=E;++T){p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes();for(var M=2;M<=h;++M)p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P;I+=TE)return d(null,I);p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes(),M=2,F()}function F(){if(M<=h)return p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P,++M,y.util.setImmediate(F);I+=T{var y=x(340);x(1558);var u=Q.exports=y.pem=y.pem||{};function g(m){for(var h=m.name+": ",c=[],f=function(v,p){return" "+p},d=0;d65&&-1!==S){var E=h[S];","===E?(++S,h=h.substr(0,S)+"\r\n "+h.substr(S)):h=h.substr(0,S)+"\r\n"+E+h.substr(S+1),b=d-S-1,S=-1,++d}else(" "===h[d]||"\t"===h[d]||","===h[d])&&(S=d);return h}function w(m){return m.replace(/^\s+/,"")}u.encode=function(m,h){h=h||{};var f,c="-----BEGIN "+m.type+"-----\r\n";if(m.procType&&(c+=g(f={name:"Proc-Type",values:[String(m.procType.version),m.procType.type]})),m.contentDomain&&(c+=g(f={name:"Content-Domain",values:[m.contentDomain]})),m.dekInfo&&(f={name:"DEK-Info",values:[m.dekInfo.algorithm]},m.dekInfo.parameters&&f.values.push(m.dekInfo.parameters),c+=g(f)),m.headers)for(var d=0;d{var y=x(340);x(1558),x(9111),x(1025);var u=Q.exports=y.pkcs1=y.pkcs1||{};function g(w,m,h){h||(h=y.md.sha1.create());for(var c="",f=Math.ceil(m/h.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);h.start(),h.update(w+b),c+=h.digest().getBytes()}return c.substring(0,m)}u.encode_rsa_oaep=function(w,m,h){var c,f,d,b;"string"==typeof h?(c=h,f=arguments[3]||void 0,d=arguments[4]||void 0):h&&(c=h.label||void 0,f=h.seed||void 0,d=h.md||void 0,h.mgf1&&h.mgf1.md&&(b=h.mgf1.md)),d?d.start():d=y.md.sha1.create(),b||(b=d);var S=Math.ceil(w.n.bitLength()/8),E=S-2*d.digestLength-2;if(m.length>E)throw(v=new Error("RSAES-OAEP input message length is too long.")).length=m.length,v.maxLength=E,v;c||(c=""),d.update(c,"raw");for(var p=d.digest(),I="",A=E-m.length,P=0;P{var y=x(340);x(3859),x(607),x(2718),x(6169),x(4088),x(3341),x(9111),x(1558),x(3911);var u=y.asn1,g=Q.exports=y.pkcs7=y.pkcs7||{};function w(A){var P={},D=[];if(!u.validate(A,g.asn1.recipientInfoValidator,P,D)){var T=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw T.errors=D,T}return{version:P.version.charCodeAt(0),issuer:y.pki.RDNAttributesAsArray(P.issuer),serialNumber:y.util.createBuffer(P.serial).toHex(),encryptedContent:{algorithm:u.derToOid(P.encAlgorithm),parameter:P.encParameter?P.encParameter.value:void 0,content:P.encKey}}}function m(A){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(A.version).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[y.pki.distinguishedNameToAsn1({attributes:A.issuer}),u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,y.util.hexToBytes(A.serialNumber))]),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.encryptedContent.algorithm).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")]),u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,A.encryptedContent.content)])}function c(A){for(var P=[],D=0;D0){for(var D=u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T=D&&M0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,T)),k.length>0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,k)),F.value[0].value.push(u.create(u.Class.UNIVERSAL,u.Type.SET,!0,A.signerInfos)),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.type).getBytes()),F])},addSigner:function(T){var M=T.issuer,k=T.serialNumber;if(T.certificate){var F=T.certificate;"string"==typeof F&&(F=y.pki.certificateFromPem(F)),M=F.issuer.attributes,k=F.serialNumber}var $=T.key;if(!$)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof $&&($=y.pki.privateKeyFromPem($));var C=T.digestAlgorithm||y.pki.oids.sha1;switch(C){case y.pki.oids.sha1:case y.pki.oids.sha256:case y.pki.oids.sha384:case y.pki.oids.sha512:case y.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+C)}var O=T.authenticatedAttributes||[];if(O.length>0){for(var U=!1,L=!1,H=0;H{var y=x(340);x(607),x(1558);var u=y.asn1,g=Q.exports=y.pkcs7asn1=y.pkcs7asn1||{};y.pkcs7=y.pkcs7||{},y.pkcs7.asn1=g;var w={name:"ContentInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};g.contentInfoValidator=w;var m={name:"EncryptedContentInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:u.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};g.envelopedDataValidator={name:"EnvelopedData",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(m)},g.encryptedDataValidator={name:"EncryptedData",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"}].concat(m)},g.signedDataValidator={name:"SignedData",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},w,{name:"SignedData.Certificates",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,capture:"signerInfos",optional:!0,value:[{name:"SignerInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:u.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:u.Class.UNIVERSAL,type:u.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]}]}]},g.recipientInfoValidator={name:"RecipientInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:u.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:u.Class.UNIVERSAL,type:u.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},7335:(Q,K,x)=>{var y=x(340);x(1558),x(3823),x(9111),function(){if(y.prime)Q.exports=y.prime;else{var u=Q.exports=y.prime=y.prime||{},g=y.jsbn.BigInteger,w=[6,4,2,4,2,4,6,2],m=new g(null);m.fromInt(30);var h=function(v,p){return v|p};u.generateProbablePrime=function(v,p,I){"function"==typeof p&&(I=p,p={});var A=(p=p||{}).algorithm||"PRIMEINC";"string"==typeof A&&(A={name:A}),A.options=A.options||{};var P=p.prng||y.random;if("PRIMEINC"===A.name)return function c(v,p,I,A){return"workers"in I?function b(v,p,I,A){if(typeof Worker>"u")return f(v,p,I,A);var P=S(v,p),D=I.workers,T=I.workLoad||100,M=30*T/8,k=I.workerScript||"forge/prime.worker.js";if(-1===D)return y.util.estimateCores(function($,C){$&&(C=2),D=C-1,F()});function F(){D=Math.max(1,D);for(var $=[],C=0;Cv&&(P=S(v,p));var ee=P.toString(16);H.target.postMessage({hex:ee,workLoad:T}),P.dAddOffset(M,0)}}}F()}(v,p,I,A):f(v,p,I,A)}(v,{nextBytes:function(T){for(var M=P.getBytesSync(T.length),k=0;kp&&(v=S(p,I)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(D<0||+new Date-M{var y=x(340);x(1558);var u=null;y.util.isNodejs&&!y.options.usePureJavaScript&&!process.versions["node-webkit"]&&(u=x(9437)),(Q.exports=y.prng=y.prng||{}).create=function(w){for(var m={plugin:w,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},h=w.md,c=new Array(32),f=0;f<32;++f)c[f]=h.create();function b(){if(m.pools[0].messageLength>=32)return S();m.collect(m.seedFileSync(32-m.pools[0].messageLength<<5)),S()}function S(){m.reseeds=4294967295===m.reseeds?0:m.reseeds+1;var v=m.plugin.md.create();v.update(m.keyBytes);for(var p=1,I=0;I<32;++I)m.reseeds%p==0&&(v.update(m.pools[I].digest().getBytes()),m.pools[I].start()),p<<=1;m.keyBytes=v.digest().getBytes(),v.start(),v.update(m.keyBytes);var A=v.digest().getBytes();m.key=m.plugin.formatKey(m.keyBytes),m.seed=m.plugin.formatSeed(A),m.generated=0}function E(v){var p=null,I=y.util.globalScope,A=I.crypto||I.msCrypto;A&&A.getRandomValues&&(p=function(O){return A.getRandomValues(O)});var P=y.util.createBuffer();if(p)for(;P.length()>16)))<<16,C=4294967295&(F=(2147483647&(F+=k>>15))+(F>>31)),M=0;M<3;++M)$=C>>>(M<<3),$^=Math.floor(256*Math.random()),P.putByte(255&$);return P.getBytes(v)}return m.pools=c,m.pool=0,m.generate=function(v,p){if(!p)return m.generateSync(v);var I=m.plugin.cipher,A=m.plugin.increment,P=m.plugin.formatKey,D=m.plugin.formatSeed,T=y.util.createBuffer();m.key=null,function M(k){if(k)return p(k);if(T.length()>=v)return p(null,T.getBytes(v));if(m.generated>1048575&&(m.key=null),null===m.key)return y.util.nextTick(function(){!function d(v){if(m.pools[0].messageLength>=32)return S(),v();m.seedFile(32-m.pools[0].messageLength<<5,function(I,A){if(I)return v(I);m.collect(A),S(),v()})}(M)});var F=I(m.key,m.seed);m.generated+=F.length,T.putBytes(F),m.key=P(I(m.key,A(m.seed))),m.seed=D(I(m.key,m.seed)),y.util.setImmediate(M)}()},m.generateSync=function(v){var p=m.plugin.cipher,I=m.plugin.increment,A=m.plugin.formatKey,P=m.plugin.formatSeed;m.key=null;for(var D=y.util.createBuffer();D.length()1048575&&(m.key=null),null===m.key&&b();var T=p(m.key,m.seed);m.generated+=T.length,D.putBytes(T),m.key=A(p(m.key,I(m.seed))),m.seed=P(p(m.key,m.seed))}return D.getBytes(v)},u?(m.seedFile=function(v,p){u.randomBytes(v,function(I,A){if(I)return p(I);p(null,A.toString())})},m.seedFileSync=function(v){return u.randomBytes(v).toString()}):(m.seedFile=function(v,p){try{p(null,E(v))}catch(I){p(I)}},m.seedFileSync=E),m.collect=function(v){for(var p=v.length,I=0;I>A&255);m.collect(I)},m.registerWorker=function(v){v===self?m.seedFile=function(I,A){self.addEventListener("message",function P(D){var T=D.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",P),A(T.forge.prng.err,T.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:I}}})}:v.addEventListener("message",function(I){var A=I.data;A.forge&&A.forge.prng&&m.seedFile(A.forge.prng.needed,function(P,D){v.postMessage({forge:{prng:{err:P,bytes:D}}})})})},m}},2808:(Q,K,x)=>{var y=x(340);x(9111),x(1558),(Q.exports=y.pss=y.pss||{}).create=function(g){3===arguments.length&&(g={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var f,w=g.md,m=g.mgf,h=w.digestLength,c=g.salt||null;if("string"==typeof c&&(c=y.util.createBuffer(c)),"saltLength"in g)f=g.saltLength;else{if(null===c)throw new Error("Salt length not specified or specific salt not given.");f=c.length()}if(null!==c&&c.length()!==f)throw new Error("Given salt length does not match length of given salt.");var d=g.prng||y.random,b={encode:function(S,E){var v,P,p=E-1,I=Math.ceil(p/8),A=S.digest().getBytes();if(I>8*I-p&255;return(C=String.fromCharCode(C.charCodeAt(0)&~O)+C.substr(1))+T+String.fromCharCode(188)},verify:function(S,E,v){var p,I=v-1,A=Math.ceil(I/8);if(E=E.substr(-A),A>8*A-I&255;if(0!=(D.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var k=m.generate(T,P),F="";for(p=0;p{var y=x(340);x(3859),x(8936),x(1015),x(1558),y.random&&y.random.getBytes?Q.exports=y.random:function(u){var g={},w=new Array(4),m=y.util.createBuffer();function h(){var v=y.prng.create(g);return v.getBytes=function(p,I){return v.generate(p,I)},v.getBytesSync=function(p){return v.generate(p)},v}g.formatKey=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),y.aes._expandKey(v,!1)},g.formatSeed=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),v},g.cipher=function(v,p){return y.aes._updateBlock(v,p,w,!1),m.putInt32(w[0]),m.putInt32(w[1]),m.putInt32(w[2]),m.putInt32(w[3]),m.getBytes()},g.increment=function(v){return++v[3],v},g.md=y.md.sha256;var c=h(),f=null,d=y.util.globalScope,b=d.crypto||d.msCrypto;if(b&&b.getRandomValues&&(f=function(v){return b.getRandomValues(v)}),y.options.usePureJavaScript||!y.util.isNodejs&&!f){if(typeof window>"u"||window,c.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var E in navigator)try{"string"==typeof navigator[E]&&(S+=navigator[E])}catch{}c.collect(S),S=null}u&&(u().mousemove(function(v){c.collectInt(v.clientX,16),c.collectInt(v.clientY,16)}),u().keypress(function(v){c.collectInt(v.charCode,8)}))}if(y.random)for(var E in c)y.random[E]=c[E];else y.random=c;y.random.createInstance=h,Q.exports=y.random}(typeof jQuery<"u"?jQuery:null)},1552:(Q,K,x)=>{var y=x(340);x(1558);var u=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],g=[1,2,3,5],w=function(c,f){return c<>16-f},m=function(c,f){return(65535&c)>>f|c<<16-f&65535};Q.exports=y.rc2=y.rc2||{},y.rc2.expandKey=function(c,f){"string"==typeof c&&(c=y.util.createBuffer(c)),f=f||128;var p,d=c,b=c.length(),S=f,E=Math.ceil(S/8),v=255>>(7&S);for(p=b;p<128;p++)d.putByte(u[d.at(p-1)+d.at(p-b)&255]);for(d.setAt(128-E,u[d.at(128-E)&v]),p=127-E;p>=0;p--)d.setAt(p,u[d.at(p+1)^d.at(p+E)]);return d};var h=function(c,f,d){var p,I,A,P,b=!1,S=null,E=null,v=null,D=[];for(c=y.rc2.expandKey(c,f),A=0;A<64;A++)D.push(c.getInt16Le());d?(p=function(k){for(A=0;A<4;A++)k[A]+=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),k[A]=w(k[A],g[A]),P++},I=function(k){for(A=0;A<4;A++)k[A]+=D[63&k[(A+3)%4]]}):(p=function(k){for(A=3;A>=0;A--)k[A]=m(k[A],g[A]),k[A]-=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),P--},I=function(k){for(A=3;A>=0;A--)k[A]-=D[63&k[(A+3)%4]]});var T=function(k){var F=[];for(A=0;A<4;A++){var $=S.getInt16Le();null!==v&&(d?$^=v.getInt16Le():v.putInt16Le($)),F.push(65535&$)}P=d?0:63;for(var C=0;C=8;)T([[5,p],[1,I],[6,p],[1,I],[5,p]])},finish:function(k){var F=!0;if(d)if(k)F=k(8,S,!d);else{var $=8===S.length()?8:8-S.length();S.fillWithByte($,$)}if(F&&(b=!0,M.update()),!d&&(F=0===S.length()))if(k)F=k(8,E,!d);else{var C=E.length(),O=E.at(C-1);O>C?F=!1:E.truncate(O)}return F}}};y.rc2.startEncrypting=function(c,f,d){var b=y.rc2.createEncryptionCipher(c,128);return b.start(f,d),b},y.rc2.createEncryptionCipher=function(c,f){return h(c,f,!0)},y.rc2.startDecrypting=function(c,f,d){var b=y.rc2.createDecryptionCipher(c,128);return b.start(f,d),b},y.rc2.createDecryptionCipher=function(c,f){return h(c,f,!1)}},4571:(Q,K,x)=>{var y=x(340);if(x(607),x(3823),x(6169),x(5237),x(7335),x(9111),x(1558),typeof u>"u")var u=y.jsbn.BigInteger;var g=y.util.isNodejs?x(9437):null,w=y.asn1,m=y.util;y.pki=y.pki||{},Q.exports=y.pki.rsa=y.rsa=y.rsa||{};var h=y.pki,c=[6,4,2,4,2,4,6,2],f={name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},b={name:"RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},S=y.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},E={name:"DigestInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:w.Class.UNIVERSAL,type:w.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},v=function(L){if(!(L.algorithm in h.oids)){var ne=new Error("Unknown message digest algorithm.");throw ne.algorithm=L.algorithm,ne}var G=w.oidToDer(h.oids[L.algorithm]).getBytes(),ee=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]),Z=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]);Z.value.push(w.create(w.Class.UNIVERSAL,w.Type.OID,!1,G)),Z.value.push(w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,""));var W=w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,L.digest().getBytes());return ee.value.push(Z),ee.value.push(W),w.toDer(ee).getBytes()},p=function(L,H,ne){if(ne)return L.modPow(H.e,H.n);if(!H.p||!H.q)return L.modPow(H.d,H.n);var G;H.dP||(H.dP=H.d.mod(H.p.subtract(u.ONE))),H.dQ||(H.dQ=H.d.mod(H.q.subtract(u.ONE))),H.qInv||(H.qInv=H.q.modInverse(H.p));do{G=new u(y.util.bytesToHex(y.random.getBytes(H.n.bitLength()/8)),16)}while(G.compareTo(H.n)>=0||!G.gcd(H.n).equals(u.ONE));for(var ee=(L=L.multiply(G.modPow(H.e,H.n)).mod(H.n)).mod(H.p).modPow(H.dP,H.p),Z=L.mod(H.q).modPow(H.dQ,H.q);ee.compareTo(Z)<0;)ee=ee.add(H.p);var W=ee.subtract(Z).multiply(H.qInv).mod(H.p).multiply(H.q).add(Z);return W.multiply(G.modInverse(H.n)).mod(H.n)};function I(L,H,ne){var G=y.util.createBuffer(),ee=Math.ceil(H.n.bitLength()/8);if(L.length>ee-11){var Z=new Error("Message is too long for PKCS#1 v1.5 padding.");throw Z.length=L.length,Z.max=ee-11,Z}G.putByte(0),G.putByte(ne);var te,W=ee-3-L.length;if(0===ne||1===ne){te=0===ne?0:255;for(var oe=0;oe0;){var de=0,he=y.random.getBytes(W);for(oe=0;oe"u")throw new Error("Encryption block is invalid.");var oe=0;if(0===te){oe=ee-3-G;for(var de=0;de1;){if(255!==Z.getByte()){--Z.read;break}++oe}else if(2===te)for(oe=0;Z.length()>1;){if(0===Z.getByte()){--Z.read;break}++oe}if(0!==Z.getByte()||oe!==ee-3-Z.length())throw new Error("Encryption block is invalid.");return Z.getBytes()}function P(L,H,ne){"function"==typeof H&&(ne=H,H={});var G={algorithm:{name:(H=H||{}).algorithm||"PRIMEINC",options:{workers:H.workers||2,workLoad:H.workLoad||100,workerScript:H.workerScript}}};function ee(){Z(L.pBits,function(te,oe){return te?ne(te):(L.p=oe,null!==L.q?W(te,L.q):void Z(L.qBits,W))})}function Z(te,oe){y.prime.generateProbablePrime(te,G,oe)}function W(te,oe){if(te)return ne(te);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 ee();if(0!==L.q.subtract(u.ONE).gcd(L.e).compareTo(u.ONE))return L.q=null,void Z(L.qBits,W);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 ee();if(L.n=L.p.multiply(L.q),L.n.bitLength()!==L.bits)return L.q=null,void Z(L.qBits,W);var he=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,he,L.p,L.q,he.mod(L.p1),he.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)},ne(null,L.keys)}"prng"in H&&(G.prng=H.prng),ee()}function D(L){var H=L.toString(16);H[0]>="8"&&(H="00"+H);var ne=y.util.hexToBytes(H);return ne.length>1&&(0===ne.charCodeAt(0)&&0==(128&ne.charCodeAt(1))||255===ne.charCodeAt(0)&&128==(128&ne.charCodeAt(1)))?ne.substr(1):ne}function T(L){return L<=100?27:L<=150?18:L<=200?15:L<=250?12:L<=300?9:L<=350?8:L<=400?7:L<=500?6:L<=600?5:L<=800?4:L<=1250?3:2}function M(L){return y.util.isNodejs&&"function"==typeof g[L]}function k(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.crypto&&"object"==typeof m.globalScope.crypto.subtle&&"function"==typeof m.globalScope.crypto.subtle[L]}function F(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.msCrypto&&"object"==typeof m.globalScope.msCrypto.subtle&&"function"==typeof m.globalScope.msCrypto.subtle[L]}function $(L){for(var H=y.util.hexToBytes(L.toString(16)),ne=new Uint8Array(H.length),G=0;G0;)de.putByte(0),--he;return de.putBytes(y.util.hexToBytes(oe)),de.getBytes()},h.rsa.decrypt=function(L,H,ne,G){var ee=Math.ceil(H.n.bitLength()/8);if(L.length!==ee){var Z=new Error("Encrypted message length is invalid.");throw Z.length=L.length,Z.expected=ee,Z}var W=new u(y.util.createBuffer(L).toHex(),16);if(W.compareTo(H.n)>=0)throw new Error("Encrypted message is invalid.");for(var oe=p(W,H,ne).toString(16),de=y.util.createBuffer(),he=ee-Math.ceil(oe.length/2);he>0;)de.putByte(0),--he;return de.putBytes(y.util.hexToBytes(oe)),!1!==G?A(de.getBytes(),H,ne):de.getBytes()},h.rsa.createKeyPairGenerationState=function(L,H,ne){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var W,G=(ne=ne||{}).prng||y.random,ee={nextBytes:function(te){for(var oe=G.getBytesSync(te.length),de=0;de>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(W.eInt),W},h.rsa.stepKeyPairGenerationState=function(L,H){"algorithm"in L||(L.algorithm="PRIMEINC");var ne=new u(null);ne.fromInt(30);for(var W,G=0,ee=function(Pe,De){return Pe|De},Z=+new Date,te=0;null===L.keys&&(H<=0||teoe?L.pqState=0:L.num.isProbablePrime(T(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(c[G++%8],0):2===L.pqState?L.pqState=0===L.num.subtract(u.ONE).gcd(L.e).compareTo(u.ONE)?3:0:3===L.pqState&&(L.pqState=0,null===L.p?L.p=L.num:L.q=L.num,null!==L.p&&null!==L.q&&++L.state,L.num=null)}else if(1===L.state)L.p.compareTo(L.q)<0&&(L.num=L.p,L.p=L.q,L.q=L.num),++L.state;else if(2===L.state)L.p1=L.p.subtract(u.ONE),L.q1=L.q.subtract(u.ONE),L.phi=L.p1.multiply(L.q1),++L.state;else if(3===L.state)0===L.phi.gcd(L.e).compareTo(u.ONE)?++L.state:(L.p=null,L.q=null,L.state=0);else if(4===L.state)L.n=L.p.multiply(L.q),L.n.bitLength()===L.bits?++L.state:(L.q=null,L.state=0);else if(5===L.state){var he=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,he,L.p,L.q,he.mod(L.p1),he.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)}}te+=(W=+new Date)-Z,Z=W}return null!==L.keys},h.rsa.generateKeyPair=function(L,H,ne,G){if(1===arguments.length?"object"==typeof L?(ne=L,L=void 0):"function"==typeof L&&(G=L,L=void 0):2===arguments.length?"number"==typeof L?"function"==typeof H?(G=H,H=void 0):"number"!=typeof H&&(ne=H,H=void 0):(ne=L,G=H,L=void 0,H=void 0):3===arguments.length&&("number"==typeof H?"function"==typeof ne&&(G=ne,ne=void 0):(G=ne,ne=H,H=void 0)),ne=ne||{},void 0===L&&(L=ne.bits||2048),void 0===H&&(H=ne.e||65537),!y.options.usePureJavaScript&&!ne.prng&&L>=256&&L<=16384&&(65537===H||3===H))if(G){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:H,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(te,oe,de){if(te)return G(te);G(null,{privateKey:h.privateKeyFromPem(de),publicKey:h.publicKeyFromPem(oe)})});if(k("generateKey")&&k("exportKey"))return m.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:$(H),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(te){return m.globalScope.crypto.subtle.exportKey("pkcs8",te.privateKey)}).then(void 0,function(te){G(te)}).then(function(te){if(te){var oe=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(te)));G(null,{privateKey:oe,publicKey:h.setRsaPublicKey(oe.n,oe.e)})}});if(F("generateKey")&&F("exportKey")){var ee=m.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:$(H),hash:{name:"SHA-256"}},!0,["sign","verify"]);return ee.oncomplete=function(te){var de=m.globalScope.msCrypto.subtle.exportKey("pkcs8",te.target.result.privateKey);de.oncomplete=function(he){var De=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(he.target.result)));G(null,{privateKey:De,publicKey:h.setRsaPublicKey(De.n,De.e)})},de.onerror=function(he){G(he)}},void(ee.onerror=function(te){G(te)})}}else if(M("generateKeyPairSync")){var Z=g.generateKeyPairSync("rsa",{modulusLength:L,publicExponent:H,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:h.privateKeyFromPem(Z.privateKey),publicKey:h.publicKeyFromPem(Z.publicKey)}}var W=h.rsa.createKeyPairGenerationState(L,H,ne);if(!G)return h.rsa.stepKeyPairGenerationState(W,0),W.keys;P(W,ne,G)},h.setRsaPublicKey=h.rsa.setPublicKey=function(L,H){var ne={n:L,e:H,encrypt:function(G,ee,Z){if("string"==typeof ee?ee=ee.toUpperCase():void 0===ee&&(ee="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===ee)ee={encode:function(te,oe,de){return I(te,oe,2).getBytes()}};else if("RSA-OAEP"===ee||"RSAES-OAEP"===ee)ee={encode:function(te,oe){return y.pkcs1.encode_rsa_oaep(oe,te,Z)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(ee))ee={encode:function(te){return te}};else if("string"==typeof ee)throw new Error('Unsupported encryption scheme: "'+ee+'".');var W=ee.encode(G,ne,!0);return h.rsa.encrypt(W,ne,!0)},verify:function(G,ee,Z,W){"string"==typeof Z?Z=Z.toUpperCase():void 0===Z&&(Z="RSASSA-PKCS1-V1_5"),void 0===W&&(W={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in W||(W._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===Z?Z={verify:function(oe,de){de=A(de,ne,!0);var he=w.fromDer(de,{parseAllBytes:W._parseAllDigestBytes}),Pe={},De=[];if(!w.validate(he,E,Pe,De))throw(Be=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=De,Be;var Be,ve=w.derToOid(Pe.algorithmIdentifier);if(ve!==y.oids.md2&&ve!==y.oids.md5&&ve!==y.oids.sha1&&ve!==y.oids.sha224&&ve!==y.oids.sha256&&ve!==y.oids.sha384&&ve!==y.oids.sha512&&ve!==y.oids["sha512-224"]&&ve!==y.oids["sha512-256"])throw(Be=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=ve,Be;if((ve===y.oids.md2||ve===y.oids.md5)&&!("parameters"in Pe))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return oe===Pe.digest}}:("NONE"===Z||"NULL"===Z||null===Z)&&(Z={verify:function(oe,de){return oe===A(de,ne,!0)}});var te=h.rsa.decrypt(ee,ne,!0,!1);return Z.verify(G,te,ne.n.bitLength())}};return ne},h.setRsaPrivateKey=h.rsa.setPrivateKey=function(L,H,ne,G,ee,Z,W,te){var oe={n:L,e:H,d:ne,p:G,q:ee,dP:Z,dQ:W,qInv:te,decrypt:function(de,he,Pe){"string"==typeof he?he=he.toUpperCase():void 0===he&&(he="RSAES-PKCS1-V1_5");var De=h.rsa.decrypt(de,oe,!1,!1);if("RSAES-PKCS1-V1_5"===he)he={decode:A};else if("RSA-OAEP"===he||"RSAES-OAEP"===he)he={decode:function(Be,ve){return y.pkcs1.decode_rsa_oaep(ve,Be,Pe)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(he))throw new Error('Unsupported encryption scheme: "'+he+'".');he={decode:function(Be){return Be}}}return he.decode(De,oe,!1)},sign:function(de,he){var Pe=!1;"string"==typeof he&&(he=he.toUpperCase()),void 0===he||"RSASSA-PKCS1-V1_5"===he?(he={encode:v},Pe=1):("NONE"===he||"NULL"===he||null===he)&&(he={encode:function(){return de}},Pe=1);var De=he.encode(de,oe.n.bitLength());return h.rsa.encrypt(De,oe,Pe)}};return oe},h.wrapRsaPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,w.toDer(L).getBytes())])},h.privateKeyFromAsn1=function(L){var ee,Z,W,te,oe,de,he,Pe,H={},ne=[];if(w.validate(L,f,H,ne)&&(L=w.fromDer(y.util.createBuffer(H.privateKey))),!w.validate(L,d,H={},ne=[])){var G=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw G.errors=ne,G}return ee=y.util.createBuffer(H.privateKeyModulus).toHex(),Z=y.util.createBuffer(H.privateKeyPublicExponent).toHex(),W=y.util.createBuffer(H.privateKeyPrivateExponent).toHex(),te=y.util.createBuffer(H.privateKeyPrime1).toHex(),oe=y.util.createBuffer(H.privateKeyPrime2).toHex(),de=y.util.createBuffer(H.privateKeyExponent1).toHex(),he=y.util.createBuffer(H.privateKeyExponent2).toHex(),Pe=y.util.createBuffer(H.privateKeyCoefficient).toHex(),h.setRsaPrivateKey(new u(ee,16),new u(Z,16),new u(W,16),new u(te,16),new u(oe,16),new u(de,16),new u(he,16),new u(Pe,16))},h.privateKeyToAsn1=h.privateKeyToRSAPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.qInv))])},h.publicKeyFromAsn1=function(L){var H={},ne=[];if(w.validate(L,S,H,ne)){var ee,G=w.derToOid(H.publicKeyOid);if(G!==h.oids.rsaEncryption)throw(ee=new Error("Cannot read public key. Unknown OID.")).oid=G,ee;L=H.rsaPublicKey}if(!w.validate(L,b,H,ne=[]))throw(ee=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=ne,ee;var Z=y.util.createBuffer(H.publicKeyModulus).toHex(),W=y.util.createBuffer(H.publicKeyExponent).toHex();return h.setRsaPublicKey(new u(Z,16),new u(W,16))},h.publicKeyToAsn1=h.publicKeyToSubjectPublicKeyInfo=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.BITSTRING,!1,[h.publicKeyToRSAPublicKey(L)])])},h.publicKeyToRSAPublicKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e))])}},1025:(Q,K,x)=>{var y=x(340);x(1877),x(1558);var u=Q.exports=y.sha1=y.sha1||{};y.md.sha1=y.md.algorithms.sha1=u,u.create=function(){w||function m(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),w=!0}();var c=null,f=y.util.createBuffer(),d=new Array(80),b={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var S=b.messageLengthSize/4,E=0;E>>0,v>>>0];for(var p=b.fullMessageLength.length-1;p>=0;--p)b.fullMessageLength[p]+=v[1],v[1]=v[0]+(b.fullMessageLength[p]/4294967296>>>0),b.fullMessageLength[p]=b.fullMessageLength[p]>>>0,v[0]=v[1]/4294967296>>>0;return f.putBytes(S),h(c,d,f),(f.read>2048||0===f.length())&&f.compact(),b},b.digest=function(){var S=y.util.createBuffer();S.putBytes(f.bytes()),S.putBytes(g.substr(0,b.blockLength-(b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize&b.blockLength-1)));for(var p,A=8*b.fullMessageLength[0],P=0;P>>0)>>>0),A=p>>>0;S.putInt32(A);var D={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};h(D,d,S);var T=y.util.createBuffer();return T.putInt32(D.h0),T.putInt32(D.h1),T.putInt32(D.h2),T.putInt32(D.h3),T.putInt32(D.h4),T},b};var g=null,w=!1;function h(c,f,d){for(var b,S,E,v,p,I,P,D=d.length();D>=64;){for(S=c.h0,E=c.h1,v=c.h2,p=c.h3,I=c.h4,P=0;P<16;++P)b=d.getInt32(),f[P]=b,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<20;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<32;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<40;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<60;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E&v|p&(E^v))+I+2400959708+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<80;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+3395469782+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;c.h0=c.h0+S|0,c.h1=c.h1+E|0,c.h2=c.h2+v|0,c.h3=c.h3+p|0,c.h4=c.h4+I|0,D-=64}}},8936:(Q,K,x)=>{var y=x(340);x(1877),x(1558);var u=Q.exports=y.sha256=y.sha256||{};y.md.sha256=y.md.algorithms.sha256=u,u.create=function(){w||function h(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],w=!0}();var f=null,d=y.util.createBuffer(),b=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var E=S.messageLengthSize/4,v=0;v>>0,p>>>0];for(var I=S.fullMessageLength.length-1;I>=0;--I)S.fullMessageLength[I]+=p[1],p[1]=p[0]+(S.fullMessageLength[I]/4294967296>>>0),S.fullMessageLength[I]=S.fullMessageLength[I]>>>0,p[0]=p[1]/4294967296>>>0;return d.putBytes(E),c(f,b,d),(d.read>2048||0===d.length())&&d.compact(),S},S.digest=function(){var E=y.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,S.blockLength-(S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize&S.blockLength-1)));for(var I,P=8*S.fullMessageLength[0],D=0;D>>0)>>>0),P=I>>>0;E.putInt32(P);var T={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4,h5:f.h5,h6:f.h6,h7:f.h7};c(T,b,E);var M=y.util.createBuffer();return M.putInt32(T.h0),M.putInt32(T.h1),M.putInt32(T.h2),M.putInt32(T.h3),M.putInt32(T.h4),M.putInt32(T.h5),M.putInt32(T.h6),M.putInt32(T.h7),M},S};var g=null,w=!1,m=null;function c(f,d,b){for(var S,E,A,P,D,T,M,k,F,$,C,O,U=b.length();U>=64;){for(P=0;P<16;++P)d[P]=b.getInt32();for(;P<64;++P)d[P]=(S=((S=d[P-2])>>>17|S<<15)^(S>>>19|S<<13)^S>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(D=f.h0,T=f.h1,M=f.h2,k=f.h3,F=f.h4,$=f.h5,C=f.h6,O=f.h7,P=0;P<64;++P)A=D&T|M&(D^T),S=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(C^F&($^C))+m[P]+d[P],O=C,C=$,$=F,F=k+S>>>0,k=M,M=T,T=D,D=S+(E=((D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10))+A)>>>0;f.h0=f.h0+D|0,f.h1=f.h1+T|0,f.h2=f.h2+M|0,f.h3=f.h3+k|0,f.h4=f.h4+F|0,f.h5=f.h5+$|0,f.h6=f.h6+C|0,f.h7=f.h7+O|0,U-=64}}},9578:(Q,K,x)=>{var y=x(340);x(1877),x(1558);var u=Q.exports=y.sha512=y.sha512||{};y.md.sha512=y.md.algorithms.sha512=u;var g=y.sha384=y.sha512.sha384=y.sha512.sha384||{};g.create=function(){return u.create("SHA-384")},y.md.sha384=y.md.algorithms.sha384=g,y.sha512.sha256=y.sha512.sha256||{create:function(){return u.create("SHA-512/256")}},y.md["sha512/256"]=y.md.algorithms["sha512/256"]=y.sha512.sha256,y.sha512.sha224=y.sha512.sha224||{create:function(){return u.create("SHA-512/224")}},y.md["sha512/224"]=y.md.algorithms["sha512/224"]=y.sha512.sha224,u.create=function(b){if(m||function f(){w=String.fromCharCode(128),w+=y.util.fillString(String.fromCharCode(0),128),h=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(c={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],m=!0}(),typeof b>"u"&&(b="SHA-512"),!(b in c))throw new Error("Invalid SHA-512 algorithm: "+b);for(var S=c[b],E=null,v=y.util.createBuffer(),p=new Array(80),I=0;I<80;++I)p[I]=new Array(2);var A=64;switch(b){case"SHA-384":A=48;break;case"SHA-512/256":A=32;break;case"SHA-512/224":A=28}var P={algorithm:b.replace("-","").toLowerCase(),blockLength:128,digestLength:A,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){P.messageLength=0,P.fullMessageLength=P.messageLength128=[];for(var D=P.messageLengthSize/4,T=0;T>>0,M>>>0];for(var k=P.fullMessageLength.length-1;k>=0;--k)P.fullMessageLength[k]+=M[1],M[1]=M[0]+(P.fullMessageLength[k]/4294967296>>>0),P.fullMessageLength[k]=P.fullMessageLength[k]>>>0,M[0]=M[1]/4294967296>>>0;return v.putBytes(D),d(E,p,v),(v.read>2048||0===v.length())&&v.compact(),P},P.digest=function(){var D=y.util.createBuffer();D.putBytes(v.bytes()),D.putBytes(w.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var k,$=8*P.fullMessageLength[0],C=0;C>>0)>>>0),$=k>>>0;D.putInt32($);var O=new Array(E.length);for(C=0;C=128;){for(ve=0;ve<16;++ve)S[ve][0]=E.getInt32()>>>0,S[ve][1]=E.getInt32()>>>0;for(;ve<80;++ve)p=(((He=(nt=S[ve-2])[0])<<13|(ke=nt[1])>>>19)^(ke<<3|He>>>29)^(He<<26|ke>>>6))>>>0,S[ve][0]=(v=((He>>>19|ke<<13)^(ke>>>29|He<<3)^He>>>6)>>>0)+(Pt=S[ve-7])[0]+(I=(((He=(_t=S[ve-15])[0])>>>1|(ke=_t[1])<<31)^(He>>>8|ke<<24)^He>>>7)>>>0)+(Vt=S[ve-16])[0]+((ke=p+Pt[1]+(A=((He<<31|ke>>>1)^(He<<24|ke>>>8)^(He<<25|ke>>>7))>>>0)+Vt[1])/4294967296>>>0)>>>0,S[ve][1]=ke>>>0;for(O=b[0][0],U=b[0][1],L=b[1][0],H=b[1][1],ne=b[2][0],G=b[2][1],ee=b[3][0],Z=b[3][1],W=b[4][0],te=b[4][1],oe=b[5][0],de=b[5][1],he=b[6][0],Pe=b[6][1],De=b[7][0],Be=b[7][1],ve=0;ve<80;++ve)v=De+(((W>>>14|te<<18)^(W>>>18|te<<14)^(te>>>9|W<<23))>>>0)+((he^W&(oe^he))>>>0)+h[ve][0]+S[ve][0]+((ke=Be+(((W<<18|te>>>14)^(W<<14|te>>>18)^(te<<23|W>>>9))>>>0)+((Pe^te&(de^Pe))>>>0)+h[ve][1]+S[ve][1])/4294967296>>>0)>>>0,p=ke>>>0,I=(((O>>>28|U<<4)^(U>>>2|O<<30)^(U>>>7|O<<25))>>>0)+((O&L|ne&(O^L))>>>0)+((ke=(((O<<4|U>>>28)^(U<<30|O>>>2)^(U<<25|O>>>7))>>>0)+((U&H|G&(U^H))>>>0))/4294967296>>>0)>>>0,A=ke>>>0,De=he,Be=Pe,he=oe,Pe=de,oe=W,de=te,W=ee+v+((ke=Z+p)/4294967296>>>0)>>>0,te=ke>>>0,ee=ne,Z=G,ne=L,G=H,L=O,H=U,O=v+I+((ke=p+A)/4294967296>>>0)>>>0,U=ke>>>0;b[0][0]=b[0][0]+O+((ke=b[0][1]+U)/4294967296>>>0)>>>0,b[0][1]=ke>>>0,b[1][0]=b[1][0]+L+((ke=b[1][1]+H)/4294967296>>>0)>>>0,b[1][1]=ke>>>0,b[2][0]=b[2][0]+ne+((ke=b[2][1]+G)/4294967296>>>0)>>>0,b[2][1]=ke>>>0,b[3][0]=b[3][0]+ee+((ke=b[3][1]+Z)/4294967296>>>0)>>>0,b[3][1]=ke>>>0,b[4][0]=b[4][0]+W+((ke=b[4][1]+te)/4294967296>>>0)>>>0,b[4][1]=ke>>>0,b[5][0]=b[5][0]+oe+((ke=b[5][1]+de)/4294967296>>>0)>>>0,b[5][1]=ke>>>0,b[6][0]=b[6][0]+he+((ke=b[6][1]+Pe)/4294967296>>>0)>>>0,b[6][1]=ke>>>0,b[7][0]=b[7][0]+De+((ke=b[7][1]+Be)/4294967296>>>0)>>>0,b[7][1]=ke>>>0,Yt-=128}}},1558:(Q,K,x)=>{var y=x(340),u=x(9391),g=Q.exports=y.util=y.util||{};function w(D){if(8!==D&&16!==D&&24!==D&&32!==D)throw new Error("Only 8, 16, 24, or 32 bits supported: "+D)}function m(D){if(this.data="",this.read=0,"string"==typeof D)this.data=D;else if(g.isArrayBuffer(D)||g.isArrayBufferView(D))if(typeof Buffer<"u"&&D instanceof Buffer)this.data=D.toString("binary");else{var T=new Uint8Array(D);try{this.data=String.fromCharCode.apply(null,T)}catch{for(var M=0;M15?(M=Date.now(),$(U)):(T.push(U),1===T.length&&F.setAttribute("a",k=!k))}}g.nextTick=g.setImmediate})(),g.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,g.globalScope=g.isNodejs?global:typeof self>"u"?window:self,g.isArray=Array.isArray||function(D){return"[object Array]"===Object.prototype.toString.call(D)},g.isArrayBuffer=function(D){return typeof ArrayBuffer<"u"&&D instanceof ArrayBuffer},g.isArrayBufferView=function(D){return D&&g.isArrayBuffer(D.buffer)&&void 0!==D.byteLength},g.ByteBuffer=m,g.ByteStringBuffer=m,g.ByteStringBuffer.prototype._optimizeConstructedString=function(D){this._constructedStringLength+=D,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},g.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},g.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},g.ByteStringBuffer.prototype.putByte=function(D){return this.putBytes(String.fromCharCode(D))},g.ByteStringBuffer.prototype.fillWithByte=function(D,T){D=String.fromCharCode(D);for(var M=this.data;T>0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return this.data=M,this._optimizeConstructedString(T),this},g.ByteStringBuffer.prototype.putBytes=function(D){return this.data+=D,this._optimizeConstructedString(D.length),this},g.ByteStringBuffer.prototype.putString=function(D){return this.putBytes(g.encodeUtf8(D))},g.ByteStringBuffer.prototype.putInt16=function(D){return this.putBytes(String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt24=function(D){return this.putBytes(String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt32=function(D){return this.putBytes(String.fromCharCode(D>>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt16Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255))},g.ByteStringBuffer.prototype.putInt24Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255))},g.ByteStringBuffer.prototype.putInt32Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>24&255))},g.ByteStringBuffer.prototype.putInt=function(D,T){w(T);var M="";do{T-=8,M+=String.fromCharCode(D>>T&255)}while(T>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(D,T){return D<0&&(D+=2<0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.ByteStringBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.ByteStringBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.ByteStringBuffer.prototype.at=function(D){return this.data.charCodeAt(this.read+D)},g.ByteStringBuffer.prototype.setAt=function(D,T){return this.data=this.data.substr(0,this.read+D)+String.fromCharCode(T)+this.data.substr(this.read+D+1),this},g.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},g.ByteStringBuffer.prototype.copy=function(){var D=g.createBuffer(this.data);return D.read=this.read,D},g.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},g.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},g.ByteStringBuffer.prototype.truncate=function(D){var T=Math.max(0,this.length()-D);return this.data=this.data.substr(this.read,T),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var D="",T=this.read;T=D)return this;T=Math.max(T||this.growSize,D);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),k=new Uint8Array(this.length()+T);return k.set(M),this.data=new DataView(k.buffer),this},g.DataBuffer.prototype.putByte=function(D){return this.accommodate(1),this.data.setUint8(this.write++,D),this},g.DataBuffer.prototype.fillWithByte=function(D,T){this.accommodate(T);for(var M=0;M>8&65535),this.data.setInt8(this.write,D>>16&255),this.write+=3,this},g.DataBuffer.prototype.putInt32=function(D){return this.accommodate(4),this.data.setInt32(this.write,D),this.write+=4,this},g.DataBuffer.prototype.putInt16Le=function(D){return this.accommodate(2),this.data.setInt16(this.write,D,!0),this.write+=2,this},g.DataBuffer.prototype.putInt24Le=function(D){return this.accommodate(3),this.data.setInt8(this.write,D>>16&255),this.data.setInt16(this.write,D>>8&65535,!0),this.write+=3,this},g.DataBuffer.prototype.putInt32Le=function(D){return this.accommodate(4),this.data.setInt32(this.write,D,!0),this.write+=4,this},g.DataBuffer.prototype.putInt=function(D,T){w(T),this.accommodate(T/8);do{T-=8,this.data.setInt8(this.write++,D>>T&255)}while(T>0);return this},g.DataBuffer.prototype.putSignedInt=function(D,T){return w(T),this.accommodate(T/8),D<0&&(D+=2<0);return T},g.DataBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.DataBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.DataBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.DataBuffer.prototype.at=function(D){return this.data.getUint8(this.read+D)},g.DataBuffer.prototype.setAt=function(D,T){return this.data.setUint8(D,T),this},g.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},g.DataBuffer.prototype.copy=function(){return new g.DataBuffer(this)},g.DataBuffer.prototype.compact=function(){if(this.read>0){var D=new Uint8Array(this.data.buffer,this.read),T=new Uint8Array(D.byteLength);T.set(D),this.data=new DataView(T),this.write-=this.read,this.read=0}return this},g.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},g.DataBuffer.prototype.truncate=function(D){return this.write=Math.max(0,this.length()-D),this.read=Math.min(this.read,this.write),this},g.DataBuffer.prototype.toHex=function(){for(var D="",T=this.read;T0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return M},g.xorBytes=function(D,T,M){for(var k="",F="",$="",C=0,O=0;M>0;--M,++C)F=D.charCodeAt(C)^T.charCodeAt(C),O>=10&&(k+=$,$="",O=0),$+=String.fromCharCode(F),++O;return k+$},g.hexToBytes=function(D){var T="",M=0;for(!0&D.length&&(M=1,T+=String.fromCharCode(parseInt(D[0],16)));M>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D)};var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";g.encode64=function(D,T){for(var F,$,C,M="",k="",O=0;O>2),M+=f.charAt((3&F)<<4|$>>4),isNaN($)?M+="==":(M+=f.charAt((15&$)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.decode64=function(D){D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,k,F,$,T="",C=0;C>4),64!==F&&(T+=String.fromCharCode((15&k)<<4|F>>2),64!==$&&(T+=String.fromCharCode((3&F)<<6|$)));return T},g.encodeUtf8=function(D){return unescape(encodeURIComponent(D))},g.decodeUtf8=function(D){return decodeURIComponent(escape(D))},g.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:u.encode,decode:u.decode}},g.binary.raw.encode=function(D){return String.fromCharCode.apply(null,D)},g.binary.raw.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,$=0;$>2),M+=f.charAt((3&F)<<4|$>>4),isNaN($)?M+="==":(M+=f.charAt((15&$)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.binary.base64.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(3*Math.ceil(D.length/4))),D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,$,C,O,U=0,L=M=M||0;U>4,64!==C&&(k[L++]=(15&$)<<4|C>>2,64!==O&&(k[L++]=(3&C)<<6|O));return T?L-M:k.subarray(0,L)},g.binary.base58.encode=function(D,T){return g.binary.baseN.encode(D,b,T)},g.binary.base58.decode=function(D,T){return g.binary.baseN.decode(D,b,T)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(D,T,M){D=g.encodeUtf8(D);var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,$=0;$"u"&&(M=["web","flash"]);var F,$=!1,C=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===T[0])throw new Error("Flash local storage not available.");k=D.apply(this,T),$="flash"===F}("web"===F||"both"===F)&&(T[0]=localStorage,k=D.apply(this,T),$=!0)}catch(U){C=U}if($)break}if(!$)throw C;return k};g.setItem=function(D,T,M,k,F){P(v,arguments,F)},g.getItem=function(D,T,M,k){return P(p,arguments,k)},g.removeItem=function(D,T,M,k){P(I,arguments,k)},g.clearItems=function(D,T,M){P(A,arguments,M)},g.isEmpty=function(D){for(var T in D)if(D.hasOwnProperty(T))return!1;return!0},g.format=function(D){for(var M,k,T=/%./g,F=0,$=[],C=0;M=T.exec(D);){(k=D.substring(C,T.lastIndex-2)).length>0&&$.push(k),C=T.lastIndex;var O=M[0][1];switch(O){case"s":case"o":$.push(F");break;case"%":$.push("%");break;default:$.push("<%"+O+"?>")}}return $.push(D.substring(C)),$.join("")},g.formatNumber=function(D,T,M,k){var F=D,$=isNaN(T=Math.abs(T))?2:T,C=void 0===M?",":M,O=void 0===k?".":k,U=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed($),10)+"",H=L.length>3?L.length%3:0;return U+(H?L.substr(0,H)+O:"")+L.substr(H).replace(/(\d{3})(?=\d)/g,"$1"+O)+($?C+Math.abs(F-L).toFixed($).slice(2):"")},g.formatSize=function(D){return D>=1073741824?g.formatNumber(D/1073741824,2,".","")+" GiB":D>=1048576?g.formatNumber(D/1048576,2,".","")+" MiB":D>=1024?g.formatNumber(D/1024,0)+" KiB":g.formatNumber(D,0)+" bytes"},g.bytesFromIP=function(D){return-1!==D.indexOf(".")?g.bytesFromIPv4(D):-1!==D.indexOf(":")?g.bytesFromIPv6(D):null},g.bytesFromIPv4=function(D){if(4!==(D=D.split(".")).length)return null;for(var T=g.createBuffer(),M=0;MM[k].end-M[k].start&&(k=M.length-1)):M.push({start:O,end:O})}T.push($)}if(M.length>0){var U=M[k];U.end-U.start>0&&(T.splice(U.start,U.end-U.start+1,""),0===U.start&&T.unshift(""),7===U.end&&T.push(""))}return T.join(":")},g.estimateCores=function(D,T){if("function"==typeof D&&(T=D,D={}),D=D||{},"cores"in g&&!D.update)return T(null,g.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return g.cores=navigator.hardwareConcurrency,T(null,g.cores);if(typeof Worker>"u")return g.cores=1,T(null,g.cores);if(typeof Blob>"u")return g.cores=2,T(null,g.cores);var M=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(C){for(var O=Date.now(),U=O+4;Date.now()ee.st&&H.stH.st&&ee.st{var y=x(340);x(3859),x(607),x(2718),x(1877),x(9339),x(6169),x(4088),x(2808),x(4571),x(1558);var u=y.asn1,g=Q.exports=y.pki=y.pki||{},w=g.oids,m={};m.CN=w.commonName,m.commonName="CN",m.C=w.countryName,m.countryName="C",m.L=w.localityName,m.localityName="L",m.ST=w.stateOrProvinceName,m.stateOrProvinceName="ST",m.O=w.organizationName,m.organizationName="O",m.OU=w.organizationalUnitName,m.organizationalUnitName="OU",m.E=w.emailAddress,m.emailAddress="E";var h=y.pki.rsa.publicKeyValidator,c={name:"Certificate",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:u.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:u.Class.UNIVERSAL,type:u.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:u.Class.UNIVERSAL,type:u.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:u.Class.UNIVERSAL,type:u.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:u.Class.UNIVERSAL,type:u.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},h,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:u.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:u.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:u.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},f={name:"rsapss",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:u.Class.UNIVERSAL,type:u.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:u.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:u.Class.UNIVERSAL,type:u.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:u.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:u.Class.UNIVERSAL,type:u.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:u.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:u.Class.UNIVERSAL,type:u.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequest",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[{name:"CertificationRequestInfo",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:u.Class.UNIVERSAL,type:u.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},h,{name:"CertificationRequestInfo.attributes",tagClass:u.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:u.Class.UNIVERSAL,type:u.Type.SET,constructed:!0}]}]}]},{name:"CertificationRequest.signatureAlgorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:u.Class.UNIVERSAL,type:u.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:u.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:u.Class.UNIVERSAL,type:u.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function S(C,O){"string"==typeof O&&(O={shortName:O});for(var L,U=null,H=0;null===U&&H"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in m&&(O.name=g.oids[m[O.shortName]])),typeof O.type>"u"){if(!O.name||!(O.name in g.oids))throw(L=new Error("Attribute type not specified.")).attribute=O,L;O.type=g.oids[O.name]}if(typeof O.shortName>"u"&&O.name&&O.name in m&&(O.shortName=m[O.name]),O.type===w.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=u.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var H=0;H"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function D(C,O){if(O=O||{},typeof C.name>"u"&&C.id&&C.id in g.oids&&(C.name=g.oids[C.id]),typeof C.id>"u"){if(!C.name||!(C.name in g.oids))throw(U=new Error("Extension ID not specified.")).extension=C,U;C.id=g.oids[C.name]}if(typeof C.value<"u")return C;if("keyUsage"===C.name){var L=0,H=0,ne=0;C.digitalSignature&&(H|=128,L=7),C.nonRepudiation&&(H|=64,L=6),C.keyEncipherment&&(H|=32,L=5),C.dataEncipherment&&(H|=16,L=4),C.keyAgreement&&(H|=8,L=3),C.keyCertSign&&(H|=4,L=2),C.cRLSign&&(H|=2,L=1),C.encipherOnly&&(H|=1,L=0),C.decipherOnly&&(ne|=128,L=7);var G=String.fromCharCode(L);0!==ne?G+=String.fromCharCode(H)+String.fromCharCode(ne):0!==H&&(G+=String.fromCharCode(H)),C.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,G)}else if("basicConstraints"===C.name)C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),C.cA&&C.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in C&&C.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.pathLenConstraint).getBytes()));else if("extKeyUsage"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);var ee=C.value.value;for(var Z in C)!0===C[Z]&&(Z in w?ee.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(w[Z]).getBytes())):-1!==Z.indexOf(".")&&ee.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(Z).getBytes())))}else if("nsCertType"===C.name)L=0,H=0,C.client&&(H|=128,L=7),C.server&&(H|=64,L=6),C.email&&(H|=32,L=5),C.objsign&&(H|=16,L=4),C.reserved&&(H|=8,L=3),C.sslCA&&(H|=4,L=2),C.emailCA&&(H|=2,L=1),C.objCA&&(H|=1,L=0),G=String.fromCharCode(L),0!==H&&(G+=String.fromCharCode(H)),C.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,G);else if("subjectAltName"===C.name||"issuerAltName"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);for(var te=0;te128)throw new Error('Invalid "nsComment" content.');C.value=u.create(u.Class.UNIVERSAL,u.Type.IA5STRING,!1,C.comment)}else if("subjectKeyIdentifier"===C.name&&O.cert){var oe=O.cert.generateSubjectKeyIdentifier();C.subjectKeyIdentifier=oe.toHex(),C.value=u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,oe.getBytes())}else if("authorityKeyIdentifier"===C.name&&O.cert){if(C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),ee=C.value.value,C.keyIdentifier){var de=!0===C.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():C.keyIdentifier;ee.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!1,de))}if(C.authorityCertIssuer){var he=[u.create(u.Class.CONTEXT_SPECIFIC,4,!0,[I(!0===C.authorityCertIssuer?O.cert.issuer:C.authorityCertIssuer)])];ee.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,he))}if(C.serialNumber){var Pe=y.util.hexToBytes(!0===C.serialNumber?O.cert.serialNumber:C.serialNumber);ee.push(u.create(u.Class.CONTEXT_SPECIFIC,2,!1,Pe))}}else if("cRLDistributionPoints"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),ee=C.value.value;var W,De=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),Be=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);for(te=0;te"u")throw(U=new Error("Extension value not specified.")).extension=C,U;return C}function T(C,O){if(C===w["RSASSA-PSS"]){var U=[];return void 0!==O.hash.algorithmOid&&U.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&&U.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&&U.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,U)}return u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")}function M(C){var O=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===C.attributes.length)return O;for(var U=C.attributes,L=0;L2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(Z.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(G.validity.notBefore=Z[0],G.validity.notAfter=Z[1],G.tbsCertificate=U.tbsCertificate,O){G.md=v({signatureOid:G.signatureOid,type:"certificate"});var W=u.toDer(G.tbsCertificate);G.md.update(W.getBytes())}var te=y.md.sha1.create(),oe=u.toDer(U.certIssuer);te.update(oe.getBytes()),G.issuer.getField=function(Pe){return S(G.issuer,Pe)},G.issuer.addField=function(Pe){P([Pe]),G.issuer.attributes.push(Pe)},G.issuer.attributes=g.RDNAttributesAsArray(U.certIssuer),U.certIssuerUniqueId&&(G.issuer.uniqueId=U.certIssuerUniqueId),G.issuer.hash=te.digest().toHex();var de=y.md.sha1.create(),he=u.toDer(U.certSubject);return de.update(he.getBytes()),G.subject.getField=function(Pe){return S(G.subject,Pe)},G.subject.addField=function(Pe){P([Pe]),G.subject.attributes.push(Pe)},G.subject.attributes=g.RDNAttributesAsArray(U.certSubject),U.certSubjectUniqueId&&(G.subject.uniqueId=U.certSubjectUniqueId),G.subject.hash=de.digest().toHex(),G.extensions=U.certExtensions?g.certificateExtensionsFromAsn1(U.certExtensions):[],G.publicKey=g.publicKeyFromAsn1(U.subjectPublicKeyInfo),G},g.certificateExtensionsFromAsn1=function(C){for(var O=[],U=0;U1&&(L=U.value.charCodeAt(1),H=U.value.length>2?U.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&H)}else if("basicConstraints"===O.name){var U=u.fromDer(O.value);O.cA=U.value.length>0&&U.value[0].type===u.Type.BOOLEAN&&0!==U.value[0].value.charCodeAt(0);var ne=null;U.value.length>0&&U.value[0].type===u.Type.INTEGER?ne=U.value[0].value:U.value.length>1&&(ne=U.value[1].value),null!==ne&&(O.pathLenConstraint=u.derToInteger(ne))}else if("extKeyUsage"===O.name){U=u.fromDer(O.value);for(var G=0;G1&&(L=U.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=[],U=u.fromDer(O.value);for(var Z,W=0;W=k&&C0&&L.value.push(g.certificateExtensionsToAsn1(C.extensions)),L},g.getCertificationRequestInfo=function(C){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.version).getBytes()),I(C.subject),g.publicKeyToAsn1(C.publicKey),M(C)])},g.distinguishedNameToAsn1=function(C){return I(C)},g.certificateToAsn1=function(C){var O=C.tbsCertificate||g.getTBSCertificate(C);return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[O,u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(C.signatureOid).getBytes()),T(C.signatureOid,C.signatureParameters)]),u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,String.fromCharCode(0)+C.signature)])},g.certificateExtensionsToAsn1=function(C){var O=u.create(u.Class.CONTEXT_SPECIFIC,3,!0,[]),U=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);O.value.push(U);for(var L=0;L"u"&&(H=new Date);var ne=!0,G=null,ee=0;do{var Z=O.shift(),W=null,te=!1;if(H&&(HZ.validity.notAfter)&&(G={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:Z.validity.notBefore,notAfter:Z.validity.notAfter,now:H}),null===G){if(null===(W=O[0]||C.getIssuer(Z))&&Z.isIssuer(Z)&&(te=!0,W=Z),W){var oe=W;y.util.isArray(oe)||(oe=[oe]);for(var de=!1;!de&&oe.length>0;){W=oe.shift();try{de=W.verify(Z)}catch{}}de||(G={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===G&&(!W||te)&&!C.hasCertificate(Z)&&(G={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===G&&W&&!Z.isIssuer(W)&&(G={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===G)for(var he={keyUsage:!0,basicConstraints:!0},Pe=0;null===G&&PeBe.pathLenConstraint&&(G={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var ke=null===G||G.error,nt=U.verify?U.verify(ke,ee,L):ke;if(!0!==nt)throw!0===ke&&(G={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate}),(nt||0===nt)&&("object"!=typeof nt||y.util.isArray(nt)?"string"==typeof nt&&(G.error=nt):(nt.message&&(G.message=nt.message),nt.error&&(G.error=nt.error))),G;G=null,ne=!1,++ee}while(O.length>0);return!0}},1638:Q=>{"use strict";Q.exports=()=>{const x={};return x.promise=new Promise((y,u)=>{x.resolve=y,x.reject=u}),x}},3904:(Q,K,x)=>{const y=x(8317),u=x(1638);Q.exports=class{constructor(){this._buffer=new y,this._waitingConsumers=new y}push(w){const{promise:m,resolve:h}=u();return this._buffer.push({chunk:w,resolve:h}),this._consume(),m}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const w=this._waitingConsumers.shift(),m=this._buffer.shift();w.resolve(m.chunk),m.resolve()}}shift(){const{promise:w,resolve:m}=u();return this._waitingConsumers.push({resolve:m}),this._consume(),w}isEmpty(){return this._buffer.isEmpty()}}},6216:(Q,K,x)=>{"use strict";Q.exports=x(1908).default},1908:function(Q,K,x){"use strict";var y=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(K,"__esModule",{value:!0});const u=x(2953),g=y(x(8035)),w=y(x(9809)),m=x(8399),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map(b=>new u.Netmask(b));function d(b){return/^::$/.test(b)||/^::1$/.test(b)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(b)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(b)||/^ff([0-9a-fA-F]{2,2}):/i.test(b)}K.default=b=>{if((0,m.isValid)(b)){const S=(0,m.parse)(b);if("ipv4"===S.kind())return function f(b){for(let S of c)if(S.contains(b))return!0;return!1}(S.toNormalizedString());if("ipv6"===S.kind())return d(b)}else if((0,w.default)(b)&&g.default.v6().test(b))return d(b)}},5477:(Q,K,x)=>{"use strict";Q.exports=x(8212)},8212:(Q,K,x)=>{"use strict";var y=K;function u(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(9648),y.BufferWriter=x(3485),y.Reader=x(1262),y.BufferReader=x(4227),y.util=x(9449),y.rpc=x(8858),y.roots=x(7859),y.configure=u,u()},1262:(Q,K,x)=>{"use strict";Q.exports=h;var u,y=x(9449),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new u(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){u=E,h.create=f(),u._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},4227:(Q,K,x)=>{"use strict";Q.exports=g;var y=x(1262);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(9449);function g(w){y.call(this,w)}g._configure=function(){u.Buffer&&(g.prototype._slice=u.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},7859:Q=>{"use strict";Q.exports={}},8858:(Q,K,x)=>{"use strict";K.Service=x(4523)},4523:(Q,K,x)=>{"use strict";Q.exports=u;var y=x(9449);function u(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(u.prototype=Object.create(y.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},u.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},4185:(Q,K,x)=>{"use strict";Q.exports=u;var y=x(9449);function u(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=u.zero=new u(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new u(d,b)},u.from=function(c){if("number"==typeof c)return u.fromNumber(c);if(y.isString(c)){if(!y.Long)return u.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new u(c.low>>>0,c.high>>>0):g},u.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;u.fromHash=function(c){return c===w?g:new u((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},u.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},u.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},u.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},u.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},9449:function(Q,K,x){"use strict";var y=K;function u(w,m,h){for(var c=Object.keys(m),f=0;f0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=u,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Q.exports=d;var u,y=x(9449),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new u})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){u=P,d.create=b(),u._configure()}},3485:(Q,K,x)=>{"use strict";Q.exports=g;var y=x(9648);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(9449);function g(){y.call(this)}function w(m,h,c){m.length<40?u.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=u.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},7981:(Q,K,x)=>{"use strict";Q.exports=x(2382)},8758:Q=>{"use strict";Q.exports=x;var y,K=/\/|\./;function x(u,g){K.test(u)||(u="google/protobuf/"+u+".proto",g={nested:{google:{nested:{protobuf:{nested:g}}}}}),x[u]=g}x("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),x("duration",{Duration:y={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),x("timestamp",{Timestamp:y}),x("empty",{Empty:{fields:{}}}),x("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),x("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),x("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),x.get=function(g){return x[g]||null}},6839:(Q,K,x)=>{"use strict";var y=K,u=x(4080),g=x(7695);function w(h,c,f,d){if(c.resolvedType)if(c.resolvedType instanceof u){h("switch(d%s){",d);for(var b=c.resolvedType.values,S=Object.keys(b),E=0;E>>0",d,d);break;case"int32":case"sint32":case"sfixed32":h("m%s=d%s|0",d,d);break;case"uint64":v=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,v)('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,v?"true":"");break;case"bytes":h('if(typeof d%s==="string")',d)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",d,d,d)("else if(d%s.length >= 0)",d)("m%s=d%s",d,d);break;case"string":h("m%s=String(d%s)",d,d);break;case"bool":h("m%s=Boolean(d%s)",d,d)}}return h}function m(h,c,f,d){if(c.resolvedType)c.resolvedType instanceof u?h("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,f,d,d,f,d,d):h("d%s=types[%i].toObject(m%s,o)",d,f,d);else{var b=!1;switch(c.type){case"double":case"float":h("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":b=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h('if(typeof m%s==="number")',d)("d%s=o.longs===String?String(m%s):m%s",d,d,d)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",d,d,d,d,b?"true":"",d);break;case"bytes":h("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",d,d,d,d,d);break;default:h("d%s=m%s",d,d)}}return h}y.fromObject=function(c){var f=c.fieldsArray,d=g.codegen(["d"],c.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!f.length)return d("return new this.ctor");d("var m=new this.ctor");for(var b=0;b{"use strict";Q.exports=function m(h){var c=g.codegen(["r","l"],h.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(h.fieldsArray.filter(function(v){return v.map}).length?",k,value":""))("while(r.pos>>3){");for(var f=0;f>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===u.basic[b]?c("value=types[%i].decode(r,r.uint32())",f):c("value=r.%s()",b),c("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c(void 0!==u.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",S)):d.repeated?(c("if(!(%s&&%s.length))",S,S)("%s=[]",S),void 0!==u.packed[b]&&c("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";Q.exports=function m(h){for(var d,c=g.codegen(["m","w"],h.name+"$encode")("if(!w)")("w=Writer.create()"),b=h.fieldsArray.slice().sort(g.compareFieldsById),f=0;f>>0,8|u.mapKey[S.keyType],S.keyType),void 0===p?c("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",E,d):c(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,v,d),c("}")("}")):S.repeated?(c("if(%s!=null&&%s.length){",d,d),S.packed&&void 0!==u.packed[v]?c("w.uint32(%i).fork()",(S.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",d)("w.%s(%s[i])",v,d)("w.ldelim()"):(c("for(var i=0;i<%s.length;++i)",d),void 0===p?w(c,S,E,d+"[i]"):c("w.uint32(%i).%s(%s[i])",(S.id<<3|p)>>>0,v,d)),c("}")):(S.optional&&c("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,S.name),void 0===p?w(c,S,E,d):c("w.uint32(%i).%s(%s)",(S.id<<3|p)>>>0,v,d))}return c("return w")};var y=x(4080),u=x(1431),g=x(7695);function w(h,c,f,d){return c.resolvedType.group?h("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",f,d,(c.id<<3|3)>>>0,(c.id<<3|4)>>>0):h("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",f,d,(c.id<<3|2)>>>0)}},4080:(Q,K,x)=>{"use strict";Q.exports=w;var y=x(7108);((w.prototype=Object.create(y.prototype)).constructor=w).className="Enum";var u=x(9404),g=x(7695);function w(m,h,c,f,d,b){if(y.call(this,m,c),h&&"object"!=typeof h)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=f,this.comments=d||{},this.valuesOptions=b,this.reserved=void 0,h)for(var S=Object.keys(h),E=0;E{"use strict";Q.exports=c;var y=x(7108);((c.prototype=Object.create(y.prototype)).constructor=c).className="Field";var m,u=x(4080),g=x(1431),w=x(7695),h=/^required|optional|repeated$/;function c(f,d,b,S,E,v,p){if(w.isObject(S)?(p=E,v=S,S=E=void 0):w.isObject(E)&&(p=v,v=E,E=void 0),y.call(this,f,v),!w.isInteger(d)||d<0)throw TypeError("id must be a non-negative integer");if(!w.isString(b))throw TypeError("type must be a string");if(void 0!==S&&!h.test(S=S.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==E&&!w.isString(E))throw TypeError("extend must be a string");"proto3_optional"===S&&(S="optional"),this.rule=S&&"optional"!==S?S:void 0,this.type=b,this.id=d,this.extend=E||void 0,this.required="required"===S,this.optional=!this.required,this.repeated="repeated"===S,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!w.Long&&void 0!==g.long[b],this.bytes="bytes"===b,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=p}c.fromJSON=function(d,b){return new c(d,b.id,b.type,b.rule,b.extend,b.options,b.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(d,b,S){return"packed"===d&&(this._packed=null),y.prototype.setOption.call(this,d,b,S)},c.prototype.toJSON=function(d){var b=!!d&&Boolean(d.keepComments);return w.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",b?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=g.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.typeDefault=this.resolvedType instanceof m?null:this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof u&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&((!0===this.options.packed||void 0!==this.options.packed&&this.resolvedType&&!(this.resolvedType instanceof u))&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=w.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var d;w.base64.test(this.typeDefault)?w.base64.decode(this.typeDefault,d=w.newBuffer(w.base64.length(this.typeDefault)),0):w.utf8.write(this.typeDefault,d=w.newBuffer(w.utf8.length(this.typeDefault)),0),this.typeDefault=d}return this.defaultValue=this.map?w.emptyObject:this.repeated?w.emptyArray:this.typeDefault,this.parent instanceof m&&(this.parent.ctor.prototype[this.name]=this.defaultValue),y.prototype.resolve.call(this)},c.d=function(d,b,S,E){return"function"==typeof b?b=w.decorateType(b).name:b&&"object"==typeof b&&(b=w.decorateEnum(b).name),function(p,I){w.decorateType(p.constructor).add(new c(I,d,b,S,{default:E}))}},c._configure=function(d){m=d}},6093:(Q,K,x)=>{"use strict";var y=Q.exports=x(3531);y.build="light",y.load=function u(w,m,h){return"function"==typeof m?(h=m,m=new y.Root):m||(m=new y.Root),m.load(w,h)},y.loadSync=function g(w,m){return m||(m=new y.Root),m.loadSync(w)},y.encoder=x(8350),y.decoder=x(4866),y.verifier=x(4607),y.converter=x(6839),y.ReflectionObject=x(7108),y.Namespace=x(9404),y.Root=x(2796),y.Enum=x(4080),y.Type=x(9697),y.Field=x(7937),y.OneOf=x(8967),y.MapField=x(2319),y.Service=x(2839),y.Method=x(1892),y.Message=x(3535),y.wrappers=x(3534),y.types=x(1431),y.util=x(7695),y.ReflectionObject._configure(y.Root),y.Namespace._configure(y.Type,y.Service,y.Enum),y.Root._configure(y.Type),y.Field._configure(y.Type)},3531:(Q,K,x)=>{"use strict";var y=K;function u(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(3459),y.BufferWriter=x(6688),y.Reader=x(1662),y.BufferReader=x(1396),y.util=x(6504),y.rpc=x(4081),y.roots=x(4661),y.configure=u,u()},2382:(Q,K,x)=>{"use strict";var y=Q.exports=x(6093);y.build="full",y.tokenize=x(5638),y.parse=x(3629),y.common=x(8758),y.Root._configure(y.Type,y.parse,y.common)},2319:(Q,K,x)=>{"use strict";Q.exports=w;var y=x(7937);((w.prototype=Object.create(y.prototype)).constructor=w).className="MapField";var u=x(1431),g=x(7695);function w(m,h,c,f,d,b){if(y.call(this,m,h,f,void 0,void 0,d,b),!g.isString(c))throw TypeError("keyType must be a string");this.keyType=c,this.resolvedKeyType=null,this.map=!0}w.fromJSON=function(h,c){return new w(h,c.id,c.keyType,c.type,c.options,c.comment)},w.prototype.toJSON=function(h){var c=!!h&&Boolean(h.keepComments);return g.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",c?this.comment:void 0])},w.prototype.resolve=function(){if(this.resolved)return this;if(void 0===u.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return y.prototype.resolve.call(this)},w.d=function(h,c,f){return"function"==typeof f?f=g.decorateType(f).name:f&&"object"==typeof f&&(f=g.decorateEnum(f).name),function(b,S){g.decorateType(b.constructor).add(new w(S,h,c,f))}}},3535:(Q,K,x)=>{"use strict";Q.exports=u;var y=x(6504);function u(g){if(g)for(var w=Object.keys(g),m=0;m{"use strict";Q.exports=g;var y=x(7108);((g.prototype=Object.create(y.prototype)).constructor=g).className="Method";var u=x(7695);function g(w,m,h,c,f,d,b,S,E){if(u.isObject(f)?(b=f,f=d=void 0):u.isObject(d)&&(b=d,d=void 0),void 0!==m&&!u.isString(m))throw TypeError("type must be a string");if(!u.isString(h))throw TypeError("requestType must be a string");if(!u.isString(c))throw TypeError("responseType must be a string");y.call(this,w,b),this.type=m||"rpc",this.requestType=h,this.requestStream=!!f||void 0,this.responseType=c,this.responseStream=!!d||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=S,this.parsedOptions=E}g.fromJSON=function(m,h){return new g(m,h.type,h.requestType,h.responseType,h.requestStream,h.responseStream,h.options,h.comment,h.parsedOptions)},g.prototype.toJSON=function(m){var h=!!m&&Boolean(m.keepComments);return u.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",h?this.comment:void 0,"parsedOptions",this.parsedOptions])},g.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),y.prototype.resolve.call(this))}},9404:(Q,K,x)=>{"use strict";Q.exports=d;var y=x(7108);((d.prototype=Object.create(y.prototype)).constructor=d).className="Namespace";var m,h,c,u=x(7937),g=x(7695),w=x(8967);function f(S,E){if(S&&S.length){for(var v={},p=0;pv)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p0;){var I=E.shift();if(p.nested&&p.nested[I]){if(!((p=p.nested[I])instanceof d))throw Error("path conflicts with non-namespace objects")}else p.add(p=new d(I))}return v&&p.addJSON(v),p},d.prototype.resolveAll=function(){for(var E=this.nestedArray,v=0;v-1)return I}else if(I instanceof d&&(I=I.lookup(E.slice(1),v,!0)))return I}else for(var A=0;A{"use strict";Q.exports=g,g.className="ReflectionObject";var u,y=x(7695);function g(w,m){if(!y.isString(w))throw TypeError("name must be a string");if(m&&!y.isObject(m))throw TypeError("options must be an object");this.options=m,this.parsedOptions=null,this.name=w,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(g.prototype,{root:{get:function(){for(var w=this;null!==w.parent;)w=w.parent;return w}},fullName:{get:function(){for(var w=[this.name],m=this.parent;m;)w.unshift(m.name),m=m.parent;return w.join(".")}}}),g.prototype.toJSON=function(){throw Error()},g.prototype.onAdd=function(m){this.parent&&this.parent!==m&&this.parent.remove(this),this.parent=m,this.resolved=!1;var h=m.root;h instanceof u&&h._handleAdd(this)},g.prototype.onRemove=function(m){var h=m.root;h instanceof u&&h._handleRemove(this),this.parent=null,this.resolved=!1},g.prototype.resolve=function(){return this.resolved||this.root instanceof u&&(this.resolved=!0),this},g.prototype.getOption=function(m){if(this.options)return this.options[m]},g.prototype.setOption=function(m,h,c){return(!c||!this.options||void 0===this.options[m])&&((this.options||(this.options={}))[m]=h),this},g.prototype.setParsedOption=function(m,h,c){this.parsedOptions||(this.parsedOptions=[]);var f=this.parsedOptions;if(c){var d=f.find(function(E){return Object.prototype.hasOwnProperty.call(E,m)});d?y.setProperty(d[m],c,h):((d={})[m]=y.setProperty({},c,h),f.push(d))}else{var S={};S[m]=h,f.push(S)}return this},g.prototype.setOptions=function(m,h){if(m)for(var c=Object.keys(m),f=0;f{"use strict";Q.exports=w;var y=x(7108);((w.prototype=Object.create(y.prototype)).constructor=w).className="OneOf";var u=x(7937),g=x(7695);function w(h,c,f,d){if(Array.isArray(c)||(f=c,c=void 0),y.call(this,h,f),void 0!==c&&!Array.isArray(c))throw TypeError("fieldNames must be an Array");this.oneof=c||[],this.fieldsArray=[],this.comment=d}function m(h){if(h.parent)for(var c=0;c-1&&this.oneof.splice(f,1),c.partOf=null,this},w.prototype.onAdd=function(c){y.prototype.onAdd.call(this,c);for(var d=0;d{"use strict";Q.exports=F,F.filename=null,F.defaults={keepCase:!1};var y=x(5638),u=x(2796),g=x(9697),w=x(7937),m=x(2319),h=x(8967),c=x(4080),f=x(2839),d=x(1892),b=x(1431),S=x(7695),E=/^[1-9][0-9]*$/,v=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,I=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,D=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,T=/^[a-zA-Z_][a-zA-Z_0-9]*$/,M=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F($,C,O){C instanceof u||(O=C,C=new u),O||(O=F.defaults);var te,oe,de,he,Ue,U=O.preferTrailingComment||!1,L=y($,O.alternateCommentMode||!1),H=L.next,ne=L.push,G=L.peek,ee=L.skip,Z=L.cmnt,W=!0,Pe=!1,De=C,Be=O.keepCase?function(Ee){return Ee}:S.camelCase;function ve(Ee,pe,_e){var Le=F.filename;return _e||(F.filename=null),Error("illegal "+(pe||"token")+" '"+Ee+"' ("+(Le?Le+", ":"")+"line "+L.line+")")}function He(){var pe,Ee=[];do{if('"'!==(pe=H())&&"'"!==pe)throw ve(pe);Ee.push(H()),ee(pe),pe=G()}while('"'===pe||"'"===pe);return Ee.join("")}function ke(Ee){var pe=H();switch(pe){case"'":case'"':return ne(pe),He();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Pt(Ee,pe){var _e=1;switch("-"===Ee.charAt(0)&&(_e=-1,Ee=Ee.substring(1)),Ee){case"inf":case"INF":case"Inf":return _e*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(E.test(Ee))return _e*parseInt(Ee,10);if(p.test(Ee))return _e*parseInt(Ee,16);if(A.test(Ee))return _e*parseInt(Ee,8);if(D.test(Ee))return _e*parseFloat(Ee);throw ve(Ee,"number",pe)}(pe,!0)}catch{if(Ee&&M.test(pe))return pe;throw ve(pe,"value")}}function nt(Ee,pe){var _e,Le;do{!pe||'"'!==(_e=G())&&"'"!==_e?Ee.push([Le=_t(H()),ee("to",!0)?_t(H()):Le]):Ee.push(He())}while(ee(",",!0));ee(";")}function _t(Ee,pe){switch(Ee){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!pe&&"-"===Ee.charAt(0))throw ve(Ee,"id");if(v.test(Ee))return parseInt(Ee,10);if(I.test(Ee))return parseInt(Ee,16);if(P.test(Ee))return parseInt(Ee,8);throw ve(Ee,"id")}function Vt(){if(void 0!==te)throw ve("package");if(te=H(),!M.test(te))throw ve(te,"name");De=De.define(te),ee(";")}function Yt(){var pe,Ee=G();switch(Ee){case"weak":pe=de||(de=[]),H();break;case"public":H();default:pe=oe||(oe=[])}Ee=He(),ee(";"),pe.push(Ee)}function nn(){if(ee("="),he=He(),!(Pe="proto3"===he)&&"proto2"!==he)throw ve(he,"syntax");ee(";")}function cn(Ee,pe){switch(pe){case"option":return ge(Ee,pe),ee(";"),!0;case"message":return Tr(Ee,pe),!0;case"enum":return re(Ee,pe),!0;case"service":return function je(Ee,pe){if(!T.test(pe=H()))throw ve(pe,"service name");var _e=new f(pe);$n(_e,function(Ne){if(!cn(_e,Ne)){if("rpc"!==Ne)throw ve(Ne);!function Je(Ee,pe){var _e=Z(),Le=pe;if(!T.test(pe=H()))throw ve(pe,"name");var at,Nt,ft,qe,Ne=pe;if(ee("("),ee("stream",!0)&&(Nt=!0),!M.test(pe=H())||(at=pe,ee(")"),ee("returns"),ee("("),ee("stream",!0)&&(qe=!0),!M.test(pe=H())))throw ve(pe);ft=pe,ee(")");var jn=new d(Ne,Le,at,ft,Nt,qe);jn.comment=_e,$n(jn,function(Tn){if("option"!==Tn)throw ve(Tn);ge(jn,Tn),ee(";")}),Ee.add(jn)}(_e,Ne)}}),Ee.add(_e)}(Ee,pe),!0;case"extend":return function Xe(Ee,pe){if(!M.test(pe=H()))throw ve(pe,"reference");var _e=pe;$n(null,function(Ne){switch(Ne){case"required":case"repeated":_n(Ee,Ne,_e);break;case"optional":_n(Ee,Pe?"proto3_optional":"optional",_e);break;default:if(!Pe||!M.test(Ne))throw ve(Ne);ne(Ne),_n(Ee,"optional",_e)}})}(Ee,pe),!0}return!1}function $n(Ee,pe,_e){var Le=L.line;if(Ee&&("string"!=typeof Ee.comment&&(Ee.comment=Z()),Ee.filename=F.filename),ee("{",!0)){for(var Ne;"}"!==(Ne=H());)pe(Ne);ee(";",!0)}else _e&&_e(),ee(";"),Ee&&("string"!=typeof Ee.comment||U)&&(Ee.comment=Z(Le)||Ee.comment)}function Tr(Ee,pe){if(!T.test(pe=H()))throw ve(pe,"type name");var _e=new g(pe);$n(_e,function(Ne){if(!cn(_e,Ne))switch(Ne){case"map":!function Qr(Ee){ee("<");var pe=H();if(void 0===b.mapKey[pe])throw ve(pe,"type");ee(",");var _e=H();if(!M.test(_e))throw ve(_e,"type");ee(">");var Le=H();if(!T.test(Le))throw ve(Le,"name");ee("=");var Ne=new m(Be(Le),_t(H()),pe,_e);$n(Ne,function(Nt){if("option"!==Nt)throw ve(Nt);ge(Ne,Nt),ee(";")},function(){ze(Ne)}),Ee.add(Ne)}(_e);break;case"required":case"repeated":_n(_e,Ne);break;case"optional":_n(_e,Pe?"proto3_optional":"optional");break;case"oneof":!function es(Ee,pe){if(!T.test(pe=H()))throw ve(pe,"name");var _e=new h(Be(pe));$n(_e,function(Ne){"option"===Ne?(ge(_e,Ne),ee(";")):(ne(Ne),_n(_e,"optional"))}),Ee.add(_e)}(_e,Ne);break;case"extensions":nt(_e.extensions||(_e.extensions=[]));break;case"reserved":nt(_e.reserved||(_e.reserved=[]),!0);break;default:if(!Pe||!M.test(Ne))throw ve(Ne);ne(Ne),_n(_e,"optional")}}),Ee.add(_e)}function _n(Ee,pe,_e){var Le=H();if("group"!==Le){if(!M.test(Le))throw ve(Le,"type");var Ne=H();if(!T.test(Ne))throw ve(Ne,"name");Ne=Be(Ne),ee("=");var at=new w(Ne,_t(H()),Le,pe,_e);if($n(at,function(qe){if("option"!==qe)throw ve(qe);ge(at,qe),ee(";")},function(){ze(at)}),"proto3_optional"===pe){var Nt=new h("_"+Ne);at.setOption("proto3_optional",!0),Nt.add(at),Ee.add(Nt)}else Ee.add(at);!Pe&&at.repeated&&(void 0!==b.packed[Le]||void 0===b.basic[Le])&&at.setOption("packed",!1,!0)}else!function Oi(Ee,pe){var _e=H();if(!T.test(_e))throw ve(_e,"name");var Le=S.lcFirst(_e);_e===Le&&(_e=S.ucFirst(_e)),ee("=");var Ne=_t(H()),at=new g(_e);at.group=!0;var Nt=new w(Le,Ne,_e,pe);Nt.filename=F.filename,$n(at,function(qe){switch(qe){case"option":ge(at,qe),ee(";");break;case"required":case"repeated":_n(at,qe);break;case"optional":_n(at,Pe?"proto3_optional":"optional");break;case"message":Tr(at,qe);break;case"enum":re(at,qe);break;default:throw ve(qe)}}),Ee.add(at).add(Nt)}(Ee,pe)}function re(Ee,pe){if(!T.test(pe=H()))throw ve(pe,"name");var _e=new c(pe);$n(_e,function(Ne){switch(Ne){case"option":ge(_e,Ne),ee(";");break;case"reserved":nt(_e.reserved||(_e.reserved=[]),!0);break;default:!function le(Ee,pe){if(!T.test(pe))throw ve(pe,"name");ee("=");var _e=_t(H(),!0),Le={options:void 0,setOption:function(Ne,at){void 0===this.options&&(this.options={}),this.options[Ne]=at}};$n(Le,function(at){if("option"!==at)throw ve(at);ge(Le,at),ee(";")},function(){ze(Le)}),Ee.add(pe,_e,Le.comment,Le.options)}(_e,Ne)}}),Ee.add(_e)}function ge(Ee,pe){var _e=ee("(",!0);if(!M.test(pe=H()))throw ve(pe,"name");var at,Le=pe,Ne=Le;_e&&(ee(")"),Ne=Le="("+Le+")",pe=G(),k.test(pe)&&(at=pe.slice(1),Le+=pe,H())),ee("="),function xe(Ee,pe,_e,Le){Ee.setParsedOption&&Ee.setParsedOption(pe,_e,Le)}(Ee,Ne,ye(Ee,Le),at)}function ye(Ee,pe){if(ee("{",!0)){for(var _e={};!ee("}",!0);){if(!T.test(Ue=H()))throw ve(Ue,"name");var Le,Ne=Ue;if(ee(":",!0),"{"===G())Le=ye(Ee,pe+"."+Ue);else if("["===G()){var at;if(Le=[],ee("[",!0)){do{at=ke(!0),Le.push(at)}while(ee(",",!0));ee("]"),typeof at<"u"&&be(Ee,pe+"."+Ue,at)}}else Le=ke(!0),be(Ee,pe+"."+Ue,Le);var Nt=_e[Ne];Nt&&(Le=[].concat(Nt).concat(Le)),_e[Ne]=Le,ee(",",!0),ee(";",!0)}return _e}var ft=ke(!0);return be(Ee,pe,ft),ft}function be(Ee,pe,_e){Ee.setOption&&Ee.setOption(pe,_e)}function ze(Ee){if(ee("[",!0)){do{ge(Ee,"option")}while(ee(",",!0));ee("]")}return Ee}for(;null!==(Ue=H());)switch(Ue){case"package":if(!W)throw ve(Ue);Vt();break;case"import":if(!W)throw ve(Ue);Yt();break;case"syntax":if(!W)throw ve(Ue);nn();break;case"option":ge(De,Ue),ee(";");break;default:if(cn(De,Ue)){W=!1;continue}throw ve(Ue)}return F.filename=null,{package:te,imports:oe,weakImports:de,syntax:he,root:C}}},1662:(Q,K,x)=>{"use strict";Q.exports=h;var u,y=x(6504),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new u(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){u=E,h.create=f(),u._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},1396:(Q,K,x)=>{"use strict";Q.exports=g;var y=x(1662);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(6504);function g(w){y.call(this,w)}g._configure=function(){u.Buffer&&(g.prototype._slice=u.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},2796:(Q,K,x)=>{"use strict";Q.exports=d;var y=x(9404);((d.prototype=Object.create(y.prototype)).constructor=d).className="Root";var h,c,f,u=x(7937),g=x(4080),w=x(8967),m=x(7695);function d(v){y.call(this,"",v),this.deferred=[],this.files=[]}function b(){}d.fromJSON=function(p,I){return I||(I=new d),p.options&&I.setOptions(p.options),I.addJSON(p.nested)},d.prototype.resolvePath=m.path.resolve,d.prototype.fetch=m.fetch,d.prototype.load=function v(p,I,A){"function"==typeof I&&(A=I,I=void 0);var P=this;if(!A)return m.asPromise(v,P,p,I);var D=A===b;function T(U,L){if(A){var H=A;if(A=null,D)throw U;H(U,L)}}function M(U){var L=U.lastIndexOf("google/protobuf/");if(L>-1){var H=U.substring(L);if(H in f)return H}return null}function k(U,L){try{if(m.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),m.isString(L)){c.filename=U;var ne,H=c(L,P,I),G=0;if(H.imports)for(;G-1)){if(P.files.push(U),U in f)return void(D?k(U,f[U]):(++$,setTimeout(function(){--$,k(U,f[U])})));if(D){var H;try{H=m.fs.readFileSync(U).toString("utf8")}catch(ne){return void(L||T(ne))}k(U,H)}else++$,P.fetch(U,function(ne,G){if(--$,A){if(ne)return void(L?$||T(null,P):T(ne));k(U,G)}})}}var $=0;m.isString(p)&&(p=[p]);for(var O,C=0;C-1&&this.deferred.splice(I,1)}}else if(p instanceof g)S.test(p.name)&&delete p.parent[p.name];else if(p instanceof y){for(var A=0;A{"use strict";Q.exports={}},4081:(Q,K,x)=>{"use strict";K.Service=x(5261)},5261:(Q,K,x)=>{"use strict";Q.exports=u;var y=x(6504);function u(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(u.prototype=Object.create(y.EventEmitter.prototype)).constructor=u,u.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},u.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},2839:(Q,K,x)=>{"use strict";Q.exports=m;var y=x(9404);((m.prototype=Object.create(y.prototype)).constructor=m).className="Service";var u=x(1892),g=x(7695),w=x(4081);function m(c,f){y.call(this,c,f),this.methods={},this._methodsArray=null}function h(c){return c._methodsArray=null,c}m.fromJSON=function(f,d){var b=new m(f,d.options);if(d.methods)for(var S=Object.keys(d.methods),E=0;E{"use strict";Q.exports=d;var K=/[\s{}=;:[\],'"()<>]/g,x=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,y=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,u=/^ *[*/]+ */,g=/^\s*\*?\/*/,w=/\n/g,m=/\s/,h=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function f(b){return b.replace(h,function(S,E){switch(E){case"\\":case"":return E;default:return c[E]||""}})}function d(b,S){b=b.toString();var E=0,v=b.length,p=1,I=0,A={},P=[],D=null;function T(G){return Error("illegal "+G+" (line "+p+")")}function k(G){return b.charAt(G)}function F(G,ee,Z){var de,W={type:b.charAt(G++),lineEmpty:!1,leading:Z},oe=G-(S?2:3);do{if(--oe<0||"\n"===(de=b.charAt(oe))){W.lineEmpty=!0;break}}while(" "===de||"\t"===de);for(var he=b.substring(G,ee).split(w),Pe=0;Pe0)return P.shift();if(D)return function M(){var G="'"===D?y:x;G.lastIndex=E-1;var ee=G.exec(b);if(!ee)throw T("string");return E=G.lastIndex,U(D),D=null,f(ee[1])}();var G,ee,Z,W,te,oe=0===E;do{if(E===v)return null;for(G=!1;m.test(Z=k(E));)if("\n"===Z&&(oe=!0,++p),++E===v)return null;if("/"===k(E)){if(++E===v)throw T("comment");if("/"===k(E))if(S){if(W=E,te=!1,$(E)){te=!0;do{if((E=C(E))===v||(E++,!oe))break}while($(E))}else E=Math.min(v,C(E)+1);te&&(F(W,E,oe),oe=!0),p++,G=!0}else{for(te="/"===k(W=E+1);"\n"!==k(++E);)if(E===v)return null;++E,te&&(F(W,E-1,oe),oe=!0),++p,G=!0}else{if("*"!==(Z=k(E)))return"/";W=E+1,te=S||"*"===k(W);do{if("\n"===Z&&++p,++E===v)throw T("comment");ee=Z,Z=k(E)}while("*"!==ee||"/"!==Z);++E,te&&(F(W,E-2,oe),oe=!0),G=!0}}}while(G);var de=E;if(K.lastIndex=0,!K.test(k(de++)))for(;de{"use strict";Q.exports=A;var y=x(9404);((A.prototype=Object.create(y.prototype)).constructor=A).className="Type";var u=x(4080),g=x(8967),w=x(7937),m=x(2319),h=x(2839),c=x(3535),f=x(1662),d=x(3459),b=x(7695),S=x(8350),E=x(4866),v=x(4607),p=x(6839),I=x(3534);function A(D,T){y.call(this,D,T),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function P(D){return D._fieldsById=D._fieldsArray=D._oneofsArray=null,delete D.encode,delete D.decode,delete D.verify,D}Object.defineProperties(A.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var D=Object.keys(this.fields),T=0;T{"use strict";var y=K,u=x(7695),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function w(m,h){var c=0,f={};for(h|=0;c{"use strict";var g,w,y=Q.exports=x(6504),u=x(4661);y.codegen=x(9810),y.fetch=x(1159),y.path=x(2175),y.fs=y.inquire("fs"),y.toArray=function(b){if(b){for(var S=Object.keys(b),E=new Array(S.length),v=0;v0)p[P]=v(p[P]||{},I,A);else{var D=p[P];D&&(A=[].concat(D).concat(A)),p[P]=A}return p}(b,S=S.split("."),E)},Object.defineProperty(y,"decorateRoot",{get:function(){return u.decorated||(u.decorated=new(x(2796)))}})},8468:(Q,K,x)=>{"use strict";Q.exports=u;var y=x(6504);function u(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=u.zero=new u(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=u.zeroHash="\0\0\0\0\0\0\0\0";u.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new u(d,b)},u.from=function(c){if("number"==typeof c)return u.fromNumber(c);if(y.isString(c)){if(!y.Long)return u.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new u(c.low>>>0,c.high>>>0):g},u.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},u.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;u.fromHash=function(c){return c===w?g:new u((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},u.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},u.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},u.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},u.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},6504:function(Q,K,x){"use strict";var y=K;function u(w,m,h){for(var c=Object.keys(m),f=0;fw,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),m}y.asPromise=x(253),y.base64=x(8475),y.EventEmitter=x(4166),y.float=x(3753),y.inquire=x(4343),y.utf8=x(9865),y.pool=x(4352),y.LongBits=x(8468),y.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),y.global=y.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,y.emptyArray=Object.freeze?Object.freeze([]):[],y.emptyObject=Object.freeze?Object.freeze({}):{},y.isInteger=Number.isInteger||function(m){return"number"==typeof m&&isFinite(m)&&Math.floor(m)===m},y.isString=function(m){return"string"==typeof m||m instanceof String},y.isObject=function(m){return m&&"object"==typeof m},y.isset=y.isSet=function(m,h){var c=m[h];return!(null==c||!m.hasOwnProperty(h))&&("object"!=typeof c||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=u,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Q.exports=function h(c){var f=u.codegen(["m"],c.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),b={};c.oneofsArray.length&&f("var p={}");for(var S=0;S{"use strict";var y=K,u=x(3535);y[".google.protobuf.Any"]={fromObject:function(g){if(g&&g["@type"]){var w=g["@type"].substring(g["@type"].lastIndexOf("/")+1),m=this.lookup(w);if(m){var h="."===g["@type"].charAt(0)?g["@type"].slice(1):g["@type"];return-1===h.indexOf("/")&&(h="/"+h),this.create({type_url:h,value:m.encode(m.fromObject(g)).finish()})}}return this.fromObject(g)},toObject:function(g,w){var h="",c="";if(w&&w.json&&g.type_url&&g.value){c=g.type_url.substring(g.type_url.lastIndexOf("/")+1),h=g.type_url.substring(0,g.type_url.lastIndexOf("/")+1);var f=this.lookup(c);f&&(g=f.decode(g.value))}if(!(g instanceof this.ctor)&&g instanceof u){var d=g.$type.toObject(g,w),b="."===g.$type.fullName[0]?g.$type.fullName.slice(1):g.$type.fullName;return""===h&&(h="type.googleapis.com/"),d["@type"]=c=h+b,d}return this.toObject(g,w)}}},3459:(Q,K,x)=>{"use strict";Q.exports=d;var u,y=x(6504),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new u})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){u=P,d.create=b(),u._configure()}},6688:(Q,K,x)=>{"use strict";Q.exports=g;var y=x(3459);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(6504);function g(){y.call(this)}function w(m,h,c){m.length<40?u.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=u.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},9652:(Q,K,x)=>{const y=x(7310),u=x(9964),g=x(6111),w=x(7380),{RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c}=x(962),f=x(2296),d=x(6052),b=x(1028),S=x(5935),E=x(6154),v=x(2743),p=x(2854);Q.exports={RateLimiterRedis:y,RateLimiterMongo:u,RateLimiterMySQL:g,RateLimiterPostgres:w,RateLimiterMemory:f,RateLimiterMemcache:d,RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c,RLWrapperBlackAndWhite:b,RateLimiterUnion:S,RateLimiterQueue:E,BurstyRateLimiter:v,RateLimiterRes:p}},2743:(Q,K,x)=>{const y=x(2854);Q.exports=class{constructor(g,w){this._rateLimiter=g,this._burstLimiter=w}_combineRes(g,w){return new y(g.remainingPoints,Math.min(g.msBeforeNext,w.msBeforeNext),g.consumedPoints,g.isFirstInDuration)}consume(g,w=1,m={}){return this._rateLimiter.consume(g,w,m).catch(h=>h instanceof y?this._burstLimiter.consume(g,w,m).then(c=>Promise.resolve(this._combineRes(h,c))).catch(c=>Promise.reject(c instanceof y?this._combineRes(h,c):c)):Promise.reject(h))}get(g){return Promise.all([this._rateLimiter.get(g),this._burstLimiter.get(g)]).then(([w,m])=>this._combineRes(w,m))}get points(){return this._rateLimiter.points}}},1028:(Q,K,x)=>{const y=x(2854);Q.exports=class{constructor(g={}){this.limiter=g.limiter,this.blackList=g.blackList,this.whiteList=g.whiteList,this.isBlackListed=g.isBlackListed,this.isWhiteListed=g.isWhiteListed,this.runActionAnyway=g.runActionAnyway}get limiter(){return this._limiter}set limiter(g){if(typeof g>"u")throw new Error("limiter is not set");this._limiter=g}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(g){this._runActionAnyway=!(typeof g>"u")&&g}get blackList(){return this._blackList}set blackList(g){this._blackList=Array.isArray(g)?g:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isBlackListed must be function");this._isBlackListed=g}get whiteList(){return this._whiteList}set whiteList(g){this._whiteList=Array.isArray(g)?g:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isWhiteListed must be function");this._isWhiteListed=g}isBlackListedSomewhere(g){return this.blackList.indexOf(g)>=0||this.isBlackListed(g)}isWhiteListedSomewhere(g){return this.whiteList.indexOf(g)>=0||this.isWhiteListed(g)}getBlackRes(){return new y(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new y(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(g,w=1){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.rejectBlack()),typeof m>"u"?this.limiter.consume(g,w):(this.runActionAnyway&&this.limiter.consume(g,w).catch(()=>{}),m)}block(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.block(g,w):(this.runActionAnyway&&this.limiter.block(g,w).catch(()=>{}),m)}penalty(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.penalty(g,w):(this.runActionAnyway&&this.limiter.penalty(g,w).catch(()=>{}),m)}reward(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.reward(g,w):(this.runActionAnyway&&this.limiter.reward(g,w).catch(()=>{}),m)}get(g){let w;return this.isWhiteListedSomewhere(g)?w=this.resolveWhite():this.isBlackListedSomewhere(g)&&(w=this.resolveBlack()),typeof w>"u"||this.runActionAnyway?this.limiter.get(g):w}delete(g){return this.limiter.delete(g)}}},1468:Q=>{Q.exports=class{constructor(x={}){this.points=x.points,this.duration=x.duration,this.blockDuration=x.blockDuration,this.execEvenly=x.execEvenly,this.execEvenlyMinDelayMs=x.execEvenlyMinDelayMs,this.keyPrefix=x.keyPrefix}get points(){return this._points}set points(x){this._points=x>=0?x:4}get duration(){return this._duration}set duration(x){this._duration=typeof x>"u"?1:x}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(x){this._blockDuration=typeof x>"u"?0:x}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(x){this._execEvenly=!(typeof x>"u")&&Boolean(x)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(x){this._execEvenlyMinDelayMs=typeof x>"u"?Math.ceil(this.msDuration/this.points):x}get keyPrefix(){return this._keyPrefix}set keyPrefix(x){if(typeof x>"u"&&(x="rlflx"),"string"!=typeof x)throw new Error("keyPrefix must be string");this._keyPrefix=x}_getKeySecDuration(x={}){return x&&x.customDuration>=0?x.customDuration:this.duration}getKey(x){return this.keyPrefix.length>0?`${this.keyPrefix}:${x}`:x}parseKey(x){return x.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},962:(Q,K,x)=>{const y=x(7946),u=x(5768),g=x(1468),w=x(2296),m=x(2854),h="rate_limiter_flexible";let c=null;const f=function(D,T,M,k){let F;F=null===k||!0===k||!1===k?k:{remainingPoints:k.remainingPoints,msBeforeNext:k.msBeforeNext,consumedPoints:k.consumedPoints,isFirstInDuration:k.isFirstInDuration},D.send({channel:h,keyPrefix:T.keyPrefix,promiseId:T.promiseId,type:M,data:F})},d=function(D){setTimeout(()=>{this._initiated?process.send(D):typeof this._promises[D.promiseId]<"u"&&d.call(this,D)},30)},b=function(D,T,M,k,F){const $={channel:h,keyPrefix:this.keyPrefix,func:D,promiseId:T,data:{key:M,arg:k,opts:F}};this._initiated?process.send($):d.call(this,$)},S=function(D,T){if(!T||T.channel!==h||typeof this._rateLimiters[T.keyPrefix]>"u")return!1;let M;switch(T.func){case"consume":M=this._rateLimiters[T.keyPrefix].consume(T.data.key,T.data.arg,T.data.opts);break;case"penalty":M=this._rateLimiters[T.keyPrefix].penalty(T.data.key,T.data.arg,T.data.opts);break;case"reward":M=this._rateLimiters[T.keyPrefix].reward(T.data.key,T.data.arg,T.data.opts);break;case"block":M=this._rateLimiters[T.keyPrefix].block(T.data.key,T.data.arg,T.data.opts);break;case"get":M=this._rateLimiters[T.keyPrefix].get(T.data.key,T.data.opts);break;case"delete":M=this._rateLimiters[T.keyPrefix].delete(T.data.key,T.data.opts);break;default:return!1}M&&M.then(k=>{f(D,T,"resolve",k)}).catch(k=>{f(D,T,"reject",k)})},E=function(D){if(!D||D.channel!==h||D.keyPrefix!==this.keyPrefix)return!1;if(this._promises[D.promiseId]){let T;switch(clearTimeout(this._promises[D.promiseId].timeoutId),T=null===D.data||!0===D.data||!1===D.data?D.data:new m(D.data.remainingPoints,D.data.msBeforeNext,D.data.consumedPoints,D.data.isFirstInDuration),D.type){case"resolve":this._promises[D.promiseId].resolve(T);break;case"reject":this._promises[D.promiseId].reject(T);break;default:throw new Error(`RateLimiterCluster: no such message type '${D.type}'`)}delete this._promises[D.promiseId]}},v=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},p=function(D,T){const M=process.hrtime();let k=M[0].toString()+M[1].toString();return typeof this._promises[k]<"u"&&(k+=u.randomBytes(12).toString("base64")),this._promises[k]={resolve:D,reject:T,timeoutId:setTimeout(()=>{delete this._promises[k],T(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},k};Q.exports={RateLimiterClusterMaster:class I{constructor(){if(c)return c;this._rateLimiters={},y.setMaxListeners(0),y.on("message",(T,M)=>{M&&M.channel===h&&"init"===M.type?(typeof this._rateLimiters[M.opts.keyPrefix]>"u"&&(this._rateLimiters[M.opts.keyPrefix]=new w(M.opts)),T.send({channel:h,type:"init",keyPrefix:M.opts.keyPrefix})):S.call(this,T,M)}),c=this}},RateLimiterClusterMasterPM2:class A{constructor(T){if(c)return c;this._rateLimiters={},T.launchBus((M,k)=>{k.on("process:msg",F=>{const $=F.raw;$&&$.channel===h&&"init"===$.type?(typeof this._rateLimiters[$.opts.keyPrefix]>"u"&&(this._rateLimiters[$.opts.keyPrefix]=new w($.opts)),T.sendDataToProcessId(F.process.pm_id,{data:{},topic:h,channel:h,type:"init",keyPrefix:$.opts.keyPrefix},(C,O)=>{C&&console.log(C,O)})):S.call(this,{send:O=>{const U=O;U.topic=h,typeof U.data>"u"&&(U.data={}),T.sendDataToProcessId(F.process.pm_id,U,(L,H)=>{L&&console.log(L,H)})}},$)})}),c=this}},RateLimiterCluster:class P extends g{get timeoutMs(){return this._timeoutMs}set timeoutMs(T){this._timeoutMs=typeof T>"u"?5e3:Math.abs(parseInt(T))}constructor(T={}){super(T),process.setMaxListeners(0),this.timeoutMs=T.timeoutMs,this._initiated=!1,process.on("message",M=>{M&&M.channel===h&&"init"===M.type&&M.keyPrefix===this.keyPrefix?this._initiated=!0:E.call(this,M)}),process.send({channel:h,type:"init",opts:v.call(this)}),this._promises={}}consume(T,M=1,k={}){return new Promise((F,$)=>{const C=p.call(this,F,$);b.call(this,"consume",C,T,M,k)})}penalty(T,M=1,k={}){return new Promise((F,$)=>{const C=p.call(this,F,$);b.call(this,"penalty",C,T,M,k)})}reward(T,M=1,k={}){return new Promise((F,$)=>{const C=p.call(this,F,$);b.call(this,"reward",C,T,M,k)})}block(T,M,k={}){return new Promise((F,$)=>{const C=p.call(this,F,$);b.call(this,"block",C,T,M,k)})}get(T,M={}){return new Promise((k,F)=>{const $=p.call(this,k,F);b.call(this,"get",$,T,M)})}delete(T,M={}){return new Promise((k,F)=>{const $=p.call(this,k,F);b.call(this,"delete",$,T,M)})}}}},6052:(Q,K,x)=>{const y=x(3794),u=x(2854);Q.exports=class g extends y{constructor(m){super(m),this.client=m.storeClient}_getRateLimiterRes(m,h,c){const f=new u;return f.consumedPoints=parseInt(c.consumedPoints),f.isFirstInDuration=c.consumedPoints===h,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=c.msBeforeNext,f}_upsert(m,h,c,f=!1,d={}){return new Promise((b,S)=>{const E=Date.now(),v=Math.floor(c/1e3);f?this.client.set(m,h,v,p=>{p?S(p):this.client.set(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.incr(m,h,(p,I)=>{p||!1===I?this.client.add(m,h,v,(A,P)=>{if(A||!P)if(typeof d.attemptNumber>"u"||d.attemptNumber<3){const D=Object.assign({},d);D.attemptNumber=D.attemptNumber?D.attemptNumber+1:1,this._upsert(m,h,c,f,D).then(T=>b(T)).catch(T=>S(T))}else S(new Error("Can not add key"));else this.client.add(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.get(`${m}_expire`,(A,P)=>{if(A)S(A);else{const D=!1===P?0:P,T={consumedPoints:I,msBeforeNext:D>=0?Math.max(D-E,0):-1};b(T)}})})})}_get(m){return new Promise((h,c)=>{const f=Date.now();this.client.get(m,(d,b)=>{b?this.client.get(`${m}_expire`,(S,E)=>{if(S)c(S);else{const v=!1===E?0:E,p={consumedPoints:b,msBeforeNext:v>=0?Math.max(v-f,0):-1};h(p)}}):h(null)})})}_delete(m){return new Promise((h,c)=>{this.client.del(m,(f,d)=>{f?c(f):!1===d?h(d):this.client.del(`${m}_expire`,b=>{b?c(b):h(d)})})})}}},2296:(Q,K,x)=>{const y=x(1468),u=x(2413),g=x(2854);Q.exports=class w extends y{constructor(h={}){super(h),this._memoryStorage=new u}consume(h,c=1,f={}){return new Promise((d,b)=>{const S=this.getKey(h),E=this._getKeySecDuration(f);let v=this._memoryStorage.incrby(S,c,E);if(v.remainingPoints=Math.max(this.points-v.consumedPoints,0),v.consumedPoints>this.points)this.blockDuration>0&&v.consumedPoints<=this.points+c&&(v=this._memoryStorage.set(S,v.consumedPoints,this.blockDuration)),b(v);else if(this.execEvenly&&v.msBeforeNext>0&&!v.isFirstInDuration){let p=Math.ceil(v.msBeforeNext/(v.remainingPoints+2));p{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}reward(h,c=1,f={}){const d=this.getKey(h);return new Promise(b=>{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,-c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}block(h,c){const f=1e3*c,d=this.points+1;return this._memoryStorage.set(this.getKey(h),d,c),Promise.resolve(new g(0,0===f?-1:f,d))}set(h,c,f){const d=1e3*(f>=0?f:this.duration);return this._memoryStorage.set(this.getKey(h),c,f),Promise.resolve(new g(0,0===d?-1:d,c))}get(h){const c=this._memoryStorage.get(this.getKey(h));return null!==c&&(c.remainingPoints=Math.max(this.points-c.consumedPoints,0)),Promise.resolve(c)}delete(h){return Promise.resolve(this._memoryStorage.delete(this.getKey(h)))}}},9964:(Q,K,x)=>{const y=x(3794),u=x(2854);function g(m){try{const h=m.client?m.client:m,{version:c}=h.topology.s.options.metadata.driver,f=c.split(".").map(d=>parseInt(d));return{major:f[0],feature:f[1],patch:f[2]}}catch{return{major:0,feature:0,patch:0}}}class w extends y{constructor(h){super(h),this.dbName=h.dbName,this.tableName=h.tableName,this.indexKeyPrefix=h.indexKeyPrefix,this.client=h.mongo?h.mongo:h.storeClient,"function"==typeof this.client.then?this.client.then(c=>{this.client=c,this._initCollection(),this._driverVersion=g(this.client)}):(this._initCollection(),this._driverVersion=g(this.client))}get dbName(){return this._dbName}set dbName(h){this._dbName=typeof h>"u"?w.getDbName():h}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(h){this._tableName=typeof h>"u"?this.keyPrefix:h}get client(){return this._client}set client(h){if(typeof h>"u")throw new Error("mongo is not set");this._client=h}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(h){this._indexKeyPrefix=h||{}}_initCollection(){const c=("function"==typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);c.createIndex({expire:-1},{expireAfterSeconds:0}),c.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=c}_getRateLimiterRes(h,c,f){const d=new u;let b;return b=typeof f.value>"u"?f:f.value,d.isFirstInDuration=b.points===c,d.consumedPoints=b.points,d.remainingPoints=Math.max(this.points-d.consumedPoints,0),d.msBeforeNext=null!==b.expire?Math.max(new Date(b.expire).getTime()-Date.now(),0):-1,d}_upsert(h,c,f,d=!1,b={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const S=b.attrs||{};let E,v;d?(E={key:h},E=Object.assign(E,S),v={$set:{key:h,points:c,expire:f>0?new Date(Date.now()+f):null}},v.$set=Object.assign(v.$set,S)):(E={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:h},E=Object.assign(E,S),v={$setOnInsert:{key:h,expire:f>0?new Date(Date.now()+f):null},$inc:{points:c}},v.$setOnInsert=Object.assign(v.$setOnInsert,S));const p={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?p.returnDocument="after":p.returnOriginal=!1,new Promise((I,A)=>{this._collection.findOneAndUpdate(E,v,p).then(P=>{I(P)}).catch(P=>{if(P&&11e3===P.code){const D=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:h},S),T={$set:Object.assign({key:h,points:c,expire:f>0?new Date(Date.now()+f):null},S)};this._collection.findOneAndUpdate(D,T,p).then(M=>{I(M)}).catch(M=>{M&&11e3===M.code?this._upsert(h,c,f,d).then(k=>I(k)).catch(k=>A(k)):A(M)})}else A(P)})})}_get(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const f=c.attrs||{},d=Object.assign({key:h,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},f);return this._collection.findOne(d)}_delete(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const d=Object.assign({key:h},c.attrs||{});return this._collection.deleteOne(d).then(b=>b.deletedCount>0)}}Q.exports=w},6111:(Q,K,x)=>{const y=x(3794),u=x(2854);Q.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.dbName=m.dbName,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._getConnection().then(c=>{c.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,m],()=>{this._releaseConnection(c),h()})}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((m,h)=>{this.client.getConnection((c,f)=>{if(c)return h(c);m(f)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(m){switch(this.clientType){case"pool":return m.release();case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m);default:return!0}}_createDbAndTable(){return new Promise((m,h)=>{this._getConnection().then(c=>{c.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,f=>{if(f)return this._releaseConnection(c),h(f);c.query(this._getCreateTableStmt(),d=>{if(d)return this._releaseConnection(c),h(d);this._releaseConnection(c),m()})})}).catch(c=>{h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(m){if(typeof m>"u")if("Connection"===this.client.constructor.name)m="connection";else if("Pool"===this.client.constructor.name)m="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get dbName(){return this._dbName}set dbName(m){this._dbName=typeof m>"u"?"rtlmtrflx":m}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new u,[d]=c;return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_upsertTransaction(m,h,c,f,d){return new Promise((b,S)=>{m.query("BEGIN",E=>{if(E)return m.rollback(),S(E);const v=Date.now(),p=f>0?v+f:null;let I,A;d?(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",A=[this.dbName,this.tableName,h,c,p,c,p]):(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",A=[this.dbName,this.tableName,h,c,p,v,c,c,v,p]),m.query(I,A,P=>{if(P)return m.rollback(),S(P);m.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,h],(D,T)=>{if(D)return m.rollback(),S(D);m.query("COMMIT",M=>{if(M)return m.rollback(),S(M);b(T)})})})})})}_upsert(m,h,c,f=!1){return this.tableCreated?new Promise((d,b)=>{this._getConnection().then(S=>{this._upsertTransaction(S,m,h,c,f).then(E=>{d(E),this._releaseConnection(S)}).catch(E=>{b(E),this._releaseConnection(S)})}).catch(S=>{b(S)})}):Promise.reject(Error("Table is not created yet"))}_get(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,m,Date.now()],(d,b)=>{d?c(d):h(0===b.length?null:b),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,m],(d,b)=>{d?c(d):h(b.affectedRows>0),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}}},7380:(Q,K,x)=>{const y=x(3794),u=x(2854);Q.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?"function"==typeof h&&h():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._query({name:"rlflx-clear-expired",text:`DELETE FROM ${this.tableName} WHERE expire < $1`,values:[m]}).then(()=>{h()}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(m){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m)}}_createTable(){return new Promise((m,h)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{m()}).catch(c=>{"23505"===c.code?m():h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this.tableName} ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );`}get clientType(){return this._clientType}set clientType(m){const h=this.client.constructor.name;if(typeof m>"u")if("Client"===h)m="client";else if("Pool"===h||"BoundPool"===h)m="pool";else{if("Sequelize"!==h)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new u,d=c.rows[0];return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_query(m){const c={name:`${this.tableName.toLowerCase()}:${m.name}`,text:m.text,values:m.values};return new Promise((f,d)=>{this._getConnection().then(b=>{b.query(c).then(S=>{f(S),this._releaseConnection(b)}).catch(S=>{d(S),this._releaseConnection(b)})}).catch(b=>{d(b)})})}_upsert(m,h,c,f=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const d=c>0?Date.now()+c:null;return this._query({name:f?"rlflx-upsert-force":"rlflx-upsert",text:`\n INSERT INTO ${this.tableName} VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (${this.tableName}.expire <= $4 OR 1=${f?1:0}) THEN $2\n ELSE ${this.tableName}.points + ($2)\n END,\n expire = ${f?" $3 ":` CASE\n WHEN ${this.tableName}.expire <= $4 THEN $3\n ELSE ${this.tableName}.expire\n END `}\n RETURNING points, expire;`,values:[m,h,d,Date.now()]})}_get(m){return this.tableCreated?new Promise((h,c)=>{this._query({name:"rlflx-get",text:`\n SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[m,Date.now()]}).then(f=>{0===f.rowCount&&(f=null),h(f)}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[m]}).then(h=>h.rowCount>0):Promise.reject(Error("Table is not created yet"))}}},6154:(Q,K,x)=>{const y=x(2553),u=4294967295,g="limiter";Q.exports=class{constructor(h,c={maxQueueSize:u}){this._queueLimiters={KEY_DEFAULT:new w(h,c)},this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(h=g){return this._queueLimiters[h]?this._queueLimiters[h].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(h,c=g){return this._queueLimiters[c]||(this._queueLimiters[c]=new w(this._limiterFlexible,{key:c,maxQueueSize:this._maxQueueSize})),this._queueLimiters[c].removeTokens(h)}};class w{constructor(h,c={maxQueueSize:u,key:g}){this._key=c.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(h=>null!==h?h.remainingPoints:this._limiterFlexible.points)}removeTokens(h){const c=this;return new Promise((f,d)=>{h>c._limiterFlexible.points?d(new y(`Requested tokens ${h} exceeds maximum ${c._limiterFlexible.points} tokens per interval`)):c._queue.length>0?c._queueRequest.call(c,f,d,h):c._limiterFlexible.consume(c._key,h).then(b=>{f(b.remainingPoints)}).catch(b=>{b instanceof Error?d(b):(c._queueRequest.call(c,f,d,h),null===c._waitTimeout&&(c._waitTimeout=setTimeout(c._processFIFO.bind(c),b.msBeforeNext)))})})}_queueRequest(h,c,f){const d=this;d._queue.length{c.resolve(f.remainingPoints),h._processFIFO.call(h)}).catch(f=>{f instanceof Error?(c.reject(f),h._processFIFO.call(h)):(h._queue.unshift(c),null===h._waitTimeout&&(h._waitTimeout=setTimeout(h._processFIFO.bind(h),f.msBeforeNext)))})}}},7310:(Q,K,x)=>{const y=x(3794),u=x(2854),g="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";Q.exports=class w extends y{constructor(h){super(h),this.client=h.redis?h.redis:h.storeClient,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:g})}_getRateLimiterRes(h,c,f){let[d,b]=f;Array.isArray(d)&&([,d]=d,[,b]=b);const S=new u;return S.consumedPoints=parseInt(d),S.isFirstInDuration=S.consumedPoints===c,S.remainingPoints=Math.max(this.points-S.consumedPoints,0),S.msBeforeNext=b,S}_upsert(h,c,f,d=!1){return new Promise((b,S)=>{const E=Math.floor(f/1e3),v=this.client.multi();if(d)E>0?v.set(h,c,"EX",E):v.set(h,c),v.pttl(h).exec((p,I)=>p?S(p):b(I));else if(E>0){const p=function(I,A){return I?S(I):b(A)};"function"==typeof this.client.rlflxIncr?this.client.rlflxIncr(h,c,E,p):this.client.eval(g,1,h,c,E,p)}else v.incrby(h,c).pttl(h).exec((p,I)=>p?S(p):b(I))})}_get(h){return new Promise((c,f)=>{this.client.multi().get(h).pttl(h).exec((d,b)=>{if(d)f(d);else{const[S]=b;if(null===S)return c(null);c(b)}})})}_delete(h){return new Promise((c,f)=>{this.client.del(h,(d,b)=>{d?f(d):c(b>0)})})}}},2854:Q=>{Q.exports=class{constructor(x,y,u,g){this.remainingPoints=typeof x>"u"?0:x,this.msBeforeNext=typeof y>"u"?0:y,this.consumedPoints=typeof u>"u"?0:u,this.isFirstInDuration=!(typeof g>"u")&&g}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(x){return this._msBeforeNext=x,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(x){return this._remainingPoints=x,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(x){return this._consumedPoints=x,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(x){this._isFirstInDuration=Boolean(x)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},3794:(Q,K,x)=>{const y=x(1468),u=x(151),g=x(2854);Q.exports=class extends y{constructor(m={}){super(m),this.inmemoryBlockOnConsumed=m.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=m.inmemoryBlockDuration,this.insuranceLimiter=m.insuranceLimiter,this._inmemoryBlockedKeys=new u}get client(){return this._client}set client(m){if(typeof m>"u")throw new Error("storeClient is not set");this._client=m}_afterConsume(m,h,c,f,d,b={}){const S=this._getRateLimiterRes(c,f,d);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&S.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(c,S.msBeforeNext),S.consumedPoints>this.points?h(S):m(S);if(S.consumedPoints>this.points){let E=Promise.resolve();this.blockDuration>0&&S.consumedPoints<=this.points+f&&(S.msBeforeNext=this.msBlockDuration,E=this._block(c,S.consumedPoints,this.msBlockDuration,b)),this.inmemoryBlockOnConsumed>0&&S.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(c,this.inmemoryBlockDuration),S.msBeforeNext=this.msInmemoryBlockDuration),E.then(()=>{h(S)}).catch(v=>{h(v)})}else if(this.execEvenly&&S.msBeforeNext>0&&!S.isFirstInDuration){let E=Math.ceil(S.msBeforeNext/(S.remainingPoints+2));E{c(E)}).catch(E=>{f(E)}):f(m)}getInmemoryBlockMsBeforeExpire(m){return this.inmemoryBlockOnConsumed>0?this._inmemoryBlockedKeys.msBeforeExpire(m):0}get inmemoryBlockOnConsumed(){return this._inmemoryBlockOnConsumed}set inmemoryBlockOnConsumed(m){if(this._inmemoryBlockOnConsumed=m?parseInt(m):0,this.inmemoryBlockOnConsumed>0&&this.points>this.inmemoryBlockOnConsumed)throw new Error('inmemoryBlockOnConsumed option must be greater or equal "points" option')}get inmemoryBlockDuration(){return this._inmemoryBlockDuration}set inmemoryBlockDuration(m){if(this._inmemoryBlockDuration=m?parseInt(m):0,this.inmemoryBlockDuration>0&&0===this.inmemoryBlockOnConsumed)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return 1e3*this._inmemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(m){if(typeof m<"u"&&!(m instanceof y))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=m,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(m,h,c={}){const f=1e3*h;return this._block(this.getKey(m),this.points+1,f,c)}set(m,h,c,f={}){const d=1e3*(c>=0?c:this.duration);return this._block(this.getKey(m),h,d,f)}consume(m,h=1,c={}){return new Promise((f,d)=>{const b=this.getKey(m),S=this.getInmemoryBlockMsBeforeExpire(b);if(S>0)return d(new g(0,S));this._upsert(b,h,1e3*this._getKeySecDuration(c),!1,c).then(E=>{this._afterConsume(f,d,b,h,E)}).catch(E=>{this._handleError(E,"consume",f,d,m,h,c)})})}penalty(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,h,S))}).catch(S=>{this._handleError(S,"penalty",d,b,m,h,c)})})}reward(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,-h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,-h,S))}).catch(S=>{this._handleError(S,"reward",d,b,m,h,c)})})}get(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._get(c,h).then(b=>{f(null===b||typeof b>"u"?null:this._getRateLimiterRes(c,0,b))}).catch(b=>{this._handleError(b,"get",f,d,m,h)})})}delete(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._delete(c,h).then(b=>{this._inmemoryBlockedKeys.delete(c),f(b)}).catch(b=>{this._handleError(b,"delete",f,d,m,h)})})}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(m,h,c){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(m,h,c,f={}){return new Promise((d,b)=>{this._upsert(m,h,c,!0,f).then(()=>{d(new g(0,c>0?c:-1,h))}).catch(S=>{this._handleError(S,"block",d,b,this.parseKey(m),c/1e3,f)})})}_get(m,h={}){throw new Error("You have to implement the method '_get'!")}_delete(m,h={}){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}},5935:(Q,K,x)=>{const y=x(1468);Q.exports=class{constructor(...g){if(g.length<2)throw new Error("RateLimiterUnion: at least two limiters have to be set");g.forEach(w=>{if(!(w instanceof y))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=g}consume(g,w=1){return new Promise((m,h)=>{const c=[];this._limiters.forEach(f=>{c.push(f.consume(g,w).catch(d=>({rejected:!0,rej:d})))}),Promise.all(c).then(f=>{const d={};let b=!1;f.forEach(S=>{!0===S.rejected&&(b=!0)});for(let S=0;S{Q.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const x=Date.now();Object.keys(this._keys).forEach(y=>{this._keys[y]<=x&&delete this._keys[y]}),this._addedKeysAmount=Object.keys(this._keys).length}add(x,y){this.addMs(x,1e3*y)}addMs(x,y){this._keys[x]=Date.now()+y,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(x){const y=this._keys[x];if(y&&y>=Date.now()){this.collectExpired();const u=Date.now();return y>=u?y-u:0}return 0}delete(x){x?delete this._keys[x]:Object.keys(this._keys).forEach(y=>{delete this._keys[y]})}}},151:(Q,K,x)=>{const y=x(3732);Q.exports=y},2413:(Q,K,x)=>{const y=x(8725),u=x(2854);Q.exports=class{constructor(){this._storage={}}incrby(w,m,h){if(this._storage[w]){const c=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return 0!==c?(this._storage[w].value=this._storage[w].value+m,new u(0,c,this._storage[w].value,!1)):this.set(w,m,h)}return this.set(w,m,h)}set(w,m,h){const c=1e3*h;return this._storage[w]&&this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),this._storage[w]=new y(m,c>0?new Date(Date.now()+c):null),c>0&&(this._storage[w].timeoutId=setTimeout(()=>{delete this._storage[w]},c),this._storage[w].timeoutId.unref&&this._storage[w].timeoutId.unref()),new u(0,0===c?-1:c,this._storage[w].value,!0)}get(w){if(this._storage[w]){const m=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return new u(0,m,this._storage[w].value,!1)}return null}delete(w){return!!this._storage[w]&&(this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),delete this._storage[w],!0)}}},8725:Q=>{Q.exports=class{constructor(x,y,u=null){this.value=x,this.expiresAt=y,this.timeoutId=u}get value(){return this._value}set value(x){this._value=parseInt(x)}get expiresAt(){return this._expiresAt}set expiresAt(x){!(x instanceof Date)&&Number.isInteger(x)&&(x=new Date(x)),this._expiresAt=x}get timeoutId(){return this._timeoutId}set timeoutId(x){this._timeoutId=x}}},2553:Q=>{Q.exports=class extends Error{constructor(x,y){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=x,y&&(this.extra=y)}}},2185:(Q,K,x)=>{"use strict";Q.exports=m;var y=x(4948),u=m.prototype,g=new Date%1e9;function m(h){this.id=(h=h||{}).id||function w(){return(1e9*Math.random()>>>0)+g++}(),this.max=h.max||1/0,this.items=h.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(h.lastModified||new Date);for(var c,f,d=this.items.length;d--;)c=this.items[d],f=new Date(c.expires)-new Date,this._lookup[c.key]=c,f>0?this.expire(c.key,f):f<=0&&this.delete(c.key)}u.has=function(h){return h in this._lookup},u.get=function(h){if(!this.has(h))return null;var c=this._lookup[h];return c.refresh&&this.expire(h,c.refresh),this.items.splice(this.items.indexOf(c),1),this.items.push(c),c.value},u.meta=function(h){if(!this.has(h))return null;var c=this._lookup[h];return"meta"in c?c.meta:null},u.set=function(h,c,f){var d=this._lookup[h],b=this._lookup[h]={key:h,value:c};return this.lastModified=new Date,d?(clearTimeout(d.timeout),this.items.splice(this.items.indexOf(d),1,b)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(b),this.size++),f&&("ttl"in f&&this.expire(h,f.ttl),"meta"in f&&(b.meta=f.meta),f.refresh&&(b.refresh=f.ttl)),this},u.delete=function(h){var c=this._lookup[h];return!!c&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(c),1),clearTimeout(c.timeout),delete this._lookup[h],this.size--,this)},u.expire=function(h,c){var f=c||0,d=this._lookup[h];if(!d)return this;if("string"==typeof f&&(f=y(c)),"number"!=typeof f)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(d.timeout),d.timeout=setTimeout(this.delete.bind(this,d.key),f),d.expires=Number(new Date)+f,this},u.clear=function(){for(var h=this.items.length;h--;)this.delete(this.items[h].key);return this},u.toJSON=function(){for(var c,h=new Array(this.items.length),f=h.length;f--;)h[f]={key:(c=this.items[f]).key,meta:c.meta,value:c.value,expires:c.expires,refresh:c.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:h}}},1953:(Q,K,x)=>{"use strict";const y=x(1164);class u{constructor(m,h,c){const f=this;this._started=y(),this._rescheduled=0,this._scheduled=h,this._args=c,this._triggered=!1,this._timerWrapper=()=>{f._rescheduled>0?(f._scheduled=f._rescheduled-(y()-f._started),f._schedule(f._scheduled)):(f._triggered=!0,m.apply(null,f._args))},this._timer=setTimeout(this._timerWrapper,h)}reschedule(m){m||(m=this._scheduled);const h=y();h+m-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(m)):this._triggered?this._schedule(m):(this._started=h,this._rescheduled=m)}_schedule(m){this._triggered=!1,this._started=y(),this._rescheduled=0,this._scheduled=m,this._timer=setTimeout(this._timerWrapper,m)}clear(){clearTimeout(this._timer)}}Q.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let w;if(arguments.length>0){w=new Array(arguments.length-2);for(var m=0;m{"use strict";Q.exports=function(){return Date.now()}},8353:(Q,K,x)=>{"use strict";var y=x(5341),u=/[\/\?<>\\:\*\|"]/g,g=/[\x00-\x1f\x80-\x9f]/g,w=/^\.+$/,m=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,h=/[\. ]+$/;function c(f,d){if("string"!=typeof f)throw new Error("Input must be string");var b=f.replace(u,d).replace(g,d).replace(w,d).replace(m,d).replace(h,d);return y(b,255)}Q.exports=function(f,d){var b=d&&d.replacement||"",S=c(f,b);return""===b?S:c(S,"")}},9849:(Q,K,x)=>{"use strict";var y=x(411).default;const u=new Map;function m(){return(m=y(function*(f,d,b){for(;u.get(b);){try{yield f()}catch(S){setTimeout(()=>{throw S},1);break}if(!u.get(b))break;yield new Promise(S=>{const E=setTimeout(S,d);u.set(b,E)})}})).apply(this,arguments)}Q.exports={setDelayedInterval:function h(f,d,b){b=b||d;const S=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function w(f,d,b){m.apply(this,arguments)}(f,d,S)},b);return u.set(S,E),S},clearDelayedInterval:function c(f){const d=u.get(f);d&&(clearTimeout(d),u.delete(f))}}},4175:(Q,K,x)=>{"use strict";const{AbortController:y}=globalThis,u=x(1953);class g extends y{constructor(m){super(),this._ms=m,this._timer=u(()=>this.abort(),m),Object.setPrototypeOf(this,g.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=u(()=>this.abort(),this._ms)}}Q.exports={TimeoutController:g}},5341:(Q,K,x)=>{"use strict";var y=x(3938),u=x(1752);Q.exports=y.bind(null,u)},3938:Q=>{"use strict";function x(y){return y>=56320&&y<=57343}Q.exports=function(u,g,w){if("string"!=typeof g)throw new Error("Input must be string");for(var c,f,m=g.length,h=0,d=0;d=55296&&y<=56319&&x(g.charCodeAt(d+1))&&(f+=g[d+=1]),(h+=u(f))===w)return g.slice(0,d+1);if(h>w)return g.slice(0,d-f.length+1)}var y;return g}},1752:Q=>{"use strict";function K(y){return y>=55296&&y<=56319}Q.exports=function(u){if("string"!=typeof u)throw new Error("Input must be string");for(var g=u.length,w=0,m=null,h=null,c=0;c=56320&&y<=57343?null!=h&&K(h)?w+=1:w+=3:m<=127?w+=1:m>=128&&m<=2047?w+=2:m>=2048&&m<=65535&&(w+=3),h=m;var y;return w}},5251:Q=>{Q.exports=function y(u,m){var f,w=0,h=0,c=m=m||0,d=u.length;do{if(c>=d||h>49)throw y.bytes=0,new RangeError("Could not decode varint");f=u[c++],w+=h<28?(127&f)<=128);return y.bytes=c-m,w}},6170:Q=>{Q.exports=function g(w,m,h){if(Number.MAX_SAFE_INTEGER&&w>Number.MAX_SAFE_INTEGER)throw g.bytes=0,new RangeError("Could not encode varint");m=m||[];for(var c=h=h||0;w>=u;)m[h++]=255&w|128,w/=128;for(;-128&w;)m[h++]=255&w|128,w>>>=7;return m[h]=0|w,g.bytes=h-c+1,m};var u=Math.pow(2,31)},398:(Q,K,x)=>{Q.exports={encode:x(6170),decode:x(5251),encodingLength:x(7963)}},7963:Q=>{var K=Math.pow(2,7),x=Math.pow(2,14),y=Math.pow(2,21),u=Math.pow(2,28),g=Math.pow(2,35),w=Math.pow(2,42),m=Math.pow(2,49),h=Math.pow(2,56),c=Math.pow(2,63);Q.exports=function(f){return f{"use strict";!function(re){const le=re.performance;function ge(jt){le&&le.mark&&le.mark(jt)}function ye(jt,rt){le&&le.measure&&le.measure(jt,rt)}ge("Zone");const be=re.__Zone_symbol_prefix||"__zone_symbol__";function xe(jt){return be+jt}const ze=!0===re[xe("forceDuplicateZoneCheck")];if(re.Zone){if(ze||"function"!=typeof re.Zone.__symbol__)throw new Error("Zone already loaded.");return re.Zone}let je=(()=>{class jt{constructor(ce,me){this._parent=ce,this._name=me?me.name||"unnamed":"",this._properties=me&&me.properties||{},this._zoneDelegate=new Xe(this,this._parent&&this._parent._zoneDelegate,me)}static assertZonePatched(){if(re.Promise!==wi.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=jt.current;for(;ce.parent;)ce=ce.parent;return ce}static get current(){return Nn.zone}static get currentTask(){return Br}static __load_patch(ce,me,lt=!1){if(wi.hasOwnProperty(ce)){if(!lt&&ze)throw Error("Already loaded patch: "+ce)}else if(!re["__Zone_disable_"+ce]){const Dt="Zone:"+ce;ge(Dt),wi[ce]=me(re,jt,Yn),ye(Dt,Dt)}}get parent(){return this._parent}get name(){return this._name}get(ce){const me=this.getZoneWith(ce);if(me)return me._properties[ce]}getZoneWith(ce){let me=this;for(;me;){if(me._properties.hasOwnProperty(ce))return me;me=me._parent}return null}fork(ce){if(!ce)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,ce)}wrap(ce,me){if("function"!=typeof ce)throw new Error("Expecting function got: "+ce);const lt=this._zoneDelegate.intercept(this,ce,me),Dt=this;return function(){return Dt.runGuarded(lt,this,arguments,me)}}run(ce,me,lt,Dt){Nn={parent:Nn,zone:this};try{return this._zoneDelegate.invoke(this,ce,me,lt,Dt)}finally{Nn=Nn.parent}}runGuarded(ce,me=null,lt,Dt){Nn={parent:Nn,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,me,lt,Dt)}catch(An){if(this._zoneDelegate.handleError(this,An))throw An}}finally{Nn=Nn.parent}}runTask(ce,me,lt){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||jn).name+"; Execution: "+this.name+")");if(ce.state===$t&&(ce.type===Ar||ce.type===Et))return;const Dt=ce.state!=ot;Dt&&ce._transitionTo(ot,un),ce.runCount++;const An=Br;Br=ce,Nn={parent:Nn,zone:this};try{ce.type==Et&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,me,lt)}catch(Ve){if(this._zoneDelegate.handleError(this,Ve))throw Ve}}finally{ce.state!==$t&&ce.state!==et&&(ce.type==Ar||ce.data&&ce.data.isPeriodic?Dt&&ce._transitionTo(un,ot):(ce.runCount=0,this._updateTaskCount(ce,-1),Dt&&ce._transitionTo($t,ot,$t))),Nn=Nn.parent,Br=An}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let lt=this;for(;lt;){if(lt===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);lt=lt.parent}}ce._transitionTo(Tn,$t);const me=[];ce._zoneDelegates=me,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(lt){throw ce._transitionTo(et,Tn,$t),this._zoneDelegate.handleError(this,lt),lt}return ce._zoneDelegates===me&&this._updateTaskCount(ce,1),ce.state==Tn&&ce._transitionTo(un,Tn),ce}scheduleMicroTask(ce,me,lt,Dt){return this.scheduleTask(new Ue(Wt,ce,me,lt,Dt,void 0))}scheduleMacroTask(ce,me,lt,Dt,An){return this.scheduleTask(new Ue(Et,ce,me,lt,Dt,An))}scheduleEventTask(ce,me,lt,Dt,An){return this.scheduleTask(new Ue(Ar,ce,me,lt,Dt,An))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||jn).name+"; Execution: "+this.name+")");ce._transitionTo(Dn,un,ot);try{this._zoneDelegate.cancelTask(this,ce)}catch(me){throw ce._transitionTo(et,Dn),this._zoneDelegate.handleError(this,me),me}return this._updateTaskCount(ce,-1),ce._transitionTo($t,Dn),ce.runCount=0,ce}_updateTaskCount(ce,me){const lt=ce._zoneDelegates;-1==me&&(ce._zoneDelegates=null);for(let Dt=0;Dtjt.hasTask(ce,me),onScheduleTask:(jt,rt,ce,me)=>jt.scheduleTask(ce,me),onInvokeTask:(jt,rt,ce,me,lt,Dt)=>jt.invokeTask(ce,me,lt,Dt),onCancelTask:(jt,rt,ce,me)=>jt.cancelTask(ce,me)};class Xe{constructor(rt,ce,me){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=rt,this._parentDelegate=ce,this._forkZS=me&&(me&&me.onFork?me:ce._forkZS),this._forkDlgt=me&&(me.onFork?ce:ce._forkDlgt),this._forkCurrZone=me&&(me.onFork?this.zone:ce._forkCurrZone),this._interceptZS=me&&(me.onIntercept?me:ce._interceptZS),this._interceptDlgt=me&&(me.onIntercept?ce:ce._interceptDlgt),this._interceptCurrZone=me&&(me.onIntercept?this.zone:ce._interceptCurrZone),this._invokeZS=me&&(me.onInvoke?me:ce._invokeZS),this._invokeDlgt=me&&(me.onInvoke?ce:ce._invokeDlgt),this._invokeCurrZone=me&&(me.onInvoke?this.zone:ce._invokeCurrZone),this._handleErrorZS=me&&(me.onHandleError?me:ce._handleErrorZS),this._handleErrorDlgt=me&&(me.onHandleError?ce:ce._handleErrorDlgt),this._handleErrorCurrZone=me&&(me.onHandleError?this.zone:ce._handleErrorCurrZone),this._scheduleTaskZS=me&&(me.onScheduleTask?me:ce._scheduleTaskZS),this._scheduleTaskDlgt=me&&(me.onScheduleTask?ce:ce._scheduleTaskDlgt),this._scheduleTaskCurrZone=me&&(me.onScheduleTask?this.zone:ce._scheduleTaskCurrZone),this._invokeTaskZS=me&&(me.onInvokeTask?me:ce._invokeTaskZS),this._invokeTaskDlgt=me&&(me.onInvokeTask?ce:ce._invokeTaskDlgt),this._invokeTaskCurrZone=me&&(me.onInvokeTask?this.zone:ce._invokeTaskCurrZone),this._cancelTaskZS=me&&(me.onCancelTask?me:ce._cancelTaskZS),this._cancelTaskDlgt=me&&(me.onCancelTask?ce:ce._cancelTaskDlgt),this._cancelTaskCurrZone=me&&(me.onCancelTask?this.zone:ce._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const lt=me&&me.onHasTask;(lt||ce&&ce._hasTaskZS)&&(this._hasTaskZS=lt?me:Je,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=rt,me.onScheduleTask||(this._scheduleTaskZS=Je,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),me.onInvokeTask||(this._invokeTaskZS=Je,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),me.onCancelTask||(this._cancelTaskZS=Je,this._cancelTaskDlgt=ce,this._cancelTaskCurrZone=this.zone))}fork(rt,ce){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,rt,ce):new je(rt,ce)}intercept(rt,ce,me){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,rt,ce,me):ce}invoke(rt,ce,me,lt,Dt){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,rt,ce,me,lt,Dt):ce.apply(me,lt)}handleError(rt,ce){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,rt,ce)}scheduleTask(rt,ce){let me=ce;if(this._scheduleTaskZS)this._hasTaskZS&&me._zoneDelegates.push(this._hasTaskDlgtOwner),me=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,rt,ce),me||(me=ce);else if(ce.scheduleFn)ce.scheduleFn(ce);else{if(ce.type!=Wt)throw new Error("Task is missing scheduleFn.");ft(ce)}return me}invokeTask(rt,ce,me,lt){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,rt,ce,me,lt):ce.callback.apply(me,lt)}cancelTask(rt,ce){let me;if(this._cancelTaskZS)me=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,rt,ce);else{if(!ce.cancelFn)throw Error("Task is not cancelable");me=ce.cancelFn(ce)}return me}hasTask(rt,ce){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,rt,ce)}catch(me){this.handleError(rt,me)}}_updateTaskCount(rt,ce){const me=this._taskCounts,lt=me[rt],Dt=me[rt]=lt+ce;if(Dt<0)throw new Error("More tasks executed then were scheduled.");0!=lt&&0!=Dt||this.hasTask(this.zone,{microTask:me.microTask>0,macroTask:me.macroTask>0,eventTask:me.eventTask>0,change:rt})}}class Ue{constructor(rt,ce,me,lt,Dt,An){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=rt,this.source=ce,this.data=lt,this.scheduleFn=Dt,this.cancelFn=An,!me)throw new Error("callback is not defined");this.callback=me;const Ve=this;this.invoke=rt===Ar&<&<.useG?Ue.invokeTask:function(){return Ue.invokeTask.call(re,Ve,this,arguments)}}static invokeTask(rt,ce,me){rt||(rt=this),_r++;try{return rt.runCount++,rt.zone.runTask(rt,ce,me)}finally{1==_r&&qe(),_r--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo($t,Tn)}_transitionTo(rt,ce,me){if(this._state!==ce&&this._state!==me)throw new Error(`${this.type} '${this.source}': can not transition to '${rt}', expecting state '${ce}'${me?" or '"+me+"'":""}, was '${this._state}'.`);this._state=rt,rt==$t&&(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 Ee=xe("setTimeout"),pe=xe("Promise"),_e=xe("then");let at,Le=[],Ne=!1;function Nt(jt){if(at||re[pe]&&(at=re[pe].resolve(0)),at){let rt=at[_e];rt||(rt=at.then),rt.call(at,jt)}else re[Ee](jt,0)}function ft(jt){0===_r&&0===Le.length&&Nt(qe),jt&&Le.push(jt)}function qe(){if(!Ne){for(Ne=!0;Le.length;){const jt=Le;Le=[];for(let rt=0;rtNn,onUnhandledError:Mn,microtaskDrainDone:Mn,scheduleMicroTask:ft,showUncaughtError:()=>!je[xe("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:Mn,patchMethod:()=>Mn,bindArguments:()=>[],patchThen:()=>Mn,patchMacroTask:()=>Mn,patchEventPrototype:()=>Mn,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>Mn,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>Mn,wrapWithCurrentZone:()=>Mn,filterProperties:()=>[],attachOriginToPatched:()=>Mn,_redefineProperty:()=>Mn,patchCallbacks:()=>Mn,nativeScheduleMicroTask:Nt};let Nn={parent:null,zone:new je(null,null)},Br=null,_r=0;function Mn(){}ye("Zone","Zone"),re.Zone=je}(typeof window<"u"&&window||typeof self<"u"&&self||global);const Q=Object.getOwnPropertyDescriptor,K=Object.defineProperty,x=Object.getPrototypeOf,y=Object.create,u=Array.prototype.slice,g="addEventListener",w="removeEventListener",m=Zone.__symbol__(g),h=Zone.__symbol__(w),c="true",f="false",d=Zone.__symbol__("");function b(re,le){return Zone.current.wrap(re,le)}function S(re,le,ge,ye,be){return Zone.current.scheduleMacroTask(re,le,ge,ye,be)}const E=Zone.__symbol__,v=typeof window<"u",p=v?window:void 0,I=v&&p||"object"==typeof self&&self||global;function P(re,le){for(let ge=re.length-1;ge>=0;ge--)"function"==typeof re[ge]&&(re[ge]=b(re[ge],le+"_"+ge));return re}function T(re){return!re||!1!==re.writable&&!("function"==typeof re.get&&typeof re.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,k=!("nw"in I)&&typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process),F=!k&&!M&&!(!v||!p.HTMLElement),$=typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process)&&!M&&!(!v||!p.HTMLElement),C={},O=function(re){if(!(re=re||I.event))return;let le=C[re.type];le||(le=C[re.type]=E("ON_PROPERTY"+re.type));const ge=this||re.target||I,ye=ge[le];let be;if(F&&ge===p&&"error"===re.type){const xe=re;be=ye&&ye.call(this,xe.message,xe.filename,xe.lineno,xe.colno,xe.error),!0===be&&re.preventDefault()}else be=ye&&ye.apply(this,arguments),null!=be&&!be&&re.preventDefault();return be};function U(re,le,ge){let ye=Q(re,le);if(!ye&&ge&&Q(ge,le)&&(ye={enumerable:!0,configurable:!0}),!ye||!ye.configurable)return;const be=E("on"+le+"patched");if(re.hasOwnProperty(be)&&re[be])return;delete ye.writable,delete ye.value;const xe=ye.get,ze=ye.set,je=le.slice(2);let Je=C[je];Je||(Je=C[je]=E("ON_PROPERTY"+je)),ye.set=function(Xe){let Ue=this;!Ue&&re===I&&(Ue=I),Ue&&("function"==typeof Ue[Je]&&Ue.removeEventListener(je,O),ze&&ze.call(Ue,null),Ue[Je]=Xe,"function"==typeof Xe&&Ue.addEventListener(je,O,!1))},ye.get=function(){let Xe=this;if(!Xe&&re===I&&(Xe=I),!Xe)return null;const Ue=Xe[Je];if(Ue)return Ue;if(xe){let Ee=xe.call(this);if(Ee)return ye.set.call(this,Ee),"function"==typeof Xe.removeAttribute&&Xe.removeAttribute(le),Ee}return null},K(re,le,ye),re[be]=!0}function L(re,le,ge){if(le)for(let ye=0;yefunction(ze,je){const Je=ge(ze,je);return Je.cbIdx>=0&&"function"==typeof je[Je.cbIdx]?S(Je.name,je[Je.cbIdx],Je,be):xe.apply(ze,je)})}function Z(re,le){re[E("OriginalDelegate")]=le}let W=!1,te=!1;function de(){if(W)return te;W=!0;try{const re=p.navigator.userAgent;(-1!==re.indexOf("MSIE ")||-1!==re.indexOf("Trident/")||-1!==re.indexOf("Edge/"))&&(te=!0)}catch{}return te}Zone.__load_patch("ZoneAwarePromise",(re,le,ge)=>{const ye=Object.getOwnPropertyDescriptor,be=Object.defineProperty,ze=ge.symbol,je=[],Je=!0===re[ze("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],Xe=ze("Promise"),Ue=ze("then");ge.onUnhandledError=Ve=>{if(ge.showUncaughtError()){const Ge=Ve&&Ve.rejection;Ge?console.error("Unhandled Promise rejection:",Ge instanceof Error?Ge.message:Ge,"; Zone:",Ve.zone.name,"; Task:",Ve.task&&Ve.task.source,"; Value:",Ge,Ge instanceof Error?Ge.stack:void 0):console.error(Ve)}},ge.microtaskDrainDone=()=>{for(;je.length;){const Ve=je.shift();try{Ve.zone.runGuarded(()=>{throw Ve.throwOriginal?Ve.rejection:Ve})}catch(Ge){_e(Ge)}}};const pe=ze("unhandledPromiseRejectionHandler");function _e(Ve){ge.onUnhandledError(Ve);try{const Ge=le[pe];"function"==typeof Ge&&Ge.call(this,Ve)}catch{}}function Le(Ve){return Ve&&Ve.then}function Ne(Ve){return Ve}function at(Ve){return ce.reject(Ve)}const Nt=ze("state"),ft=ze("value"),qe=ze("finally"),jn=ze("parentPromiseValue"),$t=ze("parentPromiseState"),un=null,Dn=!1;function Wt(Ve,Ge){return Ce=>{try{Yn(Ve,Ge,Ce)}catch(Ke){Yn(Ve,!1,Ke)}}}const Et=function(){let Ve=!1;return function(Ce){return function(){Ve||(Ve=!0,Ce.apply(null,arguments))}}},wi=ze("currentTaskTrace");function Yn(Ve,Ge,Ce){const Ke=Et();if(Ve===Ce)throw new TypeError("Promise resolved with itself");if(Ve[Nt]===un){let ct=null;try{("object"==typeof Ce||"function"==typeof Ce)&&(ct=Ce&&Ce.then)}catch(ht){return Ke(()=>{Yn(Ve,!1,ht)})(),Ve}if(Ge!==Dn&&Ce instanceof ce&&Ce.hasOwnProperty(Nt)&&Ce.hasOwnProperty(ft)&&Ce[Nt]!==un)Br(Ce),Yn(Ve,Ce[Nt],Ce[ft]);else if(Ge!==Dn&&"function"==typeof ct)try{ct.call(Ce,Ke(Wt(Ve,Ge)),Ke(Wt(Ve,!1)))}catch(ht){Ke(()=>{Yn(Ve,!1,ht)})()}else{Ve[Nt]=Ge;const ht=Ve[ft];if(Ve[ft]=Ce,Ve[qe]===qe&&!0===Ge&&(Ve[Nt]=Ve[$t],Ve[ft]=Ve[jn]),Ge===Dn&&Ce instanceof Error){const it=le.currentTask&&le.currentTask.data&&le.currentTask.data.__creationTrace__;it&&be(Ce,wi,{configurable:!0,enumerable:!1,writable:!0,value:it})}for(let it=0;it{try{const pt=Ve[ft],Mt=!!Ce&&qe===Ce[qe];Mt&&(Ce[jn]=pt,Ce[$t]=ht);const It=Ge.run(it,void 0,Mt&&it!==at&&it!==Ne?[]:[pt]);Yn(Ce,!0,It)}catch(pt){Yn(Ce,!1,pt)}},Ce)}const jt=function(){},rt=re.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Ge){return Yn(new this(null),!0,Ge)}static reject(Ge){return Yn(new this(null),Dn,Ge)}static any(Ge){if(!Ge||"function"!=typeof Ge[Symbol.iterator])return Promise.reject(new rt([],"All promises were rejected"));const Ce=[];let Ke=0;try{for(let it of Ge)Ke++,Ce.push(ce.resolve(it))}catch{return Promise.reject(new rt([],"All promises were rejected"))}if(0===Ke)return Promise.reject(new rt([],"All promises were rejected"));let ct=!1;const ht=[];return new ce((it,pt)=>{for(let Mt=0;Mt{ct||(ct=!0,it(It))},It=>{ht.push(It),Ke--,0===Ke&&(ct=!0,pt(new rt(ht,"All promises were rejected")))})})}static race(Ge){let Ce,Ke,ct=new this((pt,Mt)=>{Ce=pt,Ke=Mt});function ht(pt){Ce(pt)}function it(pt){Ke(pt)}for(let pt of Ge)Le(pt)||(pt=this.resolve(pt)),pt.then(ht,it);return ct}static all(Ge){return ce.allWithCallback(Ge)}static allSettled(Ge){return(this&&this.prototype instanceof ce?this:ce).allWithCallback(Ge,{thenCallback:Ke=>({status:"fulfilled",value:Ke}),errorCallback:Ke=>({status:"rejected",reason:Ke})})}static allWithCallback(Ge,Ce){let Ke,ct,ht=new this((It,En)=>{Ke=It,ct=En}),it=2,pt=0;const Mt=[];for(let It of Ge){Le(It)||(It=this.resolve(It));const En=pt;try{It.then(gn=>{Mt[En]=Ce?Ce.thenCallback(gn):gn,it--,0===it&&Ke(Mt)},gn=>{Ce?(Mt[En]=Ce.errorCallback(gn),it--,0===it&&Ke(Mt)):ct(gn)})}catch(gn){ct(gn)}it++,pt++}return it-=2,0===it&&Ke(Mt),ht}constructor(Ge){const Ce=this;if(!(Ce instanceof ce))throw new Error("Must be an instanceof Promise.");Ce[Nt]=un,Ce[ft]=[];try{const Ke=Et();Ge&&Ge(Ke(Wt(Ce,!0)),Ke(Wt(Ce,Dn)))}catch(Ke){Yn(Ce,!1,Ke)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return ce}then(Ge,Ce){var Ke;let ct=null===(Ke=this.constructor)||void 0===Ke?void 0:Ke[Symbol.species];(!ct||"function"!=typeof ct)&&(ct=this.constructor||ce);const ht=new ct(jt),it=le.current;return this[Nt]==un?this[ft].push(it,ht,Ge,Ce):_r(this,it,ht,Ge,Ce),ht}catch(Ge){return this.then(null,Ge)}finally(Ge){var Ce;let Ke=null===(Ce=this.constructor)||void 0===Ce?void 0:Ce[Symbol.species];(!Ke||"function"!=typeof Ke)&&(Ke=ce);const ct=new Ke(jt);ct[qe]=qe;const ht=le.current;return this[Nt]==un?this[ft].push(ht,ct,Ge,Ge):_r(this,ht,ct,Ge,Ge),ct}}ce.resolve=ce.resolve,ce.reject=ce.reject,ce.race=ce.race,ce.all=ce.all;const me=re[Xe]=re.Promise;re.Promise=ce;const lt=ze("thenPatched");function Dt(Ve){const Ge=Ve.prototype,Ce=ye(Ge,"then");if(Ce&&(!1===Ce.writable||!Ce.configurable))return;const Ke=Ge.then;Ge[Ue]=Ke,Ve.prototype.then=function(ct,ht){return new ce((pt,Mt)=>{Ke.call(this,pt,Mt)}).then(ct,ht)},Ve[lt]=!0}return ge.patchThen=Dt,me&&(Dt(me),G(re,"fetch",Ve=>function An(Ve){return function(Ge,Ce){let Ke=Ve.apply(Ge,Ce);if(Ke instanceof ce)return Ke;let ct=Ke.constructor;return ct[lt]||Dt(ct),Ke}}(Ve))),Promise[le.__symbol__("uncaughtPromiseErrors")]=je,ce}),Zone.__load_patch("toString",re=>{const le=Function.prototype.toString,ge=E("OriginalDelegate"),ye=E("Promise"),be=E("Error"),xe=function(){if("function"==typeof this){const Xe=this[ge];if(Xe)return"function"==typeof Xe?le.call(Xe):Object.prototype.toString.call(Xe);if(this===Promise){const Ue=re[ye];if(Ue)return le.call(Ue)}if(this===Error){const Ue=re[be];if(Ue)return le.call(Ue)}}return le.call(this)};xe[ge]=le,Function.prototype.toString=xe;const ze=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":ze.call(this)}});let he=!1;if(typeof window<"u")try{const re=Object.defineProperty({},"passive",{get:function(){he=!0}});window.addEventListener("test",re,re),window.removeEventListener("test",re,re)}catch{he=!1}const Pe={useG:!0},De={},Be={},ve=new RegExp("^"+d+"(\\w+)(true|false)$"),He=E("propagationStopped");function ke(re,le){const ge=(le?le(re):re)+f,ye=(le?le(re):re)+c,be=d+ge,xe=d+ye;De[re]={},De[re][f]=be,De[re][c]=xe}function nt(re,le,ge,ye){const be=ye&&ye.add||g,xe=ye&&ye.rm||w,ze=ye&&ye.listeners||"eventListeners",je=ye&&ye.rmAll||"removeAllListeners",Je=E(be),Xe="."+be+":",pe=function(ft,qe,jn){if(ft.isRemoved)return;const $t=ft.callback;let Tn;"object"==typeof $t&&$t.handleEvent&&(ft.callback=ot=>$t.handleEvent(ot),ft.originalDelegate=$t);try{ft.invoke(ft,qe,[jn])}catch(ot){Tn=ot}const un=ft.options;return un&&"object"==typeof un&&un.once&&qe[xe].call(qe,jn.type,ft.originalDelegate?ft.originalDelegate:ft.callback,un),Tn};function _e(ft,qe,jn){if(!(qe=qe||re.event))return;const $t=ft||qe.target||re,Tn=$t[De[qe.type][jn?c:f]];if(Tn){const un=[];if(1===Tn.length){const ot=pe(Tn[0],$t,qe);ot&&un.push(ot)}else{const ot=Tn.slice();for(let Dn=0;Dn{throw Dn})}}}const Le=function(ft){return _e(this,ft,!1)},Ne=function(ft){return _e(this,ft,!0)};function at(ft,qe){if(!ft)return!1;let jn=!0;qe&&void 0!==qe.useG&&(jn=qe.useG);const $t=qe&&qe.vh;let Tn=!0;qe&&void 0!==qe.chkDup&&(Tn=qe.chkDup);let un=!1;qe&&void 0!==qe.rt&&(un=qe.rt);let ot=ft;for(;ot&&!ot.hasOwnProperty(be);)ot=x(ot);if(!ot&&ft[be]&&(ot=ft),!ot||ot[Je])return!1;const Dn=qe&&qe.eventNameToString,et={},Wt=ot[Je]=ot[be],Et=ot[E(xe)]=ot[xe],Ar=ot[E(ze)]=ot[ze],wi=ot[E(je)]=ot[je];let Yn;function Nn(Ce,Ke){return!he&&"object"==typeof Ce&&Ce?!!Ce.capture:he&&Ke?"boolean"==typeof Ce?{capture:Ce,passive:!0}:Ce?"object"==typeof Ce&&!1!==Ce.passive?Object.assign(Object.assign({},Ce),{passive:!0}):Ce:{passive:!0}:Ce}qe&&qe.prepend&&(Yn=ot[E(qe.prepend)]=ot[qe.prepend]);const ce=jn?function(Ce){if(!et.isExisting)return Wt.call(et.target,et.eventName,et.capture?Ne:Le,et.options)}:function(Ce){return Wt.call(et.target,et.eventName,Ce.invoke,et.options)},me=jn?function(Ce){if(!Ce.isRemoved){const Ke=De[Ce.eventName];let ct;Ke&&(ct=Ke[Ce.capture?c:f]);const ht=ct&&Ce.target[ct];if(ht)for(let it=0;itfunction(be,xe){be[He]=!0,ye&&ye.apply(be,xe)})}function Vt(re,le,ge,ye,be){const xe=Zone.__symbol__(ye);if(le[xe])return;const ze=le[xe]=le[ye];le[ye]=function(je,Je,Xe){return Je&&Je.prototype&&be.forEach(function(Ue){const Ee=`${ge}.${ye}::`+Ue,pe=Je.prototype;try{if(pe.hasOwnProperty(Ue)){const _e=re.ObjectGetOwnPropertyDescriptor(pe,Ue);_e&&_e.value?(_e.value=re.wrapWithCurrentZone(_e.value,Ee),re._redefineProperty(Je.prototype,Ue,_e)):pe[Ue]&&(pe[Ue]=re.wrapWithCurrentZone(pe[Ue],Ee))}else pe[Ue]&&(pe[Ue]=re.wrapWithCurrentZone(pe[Ue],Ee))}catch{}}),ze.call(le,je,Je,Xe)},re.attachOriginToPatched(le[ye],ze)}function Yt(re,le,ge){if(!ge||0===ge.length)return le;const ye=ge.filter(xe=>xe.target===re);if(!ye||0===ye.length)return le;const be=ye[0].ignoreProperties;return le.filter(xe=>-1===be.indexOf(xe))}function nn(re,le,ge,ye){re&&L(re,Yt(re,le,ge),ye)}function cn(re){return Object.getOwnPropertyNames(re).filter(le=>le.startsWith("on")&&le.length>2).map(le=>le.substring(2))}Zone.__load_patch("util",(re,le,ge)=>{const ye=cn(re);ge.patchOnProperties=L,ge.patchMethod=G,ge.bindArguments=P,ge.patchMacroTask=ee;const be=le.__symbol__("BLACK_LISTED_EVENTS"),xe=le.__symbol__("UNPATCHED_EVENTS");re[xe]&&(re[be]=re[xe]),re[be]&&(le[be]=le[xe]=re[be]),ge.patchEventPrototype=_t,ge.patchEventTarget=nt,ge.isIEOrEdge=de,ge.ObjectDefineProperty=K,ge.ObjectGetOwnPropertyDescriptor=Q,ge.ObjectCreate=y,ge.ArraySlice=u,ge.patchClass=ne,ge.wrapWithCurrentZone=b,ge.filterProperties=Yt,ge.attachOriginToPatched=Z,ge._redefineProperty=Object.defineProperty,ge.patchCallbacks=Vt,ge.getGlobalObjects=()=>({globalSources:Be,zoneSymbolEventNames:De,eventNames:ye,isBrowser:F,isMix:$,isNode:k,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:w})});const Tr=E("zoneTask");function _n(re,le,ge,ye){let be=null,xe=null;ge+=ye;const ze={};function je(Xe){const Ue=Xe.data;return Ue.args[0]=function(){return Xe.invoke.apply(this,arguments)},Ue.handleId=be.apply(re,Ue.args),Xe}function Je(Xe){return xe.call(re,Xe.data.handleId)}be=G(re,le+=ye,Xe=>function(Ue,Ee){if("function"==typeof Ee[0]){const pe={isPeriodic:"Interval"===ye,delay:"Timeout"===ye||"Interval"===ye?Ee[1]||0:void 0,args:Ee},_e=Ee[0];Ee[0]=function(){try{return _e.apply(this,arguments)}finally{pe.isPeriodic||("number"==typeof pe.handleId?delete ze[pe.handleId]:pe.handleId&&(pe.handleId[Tr]=null))}};const Le=S(le,Ee[0],pe,je,Je);if(!Le)return Le;const Ne=Le.data.handleId;return"number"==typeof Ne?ze[Ne]=Le:Ne&&(Ne[Tr]=Le),Ne&&Ne.ref&&Ne.unref&&"function"==typeof Ne.ref&&"function"==typeof Ne.unref&&(Le.ref=Ne.ref.bind(Ne),Le.unref=Ne.unref.bind(Ne)),"number"==typeof Ne||Ne?Ne:Le}return Xe.apply(re,Ee)}),xe=G(re,ge,Xe=>function(Ue,Ee){const pe=Ee[0];let _e;"number"==typeof pe?_e=ze[pe]:(_e=pe&&pe[Tr],_e||(_e=pe)),_e&&"string"==typeof _e.type?"notScheduled"!==_e.state&&(_e.cancelFn&&_e.data.isPeriodic||0===_e.runCount)&&("number"==typeof pe?delete ze[pe]:pe&&(pe[Tr]=null),_e.zone.cancelTask(_e)):Xe.apply(re,Ee)})}Zone.__load_patch("legacy",re=>{const le=re[Zone.__symbol__("legacyPatch")];le&&le()}),Zone.__load_patch("queueMicrotask",(re,le,ge)=>{ge.patchMethod(re,"queueMicrotask",ye=>function(be,xe){le.current.scheduleMicroTask("queueMicrotask",xe[0])})}),Zone.__load_patch("timers",re=>{const ge="clear";_n(re,"set",ge,"Timeout"),_n(re,"set",ge,"Interval"),_n(re,"set",ge,"Immediate")}),Zone.__load_patch("requestAnimationFrame",re=>{_n(re,"request","cancel","AnimationFrame"),_n(re,"mozRequest","mozCancel","AnimationFrame"),_n(re,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(re,le)=>{const ge=["alert","prompt","confirm"];for(let ye=0;yefunction(Je,Xe){return le.current.run(xe,re,Xe,je)})}),Zone.__load_patch("EventTarget",(re,le,ge)=>{(function es(re,le){le.patchEventPrototype(re,le)})(re,ge),function Qr(re,le){if(Zone[le.symbol("patchEventTarget")])return;const{eventNames:ge,zoneSymbolEventNames:ye,TRUE_STR:be,FALSE_STR:xe,ZONE_SYMBOL_PREFIX:ze}=le.getGlobalObjects();for(let Je=0;Je{ne("MutationObserver"),ne("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(re,le,ge)=>{ne("IntersectionObserver")}),Zone.__load_patch("FileReader",(re,le,ge)=>{ne("FileReader")}),Zone.__load_patch("on_property",(re,le,ge)=>{!function $n(re,le){if(k&&!$||Zone[re.symbol("patchEvents")])return;const ge=le.__Zone_ignore_on_properties;let ye=[];if(F){const be=window;ye=ye.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);const xe=function oe(){try{const re=p.navigator.userAgent;if(-1!==re.indexOf("MSIE ")||-1!==re.indexOf("Trident/"))return!0}catch{}return!1}()?[{target:be,ignoreProperties:["error"]}]:[];nn(be,cn(be),ge&&ge.concat(xe),x(be))}ye=ye.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let be=0;be{!function Oi(re,le){const{isBrowser:ge,isMix:ye}=le.getGlobalObjects();(ge||ye)&&re.customElements&&"customElements"in re&&le.patchCallbacks(le,re.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(re,ge)}),Zone.__load_patch("XHR",(re,le)=>{!function Je(Xe){const Ue=Xe.XMLHttpRequest;if(!Ue)return;const Ee=Ue.prototype;let _e=Ee[m],Le=Ee[h];if(!_e){const et=Xe.XMLHttpRequestEventTarget;if(et){const Wt=et.prototype;_e=Wt[m],Le=Wt[h]}}const Ne="readystatechange",at="scheduled";function Nt(et){const Wt=et.data,Et=Wt.target;Et[xe]=!1,Et[je]=!1;const Ar=Et[be];_e||(_e=Et[m],Le=Et[h]),Ar&&Le.call(Et,Ne,Ar);const wi=Et[be]=()=>{if(Et.readyState===Et.DONE)if(!Wt.aborted&&Et[xe]&&et.state===at){const Nn=Et[le.__symbol__("loadfalse")];if(0!==Et.status&&Nn&&Nn.length>0){const Br=et.invoke;et.invoke=function(){const _r=Et[le.__symbol__("loadfalse")];for(let Mn=0;Mn<_r.length;Mn++)_r[Mn]===et&&_r.splice(Mn,1);!Wt.aborted&&et.state===at&&Br.call(et)},Nn.push(et)}else et.invoke()}else!Wt.aborted&&!1===Et[xe]&&(Et[je]=!0)};return _e.call(Et,Ne,wi),Et[ge]||(Et[ge]=et),ot.apply(Et,Wt.args),Et[xe]=!0,et}function ft(){}function qe(et){const Wt=et.data;return Wt.aborted=!0,Dn.apply(Wt.target,Wt.args)}const jn=G(Ee,"open",()=>function(et,Wt){return et[ye]=0==Wt[2],et[ze]=Wt[1],jn.apply(et,Wt)}),Tn=E("fetchTaskAborting"),un=E("fetchTaskScheduling"),ot=G(Ee,"send",()=>function(et,Wt){if(!0===le.current[un]||et[ye])return ot.apply(et,Wt);{const Et={target:et,url:et[ze],isPeriodic:!1,args:Wt,aborted:!1},Ar=S("XMLHttpRequest.send",ft,Et,Nt,qe);et&&!0===et[je]&&!Et.aborted&&Ar.state===at&&Ar.invoke()}}),Dn=G(Ee,"abort",()=>function(et,Wt){const Et=function pe(et){return et[ge]}(et);if(Et&&"string"==typeof Et.type){if(null==Et.cancelFn||Et.data&&Et.data.aborted)return;Et.zone.cancelTask(Et)}else if(!0===le.current[Tn])return Dn.apply(et,Wt)})}(re);const ge=E("xhrTask"),ye=E("xhrSync"),be=E("xhrListener"),xe=E("xhrScheduled"),ze=E("xhrURL"),je=E("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",re=>{re.navigator&&re.navigator.geolocation&&function D(re,le){const ge=re.constructor.name;for(let ye=0;ye{const Je=function(){return je.apply(this,P(arguments,ge+"."+be))};return Z(Je,je),Je})(xe)}}}(re.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(re,le)=>{function ge(ye){return function(be){Pt(re,ye).forEach(ze=>{const je=re.PromiseRejectionEvent;if(je){const Je=new je(ye,{promise:be.promise,reason:be.rejection});ze.invoke(Je)}})}}re.PromiseRejectionEvent&&(le[E("unhandledPromiseRejectionHandler")]=ge("unhandledrejection"),le[E("rejectionHandledHandler")]=ge("rejectionhandled"))})},9572:()=>{},4490:()=>{},985:()=>{},9437:()=>{},7946:()=>{},5768:()=>{},7602:function(Q,K,x){"use strict";var u,g;u=[x(5477)],void 0!==(g=function(w){var m=w.Reader,h=w.Writer,c=w.util,f=w.roots.default||(w.roots.default={});return f.RPC=function(){function d(S){if(this.subscriptions=[],this.messages=[],S)for(var E=Object.keys(S),v=0;v>>3){case 1:I.subscriptions&&I.subscriptions.length||(I.subscriptions=[]),I.subscriptions.push(f.RPC.SubOpts.decode(E,E.uint32()));break;case 2:I.messages&&I.messages.length||(I.messages=[]),I.messages.push(f.RPC.Message.decode(E,E.uint32()));break;case 3:I.control=f.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return I},d.fromObject=function(E){if(E instanceof f.RPC)return E;var v=new f.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");v.subscriptions=[];for(var p=0;p>>3){case 1:P.subscribe=p.bool();break;case 2:P.topic=p.string();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.SubOpts)return p;var I=new f.RPC.SubOpts;return null!=p.subscribe&&(I.subscribe=Boolean(p.subscribe)),null!=p.topic&&(I.topic=String(p.topic)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.subscribe&&p.hasOwnProperty("subscribe")&&(A.subscribe=p.subscribe,I.oneofs&&(A._subscribe="subscribe")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic,I.oneofs&&(A._topic="topic")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.Message=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.from=p.bytes();break;case 2:P.data=p.bytes();break;case 3:P.seqno=p.bytes();break;case 4:P.topic=p.string();break;case 5:P.signature=p.bytes();break;case 6:P.key=p.bytes();break;default:p.skipType(7&D)}}if(!P.hasOwnProperty("topic"))throw c.ProtocolError("missing required 'topic'",{instance:P});return P},S.fromObject=function(p){if(p instanceof f.RPC.Message)return p;var I=new f.RPC.Message;return null!=p.from&&("string"==typeof p.from?c.base64.decode(p.from,I.from=c.newBuffer(c.base64.length(p.from)),0):p.from.length&&(I.from=p.from)),null!=p.data&&("string"==typeof p.data?c.base64.decode(p.data,I.data=c.newBuffer(c.base64.length(p.data)),0):p.data.length&&(I.data=p.data)),null!=p.seqno&&("string"==typeof p.seqno?c.base64.decode(p.seqno,I.seqno=c.newBuffer(c.base64.length(p.seqno)),0):p.seqno.length&&(I.seqno=p.seqno)),null!=p.topic&&(I.topic=String(p.topic)),null!=p.signature&&("string"==typeof p.signature?c.base64.decode(p.signature,I.signature=c.newBuffer(c.base64.length(p.signature)),0):p.signature.length&&(I.signature=p.signature)),null!=p.key&&("string"==typeof p.key?c.base64.decode(p.key,I.key=c.newBuffer(c.base64.length(p.key)),0):p.key.length&&(I.key=p.key)),I},S.toObject=function(p,I){I||(I={});var A={};return I.defaults&&(A.topic=""),null!=p.from&&p.hasOwnProperty("from")&&(A.from=I.bytes===String?c.base64.encode(p.from,0,p.from.length):I.bytes===Array?Array.prototype.slice.call(p.from):p.from,I.oneofs&&(A._from="from")),null!=p.data&&p.hasOwnProperty("data")&&(A.data=I.bytes===String?c.base64.encode(p.data,0,p.data.length):I.bytes===Array?Array.prototype.slice.call(p.data):p.data,I.oneofs&&(A._data="data")),null!=p.seqno&&p.hasOwnProperty("seqno")&&(A.seqno=I.bytes===String?c.base64.encode(p.seqno,0,p.seqno.length):I.bytes===Array?Array.prototype.slice.call(p.seqno):p.seqno,I.oneofs&&(A._seqno="seqno")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic),null!=p.signature&&p.hasOwnProperty("signature")&&(A.signature=I.bytes===String?c.base64.encode(p.signature,0,p.signature.length):I.bytes===Array?Array.prototype.slice.call(p.signature):p.signature,I.oneofs&&(A._signature="signature")),null!=p.key&&p.hasOwnProperty("key")&&(A.key=I.bytes===String?c.base64.encode(p.key,0,p.key.length):I.bytes===Array?Array.prototype.slice.call(p.key):p.key,I.oneofs&&(A._key="key")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlMessage=function(){function S(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var v=Object.keys(E),p=0;p>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(f.RPC.ControlIHave.decode(v,v.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(f.RPC.ControlIWant.decode(v,v.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(f.RPC.ControlGraft.decode(v,v.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(f.RPC.ControlPrune.decode(v,v.uint32()));break;default:v.skipType(7&P)}}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlMessage)return v;var p=new f.RPC.ControlMessage;if(v.ihave){if(!Array.isArray(v.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");p.ihave=[];for(var I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.messageIDs&&P.messageIDs.length||(P.messageIDs=[]),P.messageIDs.push(p.bytes());break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlIHave)return p;var I=new f.RPC.ControlIHave;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.messageIDs){if(!Array.isArray(p.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");I.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(v.bytes())):v.skipType(7&P)}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlIWant)return v;var p=new f.RPC.ControlIWant;if(v.messageIDs){if(!Array.isArray(v.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");p.messageIDs=[];for(var I=0;I>>3==1?P.topicID=p.string():p.skipType(7&D)}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlGraft)return p;var I=new f.RPC.ControlGraft;return null!=p.topicID&&(I.topicID=String(p.topicID)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlPrune=function(){function S(v){if(this.peers=[],v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.peers&&P.peers.length||(P.peers=[]),P.peers.push(f.RPC.PeerInfo.decode(p,p.uint32()));break;case 3:P.backoff=p.uint64();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlPrune)return p;var I=new f.RPC.ControlPrune;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.peers){if(!Array.isArray(p.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");I.peers=[];for(var A=0;A>>0,p.backoff.high>>>0).toNumber(!0))),I},S.toObject=function(p,I){I||(I={});var A={};if((I.arrays||I.defaults)&&(A.peers=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),p.peers&&p.peers.length){A.peers=[];for(var P=0;P>>0,p.backoff.high>>>0).toNumber(!0):p.backoff,I.oneofs&&(A._backoff="backoff")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.PeerInfo=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.peerID=p.bytes();break;case 2:P.signedPeerRecord=p.bytes();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.PeerInfo)return p;var I=new f.RPC.PeerInfo;return null!=p.peerID&&("string"==typeof p.peerID?c.base64.decode(p.peerID,I.peerID=c.newBuffer(c.base64.length(p.peerID)),0):p.peerID.length&&(I.peerID=p.peerID)),null!=p.signedPeerRecord&&("string"==typeof p.signedPeerRecord?c.base64.decode(p.signedPeerRecord,I.signedPeerRecord=c.newBuffer(c.base64.length(p.signedPeerRecord)),0):p.signedPeerRecord.length&&(I.signedPeerRecord=p.signedPeerRecord)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.peerID&&p.hasOwnProperty("peerID")&&(A.peerID=I.bytes===String?c.base64.encode(p.peerID,0,p.peerID.length):I.bytes===Array?Array.prototype.slice.call(p.peerID):p.peerID,I.oneofs&&(A._peerID="peerID")),null!=p.signedPeerRecord&&p.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=I.bytes===String?c.base64.encode(p.signedPeerRecord,0,p.signedPeerRecord.length):I.bytes===Array?Array.prototype.slice.call(p.signedPeerRecord):p.signedPeerRecord,I.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d}(),f}.apply(K,u))&&(Q.exports=g)},7395:(Q,K,x)=>{var y=x(6865);function u(g){var w,m;function c(d,b){try{var S=g[d](b),E=S.value,v=E instanceof y;Promise.resolve(v?E.wrapped:E).then(function(p){v?c("return"===d?"return":"next",p):f(S.done?"return":"normal",p)},function(p){c("throw",p)})}catch(p){f("throw",p)}}function f(d,b){switch(d){case"return":w.resolve({value:b,done:!0});break;case"throw":w.reject(b);break;default:w.resolve({value:b,done:!1})}(w=w.next)?c(w.key,w.arg):m=null}this._invoke=function h(d,b){return new Promise(function(S,E){var v={key:d,arg:b,resolve:S,reject:E,next:null};m?m=m.next=v:(w=m=v,c(d,b))})},"function"!=typeof g.return&&(this.return=void 0)}u.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},u.prototype.next=function(g){return this._invoke("next",g)},u.prototype.throw=function(g){return this._invoke("throw",g)},u.prototype.return=function(g){return this._invoke("return",g)},Q.exports=u,Q.exports.__esModule=!0,Q.exports.default=Q.exports},6865:Q=>{Q.exports=function K(x){this.wrapped=x},Q.exports.__esModule=!0,Q.exports.default=Q.exports},4670:Q=>{Q.exports=function K(x,y){var u={},g=!1;function w(m,h){return g=!0,h=new Promise(function(c){c(x[m](h))}),{done:!1,value:y(h)}}return u[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},u.next=function(m){return g?(g=!1,m):w("next",m)},"function"==typeof x.throw&&(u.throw=function(m){if(g)throw g=!1,m;return w("throw",m)}),"function"==typeof x.return&&(u.return=function(m){return g?(g=!1,m):w("return",m)}),u},Q.exports.__esModule=!0,Q.exports.default=Q.exports},2508:Q=>{function x(y){function u(g){if(Object(g)!==g)return Promise.reject(new TypeError(g+" is not an object."));var w=g.done;return Promise.resolve(g.value).then(function(m){return{value:m,done:w}})}return(x=function(w){this.s=w,this.n=w.next}).prototype={s:null,n:null,next:function(){return u(this.n.apply(this.s,arguments))},return:function(w){var m=this.s.return;return void 0===m?Promise.resolve({value:w,done:!0}):u(m.apply(this.s,arguments))},throw:function(w){var m=this.s.return;return void 0===m?Promise.reject(w):u(m.apply(this.s,arguments))}},new x(y)}Q.exports=function K(y){var u,g,w,m=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,w=Symbol.iterator);m--;){if(g&&null!=(u=y[g]))return u.call(y);if(w&&null!=(u=y[w]))return new x(u.call(y));g="@@asyncIterator",w="@@iterator"}throw new TypeError("Object is not async iterable")},Q.exports.__esModule=!0,Q.exports.default=Q.exports},411:Q=>{function K(y,u,g,w,m,h,c){try{var f=y[h](c),d=f.value}catch(b){return void g(b)}f.done?u(d):Promise.resolve(d).then(w,m)}Q.exports=function x(y){return function(){var u=this,g=arguments;return new Promise(function(w,m){var h=y.apply(u,g);function c(d){K(h,w,m,c,f,"next",d)}function f(d){K(h,w,m,c,f,"throw",d)}c(void 0)})}},Q.exports.__esModule=!0,Q.exports.default=Q.exports},2449:(Q,K,x)=>{var y=x(6865);Q.exports=function u(g){return new y(g)},Q.exports.__esModule=!0,Q.exports.default=Q.exports},3683:(Q,K,x)=>{var y=x(7395);Q.exports=function u(g){return function(){return new y(g.apply(this,arguments))}},Q.exports.__esModule=!0,Q.exports.default=Q.exports}},Q=>{Q(Q.s=7497)}]);