mirror of
https://github.com/logos-messaging/examples.waku.org.git
synced 2026-01-05 06:13:11 +00:00
1 line
993 KiB
JavaScript
1 line
993 KiB
JavaScript
(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.length&&!e.closed;t++)e.next(n[t]);e.complete()})}(n);if(Br(n))return function Ce(n){return new cn(e=>{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=>_<r?Y(X):l.push(X),Y=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&&_<r;){const fe=l.shift();o?pt(e,o,()=>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;t++){const s=n.data[t].type.prototype,{ngAfterContentInit:o,ngAfterContentChecked:a,ngAfterViewInit:l,ngAfterViewChecked:_,ngOnDestroy:R}=s;o&&(n.contentHooks||(n.contentHooks=[])).push(-t,o),a&&((n.contentHooks||(n.contentHooks=[])).push(t,a),(n.contentCheckHooks||(n.contentCheckHooks=[])).push(t,a)),l&&(n.viewHooks||(n.viewHooks=[])).push(-t,l),_&&((n.viewHooks||(n.viewHooks=[])).push(t,_),(n.viewCheckHooks||(n.viewCheckHooks=[])).push(t,_)),null!=R&&(n.destroyHooks||(n.destroyHooks=[])).push(t,R)}}function mf(n,e,t){fb(n,e,3,t)}function vf(n,e,t,r){(3&n[2])===t&&fb(n,e,t,r)}function Pp(n,e){let t=n[2];(3&t)===e&&(t&=2047,t+=1,n[2]=t)}function fb(n,e,t,r){const s=r??-1,o=e.length-1;let a=0;for(let l=void 0!==r?65535&n[18]:0;l<o;l++)if("number"==typeof e[l+1]){if(a=e[l],null!=r&&a>=r)break}else e[l]<0&&(n[18]+=65536),(a<s||-1==s)&&(bx(n,t,e,l),n[18]=(4294901760&n[18])+l+2),l++}function bx(n,e,t,r){const i=t[r]<0,s=t[r+1],a=n[i?-t[r]:t[r]];if(i){if(n[2]>>11<n[18]>>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(;r<t.length;){const i=t[r];if("number"==typeof i){if(0!==i)break;r++;const s=t[r++],o=t[r++],a=t[r++];n.setAttribute(e,o,a,s)}else{const s=i,o=t[++r];hb(s)?n.setProperty(e,s,o):n.setAttribute(e,s,o),r++}}return r}function db(n){return 3===n||4===n||6===n}function hb(n){return 64===n.charCodeAt(0)}function bf(n,e){if(null!==e&&0!==e.length)if(null===n||0===n.length)n=e.slice();else{let t=-1;for(let r=0;r<e.length;r++){const i=e[r];"number"==typeof i?t=i:0===t||pb(n,t,i,null,-1===t||2===t?e[++r]:null)}}return n}function pb(n,e,t,r,i){let s=0,o=n.length;if(-1===e)o=-1;else for(;s<n.length;){const a=n[s++];if("number"==typeof a){if(a===e){o=-1;break}if(a>e){o=s-1;break}}}for(;s<n.length;){const a=n[s];if("number"==typeof a)break;if(a===t){if(null===r)return void(null!==i&&(n[s+1]=i));if(r===n[s+1])return void(n[s+2]=i)}s++,null!==r&&s++,null!==i&&s++}-1!==o&&(n.splice(o,0,e),s=o+1),n.splice(s++,0,t),null!==r&&n.splice(s++,0,r),null!==i&&n.splice(s++,0,i)}function gb(n){return-1!==n}function Ga(n){return 32767&n}function za(n,e){let t=function Cx(n){return n>>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<<i}(n,e,t)}function vb(n,e,t){if(t&St.Optional)return n;tf()}function Eb(n,e,t,r){if(t&St.Optional&&void 0===r&&(r=null),0==(t&(St.Self|St.Host))){const i=n[9],s=Li(void 0);try{return i?i.get(e,r,t&St.Optional):KE(e,r,t&St.Optional)}finally{Li(s)}}return vb(r,0,t)}function bb(n,e,t,r=St.Default,i){if(null!==n){if(1024&e[2]){const o=function Mx(n,e,t,r,i){let s=n,o=e;for(;null!==s&&null!==o&&1024&o[2]&&!(256&o[2]);){const a=wb(s,o,t,r|St.Self,Ts);if(a!==Ts)return a;let l=s.parent;if(!l){const _=o[21];if(_){const R=_.get(t,Ts,r);if(R!==Ts)return R}l=Sb(o),o=o[15]}s=l}return i}(n,e,t,r,Ts);if(o!==Ts)return o}const s=wb(n,e,t,r,Ts);if(s!==Ts)return s}return Eb(e,t,r,i)}function wb(n,e,t,r,i){const s=function Rx(n){if("string"==typeof n)return n.charCodeAt(0)||0;const e=n.hasOwnProperty(gu)?n[gu]:void 0;return"number"==typeof e?e>=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<B;V++){const Y=o[V];if(V<l&&t===Y||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<<n)}function Db(n,e){return!(n&St.Self||n&St.Host&&e)}class Wa{constructor(e,t){this._tNode=e,this._lView=t}get(e,t,r){return bb(this._tNode,this._lView,e,r,t)}}function Px(){return new Wa(Dr(),Me())}function Sb(n){const e=n[1],t=e.type;return 2===t?e.declTNode:1===t?n[6]:null}const Qa="__parameters__";function Za(n,e,t){return Do(()=>{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<n.length;t++){const r=bt(n[t]);if(Array.isArray(r)){if(0===r.length)throw new mt(900,!1);let i,s=St.Default;for(let o=0;o<r.length;o++){const a=r[o],l=Qx(a);"number"==typeof l?-1===l?i=a.token:s|=l:i=a}e.push(wn(i,s))}else e.push(wn(r))}return e}function Pu(n,e){return n[Kp]=e,n.prototype[Kp]=e,n}function Qx(n){return n[Kp]}const Af=Pu(Za("Optional"),8),xf=Pu(Za("SkipSelf"),4);let Gp;const Jb=new Xt("ENVIRONMENT_INITIALIZER"),ew=new Xt("INJECTOR",-1),tw=new Xt("INJECTOR_DEF_TYPES");class nw{get(e,t=xu){if(t===xu){const r=new Error(`NullInjectorError: No provider for ${dn(e)}!`);throw r.name="NullInjectorError",r}return t}}function MR(...n){return{\u0275providers:rw(0,n)}}function rw(n,...e){const t=[],r=new Set;let i;return Ws(e,s=>{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<n.length;t++){const{providers:i}=n[t];Ws(i,s=>{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;r<n;r++)t.push(e);return t}(e,"?"),new mt(204,!1);const t=function PA(n){const e=n&&(n[rf]||n[HE]);if(e){const t=function NA(n){if(n.hasOwnProperty("name"))return n.name;const e=(""+n).match(/^function\s*([^\s(]+)/);return null===e?"":e[1]}(n);return console.warn(`DEPRECATED: DI is instantiating a token "${t}" that inherits its @Injectable decorator but does not provide one itself.\nThis will become an error in a future version of Angular. Please add @Injectable() to the "${t}" class.`),e}return null}(n);return null!==t?()=>t.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;a<t.length;a++){const l=t[a];Uu(l[1],l,n,e,r,s)}}(e,n,s,t,i)}}function bg(n,e,t){return n.createElement(e,t)}function Tw(n,e){const t=n[9],r=t.indexOf(e),i=e[3];512&e[2]&&(e[2]&=-513,Dp(i,-1)),t.splice(r,1)}function wg(n,e){if(n.length<=10)return;const t=10+e,r=n[t];if(r){const i=r[17];null!==i&&i!==n&&Tw(i,r),e>0&&(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<t.length;r+=2){const i=e[t[r]];if(!(i instanceof _u)){const s=t[r+1];if(Array.isArray(s))for(let o=0;o<s.length;o+=2){const a=i[s[o]],l=s[o+1];try{l.call(a)}finally{}}else try{s.call(i)}finally{}}}}(n,e),function kP(n,e){const t=n.cleanup,r=e[7];let i=-1;if(null!==t)for(let s=0;s<t.length-1;s+=2)if("string"==typeof t[s]){const o=t[s+1],a="function"==typeof o?o(e):dr(e[o]),l=r[i=t[s+2]],_=t[s+3];"boolean"==typeof _?a.removeEventListener(t[s],l,_):_>=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;s<r.length;s++)(0,r[s])();e[7]=null}}(n,e),1===e[1].type&&e[11].destroy();const t=e[17];if(null!==t&&ss(e[3])){t!==e[3]&&Tw(t,e);const r=e[19];null!==r&&r.detachView(n)}!function fP(n){fg.delete(n[20])}(e)}}function xw(n,e,t){return function Rw(n,e,t){let r=e;for(;null!==r&&40&r.type;)r=(e=r).parent;if(null===r)return t[0];if(2&r.flags){const i=n.data[r.directiveStart].encapsulation;if(i===Cs.None||i===Cs.Emulated)return null}return Vi(r,t)}(n,e.parent,t)}function da(n,e,t,r,i){n.insertBefore(e,t,r,i)}function Pw(n,e,t){n.appendChild(e,t)}function Nw(n,e,t,r,i){null!==r?da(n,e,t,r,i):Pw(n,e,t)}function Uf(n,e){return n.parentNode(e)}let kw=function Ow(n,e,t){return 40&n.type?Vi(n,t):null};function Vf(n,e,t,r){const i=xw(n,r,e),s=e[11],a=function Mw(n,e,t){return kw(n,e,t)}(r.parent||e[6],r,e);if(null!=i)if(Array.isArray(t))for(let l=0;l<t.length;l++)Nw(s,i,t[l],a,!1);else Nw(s,i,t,a,!1)}function Hf(n,e){if(null!==e){const t=e.type;if(3&t)return Vi(e,n);if(4&t)return Sg(-1,n[e.index]);if(8&t){const r=e.child;if(null!==r)return Hf(n,r);{const i=n[e.index];return ss(i)?Sg(-1,i):dr(i)}}if(32&t)return yg(e,n)()||dr(n[e.index]);{const r=Bw(n,e);return null!==r?Array.isArray(r)?r[0]:Hf(Fu(n[16]),r):Hf(n,e.next)}}return null}function Bw(n,e){return null!==e?n[16][6].projection[e.projection]:null}function Sg(n,e){const t=10+n+1;if(t<e.length){const r=e[t],i=r[1].firstChild;if(null!==i)return Hf(r,i)}return e[7]}function Cg(n,e,t,r,i,s,o){for(;null!=t;){const a=r[t.index],l=t.type;if(o&&0===e&&(a&&Vr(dr(a),r),t.flags|=4),64!=(64&t.flags))if(8&l)Cg(n,e,t.child,r,i,s,!1),cc(e,n,i,a,s);else if(32&l){const _=yg(t,r);let R;for(;R=_();)cc(e,n,i,R,s);cc(e,n,i,a,s)}else 16&l?Uw(n,e,r,t,i,s):cc(e,n,i,a,s);t=o?t.projectionNext:t.next}}function Uu(n,e,t,r,i,s){Cg(t,r,n.firstChild,e,i,s,!1)}function Uw(n,e,t,r,i,s){const o=t[16],l=o[6].projection[r.projection];if(Array.isArray(l))for(let _=0;_<l.length;_++)cc(e,n,i,l[_],s);else Cg(n,e,l,o[3],i,s,!0)}function Vw(n,e,t){n.setAttribute(e,"style",t)}function Ig(n,e,t){""===t?n.removeAttribute(e,"class"):n.setAttribute(e,"class",t)}function Hw(n,e,t){let r=n.length;for(;;){const i=n.indexOf(e,t);if(-1===i)return i;if(0===i||n.charCodeAt(i-1)<=32){const s=e.length;if(i+s===r||n.charCodeAt(i+s)<=32)return i}t=i+1}}const Kw="ng-template";function KP(n,e,t){let r=0;for(;r<n.length;){let i=n[r++];if(t&&"class"===i){if(i=n[r],-1!==Hw(i.toLowerCase(),e,0))return!0}else if(1===i){for(;r<n.length&&"string"==typeof(i=n[r++]);)if(i.toLowerCase()===e)return!0;return!1}}return!1}function $w(n){return 4===n.type&&n.value!==Kw}function $P(n,e,t){return e===(4!==n.type||t?n.value:Kw)}function jP(n,e,t){let r=4;const i=n.attrs||[],s=function WP(n){for(let e=0;e<n.length;e++)if(db(n[e]))return e;return n.length}(i);let o=!1;for(let a=0;a<e.length;a++){const l=e[a];if("number"!=typeof l){if(!o)if(4&r){if(r=2|1&r,""!==l&&!$P(n,l,t)||""===l&&1===e.length){if(as(r))return!1;o=!0}}else{const _=8&r?l:e[++a];if(8&r&&null!==n.attrs){if(!KP(n.attrs,_,t)){if(as(r))return!1;o=!0}continue}const N=GP(8&r?"class":l,i,$w(n),t);if(-1===N){if(as(r))return!1;o=!0;continue}if(""!==_){let B;B=N>s?"":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<e.length;){const o=e[i];if(o===n)return i;if(3===o||6===o)s=!0;else{if(1===o||2===o){let a=e[++i];for(;"string"==typeof a;)a=e[++i];continue}if(4===o)break;if(0===o){i+=4;continue}}i+=s?1:2}return-1}return function qP(n,e){let t=n.indexOf(4);if(t>-1)for(t++;t<n.length;){const r=n[t];if("number"==typeof r)return-1;if(r===e)return t;t++}return-1}(e,n)}function jw(n,e,t=!1){for(let r=0;r<e.length;r++)if(jP(n,e[r],t))return!0;return!1}function Gw(n,e){return n?":not("+e.trim()+")":e}function YP(n){let e=n[0],t=1,r=2,i="",s=!1;for(;t<n.length;){let o=n[t];if("string"==typeof o)if(2&r){const a=n[++t];i+="["+o+(a.length>0?'="'+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;r<t.length;r+=2){const i=t[r],s=t[r+1];if(-1!==s){const o=n.data[s];Ap(i),o.contentQueries(2,e[s],s)}}}function zf(n,e,t,r,i,s,o,a,l,_,R){const N=e.blueprint.slice();return N[0]=i,N[2]=76|r,(null!==R||n&&1024&n[2])&&(N[2]|=1024),JE(N),N[3]=N[15]=n,N[8]=t,N[10]=o||n&&n[10],N[11]=a||n&&n[11],N[12]=l||n&&n[12]||null,N[9]=_||n&&n[9]||null,N[6]=s,N[20]=function uP(){return cP++}(),N[21]=R,N[16]=2==e.type?n[16]:N,N}function lc(n,e,t,r,i){let s=n.data[e];if(null===s)s=function Hg(n,e,t,r,i){const s=nb(),o=Sp(),l=n.data[e]=function ON(n,e,t,r,i,s){return{type:t,index:r,insertBeforeIndex:null,injectorIndex:e?e.injectorIndex:-1,directiveStart:-1,directiveEnd:-1,directiveStylingLast:-1,propertyBindings:null,flags:0,providerIndexes:0,value:i,attrs:s,mergedAttrs:null,localNames:null,initialInputs:void 0,inputs:null,outputs:null,tViews:null,next:null,projectionNext:null,child:null,parent:e,projection:null,styles:null,stylesWithoutHost:null,residualStyles:void 0,classes:null,classesWithoutHost:null,residualClasses:void 0,classBindings:0,styleBindings:0}}(0,o?s:s&&s.parent,t,e,r,i);return null===n.firstChild&&(n.firstChild=l),null!==s&&(o?null==s.child&&null!==l.parent&&(s.child=l):null===s.next&&(s.next=l)),l}(n,e,t,r,i),function cx(){return Ct.lFrame.inI18n}()&&(s.flags|=64);else if(64&s.type){s.type=t,s.value=r,s.attrs=i;const o=function wu(){const n=Ct.lFrame,e=n.currentTNode;return n.isParent?e:e.parent}();s.injectorIndex=null===o?-1:o.injectorIndex}return Is(s,!0),s}function fc(n,e,t,r){if(0===t)return-1;const i=e.length;for(let s=0;s<t;s++)e.push(r),n.blueprint.push(r),n.data.push(null);return i}function Wf(n,e,t){xp(e);try{const r=n.viewQuery;null!==r&&Yg(1,r,t);const i=n.template;null!==i&&g_(n,e,i,1,t),n.firstCreatePass&&(n.firstCreatePass=!1),n.staticContentQueries&&p_(n,e),n.staticViewQueries&&Yg(2,n.viewQuery,t);const s=n.components;null!==s&&function RN(n,e){for(let t=0;t<e.length;t++)YN(n,e[t])}(e,s)}catch(r){throw n.firstCreatePass&&(n.incompleteFirstPass=!0,n.firstCreatePass=!1),r}finally{e[2]&=-5,Rp()}}function Hu(n,e,t,r){const i=e[2];if(128!=(128&i)){xp(e);try{JE(e),function rb(n){return Ct.lFrame.bindingIndex=n}(n.bindingStartIndex),null!==t&&g_(n,e,t,2,r);const o=3==(3&i);if(o){const _=n.preOrderCheckHooks;null!==_&&mf(e,_,null)}else{const _=n.preOrderHooks;null!==_&&vf(e,_,0,null),Pp(e,0)}if(function qN(n){for(let e=mg(n);null!==e;e=vg(e)){if(!e[2])continue;const t=e[9];for(let r=0;r<t.length;r++){const i=t[r],s=i[3];0==(512&i[2])&&Dp(s,1),i[2]|=512}}}(e),function WN(n){for(let e=mg(n);null!==e;e=vg(e))for(let t=10;t<e.length;t++){const r=e[t],i=r[1];pf(r)&&Hu(i,r,i.template,r[8])}}(e),null!==n.contentQueries&&p_(n,e),o){const _=n.contentCheckHooks;null!==_&&mf(e,_)}else{const _=n.contentHooks;null!==_&&vf(e,_,1),Pp(e,1)}!function AN(n,e){const t=n.hostBindingOpCodes;if(null!==t)try{for(let r=0;r<t.length;r++){const i=t[r];if(i<0)Co(~i);else{const s=i,o=t[++r],a=t[++r];ux(o,s),a(2,e[s])}}}finally{Co(-1)}}(n,e);const a=n.components;null!==a&&function xN(n,e){for(let t=0;t<e.length;t++)QN(n,e[t])}(e,a);const l=n.viewQuery;if(null!==l&&Yg(2,l,r),o){const _=n.viewCheckHooks;null!==_&&mf(e,_)}else{const _=n.viewHooks;null!==_&&vf(e,_,2),Pp(e,2)}!0===n.firstUpdatePass&&(n.firstUpdatePass=!1),e[2]&=-41,512&e[2]&&(e[2]&=-513,Dp(e[3],-1))}finally{Rp()}}}function PN(n,e,t,r){const i=e[10],o=function XE(n){return 4==(4&n[2])}(e);try{!o&&i.begin&&i.begin(),o&&Wf(n,e,r),Hu(n,e,t,r)}finally{!o&&i.end&&i.end()}}function g_(n,e,t,r,i){const s=ti(),o=2&r;try{Co(-1),o&&e.length>22&&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;a<s;a++){const l=n.data[a],_=os(l);_&&jN(e,t,l);const R=Cu(e,n,a,t);Vr(R,e),null!==o&&GN(0,a-i,R,l,0,o),_&&(Ii(t.index,e)[8]=R)}}(n,e,t,Vi(t,e)),128==(128&t.flags)&&function VN(n,e,t){const r=t.directiveStart,i=t.directiveEnd,s=t.index,o=function lx(){return Ct.lFrame.currentDirectiveIndex}();try{Co(s);for(let a=r;a<i;a++){const l=n.data[a],_=e[a];Ip(a),(null!==l.hostBindings||0!==l.hostVars||null!==l.hostAttrs)&&D_(l,_)}}finally{Co(-1),Ip(o)}}(n,e,t))}function $g(n,e,t=Vi){const r=e.localNames;if(null!==r){let i=e.index+1;for(let s=0;s<r.length;s+=2){const o=r[s+1],a=-1===o?t(e,n):n[o];n[i++]=a}}}function m_(n){const e=n.tView;return null===e||e.incompleteFirstPass?n.tView=jg(1,null,n.template,n.decls,n.vars,n.directiveDefs,n.pipeDefs,n.viewQuery,n.schemas,n.consts):e}function jg(n,e,t,r,i,s,o,a,l,_){const R=22+r,N=R+i,B=function NN(n,e){const t=[];for(let r=0;r<e;r++)t.push(r<n?null:At);return t}(R,N),V="function"==typeof _?_():_;return B[1]={type:n,blueprint:B,template:t,queries:null,viewQuery:a,declTNode:e,data:B.slice().fill(null,R),bindingStartIndex:R,expandoStartIndex:N,hostBindingOpCodes:null,firstCreatePass:!0,firstUpdatePass:!0,staticViewQueries:!1,staticContentQueries:!1,preOrderHooks:null,preOrderCheckHooks:null,contentHooks:null,contentCheckHooks:null,viewHooks:null,viewCheckHooks:null,destroyHooks:null,cleanup:null,contentQueries:null,components:null,directiveRegistry:"function"==typeof s?s():s,pipeRegistry:"function"==typeof o?o():o,firstChild:null,schemas:l,consts:V,incompleteFirstPass:!1}}function E_(n,e,t){for(let r in n)if(n.hasOwnProperty(r)){const i=n[r];(t=null===t?{}:t).hasOwnProperty(r)?t[r].push(e,i):t[r]=[e,i]}return t}function b_(n,e){const r=e.directiveEnd,i=n.data,s=e.attrs,o=[];let a=null,l=null;for(let _=e.directiveStart;_<r;_++){const R=i[_],N=R.inputs,B=null===s||$w(e)?null:zN(N,s);o.push(B),a=E_(N,_,a),l=E_(R.outputs,_,l)}null!==a&&(a.hasOwnProperty("class")&&(e.flags|=16),a.hasOwnProperty("style")&&(e.flags|=32)),e.initialInputs=o,e.inputs=a,e.outputs=l}function w_(n,e){const t=Ii(e,n);16&t[2]||(t[2]|=32)}function Gg(n,e,t,r){let i=!1;if(tb()){const s=function HN(n,e,t){const r=n.directiveRegistry;let i=null;if(r)for(let s=0;s<r.length;s++){const o=r[s];jw(t,o.selectors,!1)&&(i||(i=[]),Df(Su(t,e),n,o.type),os(o)?(S_(n,t),i.unshift(o)):i.push(o))}return i}(n,e,t),o=null===r?null:{"":-1};if(null!==s){i=!0,C_(t,n.data.length,s.length);for(let R=0;R<s.length;R++){const N=s[R];N.providersResolver&&N.providersResolver(N)}let a=!1,l=!1,_=fc(n,e,s.length,null);for(let R=0;R<s.length;R++){const N=s[R];t.mergedAttrs=bf(t.mergedAttrs,N.hostAttrs),I_(n,t,e,_,N),$N(_,N,o),null!==N.contentQueries&&(t.flags|=8),(null!==N.hostBindings||null!==N.hostAttrs||0!==N.hostVars)&&(t.flags|=128);const B=N.type.prototype;!a&&(B.ngOnChanges||B.ngOnInit||B.ngDoCheck)&&((n.preOrderHooks||(n.preOrderHooks=[])).push(t.index),a=!0),!l&&(B.ngOnChanges||B.ngDoCheck)&&((n.preOrderCheckHooks||(n.preOrderCheckHooks=[])).push(t.index),l=!0),_++}b_(n,t)}o&&function KN(n,e,t){if(e){const r=n.localNames=[];for(let i=0;i<e.length;i+=2){const s=t[e[i+1]];if(null==s)throw new mt(-301,!1);r.push(e[i],s)}}}(t,r,o)}return t.mergedAttrs=bf(t.mergedAttrs,t.attrs),i}function __(n,e,t,r,i,s){const o=s.hostBindings;if(o){let a=n.hostBindingOpCodes;null===a&&(a=n.hostBindingOpCodes=[]);const l=~e.index;(function FN(n){let e=n.length;for(;e>0;){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;r<e.exportAs.length;r++)t[e.exportAs[r]]=n;os(e)&&(t[""]=n)}}function C_(n,e,t){n.flags|=1,n.directiveStart=e,n.directiveEnd=e+t,n.providerIndexes=e}function I_(n,e,t,r,i){n.data[r]=i;const s=i.factory||(i.factory=la(i.type)),o=new _u(s,os(i),Kt);n.blueprint[r]=o,t[r]=o,__(n,e,0,r,fc(n,t,i.hostVars,At),i)}function jN(n,e,t){const r=Vi(e,n),i=m_(t),s=n[10],o=qf(n,zf(n,i,null,t.onPush?32:16,r,e,s,s.createRenderer(r,t),null,null,null));n[e.index]=o}function GN(n,e,t,r,i,s){const o=s[e];if(null!==o){const a=r.setInput;for(let l=0;l<o.length;){const _=o[l++],R=o[l++],N=o[l++];null!==a?r.setInput(t,N,_,R):t[R]=N}}}function zN(n,e){let t=null,r=0;for(;r<e.length;){const i=e[r];if(0!==i)if(5!==i){if("number"==typeof i)break;n.hasOwnProperty(i)&&(null===t&&(t=[]),t.push(i,n[i],e[r+1])),r+=2}else r+=2;else r+=4}return t}function T_(n,e,t,r){return new Array(n,!0,!1,e,null,0,r,t,null,null)}function QN(n,e){const t=Ii(e,n);if(pf(t)){const r=t[1];48&t[2]?Hu(r,t,r.template,t[8]):t[5]>0&&Wg(t)}}function Wg(n){for(let r=mg(n);null!==r;r=vg(r))for(let i=10;i<r.length;i++){const s=r[i];if(pf(s))if(512&s[2]){const o=s[1];Hu(o,s,o.template,s[8])}else s[5]>0&&Wg(s)}const t=n[1].components;if(null!==t)for(let r=0;r<t.length;r++){const i=Ii(t[r],n);pf(i)&&i[5]>0&&Wg(i)}}function YN(n,e){const t=Ii(e,n),r=t[1];(function ZN(n,e){for(let t=e.length;t<n.blueprint.length;t++)e.push(n.blueprint[t])})(r,t),Wf(r,t,t[8])}function qf(n,e){return n[13]?n[14][4]=e:n[13]=e,n[14]=e,e}function qg(n){for(;n;){n[2]|=32;const e=Fu(n);if(HA(n)&&!e)return n;n=e}return null}function Yg(n,e,t){Ap(0),e(n,t)}function x_(n){return n[7]||(n[7]=[])}function R_(n){return n.cleanup||(n.cleanup=[])}function N_(n,e){const t=n[9],r=t?t.get(oc,null):null;r&&r.handleError(e)}function Zg(n,e,t,r,i){for(let s=0;s<t.length;){const o=t[s++],a=t[s++],l=e[o],_=n.data[o];null!==_.setInput?_.setInput(l,i,r,a):l[a]=i}}function Ys(n,e,t){const r=function hf(n,e){return dr(e[n])}(e,n);!function Iw(n,e,t){n.setValue(e,t)}(n[11],r,t)}function Qf(n,e,t){let r=t?n.styles:null,i=t?n.classes:null,s=0;if(null!==e)for(let o=0;o<e.length;o++){const a=e[o];"number"==typeof a?s=a:1==s?i=ki(i,a):2==s&&(r=ki(r,a+": "+e[++o]+";"))}t?n.styles=r:n.stylesWithoutHost=r,t?n.classes=i:n.classesWithoutHost=i}function Yf(n,e,t,r,i=!1){for(;null!==t;){const s=e[t.index];if(null!==s&&r.push(dr(s)),ss(s))for(let a=10;a<s.length;a++){const l=s[a],_=l[1].firstChild;null!==_&&Yf(l[1],l,_,r)}const o=t.type;if(8&o)Yf(n,e,t.child,r);else if(32&o){const a=yg(t,e);let l;for(;l=a();)r.push(l)}else if(16&o){const a=Bw(e,t);if(Array.isArray(a))r.push(...a);else{const l=Fu(e[16]);Yf(l[1],l,a,r,!0)}}t=i?t.projectionNext:t.next}return r}class Ku{constructor(e,t){this._lView=e,this._cdRefInjectingView=t,this._appRef=null,this._attachedToViewContainer=!1}get rootNodes(){const e=this._lView,t=e[1];return Yf(t,e,t.firstChild,[])}get context(){return this._lView[8]}set context(e){this._lView[8]=e}get destroyed(){return 128==(128&this._lView[2])}destroy(){if(this._appRef)this._appRef.detachView(this);else if(this._attachedToViewContainer){const e=this._lView[3];if(ss(e)){const t=e[8],r=t?t.indexOf(this):-1;r>-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;e<n.components.length;e++){const t=n.components[e],r=pg(t);if(null!==r){const i=r[1];PN(i,r,i.template,t)}}}(n[8])}(this._view)}checkNoChanges(){}get context(){return null}}class Xg extends Ff{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){const t=Sn(e);return new $u(t,this.ngModule)}}function M_(n){const e=[];for(let t in n)n.hasOwnProperty(t)&&e.push({propName:n[t],templateName:t});return e}class tM{constructor(e,t){this.injector=e,this.parentInjector=t}get(e,t,r){const i=this.injector.get(e,sg,r);return i!==sg||t===sg?i:this.parentInjector.get(e,t,r)}}class $u extends uw{constructor(e,t){super(),this.componentDef=e,this.ngModule=t,this.componentType=e.type,this.selector=function ZP(n){return n.map(YP).join(",")}(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!t}get inputs(){return M_(this.componentDef.inputs)}get outputs(){return M_(this.componentDef.outputs)}create(e,t,r,i){let s=(i=i||this.ngModule)instanceof nc?i:i?.injector;s&&null!==this.componentDef.getStandaloneInjector&&(s=this.componentDef.getStandaloneInjector(s)||s);const o=s?new tM(e,s):e,a=o.get(fw,null);if(null===a)throw new mt(407,!1);const l=o.get(QR,null),_=a.createRenderer(null,this.componentDef),R=this.componentDef.selectors[0][0]||"div",N=r?function MN(n,e,t){return n.selectRootElement(e,t===Cs.ShadowDom)}(_,r,this.componentDef.encapsulation):bg(a.createRenderer(null,this.componentDef),R,function eM(n){const e=n.toLowerCase();return"svg"===e?"svg":"math"===e?"math":null}(R)),B=this.componentDef.onPush?288:272,V={components:[]},Y=jg(0,null,null,1,0,null,null,null,null,null),X=zf(null,Y,V,B,null,null,a,_,l,o,null);let ie,fe;xp(X);try{const Se=function iM(n,e,t,r,i,s){const o=t[1];t[22]=n;const l=lc(o,22,2,"#host",null),_=l.mergedAttrs=e.hostAttrs;null!==_&&(Qf(l,_,!0),null!==n&&(Ef(i,n,_),null!==l.classes&&Ig(i,n,l.classes),null!==l.styles&&Vw(i,n,l.styles)));const R=r.createRenderer(n,e),N=zf(t,m_(e),null,e.onPush?32:16,t[22],l,r,R,s||null,null,null);return o.firstCreatePass&&(Df(Su(l,t),o,e.type),S_(o,l),C_(l,t.length,1)),qf(t,N),t[22]=N}(N,this.componentDef,X,a,_);if(N)if(r)Ef(_,N,["ng-version",YR.full]);else{const{attrs:ae,classes:Ie}=function XP(n){const e=[],t=[];let r=1,i=2;for(;r<n.length;){let s=n[r];if("string"==typeof s)2===i?""!==s&&e.push(s,n[++r]):8===i&&t.push(s);else{if(!as(i))break;i=s}r++}return{attrs:e,classes:t}}(this.componentDef.selectors[0]);ae&&Ef(_,N,ae),Ie&&Ie.length>0&&Ig(_,N,Ie.join(" "))}if(fe=_p(Y,22),void 0!==t){const ae=fe.projection=[];for(let Ie=0;Ie<this.ngContentSelectors.length;Ie++){const Fe=t[Ie];ae.push(null!=Fe?Array.from(Fe):null)}}ie=function sM(n,e,t,r,i){const s=t[1],o=function BN(n,e,t){const r=Dr();n.firstCreatePass&&(t.providersResolver&&t.providersResolver(t),I_(n,r,e,fc(n,e,1,null),t),b_(n,r));const i=Cu(e,n,r.directiveStart,r);Vr(i,e);const s=Vi(r,e);return s&&Vr(s,e),i}(s,t,e);if(r.components.push(o),n[8]=o,null!==i)for(const l of i)l(o,e);if(e.contentQueries){const l=Dr();e.contentQueries(1,o,l.directiveStart)}const a=Dr();return!s.firstCreatePass||null===e.hostBindings&&null===e.hostAttrs||(Co(a.index),__(t[1],a,0,a.directiveStart,a.directiveEnd,e),D_(e,o)),o}(Se,this.componentDef,X,V,[aM]),Wf(Y,X,null)}finally{Rp()}return new rM(this.componentType,ie,ic(fe,X),X,fe)}}class rM extends class $R{}{constructor(e,t,r,i,s){super(),this.location=r,this._rootLView=i,this._tNode=s,this.instance=t,this.hostView=this.changeDetectorRef=new JN(i),this.componentType=e}setInput(e,t){const r=this._tNode.inputs;let i;if(null!==r&&(i=r[e])){const s=this._rootLView;Zg(s[1],s,i,e,t),w_(s,this._tNode.index)}}get injector(){return new Wa(this._tNode,this._rootLView)}destroy(){this.hostView.destroy()}onDestroy(e){this.hostView.onDestroy(e)}}function aM(){const n=Dr();yf(Me()[1],n)}let Zf=null;function pa(){if(!Zf){const n=On.Symbol;if(n&&n.iterator)Zf=n.iterator;else{const e=Object.getOwnPropertyNames(Map.prototype);for(let t=0;t<e.length;++t){const r=e[t];"entries"!==r&&"size"!==r&&Map.prototype[r]===Map.prototype.entries&&(Zf=r)}}}return Zf}function ju(n){return!!function ey(n){return null!==n&&("function"==typeof n||"object"==typeof n)}(n)&&(Array.isArray(n)||!(n instanceof Map)&&pa()in n)}function Hr(n,e,t){return!Object.is(n[e],t)&&(n[e]=t,!0)}function pc(n,e,t,r,i,s){const a=function ga(n,e,t,r){const i=Hr(n,e,t);return Hr(n,e+1,r)||i}(n,function Gs(){return Ct.lFrame.bindingIndex}(),t,i);return function zs(n){const e=Ct.lFrame,t=e.bindingIndex;return e.bindingIndex=e.bindingIndex+n,t}(2),a?e+Tt(t)+r+Tt(i)+s:At}function Jf(n,e,t){const r=Me();return Hr(r,ja(),e)&&function xi(n,e,t,r,i,s,o,a){const l=Vi(e,t);let R,_=e.inputs;!a&&null!=_&&(R=_[r])?(Zg(n,t,R,r,i),lf(e)&&w_(t,e.index)):3&e.type&&(r=function kN(n){return"class"===n?"className":"for"===n?"htmlFor":"formaction"===n?"formAction":"innerHtml"===n?"innerHTML":"readonly"===n?"readOnly":"tabindex"===n?"tabIndex":n}(r),i=null!=o?o(i,e.value||"",r):i,s.setProperty(l,r,i))}(sn(),function tr(){const n=Ct.lFrame;return _p(n.tView,n.selectedIndex)}(),r,n,e,r[11],t,!1),Jf}function ty(n,e,t,r,i){const o=i?"class":"style";Zg(n,t,e.inputs[o],o,r)}function Zs(n,e,t,r){const i=Me(),s=sn(),o=22+n,a=i[11],l=i[o]=bg(a,e,function vx(){return Ct.lFrame.currentNamespace}()),_=s.firstCreatePass?function _M(n,e,t,r,i,s,o){const a=e.consts,_=lc(e,n,2,i,So(a,s));return Gg(e,t,_,So(a,o)),null!==_.attrs&&Qf(_,_.attrs,!1),null!==_.mergedAttrs&&Qf(_,_.mergedAttrs,!0),null!==e.queries&&e.queries.elementStart(e,_),_}(o,s,i,0,e,t,r):s.data[o];Is(_,!0);const R=_.mergedAttrs;null!==R&&Ef(a,l,R);const N=_.classes;null!==N&&Ig(a,l,N);const B=_.styles;return null!==B&&Vw(a,l,B),64!=(64&_.flags)&&Vf(s,i,l,_),0===function ex(){return Ct.lFrame.elementDepthCount}()&&Vr(l,i),function tx(){Ct.lFrame.elementDepthCount++}(),ff(_)&&(Kg(s,i,_),function y_(n,e,t){if(mp(e)){const i=e.directiveEnd;for(let s=e.directiveStart;s<i;s++){const o=n.data[s];o.contentQueries&&o.contentQueries(1,t[s],s)}}}(s,_,i)),null!==r&&$g(i,_),Zs}function Xs(){let n=Dr();Sp()?function Cp(){Ct.lFrame.isParent=!1}():(n=n.parent,Is(n,!1));const e=n;!function nx(){Ct.lFrame.elementDepthCount--}();const t=sn();return t.firstCreatePass&&(yf(t,n),mp(n)&&t.queries.elementEnd(n)),null!=e.classesWithoutHost&&function Dx(n){return 0!=(16&n.flags)}(e)&&ty(t,e,Me(),e.classesWithoutHost,!0),null!=e.stylesWithoutHost&&function Sx(n){return 0!=(32&n.flags)}(e)&&ty(t,e,Me(),e.stylesWithoutHost,!1),Xs}function ny(n,e,t,r){return Zs(n,e,t,r),Xs(),ny}function sy(n){return!!n&&"function"==typeof n.then}const CM=function q_(n){return!!n&&"function"==typeof n.subscribe};function oy(n,e,t,r){const i=Me(),s=sn(),o=Dr();return function Y_(n,e,t,r,i,s,o,a){const l=ff(r),R=n.firstCreatePass&&R_(n),N=e[8],B=x_(e);let V=!0;if(3&r.type||a){const ie=Vi(r,e),fe=a?a(ie):ie,Se=B.length,ae=a?Fe=>a(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;s<i.length-1;s+=2){const o=i[s];if(o===t&&i[s+1]===r){const a=e[7],l=i[s+2];return a.length>l?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;fe<ie;fe+=2){const Te=e[X[fe]][X[fe+1]].subscribe(s),dt=B.length;B.push(s,Te),R&&R.push(i,r.index,dt,-(dt+1))}}}(s,i,i[11],o,n,e,0,r),oy}function Z_(n,e,t,r){try{return!1!==t(r)}catch(i){return N_(n,i),!1}}function X_(n,e,t,r,i){return function s(o){if(o===Function)return r;qg(2&n.flags?Ii(n.index,e):e);let l=Z_(e,0,r,o),_=s.__ngNextListenerFn__;for(;_;)l=Z_(e,0,_,o)&&l,_=_.__ngNextListenerFn__;return i&&!1===l&&(o.preventDefault(),o.returnValue=!1),l}}function _c(n,e=""){const t=Me(),r=sn(),i=n+22,s=r.firstCreatePass?lc(r,i,1,e,null):r.data[i],o=t[i]=function Eg(n,e){return n.createText(e)}(t[11],e);Vf(r,t,o,s),Is(s,!1)}function uy(n){return td("",n,""),uy}function td(n,e,t){const r=Me(),i=function hc(n,e,t,r){return Hr(n,ja(),t)?e+Tt(t)+r:At}(r,n,e,t);return i!==At&&Ys(r,ti(),i),td}function ly(n,e,t,r,i){const s=Me(),o=pc(s,n,e,t,r,i);return o!==At&&Ys(s,ti(),o),ly}const Sc="en-US";let $1=Sc;class Ic{}class gD extends Ic{constructor(e,t){super(),this._parent=t,this._bootstrapComponents=[],this.destroyCbs=[],this.componentFactoryResolver=new Xg(this);const r=function Si(n,e){const t=n[$E]||null;if(!t&&!0===e)throw new Error(`Type ${dn(n)} does not have '\u0275mod' property.`);return t}(e);this._bootstrapComponents=function qs(n){return n instanceof Function?n():n}(r.bootstrap),this._r3Injector=Zw(e,t,[{provide:Ic,useValue:this},{provide:Ff,useValue:this.componentFactoryResolver}],dn(e),new Set(["environment"])),this._r3Injector.resolveInjectorInitializers(),this.instance=this._r3Injector.get(e)}get injector(){return this._r3Injector}destroy(){const e=this._r3Injector;!e.destroyed&&e.destroy(),this.destroyCbs.forEach(t=>t()),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<s-10?(e[4]=t[i],Ib(t,10+r,e)):(t.push(e),e[4]=null),e[3]=t;const o=e[17];null!==o&&t!==o&&function OP(n,e){const t=n[9];e[16]!==e[3][3][16]&&(n[2]=!0),null===t?n[9]=[e]:t.push(e)}(o,e);const a=e[19];null!==a&&a.insertView(n),e[2]|=64}(i,r,o,s);const a=Sg(s,o),l=r[11],_=Uf(l,o[7]);return null!==_&&function RP(n,e,t,r,i,s){r[0]=i,r[6]=e,Uu(n,r,t,1,i,s)}(i,o[6],l,r,_,a),e.attachToViewContainerRef(),Ib(wy(o),s,e),e}move(e,t){return this.insert(e,t)}indexOf(e){const t=xD(this._lContainer);return null!==t?t.indexOf(e):-1}remove(e){const t=this._adjustIndex(e,-1),r=wg(this._lContainer,t);r&&(Cf(wy(this._lContainer),t),Aw(r[1],r))}detach(e){const t=this._adjustIndex(e,-1),r=wg(this._lContainer,t);return r&&null!=Cf(wy(this._lContainer),t)?new Ku(r):null}_adjustIndex(e,t=0){return e??this.length+t}};function xD(n){return n[8]}function wy(n){return n[8]||(n[8]=[])}function cd(...n){}const eS=new Xt("Application Initializer");let ud=(()=>{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<this.appInits.length;i++){const s=this.appInits[i]();if(sy(s))t.push(s);else if(CM(s)){const o=new Promise((a,l)=>{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<IS(r,i,s)?t:r,a=IS(o,i,s),l=o.currentIndex;if(o===r)i--,r=r._nextRemoved;else if(t=t._next,null==o.previousIndex)i++;else{s||(s=[]);const _=a-i,R=l-i;if(_!=R){for(let B=0;B<_;B++){const V=B<s.length?s[B]:s[B]=0,Y=V+B;R<=Y&&Y<_&&(s[B]=V+1)}s[o.previousIndex]=R-_}}a!==l&&e(o,a,l)}}forEachPreviousItem(e){let t;for(t=this._previousItHead;null!==t;t=t._nextPrevious)e(t)}forEachAddedItem(e){let t;for(t=this._additionsHead;null!==t;t=t._nextAdded)e(t)}forEachMovedItem(e){let t;for(t=this._movesHead;null!==t;t=t._nextMoved)e(t)}forEachRemovedItem(e){let t;for(t=this._removalsHead;null!==t;t=t._nextRemoved)e(t)}forEachIdentityChange(e){let t;for(t=this._identityChangesHead;null!==t;t=t._nextIdentityChange)e(t)}diff(e){if(null==e&&(e=[]),!ju(e))throw new mt(900,!1);return this.check(e)?this:null}onDestroy(){}check(e){this._reset();let i,s,o,t=this._itHead,r=!1;if(Array.isArray(e)){this.length=e.length;for(let a=0;a<this.length;a++)s=e[a],o=this._trackByFn(a,s),null!==t&&Object.is(t.trackById,o)?(r&&(t=this._verifyReinsertion(t,s,o,a)),Object.is(t.item,s)||this._addIdentityChange(t,s)):(t=this._mismatch(t,s,o,a),r=!0),t=t._next}else i=0,function yM(n,e){if(Array.isArray(n))for(let t=0;t<n.length;t++)e(n[t]);else{const t=n[pa()]();let r;for(;!(r=t.next()).done;)e(r.value)}}(e,a=>{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<t.length&&(i=t[r]),r+e+i}function AS(){return new pd([new SS])}let pd=(()=>{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<s;i++){const a=r.get(i).context;a.index=i,a.count=s,a.ngForOf=this._ngForOf}t.forEachIdentityChange(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<i.length;s++)r.remove(i[s])})}},deps:[ZS,ro,ha],multi:!0}];let a4=(()=>{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<i.length;s++){const o=i[s];if(o.supports(t))return this._eventNameToPlugin.set(t,o),o}throw new Error(`No event manager plugin found for event ${t}`)}}return n.\u0275fac=function(t){return new(t||n)(wn(Td),wn(Kr))},n.\u0275prov=Gn({token:n,factory:n.\u0275fac}),n})();class XS{constructor(e){this._doc=e}addGlobalEventListener(e,t,r){const i=nl().getGlobalEventTarget(this._doc,e);if(!i)throw new Error(`Unsupported event target ${i} for event ${t}`);return this.addEventListener(i,t,r)}}let JS=(()=>{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<e.length;r++){let i=e[r];Array.isArray(i)?xd(n,i,t):(i=i.replace(u0,n),t.push(i))}return t}function rC(n){return e=>{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<s.length;o++){const a=document.createElement("style");a.textContent=s[o],this.shadowRoot.appendChild(a)}}nodeOrShadowRoot(e){return e===this.hostEl?this.shadowRoot:e}destroy(){this.sharedStylesHost.removeHost(this.shadowRoot)}appendChild(e,t){return super.appendChild(this.nodeOrShadowRoot(e),t)}insertBefore(e,t,r){return super.insertBefore(this.nodeOrShadowRoot(e),t,r)}removeChild(e,t){return super.removeChild(this.nodeOrShadowRoot(e),t)}parentNode(e){return this.nodeOrShadowRoot(super.parentNode(this.nodeOrShadowRoot(e)))}}let g4=(()=>{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;t<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0}cl.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},cl.prototype.next=function(n){return this._invoke("next",n)},cl.prototype.throw=function(n){return this._invoke("throw",n)},cl.prototype.return=function(n){return this._invoke("return",n)};const vC=Symbol.for("@achingbrain/uint8arraylist");function EC(n,e){if(null==e||e<0)throw new RangeError("index is out of bounds");let t=0;for(const r of n){const i=t+r.byteLength;if(e<i)return{buf:r,index:e-t};t=i}throw new RangeError("index is out of bounds")}function g0(n){return Boolean(n?.[vC])}class jr{constructor(...e){Object.defineProperty(this,vC,{value:!0}),this.bufs=[],this.length=0,e.length>0&&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;r<e.length;r++)this.set(t+r,e[r]);else{if(!g0(e))throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList");for(let r=0;r<e.length;r++)this.set(t+r,e.get(r))}}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0))for(;this.bufs.length>0;){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<this.bufs.length;s++){const o=this.bufs[s],a=i,l=a+o.byteLength;if(i=l,e>=l)continue;const _=e>=a&&e<l,R=t>a&&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;t<this.bufs.length;t++)if(!Pr(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){const r=new jr;return r.bufs=e,null==t&&(t=e.reduce((i,s)=>i+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.byteLength)for(;s<5;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}throw 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=>n<F4?1:n<U4?2:n<V4?3:n<H4?4:n<K4?5:n<$4?6:n<j4?7:n<G4?8:n<z4?9:10,encode(n,e,t=0){if(null!=Number.MAX_SAFE_INTEGER&&n>Number.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.byteLength<o)break;const ie=i.sublist(0,o);i.consume(o),null!=n?.onData&&n.onData(ie),yield ie,s=Mo.LENGTH}}}catch(X){N=!0,B=X}finally{try{R&&null!=V.return&&(yield tt(V.return()))}finally{if(N)throw B}}if(i.byteLength>0)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<t.length-1;r++)E0(t[r])&&(t[r]=J4(t[r]));return((...n)=>{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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<t.length;r++)t[r]=255;for(var i=0;i<n.length;i++){var s=n.charAt(i),o=s.charCodeAt(0);if(255!==t[o])throw new TypeError(s+" is ambiguous");t[o]=i}var a=n.length,l=n.charAt(0),_=Math.log(a)/Math.log(256),R=Math.log(256)/Math.log(a);function B(Y){if("string"!=typeof Y)throw new TypeError("Expected String");if(0===Y.length)return new Uint8Array;var X=0;if(" "!==Y[X]){for(var ie=0,fe=0;Y[X]===l;)ie++,X++;for(var Se=(Y.length-X)*_+1>>>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<fe)&&-1!==Te;Te--,Fe++)ae[Te]=(Ie+=a*ae[Te]>>>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<ie)&&-1!==dt;dt--,Te++)Ie[dt]=(Fe+=256*Ie[dt]>>>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<ae;++ut)an+=n.charAt(Ie[ut]);return an},decodeUnsafe:B,decode:function V(Y){var X=B(Y);if(X)return X;throw new Error(`Non-${e} character`)}}},Oc=(new Uint8Array(0),n=>{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)-1;let s="",o=0,a=0;for(let l=0;l<n.length;++l)for(a=a<<8|n[l],o+=8;o>t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<<t-o]),r)for(;s.length*t&7;)s+="=";return s})(i,r,t),decode:i=>((n,e,t,r)=>{const i={};for(let R=0;R<e.length;++R)i[e[R]]=R;let s=n.length;for(;"="===n[s-1];)--s;const o=new Uint8Array(s*t/8|0);let a=0,l=0,_=0;for(let R=0;R<s;++R){const N=i[n[R]];if(void 0===N)throw new SyntaxError(`Non-${r} character`);l=l<<t|N,a+=t,a>=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)<<i:(127&o)*Math.pow(2,i),i+=7}while(o>=128);return S0.bytes=s-r,t},encodingLength:function(n){return n<tF?1:n<nF?2:n<rF?3:n<iF?4:n<sF?5:n<oF?6:n<aF?7:n<cF?8:n<uF?9:10}};const Vd=fF,C0=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<n.byteLength;t++)if(n[t]!==e[t])return!1;return!0})(n.bytes,e.bytes))(this.multihash,e.multihash)}toString(e){const{bytes:t,version:r,_baseCache:i}=this;return 0===r?AF(t,i,e||si.encoder):xF(t,i,e||so.encoder)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return NF(/^0\.0/,MF),!(!e||!e[VC]&&e.asCID!==e)}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof mr)return e;if(null!=e&&e.asCID===e){const{version:t,code:r,multihash:i,bytes:s}=e;return new mr(t,r,i,s||UC(t,r,i.bytes))}if(null!=e&&!0===e[VC]){const{version:t,multihash:r,code:i}=e,s=$d(r);return mr.create(t,i,s)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");switch(e){case 0:if(t!==dl)throw new Error(`Version 0 CID must use dag-pb (code: ${dl}) block encoding`);return new mr(e,t,r,r.bytes);case 1:{const i=UC(e,t,r.bytes);return new mr(e,t,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return mr.create(0,dl,e)}static createV1(e,t){return mr.create(1,e,t)}static decode(e){const[t,r]=mr.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=mr.inspectBytes(e),r=t.size-t.multihashSize,i=Oc(e.subarray(r,r+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");const s=i.subarray(t.multihashSize-t.digestSize),o=new I0(t.multihashCode,t.digestSize,s,i);return[0===t.version?mr.createV0(o):mr.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{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<n.length;t++)e+=String.fromCharCode(n[t]);return e},n=>{const e=xc((n=n.substring(1)).length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}),$C={utf8:KC,"utf-8":KC,hex:hl.base16,latin1:T0,ascii:T0,binary:T0,...hl};function xt(n,e="utf8"){const t=$C[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?t.decoder.decode(`${t.prefix}${n}`):globalThis.Buffer.from(n,"utf8")}const ks={get(n=globalThis){const e=n.crypto;if(null==e||null==e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var LF=x(1558);function Rt(n,e="utf8"){const t=$C[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?t.encoder.encode(n).substring(1):globalThis.Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("utf8")}function Ls(n,e){let t=Uint8Array.from(n.abs().toByteArray());if(t=0===t[0]?t.slice(1):t,null!=e){if(t.length>e)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<t;o++){s=i,r.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),r.push(s);i=s.double()}return r}wNAF(e,t){!t&&this.equals(In.BASE)&&(t=vn.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=t&&O0.get(t);i||(i=this.precomputeWindow(r),t&&1!==r&&(i=In.normalizeZ(i),O0.set(t,i)));let s=In.ZERO,o=In.ZERO;const a=1+(zd?128/r:256/r),l=2**(r-1),_=BigInt(2**r-1),R=2**r,N=BigInt(r);for(let B=0;B<a;B++){const V=B*l;let Y=Number(e&_);if(e>>=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;r<n.length;r++){const s=n[r];t.set(s,i),i+=s.length}return t}const GF=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Fc(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t<n.length;t++)e+=GF[n[t]];return e}const zF=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function Bo(n){if("bigint"!=typeof n)throw new Error("Expected bigint");if(!(rn<=n&&n<zF))throw new Error("Expected number < 2^256");return n.toString(16).padStart(64,"0")}function Uc(n){const e=Fo(Bo(n));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function gl(n){const e=n.toString(16);return 1&e.length?`0${e}`:e}function Wd(n){if("string"!=typeof n)throw new TypeError("hexToNumber: expected string, got "+typeof n);return BigInt(`0x${n}`)}function Fo(n){if("string"!=typeof n)throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+n.length);const e=new Uint8Array(n.length/2);for(let t=0;t<e.length;t++){const r=2*t,i=n.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");e[t]=s}return e}function pi(n){return Wd(Fc(n))}function Bs(n){return n instanceof Uint8Array?Uint8Array.from(n):Fo(n)}function XC(n){if("number"==typeof n&&Number.isSafeInteger(n)&&n>0)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 rn<n&&n<Cn.n}function qd(n){return rn<n&&n<Cn.P}function rI(n,e,t){const r=pi(n);if(!Kc(r))return;const{n:i}=Cn,s=vn.BASE.multiply(r),o=Ze(s.x,i);if(o===rn)return;const a=Ze(Vc(r,i)*Ze(e+t*o,i),i);if(a===rn)return;const l=new Lo(o,a);return{sig:l,recovery:(s.x===l.r?0:2)|Number(s.y&Wn)}}function va(n){let e;if("bigint"==typeof n)e=n;else if("number"==typeof n&&Number.isSafeInteger(n)&&n>0)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<rn?e:t)}function cI(n){return Uc(n)}function uI(n,e,t){if(null==n)throw new Error(`sign: expected valid message hash, not "${n}"`);const r=Bs(n),i=va(e),s=[cI(i),YF(r)];if(null!=t){!0===t&&(t=gi.randomBytes(32));const l=Bs(t);if(32!==l.length)throw new Error("sign: Expected 32 bytes of extra data");s.push(l)}return{seed:Bc(...s),m:aI(r),d:i}}function lI(n,e){let{sig:t,recovery:r}=n;const{canonical:i,der:s,recovered:o}=Object.assign({canonical:!0,der:!0},e);i&&t.hasHighS()&&(t=t.normalizeS(),r^=1);const a=s?t.toDERRawBytes():t.toCompactRawBytes();return o?[a,r]:a}function ZF(n,e){return L0.apply(this,arguments)}function L0(){return(L0=j(function*(n,e,t={}){const{seed:r,m:i,d:s}=uI(n,e,t.extraEntropy);let o;const a=new nI;for(yield a.reseed(r);!(o=rI(yield a.generate(),i,s));)yield a.reseed();return lI(o,t)})).apply(this,arguments)}const XF={strict:!0};function JF(n,e,t,r=XF){let i;try{i=iI(n),e=Bs(e)}catch{return!1}const{r:s,s:o}=i;if(r.strict&&i.hasHighS())return!1;const a=tI(e);let l;try{l=function k0(n){return n instanceof vn?(n.assertValidity(),n):vn.fromHex(n)}(t)}catch{return!1}const{n:_}=Cn,R=Vc(o,_),N=Ze(a*R,_),B=Ze(s*R,_),V=vn.BASE.multiplyAndAddUnsafe(l,N,B);return!!V&&Ze(V.x,_)===s}vn.BASE._setWindowSize(8);const Pi={node:KF,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},Yd={},gi={bytesToHex:Fc,hexToBytes:Fo,concatBytes:Bc,mod:Ze,invert:Vc,isValidPrivateKey(n){try{return va(n),!0}catch{return!1}},_bigintTo32Bytes:Uc,_normalizePrivateKey:va,hashToPrivateKey:n=>{if((n=Bs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return 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<t;o++){s=i,r.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),r.push(s);i=s.double()}return r}wNAF(e,t){!t&&this.equals(hn.BASE)&&(t=Jn.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=t&&J0.get(t);i||(i=this.precomputeWindow(r),t&&1!==r&&(i=hn.normalizeZ(i),J0.set(t,i)));let s=hn.ZERO,o=hn.ZERO;const a=1+256/r,l=2**(r-1),_=BigInt(2**r-1),R=2**r,N=BigInt(r);for(let B=0;B<a;B++){const V=B*l;let Y=Number(e&_);if(e>>=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<n.length;t++)if(n[t]!==e[t])return!1;return!0}(zc(s),e)||Vo(s))throw new Error(i);const o=Ae(s*s),a=Ae(en+t*o),l=Ae(en-t*o),_=Ae(a*a),R=Ae(l*l),N=Ae(t*r*_-R),{isValid:B,value:V}=II(Ae(N*R)),Y=Ae(V*l),X=Ae(V*Y*N);let ie=Ae((s+s)*Y);Vo(ie)&&(ie=Ae(-ie));const fe=Ae(a*X),Se=Ae(ie*fe);if(!B||Vo(Se)||fe===rr)throw new Error(i);return new zi(new hn(ie,fe,en,Se))}toRawBytes(){let{x:e,y:t,z:r,t:i}=this.ep;const s=Ae(Ae(r+t)*Ae(r-t)),o=Ae(e*t),a=Ae(o*o),{value:l}=II(Ae(s*a)),_=Ae(l*s),R=Ae(l*o),N=Ae(_*R*i);let B;if(Vo(i*N)){let Y=Ae(t*ml),X=Ae(e*ml);e=Y,t=X,B=Ae(_*_6)}else B=R;Vo(e*N)&&(t=Ae(-t));let V=Ae((r-t)*B);return Vo(V)&&(V=Ae(-V)),zc(V)}toHex(){return vl(this.toRawBytes())}toString(){return this.toHex()}equals(e){Z0(e);const t=this.ep,r=e.ep,i=Ae(t.x*r.y)===Ae(t.y*r.x),s=Ae(t.y*r.y)===Ae(t.x*r.x);return i||s}add(e){return Z0(e),new zi(this.ep.add(e.ep))}subtract(e){return Z0(e),new zi(this.ep.subtract(e.ep))}multiply(e){return new zi(this.ep.multiply(e))}multiplyUnsafe(e){return new zi(this.ep.multiplyUnsafe(e))}}zi.BASE=new zi(hn.BASE),zi.ZERO=new zi(hn.ZERO);const J0=new WeakMap;class Jn{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,J0.delete(this)}static fromHex(e,t=!0){const{d:r,P:i}=Ln,s=(e=ms(e,32)).slice();s[31]=-129&e[31];const o=Ea(s);if(t&&o>=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;r<n.length;r++){const s=n[r];t.set(s,i),i+=s.length}return t}const C6=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function vl(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=C6[n[t]];return e}function em(n){if("string"!=typeof n)throw new TypeError("hexToBytes: expected string, got "+typeof n);if(n.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(n.length/2);for(let t=0;t<e.length;t++){const r=2*t,i=n.slice(r,r+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");e[t]=s}return e}function SI(n){return em(n.toString(16).padStart(64,"0"))}function zc(n){return SI(n).reverse()}function Vo(n){return(Ae(n)&en)===en}function Ea(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+vl(Uint8Array.from(n).reverse()))}const I6=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function tm(n){return Ae(Ea(n)&I6)}function Ae(n,e=Ln.P){const t=n%e;return 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<e)if(t){if(rr<n)return n}else if(rr<=n)return n;throw new TypeError("Expected valid scalar: 0 < scalar < max")}function AI(n){if(32!==(n="bigint"==typeof n||"number"==typeof n?SI(qc(n,wI)):ms(n)).length)throw new Error("Expected 32 bytes");return n}function xI(n){const e=function TI(n){return n[0]&=248,n[31]&=127,n[31]|=64,n}(n.slice(0,32)),t=n.slice(32,64),r=Wc(e),i=Jn.BASE.multiply(r),s=i.toRawBytes();return{head:e,prefix:t,scalar:r,point:i,pointBytes:s}}let El;function bl(n){return rm.apply(this,arguments)}function rm(){return rm=j(function*(n){return xI(yield ba.sha512(AI(n)))}),rm.apply(this,arguments)}function RI(n){return sm.apply(this,arguments)}function sm(){return sm=j(function*(n){return(yield bl(n)).pointBytes}),sm.apply(this,arguments)}function P6(n,e){return om.apply(this,arguments)}function om(){return om=j(function*(n,e){n=ms(n);const{prefix:t,scalar:r,pointBytes:i}=yield bl(e),s=Wc(yield ba.sha512(t,n)),o=Jn.BASE.multiply(s),l=Ae(s+Wc(yield ba.sha512(o.toRawBytes(),i,n))*r,Ln.l);return new Gc(o,l).toRawBytes()}),om.apply(this,arguments)}function PI(n,e,t){e=ms(e),t instanceof Jn||(t=Jn.fromHex(t,!1));const{r,s:i}=n instanceof Gc?n.assertValidity():Gc.fromHex(n);return{r,s:i,SB:hn.BASE.multiplyUnsafe(i),pub:t,msg:e}}function NI(n,e,t,r){const i=Wc(r),s=hn.fromAffine(n).multiplyUnsafe(i);return hn.fromAffine(e).add(s).subtract(t).multiplyUnsafe(Ln.h).equals(hn.ZERO)}function M6(n,e,t){return am.apply(this,arguments)}function am(){return am=j(function*(n,e,t){const{r,SB:i,msg:s,pub:o}=PI(n,e,t),a=yield ba.sha512(r.toRawBytes(),o.toRawBytes(),s);return NI(o,r,i,a)}),am.apply(this,arguments)}Jn.BASE._setWindowSize(8);const Ho={node:b6,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ba={bytesToHex:vl,hexToBytes:em,concatBytes:DI,getExtendedPublicKey:bl,mod:Ae,invert:Jd,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar: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<a;){const l=i.uint32();switch(l>>>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;_+=65519){let R=_+65519;R>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;_+=ul){let R=_+ul;R>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<s)break;const l={id:r,type:i};(i===tn.NEW_STREAM||i===tn.MESSAGE_INITIATOR||i===tn.MESSAGE_RECEIVER)&&(l.data=this._buffer.sublist(o,o+s)),t.push(l),this._buffer.consume(o+s),this._headerInfo=null}return t}_decodeHeader(e){const{value:t,offset:r}=JI(e),{value:i,offset:s}=JI(e,r),o=7&t;if(null==Um[o])throw new Error(`Invalid type received: ${o}`);return{id:t>>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)<<r:(127&s)*Math.pow(2,r),r+=7}while(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||"<anonymous>"})`,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;i<r.length;i++){let o;cT(r[i])&&(o=uT(r[i]),r[i]=Rt(o.slice(0,2),"base16")),null!=o&&++i<8&&r.splice(i,0,Rt(o.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(i=0;i<r.length&&""!==r[i];i++);const s=[i,1];for(i=9-r.length;i>0;i--)s.push("0");r.splice.apply(r,s)}for(t=new Uint8Array(e+16),i=0;i<r.length;i++){const s=parseInt(r[i],16);t[e++]=s>>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;o<t;o++)r.push(n[e+o]);i=r.join(".")}else if(16===t){for(let o=0;o<t;o+=2)r.push(s.getUint16(e+o).toString(16));i=r.join(":"),i=i.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3"),i=i.replace(/:{3,4}/,"::")}return i}(n,0,n.length);if(null==e||!qm(e))throw new Error("invalid ip address");return e}(e);case 6:case 273:case 33:case 132:return hT(e).toString();case 53:case 54:case 55:case 56:case 400:case 777:return function fU(n){const e=ur.decode(n);if((n=n.slice(ur.decode.bytes)).length!==e)throw new Error("inconsistent lengths");return Rt(n)}(e);case 421:return function gU(n){const e=ur.decode(n),t=n.slice(ur.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return Rt(t,"base58btc")}(e);case 444:case 445:return function pT(n){const e=n.slice(0,n.length-2),t=n.slice(n.length-2);return`${Rt(e,"base32")}:${hT(t)}`}(e);case 466:return function pU(n){const e=ur.decode(n),t=n.slice(ur.decode.bytes);if(t.length!==e)throw new Error("inconsistent lengths");return"u"+Rt(t,"base64url")}(e);default:return Rt(e,"base16")}}function fT(n,e){switch(Er(n).code){case 4:case 41:return function dT(n){if(!qm(n))throw new Error("invalid ip address");return uT(n)}(e);case 6:case 273:case 33:case 132:return Zm(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 777:return function lU(n){const e=xt(n),t=Uint8Array.from(ur.encode(e.length));return yr([t,e],t.length+e.length)}(e);case 421:return function dU(n){let e;e="Q"===n[0]||"1"===n[0]?$d(si.decode(`z${n}`)).bytes:mr.parse(n).multihash.bytes;const t=Uint8Array.from(ur.encode(e.length));return yr([t,e],t.length+e.length)}(e);case 444:return function yU(n){const e=n.split(":");if(2!==e.length)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(16!==e[0].length)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion 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 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(;t<n.length;){const r=ur.decode(n,t),i=ur.decode.bytes,o=mT(Er(r),n.slice(t+i));if(0===o){e.push([r]),t+=i;continue}const a=n.slice(t+i,t+i+o);if(t+=o+i,t>n.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;r++){const i=t[r],s=Er(i);if(0!==s.size){if(r++,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(;i<r.length;){const s=ur.decode(r,i),o=ur.decode.bytes;i+=mT(Er(s),r.slice(i+o))+o,t.push(s)}return t}protoNames(){return this.protos().map(t=>t.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"<Multiaddr "+Rt(this.bytes,"base16")+" - "+Xm(this.bytes)+">"}inspect(){return"<Multiaddr "+Rt(this.bytes,"base16")+" - "+Xm(this.bytes)+">"}}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<n.length)return null;let r=t;return n.some(i=>(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;i<t.length;i++){if(r.length<i+1)return!1;const s=t[i],o=r[i];if(s<o)return!0;if(s>o)return!1}return t.length<r.length}reverse(){return kr.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(lo).slice(1)}type(){return function JU(n){const e=n.split(":");return e.length<2?"":e.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function eV(n){const e=n.split(":");return e[e.length-1]}(this.baseNamespace())}instance(e){return new kr(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(lo)||(e+=lo),e+=this.type(),new kr(e)}parent(){const e=this.list();return new kr(1===e.length?lo:e.slice(0,-1).join(lo))}child(e){return this.toString()===lo?e:e.toString()===lo?this:new kr(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()!==this.toString()&&e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()!==this.toString()&&this.toString().startsWith(e.toString())}isTopLevel(){return 1===this.list().length}concat(...e){return kr.withNamespaces([...this.namespaces(),...tV(e.map(t=>t.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(t<e)throw se(new Error("not found"),"NOT_FOUND")}),cv.apply(this,arguments)}var mi=x(4175),Sa=x(7420),gh=x(9849),Lr=x(8210);const KT=Ft("libp2p:peer-routing");class iV{constructor(e,t){this.components=e,this.routers=t.routers,this.refreshManagerInit=t.refreshManager??{},this.started=!1,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started||0===e.routers.length||null!=e.timeoutId||!1===e.refreshManagerInit.enabled||(e.timeoutId=(0,gh.setDelayedInterval)(e._findClosestPeersTask,e.refreshManagerInit.interval,e.refreshManagerInit.bootDelay),e.started=!0)})()}_findClosestPeersTask(){var e=this;return j(function*(){if(null==e.abortController)try{e.abortController=new mi.TimeoutController(e.refreshManagerInit.timeout??1e4);try{(0,Lr.setMaxListeners)?.(1/0,e.abortController.signal)}catch{}yield Wo(e.getClosestPeers(e.components.getPeerId().toBytes(),{signal:e.abortController.signal}))}catch(t){KT.error(t)}finally{e.abortController?.clear(),e.abortController=void 0}})()}stop(){var e=this;return j(function*(){(0,gh.clearDelayedInterval)(e.timeoutId),e.abortController?.abort(),e.started=!1})()}findPeer(e,t){var r=this;return j(function*(){if(0===r.routers.length)throw se(new Error("No peer routers available"),we.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===r.components.getPeerId().toString())throw se(new Error("Should not try to find self"),we.ERR_FIND_SELF);const i=yield zn(Md(...r.routers.map(s=>on(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<this.opts.minConnections)throw se(new Error("Connection Manager maxConnections must be greater than minConnections"),we.ERR_INVALID_PARAMETERS);Wr("options: %o",this.opts),this.connections=new Map,this.started=!1,this._checkMetrics=this._checkMetrics.bind(this),this.latencyMonitor=new fV({latencyCheckIntervalMs:e.pollInterval,dataEmitIntervalMs:e.pollInterval});try{(0,Lr.setMaxListeners)?.(1/0,this)}catch{}this.dialer=new bV(this.opts),this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.startupReconnectTimeout=e.startupReconnectTimeout??6e4,this.dialTimeout=e.dialTimeout??3e4}init(e){this.components=e,this.dialer.init(e),this.components.getMetrics()?.updateComponentMetric({system:hv,component:pv,metric:"connections",label:"direction",value:()=>{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:_<R?-1:0}),o=[];for(const a of s)if(Wr("too many connections open - closing a connection to %p",a.remotePeer),o.push(a),o.length===e)break;yield Promise.all(o.map(function(){var a=j(function*(l){try{yield l.close()}catch(_){Wr.error(_)}t.onDisconnect(new qt("connectionEnd",{detail:l}))});return function(l){return a.apply(this,arguments)}}()))})()}}const qo=Ft("libp2p:connection-manager:auto-dialler"),TV={enabled:!0,minConnections:0,autoDialInterval:1e4};class AV{constructor(e,t){this.components=e,this.options=Ol.call({ignoreUndefined:!0},TV,t),this.running=!1,this._autoDial=this._autoDial.bind(this),qo("options: %j",this.options)}isStarted(){return this.running}start(){var e=this;return j(function*(){e.options.enabled?(e.running=!0,e._autoDial().catch(t=>{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&&s<i.length&&e.components.getConnectionManager().getConnections().length<t;s++){if(!e.running)return;const o=i[s];if(0===e.components.getConnectionManager().getConnections(o.id).length){qo("connecting to a peerStore stored peer %p",o.id);try{yield e.components.getConnectionManager().openConnection(o.id)}catch(a){qo.error("could not connect to peerStore stored peer",a)}}}!e.running||(e.autoDialTimeout=kl(e._autoDial,e.options.autoDialInterval))})()}}var Qt;!function(n){let e;var a;let t,r,i,s,o;(a=e=n.Status||(n.Status={})).SUCCESS="SUCCESS",a.HOP_SRC_ADDR_TOO_LONG="HOP_SRC_ADDR_TOO_LONG",a.HOP_DST_ADDR_TOO_LONG="HOP_DST_ADDR_TOO_LONG",a.HOP_SRC_MULTIADDR_INVALID="HOP_SRC_MULTIADDR_INVALID",a.HOP_DST_MULTIADDR_INVALID="HOP_DST_MULTIADDR_INVALID",a.HOP_NO_CONN_TO_DST="HOP_NO_CONN_TO_DST",a.HOP_CANT_DIAL_DST="HOP_CANT_DIAL_DST",a.HOP_CANT_OPEN_DST_STREAM="HOP_CANT_OPEN_DST_STREAM",a.HOP_CANT_SPEAK_RELAY="HOP_CANT_SPEAK_RELAY",a.HOP_CANT_RELAY_TO_SELF="HOP_CANT_RELAY_TO_SELF",a.STOP_SRC_ADDR_TOO_LONG="STOP_SRC_ADDR_TOO_LONG",a.STOP_DST_ADDR_TOO_LONG="STOP_DST_ADDR_TOO_LONG",a.STOP_SRC_MULTIADDR_INVALID="STOP_SRC_MULTIADDR_INVALID",a.STOP_DST_MULTIADDR_INVALID="STOP_DST_MULTIADDR_INVALID",a.STOP_RELAY_REFUSED="STOP_RELAY_REFUSED",a.MALFORMED_MESSAGE="MALFORMED_MESSAGE",function(a){a[a.SUCCESS=100]="SUCCESS",a[a.HOP_SRC_ADDR_TOO_LONG=220]="HOP_SRC_ADDR_TOO_LONG",a[a.HOP_DST_ADDR_TOO_LONG=221]="HOP_DST_ADDR_TOO_LONG",a[a.HOP_SRC_MULTIADDR_INVALID=250]="HOP_SRC_MULTIADDR_INVALID",a[a.HOP_DST_MULTIADDR_INVALID=251]="HOP_DST_MULTIADDR_INVALID",a[a.HOP_NO_CONN_TO_DST=260]="HOP_NO_CONN_TO_DST",a[a.HOP_CANT_DIAL_DST=261]="HOP_CANT_DIAL_DST",a[a.HOP_CANT_OPEN_DST_STREAM=262]="HOP_CANT_OPEN_DST_STREAM",a[a.HOP_CANT_SPEAK_RELAY=270]="HOP_CANT_SPEAK_RELAY",a[a.HOP_CANT_RELAY_TO_SELF=280]="HOP_CANT_RELAY_TO_SELF",a[a.STOP_SRC_ADDR_TOO_LONG=320]="STOP_SRC_ADDR_TOO_LONG",a[a.STOP_DST_ADDR_TOO_LONG=321]="STOP_DST_ADDR_TOO_LONG",a[a.STOP_SRC_MULTIADDR_INVALID=350]="STOP_SRC_MULTIADDR_INVALID",a[a.STOP_DST_MULTIADDR_INVALID=351]="STOP_DST_MULTIADDR_INVALID",a[a.STOP_RELAY_REFUSED=390]="STOP_RELAY_REFUSED",a[a.MALFORMED_MESSAGE=400]="MALFORMED_MESSAGE"}(t||(t={})),function(a){a.codec=()=>Oo(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<B;){const V=_.uint32();switch(V>>>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<R;){const N=a.uint32();switch(N>>>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;t<e.initialCounters.length;t++){const r=e.initialCounters[t];this.stats[r]=0n,this.movingAverages[r]=[];for(let i=0;i<this.movingAverageIntervals.length;i++){const s=this.movingAverageIntervals[i];(this.movingAverages[r][s]=p2(s)).push(this.frequencyLastTime,0)}}}start(){!this.enabled||this.queue.length>0&&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;_<l.length;_++){const R=l[_];let N=a[R];null==N&&(N=a[R]=p2(R)),N.push(r,o)}}_applyOp(e){const t=e[0],r=e[1];if("number"!=typeof r)throw new Error("invalid increment number");let i;i=Object.prototype.hasOwnProperty.call(this.stats,t)?this.stats[t]:this.stats[t]=0n,this.stats[t]=i+BigInt(r),null==this.frequencyAccumulators[t]&&(this.frequencyAccumulators[t]=0),this.frequencyAccumulators[t]+=r}}const JV=["dataReceived","dataSent"],e9={in:"dataReceived",out:"dataSent"};class t9{constructor(e){this.enabled=e.enabled,this.statsInit={...e,initialCounters:JV},this.globalStats=new Iv(this.statsInit),this.peerStats=new Map,this.protocolStats=new Map,this.oldPeers=ZV(e.maxOldPeersRetention??50),this.running=!1,this._onMessage=this._onMessage.bind(this),this.systems=new Map}isStarted(){return this.running}start(){var e=this;return j(function*(){!e.enabled||(e.running=!0)})()}stop(){var e=this;return j(function*(){if(e.running){e.running=!1,e.globalStats.stop();for(const t of e.peerStats.values())t.stop();for(const t of e.protocolStats.values())t.stop()}})()}getGlobal(){return this.globalStats}getPeers(){return Array.from(this.peerStats.keys())}getComponentMetrics(){return this.systems}updateComponentMetric(e){const{system:t="libp2p",component:r,metric:i,value:s,label:o,help:a}=e;this.systems.has(t)||this.systems.set(t,new Map);const l=this.systems.get(t);if(null==l)throw new Error("Unknown metric system");l.has(r)||l.set(r,new Map);const _=l.get(r);if(null==_)throw new Error("Unknown metric component");_.set(i,{label:o,help:a,calculate:"function"!=typeof s?()=>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(),t<n&&e.size>0&&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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<l;){const _=s.uint32();_>>>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<o;){const a=r.uint32();switch(a>>>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<s;){const o=t.uint32();o>>>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<a;){const l=i.uint32();switch(l>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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").size<e||(yield st(t,lr,"m",kh).call(t,"next",()=>st(t,Ni,"f").size<e))})()}onIdle(){var e=this;return j(function*(){0===st(e,Mi,"f")&&0===st(e,Ni,"f").size||(yield st(e,lr,"m",kh).call(e,"idle"))})()}get size(){return st(this,Ni,"f").size}sizeBy(e){return st(this,Ni,"f").filter(e).length}get pending(){return st(this,Mi,"f")}get isPaused(){return st(this,ea,"f")}}jl=new WeakMap,Gl=new WeakMap,Jo=new WeakMap,xh=new WeakMap,zl=new WeakMap,Rh=new WeakMap,Ss=new WeakMap,Wl=new WeakMap,Ni=new WeakMap,Ph=new WeakMap,Mi=new WeakMap,ql=new WeakMap,ea=new WeakMap,Nh=new WeakMap,lr=new WeakSet,L2=function(){return st(this,Gl,"f")||st(this,Jo,"f")<st(this,xh,"f")},B2=function(){return st(this,Mi,"f")<st(this,ql,"f")},F2=function(){var e;er(this,Mi,(e=st(this,Mi,"f"),--e),"f"),st(this,lr,"m",Mh).call(this),this.emit("next")},U2=function(){this.emit("empty"),0===st(this,Mi,"f")&&this.emit("idle")},V2=function(){st(this,lr,"m",qv).call(this),st(this,lr,"m",Wv).call(this),er(this,Wl,void 0,"f")},H2=function(){const e=Date.now();if(void 0===st(this,Ss,"f")){const t=st(this,Rh,"f")-e;if(!(t<0))return void 0===st(this,Wl,"f")&&er(this,Wl,setTimeout(()=>{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<s;){const o=t.uint32();o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<n.length;t++){const r=Math.floor(Math.random()*Math.floor(n.length)),i=n[t];n[t]=n[r],n[r]=i}return n}(n).slice(0,e)}const oA=cr("waku:peer-discovery-static-list");let L7=(()=>{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<l;){const _=s.uint32();_>>>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<o;){const a=r.uint32();switch(a>>>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<s;){const o=t.uint32();o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<a;){const l=i.uint32();switch(l>>>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<s;){const o=t.uint32();o>>>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<s;){const o=t.uint32();switch(o>>>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<a;){const l=i.uint32();switch(l>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<a;){const l=i.uint32();switch(l>>>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<s;){const o=t.uint32();o>>>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<s;){const o=t.uint32();switch(o>>>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<a;){const l=i.uint32();switch(l>>>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<s;){const o=t.uint32();switch(o>>>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<s;){const o=t.uint32();switch(o>>>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<t;i++)this.history[i]=[]}get size(){return this.msgs.size}put(e,t,r=!1){const{msgIdStr:i}=e;return!this.msgs.has(i)&&(this.msgs.set(i,{message:t,validated:r,originatingPeers:new Set,iwantCounts:new Map}),this.history[0].push({...e,topic:t.topic}),!0)}observeDuplicate(e,t){const r=this.msgs.get(e);r&&!r.validated&&r.originatingPeers.add(t)}get(e){return this.msgs.get(this.msgIdToStrFn(e))?.message}getWithIWantCount(e,t){const r=this.msgs.get(e);if(!r)return null;const i=(r.iwantCounts.get(t)??0)+1;return r.iwantCounts.set(t,i),{msg:r.message,count:i}}getGossipIDs(e){const t=new Map;for(let r=0;r<this.gossip;r++)this.history[r].forEach(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<n.length;t++){const r=Math.floor(Math.random()*Math.floor(n.length)),i=n[t];n[t]=n[r],n[r]=i}return n}function OH(n){return Rt(n,"base64")}const ip="StrictSign",vE="StrictNoSign";var sp=(()=>(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.meshMessageDeliveries<l.meshMessageDeliveriesThreshold){const V=l.meshMessageDeliveriesThreshold-a.meshMessageDeliveries;_+=V*V*l.meshMessageDeliveriesWeight}_+=a.meshFailurePenalty*l.meshFailurePenaltyWeight,_+=a.invalidMessageDeliveries*a.invalidMessageDeliveries*l.invalidMessageDeliveriesWeight,i+=_*l.topicWeight}),t.topicScoreCap>0&&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.expire<e;)this.records.delete(t.msgId),this.queue.shift(),t=this.queue.peekFront()}clear(){this.records.clear(),this.queue.clear()}}const lu=Ft("libp2p:gossipsub:score");class WH{constructor(e,t,r){this.params=e,this.metrics=t,this.peerStats=new Map,this.peerIPs=new Map,this.scoreCache=new Map,this.deliveryRecords=new zH,this.components=new co,function VH(n){for(const[e,t]of Object.entries(n.topics))try{HH(t)}catch(r){throw se(new Error(`invalid score parameters for topic ${e}: ${r.message}`),Fn)}if(n.topicScoreCap<0)throw se(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),Fn);if(null==n.appSpecificScore)throw se(new Error("missing application specific score function"),Fn);if(n.IPColocationFactorWeight>0)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.firstMessageDeliveries<t&&(o.firstMessageDeliveries=0),o.meshMessageDeliveries*=a.meshMessageDeliveriesDecay,o.meshMessageDeliveries<t&&(o.meshMessageDeliveries=0),o.meshFailurePenalty*=a.meshFailurePenaltyDecay,o.meshFailurePenalty<t&&(o.meshFailurePenalty=0),o.invalidMessageDeliveries*=a.invalidMessageDeliveriesDecay,o.invalidMessageDeliveries<t&&(o.invalidMessageDeliveries=0),o.inMesh&&(o.meshTime=e-o.graftTime,o.meshTime>a.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenalty<t&&(r.behaviourPenalty=0)):e>r.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<s){const o=s-i.meshMessageDeliveries;i.meshFailurePenalty+=o*o}i.inMesh=!1,i.meshMessageDeliveriesActive=!1}),t.connected=!1,t.expire=Date.now()+this.params.retainScore}}graft(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);i&&(i.inMesh=!0,i.graftTime=Date.now(),i.meshTime=0,i.meshMessageDeliveriesActive=!1)}}prune(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);if(i){const s=this.params.topics[t].meshMessageDeliveriesThreshold;if(i.meshMessageDeliveriesActive&&i.meshMessageDeliveries<s){const o=s-i.meshMessageDeliveries;i.meshFailurePenalty+=o*o}i.meshMessageDeliveriesActive=!1,i.inMesh=!1}}}validateMessage(e){this.deliveryRecords.ensureRecord(e)}deliverMessage(e,t,r){this.markFirstMessageDelivery(e,r);const i=this.deliveryRecords.ensureRecord(t),s=Date.now();i.status===ai.unknown?(i.status=ai.valid,i.validated=s,i.peers.forEach(o=>{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<e&&(t.set(a,(t.get(a)??0)+1),i.delete(a),r++)}),i.size||this.promises.delete(s)}),this.metrics?.iwantPromiseBroken.inc(r),t}deliverMessage(e){this.trackMessage(e);const t=this.promises.get(e);t&&(this.promises.delete(e),this.metrics&&(this.metrics.iwantPromiseResolved.inc(1),this.metrics.iwantPromiseResolvedPeers.inc(t.size)))}rejectMessage(e,t){this.trackMessage(e),t!==Xi.Error&&this.promises.delete(e)}clear(){this.promises.clear()}prune(){const e=Date.now()-this.requestMsByMsgExpire;for(const[t,r]of this.requestMsByMsg.entries()){if(!(r<e))break;this.requestMsByMsg.delete(t)}}trackMessage(e){if(this.metrics){const t=this.requestMsByMsg.get(e);void 0!==t&&(this.metrics.iwantPromiseDeliveryTime.observe((Date.now()-t)/1e3),this.requestMsByMsg.delete(e))}}}class bE{constructor(e){this.entries=new Map,this.validityMs=e.validityMs}get size(){return this.entries.size}put(e,t){this.entries.set(e,{value:t,validUntilMs:Date.now()+this.validityMs})}prune(){const e=Date.now();for(const[t,r]of this.entries.entries()){if(!(r.validUntilMs<e))break;this.entries.delete(t)}}has(e){return this.entries.has(e)}get(e){const t=this.entries.get(e);return t&&t.validUntilMs>=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.meshMessageDeliveries<X.meshMessageDeliveriesThreshold){const an=X.meshMessageDeliveriesThreshold-V.meshMessageDeliveries;ae+=an*an*X.meshMessageDeliveriesWeight}Ie+=V.meshFailurePenalty*X.meshFailurePenaltyWeight,Fe+=V.invalidMessageDeliveries*V.invalidMessageDeliveries*X.invalidMessageDeliveriesWeight,s+=(fe+Se+ae+Ie+Fe)*X.topicWeight,ie.p1w+=fe,ie.p2w+=Se,ie.p3w+=ae,ie.p3bw+=Ie,ie.p4w+=Fe}),t.topicScoreCap>0&&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(r<this.opts.scoreThresholds.gossipThreshold)return this.log("IHAVE: ignoring peer %s with score below threshold [ score = %d ]",e,r),this.metrics?.ihaveRcvIgnored.inc({reason:du.LowScore}),[];const i=(this.peerhave.get(e)??0)+1;if(this.peerhave.set(e,i),i>10)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<this.opts.scoreThresholds.gossipThreshold)return this.log("IWANT: ignoring peer %s with score below threshold [score = %d]",e,r),[];const i=new Map,s=new Map;let o=0;return t.forEach(({messageIDs:a})=>{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?(r.log("GRAFT: ignoring backed off peer %s",e),r.score.addPenalty(e,1,fu.GraftBackoff),a=!1,o<R+r.opts.graftFloodThreshold-r.opts.pruneBackoff&&r.score.addPenalty(e,1,fu.GraftBackoff),r.addBackoff(e,l),void i.push(l)):s<0?(r.log("GRAFT: ignoring peer %s with negative score: score=%d, topic=%s",e,s,l),i.push(l),a=!1,void r.addBackoff(e,l)):_.size>=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<r.opts.scoreThresholds.acceptPXThreshold){r.log("PRUNE: ignoring PX from peer %s with insufficient score [score = %d, topic = %s]",e,i,s);continue}yield r.pxConnect(a)}}})()}addBackoff(e,t){this.doAddBackoff(e,t,this.opts.pruneBackoff)}doAddBackoff(e,t,r){let i=this.backoff.get(t);i||(i=new Map,this.backoff.set(t,i));const s=Date.now()+r;(i.get(e)??0)<s&&i.set(e,s)}applyIwantPenalties(){this.gossipTracer.getBrokenPromises().forEach((e,t)=>{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&&t.delete(s)}),0===t.size&&this.backoff.delete(r)})}directConnect(){var e=this;return j(function*(){const t=[];e.direct.forEach(r=>{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<this.opts.D){const i=t.size;this.getRandomGossipPeers(e,this.opts.D,o=>!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<r&&function sK(n,e){return SE(n,e,()=>!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<o){const ut=Pn=>{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;ir<t&&Pn>0;ir++)e.outbound.get(Te[ir])&&(ut(ir),Pn--)}let an=t-dt;for(let Pn=t;Pn<Te.length&&an>0;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<o&&SE(Se,o-Te,an=>!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<e.opts.scoreThresholds.opportunisticGraftThreshold){const Pn=SE(Se,e.opts.opportunisticGraftPeers,ir=>_(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<Y&&(e.fanout.delete(ie),e.fanoutLastpub.delete(ie))}),e.fanout.forEach((X,ie)=>{const fe=e.topics.get(ie);X.forEach(Fe=>{(!fe.has(Fe)||_(Fe)<e.opts.scoreThresholds.publishThreshold)&&X.delete(Fe)});const Se=e.topics.get(ie),ae=[],Ie=new Set;if(V.set(ie,Ie),Se){const Fe=vo(Array.from(Se));for(const Te of Fe){const dt=e.streamsOutbound.get(Te);if(dt&&e.multicodecs.includes(dt.protocol)&&!X.has(Te)&&!e.direct.has(Te)){const ut=_(Te);ut>=e.opts.scoreThresholds.publishThreshold&&ae.push(Te),ut>=e.opts.scoreThresholds.gossipThreshold&&Ie.add(Te)}}}X.size<t&&ae.slice(0,t-X.size).forEach(Te=>{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<s;){const o=t.uint32();o>>>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<arguments.length;)u[g++]=arguments[w++];return new Promise(function(c,f){u[g]=function(b){if(m)if(m=!1,b)f(b);else{for(var S=new Array(arguments.length-1),E=0;E<S.length;)S[E++]=arguments[E];c.apply(null,S)}};try{x.apply(y||null,u)}catch(d){m&&(m=!1,f(d))}})}},8475:(Q,K)=>{"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<f;){var p=h[c++];switch(E){case 0:b[S++]=y[p>>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;E<h.length;){var v=h.charCodeAt(E++);if(61===v&&b>1)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<c.length;)f[b]=c[b],d[b]=m[c[b++]];return f[b]=h,Function.apply(null,f).apply(null,d)}return Function(h)()}for(var S=new Array(arguments.length-1),E=0;E<S.length;)S[E]=arguments[++E];if(E=0,m=m.replace(/%([%dfijs])/g,function(p,I){var A=S[E++];switch(I){case"d":case"f":return String(Number(A));case"i":return String(Math.floor(A));case"j":return JSON.stringify(A);case"s":return String(A)}return"%"}),E!==S.length)throw Error("parameter count mismatch");return u.push(m),g}function w(m){return"function "+(m||y||"")+"("+(x&&x.join(",")||"")+"){\n "+u.join("\n ")+"\n}"}return g.toString=w,g}Q.exports=K,K.verbose=!1},4166:Q=>{"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<g.length;)g[w].fn===u?g.splice(w,1):++w;return this},K.prototype.emit=function(y){var u=this._listeners[y];if(u){for(var g=[],w=1;w<arguments.length;)g.push(arguments[w++]);for(w=0;w<u.length;)u[w].fn.apply(u[w++].ctx,g)}return this}},1159:(Q,K,x)=>{"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<d.responseText.length;++E)S.push(255&d.responseText.charCodeAt(E))}return f(null,typeof Uint8Array<"u"?new Uint8Array(S):S)}return f(null,d.responseText)}},c.binary&&("overrideMimeType"in d&&d.overrideMimeType("text/plain; charset=x-user-defined"),d.responseType="arraybuffer"),d.open("GET",h),d.send()}},3753:Q=>{"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;f<m.length;)".."===m[f]?f>0&&".."!==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;m<u.length;++m)(w=u.charCodeAt(m))<128?g+=1:w<2048?g+=2:55296==(64512&w)&&56320==(64512&u.charCodeAt(m+1))?(++m,g+=4):g+=3;return g},x.read=function(u,g,w){if(w-g<1)return"";for(var d,h=null,c=[],f=0;g<w;)(d=u[g++])<128?c[f++]=d:d>191&&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<u.length;++f)(h=u.charCodeAt(f))<128?g[w++]=h:h<2048?(g[w++]=h>>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<te+Z/8;he++)oe+=W[he]*de,de*=256;return oe},K.writeUintBE=function F(Z,W,te,oe){if(void 0===te&&(te=new Uint8Array(Z/8)),void 0===oe&&(oe=0),Z%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!y.isSafeInteger(W))throw new Error("writeUintBE value must be an integer");for(var de=1,he=Z/8+oe-1;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<oe+Z/8;he++)te[he]=W/de&255,de*=256;return te},K.readFloat32BE=function C(Z,W){return void 0===W&&(W=0),new DataView(Z.buffer,Z.byteOffset,Z.byteLength).getFloat32(W)},K.readFloat32LE=function O(Z,W){return void 0===W&&(W=0),new DataView(Z.buffer,Z.byteOffset,Z.byteLength).getFloat32(W,!0)},K.readFloat64BE=function U(Z,W){return void 0===W&&(W=0),new DataView(Z.buffer,Z.byteOffset,Z.byteLength).getFloat64(W)},K.readFloat64LE=function L(Z,W){return void 0===W&&(W=0),new DataView(Z.buffer,Z.byteOffset,Z.byteLength).getFloat64(W,!0)},K.writeFloat32BE=function H(Z,W,te){return void 0===W&&(W=new Uint8Array(4)),void 0===te&&(te=0),new DataView(W.buffer,W.byteOffset,W.byteLength).setFloat32(te,Z),W},K.writeFloat32LE=function ne(Z,W,te){return void 0===W&&(W=new Uint8Array(4)),void 0===te&&(te=0),new DataView(W.buffer,W.byteOffset,W.byteLength).setFloat32(te,Z,!0),W},K.writeFloat64BE=function G(Z,W,te){return void 0===W&&(W=new Uint8Array(8)),void 0===te&&(te=0),new DataView(W.buffer,W.byteOffset,W.byteLength).setFloat64(te,Z),W},K.writeFloat64LE=function ee(Z,W,te){return void 0===W&&(W=new Uint8Array(8)),void 0===te&&(te=0),new DataView(W.buffer,W.byteOffset,W.byteLength).setFloat64(te,Z,!0),W}},5749:(Q,K,x)=>{"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.length<this.tagLength)return null;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 A=new Uint8Array(this.tagLength);if(this._authenticate(A,I,S.subarray(0,S.length-this.tagLength),E),!h.equal(A,S.subarray(S.length-this.tagLength,S.length)))return null;var D,P=S.length-this.tagLength;if(v){if(v.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");D=v}else D=new Uint8Array(P);return u.streamXOR(this._key,p,S.subarray(0,S.length-this.tagLength),D,4),w.wipe(p),D},d.prototype.clean=function(){return w.wipe(this._key),this},d.prototype._authenticate=function(b,S,E,v){var p=new g.Poly1305(S);v&&(p.update(v),v.length%16>0&&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<A.length;P++)b[P]=A[P];p.clean(),w.wipe(A),w.wipe(I)},d}();K.OK=f},6237:(Q,K,x)=>{"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<b.length)throw new Error("ChaCha: destination is shorter than source");var v,p;if(0===E){if(8!==d.length&&12!==d.length)throw new Error("ChaCha nonce must be 8 or 12 bytes");(v=new Uint8Array(16)).set(d,p=v.length-d.length)}else{if(16!==d.length)throw new Error("ChaCha nonce with counter must be 16 bytes");v=d,p=E}for(var I=new Uint8Array(64),A=0;A<b.length;A+=64){w(I,v,f);for(var P=A;P<A+64&&P<b.length;P++)S[P]=b[P]^I[P-A];c(v,0,p)}return u.wipe(I),0===E&&u.wipe(v),S}function c(f,d,b){for(var S=1;b--;)f[d]=255&(S=S+(255&f[d])|0),S>>>=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<w.length;c++)h|=w[c]^m[c];return 1&h-1>>>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<c.length;f++)this._bufpos===this._buffer.length&&this._fillBuffer(),c[f]=this._buffer[this._bufpos++];return c},m.prototype.clean=function(){this._hmac.clean(),g.wipe(this._buffer),g.wipe(this._counter),this._bufpos=0},m}();K.t=w},9605:(Q,K,x)=>{"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<d.length;b++)d[b]^=54;for(this._inner.update(d),b=0;b<d.length;b++)d[b]^=106;this._outer.update(d),y.isSerializableHash(this._inner)&&y.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),g.wipe(d)}return h.prototype.reset=function(){if(!y.isSerializableHash(this._inner)||!y.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},h.prototype.clean=function(){y.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),y.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},h.prototype.update=function(c){return this._inner.update(c),this},h.prototype.finish=function(c){return this._finished?(this._outer.finish(c),this):(this._inner.finish(c),this._outer.update(c.subarray(0,this.digestLength)).finish(c),this._finished=!0,this)},h.prototype.digest=function(){var c=new Uint8Array(this.digestLength);return this.finish(c),c},h.prototype.saveState=function(){if(!y.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},h.prototype.restoreState=function(c){if(!y.isSerializableHash(this._inner)||!y.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(c),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},h.prototype.cleanSavedState=function(c){if(!y.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(c)},h}();K.HMAC=w,K.hmac=function m(h,c,f){var d=new w(h,c);d.update(f);var b=d.digest();return d.clean(),b},K.equal=u.equal},6559:(Q,K)=>{"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<<c|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<b;S++)this._buffer[this._leftover+S]=c[f+S];if(d-=b,f+=b,this._leftover+=b,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(d>=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(S=0;S<d;S++)this._buffer[this._leftover+S]=c[f+S];this._leftover+=d}return this},h.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var c=new Uint8Array(16);return this.finish(c),c},h.prototype.clean=function(){return u.wipe(this._buffer),u.wipe(this._r),u.wipe(this._h),u.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},h}();K.Poly1305=g,K.oneTimeAuth=function w(h,c){var f=new g(h);f.update(c);var d=f.digest();return f.clean(),d},K.equal=function m(h,c){return h.length===K.DIGEST_LENGTH&&c.length===K.DIGEST_LENGTH&&y.equal(h,c)}},7365:(Q,K,x)=>{"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;A<I.length&&d>0;A++){const P=I[A];P<p&&(E+=b.charAt(P%v),d--)}(0,g.wipe)(I)}return E}K.randomString=c,K.randomStringForEntropy=function f(d,b=h,S=K.defaultRandomSource){return c(Math.ceil(d/(Math.log(b.length)/Math.LN2)),b,S)}},1006:(Q,K)=>{"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<w.length;m+=65536)this._crypto.getRandomValues(w.subarray(m,m+Math.min(w.length-m,65536)));return w}}},2486:(Q,K,x)=>{"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<h.length;c++)h[c]=m[c];return(0,y.wipe)(m),h}}},3518:(Q,K,x)=>{"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._bufferLength<this.blockSize&&b>0;)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;I<p-8;I++)this._buffer[I]=0;u.writeUint32BE(E,this._buffer,p-8),u.writeUint32BE(v,this._buffer,p-4),h(this._temp,this._state,this._buffer,0,p),this._finished=!0}for(I=0;I<this.digestLength/4;I++)u.writeUint32BE(this._state[I],d,4*I);return this},f.prototype.digest=function(){var d=new Uint8Array(this.digestLength);return this.finish(d),d},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?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<y.length;u++)y[u]=0;return y}},6685:(Q,K,x)=>{"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;$<k.length;$++)F[$]=k[$];return F}K.kz=32,K.KS=32;const m=new Uint8Array(32);m[0]=9;const h=w([56129,1]);function c(k){let F=1;for(let $=0;$<16;$++){let C=k[$]+F+65535;F=Math.floor(C/65536),k[$]=C-65536*F}k[0]+=F-1+37*(F-1)}function f(k,F,$){const C=~($-1);for(let O=0;O<16;O++){const U=C&(k[O]^F[O]);k[O]^=U,F[O]^=U}}function S(k,F,$){for(let C=0;C<16;C++)k[C]=F[C]+$[C]}function E(k,F,$){for(let C=0;C<16;C++)k[C]=F[C]-$[C]}function v(k,F,$){let C,O,U=0,L=0,H=0,ne=0,G=0,ee=0,Z=0,W=0,te=0,oe=0,de=0,he=0,Pe=0,De=0,Be=0,ve=0,He=0,ke=0,nt=0,Pt=0,_t=0,Vt=0,Yt=0,nn=0,cn=0,$n=0,Tr=0,_n=0,Oi=0,Qr=0,es=0,re=$[0],le=$[1],ge=$[2],ye=$[3],be=$[4],xe=$[5],ze=$[6],je=$[7],Je=$[8],Xe=$[9],Ue=$[10],Ee=$[11],pe=$[12],_e=$[13],Le=$[14],Ne=$[15];C=F[0],U+=C*re,L+=C*le,H+=C*ge,ne+=C*ye,G+=C*be,ee+=C*xe,Z+=C*ze,W+=C*je,te+=C*Je,oe+=C*Xe,de+=C*Ue,he+=C*Ee,Pe+=C*pe,De+=C*_e,Be+=C*Le,ve+=C*Ne,C=F[1],L+=C*re,H+=C*le,ne+=C*ge,G+=C*ye,ee+=C*be,Z+=C*xe,W+=C*ze,te+=C*je,oe+=C*Je,de+=C*Xe,he+=C*Ue,Pe+=C*Ee,De+=C*pe,Be+=C*_e,ve+=C*Le,He+=C*Ne,C=F[2],H+=C*re,ne+=C*le,G+=C*ge,ee+=C*ye,Z+=C*be,W+=C*xe,te+=C*ze,oe+=C*je,de+=C*Je,he+=C*Xe,Pe+=C*Ue,De+=C*Ee,Be+=C*pe,ve+=C*_e,He+=C*Le,ke+=C*Ne,C=F[3],ne+=C*re,G+=C*le,ee+=C*ge,Z+=C*ye,W+=C*be,te+=C*xe,oe+=C*ze,de+=C*je,he+=C*Je,Pe+=C*Xe,De+=C*Ue,Be+=C*Ee,ve+=C*pe,He+=C*_e,ke+=C*Le,nt+=C*Ne,C=F[4],G+=C*re,ee+=C*le,Z+=C*ge,W+=C*ye,te+=C*be,oe+=C*xe,de+=C*ze,he+=C*je,Pe+=C*Je,De+=C*Xe,Be+=C*Ue,ve+=C*Ee,He+=C*pe,ke+=C*_e,nt+=C*Le,Pt+=C*Ne,C=F[5],ee+=C*re,Z+=C*le,W+=C*ge,te+=C*ye,oe+=C*be,de+=C*xe,he+=C*ze,Pe+=C*je,De+=C*Je,Be+=C*Xe,ve+=C*Ue,He+=C*Ee,ke+=C*pe,nt+=C*_e,Pt+=C*Le,_t+=C*Ne,C=F[6],Z+=C*re,W+=C*le,te+=C*ge,oe+=C*ye,de+=C*be,he+=C*xe,Pe+=C*ze,De+=C*je,Be+=C*Je,ve+=C*Xe,He+=C*Ue,ke+=C*Ee,nt+=C*pe,Pt+=C*_e,_t+=C*Le,Vt+=C*Ne,C=F[7],W+=C*re,te+=C*le,oe+=C*ge,de+=C*ye,he+=C*be,Pe+=C*xe,De+=C*ze,Be+=C*je,ve+=C*Je,He+=C*Xe,ke+=C*Ue,nt+=C*Ee,Pt+=C*pe,_t+=C*_e,Vt+=C*Le,Yt+=C*Ne,C=F[8],te+=C*re,oe+=C*le,de+=C*ge,he+=C*ye,Pe+=C*be,De+=C*xe,Be+=C*ze,ve+=C*je,He+=C*Je,ke+=C*Xe,nt+=C*Ue,Pt+=C*Ee,_t+=C*pe,Vt+=C*_e,Yt+=C*Le,nn+=C*Ne,C=F[9],oe+=C*re,de+=C*le,he+=C*ge,Pe+=C*ye,De+=C*be,Be+=C*xe,ve+=C*ze,He+=C*je,ke+=C*Je,nt+=C*Xe,Pt+=C*Ue,_t+=C*Ee,Vt+=C*pe,Yt+=C*_e,nn+=C*Le,cn+=C*Ne,C=F[10],de+=C*re,he+=C*le,Pe+=C*ge,De+=C*ye,Be+=C*be,ve+=C*xe,He+=C*ze,ke+=C*je,nt+=C*Je,Pt+=C*Xe,_t+=C*Ue,Vt+=C*Ee,Yt+=C*pe,nn+=C*_e,cn+=C*Le,$n+=C*Ne,C=F[11],he+=C*re,Pe+=C*le,De+=C*ge,Be+=C*ye,ve+=C*be,He+=C*xe,ke+=C*ze,nt+=C*je,Pt+=C*Je,_t+=C*Xe,Vt+=C*Ue,Yt+=C*Ee,nn+=C*pe,cn+=C*_e,$n+=C*Le,Tr+=C*Ne,C=F[12],Pe+=C*re,De+=C*le,Be+=C*ge,ve+=C*ye,He+=C*be,ke+=C*xe,nt+=C*ze,Pt+=C*je,_t+=C*Je,Vt+=C*Xe,Yt+=C*Ue,nn+=C*Ee,cn+=C*pe,$n+=C*_e,Tr+=C*Le,_n+=C*Ne,C=F[13],De+=C*re,Be+=C*le,ve+=C*ge,He+=C*ye,ke+=C*be,nt+=C*xe,Pt+=C*ze,_t+=C*je,Vt+=C*Je,Yt+=C*Xe,nn+=C*Ue,cn+=C*Ee,$n+=C*pe,Tr+=C*_e,_n+=C*Le,Oi+=C*Ne,C=F[14],Be+=C*re,ve+=C*le,He+=C*ge,ke+=C*ye,nt+=C*be,Pt+=C*xe,_t+=C*ze,Vt+=C*je,Yt+=C*Je,nn+=C*Xe,cn+=C*Ue,$n+=C*Ee,Tr+=C*pe,_n+=C*_e,Oi+=C*Le,Qr+=C*Ne,C=F[15],ve+=C*re,He+=C*le,ke+=C*ge,nt+=C*ye,Pt+=C*be,_t+=C*xe,Vt+=C*ze,Yt+=C*je,nn+=C*Je,cn+=C*Xe,$n+=C*Ue,Tr+=C*Ee,_n+=C*pe,Oi+=C*_e,Qr+=C*Le,es+=C*Ne,U+=38*He,L+=38*ke,H+=38*nt,ne+=38*Pt,G+=38*_t,ee+=38*Vt,Z+=38*Yt,W+=38*nn,te+=38*cn,oe+=38*$n,de+=38*Tr,he+=38*_n,Pe+=38*Oi,De+=38*Qr,Be+=38*es,O=1,C=U+O+65535,O=Math.floor(C/65536),U=C-65536*O,C=L+O+65535,O=Math.floor(C/65536),L=C-65536*O,C=H+O+65535,O=Math.floor(C/65536),H=C-65536*O,C=ne+O+65535,O=Math.floor(C/65536),ne=C-65536*O,C=G+O+65535,O=Math.floor(C/65536),G=C-65536*O,C=ee+O+65535,O=Math.floor(C/65536),ee=C-65536*O,C=Z+O+65535,O=Math.floor(C/65536),Z=C-65536*O,C=W+O+65535,O=Math.floor(C/65536),W=C-65536*O,C=te+O+65535,O=Math.floor(C/65536),te=C-65536*O,C=oe+O+65535,O=Math.floor(C/65536),oe=C-65536*O,C=de+O+65535,O=Math.floor(C/65536),de=C-65536*O,C=he+O+65535,O=Math.floor(C/65536),he=C-65536*O,C=Pe+O+65535,O=Math.floor(C/65536),Pe=C-65536*O,C=De+O+65535,O=Math.floor(C/65536),De=C-65536*O,C=Be+O+65535,O=Math.floor(C/65536),Be=C-65536*O,C=ve+O+65535,O=Math.floor(C/65536),ve=C-65536*O,U+=O-1+37*(O-1),O=1,C=U+O+65535,O=Math.floor(C/65536),U=C-65536*O,C=L+O+65535,O=Math.floor(C/65536),L=C-65536*O,C=H+O+65535,O=Math.floor(C/65536),H=C-65536*O,C=ne+O+65535,O=Math.floor(C/65536),ne=C-65536*O,C=G+O+65535,O=Math.floor(C/65536),G=C-65536*O,C=ee+O+65535,O=Math.floor(C/65536),ee=C-65536*O,C=Z+O+65535,O=Math.floor(C/65536),Z=C-65536*O,C=W+O+65535,O=Math.floor(C/65536),W=C-65536*O,C=te+O+65535,O=Math.floor(C/65536),te=C-65536*O,C=oe+O+65535,O=Math.floor(C/65536),oe=C-65536*O,C=de+O+65535,O=Math.floor(C/65536),de=C-65536*O,C=he+O+65535,O=Math.floor(C/65536),he=C-65536*O,C=Pe+O+65535,O=Math.floor(C/65536),Pe=C-65536*O,C=De+O+65535,O=Math.floor(C/65536),De=C-65536*O,C=Be+O+65535,O=Math.floor(C/65536),Be=C-65536*O,C=ve+O+65535,O=Math.floor(C/65536),ve=C-65536*O,U+=O-1+37*(O-1),k[0]=U,k[1]=L,k[2]=H,k[3]=ne,k[4]=G,k[5]=ee,k[6]=Z,k[7]=W,k[8]=te,k[9]=oe,k[10]=de,k[11]=he,k[12]=Pe,k[13]=De,k[14]=Be,k[15]=ve}function p(k,F){v(k,F,F)}function A(k,F){const $=new Uint8Array(32),C=new Float64Array(80),O=w(),U=w(),L=w(),H=w(),ne=w(),G=w();for(let te=0;te<31;te++)$[te]=k[te];$[31]=127&k[31]|64,$[0]&=248,function b(k,F){for(let $=0;$<16;$++)k[$]=F[2*$]+(F[2*$+1]<<8);k[15]&=32767}(C,F);for(let te=0;te<16;te++)U[te]=C[te];O[0]=H[0]=1;for(let te=254;te>=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<C.length;U++)O|=C[U];if(0===O)throw new Error("X25519: invalid shared key")}return C}},6449:Q=>{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<I;v++)!p[v]||("-"===(E=p[v].replace(/\*/g,".*?"))[0]?w.skips.push(new RegExp("^"+E.slice(1)+"$")):w.names.push(new RegExp("^"+E+"$")))},w.enabled=function f(E){if("*"===E[E.length-1])return!0;let v,p;for(v=0,p=w.skips.length;v<p;v++)if(w.skips[v].test(E))return!1;for(v=0,p=w.names.length;v<p;v++)if(w.names[v].test(E))return!0;return!1},w.humanize=x(4564),w.destroy=function S(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(u).forEach(E=>{w[E]=u[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p<E.length;p++)v=(v<<5)-v+E.charCodeAt(p),v|=0;return w.colors[Math.abs(v)%w.colors.length]},w.enable(w.load()),w}},4555:Q=>{"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._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},K.prototype.unshift=function(y){return void 0===y?this.size():(this._head=this._head-1+this._list.length&this._capacityMask,this._list[this._head]=y,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail))},K.prototype.shift=function(){var y=this._head;if(y!==this._tail){var u=this._list[y];return this._list[y]=void 0,this._head=y+1&this._capacityMask,y<2&&this._tail>1e4&&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._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},K.prototype.pop=function(){var y=this._tail;if(y!==this._head){var u=this._list.length;this._tail=y-1+u&this._capacityMask;var g=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&y>1e4&&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(y<g/2){for(h=y;h>0;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;f<u;f++)w[f]=this._list[this._head+g+f&this._capacityMask];if(g=this._head+g&this._capacityMask,y+u===h){for(this._tail=this._tail-u+c&this._capacityMask,f=u;f>0;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(g<h/2){for(this._head=this._head+y+u+c&this._capacityMask,f=y;f>0;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||g<w/2){for(h=new Array(g),m=0;m<g;m++)h[m]=this._list[this._head+m&this._capacityMask];for(0===u?(c=[],g>0&&(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;m<S;m++)h[m]=this._list[this._head+g+u+m&this._capacityMask];for(0===u?(c=[],g!=w&&(this._tail=this._head+g+d&this._capacityMask)):(c=this.remove(g,u),this._tail=this._tail-S+d&this._capacityMask);b<f;)this.push(arguments[b++]);for(m=0;m<S;m++)this.push(h[m])}return c}return this.remove(g,u)}}},K.prototype.clear=function(){this._head=0,this._tail=0},K.prototype.isEmpty=function(){return this._head===this._tail},K.prototype.toArray=function(){return this._copyArray(!1)},K.prototype._fromArray=function(y){for(var u=0;u<y.length;u++)this.push(y[u])},K.prototype._copyArray=function(y){var m,u=[],g=this._list,w=g.length;if(y||this._head>this._tail){for(m=this._head;m<w;m++)u.push(g[m]);for(m=0;m<this._tail;m++)u.push(g[m])}else for(m=this._head;m<this._tail;m++)u.push(g[m]);return u},K.prototype._growArray=function(){this._head&&(this._list=this._copyArray(!0),this._head=0),this._tail=this._list.length,this._list.length<<=1,this._capacityMask=this._capacityMask<<1|1},K.prototype._shrinkArray=function(){this._list.length>>>=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<S;b++)E[b]=d[b].fn;return E},m.prototype.listenerCount=function(c){var d=this._events[x?x+c:c];return d?d.fn?1:d.length:0},m.prototype.emit=function(c,f,d,b,S,E){var v=x?x+c:c;if(!this._events[v])return!1;var A,P,p=this._events[v],I=arguments.length;if(p.fn){switch(p.once&&this.removeListener(c,p.fn,void 0,!0),I){case 1:return p.fn.call(p.context),!0;case 2:return p.fn.call(p.context,f),!0;case 3:return p.fn.call(p.context,f,d),!0;case 4:return p.fn.call(p.context,f,d,b),!0;case 5:return p.fn.call(p.context,f,d,b,S),!0;case 6:return p.fn.call(p.context,f,d,b,S,E),!0}for(P=1,A=new Array(I-1);P<I;P++)A[P-1]=arguments[P];p.fn.apply(p.context,A)}else{var T,D=p.length;for(P=0;P<D;P++)switch(p[P].once&&this.removeListener(c,p[P].fn,void 0,!0),I){case 1:p[P].fn.call(p[P].context);break;case 2:p[P].fn.call(p[P].context,f);break;case 3:p[P].fn.call(p[P].context,f,d);break;case 4:p[P].fn.call(p[P].context,f,d,b);break;default:if(!A)for(T=1,A=new Array(I-1);T<I;T++)A[T-1]=arguments[T];p[P].fn.apply(p[P].context,A)}}return!0},m.prototype.on=function(c,f,d){return g(this,c,f,d,!1)},m.prototype.once=function(c,f,d){return g(this,c,f,d,!0)},m.prototype.removeListener=function(c,f,d,b){var S=x?x+c:c;if(!this._events[S])return this;if(!f)return w(this,S),this;var E=this._events[S];if(E.fn)E.fn===f&&(!b||E.once)&&(!d||E.context===d)&&w(this,S);else{for(var v=0,p=[],I=E.length;v<I;v++)(E[v].fn!==f||b&&!E[v].once||d&&E[v].context!==d)&&p.push(E[v]);p.length?this._events[S]=1===p.length?p[0]:p:w(this,S)}return this},m.prototype.removeAllListeners=function(c){var f;return c?this._events[f=x?x+c:c]&&w(this,f):(this._events=new y,this._eventsCount=0),this},m.prototype.off=m.prototype.removeListener,m.prototype.addListener=m.prototype.on,m.prefixed=x,m.EventEmitter=m,Q.exports=m},8210:Q=>{"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;k<M.length;++k)M[k]=T[k].listener||T[k];return M}($):v($,$.length)}function E(T){var M=this._events;if(void 0!==M){var k=M[T];if("function"==typeof k)return 1;if(void 0!==k)return k.length}return 0}function v(T,M){for(var k=new Array(M),F=0;F<M;++F)k[F]=T[F];return k}function D(T,M,k,F){if("function"==typeof T.on)F.once?T.once(M,k):T.on(M,k);else{if("function"!=typeof T.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof T);T.addEventListener(M,function $(C){F.once&&T.removeEventListener(M,$),k(C)})}}Object.defineProperty(w,"defaultMaxListeners",{enumerable:!0,get:function(){return m},set:function(T){if("number"!=typeof T||T<0||g(T))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+T+".");m=T}}),w.init=function(){(void 0===this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},w.prototype.setMaxListeners=function(M){if("number"!=typeof M||M<0||g(M))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+M+".");return this._maxListeners=M,this},w.prototype.getMaxListeners=function(){return c(this)},w.prototype.emit=function(M){for(var k=[],F=1;F<arguments.length;F++)k.push(arguments[F]);var $="error"===M,C=this._events;if(void 0!==C)$=$&&void 0===C.error;else if(!$)return!1;if($){var O;if(k.length>0&&(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<H;++F)x(ne[F],this,k)}return!0},w.prototype.on=w.prototype.addListener=function(M,k){return f(this,M,k,!1)},w.prototype.prependListener=function(M,k){return f(this,M,k,!0)},w.prototype.once=function(M,k){return h(k),this.on(M,b(this,M,k)),this},w.prototype.prependOnceListener=function(M,k){return h(k),this.prependListener(M,b(this,M,k)),this},w.prototype.off=w.prototype.removeListener=function(M,k){var F,$,C,O,U;if(h(k),void 0===($=this._events))return this;if(void 0===(F=$[M]))return this;if(F===k||F.listener===k)0==--this._eventsCount?this._events=Object.create(null):(delete $[M],$.removeListener&&this.emit("removeListener",M,F.listener||k));else if("function"!=typeof F){for(C=-1,O=F.length-1;O>=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<T.length;M++)T[M]=T[M+1];T.pop()}(F,C),1===F.length&&($[M]=F[0]),void 0!==$.removeListener&&this.emit("removeListener",M,U||k)}return this},w.prototype.removeAllListeners=function(M){var k,F,$;if(void 0===(F=this._events))return this;if(void 0===F.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==F[M]&&(0==--this._eventsCount?this._events=Object.create(null):delete F[M]),this;if(0===arguments.length){var O,C=Object.keys(F);for($=0;$<C.length;++$)"removeListener"!==(O=C[$])&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(k=F[M]))this.removeListener(M,k);else if(void 0!==k)for($=k.length-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;k<T.length;k++)M.push(parseInt(T[k],16));return M}(),zoneId:A}}function f(E,v,p,I){if(E.length!==v.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let P,A=0;for(;I>0;){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<v;)E=`0${E}`;return E}const S={};S.IPv4=function(){function E(v){if(4!==v.length)throw new Error("ipaddr: ipv4 octet count should be 4");let p,I;for(p=0;p<v.length;p++)if(I=v[p],!(0<=I&&I<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=v}return E.prototype.SpecialRanges={unspecified:[[new E([0,0,0,0]),8]],broadcast:[[new E([255,255,255,255]),32]],multicast:[[new E([224,0,0,0]),4]],linkLocal:[[new E([169,254,0,0]),16]],loopback:[[new E([127,0,0,0]),8]],carrierGradeNat:[[new E([100,64,0,0]),10]],private:[[new E([10,0,0,0]),8],[new E([172,16,0,0]),12],[new E([192,168,0,0]),16]],reserved:[[new E([192,0,0,0]),24],[new E([192,0,2,0]),24],[new E([192,88,99,0]),24],[new E([198,51,100,0]),24],[new E([203,0,113,0]),24],[new E([240,0,0,0]),4]]},E.prototype.kind=function(){return"ipv4"},E.prototype.match=function(v,p){let I;if(void 0===p&&(I=v,v=I[0],p=I[1]),"ipv4"!==v.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return f(this.octets,v.octets,8,p)},E.prototype.prefixLengthFromSubnetMask=function(){let v=0,p=!1;const I={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0};let A,P,D;for(A=3;A>=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;D<A.length;D++)p=A[D],P.push(d(p));return P}();if(v=E.match(y.longValue)){if(I=d(v[1]),I>4294967295||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<I;)v[p]=255,p++;return I<4&&(v[I]=Math.pow(2,E%8)-1<<8-E%8),new this(v)},S.IPv6=function(){function E(v,p){let I,A;if(16===v.length)for(this.parts=[],I=0;I<=14;I+=2)this.parts.push(v[I]<<8|v[I+1]);else{if(8!==v.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=v}for(I=0;I<this.parts.length;I++)if(A=this.parts[I],!(0<=A&&A<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");p&&(this.zoneId=p)}return E.prototype.SpecialRanges={unspecified:[new E([0,0,0,0,0,0,0,0]),128],linkLocal:[new E([65152,0,0,0,0,0,0,0]),10],multicast:[new E([65280,0,0,0,0,0,0,0]),8],loopback:[new E([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new E([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new E([0,0,0,0,0,65535,0,0]),96],rfc6145:[new E([0,0,0,0,65535,0,0,0]),96],rfc6052:[new E([100,65435,0,0,0,0,0,0]),96],"6to4":[new E([8194,0,0,0,0,0,0,0]),16],teredo:[new E([8193,0,0,0,0,0,0,0]),32],reserved:[[new E([8193,3512,0,0,0,0,0,0]),32]]},E.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},E.prototype.kind=function(){return"ipv6"},E.prototype.match=function(v,p){let I;if(void 0===p&&(I=v,v=I[0],p=I[1]),"ipv6"!==v.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return f(this.parts,v.parts,16,p)},E.prototype.prefixLengthFromSubnetMask=function(){let v=0,p=!1;const I={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0};let A,P;for(let D=7;D>=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<I.length;A++)v=I[A],p.push(v>>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const I=[];for(let A=0;A<this.parts.length;A++)I.push(b(this.parts[A].toString(16),4));return I}.call(this).join(":");let p="";return this.zoneId&&(p=`%${this.zoneId}`),v+p},E.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");const v=this.parts.slice(-2),p=v[0],I=v[1];return new S.IPv4([p>>8,255&p,I>>8,255&I])},E.prototype.toNormalizedString=function(){const v=function(){const I=[];for(let A=0;A<this.parts.length;A++)I.push(this.parts[A].toString(16));return I}.call(this).join(":");let p="";return this.zoneId&&(p=`%${this.zoneId}`),v+p},E.prototype.toRFC5952String=function(){const v=/((^|:)(0(:|$)){2,})/g,p=this.toNormalizedString();let P,I=0,A=-1;for(;P=v.exec(p);)P[0].length>A&&(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;p<P.length;p++)if(A=P[p],!(0<=A&&A<=255))return null;return v.parts.push(P[0]<<8|P[1]),v.parts.push(P[2]<<8|P[3]),{parts:v.parts,zoneId:v.zoneId}}return null},S.IPv6.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>128)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<I;)v[p]=255,p++;return I<16&&(v[I]=Math.pow(2,E%8)-1<<8-E%8),new this(v)},S.fromByteArray=function(E){const v=E.length;if(4===v)return new S.IPv4(E);if(16===v)return new S.IPv6(E);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},S.isValid=function(E){return S.IPv6.isValid(E)||S.IPv4.isValid(E)},S.parse=function(E){if(S.IPv6.isValid(E))return S.IPv6.parse(E);if(S.IPv4.isValid(E))return S.IPv4.parse(E);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},S.parseCIDR=function(E){try{return S.IPv6.parseCIDR(E)}catch{try{return S.IPv4.parseCIDR(E)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},S.process=function(E){const v=this.parse(E);return"ipv6"===v.kind()&&v.isIPv4MappedAddress()?v.toIPv4Address():v},S.subnetMatch=function(E,v,p){let I,A,P,D;for(A in null==p&&(p="unicast"),v)if(Object.prototype.hasOwnProperty.call(v,A))for(P=v[A],P[0]&&!(P[0]instanceof Array)&&(P=[P]),I=0;I<P.length;I++)if(D=P[I],E.kind()===D[0].kind()&&E.match.apply(E,D))return A;return p},Q.exports?Q.exports=S:K.ipaddr=S}(this)},8404:Q=>{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<T.length;k++)!u.call(T,k)||(M.push(String(k)),w(P,D++,T===p?T[k]:f(T[k])));P=S(P,T,c(T).filter(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<x.length;y++)u[y]=x[y];return u}return Array.from(x)}Q.exports=function(y){var u=void 0,g=void 0;function w(c){if(!(c instanceof Object))throw new Error('Target "'+c+'" is not an object');g=c}function m(c){Object.keys(c).forEach(function(f){var d=c[f];if("function"!=typeof d)throw new Error('Trap "'+f+": "+d+'" is not a function');if(!Reflect[f])throw new Error('Trap "'+f+": "+d+'" is not a valid trap')}),u=c}w(function(){}),y&&w(y),m(Reflect);var h=new Proxy({},{get:function(f,d){return function(){for(var b=arguments.length,S=Array(b),E=0;E<b;E++)S[E]=arguments[E];return u[d].apply(null,[g].concat(K(S.slice(1))))}}});return{setTarget:w,setHandler:m,getTarget:function(){return g},getHandler:function(){return u},proxy:new Proxy(g,h)}}},2953:function(Q,K){(function(){var x,y,u,g,w,m,h,c;c=function(f){return[(f&255<<24)>>>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<f.length;){if("0"<=f[S]&&f[S]<=b)E=E*d+(u(f[S])-g)>>>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<A.length;++P)I.putByte(A[P])}}else I=y.util.createBuffer(I);if(!y.util.isArray(I)){A=I,I=[];var D=A.length();if(16===D||24===D||32===D)for(D>>>=2,P=0;P<D;++P)I.push(A.getInt32())}if(!y.util.isArray(I)||4!==I.length&&6!==I.length&&8!==I.length)throw new Error("Invalid key parameter.");var M=-1!==["CFB","OFB","CTR","GCM"].indexOf(this.mode.name);this._w=S(I,p.decrypt&&!M),this._init=!0}},y.aes._expandKey=function(p,I){return g||b(),S(p,I)},y.aes._updateBlock=E,u("AES-ECB",y.cipher.modes.ecb),u("AES-CBC",y.cipher.modes.cbc),u("AES-CFB",y.cipher.modes.cfb),u("AES-OFB",y.cipher.modes.ofb),u("AES-CTR",y.cipher.modes.ctr),u("AES-GCM",y.cipher.modes.gcm);var m,h,c,f,d,g=!1;function b(){g=!0,c=[0,1,2,4,8,16,32,64,128,27,54];for(var p=new Array(256),I=0;I<128;++I)p[I]=I<<1,p[I+128]=I+128<<1^283;for(m=new Array(256),h=new Array(256),f=new Array(4),d=new Array(4),I=0;I<4;++I)f[I]=new Array(256),d[I]=new Array(256);var D,T,M,k,F,$,C,A=0,P=0;for(I=0;I<256;++I){m[A]=k=(k=P^P<<1^P<<2^P<<3^P<<4)>>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<k;++F)P=A[F-1],F%T==0?(P=m[P>>>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<k;F+=4,ne-=4)if(0===F||F===k-4)H[F]=A[ne],H[F+1]=A[ne+3],H[F+2]=A[ne+2],H[F+3]=A[ne+1];else for(var G=0;G<4;++G)H[F+(3&-G)]=C[m[($=A[ne+G])>>>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<D;++Z)H=T[C>>>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;v<b.length;++v)void 0!==b[v]&&E.push(b[v]);b=E}var p={tagClass:c,type:f,constructed:d,composed:d||y.util.isArray(b),value:b};return S&&"bitStringContents"in S&&(p.bitStringContents=S.bitStringContents,p.original=u.copy(p)),p},u.copy=function(c,f){var d;if(y.util.isArray(c)){d=[];for(var b=0;b<c.length;++b)d.push(u.copy(c[b],f));return d}return"string"==typeof c?c:(d={tagClass:c.tagClass,type:c.type,constructed:c.constructed,composed:c.composed,value:u.copy(c.value,f)},f&&!f.excludeBitStringContents&&(d.bitStringContents=c.bitStringContents),d)},u.equals=function(c,f,d){if(y.util.isArray(c)){if(!y.util.isArray(f)||c.length!==f.length)return!1;for(var b=0;b<c.length;++b)if(!u.equals(c[b],f[b]))return!1;return!0}if(typeof c!=typeof f)return!1;if("string"==typeof c)return c===f;var S=c.tagClass===f.tagClass&&c.type===f.type&&c.constructed===f.constructed&&c.composed===f.composed&&u.equals(c.value,f.value);return d&&d.includeBitStringContents&&(S=S&&c.bitStringContents===f.bitStringContents),S},u.getBerValueLength=function(c){var f=c.getByte();if(128!==f)return 128&f?c.getInt((127&f)<<3):f},u.fromDer=function(c,f){void 0===f&&(f={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"==typeof f&&(f={strict:f,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in f||(f.strict=!0),"parseAllBytes"in f||(f.parseAllBytes=!0),"decodeBitStrings"in f||(f.decodeBitStrings=!0),"string"==typeof c&&(c=y.util.createBuffer(c));var d=c.length(),b=m(c,c.length(),0,f);if(f.parseAllBytes&&0!==c.length()){var S=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw S.byteCount=d,S.remaining=c.length(),S}return b},u.toDer=function(c){var f=y.util.createBuffer(),d=c.tagClass|c.type,b=y.util.createBuffer(),S=!1;if("bitStringContents"in c&&(S=!0,c.original&&(S=u.equals(c,c.original))),S)b.putBytes(c.bitStringContents);else if(c.composed){c.constructed?d|=32:b.putByte(0);for(var E=0;E<c.value.length;++E)void 0!==c.value[E]&&b.putBuffer(u.toDer(c.value[E]))}else if(c.type===u.Type.BMPSTRING)for(E=0;E<c.value.length;++E)b.putInt16(c.value.charCodeAt(E));else c.type===u.Type.INTEGER&&c.value.length>1&&(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<f.length;++p){b=!0,S=[],E=parseInt(f[p],10);do{v=127&E,E>>>=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<d.length;++b)d[b].length<2&&(f+="0"),f+=d[b];return f+"Z"},u.dateToGeneralizedTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push(""+c.getUTCFullYear()),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<d.length;++b)d[b].length<2&&(f+="0"),f+=d[b];return f+"Z"},u.integerToDer=function(c){var f=y.util.createBuffer();if(c>=-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&&v<f.value.length;++v)S=f.value[v].optional||!1,c.value[E]&&((S=u.validate(c.value[E],f.value[v],d,b))?++E:f.value[v].optional&&(S=!0)),!S&&b&&b.push("["+f.name+'] Tag class "'+f.tagClass+'", type "'+f.type+'" expected value length "'+f.value.length+'", got "'+c.value.length+'"');if(S&&d&&(f.capture&&(d[f.capture]=c.value),f.captureAsn1&&(d[f.captureAsn1]=c),f.captureBitStringContents&&"bitStringContents"in c&&(d[f.captureBitStringContents]=c.bitStringContents),f.captureBitStringValue&&"bitStringContents"in c))if(c.bitStringContents.length<2)d[f.captureBitStringValue]="";else{if(0!==c.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");d[f.captureBitStringValue]=c.bitStringContents.slice(1)}}else b&&b.push("["+f.name+'] Expected constructed "'+f.constructed+'", got "'+c.constructed+'"');else b&&(c.tagClass!==f.tagClass&&b.push("["+f.name+'] Expected tag class "'+f.tagClass+'", got "'+c.tagClass+'"'),c.type!==f.type&&b.push("["+f.name+'] Expected type "'+f.type+'", got "'+c.type+'"'));return S};var h=/[^\\u0000-\\u00ff]/;u.prettyPrint=function(c,f,d){var b="";d=d||2,(f=f||0)>0&&(b+="\n");for(var S="",E=0;E<f*d;++E)S+=" ";switch(b+=S+"Tag: ",c.tagClass){case u.Class.UNIVERSAL:b+="Universal:";break;case u.Class.APPLICATION:b+="Application:";break;case u.Class.CONTEXT_SPECIFIC:b+="Context-Specific:";break;case u.Class.PRIVATE:b+="Private:"}if(c.tagClass===u.Class.UNIVERSAL)switch(b+=c.type,c.type){case u.Type.NONE:b+=" (None)";break;case u.Type.BOOLEAN:b+=" (Boolean)";break;case u.Type.INTEGER:b+=" (Integer)";break;case u.Type.BITSTRING:b+=" (Bit string)";break;case u.Type.OCTETSTRING:b+=" (Octet string)";break;case u.Type.NULL:b+=" (Null)";break;case u.Type.OID:b+=" (Object Identifier)";break;case u.Type.ODESC:b+=" (Object Descriptor)";break;case u.Type.EXTERNAL:b+=" (External or Instance of)";break;case u.Type.REAL:b+=" (Real)";break;case u.Type.ENUMERATED:b+=" (Enumerated)";break;case u.Type.EMBEDDED:b+=" (Embedded PDV)";break;case u.Type.UTF8:b+=" (UTF8)";break;case u.Type.ROID:b+=" (Relative Object Identifier)";break;case u.Type.SEQUENCE:b+=" (Sequence)";break;case u.Type.SET:b+=" (Set)";break;case u.Type.PRINTABLESTRING:b+=" (Printable String)";break;case u.Type.IA5String:b+=" (IA5String (ASCII))";break;case u.Type.UTCTIME:b+=" (UTC time)";break;case u.Type.GENERALIZEDTIME:b+=" (Generalized time)";break;case u.Type.BMPSTRING:b+=" (BMP String)"}else b+=c.type;if(b+="\n",b+=S+"Constructed: "+c.constructed+"\n",c.composed){var v=0,p="";for(E=0;E<c.value.length;++E)void 0!==c.value[E]&&(v+=1,p+=u.prettyPrint(c.value[E],f+1,d),E+1<c.value.length&&(p+=","));b+=S+"Sub values: "+v+p}else{if(b+=S+"Value: ",c.type===u.Type.OID){var I=u.derToOid(c.value);b+=I,y.pki&&y.pki.oids&&I in y.pki.oids&&(b+=" ("+y.pki.oids[I]+") ")}if(c.type===u.Type.INTEGER)try{b+=u.derToInteger(c.value)}catch{b+="0x"+y.util.bytesToHex(c.value)}else if(c.type===u.Type.BITSTRING){if(b+=c.value.length>1?"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;h<u.length;++h){for(var b=0,S=u[h];b<d.length;++b)d[b]=(S+=d[b]<<8)%c,S=S/c|0;for(;S>0;)d.push(S%c),S=S/c|0}for(h=0;0===u[h]&&h<u.length-1;++h)m+=f;for(h=d.length-1;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;w<u.length();++w){for(var f=0,d=u.at(w);f<c.length;++f)c[f]=(d+=c[f]<<8)%m,d=d/m|0;for(;d>0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===u.at(w)&&w<u.length()-1;++w)b+=h;for(w=c.length-1;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<g.length;++m)w[g.charCodeAt(m)]=m}u=u.replace(/\s/g,"");var h=g.length,c=g.charAt(0),f=[0];for(m=0;m<u.length;m++){var d=w[u.charCodeAt(m)];if(void 0===d)return;for(var b=0,S=d;b<f.length;++b)f[b]=255&(S+=f[b]*h),S>>=8;for(;S>0;)f.push(255&S),S>>=8}for(var E=0;u[E]===c&&E<u.length-1;++E)f.push(0);return typeof Buffer<"u"?Buffer.from(f.reverse()):new Uint8Array(f.reverse())}},6168:(Q,K,x)=>{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;d<f.length;++d)h.putByte(f[d])}if(h.length()<c)throw new Error("Invalid IV length; got "+h.length()+" bytes and expected "+c+" bytes.");if(!y.util.isArray(h)){var b=[],S=c/4;for(d=0;d<S;++d)b.push(h.getInt32());h=b}return h}function w(h){h[h.length-1]=h[h.length-1]+1&4294967295}function m(h){return[h/4294967296|0,4294967295&h]}u.ecb=function(h){h=h||{},this.name="ECB",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.ecb.prototype.start=function(h){},u.ecb.prototype.encrypt=function(h,c,f){if(h.length()<this.blockSize&&!(f&&h.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=h.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),d=0;d<this._ints;++d)c.putInt32(this._outBlock[d])},u.ecb.prototype.decrypt=function(h,c,f){if(h.length()<this.blockSize&&!(f&&h.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=h.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),d=0;d<this._ints;++d)c.putInt32(this._outBlock[d])},u.ecb.prototype.pad=function(h,c){var f=h.length()===this.blockSize?this.blockSize:this.blockSize-h.length();return h.fillWithByte(f,f),!0},u.ecb.prototype.unpad=function(h,c){if(c.overflow>0)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()<this.blockSize&&!(f&&h.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=this._prev[d]^h.getInt32();for(this.cipher.encrypt(this._inBlock,this._outBlock),d=0;d<this._ints;++d)c.putInt32(this._outBlock[d]);this._prev=this._outBlock},u.cbc.prototype.decrypt=function(h,c,f){if(h.length()<this.blockSize&&!(f&&h.length()>0))return!0;for(var d=0;d<this._ints;++d)this._inBlock[d]=h.getInt32();for(this.cipher.decrypt(this._inBlock,this._outBlock),d=0;d<this._ints;++d)c.putInt32(this._prev[d]^this._outBlock[d]);this._prev=this._inBlock.slice(0)},u.cbc.prototype.pad=function(h,c){var f=h.length()===this.blockSize?this.blockSize:this.blockSize-h.length();return h.fillWithByte(f,f),!0},u.cbc.prototype.unpad=function(h,c){if(c.overflow>0)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;b<this._ints;++b)this._inBlock[b]=h.getInt32()^this._outBlock[b],c.putInt32(this._inBlock[b]);else{var S=(this.blockSize-d)%this.blockSize;for(S>0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b<this._ints;++b)this._partialBlock[b]=h.getInt32()^this._outBlock[b],this._partialOutput.putInt32(this._partialBlock[b]);if(S>0)h.read-=this.blockSize;else for(b=0;b<this._ints;++b)this._inBlock[b]=this._partialBlock[b];if(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}},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;b<this._ints;++b)this._inBlock[b]=h.getInt32(),c.putInt32(this._inBlock[b]^this._outBlock[b]);else{var S=(this.blockSize-d)%this.blockSize;for(S>0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b<this._ints;++b)this._partialBlock[b]=h.getInt32(),this._partialOutput.putInt32(this._partialBlock[b]^this._outBlock[b]);if(S>0)h.read-=this.blockSize;else for(b=0;b<this._ints;++b)this._inBlock[b]=this._partialBlock[b];if(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}},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;b<this._ints;++b)c.putInt32(h.getInt32()^this._outBlock[b]),this._inBlock[b]=this._outBlock[b];else{var S=(this.blockSize-d)%this.blockSize;for(S>0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b<this._ints;++b)this._partialOutput.putInt32(h.getInt32()^this._outBlock[b]);if(S>0)h.read-=this.blockSize;else for(b=0;b<this._ints;++b)this._inBlock[b]=this._outBlock[b];if(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}},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;b<this._ints;++b)c.putInt32(h.getInt32()^this._outBlock[b]);else{var S=(this.blockSize-d)%this.blockSize;for(S>0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b<this._ints;++b)this._partialOutput.putInt32(h.getInt32()^this._outBlock[b]);if(S>0&&(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;b<this._ints;++b)c.putInt32(this._outBlock[b]^=h.getInt32());this._cipherLength+=this.blockSize}else{var S=(this.blockSize-d)%this.blockSize;for(S>0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b<this._ints;++b)this._partialOutput.putInt32(h.getInt32()^this._outBlock[b]);if(S<=0||f){if(f){var E=d%this.blockSize;this._cipherLength+=E,this._partialOutput.truncate(this.blockSize-E)}else this._cipherLength+=this.blockSize;for(b=0;b<this._ints;++b)this._outBlock[b]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&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(d<this.blockSize&&!(f&&d>0))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;b<this._ints;++b)c.putInt32(this._outBlock[b]^this._hashBlock[b]);this._cipherLength+=d<this.blockSize?d%this.blockSize:this.blockSize},u.gcm.prototype.afterFinish=function(h,c){var f=!0;c.decrypt&&c.overflow&&h.truncate(this.blockSize-c.overflow),this.tag=y.util.createBuffer();var d=this._aDataLength.concat(m(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,d);var b=[];this.cipher.encrypt(this._j0,b);for(var S=0;S<this._ints;++S)this.tag.putInt32(this._s[S]^b[S]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),c.decrypt&&this.tag.bytes()!==this._tag&&(f=!1),f},u.gcm.prototype.multiply=function(h,c){for(var f=[0,0,0,0],d=c.slice(0),b=0;b<128;++b)h[b/32|0]&1<<31-b%32&&(f[0]^=d[0],f[1]^=d[1],f[2]^=d[2],f[3]^=d[3]),this.pow(d,d);return f},u.gcm.prototype.pow=function(h,c){for(var f=1&h[3],d=3;d>0;--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<b;++E){var v=[0,0,0,0];v[E/d|0]=1<<c-1<<(d-1-E%d)*c,S[E]=this.generateSubHashTable(this.multiply(v,h),c)}return S},u.gcm.prototype.generateSubHashTable=function(h,c){var f=1<<c,d=f>>>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<d;){for(var E=1;E<S;++E){var v=b[S],p=b[E];b[S+E]=[v[0]^p[0],v[1]^p[1],v[2]^p[2],v[3]^p[3]]}S*=2}for(b[0]=[0,0,0,0],S=d+1;S<f;++S){var I=b[S^d];b[S]=[h[0]^I[0],h[1]^I[1],h[2]^I[2],h[3]^I[3]]}return b}},2718:(Q,K,x)=>{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<ne;te++){var oe=p.getInt32(),de=p.getInt32();oe^=(W=252645135&(oe>>>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<ee.length;++he){ee[he]?(oe=oe<<2|oe>>>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;$<D;$+=3){for(var C=T[$+1],O=T[$+2],U=T[$];U!=C;U+=O){var L=F^p[U],H=(F>>>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;S<b.length;++S)d.putByte(b[S])}var E=d.length();for(E>w.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),S=0;S<E;++S)b=d.at(S),m.putByte(54^b),h.putByte(92^b);if(E<w.blockLength)for(b=w.blockLength-E,S=0;S<b;++S)m.putByte(54),h.putByte(92);g=d,m=m.bytes(),h=h.bytes()}w.start(),w.update(m)},update:function(f){w.update(f)},getMac:function(){var f=w.digest().bytes();return w.start(),w.update(h),w.update(f),w.digest()}};return c.digest=c.getMac,c}},3823:(Q,K,x)=>{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<<u)-1,m.prototype.DV=1<<u,m.prototype.FV=Math.pow(2,52),m.prototype.F1=52-u,m.prototype.F2=2*u-52;var v,p,E=new Array;for(v="0".charCodeAt(0),p=0;p<=9;++p)E[v++]=p;for(v="a".charCodeAt(0),p=10;p<36;++p)E[v++]=p;for(v="A".charCodeAt(0),p=10;p<36;++p)E[v++]=p;function I(z){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(z)}function A(z,q){return E[z.charCodeAt(q)]??-1}function T(z){var q=h();return q.fromInt(z),q}function U(z){var J,q=1;return 0!=(J=z>>>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<<z.DB-15)-1,this.mt2=2*z.t}function Ue(z,q){return z&q}function pe(z,q){return z|q}function Le(z,q){return z^q}function at(z,q){return z&~q}function $t(z){if(0==z)return-1;var q=0;return 0==(65535&z)&&(z>>=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<this.m.t;++q){var J=32767&z.data[q],ue=J*this.mpl+((J*this.mph+(z.data[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)-1)<<Oe,this.data[this.t++]=We>>this.DB-Oe):this.data[this.t-1]|=We<<Oe,(Oe+=J)>=this.DB&&(Oe-=this.DB))}8==J&&0!=(128&z[0])&&(this.s=-1,Oe>0&&(this.data[this.t-1]|=(1<<this.DB-Oe)-1<<Oe)),this.clamp(),Re&&m.ZERO.subTo(this,this)},m.prototype.clamp=function k(){for(var z=this.s&this.DM;this.t>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<this.t;++J)q.data[J-z]=this.data[J];q.t=Math.max(this.t-z,0),q.s=this.s},m.prototype.lShiftTo=function G(z,q){var $e,J=z%this.DB,ue=this.DB-J,Re=(1<<ue)-1,Oe=Math.floor(z/this.DB),We=this.s<<J&this.DM;for($e=this.t-1;$e>=0;--$e)q.data[$e+Oe+1]=this.data[$e]>>ue|We,We=(this.data[$e]&Re)<<J;for($e=Oe-1;$e>=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)-1;q.data[0]=this.data[J]>>ue;for(var We=J+1;We<this.t;++We)q.data[We-J-1]|=(this.data[We]&Oe)<<Re,q.data[We-J]=this.data[We]>>ue;ue>0&&(q.data[this.t-J-1]|=(this.s&Oe)<<Re),q.t=this.t-J,q.clamp()}},m.prototype.subTo=function Z(z,q){for(var J=0,ue=0,Re=Math.min(z.t,this.t);J<Re;)ue+=this.data[J]-z.data[J],q.data[J++]=ue&this.DM,ue>>=this.DB;if(z.t<this.t){for(ue-=z.s;J<this.t;)ue+=this.data[J],q.data[J++]=ue&this.DM,ue>>=this.DB;ue+=this.s}else{for(ue+=this.s;J<z.t;)ue-=z.data[J],q.data[J++]=ue&this.DM,ue>>=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<ue.t;++Re)q.data[Re+J.t]=J.am(0,ue.data[Re],q,Re,0,J.t);q.s=0,q.clamp(),this.s!=z.s&&m.ZERO.subTo(q,q)},m.prototype.squareTo=function te(z){for(var q=this.abs(),J=z.t=2*q.t;--J>=0;)z.data[J]=0;for(J=0;J<q.t-1;++J){var ue=q.am(J,q.data[J],z,2*J,0,1);(z.data[J+q.t]+=q.am(J+1,2*q.data[J],z,2*J+1,ue,q.t-J-1))>=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.t<ue.t)return q?.fromInt(0),void(null!=J&&this.copyTo(J));null==J&&(J=h());var Oe=h(),We=this.s,$e=z.s,Zt=this.DB-U(ue.data[ue.t-1]);Zt>0?(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<<this.F1)+(fr>1?Oe.data[fr-2]>>this.F2:0),ns=this.FV/Yr,_o=(1<<this.F1)/Yr,Gt=1<<this.F2,Zr=J.t,dn=Zr-fr,ki=q??h();for(Oe.dlShiftTo(dn,ki),J.compareTo(ki)>=0&&(J.data[J.t++]=1,J.subTo(ki,J)),m.ONE.dlShiftTo(fr,ki),ki.subTo(Oe,Oe);Oe.t<fr;)Oe.data[Oe.t++]=0;for(;--dn>=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))<pu)for(Oe.dlShiftTo(dn,ki),J.subTo(ki,J);J.data[Zr]<--pu;)J.subTo(ki,J)}null!=q&&(J.drShiftTo(fr,q),We!=$e&&m.ZERO.subTo(q,q)),J.t=fr,J.clamp(),Zt>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<<Oe)>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<<q)-1,Re=!1,Oe="",We=this.t,$e=this.DB-We*this.DB%q;if(We-- >0)for($e<this.DB&&(ue=this.data[We]>>$e)>0&&(Re=!0,Oe=I(ue));We>=0;)$e<q?(ue=(this.data[We]&(1<<$e)-1)<<q-$e,ue|=this.data[--We]>>($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<z.length;++$e){var Zt=A(z,$e);Zt<0?"-"==z.charAt($e)&&0==this.signum()&&(Re=!0):(We=q*We+Zt,++Oe>=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<<Re)-1:ue[0]=0,this.fromString(ue,256)}},m.prototype.bitwiseTo=function Xe(z,q,J){var ue,Re,Oe=Math.min(z.t,this.t);for(ue=0;ue<Oe;++ue)J.data[ue]=q(this.data[ue],z.data[ue]);if(z.t<this.t){for(Re=z.s&this.DM,ue=Oe;ue<this.t;++ue)J.data[ue]=q(this.data[ue],Re);J.t=this.t}else{for(Re=this.s&this.DM,ue=Oe;ue<z.t;++ue)J.data[ue]=q(Re,z.data[ue]);J.t=z.t}J.s=q(this.s,z.s),J.clamp()},m.prototype.changeBit=function et(z,q){var J=m.ONE.shiftLeft(z);return this.bitwiseTo(J,q,J),J},m.prototype.addTo=function wi(z,q){for(var J=0,ue=0,Re=Math.min(z.t,this.t);J<Re;)ue+=this.data[J]+z.data[J],q.data[J++]=ue&this.DM,ue>>=this.DB;if(z.t<this.t){for(ue+=z.s;J<this.t;)ue+=this.data[J],q.data[J++]=ue&this.DM,ue>>=this.DB;ue+=this.s}else{for(ue+=this.s;J<z.t;)ue+=z.data[J],q.data[J++]=ue&this.DM,ue>>=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<Re;++ue)J.data[ue+this.t]=this.am(0,z.data[ue],J,ue,0,this.t);for(Re=Math.min(z.t,q);ue<Re;++ue)this.am(0,z.data[ue],J,ue,0,q-ue);J.clamp()},m.prototype.multiplyUpperTo=function Ce(z,q,J){--q;var ue=J.t=this.t+z.t-q;for(J.s=0;--ue>=0;)J.data[ue]=0;for(ue=Math.max(q-this.t,0);ue<z.t;++ue)J.data[this.t+ue-q]=this.am(q-ue,z.data[ue],J,0,0,this.t+ue-q);J.clamp(),J.drShiftTo(1,J)},m.prototype.modInt=function gn(z){if(z<=0)return 0;var q=this.DV%z,J=this.s<0?z-1:0;if(this.t>0)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<z.length;++q)z[q]=Math.floor(256*Math.random())}}}(),We=0;We<z;++We){do{Oe=new m(this.bitLength(),Re)}while(Oe.compareTo(m.ONE)<=0||Oe.compareTo(q)>=0);var $e=Oe.modPow(ue,this);if(0!=$e.compareTo(m.ONE)&&0!=$e.compareTo(q)){for(var Zt=1;Zt++<J&&0!=$e.compareTo(q);)if(0==($e=$e.modPowInt(2,this)).compareTo(m.ONE))return!1;if(0!=$e.compareTo(q))return!1}}return!0},m.prototype.clone=function _n(){var z=h();return this.copyTo(z),z},m.prototype.intValue=function Oi(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},m.prototype.byteValue=function Qr(){return 0==this.t?this.s:this.data[0]<<24>>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<this.DB&&(ue=this.data[z]>>J)!=(this.s&this.DM)>>J&&(q[Re++]=ue|this.s<<this.DB-J);z>=0;)J<8?(ue=(this.data[z]&(1<<J)-1)<<8-J,ue|=this.data[--z]>>(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;++q)z.data[q]=this.DM&~this.data[q];return z.t=this.t,z.s=~this.s,z},m.prototype.shiftLeft=function qe(z){var q=h();return z<0?this.rShiftTo(-z,q):this.lShiftTo(z,q),q},m.prototype.shiftRight=function jn(z){var q=h();return z<0?this.lShiftTo(-z,q):this.rShiftTo(z,q),q},m.prototype.getLowestSetBit=function Tn(){for(var z=0;z<this.t;++z)if(0!=this.data[z])return z*this.DB+$t(this.data[z]);return this.s<0?this.t*this.DB:-1},m.prototype.bitCount=function ot(){for(var z=0,q=this.s&this.DM,J=0;J<this.t;++J)z+=un(this.data[J]^q);return z},m.prototype.testBit=function Dn(z){var q=Math.floor(z/this.DB);return q>=this.t?0!=this.s:0!=(this.data[q]&1<<z%this.DB)},m.prototype.setBit=function Wt(z){return this.changeBit(z,pe)},m.prototype.clearBit=function Et(z){return this.changeBit(z,at)},m.prototype.flipBit=function Ar(z){return this.changeBit(z,Le)},m.prototype.add=function Yn(z){var q=h();return this.addTo(z,q),q},m.prototype.subtract=function Nn(z){var q=h();return this.subTo(z,q),q},m.prototype.multiply=function Br(z){var q=h();return this.multiplyTo(z,q),q},m.prototype.divide=function _r(z){var q=h();return this.divRemTo(z,q,null),q},m.prototype.remainder=function Mn(z){var q=h();return this.divRemTo(z,null,q),q},m.prototype.divideAndRemainder=function jt(z){var q=h(),J=h();return this.divRemTo(z,q,J),new Array(q,J)},m.prototype.modPow=function It(z,q){var ue,Oe,J=z.bitLength(),Re=T(1);if(J<=0)return Re;ue=J<18?1:J<48?3:J<144?4:J<768?5:6,Oe=J<8?new he(q):q.isEven()?new Ke(q):new nt(q);var We=new Array,$e=3,Zt=ue-1,fr=(1<<ue)-1;if(We[1]=Oe.convert(this),ue>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<<J+1)-1)<<Zt-J,Yr>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<<J);)Oe.sqrTo(Re,Gt),Zr=Re,Re=Gt,Gt=Zr,--J<0&&(J=this.DB-1,--Yr)}return Oe.revert(Re)},m.prototype.modInverse=function ts(z){var q=z.isEven();if(this.isEven()&&q||0==z.signum())return m.ZERO;for(var J=z.clone(),ue=this.clone(),Re=T(1),Oe=T(0),We=T(0),$e=T(1);0!=J.signum();){for(;J.isEven();)J.rShiftTo(1,J),q?((!Re.isEven()||!Oe.isEven())&&(Re.addTo(this,Re),Oe.subTo(z,Oe)),Re.rShiftTo(1,Re)):Oe.isEven()||Oe.subTo(z,Oe),Oe.rShiftTo(1,Oe);for(;ue.isEven();)ue.rShiftTo(1,ue),q?((!We.isEven()||!$e.isEven())&&(We.addTo(this,We),$e.subTo(z,$e)),We.rShiftTo(1,We)):$e.isEven()||$e.subTo(z,$e),$e.rShiftTo(1,$e);J.compareTo(ue)>=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(Re<Oe&&(Oe=Re),Oe>0&&(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<qn.length;++q)if(J.data[0]==qn[q])return!0;return!1}if(J.isEven())return!1;for(q=1;q<qn.length;){for(var ue=qn[q],Re=q+1;Re<qn.length&&ue<ia;)ue*=qn[Re++];for(ue=J.modInt(ue);q<Re;)if(ue%qn[q++]==0)return!1}return J.millerRabin(z)}},1877:(Q,K,x)=>{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<f;d++){var b=new y.util.ByteBuffer;b.putInt32(d),g.start(),g.update(m+b.getBytes()),c.putBuffer(g.digest())}return c.truncate(c.length()-h),c.getBytes()}}}},6169:(Q,K,x)=>{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<v.length;M++)C.putInt16(v.charCodeAt(M));C.putInt16(0)}var O=C.length(),U=p.length(),L=new y.util.ByteBuffer;L.fillWithByte(I,F);var H=F*Math.ceil(U/F),ne=new y.util.ByteBuffer;for(M=0;M<H;M++)ne.putByte(p.at(M%U));var G=F*Math.ceil(O/F),ee=new y.util.ByteBuffer;for(M=0;M<G;M++)ee.putByte(C.at(M%O));var Z=ne;Z.putBuffer(ee);for(var W=Math.ceil(P/k),te=1;te<=W;te++){var oe=new y.util.ByteBuffer;oe.putBytes(L.bytes()),oe.putBytes(Z.bytes());for(var de=0;de<A;de++)D.start(),D.update(oe.getBytes()),oe=D.digest();var he=new y.util.ByteBuffer;for(M=0;M<F;M++)he.putByte(oe.at(M%k));var Pe=Math.ceil(U/F)+Math.ceil(O/F),De=new y.util.ByteBuffer;for(T=0;T<Pe;T++){var Be=new y.util.ByteBuffer(Z.getBytes(F)),ve=511;for(M=he.length()-1;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<I;++T,D+=16)P.push(d(A,P[T-1]+v+p));return P.join("").substr(0,I)}},9015:(Q,K,x)=>{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+=T<E?A:A.substr(0,v)}return I}function k(){if(T>E)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<E?A:A.substr(0,v),++T,k()}T=1,k()}},4088:(Q,K,x)=>{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;d<m.values.length;++d)c.push(m.values[d].replace(/^(\S+\r\n)/,f));h+=c.join(",")+"\r\n";var b=0,S=-1;for(d=0;d<h.length;++d,++b)if(b>65&&-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<m.headers.length;++d)c+=g(m.headers[d]);return m.procType&&(c+="\r\n"),(c+=y.util.encode64(m.body,h.maxline||64)+"\r\n")+"-----END "+m.type+"-----\r\n"},u.decode=function(m){for(var b,h=[],c=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,f=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,d=/\r?\n/;b=c.exec(m);){var S=b[1];"NEW CERTIFICATE REQUEST"===S&&(S="CERTIFICATE REQUEST");var E={type:S,procType:null,contentDomain:null,dekInfo:null,headers:[],body:y.util.decode64(b[3])};if(h.push(E),b[2]){for(var v=b[2].split(d),p=0;b&&p<v.length;){for(var I=v[p].replace(/\s+$/,""),A=p+1;A<v.length;++A){var P=v[A];if(!/\s/.test(P[0]))break;I+=P,p=A}if(b=I.match(f)){for(var D={name:b[1],values:[]},T=b[2].split(","),M=0;M<T.length;++M)D.values.push(w(T[M]));if(E.procType)if(E.contentDomain||"Content-Domain"!==D.name)if(E.dekInfo||"DEK-Info"!==D.name)E.headers.push(D);else{if(0===D.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');E.dekInfo={algorithm:T[0],parameters:T[1]||null}}else E.contentDomain=T[0]||"";else{if("Proc-Type"!==D.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==D.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');E.procType={version:T[0],type:T[1]}}}++p}if("ENCRYPTED"===E.procType&&!E.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===h.length)throw new Error("Invalid PEM formatted message.");return h}},5237:(Q,K,x)=>{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<f;++d){var b=String.fromCharCode(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<A;P++)I+="\0";var D=p.getBytes()+I+"\x01"+m;if(f){if(f.length!==d.digestLength){var v;throw(v=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=f.length,v.digestLength=d.digestLength,v}}else f=y.random.getBytes(d.digestLength);var T=g(f,S-d.digestLength-1,b),M=y.util.xorBytes(D,T,D.length),k=g(M,d.digestLength,b),F=y.util.xorBytes(f,k,f.length);return"\0"+F+M},u.decode_rsa_oaep=function(w,m,h){var c,f,d;"string"==typeof h?(c=h,f=arguments[3]||void 0):h&&(c=h.label||void 0,f=h.md||void 0,h.mgf1&&h.mgf1.md&&(d=h.mgf1.md));var b=Math.ceil(w.n.bitLength()/8);if(m.length!==b)throw(M=new Error("RSAES-OAEP encoded message length is invalid.")).length=m.length,M.expectedLength=b,M;if(void 0===f?f=y.md.sha1.create():f.start(),d||(d=f),b<2*f.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");c||(c=""),f.update(c,"raw");for(var S=f.digest().getBytes(),E=m.charAt(0),v=m.substring(1,f.digestLength+1),p=m.substring(1+f.digestLength),I=g(p,f.digestLength,d),A=y.util.xorBytes(v,I,v.length),P=g(A,b-f.digestLength-1,d),D=y.util.xorBytes(p,P,p.length),T=D.substring(0,f.digestLength),M="\0"!==E,k=0;k<f.digestLength;++k)M|=S.charAt(k)!==T.charAt(k);for(var F=1,$=f.digestLength,C=f.digestLength;C<D.length;C++){var O=D.charCodeAt(C),U=1&O^1,L=F?65534:0;M|=O&L,$+=F&=U}if(M||1!==D.charCodeAt($))throw new Error("Invalid RSAES-OAEP padding.");return D.substring($+1)}},6826:(Q,K,x)=>{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;D<A.length;++D)P.push(m(A[D]));return P}function d(A){var P=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.digestAlgorithm).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")])]);if(A.authenticatedAttributesAsn1&&P.value.push(A.authenticatedAttributesAsn1),P.value.push(u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.signatureAlgorithm).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")])),P.value.push(u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,A.signature)),A.unauthenticatedAttributes.length>0){for(var D=u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T<A.unauthenticatedAttributes.length;++T)D.values.push(E(A.unauthenticatedAttributes[T]));P.value.push(D)}return P}function E(A){var P;if(A.type===y.pki.oids.contentType)P=u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.value).getBytes());else if(A.type===y.pki.oids.messageDigest)P=u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,A.value.bytes());else if(A.type===y.pki.oids.signingTime){var D=new Date("1950-01-01T00:00:00Z"),T=new Date("2050-01-01T00:00:00Z"),M=A.value;if("string"==typeof M){var k=Date.parse(M);M=isNaN(k)?13===M.length?u.utcTimeToDate(M):u.generalizedTimeToDate(M):new Date(k)}P=M>=D&&M<T?u.create(u.Class.UNIVERSAL,u.Type.UTCTIME,!1,u.dateToUtcTime(M)):u.create(u.Class.UNIVERSAL,u.Type.GENERALIZEDTIME,!1,u.dateToGeneralizedTime(M))}return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.type).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SET,!0,[P])])}function v(A){return[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(y.pki.oids.data).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.algorithm).getBytes()),A.parameter?u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,A.parameter.getBytes()):void 0]),u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,A.content.getBytes())])]}function p(A,P,D){var T={};if(!u.validate(P,D,T,[])){var k=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw k.errors=k,k}if(u.derToOid(T.contentType)!==y.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(T.encryptedContent){var $="";if(y.util.isArray(T.encryptedContent))for(var C=0;C<T.encryptedContent.length;++C){if(T.encryptedContent[C].type!==u.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");$+=T.encryptedContent[C].value}else $=T.encryptedContent;A.encryptedContent={algorithm:u.derToOid(T.encAlgorithm),parameter:y.util.createBuffer(T.encParameter.value),content:y.util.createBuffer($)}}if(T.content){if($="",y.util.isArray(T.content))for(C=0;C<T.content.length;++C){if(T.content[C].type!==u.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");$+=T.content[C].value}else $=T.content;A.content=y.util.createBuffer($)}return A.version=T.version.charCodeAt(0),A.rawCapture=T,T}function I(A){if(void 0===A.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===A.content){var P;switch(A.encryptedContent.algorithm){case y.pki.oids["aes128-CBC"]:case y.pki.oids["aes192-CBC"]:case y.pki.oids["aes256-CBC"]:P=y.aes.createDecryptionCipher(A.encryptedContent.key);break;case y.pki.oids.desCBC:case y.pki.oids["des-EDE3-CBC"]:P=y.des.createDecryptionCipher(A.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+A.encryptedContent.algorithm)}if(P.start(A.encryptedContent.parameter),P.update(A.encryptedContent.content),!P.finish())throw new Error("Symmetric decryption failed.");A.content=P.output}}g.messageFromPem=function(A){var P=y.pem.decode(A)[0];if("PKCS7"!==P.type){var D=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw D.headerType=P.type,D}if(P.procType&&"ENCRYPTED"===P.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var T=u.fromDer(P.body);return g.messageFromAsn1(T)},g.messageToPem=function(A,P){var D={type:"PKCS7",body:u.toDer(A.toAsn1()).getBytes()};return y.pem.encode(D,{maxline:P})},g.messageFromAsn1=function(A){var P={},D=[];if(!u.validate(A,g.asn1.contentInfoValidator,P,D)){var T=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw T.errors=D,T}var k,M=u.derToOid(P.contentType);switch(M){case y.pki.oids.envelopedData:k=g.createEnvelopedData();break;case y.pki.oids.encryptedData:k=g.createEncryptedData();break;case y.pki.oids.signedData:k=g.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+M+" is not (yet) supported.")}return k.fromAsn1(P.content.value[0]),k},g.createSignedData=function(){var A=null;return A={type:y.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(T){if(p(A,T,g.asn1.signedDataValidator),A.certificates=[],A.crls=[],A.digestAlgorithmIdentifiers=[],A.contentInfo=null,A.signerInfos=[],A.rawCapture.certificates)for(var M=A.rawCapture.certificates.value,k=0;k<M.length;++k)A.certificates.push(y.pki.certificateFromAsn1(M[k]))},toAsn1:function(){A.contentInfo||A.sign();for(var T=[],M=0;M<A.certificates.length;++M)T.push(y.pki.certificateToAsn1(A.certificates[M]));var k=[],F=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[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.SET,!0,A.digestAlgorithmIdentifiers),A.contentInfo])]);return T.length>0&&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<O.length;++H){var ne=O[H];if(U||ne.type!==y.pki.oids.contentType){if(L||ne.type!==y.pki.oids.messageDigest);else if(L=!0,U)break}else if(U=!0,L)break}if(!U||!L)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}A.signers.push({key:$,version:1,issuer:M,serialNumber:k,digestAlgorithm:C,signatureAlgorithm:y.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:O,unauthenticatedAttributes:[]})},sign:function(T){var M;if(T=T||{},"object"==typeof A.content&&null!==A.contentInfo||(A.contentInfo=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(y.pki.oids.data).getBytes())]),!("content"in A))||(A.content instanceof y.util.ByteBuffer?M=A.content.bytes():"string"==typeof A.content&&(M=y.util.encodeUtf8(A.content)),T.detached?A.detachedContent=u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,M):A.contentInfo.value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,M)]))),0!==A.signers.length){var k=function P(){for(var T={},M=0;M<A.signers.length;++M){var k=A.signers[M];(F=k.digestAlgorithm)in T||(T[F]=y.md[y.pki.oids[F]].create()),k.md=0===k.authenticatedAttributes.length?T[F]:y.md[y.pki.oids[F]].create()}for(var F in A.digestAlgorithmIdentifiers=[],T)A.digestAlgorithmIdentifiers.push(u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(F).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")]));return T}();!function D(T){var M;if(!(M=A.detachedContent?A.detachedContent:(M=A.contentInfo.value[1]).value[0]))throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var k=u.derToOid(A.contentInfo.value[0].value),F=u.toDer(M);for(var $ in F.getByte(),u.getBerValueLength(F),F=F.getBytes(),T)T[$].start().update(F);for(var C=new Date,O=0;O<A.signers.length;++O){var U=A.signers[O];if(0===U.authenticatedAttributes.length){if(k!==y.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{U.authenticatedAttributesAsn1=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var L=u.create(u.Class.UNIVERSAL,u.Type.SET,!0,[]),H=0;H<U.authenticatedAttributes.length;++H){var ne=U.authenticatedAttributes[H];ne.type===y.pki.oids.messageDigest?ne.value=T[U.digestAlgorithm].digest():ne.type===y.pki.oids.signingTime&&(ne.value||(ne.value=C)),L.value.push(E(ne)),U.authenticatedAttributesAsn1.value.push(E(ne))}F=u.toDer(L).getBytes(),U.md.start().update(F)}U.signature=U.key.sign(U.md,"RSASSA-PKCS1-V1_5")}A.signerInfos=function S(A){for(var P=[],D=0;D<A.length;++D)P.push(d(A[D]));return P}(A.signers)}(k)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(T){"string"==typeof T&&(T=y.pki.certificateFromPem(T)),A.certificates.push(T)},addCertificateRevokationList:function(T){throw new Error("PKCS#7 CRL support not yet implemented.")}}},g.createEncryptedData=function(){var A=null;return A={type:y.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:y.pki.oids["aes256-CBC"]},fromAsn1:function(P){p(A,P,g.asn1.encryptedDataValidator)},decrypt:function(P){void 0!==P&&(A.encryptedContent.key=P),I(A)}}},g.createEnvelopedData=function(){var A=null;return A={type:y.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:y.pki.oids["aes256-CBC"]},fromAsn1:function(P){var D=p(A,P,g.asn1.envelopedDataValidator);A.recipients=function h(A){for(var P=[],D=0;D<A.length;++D)P.push(w(A[D]));return P}(D.recipientInfos.value)},toAsn1:function(){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.type).getBytes()),u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[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.SET,!0,c(A.recipients)),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,v(A.encryptedContent))])])])},findRecipient:function(P){for(var D=P.issuer.attributes,T=0;T<A.recipients.length;++T){var M=A.recipients[T],k=M.issuer;if(M.serialNumber===P.serialNumber&&k.length===D.length){for(var F=!0,$=0;$<D.length;++$)if(k[$].type!==D[$].type||k[$].value!==D[$].value){F=!1;break}if(F)return M}}return null},decrypt:function(P,D){if(void 0===A.encryptedContent.key&&void 0!==P&&void 0!==D)switch(P.encryptedContent.algorithm){case y.pki.oids.rsaEncryption:case y.pki.oids.desCBC:var T=D.decrypt(P.encryptedContent.content);A.encryptedContent.key=y.util.createBuffer(T);break;default:throw new Error("Unsupported asymmetric cipher, OID "+P.encryptedContent.algorithm)}I(A)},addRecipient:function(P){A.recipients.push({version:0,issuer:P.issuer.attributes,serialNumber:P.serialNumber,encryptedContent:{algorithm:y.pki.oids.rsaEncryption,key:P.publicKey}})},encrypt:function(P,D){if(void 0===A.encryptedContent.content){var T,M,k;switch(P=P||A.encryptedContent.key,D=D||A.encryptedContent.algorithm){case y.pki.oids["aes128-CBC"]:T=16,M=16,k=y.aes.createEncryptionCipher;break;case y.pki.oids["aes192-CBC"]:T=24,M=16,k=y.aes.createEncryptionCipher;break;case y.pki.oids["aes256-CBC"]:T=32,M=16,k=y.aes.createEncryptionCipher;break;case y.pki.oids["des-EDE3-CBC"]:T=24,M=8,k=y.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+D)}if(void 0===P)P=y.util.createBuffer(y.random.getBytes(T));else if(P.length()!=T)throw new Error("Symmetric key has wrong length; got "+P.length()+" bytes, expected "+T+".");A.encryptedContent.algorithm=D,A.encryptedContent.key=P,A.encryptedContent.parameter=y.util.createBuffer(y.random.getBytes(M));var F=k(P);if(F.start(A.encryptedContent.parameter.copy()),F.update(A.content),!F.finish())throw new Error("Symmetric encryption failed.");A.encryptedContent.content=F.output}for(var $=0;$<A.recipients.length;++$){var C=A.recipients[$];if(void 0===C.encryptedContent.content){if(C.encryptedContent.algorithm!==y.pki.oids.rsaEncryption)throw new Error("Unsupported asymmetric cipher, OID "+C.encryptedContent.algorithm);C.encryptedContent.content=C.encryptedContent.key.encrypt(A.encryptedContent.key.data)}}}}}},3341:(Q,K,x)=>{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;C<D;++C)$[C]=new Worker(k);for(C=0;C<D;++C)$[C].addEventListener("message",L);var U=!1;function L(H){if(!U){var ne=H.data;if(ne.found){for(var G=0;G<$.length;++G)$[G].terminate();return U=!0,A(null,new g(ne.prime,16))}P.bitLength()>v&&(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;k<T.length;++k)T[k]=M.charCodeAt(k)}},A.options,I);throw new Error("Invalid prime generation algorithm: "+A.name)}}function f(v,p,I,A){var P=S(v,p),T=function E(v){return v<=100?27:v<=150?18:v<=200?15:v<=250?12:v<=300?9:v<=350?8:v<=400?7:v<=500?6:v<=600?5:v<=800?4:v<=1250?3:2}(P.bitLength());"millerRabinTests"in I&&(T=I.millerRabinTests);var M=10;"maxBlockTime"in I&&(M=I.maxBlockTime),d(P,v,p,0,T,M,A)}function d(v,p,I,A,P,D,T){var M=+new Date;do{if(v.bitLength()>p&&(v=S(p,I)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(D<0||+new Date-M<D);y.util.setImmediate(function(){d(v,p,I,A,P,D,T)})}function S(v,p){var I=new g(v,p),A=v-1;return I.testBit(A)||I.bitwiseTo(g.ONE.shiftLeft(A),h,I),I.dAddOffset(31-I.mod(m).byteValue(),0),I}}()},1015:(Q,K,x)=>{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()<v;){var D=Math.max(1,Math.min(v-P.length(),65536)/4),T=new Uint32Array(Math.floor(D));try{p(T);for(var M=0;M<T.length;++M)P.putInt32(T[M])}catch(O){if(!(typeof QuotaExceededError<"u"&&O instanceof QuotaExceededError))throw O}}if(P.length()<v)for(var k,F,$,C=Math.floor(65536*Math.random());P.length()<v;)for(F=16807*(65535&C),F+=(32767&(k=16807*(C>>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()<v;){m.generated>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<p;++I)m.pools[m.pool].update(v.substr(I,1)),m.pool=31===m.pool?0:m.pool+1},m.collectInt=function(v,p){for(var I="",A=0;A<p;A+=8)I+=String.fromCharCode(v>>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<h+f+2)throw new Error("Message is too long to encrypt.");P=null===c?d.getBytesSync(f):c.bytes();var D=new y.util.ByteBuffer;D.fillWithByte(0,8),D.putBytes(A),D.putBytes(P),w.start(),w.update(D.getBytes());var T=w.digest().getBytes(),M=new y.util.ByteBuffer;M.fillWithByte(0,I-f-h-2),M.putByte(1),M.putBytes(P);var k=M.getBytes(),F=I-h-1,$=m.generate(T,F),C="";for(v=0;v<F;v++)C+=String.fromCharCode(k.charCodeAt(v)^$.charCodeAt(v));var O=65280>>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<h+f+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==E.charCodeAt(A-1))throw new Error("Encoded message does not end in 0xBC.");var P=A-h-1,D=E.substr(0,P),T=E.substr(P,h),M=65280>>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<P;p++)F+=String.fromCharCode(D.charCodeAt(p)^k.charCodeAt(p));F=String.fromCharCode(F.charCodeAt(0)&~M)+F.substr(1);var $=A-h-f-2;for(p=0;p<$;p++)if(0!==F.charCodeAt(p))throw new Error("Leftmost octets not zero as expected");if(1!==F.charCodeAt($))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var C=F.substr(-f),O=new y.util.ByteBuffer;return O.fillWithByte(0,8),O.putBytes(S),O.putBytes(C),w.start(),w.update(O.getBytes()),T===w.digest().getBytes()}};return b}},9111:(Q,K,x)=>{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<<f&65535|(65535&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<k.length;C++)for(var O=0;O<k[C][0];O++)k[C][1](F);for(A=0;A<4;A++)null!==v&&(d?v.putInt16Le(F[A]):F[A]^=v.getInt16Le()),E.putInt16Le(F[A])},M=null;return M={start:function(k,F){k&&"string"==typeof k&&(k=y.util.createBuffer(k)),b=!1,S=y.util.createBuffer(),E=F||new y.util.createBuffer,v=k,M.output=E},update:function(k){for(b||S.putBuffer(k);S.length()>=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;oe<W;++oe)G.putByte(te)}else for(;W>0;){var de=0,he=y.random.getBytes(W);for(oe=0;oe<W;++oe)0===(te=he.charCodeAt(oe))?++de:G.putByte(te);W=de}return G.putByte(0),G.putBytes(L),G}function A(L,H,ne,G){var ee=Math.ceil(H.n.bitLength()/8),Z=y.util.createBuffer(L),W=Z.getByte(),te=Z.getByte();if(0!==W||ne&&0!==te&&1!==te||!ne&&2!=te||ne&&0===te&&typeof G>"u")throw new Error("Encryption block is invalid.");var oe=0;if(0===te){oe=ee-3-G;for(var de=0;de<oe;++de)if(0!==Z.getByte())throw new Error("Encryption block is invalid.")}else if(1===te)for(oe=0;Z.length()>1;){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;G<H.length;++G)ne[G]=H.charCodeAt(G);return ne}h.rsa.encrypt=function(L,H,ne){var ee,G=ne,Z=Math.ceil(H.n.bitLength()/8);!1!==ne&&!0!==ne?(G=2===ne,ee=I(L,H,ne)):(ee=y.util.createBuffer()).putBytes(L);for(var W=new u(ee.toHex(),16),oe=p(W,H,G).toString(16),de=y.util.createBuffer(),he=Z-Math.ceil(oe.length/2);he>0;)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<te.length;++de)te[de]=oe.charCodeAt(de)}},Z=ne.algorithm||"PRIMEINC";if("PRIMEINC"!==Z)throw new Error("Invalid key generation algorithm: "+Z);return(W={algorithm:Z,state:0,bits:L,rng:ee,eInt:H||65537,e:new u(null),p:null,q:null,qBits:L>>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||te<H);){if(0===L.state){var oe=null===L.p?L.pBits:L.qBits,de=oe-1;0===L.pqState?(L.num=new u(oe,L.rng),L.num.testBit(de)||L.num.bitwiseTo(u.ONE.shiftLeft(de),ee,L.num),L.num.dAddOffset(31-L.num.mod(ne).byteValue(),0),G=0,++L.pqState):1===L.pqState?L.num.bitLength()>oe?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<S;++E)b.fullMessageLength.push(0);return f=y.util.createBuffer(),c={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},b}};return b.start(),b.update=function(S,E){"utf8"===E&&(S=y.util.encodeUtf8(S));var v=S.length;b.messageLength+=v,v=[v/4294967296>>>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<b.fullMessageLength.length-1;++P)S.putInt32((A+=(p=8*b.fullMessageLength[P+1])/4294967296>>>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<E;++v)S.fullMessageLength.push(0);return d=y.util.createBuffer(),f={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},S}};return S.start(),S.update=function(E,v){"utf8"===v&&(E=y.util.encodeUtf8(E));var p=E.length;S.messageLength+=p,p=[p/4294967296>>>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<S.fullMessageLength.length-1;++D)E.putInt32((P+=(I=8*S.fullMessageLength[D+1])/4294967296>>>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<D;++T)P.fullMessageLength.push(0);for(v=y.util.createBuffer(),E=new Array(S.length),T=0;T<S.length;++T)E[T]=S[T].slice(0);return P}};return P.start(),P.update=function(D,T){"utf8"===T&&(D=y.util.encodeUtf8(D));var M=D.length;P.messageLength+=M,M=[M/4294967296>>>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<P.fullMessageLength.length-1;++C)D.putInt32(($+=(k=8*P.fullMessageLength[C+1])/4294967296>>>0)>>>0),$=k>>>0;D.putInt32($);var O=new Array(E.length);for(C=0;C<E.length;++C)O[C]=E[C].slice(0);d(O,p,D);var L,U=y.util.createBuffer();for(L="SHA-512"===b?O.length:"SHA-384"===b?O.length-2:O.length-4,C=0;C<L;++C)U.putInt32(O[C][0]),(C!==L-1||"SHA-512/224"!==b)&&U.putInt32(O[C][1]);return U},P};var w=null,m=!1,h=null,c=null;function d(b,S,E){for(var v,p,I,A,O,U,L,H,ne,G,ee,Z,W,te,oe,de,he,Pe,De,Be,ve,He,ke,nt,Pt,_t,Vt,Yt=E.length();Yt>=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;M<T.length;++M)this.putByte(T[M])}}else(D instanceof m||"object"==typeof D&&"string"==typeof D.data&&"number"==typeof D.read)&&(this.data=D.data,this.read=D.read);this._constructedStringLength=0}(function(){if(typeof process<"u"&&process.nextTick&&!process.browser)return g.nextTick=process.nextTick,void(g.setImmediate="function"==typeof setImmediate?setImmediate:g.nextTick);if("function"==typeof setImmediate)return g.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(g.nextTick=function(O){return setImmediate(O)});if(g.setImmediate=function(O){setTimeout(O,0)},typeof window<"u"&&"function"==typeof window.postMessage){let O=function(U){if(U.source===window&&U.data===D){U.stopPropagation();var L=T.slice();T.length=0,L.forEach(function(H){H()})}};var D="forge.setImmediate",T=[];g.setImmediate=function(U){T.push(U),1===T.length&&window.postMessage(D,"*")},window.addEventListener("message",O,!0)}if(typeof MutationObserver<"u"){var M=Date.now(),k=!0,F=document.createElement("div");T=[],new MutationObserver(function(){var U=T.slice();T.length=0,U.forEach(function(L){L()})}).observe(F,{attributes:!0});var $=g.setImmediate;g.setImmediate=function(U){Date.now()-M>15?(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<<T-1),this.putInt(D,T)},g.ByteStringBuffer.prototype.putBuffer=function(D){return this.putBytes(D.getBytes())},g.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},g.ByteStringBuffer.prototype.getInt16=function(){var D=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,D},g.ByteStringBuffer.prototype.getInt24=function(){var D=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,D},g.ByteStringBuffer.prototype.getInt32=function(){var D=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,D},g.ByteStringBuffer.prototype.getInt16Le=function(){var D=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,D},g.ByteStringBuffer.prototype.getInt24Le=function(){var D=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,D},g.ByteStringBuffer.prototype.getInt32Le=function(){var D=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,D},g.ByteStringBuffer.prototype.getInt=function(D){w(D);var T=0;do{T=(T<<8)+this.data.charCodeAt(this.read++),D-=8}while(D>0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<<D-2;return T>=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<this.data.length;++T){var M=this.data.charCodeAt(T);M<16&&(D+="0"),D+=M.toString(16)}return D},g.ByteStringBuffer.prototype.toString=function(){return g.decodeUtf8(this.bytes())},g.DataBuffer=function c(D,T){this.read=(T=T||{}).readOffset||0,this.growSize=T.growSize||1024;var M=g.isArrayBuffer(D),k=g.isArrayBufferView(D);if(M||k)return this.data=M?new DataView(D):new DataView(D.buffer,D.byteOffset,D.byteLength),void(this.write="writeOffset"in T?T.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=D&&this.putBytes(D),"writeOffset"in T&&(this.write=T.writeOffset)},g.DataBuffer.prototype.length=function(){return this.write-this.read},g.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},g.DataBuffer.prototype.accommodate=function(D,T){if(this.length()>=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<T;++M)this.data.setUint8(D);return this},g.DataBuffer.prototype.putBytes=function(D,T){if(g.isArrayBufferView(D)){var k=(M=new Uint8Array(D.buffer,D.byteOffset,D.byteLength)).byteLength-M.byteOffset;return this.accommodate(k),new Uint8Array(this.data.buffer,this.write).set(M),this.write+=k,this}if(g.isArrayBuffer(D)){var M=new Uint8Array(D);return this.accommodate(M.byteLength),new Uint8Array(this.data.buffer).set(M,this.write),this.write+=M.byteLength,this}if(D instanceof g.DataBuffer||"object"==typeof D&&"number"==typeof D.read&&"number"==typeof D.write&&g.isArrayBufferView(D.data))return M=new Uint8Array(D.data.byteLength,D.read,D.length()),this.accommodate(M.byteLength),new Uint8Array(D.data.byteLength,this.write).set(M),this.write+=M.byteLength,this;if(D instanceof g.ByteStringBuffer&&(D=D.data,T="binary"),T=T||"binary","string"==typeof D){var $;if("hex"===T)return this.accommodate(Math.ceil(D.length/2)),$=new Uint8Array(this.data.buffer,this.write),this.write+=g.binary.hex.decode(D,$,this.write),this;if("base64"===T)return this.accommodate(3*Math.ceil(D.length/4)),$=new Uint8Array(this.data.buffer,this.write),this.write+=g.binary.base64.decode(D,$,this.write),this;if("utf8"===T&&(D=g.encodeUtf8(D),T="binary"),"binary"===T||"raw"===T)return this.accommodate(D.length),$=new Uint8Array(this.data.buffer,this.write),this.write+=g.binary.raw.decode($),this;if("utf16"===T)return this.accommodate(2*D.length),$=new Uint16Array(this.data.buffer,this.write),this.write+=g.text.utf16.encode($),this;throw new Error("Invalid encoding: "+T)}throw Error("Invalid parameter: "+D)},g.DataBuffer.prototype.putBuffer=function(D){return this.putBytes(D),D.clear(),this},g.DataBuffer.prototype.putString=function(D){return this.putBytes(D,"utf16")},g.DataBuffer.prototype.putInt16=function(D){return this.accommodate(2),this.data.setInt16(this.write,D),this.write+=2,this},g.DataBuffer.prototype.putInt24=function(D){return this.accommodate(3),this.data.setInt16(this.write,D>>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<<T-1),this.putInt(D,T)},g.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},g.DataBuffer.prototype.getInt16=function(){var D=this.data.getInt16(this.read);return this.read+=2,D},g.DataBuffer.prototype.getInt24=function(){var D=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,D},g.DataBuffer.prototype.getInt32=function(){var D=this.data.getInt32(this.read);return this.read+=4,D},g.DataBuffer.prototype.getInt16Le=function(){var D=this.data.getInt16(this.read,!0);return this.read+=2,D},g.DataBuffer.prototype.getInt24Le=function(){var D=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,D},g.DataBuffer.prototype.getInt32Le=function(){var D=this.data.getInt32(this.read,!0);return this.read+=4,D},g.DataBuffer.prototype.getInt=function(D){w(D);var T=0;do{T=(T<<8)+this.data.getInt8(this.read++),D-=8}while(D>0);return T},g.DataBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<<D-2;return T>=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;T<this.data.byteLength;++T){var M=this.data.getUint8(T);M<16&&(D+="0"),D+=M.toString(16)}return D},g.DataBuffer.prototype.toString=function(D){var T=new Uint8Array(this.data,this.read,this.length());if("binary"===(D=D||"utf8")||"raw"===D)return g.binary.raw.encode(T);if("hex"===D)return g.binary.hex.encode(T);if("base64"===D)return g.binary.base64.encode(T);if("utf8"===D)return g.text.utf8.decode(T);if("utf16"===D)return g.text.utf16.decode(T);throw new Error("Invalid encoding: "+D)},g.createBuffer=function(D,T){return T=T||"raw",void 0!==D&&"utf8"===T&&(D=g.encodeUtf8(D)),new g.ByteBuffer(D)},g.fillString=function(D,T){for(var M="";T>0;)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<D.length;M+=2)T+=String.fromCharCode(parseInt(D.substr(M,2),16));return T},g.bytesToHex=function(D){return g.createBuffer(D).toHex()},g.int32ToBytes=function(D){return String.fromCharCode(D>>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<D.length;)F=D.charCodeAt(O++),$=D.charCodeAt(O++),C=D.charCodeAt(O++),M+=f.charAt(F>>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<D.length;)M=d[D.charCodeAt(C++)-43],k=d[D.charCodeAt(C++)-43],F=d[D.charCodeAt(C++)-43],$=d[D.charCodeAt(C++)-43],T+=String.fromCharCode(M<<2|k>>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;$<D.length;++$)k[F++]=D.charCodeAt($);return T?F-M:k},g.binary.hex.encode=g.bytesToHex,g.binary.hex.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(Math.ceil(D.length/2)));var F=0,$=M=M||0;for(1&D.length&&(F=1,k[$++]=parseInt(D[0],16));F<D.length;F+=2)k[$++]=parseInt(D.substr(F,2),16);return T?$-M:k},g.binary.base64.encode=function(D,T){for(var F,$,C,M="",k="",O=0;O<D.byteLength;)F=D[O++],$=D[O++],C=D[O++],M+=f.charAt(F>>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<D.length;)F=d[D.charCodeAt(U++)-43],$=d[D.charCodeAt(U++)-43],C=d[D.charCodeAt(U++)-43],O=d[D.charCodeAt(U++)-43],k[L++]=F<<2|$>>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;$<D.length;++$)k[F++]=D.charCodeAt($);return T?F-M:k},g.text.utf8.decode=function(D){return g.decodeUtf8(String.fromCharCode.apply(null,D))},g.text.utf16.encode=function(D,T,M){var k=T;k||(k=new Uint8Array(2*D.length));for(var F=new Uint16Array(k.buffer),$=M=M||0,C=M,O=0;O<D.length;++O)F[C++]=D.charCodeAt(O),$+=2;return T?$-M:k},g.text.utf16.decode=function(D){return String.fromCharCode.apply(null,new Uint16Array(D.buffer))},g.deflate=function(D,T,M){if(T=g.decode64(D.deflate(g.encode64(T)).rval),M){var k=2;32&T.charCodeAt(1)&&(k=6),T=T.substring(k,T.length-4)}return T},g.inflate=function(D,T,M){var k=D.inflate(g.encode64(T)).rval;return null===k?null:g.decode64(k)};var S=function(D,T,M){if(!D)throw new Error("WebStorage not available.");var k;if(null===M?k=D.removeItem(T):(M=g.encode64(JSON.stringify(M)),k=D.setItem(T,M)),typeof k<"u"&&!0!==k.rval){var F=new Error(k.error.message);throw F.id=k.error.id,F.name=k.error.name,F}},E=function(D,T){if(!D)throw new Error("WebStorage not available.");var M=D.getItem(T);if(D.init)if(null===M.rval){if(M.error){var k=new Error(M.error.message);throw k.id=M.error.id,k.name=M.error.name,k}M=null}else M=M.rval;return null!==M&&(M=JSON.parse(g.decode64(M))),M},v=function(D,T,M,k){var F=E(D,T);null===F&&(F={}),F[M]=k,S(D,T,F)},p=function(D,T,M){var k=E(D,T);return null!==k&&(k=M in k?k[M]:null),k},I=function(D,T,M){var k=E(D,T);if(null!==k&&M in k){delete k[M];var F=!0;for(var $ in k){F=!1;break}F&&(k=null),S(D,T,k)}},A=function(D,T){S(D,T,null)},P=function(D,T,M){var k=null;typeof M>"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<arguments.length?arguments[1+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;M<D.length;++M){var k=parseInt(D[M],10);if(isNaN(k))return null;T.putByte(k)}return T.getBytes()},g.bytesFromIPv6=function(D){for(var T=0,M=2*(8-(D=D.split(":").filter(function(C){return 0===C.length&&++T,!0})).length+T),k=g.createBuffer(),F=0;F<8;++F)if(D[F]&&0!==D[F].length){var $=g.hexToBytes(D[F]);$.length<2&&k.putByte(0),k.putBytes($)}else k.fillWithByte(0,M),M=0;return k.getBytes()},g.bytesToIP=function(D){return 4===D.length?g.bytesToIPv4(D):16===D.length?g.bytesToIPv6(D):null},g.bytesToIPv4=function(D){if(4!==D.length)return null;for(var T=[],M=0;M<D.length;++M)T.push(D.charCodeAt(M));return T.join(".")},g.bytesToIPv6=function(D){if(16!==D.length)return null;for(var T=[],M=[],k=0,F=0;F<D.length;F+=2){for(var $=g.bytesToHex(D[F]+D[F+1]);"0"===$[0]&&"0"!==$;)$=$.substr(1);if("0"===$){var C=M[M.length-1],O=T.length;C&&O===C.end+1?(C.end=O,C.end-C.start>M[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()<U;);self.postMessage({st:O,et:U})})}.toString(),")()"],{type:"application/javascript"}));!function k(C,O,U){if(0===O){var L=Math.floor(C.reduce(function(H,ne){return H+ne},0)/C.length);return g.cores=Math.max(1,L),URL.revokeObjectURL(M),T(null,g.cores)}!function F(C,O){for(var U=[],L=[],H=0;H<C;++H){var ne=new Worker(M);ne.addEventListener("message",function(G){if(L.push(G.data),L.length===C){for(var ee=0;ee<C;++ee)U[ee].terminate();O(null,L)}}),U.push(ne)}for(H=0;H<C;++H)U[H].postMessage(H)}(U,function(H,ne){C.push(function $(C,O){for(var U=[],L=0;L<C;++L)for(var H=O[L],ne=U[L]=[],G=0;G<C;++G)if(L!==G){var ee=O[G];(H.st>ee.st&&H.st<ee.et||ee.st>H.st&&ee.st<H.et)&&ne.push(G)}return U.reduce(function(Z,W){return Math.max(Z,W.length)},0)}(U,ne)),k(C,O-1,U)})}([],5,16)}},3911:(Q,K,x)=>{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<C.attributes.length;++H)L=C.attributes[H],(O.type&&O.type===L.type||O.name&&O.name===L.name||O.shortName&&O.shortName===L.shortName)&&(U=L);return U}g.RDNAttributesAsArray=function(C,O){for(var L,H,ne,U=[],G=0;G<C.value.length;++G){L=C.value[G];for(var ee=0;ee<L.value.length;++ee)(ne={}).type=u.derToOid((H=L.value[ee]).value[0].value),ne.value=H.value[1].value,ne.valueTagClass=H.value[1].type,ne.type in w&&(ne.name=w[ne.type],ne.name in m&&(ne.shortName=m[ne.name])),O&&(O.update(ne.type),O.update(ne.value)),U.push(ne)}return U},g.CRIAttributesAsArray=function(C){for(var O=[],U=0;U<C.length;++U)for(var L=C[U],H=u.derToOid(L.value[0].value),ne=L.value[1].value,G=0;G<ne.length;++G){var ee={};if(ee.type=H,ee.value=ne[G].value,ee.valueTagClass=ne[G].type,ee.type in w&&(ee.name=w[ee.type],ee.name in m&&(ee.shortName=m[ee.name])),ee.type===w.extensionRequest){ee.extensions=[];for(var Z=0;Z<ee.value.length;++Z)ee.extensions.push(g.certificateExtensionFromAsn1(ee.value[Z]))}O.push(ee)}return O};var E=function(C,O,U){var L={};if(C!==w["RSASSA-PSS"])return L;U&&(L={hash:{algorithmOid:w.sha1},mgf:{algorithmOid:w.mgf1,hash:{algorithmOid:w.sha1}},saltLength:20});var H={},ne=[];if(!u.validate(O,f,H,ne)){var G=new Error("Cannot read RSASSA-PSS parameter block.");throw G.errors=ne,G}return void 0!==H.hashOid&&(L.hash=L.hash||{},L.hash.algorithmOid=u.derToOid(H.hashOid)),void 0!==H.maskGenOid&&(L.mgf=L.mgf||{},L.mgf.algorithmOid=u.derToOid(H.maskGenOid),L.mgf.hash=L.mgf.hash||{},L.mgf.hash.algorithmOid=u.derToOid(H.maskGenHashOid)),void 0!==H.saltLength&&(L.saltLength=H.saltLength.charCodeAt(0)),L},v=function(C){switch(w[C.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return y.md.sha1.create();case"md5WithRSAEncryption":return y.md.md5.create();case"sha256WithRSAEncryption":case"RSASSA-PSS":return y.md.sha256.create();case"sha384WithRSAEncryption":return y.md.sha384.create();case"sha512WithRSAEncryption":return y.md.sha512.create();default:var O=new Error("Could not compute "+C.type+" digest. Unknown signature OID.");throw O.signatureOid=C.signatureOid,O}},p=function(C){var U,O=C.certificate;switch(O.signatureOid){case w.sha1WithRSAEncryption:case w.sha1WithRSASignature:break;case w["RSASSA-PSS"]:var L,H,ne;if(void 0===(L=w[O.signatureParameters.mgf.hash.algorithmOid])||void 0===y.md[L])throw(ne=new Error("Unsupported MGF hash function.")).oid=O.signatureParameters.mgf.hash.algorithmOid,ne.name=L,ne;if(void 0===(H=w[O.signatureParameters.mgf.algorithmOid])||void 0===y.mgf[H])throw(ne=new Error("Unsupported MGF function.")).oid=O.signatureParameters.mgf.algorithmOid,ne.name=H,ne;if(H=y.mgf[H].create(y.md[L].create()),void 0===(L=w[O.signatureParameters.hash.algorithmOid])||void 0===y.md[L])throw(ne=new Error("Unsupported RSASSA-PSS hash function.")).oid=O.signatureParameters.hash.algorithmOid,ne.name=L,ne;U=y.pss.create(y.md[L].create(),H,O.signatureParameters.saltLength)}return O.publicKey.verify(C.md.digest().getBytes(),C.signature,U)};function I(C){for(var U,L,O=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),H=C.attributes,ne=0;ne<H.length;++ne){var G=(U=H[ne]).value,ee=u.Type.PRINTABLESTRING;"valueTagClass"in U&&(ee=U.valueTagClass)===u.Type.UTF8&&(G=y.util.encodeUtf8(G)),L=u.create(u.Class.UNIVERSAL,u.Type.SET,!0,[u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(U.type).getBytes()),u.create(u.Class.UNIVERSAL,ee,!1,G)])]),O.value.push(L)}return O}function P(C){for(var O,U=0;U<C.length;++U){if(typeof(O=C[U]).name>"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<O.extensions.length;++H)O.value.push(g.certificateExtensionToAsn1(D(O.extensions[H])))}var L;if(typeof O.value>"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;te<C.altNames.length;++te){if(G=(W=C.altNames[te]).value,7===W.type&&W.ip){if(null===(G=y.util.bytesFromIP(W.ip)))throw(U=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=C,U}else 8===W.type&&(G=u.oidToDer(W.oid?u.oidToDer(W.oid):G));C.value.value.push(u.create(u.Class.CONTEXT_SPECIFIC,W.type,!1,G))}}else if("nsComment"===C.name&&O.cert){if(!/^[\x00-\x7F]*$/.test(C.comment)||C.comment.length<1||C.comment.length>128)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<C.altNames.length;++te){if(G=(W=C.altNames[te]).value,7===W.type&&W.ip){if(null===(G=y.util.bytesFromIP(W.ip)))throw(U=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=C,U}else 8===W.type&&(G=u.oidToDer(W.oid?u.oidToDer(W.oid):G));Be.value.push(u.create(u.Class.CONTEXT_SPECIFIC,W.type,!1,G))}De.value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[Be])),ee.push(De)}var U;if(typeof C.value>"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;L<U.length;++L){var H=U[L],ne=H.value,G=u.Type.UTF8;"valueTagClass"in H&&(G=H.valueTagClass),G===u.Type.UTF8&&(ne=y.util.encodeUtf8(ne));var ee=!1;"valueConstructed"in H&&(ee=H.valueConstructed);var Z=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(H.type).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SET,!0,[u.create(u.Class.UNIVERSAL,G,ee,ne)])]);O.value.push(Z)}return O}g.certificateFromPem=function(C,O,U){var L=y.pem.decode(C)[0];if("CERTIFICATE"!==L.type&&"X509 CERTIFICATE"!==L.type&&"TRUSTED CERTIFICATE"!==L.type){var H=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw H.headerType=L.type,H}if(L.procType&&"ENCRYPTED"===L.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var ne=u.fromDer(L.body,U);return g.certificateFromAsn1(ne,O)},g.certificateToPem=function(C,O){var U={type:"CERTIFICATE",body:u.toDer(g.certificateToAsn1(C)).getBytes()};return y.pem.encode(U,{maxline:O})},g.publicKeyFromPem=function(C){var O=y.pem.decode(C)[0];if("PUBLIC KEY"!==O.type&&"RSA PUBLIC KEY"!==O.type){var U=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw U.headerType=O.type,U}if(O.procType&&"ENCRYPTED"===O.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var L=u.fromDer(O.body);return g.publicKeyFromAsn1(L)},g.publicKeyToPem=function(C,O){var U={type:"PUBLIC KEY",body:u.toDer(g.publicKeyToAsn1(C)).getBytes()};return y.pem.encode(U,{maxline:O})},g.publicKeyToRSAPublicKeyPem=function(C,O){var U={type:"RSA PUBLIC KEY",body:u.toDer(g.publicKeyToRSAPublicKey(C)).getBytes()};return y.pem.encode(U,{maxline:O})},g.getPublicKeyFingerprint=function(C,O){var H,U=(O=O||{}).md||y.md.sha1.create();switch(O.type||"RSAPublicKey"){case"RSAPublicKey":H=u.toDer(g.publicKeyToRSAPublicKey(C)).getBytes();break;case"SubjectPublicKeyInfo":H=u.toDer(g.publicKeyToAsn1(C)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+O.type+'".')}U.start(),U.update(H);var ne=U.digest();if("hex"===O.encoding){var G=ne.toHex();return O.delimiter?G.match(/.{2}/g).join(O.delimiter):G}if("binary"===O.encoding)return ne.getBytes();if(O.encoding)throw new Error('Unknown encoding "'+O.encoding+'".');return ne},g.certificationRequestFromPem=function(C,O,U){var L=y.pem.decode(C)[0];if("CERTIFICATE REQUEST"!==L.type){var H=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw H.headerType=L.type,H}if(L.procType&&"ENCRYPTED"===L.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var ne=u.fromDer(L.body,U);return g.certificationRequestFromAsn1(ne,O)},g.certificationRequestToPem=function(C,O){var U={type:"CERTIFICATE REQUEST",body:u.toDer(g.certificationRequestToAsn1(C)).getBytes()};return y.pem.encode(U,{maxline:O})},g.createCertificate=function(){var C={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return C.siginfo.algorithmOid=null,C.validity={},C.validity.notBefore=new Date,C.validity.notAfter=new Date,C.issuer={},C.issuer.getField=function(O){return S(C.issuer,O)},C.issuer.addField=function(O){P([O]),C.issuer.attributes.push(O)},C.issuer.attributes=[],C.issuer.hash=null,C.subject={},C.subject.getField=function(O){return S(C.subject,O)},C.subject.addField=function(O){P([O]),C.subject.attributes.push(O)},C.subject.attributes=[],C.subject.hash=null,C.extensions=[],C.publicKey=null,C.md=null,C.setSubject=function(O,U){P(O),C.subject.attributes=O,delete C.subject.uniqueId,U&&(C.subject.uniqueId=U),C.subject.hash=null},C.setIssuer=function(O,U){P(O),C.issuer.attributes=O,delete C.issuer.uniqueId,U&&(C.issuer.uniqueId=U),C.issuer.hash=null},C.setExtensions=function(O){for(var U=0;U<O.length;++U)D(O[U],{cert:C});C.extensions=O},C.getExtension=function(O){"string"==typeof O&&(O={name:O});for(var L,U=null,H=0;null===U&&H<C.extensions.length;++H)L=C.extensions[H],(O.id&&L.id===O.id||O.name&&L.name===O.name)&&(U=L);return U},C.sign=function(O,U){C.md=U||y.md.sha1.create();var L=w[C.md.algorithm+"WithRSAEncryption"];if(!L){var H=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw H.algorithm=C.md.algorithm,H}C.signatureOid=C.siginfo.algorithmOid=L,C.tbsCertificate=g.getTBSCertificate(C);var ne=u.toDer(C.tbsCertificate);C.md.update(ne.getBytes()),C.signature=O.sign(C.md)},C.verify=function(O){var U=!1;if(!C.issued(O)){var L=O.issuer,H=C.subject,ne=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw ne.expectedIssuer=H.attributes,ne.actualIssuer=L.attributes,ne}var G=O.md;if(null===G){G=v({signatureOid:O.signatureOid,type:"certificate"});var ee=O.tbsCertificate||g.getTBSCertificate(O),Z=u.toDer(ee);G.update(Z.getBytes())}return null!==G&&(U=p({certificate:C,md:G,signature:O.signature})),U},C.isIssuer=function(O){var U=!1,L=C.issuer,H=O.subject;if(L.hash&&H.hash)U=L.hash===H.hash;else if(L.attributes.length===H.attributes.length){U=!0;for(var ne,G,ee=0;U&&ee<L.attributes.length;++ee)((ne=L.attributes[ee]).type!==(G=H.attributes[ee]).type||ne.value!==G.value)&&(U=!1)}return U},C.issued=function(O){return O.isIssuer(C)},C.generateSubjectKeyIdentifier=function(){return g.getPublicKeyFingerprint(C.publicKey,{type:"RSAPublicKey"})},C.verifySubjectKeyIdentifier=function(){for(var O=w.subjectKeyIdentifier,U=0;U<C.extensions.length;++U){var L=C.extensions[U];if(L.id===O){var H=C.generateSubjectKeyIdentifier().getBytes();return y.util.hexToBytes(L.subjectKeyIdentifier)===H}}return!1},C},g.certificateFromAsn1=function(C,O){var U={},L=[];if(!u.validate(C,c,U,L)){var H=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw H.errors=L,H}if(u.derToOid(U.publicKeyOid)!==g.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var G=g.createCertificate();G.version=U.certVersion?U.certVersion.charCodeAt(0):0;var ee=y.util.createBuffer(U.certSerialNumber);G.serialNumber=ee.toHex(),G.signatureOid=y.asn1.derToOid(U.certSignatureOid),G.signatureParameters=E(G.signatureOid,U.certSignatureParams,!0),G.siginfo.algorithmOid=y.asn1.derToOid(U.certinfoSignatureOid),G.siginfo.parameters=E(G.siginfo.algorithmOid,U.certinfoSignatureParams,!1),G.signature=U.certSignature;var Z=[];if(void 0!==U.certValidity1UTCTime&&Z.push(u.utcTimeToDate(U.certValidity1UTCTime)),void 0!==U.certValidity2GeneralizedTime&&Z.push(u.generalizedTimeToDate(U.certValidity2GeneralizedTime)),void 0!==U.certValidity3UTCTime&&Z.push(u.utcTimeToDate(U.certValidity3UTCTime)),void 0!==U.certValidity4GeneralizedTime&&Z.push(u.generalizedTimeToDate(U.certValidity4GeneralizedTime)),Z.length>2)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;U<C.value.length;++U)for(var L=C.value[U],H=0;H<L.value.length;++H)O.push(g.certificateExtensionFromAsn1(L.value[H]));return O},g.certificateExtensionFromAsn1=function(C){var O={};if(O.id=u.derToOid(C.value[0].value),O.critical=!1,C.value[1].type===u.Type.BOOLEAN?(O.critical=0!==C.value[1].value.charCodeAt(0),O.value=C.value[2].value):O.value=C.value[1].value,O.id in w)if(O.name=w[O.id],"keyUsage"===O.name){var L=0,H=0;(U=u.fromDer(O.value)).value.length>1&&(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;G<U.value.length;++G){var ee=u.derToOid(U.value[G].value);ee in w?O[w[ee]]=!0:O[ee]=!0}}else if("nsCertType"===O.name)L=0,(U=u.fromDer(O.value)).value.length>1&&(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<U.value.length;++W){var te={type:(Z=U.value[W]).type,value:Z.value};switch(O.altNames.push(te),Z.type){case 1:case 2:case 6:break;case 7:te.ip=y.util.bytesToIP(Z.value);break;case 8:te.oid=u.derToOid(Z.value)}}}else"subjectKeyIdentifier"===O.name&&(U=u.fromDer(O.value),O.subjectKeyIdentifier=y.util.bytesToHex(U.value));return O},g.certificationRequestFromAsn1=function(C,O){var U={},L=[];if(!u.validate(C,b,U,L)){var H=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw H.errors=L,H}if(u.derToOid(U.publicKeyOid)!==g.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var G=g.createCertificationRequest();if(G.version=U.csrVersion?U.csrVersion.charCodeAt(0):0,G.signatureOid=y.asn1.derToOid(U.csrSignatureOid),G.signatureParameters=E(G.signatureOid,U.csrSignatureParams,!0),G.siginfo.algorithmOid=y.asn1.derToOid(U.csrSignatureOid),G.siginfo.parameters=E(G.siginfo.algorithmOid,U.csrSignatureParams,!1),G.signature=U.csrSignature,G.certificationRequestInfo=U.certificationRequestInfo,O){G.md=v({signatureOid:G.signatureOid,type:"certification request"});var ee=u.toDer(G.certificationRequestInfo);G.md.update(ee.getBytes())}var Z=y.md.sha1.create();return G.subject.getField=function(W){return S(G.subject,W)},G.subject.addField=function(W){P([W]),G.subject.attributes.push(W)},G.subject.attributes=g.RDNAttributesAsArray(U.certificationRequestInfoSubject,Z),G.subject.hash=Z.digest().toHex(),G.publicKey=g.publicKeyFromAsn1(U.subjectPublicKeyInfo),G.getAttribute=function(W){return S(G,W)},G.addAttribute=function(W){P([W]),G.attributes.push(W)},G.attributes=g.CRIAttributesAsArray(U.certificationRequestInfoAttributes||[]),G},g.createCertificationRequest=function(){var C={version:0,signatureOid:null,signature:null,siginfo:{}};return C.siginfo.algorithmOid=null,C.subject={},C.subject.getField=function(O){return S(C.subject,O)},C.subject.addField=function(O){P([O]),C.subject.attributes.push(O)},C.subject.attributes=[],C.subject.hash=null,C.publicKey=null,C.attributes=[],C.getAttribute=function(O){return S(C,O)},C.addAttribute=function(O){P([O]),C.attributes.push(O)},C.md=null,C.setSubject=function(O){P(O),C.subject.attributes=O,C.subject.hash=null},C.setAttributes=function(O){P(O),C.attributes=O},C.sign=function(O,U){C.md=U||y.md.sha1.create();var L=w[C.md.algorithm+"WithRSAEncryption"];if(!L){var H=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw H.algorithm=C.md.algorithm,H}C.signatureOid=C.siginfo.algorithmOid=L,C.certificationRequestInfo=g.getCertificationRequestInfo(C);var ne=u.toDer(C.certificationRequestInfo);C.md.update(ne.getBytes()),C.signature=O.sign(C.md)},C.verify=function(){var O=!1,U=C.md;if(null===U){U=v({signatureOid:C.signatureOid,type:"certification request"});var L=C.certificationRequestInfo||g.getCertificationRequestInfo(C),H=u.toDer(L);U.update(H.getBytes())}return null!==U&&(O=p({certificate:C,md:U,signature:C.signature})),O},C};var k=new Date("1950-01-01T00:00:00Z"),F=new Date("2050-01-01T00:00:00Z");function $(C){return C>=k&&C<F?u.create(u.Class.UNIVERSAL,u.Type.UTCTIME,!1,u.dateToUtcTime(C)):u.create(u.Class.UNIVERSAL,u.Type.GENERALIZEDTIME,!1,u.dateToGeneralizedTime(C))}g.getTBSCertificate=function(C){var O=$(C.validity.notBefore),U=$(C.validity.notAfter),L=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.version).getBytes())]),u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,y.util.hexToBytes(C.serialNumber)),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(C.siginfo.algorithmOid).getBytes()),T(C.siginfo.algorithmOid,C.siginfo.parameters)]),I(C.issuer),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[O,U]),I(C.subject),g.publicKeyToAsn1(C.publicKey)]);return C.issuer.uniqueId&&L.value.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,String.fromCharCode(0)+C.issuer.uniqueId)])),C.subject.uniqueId&&L.value.push(u.create(u.Class.CONTEXT_SPECIFIC,2,!0,[u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,String.fromCharCode(0)+C.subject.uniqueId)])),C.extensions.length>0&&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<C.length;++L)U.value.push(g.certificateExtensionToAsn1(C[L]));return O},g.certificateExtensionToAsn1=function(C){var O=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);O.value.push(u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(C.id).getBytes())),C.critical&&O.value.push(u.create(u.Class.UNIVERSAL,u.Type.BOOLEAN,!1,String.fromCharCode(255)));var U=C.value;return"string"!=typeof C.value&&(U=u.toDer(U).getBytes()),O.value.push(u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,U)),O},g.certificationRequestToAsn1=function(C){var O=C.certificationRequestInfo||g.getCertificationRequestInfo(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.createCaStore=function(C){var O={certs:{}};function U(G){return L(G),O.certs[G.hash]||null}function L(G){if(!G.hash){var ee=y.md.sha1.create();G.attributes=g.RDNAttributesAsArray(I(G),ee),G.hash=ee.digest().toHex()}}if(O.getIssuer=function(G){return U(G.issuer)},O.addCertificate=function(G){if("string"==typeof G&&(G=y.pki.certificateFromPem(G)),L(G.subject),!O.hasCertificate(G))if(G.subject.hash in O.certs){var ee=O.certs[G.subject.hash];y.util.isArray(ee)||(ee=[ee]),ee.push(G),O.certs[G.subject.hash]=ee}else O.certs[G.subject.hash]=G},O.hasCertificate=function(G){"string"==typeof G&&(G=y.pki.certificateFromPem(G));var ee=U(G.subject);if(!ee)return!1;y.util.isArray(ee)||(ee=[ee]);for(var Z=u.toDer(g.certificateToAsn1(G)).getBytes(),W=0;W<ee.length;++W)if(Z===u.toDer(g.certificateToAsn1(ee[W])).getBytes())return!0;return!1},O.listAllCertificates=function(){var G=[];for(var ee in O.certs)if(O.certs.hasOwnProperty(ee)){var Z=O.certs[ee];if(y.util.isArray(Z))for(var W=0;W<Z.length;++W)G.push(Z[W]);else G.push(Z)}return G},O.removeCertificate=function(G){var ee;if("string"==typeof G&&(G=y.pki.certificateFromPem(G)),L(G.subject),!O.hasCertificate(G))return null;var Z=U(G.subject);if(!y.util.isArray(Z))return ee=O.certs[G.subject.hash],delete O.certs[G.subject.hash],ee;for(var W=u.toDer(g.certificateToAsn1(G)).getBytes(),te=0;te<Z.length;++te)W===u.toDer(g.certificateToAsn1(Z[te])).getBytes()&&(ee=Z[te],Z.splice(te,1));return 0===Z.length&&delete O.certs[G.subject.hash],ee},C)for(var H=0;H<C.length;++H)O.addCertificate(C[H]);return O},g.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},g.verifyCertificateChain=function(C,O,U){"function"==typeof U&&(U={verify:U}),U=U||{};var L=(O=O.slice(0)).slice(0),H=U.validityCheckDate;typeof H>"u"&&(H=new Date);var ne=!0,G=null,ee=0;do{var Z=O.shift(),W=null,te=!1;if(H&&(H<Z.validity.notBefore||H>Z.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&&Pe<Z.extensions.length;++Pe){var De=Z.extensions[Pe];De.critical&&!(De.name in he)&&(G={message:"Certificate has an unsupported critical extension.",error:g.certificateError.unsupported_certificate})}if(null===G&&(!ne||0===O.length&&(!W||te))){var Be=Z.getExtension("basicConstraints"),ve=Z.getExtension("keyUsage");null!==ve&&(!ve.keyCertSign||null===Be)&&(G={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:g.certificateError.bad_certificate}),null===G&&null!==Be&&!Be.cA&&(G={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:g.certificateError.bad_certificate}),null===G&&null!==ve&&"pathLenConstraint"in Be&&ee-1>Be.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;f<c.length;++f)(void 0===w[c[f]]||!h)&&(w[c[f]]=m[c[f]]);return w}function g(w){function m(h,c){if(!(this instanceof m))return new m(h,c);Object.defineProperty(this,"message",{get:function(){return h}}),Error.captureStackTrace?Error.captureStackTrace(this,m):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),c&&u(this,c)}return(m.prototype=Object.create(Error.prototype)).constructor=m,Object.defineProperty(m.prototype,"name",{get:function(){return w}}),m.prototype.toString=function(){return this.name+": "+this.message},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(4185),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<m.length;++c)h[m[c]]=1;return function(){for(var f=Object.keys(this),d=f.length-1;d>-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<m.length;++c)m[c]!==h&&delete this[m[c]]}},y.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},y._configure=function(){var w=y.Buffer;w?(y._Buffer_from=w.from!==Uint8Array.from&&w.from||function(h,c){return new w(h,c)},y._Buffer_allocUnsafe=w.allocUnsafe||function(h){return new w(h)}):y._Buffer_from=y._Buffer_allocUnsafe=null}},9648:(Q,K,x)=>{"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<D.length;++k)T[M+k]=D[k]};d.prototype.bytes=function(D){var T=D.length>>>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<h.length;)c[f++]=h[d++]}},g.prototype.bytes=function(h){u.isString(h)&&(h=u._Buffer_from(h,"base64"));var c=h.length>>>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<S.length;++E)b[S[E]]===c.typeDefault&&(h("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',d,d,d),c.repeated||h("break")),h("case%j:",S[E])("case %i:",b[S[E]])("m%s=%j",d,b[S[E]])("break");h("}")}else h('if(typeof d%s!=="object")',d)("throw TypeError(%j)",c.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",d,f,d);else{var v=!1;switch(c.type){case"double":case"float":h("m%s=Number(d%s)",d,d);break;case"uint32":case"fixed32":h("m%s=d%s>>>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<f.length;++b){var S=f[b].resolve(),E=g.safeProp(S.name);S.map?(d("if(d%s){",E)('if(typeof d%s!=="object")',E)("throw TypeError(%j)",S.fullName+": object expected")("m%s={}",E)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",E),w(d,S,b,E+"[ks[i]]")("}")("}")):S.repeated?(d("if(d%s){",E)("if(!Array.isArray(d%s))",E)("throw TypeError(%j)",S.fullName+": array expected")("m%s=[]",E)("for(var i=0;i<d%s.length;++i){",E),w(d,S,b,E+"[i]")("}")("}")):(S.resolvedType instanceof u||d("if(d%s!=null){",E),w(d,S,b,E),S.resolvedType instanceof u||d("}"))}return d("return m")},y.toObject=function(c){var f=c.fieldsArray.slice().sort(g.compareFieldsById);if(!f.length)return g.codegen()("return {}");for(var d=g.codegen(["m","o"],c.name+"$toObject")("if(!o)")("o={}")("var d={}"),b=[],S=[],E=[],v=0;v<f.length;++v)f[v].partOf||(f[v].resolve().repeated?b:f[v].map?S:E).push(f[v]);if(b.length){for(d("if(o.arrays||o.defaults){"),v=0;v<b.length;++v)d("d%s=[]",g.safeProp(b[v].name));d("}")}if(S.length){for(d("if(o.objects||o.defaults){"),v=0;v<S.length;++v)d("d%s={}",g.safeProp(S[v].name));d("}")}if(E.length){for(d("if(o.defaults){"),v=0;v<E.length;++v){var I=g.safeProp((p=E[v]).name);if(p.resolvedType instanceof u)d("d%s=o.enums===String?%j:%j",I,p.resolvedType.valuesById[p.typeDefault],p.typeDefault);else if(p.long)d("if(util.Long){")("var n=new util.Long(%i,%i,%j)",p.typeDefault.low,p.typeDefault.high,p.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",I)("}else")("d%s=o.longs===String?%j:%i",I,p.typeDefault.toString(),p.typeDefault.toNumber());else if(p.bytes){var A="["+Array.prototype.slice.call(p.typeDefault).join(",")+"]";d("if(o.bytes===String)d%s=%j",I,String.fromCharCode.apply(String,p.typeDefault))("else{")("d%s=%s",I,A)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",I,I)("}")}else d("d%s=%j",I,p.typeDefault)}d("}")}var P=!1;for(v=0;v<f.length;++v){var p,D=c._fieldsArray.indexOf(p=f[v]);I=g.safeProp(p.name),p.map?(P||(P=!0,d("var ks2")),d("if(m%s&&(ks2=Object.keys(m%s)).length){",I,I)("d%s={}",I)("for(var j=0;j<ks2.length;++j){"),m(d,p,D,I+"[ks2[j]]")("}")):p.repeated?(d("if(m%s&&m%s.length){",I,I)("d%s=[]",I)("for(var j=0;j<m%s.length;++j){",I),m(d,p,D,I+"[j]")("}")):(d("if(m%s!=null&&m.hasOwnProperty(%j)){",I,p.name),m(d,p,D,I),p.partOf&&d("if(o.oneofs)")("d%s=%j",g.safeProp(p.partOf.name),p.name)),d("}")}return d("return d")}},4866:(Q,K,x)=>{"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<c){")("var t=r.uint32()");h.group&&c("if((t&7)===4)")("break"),c("switch(t>>>3){");for(var f=0;f<h.fieldsArray.length;++f){var d=h._fieldsArray[f].resolve(),b=d.resolvedType instanceof y?"int32":d.type,S="m"+g.safeProp(d.name);c("case %i: {",d.id),d.map?(c("if(%s===util.emptyObject)",S)("%s={}",S)("var c2 = r.uint32()+r.pos"),void 0!==u.defaults[d.keyType]?c("k=%j",u.defaults[d.keyType]):c("k=null"),void 0!==u.defaults[b]?c("value=%j",u.defaults[b]):c("value=null"),c("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>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<c2)")("%s.push(r.%s())",S,b)("}else"),void 0===u.basic[b]?c(d.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",S,f):c("%s.push(r.%s())",S,b)):void 0===u.basic[b]?c(d.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",S,f):c("%s=r.%s()",S,b),c("break")("}")}for(c("default:")("r.skipType(t&7)")("break")("}")("}"),f=0;f<h._fieldsArray.length;++f){var E=h._fieldsArray[f];E.required&&c("if(!m.hasOwnProperty(%j))",E.name)("throw util.ProtocolError(%j,{instance:m})",w(E))}return c("return m")};var y=x(4080),u=x(1431),g=x(7695);function w(h){return"missing required '"+h.name+"'"}},8350:(Q,K,x)=>{"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<b.length;++f){var S=b[f].resolve(),E=h._fieldsArray.indexOf(S),v=S.resolvedType instanceof y?"int32":S.type,p=u.basic[v];d="m"+g.safeProp(S.name),S.map?(c("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",d,S.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",d)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(S.id<<3|2)>>>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<S.length;++E)"number"==typeof h[S[E]]&&(this.valuesById[this.values[S[E]]=h[S[E]]]=S[E])}w.fromJSON=function(h,c){var f=new w(h,c.values,c.options,c.comment,c.comments);return f.reserved=c.reserved,f},w.prototype.toJSON=function(h){var c=!!h&&Boolean(h.keepComments);return g.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",c?this.comment:void 0,"comments",c?this.comments:void 0])},w.prototype.add=function(h,c,f,d){if(!g.isString(h))throw TypeError("name must be a string");if(!g.isInteger(c))throw TypeError("id must be an integer");if(void 0!==this.values[h])throw Error("duplicate name '"+h+"' in "+this);if(this.isReservedId(c))throw Error("id "+c+" is reserved in "+this);if(this.isReservedName(h))throw Error("name '"+h+"' is reserved in "+this);if(void 0!==this.valuesById[c]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+c+" in "+this);this.values[h]=c}else this.valuesById[this.values[h]=c]=h;return d&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[h]=d||null),this.comments[h]=f||null,this},w.prototype.remove=function(h){if(!g.isString(h))throw TypeError("name must be a string");var c=this.values[h];if(null==c)throw Error("name '"+h+"' does not exist in "+this);return delete this.valuesById[c],delete this.values[h],delete this.comments[h],this.valuesOptions&&delete this.valuesOptions[h],this},w.prototype.isReservedId=function(h){return u.isReservedId(this.reserved,h)},w.prototype.isReservedName=function(h){return u.isReservedName(this.reserved,h)}},7937:(Q,K,x)=>{"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<w.length;++m)this[w[m]]=g[w[m]]}u.create=function(w){return this.$type.create(w)},u.encode=function(w,m){return this.$type.encode(w,m)},u.encodeDelimited=function(w,m){return this.$type.encodeDelimited(w,m)},u.decode=function(w){return this.$type.decode(w)},u.decodeDelimited=function(w){return this.$type.decodeDelimited(w)},u.verify=function(w){return this.$type.verify(w)},u.fromObject=function(w){return this.$type.fromObject(w)},u.toObject=function(w,m){return this.$type.toObject(w,m)},u.prototype.toJSON=function(){return this.$type.toObject(this,y.toJSONOptions)}},1892:(Q,K,x)=>{"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;p<S.length;++p)v[S[p].name]=S[p].toJSON(E);return v}}function d(S,E){y.call(this,S,E),this.nested=void 0,this._nestedArray=null}function b(S){return S._nestedArray=null,S}d.fromJSON=function(E,v){return new d(E,v.options).addJSON(v.nested)},d.arrayToJSON=f,d.isReservedId=function(E,v){if(E)for(var p=0;p<E.length;++p)if("string"!=typeof E[p]&&E[p][0]<=v&&E[p][1]>v)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p<E.length;++p)if(E[p]===v)return!0;return!1},Object.defineProperty(d.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=g.toArray(this.nested))}}),d.prototype.toJSON=function(E){return g.toObject(["options",this.options,"nested",f(this.nestedArray,E)])},d.prototype.addJSON=function(E){if(E)for(var A,p=Object.keys(E),I=0;I<p.length;++I)this.add((void 0!==(A=E[p[I]]).fields?m.fromJSON:void 0!==A.values?c.fromJSON:void 0!==A.methods?h.fromJSON:void 0!==A.id?u.fromJSON:d.fromJSON)(p[I],A));return this},d.prototype.get=function(E){return this.nested&&this.nested[E]||null},d.prototype.getEnum=function(E){if(this.nested&&this.nested[E]instanceof c)return this.nested[E].values;throw Error("no such enum: "+E)},d.prototype.add=function(E){if(!(E instanceof u&&void 0!==E.extend||E instanceof m||E instanceof w||E instanceof c||E instanceof h||E instanceof d))throw TypeError("object must be a valid nested object");if(this.nested){var v=this.get(E.name);if(v){if(!(v instanceof d&&E instanceof d)||v instanceof m||v instanceof h)throw Error("duplicate name '"+E.name+"' in "+this);for(var p=v.nestedArray,I=0;I<p.length;++I)E.add(p[I]);this.remove(v),this.nested||(this.nested={}),E.setOptions(v.options,!0)}}else this.nested={};return this.nested[E.name]=E,E.onAdd(this),b(this)},d.prototype.remove=function(E){if(!(E instanceof y))throw TypeError("object must be a ReflectionObject");if(E.parent!==this)throw Error(E+" is not a member of "+this);return delete this.nested[E.name],Object.keys(this.nested).length||(this.nested=void 0),E.onRemove(this),b(this)},d.prototype.define=function(E,v){if(g.isString(E))E=E.split(".");else if(!Array.isArray(E))throw TypeError("illegal path");if(E&&E.length&&""===E[0])throw Error("path must be relative");for(var p=this;E.length>0;){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<E.length;)E[v]instanceof d?E[v++].resolveAll():E[v++].resolve();return this.resolve()},d.prototype.lookup=function(E,v,p){if("boolean"==typeof v?(p=v,v=void 0):v&&!Array.isArray(v)&&(v=[v]),g.isString(E)&&E.length){if("."===E)return this.root;E=E.split(".")}else if(!E.length)return this;if(""===E[0])return this.root.lookup(E.slice(1),v);var I=this.get(E[0]);if(I){if(1===E.length){if(!v||v.indexOf(I.constructor)>-1)return I}else if(I instanceof d&&(I=I.lookup(E.slice(1),v,!0)))return I}else for(var A=0;A<this.nestedArray.length;++A)if(this._nestedArray[A]instanceof d&&(I=this._nestedArray[A].lookup(E,v,!0)))return I;return null===this.parent||p?null:this.parent.lookup(E,v)},d.prototype.lookupType=function(E){var v=this.lookup(E,[m]);if(!v)throw Error("no such type: "+E);return v},d.prototype.lookupEnum=function(E){var v=this.lookup(E,[c]);if(!v)throw Error("no such Enum '"+E+"' in "+this);return v},d.prototype.lookupTypeOrEnum=function(E){var v=this.lookup(E,[m,c]);if(!v)throw Error("no such Type or Enum '"+E+"' in "+this);return v},d.prototype.lookupService=function(E){var v=this.lookup(E,[h]);if(!v)throw Error("no such Service '"+E+"' in "+this);return v},d._configure=function(S,E,v){m=S,h=E,c=v}},7108:(Q,K,x)=>{"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<c.length;++f)this.setOption(c[f],m[c[f]],h);return this},g.prototype.toString=function(){var m=this.constructor.className,h=this.fullName;return h.length?m+" "+h:m},g._configure=function(w){u=w}},8967:(Q,K,x)=>{"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<h.fieldsArray.length;++c)h.fieldsArray[c].parent||h.parent.add(h.fieldsArray[c])}w.fromJSON=function(c,f){return new w(c,f.oneof,f.options,f.comment)},w.prototype.toJSON=function(c){var f=!!c&&Boolean(c.keepComments);return g.toObject(["options",this.options,"oneof",this.oneof,"comment",f?this.comment:void 0])},w.prototype.add=function(c){if(!(c instanceof u))throw TypeError("field must be a Field");return c.parent&&c.parent!==this.parent&&c.parent.remove(c),this.oneof.push(c.name),this.fieldsArray.push(c),c.partOf=this,m(this),this},w.prototype.remove=function(c){if(!(c instanceof u))throw TypeError("field must be a Field");var f=this.fieldsArray.indexOf(c);if(f<0)throw Error(c+" is not a member of "+this);return this.fieldsArray.splice(f,1),(f=this.oneof.indexOf(c.name))>-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<this.oneof.length;++d){var b=c.get(this.oneof[d]);b&&!b.partOf&&(b.partOf=this,this.fieldsArray.push(b))}m(this)},w.prototype.onRemove=function(c){for(var d,f=0;f<this.fieldsArray.length;++f)(d=this.fieldsArray[f]).parent&&d.parent.remove(d);y.prototype.onRemove.call(this,c)},w.d=function(){for(var c=new Array(arguments.length),f=0;f<arguments.length;)c[f]=arguments[f++];return function(b,S){g.decorateType(b.constructor).add(new w(S,c)),Object.defineProperty(b,S,{get:g.oneOfGetter(c),set:g.oneOfSetter(c)})}}},3629:(Q,K,x)=>{"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<H.imports.length;++G)(ne=M(H.imports[G])||P.resolvePath(U,H.imports[G]))&&F(ne);if(H.weakImports)for(G=0;G<H.weakImports.length;++G)(ne=M(H.weakImports[G])||P.resolvePath(U,H.weakImports[G]))&&F(ne,!0)}else P.setOptions(L.options).addJSON(L.nested)}catch(ee){T(ee)}!D&&!$&&T(null,P)}function F(U,L){if(!(P.files.indexOf(U)>-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<p.length;++C)(O=P.resolvePath("",p[C]))&&F(O);if(D)return P;$||T(null,P)},d.prototype.loadSync=function(p,I){if(!m.isNode)throw Error("not supported");return this.load(p,I,b)},d.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map(function(p){return"'extend "+p.extend+"' in "+p.parent.fullName}).join(", "));return y.prototype.resolveAll.call(this)};var S=/^[A-Z]/;function E(v,p){var I=p.parent.lookup(p.extend);if(I){var A=new u(p.fullName,p.id,p.type,p.rule,void 0,p.options);return A.declaringField=p,p.extensionField=A,I.add(A),!0}return!1}d.prototype._handleAdd=function(p){if(p instanceof u)void 0!==p.extend&&!p.extensionField&&(E(0,p)||this.deferred.push(p));else if(p instanceof g)S.test(p.name)&&(p.parent[p.name]=p.values);else if(!(p instanceof w)){if(p instanceof h)for(var I=0;I<this.deferred.length;)E(0,this.deferred[I])?this.deferred.splice(I,1):++I;for(var A=0;A<p.nestedArray.length;++A)this._handleAdd(p._nestedArray[A]);S.test(p.name)&&(p.parent[p.name]=p)}},d.prototype._handleRemove=function(p){if(p instanceof u){if(void 0!==p.extend)if(p.extensionField)p.extensionField.parent.remove(p.extensionField),p.extensionField=null;else{var I=this.deferred.indexOf(p);I>-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<p.nestedArray.length;++A)this._handleRemove(p._nestedArray[A]);S.test(p.name)&&delete p.parent[p.name]}},d._configure=function(v,p,I){h=v,c=p,f=I}},4661:Q=>{"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<S.length;++E)b.add(u.fromJSON(S[E],d.methods[S[E]]));return d.nested&&b.addJSON(d.nested),b.comment=d.comment,b},m.prototype.toJSON=function(f){var d=y.prototype.toJSON.call(this,f),b=!!f&&Boolean(f.keepComments);return g.toObject(["options",d&&d.options||void 0,"methods",y.arrayToJSON(this.methodsArray,f)||{},"nested",d&&d.nested||void 0,"comment",b?this.comment:void 0])},Object.defineProperty(m.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=g.toArray(this.methods))}}),m.prototype.get=function(f){return this.methods[f]||y.prototype.get.call(this,f)},m.prototype.resolveAll=function(){for(var f=this.methodsArray,d=0;d<f.length;++d)f[d].resolve();return y.prototype.resolve.call(this)},m.prototype.add=function(f){if(this.get(f.name))throw Error("duplicate name '"+f.name+"' in "+this);return f instanceof u?(this.methods[f.name]=f,f.parent=this,h(this)):y.prototype.add.call(this,f)},m.prototype.remove=function(f){if(f instanceof u){if(this.methods[f.name]!==f)throw Error(f+" is not a member of "+this);return delete this.methods[f.name],f.parent=null,h(this)}return y.prototype.remove.call(this,f)},m.prototype.create=function(f,d,b){for(var v,S=new w.Service(f,d,b),E=0;E<this.methodsArray.length;++E){var p=g.lcFirst((v=this._methodsArray[E]).resolve().name).replace(/[^$\w_]/g,"");S[p]=g.codegen(["r","c"],g.isReserved(p)?p+"_":p)("return this.rpcCall(m,q,s,r,c)")({m:v,q:v.resolvedRequestType.ctor,s:v.resolvedResponseType.ctor})}return S}},5638:Q=>{"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;Pe<he.length;++Pe)he[Pe]=he[Pe].replace(S?g:u,"").trim();W.text=he.join("\n").trim(),A[p]=W,I=p}function $(G){var ee=C(G),Z=b.substring(G,ee);return/^\s*\/{1,2}/.test(Z)}function C(G){for(var ee=G;ee<v&&"\n"!==k(ee);)ee++;return ee}function O(){if(P.length>0)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<v&&!K.test(k(de));)++de;var Pe=b.substring(E,E=de);return('"'===Pe||"'"===Pe)&&(D=Pe),Pe}function U(G){P.push(G)}function L(){if(!P.length){var G=O();if(null===G)return null;U(G)}return P[0]}return Object.defineProperty({next:O,peek:L,push:U,skip:function H(G,ee){var Z=L();if(Z===G)return O(),!0;if(!ee)throw T("token '"+Z+"', '"+G+"' expected");return!1},cmnt:function ne(G){var Z,ee=null;return void 0===G?(Z=A[p-1],delete A[p-1],Z&&(S||"*"===Z.type||Z.lineEmpty)&&(ee=Z.leading?Z.text:null)):(I<G&&L(),Z=A[G],delete A[G],Z&&!Z.lineEmpty&&(S||"/"===Z.type)&&(ee=Z.leading?null:Z.text)),ee}},"line",{get:function(){return p}})}d.unescape=f},9697:(Q,K,x)=>{"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<D.length;++T){var M=this.fields[D[T]],k=M.id;if(this._fieldsById[k])throw Error("duplicate id "+k+" in "+this);this._fieldsById[k]=M}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=b.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=b.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=A.generateConstructor(this)())},set:function(D){var T=D.prototype;T instanceof c||((D.prototype=new c).constructor=D,b.merge(D.prototype,T)),D.$type=D.prototype.$type=this,b.merge(D,c,!0),this._ctor=D;for(var M=0;M<this.fieldsArray.length;++M)this._fieldsArray[M].resolve();var k={};for(M=0;M<this.oneofsArray.length;++M)k[this._oneofsArray[M].resolve().name]={get:b.oneOfGetter(this._oneofsArray[M].oneof),set:b.oneOfSetter(this._oneofsArray[M].oneof)};M&&Object.defineProperties(D.prototype,k)}}}),A.generateConstructor=function(T){for(var F,M=b.codegen(["p"],T.name),k=0;k<T.fieldsArray.length;++k)(F=T._fieldsArray[k]).map?M("this%s={}",b.safeProp(F.name)):F.repeated&&M("this%s=[]",b.safeProp(F.name));return M("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},A.fromJSON=function(T,M){var k=new A(T,M.options);k.extensions=M.extensions,k.reserved=M.reserved;for(var F=Object.keys(M.fields),$=0;$<F.length;++$)k.add((typeof M.fields[F[$]].keyType<"u"?m.fromJSON:w.fromJSON)(F[$],M.fields[F[$]]));if(M.oneofs)for(F=Object.keys(M.oneofs),$=0;$<F.length;++$)k.add(g.fromJSON(F[$],M.oneofs[F[$]]));if(M.nested)for(F=Object.keys(M.nested),$=0;$<F.length;++$){var C=M.nested[F[$]];k.add((void 0!==C.id?w.fromJSON:void 0!==C.fields?A.fromJSON:void 0!==C.values?u.fromJSON:void 0!==C.methods?h.fromJSON:y.fromJSON)(F[$],C))}return M.extensions&&M.extensions.length&&(k.extensions=M.extensions),M.reserved&&M.reserved.length&&(k.reserved=M.reserved),M.group&&(k.group=!0),M.comment&&(k.comment=M.comment),k},A.prototype.toJSON=function(T){var M=y.prototype.toJSON.call(this,T),k=!!T&&Boolean(T.keepComments);return b.toObject(["options",M&&M.options||void 0,"oneofs",y.arrayToJSON(this.oneofsArray,T),"fields",y.arrayToJSON(this.fieldsArray.filter(function(F){return!F.declaringField}),T)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",M&&M.nested||void 0,"comment",k?this.comment:void 0])},A.prototype.resolveAll=function(){for(var T=this.fieldsArray,M=0;M<T.length;)T[M++].resolve();var k=this.oneofsArray;for(M=0;M<k.length;)k[M++].resolve();return y.prototype.resolveAll.call(this)},A.prototype.get=function(T){return this.fields[T]||this.oneofs&&this.oneofs[T]||this.nested&&this.nested[T]||null},A.prototype.add=function(T){if(this.get(T.name))throw Error("duplicate name '"+T.name+"' in "+this);if(T instanceof w&&void 0===T.extend){if(this._fieldsById?this._fieldsById[T.id]:this.fieldsById[T.id])throw Error("duplicate id "+T.id+" in "+this);if(this.isReservedId(T.id))throw Error("id "+T.id+" is reserved in "+this);if(this.isReservedName(T.name))throw Error("name '"+T.name+"' is reserved in "+this);return T.parent&&T.parent.remove(T),this.fields[T.name]=T,T.message=this,T.onAdd(this),P(this)}return T instanceof g?(this.oneofs||(this.oneofs={}),this.oneofs[T.name]=T,T.onAdd(this),P(this)):y.prototype.add.call(this,T)},A.prototype.remove=function(T){if(T instanceof w&&void 0===T.extend){if(!this.fields||this.fields[T.name]!==T)throw Error(T+" is not a member of "+this);return delete this.fields[T.name],T.parent=null,T.onRemove(this),P(this)}if(T instanceof g){if(!this.oneofs||this.oneofs[T.name]!==T)throw Error(T+" is not a member of "+this);return delete this.oneofs[T.name],T.parent=null,T.onRemove(this),P(this)}return y.prototype.remove.call(this,T)},A.prototype.isReservedId=function(T){return y.isReservedId(this.reserved,T)},A.prototype.isReservedName=function(T){return y.isReservedName(this.reserved,T)},A.prototype.create=function(T){return new this.ctor(T)},A.prototype.setup=function(){for(var T=this.fullName,M=[],k=0;k<this.fieldsArray.length;++k)M.push(this._fieldsArray[k].resolve().resolvedType);this.encode=S(this)({Writer:d,types:M,util:b}),this.decode=E(this)({Reader:f,types:M,util:b}),this.verify=v(this)({types:M,util:b}),this.fromObject=p.fromObject(this)({types:M,util:b}),this.toObject=p.toObject(this)({types:M,util:b});var F=I[T];if(F){var $=Object.create(this);$.fromObject=this.fromObject,this.fromObject=F.fromObject.bind($),$.toObject=this.toObject,this.toObject=F.toObject.bind($)}return this},A.prototype.encode=function(T,M){return this.setup().encode(T,M)},A.prototype.encodeDelimited=function(T,M){return this.encode(T,M&&M.len?M.fork():M).ldelim()},A.prototype.decode=function(T,M){return this.setup().decode(T,M)},A.prototype.decodeDelimited=function(T){return T instanceof f||(T=f.create(T)),this.decode(T,T.uint32())},A.prototype.verify=function(T){return this.setup().verify(T)},A.prototype.fromObject=function(T){return this.setup().fromObject(T)},A.prototype.toObject=function(T,M){return this.setup().toObject(T,M)},A.d=function(T){return function(k){b.decorateType(k,T)}}},1431:(Q,K,x)=>{"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<m.length;)f[g[c+h]]=m[c++];return f}y.basic=w([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),y.defaults=w([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",u.emptyArray,null]),y.long=w([0,0,0,1,1],7),y.mapKey=w([0,0,0,5,5,0,0,0,1,1,0,2],2),y.packed=w([1,5,0,0,0,5,5,0,0,0,1,1,0])},7695:(Q,K,x)=>{"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;v<S.length;)E[v]=b[S[v++]];return E}return[]},y.toObject=function(b){for(var S={},E=0;E<b.length;){var v=b[E++],p=b[E++];void 0!==p&&(S[v]=p)}return S};var m=/\\/g,h=/"/g;y.isReserved=function(b){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(b)},y.safeProp=function(b){return!/^[$\w_]+$/.test(b)||y.isReserved(b)?'["'+b.replace(m,"\\\\").replace(h,'\\"')+'"]':"."+b},y.ucFirst=function(b){return b.charAt(0).toUpperCase()+b.substring(1)};var c=/_([a-z])/g;y.camelCase=function(b){return b.substring(0,1)+b.substring(1).replace(c,function(S,E){return E.toUpperCase()})},y.compareFieldsById=function(b,S){return b.id-S.id},y.decorateType=function(b,S){if(b.$type)return S&&b.$type.name!==S&&(y.decorateRoot.remove(b.$type),b.$type.name=S,y.decorateRoot.add(b.$type)),b.$type;g||(g=x(9697));var E=new g(S||b.name);return y.decorateRoot.add(E),E.ctor=b,Object.defineProperty(b,"$type",{value:E,enumerable:!1}),Object.defineProperty(b.prototype,"$type",{value:E,enumerable:!1}),E};var f=0;y.decorateEnum=function(b){if(b.$type)return b.$type;w||(w=x(4080));var S=new w("Enum"+f++,b);return y.decorateRoot.add(S),Object.defineProperty(b,"$type",{value:S,enumerable:!1}),S},y.setProperty=function(b,S,E){if("object"!=typeof b)throw TypeError("dst must be an object");if(!S)throw TypeError("path must be specified");return function v(p,I,A){var P=I.shift();if("__proto__"===P)return p;if(I.length>0)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;f<c.length;++f)(void 0===w[c[f]]||!h)&&(w[c[f]]=m[c[f]]);return w}function g(w){function m(h,c){if(!(this instanceof m))return new m(h,c);Object.defineProperty(this,"message",{get:function(){return h}}),Error.captureStackTrace?Error.captureStackTrace(this,m):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),c&&u(this,c)}return m.prototype=Object.create(Error.prototype,{constructor:{value:m,writable:!0,enumerable:!1,configurable:!0},name:{get:()=>w,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<m.length;++c)h[m[c]]=1;return function(){for(var f=Object.keys(this),d=f.length-1;d>-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<m.length;++c)m[c]!==h&&delete this[m[c]]}},y.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},y._configure=function(){var w=y.Buffer;w?(y._Buffer_from=w.from!==Uint8Array.from&&w.from||function(h,c){return new w(h,c)},y._Buffer_allocUnsafe=w.allocUnsafe||function(h){return new w(h)}):y._Buffer_from=y._Buffer_allocUnsafe=null}},4607:(Q,K,x)=>{"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<c.fieldsArray.length;++S){var E=c._fieldsArray[S].resolve(),v="m"+u.safeProp(E.name);if(E.optional&&f("if(%s!=null&&m.hasOwnProperty(%j)){",v,E.name),E.map)f("if(!util.isObject(%s))",v)("return%j",g(E,"object"))("var k=Object.keys(%s)",v)("for(var i=0;i<k.length;++i){"),m(f,E,"k[i]"),w(f,E,S,v+"[k[i]]")("}");else if(E.repeated)f("if(!Array.isArray(%s))",v)("return%j",g(E,"array"))("for(var i=0;i<%s.length;++i){",v),w(f,E,S,v+"[i]")("}");else{if(E.partOf){var p=u.safeProp(E.partOf.name);1===b[E.partOf.name]&&f("if(p%s===1)",p)("return%j",E.partOf.name+": multiple values"),b[E.partOf.name]=1,f("p%s=1",p)}w(f,E,S,v)}E.optional&&f("}")}return f("return null")};var y=x(4080),u=x(7695);function g(c,f){return c.name+": "+f+(c.repeated&&"array"!==f?"[]":c.map&&"object"!==f?"{k:"+c.keyType+"}":"")+" expected"}function w(c,f,d,b){if(f.resolvedType)if(f.resolvedType instanceof y){c("switch(%s){",b)("default:")("return%j",g(f,"enum value"));for(var S=Object.keys(f.resolvedType.values),E=0;E<S.length;++E)c("case %i:",f.resolvedType.values[S[E]]);c("break")("}")}else c("{")("var e=types[%i].verify(%s);",d,b)("if(e)")("return%j+e",f.name+".")("}");else switch(f.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":c("if(!util.isInteger(%s))",b)("return%j",g(f,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":c("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",b,b,b,b)("return%j",g(f,"integer|Long"));break;case"float":case"double":c('if(typeof %s!=="number")',b)("return%j",g(f,"number"));break;case"bool":c('if(typeof %s!=="boolean")',b)("return%j",g(f,"boolean"));break;case"string":c("if(!util.isString(%s))",b)("return%j",g(f,"string"));break;case"bytes":c('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',b,b,b)("return%j",g(f,"buffer"))}return c}function m(c,f,d){switch(f.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":c("if(!util.key32Re.test(%s))",d)("return%j",g(f,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":c("if(!util.key64Re.test(%s))",d)("return%j",g(f,"integer|Long key"));break;case"bool":c("if(!util.key2Re.test(%s))",d)("return%j",g(f,"boolean key"))}return c}},3534:(Q,K,x)=>{"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<D.length;++k)T[M+k]=D[k]};d.prototype.bytes=function(D){var T=D.length>>>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<h.length;)c[f++]=h[d++]}},g.prototype.bytes=function(h){u.isString(h)&&(h=u._Buffer_from(h,"base64"));var c=h.length>>>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<this.execEvenlyMinDelayMs&&(p=v.consumedPoints*this.execEvenlyMinDelayMs),setTimeout(d,p,v)}else d(v)})}penalty(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)})}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<d._maxQueueSize?d._queue.push({resolve:h,reject:c,tokens:f}):c(new y(`Number of requests reached it's maximum ${d._maxQueueSize}`))}_processFIFO(){const h=this;if(null!==h._waitTimeout&&(clearTimeout(h._waitTimeout),h._waitTimeout=null),0===h._queue.length)return;const c=h._queue.shift();h._limiterFlexible.consume(h._key,c.tokens).then(f=>{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<this.execEvenlyMinDelayMs&&(E=S.consumedPoints*this.execEvenlyMinDelayMs),setTimeout(m,E,S)}else m(S)}_handleError(m,h,c,f,d,b=!1,S={}){this.insuranceLimiter instanceof y?this.insuranceLimiter[h](d,b,S).then(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<f.length;S++)b&&!0===f[S].rejected?d[this._limiters[S].keyPrefix]=f[S].rej:b||(d[this._limiters[S].keyPrefix]=f[S]);b?h(d):m(d)})})}}},3732:Q=>{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<w.length;m++)w[m]=arguments[m+2]}return new u(arguments[0],arguments[1],w)}},1164:Q=>{"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<m;d+=1){if(c=g.charCodeAt(d),f=g[d],(y=c)>=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<g;c++)(y=m=u.charCodeAt(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)<<h:(127&f)*Math.pow(2,h),h+=7}while(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<K?1:f<x?2:f<y?3:f<u?4:f<g?5:f<w?6:f<m?7:f<h?8:f<c?9:10}},5332:()=>{"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":"<root>",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;Dt<lt.length;Dt++)lt[Dt]._updateTaskCount(ce.type,me)}}return jt.__symbol__=xe,jt})();const Je={name:"",onHasTask:(jt,rt,ce,me)=>jt.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;rt<jt.length;rt++){const ce=jt[rt];try{ce.zone.runTask(ce,null,null)}catch(me){Yn.onUnhandledError(me)}}}Yn.microtaskDrainDone(),Ne=!1}}const jn={name:"NO ZONE"},$t="notScheduled",Tn="scheduling",un="scheduled",ot="running",Dn="canceling",et="unknown",Wt="microTask",Et="macroTask",Ar="eventTask",wi={},Yn={symbol:xe,currentZoneFrame:()=>Nn,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;ye<le.length;ye++)U(re,"on"+le[ye],ge);else{const ye=[];for(const be in re)"on"==be.slice(0,2)&&ye.push(be);for(let be=0;be<ye.length;be++)U(re,ye[be],ge)}}const H=E("originalInstance");function ne(re){const le=I[re];if(!le)return;I[E(re)]=le,I[re]=function(){const be=P(arguments,re);switch(be.length){case 0:this[H]=new le;break;case 1:this[H]=new le(be[0]);break;case 2:this[H]=new le(be[0],be[1]);break;case 3:this[H]=new le(be[0],be[1],be[2]);break;case 4:this[H]=new le(be[0],be[1],be[2],be[3]);break;default:throw new Error("Arg list too long.")}},Z(I[re],le);const ge=new le(function(){});let ye;for(ye in ge)"XMLHttpRequest"===re&&"responseBlob"===ye||function(be){"function"==typeof ge[be]?I[re].prototype[be]=function(){return this[H][be].apply(this[H],arguments)}:K(I[re].prototype,be,{set:function(xe){"function"==typeof xe?(this[H][be]=b(xe,re+"."+be),Z(this[H][be],xe)):this[H][be]=xe},get:function(){return this[H][be]}})}(ye);for(ye in le)"prototype"!==ye&&le.hasOwnProperty(ye)&&(I[re][ye]=le[ye])}function G(re,le,ge){let ye=re;for(;ye&&!ye.hasOwnProperty(le);)ye=x(ye);!ye&&re[le]&&(ye=re);const be=E(le);let xe=null;if(ye&&(!(xe=ye[be])||!ye.hasOwnProperty(be))&&(xe=ye[be]=ye[le],T(ye&&Q(ye,le)))){const je=ge(xe,be,le);ye[le]=function(){return je(this,arguments)},Z(ye[le],xe)}return xe}function ee(re,le,ge){let ye=null;function be(xe){const ze=xe.data;return ze.args[ze.cbIdx]=function(){xe.invoke.apply(this,arguments)},ye.apply(ze.target,ze.args),xe}ye=G(re,le,xe=>function(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<ht.length;)_r(Ve,ht[it++],ht[it++],ht[it++],ht[it++]);if(0==ht.length&&Ge==Dn){Ve[Nt]=0;let it=Ce;try{throw new Error("Uncaught (in promise): "+function xe(Ve){return Ve&&Ve.toString===Object.prototype.toString?(Ve.constructor&&Ve.constructor.name||"")+": "+JSON.stringify(Ve):Ve?Ve.toString():Object.prototype.toString.call(Ve)}(Ce)+(Ce&&Ce.stack?"\n"+Ce.stack:""))}catch(pt){it=pt}Je&&(it.throwOriginal=!0),it.rejection=Ce,it.promise=Ve,it.zone=le.current,it.task=le.currentTask,je.push(it),ge.scheduleMicroTask()}}}return Ve}const Nn=ze("rejectionHandledHandler");function Br(Ve){if(0===Ve[Nt]){try{const Ge=le[Nn];Ge&&"function"==typeof Ge&&Ge.call(this,{rejection:Ve[ft],promise:Ve})}catch{}Ve[Nt]=Dn;for(let Ge=0;Ge<je.length;Ge++)Ve===je[Ge].promise&&je.splice(Ge,1)}}function _r(Ve,Ge,Ce,Ke,ct){Br(Ve);const ht=Ve[Nt],it=ht?"function"==typeof Ke?Ke:Ne:"function"==typeof ct?ct:at;Ge.scheduleMicroTask("Promise.then",()=>{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<Ce.length;Mt++)Ce[Mt].then(It=>{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<ot.length&&(!qe||!0!==qe[He]);Dn++){const et=pe(ot[Dn],$t,qe);et&&un.push(et)}}if(1===un.length)throw un[0];for(let ot=0;ot<un.length;ot++){const Dn=un[ot];le.nativeScheduleMicroTask(()=>{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;it<ht.length;it++)if(ht[it]===Ce){ht.splice(it,1),Ce.isRemoved=!0,0===ht.length&&(Ce.allRemoved=!0,Ce.target[ct]=null);break}}if(Ce.allRemoved)return Et.call(Ce.target,Ce.eventName,Ce.capture?Ne:Le,Ce.options)}:function(Ce){return Et.call(Ce.target,Ce.eventName,Ce.invoke,Ce.options)},Dt=qe&&qe.diff?qe.diff:function(Ce,Ke){const ct=typeof Ke;return"function"===ct&&Ce.callback===Ke||"object"===ct&&Ce.originalDelegate===Ke},An=Zone[E("UNPATCHED_EVENTS")],Ve=re[E("PASSIVE_EVENTS")],Ge=function(Ce,Ke,ct,ht,it=!1,pt=!1){return function(){const Mt=this||re;let It=arguments[0];qe&&qe.transferEventName&&(It=qe.transferEventName(It));let En=arguments[1];if(!En)return Ce.apply(this,arguments);if(k&&"uncaughtException"===It)return Ce.apply(this,arguments);let gn=!1;if("function"!=typeof En){if(!En.handleEvent)return Ce.apply(this,arguments);gn=!0}if($t&&!$t(Ce,En,Mt,arguments))return;const ts=he&&!!Ve&&-1!==Ve.indexOf(It),qn=Nn(arguments[2],ts);if(An)for(let Zt=0;Zt<An.length;Zt++)if(It===An[Zt])return ts?Ce.call(Mt,It,En,qn):Ce.apply(this,arguments);const ia=!!qn&&("boolean"==typeof qn||qn.capture),wo=!(!qn||"object"!=typeof qn)&&qn.once,Jl=Zone.current;let sa=De[It];sa||(ke(It,Dn),sa=De[It]);const z=sa[ia?c:f];let ue,q=Mt[z],J=!1;if(q){if(J=!0,Tn)for(let Zt=0;Zt<q.length;Zt++)if(Dt(q[Zt],En))return}else q=Mt[z]=[];const Re=Mt.constructor.name,Oe=Be[Re];Oe&&(ue=Oe[It]),ue||(ue=Re+Ke+(Dn?Dn(It):It)),et.options=qn,wo&&(et.options.once=!1),et.target=Mt,et.capture=ia,et.eventName=It,et.isExisting=J;const We=jn?Pe:void 0;We&&(We.taskData=et);const $e=Jl.scheduleEventTask(ue,En,We,ct,ht);return et.target=null,We&&(We.taskData=null),wo&&(qn.once=!0),!he&&"boolean"==typeof $e.options||($e.options=qn),$e.target=Mt,$e.capture=ia,$e.eventName=It,gn&&($e.originalDelegate=En),pt?q.unshift($e):q.push($e),it?Mt:void 0}};return ot[be]=Ge(Wt,Xe,ce,me,un),Yn&&(ot.prependListener=Ge(Yn,".prependListener:",function(Ce){return Yn.call(et.target,et.eventName,Ce.invoke,et.options)},me,un,!0)),ot[xe]=function(){const Ce=this||re;let Ke=arguments[0];qe&&qe.transferEventName&&(Ke=qe.transferEventName(Ke));const ct=arguments[2],ht=!!ct&&("boolean"==typeof ct||ct.capture),it=arguments[1];if(!it)return Et.apply(this,arguments);if($t&&!$t(Et,it,Ce,arguments))return;const pt=De[Ke];let Mt;pt&&(Mt=pt[ht?c:f]);const It=Mt&&Ce[Mt];if(It)for(let En=0;En<It.length;En++){const gn=It[En];if(Dt(gn,it))return It.splice(En,1),gn.isRemoved=!0,0===It.length&&(gn.allRemoved=!0,Ce[Mt]=null,"string"==typeof Ke)&&(Ce[d+"ON_PROPERTY"+Ke]=null),gn.zone.cancelTask(gn),un?Ce:void 0}return Et.apply(this,arguments)},ot[ze]=function(){const Ce=this||re;let Ke=arguments[0];qe&&qe.transferEventName&&(Ke=qe.transferEventName(Ke));const ct=[],ht=Pt(Ce,Dn?Dn(Ke):Ke);for(let it=0;it<ht.length;it++){const pt=ht[it];ct.push(pt.originalDelegate?pt.originalDelegate:pt.callback)}return ct},ot[je]=function(){const Ce=this||re;let Ke=arguments[0];if(Ke){qe&&qe.transferEventName&&(Ke=qe.transferEventName(Ke));const ct=De[Ke];if(ct){const pt=Ce[ct[f]],Mt=Ce[ct[c]];if(pt){const It=pt.slice();for(let En=0;En<It.length;En++){const gn=It[En];this[xe].call(this,Ke,gn.originalDelegate?gn.originalDelegate:gn.callback,gn.options)}}if(Mt){const It=Mt.slice();for(let En=0;En<It.length;En++){const gn=It[En];this[xe].call(this,Ke,gn.originalDelegate?gn.originalDelegate:gn.callback,gn.options)}}}}else{const ct=Object.keys(Ce);for(let ht=0;ht<ct.length;ht++){const pt=ve.exec(ct[ht]);let Mt=pt&&pt[1];Mt&&"removeListener"!==Mt&&this[je].call(this,Mt)}this[je].call(this,"removeListener")}if(un)return this},Z(ot[be],Wt),Z(ot[xe],Et),wi&&Z(ot[je],wi),Ar&&Z(ot[ze],Ar),!0}let Nt=[];for(let ft=0;ft<ge.length;ft++)Nt[ft]=at(ge[ft],ye);return Nt}function Pt(re,le){if(!le){const xe=[];for(let ze in re){const je=ve.exec(ze);let Je=je&&je[1];if(Je&&(!le||Je===le)){const Xe=re[ze];if(Xe)for(let Ue=0;Ue<Xe.length;Ue++)xe.push(Xe[Ue])}}return xe}let ge=De[le];ge||(ke(le),ge=De[le]);const ye=re[ge[f]],be=re[ge[c]];return ye?be?ye.concat(be):ye.slice():be?be.slice():[]}function _t(re,le){const ge=re.Event;ge&&ge.prototype&&le.patchMethod(ge.prototype,"stopImmediatePropagation",ye=>function(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;ye<ge.length;ye++)G(re,ge[ye],(xe,ze,je)=>function(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<ge.length;Je++){const Xe=ge[Je],pe=ze+(Xe+xe),_e=ze+(Xe+be);ye[Xe]={},ye[Xe][xe]=pe,ye[Xe][be]=_e}const je=re.EventTarget;je&&je.prototype&&le.patchEventTarget(re,le,[je&&je.prototype])}(re,ge);const ye=re.XMLHttpRequestEventTarget;ye&&ye.prototype&&ge.patchEventTarget(re,ge,[ye.prototype])}),Zone.__load_patch("MutationObserver",(re,le,ge)=>{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<ye.length;be++){const xe=le[ye[be]];xe&&xe.prototype&&nn(xe.prototype,cn(xe.prototype),ge)}}(ge,re)}),Zone.__load_patch("customElements",(re,le,ge)=>{!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<le.length;ye++){const be=le[ye],xe=re[be];if(xe){if(!T(Q(re,be)))continue;re[be]=(je=>{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<E.length;++v)null!=S[E[v]]&&(this[E[v]]=S[E[v]])}var b;return d.prototype.subscriptions=c.emptyArray,d.prototype.messages=c.emptyArray,d.prototype.control=null,Object.defineProperty(d.prototype,"_control",{get:c.oneOfGetter(b=["control"]),set:c.oneOfSetter(b)}),d.encode=function(E,v){if(v||(v=h.create()),null!=E.subscriptions&&E.subscriptions.length)for(var p=0;p<E.subscriptions.length;++p)f.RPC.SubOpts.encode(E.subscriptions[p],v.uint32(10).fork()).ldelim();if(null!=E.messages&&E.messages.length)for(p=0;p<E.messages.length;++p)f.RPC.Message.encode(E.messages[p],v.uint32(18).fork()).ldelim();return null!=E.control&&Object.hasOwnProperty.call(E,"control")&&f.RPC.ControlMessage.encode(E.control,v.uint32(26).fork()).ldelim(),v},d.decode=function(E,v){E instanceof m||(E=m.create(E));for(var p=void 0===v?E.len:E.pos+v,I=new f.RPC;E.pos<p;){var A=E.uint32();switch(A>>>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<E.subscriptions.length;++p){if("object"!=typeof E.subscriptions[p])throw TypeError(".RPC.subscriptions: object expected");v.subscriptions[p]=f.RPC.SubOpts.fromObject(E.subscriptions[p])}}if(E.messages){if(!Array.isArray(E.messages))throw TypeError(".RPC.messages: array expected");for(v.messages=[],p=0;p<E.messages.length;++p){if("object"!=typeof E.messages[p])throw TypeError(".RPC.messages: object expected");v.messages[p]=f.RPC.Message.fromObject(E.messages[p])}}if(null!=E.control){if("object"!=typeof E.control)throw TypeError(".RPC.control: object expected");v.control=f.RPC.ControlMessage.fromObject(E.control)}return v},d.toObject=function(E,v){v||(v={});var p={};if((v.arrays||v.defaults)&&(p.subscriptions=[],p.messages=[]),E.subscriptions&&E.subscriptions.length){p.subscriptions=[];for(var I=0;I<E.subscriptions.length;++I)p.subscriptions[I]=f.RPC.SubOpts.toObject(E.subscriptions[I],v)}if(E.messages&&E.messages.length)for(p.messages=[],I=0;I<E.messages.length;++I)p.messages[I]=f.RPC.Message.toObject(E.messages[I],v);return null!=E.control&&E.hasOwnProperty("control")&&(p.control=f.RPC.ControlMessage.toObject(E.control,v),v.oneofs&&(p._control="control")),p},d.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},d.SubOpts=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I<p.length;++I)null!=v[p[I]]&&(this[p[I]]=v[p[I]])}var E;return S.prototype.subscribe=null,S.prototype.topic=null,Object.defineProperty(S.prototype,"_subscribe",{get:c.oneOfGetter(E=["subscribe"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_topic",{get:c.oneOfGetter(E=["topic"]),set:c.oneOfSetter(E)}),S.encode=function(p,I){return I||(I=h.create()),null!=p.subscribe&&Object.hasOwnProperty.call(p,"subscribe")&&I.uint32(8).bool(p.subscribe),null!=p.topic&&Object.hasOwnProperty.call(p,"topic")&&I.uint32(18).string(p.topic),I},S.decode=function(p,I){p instanceof m||(p=m.create(p));for(var A=void 0===I?p.len:p.pos+I,P=new f.RPC.SubOpts;p.pos<A;){var D=p.uint32();switch(D>>>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<p.length;++I)null!=v[p[I]]&&(this[p[I]]=v[p[I]])}var E;return S.prototype.from=null,S.prototype.data=null,S.prototype.seqno=null,S.prototype.topic="",S.prototype.signature=null,S.prototype.key=null,Object.defineProperty(S.prototype,"_from",{get:c.oneOfGetter(E=["from"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_data",{get:c.oneOfGetter(E=["data"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_seqno",{get:c.oneOfGetter(E=["seqno"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_signature",{get:c.oneOfGetter(E=["signature"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_key",{get:c.oneOfGetter(E=["key"]),set:c.oneOfSetter(E)}),S.encode=function(p,I){return I||(I=h.create()),null!=p.from&&Object.hasOwnProperty.call(p,"from")&&I.uint32(10).bytes(p.from),null!=p.data&&Object.hasOwnProperty.call(p,"data")&&I.uint32(18).bytes(p.data),null!=p.seqno&&Object.hasOwnProperty.call(p,"seqno")&&I.uint32(26).bytes(p.seqno),I.uint32(34).string(p.topic),null!=p.signature&&Object.hasOwnProperty.call(p,"signature")&&I.uint32(42).bytes(p.signature),null!=p.key&&Object.hasOwnProperty.call(p,"key")&&I.uint32(50).bytes(p.key),I},S.decode=function(p,I){p instanceof m||(p=m.create(p));for(var A=void 0===I?p.len:p.pos+I,P=new f.RPC.Message;p.pos<A;){var D=p.uint32();switch(D>>>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<v.length;++p)null!=E[v[p]]&&(this[v[p]]=E[v[p]])}return S.prototype.ihave=c.emptyArray,S.prototype.iwant=c.emptyArray,S.prototype.graft=c.emptyArray,S.prototype.prune=c.emptyArray,S.encode=function(v,p){if(p||(p=h.create()),null!=v.ihave&&v.ihave.length)for(var I=0;I<v.ihave.length;++I)f.RPC.ControlIHave.encode(v.ihave[I],p.uint32(10).fork()).ldelim();if(null!=v.iwant&&v.iwant.length)for(I=0;I<v.iwant.length;++I)f.RPC.ControlIWant.encode(v.iwant[I],p.uint32(18).fork()).ldelim();if(null!=v.graft&&v.graft.length)for(I=0;I<v.graft.length;++I)f.RPC.ControlGraft.encode(v.graft[I],p.uint32(26).fork()).ldelim();if(null!=v.prune&&v.prune.length)for(I=0;I<v.prune.length;++I)f.RPC.ControlPrune.encode(v.prune[I],p.uint32(34).fork()).ldelim();return p},S.decode=function(v,p){v instanceof m||(v=m.create(v));for(var I=void 0===p?v.len:v.pos+p,A=new f.RPC.ControlMessage;v.pos<I;){var P=v.uint32();switch(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<v.ihave.length;++I){if("object"!=typeof v.ihave[I])throw TypeError(".RPC.ControlMessage.ihave: object expected");p.ihave[I]=f.RPC.ControlIHave.fromObject(v.ihave[I])}}if(v.iwant){if(!Array.isArray(v.iwant))throw TypeError(".RPC.ControlMessage.iwant: array expected");for(p.iwant=[],I=0;I<v.iwant.length;++I){if("object"!=typeof v.iwant[I])throw TypeError(".RPC.ControlMessage.iwant: object expected");p.iwant[I]=f.RPC.ControlIWant.fromObject(v.iwant[I])}}if(v.graft){if(!Array.isArray(v.graft))throw TypeError(".RPC.ControlMessage.graft: array expected");for(p.graft=[],I=0;I<v.graft.length;++I){if("object"!=typeof v.graft[I])throw TypeError(".RPC.ControlMessage.graft: object expected");p.graft[I]=f.RPC.ControlGraft.fromObject(v.graft[I])}}if(v.prune){if(!Array.isArray(v.prune))throw TypeError(".RPC.ControlMessage.prune: array expected");for(p.prune=[],I=0;I<v.prune.length;++I){if("object"!=typeof v.prune[I])throw TypeError(".RPC.ControlMessage.prune: object expected");p.prune[I]=f.RPC.ControlPrune.fromObject(v.prune[I])}}return p},S.toObject=function(v,p){p||(p={});var I={};if((p.arrays||p.defaults)&&(I.ihave=[],I.iwant=[],I.graft=[],I.prune=[]),v.ihave&&v.ihave.length){I.ihave=[];for(var A=0;A<v.ihave.length;++A)I.ihave[A]=f.RPC.ControlIHave.toObject(v.ihave[A],p)}if(v.iwant&&v.iwant.length)for(I.iwant=[],A=0;A<v.iwant.length;++A)I.iwant[A]=f.RPC.ControlIWant.toObject(v.iwant[A],p);if(v.graft&&v.graft.length)for(I.graft=[],A=0;A<v.graft.length;++A)I.graft[A]=f.RPC.ControlGraft.toObject(v.graft[A],p);if(v.prune&&v.prune.length)for(I.prune=[],A=0;A<v.prune.length;++A)I.prune[A]=f.RPC.ControlPrune.toObject(v.prune[A],p);return I},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlIHave=function(){function S(v){if(this.messageIDs=[],v)for(var p=Object.keys(v),I=0;I<p.length;++I)null!=v[p[I]]&&(this[p[I]]=v[p[I]])}var E;return S.prototype.topicID=null,S.prototype.messageIDs=c.emptyArray,Object.defineProperty(S.prototype,"_topicID",{get:c.oneOfGetter(E=["topicID"]),set:c.oneOfSetter(E)}),S.encode=function(p,I){if(I||(I=h.create()),null!=p.topicID&&Object.hasOwnProperty.call(p,"topicID")&&I.uint32(10).string(p.topicID),null!=p.messageIDs&&p.messageIDs.length)for(var A=0;A<p.messageIDs.length;++A)I.uint32(18).bytes(p.messageIDs[A]);return I},S.decode=function(p,I){p instanceof m||(p=m.create(p));for(var A=void 0===I?p.len:p.pos+I,P=new f.RPC.ControlIHave;p.pos<A;){var D=p.uint32();switch(D>>>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<p.messageIDs.length;++A)"string"==typeof p.messageIDs[A]?c.base64.decode(p.messageIDs[A],I.messageIDs[A]=c.newBuffer(c.base64.length(p.messageIDs[A])),0):p.messageIDs[A].length&&(I.messageIDs[A]=p.messageIDs[A])}return I},S.toObject=function(p,I){I||(I={});var A={};if((I.arrays||I.defaults)&&(A.messageIDs=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),p.messageIDs&&p.messageIDs.length){A.messageIDs=[];for(var P=0;P<p.messageIDs.length;++P)A.messageIDs[P]=I.bytes===String?c.base64.encode(p.messageIDs[P],0,p.messageIDs[P].length):I.bytes===Array?Array.prototype.slice.call(p.messageIDs[P]):p.messageIDs[P]}return A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlIWant=function(){function S(E){if(this.messageIDs=[],E)for(var v=Object.keys(E),p=0;p<v.length;++p)null!=E[v[p]]&&(this[v[p]]=E[v[p]])}return S.prototype.messageIDs=c.emptyArray,S.encode=function(v,p){if(p||(p=h.create()),null!=v.messageIDs&&v.messageIDs.length)for(var I=0;I<v.messageIDs.length;++I)p.uint32(10).bytes(v.messageIDs[I]);return p},S.decode=function(v,p){v instanceof m||(v=m.create(v));for(var I=void 0===p?v.len:v.pos+p,A=new f.RPC.ControlIWant;v.pos<I;){var P=v.uint32();P>>>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<v.messageIDs.length;++I)"string"==typeof v.messageIDs[I]?c.base64.decode(v.messageIDs[I],p.messageIDs[I]=c.newBuffer(c.base64.length(v.messageIDs[I])),0):v.messageIDs[I].length&&(p.messageIDs[I]=v.messageIDs[I])}return p},S.toObject=function(v,p){p||(p={});var I={};if((p.arrays||p.defaults)&&(I.messageIDs=[]),v.messageIDs&&v.messageIDs.length){I.messageIDs=[];for(var A=0;A<v.messageIDs.length;++A)I.messageIDs[A]=p.bytes===String?c.base64.encode(v.messageIDs[A],0,v.messageIDs[A].length):p.bytes===Array?Array.prototype.slice.call(v.messageIDs[A]):v.messageIDs[A]}return I},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlGraft=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I<p.length;++I)null!=v[p[I]]&&(this[p[I]]=v[p[I]])}var E;return S.prototype.topicID=null,Object.defineProperty(S.prototype,"_topicID",{get:c.oneOfGetter(E=["topicID"]),set:c.oneOfSetter(E)}),S.encode=function(p,I){return I||(I=h.create()),null!=p.topicID&&Object.hasOwnProperty.call(p,"topicID")&&I.uint32(10).string(p.topicID),I},S.decode=function(p,I){p instanceof m||(p=m.create(p));for(var A=void 0===I?p.len:p.pos+I,P=new f.RPC.ControlGraft;p.pos<A;){var D=p.uint32();D>>>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<p.length;++I)null!=v[p[I]]&&(this[p[I]]=v[p[I]])}var E;return S.prototype.topicID=null,S.prototype.peers=c.emptyArray,S.prototype.backoff=null,Object.defineProperty(S.prototype,"_topicID",{get:c.oneOfGetter(E=["topicID"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_backoff",{get:c.oneOfGetter(E=["backoff"]),set:c.oneOfSetter(E)}),S.encode=function(p,I){if(I||(I=h.create()),null!=p.topicID&&Object.hasOwnProperty.call(p,"topicID")&&I.uint32(10).string(p.topicID),null!=p.peers&&p.peers.length)for(var A=0;A<p.peers.length;++A)f.RPC.PeerInfo.encode(p.peers[A],I.uint32(18).fork()).ldelim();return null!=p.backoff&&Object.hasOwnProperty.call(p,"backoff")&&I.uint32(24).uint64(p.backoff),I},S.decode=function(p,I){p instanceof m||(p=m.create(p));for(var A=void 0===I?p.len:p.pos+I,P=new f.RPC.ControlPrune;p.pos<A;){var D=p.uint32();switch(D>>>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<p.peers.length;++A){if("object"!=typeof p.peers[A])throw TypeError(".RPC.ControlPrune.peers: object expected");I.peers[A]=f.RPC.PeerInfo.fromObject(p.peers[A])}}return null!=p.backoff&&(c.Long?(I.backoff=c.Long.fromValue(p.backoff)).unsigned=!0:"string"==typeof p.backoff?I.backoff=parseInt(p.backoff,10):"number"==typeof p.backoff?I.backoff=p.backoff:"object"==typeof p.backoff&&(I.backoff=new c.LongBits(p.backoff.low>>>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<p.peers.length;++P)A.peers[P]=f.RPC.PeerInfo.toObject(p.peers[P],I)}return null!=p.backoff&&p.hasOwnProperty("backoff")&&(A.backoff="number"==typeof p.backoff?I.longs===String?String(p.backoff):p.backoff:I.longs===String?c.Long.prototype.toString.call(p.backoff):I.longs===Number?new c.LongBits(p.backoff.low>>>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<p.length;++I)null!=v[p[I]]&&(this[p[I]]=v[p[I]])}var E;return S.prototype.peerID=null,S.prototype.signedPeerRecord=null,Object.defineProperty(S.prototype,"_peerID",{get:c.oneOfGetter(E=["peerID"]),set:c.oneOfSetter(E)}),Object.defineProperty(S.prototype,"_signedPeerRecord",{get:c.oneOfGetter(E=["signedPeerRecord"]),set:c.oneOfSetter(E)}),S.encode=function(p,I){return I||(I=h.create()),null!=p.peerID&&Object.hasOwnProperty.call(p,"peerID")&&I.uint32(10).bytes(p.peerID),null!=p.signedPeerRecord&&Object.hasOwnProperty.call(p,"signedPeerRecord")&&I.uint32(18).bytes(p.signedPeerRecord),I},S.decode=function(p,I){p instanceof m||(p=m.create(p));for(var A=void 0===I?p.len:p.pos+I,P=new f.RPC.PeerInfo;p.pos<A;){var D=p.uint32();switch(D>>>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)}]); |