var N$=Object.defineProperty,M$=(q,V,x)=>V in q?N$(q,V,{enumerable:!0,configurable:!0,writable:!0,value:x}):q[V]=x,nf=(q,V,x)=>(M$(q,"symbol"!=typeof V?V+"":V,x),x),z2=(q,V,x)=>{if(!V.has(q))throw TypeError("Cannot "+x)},ta=(q,V,x)=>(z2(q,V,"read from private field"),x?x.call(q):V.get(q)),up=(q,V,x)=>{if(V.has(q))throw TypeError("Cannot add the same private member more than once");V instanceof WeakSet?V.add(q):V.set(q,x)},bo=(q,V,x,y)=>(z2(q,V,"write to private field"),y?y.call(q,x):V.set(q,x),x),nb=(q,V,x,y)=>({set _(u){bo(q,V,u,x)},get _(){return ta(q,V,y)}});(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{1882:(q,V,x)=>{var Ks,ka,La,y={};x.r(y),x.d(y,{identity:()=>X4});var u={};x.r(u),x.d(u,{base2:()=>J4});var g={};x.r(g),x.d(g,{base8:()=>e6});var w={};x.r(w),x.d(w,{base10:()=>t6});var m={};x.r(m),x.d(m,{base16:()=>n6,base16upper:()=>r6});var h={};x.r(h),x.d(h,{base32:()=>ao,base32hex:()=>a6,base32hexpad:()=>u6,base32hexpadupper:()=>l6,base32hexupper:()=>c6,base32pad:()=>s6,base32padupper:()=>o6,base32upper:()=>i6,base32z:()=>f6});var c={};x.r(c),x.d(c,{base36:()=>d6,base36upper:()=>h6});var f={};x.r(f),x.d(f,{base58btc:()=>oi,base58flickr:()=>p6});var d={};x.r(d),x.d(d,{base64:()=>$d,base64pad:()=>g6,base64url:()=>y6,base64urlpad:()=>m6});var b={};x.r(b),x.d(b,{base256emoji:()=>_6});var I={};x.r(I),x.d(I,{sha256:()=>pi,sha512:()=>$6});var E={};x.r(E),x.d(E,{identity:()=>Mc});var v={};x.r(v),x.d(v,{code:()=>z6,decode:()=>q6,encode:()=>W6,name:()=>G6});var p={};x.r(p),x.d(p,{code:()=>X6,decode:()=>e5,encode:()=>J6,name:()=>Z6});var D={};x.r(D),x.d(D,{RsaPrivateKey:()=>eh,RsaPublicKey:()=>G0,fromJwk:()=>j5,generateKeyPair:()=>G5,unmarshalRsaPrivateKey:()=>K5,unmarshalRsaPublicKey:()=>$5});var A={};x.r(A),x.d(A,{Ed25519PrivateKey:()=>Sl,Ed25519PublicKey:()=>dm,generateKeyPair:()=>mF,generateKeyPairFromSeed:()=>vF,unmarshalEd25519PrivateKey:()=>gF,unmarshalEd25519PublicKey:()=>yF});var P={};function S(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:()=>vm,Secp256k1PublicKey:()=>mm,generateKeyPair:()=>TF,unmarshalSecp256k1PrivateKey:()=>CF,unmarshalSecp256k1PublicKey:()=>DF});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(S(r))try{r()}catch(s){e=s instanceof M?s.errors:[s]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const s of i)try{O(s)}catch(o){e=e??[],o instanceof M?e=[...e,...o.errors]:e.push(o)}}if(e)throw new M(e)}}add(e){var t;if(e&&e!==this)if(this.closed)O(e);else{if(e instanceof F){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(t=this._finalizers)&&void 0!==t?t:[]).push(e)}}_hasParent(e){const{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){const{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){const{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&k(t,e)}remove(e){const{_finalizers:t}=this;t&&k(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const j=F.EMPTY;function C(n){return n instanceof F||n&&"closed"in n&&S(n.remove)&&S(n.add)&&S(n.unsubscribe)}function O(n){S(n)?n():n.unsubscribe()}const H={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout(n,e,...t){const{delegate:r}=L;return r?.setTimeout?r.setTimeout(n,e,...t):setTimeout(n,e,...t)},clearTimeout(n){const{delegate:e}=L;return(e?.clearTimeout||clearTimeout)(n)},delegate:void 0};function K(n){L.setTimeout(()=>{const{onUnhandledError:e}=H;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(H.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=Rt}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 Se(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(),S(e)||!e)i={next:e??void 0,error:t??void 0,complete:r??void 0};else{let s;this&&H.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&Se(e.next,s),error:e.error&&Se(e.error,s),complete:e.complete&&Se(e.complete,s)}):i=e}this.destination=new Be(i)}}function He(n){H.useDeprecatedSynchronousErrorHandling?function de(n){H.useDeprecatedSynchronousErrorHandling&&te&&(te.errorThrown=!0,te.error=n)}(n):K(n)}function nt(n,e){const{onStoppedNotification:t}=H;t&&L.setTimeout(()=>t(n,e))}const Rt={closed:!0,next:ne,error:function ke(n){throw n},complete:ne},_t="function"==typeof Symbol&&Symbol.observable||"@@observable";function Bt(n){return n}let sn=(()=>{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 vn(n){return n&&n instanceof he||function Ar(n){return n&&S(n.next)&&S(n.error)&&S(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=Un(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 en(n){return 0===n.length?Bt:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=Un(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function Un(n){var e;return null!==(e=n??H.Promise)&&void 0!==e?e:Promise}const Li=T(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let Qr=(()=>{class n extends sn{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){const r=new ns(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Li}next(t){oe(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(t)}})}error(t){oe(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=t;const{observers:r}=this;for(;r.length;)r.shift().error(t)}})}complete(){oe(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:t}=this;for(;t.length;)t.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0}_trySubscribe(t){return this._throwIfClosed(),super._trySubscribe(t)}_subscribe(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)}_innerSubscribe(t){const{hasError:r,isStopped:i,observers:s}=this;return r||i?j:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,k(s,t)}))}_checkFinalizedStatuses(t){const{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){const t=new sn;return t.source=this,t}}return n.create=(e,t)=>new ns(e,t),n})();class ns 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:j}}function le(n){return e=>{if(function ie(n){return S(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 Ht(n){return this instanceof Ht?(this.v=n,this):new Ht(n)}function Sn(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(U){return new Promise(function(Y,X){s.push([B,U,Y,X])>1||a(B,U)})})}function a(B,U){try{!function l(B){B.value instanceof Ht?Promise.resolve(B.value.v).then(_,R):N(s[0][2],B)}(r[B](U))}catch(Y){N(s[0][3],Y)}}function _(B){a("next",B)}function R(B){a("throw",B)}function N(B,U){B(U),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 An=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function Vr(n){return S(n?.then)}function _r(n){return S(n[_t])}function Rn(n){return Symbol.asyncIterator&&S(n?.[Symbol.asyncIterator])}function Kt(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 S(n?.[ce])}function ft(n){return Sn(this,arguments,function*(){const t=n.getReader();try{for(;;){const{value:r,done:i}=yield Ht(t.read());if(i)return yield Ht(void 0);yield yield Ht(r)}}finally{t.releaseLock()}})}function St(n){return S(n?.getReader)}function In(n){if(n instanceof sn)return n;if(null!=n){if(_r(n))return function Ve(n){return new sn(e=>{const t=n[_t]();if(S(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(n);if(An(n))return function Ge(n){return new sn(e=>{for(let t=0;t{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,K)})}(n);if(Rn(n))return ct(n);if(me(n))return function Ke(n){return new sn(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(St(n))return function pt(n){return ct(ft(n))}(n)}throw Kt(n)}function ct(n){return new sn(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 gt(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 Dt(n,e,t=1/0){return S(e)?Dt((r,i)=>function we(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))(In(n(r,i))),t):("number"==typeof e&&(t=e),le((r,i)=>function Nt(n,e,t,r,i,s,o,a){const l=[];let _=0,R=0,N=!1;const B=()=>{N&&!l.length&&!_&&e.complete()},U=X=>_{s&&e.next(X),_++;let re=!1;In(t(X,R++)).subscribe(ge(e,fe=>{i?.(fe),s?U(fe):e.next(fe)},()=>{re=!0},void 0,()=>{if(re)try{for(_--;l.length&&_Y(fe)):Y(fe)}B()}catch(fe){e.error(fe)}}))};return n.subscribe(ge(e,U,()=>{N=!0,B()})),()=>{a?.()}}(r,i,n,t)))}const fn=new sn(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=>gt(r,n,()=>r.next(i),e),()=>gt(r,n,()=>r.complete(),e),i=>gt(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 sn(t=>{gt(t,e,()=>{const r=n[Symbol.asyncIterator]();gt(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function Zr(...n){const e=function ra(n){return function na(n){return n&&S(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?In(r[0]):function gn(n=1/0){return Dt(Bt,n)}(t)(function ui(n,e){return e?function lr(n,e){if(null!=n){if(_r(n))return function ue(n,e){return In(n).pipe(J(e),Q(e))}(n,e);if(An(n))return function Oe(n,e){return new sn(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}(n,e);if(Vr(n))return function Re(n,e){return In(n).pipe(J(e),Q(e))}(n,e);if(Rn(n))return $e(n,e);if(me(n))return function qe(n,e){return new sn(t=>{let r;return gt(t,e,()=>{r=n[ce](),gt(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)}),()=>S(r?.return)&&r.return()})}(n,e);if(St(n))return function Yt(n,e){return $e(ft(n),e)}(n,e)}throw Kt(n)}(n,e):In(n)}(r,e)):fn}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 $t(n){for(let e in n)if(n[e]===$t)return e;throw Error("Could not find renamed property on target object.")}function cn(n){if("string"==typeof n)return n;if(Array.isArray(n))return"["+n.map(cn).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 Bi(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const pu=$t({__forward_ref__:$t});function fp(n){return n.__forward_ref__=fp,n.toString=function(){return cn(this())},n}function wt(n){return function dp(n){return"function"==typeof n&&n.hasOwnProperty(pu)&&n.__forward_ref__===fp}(n)?n():n}class vt extends Error{constructor(e,t){super(function sf(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 of(n,e){throw new vt(-201,!1)}function Si(n,e){null==n&&function yn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function Hn(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 af(n){return rb(n,cf)||rb(n,sb)}function rb(n,e){return n.hasOwnProperty(e)?n[e]:null}function ib(n){return n&&(n.hasOwnProperty(hp)||n.hasOwnProperty(eA))?n[hp]:null}const cf=$t({\u0275prov:$t}),hp=$t({\u0275inj:$t}),sb=$t({ngInjectableDef:$t}),eA=$t({ngInjectorDef:$t});var It=(()=>((It=It||{})[It.Default=0]="Default",It[It.Host=1]="Host",It[It.Self=2]="Self",It[It.SkipSelf=4]="SkipSelf",It[It.Optional=8]="Optional",It))();let pp;function Fi(n){const e=pp;return pp=n,e}function ob(n,e,t){const r=af(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&It.Optional?null:void 0!==e?e:void of(cn(n))}function So(n){return{toString:n}.toString()}var ss=(()=>((ss=ss||{})[ss.OnPush=0]="OnPush",ss[ss.Default=1]="Default",ss))(),Ds=(()=>{return(n=Ds||(Ds={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",Ds;var n})();const kn=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),Fa={},hn=[],uf=$t({\u0275cmp:$t}),gp=$t({\u0275dir:$t}),yp=$t({\u0275pipe:$t}),ab=$t({\u0275mod:$t}),js=$t({\u0275fac:$t}),gu=$t({__NG_ELEMENT_ID__:$t});let nA=0;function lf(n){return So(()=>{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===ss.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||hn,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||Ds.Emulated,id:"c"+nA++,styles:n.styles||hn,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=lb(n.inputs,r),i.outputs=lb(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(cb).filter(ub):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(ei).filter(ub):null,i})}function cb(n){return bn(n)||Jr(n)}function ub(n){return null!==n}function yu(n){return So(()=>({type:n.type,bootstrap:n.bootstrap||hn,declarations:n.declarations||hn,imports:n.imports||hn,exports:n.exports||hn,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function lb(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 Ui=lf;function bn(n){return n[uf]||null}function Jr(n){return n[gp]||null}function ei(n){return n[yp]||null}function fi(n){return Array.isArray(n)&&"object"==typeof n[1]}function as(n){return Array.isArray(n)&&!0===n[1]}function Ep(n){return 0!=(8&n.flags)}function pf(n){return 2==(2&n.flags)}function gf(n){return 1==(1&n.flags)}function cs(n){return null!==n.template}function cA(n){return 0!=(256&n[2])}function ca(n,e){return n.hasOwnProperty(js)?n[js]:null}class fA{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function hb(n){return n.type.prototype.ngOnChanges&&(n.setInput=hA),dA}function dA(){const n=gb(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 hA(n,e,t,r){const i=gb(n)||function pA(n,e){return n[pb]=e}(n,{previous:Fa,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],l=o[a];s[a]=new fA(l&&l.currentValue,e,o===Fa),n[r]=e}const pb="__ngSimpleChanges__";function gb(n){return n[pb]||null}function fr(n){for(;Array.isArray(n);)n=n[0];return n}function Ki(n,e){return fr(e[n.index])}function Ip(n,e){return n.data[e]}function Di(n,e){const t=e[n];return fi(t)?t:t[0]}function vf(n){return 64==(64&n[2])}function Io(n,e){return null==e?null:n[e]}function yb(n){n[18]=0}function Cp(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:Db(null),bindingsEnabled:!0};function vb(){return Ct.bindingsEnabled}function Me(){return Ct.lFrame.lView}function nn(){return Ct.lFrame.tView}function Sr(){let n=Eb();for(;null!==n&&64===n.type;)n=n.parent;return n}function Eb(){return Ct.lFrame.currentTNode}function Ts(n,e){const t=Ct.lFrame;t.currentTNode=n,t.isParent=e}function Dp(){return Ct.lFrame.isParent}function $a(){return Ct.lFrame.bindingIndex++}function PA(n,e){const t=Ct.lFrame;t.bindingIndex=t.bindingRootIndex=n,xp(e)}function xp(n){Ct.lFrame.currentDirectiveIndex=n}function Rp(n){Ct.lFrame.currentQueryIndex=n}function MA(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function Ib(n,e,t){if(t&It.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&It.Host||(i=MA(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=Ct.lFrame=Cb();return r.currentTNode=e,r.lView=n,!0}function Pp(n){const e=Cb(),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 Cb(){const n=Ct.lFrame,e=null===n?null:n.child;return null===e?Db(n):e}function Db(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 Tb(){const n=Ct.lFrame;return Ct.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const xb=Tb;function Np(){const n=Tb();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 ni(){return Ct.lFrame.selectedIndex}function Co(n){Ct.lFrame.selectedIndex=n}function Ef(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[l]<0&&(n[18]+=65536),(a>11>16&&(3&n[2])===e){n[2]+=2048;try{s.call(a)}finally{}}}else try{s.call(a)}finally{}}class Su{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function _f(n,e,t){let r=0;for(;re){o=s-1;break}}}for(;s>16}(n),r=e;for(;t>0;)r=r[15],t--;return r}let kp=!0;function If(n){const e=kp;return kp=n,e}let qA=0;const xs={};function Cu(n,e){const t=Bp(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Lp(r.data,n),Lp(e,null),Lp(r.blueprint,null));const i=Cf(n,e),s=n.injectorIndex;if(Mb(i)){const o=ja(i),a=Ga(i,e),l=a[1].data;for(let _=0;_<8;_++)e[s+_]=a[o+_]|l[o+_]}return e[s+8]=i,s}function Lp(n,e){n.push(0,0,0,0,0,0,0,0,e)}function Bp(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function Cf(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=Kb(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 YA(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(gu)&&(r=t[gu]),null==r&&(r=t[gu]=qA++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:JA:e}(t);if("function"==typeof s){if(!Ib(e,n,r))return r&It.Host?Lb(i,0,r):Bb(e,t,r,i);try{const o=s(r);if(null!=o||r&It.Optional)return o;of()}finally{xb()}}else if("number"==typeof s){let o=null,a=Bp(n,e),l=-1,_=r&It.Host?e[16][6]:null;for((-1===a||r&It.SkipSelf)&&(l=-1===a?Cf(n,e):e[a+8],-1!==l&&Hb(r,!1)?(o=e[1],a=ja(l),e=Ga(l,e)):a=-1);-1!==a;){const R=e[1];if(Vb(s,a,R.data)){const N=ZA(a,e,t,o,r,_);if(N!==xs)return N}l=e[a+8],-1!==l&&Hb(r,e[1].data[a+8]===_)&&Vb(s,a,e)?(o=R,a=ja(l),e=Ga(l,e)):a=-1}}return i}function ZA(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],R=function Tf(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 U=r?a:a+R;U=l&&Y.type===t)return U}if(i){const U=o[l];if(U&&cs(U)&&U.type===t)return l}return null}(a,o,t,null==r?pf(a)&&kp:r!=o&&0!=(3&a.type),i&It.Host&&s===a);return null!==R?Du(e,o,R,a):xs}function Du(n,e,t,r){let i=n[t];const s=e.data;if(function $A(n){return n instanceof Su}(i)){const o=i;o.resolving&&function W2(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new vt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function dn(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=If(o.canSeeViewProviders);o.resolving=!0;const l=o.injectImpl?Fi(o.injectImpl):null;Ib(n,r,It.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function HA(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=hb(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&&Fi(l),If(a),o.resolving=!1,xb()}}return i}function Vb(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function Vp(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 Qt{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=Hn({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 jb(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function xf(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const Ru={},jp="__NG_DI_FLAG__",Rf="ngTempTokenPath",hR=/\n/gm,qb="__source";let Pu;function Xa(n){const e=Pu;return Pu=n,e}function gR(n,e=It.Default){if(void 0===Pu)throw new vt(-203,!1);return null===Pu?ob(n,void 0,e):Pu.get(n,e&It.Optional?null:void 0,e)}function mn(n,e=It.Default){return(function tA(){return pp}()||gR)(wt(n),e)}function Gp(n){const e=[];for(let t=0;t{const o=s;eg(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&ww(i,t),t}function ww(n,e){for(let t=0;t{e.push(s)})}}function eg(n,e,t,r){if(!(n=wt(n)))return!1;let i=null,s=ib(n);const o=!s&&bn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const l=n.ngModule;if(s=ib(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)eg(_,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let _;r.add(i);try{Ws(s.imports,R=>{eg(R,e,t,r)&&(_||(_=[]),_.push(R))})}finally{}void 0!==_&&ww(_,e)}if(!a){const _=ca(i)||(()=>new i);e.push({provide:i,useFactory:_,deps:hn},{provide:vw,useValue:i,multi:!0},{provide:yw,useValue:()=>mn(i),multi:!0})}const l=s.providers;null==l||a||Ws(l,R=>{e.push(R)})}}return i!==n&&void 0!==n.providers}const nP=$t({provide:String,useValue:$t});function tg(n){return null!==n&&"object"==typeof n&&nP in n}function ua(n){return"function"==typeof n}const ng=new Qt("Set Injector scope."),Ff={},iP={};let rg;function Uf(){return void 0===rg&&(rg=new Ew),rg}class tc{}class Iw extends tc{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,sg(e,o=>this.processProvider(o)),this.records.set(mw,nc(void 0,this)),i.has("environment")&&this.records.set(tc,nc(void 0,this));const s=this.records.get(ng);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(vw.multi,hn,It.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=Xa(this),r=Fi(void 0);try{return e()}finally{Xa(t),Fi(r)}}get(e,t=Ru,r=It.Default){this.assertNotDestroyed();const i=Xa(this),s=Fi(void 0);try{if(!(r&It.SkipSelf)){let a=this.records.get(e);if(void 0===a){const l=function uP(n){return"function"==typeof n||"object"==typeof n&&n instanceof Qt}(e)&&af(e);a=l&&this.injectableDefInScope(l)?nc(ig(e),Ff):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&It.Self?Uf():this.parent).get(e,t=r&It.Optional&&t===Ru?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[Rf]=o[Rf]||[]).unshift(cn(e)),i)throw o;return function vR(n,e,t,r){const i=n[Rf];throw e[qb]&&i.unshift(e[qb]),n.message=function ER(n,e,t,r=null){n=n&&"\n"===n.charAt(0)&&"\u0275"==n.charAt(1)?n.slice(2):n;let i=cn(e);if(Array.isArray(e))i=e.map(cn).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):cn(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(hR,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[Rf]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{Fi(s),Xa(i)}}resolveInjectorInitializers(){const e=Xa(this),t=Fi(void 0);try{const r=this.get(yw.multi,hn,It.Self);for(const i of r)i()}finally{Xa(e),Fi(t)}}toString(){const e=[],t=this.records;for(const r of t.keys())e.push(cn(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new vt(205,!1)}processProvider(e){let t=ua(e=wt(e))?e:wt(e&&e.provide);const r=function oP(n){return tg(n)?nc(void 0,n.useValue):nc(function Cw(n,e,t){let r;if(ua(n)){const i=wt(n);return ca(i)||ig(i)}if(tg(n))r=()=>wt(n.useValue);else if(function Sw(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...Gp(n.deps||[]));else if(function _w(n){return!(!n||!n.useExisting)}(n))r=()=>mn(wt(n.useExisting));else{const i=wt(n&&(n.useClass||n.provide));if(!function aP(n){return!!n.deps}(n))return ca(i)||ig(i);r=()=>new i(...Gp(n.deps))}return r}(n),Ff)}(e);if(ua(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=nc(void 0,Ff,!0),i.factory=()=>Gp(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===Ff&&(t.value=iP,t.value=t.factory()),"object"==typeof t.value&&t.value&&function cP(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=wt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function ig(n){const e=af(n),t=null!==e?e.factory:ca(n);if(null!==t)return t;if(n instanceof Qt)throw new vt(204,!1);if(n instanceof Function)return function sP(n){const e=n.length;if(e>0)throw function Au(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new vt(204,!1)}function nc(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function lP(n){return!!n.\u0275providers}function sg(n,e){for(const t of n)Array.isArray(t)?sg(t,e):lP(t)?sg(t.\u0275providers,e):e(t)}class Dw{}class hP{resolveComponentFactory(e){throw function dP(n){const e=Error(`No component factory found for ${cn(n)}. Did you add it to @NgModule.entryComponents?`);return e.ngComponent=n,e}(e)}}let Vf=(()=>{class n{}return n.NULL=new hP,n})();function pP(){return rc(Sr(),Me())}function rc(n,e){return new ic(Ki(n,e))}let ic=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=pP,n})();class xw{}let mP=(()=>{class n{}return n.\u0275prov=Hn({token:n,providedIn:"root",factory:()=>null}),n})();class og{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const vP=new og("14.2.11"),ag={};function dg(n){return n.ngOriginalError}class sc{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&&dg(e);for(;t&&dg(t);)t=dg(t);return t||null}}const hg=new Map;let RP=0;const gg="__ngContext__";function $r(n,e){fi(e)?(n[gg]=e[20],function NP(n){hg.set(n[20],n)}(e)):n[gg]=e}var di=(()=>((di=di||{})[di.Important=1]="Important",di[di.DashCase=2]="DashCase",di))();function mg(n,e){return undefined(n,e)}function Uu(n){const e=n[3];return as(e)?e[3]:e}function vg(n){return $w(n[13])}function Eg(n){return $w(n[4])}function $w(n){for(;null!==n&&!as(n);)n=n[4];return n}function ac(n,e,t,r,i){if(null!=r){let s,o=!1;as(r)?s=r:fi(r)&&(o=!0,r=r[0]);const a=fr(r);0===n&&null!==t?null==i?Yw(e,t,a):la(e,t,a,i||null,!0):1===n&&null!==t?la(e,t,a,i||null,!0):2===n?function n_(n,e,t){const r=Hf(n,e);r&&function sN(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function cN(n,e,t,r,i){const s=t[7];s!==fr(t)&&ac(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=xf(n,10+e);!function ZP(n,e){Vu(n,e,e[11],2,null,null),e[0]=null,e[6]=null}(r[1],r);const o=s[19];null!==o&&o.detachView(s[1]),r[3]=null,r[4]=null,r[2]&=-65}return r}function zw(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&Vu(n,e,t,3,null,null),function eN(n){let e=n[13];if(!e)return Sg(n[1],n);for(;e;){let t=null;if(fi(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)fi(e)&&Sg(e[1],e),e=e[3];null===e&&(e=n),fi(e)&&Sg(e[1],e),t=e&&e[4]}e=t}}(e)}}function Sg(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function iN(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=_]():r[i=-_].unsubscribe(),s+=2}else{const o=r[i=t[s+1]];t[s].call(o)}if(null!==r){for(let s=i+1;ss?"":i[N+1].toLowerCase();const U=8&r?B:null;if(U&&-1!==s_(U,_,0)||2&r&&_!==B){if(us(r))return!1;o=!0}}}}else{if(!o&&!us(r)&&!us(l))return!1;if(o&&us(l))continue;o=!1,r=l|1&r}}return us(r)||o}function us(n){return 0==(1&n)}function hN(n,e,t,r){if(null===e)return-1;let i=0;if(r||!t){let s=!1;for(;i-1)for(t++;t0?'="'+a+'"':"")+"]"}else 8&r?i+="."+o:4&r&&(i+=" "+o);else""!==i&&!us(o)&&(e+=u_(s,i),i=""),r=o,s=s||!us(r);t++}return""!==i&&(e+=u_(s,i)),e}const xt={};function Hu(n){l_(nn(),Me(),ni()+n,!1)}function l_(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&bf(e,s,t)}else{const s=n.preOrderHooks;null!==s&&wf(e,s,0,t)}Co(t)}function p_(n,e=null,t=null,r){const i=g_(n,e,t,r);return i.resolveInjectorInitializers(),i}function g_(n,e=null,t=null,r,i=new Set){const s=[t||hn,tP(n)];return r=r||("object"==typeof n?void 0:cn(n)),new Iw(s,e||Uf(),r||null,i)}let fa=(()=>{class n{static create(t,r){if(Array.isArray(t))return p_({name:""},r,t,"");{const i=t.name??"";return p_({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=Ru,n.NULL=new Ew,n.\u0275prov=Hn({token:n,providedIn:"any",factory:()=>mn(mw)}),n.__NG_ELEMENT_ID__=-1,n})();function Ut(n,e=It.Default){const t=Me();return null===t?mn(n,e):Fb(Sr(),t,wt(n),e)}function N_(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&l_(n,e,22,!1),t(r,i)}finally{Co(s)}}function jg(n,e,t){!vb()||(function oM(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||Cu(t,e),$r(r,e);const o=t.initialInputs;for(let a=i;a0;){const t=n[--e];if("number"==typeof t&&t<0)return t}return 0})(a)!=l&&a.push(l),a.push(r,i,o)}}function H_(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function K_(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function lM(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Yg(t)}}function Yg(n){for(let r=vg(n);null!==r;r=Eg(r))for(let i=10;i0&&Yg(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Yg(i)}}function mM(n,e){const t=Di(e,n),r=t[1];(function vM(n,e){for(let t=e.length;t-1&&(_g(e,r),xf(t,r))}this._attachedToViewContainer=!1}zw(this._lView[1],this._lView)}onDestroy(e){!function L_(n,e,t,r){const i=z_(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&W_(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(){Zf(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new vt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function JP(n,e){Vu(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new vt(902,!1);this._appRef=e}}class EM extends Ku{constructor(e){super(e),this._view=e}detectChanges(){const e=this._view;Zf(e[1],e,e[8],!1)}checkNoChanges(){}get context(){return null}}class Jg extends Vf{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){const t=bn(e);return new $u(t,this.ngModule)}}function Q_(n){const e=[];for(let t in n)n.hasOwnProperty(t)&&e.push({propName:n[t],templateName:t});return e}class wM{constructor(e,t){this.injector=e,this.parentInjector=t}get(e,t,r){const i=this.injector.get(e,ag,r);return i!==ag||t===ag?i:this.parentInjector.get(e,t,r)}}class $u extends Dw{constructor(e,t){super(),this.componentDef=e,this.ngModule=t,this.componentType=e.type,this.selector=function EN(n){return n.map(vN).join(",")}(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!t}get inputs(){return Q_(this.componentDef.inputs)}get outputs(){return Q_(this.componentDef.outputs)}create(e,t,r,i){let s=(i=i||this.ngModule)instanceof tc?i:i?.injector;s&&null!==this.componentDef.getStandaloneInjector&&(s=this.componentDef.getStandaloneInjector(s)||s);const o=s?new wM(e,s):e,a=o.get(xw,null);if(null===a)throw new vt(407,!1);const l=o.get(mP,null),_=a.createRenderer(null,this.componentDef),R=this.componentDef.selectors[0][0]||"div",N=r?function eM(n,e,t){return n.selectRootElement(e,t===Ds.ShadowDom)}(_,r,this.componentDef.encapsulation):wg(_,R,function bM(n){const e=n.toLowerCase();return"svg"===e?"svg":"math"===e?"math":null}(R)),B=this.componentDef.onPush?288:272,U=zg(0,null,null,1,0,null,null,null,null,null),Y=qf(null,U,null,B,null,null,a,_,l,o,null);let X,re;Pp(Y);try{const fe=function IM(n,e,t,r,i,s){const o=t[1];t[22]=n;const l=uc(o,22,2,"#host",null),_=l.mergedAttrs=e.hostAttrs;null!==_&&(Xf(l,_,!0),null!==n&&(_f(i,n,_),null!==l.classes&&Tg(i,n,l.classes),null!==l.styles&&i_(i,n,l.styles)));const R=r.createRenderer(n,e),N=qf(t,k_(e),null,e.onPush?32:16,t[22],l,r,R,s||null,null,null);return o.firstCreatePass&&(Df(Cu(l,t),o,e.type),K_(o,l),$_(l,t.length,1)),Qf(t,N),t[22]=N}(N,this.componentDef,Y,a,_);if(N)if(r)_f(_,N,["ng-version",vP.full]);else{const{attrs:Ie,classes:ae}=function bN(n){const e=[],t=[];let r=1,i=2;for(;r0&&Tg(_,N,ae.join(" "))}if(re=Ip(U,22),void 0!==t){const Ie=re.projection=[];for(let ae=0;aea(fr(Ue[r.index])):r.index;let De=null;if(!a&&l&&(De=function GM(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;sl?a[l]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==De)(De.__ngLastListenerFn__||De).__ngNextListenerFn__=s,De.__ngLastListenerFn__=s,U=!1;else{s=g1(r,e,N,s,!1);const Ue=t.listen(fe,i,s);B.push(s,Ue),R&&R.push(i,ae,Ie,Ie+1)}}else s=g1(r,e,N,s,!1);const Y=r.outputs;let X;if(U&&null!==Y&&(X=Y[i])){const re=X.length;if(re)for(let fe=0;fet()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class vy extends class Mk{}{constructor(e){super(),this.moduleType=e}create(e){return new NS(this.moduleType,e)}}function by(n){return e=>{setTimeout(n,void 0,e)}}const eo=class uL 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=by(s),i&&(i=by(i)),o&&(o=by(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let to=(()=>{class n{}return n.__NG_ELEMENT_ID__=hL,n})();const fL=to,dL=class extends fL{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=qf(this._declarationLView,r,e,16,null,r.declTNode,null,null,null,null,t||null);i[17]=this._declarationLView[this._declarationTContainer.index];const o=this._declarationLView[19];return null!==o&&(i[19]=o.createEmbeddedView(r)),$g(r,i,e),new Ku(i)}};function hL(){return function ud(n,e){return 4&n.type?new dL(e,n,rc(n,e)):null}(Sr(),Me())}let Ms=(()=>{class n{}return n.__NG_ELEMENT_ID__=pL,n})();function pL(){return function WS(n,e){let t;const r=e[n.index];if(as(r))t=r;else{let i;if(8&n.type)i=fr(r);else{const s=e[11];i=s.createComment("");const o=Ki(n,e);la(s,Hf(s,o),i,function oN(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=G_(r,e,i,n),Qf(e,t)}return new GS(t,n,e)}(Sr(),Me())}const gL=Ms,GS=class extends gL{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return rc(this._hostTNode,this._hostLView)}get injector(){return new za(this._hostTNode,this._hostLView)}get parentInjector(){const e=Cf(this._hostTNode,this._hostLView);if(Mb(e)){const t=Ga(e,this._hostLView),r=ja(e);return new za(t[1].data[r+8],t)}return new za(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=zS(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 xu(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(bn(e)),_=r||this.parentInjector;if(!s&&null==l.ngModule){const B=(o?_:this.parentInjector).get(tc,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 wA(n){return as(n[3])}(r)){const R=this.indexOf(e);if(-1!==R)this.detach(R);else{const N=r[3],B=new GS(N,N[6],N[3]);B.detach(B.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function tN(n,e,t,r){const i=10+r,s=t.length;r>0&&(t[i-1][4]=e),r{class n{constructor(t){this.appInits=t,this.resolve=fd,this.reject=fd,this.initialized=!1,this.done=!1,this.donePromise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}runInitializers(){if(this.initialized)return;const t=[],r=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let i=0;i{s.subscribe({complete:a,error:l})});t.push(o)}}Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),0===t.length&&r(),this.initialized=!0}}return n.\u0275fac=function(t){return new(t||n)(mn(mI,8))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const tl=new Qt("AppId",{providedIn:"root",factory:function vI(){return`${Ny()}${Ny()}${Ny()}`}});function Ny(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const EI=new Qt("Platform Initializer"),bI=new Qt("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),qL=new Qt("appBootstrapListener"),no=new Qt("LocaleId",{providedIn:"root",factory:()=>function yR(n,e=It.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),mn(n,e)}(no,It.Optional|It.SkipSelf)||function YL(){return typeof $localize<"u"&&$localize.locale||Sc}()}),e3=(()=>Promise.resolve(0))();function My(n){typeof Zone>"u"?e3.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class Gr{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new eo(!1),this.onMicrotaskEmpty=new eo(!1),this.onStable=new eo(!1),this.onError=new eo(!1),typeof Zone>"u")throw new vt(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 t3(){let n=kn.requestAnimationFrame,e=kn.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 i3(n){const e=()=>{!function r3(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(kn,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,ky(n),n.isCheckStableRunning=!0,Oy(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),ky(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return SI(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),II(n)}},onInvoke:(t,r,i,s,o,a,l)=>{try{return SI(n),t.invoke(i,s,o,a,l)}finally{n.shouldCoalesceRunChangeDetection&&e(),II(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,ky(n),Oy(n)):"macroTask"==s.change&&(n.hasPendingMacrotasks=s.macroTask))},onHandleError:(t,r,i,s)=>(t.handleError(i,s),n.runOutsideAngular(()=>n.onError.emit(s)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!Gr.isInAngularZone())throw new vt(909,!1)}static assertNotInAngularZone(){if(Gr.isInAngularZone())throw new vt(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,n3,fd,fd);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 n3={};function Oy(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 ky(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function SI(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function II(n){n._nesting--,Oy(n)}class s3{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new eo,this.onMicrotaskEmpty=new eo,this.onStable=new eo,this.onError=new eo}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 CI=new Qt(""),hd=new Qt("");let Fy,Ly=(()=>{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,Fy||(function o3(n){Fy=n}(i),i.addToWindow(r)),this._watchAngularEvents(),t.run(()=>{this.taskTrackingZone=typeof Zone>"u"?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{Gr.assertNotInAngularZone(),My(()=>{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())My(()=>{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)(mn(Gr),mn(By),mn(hd))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})(),By=(()=>{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 Fy?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Hn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),Ro=null;const DI=new Qt("AllowMultipleToken"),Uy=new Qt("PlatformDestroyListeners");function xI(n,e,t=[]){const r=`Platform: ${e}`,i=new Qt(r);return(s=[])=>{let o=Vy();if(!o||o.injector.get(DI,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function u3(n){if(Ro&&!Ro.get(DI,!1))throw new vt(400,!1);Ro=n;const e=n.get(RI);(function TI(n){const e=n.get(EI,null);e&&e.forEach(t=>t())})(n)}(function AI(n=[],e){return fa.create({name:e,providers:[{provide:ng,useValue:"platform"},{provide:Uy,useValue:new Set([()=>Ro=null])},...n]})}(a,r))}return function f3(n){const e=Vy();if(!e)throw new vt(401,!1);return e}()}}function Vy(){return Ro?.get(RI)??null}let RI=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function NI(n,e){let t;return t="noop"===n?new s3:("zone.js"===n?void 0:n)||new Gr(e),t}(r?.ngZone,function PI(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:Gr,useValue:i}];return i.run(()=>{const o=fa.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),l=a.injector.get(sc,null);if(!l)throw new vt(402,!1);return i.runOutsideAngular(()=>{const _=i.onError.subscribe({next:R=>{l.handleError(R)}});a.onDestroy(()=>{pd(this._modules,a),_.unsubscribe()})}),function MI(n,e,t){try{const r=t();return oy(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(dd);return _.runInitializers(),_.donePromise.then(()=>(function aS(n){Si(n,"Expected localeId to be defined"),"string"==typeof n&&(oS=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(no,Sc)||Sc),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=OI({},r);return function a3(n,e,t){const r=new vy(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get(Hy);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new vt(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 vt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(Uy,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)(mn(fa))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function OI(n,e){return Array.isArray(e)?e.reduce(OI,n):{...n,...e}}let Hy=(()=>{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 sn(a=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{a.next(this._stable),a.complete()})}),o=new sn(a=>{let l;this._zone.runOutsideAngular(()=>{l=this._zone.onStable.subscribe(()=>{Gr.assertNotInAngularZone(),My(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const _=this._zone.onUnstable.subscribe(()=>{Gr.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{l.unsubscribe(),_.unsubscribe()}});this.isStable=Zr(s,o.pipe(function is(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},U=()=>{B(),o=l=void 0,R=N=!1},Y=()=>{const X=o;U(),X?.unsubscribe()};return le((X,re)=>{_++,!N&&!R&&B();const fe=l=l??e();re.add(()=>{_--,0===_&&!N&&!R&&(a=_o(Y,i))}),fe.subscribe(re),!o&&_>0&&(o=new ve({next:Ie=>fe.next(Ie),error:Ie=>{N=!0,B(),a=_o(U,t,Ie),fe.error(Ie)},complete:()=>{R=!0,B(),a=_o(U,r),fe.complete()}}),In(X).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof Dw;if(!this._injector.get(dd).done)throw!i&&function mu(n){const e=bn(n)||Jr(n)||ei(n);return null!==e&&e.standalone}(t),new vt(405,false);let o;o=i?t:this._injector.get(Vf).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function c3(n){return n.isBoundToModule}(o)?void 0:this._injector.get(Ic),_=o.create(fa.NULL,[],r||o.selector,a),R=_.location.nativeElement,N=_.injector.get(CI,null);return N?.registerApplication(R),_.onDestroy(()=>{this.detachView(_.hostView),pd(this.components,_),N?.unregisterApplication(R)}),this._loadComponent(_),_}tick(){if(this._runningTick)throw new vt(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;pd(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(qL,[]).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),()=>pd(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new vt(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)(mn(Gr),mn(tc),mn(sc))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function pd(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let LI=!0;class HI{constructor(){}supports(e){return ju(e)}create(e){return new _3(e)}}const w3=(n,e)=>e;class _3{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||w3}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<$I(r,i,s)?t:r,a=$I(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 U=B{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 S3(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 KI),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 KI),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 S3{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 I3{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 KI{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new I3,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 $I(n,e,t){const r=n.previousIndex;if(null===r)return r;let i=0;return t&&r{class n{constructor(t){this.factories=t}static create(t,r){if(null!=r){const i=r.factories.slice();t=t.concat(i)}return new n(t)}static extend(t){return{provide:n,useFactory:r=>n.create(t,r||GI()),deps:[[n,new Nf,new Pf]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new vt(901,!1)}}return n.\u0275prov=Hn({token:n,providedIn:"root",factory:GI}),n})();const A3=xI(null,"core",[]);let R3=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(mn(Hy))},n.\u0275mod=yu({type:n}),n.\u0275inj=Ba({}),n})(),vd=null;function rl(){return vd}const io=new Qt("DocumentToken");class wB{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 iC=(()=>{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 wB(i.item,this._ngForOf,-1,-1),null===o?void 0:o);else if(null==o)r.remove(null===s?void 0:s);else if(null!==s){const a=r.get(s);r.move(a,o),sC(a,i)}});for(let i=0,s=r.length;i{sC(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(Ut(Ms),Ut(to),Ut(md))},n.\u0275dir=Ui({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function sC(n,e){n.context.$implicit=e.item}let ZB=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=yu({type:n}),n.\u0275inj=Ba({}),n})();class c0 extends class b8 extends class M3{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function N3(n){vd||(vd=n)}(new c0)}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 w8(){return al=al||document.querySelector("base"),al?al.getAttribute("href"):null}();return null==t?null:function _8(n){Ad=Ad||document.createElement("a"),Ad.setAttribute("href",n);const e=Ad.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){al=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function vB(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 Ad,al=null;const pC=new Qt("TRANSITION_ID"),I8=[{provide:mI,useFactory:function S8(n,e,t){return()=>{t.get(dd).donePromise.then(()=>{const r=rl(),i=e.querySelectorAll(`style[ng-transition="${n}"]`);for(let s=0;s{class n{build(){return new XMLHttpRequest}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})();const Rd=new Qt("EventManagerPlugins");let Pd=(()=>{class n{constructor(t,r){this._zone=r,this._eventNameToPlugin=new Map,t.forEach(i=>i.manager=this),this._plugins=t.slice().reverse()}addEventListener(t,r,i){return this._findPluginFor(r).addEventListener(t,r,i)}addGlobalEventListener(t,r,i){return this._findPluginFor(r).addGlobalEventListener(t,r,i)}getZone(){return this._zone}_findPluginFor(t){const r=this._eventNameToPlugin.get(t);if(r)return r;const i=this._plugins;for(let s=0;s{class n{constructor(){this._stylesSet=new Set}addStyles(t){const r=new Set;t.forEach(i=>{this._stylesSet.has(i)||(this._stylesSet.add(i),r.add(i))}),this.onStylesAdded(r)}onStylesAdded(t){}getAllStyles(){return Array.from(this._stylesSet)}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})(),cl=(()=>{class n extends yC{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(mC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(mC))}}return n.\u0275fac=function(t){return new(t||n)(mn(io))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})();function mC(n){rl().remove(n)}const u0={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/"},l0=/%COMP%/g;function Nd(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let f0=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new d0(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case Ds.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new N8(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case Ds.ShadowDom:return new M8(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=Nd(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)(mn(Pd),mn(cl),mn(tl))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})();class d0{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(u0[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(_C(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(_C(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=u0[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=u0[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&(di.DashCase|di.Important)?e.style.setProperty(t,r,i&di.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&di.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,bC(r)):this.eventManager.addEventListener(e,t,bC(r))}}function _C(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class N8 extends d0{constructor(e,t,r,i){super(e),this.component=r;const s=Nd(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function A8(n){return"_ngcontent-%COMP%".replace(l0,n)}(i+"-"+r.id),this.hostAttr=function R8(n){return"_nghost-%COMP%".replace(l0,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 M8 extends d0{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=Nd(i.id,i.styles,[]);for(let o=0;o{class n extends gC{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)(mn(io))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})();const SC=["alt","control","meta","shift"],k8={"\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"},L8={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let B8=(()=>{class n extends gC{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(()=>rl().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."),SC.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=k8[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"),SC.forEach(o=>{o!==i&&(0,L8[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)(mn(io))},n.\u0275prov=Hn({token:n,factory:n.\u0275fac}),n})();const CC=[{provide:bI,useValue:"browser"},{provide:EI,useValue:function F8(){c0.makeCurrent()},multi:!0},{provide:io,useFactory:function V8(){return function AR(n){Wp=n}(document),document},deps:[]}],H8=xI(A3,"browser",CC),DC=new Qt(""),TC=[{provide:hd,useClass:class C8{addToWindow(e){kn.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},kn.getAllAngularTestabilities=()=>e.getAllTestabilities(),kn.getAllAngularRootElements=()=>e.getAllRootElements(),kn.frameworkStabilizers||(kn.frameworkStabilizers=[]),kn.frameworkStabilizers.push(r=>{const i=kn.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?rl().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:CI,useClass:Ly,deps:[Gr,By,hd]},{provide:Ly,useClass:Ly,deps:[Gr,By,hd]}],xC=[{provide:ng,useValue:"root"},{provide:sc,useFactory:function U8(){return new sc},deps:[]},{provide:Rd,useClass:O8,multi:!0,deps:[io,Gr,bI]},{provide:Rd,useClass:B8,multi:!0,deps:[io]},{provide:f0,useClass:f0,deps:[Pd,cl,tl]},{provide:xw,useExisting:f0},{provide:yC,useExisting:cl},{provide:cl,useClass:cl,deps:[io]},{provide:Pd,useClass:Pd,deps:[Rd,Gr]},{provide:class n8{},useClass:D8,deps:[]},[]];let K8=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:tl,useValue:t.appId},{provide:pC,useExisting:tl},I8]}}}return n.\u0275fac=function(t){return new(t||n)(mn(DC,12))},n.\u0275mod=yu({type:n}),n.\u0275inj=Ba({providers:[...xC,...TC],imports:[ZB,R3]}),n})();typeof window<"u"&&window;class X8 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 $(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)})}}function NC(n){this.wrapped=n}function ul(n){var e,t;function i(o,a){try{var l=n[o](a),_=l.value,R=_ instanceof NC;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 Vt(n){return function(){return new ul(n.apply(this,arguments))}}function We(n){return new NC(n)}function ut(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 Md(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function Md(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(Md=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 Md(n)}function gr(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 Od(n){return null!=globalThis.Buffer?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function No(n=0){return null!=globalThis.Buffer?.alloc?Od(globalThis.Buffer.alloc(n)):new Uint8Array(n)}function Tc(n=0){return null!=globalThis.Buffer?.allocUnsafe?Od(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}function yr(n,e){null==e&&(e=n.reduce((i,s)=>i+s.length,0));const t=Tc(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return Od(t)}function Lr(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!g0(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!g0(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=OC(this.bufs,e);return t.buf[t.index]}set(e,t){const r=OC(this.bufs,e);r.buf[r.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let r=0;r0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}slice(e,t){const{bufs:r,length:i}=this._subList(e,t);return yr(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:yr(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new Nr;return s.length=i,s.bufs=r,s}_subList(e,t){if((e=e??0)<0&&(e=this.length+e),(t=t??this.length)<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:[...this.bufs],length:this.length};const r=[];let i=0;for(let s=0;s=l)continue;const _=e>=a&&ea&&t<=l;if(_&&R){if(e===a&&t===l){r.push(o);break}const N=e-a;r.push(o.subarray(N,N+(t-e)));break}if(_){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(R){if(t===l){r.push(o);break}r.push(o.subarray(0,t-a));break}r.push(o)}}return{bufs:r,length:t-e}}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Tc(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=Tc(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 Nr)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class kC{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 kC(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 kC(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 ya(n={}){return LC(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 LC(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new y0;const a=function(){var X=$(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((re,fe)=>{s=Ie=>{s=null,r.push(Ie);try{re(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 kd(n){const e=ya(),t=function J8(n){const e=Vt(function*(){let t=yield,r=new Nr;var o,i=!1,s=!1;try{for(var l,a=ut(n);i=!(l=yield We(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 Nr);break}}else r.append(_),t=yield r,r=new Nr}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(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(Vt(function*(){yield*gr(ut(e),We);const a=yield We(r.promise);yield*gr(ut(a),We)})());s.catch(a=>{i=a});const o={sink:(a=$(function*(l){return null!=i?yield Promise.reject(i):(r.resolve(l),yield s)}),function(_){return a.apply(this,arguments)}),source:t};var a;return{reader:t,writer:e,stream:o,rest:()=>e.end(),write:e.push,read:function(){var a=$(function*(){const l=yield t.next();if(null!=l.value)return l.value});return function(){return a.apply(this,arguments)}}()}}function BC(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 FC=4294967296;class zi{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(!0===e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){const t=1+~this.lo>>>0;let r=~this.hi>>>0;return 0===t&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){const e=-(1&this.lo);return new zi((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new zi(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=BC(e);for(;this.hi>0;)r.set(t++,127&this.lo|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(t++,127&this.lo|128),this.lo=this.lo>>>7;r.set(t++,this.lo)}static fromBigInt(e){if(0n===e)return new zi;const t=e<0;t&&(e=-e);let r=0|Number(e>>32n),i=0|Number(e-(BigInt(r)<<32n));return t&&(r=~r>>>0,i=~i>>>0,++i>FC&&(i=0,++r>FC&&(r=0))),new zi(r,i)}static fromNumber(e){if(0===e)return new zi;const t=e<0;t&&(e=-e);let r=e>>>0,i=(e-r)/4294967296>>>0;return t&&(i=~i>>>0,r=~r>>>0,++r>4294967295&&(r=0,++i>4294967295&&(i=0))),new zi(i,r)}static fromBytes(e,t=0){const r=BC(e),i=new zi;let s=0;if(e.length-t>4){for(;s<4;++s)if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i;if(i.lo=(i.lo|(127&r.get(t))<<28)>>>0,i.hi=(i.hi|(127&r.get(t))>>4)>>>0,r.get(t++)<128)return i;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i}if(e.length-t>4){for(;s<5;++s)if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}else if(t=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}throw RangeError("invalid varint encoding")}}const t4=Math.pow(2,7),n4=Math.pow(2,14),r4=Math.pow(2,21),i4=Math.pow(2,28),s4=Math.pow(2,35),o4=Math.pow(2,42),a4=Math.pow(2,49),c4=Math.pow(2,56),u4=Math.pow(2,63),Ri={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=Tc(Ri.encodingLength(n))),zi.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>zi.fromBytes(n,e).toNumber(!0)},Ld=n=>{const e=Ri.encodingLength(n),t=function f4(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Ri.encode(n,t),Ld.bytes=e,t};function oo(n){const e=(n=n??{}).lengthEncoder??Ld;return function(){var r=Vt(function*(i){var a,s=!1,o=!1;try{for(var _,l=ut(i);s=!(_=yield We(l.next())).done;s=!1){const R=_.value,N=e(R.byteLength);N instanceof Uint8Array?yield N:yield*gr(ut(N),We),R instanceof Uint8Array?yield R:yield*gr(ut(R),We)}}catch(R){o=!0,a=R}finally{try{s&&null!=l.return&&(yield We(l.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Ld.bytes=0,oo.single=(n,e)=>new Nr(((e=e??{}).lengthEncoder??Ld)(n.byteLength),n);var se=x(3069),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 ys(n){return function(){var t=Vt(function*(r){const i=new Nr;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,U=ut(r);R=!(Y=yield We(U.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(re){if(re instanceof RangeError){if(i.byteLength>l)throw se(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw re}if(s===Mo.DATA){if(i.byteLength0)throw se(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function UC(n,e={}){const t=kd(n),r=ys.fromReader(t.reader,e),i={read:(s=$(function*(o){const{value:a}=yield t.reader.next(o);if(null==a)throw new Error("Value is null");return a}),function(a){return s.apply(this,arguments)}),readLP:function(){var s=$(function*(){const{value:o}=yield r.next();if(null==o)throw new Error("Value is null");return o});return function(){return s.apply(this,arguments)}}(),readPB:function(){var s=$(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const l=a instanceof Uint8Array?a:a.slice();return o.decode(l)});return function(a){return s.apply(this,arguments)}}(),write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(oo.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=$(function*(){return yield i.readPB(s)}),function(){return o.apply(this,arguments)}),write:o=>i.writePB(o,s)};var o},unwrap:()=>(t.rest(),t.stream)};var s;return i}function VC(){const n=m0();let e=!1;return{sink:(t=$(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:Vt(function*(){const t=yield We(n.promise);yield*gr(ut(t),We)})()};var t}v0.bytes=0,ys.fromReader=(n,e)=>{let t=1;const r=Vt(function*(){for(;;)try{const{done:s,value:o}=yield We(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 ys({...e??{},onLength:s=>{t=s}})(r)};var g4=x(4368);const HC=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&&HC(n.source),m4=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=ya({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),g4(r,function(){var s=Vt(function*(){yield*gr(ut(n.source),We),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function Kn(n,...e){if(E0(n)){const r=n;n=()=>r.source}else if(HC(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&E0(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let r=1;r{let e;for(;n.length>0;)e=n.shift()(e);return e})(...t)}const ll=65535,v4=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);var E4=x(3281),b0=x(9369),$C=x(6632),jC=x(5039);const b4={hashSHA256:n=>(0,$C.vp)(n),getHKDF(n,e){const i=new E4.t($C.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=b0.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=b0._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>b0.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new jC.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new jC.OK(r).open(e,n,t)},Bd=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};Bd.bytes=2;const Fd=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)};Fd.bytes=2;class Ud extends Error{constructor(e="Unexpected Peer"){super(e),this.code=Ud.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class xc extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=xc.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;var zC=x(662),R4=x(6678),WC=x(1018),P4=x(4483),N4=x(1106);!function M4(){N4._configure(),zC._configure(R4),WC._configure(P4)}();const qC=["uint64","int64","sint64","fixed64","sfixed64"];function Mr(n,e){const t=function k4(n){return function O4(n){for(const e of qC){if(null==n[e])continue;const t=n[e];n[e]=function(){return BigInt(t.call(this).toString())}}return n}(new zC(n))}(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}function Or(n,e){const t=function B4(){return function L4(n){for(const e of qC){if(null==n[e])continue;const t=n[e];n[e]=function(r){return t.call(this,r.toString())}}return n}(WC.create())}();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}var fl=(()=>{return(n=fl||(fl={}))[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",fl;var n})();function YC(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Vd(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return YC("enum",fl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.int32())})}function kr(n,e){return YC("message",fl.LENGTH_DELIMITED,n,e)}var Ac,Rc,or=(()=>{return(n=or||(or={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",or;var n})(),Hd=(()=>{return(n=Hd||(Hd={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",Hd;var n})();(or||(or={})).codec=()=>Vd(Hd),function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.Type&&(r.uint32(8),or.codec().encode(t.Type,r)),null!=t.Data&&(r.uint32(18),r.bytes(t.Data)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=or.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(Ac||(Ac={})),function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.Type&&(r.uint32(8),or.codec().encode(t.Type,r)),null!=t.Data&&(r.uint32(18),r.bytes(t.Data)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=or.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(Rc||(Rc={})),x(2266),x(8471);var Pn=x(6608);const H4=function F4(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,ae=new Uint8Array(Ie);Y[X];){var De=t[Y.charCodeAt(X)];if(255===De)return;for(var Ue=0,xe=Ie-1;(0!==De||Ue>>0)%256>>>0,De=De/256>>>0;if(0!==De)throw new Error("Non-zero carry");fe=Ue,X++}if(" "!==Y[X]){for(var ht=Ie-fe;ht!==Ie&&0===ae[ht];)ht++;for(var lt=new Uint8Array(re+(Ie-ht)),rn=re;ht!==Ie;)lt[rn++]=ae[ht++];return lt}}}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,re=0,fe=0,Ie=Y.length;fe!==Ie&&0===Y[fe];)fe++,X++;for(var ae=(Ie-fe)*R+1>>>0,De=new Uint8Array(ae);fe!==Ie;){for(var Ue=Y[fe],xe=0,ht=ae-1;(0!==Ue||xe>>0)%a>>>0,Ue=Ue/a>>>0;if(0!==Ue)throw new Error("Non-zero carry");re=xe,fe++}for(var lt=ae-re;lt!==ae&&0===De[lt];)lt++;for(var rn=l.repeat(X);lt{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 z4{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 W4{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 QC(this,e)}}class q4{constructor(e){this.decoders=e}or(e){return QC(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 QC=(n,e)=>new q4({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class Y4{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new z4(e,t,r),this.decoder=new W4(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Kd=({name:n,prefix:e,encode:t,decode:r})=>new Y4(n,e,t,r),dl=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=H4(t,e);return Kd({prefix:n,name:e,encode:r,decode:s=>Pc(i(s))})},Br=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>Kd({prefix:e,name:n,encode:i=>((n,e,t)=>{const r="="===e[e.length-1],i=(1<t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<((n,e,t,r)=>{const i={};for(let R=0;R=8&&(a-=8,o[_++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),X4=Kd({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),J4=Br({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),e6=Br({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),t6=dl({prefix:"9",name:"base10",alphabet:"0123456789"}),n6=Br({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),r6=Br({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ao=Br({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),i6=Br({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),s6=Br({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),o6=Br({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),a6=Br({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),c6=Br({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),u6=Br({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),l6=Br({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),f6=Br({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),d6=dl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),h6=dl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),oi=dl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),p6=dl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),$d=Br({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),g6=Br({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),y6=Br({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),m6=Br({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),ZC=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}"),v6=ZC.reduce((n,e,t)=>(n[t]=e,n),[]),E6=ZC.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),_6=Kd({prefix:"\u{1f680}",name:"base256emoji",encode:function b6(n){return n.reduce((e,t)=>e+v6[t],"")},decode:function w6(n){const e=[];for(const t of n){const r=E6[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var D6=Math.pow(2,31),A6=Math.pow(2,7),R6=Math.pow(2,14),P6=Math.pow(2,21),N6=Math.pow(2,28),M6=Math.pow(2,35),O6=Math.pow(2,42),k6=Math.pow(2,49),L6=Math.pow(2,56),B6=Math.pow(2,63),U6={encode:function JC(n,e,t){e=e||[];for(var r=t=t||0;n>=D6;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,JC.bytes=t-r+1,e},decode:function w0(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw w0.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return w0.bytes=s-r,t},encodingLength:function(n){return n[jd.decode(n,e),jd.decode.bytes],Gd=(n,e,t=0)=>(jd.encode(n,e,t),e),zd=n=>jd.encodingLength(n),Nc=(n,e)=>{const t=e.byteLength,r=zd(n),i=r+zd(t),s=new Uint8Array(i+t);return Gd(n,s,0),Gd(t,s,r),s.set(e,i),new S0(n,t,e,s)},Wd=n=>{const e=Pc(n),[t,r]=_0(e),[i,s]=_0(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new S0(t,i,o,e)};class S0{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const tD=({name:n,code:e,encode:t})=>new K6(n,e,t);class K6{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?Nc(this.code,t):t.then(r=>Nc(this.code,r))}throw Error("Unknown type, must be binary type")}}const nD=n=>function(){var e=$(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),pi=tD({name:"sha2-256",code:18,encode:nD("SHA-256")}),$6=tD({name:"sha2-512",code:19,encode:nD("SHA-512")}),iD=Pc,Mc={code:0,name:"identity",encode:iD,digest:n=>Nc(0,iD(n))},G6="raw",z6=85,W6=n=>Pc(n),q6=n=>Pc(n),Y6=new TextEncoder,Q6=new TextDecoder,Z6="json",X6=512,J6=n=>Y6.encode(JSON.stringify(n)),e5=n=>JSON.parse(Q6.decode(n)),sD=new WeakMap,I0=n=>{const e=sD.get(n);if(null==e){const t=new Map;return sD.set(n,t),t}return e};class ar{constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{const{code:e,multihash:t}=this;if(e!==hl)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==s5)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return ar.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Nc(e,t);return ar.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return ar.equals(this,e)}static equals(e,t){return t&&e.code===t.code&&e.version===t.version&&((n,e)=>{if(n===e)return!0;{const t=e;return n.code===t.code&&n.size===t.size&&t.bytes instanceof Uint8Array&&((n,e)=>{if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t{const{bytes:t,version:r}=n;return 0===r?r5(t,I0(n),e||oi.encoder):i5(t,I0(n),e||ao.encoder)})(this,e)}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof ar)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:r,code:i,multihash:s,bytes:o}=t;return new ar(r,i,s,o||oD(r,i,s.bytes))}if(!0===t[o5]){const{version:r,multihash:i,code:s}=t,o=Wd(i);return ar.create(r,s,o)}return null}static create(e,t,r){if("number"!=typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==hl)throw new Error(`Version 0 CID must use dag-pb (code: ${hl}) block encoding`);return new ar(e,t,r,r.bytes);case 1:{const i=oD(e,t,r.bytes);return new ar(e,t,r,i)}default:throw new Error("Invalid version")}}static createV0(e){return ar.create(0,hl,e)}static createV1(e,t){return ar.create(1,e,t)}static decode(e){const[t,r]=ar.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=ar.inspectBytes(e),r=t.size-t.multihashSize,i=Pc(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 S0(t.multihashCode,t.digestSize,s,i);return[0===t.version?ar.createV0(o):ar.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[N,B]=_0(e.subarray(t));return t+=B,N};let i=r(),s=hl;if(18===i?(i=0,t=0):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]=n5(e,t),s=ar.decode(i);return I0(s).set(r,e),s}}const n5=(n,e)=>{switch(n[0]){case"Q":return[oi.prefix,(e||oi).decode(`${oi.prefix}${n}`)];case oi.prefix:return[oi.prefix,(e||oi).decode(n)];case ao.prefix:return[ao.prefix,(e||ao).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)]}},r5=(n,e,t)=>{const{prefix:r}=t;if(r!==oi.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},i5=(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},hl=112,s5=18,oD=(n,e,t)=>{const r=zd(n),i=r+zd(e),s=new Uint8Array(i+t.byteLength);return Gd(n,s,0),Gd(e,s,r),s.set(t,i),s},o5=Symbol.for("@ipld/js-cid/CID"),pl={...y,...u,...g,...w,...m,...h,...c,...f,...d,...b};function aD(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const cD=aD("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),C0=aD("ascii","a",n=>{let e="a";for(let t=0;t{const e=Tc((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=yr([new Uint8Array(e-t.length),t])}return Mt(t,"base64url")}function ms(n){const e=function l5(n,e){let t=At(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 Pn.jsbn.BigInteger(Mt(e,"base16"),16)}x(5988);function pD(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=Os.get();function _(){return(_=$(function*(U,Y){const X=a.getRandomValues(new Uint8Array(s)),re=a.getRandomValues(new Uint8Array(r)),fe={name:e,iv:re};"string"==typeof Y&&(Y=At(Y));const Ie={name:"PBKDF2",salt:X,iterations:o,hash:{name:i}},ae=yield a.subtle.importKey("raw",Y,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),De=yield a.subtle.deriveKey(Ie,ae,{name:e,length:t},!0,["encrypt"]),Ue=yield a.subtle.encrypt(fe,De,U);return yr([X,fe.iv,new Uint8Array(Ue)])})).apply(this,arguments)}function N(){return(N=$(function*(U,Y){const X=U.slice(0,s),re=U.slice(s,s+r),fe=U.slice(s+r),Ie={name:e,iv:re};"string"==typeof Y&&(Y=At(Y));const ae={name:"PBKDF2",salt:X,iterations:o,hash:{name:i}},De=yield a.subtle.importKey("raw",Y,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Ue=yield a.subtle.deriveKey(ae,De,{name:e,length:t},!0,["decrypt"]),xe=yield a.subtle.decrypt(Ie,Ue,fe);return new Uint8Array(xe)})).apply(this,arguments)}return t*=8,{encrypt:function l(U,Y){return _.apply(this,arguments)},decrypt:function R(U,Y){return N.apply(this,arguments)}}}function h5(n,e){return R0.apply(this,arguments)}function R0(){return(R0=$(function*(n,e){const t=$d.decode(n);return yield pD().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),x(6674);var p5=x(4490),g5=x.t(p5,2);const tn=BigInt(0),$n=BigInt(1),Oo=BigInt(2),gl=BigInt(3),y5=BigInt(8),wn=Object.freeze({a:tn,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:$n,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function gD(n){const{a:e,b:t}=wn,r=Xe(n*n),i=Xe(r*n);return Xe(i+e*n+t)}const qd=wn.a===tn;class P0 extends Error{constructor(e){super(e)}}class _n{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof pn))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new _n(e.x,e.y,$n)}static toAffineBatch(e){const t=function w5(n,e=wn.P){const t=new Array(n.length),i=Bc(n.reduce((s,o,a)=>o===tn?s:(t[a]=s,Xe(s*o,e)),$n),e);return n.reduceRight((s,o,a)=>o===tn?s:(t[a]=Xe(s*t[a],e),Xe(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return _n.toAffineBatch(e).map(_n.fromAffine)}equals(e){if(!(e instanceof _n))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,l=Xe(i*i),_=Xe(a*a),R=Xe(t*_),N=Xe(s*l),B=Xe(Xe(r*a)*_),U=Xe(Xe(o*i)*l);return R===N&&B===U}negate(){return new _n(this.x,Xe(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=Xe(e*e),s=Xe(t*t),o=Xe(s*s),a=e+s,l=Xe(Oo*(Xe(a*a)-i-o)),_=Xe(gl*i),R=Xe(_*_),N=Xe(R-Oo*l),B=Xe(_*(l-N)-y5*o),U=Xe(Oo*t*r);return new _n(N,B,U)}add(e){if(!(e instanceof _n))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===tn||o===tn)return this;if(t===tn||r===tn)return e;const l=Xe(i*i),_=Xe(a*a),R=Xe(t*_),N=Xe(s*l),B=Xe(Xe(r*a)*_),U=Xe(Xe(o*i)*l),Y=Xe(N-R),X=Xe(U-B);if(Y===tn)return X===tn?this.double():_n.ZERO;const re=Xe(Y*Y),fe=Xe(Y*re),Ie=Xe(R*re),ae=Xe(X*X-fe-Oo*Ie),De=Xe(X*(Ie-ae)-B*fe),Ue=Xe(i*a*Y);return new _n(ae,De,Ue)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=_n.ZERO;if("bigint"==typeof e&&e===tn)return t;let r=vD(e);if(r===$n)return this;if(!qd){let N=t,B=this;for(;r>tn;)r&$n&&(N=N.add(B)),B=B.double(),r>>=$n;return N}let{k1neg:i,k1:s,k2neg:o,k2:a}=bD(r),l=t,_=t,R=this;for(;s>tn||a>tn;)s&$n&&(l=l.add(R)),a&$n&&(_=_.add(R)),R=R.double(),s>>=$n,a>>=$n;return i&&(l=l.negate()),o&&(_=_.negate()),_=new _n(Xe(_.x*wn.beta),_.y,_.z),l.add(_)}precomputeWindow(e){const t=qd?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=N,Y>l&&(Y-=R,e+=$n),0===Y){let X=i[U];B%2&&(X=X.negate()),o=o.add(X)}else{let X=i[U+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=vD(e);if(qd){const{k1neg:o,k1:a,k2neg:l,k2:_}=bD(r);let{p:R,f:N}=this.wNAF(a,t),{p:B,f:U}=this.wNAF(_,t);o&&(R=R.negate()),l&&(B=B.negate()),B=new _n(Xe(B.x*wn.beta),B.y,B.z),i=R.add(B),s=N.add(U)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return _n.normalizeZ([i,s])[0]}toAffine(e=Bc(this.z)){const{x:t,y:r,z:i}=this,s=e,o=Xe(s*s),a=Xe(o*s),l=Xe(t*o),_=Xe(r*a);if(Xe(i*s)!==$n)throw new Error("invZ was invalid");return new pn(l,_)}}_n.BASE=new _n(wn.Gx,wn.Gy,$n),_n.ZERO=new _n(tn,$n,tn);const N0=new WeakMap;class pn{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,N0.delete(this)}hasEvenY(){return this.y%Oo===tn}static fromCompressedHex(e){const t=32===e.length,r=gi(t?e:e.subarray(1));if(!Qd(r))throw new Error("Point is not on curve");let s=function b5(n){const{P:e}=wn,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=Wi(_,gl)*_%e,N=Wi(R,gl)*_%e,B=Wi(N,Oo)*l%e,U=Wi(B,r)*B%e,Y=Wi(U,i)*U%e,X=Wi(Y,o)*Y%e,re=Wi(X,a)*X%e,fe=Wi(re,o)*Y%e,Ie=Wi(fe,gl)*_%e,ae=Wi(Ie,s)*U%e,De=Wi(ae,t)*l%e;return Wi(De,Oo)}(gD(r));const o=(s&$n)===$n;t?o&&(s=Xe(-s)):1==(1&e[0])!==o&&(s=Xe(-s));const a=new pn(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=gi(e.subarray(1,33)),r=gi(e.subarray(33,65)),i=new pn(t,r);return i.assertValidity(),i}static fromHex(e){const t=Ls(e),r=t.length,i=t[0];if(32===r||33===r&&(2===i||3===i))return this.fromCompressedHex(t);if(65===r&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return pn.BASE.multiply(ma(e))}static fromSignature(e,t,r){const i=wD(e=Ls(e)),{r:s,s:o}=ID(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const l=pn.fromHex((1&r?"03":"02")+Lo(s)),{n:_}=wn,R=Bc(s,_),N=Xe(-i*R,_),B=Xe(o*R,_),U=pn.BASE.multiplyAndAddUnsafe(l,N,B);if(!U)throw new Error("Cannot recover signature: point at infinify");return U.assertValidity(),U}toRawBytes(e=!1){return Bo(this.toHex(e))}toHex(e=!1){const t=Lo(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Lo(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=Xe(r*r);if(Xe(i-gD(t))!==tn)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new pn(this.x,Xe(-this.y))}double(){return _n.fromAffine(this).double().toAffine()}add(e){return _n.fromAffine(this).add(_n.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return _n.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const i=_n.fromAffine(this),s=t===tn||t===$n||this!==pn.BASE?i.multiplyUnsafe(t):i.multiply(t),o=_n.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(_n.ZERO)?void 0:a.toAffine()}}function yD(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function mD(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${kc(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:gi(t),left:n.subarray(e+2)}}pn.BASE=new pn(wn.Gx,wn.Gy),pn.ZERO=new pn(tn,tn);class ko{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?kc(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new ko(Yd(i.slice(0,64)),Yd(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 m5(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${kc(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=mD(n.subarray(2)),{data:r,left:i}=mD(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${kc(i)}`);return{r:e,s:r}}(t?e:Bo(e));return new ko(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Uc(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Uc(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>wn.n>>$n}normalizeS(){return this.hasHighS()?new ko(this.r,wn.n-this.s):this}toDERRawBytes(e=!1){return Bo(this.toDERHex(e))}toDERHex(e=!1){const t=yD(yl(this.s));if(e)return t;const r=yD(yl(this.r)),i=yl(r.length/2),s=yl(t.length/2);return`30${yl(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Bo(this.toCompactHex())}toCompactHex(){return Lo(this.r)+Lo(this.s)}}function Oc(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function kc(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&Uc(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function Xe(n,e=wn.P){const t=n%e;return t>=tn?t:e+t}function Wi(n,e){const{P:t}=wn;let r=n;for(;e-- >tn;)r*=r,r%=t;return r}function Bc(n,e=wn.P){if(n===tn||e<=tn)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Xe(n,e),r=e,i=tn,s=$n,o=$n,a=tn;for(;t!==tn;){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!==$n)throw new Error("invert: does not exist");return Xe(i,e)}const ED=(n,e)=>(n+e/Oo)/e,_5={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-$n*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function bD(n){const{n:e}=wn,{a1:t,b1:r,a2:i,b2:s,POW_2_128:o}=_5,a=ED(s*n,e),l=ED(-r*n,e);let _=Xe(n-a*t-l*i,e),R=Xe(-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 wD(n){const{n:e}=wn,r=8*n.length-256;let i=gi(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}let Fc,ml;class _D{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return yi.hmacSha256(this.k,...e)}hmacSync(...e){return ml(this.k,...e)}checkSync(){if("function"!=typeof ml)throw new P0("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}reseed(e=new Uint8Array){var t=this;return $(function*(){t.k=yield t.hmac(t.v,Uint8Array.from([0]),e),t.v=yield t.hmac(t.v),0!==e.length&&(t.k=yield t.hmac(t.v,Uint8Array.from([1]),e),t.v=yield t.hmac(t.v))})()}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}generate(){var e=this;return $(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}function Uc(n){return tn0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=Yd(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=gi(n)}if(!Uc(e))throw new Error("Expected private key: 0 < key < n");return e}function ID(n){if(n instanceof ko)return n.assertValidity(),n;try{return ko.fromDER(n)}catch{return ko.fromCompact(n)}}function CD(n,e=!1){return pn.fromPrivateKey(n).toRawBytes(e)}function TD(n){return gi(n.length>32?n.slice(0,32):n)}function S5(n){const e=TD(n),t=Xe(e,wn.n);return xD(t{if((n=Ls(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Lc(Xe(gi(n),wn.n-$n)+$n)},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:()=>yi.hashToPrivateKey(yi.randomBytes(40)),sha256:(n=$(function*(...e){if(Pi.web){const t=yield Pi.web.subtle.digest("SHA-256",Oc(...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=$(function*(e,...t){if(Pi.web){const r=yield Pi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=Oc(...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=$(function*(e,...t){let r=Xd[e];if(void 0===r){const i=yield yi.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=Oc(i,i),Xd[e]=r}return yi.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof Fc)throw new P0("sha256Sync is undefined, you need to set it");let t=Xd[n];if(void 0===t){const r=Fc(Uint8Array.from(n,i=>i.charCodeAt(0)));t=Oc(r,r),Xd[n]=t}return Fc(t,...e)},precompute(n=8,e=pn.BASE){const t=e===pn.BASE?e:new pn(e.x,e.y);return t._setWindowSize(n),t.multiply(gl),t}};var n;function Jd(n){if(isNaN(n)||n<=0)throw se(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return yi.randomBytes(n)}function R5(n){const e=Pn.asn1.fromDer(Mt(n,"ascii")),t=Pn.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:ks(t.n),e:ks(t.e),d:ks(t.d),p:ks(t.p),q:ks(t.q),dp:ks(t.dP),dq:ks(t.dQ),qi:ks(t.qInv),alg:"RS256"}}function LD(n,e){return e.map(t=>ms(n[t]))}function L5(n){return B0.apply(this,arguments)}function B0(){return B0=$(function*(n){const e=yield Os.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 FD(e);return{privateKey:t[0],publicKey:t[1]}}),B0.apply(this,arguments)}function BD(n){return F0.apply(this,arguments)}function F0(){return F0=$(function*(n){const t=[yield Os.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield U5(n)],r=yield FD({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),F0.apply(this,arguments)}function U0(){return U0=$(function*(n,e){const t=yield Os.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield Os.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),U0.apply(this,arguments)}function V0(){return V0=$(function*(n,e,t){const r=yield Os.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield Os.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),V0.apply(this,arguments)}function FD(n){return H0.apply(this,arguments)}function H0(){return H0=$(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([Os.get().subtle.exportKey("jwk",n.privateKey),Os.get().subtle.exportKey("jwk",n.publicKey)])}),H0.apply(this,arguments)}function U5(n){return K0.apply(this,arguments)}function K0(){return K0=$(function*(n){return yield Os.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),K0.apply(this,arguments)}function UD(n,e,t,r){const i=e?function k5(n){return Pn.pki.setRsaPublicKey(...LD(n,["n","e"]))}(n):function O5(n){return Pn.pki.setRsaPrivateKey(...LD(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return At(r(Mt(Uint8Array.from(t),"ascii"),i),"ascii")}function $0(n,e){return j0.apply(this,arguments)}function j0(){return j0=$(function*(n,e){const r=yield pD().encrypt(n,e);return $d.encode(r)}),j0.apply(this,arguments)}Object.defineProperties(yi,{sha256Sync:{configurable:!1,get:()=>Fc,set(n){Fc||(Fc=n)}},hmacSha256Sync:{configurable:!1,get:()=>ml,set(n){ml||(ml=n)}}}),x(8577);class G0{constructor(e){this._key=e}verify(e,t){var r=this;return $(function*(){return yield function F5(n,e,t){return V0.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function M5(n){if(null==n.n||null==n.e)throw se(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Pn.pki.publicKeyToAsn1({n:ms(n.n),e:ms(n.e)});return At(Pn.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Ac.encode({Type:or.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function V5(n,e){return UD(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return Lr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield pi.digest(e.bytes);return t})()}}class eh{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Jd(16)}sign(e){var t=this;return $(function*(){return yield function B5(n,e){return U0.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 G0(this._publicKey)}decrypt(e){return function H5(n,e){return UD(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function P5(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=Pn.pki.privateKeyToAsn1({n:ms(n.n),e:ms(n.e),d:ms(n.d),p:ms(n.p),q:ms(n.q),dP:ms(n.dp),dQ:ms(n.dq),qInv:ms(n.qi)});return At(Pn.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Rc.encode({Type:or.RSA,Data:this.marshal()}).subarray()}equals(e){return Lr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield pi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){return Mt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return $(function*(){if("pkcs-8"===t){const i=new Pn.util.ByteBuffer(r.marshal()),s=Pn.asn1.fromDer(i),o=Pn.pki.privateKeyFromAsn1(s);return Pn.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield $0(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function K5(n){return z0.apply(this,arguments)}function z0(){return z0=$(function*(n){const e=R5(n),t=yield BD(e);return new eh(t.privateKey,t.publicKey)}),z0.apply(this,arguments)}function $5(n){const e=function N5(n){const e=Pn.asn1.fromDer(Mt(n,"ascii")),t=Pn.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:ks(t.n),e:ks(t.e)}}(n);return new G0(e)}function j5(n){return W0.apply(this,arguments)}function W0(){return W0=$(function*(n){const e=yield BD(n);return new eh(e.privateKey,e.publicKey)}),W0.apply(this,arguments)}function G5(n){return q0.apply(this,arguments)}function q0(){return q0=$(function*(n){const e=yield L5(n);return new eh(e.privateKey,e.publicKey)}),q0.apply(this,arguments)}var z5=x(9572),W5=x.t(z5,2);const er=BigInt(0),Xt=BigInt(1),Hc=BigInt(2),VD=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Nn=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:VD,n:VD,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),HD=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),vl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),q5=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),Y5=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Q5=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Z5=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class un{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof Yn))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(Yn.ZERO)?un.ZERO:new un(e.x,e.y,Xt,Te(e.x*e.y))}static toAffineBatch(e){const t=function eF(n,e=Nn.P){const t=new Array(n.length),i=th(n.reduce((s,o,a)=>o===er?s:(t[a]=s,Te(s*o,e)),Xt),e);return n.reduceRight((s,o,a)=>o===er?s:(t[a]=Te(s*t[a],e),Te(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){KD(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,l=Te(t*a),_=Te(s*i),R=Te(r*a),N=Te(o*i);return l===_&&R===N}negate(){return new un(Te(-this.x),this.y,this.z,Te(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=Nn,s=Te(e*e),o=Te(t*t),a=Te(Hc*Te(r*r)),l=Te(i*s),_=e+t,R=Te(Te(_*_)-s-o),N=l+o,B=N-a,U=l-o,Y=Te(R*B),X=Te(N*U),re=Te(R*U),fe=Te(B*N);return new un(Y,X,fe,re)}add(e){KD(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:l,t:_}=e,R=Te((r-t)*(a+o)),N=Te((r+t)*(a-o)),B=Te(N-R);if(B===er)return this.double();const U=Te(i*Hc*_),Y=Te(s*Hc*l),X=Y+U,re=N+R,fe=Y-U,Ie=Te(X*B),ae=Te(re*fe),De=Te(X*fe),Ue=Te(B*re);return new un(Ie,ae,Ue,De)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let i=this,s=i;for(let o=0;o>=N,Y>l&&(Y-=R,e+=Xt),0===Y){let X=i[U];B%2&&(X=X.negate()),o=o.add(X)}else{let X=i[U+Math.abs(Y)-1];Y<0&&(X=X.negate()),s=s.add(X)}}return un.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Gc(e,Nn.l),t)}multiplyUnsafe(e){let t=Gc(e,Nn.l,!1);const r=un.BASE,i=un.ZERO;if(t===er)return i;if(this.equals(i)||t===Xt)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>er;)t&Xt&&(s=s.add(o)),o=o.double(),t>>=Xt;return s}isSmallOrder(){return this.multiplyUnsafe(Nn.h).equals(un.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Nn.l).equals(un.ZERO)}toAffine(e=th(this.z)){const{x:t,y:r,z:i}=this,s=Te(t*e),o=Te(r*e);if(Te(i*e)!==Xt)throw new Error("invZ was invalid");return new Yn(s,o)}fromRistrettoBytes(){Q0()}toRistrettoBytes(){Q0()}fromRistrettoHash(){Q0()}}function KD(n){if(!(n instanceof un))throw new TypeError("ExtendedPoint expected")}function Y0(n){if(!(n instanceof qi))throw new TypeError("RistrettoPoint expected")}function Q0(){throw new Error("Legacy method: switch to RistrettoPoint")}un.BASE=new un(Nn.Gx,Nn.Gy,Xt,Te(Nn.Gx*Nn.Gy)),un.ZERO=new un(er,Xt,Xt,er);class qi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=Nn,r=Te(vl*e*e),i=Te((r+Xt)*Q5);let s=BigInt(-1);const o=Te((s-t*r)*Te(r+t));let{isValid:a,value:l}=em(i,o),_=Te(l*e);Uo(_)||(_=Te(-_)),a||(l=_),a||(s=r);const R=Te(s*(r-Xt)*Z5-o),N=l*l,B=Te((l+l)*o),U=Te(R*q5),Y=Te(Xt-N),X=Te(Xt+N);return new un(Te(B*X),Te(Y*U),Te(U*X),Te(B*Y))}static hashToCurve(e){const t=J0((e=Es(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=J0(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new qi(r.add(s))}static fromHex(e){e=Es(e,32);const{a:t,d:r}=Nn,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=J0(e);if(!function tF(n,e){if(n.length!==e.length)return!1;for(let t=0;t=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=HD)throw new Error("Expected 0 < hex < 2**256");const a=Te(o*o),l=Te(a-Xt),_=Te(r*a+Xt);let{isValid:R,value:N}=em(l,_);if(!R)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((N&Xt)===Xt)&&(N=Te(-N)),new Yn(N,o)}static fromPrivateKey(e){return $(function*(){return(yield wl(e)).point})()}toRawBytes(){const e=$c(this.y);return e[31]|=this.x&Xt?128:0,e}toHex(){return El(this.toRawBytes())}toX25519(){const{y:e}=this;return $c(Te((Xt+e)*th(Xt-e)))}isTorsionFree(){return un.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Yn(Te(-this.x),this.y)}add(e){return un.fromAffine(this).add(un.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return un.fromAffine(this).multiply(e,this).toAffine()}}Yn.BASE=new Yn(Nn.Gx,Nn.Gy),Yn.ZERO=new Yn(er,Xt);class Kc{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=Es(e,64),r=Yn.fromHex(t.slice(0,32),!1),i=va(t.slice(32,64));return new Kc(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof Yn))throw new Error("Expected Point instance");return Gc(t,Nn.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set($c(this.s),32),e}toHex(){return El(this.toRawBytes())}}function $D(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function El(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=er?t:e+t}function th(n,e=Nn.P){if(n===er||e<=er)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Te(n,e),r=e,i=er,s=Xt,o=Xt,a=er;for(;t!==er;){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!==Xt)throw new Error("invert: does not exist");return Te(i,e)}function vs(n,e){const{P:t}=Nn;let r=n;for(;e-- >er;)r*=r,r%=t;return r}function em(n,e){const t=Te(e*e*e),r=Te(t*t*e);let s=Te(n*t*function GD(n){const{P:e}=Nn,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),l=n*n%e*n%e,_=vs(l,Hc)*l%e,R=vs(_,Xt)*n%e,N=vs(R,t)*R%e,B=vs(N,r)*N%e,U=vs(B,i)*B%e,Y=vs(U,s)*U%e,X=vs(Y,o)*Y%e,re=vs(X,o)*Y%e,fe=vs(re,r)*N%e;return{pow_p_5_8:vs(fe,Hc)*n%e,b2:l}}(n*r).pow_p_5_8);const o=Te(e*s*s),a=s,l=Te(s*vl),_=o===n,R=o===Te(-n),N=o===Te(-n*vl);return _&&(s=a),(R||N)&&(s=l),Uo(s)&&(s=Te(-s)),{isValid:_||R,value:s}}function zD(n){return em(Xt,n)}function jc(n){return Te(va(n),Nn.l)}function Es(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):X0(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Gc(n,e,t=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof n&&Number.isSafeInteger(n)&&(n=BigInt(n)),"bigint"==typeof n&&n{if((n=Es(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Te(va(n),Nn.l-Xt)+Xt},randomBytes:(n=32)=>{if(Vo.web)return Vo.web.getRandomValues(new Uint8Array(n));if(Vo.node){const{randomBytes:e}=Vo.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Ea.randomBytes(32),sha512:function(){var n=$(function*(...e){const t=$D(...e);if(Vo.web){const r=yield Vo.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(Vo.node)return Uint8Array.from(Vo.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=Yn.BASE){const t=e.equals(Yn.BASE)?e:new Yn(e.x,e.y);return t._setWindowSize(n),t.multiply(Hc),t},sha512Sync:void 0};function fF(){return cm.apply(this,arguments)}function cm(){return cm=$(function*(){const n=Ea.randomPrivateKey(),e=yield QD(n);return{privateKey:JD(n,e),publicKey:e}}),cm.apply(this,arguments)}function dF(n){return um.apply(this,arguments)}function um(){return um=$(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 QD(e);return{privateKey:JD(e,t),publicKey:t}}),um.apply(this,arguments)}function lm(){return lm=$(function*(n,e){const t=n.slice(0,32);return yield iF(e,t)}),lm.apply(this,arguments)}function fm(){return fm=$(function*(n,e,t){return yield oF(e,t,n)}),fm.apply(this,arguments)}function JD(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(Ea,{sha512Sync:{configurable:!1,get:()=>bl,set(n){bl||(bl=n)}}});class dm{constructor(e){this._key=zc(e,32)}verify(e,t){var r=this;return $(function*(){return yield function pF(n,e,t){return fm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return Ac.encode({Type:or.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Lr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield pi.digest(e.bytes);return t})()}}class Sl{constructor(e,t){this._key=zc(e,64),this._publicKey=zc(t,32)}sign(e){var t=this;return $(function*(){return yield function hF(n,e){return lm.apply(this,arguments)}(t._key,e)})()}get public(){return new dm(this._publicKey)}marshal(){return this._key}get bytes(){return Rc.encode({Type:or.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Lr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield pi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){const t=yield Mc.digest(e.public.bytes);return oi.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return $(function*(){if("libp2p-key"===t)return yield $0(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function gF(n){if(n.length>64){const r=(n=zc(n,96)).slice(0,64),i=n.slice(64,n.length);return new Sl(r,i)}const e=(n=zc(n,64)).slice(0,64),t=n.slice(32);return new Sl(e,t)}function yF(n){return n=zc(n,32),new dm(n)}function mF(){return hm.apply(this,arguments)}function hm(){return hm=$(function*(){const{privateKey:n,publicKey:e}=yield fF();return new Sl(n,e)}),hm.apply(this,arguments)}function vF(n){return pm.apply(this,arguments)}function pm(){return pm=$(function*(n){const{privateKey:e,publicKey:t}=yield dF(n);return new Sl(e,t)}),pm.apply(this,arguments)}function zc(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 EF(){return yi.randomPrivateKey()}function gm(){return gm=$(function*(n,e){const{digest:t}=yield pi.digest(e);try{return yield I5(t,n)}catch(r){throw se(r,"ERR_INVALID_INPUT")}}),gm.apply(this,arguments)}function ym(){return ym=$(function*(n,e,t){try{const{digest:r}=yield pi.digest(t);return D5(e,r,n)}catch(r){throw se(r,"ERR_INVALID_INPUT")}}),ym.apply(this,arguments)}function eT(n){try{pn.fromHex(n)}catch(e){throw se(e,"ERR_INVALID_PUBLIC_KEY")}}class mm{constructor(e){eT(e),this._key=e}verify(e,t){var r=this;return $(function*(){return yield function wF(n,e,t){return ym.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function _F(n){return pn.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return Ac.encode({Type:or.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Lr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield pi.digest(e.bytes);return t})()}}class vm{constructor(e,t){this._key=e,this._publicKey=t??function IF(n){try{return CD(n,!0)}catch(e){throw se(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function SF(n){try{CD(n,!0)}catch(e){throw se(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),eT(this._publicKey)}sign(e){var t=this;return $(function*(){return yield function bF(n,e){return gm.apply(this,arguments)}(t._key,e)})()}get public(){return new mm(this._publicKey)}marshal(){return this._key}get bytes(){return Rc.encode({Type:or.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Lr(this.bytes,e.bytes)}hash(){var e=this;return $(function*(){const{bytes:t}=yield pi.digest(e.bytes);return t})()}id(){var e=this;return $(function*(){return Mt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return $(function*(){if("libp2p-key"===t)return yield $0(r.bytes,e);throw se(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function CF(n){return new vm(n)}function DF(n){return new mm(n)}function TF(){return Em.apply(this,arguments)}function Em(){return Em=$(function*(){const n=yield EF();return new vm(n)}),Em.apply(this,arguments)}const co={rsa:D,ed25519:A,secp256k1:P};function bm(n){const e=Object.keys(co).join(" / ");return se(new Error(`invalid or unsupported key type ${n}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function wm(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return co[n];throw bm(n)}function tT(n,e){return _m.apply(this,arguments)}function _m(){return _m=$(function*(n,e){return yield wm(n).generateKeyPair(e??2048)}),_m.apply(this,arguments)}function Il(n){const e=Ac.decode(n),t=e.Data??new Uint8Array;switch(e.Type){case or.RSA:return co.rsa.unmarshalRsaPublicKey(t);case or.Ed25519:return co.ed25519.unmarshalEd25519PublicKey(t);case or.Secp256k1:return co.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw bm(e.Type??"RSA")}}function nT(n,e){return wm(e=(e??"rsa").toLowerCase()),n.bytes}function Cl(n){return Im.apply(this,arguments)}function Im(){return Im=$(function*(n){const e=Rc.decode(n),t=e.Data??new Uint8Array;switch(e.Type){case or.RSA:return yield co.rsa.unmarshalRsaPrivateKey(t);case or.Ed25519:return co.ed25519.unmarshalEd25519PrivateKey(t);case or.Secp256k1:return co.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw bm(e.Type??"RSA")}}),Im.apply(this,arguments)}function xF(n,e){return wm(e=(e??"rsa").toLowerCase()),n.bytes}function Cm(n,e){return Dm.apply(this,arguments)}function Dm(){return Dm=$(function*(n,e){try{const i=yield h5(n,e);return yield Cl(i)}catch{}const t=Pn.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=Pn.asn1.toDer(Pn.pki.privateKeyToAsn1(t));return r=At(r.getBytes(),"ascii"),yield co.rsa.unmarshalRsaPrivateKey(r)}),Dm.apply(this,arguments)}const rT=Symbol.for("@libp2p/peer-id");function iT(n){return null!=n&&Boolean(n[rT])}const sT=Object.values(pl).map(n=>n.decoder).reduce((n,e)=>n.or(e),pl.identity.decoder);class sh{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[rT](){return!0}toString(){return null==this.string&&(this.string=oi.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return ar.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return Lr(this.multihash.bytes,e);if("string"==typeof e)return Tr(e).equals(this);if(null!=e?.multihash?.bytes)return Lr(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class Dl extends sh{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class Tl extends sh{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class xl extends sh{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Fr(n){if("RSA"===n.type)return new Dl(n);if("Ed25519"===n.type)return new Tl(n);if("secp256k1"===n.type)return new xl(n);throw se(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function Tr(n,e){if(e=e??sT,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=Wd(oi.decode(`z${n}`));return n.startsWith("12D")?new Tl({multihash:t}):n.startsWith("16U")?new xl({multihash:t}):new Dl({multihash:t})}return Wc(sT.decode(n))}function Wc(n){try{const e=Wd(n);if(e.code===Mc.code){if(36===e.digest.length)return new Tl({multihash:e});if(37===e.digest.length)return new xl({multihash:e})}if(e.code===pi.code)return new Dl({multihash:e})}catch{return function AF(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===pi.code)return new Dl({multihash:n.multihash});if(e.code===Mc.code){if(36===e.digest.length)return new Tl({multihash:n.multihash});if(37===e.digest.length)return new xl({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(ar.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function Al(n,e){return Am.apply(this,arguments)}function Am(){return Am=$(function*(n,e){return 36===n.length?new Tl({multihash:Nc(Mc.code,n),privateKey:e}):37===n.length?new xl({multihash:Nc(Mc.code,n),privateKey:e}):new Dl({multihash:yield pi.digest(n),publicKey:n,privateKey:e})}),Am.apply(this,arguments)}var oh,ah;function Rm(){return Rm=$(function*(n,e,t){const r=yield NF(n,uT(e));if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return PF(n.publicKey,r,t)}),Rm.apply(this,arguments)}function PF(n,e,t){return ah.encode({identityKey:n,identitySig:e,extensions:t??{webtransportCerthashes:[]}}).subarray()}function NF(n,e){return Pm.apply(this,arguments)}function Pm(){return Pm=$(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Cl(n.privateKey)).sign(e)}),Pm.apply(this,arguments)}function aT(n){return Nm.apply(this,arguments)}function Nm(){return Nm=$(function*(n){return yield Al(n.identityKey)}),Nm.apply(this,arguments)}function cT(n){return ah.decode(n)}function uT(n){const e=At("noise-libp2p-static-key:");return yr([e,n],e.length+n.length)}function lT(n,e,t){return Mm.apply(this,arguments)}function Mm(){return Mm=$(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=uT(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 Il(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Mm.apply(this,arguments)}function ch(n){return!(!(n instanceof Uint8Array)||32!==n.length)}!function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.webtransportCerthashes)for(const s of t.webtransportCerthashes)r.uint32(10),r.bytes(s);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={webtransportCerthashes:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.webtransportCerthashes.push(t.bytes()):t.skipType(7&o)}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(oh||(oh={})),function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||null!=t.identityKey&&t.identityKey.byteLength>0)&&(r.uint32(10),r.bytes(t.identityKey)),(!0===i.writeDefaults||null!=t.identitySig&&t.identitySig.byteLength>0)&&(r.uint32(18),r.bytes(t.identitySig)),null!=t.extensions&&(r.uint32(34),oh.codec().encode(t.extensions,r,{writeDefaults:!1})),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.identityKey=t.bytes();break;case 2:i.identitySig=t.bytes();break;case 4:i.extensions=oh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(ah||(ah={}));var mr=x(4084);function kt(n){return Object.assign(mr(n),{error:mr(`${n}:error`),trace:mr(`${n}:trace`)})}mr.formatters.b=n=>null==n?"undefined":oi.baseEncode(n),mr.formatters.t=n=>null==n?"undefined":ao.baseEncode(n),mr.formatters.m=n=>null==n?"undefined":$d.baseEncode(n),mr.formatters.p=n=>null==n?"undefined":n.toString(),mr.formatters.c=n=>null==n?"undefined":n.toString(),mr.formatters.k=n=>null==n?"undefined":n.toString();const Wr=kt("libp2p:noise");let Yi;function fT(n){n?(Yi(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Mt(n.publicKey,"hex")}`),Yi(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Mt(n.privateKey,"hex")}`)):Yi("Missing local ephemeral keys.")}function dT(n){Yi(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Mt(n,"hex")}`)}Yi=v4?Wr:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class UF{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 HF extends class VF{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 Lr(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 Wr(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 UF}}initializeSymmetric(e){const t=At(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 ch(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(ch(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&&ch(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&&ch(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 KF{constructor(e,t,r,i,s,o,a,l){this.remoteExtensions={webtransportCerthashes:[]},this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=l??new HF(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}propose(){var e=this;return $(function*(){if(function MF(n){Yi(`LOCAL_STATIC_PUBLIC_KEY ${Mt(n.publicKey,"hex")}`),Yi(`LOCAL_STATIC_PRIVATE_KEY ${Mt(n.privateKey,"hex")}`)}(e.session.hs.s),e.isInitiator){Wr("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(function _4(n){return yr([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}(t)),Wr("Stage 0 - Initiator finished sending first message."),fT(e.session.hs.e)}else{Wr("Stage 0 - Responder waiting to receive first message...");const t=function C4(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 xc("xx handshake stage 0 validation fail");Wr("Stage 0 - Responder received first message."),dT(e.session.hs.re)}})()}exchange(){var e=this;return $(function*(){if(e.isInitiator){Wr("Stage 1 - Initiator waiting to receive first message from responder...");const t=function D4(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 xc("xx handshake stage 1 validation fail");Wr("Stage 1 - Initiator received the message."),dT(e.session.hs.re),function OF(n){Yi(`REMOTE_STATIC_PUBLIC_KEY ${Mt(n,"hex")}`)}(e.session.hs.rs),Wr("Initiator going to check remote's signature...");try{const s=cT(r);e.remotePeer=e.remotePeer||(yield aT(s)),yield lT(e.session.hs.rs,s,e.remotePeer),e.setRemoteNoiseExtension(s.extensions)}catch(s){throw new Ud(`Error occurred while verifying signed payload: ${s.message}`)}Wr("All good with the signature!")}else{Wr("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 S4(n){return yr([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}(t)),Wr("Stage 1 - Responder sent the second handshake message with signed payload."),fT(e.session.hs.e)}})()}finish(){var e=this;return $(function*(){if(e.isInitiator){Wr("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function I4(n){return yr([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),Wr("Stage 2 - Initiator sent message with signed payload.")}else{Wr("Stage 2 - Responder waiting for third handshake message...");const t=function T4(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 xc("xx handshake stage 2 validation fail");Wr("Stage 2 - Responder received the message, finished handshake.");try{const s=cT(r);e.remotePeer=e.remotePeer||(yield aT(s)),yield lT(e.session.hs.rs,s,e.remotePeer),e.setRemoteNoiseExtension(s.extensions)}catch(s){throw new Ud(`Error occurred while verifying signed payload: ${s.message}`)}}!function kF(n){n.cs1&&n.cs2?(Yi(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Mt(n.cs1.k,"hex")}`),Yi(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Mt(n.cs2.k,"hex")}`)):Yi("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 xc("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteNoiseExtension(e){e&&(this.remoteExtensions=e)}}class jF{constructor(e={}){this.protocol="/noise";const{staticNoiseKey:t,extensions:r,crypto:i,prologueBytes:s,metrics:o}=e;this.crypto=i??b4,this.extensions=r,this.metrics=o?function $F(n){return{xxHandshakeSuccesses:n.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:n.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:n.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:n.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:n.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}(o):void 0,this.staticKeys=t?this.crypto.generateX25519KeyPairFromSeed(t):this.crypto.generateX25519KeyPair(),this.prologue=s??new Uint8Array(0)}secureOutbound(e,t,r){var i=this;return $(function*(){const s=UC(t,{lengthEncoder:Bd,lengthDecoder:Fd,maxDataLength:ll}),o=yield i.performHandshake({connection:s,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteExtensions:o.remoteExtensions,remotePeer:o.remotePeer}})()}secureInbound(e,t,r){var i=this;return $(function*(){const s=UC(t,{lengthEncoder:Bd,lengthDecoder:Fd,maxDataLength:ll}),o=yield i.performHandshake({connection:s,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remotePeer:o.remotePeer,remoteExtensions:o.remoteExtensions}})()}performHandshake(e){var t=this;return $(function*(){const r=yield function RF(n,e,t){return Rm.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.extensions);return yield t.performXXHandshake(e,r)})()}performXXHandshake(e,t){var r=this;return $(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new KF(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish(),r.metrics?.xxHandshakeSuccesses.increment()}catch(l){if(r.metrics?.xxHandshakeErrors.increment(),l instanceof Error)throw l.message=`Error occurred during XX handshake: ${l.message}`,l}return a})()}createSecureConnection(e,t){var r=this;return $(function*(){const[i,s]=function p4(){const n=VC(),e=VC();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),o=e.unwrap();return yield Kn(i,function x4(n,e){return function(){var t=Vt(function*(r){var o,i=!1,s=!1;try{for(var l,a=ut(r);i=!(l=yield We(a.next())).done;i=!1){const _=l.value;for(let R=0;R<_.length;R+=65519){let N=R+65519;N>_.length&&(N=_.length);const B=n.encrypt(_.subarray(R,N),n.session);e?.encryptedPackets.increment(),yield Bd(B.byteLength),yield B}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}});return function(r){return t.apply(this,arguments)}}()}(t,r.metrics),o,ys({lengthDecoder:Fd}),function A4(n,e){return function(){var t=Vt(function*(r){var o,i=!1,s=!1;try{for(var l,a=ut(r);i=!(l=yield We(a.next())).done;i=!1){const _=l.value;for(let R=0;R<_.length;R+=ll){let N=R+ll;N>_.length&&(N=_.length);const{plaintext:B,valid:U}=n.decrypt(_.subarray(R,N),n.session);if(!U)throw e?.decryptErrors.increment(),new Error("Failed to validate decrypted chunk");e?.decryptedPackets.increment(),yield B}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}});return function(r){return t.apply(this,arguments)}}()}(t,r.metrics),i),s})()}}function GF(n={}){return()=>new jF(n)}const qc=new class zF{constructor(){nf(this,"index",0),nf(this,"input","")}new(e){return this.index=0,this.input=e,this}readAtomically(e){const t=this.index,r=e();return void 0===r&&(this.index=t),r}parseWith(e){const t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{const t=this.readChar();if(t===e)return t})}readSeparator(e,t,r){return this.readAtomically(()=>{if(!(t>0&&void 0===this.readGivenChar(e)))return r()})}readNumber(e,t,r,i){return this.readAtomically(()=>{let s=0,o=0;const a=this.peekChar();if(void 0===a)return;const l="0"===a,_=2**(8*i)-1;for(;;){const R=this.readAtomically(()=>{const N=this.readChar();if(void 0===N)return;const B=Number.parseInt(N,e);return Number.isNaN(B)?void 0:B});if(void 0===R)break;if(s*=e,s+=R,s>_||(o+=1,void 0!==t&&o>t))return}return 0!==o?!r&&l&&o>1?void 0:s:void 0})}readIPv4Addr(){return this.readAtomically(()=>{const e=new Uint8Array(4);for(let t=0;tthis.readNumber(10,3,!1,1));if(void 0===r)return;e[t]=r}return e})}readIPv6Addr(){const e=t=>{for(let r=0;rthis.readIPv4Addr());if(void 0!==o)return t[i]=o[0],t[i+1]=o[1],t[i+2]=o[2],t[i+3]=o[3],[i+4,!0]}const s=this.readSeparator(":",r,()=>this.readNumber(16,4,!0,2));if(void 0===s)return[i,!1];t[i]=s>>8,t[i+1]=255&s}return[t.length,!1]};return this.readAtomically(()=>{const t=new Uint8Array(16),[r,i]=e(t);if(16===r)return t;if(i||void 0===this.readGivenChar(":")||void 0===this.readGivenChar(":"))return;const s=new Uint8Array(14),o=16-(r+2),[a]=e(s.subarray(0,o));return t.set(s.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};function yT(n){return Boolean(function QF(n){if(!(n.length>45))return qc.new(n).parseWith(()=>qc.readIPAddr())}(n))}const mT=function pT(n){return Boolean(function qF(n){if(!(n.length>15))return qc.new(n).parseWith(()=>qc.readIPv4Addr())}(n))},ZF=function gT(n){return Boolean(function YF(n){if(!(n.length>45))return qc.new(n).parseWith(()=>qc.readIPv6Addr())}(n))},vT=function(n){let e=0;if(n=n.toString().trim(),mT(n)){const t=new Uint8Array(e+4);return n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)}),t}if(ZF(n)){const t=n.split(":",8);let r;for(r=0;r0;r--)s.push("0");t.splice.apply(t,s)}const i=new Uint8Array(e+16);for(r=0;r>8&255,i[e++]=255&s}return i}throw new Error("invalid ip address")},bs=-1,uh={},Om={};function vr(n){if("number"==typeof n){if(null!=Om[n])return Om[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=uh[n])return uh[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,bs,"ip6zone"],[53,bs,"dns",!0],[54,bs,"dns4",!0],[55,bs,"dns6",!0],[56,bs,"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,bs,"unix",!1,!0],[421,bs,"ipfs"],[421,bs,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,bs,"garlic64"],[460,0,"quic"],[465,0,"webtransport"],[466,bs,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,bs,"memory"]].forEach(n=>{const e=function JF(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);Om[e.code]=e,uh[e.name]=e});var cr=x(4725);function km(n,e){switch(vr(n).code){case 4:case 41:return function tU(n){const e=function(n,e=0,t){e=~~e,t=t??n.length-e;const r=new DataView(n.buffer);if(4===t){const i=[];for(let s=0;s65536)throw new Error("Port number is not in range(1, 65536)");const i=Bm(r);return yr([t,i],t.length+i.length)}(e);case 445:return function uU(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=ao.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=Bm(r);return yr([t,i],t.length+i.length)}(e);case 466:return function sU(n){const e=eU.decode(n),t=Uint8Array.from(cr.encode(e.length));return yr([t,e],t.length+e.length)}(e);default:return At(e,"base16")}}const Lm=Object.values(pl).map(n=>n.decoder),eU=function(){let n=Lm[0].or(Lm[1]);return Lm.slice(2).forEach(e=>n=n.or(e)),n}();function Bm(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function wT(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function ST(n){return n.map(e=>{const t=lh(e);return null!=e[1]?[t.code,km(t.code,e[1])]:[t.code]})}function IT(n){return Um(yr(n.map(e=>{const t=lh(e);let r=Uint8Array.from(cr.encode(t.code));return e.length>1&&null!=e[1]&&(r=yr([r,e[1]])),r})))}function CT(n,e){return n.size>0?n.size/8:0===n.size?0:cr.decode(e)+cr.decode.bytes}function Fm(n){const e=[];let t=0;for(;tn.length)throw xT("Invalid address Uint8Array: "+Mt(n,"base16"));e.push([r,a])}return e}function DT(n){return function fU(n){const e=[];return n.map(t=>{const r=lh(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),Vm(e.join("/"))}(ST(Fm(n)))}function Um(n){const e=function TT(n){try{Fm(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function Vm(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function xT(n){return new Error("Error parsing address: "+n)}function lh(n){return vr(n[0])}var Rl,Pl,Nl,AT,Yc=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)},Hm=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};const gU=Symbol.for("nodejs.util.inspect.custom"),RT=[vr("dns").code,vr("dns4").code,vr("dns6").code,vr("dnsaddr").code],yU=[vr("p2p").code,vr("ipfs").code],PT=new Map,NT=Symbol.for("@multiformats/js-multiaddr/multiaddr");function mU(n,e){if(null==n)throw new Error("requires node address object");if(null==e)throw new Error("requires transport protocol");let t;switch(n.family){case 4:t="ip4";break;case 6:t="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new Ko("/"+[t,n.address,e,n.port].join("/"))}function fh(n){return Boolean(n?.[NT])}class Ko{constructor(e){if(Rl.set(this,void 0),Pl.set(this,void 0),Nl.set(this,void 0),this[AT]=!0,null==e&&(e=""),e instanceof Uint8Array)this.bytes=Um(e);else if("string"==typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=function pU(n){return function hU(n){const e=function lU(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw xT("invalid address: "+n);if(!0===s.path){e.push([i,Vm(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=Vm(n)),t=function dU(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=lh(e);return e.length>1?[t.code,ET(t.code,e[1])]:[t.code]})}(e);return IT(t)}(n)}(e)}else{if(!fh(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=Um(e.bytes)}}toString(){return null==Yc(this,Rl,"f")&&Hm(this,Rl,DT(this.bytes),"f"),Yc(this,Rl,"f")}toJSON(){return this.toString()}toOptions(){const e=this.protoCodes(),t=this.toString().split("/").slice(1);let r,i;if(t.length>2)RT.includes(e[0])&&yU.includes(e[1])?(r=vr("tcp").name,i=443):(r=vr(t[2]).name,i=parseInt(t[3]));else{if(!RT.includes(e[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');r=vr("tcp").name,i=443}return{family:41===e[0]||55===e[0]?6:4,host:t[1],transport:r,port:i}}protos(){return this.protoCodes().map(e=>Object.assign({},vr(e)))}protoCodes(){const e=[],t=this.bytes;let r=0;for(;re.name)}tuples(){return null==Yc(this,Pl,"f")&&Hm(this,Pl,Fm(this.bytes),"f"),Yc(this,Pl,"f")}stringTuples(){return null==Yc(this,Nl,"f")&&Hm(this,Nl,ST(this.tuples()),"f"),Yc(this,Nl,"f")}encapsulate(e){return e=new Ko(e),new Ko(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),i=r.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new Ko(r.slice(0,i))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new Ko(IT(t.slice(0,r)));return this}getPeerId(){try{const t=this.stringTuples().filter(r=>r[0]===uh.ipfs.code).pop();if(null!=t?.[1]){const r=t[1];return Mt("Q"===r[0]||"1"===r[0]?oi.decode(`z${r}`):ar.parse(r).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let e=null;try{e=this.stringTuples().filter(t=>!0===vr(t[0]).path)[0][1],null==e&&(e=null)}catch{e=null}return e}equals(e){return Lr(this.bytes,e.bytes)}resolve(e){var t=this;return $(function*(){const r=t.protos().find(o=>o.resolvable);if(null==r)return[t];const i=PT.get(r.name);if(null==i)throw se(new Error(`no available resolver for ${r.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(yield i(t,e)).map(o=>new Ko(o))})()}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return!(2!==t.length||4!==t[0].code&&41!==t[0].code||6!==t[1].code&&273!==t[1].code)}[(Rl=new WeakMap,Pl=new WeakMap,Nl=new WeakMap,AT=NT,gU)](){return this.inspect()}inspect(){return""}}function Cn(n){return new Ko(n)}const vU=mt("dns4"),EU=mt("dns6"),bU=mt("dnsaddr"),ba=qr(mt("dns"),bU,vU,EU),dh=qr(mt("ip4"),mt("ip6")),Ml=qr(jt(dh,mt("tcp")),jt(ba,mt("tcp"))),MT=jt(dh,mt("udp")),wU=jt(MT,mt("utp")),_U=jt(MT,mt("quic")),Qc=qr(jt(Ml,mt("ws")),jt(ba,mt("ws"))),wa=qr(jt(Ml,mt("wss")),jt(ba,mt("wss"))),Km=qr(jt(Ml,mt("http")),jt(dh,mt("http")),jt(ba,mt("http"))),$m=qr(jt(Ml,mt("https")),jt(dh,mt("https")),jt(ba,mt("https"))),OT=qr(jt(Qc,mt("p2p-webrtc-star"),mt("p2p")),jt(wa,mt("p2p-webrtc-star"),mt("p2p")),jt(Qc,mt("p2p-webrtc-star")),jt(wa,mt("p2p-webrtc-star"))),kT=(qr(jt(Qc,mt("p2p-websocket-star"),mt("p2p")),jt(wa,mt("p2p-websocket-star"),mt("p2p")),jt(Qc,mt("p2p-websocket-star")),jt(wa,mt("p2p-websocket-star"))),qr(jt(Km,mt("p2p-webrtc-direct"),mt("p2p")),jt($m,mt("p2p-webrtc-direct"),mt("p2p")),jt(Km,mt("p2p-webrtc-direct")),jt($m,mt("p2p-webrtc-direct")))),Ol=qr(Qc,wa,Km,$m,OT,kT,Ml,wU,_U,ba),$o=(qr(jt(Ol,mt("p2p-stardust"),mt("p2p")),jt(Ol,mt("p2p-stardust"))),qr(jt(Ol,mt("p2p")),OT,kT,mt("p2p"))),LT=qr(jt($o,mt("p2p-circuit"),$o),jt($o,mt("p2p-circuit")),jt(mt("p2p-circuit"),$o),jt(Ol,mt("p2p-circuit")),jt(mt("p2p-circuit"),Ol),mt("p2p-circuit")),BT=()=>qr(jt(LT,BT),LT),Zc=BT(),SU=qr(jt(Zc,$o,Zc),jt($o,Zc),jt(Zc,$o),Zc,$o);function FT(n){return function e(t){let r;try{r=Cn(t)}catch{return!1}const i=n(r.protoNames());return null!==i&&(!0===i||!1===i?i:0===i.length)}}function jt(...n){function e(t){if(t.length(r="function"==typeof i?i().partialMatch(t):i.partialMatch(t),Array.isArray(r)&&(t=r),null===r)),r}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:FT(e),partialMatch:e}}function qr(...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:FT(e),partialMatch:e}}function mt(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=Cn(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}}}var uo,_a=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 mi extends EventTarget{constructor(){super(...arguments),uo.set(this,new Map)}listenerCount(e){const t=_a(this,uo,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=_a(this,uo,"f").get(e);null==i&&(i=[],_a(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=_a(this,uo,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),_a(this,uo,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=_a(this,uo,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),_a(this,uo,"f").set(e.type,r)),t}}uo=new WeakMap;class IU extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const zt=globalThis.CustomEvent??IU,jm=Symbol.for("@libp2p/peer-discovery"),hh=kt("libp2p:bootstrap");let AU=(()=>{class n extends mi{constructor(t,r={list:[]}){if(null==r.list||0===r.list.length)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=t,this.timeout=r.timeout??1e3,this.list=[];for(const i of r.list){if(!SU.matches(i)){hh.error("Invalid multiaddr");continue}const s=Cn(i),o=s.getPeerId();if(null==o){hh.error("Invalid bootstrap multiaddr without peer id");continue}const a={id:Tr(o),multiaddrs:[s],protocols:[]};this.list.push(a)}this._init=r}get[jm](){return!0}get[Symbol.toStringTag](){return"@libp2p/bootstrap"}isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(hh("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout(()=>{this._discoverBootstrapPeers().catch(t=>{hh.error(t)})},this.timeout))}_discoverBootstrapPeers(){var t=this;return $(function*(){if(null!=t.timer)for(const r of t.list){if(yield t.components.peerStore.tagPeer(r.id,t._init.tagName??"bootstrap",{value:t._init.tagValue??50,ttl:t._init.tagTTL??12e4}),null==t.timer)return;t.dispatchEvent(new zt("peer",{detail:r}))}})()}stop(){null!=this.timer&&clearTimeout(this.timer),this.timer=void 0}}return n.tag="bootstrap",n})();class UT extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function ws(n,e,t){const r=t??{},i=function PU(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=Vt(function*(){let a;const l=()=>{a?.()};for(e.addEventListener("abort",l);;){let _;try{if(e.aborted){const{abortMessage:N,abortCode:B}=r;throw new UT(N,B)}const R=new Promise((N,B)=>{a=()=>{const{abortMessage:U,abortCode:Y}=r;B(new UT(U,Y))}});_=yield We(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 We(r.onAbort(n))),"function"==typeof i.return)try{const B=i.return();B instanceof Promise&&B.catch(U=>{null!=r.onReturnError&&r.onReturnError(U)})}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 NU(n,e,t){return r=>n(ws(r,e,t))}function jo(n,e,t){return{sink:NU(n.sink,e,{...t,onAbort:void 0}),source:ws(n.source,e,t)}}function VT(n){return new Uint8Array(n)}var Jt=(()=>(function(n){n[n.NEW_STREAM=0]="NEW_STREAM",n[n.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",n[n.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",n[n.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",n[n.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",n[n.RESET_RECEIVER=5]="RESET_RECEIVER",n[n.RESET_INITIATOR=6]="RESET_INITIATOR"}(Jt||(Jt={})),Jt))();const Gm=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),HT=Object.freeze({NEW_STREAM:Jt.NEW_STREAM,MESSAGE:Jt.MESSAGE_INITIATOR,CLOSE:Jt.CLOSE_INITIATOR,RESET:Jt.RESET_INITIATOR}),MU=Object.freeze({MESSAGE:Jt.MESSAGE_RECEIVER,CLOSE:Jt.CLOSE_RECEIVER,RESET:Jt.RESET_RECEIVER}),KT=new class OU{constructor(){this._pool=VT(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;cr.encode(e.id<<3|e.type,t,r),r+=cr.encode.bytes,cr.encode(e.type!==Jt.NEW_STREAM&&e.type!==Jt.MESSAGE_INITIATOR&&e.type!==Jt.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=cr.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=VT(10240),this._poolOffset=0):this._poolOffset=r,e.type!==Jt.NEW_STREAM&&e.type!==Jt.MESSAGE_INITIATOR&&e.type!==Jt.MESSAGE_RECEIVER||null==e.data?[i]:[i,...e.data instanceof Uint8Array?[e.data]:e.data]}};function Wm(){return Wm=Vt(function*(n){var r,e=!1,t=!1;try{for(var s,i=ut(n);e=!(s=yield We(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*gr(ut(KT.write(a)),We);else yield*gr(ut(KT.write(o)),We)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield We(i.return()))}finally{if(t)throw r}}}),Wm.apply(this,arguments)}class LU{constructor(){this._buffer=new Nr,this._headerInfo=null}write(e){if(null==e||0===e.length)return[];this._buffer.append(e);const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch{break}const{id:r,type:i,length:s,offset:o}=this._headerInfo;if(this._buffer.length-o>3,type:o,offset:r+s,length:i}}}function jT(n,e=0){let s,t=0,r=0,i=e;const o=n.length;do{if(i>=o||r>49)throw e=0,new RangeError("Could not decode varint");s=n.get(i++),t+=r<28?(127&s)<=128);return{value:t,offset:e=i-e}}function FU(n){return qm.apply(this,arguments)}function qm(){return qm=Vt(function*(n){const e=new LU;var i,t=!1,r=!1;try{for(var o,s=ut(n);t=!(o=yield We(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 We(s.return()))}finally{if(r)throw i}}}),qm.apply(this,arguments)}const GT=1<<20;var ph=x(346);const _s=kt("libp2p:mplex:stream"),Ym="ERR_STREAM_RESET";var zT=x(9893);const Ss=kt("libp2p:mplex");function WT(n){const e={...n,type:`${Gm[n.type]} (${n.type})`};return n.type===Jt.NEW_STREAM&&(e.data=Mt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===Jt.MESSAGE_INITIATOR||n.type===Jt.MESSAGE_RECEIVER)&&(e.data=Mt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class qU{constructor(e){this.protocol="/mplex/6.7.0",e=e??{},this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=e,this.sink=this._createSink();const t=this._createSource();this._source=t,this.source=t,this.closeController=new AbortController,this.rateLimiter=new zT.RateLimiterMemory({points:e.disconnectThreshold??5,duration:1})}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(Ss("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 $U(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=GT}=n,a=new AbortController,l=new AbortController,_=new AbortController,R="initiator"===s?HT:MU,N="initiator"===s?`i${e}`:`r${e}`,B=`${t??e}`;let re,U=!1,Y=!1,X=!1;const fe={open:Date.now()},ae=xe=>{Y||(Y=!0,_s.trace("%s stream %s sink end - err: %o",s,B,xe),null!=xe&&null==re&&(re=xe),U&&(fe.close=Date.now(),i?.(re)))},De=ya({onEnd:xe=>{U||(U=!0,_s.trace("%s stream %s source end - err: %o",s,B,xe),null!=xe&&null==re&&(re=xe),Y&&(Ue.stat.timeline.close=Date.now(),i?.(re)))}}),Ue={close:()=>{_s.trace("%s stream %s close",s,B),Ue.closeRead(),Ue.closeWrite()},closeRead:()=>{_s.trace("%s stream %s closeRead",s,B),!U&&De.end()},closeWrite:()=>{if(_s.trace("%s stream %s closeWrite",s,B),!Y){_.abort();try{r({id:e,type:R.CLOSE})}catch(xe){_s.trace("%s stream %s error sending close",s,t,xe)}ae()}},abort:xe=>{_s.trace("%s stream %s abort",s,B,xe),De.end(xe),a.abort(),ae(xe)},reset:()=>{const xe=se(new Error("stream reset"),Ym);l.abort(),De.end(xe),ae(xe)},sink:(xe=$(function*(ht){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");ht=ws(ht,(0,ph.anySignal)([a.signal,l.signal,_.signal]));try{"initiator"===s&&r({id:e,type:HT.NEW_STREAM,data:new Nr(At(B))});const jn=new Nr;var xn,lt=!1,rn=!1;try{for(var bi,ir=ut(ht);lt=!(bi=yield ir.next()).done;lt=!1){const ki=bi.value;if(ki.length<=o)r({id:e,type:R.MESSAGE,data:ki instanceof Nr?ki:new Nr(ki)});else for(jn.append(ki);0!==jn.length;){if(jn.length<=o){r({id:e,type:R.MESSAGE,data:jn.sublist()}),jn.consume(jn.length);break}r({id:e,type:R.MESSAGE,data:jn.sublist(0,o)}),jn.consume(o)}}}catch(ki){rn=!0,xn=ki}finally{try{lt&&null!=ir.return&&(yield ir.return())}finally{if(rn)throw xn}}}catch(jn){if("aborted"===jn.type&&"The operation was aborted"===jn.message){if(_.signal.aborted)return;l.signal.aborted&&(jn.message="stream reset",jn.code=Ym),a.signal.aborted&&(jn.message="stream aborted",jn.code="ERR_STREAM_ABORT")}if(jn.code===Ym)_s.trace("%s stream %s reset",s,t);else{_s.trace("%s stream %s error",s,t,jn);try{r({id:e,type:R.RESET})}catch(ki){_s.trace("%s stream %s error sending reset",s,t,ki)}}return De.end(jn),void ae(jn)}try{r({id:e,type:R.CLOSE})}catch(jn){_s.trace("%s stream %s error sending close",s,t,jn)}ae()}),function(lt){return xe.apply(this,arguments)}),source:De,sourcePush:xe=>{De.push(xe)},sourceReadableLength:()=>De.readableLength,stat:{direction:"initiator"===s?"outbound":"inbound",timeline:fe},metadata:{},id:N};var xe;return Ue}({id:t,name:r,send:_=>{Ss.enabled&&Ss.trace("%s stream %s send",i,t,WT(_)),this._source.push(_)},type:i,onEnd:()=>{Ss("%s stream with id %s and protocol %s ended",i,t,l.stat.protocol),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(l)},maxMsgSize:this._init.maxMsgSize});return s.set(t,l),l}_createSink(){var e=this;return function(){var r=$(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=ws(i,ph(s));try{yield Kn(i,FU,function UU(n){const e=n??GT,t=r=>{if((r.type===Jt.NEW_STREAM||r.type===Jt.MESSAGE_INITIATOR||r.type===Jt.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=Vt(function*(){var l,o=!1,a=!1;try{for(var R,_=ut(r);o=!(R=yield We(_.next())).done;o=!1){const N=R.value;Array.isArray(N)?(N.forEach(t),yield*gr(ut(N),We)):(t(N),yield N)}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield We(_.return()))}finally{if(a)throw l}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=$(function*(a){var R,l=!1,_=!1;try{for(var B,N=ut(a);l=!(B=yield N.next()).done;l=!1){const U=B.value;yield e._handleIncoming(U)}}catch(U){_=!0,R=U}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){Ss("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function e4(n={}){return LC(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 kU(n){return Wm.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){var t=this;return $(function*(){const{id:r,type:i}=e;if(Ss.enabled&&Ss.trace("incoming message",WT(e)),e.type===Jt.NEW_STREAM){if(t._streams.receivers.size===(t._init.maxInboundStreams??1024)){Ss("too many inbound streams open"),t._source.push({id:r,type:Jt.RESET_RECEIVER});try{yield t.rateLimiter.consume("new-stream",1)}catch{return Ss("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:Mt(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 Ss("missing stream %s for message type %s",r,Gm[i]);const a=t._init.maxStreamBufferSize??4194304;switch(i){case Jt.MESSAGE_INITIATOR:case Jt.MESSAGE_RECEIVER:if(o.sourceReadableLength()>a){t._source.push({id:e.id,type:i===Jt.MESSAGE_INITIATOR?Jt.RESET_RECEIVER:Jt.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 Jt.CLOSE_INITIATOR:case Jt.CLOSE_RECEIVER:o.closeRead();break;case Jt.RESET_INITIATOR:case Jt.RESET_RECEIVER:o.reset();break;default:Ss("unknown message type %s",i)}})()}}class YU{constructor(e={}){this.protocol="/mplex/6.7.0",this._init=e}createStreamMuxer(e={}){return new qU({...e,...this._init})}}function QU(n={}){return()=>new YU(n)}const ZU=WebSocket;var XU=x(3715);function qT(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const JU=n=>{n.binaryType="arraybuffer";const e=function(){var s=$(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const l=N=>{n.removeEventListener("open",_),n.removeEventListener("error",R),N()},_=()=>l(o),R=N=>{l(()=>a(N.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",_),n.addEventListener("error",R)})});return function(){return s.apply(this,arguments)}}(),t=Vt(function*(){const s=new XU.zN(({push:N,stop:B,fail:U})=>{const Y=re=>{let fe=null;"string"==typeof re.data&&(fe=At(re.data)),qT(re.data)&&(fe=new Uint8Array(re.data)),re.data instanceof Uint8Array&&(fe=re.data),null!=fe&&N(fe)},X=re=>U(re.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 We(e());var l,o=!1,a=!1;try{for(var R,_=ut(s);o=!(R=yield We(_.next())).done;o=!1){const N=R.value;yield qT(N)?new Uint8Array(N):N}}catch(N){a=!0,l=N}finally{try{o&&null!=_.return&&(yield We(_.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})},eV=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)})},tV=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=$(function*(i){var a,s=!1,o=!1;try{for(var _,l=ut(i);s=!(_=yield l.next()).done;s=!1){const R=_.value;try{yield eV(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 U=Object.assign(new Error("ws error"),{event:B});N(U)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),nV=(n,e)=>{e=e??{};const t=JU(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:tV(n,e),source:t,connected:(o=$(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=$(function*(){(n.readyState===n.CONNECTING||n.readyState===n.OPEN)&&(yield new Promise(a=>{n.addEventListener("close",()=>{a()}),n.close()}))});return function(){return o.apply(this,arguments)}}(),destroy:()=>{null!=n.terminate?n.terminate():n.close()},remoteAddress:r,remotePort:i,socket:n};var o};var rV=x(5499);const iV={http:"ws",https:"wss"};const gh=(n,e)=>e,uV={ip4:gh,ip6:(n,e,t,r)=>1===r.length&&"ip6"===r[0].protocol?e:`[${e}]`,tcp:(n,e,t,r,i)=>r.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${n}:${e}`:((n,e,t,r)=>{if(null!=r&&!1===r.assumeHttp)return`tcp://${n}:${e}`;let i="tcp",s=`:${e}`;return"tcp"===t[t.length-1].protocol&&(i="443"===e?"https":"http",s="443"===e||"80"===e?"":s),`${i}://${n}${s}`})(n,e,r,i),udp:(n,e)=>`udp://${n}:${e}`,dnsaddr:gh,dns4:gh,dns6:gh,ipfs:(n,e)=>`${n}/ipfs/${e}`,p2p:(n,e)=>`${n}/p2p/${e}`,http:n=>`http://${n}`,https:n=>`https://${n}`,ws:n=>`ws://${n}`,wss:n=>`wss://${n}`,"p2p-websocket-star":n=>`${n}/p2p-websocket-star`,"p2p-webrtc-star":n=>`${n}/p2p-webrtc-star`,"p2p-webrtc-direct":n=>`${n}/p2p-webrtc-direct`};class Xc extends Error{constructor(e="The operation was aborted"){super(e),this.code=Xc.code,this.type=Xc.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}}var fV=x(8318);const Qm="object"==typeof window&&"object"==typeof document&&9===document.nodeType,yh=fV(),mh=Qm&&!yh,dV=yh&&!Qm,hV=yh&&Qm,pV=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!yh,YT="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,gV=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class bV extends Error{constructor(e){super(e),this.name="TimeoutError"}}class wV extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const XT=n=>void 0===globalThis.DOMException?new wV(n):new DOMException(n),JT=n=>{const e=void 0===n.reason?XT("This operation was aborted."):n.reason;return e instanceof Error?e:XT(e)};function ex(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&&_(JT(R)),R.addEventListener("abort",()=>{_(JT(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{l(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new bV("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),$(function*(){try{l(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else l(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const tx=kt("libp2p:websockets:socket");function nx(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Qc.matches(t)||wa.matches(t)})}const Zm=Symbol.for("@libp2p/transport"),Go=kt("libp2p:websockets");class IV{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[Zm](){return!0}dial(e,t){var r=this;return $(function*(){Go("dialing %s",e),t=t??{};const s=function _V(n,e,t){const r={sink:i=>$(function*(){null!=t?.signal&&(i=ws(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&tx.error(s)}})(),source:null!=(t=t??{}).signal?ws(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>$(function*(){const i=Date.now();try{yield ex(n.close(),{milliseconds:2e3})}catch{const{host:o,port:a}=r.remoteAddr.toOptions();tx("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 n.socket.addEventListener("close",()=>{null==r.timeline.close&&(r.timeline.close=Date.now())},{once:!0}),r}(yield r._connect(e,t),e);Go("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return Go("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return $(function*(){if(!0===t?.signal?.aborted)throw new Xc;const i=e.toOptions();Go("dialing %s:%s",i.host,i.port);const s=m0(),o=R=>{Go.error("connection error:",R),s.reject(R)},a=function aV(n,e){e=e??{};const r=((n,e)=>(0,rV.relative)(n,e,iV,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new ZU(r,e.websocket);return nV(i,e)}(function lV(n,e){const t=Cn(n),r=t.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=uV[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]),Go("connected %s",e),a;let l;const _=new Promise((R,N)=>{if(l=()=>{N(new Xc),a.close().catch(B=>{Go.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 Go("connected %s",e),a})()}createListener(e){return function yV(){throw new Error("WebSocket Servers can not be created in the browser!")}()}filter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):mh||YT?function SV(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return wa.matches(t)&&ba.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):nx(e)}}function CV(n={}){return()=>new IV(n)}var xr=(()=>(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(xr||(xr={})),xr))(),rx=x(2797);mr("waku:select-peer");var ev=x(8626),tv=x.n(ev);const nv=ev.Reader;function tr(n,e){const t=nv.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=nv.prototype[n];nv.prototype[n]=function(){return BigInt(e.call(this).toString())}});const rv=ev.Writer;function nr(n,e){const t=rv.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=rv.prototype[n];rv.prototype[n]=function(t){return e.call(this,t.toString())}});var Eh,bh,ox,wh,_h,kl=(()=>(function(n){n[n.VARINT=0]="VARINT",n[n.BIT64=1]="BIT64",n[n.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",n[n.START_GROUP=3]="START_GROUP",n[n.END_GROUP=4]="END_GROUP",n[n.BIT32=5]="BIT32"}(kl||(kl={})),kl))();function ix(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function sx(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return ix("enum",kl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function rr(n,e){return ix("message",kl.LENGTH_DELIMITED,n,e)}!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=rr((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),null!=s.contentTopic&&(o.uint32(10),o.string(s.contentTopic)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={},l=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.contentTopic=s.string():s.skipType(7&_)}return a})),i),r.encode=s=>nr(s,r.codec()),r.decode=s=>tr(s,r.codec())}(e=n.ContentFilter||(n.ContentFilter={})),n.codec=()=>(null==t&&(t=rr((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null!=r.subscribe&&(i.uint32(8),i.bool(r.subscribe)),null!=r.topic&&(i.uint32(18),i.string(r.topic)),null==r.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const o of r.contentFilters)i.uint32(26),n.ContentFilter.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={contentFilters:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.subscribe=r.bool();break;case 2:s.topic=r.string();break;case 3:s.contentFilters.push(n.ContentFilter.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>nr(r,n.codec()),n.decode=r=>tr(r,n.codec())}(Eh||(Eh={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((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),_h.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.messages.push(_h.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(bh||(bh={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Eh.codec().encode(t.request,r)),null!=t.push&&(r.uint32(26),bh.codec().encode(t.push,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Eh.codec().decode(t,t.uint32());break;case 3:i.push=bh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(ox||(ox={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.proof)throw new Error('Protocol error: required field "proof" was not found in object');if(r.uint32(10),r.bytes(t.proof),null==t.merkleRoot)throw new Error('Protocol error: required field "merkleRoot" was not found in object');if(r.uint32(18),r.bytes(t.merkleRoot),null==t.epoch)throw new Error('Protocol error: required field "epoch" was not found in object');if(r.uint32(26),r.bytes(t.epoch),null==t.shareX)throw new Error('Protocol error: required field "shareX" was not found in object');if(r.uint32(34),r.bytes(t.shareX),null==t.shareY)throw new Error('Protocol error: required field "shareY" was not found in object');if(r.uint32(42),r.bytes(t.shareY),null==t.nullifier)throw new Error('Protocol error: required field "nullifier" was not found in object');if(r.uint32(50),r.bytes(t.nullifier),null==t.rlnIdentifier)throw new Error('Protocol error: required field "rlnIdentifier" was not found in object');r.uint32(58),r.bytes(t.rlnIdentifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.proof=t.bytes();break;case 2:i.merkleRoot=t.bytes();break;case 3:i.epoch=t.bytes();break;case 4:i.shareX=t.bytes();break;case 5:i.shareY=t.bytes();break;case 6:i.nullifier=t.bytes();break;case 7:i.rlnIdentifier=t.bytes();break;default:t.skipType(7&o)}}if(null==i.proof)throw new Error('Protocol error: value for required field "proof" was not found in protobuf');if(null==i.merkleRoot)throw new Error('Protocol error: value for required field "merkleRoot" was not found in protobuf');if(null==i.epoch)throw new Error('Protocol error: value for required field "epoch" was not found in protobuf');if(null==i.shareX)throw new Error('Protocol error: value for required field "shareX" was not found in protobuf');if(null==i.shareY)throw new Error('Protocol error: value for required field "shareY" was not found in protobuf');if(null==i.nullifier)throw new Error('Protocol error: value for required field "nullifier" was not found in protobuf');if(null==i.rlnIdentifier)throw new Error('Protocol error: value for required field "rlnIdentifier" was not found in protobuf');return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(wh||(wh={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((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)),null!=t.rateLimitProof&&(r.uint32(170),wh.codec().encode(t.rateLimitProof,r)),null!=t.ephemeral&&(r.uint32(248),r.bool(t.ephemeral)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;case 21:i.rateLimitProof=wh.codec().decode(t,t.uint32());break;case 31:i.ephemeral=t.bool();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(_h||(_h={}));const Sa="/vac/waku/filter/2.0.0-beta1";var Sh,Ih,ax,Ch,Dh;mr("waku:filter"),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(10),r.string(t.pubSubTopic)),null!=t.message&&(r.uint32(18),Dh.codec().encode(t.message,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.pubSubTopic=t.string();break;case 2:i.message=Dh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Sh||(Sh={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.isSuccess&&(r.uint32(8),r.bool(t.isSuccess)),null!=t.info&&(r.uint32(18),r.string(t.info)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.isSuccess=t.bool();break;case 2:i.info=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Ih||(Ih={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Sh.codec().encode(t.request,r)),null!=t.response&&(r.uint32(26),Ih.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Sh.codec().decode(t,t.uint32());break;case 3:i.response=Ih.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(ax||(ax={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.proof)throw new Error('Protocol error: required field "proof" was not found in object');if(r.uint32(10),r.bytes(t.proof),null==t.merkleRoot)throw new Error('Protocol error: required field "merkleRoot" was not found in object');if(r.uint32(18),r.bytes(t.merkleRoot),null==t.epoch)throw new Error('Protocol error: required field "epoch" was not found in object');if(r.uint32(26),r.bytes(t.epoch),null==t.shareX)throw new Error('Protocol error: required field "shareX" was not found in object');if(r.uint32(34),r.bytes(t.shareX),null==t.shareY)throw new Error('Protocol error: required field "shareY" was not found in object');if(r.uint32(42),r.bytes(t.shareY),null==t.nullifier)throw new Error('Protocol error: required field "nullifier" was not found in object');if(r.uint32(50),r.bytes(t.nullifier),null==t.rlnIdentifier)throw new Error('Protocol error: required field "rlnIdentifier" was not found in object');r.uint32(58),r.bytes(t.rlnIdentifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.proof=t.bytes();break;case 2:i.merkleRoot=t.bytes();break;case 3:i.epoch=t.bytes();break;case 4:i.shareX=t.bytes();break;case 5:i.shareY=t.bytes();break;case 6:i.nullifier=t.bytes();break;case 7:i.rlnIdentifier=t.bytes();break;default:t.skipType(7&o)}}if(null==i.proof)throw new Error('Protocol error: value for required field "proof" was not found in protobuf');if(null==i.merkleRoot)throw new Error('Protocol error: value for required field "merkleRoot" was not found in protobuf');if(null==i.epoch)throw new Error('Protocol error: value for required field "epoch" was not found in protobuf');if(null==i.shareX)throw new Error('Protocol error: value for required field "shareX" was not found in protobuf');if(null==i.shareY)throw new Error('Protocol error: value for required field "shareY" was not found in protobuf');if(null==i.nullifier)throw new Error('Protocol error: value for required field "nullifier" was not found in protobuf');if(null==i.rlnIdentifier)throw new Error('Protocol error: value for required field "rlnIdentifier" was not found in protobuf');return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Ch||(Ch={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((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)),null!=t.rateLimitProof&&(r.uint32(170),Ch.codec().encode(t.rateLimitProof,r)),null!=t.ephemeral&&(r.uint32(248),r.bool(t.ephemeral)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;case 21:i.rateLimitProof=Ch.codec().decode(t,t.uint32());break;case 31:i.ephemeral=t.bool();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Dh||(Dh={})),mr("waku:light-push");const Ll="/vac/waku/lightpush/2.0.0-beta1";var xh,Ah;!function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.proof)throw new Error('Protocol error: required field "proof" was not found in object');if(r.uint32(10),r.bytes(t.proof),null==t.merkleRoot)throw new Error('Protocol error: required field "merkleRoot" was not found in object');if(r.uint32(18),r.bytes(t.merkleRoot),null==t.epoch)throw new Error('Protocol error: required field "epoch" was not found in object');if(r.uint32(26),r.bytes(t.epoch),null==t.shareX)throw new Error('Protocol error: required field "shareX" was not found in object');if(r.uint32(34),r.bytes(t.shareX),null==t.shareY)throw new Error('Protocol error: required field "shareY" was not found in object');if(r.uint32(42),r.bytes(t.shareY),null==t.nullifier)throw new Error('Protocol error: required field "nullifier" was not found in object');if(r.uint32(50),r.bytes(t.nullifier),null==t.rlnIdentifier)throw new Error('Protocol error: required field "rlnIdentifier" was not found in object');r.uint32(58),r.bytes(t.rlnIdentifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.proof=t.bytes();break;case 2:i.merkleRoot=t.bytes();break;case 3:i.epoch=t.bytes();break;case 4:i.shareX=t.bytes();break;case 5:i.shareY=t.bytes();break;case 6:i.nullifier=t.bytes();break;case 7:i.rlnIdentifier=t.bytes();break;default:t.skipType(7&o)}}if(null==i.proof)throw new Error('Protocol error: value for required field "proof" was not found in protobuf');if(null==i.merkleRoot)throw new Error('Protocol error: value for required field "merkleRoot" was not found in protobuf');if(null==i.epoch)throw new Error('Protocol error: value for required field "epoch" was not found in protobuf');if(null==i.shareX)throw new Error('Protocol error: value for required field "shareX" was not found in protobuf');if(null==i.shareY)throw new Error('Protocol error: value for required field "shareY" was not found in protobuf');if(null==i.nullifier)throw new Error('Protocol error: value for required field "nullifier" was not found in protobuf');if(null==i.rlnIdentifier)throw new Error('Protocol error: value for required field "rlnIdentifier" was not found in protobuf');return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(xh||(xh={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((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)),null!=t.rateLimitProof&&(r.uint32(170),xh.codec().encode(t.rateLimitProof,r)),null!=t.ephemeral&&(r.uint32(248),r.bool(t.ephemeral)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;case 21:i.rateLimitProof=xh.codec().decode(t,t.uint32());break;case 31:i.ephemeral=t.bool();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Ah||(Ah={}));const cx=mr("waku:message:version-0"),ux=BigInt(1e6);class PV{constructor(e){this.proto=e}get _rawPayload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get ephemeral(){return Boolean(this.proto.ephemeral)}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/ux));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}}class lx{constructor(e,t=!1){this.contentTopic=e,this.ephemeral=t}toWire(e){var t=this;return $(function*(){return Ah.encode(yield t.toProtoObj(e))})()}toProtoObj(e){var t=this;return $(function*(){const r=e.timestamp??new Date;return{payload:e.payload,version:0,contentTopic:t.contentTopic,timestamp:BigInt(r.valueOf())*ux,rateLimitProof:e.rateLimitProof,ephemeral:t.ephemeral}})()}}class NV{constructor(e,t=!1){this.contentTopic=e,this.ephemeral=t}fromWireToProtoObj(e){const t=Ah.decode(e);return cx("Message decoded",t),Promise.resolve({payload:t.payload??void 0,contentTopic:t.contentTopic??void 0,version:t.version??void 0,timestamp:t.timestamp??void 0,rateLimitProof:t.rateLimitProof??void 0,ephemeral:t.ephemeral??!1})}fromProtoObj(e){return $(function*(){return void 0===e.version&&(e.version=0),0!==e.version?(cx("Failed to decode due to incorrect version, expected:",0,", actual:",e.version),Promise.resolve(void 0)):new PV(e)})()}}const Ia=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];function fx(n,...e){if(!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}const cv_exists=function LV(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")},cv_output=function BV(n,e){fx(n);const t=e.outputLen;if(n.lengthnew DataView(n.buffer,n.byteOffset,n.byteLength)),Bs=(n,e)=>n<<32-e|n>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function fv(n){if("string"==typeof n&&(n=function VV(n){if("string"!=typeof n)throw new TypeError("utf8ToBytes expected string, got "+typeof n);return(new TextEncoder).encode(n)}(n)),!(n instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof n})`);return n}Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));const zV=(n,e,t)=>n&e^~n&t,WV=(n,e,t)=>n&e^n&t^e&t,qV=new Uint32Array([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]),zo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Wo=new Uint32Array(64);class YV extends class GV extends class HV{clone(){return this._cloneInto()}}{constructor(e,t,r,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=uv(this.buffer)}update(e){cv_exists(this);const{view:t,buffer:r,blockLen:i}=this,s=(e=fv(e)).length;for(let o=0;oi-o&&(this.process(r,0),o=0);for(let l=o;l>i&s),a=Number(t&s),_=r?0:4;n.setUint32(e+(r?4:0),o,r),n.setUint32(e+_,a,r)})(r,i-8,BigInt(8*this.length),s),this.process(r,0);const a=uv(e);this.get().forEach((l,_)=>a.setUint32(4*_,l,s))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:i,finished:s,destroyed:o,pos:a}=this;return e.length=i,e.pos=a,e.finished=s,e.destroyed=o,i%t&&e.buffer.set(r),e}}{constructor(){super(64,32,8,!1),this.A=0|zo[0],this.B=0|zo[1],this.C=0|zo[2],this.D=0|zo[3],this.E=0|zo[4],this.F=0|zo[5],this.G=0|zo[6],this.H=0|zo[7]}get(){const{A:e,B:t,C:r,D:i,E:s,F:o,G:a,H:l}=this;return[e,t,r,i,s,o,a,l]}set(e,t,r,i,s,o,a,l){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|i,this.E=0|s,this.F=0|o,this.G=0|a,this.H=0|l}process(e,t){for(let N=0;N<16;N++,t+=4)Wo[N]=e.getUint32(t,!1);for(let N=16;N<64;N++){const B=Wo[N-15],U=Wo[N-2],Y=Bs(B,7)^Bs(B,18)^B>>>3,X=Bs(U,17)^Bs(U,19)^U>>>10;Wo[N]=X+Wo[N-7]+Y+Wo[N-16]|0}let{A:r,B:i,C:s,D:o,E:a,F:l,G:_,H:R}=this;for(let N=0;N<64;N++){const U=R+(Bs(a,6)^Bs(a,11)^Bs(a,25))+zV(a,l,_)+qV[N]+Wo[N]|0,X=(Bs(r,2)^Bs(r,13)^Bs(r,22))+WV(r,i,s)|0;R=_,_=l,l=a,a=o+U|0,o=s,s=i,i=r,r=U+X|0}r=r+this.A|0,i=i+this.B|0,s=s+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,_=_+this.G|0,R=R+this.H|0,this.set(r,i,s,o,a,l,_,R)}roundClean(){Wo.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}var Rh,Jc,Ph,Nh,Bl,dx,Mh,Oh;!function $V(n){const e=r=>n().update(fv(r)).digest(),t=n();e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n()}(()=>new YV),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(16),r.sint64(t.receivedTime)),null!=t.senderTime&&(r.uint32(24),r.sint64(t.senderTime)),null!=t.pubsubTopic&&(r.uint32(34),r.string(t.pubsubTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.sint64();break;case 3:i.senderTime=t.sint64();break;case 4:i.pubsubTopic=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Rh||(Rh={})),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=()=>sx(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=rr((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),Rh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=Rh.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=>nr(i,n.codec()),n.decode=i=>tr(i,n.codec())}(Jc||(Jc={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Ph||(Ph={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((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),Ph.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),Jc.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(40),r.sint64(t.startTime)),null!=t.endTime&&(r.uint32(48),r.sint64(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Ph.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=Jc.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=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Nh||(Nh={})),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=()=>sx(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=rr((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),Oh.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),Jc.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(Oh.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=Jc.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=>nr(i,n.codec()),n.decode=i=>tr(i,n.codec())}(Bl||(Bl={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),Nh.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),Bl.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=Nh.codec().decode(t,t.uint32());break;case 3:i.response=Bl.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(dx||(dx={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.proof)throw new Error('Protocol error: required field "proof" was not found in object');if(r.uint32(10),r.bytes(t.proof),null==t.merkleRoot)throw new Error('Protocol error: required field "merkleRoot" was not found in object');if(r.uint32(18),r.bytes(t.merkleRoot),null==t.epoch)throw new Error('Protocol error: required field "epoch" was not found in object');if(r.uint32(26),r.bytes(t.epoch),null==t.shareX)throw new Error('Protocol error: required field "shareX" was not found in object');if(r.uint32(34),r.bytes(t.shareX),null==t.shareY)throw new Error('Protocol error: required field "shareY" was not found in object');if(r.uint32(42),r.bytes(t.shareY),null==t.nullifier)throw new Error('Protocol error: required field "nullifier" was not found in object');if(r.uint32(50),r.bytes(t.nullifier),null==t.rlnIdentifier)throw new Error('Protocol error: required field "rlnIdentifier" was not found in object');r.uint32(58),r.bytes(t.rlnIdentifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.proof=t.bytes();break;case 2:i.merkleRoot=t.bytes();break;case 3:i.epoch=t.bytes();break;case 4:i.shareX=t.bytes();break;case 5:i.shareY=t.bytes();break;case 6:i.nullifier=t.bytes();break;case 7:i.rlnIdentifier=t.bytes();break;default:t.skipType(7&o)}}if(null==i.proof)throw new Error('Protocol error: value for required field "proof" was not found in protobuf');if(null==i.merkleRoot)throw new Error('Protocol error: value for required field "merkleRoot" was not found in protobuf');if(null==i.epoch)throw new Error('Protocol error: value for required field "epoch" was not found in protobuf');if(null==i.shareX)throw new Error('Protocol error: value for required field "shareX" was not found in protobuf');if(null==i.shareY)throw new Error('Protocol error: value for required field "shareY" was not found in protobuf');if(null==i.nullifier)throw new Error('Protocol error: value for required field "nullifier" was not found in protobuf');if(null==i.rlnIdentifier)throw new Error('Protocol error: value for required field "rlnIdentifier" was not found in protobuf');return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Mh||(Mh={})),function(n){let e;n.codec=()=>(null==e&&(e=rr((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)),null!=t.rateLimitProof&&(r.uint32(170),Mh.codec().encode(t.rateLimitProof,r)),null!=t.ephemeral&&(r.uint32(248),r.bool(t.ephemeral)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;case 21:i.rateLimitProof=Mh.codec().decode(t,t.uint32());break;case 31:i.ephemeral=t.bool();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(Oh||(Oh={})),BigInt(1e6),mr("waku:store");const kh="/vac/waku/store/2.0.0-beta4",i7="js-waku",tu=mr("waku:waku");class s7{constructor(e,t,r,i,s){this.libp2p=t;const{peerStore:o,connectionManager:a,registrar:l}=t,_={peerStore:o,connectionManager:a,registrar:l};r&&(this.store=r(_)),s&&(this.filter=s(_)),i&&(this.lightPush=i(_)),function o7(n){if(n)try{return n.multicodecs.includes(Ia[Ia.length-1])}catch{}return!1}(t.pubsub)&&(this.relay=t.pubsub),tu("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 R=e.pingKeepAlive||0,N=this.relay?e.relayKeepAlive||300:0;t.connectionManager.addEventListener("peer:connect",B=>{this.startKeepAlive(B.detail.remotePeer,R,N)}),t.connectionManager.addEventListener("peer:disconnect",B=>{this.stopKeepAlive(B.detail.remotePeer)}),t.addEventListener("peer:discovery",B=>{const U=B.detail.id;tu(`Found peer ${U.toString()}, dialing.`),t.dial(U).catch(Y=>{tu(`Fail to dial ${U}`,Y)})})}dial(e,t){var r=this;return $(function*(){const i=t??[];typeof t>"u"&&(r.relay&&i.push(xr.Relay),r.store&&i.push(xr.Store),r.filter&&i.push(xr.Filter),r.lightPush&&i.push(xr.LightPush));const s=[];return i.includes(xr.Relay)&&Ia.forEach(o=>s.push(o)),i.includes(xr.Store)&&s.push(kh),i.includes(xr.LightPush)&&s.push(Ll),i.includes(xr.Filter)&&s.push(Sa),r.libp2p.dialProtocol(e,s)})()}start(){var e=this;return $(function*(){yield e.libp2p.start()})()}stop(){var e=this;return $(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}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=>{tu(`Ping failed (${i})`,o)})},1e3*t));const s=this.relay;if(s&&0!==r){const o=new lx("/relay-ping/1/ping/null");this.relayKeepAliveTimers[i]=setInterval(()=>{tu("Sending Waku Relay ping message"),s.send(o,{payload:new Uint8Array}).catch(a=>tu("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={}}}var gv;!function(n){let e;n.codec=()=>(null==e&&(e=rr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==2?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>nr(t,n.codec()),n.decode=t=>tr(t,n.codec())}(gv||(gv={}));var Lh;!function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||null!=t.publicKey&&t.publicKey.byteLength>0)&&(r.uint32(10),r.bytes(t.publicKey)),(!0===i.writeDefaults||null!=t.payloadType&&t.payloadType.byteLength>0)&&(r.uint32(18),r.bytes(t.payloadType)),(!0===i.writeDefaults||null!=t.payload&&t.payload.byteLength>0)&&(r.uint32(26),r.bytes(t.payload)),(!0===i.writeDefaults||null!=t.signature&&t.signature.byteLength>0)&&(r.uint32(42),r.bytes(t.signature)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.publicKey=t.bytes();break;case 2:i.payloadType=t.bytes();break;case 3:i.payload=t.bytes();break;case 5:i.signature=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(Lh||(Lh={}));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=Lh.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return Lr(this.marshal(),e.marshal())}validate(e){var t=this;return $(function*(){const r=gx(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Il(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}vi.createFromProtobuf=function(){var n=$(function*(e){const t=Lh.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=$(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=gx(r,i,s),l=yield(yield Cl(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=$(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 gx=(n,e,t)=>{const r=At(n),i=Ri.encode(r.byteLength),s=Ri.encode(e.length),o=Ri.encode(t.length);return new Nr(i,r,s,e,o,t)};var Bh;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=kr((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),(!0===a.writeDefaults||null!=s.multiaddr&&s.multiaddr.byteLength>0)&&(o.uint32(10),o.bytes(s.multiaddr)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={multiaddr:new Uint8Array(0)},l=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&_)}return a})),i),r.encode=s=>Or(s,r.codec()),r.decode=s=>Mr(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=kr((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),(!0===s.writeDefaults||null!=r.peerId&&r.peerId.byteLength>0)&&(i.uint32(10),i.bytes(r.peerId)),(!0===s.writeDefaults||0n!==r.seq)&&(i.uint32(16),i.uint64(r.seq)),null!=r.addresses)for(const o of r.addresses)i.uint32(26),n.AddressInfo.codec().encode(o,i,{writeDefaults:!0});!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses.push(n.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>Or(r,n.codec()),n.decode=r=>Mr(r,n.codec())}(Bh||(Bh={}));const f7=Uint8Array.from([3,1]);let nu=(()=>{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=Bh.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 u7(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=Bh.decode(e),r=Wc(t.peerId),i=(t.addresses??[]).map(o=>Cn(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=f7,n})();const yv=Symbol.for("@libp2p/topology"),yx=()=>{};class h7{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??yx,this.onDisconnect=e.onDisconnect??yx}get[Symbol.toStringTag](){return yv.toString()}get[yv](){return!0}setRegistrar(e){var t=this;return $(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class g7{constructor(e,t,r){this.gossip=e,this.msgs=new Map,this.history=[],this.notValidatedCount=0,this.msgIdToStrFn=r;for(let i=0;i{const s=this.msgs.get(i.msgIdStr);if(s&&s.validated&&e.has(i.topic)){let o=t.get(i.topic);o||(o=[],t.set(i.topic,o)),o.push(i.msgId)}});return t}validate(e){const t=this.msgs.get(e);if(!t)return null;t.validated||this.notValidatedCount--;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=>{const r=this.msgs.get(t.msgIdStr);r&&(this.msgs.delete(t.msgIdStr),r.validated||this.notValidatedCount--)}),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return t?(this.msgs.delete(e),t):null}}var y7=x(160);const{RPC:mv}=y7,mx="/floodsub/1.0.0",vx="/meshsub/1.0.0",Ev="/meshsub/1.1.0",iu=5e3;function lo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}(Fs||(Fs={})),Fs))(),Uh=(()=>(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(Uh||(Uh={})),Uh))(),Ca=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Anonymous=1]="Anonymous"}(Ca||(Ca={})),Ca))(),Zi=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(Zi||(Zi={})),Zi))(),ai=(()=>(function(n){n.InvalidSignature="invalid_signature",n.InvalidSeqno="invalid_seqno",n.InvalidPeerId="invalid_peerid",n.SignaturePresent="signature_present",n.SeqnoPresent="seqno_present",n.FromPresent="from_present",n.TransformFailed="transform_failed"}(ai||(ai={})),ai))(),Xi=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(Xi||(Xi={})),Xi))();function bx(n){switch(n){case Fs.Ignore:return Zi.Ignore;case Fs.Reject:return Zi.Reject}}function wv(){return wv=$(function*(n,e){switch(n){case Fh:{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 Cl(e.privateKey);return{type:Ca.Signing,author:e,key:e.publicKey,privateKey:t}}case bv:return{type:Ca.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),wv.apply(this,arguments)}const Mn="ERR_INVALID_PEER_SCORE_PARAMS",Y7={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},Q7={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 Z7(n={}){return{...Y7,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function X7(n={}){return{...Q7,...n}}(r),e),{}):{}}}function e9(n){if(n.topicWeight<0)throw se(new Error("invalid topic weight; must be >= 0"),Mn);if(0===n.timeInMeshQuantum)throw se(new Error("invalid TimeInMeshQuantum; must be non zero"),Mn);if(n.timeInMeshWeight<0)throw se(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Mn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw se(new Error("invalid TimeInMeshQuantum; must be positive"),Mn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw se(new Error("invalid TimeInMeshCap; must be positive"),Mn);if(n.firstMessageDeliveriesWeight<0)throw se(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Mn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw se(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Mn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw se(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Mn);if(n.meshMessageDeliveriesWeight>0)throw se(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Mn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw se(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Mn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw se(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Mn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw se(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Mn);if(n.meshMessageDeliveriesWindow<0)throw se(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Mn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw se(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Mn);if(n.meshFailurePenaltyWeight>0)throw se(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Mn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw se(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Mn);if(n.invalidMessageDeliveriesWeight>0)throw se(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Mn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw se(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Mn)}const t9={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function n9(n={}){return{...t9,...n}}function r9(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 U=a.meshTime/l.timeInMeshQuantum;U>l.timeInMeshCap&&(U=l.timeInMeshCap),_+=U*l.timeInMeshWeight}let R=a.firstMessageDeliveries;if(R>l.firstMessageDeliveriesCap&&(R=l.firstMessageDeliveriesCap),_+=R*l.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(n)*t.appSpecificWeight,e.knownIPs.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 i9=x(6201),ci=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(ci||(ci={})),ci))();class s9{constructor(){this.records=new Map,this.queue=new i9}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:ci.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!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 a9 extends Map{constructor(e){super(),this.getDefault=e}getOrDefault(e){let t=super.get(e);return void 0===t&&(t=this.getDefault(),this.set(e,t)),t}}const su=kt("libp2p:gossipsub:score");class c9{constructor(e,t,r){this.params=e,this.metrics=t,this.peerStats=new Map,this.peerIPs=new a9(()=>new Set),this.scoreCache=new Map,this.deliveryRecords=new s9,function J7(n){for(const[e,t]of Object.entries(n.topics))try{e9(t)}catch(r){throw se(new Error(`invalid score parameters for topic ${e}: ${r.message}`),Mn)}if(n.topicScoreCap<0)throw se(new Error("invalid topic score cap; must be positive (or 0 for no cap)"),Mn);if(null==n.appSpecificScore)throw se(new Error("missing application specific score function"),Mn);if(n.IPColocationFactorWeight>0)throw se(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Mn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw se(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Mn);if(n.behaviourPenaltyWeight>0)throw se(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Mn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw se(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Mn);if(n.decayInterval<1e3)throw se(new Error("invalid DecayInterval; must be at least 1s"),Mn);if(n.decayToZero<=0||n.decayToZero>=1)throw se(new Error("invalid DecayToZero; must be between 0 and 1"),Mn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??r9}get size(){return this.peerStats.size}start(){this._backgroundInterval?su("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),su("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),su("stopped")):su("Peer score already stopped")}background(){this.refreshScores(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([e,t])=>[e,t]))}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach((r,i)=>{r.connected?(Object.entries(r.topics).forEach(([s,o])=>{const a=this.params.topics[s];void 0!==a&&(o.firstMessageDeliveries*=a.firstMessageDeliveriesDecay,o.firstMessageDeliveriesa.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this.removeIPsForPeer(i,r.knownIPs),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){this.peerStats.set(e,{connected:!0,expire:0,topics:{},knownIPs:new Set,behaviourPenalty:0})}addIP(e,t){const r=this.peerStats.get(e);r&&r.knownIPs.add(t),this.peerIPs.getOrDefault(t).add(e)}removeIP(e,t){const r=this.peerStats.get(e);r&&r.knownIPs.delete(t);const i=this.peerIPs.get(t);i&&(i.delete(e),0===i.size&&this.peerIPs.delete(t))}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this.removeIPsForPeer(e,t.knownIPs),void this.peerStats.delete(e);Object.entries(t.topics).forEach(([r,i])=>{i.firstMessageDeliveries=0;const s=this.params.topics[r].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveries{o!==e.toString()&&this.markDuplicateMessageDelivery(o,r)})):su("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,ci[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case Zi.Error:return void this.markInvalidMessageDelivery(e,r);case Zi.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===ci.unknown)return i===Zi.Ignore?(s.status=ci.ignored,void s.peers.clear()):(s.status=ci.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());su("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,ci[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case ci.unknown:i.peers.add(e);break;case ci.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case ci.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)}}}removeIPsForPeer(e,t){for(const r of t){const i=this.peerIPs.get(r);i&&(i.delete(e),0===i.size&&this.peerIPs.delete(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 u9{constructor(e,t,r){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=Math.floor(Math.random()*t.length),s=this.msgIdToStrFn(t[r]);let o=this.promises.get(s);o||(o=new Map,this.promises.set(s,o));const a=Date.now();o.has(e)||(o.set(e,a+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(s)||this.requestMsByMsg.set(s,a)))}getBrokenPromises(){const e=Date.now(),t=new Map;let r=0;return this.promises.forEach((i,s)=>{i.forEach((o,a)=>{o=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var fo=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(fo||(fo={})),fo))(),Da=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(Da||(Da={})),Da))(),ou=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(ou||(ou={})),ou))(),au=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(au||(au={})),au))(),Ta=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(Ta||(Ta={})),Ta))();x(5841);var f9=x(7585);const _x={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function Sx(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(_x).join(" / ");throw se(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=f9(n,e,t,r,_x[i]);return u5.encode64(o,null)}const Ix=At("libp2p-pubsub:");function Cv(){return Cv=$(function*(n,e,t,r){switch(n.type){case Ca.Signing:{const i={from:n.author.toBytes(),data:r,seqno:Jd(8),topic:e,signature:void 0,key:void 0},s=yr([Ix,mv.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${Mt(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key}}}case Ca.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}}}}),Cv.apply(this,arguments)}function Dv(){return Dv=$(function*(n,e){switch(n){case bv:return null!=e.signature?{valid:!1,error:ai.SignaturePresent}:null!=e.seqno?{valid:!1,error:ai.SeqnoPresent}:null!=e.key?{valid:!1,error:ai.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case Fh:{if(null==e.seqno)return{valid:!1,error:ai.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:ai.InvalidSeqno};if(null==e.signature)return{valid:!1,error:ai.InvalidSignature};if(null==e.from)return{valid:!1,error:ai.InvalidPeerId};let t,r;try{t=Wc(e.from)}catch{return{valid:!1,error:ai.InvalidPeerId}}if(e.key){if(r=Il(e.key),void 0!==t.publicKey&&!Lr(r.bytes,t.publicKey))return{valid:!1,error:ai.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:ai.InvalidPeerId};r=Il(t.publicKey)}const s=yr([Ix,mv.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${Mt(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??nT(r)}}:{valid:!1,error:ai.InvalidSignature}}}}),Dv.apply(this,arguments)}function m9(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=At(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 v9(n){return Tv.apply(this,arguments)}function Tv(){return Tv=$(function*(n){return yield pi.encode(n.data)}),Tv.apply(this,arguments)}function E9(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([B,U])=>{const Y=i.get(B)??"unknown",X=t.topics[B];if(void 0===X)return;let re=o.get(Y);re||(re={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(Y,re));let fe=0,Ie=0,ae=0,De=0,Ue=0;U.inMesh&&(fe+=Math.max(U.meshTime/X.timeInMeshQuantum,X.timeInMeshCap)*X.timeInMeshWeight);let xe=U.firstMessageDeliveries;if(xe>X.firstMessageDeliveriesCap&&(xe=X.firstMessageDeliveriesCap),Ie+=xe*X.firstMessageDeliveriesWeight,U.meshMessageDeliveriesActive&&U.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const B=t.topicScoreCap/s;for(const U of o.values())U.p1w*=B,U.p2w*=B,U.p3w*=B,U.p3bw*=B,U.p4w*=B}let a=0,l=0,_=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.knownIPs.forEach(B=>{if(t.IPColocationFactorWhitelist.has(B))return;const U=r.get(B),Y=U?U.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}}class w9{constructor(e,t,r){this.rawStream=e,this.pushable=ya({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,Kn(ws(this.pushable,this.closeController.signal,{returnOnAbort:!0}),oo(),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 _9{constructor(e,t={}){this.rawStream=e,this.closeController=new AbortController,this.source=ws(Kn(this.rawStream,ys(t)),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var S9=x(7596);const I9={maxSubscriptions:1/0,maxMessages:1/0,maxIhaveMessageIDs:1/0,maxIwantMessageIDs:1/0,maxControlMessages:1/0,maxPeerInfos:1/0};function C9(n,e){e={...e};const t=S9.Reader.create(n),r=n.length,i=void 0===r?t.len:t.pos+r,s={};for(;t.pos>>3){case 1:s.subscriptions&&s.subscriptions.length||(s.subscriptions=[]),s.subscriptions.length>>3){case 1:r.subscribe=n.bool();break;case 2:r.topic=n.string();break;default:n.skipType(7&i)}}return r}function T9(n,e){const t=void 0===e?n.len:n.pos+e,r={};for(;n.pos>>3){case 1:r.from=n.bytes();break;case 2:r.data=n.bytes();break;case 3:r.seqno=n.bytes();break;case 4:r.topic=n.string();break;case 5:r.signature=n.bytes();break;case 6:r.key=n.bytes();break;default:n.skipType(7&i)}}if(!r.topic)throw Error("missing required 'topic'");return r}function x9(n,e,t){const r=void 0===e?n.len:n.pos+e,i={};for(;n.pos>>3){case 1:i.ihave&&i.ihave.length||(i.ihave=[]),i.ihave.length>>3){case 1:i.topicID=n.string();break;case 2:i.messageIDs&&i.messageIDs.length||(i.messageIDs=[]),t.maxIhaveMessageIDs-- >0?i.messageIDs.push(n.bytes()):n.skipType(7&s);break;default:n.skipType(7&s)}}return i}function R9(n,e,t){const r=void 0===e?n.len:n.pos+e,i={};for(;n.pos>>3==1?(i.messageIDs&&i.messageIDs.length||(i.messageIDs=[]),t.maxIwantMessageIDs-- >0?i.messageIDs.push(n.bytes()):n.skipType(7&s)):n.skipType(7&s)}return i}function P9(n,e){const t=void 0===e?n.len:n.pos+e,r={};for(;n.pos>>3==1?r.topicID=n.string():n.skipType(7&i)}return r}function N9(n,e,t){const r=void 0===e?n.len:n.pos+e,i={};for(;n.pos>>3){case 1:i.topicID=n.string();break;case 2:i.peers&&i.peers.length||(i.peers=[]),t.maxPeerInfos-- >0?i.peers.push(M9(n,n.uint32())):n.skipType(7&s);break;case 3:i.backoff=n.uint64();break;default:n.skipType(7&s)}}return i}function M9(n,e){const t=void 0===e?n.len:n.pos+e,r={};for(;n.pos>>3){case 1:r.peerID=n.bytes();break;case 2:r.signedPeerRecord=n.bytes();break;default:n.skipType(7&i)}}return r}var Fl=(()=>(function(n){n[n.ip4=4]="ip4",n[n.ip6=41]="ip6"}(Fl||(Fl={})),Fl))();function xv(n){for(const e of n.tuples())switch(e[0]){case Fl.ip4:case Fl.ip6:return km(e[0],e[1])}return null}var Ei=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(Ei||(Ei={})),Ei))();class Av extends mi{constructor(e,t={}){super(),this.multicodecs=[Ev,vx],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=ya({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.directPeerInitial=null,this.status={code:Ei.stopped},this.heartbeatTimer=null,this.onPeerAddressChange=i=>{const{peerId:s,multiaddrs:o,oldMultiaddrs:a}=i.detail,l=new Set,_=new Set;for(const N of o){const B=xv(N);B&&l.add(B)}for(const N of a){const B=xv(N);B&&(l.has(B)?l.delete(B):_.add(B))}const R=s.toString();for(const N of _)this.score.removeIP(R,N);for(const N of l)this.score.addIP(R,N)},this.runHeartbeat=()=>{const i=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(s=>{this.log("Error running heartbeat",s)}).finally(()=>{if(i?.(),this.status.code===Ei.started){clearTimeout(this.status.heartbeatTimeout);let s=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;s<.25*this.opts.heartbeatInterval&&(s+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,s)}})};const r={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,...t,scoreParams:Z7(t.scoreParams),scoreThresholds:n9(t.scoreThresholds)};if(this.components=e,this.decodeRpcLimits=r.decodeRpcLimits??I9,this.globalSignaturePolicy=r.globalSignaturePolicy??Fh,r.fallbackToFloodsub&&this.multicodecs.push(mx),this.log=kt(r.debugName??"libp2p:gossipsub"),this.opts=r,this.direct=new Set(r.directPeers.map(i=>i.id.toString())),this.seenCache=new Sv({validityMs:r.seenTTL}),this.publishedMessageIds=new Sv({validityMs:r.seenTTL}),t.msgIdFn)this.msgIdFn=t.msgIdFn;else switch(this.globalSignaturePolicy){case Fh:this.msgIdFn=m9;break;case bv:this.msgIdFn=v9}if(t.fastMsgIdFn&&(this.fastMsgIdFn=t.fastMsgIdFn,this.fastMsgIdCache=new Sv({validityMs:r.seenTTL})),this.msgIdToStrFn=t.msgIdToStrFn??W7,this.mcache=t.messageCache||new g7(r.mcacheGossip,r.mcacheLength,this.msgIdToStrFn),t.dataTransform&&(this.dataTransform=t.dataTransform),t.metricsRegister){if(!t.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const i=Math.max(...Object.values(r.scoreParams.topics).map(o=>o.meshMessageDeliveriesWindow),1e3),s=function l9(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"}),mcacheNotValidatedCount:n.gauge({name:"gossipsub_mcache_not_validated_count",help:"Current mcache msg count not validated"}),fastMsgIdCacheCollision:n.gauge({name:"gossipsub_fastmsgid_cache_collision_total",help:"Total count of key collisions on fastmsgid cache put"}),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===Zi.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:Ta.graylist},s),this.peersByScoreThreshold.set({threshold:Ta.publish},o),this.peersByScoreThreshold.set({threshold:Ta.gossip},a),this.peersByScoreThreshold.set({threshold:Ta.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)}}}}(t.metricsRegister,t.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:r.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:i/1e3});s.mcacheSize.addCollect(()=>this.onScrapeMetrics(s));for(const o of this.multicodecs)s.protocolsEnabled.set({protocol:o},1);this.metrics=s}else this.metrics=null;this.gossipTracer=new u9(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new c9(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:r.heartbeatInterval}),this.maxInboundStreams=t.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams,this.allowedTopics=r.allowedTopics?new Set(r.allowedTopics):null}getPeers(){return[...this.peers.keys()].map(e=>Tr(e))}isStarted(){return this.status.code===Ei.started}start(){var e=this;return $(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function q7(n,e){return wv.apply(this,arguments)}(e.globalSignaturePolicy,e.components.peerId),e.outboundInflightQueue=ya({objectMode:!0}),Kn(e.outboundInflightQueue,function(){var o=$(function*(a){var R,l=!1,_=!1;try{for(var B,N=ut(a);l=!(B=yield N.next()).done;l=!1){const{peerId:U,connection:Y}=B.value;yield e.createOutboundStream(U,Y)}}catch(U){_=!0,R=U}finally{try{l&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()).catch(o=>e.log.error("outbound inflight queue error",o)),yield Promise.all(e.opts.directPeers.map(function(){var o=$(function*(a){yield e.components.peerStore.addressBook.add(a.id,a.addrs)});return function(a){return o.apply(this,arguments)}}()));const t=e.components.registrar;yield Promise.all(e.multicodecs.map(o=>t.handle(o,e.onIncomingStream.bind(e),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams})));const r=function p7(n){return new h7(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.components.peerStore.addEventListener("change:multiaddrs",e.onPeerAddressChange),e.status={code:Ei.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then($(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=$(function*(a){return yield e.connect(a)});return function(a){return o.apply(this,arguments)}}()))})).catch(o=>{e.log(o)})},1e3),e.log("started")})()}stop(){var e=this;return $(function*(){if(e.log("stopping"),e.status.code!==Ei.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:Ei.stopped},e.components.peerStore.removeEventListener("change:multiaddrs",e.onPeerAddressChange);const r=e.components.registrar;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,t.remoteAddr),this.createInboundStream(r,e),this.outboundInflightQueue.push({peerId:r,connection:t})}onPeerConnected(e,t){!this.isStarted()||(this.addPeer(e,t.stat.direction,t.remoteAddr),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}createOutboundStream(e,t){var r=this;return $(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new w9(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===mx&&r.floodsubPeers.add(i),r.metrics?.peersPerProtocol.inc({protocol:o},1),r.subscriptions.size>0&&(r.log("send subscriptions to",i),r.sendSubscriptions(i,Array.from(r.subscriptions),!0))}catch(s){r.log.error("createOutboundStream error",s)}})()}createInboundStream(e,t){var r=this;return $(function*(){if(!r.isStarted())return;const i=e.toString();if(!r.peers.has(i))return;const s=r.streamsInbound.get(i);void 0!==s&&(r.log("replacing existing inbound steam %s",i),s.close()),r.log("create inbound stream %s",i);const o=new _9(t,{maxDataLength:r.opts.maxInboundDataLength});r.streamsInbound.set(i,o),r.pipePeerReadStream(e,o.source).catch(a=>r.log(a))})()}addPeer(e,t,r){const i=e.toString();if(!this.peers.has(i)){this.log("new peer %p",e),this.peers.add(i),this.score.addPeer(i);const s=xv(r);null!==s?this.score.addIP(i,s):this.log("Added peer has no IP in current address %s %s",i,r.toString()),this.outbound.has(i)||this.outbound.set(i,"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,Da.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=>Tr(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return $(function*(){try{yield Kn(t,function(){var i=$(function*(s){var l,o=!1,a=!1;try{for(var R,_=ut(s);o=!(R=yield _.next()).done;o=!1){const N=R.value;try{const B=N.subarray(),U=C9(B,r.decodeRpcLimits);r.metrics?.onRpcRecv(U,B.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,U):r.handleReceivedRpc(e,U).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.handlePeerReadStreamError(i,e)}})()}handlePeerReadStreamError(e,t){this.log.error(e),this.onPeerDisconnected(t)}handleReceivedRpc(e,t){var r=this;return $(function*(){if(!r.acceptFrom(e.toString()))return r.log("received message from unacceptable peer %p",e),void r.metrics?.rpcRecvNotAccepted.inc();if(r.log("rpc from %p",e),t.subscriptions&&t.subscriptions.length>0){const i=[];t.subscriptions.forEach(s=>{const o=s.topic,a=!0===s.subscribe;if(null!=o){if(r.allowedTopics&&!r.allowedTopics.has(o))return;r.handleReceivedSubscription(e,o,a),i.push({topic:o,subscribe:a})}}),r.dispatchEvent(new zt("subscription-change",{detail:{peerId:e,subscriptions:i}}))}if(t.messages)for(const i of t.messages){if(r.allowedTopics&&!r.allowedTopics.has(i.topic))continue;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,r){this.log("subscription update from %p topic %s",e,t);let i=this.topics.get(t);null==i&&(i=new Set,this.topics.set(t,i)),r?i.add(e.toString()):i.delete(e.toString())}handleReceivedMessage(e,t){var r=()=>super.dispatchEvent,i=this;return $(function*(){i.metrics?.onMsgRecvPreValidation(t.topic);const s=yield i.validateReceivedMessage(e,t);switch(i.metrics?.onMsgRecvResult(t.topic,s.code),s.code){case Xi.duplicate:return i.score.duplicateMessage(e.toString(),s.msgIdStr,t.topic),void i.mcache.observeDuplicate(s.msgIdStr,e.toString());case Xi.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 Xi.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.peerId.equals(e)||i.opts.emitSelf)&&(r().call(i,new zt("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new zt("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return $(function*(){const i=r.fastMsgIdFn?.(t),s=void 0!==i?r.fastMsgIdCache?.get(i):void 0;if(s)return{code:Xi.duplicate,msgIdStr:s};const o=yield function h9(n,e){return Dv.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:Xi.invalid,reason:Zi.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:Xi.invalid,reason:Zi.Error,error:ai.TransformFailed}}const l=yield r.msgIdFn(a),_=r.msgIdToStrFn(l),R={msgId:l,msgIdStr:_};if(void 0!==i&&r.fastMsgIdCache&&r.fastMsgIdCache.put(i,_)&&r.metrics?.fastMsgIdCacheCollision.inc(),r.seenCache.has(_))return{code:Xi.duplicate,msgIdStr:_};r.seenCache.put(_);const N=r.topicValidators.get(t.topic);if(null!=N){let B;try{B=yield N(e,a)}catch(U){const Y=U.code;"ERR_TOPIC_VALIDATOR_IGNORE"===Y&&(B=Fs.Ignore),B="ERR_TOPIC_VALIDATOR_REJECT"===Y?Fs.Reject:Fs.Ignore}if(B!==Fs.Accept)return{code:Xi.invalid,reason:bx(B),msgIdStr:_}}return{code:Xi.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}))})}handleControlMessage(e,t){var r=this;return $(function*(){if(void 0===t)return;const i=t.ihave?r.handleIHave(e,t.ihave):[],s=t.iwant?r.handleIWant(e,t.iwant):[],o=t.graft?yield r.handleGraft(e,t.graft):[];t.prune&&(yield r.handlePrune(e,t.prune)),(i.length||s.length||o.length)&&r.sendRpc(e,{messages:s,control:{iwant:i,prune:o}})})()}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const i=this.score.score(e);return i>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),i>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(r10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:au.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=iu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:au.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:_,messageIDs:R})=>{if(!_||!R||!this.mesh.has(_))return;let N=0;R.forEach(B=>{const U=this.msgIdToStrFn(B);this.seenCache.has(U)||(o.set(U,B),N++)}),this.metrics?.onIhaveRcv(_,R.length,N)}),!o.size)return[];let a=o.size;a+s>iu&&(a=iu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let l=Array.from(o.values());return lo(l),l=l.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,l),[{messageIDs:l}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(l=>{const _=this.msgIdToStrFn(l),R=this.mcache.getWithIWantCount(_,e);null!=R?(s.set(R.msg.topic,1+(s.get(R.msg.topic)??0)),R.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,l):i.set(_,R.msg)):o++})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}handleGraft(e,t){var r=this;return $(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:l})=>{if(!l)return;const _=r.mesh.get(l);if(!_)return void(a=!1);if(_.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(l),void(a=!1);const R=r.backoff.get(l)?.get(e);return"number"==typeof R&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(l),void r.addBackoff(e,l)):(r.log("GRAFT: Add mesh link from %s in %s",e,l),r.score.graft(e,l),_.add(e),void r.metrics?.onAddToMesh(l,fo.Subscribed,1))}),i.length?yield Promise.all(i.map(l=>r.makePrune(e,l,a))):[]})()}handlePrune(e,t){var r=this;return $(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const l=r.mesh.get(s);if(!l)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),l.has(e)&&(l.delete(e),r.metrics?.onRemoveFromMesh(s,Da.Unsub,1)),"number"==typeof o&&o>0?r.doAddBackoff(e,s,1e3*o):r.addBackoff(e,s),a&&a.length){if(i{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,ou.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%15!=0)return;const e=Date.now();this.backoff.forEach((t,r)=>{t.forEach((i,s)=>{i{e.streamsOutbound.has(r)||t.push(r)}),yield Promise.all(t.map(function(){var r=$(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return $(function*(){e.length>t.opts.prunePeers&&(lo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=$(function*(s){if(!s.peerID)return;const o=Wc(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.peerStore.addressBook.consumePeerRecord(a)))return void t.log("bogus peer record obtained through px: could not add peer record to address book");r.push(o)}catch{t.log("bogus peer record obtained through px: invalid signature or not a peer record")}}});return function(s){return i.apply(this,arguments)}}())),r.length&&(yield Promise.all(r.map(function(){var i=$(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return $(function*(){t.log("Initiating connection with %s",e);const r=Tr(e),i=yield t.components.connectionManager.openConnection(r);for(const s of t.multicodecs)for(const o of t.components.registrar.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,fo.Fanout,t.size)),t.size!t.has(o)&&!this.direct.has(o)&&this.score.score(o)>=0).forEach(o=>{t.add(o)}),this.metrics?.onAddToMesh(e,fo.Random,t.size-i)}this.mesh.set(e,t),t.forEach(i=>{this.log("JOIN: Add mesh link to %s in %s",i,e),this.sendGraft(i,e)})}leave(e){var t=this;return $(function*(){if(t.status.code!==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=$(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);s.forEach(o=>{this.sendRpc(o,{messages:[t]})}),this.metrics?.onForwardMsg(t.topic,s.size)}publish(e,t){var r=()=>super.dispatchEvent,i=this;return $(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const{raw:o,msg:a}=yield function d9(n,e,t,r){return Cv.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(_);for(const U of R)i.sendRpc(U,{messages:[o]})||R.delete(U);return i.metrics?.onPublishMsg(e,N,R.size,null!=o.data?o.data.length:0),B&&(R.add(i.components.peerId.toString()),r().call(i,new zt("gossipsub:message",{detail:{propagationSource:i.components.peerId,msgId:_,msg:a}})),r().call(i,new zt("message",{detail:a}))),{recipients:Array.from(R.values()).map(U=>Tr(U))}})()}reportMessageValidationResult(e,t,r){if(r===Fs.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=bx(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){this.sendRpc(e,{control:{graft:[{topicID:t}]}})}sendPrune(e,t){var r=this;return $(function*(){const i=[yield r.makePrune(e,t,r.opts.doPX)];r.sendRpc(e,{control:{prune:i}})})()}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=mv.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){if(r.graft){t.control||(t.control={}),t.control.graft||(t.control.graft=[]);for(const i of r.graft)i.topicID&&this.mesh.get(i.topicID)?.has(e)&&t.control.graft.push(i)}if(r.prune){t.control||(t.control={}),t.control.prune||(t.control.prune=[]);for(const i of r.prune)i.topicID&&!this.mesh.get(i.topicID)?.has(e)&&t.control.prune.push(i)}}piggybackGossip(e,t,r){t.control||(t.control={}),t.control.ihave=r}sendGraftPrune(e,t,r){var i=this;return $(function*(){const s=i.opts.doPX;for(const[o,a]of e){const l=a.map(N=>({topicID:N}));let _=[];const R=t.get(o);R&&(_=yield Promise.all(R.map(function(){var N=$(function*(B){return yield i.makePrune(o,B,s&&!r.get(o))});return function(B){return N.apply(this,arguments)}}())),t.delete(o)),i.sendRpc(o,{control:{graft:l,prune:_}})}for(const[o,a]of t){const l=yield Promise.all(a.map(function(){var _=$(function*(R){return yield i.makePrune(o,R,s&&!r.get(o))});return function(R){return _.apply(this,arguments)}}()));i.sendRpc(o,{control:{prune:l}})}})()}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||(lo(r),r.length>iu&&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=lo(Array.from(o)).slice(0,i),o.forEach(a=>{let l=r;r.length>iu&&(l=lo(l.slice()).slice(0,iu)),this.pushGossip(a,{topicID:e,messageIDs:l})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,{control:{ihave:t}});for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,{control:{graft:t.graft,prune:t.prune}})}pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}makePrune(e,t,r){var i=this;return $(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===vx)return{topicID:t,peers:[]};const s=i.opts.pruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:s};const o=i.getRandomGossipPeers(t,i.opts.prunePeers,l=>l!==e&&i.score.score(l)>=0),a=yield Promise.all(Array.from(o).map(function(){var l=$(function*(_){const R=Tr(_);return{peerID:R.toBytes(),signedPeerRecord:yield i.components.peerStore.addressBook.getRawEnvelope(R)}});return function(_){return l.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return $(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const l=new Map,_=X=>{let re=l.get(X);return void 0===re&&(re=e.score.score(X),l.set(X,re)),re},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 U=new Map;e.mesh.forEach((X,re)=>{const fe=e.topics.get(re),Ie=new Set,ae=new Set;if(U.set(re,ae),fe){const xe=lo(Array.from(fe)),ht=e.backoff.get(re);for(const lt of xe){const rn=e.streamsOutbound.get(lt);if(rn&&e.multicodecs.includes(rn.protocol)&&!X.has(lt)&&!e.direct.has(lt)){const xn=_(lt);(!ht||!ht.has(lt))&&xn>=0&&Ie.add(lt),xn>=e.opts.scoreThresholds.gossipThreshold&&ae.add(lt)}}}const De=(xe,ht)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",xe,re),e.addBackoff(xe,re),X.delete(xe),_(xe)>=e.opts.scoreThresholds.gossipThreshold&&ae.add(xe),e.metrics?.onRemoveFromMesh(re,ht,1);const lt=N.get(xe);lt?lt.push(re):N.set(xe,[re])},Ue=(xe,ht)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",xe,re),e.score.graft(xe,re),X.add(xe),ae.delete(xe),e.metrics?.onAddToMesh(re,ht,1);const lt=R.get(xe);lt?lt.push(re):R.set(xe,[re])};if(X.forEach(xe=>{const ht=_(xe);ht<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",xe,ht,re),De(xe,Da.BadScore),B.set(xe,!0))}),X.size!0)}(Ie,t-X.size).forEach(lt=>{Ue(lt,fo.NotEnough)}),X.size>i){let xe=Array.from(X);xe.sort((lt,rn)=>_(rn)-_(lt)),xe=xe.slice(0,s).concat(lo(xe.slice(s)));let ht=0;if(xe.slice(0,t).forEach(lt=>{e.outbound.get(lt)&&ht++}),ht{const ir=xe[xn];for(let bi=xn;bi>0;bi--)xe[bi]=xe[bi-1];xe[0]=ir};if(ht>0){let xn=ht;for(let ir=1;ir0;ir++)e.outbound.get(xe[ir])&&(lt(ir),xn--)}let rn=t-ht;for(let xn=t;xn0;xn++)e.outbound.get(xe[xn])&&(lt(xn),rn--)}xe.slice(t).forEach(lt=>{De(lt,Da.Excess)})}if(X.size>=r){let xe=0;X.forEach(ht=>{e.outbound.get(ht)&&xe++}),xe!0===e.outbound.get(rn)).forEach(rn=>{Ue(rn,fo.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&X.size>1){const xe=Array.from(X).sort((rn,xn)=>_(rn)-_(xn)),ht=Math.floor(X.size/2),lt=_(xe[ht]);if(lt_(ir)>lt);for(const ir of xn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",ir,re),Ue(ir,fo.Opportunistic)}}});const Y=Date.now();e.fanoutLastpub.forEach((X,re)=>{X+a{const fe=e.topics.get(re);X.forEach(Ue=>{(!fe.has(Ue)||_(Ue)=e.opts.scoreThresholds.publishThreshold&&ae.push(xe),lt>=e.opts.scoreThresholds.gossipThreshold&&De.add(xe)}}}X.size{X.add(xe),De?.delete(xe)})}),e.emitGossip(U),yield e.sendGraftPrune(R,N,B),e.flush(),e.mcache.shift(),e.dispatchEvent(new zt("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=lo(s),t>0&&s.length>t&&(s=s.slice(0,t)),new Set(s)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.mcacheNotValidatedCount.set(this.mcache.notValidatedCount),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 b9(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=E9(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)}}Av.multicodec=Ev;const L9=mr("waku:message:topic-only");class B9{constructor(e){this.proto=e}get contentTopic(){return this.proto.contentTopic??""}}class F9{constructor(){this.contentTopic=""}fromWireToProtoObj(e){const t=gv.decode(e);return L9("Message decoded",t),Promise.resolve({contentTopic:t.contentTopic,payload:void 0,rateLimitProof:void 0,timestamp:void 0,version:void 0,ephemeral:void 0})}fromProtoObj(e){return $(function*(){return new B9(e)})()}}const Ul=mr("waku:relay");class Rv extends Av{constructor(e,t){super(e,t=Object.assign(t??{},{globalSignaturePolicy:Uh.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=Ia,this.observers=new Map,this.pubSubTopic=t?.pubSubTopic??"/waku/2/default-waku/proto",this.defaultDecoder=new F9}start(){var e=()=>super.start,t=this;return $(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e,t){var r=this;return $(function*(){const i=yield e.toWire(t);return i?r.publish(r.pubSubTopic,i):(Ul("Failed to encode message, aborting publish"),{recipients:[]})})()}addObserver(e,t){const r={decoder:e,callback:t};return function k9(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=$(function*(i){if(i.detail.msg.topic!==e)return;Ul(`Message received on ${e}`);const s=yield t.defaultDecoder.fromWireToProtoObj(i.detail.msg.data);if(!s||!s.contentTopic)return void Ul("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=$(function*({decoder:l,callback:_}){const R=yield l.fromWireToProtoObj(i.detail.msg.data);if(!R)return void Ul("Internal error: message previously decoded failed on 2nd pass.");const N=yield l.fromProtoObj(R);N?_(N):Ul("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 U9(n={}){return e=>new Rv(e,n)}Rv.multicodec=Ia[0],Rv.multicodec=Ia[Ia.length-1];var cu=(()=>(function(n){n.Prod="prod",n.Test="test"}(cu||(cu={})),cu))();function $9(n=cu.Prod,e=1){if(e<=0)return[];let t;switch(n){case cu.Prod:t=Pv.fleets["wakuv2.prod"]["waku-websocket"];break;case cu.Test:t=Pv.fleets["wakuv2.test"]["waku-websocket"];break;default:t=Pv.fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),function V9(n,e){return n.length<=e||n.length<=1?n:function H9(n){if(n.length<=1)return n;for(let t=0;tVt(function*(){const t=yield We(rx(n));yield*gr(ut(t.sort(e)),We)})();var Dx=x(363),xa=x(8080),Tx=x(9740);let xx=(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?"-":"_"),"");const po="/",Ax=(new TextEncoder).encode(po),Vh=Ax[0];class Ur{constructor(e,t){if("string"==typeof e)this._buf=At(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]!==Vh)throw new Error("Invalid key")}toString(e="utf8"){return Mt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Ur(e.join(po))}static random(){return new Ur(xx().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new Ur(e):"function"==typeof e.uint8Array?new Ur(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=Ax),this._buf[0]!==Vh){const e=new Uint8Array(this._buf.byteLength+1);e.fill(Vh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Vh;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let i=0;io)return!1}return t.lengtht.namespaces()))])}}function Y9(n){return[].concat(...n)}class Z9 extends class j9{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 Vt(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(e);i=!(l=yield We(a.next())).done;i=!1){const{key:_,value:R}=l.value;yield We(r.put(_,R,t)),yield{key:_,value:R}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return Vt(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(e);i=!(l=yield We(a.next())).done;i=!1){const _=l.value;yield r.get(_,t)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return Vt(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(e);i=!(l=yield We(a.next())).done;i=!1){const _=l.value;yield We(r.delete(_,t)),yield _}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}})()}batch(){var e=this;let t=[],r=[];return{put(i,s){t.push({key:i,value:s})},delete(i){r.push(i)},commit:(i=$(function*(s){yield Dx(e.putMany(t,s)),t=[],yield Dx(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return Vt(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return Vt(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=xa(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>xa(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>Cx(i,s),r)),null!=e.offset){let i=0;r=xa(r,()=>i++>=e.offset)}return null!=e.limit&&(r=Tx(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=xa(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>xa(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>Cx(i,s),r)),null!=e.offset){let i=0;r=xa(r,()=>i++>=e.offset)}return null!=e.limit&&(r=Tx(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return $(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return $(function*(){if(!(yield t.has(e)))throw function Q9(n){return n=n||new Error("Not Found"),se(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return $(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return $(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return Vt(function*(){yield*gr(ut(Object.entries(e.data).map(([t,r])=>({key:new Ur(t),value:r}))),We)})()}_allKeys(){var e=this;return Vt(function*(){yield*gr(ut(Object.entries(e.data).map(([t])=>new Ur(t))),We)})()}}var ln=(()=>(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"}(ln||(ln={})),ln))(),be=(()=>(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",n.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED"}(be||(be={})),be))();function Vl(n,e){return Ov.apply(this,arguments)}function Ov(){return Ov=Vt(function*(n,e){var i,t=!1,r=!1;try{for(var o,s=ut(n);t=!(o=yield We(s.next())).done;t=!1){const a=o.value;(yield We(e(a)))&&(yield a)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield We(s.return()))}finally{if(r)throw i}}}),Ov.apply(this,arguments)}function Rx(n,e){return kv.apply(this,arguments)}function kv(){return kv=Vt(function*(n,e){var i,t=!1,r=!1;try{for(var o,s=ut(n);t=!(o=yield We(s.next())).done;t=!1){const a=o.value;yield e(a)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield We(s.return()))}finally{if(r)throw i}}}),kv.apply(this,arguments)}function Lv(n,e){return Bv.apply(this,arguments)}function Bv(){return Bv=Vt(function*(n,e){yield*gr(ut(Rx(n,function(){var t=$(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),We)}),Bv.apply(this,arguments)}function Px(n){const e=new Set;return Vl(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function Nx(n){return Fv.apply(this,arguments)}function Fv(){return Fv=Vt(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=ut(n);r=!(a=yield We(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 We(o.return()))}finally{if(i)throw s}}if(tVt(function*(){try{yield yield We(s.findPeer(e,t))}catch(o){Mx.error(o)}})())),s=>Vl(s,Boolean),s=>Lv(s,r.components.peerStore),function(){var s=$(function*(o){return yield uu(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw se(new Error(ln.NOT_FOUND),be.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return Vt(function*(){if(0===r.routers.length)throw se(new Error("No peer routers available"),be.ERR_NO_ROUTERS_AVAILABLE);yield*gr(ut(Kn(Uv(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>Lv(i,r.components.peerStore),i=>Px(i),i=>Nx(i))),We)})()}}class J9{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0})()}stop(){var e=this;return $(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return Vt(function*(){if(0===r.routers.length)throw se(new Error("No content this.routers available"),be.ERR_NO_ROUTERS_AVAILABLE);yield*gr(ut(Kn(Uv(...r.routers.map(i=>i.findProviders(e,t))),i=>Lv(i,r.components.peerStore),i=>Px(i),i=>Nx(i))),We)})()}provide(e,t={}){var r=this;return $(function*(){if(0===r.routers.length)throw se(new Error("No content routers available"),be.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=$(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return $(function*(){if(!i.isStarted())throw se(new Error(ln.NOT_STARTED_YET),be.DHT_NOT_STARTED);const s=i.components.dht;null!=s&&(yield Hh(s.put(e,t,r)))})()}get(e,t){var r=this;return $(function*(){if(!r.isStarted())throw se(new Error(ln.NOT_STARTED_YET),be.DHT_NOT_STARTED);const i=r.components.dht;if(null!=i){var a,s=!1,o=!1;try{for(var _,l=ut(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(ln.NOT_FOUND),be.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return Vt(function*(){if(!i.isStarted())throw se(new Error(ln.NOT_STARTED_YET),be.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.dht;if(null!=o){var _,a=!1,l=!1;try{for(var N,R=ut(o.get(e,r));a=!(N=yield We(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 We(R.return()))}finally{if(l)throw _}}}if(0===s)throw se(new Error(ln.NOT_FOUND),be.ERR_NOT_FOUND)})()}}function Hl(n){if(iT(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=Cn(n)),fh(n)&&(e=n,n=function eH(n){const e=n.getPeerId();if(null==e)throw se(new Error(`${n.toString()} does not have a valid peer type`),be.ERR_INVALID_MULTIADDR);try{return Tr(e)}catch{throw se(new Error(`${n.toString()} is not a valid peer type`),be.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const tH=n=>n;class nH extends mi{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??tH}getListenAddrs(){return Array.from(this.listen).map(e=>Cn(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>Cn(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>Cn(e))}confirmObservedAddr(e){}removeObservedAddr(e){}addObservedAddr(e){let t=Cn(e);const r=t.getPeerId();null!=r&&Tr(r).equals(this.components.peerId)&&(t=t.decapsulate(Cn(`/p2p/${this.components.peerId.toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new zt("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(r=>r.toString());0===e.length&&(e=this.components.transportManager.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=>Cn(r))).map(r=>r.getPeerId()===this.components.peerId.toString()?r:r.encapsulate(`/p2p/${this.components.peerId.toString()}`))}}const Kl=x(191),Ox=kt("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class iH extends mi{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"?Ox("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];Ox(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new zt("visibilityChange",{detail:e}))}}const go=kt("libp2p:connection-manager:latency-monitor");class sH extends mi{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,go("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?go("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):go("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(go("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?(go("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(go("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function oH(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new iH,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 zt("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(),go.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,go.trace("MS: %s Data: %O",i,this.latencyData)};go.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 $l=x(2113);const Lx="CLOSING",$v="CLOSED";function $h(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 aH{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 $h(this.map.entries(),e=>[Tr(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,Tr(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 $h(this.map.keys(),e=>Tr(e))}values(){return this.map.values()}get size(){return this.map.size}}class jl{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 $h(this.set.entries(),e=>{const t=Tr(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=Tr(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return $h(this.set.values(),e=>Tr(e))}intersection(e){const t=new jl;for(const r of e)this.has(r)&&t.add(r);return t}difference(e){const t=new jl;for(const r of this)e.has(r)||t.add(r);return t}union(e){const t=new jl;for(const r of e)t.add(r);for(const r of this)t.add(r);return t}}Symbol;const Er=kt("libp2p:connection-manager"),uH={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,inboundConnectionThreshold:5,maxIncomingPendingConnections:10},Gv="libp2p",zv="connection-manager";class fH extends mi{constructor(e,t){if(super(),this.opts=Kl.call({ignoreUndefined:!0},uH,t),this.opts.maxConnectionsCn(r)),this.deny=(t.deny??[]).map(r=>Cn(r)),this.inboundConnectionRateLimiter=new zT.RateLimiterMemory({points:this.opts.inboundConnectionThreshold,duration:1}),this.incomingPendingConnections=0}isStarted(){return this.started}start(){var e=this;return $(function*(){null!=e.components.metrics&&(e.timer=e.timer??$l(e._checkMetrics,e.opts.pollInterval)),e.components.metrics?.updateComponentMetric({system:Gv,component:zv,metric:"connections",label:"direction",value:()=>{const t={inbound:0,outbound:0};for(const r of e.connections.values())for(const i of r)"inbound"===i.stat.direction?t.inbound++:t.outbound++;return t}}),e.components.metrics?.updateComponentMetric({system:Gv,component:zv,metric:"protocol-streams-total",label:"protocol",value:()=>{const t={};for(const r of e.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}}),e.components.metrics?.updateComponentMetric({system:Gv,component:zv,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{const t={};for(const i of e.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}}),e.latencyMonitor.start(),e._onLatencyMeasure=e._onLatencyMeasure.bind(e),e.latencyMonitor.addEventListener("data",e._onLatencyMeasure),e.started=!0,Er("started")})()}afterStart(){var e=this;return $(function*(){e.components.upgrader.addEventListener("connection",e.onConnect),e.components.upgrader.addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then($(function*(){const t=[];for(const r of yield e.components.peerStore.all())(yield e.components.peerStore.getTags(r.id)).filter(o=>"keep-alive"===o.name).length>0&&t.push(r.id);e.connectOnStartupController?.clear(),e.connectOnStartupController=new Ni.TimeoutController(e.startupReconnectTimeout);try{(0,Yr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=$(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{Er.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{Er.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return $(function*(){e.connectOnStartupController?.abort(),e.components.upgrader.removeEventListener("connection",e.onConnect),e.components.upgrader.removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return $(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),e.started=!1,yield e._close(),Er("stopped")})()}_close(){var e=this;return $(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push($(function*(){try{yield i.close()}catch(s){Er.error(s)}})());Er("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return $(function*(){const t=e.components.metrics;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),Er.trace("metrics update",o)}finally{e.timer=$l(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{Er.error(t)})}_onConnect(e){var t=this;return $(function*(){const{detail:r}=e;if(!t.started)return void(yield r.close());const i=r.remotePeer,s=i.toString(),o=t.connections.get(s);null!=o?o.push(r):t.connections.set(s,[r]),null!=i.publicKey&&(yield t.components.peerStore.keyBook.set(i,i.publicKey));const a=t.getConnections().length,l=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,l),t.dispatchEvent(new zt("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 zt("peer:disconnect",{detail:t})),this.components.metrics?.onPeerDisconnected(t.remotePeer))}getConnections(e){if(null!=e)return this.connections.get(e.toString())??[];let t=[];for(const r of this.connections.values())t=t.concat(r);return t}openConnection(e,t={}){var r=this;return $(function*(){Er("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return Er("had an existing connection to %p",e),i[0];let s;if(null==t?.signal){s=new Ni.TimeoutController(r.dialTimeout),t.signal=s.signal;try{(0,Yr.setMaxListeners)?.(1/0,s.signal)}catch{}}try{const o=yield r.components.dialer.dial(e,t);let a=r.connections.get(e.toString());null==a&&(a=[],r.connections.set(e.toString(),a));let l=!1;for(const _ of a)_.id===o.id&&(l=!0);return l||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return $(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=$(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!iT(e))throw se(new Error("peerId must be an instance of peer-id"),be.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=>{Er.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return $(function*(){const s=i.opts[e];Er.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(Er("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",i.components.peerId,e,t,s,r),yield i._pruneConnections(r))})()}_pruneConnections(e){var t=this;return $(function*(){const r=t.getConnections(),i=new aH;for(const a of r){const l=a.remotePeer;if(i.has(l))continue;const _=yield t.components.peerStore.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:_e.remoteAddr.toString().startsWith(s.toString())))return Er("connection from %s refused - connection remote address was in deny list",e.remoteAddr),!1;if(t.allow.some(s=>e.remoteAddr.toString().startsWith(s.toString())))return t.incomingPendingConnections++,!0;if(t.incomingPendingConnections===t.opts.maxIncomingPendingConnections)return Er("connection from %s refused - incomingPendingConnections exceeded by peer %s",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){const s=e.remoteAddr.nodeAddress().address;try{yield t.inboundConnectionRateLimiter.consume(s,1)}catch{return Er("connection from %s refused - inboundConnectionThreshold exceeded by host %s",s,e.remoteAddr),!1}}return t.getConnections().length{qo.error("could start autodial",t)}),qo("started")):qo("not enabled")})()}stop(){var e=this;return $(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),qo("stopped")):qo("not enabled")})()}_autoDial(){var e=this;return $(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.connectionManager.getConnections().length>=t)return void(e.autoDialTimeout=$l(e._autoDial,e.options.autoDialInterval));const r=yield e.components.peerStore.all(),i=yield Kn(r.sort(()=>Math.random()>.5?1:-1),s=>Vl(s,o=>!o.id.equals(e.components.peerId)),s=>qv(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=$(function*(o){return yield jh(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sVd(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=()=>Vd(i)}(r=n.Type||(n.Type={})),function(a){let l;a.codec=()=>(null==l&&(l=kr((_,R,N={})=>{if(!1!==N.lengthDelimited&&R.fork(),(!0===N.writeDefaults||null!=_.id&&_.id.byteLength>0)&&(R.uint32(10),R.bytes(_.id)),null!=_.addrs)for(const B of _.addrs)R.uint32(18),R.bytes(B);!1!==N.lengthDelimited&&R.ldelim()},(_,R)=>{const N={id:new Uint8Array(0),addrs:[]},B=null==R?_.len:_.pos+R;for(;_.pos>>3){case 1:N.id=_.bytes();break;case 2:N.addrs.push(_.bytes());break;default:_.skipType(7&U)}}return N})),l),a.encode=_=>Or(_,a.codec()),a.decode=_=>Mr(_,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=kr((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,{writeDefaults:!1})),null!=a.dstPeer&&(l.uint32(26),n.Peer.codec().encode(a.dstPeer,l,{writeDefaults:!1})),null!=a.code&&(l.uint32(32),n.Status.codec().encode(a.code,l)),!1!==_.lengthDelimited&&l.ldelim()},(a,l)=>{const _={},R=null==l?a.len:a.pos+l;for(;a.pos>>3){case 1:_.type=n.Type.codec().decode(a);break;case 2:_.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:_.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:_.code=n.Status.codec().decode(a);break;default:a.skipType(7&N)}}return _})),o),n.encode=a=>Or(a,n.codec()),n.decode=a=>Mr(a,n.codec())}(Wt||(Wt={}));const pH=kt("libp2p:stream:converter");function Bx(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=Vt(function*(){var B,R=!1,N=!1;try{for(var Y,U=ut(s);R=!(Y=yield We(U.next())).done;R=!1){const X=Y.value;yield*gr(ut(X),We)}}catch(X){N=!0,B=X}finally{try{R&&null!=U.return&&(yield We(U.return()))}finally{if(N)throw B}}})(),a={sink:R=>$(function*(){null!=e.signal&&(R=ws(R,e.signal));try{yield i(R),yield l()}catch(N){"aborted"!==N.type&&pH(N)}})(),source:null!=e.signal?ws(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>$(function*(){yield i(Vt(function*(){yield new Uint8Array(0)})()),yield l()})()};function l(){return _.apply(this,arguments)}function _(){return(_=$(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const lu="/libp2p/circuit/relay/0.1.0";function Fx(n,e){n.write({type:Wt.Type.STATUS,code:e})}function Ux(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>Cn(t))}catch(t){throw Fx(e,n.type===Wt.Type.HOP?Wt.Status.HOP_DST_MULTIADDR_INVALID:Wt.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>Cn(t))}catch(t){throw Fx(e,n.type===Wt.Type.HOP?Wt.Status.HOP_SRC_MULTIADDR_INVALID:Wt.Status.STOP_SRC_MULTIADDR_INVALID),t}}const Gl=kt("libp2p:circuit:stream-handler");class Gh{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=kd(this.stream),this.decoder=ys.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return $(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=Wt.decode(t.value);return Gl("read message type",r.type),r}Gl("read received no value, closing stream"),e.close()})()}write(e){Gl("write message type %s",e.type),this.shake.write(oo.single(Wt.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Gl("closing the stream"),this.rest().sink([]).catch(e=>{Gl.error(e)})}}const zl=kt("libp2p:circuit:stop");function mH(n){return Qv.apply(this,arguments)}function Qv(){return Qv=$(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(lu,{signal:r});zl("starting stop request to %p",e.remotePeer);const s=new Gh({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===Wt.Status.SUCCESS?(zl("stop request to %p was successful",e.remotePeer),s.rest()):(zl("stop request failed with code %d",o.code),void s.close());s.close()}),Qv.apply(this,arguments)}const Ji=kt("libp2p:circuit:hop");function Zv(){return Zv=$(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return Ji("HOP request received but we are not acting as a relay"),r.end({type:Wt.Type.STATUS,code:Wt.Status.HOP_CANT_SPEAK_RELAY});try{Ux(t,r)}catch(N){return void Ji.error("invalid hop request via peer %p %o",e.remotePeer,N)}if(null==t.dstPeer)return void Ji("HOP request received but we do not receive a dstPeer");const o=Wc(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return Ji("HOP request received but we are not connected to the destination peer"),r.end({type:Wt.Type.STATUS,code:Wt.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return Ji("did not have connection to remote peer"),r.end({type:Wt.Type.STATUS,code:Wt.Status.HOP_NO_CONN_TO_DST});const l={type:Wt.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let _;try{Ji("performing STOP request");const N=yield mH({connection:a[0],request:l});if(null==N)throw new Error("Could not stop");_=N}catch(N){return void Ji.error(N)}Ji("hop request from %p is valid",e.remotePeer),r.write({type:Wt.Type.STATUS,code:Wt.Status.SUCCESS});const R=r.rest();return Ji("creating related connections"),yield Kn(R,_,R)}),Zv.apply(this,arguments)}function Xv(){return Xv=$(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream(lu,{signal:r}),s=new Gh({stream:i});s.write(t);const o=yield s.read();if(null==o)throw se(new Error("HOP request had no response"),be.ERR_HOP_REQUEST_FAILED);if(o.code===Wt.Status.SUCCESS)return Ji("hop request was successful"),s.rest();throw Ji("hop request failed with code %d, closing stream",o.code),s.close(),se(new Error(`HOP request failed with code "${o.code??"unknown"}"`),be.ERR_HOP_REQUEST_FAILED)}),Xv.apply(this,arguments)}function Jv(){return Jv=$(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream(lu,{signal:t}),i=new Gh({stream:r});i.write({type:Wt.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==Wt.Status.SUCCESS)}),Jv.apply(this,arguments)}const es=kt("libp2p:circuit");class _H{constructor(e,t){this._init=t,this.components=e,this._started=!1}isStarted(){return this._started}start(){var e=this;return $(function*(){e._started||(e._started=!0,yield e.components.registrar.handle(lu,t=>{e._onProtocol(t).catch(r=>{es.error(r)})}).catch(t=>{es.error(t)}))})()}stop(){var e=this;return $(function*(){yield e.components.registrar.unhandle(lu)})()}hopEnabled(){return!0}hopActive(){return!0}get[Zm](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new Ni.TimeoutController(t._init.hop.timeout);try{(0,Yr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=jo(i,s.signal),a=new Gh({stream:{...i,...o}}),l=yield a.read();if(null==l)return es("request was invalid, could not read from stream"),a.write({type:Wt.Type.STATUS,code:Wt.Status.MALFORMED_MESSAGE}),void a.close();let _;switch(l.type){case Wt.Type.CAN_HOP:es("received CAN_HOP request from %p",r.remotePeer),yield function wH(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();Ji("can hop (%s) request from %p",i,e.remotePeer),t.end({type:Wt.Type.STATUS,code:i?Wt.Status.SUCCESS:Wt.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case Wt.Type.HOP:es("received HOP request from %p",r.remotePeer),yield function vH(n){return Zv.apply(this,arguments)}({connection:r,request:l,streamHandler:a,circuit:t,connectionManager:t.components.connectionManager});break;case Wt.Type.STOP:es("received STOP request from %p",r.remotePeer),_=yield function yH(n){const{connection:e,request:t,streamHandler:r}=n;try{Ux(t,r)}catch(i){return void zl.error("invalid stop request via peer %p %o",e.remotePeer,i)}return zl("stop request is valid"),r.write({type:Wt.Type.STATUS,code:Wt.Status.SUCCESS}),r.rest()}({connection:r,request:l,streamHandler:a});break;default:return es("Request of type %s not supported",l.type),a.write({type:Wt.Type.STATUS,code:Wt.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=_){const B=Bx({stream:_,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(Cn(l.dstPeer?.addrs[0])),localAddr:Cn(l.srcPeer?.addrs[0])}),U=l.type===Wt.Type.HOP?"relay":"inbound";es("new %s connection %s",U,B.remoteAddr);const Y=yield t.components.upgrader.upgradeInbound(B);es("%s connection %s upgraded",U,B.remoteAddr),null!=t.handler&&t.handler(Y)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return $(function*(){const i=e.toString().split("/p2p-circuit"),s=Cn(i[0]),o=Cn(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 es.error(Y),se(new Error(Y),be.ERR_RELAYED_DIAL)}const _=Tr(a),R=Tr(l);let N=!1,U=r.components.connectionManager.getConnections(_)[0];null==U&&(yield r.components.peerStore.addressBook.add(_,[s]),U=yield r.components.connectionManager.openConnection(_,t),N=!0);try{const Y=yield function EH(n){return Xv.apply(this,arguments)}({...t,connection:U,request:{type:Wt.Type.HOP,srcPeer:{id:r.components.peerId.toBytes(),addrs:r.components.addressManager.getAddresses().map(fe=>fe.bytes)},dstPeer:{id:R.toBytes(),addrs:[Cn(o).bytes]}}}),X=s.encapsulate(`/p2p-circuit/p2p/${r.components.peerId.toString()}`),re=Bx({stream:Y,remoteAddr:e,localAddr:X});return es("new outbound connection %s",re.remoteAddr),yield r.components.upgrader.upgradeOutbound(re)}catch(Y){throw es.error("Circuit relay dial failed",Y),N&&(yield U.close()),Y}})()}createListener(e){return this.handler=e.handler,function gH(n){const e=new Map;function r(){return(r=$(function*(o){const l=Cn(o.toString().split("/p2p-circuit").find(U=>""!==U)),_=l.getPeerId();if(null==_)throw new Error("Could not determine relay peer from multiaddr");const R=Tr(_);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 zt("listening"))})).apply(this,arguments)}const s=Object.assign(new mi,{close:(o=$(function*(){return yield Promise.resolve()}),function(){return o.apply(this,arguments)}),listen:function t(o){return r.apply(this,arguments)},getAddrs:function i(){const o=[];for(const a of e.values())o.push(a);return o}});var o;return n.connectionManager.addEventListener("peer:disconnect",o=>{const{detail:a}=o;e.delete(a.remotePeer.toString())&&s.dispatchEvent(new zt("close"))}),s}({connectionManager:this.components.connectionManager,peerStore:this.components.peerStore})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>Zc.matches(t))}}function Vx(n){return eE.apply(this,arguments)}function eE(){return eE=$(function*(n){const e=(new TextEncoder).encode(n),t=yield pi.digest(e);return ar.createV0(t)}),eE.apply(this,arguments)}const Kx="hop_relay",jx="/libp2p/relay";var Gx=x(3863);function zx(n){const{address:e}=n.nodeAddress();return Boolean(Gx(e))}function tE(n,e){const t=zx(n.multiaddr),r=zx(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}const Wl=kt("libp2p:auto-relay"),DH=()=>{};class TH{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??tE,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??DH,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.peerStore.addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{Wl.error(i)})}),this.components.connectionManager.addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return $(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===lu)){if(!t.listenRelays.has(s))try{const a=t.components.connectionManager.getConnections(r);if(0===a.length)return;const l=a[0];if(l.remoteAddr.protoCodes().includes(290))return void Wl(`relayed connection to ${s} will not be used to hop on`);(yield function bH(n){return Jv.apply(this,arguments)}({connection:l}))&&(yield t.components.peerStore.metadataBook.setValue(r,Kx,At("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=>{Wl.error(s)})}_addListenRelay(e,t){var r=this;return $(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield Kn(yield r.components.peerStore.addressBook.get(e.remotePeer),o=>qv(o,r.addressSorter),function(){var o=$(function*(a){return yield jh(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=$(function*(a){try{let l=a.multiaddr;return null==l.getPeerId()&&(l=l.encapsulate(`/p2p/${e.remotePeer.toString()}`)),l=l.encapsulate("/p2p-circuit"),yield r.components.transportManager.listen([l]),!0}catch(l){Wl.error("error listening on circuit address",l),r.onError(l)}return!1});return function(a){return o.apply(this,arguments)}}()))).includes(!0)&&r.listenRelays.add(t)}catch(i){r.onError(i),r.listenRelays.delete(t)}})()}_removeListenRelay(e){var t=this;return $(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return $(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.peerStore.all();for(const{id:R,metadata:N}of i){const B=R.toString();if(t.listenRelays.has(B)||e.includes(B))continue;const U=N.get(Kx);if(null==U||"true"!==Mt(U))continue;const Y=t.components.connectionManager.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 Vx(jx);var a,s=!1,o=!1;try{for(var _,l=ut(t.components.contentRouting.findProviders(R));s=!(_=yield l.next()).done;s=!1){const N=_.value;if(0===N.multiaddrs.length)continue;const B=N.id;if(!B.equals(t.components.peerId)&&(yield t.components.peerStore.addressBook.add(B,N.multiaddrs),yield t._tryToListenOnRelay(B),t.listenRelays.size>=t.maxListeners))return}}catch(N){o=!0,a=N}finally{try{s&&null!=l.return&&(yield l.return())}finally{if(o)throw a}}}catch(R){t.onError(R)}})()}_tryToListenOnRelay(e){var t=this;return $(function*(){try{const r=yield t.components.connectionManager.openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){Wl.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const Wx=kt("libp2p:relay");class xH{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new TH(e,{addressSorter:t.addressSorter,...t.autoRelay}):void 0,this.started=!1,this.init=t,this._advertiseService=this._advertiseService.bind(this)}isStarted(){return this.started}start(){var e=this;return $(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,Kh.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return $(function*(){null!=e.timeout&&(0,Kh.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return $(function*(){try{const t=yield Vx(jx);yield e.components.contentRouting.provide(t)}catch(t){t.code===be.ERR_NO_ROUTERS_AVAILABLE?(Wx.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):Wx.error(t)}})()}}var AH=x(5150);x(288),x(626);const qx=Pn.pki;function nE(){return nE=$(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),nE.apply(this,arguments)}const NH=kt("libp2p:keychain:cms"),rE=new WeakMap;class MH{constructor(e,t){if(null==e)throw se(new Error("keychain is required"),be.ERR_KEYCHAIN_REQUIRED);this.keychain=e,rE.set(this,{dek:t})}encrypt(e,t){var r=this;return $(function*(){if(!(t instanceof Uint8Array))throw se(new Error("Plain data must be a Uint8Array"),be.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=rE.get(r);if(null==o)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const l=Pn.pki.decryptRsaPrivateKey(s,o.dek),_=yield((n,e)=>{const t=qx.rsa.setPublicKey(e.n,e.e),r=qx.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=Pn.pkcs7.createEnvelopedData();return R.addRecipient(_),R.content=Pn.util.createBuffer(t),R.encrypt(),At(Pn.asn1.toDer(R.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return $(function*(){if(!(e instanceof Uint8Array))throw se(new Error("CMS data is required"),be.ERR_INVALID_PARAMETERS);let r;try{const N=Pn.util.createBuffer(Mt(e,"ascii")),B=Pn.asn1.fromDer(N);r=Pn.pkcs7.messageFromAsn1(B)}catch(N){throw NH.error(N),se(new Error("Invalid CMS"),be.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 PH(n,e){return nE.apply(this,arguments)}(i,function(){var N=$(function*(B){try{if(null!=(yield t.keychain.findKeyById(B.keyId)))return!0}catch{return!1}return!1});return function(B){return N.apply(this,arguments)}}());if(null==s){const N=i.map(B=>B.keyId);throw se(new Error(`Decryption needs one of the key(s): ${N.join(", ")}`),be.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"),be.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),l=rE.get(t);if(null==l)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const R=Pn.pki.decryptRsaPrivateKey(a,l.dek);return r.decrypt(s.recipient,R),At(r.content.getBytes(),"ascii")})()}}const zh=kt("libp2p:keychain"),Yo=new WeakMap,iE={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function yo(n){return null!=n&&"string"==typeof n&&n===AH(n.trim())&&n.length>0}function Dn(){return sE.apply(this,arguments)}function sE(){return(sE=$(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function Us(n){return new Ur("/pkcs8/"+n)}function mo(n){return new Ur("/info/"+n)}class Qx{constructor(e,t){if(this.components=e,this.init=Kl(iE,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?Sx(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Yo.set(this,{dek:r}),this.started=!1}isStarted(){return this.started}start(){var e=this;return $(function*(){const t=mo("self");(yield e.components.datastore.has(t))||(yield e.importPeer("self",e.components.peerId)),e.started=!0})()}stop(){this.started=!1}get cms(){const e=Yo.get(this);if(null==e)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);return new MH(this,e.dek)}static generateOptions(){const e=Object.assign({},iE),t=3*Math.ceil(16/3);return e.dek.salt=Mt(Jd(t),"base64"),e}static get options(){return iE}createKey(e,t,r=2048){var i=this;return $(function*(){if(!yo(e)||"self"===e)throw yield Dn(),se(new Error("Invalid key name"),be.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield Dn(),se(new Error("Invalid key type"),be.ERR_INVALID_KEY_TYPE);const s=Us(e);if(yield i.components.datastore.has(s))throw yield Dn(),se(new Error("Key name already exists"),be.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield Dn(),se(new Error("Invalid RSA key size"),be.ERR_INVALID_KEY_SIZE);let a;try{const l=yield tT(t,r),_=yield l.id(),R=Yo.get(i);if(null==R)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const N=R.dek,B=yield l.export(N);a={name:e,id:_};const U=i.components.datastore.batch();U.put(s,At(B)),U.put(mo(e),At(JSON.stringify(a))),yield U.commit()}catch(l){throw yield Dn(),l}return a})()}listKeys(){var e=this;return $(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var l,a=ut(e.components.datastore.query(t));i=!(l=yield a.next()).done;i=!1)r.push(JSON.parse(Mt(l.value.value)))}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return $(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield Dn(),r}})()}findKeyByName(e){var t=this;return $(function*(){if(!yo(e))throw yield Dn(),se(new Error(`Invalid key name '${e}'`),be.ERR_INVALID_KEY_NAME);const r=mo(e);try{const i=yield t.components.datastore.get(r);return JSON.parse(Mt(i))}catch(i){throw yield Dn(),zh.error(i),se(new Error(`Key '${e}' does not exist.`),be.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return $(function*(){if(!yo(e)||"self"===e)throw yield Dn(),se(new Error(`Invalid key name '${e}'`),be.ERR_INVALID_KEY_NAME);const r=Us(e),i=yield t.findKeyByName(e),s=t.components.datastore.batch();return s.delete(r),s.delete(mo(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return $(function*(){if(!yo(e)||"self"===e)throw yield Dn(),se(new Error(`Invalid old key name '${e}'`),be.ERR_OLD_KEY_NAME_INVALID);if(!yo(t)||"self"===t)throw yield Dn(),se(new Error(`Invalid new key name '${t}'`),be.ERR_NEW_KEY_NAME_INVALID);const i=Us(e),s=Us(t),o=mo(e),a=mo(t);if(yield r.components.datastore.has(s))throw yield Dn(),se(new Error(`Key '${t}' already exists`),be.ERR_KEY_ALREADY_EXISTS);try{const _=yield r.components.datastore.get(i),R=yield r.components.datastore.get(o),N=JSON.parse(Mt(R));N.name=t;const B=r.components.datastore.batch();return B.put(s,_),B.put(a,At(JSON.stringify(N))),B.delete(i),B.delete(o),yield B.commit(),N}catch(_){throw yield Dn(),_}})()}exportKey(e,t){var r=this;return $(function*(){if(!yo(e))throw yield Dn(),se(new Error(`Invalid key name '${e}'`),be.ERR_INVALID_KEY_NAME);if(null==t)throw yield Dn(),se(new Error("Password is required"),be.ERR_PASSWORD_REQUIRED);const i=Us(e);try{const o=Mt(yield r.components.datastore.get(i)),a=Yo.get(r);if(null==a)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const l=a.dek;return yield(yield Cm(o,l)).export(t)}catch(s){throw yield Dn(),s}})()}importKey(e,t,r){var i=this;return $(function*(){if(!yo(e)||"self"===e)throw yield Dn(),se(new Error(`Invalid key name '${e}'`),be.ERR_INVALID_KEY_NAME);if(null==t)throw yield Dn(),se(new Error("PEM encoded key is required"),be.ERR_PEM_REQUIRED);const s=Us(e);if(yield i.components.datastore.has(s))throw yield Dn(),se(new Error(`Key '${e}' already exists`),be.ERR_KEY_ALREADY_EXISTS);let a,l;try{a=yield Cm(t,r)}catch{throw yield Dn(),se(new Error("Cannot read the key, most likely the password is wrong"),be.ERR_CANNOT_READ_KEY)}try{l=yield a.id();const N=Yo.get(i);if(null==N)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const B=N.dek;t=yield a.export(B)}catch(N){throw yield Dn(),N}const _={name:e,id:l},R=i.components.datastore.batch();return R.put(s,At(t)),R.put(mo(e),At(JSON.stringify(_))),yield R.commit(),_})()}importPeer(e,t){var r=this;return $(function*(){try{if(!yo(e))throw se(new Error(`Invalid key name '${e}'`),be.ERR_INVALID_KEY_NAME);if(null==t)throw se(new Error("PeerId is required"),be.ERR_MISSING_PRIVATE_KEY);if(null==t.privateKey)throw se(new Error("PeerId.privKey is required"),be.ERR_MISSING_PRIVATE_KEY);const i=yield Cl(t.privateKey),s=Us(e);if(yield r.components.datastore.has(s))throw yield Dn(),se(new Error(`Key '${e}' already exists`),be.ERR_KEY_ALREADY_EXISTS);const a=Yo.get(r);if(null==a)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const l=a.dek,_=yield i.export(l),R={name:e,id:t.toString()},N=r.components.datastore.batch();return N.put(s,At(_)),N.put(mo(e),At(JSON.stringify(R))),yield N.commit(),R}catch(i){throw yield Dn(),i}})()}getPrivateKey(e){var t=this;return $(function*(){if(!yo(e))throw yield Dn(),se(new Error(`Invalid key name '${e}'`),be.ERR_INVALID_KEY_NAME);try{const r=Us(e);return Mt(yield t.components.datastore.get(r))}catch(r){throw yield Dn(),zh.error(r),se(new Error(`Key '${e}' does not exist.`),be.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return $(function*(){if("string"!=typeof e)throw yield Dn(),se(new Error(`Invalid old pass type '${typeof e}'`),be.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield Dn(),se(new Error(`Invalid new pass type '${typeof t}'`),be.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield Dn(),se(new Error(`Invalid pass length ${t.length}`),be.ERR_INVALID_PASS_LENGTH);zh("recreating keychain");const i=Yo.get(r);if(null==i)throw se(new Error("dek missing"),be.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?Sx(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";Yo.set(r,{dek:o});const a=yield r.listKeys();for(const l of a){const R=Mt(yield r.components.datastore.get(Us(l.name))),N=yield Cm(R,s),B=o.toString(),U=yield N.export(B),Y=r.components.datastore.batch(),X={name:l.name,id:l.id};Y.put(Us(l.name),At(U)),Y.put(mo(l.name),At(JSON.stringify(X))),yield Y.commit()}zh("keychain reconstructed")})()}}function Zx(n,e){return oE.apply(this,arguments)}function oE(){return oE=Vt(function*(n,e){var i,t=!1,r=!1;try{for(var o,s=ut(n);t=!(o=yield We(s.next())).done;t=!1){const a=o.value;yield We(e(a)),yield a}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield We(s.return()))}finally{if(r)throw i}}}),oE.apply(this,arguments)}var kH=x(4591);class UH{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 t2(n){return new UH(n)}class aE extends mi{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t0&&this._resetComputeTimeout()}stop(){null!=this.timeout&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=$l(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 zt("update",{detail:this.stats}))}}_updateFrequency(e){const t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;const o=i/(t??1)*1e3;let a=this.movingAverages[e];null==a&&(a=this.movingAverages[e]=[]);const l=this.movingAverageIntervals;for(let _=0;_s:s})}forPeer(e){const t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){const t=e.toString(),r=this.peerStats.get(t);null!=r&&(r.stop(),this.peerStats.delete(t),this.oldPeers.set(t,r))}_onMessage(e){if(!this.running)return;const{remotePeer:t,protocol:r,direction:i,dataLength:s}=e,o=HH[i];let a=this.forPeer(t);if(null==a){const l=new aE(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 aE(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 $H(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=Zx(r.source,l=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:l.byteLength}));const a=r.sink;r.sink=function(){var l=$(function*(_){return yield Kn(_,R=>Zx(R,N=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:N.byteLength})}),a)});return function(_){return l.apply(this,arguments)}}()}}function cE(n){return uE.apply(this,arguments)}function uE(){return uE=$(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),uE.apply(this,arguments)}class jH{constructor(e){nf(this,"value"),nf(this,"next"),this.value=e}}class GH{constructor(){up(this,Ks,void 0),up(this,ka,void 0),up(this,La,void 0),this.clear()}enqueue(e){const t=new jH(e);ta(this,Ks)?(ta(this,ka).next=t,bo(this,ka,t)):(bo(this,Ks,t),bo(this,ka,t)),nb(this,La)._++}dequeue(){const e=ta(this,Ks);if(e)return bo(this,Ks,ta(this,Ks).next),nb(this,La)._--,e.value}clear(){bo(this,Ks,void 0),bo(this,ka,void 0),bo(this,La,0)}get size(){return ta(this,La)}*[Symbol.iterator](){let e=ta(this,Ks);for(;e;)yield e.value,e=e.next}}function zH(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 GH;let t=0;const i=function(){var a=$(function*(l,_,R){t++;const N=$(function*(){return l(...R)})();_(N);try{yield N}catch{}t--,e.size>0&&e.dequeue()()});return function(_,R,N){return a.apply(this,arguments)}}(),o=(a,...l)=>new Promise(_=>{((a,l,_)=>{e.enqueue(i.bind(void 0,a,l,_)),$(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,_,l)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function WH(n){return lE.apply(this,arguments)}function lE(){return lE=$(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=zH(t);return Promise.all(n.map(i=>cE(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),lE.apply(this,arguments)}Ks=new WeakMap,ka=new WeakMap,La=new WeakMap;class qH 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 fE(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new qH({system:e,component:t,metric:r,metrics:i}):new Map,s}const Ra=kt("libp2p:transports");class YH extends mi{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=fE({component:"transport-manager",metric:"listeners",metrics:this.components.metrics}),this.faultTolerance=t.faultTolerance??Pa.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw se(new Error("Transport must have a valid tag"),be.ERR_INVALID_KEY);if(this.transports.has(t))throw se(new Error("There is already a transport with this tag"),be.ERR_DUPLICATE_TRANSPORT);Ra("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){var e=this;return $(function*(){const t=e.components.addressManager.getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return $(function*(){const t=[];for(const[r,i]of e.listeners)for(Ra("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),Ra("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return $(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw se(new Error(`No transport available for address ${String(e)}`),be.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.upgrader})}catch(s){throw null==s.code&&(s.code=be.ERR_TRANSPORT_DIAL_FAILED),s}})()}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}transportForMultiaddr(e){for(const t of this.transports.values())if(t.filter([e]).length>0)return t}listen(e){var t=this;return $(function*(){if(null==e||0===e.length)return void Ra("no addresses were provided for listening, this node is dial only");const r=[];for(const[i,s]of t.transports.entries()){const o=s.filter(e),a=[];for(const R of o){Ra("creating listener for %s on %s",i,R);const N=s.createListener({upgrader:t.components.upgrader});let B=t.listeners.get(i);null==B&&(B=[],t.listeners.set(i,B)),B.push(N),N.addEventListener("listening",()=>{t.dispatchEvent(new zt("listener:listening",{detail:N}))}),N.addEventListener("close",()=>{t.dispatchEvent(new zt("listener:close",{detail:N}))}),a.push(N.listen(R))}if(0!==a.length){if(null==(yield WH(a)).find(R=>R.isFulfilled)&&t.faultTolerance!==Pa.NO_FATAL)throw se(new Error(`Transport (${i}) could not listen on any available address`),be.ERR_NO_VALID_ADDRESSES)}else r.push(i)}if(r.length===t.transports.size){const i=`no valid addresses were provided for transports [${r.join(", ")}]`;if(t.faultTolerance===Pa.FATAL_ALL)throw se(new Error(i),be.ERR_NO_VALID_ADDRESSES);Ra(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return $(function*(){Ra("removing %s",e);for(const r of t.listeners.get(e)??[])yield r.close();t.transports.delete(e),t.listeners.delete(e)})()}removeAll(){var e=this;return $(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var Pa=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(Pa||(Pa={})),Pa))();const fu="/multistream/1.0.0";var ZH=x(247);const n2=At("\n");function dE(n){const e=new Nr(n,n2);return oo.single(e)}function ql(n,e,t={}){const r=dE(e);n.push(!0===t.writeBytes?r.subarray():r)}function XH(n,e,t={}){const r=new Nr;for(const i of e)r.append(dE(i));n.push(!0===t.writeBytes?r.subarray():r)}function JH(n,e){return hE.apply(this,arguments)}function hE(){return hE=$(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=$(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=ws(r,e.signal));const o=yield Kn(i,ys({onLength:a=>{t=a},maxDataLength:1024}),function(){var a=$(function*(l){return yield ZH(l)});return function(l){return a.apply(this,arguments)}}());if(null==o||0===o.length)throw se(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==n2[0])throw se(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),hE.apply(this,arguments)}function Wh(n,e){return pE.apply(this,arguments)}function pE(){return pE=$(function*(n,e){return Mt((yield JH(n,e)).subarray())}),pE.apply(this,arguments)}const Yl=kt("libp2p:mss:select");function gE(n,e){return yE.apply(this,arguments)}function yE(){return yE=$(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=kd(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");Yl('select: write ["%s", "%s"]',fu,a),XH(i,[At(fu),At(a)],t);let R=yield Wh(r,t);if(Yl('select: read "%s"',R),R===fu&&(R=yield Wh(r,t),Yl('select: read "%s"',R)),R===a)return s(),{stream:o,protocol:a};for(const N of e){Yl('select: write "%s"',N),ql(i,At(N),t);const B=yield Wh(r,t);if(Yl('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")}),yE.apply(this,arguments)}const Ql=kt("libp2p:mss:handle");function mE(n,e,t){return vE.apply(this,arguments)}function vE(){return vE=$(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=kd(n);for(;;){const a=yield Wh(i,t);if(Ql('read "%s"',a),a!==fu){if(e.includes(a))return ql(r,At(a),t),Ql('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(ql(r,At("na"),t),Ql('respond with "na" for "%s"',a)):(ql(r,new Nr(...e.map(l=>dE(At(l)))),t),Ql('respond with "%s" for %s',e,a))}else Ql('respond with "%s" for "%s"',fu,a),ql(r,At(fu),t)}}),vE.apply(this,arguments)}var r2=x(1626);const i2=Symbol.for("@libp2p/connection"),eK=kt("libp2p:connection");class tK{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[i2](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return $(function*(){if(r.stat.status===Lx)throw se(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===$v)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 $(function*(){if(e.stat.status!==$v&&!e._closing){e.stat.status=Lx;try{e.streams.forEach(t=>t.close())}catch(t){eK.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=$v}})()}}const s2=kt("libp2p:registrar");class rK{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.connectionManager.addEventListener("peer:disconnect",this._onDisconnect),this.components.peerStore.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}`),be.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}handle(e,t,r){var i=this;return $(function*(){if(i.handlers.has(e))throw se(new Error(`Handler already registered for protocol ${e}`),be.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Kl.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);i.handlers.set(e,{handler:t,options:s}),yield i.components.peerStore.protoBook.add(i.components.peerId,[e])})()}unhandle(e){var t=this;return $(function*(){const r=Array.isArray(e)?e:[e];r.forEach(i=>{t.handlers.delete(i)}),yield t.components.peerStore.protoBook.remove(t.components.peerId,r)})()}register(e,t){var r=this;return $(function*(){if(!function d7(n){return null!=n&&Boolean(n[yv])}(t))throw s2.error("topology must be an instance of interfaces/topology"),se(new Error("topology must be an instance of interfaces/topology"),be.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.peerStore.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=>{s2.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.connectionManager.getConnections(t)[0];null!=R&&_.onConnect(t,R)}}}}const Fn=kt("libp2p:upgrader");function c2(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class oK extends mi{constructor(e,t){super(),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(r=>{this.connectionEncryption.set(r.protocol,r)}),this.muxers=new Map,t.muxers.forEach(r=>{this.muxers.set(r.protocol,r)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout}upgradeInbound(e){var t=this;return $(function*(){if(!(yield t.components.connectionManager.acceptIncomingConnection(e)))throw se(new Error("connection denied"),be.ERR_CONNECTION_DENIED);let i,s,o,a,l,_,R;const N=t.components.metrics,B=new Ni.TimeoutController(t.inboundUpgradeTimeout);try{(0,Yr.setMaxListeners)?.(1/0,B.signal)}catch{}try{const U=jo(e,B.signal);if(e.source=U.source,e.sink=U.sink,yield t.components.connectionGater.denyInboundConnection(e))throw se(new Error("The multiaddr connection is blocked by gater.acceptConnection"),be.ERR_CONNECTION_INTERCEPTED);if(null!=N){({setTarget:_,proxy:R}=r2());const re=`${(1e9*Math.random()).toString(36)}${Date.now()}`;_({toString:()=>re}),N.trackStream({stream:e,remotePeer:R})}Fn("starting the inbound connection upgrade");let Y=e;const X=t.components.connectionProtector;null!=X&&(Fn("protecting the inbound connection"),Y=yield X.protect(e));try{if(({conn:i,remotePeer:s,protocol:l}=yield t._encryptInbound(Y)),yield t.components.connectionGater.denyInboundEncryptedConnection(s,{...Y,...i}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),be.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const re=yield t._multiplexInbound({...Y,...i},t.muxers);a=re.muxerFactory,o=re.stream}else o=i}catch(re){throw Fn.error("Failed to upgrade inbound connection",re),re}if(yield t.components.connectionGater.denyInboundUpgradedConnection(s,{...Y,...i}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),be.ERR_CONNECTION_INTERCEPTED);return null!=N&&(N.updatePlaceholder(R,s),_(s)),Fn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:l,direction:"inbound",maConn:e,upgradedConn:o,muxerFactory:a,remotePeer:s})}finally{t.components.connectionManager.afterUpgradeInbound(),B.clear()}})()}upgradeOutbound(e,t){var r=this;return $(function*(){const i=e.remoteAddr.getPeerId();if(null==i)throw se(new Error("outbound connection must have a peer id"),be.ERR_INVALID_MULTIADDR);const s=Tr(i);if(yield r.components.connectionGater.denyOutboundConnection(s,e))throw se(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),be.ERR_CONNECTION_INTERCEPTED);let o,a,l,_,R,N,B;const U=r.components.metrics;if(null!=U){({setTarget:N,proxy:B}=r2());const X=`${(1e9*Math.random()).toString(36)}${Date.now()}`;N({toB58String:()=>X}),U.trackStream({stream:e,remotePeer:B})}Fn("Starting the outbound connection upgrade");let Y=e;if(!0!==t?.skipProtection){const X=r.components.connectionProtector;null!=X&&(Y=yield X.protect(e))}try{if(o=Y,!0!==t?.skipEncryption){if(({conn:o,remotePeer:a,protocol:_}=yield r._encryptOutbound(Y,s)),yield r.components.connectionGater.denyOutboundEncryptedConnection(a,{...Y,...o}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),be.ERR_CONNECTION_INTERCEPTED)}else _="native",a=s;if(l=o,null!=t?.muxerFactory)R=t.muxerFactory;else if(r.muxers.size>0){const X=yield r._multiplexOutbound({...Y,...o},r.muxers);R=X.muxerFactory,l=X.stream}}catch(X){throw Fn.error("Failed to upgrade outbound connection",X),yield e.close(X),X}if(yield r.components.connectionGater.denyOutboundUpgradedConnection(a,{...Y,...o}))throw se(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),be.ERR_CONNECTION_INTERCEPTED);return null!=U&&(U.updatePlaceholder(B,a),N(a)),Fn("Successfully upgraded outbound connection"),r._createConnection({cryptoProtocol:_,direction:"outbound",maConn:e,upgradedConn:l,muxerFactory:R,remotePeer:a})})()}_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($(function*(){const X=t.components.registrar.getProtocols(),{stream:re,protocol:fe}=yield mE(Y,X);if(Fn("%s: incoming stream opened on %s",i,fe),t.components.metrics?.trackStream({stream:re,remotePeer:a,protocol:fe}),null==N)return;const ae=function iK(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==be.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(fe,t.components.registrar);c2(fe,"inbound",N)!==ae?(Y.source=re.source,Y.sink=re.sink,Y.stat.protocol=fe,t.components.peerStore.protoBook.add(a,[fe]).catch(Ue=>Fn.error(Ue)),N.addStream(Y),t._onStream({connection:N,stream:Y,protocol:fe})):Y.abort(se(new Error(`Too many inbound protocol streams for protocol "${fe}" - limit ${ae}`),be.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(X=>{Fn.error(X),null==Y.stat.timeline.close&&Y.close()})},onStreamEnd:Y=>{N?.removeStream(Y.id)}}),R=function(){var Y=$(function*(X,re={}){if(null==_)throw se(new Error("Stream is not multiplexed"),be.ERR_MUXER_UNAVAILABLE);Fn("%s: starting new stream on %s",i,X);const fe=yield _.newStream(),Ie=t.components.metrics;let ae;try{if(null==re.signal){Fn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",X),ae=new Ni.TimeoutController(3e4),re.signal=ae.signal;try{(0,Yr.setMaxListeners)?.(1/0,ae.signal)}catch{}}const{stream:De,protocol:Ue}=yield gE(fe,X,re);Ie?.trackStream({stream:De,remotePeer:a,protocol:Ue});const xe=function sK(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==be.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}(Ue,t.components.registrar);if(c2(Ue,"outbound",N)===xe){const lt=se(new Error(`Too many outbound protocol streams for protocol "${Ue}" - limit ${xe}`),be.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw fe.abort(lt),lt}return t.components.peerStore.protoBook.add(a,[Ue]).catch(lt=>Fn.error(lt)),fe.source=De.source,fe.sink=De.sink,fe.stat.protocol=Ue,fe}catch(De){throw Fn.error("could not create new stream",De),null==fe.stat.timeline.close&&fe.close(),null!=De.code?De:se(De,be.ERR_UNSUPPORTED_PROTOCOL)}finally{ae?.clear()}});return function(re){return Y.apply(this,arguments)}}(),Kn(o,_,o).catch(Fn.error));const B=s.timeline;s.timeline=new Proxy(B,{set:(...Y)=>(null!=N&&"close"===Y[1]&&null!=Y[2]&&null==B.close&&$(function*(){try{"OPEN"===N.stat.status&&(yield N.close())}catch(X){Fn.error(X)}finally{t.dispatchEvent(new zt("connectionEnd",{detail:N}))}})().catch(X=>{Fn.error(X)}),Reflect.set(...Y))}),s.timeline.upgraded=Date.now();const U=()=>{throw se(new Error("connection is not multiplexed"),be.ERR_CONNECTION_NOT_MULTIPLEXED)};return N=function nK(n){return new tK(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:_?.protocol,encryption:r},newStream:R??U,getStreams:()=>null!=_?_.streams:U(),close:(Y=$(function*(){yield s.close(),_?.close()}),function(){return Y.apply(this,arguments)})}),this.dispatchEvent(new zt("connection",{detail:N})),N;var Y}_onStream(e){const{connection:t,stream:r,protocol:i}=e,{handler:s}=this.components.registrar.getHandler(i);s({connection:t,stream:r})}_encryptInbound(e){var t=this;return $(function*(){const r=Array.from(t.connectionEncryption.keys());Fn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield mE(e,r,{writeBytes:!0}),o=t.connectionEncryption.get(s);if(null==o)throw new Error(`no crypto module found for ${s}`);return Fn("encrypting inbound connection..."),{...yield o.secureInbound(t.components.peerId,i),protocol:s}}catch(i){throw se(i,be.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return $(function*(){const i=Array.from(r.connectionEncryption.keys());Fn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield gE(e,i,{writeBytes:!0}),a=r.connectionEncryption.get(o);if(null==a)throw new Error(`no crypto module found for ${o}`);return Fn("encrypting outbound connection to %p",t),{...yield a.secureOutbound(r.components.peerId,s,t),protocol:o}}catch(s){throw se(s,be.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return $(function*(){const r=Array.from(t.keys());Fn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield gE(e,r,{writeBytes:!0});return Fn("%s selected as muxer protocol",s),{stream:i,muxerFactory:t.get(s)}}catch(i){throw Fn.error("error multiplexing outbound stream",i),se(i,be.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return $(function*(){const r=Array.from(t.keys());Fn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield mE(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw Fn.error("error multiplexing inbound stream",i),se(i,be.ERR_MUXER_UNAVAILABLE)}})()}}var Na;!function(n){let e;n.codec=()=>(null==e&&(e=kr((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)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)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={listenAddrs:[],protocols:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 5:i.protocolVersion=t.string();break;case 6:i.agentVersion=t.string();break;case 1:i.publicKey=t.bytes();break;case 2:i.listenAddrs.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(Na||(Na={}));const l2="js-libp2p/0.0.0",On=kt("libp2p:identify");class EE{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.connectionManager.addEventListener("peer:connect",r=>{this.identify(r.detail).catch(On.error)}),this.components.peerStore.addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.peerId.equals(i)&&this.pushToPeerStore().catch(s=>On.error(s))}),this.components.peerStore.addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.peerId.equals(i)&&this.pushToPeerStore().catch(s=>On.error(s))})}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started||(yield e.components.peerStore.metadataBook.setValue(e.components.peerId,"AgentVersion",At(e.host.agentVersion)),yield e.components.peerStore.metadataBook.setValue(e.components.peerId,"ProtocolVersion",At(e.host.protocolVersion)),yield e.components.registrar.handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{On.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.registrar.handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{On.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return $(function*(){yield e.components.registrar.unhandle(e.identifyProtocolStr),yield e.components.registrar.unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return $(function*(){const r=yield t.components.peerStore.addressBook.getRawEnvelope(t.components.peerId),i=t.components.addressManager.getAddresses().map(a=>a.bytes),s=yield t.components.peerStore.protoBook.get(t.components.peerId),o=e.map(function(){var a=$(function*(l){let _;const R=new Ni.TimeoutController(t.init.timeout);try{(0,Yr.setMaxListeners)?.(1/0,R.signal)}catch{}try{_=yield l.newStream([t.identifyPushProtocolStr],{signal:R.signal}),yield jo(_,R.signal).sink(Kn([Na.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],oo()))}catch(N){On.error("could not push identify update to peer",N)}finally{_?.close(),R.clear()}});return function(l){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return $(function*(){if(!e.isStarted())return;const t=[];for(const r of e.components.connectionManager.getConnections()){const i=r.remotePeer;!(yield e.components.peerStore.get(i)).protocols.includes(e.identifyPushProtocolStr)||t.push(r)}yield e.push(t)})()}_identify(e,t={}){var r=this;return $(function*(){let i,o,s=t.signal;if(null==s){i=new Ni.TimeoutController(r.init.timeout),s=i.signal;try{(0,Yr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=jo(o,s),l=yield Kn([],a,ys({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var _=$(function*(R){return yield uu(R)});return function(R){return _.apply(this,arguments)}}());if(null==l)throw se(new Error("No data could be retrieved"),be.ERR_CONNECTION_ENDED);try{return Na.decode(l)}catch(_){throw se(_,be.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return $(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:l,signedPeerRecord:_,agentVersion:R,protocolVersion:N}=i;if(null==s)throw se(new Error("public key was missing from identify message"),be.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"),be.ERR_INVALID_PEER);if(r.components.peerId.equals(B))throw se(new Error("identified peer is our own peer id?"),be.ERR_INVALID_PEER);const U=EE.getCleanMultiaddr(l);if(null!=_){On("received signed peer record from %p",B);try{const Y=yield vi.openAndCertify(_,nu.DOMAIN);if(!Y.peerId.equals(B))throw se(new Error("identified peer does not match the expected peer"),be.ERR_INVALID_PEER);if(yield r.components.peerStore.addressBook.consumePeerRecord(Y))return yield r.components.peerStore.protoBook.set(B,a),null!=R&&(yield r.components.peerStore.metadataBook.setValue(B,"AgentVersion",At(R))),null!=N&&(yield r.components.peerStore.metadataBook.setValue(B,"ProtocolVersion",At(N))),void On("identify completed for peer %p and protocols %o",B,a)}catch(Y){On("received invalid envelope, discard it and fallback to listenAddrs is available",Y)}}else On("no signed peer record received from %p",B);On("falling back to legacy addresses from %p",B);try{yield r.components.peerStore.addressBook.set(B,o.map(Y=>Cn(Y)))}catch(Y){On.error("received invalid addrs",Y)}yield r.components.peerStore.protoBook.set(B,a),null!=R&&(yield r.components.peerStore.metadataBook.setValue(B,"AgentVersion",At(R))),null!=N&&(yield r.components.peerStore.metadataBook.setValue(B,"ProtocolVersion",At(N))),On("identify completed for peer %p and protocols %o",B,a),On("received observed address of %s",U?.toString())})()}_handleIdentify(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new Ni.TimeoutController(t.init.timeout);try{(0,Yr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=t.components.peerId.publicKey??new Uint8Array(0),a=yield t.components.peerStore.get(t.components.peerId),l=t.components.addressManager.getAddresses().map(U=>U.decapsulateCode(vr("p2p").code));let _=a.peerRecordEnvelope;if(l.length>0&&null==_){const U=new nu({peerId:t.components.peerId,multiaddrs:l}),Y=yield vi.seal(U,t.components.peerId);yield t.components.peerStore.addressBook.consumePeerRecord(Y),_=Y.marshal().subarray()}const R=Na.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:l.map(U=>U.bytes),signedPeerRecord:_,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),N=jo(i,s.signal),B=Kn([R],oo());yield N.sink(B)}catch(o){On.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return $(function*(){const{connection:r,stream:i}=e,s=new Ni.TimeoutController(t.init.timeout);try{(0,Yr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const l=jo(i,s.signal),_=yield Kn([],l,ys({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var R=$(function*(N){return yield uu(N)});return function(N){return R.apply(this,arguments)}}());null!=_&&(o=Na.decode(_))}catch(l){return On.error("received invalid message",l)}finally{i.close(),s.clear()}if(null==o)return On.error("received invalid message");const a=r.remotePeer;if(t.components.peerId.equals(a))On("received push from ourselves?");else{if(On("received push from %p",a),null!=o.signedPeerRecord){On("received signedPeerRecord in push");try{const l=yield vi.openAndCertify(o.signedPeerRecord,nu.DOMAIN);if(yield t.components.peerStore.addressBook.consumePeerRecord(l))return On("consumed signedPeerRecord sent in push"),void(yield t.components.peerStore.protoBook.set(a,o.protocols));On("failed to consume signedPeerRecord sent in push")}catch(l){On("received invalid envelope, discard it and fallback to listenAddrs is available",l)}}else On("did not receive signedPeerRecord in push");try{yield t.components.peerStore.addressBook.set(a,o.listenAddrs.map(l=>Cn(l)))}catch(l){On.error("received invalid addrs",l)}try{yield t.components.peerStore.protoBook.set(a,o.protocols)}catch(l){On.error("received invalid protocols",l)}On("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return Cn(e)}catch{}}}var qh,Vs;!function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||""!==t.identifier)&&(r.uint32(10),r.string(t.identifier)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={identifier:""},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.identifier=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(qh||(qh={})),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=()=>Vd(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=kr((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),(!0===o.writeDefaults||null!=i.status&&0!==t[i.status])&&(s.uint32(8),n.StatusCode.codec().encode(i.status,s)),(!0===o.writeDefaults||null!=i.data&&i.data.byteLength>0)&&(s.uint32(18),s.bytes(i.data)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={status:e.OK,data:new Uint8Array(0)},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.status=n.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(7&l)}}return o})),r),n.encode=i=>Or(i,n.codec()),n.decode=i=>Mr(i,n.codec())}(Vs||(Vs={}));const d2=kt("libp2p:fetch");class mK{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/fetch/0.0.1`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}start(){var e=this;return $(function*(){yield e.components.registrar.handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{d2.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return $(function*(){yield e.components.registrar.unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return $(function*(){d2("dialing %s to %p",i.protocol,e);const s=yield i.components.connectionManager.openConnection(e,r);let o,l,a=r.signal;if(null==a){o=new Ni.TimeoutController(i.init.timeout),a=o.signal;try{(0,Yr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{l=yield s.newStream([i.protocol],{signal:a});const _=jo(l,a);return(yield Kn([qh.encode({identifier:t})],oo(),_,ys(),function(){var N=$(function*(B){const U=yield uu(B);if(null==U)throw se(new Error("No data received"),be.ERR_INVALID_MESSAGE);const Y=Vs.decode(U);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),be.ERR_INVALID_PARAMETERS)}default:throw se(new Error("Unknown response status"),be.ERR_INVALID_MESSAGE)}});return function(B){return N.apply(this,arguments)}}()))??null}finally{o?.clear(),l?.close()}})()}handleMessage(e){var t=this;return $(function*(){const{stream:r}=e,i=t;yield Kn(r,ys(),function(){var s=Vt(function*(o){const a=yield We(uu(o));if(null==a)throw se(new Error("No data received"),be.ERR_INVALID_MESSAGE);const l=qh.decode(a);let _;const R=i._getLookupFunction(l.identifier);if(null!=R){const N=yield We(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)}}(),oo(),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"),be.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const h2=kt("libp2p:ping");class wK{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/ping/1.0.0`,this.init=t}start(){var e=this;return $(function*(){yield e.components.registrar.handle(e.protocol,e.handleMessage,{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return $(function*(){yield e.components.registrar.unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;Kn(t,t).catch(r=>{h2.error(r)})}ping(e,t={}){var r=this;return $(function*(){h2("dialing %s to %p",r.protocol,e);const i=Date.now(),s=Jd(32),o=yield r.components.connectionManager.openConnection(e,t);let a,_,l=t.signal;if(null==l){a=new Ni.TimeoutController(r.init.timeout),l=a.signal;try{(0,Yr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{_=yield o.newStream([r.protocol],{signal:l});const R=jo(_,l),N=yield Kn([s],R,function(){var U=$(function*(Y){return yield uu(Y)});return function(Y){return U.apply(this,arguments)}}()),B=Date.now();if(null==N||!Lr(s,N.subarray()))throw se(new Error("Received wrong ping ack"),be.ERR_WRONG_PING_ACK);return B-i}finally{a?.clear(),_?.close()}})()}}function bE(){return(bE=$(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function IK(n){const{address:e}=n.nodeAddress();return function SK(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const _E=kt("libp2p:nat");function CK(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class DK{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.peerId.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"),be.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){mh||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{_E.error(e)}))}_start(){var e=this;return $(function*(){const t=e.components.transportManager.getAddrs();for(const r of t){const{family:i,host:s,port:o,transport:a}=r.toOptions();if(!r.isThinWaistAddress()||"tcp"!==a||IK(r)||4!==i)continue;const l=yield e._getClient(),_=e.externalAddress??(yield l.externalIp());if(Gx(_))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=CK();_E(`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.addressManager.addObservedAddr(mU({family:4,address:_,port:R},a))}})()}_getClient(){var e=this;return $(function*(){return null!=e.client||(e.client=yield function _K(){return bE.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return $(function*(){if(!mh&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){_E.error(t)}})()}}const TK=kt("libp2p:peer-record-updater");class xK{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0,e.components.transportManager.addEventListener("listener:listening",e.update),e.components.transportManager.addEventListener("listener:close",e.update),e.components.addressManager.addEventListener("change:addresses",e.update)})()}stop(){var e=this;return $(function*(){e.started=!1,e.components.transportManager.removeEventListener("listener:listening",e.update),e.components.transportManager.removeEventListener("listener:close",e.update),e.components.addressManager.removeEventListener("change:addresses",e.update)})()}update(){var e=this;Promise.resolve().then($(function*(){const t=new nu({peerId:e.components.peerId,multiaddrs:e.components.addressManager.getAddresses().map(i=>i.decapsulateCode(vr("p2p").code))}),r=yield vi.seal(t,e.components.peerId);yield e.components.peerStore.addressBook.consumePeerRecord(r)})).catch(t=>{TK.error("Could not update self peer record: %o",t)})}}class AK{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return $(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(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(ln.NOT_FOUND),be.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return Vt(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(r.dht.getClosestPeers(e,t));i=!(l=yield We(a.next())).done;i=!1){const _=l.value;"FINAL_PEER"===_.name&&(yield _.peer)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}})()}}var RK=x(3412),PK=x(7837);const Tn=kt("libp2p:peer-store:address-book"),Yh="change:multiaddrs";function NK(){return IE.apply(this,arguments)}function IE(){return(IE=$(function*(){return!0})).apply(this,arguments)}class MK{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??NK}consumePeerRecord(e){var t=this;return $(function*(){Tn.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Tn.trace("consumePeerRecord got write lock");try{let a;try{a=nu.createFromProtobuf(e.payload)}catch{return Tn.error("invalid peer record received"),!1}i=a.peerId;const l=a.multiaddrs;if(!i.equals(e.peerId))return Tn("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=nu.createFromProtobuf(R.payload);if(N.seqNumber>=a.seqNumber)return Tn("sequence number was lower or equal to existing sequence number - stored: %d received: %d",N.seqNumber,a.seqNumber),!1}const _=yield CE(i,l,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:_,peerRecordEnvelope:e.marshal().subarray()}),Tn("stored provided peer record for %p",a.peerId)}finally{Tn.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new zt(Yh,{detail:{peerId:i,multiaddrs:o.addresses.map(({multiaddr:a})=>a),oldMultiaddrs:null==s?[]:s.addresses.map(({multiaddr:a})=>a)}})),!0})()}getRawEnvelope(e){var t=this;return $(function*(){Tn.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Tn.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Tn.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return $(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield vi.createFromProtobuf(r)})()}get(e){var t=this;return $(function*(){e=Fr(e),Tn.trace("get wait for read lock");const r=yield t.store.lock.readLock();Tn.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Tn.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return $(function*(){if(e=Fr(e),!Array.isArray(t))throw Tn.error("multiaddrs must be an array of Multiaddrs"),se(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Tn.trace("set await write lock");const i=yield r.store.lock.writeLock();Tn.trace("set got write lock");let o,a,s=!1;try{const l=yield CE(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}),Tn("set multiaddrs for %p",e)}finally{Tn.trace("set multiaddrs for %p",e),Tn("set release write lock"),i()}r.dispatchEvent(new zt(Yh,{detail:{peerId:e,multiaddrs:a.addresses.map(l=>l.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:l})=>l)}})),s||r.dispatchEvent(new zt("peer",{detail:{id:e,multiaddrs:a.addresses.map(l=>l.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return $(function*(){if(e=Fr(e),!Array.isArray(t))throw Tn.error("multiaddrs must be an array of Multiaddrs"),se(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Tn.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Tn.trace("add got write lock");try{const l=yield CE(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}),Tn("added multiaddrs for %p",e)}finally{Tn.trace("set release write lock"),i()}r.dispatchEvent(new zt(Yh,{detail:{peerId:e,multiaddrs:a.addresses.map(l=>l.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:l})=>l)}})),!0===s&&r.dispatchEvent(new zt("peer",{detail:{id:e,multiaddrs:a.addresses.map(l=>l.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return $(function*(){e=Fr(e),Tn.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Tn.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{Tn.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new zt(Yh,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function CE(n,e,t){return DE.apply(this,arguments)}function DE(){return DE=$(function*(n,e,t,r=!1){return yield Kn(e,i=>PK(i,s=>{if(!fh(s))throw Tn.error("multiaddr must be an instance of Multiaddr"),se(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>xa(i,function(){var s=$(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>RK(i,s=>({multiaddr:s,isCertified:r})),function(){var i=$(function*(s){return yield rx(s)});return function(s){return i.apply(this,arguments)}}())}),DE.apply(this,arguments)}const Hs=kt("libp2p:peer-store:key-book"),p2="change:pubkey";class OK{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return $(function*(){if(e=Fr(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&&Lr(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 zt(p2,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return $(function*(){e=Fr(e),Hs.trace("get await write lock");const r=yield t.store.lock.readLock();Hs.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Hs("get release write lock"),r()}})()}delete(e){var t=this;return $(function*(){e=Fr(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 zt(p2,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const br=kt("libp2p:peer-store:metadata-book"),Qh="change:metadata";class kK{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return $(function*(){e=Fr(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 $(function*(){e=Fr(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 $(function*(){if(e=Fr(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 zt(Qh,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return $(function*(){if(e=Fr(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&&Lr(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 zt(Qh,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return $(function*(){e=Fr(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 zt(Qh,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return $(function*(){e=Fr(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 zt(Qh,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const wr=kt("libp2p:peer-store:proto-book"),Zh="change:protocols";class LK{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return $(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 $(function*(){if(e=Fr(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 zt(Zh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return $(function*(){if(e=Fr(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 zt(Zh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return $(function*(){if(e=Fr(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 zt(Zh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return $(function*(){e=Fr(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 zt(Zh,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Xh,Jh,ep;!function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.addresses)for(const s of t.addresses)r.uint32(10),Jh.codec().encode(s,r,{writeDefaults:!0});if(null!=t.protocols)for(const s of t.protocols)r.uint32(18),r.string(s);if(null!=t.metadata)for(const s of t.metadata)r.uint32(26),ep.codec().encode(s,r,{writeDefaults:!0});null!=t.pubKey&&(r.uint32(34),r.bytes(t.pubKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={addresses:[],protocols:[],metadata:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.addresses.push(Jh.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(ep.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=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(Xh||(Xh={})),function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||null!=t.multiaddr&&t.multiaddr.byteLength>0)&&(r.uint32(10),r.bytes(t.multiaddr)),null!=t.isCertified&&(r.uint32(16),r.bool(t.isCertified)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={multiaddr:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.multiaddr=t.bytes();break;case 2:i.isCertified=t.bool();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(Jh||(Jh={})),function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||""!==t.key)&&(r.uint32(10),r.string(t.key)),(!0===i.writeDefaults||null!=t.value&&t.value.byteLength>0)&&(r.uint32(18),r.bytes(t.value)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={key:"",value:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.key=t.string();break;case 2:i.value=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(ep||(ep={}));var BK=x(4818);class g2 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class FK extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const y2=n=>void 0===globalThis.DOMException?new FK(n):new DOMException(n),m2=n=>{const e=void 0===n.reason?y2("This operation was aborted."):n.reason;return e instanceof Error?e:y2(e)};function v2(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(m2(l)),l.addEventListener("abort",()=>{a(m2(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 g2("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(_)},e),$(function*(){try{o(yield n)}catch(l){a(l)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var vo,Ma=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class VK{constructor(){vo.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Ma(this,vo,"f")[this.size-1].priority>=t.priority)return void Ma(this,vo,"f").push(r);const i=function UK(n,e,t){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;t(n[o],e)<=0?(r=++o,i-=s+1):i=s}return r}(Ma(this,vo,"f"),r,(s,o)=>o.priority-s.priority);Ma(this,vo,"f").splice(i,0,r)}dequeue(){return Ma(this,vo,"f").shift()?.run}filter(e){return Ma(this,vo,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ma(this,vo,"f").length}}vo=new WeakMap;var ur,Zl,Xl,Qo,tp,Jl,np,Is,ef,Mi,rp,Oi,tf,Zo,ip,E2,b2,w2,_2,S2,I2,sp,TE,xE,op,ap,Qn=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 HK=new g2;class KK extends Error{}class C2 extends BK{constructor(e){var t,r,i,s;if(super(),ur.add(this),Zl.set(this,void 0),Xl.set(this,void 0),Qo.set(this,0),tp.set(this,void 0),Jl.set(this,void 0),np.set(this,0),Is.set(this,void 0),ef.set(this,void 0),Mi.set(this,void 0),rp.set(this,void 0),Oi.set(this,0),tf.set(this,void 0),Zo.set(this,void 0),ip.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:VK,...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})`);Qn(this,Zl,e.carryoverConcurrencyCount,"f"),Qn(this,Xl,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),Qn(this,tp,e.intervalCap,"f"),Qn(this,Jl,e.interval,"f"),Qn(this,Mi,new e.queueClass,"f"),Qn(this,rp,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,Qn(this,ip,!0===e.throwOnTimeout,"f"),Qn(this,Zo,!1===e.autoStart,"f")}get concurrency(){return st(this,tf,"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})`);Qn(this,tf,e,"f"),st(this,ur,"m",op).call(this)}add(e,t={}){var r=this;return $(function*(){return new Promise((i,s)=>{const o=function(){var a=$(function*(){var l,_,R;Qn(r,Oi,(_=st(r,Oi,"f"),++_),"f"),Qn(r,Qo,(R=st(r,Qo,"f"),++R),"f");try{if(null!==(l=t.signal)&&void 0!==l&&l.aborted)return void s(new KK("The task was aborted."));const B=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):v2(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?st(r,ip,"f"):t.throwOnTimeout)&&s(HK)});i(B),r.emit("completed",B)}catch(N){s(N),r.emit("error",N)}st(r,ur,"m",w2).call(r)});return function(){return a.apply(this,arguments)}}();st(r,Mi,"f").enqueue(o,t),st(r,ur,"m",sp).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return $(function*(){return Promise.all(e.map(function(){var i=$(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return st(this,Zo,"f")?(Qn(this,Zo,!1,"f"),st(this,ur,"m",op).call(this),this):this}pause(){Qn(this,Zo,!0,"f")}clear(){Qn(this,Mi,new(st(this,rp,"f")),"f")}onEmpty(){var e=this;return $(function*(){0!==st(e,Mi,"f").size&&(yield st(e,ur,"m",ap).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return $(function*(){st(t,Mi,"f").sizest(t,Mi,"f").size{st(this,ur,"m",S2).call(this)},t),"f"),!0;Qn(this,Qo,st(this,Zl,"f")?st(this,Oi,"f"):0,"f")}return!1},sp=function(){if(0===st(this,Mi,"f").size)return st(this,Is,"f")&&clearInterval(st(this,Is,"f")),Qn(this,Is,void 0,"f"),st(this,ur,"m",_2).call(this),!1;if(!st(this,Zo,"f")){const e=!st(this,ur,"a",I2);if(st(this,ur,"a",E2)&&st(this,ur,"a",b2)){const t=st(this,Mi,"f").dequeue();return!!t&&(this.emit("active"),t(),e&&st(this,ur,"m",TE).call(this),!0)}}return!1},TE=function(){st(this,Xl,"f")||void 0!==st(this,Is,"f")||(Qn(this,Is,setInterval(()=>{st(this,ur,"m",xE).call(this)},st(this,Jl,"f")),"f"),Qn(this,np,Date.now()+st(this,Jl,"f"),"f"))},xE=function(){0===st(this,Qo,"f")&&0===st(this,Oi,"f")&&st(this,Is,"f")&&(clearInterval(st(this,Is,"f")),Qn(this,Is,void 0,"f")),Qn(this,Qo,st(this,Zl,"f")?st(this,Oi,"f"):0,"f"),st(this,ur,"m",op).call(this)},op=function(){for(;st(this,ur,"m",sp).call(this););},ap=function(){var n=$(function*(t,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(t,s),i())};this.on(t,s)})});return function e(t,r){return n.apply(this,arguments)}}();const D2="lock:worker:request-read",T2="lock:worker:release-read",x2="lock:master:grant-read",A2="lock:worker:request-write",R2="lock:worker:release-write",P2="lock:master:grant-write",Xo={},du=n=>{n.addEventListener("message",e=>{du.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{du.dispatchEvent("message",n,e)})};du.addEventListener=(n,e)=>{null==Xo[n]&&(Xo[n]=[]),Xo[n].push(e)},du.removeEventListener=(n,e)=>{null!=Xo[n]&&(Xo[n]=Xo[n].filter(t=>t===e))},du.dispatchEvent=function(n,e,t){null!=Xo[n]&&Xo[n].forEach(r=>r(e,t))};const N2=du,M2=(n,e,t,r,i)=>(s,o)=>{if(o.data.type!==t)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};var l;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(l=$(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(_=>{const R=N=>{null!=N&&null!=N.data&&N.data.type===r&&N.data.identifier===a.identifier&&(s.removeEventListener("message",R),_())};s.addEventListener("message",R)})}),function(){return l.apply(this,arguments)})}}))},O2=(n,e,t,r)=>$(function*(){const i=xx();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)})}),$K={singleProcess:!1},Oa={};let Jo;function AE(n,e){return RE.apply(this,arguments)}function RE(){return RE=$(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add($(function*(){return yield ex($(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),RE.apply(this,arguments)}const zK={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const k2=kt("libp2p:peer-store:store"),L2="/peers/";class qK{constructor(e){this.components=e,this.lock=function WK(n){const e=Object.assign({},zK,n);return null==Jo&&(Jo=(n=>{if(n=Object.assign({},$K,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return N2.addEventListener("message",M2(t,"requestReadLock",D2,T2,x2)),N2.addEventListener("message",M2(t,"requestWriteLock",A2,R2,P2)),t}return{isWorker:!0,readLock:t=>O2(t,D2,x2,T2),writeLock:t=>O2(t,A2,P2,R2)}})(e),!0!==Jo.isWorker&&(Jo.addEventListener("requestReadLock",t=>{null!=Oa[t.data.name]&&Oa[t.data.name].readLock().then(function(){var r=$(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),Jo.addEventListener("requestWriteLock",function(){var t=$(function*(r){null!=Oa[r.data.name]&&Oa[r.data.name].writeLock().then(function(){var i=$(function*(s){return yield r.data.handler().finally(()=>s())});return function(s){return i.apply(this,arguments)}}())});return function(r){return t.apply(this,arguments)}}()))),null==Oa[e.name]&&(Oa[e.name]=((n,e)=>{if(!0===Jo.isWorker)return{readLock:Jo.readLock(n,e),writeLock:Jo.writeLock(n,e)};const t=new C2({concurrency:1});let r;return{readLock:()=>$(function*(){if(null!=r)return yield AE(r,e);r=new C2({concurrency:e.concurrency,autoStart:!1});const i=r,s=AE(r,e);return t.add($(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>$(function*(){return r=null,yield AE(t,e)})()}})(e.name,e)),Oa[e.name]}({name:"peer-store",singleProcess:!0})}_peerIdToDatastoreKey(e){if(null==e.type)throw k2.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 Ur(`${L2}${t}`)}has(e){var t=this;return $(function*(){return yield t.components.datastore.has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return $(function*(){yield t.components.datastore.delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return $(function*(){const r=yield t.components.datastore.get(t._peerIdToDatastoreKey(e)),i=Xh.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:Cn(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return $(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!Lr(e.pubKey,e.id.publicKey))throw k2.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=Xh.encode({addresses:i,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:s,peerRecordEnvelope:e.peerRecordEnvelope});return yield t.components.datastore.put(t._peerIdToDatastoreKey(e.id),o.subarray()),yield t.load(e.id)})()}patch(e,t){var r=this;return $(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return $(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._patch(e,t,i)})()}_patch(e,t,r){var i=this;return $(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return $(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return $(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._merge(e,t,i)})()}_merge(e,t,r){var i=this;return $(function*(){const s=new Map;return r.addresses.forEach(o=>{s.set(o.multiaddr.toString(),o.isCertified)}),(t.addresses??[]).forEach(o=>{const a=o.multiaddr.toString(),_=Boolean(s.get(a))||o.isCertified;s.set(a,_)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:Cn(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 Vt(function*(){var i,t=!1,r=!1;try{for(var o,s=ut(e.components.datastore.queryKeys({prefix:L2}));t=!(o=yield We(s.next())).done;t=!1){const l=o.value.toString().split("/")[2],_=ao.decode(l);yield e.load(Wc(_))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield We(s.return()))}finally{if(r)throw i}}})()}}var ea,cp;!function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.tags)for(const s of t.tags)r.uint32(10),cp.codec().encode(s,r,{writeDefaults:!0});!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={tags:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.tags.push(cp.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(ea||(ea={})),function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||""!==t.name)&&(r.uint32(10),r.string(t.name)),null!=t.value&&(r.uint32(16),r.uint32(t.value)),null!=t.expiry&&(r.uint32(24),r.uint64(t.expiry)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={name:""},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.name=t.string();break;case 2:i.value=t.uint32();break;case 3:i.expiry=t.uint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(cp||(cp={}));const ts=kt("libp2p:peer-store");class YK extends mi{constructor(e,t={}){super(),this.components=e,this.store=new qK(e),this.addressBook=new MK(this.dispatchEvent.bind(this),this.store,t.addressFilter),this.keyBook=new OK(this.dispatchEvent.bind(this),this.store),this.metadataBook=new kK(this.dispatchEvent.bind(this),this.store),this.protoBook=new LK(this.dispatchEvent.bind(this),this.store)}forEach(e){var t=this;return $(function*(){ts.trace("getPeers await read lock");const r=yield t.store.lock.readLock();ts.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var l,a=ut(t.store.all());i=!(l=yield a.next()).done;i=!1){const _=l.value;_.id.equals(t.components.peerId)||e(_)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{ts.trace("getPeers release read lock"),r()}})()}all(){var e=this;return $(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return $(function*(){ts.trace("delete await write lock");const r=yield t.store.lock.writeLock();ts.trace("delete got write lock");try{yield t.store.delete(e)}finally{ts.trace("delete release write lock"),r()}})()}get(e){var t=this;return $(function*(){ts.trace("get await read lock");const r=yield t.store.lock.readLock();ts.trace("get got read lock");try{return yield t.store.load(e)}finally{ts.trace("get release read lock"),r()}})()}has(e){var t=this;return $(function*(){ts.trace("has await read lock");const r=yield t.store.lock.readLock();ts.trace("has got read lock");try{return yield t.store.has(e)}finally{ts.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return $(function*(){const s=r.value??0,o=Math.round(s),a=r.ttl??void 0;if(o!==s||o<0||o>100)throw 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&&(_=ea.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",ea.encode({tags:_}).subarray())})()}unTagPeer(e,t){var r=this;return $(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=ea.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",ea.encode({tags:s}).subarray())})()}getTags(e){var t=this;return $(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=ea.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",ea.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class QK{constructor(e){this.dht=e}provide(e){var t=this;return $(function*(){yield Hh(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return Vt(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(r.dht.findProviders(e,t));i=!(l=yield We(a.next())).done;i=!1){const _=l.value;"PROVIDER"===_.name&&(yield*gr(ut(_.providers),We))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield We(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return $(function*(){yield Hh(i.dht.put(e,t,r))})()}get(e,t){var r=this;return $(function*(){var o,i=!1,s=!1;try{for(var l,a=ut(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")})()}}class ZK{constructor(e={}){this._started=!1,this._peerId=e.peerId,this._addressManager=e.addressManager,this._peerStore=e.peerStore,this._upgrader=e.upgrader,this._metrics=e.metrics,this._registrar=e.registrar,this._connectionManager=e.connectionManager,this._transportManager=e.transportManager,this._connectionGater=e.connectionGater,this._contentRouting=e.contentRouting,this._peerRouting=e.peerRouting,this._datastore=e.datastore,this._connectionProtector=e.connectionProtector,this._dht=e.dht,this._pubsub=e.pubsub,this._dialer=e.dialer}isStarted(){return this._started}beforeStart(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>ho(t)).map(function(){var t=$(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>ho(t)).map(function(){var t=$(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e._started=!0})()}afterStart(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>ho(t)).map(function(){var t=$(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>ho(t)).map(function(){var t=$(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>ho(t)).map(function(){var t=$(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e._started=!1})()}afterStop(){var e=this;return $(function*(){yield Promise.all(Object.values(e).filter(t=>ho(t)).map(function(){var t=$(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}()))})()}get peerId(){if(null==this._peerId)throw se(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this._peerId}set peerId(e){this._peerId=e}get addressManager(){if(null==this._addressManager)throw se(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this._addressManager}set addressManager(e){this._addressManager=e}get peerStore(){if(null==this._peerStore)throw se(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this._peerStore}set peerStore(e){this._peerStore=e}get upgrader(){if(null==this._upgrader)throw se(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this._upgrader}set upgrader(e){this._upgrader=e}get registrar(){if(null==this._registrar)throw se(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this._registrar}set registrar(e){this._registrar=e}get connectionManager(){if(null==this._connectionManager)throw se(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this._connectionManager}set connectionManager(e){this._connectionManager=e}get transportManager(){if(null==this._transportManager)throw se(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this._transportManager}set transportManager(e){this._transportManager=e}get connectionGater(){if(null==this._connectionGater)throw se(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this._connectionGater}set connectionGater(e){this._connectionGater=e}get contentRouting(){if(null==this._contentRouting)throw se(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this._contentRouting}set contentRouting(e){this._contentRouting=e}get peerRouting(){if(null==this._peerRouting)throw se(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this._peerRouting}set peerRouting(e){this._peerRouting=e}get datastore(){if(null==this._datastore)throw se(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this._datastore}set datastore(e){this._datastore=e}get connectionProtector(){return this._connectionProtector}set connectionProtector(e){this._connectionProtector=e}get dialer(){if(null==this._dialer)throw se(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this._dialer}set dialer(e){this._dialer=e}get metrics(){return this._metrics}set metrics(e){this._metrics=e}get dht(){return this._dht}set dht(e){this._dht=e}get pubsub(){return this._pubsub}set pubsub(e){this._pubsub=e}}var B2=x(1384);const XK=globalThis.fetch,JK=globalThis.Headers;function PE(n,e,t){return`${n}?name=${e}&type=${t}`}function e$(n,e){return NE.apply(this,arguments)}function NE(){return NE=$(function*(n,e){return yield(yield XK(n,{headers:new JK({accept:"application/dns-json"}),signal:e})).json()}),NE.apply(this,arguments)}function hu(n,e){return`${e}_${n}`}globalThis,globalThis;const ME=Object.assign(mr("dns-over-http-resolver"),{error:mr("dns-over-http-resolver:error")}),n$=class t${constructor(e={}){this._cache=new B2({max:e?.maxCache??100}),this._TXTcache=new B2({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??e$,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){const e=[...this._servers];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),i=e[t];e[t]=e[r],e[r]=i}return e}setServers(e){this._servers=e}resolve(e,t="A"){var r=this;return $(function*(){switch(t){case"A":return yield r.resolve4(e);case"AAAA":return yield r.resolve6(e);case"TXT":return yield r.resolveTxt(e);default:throw new Error(`${t} is not supported`)}})()}resolve4(e){var t=this;return $(function*(){const i=t._cache.get(hu(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(PE(o,e,"A"),a.signal),_=l.Answer.map(N=>N.data),R=Math.min(...l.Answer.map(N=>N.TTL));return t._cache.set(hu(e,"A"),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),ME.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record A`)})()}resolve6(e){var t=this;return $(function*(){const r="AAAA",i=t._cache.get(hu(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(PE(o,e,r),a.signal),_=l.Answer.map(N=>N.data),R=Math.min(...l.Answer.map(N=>N.TTL));return t._cache.set(hu(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),ME.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(l=>l!==a)}}throw s?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record AAAA`)})()}resolveTxt(e){var t=this;return $(function*(){const r="TXT",i=t._TXTcache.get(hu(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(PE(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(hu(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),ME.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:r$}=vr("dnsaddr");function OE(){return OE=$(function*(n,e={}){const t=new n$;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===r$)??[];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}),OE.apply(this,arguments)}const s$={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 i$(n){return OE.apply(this,arguments)}},addressSorter:tE},connectionGater:{},transportManager:{faultTolerance:Pa.FATAL_ALL},metrics:{enabled:!1,computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0},relay:{enabled:!0,advertise:{bootDelay:9e5,enabled:!1,ttl:18e5},hop:{enabled:!1,active:!1,timeout:3e4},autoRelay:{enabled:!1,maxListeners:2}},identify:{protocolPrefix:"ipfs",host:{agentVersion:l2},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 o$(n){const e=Kl(s$,n);if(null==e.transports||e.transports.length<1)throw se(new Error(ln.ERR_TRANSPORTS_REQUIRED),be.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw se(new Error(ln.CONN_ENCRYPTION_REQUIRED),be.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw se(new Error(ln.ERR_PROTECTOR_REQUIRED),be.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===l2&&(pV||dV?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(mh||YT||hV||gV)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var F2;!function(n){let e;n.codec=()=>(null==e&&(e=kr((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),(!0===i.writeDefaults||null!=t.id&&t.id.byteLength>0)&&(r.uint32(10),r.bytes(t.id)),null!=t.pubKey&&(r.uint32(18),r.bytes(t.pubKey)),null!=t.privKey&&(r.uint32(26),r.bytes(t.privKey)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={id:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.id=t.bytes();break;case 2:i.pubKey=t.bytes();break;case 3:i.privKey=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>Or(t,n.codec()),n.decode=t=>Mr(t,n.codec())}(F2||(F2={}));const a$=function(){var n=$(function*(){const e=yield tT("Ed25519"),t=yield function U2(n){return LE.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 LE(){return LE=$(function*(n){return yield Al(nT(n.public),xF(n))}),LE.apply(this,arguments)}class u$ extends mi{get[jm](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}get lan(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}get(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}findProviders(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}findPeer(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}getClosestPeers(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}provide(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}put(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)}getMode(){return $(function*(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)})()}setMode(){return $(function*(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)})()}refreshRoutingTable(){return $(function*(){throw se(new Error(ln.DHT_DISABLED),be.DHT_DISABLED)})()}}class l$ extends mi{constructor(){super(...arguments),this.topicValidators=new Map}isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}get multicodecs(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}getPeers(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}getTopics(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}subscribe(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}unsubscribe(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}getSubscribers(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)}publish(){return $(function*(){throw se(new Error(ln.PUBSUB_DISABLED),be.ERR_PUBSUB_DISABLED)})()}}var f$=x(6890);const H2=kt("libp2p:dialer:dial-request");class d${constructor(e){const{addrs:t,dialAction:r,dialer:i}=e;this.addrs=t,this.dialer=i,this.dialAction=r}run(e={}){var t=this;return $(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw se(new Error("No dial tokens available"),be.ERR_NO_DIAL_TOKENS);const i=new f$;for(const l of r)i.push(l).catch(_=>{H2.error(_)});const s=t.addrs.map(()=>{const l=new AbortController;try{(0,Yr.setMaxListeners)?.(1/0,l.signal)}catch{}return l});if(null!=e.signal)try{(0,Yr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var l=$(function*(_,R){const N=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0]),se(new Error("dialAction already succeeded"),be.ERR_ALREADY_SUCCEEDED);const B=s[R];if(null==B)throw se(new Error("dialAction did not come with an AbortController"),be.ERR_INVALID_PARAMETERS);let U;try{const Y=B.signal;U=yield t.dialAction(_,{...e,signal:null!=e.signal?(0,ph.anySignal)([Y,e.signal]):Y}),s[R]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(N).catch(Y=>{H2.error(Y)}):t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0])}if(null==U)throw se(new Error("dialAction led to empty object"),be.ERR_TRANSPORT_DIAL_FAILED);return a=!0,U});return function(_,R){return l.apply(this,arguments)}}()))}finally{s.forEach(l=>{void 0!==l&&l.abort()}),r.forEach(l=>t.dialer.releaseToken(l))}})()}}const Cs=kt("libp2p:dialer"),K2="dialler";class g${constructor(e,t={}){this.started=!1,this.addressSorter=t.addressSorter??tE,this.maxAddrsToDial=t.maxAddrsToDial??25,this.timeout=t.dialTimeout??3e4,this.maxDialsPerPeer=t.maxDialsPerPeer??4,this.tokens=[...new Array(t.maxParallelDials??100)].map((r,i)=>i),this.components=e,this.pendingDials=fE({component:K2,metric:"pending-dials",metrics:t.metrics}),this.pendingDialTargets=fE({component:K2,metric:"pending-dial-targets",metrics:e.metrics});for(const[r,i]of Object.entries(t.resolvers??{}))PT.set(r,i)}isStarted(){return this.started}start(){var e=this;return $(function*(){e.started=!0})()}stop(){var e=this;return $(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){Cs.error(r)}e.pendingDials.clear();for(const t of e.pendingDialTargets.values())t.reject(new Xc("Dialer was destroyed"));e.pendingDialTargets.clear()})()}dial(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Hl(e);if(r.components.peerId.equals(i))throw se(new Error("Tried to dial self"),be.ERR_DIALED_SELF);if(Cs("check multiaddrs %p",i),null!=s&&s.length>0&&(Cs("storing multiaddrs %p",i,s),yield r.components.peerStore.addressBook.add(i,s)),yield r.components.connectionGater.denyDialPeer(i))throw se(new Error("The dial request is blocked by gater.allowDialPeer"),be.ERR_PEER_DIAL_INTERCEPTED);Cs("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"),be.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const l=yield a.promise;return Cs("dial succeeded to %s",o.id),l}catch(l){throw Cs("dial failed to %s",o.id,l),a.controller.signal.aborted&&(l.code=be.ERR_TIMEOUT),Cs.error(l),l}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return $(function*(){const i=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,s=new Promise((o,a)=>{r.pendingDialTargets.set(i,{resolve:o,reject:a})});try{return yield Promise.race([r._createDialTarget(e,t),s])}finally{r.pendingDialTargets.delete(i)}})()}_createDialTarget(e,t){var r=this;return $(function*(){const i=r._resolve.bind(r),s=yield Kn(yield r.components.peerStore.addressBook.get(e),o=>Vl(o,function(){var a=$(function*(l){return!(yield r.components.connectionGater.denyDialMultiaddr(e,l.multiaddr))});return function(l){return a.apply(this,arguments)}}()),o=>qv(o,r.addressSorter),function(){var o=Vt(function*(l){var N,_=!1,R=!1;try{for(var U,B=ut(l);_=!(U=yield We(B.next())).done;_=!1){const Y=U.value;yield*gr(ut(yield We(i(Y.multiaddr,t))),We)}}catch(Y){R=!0,N=Y}finally{try{_&&null!=B.return&&(yield We(B.return()))}finally{if(R)throw N}}});return function a(l){return o.apply(this,arguments)}}(),o=>Vl(o,a=>Boolean(r.components.transportManager.transportForMultiaddr(a))),o=>Rx(o,a=>e.toString()===a.getPeerId()?a:a.encapsulate(`/p2p/${e.toString()}`)),function(){var o=$(function*(a){return yield jh(a)});return function(a){return o.apply(this,arguments)}}());if(s.length>r.maxAddrsToDial)throw yield r.components.peerStore.delete(e),se(new Error("dial with more addresses than allowed"),be.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:s}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var R=$(function*(N,B={}){if(!0===B.signal?.aborted)throw se(new Error("already aborted"),be.ERR_ALREADY_ABORTED);return yield r.components.transportManager.dial(N,B).catch(U=>{throw Cs.error("dial to %s failed",N,U),U})});return function(B){return R.apply(this,arguments)}}(),s=new d$({addrs:e.addrs,dialAction:i,dialer:this}),o=new Ni.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const l=(0,ph.anySignal)(a);try{(0,Yr.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 Cs("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(Cs("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return $(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var l=$(function*(_){return yield r._resolve(_,t)});return function(_){return l.apply(this,arguments)}}()))).flat().reduce((l,_)=>(null==l.find(R=>R.equals(_))&&l.push(_),l),[])})()}_resolveRecord(e,t){return $(function*(){try{return e=Cn(e.toString()),yield e.resolve(t)}catch(r){return Cs.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}const Eo=kt("libp2p");class y$ extends mi{constructor(e){super(),this.started=!1,this.peerId=e.peerId;const t=this.components=new ZK({peerId:e.peerId,datastore:e.datastore??new Z9,connectionGater:{denyDialPeer:(o=$(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=$(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=$(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}});var o;t.peerStore=new YK(t,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore}),this.services=[t],e.metrics.enabled&&(this.metrics=this.components.metrics=new KH(e.metrics)),this.peerStore=this.components.peerStore,this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new zt("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&(this.components.connectionProtector=e.connectionProtector(t)),this.components.upgrader=new oK(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o(this.components))),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o(this.components))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.components.dialer=new g$(this.components,e.connectionManager),this.connectionManager=this.components.connectionManager=new fH(this.components,e.connectionManager),this.registrar=this.components.registrar=new rK(this.components),this.components.transportManager=new YH(this.components,e.transportManager),this.components.addressManager=new nH(this.components,e.addresses),this.configureComponent(new xK(this.components)),this.configureComponent(new hH(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const r=Qx.generateOptions();this.keychain=this.configureComponent(new Qx(this.components,{...r,...e.keychain})),this.services.push(new DK(this.components,e.nat)),e.transports.forEach(o=>{this.components.transportManager.add(this.configureComponent(o(this.components)))}),this.identifyService=new EE(this.components,{...e.identify}),this.configureComponent(this.identifyService),this.dht=null!=e.dht?this.components.dht=e.dht(this.components):new u$,this.pubsub=null!=e.pubsub?this.components.pubsub=e.pubsub(this.components):new l$;const i=(e.peerRouters??[]).map(o=>this.configureComponent(o(this.components)));null!=e.dht&&(i.push(this.configureComponent(new AK(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.peerRouting=this.configureComponent(new X9(this.components,{...e.peerRouting,routers:i}));const s=(e.contentRouters??[]).map(o=>this.configureComponent(o(this.components)));null!=e.dht&&s.push(this.configureComponent(new QK(this.dht))),this.contentRouting=this.components.contentRouting=this.configureComponent(new J9(this.components,{routers:s})),e.relay.enabled&&(this.components.transportManager.add(this.configureComponent(new _H(this.components,e.relay))),this.configureComponent(new xH(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new mK(this.components,{...e.fetch})),this.pingService=this.configureComponent(new wK(this.components,{...e.ping}));for(const o of e.peerDiscovery??[])this.configureComponent(o(this.components)).addEventListener("peer",l=>{this.onDiscoveryPeer(l)})}configureComponent(e){return ho(e)&&this.services.push(e),e}start(){var e=this;return $(function*(){if(!e.started){e.started=!0,Eo("libp2p is starting");try{yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.start())),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has started")}catch(t){throw Eo.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return $(function*(){!e.started||(Eo("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.stop())),yield Promise.all(e.services.map(function(){var t=$(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has stopped"))})()}isStarted(){return this.started}getConnections(e){return this.components.connectionManager.getConnections(e)}getPeers(){const e=new jl;for(const t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Hl(e);return yield r.components.peerStore.addressBook.add(i,s),yield r.components.connectionManager.openConnection(i,t)})()}dialProtocol(e,t,r={}){var i=this;return $(function*(){if(null==t)throw se(new Error("no protocols were provided to open a stream"),be.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"),be.ERR_INVALID_PROTOCOLS_FOR_STREAM);return yield(yield i.dial(e,r)).newStream(t,r)})()}getMultiaddrs(){return this.components.addressManager.getAddresses()}hangUp(e){var t=this;return $(function*(){const{id:r}=Hl(e);yield t.components.connectionManager.closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return $(function*(){if(Eo("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;const i=yield r.peerStore.get(e);if(null!=i.pubKey)return i.pubKey;if(null==r.dht)throw se(new Error("Public key was not in the peer store and the DHT is not enabled"),be.ERR_NO_ROUTERS_AVAILABLE);const s=yr([At("/pk/"),e.multihash.digest]);var l,o=!1,a=!1;try{for(var R,_=ut(r.dht.get(s,t));o=!(R=yield _.next()).done;o=!1){const N=R.value;if("VALUE"===N.name){const B=Il(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()}`),be.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return $(function*(){const{id:s,multiaddrs:o}=Hl(e);return null!=o&&(yield i.components.peerStore.addressBook.add(s,o)),yield i.fetchService.fetch(s,t,r)})()}ping(e,t={}){var r=this;return $(function*(){const{id:i,multiaddrs:s}=Hl(e);return s.length>0&&(yield r.components.peerStore.addressBook.add(i,s)),yield r.pingService.ping(i,t)})()}handle(e,t,r){var i=this;return $(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=$(function*(o){yield i.components.registrar.handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return $(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=$(function*(i){yield t.components.registrar.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.peerStore.addressBook.add(t.id,t.multiaddrs).catch(r=>Eo.error(r)),t.protocols.length>0&&this.components.peerStore.protoBook.set(t.id,t.protocols).catch(r=>Eo.error(r)),this.dispatchEvent(new zt("peer:discovery",{detail:t}))):Eo.error(new Error(be.ERR_DISCOVERED_SELF))}}function m$(n){return VE.apply(this,arguments)}function VE(){return VE=$(function*(n){return null==n.peerId&&(n.peerId=yield a$()),new y$(o$(n))}),VE.apply(this,arguments)}function v$(n){return HE.apply(this,arguments)}function HE(){return HE=$(function*(n){return yield m$(n)}),HE.apply(this,arguments)}function $E(){return $E=$(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(GE()),Object.assign(e,{peerDiscovery:t}));const r=yield zE(U9(n),e,n?.userAgent);return new s7(n??{},r)}),$E.apply(this,arguments)}function GE(){return function RU(n){return e=>new AU(e,n)}({list:$9()})}function zE(n,e,t){return WE.apply(this,arguments)}function WE(){return WE=$(function*(n,e,t){return v$(Object.assign({transports:[CV({filter:nx})],streamMuxers:[QU()],connectionEncryption:[GF()],identify:{host:{agentVersion:t??i7}}},n?{pubsub:n}:{},e??{}))}),WE.apply(this,arguments)}function w$(n,e,t){"function"==typeof t&&(t={filter:t});const r=function b$(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=(...U)=>{const Y=t.multiArgs?U:U[0];t.filter&&!t.filter(Y)||(l.push(Y),t.count===l.length&&(r(),s(l)))},B=U=>{r(),o(U)};r=()=>{for(const U of a)R(U,N);for(const U of t.rejectionEvents)R(U,B)};for(const U of a)_(U,N);for(const U of t.rejectionEvents)_(U,B);t.resolveImmediately&&s(l)});if(i.cancel=r,"number"==typeof t.timeout){const s=v2(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 j2=mr("waku:wait-for-remote-peer");function qE(){return qE=$(function*(n,e,t){if(e=e??D$(n),!n.isStarted())return Promise.reject("Waku node is not started");const r=[];if(e.includes(xr.Relay)){if(!n.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(S$(n.relay))}if(e.includes(xr.Store)){if(!n.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(YE(n.store,[kh]))}if(e.includes(xr.LightPush)){if(!n.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(YE(n.lightPush,[Ll]))}if(e.includes(xr.Filter)){if(!n.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(YE(n.filter,[Sa]))}t?yield C$(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),qE.apply(this,arguments)}function YE(n,e){return QE.apply(this,arguments)}function QE(){return QE=$(function*(n,e){const t=yield n.peers();t.length?j2(`${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)){j2("Resolving for",o,s.detail.protocols),n.peerStore.removeEventListener("change:protocols",i),r();break}};n.peerStore.addEventListener("change:protocols",i)})}),QE.apply(this,arguments)}function S$(n){return ZE.apply(this,arguments)}function ZE(){return ZE=$(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield w$(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),ZE.apply(this,arguments)}const I$=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function C$(n,e,t){return XE.apply(this,arguments)}function XE(){return XE=$(function*(n,e,t){yield Promise.race([n,I$(e,t)])}),XE.apply(this,arguments)}function D$(n){const e=[];return n.relay&&e.push(xr.Relay),n.filter&&e.push(xr.Filter),n.store&&e.push(xr.Store),n.lightPush&&e.push(xr.LightPush),e}let G2=(()=>{class n{constructor(){this.wakuSubject=new Qr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new X8(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function E$(n){return $E.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function _$(n,e,t){return qE.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=Hn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function T$(n,e){if(1&n&&(Xs(0,"li")(1,"span"),wc(2),Js()()),2&n){const t=e.$implicit;Hu(2),fy("",t.timestamp," ",t.text,"")}}const JE=new(tv().Type)("ChatMessage").add(new(tv().Field)("timestamp",1,"uint32")).add(new(tv().Field)("text",2,"string"));let x$=(()=>{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}=JE.decode(r.payload),o=new Date;o.setTime(Number(s)),this.messages.push({text:i,timestamp:o})},this.decoder=new NV(this.contentTopic),this.encoder=new lx(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=JE.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=JE.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)(Ut(G2))},n.\u0275cmp=lf({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(Xs(0,"button",0),ay("click",function(){return r.sendMessage()}),wc(1," Send Message\n"),Js(),Xs(2,"h2"),wc(3,"Messages"),Js(),Xs(4,"ul",1),function u1(n,e,t,r,i,s,o,a){const l=Me(),_=nn(),R=n+22,N=_.firstCreatePass?function FM(n,e,t,r,i,s,o,a,l){const _=e.consts,R=uc(e,n,4,o||null,Io(_,a));Wg(e,t,R,Io(_,l)),Ef(e,R);const N=R.tViews=zg(2,R,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,_);return null!==e.queries&&(e.queries.template(e,R),N.queries=e.queries.embeddedTView(R)),R}(R,_,l,e,t,r,i,s,o):_.data[R];Ts(N,!1);const B=l[11].createComment("");Kf(_,l,B,N),$r(B,l),Qf(l,l[R]=G_(B,l,B,N)),gf(N)&&jg(_,l,N),null!=o&&Gg(l,N,a)}(5,T$,3,2,"li",2),Js()),2&t&&(nd("disabled","Connected"!==r.wakuStatus),Hu(5),nd("ngForOf",r.messages))},dependencies:[iC]}),n})(),A$=(()=>{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)(Ut(G2))},n.\u0275cmp=lf({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(Xs(0,"h1"),wc(1),Js(),Xs(2,"p"),wc(3),Js(),ry(4,"app-messages")),2&t&&(Hu(1),ly(r.title),Hu(2),id("Waku node's status: ",r.wakuStatus,""))},dependencies:[x$],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})(),R$=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=yu({type:n,bootstrap:[A$]}),n.\u0275inj=Ba({imports:[K8]}),n})();x(4491),function h3(){LI=!1}(),H8().bootstrapModule(R$).catch(n=>console.error(n))},3037:q=>{"use strict";q.exports=function V(x,y){for(var u=new Array(arguments.length-1),g=0,w=2,m=!0;w{"use strict";var x=V;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=[],I=0,E=0;c>2],v=(3&p)<<4,E=1;break;case 1:b[I++]=y[v|p>>4],v=(15&p)<<2,E=2;break;case 2:b[I++]=y[v|p>>6],b[I++]=y[63&p],E=0}I>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,b)),I=0)}return E&&(b[I++]=y[v],b[I++]=61,1===E&&(b[I++]=61)),d?(I&&d.push(String.fromCharCode.apply(String,b.slice(0,I))),d.join("")):String.fromCharCode.apply(String,b.slice(0,I))};var w="invalid encoding";x.decode=function(h,c,f){for(var I,d=f,b=0,E=0;E1)break;if(void 0===(v=u[v]))throw Error(w);switch(b){case 0:I=v,b=1;break;case 1:c[f++]=I<<2|(48&v)>>4,I=v,b=2;break;case 2:c[f++]=(15&I)<<4|(60&v)>>2,I=v,b=3;break;case 3:c[f++]=(3&I)<<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)}},3563:q=>{"use strict";function V(x,y){"string"==typeof x&&(y=x,x=void 0);var u=[];function g(m){if("string"!=typeof m){var h=w();if(V.verbose&&console.log("codegen: "+h),h="return "+h,m){for(var c=Object.keys(m),f=new Array(c.length+1),d=new Array(c.length),b=0;b{"use strict";function V(){this._listeners={}}q.exports=V,V.prototype.on=function(y,u,g){return(this._listeners[y]||(this._listeners[y]=[])).push({fn:u,ctx:g||this}),this},V.prototype.off=function(y,u){if(void 0===y)this._listeners={};else if(void 0===u)this._listeners[y]=[];else for(var g=this._listeners[y],w=0;w{"use strict";q.exports=w;var y=x(3037),g=x(3292)("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 I=d.response;if(!I){I=[];for(var E=0;E{"use strict";function V(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 I(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:I,w.readFloatBE=c?I:b}():function(){function m(c,f,d,b){var I=f<0?1:0;if(I&&(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((I<<31|2139095040)>>>0,d,b);else if(f<11754943508222875e-54)c((I<<31|Math.round(f/1401298464324817e-60))>>>0,d,b);else{var E=Math.floor(Math.log(f)/Math.LN2);c((I<<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),I=2*(b>>31)+1,E=b>>>23&255,v=8388607&b;return 255===E?v?NaN:I*(1/0):0===E?1401298464324817e-60*I*v:I*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 I(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:I,w.readDoubleBE=c?I:b}():function(){function m(c,f,d,b,I,E){var v=b<0?1:0;if(v&&(b=-b),0===b)c(0,I,E+f),c(1/b>0?0:2147483648,I,E+d);else if(isNaN(b))c(0,I,E+f),c(2146959360,I,E+d);else if(b>17976931348623157e292)c(0,I,E+f),c((v<<31|2146435072)>>>0,I,E+d);else{var p;if(b<22250738585072014e-324)c((p=b/5e-324)>>>0,I,E+f),c((v<<31|p/4294967296)>>>0,I,E+d);else{var D=Math.floor(Math.log(b)/Math.LN2);1024===D&&(D=1023),c(4503599627370496*(p=b*Math.pow(2,-D))>>>0,I,E+f),c((v<<31|D+1023<<20|1048576*p&1048575)>>>0,I,E+d)}}}function h(c,f,d,b,I){var E=c(b,I+f),v=c(b,I+d),p=2*(v>>31)+1,D=v>>>20&2047,A=4294967296*(1048575&v)+E;return 2047===D?A?NaN:p*(1/0):0===D?5e-324*p*A:p*Math.pow(2,D-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=V(V)},3292: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},4845:(q,V)=>{"use strict";var x=V,y=x.isAbsolute=function(w){return/^(?:\/|\w+:)/.test(w)},u=x.normalize=function(w){var m=(w=w.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),h=y(w),c="";h&&(c=m.shift()+"/");for(var f=0;f0&&".."!==m[f-1]?m.splice(--f,2):h?m.splice(f,1):++f:"."===m[f]?m.splice(f,1):++f;return c+m.join("/")};x.resolve=function(w,m,h){return h||(m=u(m)),y(m)?m:(h||(w=u(w)),(w=w.replace(/(?:\/|^)[^/]+$/,"")).length?u(w+"/"+m):m)}},8880:q=>{"use strict";q.exports=function V(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}}},7481:(q,V)=>{"use strict";var x=V;x.length=function(u){for(var g=0,w=0,m=0;m191&&d<224?c[f++]=(31&d)<<6|63&u[g++]:d>239&&d<365?(d=((7&d)<<18|(63&u[g++])<<12|(63&u[g++])<<6|63&u[g++])-65536,c[f++]=55296+(d>>10),c[f++]=56320+(1023&d)):c[f++]=(15&d)<<12|(63&u[g++])<<6|63&u[g++],f>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,c)),f=0);return h?(f&&h.push(String.fromCharCode.apply(String,c.slice(0,f))),h.join("")):String.fromCharCode.apply(String,c.slice(0,f))},x.write=function(u,g,w){for(var h,c,m=w,f=0;f>6|192,g[w++]=63&h|128):55296==(64512&h)&&56320==(64512&(c=u.charCodeAt(f+1)))?(++f,g[w++]=(h=65536+((1023&h)<<10)+(1023&c))>>18|240,g[w++]=h>>12&63|128,g[w++]=h>>6&63|128,g[w++]=63&h|128):(g[w++]=h>>12|224,g[w++]=h>>6&63|128,g[w++]=63&h|128);return w-m}},7065:(q,V,x)=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var y=x(1710);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 I(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 S(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}V.readInt16BE=function u(Z,W){return void 0===W&&(W=0),(Z[W+0]<<8|Z[W+1])<<16>>16},V.readUint16BE=function g(Z,W){return void 0===W&&(W=0),(Z[W+0]<<8|Z[W+1])>>>0},V.readInt16LE=function w(Z,W){return void 0===W&&(W=0),(Z[W+1]<<8|Z[W])<<16>>16},V.readUint16LE=function m(Z,W){return void 0===W&&(W=0),(Z[W+1]<<8|Z[W])>>>0},V.writeUint16BE=h,V.writeInt16BE=h,V.writeUint16LE=c,V.writeInt16LE=c,V.readInt32BE=f,V.readUint32BE=d,V.readInt32LE=b,V.readUint32LE=I,V.writeUint32BE=E,V.writeInt32BE=E,V.writeUint32LE=v,V.writeInt32LE=v,V.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)},V.readUint64BE=function D(Z,W){return void 0===W&&(W=0),4294967296*d(Z,W)+d(Z,W+4)},V.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)},V.readUint64LE=function P(Z,W){void 0===W&&(W=0);var te=I(Z,W);return 4294967296*I(Z,W+4)+te},V.writeUint64BE=S,V.writeInt64BE=S,V.writeUint64LE=T,V.writeInt64LE=T,V.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},V.readUintLE=function k(Z,W,te){if(void 0===te&&(te=0),Z%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(Z/8>W.length-te)throw new Error("readUintLE: array is too short for the given bitLength");for(var oe=0,de=1,he=te;he=oe;he--)te[he]=W/de&255,de*=256;return te},V.writeUintLE=function j(Z,W,te,oe){if(void 0===te&&(te=new Uint8Array(Z/8)),void 0===oe&&(oe=0),Z%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!y.isSafeInteger(W))throw new Error("writeUintLE value must be an integer");for(var de=1,he=oe;he{"use strict";var u=x(5412),g=x(6329),w=x(5136),m=x(7065),h=x(6685);V.Cv=32,V.WH=12,V.pg=16;var c=new Uint8Array(16),f=function(){function d(b){if(this.nonceLength=V.WH,this.tagLength=V.pg,b.length!==V.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return d.prototype.seal=function(b,I,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 D=new Uint8Array(32);u.stream(this._key,p,D,4);var P,A=I.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,I,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),D,P.subarray(0,P.length-this.tagLength),E),w.wipe(p),P},d.prototype.open=function(b,I,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(I.length0&&p.update(c.subarray(v.length%16))),p.update(E),E.length%16>0&&p.update(c.subarray(E.length%16));var D=new Uint8Array(8);v&&m.writeUint64LE(v.length,D),p.update(D),m.writeUint64LE(E.length,D),p.update(D);for(var A=p.digest(),P=0;P{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var y=x(7065),u=x(5136);function w(f,d,b){for(var I=1634760805,E=857760878,v=2036477234,p=1797285236,D=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],S=b[15]<<24|b[14]<<16|b[13]<<8|b[12],T=b[19]<<24|b[18]<<16|b[17]<<8|b[16],M=b[23]<<24|b[22]<<16|b[21]<<8|b[20],k=b[27]<<24|b[26]<<16|b[25]<<8|b[24],F=b[31]<<24|b[30]<<16|b[29]<<8|b[28],j=d[3]<<24|d[2]<<16|d[1]<<8|d[0],C=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],H=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=I,K=E,ne=v,G=p,ee=D,Z=A,W=P,te=S,oe=T,de=M,he=k,Pe=F,Se=j,Be=C,ve=O,He=H,ke=0;ke<20;ke+=2)ee=(ee^=oe=oe+(Se=(Se^=L=L+ee|0)>>>16|Se<<16)|0)>>>20|ee<<12,Z=(Z^=de=de+(Be=(Be^=K=K+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^=K=K+Z|0)>>>24|Be<<8)|0)>>>25|Z<<7,ee=(ee^=oe=oe+(Se=(Se^=L=L+ee|0)>>>24|Se<<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+(Se=(Se^=K=K+W|0)>>>16|Se<<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+(Se=(Se^=K=K+W|0)>>>24|Se<<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+I|0,f,0),y.writeUint32LE(K+E|0,f,4),y.writeUint32LE(ne+v|0,f,8),y.writeUint32LE(G+p|0,f,12),y.writeUint32LE(ee+D|0,f,16),y.writeUint32LE(Z+A|0,f,20),y.writeUint32LE(W+P|0,f,24),y.writeUint32LE(te+S|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(Se+j|0,f,48),y.writeUint32LE(Be+C|0,f,52),y.writeUint32LE(ve+O|0,f,56),y.writeUint32LE(He+H|0,f,60)}function m(f,d,b,I,E){if(void 0===E&&(E=0),32!==f.length)throw new Error("ChaCha: key size must be 32 bytes");if(I.length>>=8,d++;if(I>0)throw new Error("ChaCha: counter overflow")}V.streamXOR=m,V.stream=function h(f,d,b,I){return void 0===I&&(I=0),u.wipe(b),m(f,d,b,b,I)}},6685:(q,V)=>{"use strict";function u(w,m){if(w.length!==m.length)return 0;for(var h=0,c=0;c>>8}Object.defineProperty(V,"__esModule",{value:!0}),V.select=function x(w,m,h){return~(w-1)&m|w-1&h},V.lessOrEqual=function y(w,m){return(0|w)-(0|m)-1>>>31&1},V.compare=u,V.equal=function g(w,m){return 0!==w.length&&0!==m.length&&0!==u(w,m)}},2836:(q,V)=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.isSerializableHash=function x(y){return typeof y.saveState<"u"&&typeof y.restoreState<"u"&&typeof y.cleanSavedState<"u"}},3281:(q,V,x)=>{"use strict";var u=x(1639),g=x(5136),w=function(){function m(h,c,f,d){void 0===f&&(f=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=h,this._info=d;var b=u.hmac(this._hash,f,c);this._hmac=new u.HMAC(h,b),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return m.prototype._fillBuffer=function(){this._counter[0]++;var h=this._counter[0];if(0===h)throw new Error("hkdf: cannot expand more");this._hmac.reset(),h>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},m.prototype.expand=function(h){for(var c=new Uint8Array(h),f=0;f{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var y=x(2836),u=x(6685),g=x(5136),w=function(){function h(c,f){this._finished=!1,this._inner=new c,this._outer=new c,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);f.length>this.blockSize?this._inner.update(f).finish(d).clean():d.set(f);for(var b=0;b{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.mul=Math.imul||function x(h,c){var d=65535&h,I=65535&c;return d*I+((h>>>16&65535)*I+d*(c>>>16&65535)<<16>>>0)|0},V.add=function y(h,c){return h+c|0},V.sub=function u(h,c){return h-c|0},V.rotl=function g(h,c){return h<>>32-c},V.rotr=function w(h,c){return h<<32-c|h>>>c},V.isInteger=Number.isInteger||function m(h){return"number"==typeof h&&isFinite(h)&&Math.floor(h)===h},V.MAX_SAFE_INTEGER=9007199254740991,V.isSafeInteger=function(h){return V.isInteger(h)&&h>=-V.MAX_SAFE_INTEGER&&h<=V.MAX_SAFE_INTEGER}},6329:(q,V,x)=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});var y=x(6685),u=x(5136);V.DIGEST_LENGTH=16;var g=function(){function h(c){this.digestLength=V.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 I=c[6]|c[7]<<8;this._r[3]=8191&(b>>>7|I<<9);var E=c[8]|c[9]<<8;this._r[4]=255&(I>>>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 D=c[14]|c[15]<<8;this._r[8]=8191&(p>>>8|D<<8),this._r[9]=D>>>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,I=this._h[0],E=this._h[1],v=this._h[2],p=this._h[3],D=this._h[4],A=this._h[5],P=this._h[6],S=this._h[7],T=this._h[8],M=this._h[9],k=this._r[0],F=this._r[1],j=this._r[2],C=this._r[3],O=this._r[4],H=this._r[5],L=this._r[6],K=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,Se=0,Be=Se;Be+=(I+=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*K),Se=(Be+=(D+=8191&(te>>>4|oe<<12))*(5*L))>>>13,Be&=8191,Be+=(A+=oe>>>1&8191)*(5*H),Be+=(P+=8191&(oe>>>14|de<<2))*(5*O),Be+=(S+=8191&(de>>>11|he<<5))*(5*C),Be+=(T+=8191&(he>>>8|Pe<<8))*(5*j);var ve=Se+=(Be+=(M+=Pe>>>5|b)*(5*F))>>>13;ve+=I*F,ve+=E*k,ve+=v*(5*G),ve+=p*(5*ne),Se=(ve+=D*(5*K))>>>13,ve&=8191,ve+=A*(5*L),ve+=P*(5*H),ve+=S*(5*O),ve+=T*(5*C),Se+=(ve+=M*(5*j))>>>13,ve&=8191;var He=Se;He+=I*j,He+=E*F,He+=v*k,He+=p*(5*G),Se=(He+=D*(5*ne))>>>13,He&=8191,He+=A*(5*K),He+=P*(5*L),He+=S*(5*H),He+=T*(5*O);var ke=Se+=(He+=M*(5*C))>>>13;ke+=I*C,ke+=E*j,ke+=v*F,ke+=p*k,Se=(ke+=D*(5*G))>>>13,ke&=8191,ke+=A*(5*ne),ke+=P*(5*K),ke+=S*(5*L),ke+=T*(5*H);var nt=Se+=(ke+=M*(5*O))>>>13;nt+=I*O,nt+=E*C,nt+=v*j,nt+=p*F,Se=(nt+=D*k)>>>13,nt&=8191,nt+=A*(5*G),nt+=P*(5*ne),nt+=S*(5*K),nt+=T*(5*L);var Rt=Se+=(nt+=M*(5*H))>>>13;Rt+=I*H,Rt+=E*O,Rt+=v*C,Rt+=p*j,Se=(Rt+=D*F)>>>13,Rt&=8191,Rt+=A*k,Rt+=P*(5*G),Rt+=S*(5*ne),Rt+=T*(5*K);var _t=Se+=(Rt+=M*(5*L))>>>13;_t+=I*L,_t+=E*H,_t+=v*O,_t+=p*C,Se=(_t+=D*j)>>>13,_t&=8191,_t+=A*F,_t+=P*k,_t+=S*(5*G),_t+=T*(5*ne);var Bt=Se+=(_t+=M*(5*K))>>>13;Bt+=I*K,Bt+=E*L,Bt+=v*H,Bt+=p*O,Se=(Bt+=D*C)>>>13,Bt&=8191,Bt+=A*j,Bt+=P*F,Bt+=S*k,Bt+=T*(5*G);var qt=Se+=(Bt+=M*(5*ne))>>>13;qt+=I*ne,qt+=E*K,qt+=v*L,qt+=p*H,Se=(qt+=D*O)>>>13,qt&=8191,qt+=A*C,qt+=P*j,qt+=S*F,qt+=T*k;var en=Se+=(qt+=M*(5*G))>>>13;en+=I*G,en+=E*ne,en+=v*K,en+=p*L,Se=(en+=D*H)>>>13,en&=8191,en+=A*O,en+=P*C,en+=S*j,en+=T*F,I=Be=8191&(Se=(Se=((Se+=(en+=M*k)>>>13)<<2)+Se|0)+(Be&=8191)|0),E=ve+=Se>>>=13,v=He&=8191,p=ke&=8191,D=nt&=8191,A=Rt&=8191,P=_t&=8191,S=Bt&=8191,T=qt&=8191,M=en&=8191,f+=16,d-=16}this._h[0]=I,this._h[1]=E,this._h[2]=v,this._h[3]=p,this._h[4]=D,this._h[5]=A,this._h[6]=P,this._h[7]=S,this._h[8]=T,this._h[9]=M},h.prototype.finish=function(c,f){void 0===f&&(f=0);var b,I,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,I=(1^b)-1,v=0;v<10;v++)d[v]&=I;for(I=~I,v=0;v<10;v++)this._h[v]=this._h[v]&I|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 I=0;I=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(I=0;I{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.randomStringForEntropy=V.randomString=V.randomUint32=V.randomBytes=V.defaultRandomSource=void 0;const y=x(7604),u=x(7065),g=x(5136);function w(d,b=V.defaultRandomSource){return b.randomBytes(d)}V.defaultRandomSource=new y.SystemRandomSource,V.randomBytes=w,V.randomUint32=function m(d=V.defaultRandomSource){const b=w(4,d),I=(0,u.readUint32LE)(b);return(0,g.wipe)(b),I};const h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(d,b=h,I=V.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 D=w(Math.ceil(256*d/p),I);for(let A=0;A0;A++){const P=D[A];P{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.BrowserRandomSource=void 0,V.BrowserRandomSource=class y{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const g=typeof self<"u"?self.crypto||self.msCrypto:null;g&&void 0!==g.getRandomValues&&(this._crypto=g,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(g){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const w=new Uint8Array(g);for(let m=0;m{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.NodeRandomSource=void 0;const y=x(5136);V.NodeRandomSource=class u{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const w=x(985);w&&w.randomBytes&&(this._crypto=w,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(w){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let m=this._crypto.randomBytes(w);if(m.length!==w)throw new Error("NodeRandomSource: got fewer bytes than requested");const h=new Uint8Array(w);for(let c=0;c{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.SystemRandomSource=void 0;const y=x(6367),u=x(2121);V.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)}}},6632:(q,V,x)=>{"use strict";var u=x(7065),g=x(5136);V.k=32,V.cn=64;var w=function(){function f(){this.digestLength=V.k,this.blockSize=V.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 I=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[I++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(I=h(this._temp,this._state,d,I,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=d[I++],b--;return this},f.prototype.finish=function(d){if(!this._finished){var b=this._bytesHashed,I=this._bufferLength,E=b/536870912|0,v=b<<3,p=b%64<56?64:128;this._buffer[I]=128;for(var D=I+1;D0?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}();V.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,I,E){for(;E>=64;){for(var v=d[0],p=d[1],D=d[2],A=d[3],P=d[4],S=d[5],T=d[6],M=d[7],k=0;k<16;k++)f[k]=u.readUint32BE(b,I+4*k);for(k=16;k<64;k++){var j=f[k-2];f[k]=((C=(j>>>17|j<<15)^(j>>>19|j<<13)^j>>>10)+f[k-7]|0)+((O=((j=f[k-15])>>>7|j<<25)^(j>>>18|j<<14)^j>>>3)+f[k-16]|0)}for(k=0;k<64;k++){var C=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&S^~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&D^p&D)|0;M=T,T=S,S=P,P=A+C|0,A=D,D=p,p=v,v=C+O|0}d[0]+=v,d[1]+=p,d[2]+=D,d[3]+=A,d[4]+=P,d[5]+=S,d[6]+=T,d[7]+=M,I+=64,E-=64}return I}V.vp=function c(f){var d=new w;d.update(f);var b=d.digest();return d.clean(),b}},5136:(q,V)=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0}),V.wipe=function x(y){for(var u=0;u{"use strict";V.gi=V.Au=V._w=V.KS=V.kz=void 0;const u=x(12),g=x(5136);function w(k){const F=new Float64Array(16);if(k)for(let j=0;j=0;--te){const oe=j[te>>>3]>>>(7&te)&1;f(O,H,oe),f(L,K,oe),I(ne,O,L),E(O,O,L),I(L,H,K),E(H,H,K),p(K,ne),p(G,O),v(O,L,O),v(L,H,ne),I(ne,O,L),E(O,O,L),p(H,O),E(L,K,G),v(O,L,h),I(O,O,K),v(L,L,O),v(O,K,G),v(K,H,C),p(H,ne),f(O,H,oe),f(L,K,oe)}for(let te=0;te<16;te++)C[te+16]=O[te],C[te+32]=L[te],C[te+48]=H[te],C[te+64]=K[te];const ee=C.subarray(32),Z=C.subarray(16);(function D(k,F){const j=w();for(let C=0;C<16;C++)j[C]=F[C];for(let C=253;C>=0;C--)p(j,j),2!==C&&4!==C&&v(j,j,F);for(let C=0;C<16;C++)k[C]=j[C]})(ee,ee),v(Z,Z,ee);const W=new Uint8Array(32);return function d(k,F){const j=w(),C=w();for(let O=0;O<16;O++)C[O]=F[O];c(C),c(C),c(C);for(let O=0;O<2;O++){j[0]=C[0]-65517;for(let L=1;L<15;L++)j[L]=C[L]-65535-(j[L-1]>>16&1),j[L-1]&=65535;j[15]=C[15]-32767-(j[14]>>16&1);const H=j[15]>>16&1;j[14]&=65535,f(C,j,1-H)}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 S(k){if(k.length!==V.KS)throw new Error(`x25519: seed must be ${V.KS} bytes`);const F=new Uint8Array(k);return{publicKey:P(F),secretKey:F}}V._w=S,V.Au=function T(k){const F=(0,u.randomBytes)(32,k),j=S(F);return(0,g.wipe)(F),j},V.gi=function M(k,F,j=!1){if(k.length!==V.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==V.kz)throw new Error("X25519: incorrect public key length");const C=A(k,F);if(j){let O=0;for(let H=0;H{function V(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=V,q.exports.anySignal=V},4084:(q,V,x)=>{V.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,I=>{"%%"!==I&&(d++,"%c"===I&&(b=d))}),c.splice(b,0,f)},V.save=function g(c){try{c?V.storage.setItem("debug",c):V.storage.removeItem("debug")}catch{}},V.load=function w(){let c;try{c=V.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c},V.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+)/))},V.storage=function m(){try{return localStorage}catch{}}(),V.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`."))}})(),V.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"],V.log=console.debug||console.log||(()=>{}),q.exports=x(5851)(V);const{formatters:h}=q.exports;h.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}},5851:(q,V,x)=>{q.exports=function y(u){function w(E){let v,D,A,p=null;function P(...S){if(!P.enabled)return;const T=P,M=Number(new Date);T.diff=M-(v||M),T.prev=v,T.curr=M,v=M,S[0]=w.coerce(S[0]),"string"!=typeof S[0]&&S.unshift("%O");let F=0;S[0]=S[0].replace(/%([a-zA-Z%])/g,(C,O)=>{if("%%"===C)return"%";F++;const H=w.formatters[O];return"function"==typeof H&&(C=H.call(T,S[F]),S.splice(F,1),F--),C}),w.formatArgs.call(T,S),(T.log||w.log).apply(T,S)}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:(D!==w.namespaces&&(D=w.namespaces,A=w.enabled(E)),A),set:S=>{p=S}}),"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,]+/),D=p.length;for(v=0;v{w[E]=u[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p{"use strict";function V(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)}V.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]}},V.prototype.get=function(y){return this.peekAt(y)},V.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},V.prototype.peekFront=function(){return this.peek()},V.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(V.prototype,"length",{get:function(){return this.size()}}),V.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),u}},V.prototype.push=function(y){if(void 0===y)return this.size();var u=this._tail;return this._list[u]=y,this._tail=u+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&y<=u>>>2&&this._shrinkArray(),g}},V.prototype.removeOne=function(y){var u=y;if(u===(0|u)&&this._head!==this._tail){var g=this.size(),w=this._list.length;if(!(u>=g||u<-g)){u<0&&(u+=g);var h,m=this._list[u=this._head+u&this._capacityMask];if(y0;h--)this._list[u]=this._list[u=u-1+w&this._capacityMask];this._list[u]=void 0,this._head=this._head+1+w&this._capacityMask}else{for(h=g-1-y;h>0;h--)this._list[u]=this._list[u=u+1+w&this._capacityMask];this._list[u]=void 0,this._tail=this._tail-1+w&this._capacityMask}return m}}},V.prototype.remove=function(y,u){var w,g=y,m=u;if(g===(0|g)&&this._head!==this._tail){var h=this.size(),c=this._list.length;if(!(g>=h||g<-h||u<1)){if(g<0&&(g+=h),1===u||!u)return(w=new Array(1))[0]=this.removeOne(g),w;if(0===g&&g+u>=h)return w=this.toArray(),this.clear(),w;var f;for(g+u>h&&(u=h-g),w=new Array(u),f=0;f0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(0===y){for(this._head=this._head+u+c&this._capacityMask,f=u-1;f>0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(g0;f--)this.unshift(this._list[g=g-1+c&this._capacityMask]);for(g=this._head-1+c&this._capacityMask;m>0;)this._list[g=g-1+c&this._capacityMask]=void 0,m--;y<0&&(this._tail=g)}else{for(this._tail=g,g=g+u+c&this._capacityMask,f=h-(u+y);f>0;f--)this.push(this._list[g++]);for(g=this._tail;m>0;)this._list[g=g+1+c&this._capacityMask]=void 0,m--}return this._head<2&&this._tail>1e4&&this._tail<=c>>>2&&this._shrinkArray(),w}}},V.prototype.splice=function(y,u){var g=y;if(g===(0|g)){var w=this.size();if(g<0&&(g+=w),!(g>w)){if(arguments.length>2){var m,h,c,f=arguments.length,d=this._list.length,b=2;if(!w||g0&&(this._head=this._head+g+d&this._capacityMask)):(c=this.remove(g,u),this._head=this._head+g+d&this._capacityMask);f>b;)this.unshift(arguments[--f]);for(m=g;m>0;m--)this.unshift(h[m-1])}else{var I=(h=new Array(w-(g+u))).length;for(m=0;mthis._tail){for(m=this._head;m>>=1,this._capacityMask>>>=1},q.exports=V},3069:q=>{"use strict";function V(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 V(y,g)}catch{g.message=y.message,g.stack=y.stack;const m=function(){};return m.prototype=Object.create(Object.getPrototypeOf(y)),V(new m,g)}}},3715:(q,V,x)=>{"use strict";const u=x(7663);V.zN=u.EventIterator},7663:(q,V)=>{"use strict";Object.defineProperty(V,"__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)}}V.EventIterator=y,V.default=y},4818:q=>{"use strict";var V=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 I=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],I]:h._events[E].push(I):(h._events[E]=I,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)V.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,I=d.length,E=new Array(I);b{"use strict";var y,V="object"==typeof Reflect?Reflect:null,x=V&&"function"==typeof V.apply?V.apply:function(M,k,F){return Function.prototype.apply.call(M,k,F)};y=V&&"function"==typeof V.ownKeys?V.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 j(O){T.removeListener(M,C),F(O)}function C(){"function"==typeof T.removeListener&&T.removeListener("error",j),k([].slice.call(arguments))}S(T,M,C,{once:!0}),"error"!==M&&function P(T,M,k){"function"==typeof T.on&&S(T,"error",M,k)}(T,j,{once:!0})})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var m=10;function h(T){if("function"!=typeof T)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}function c(T){return void 0===T._maxListeners?w.defaultMaxListeners:T._maxListeners}function f(T,M,k,F){var j,C,O;if(h(k),void 0===(C=T._events)?(C=T._events=Object.create(null),T._eventsCount=0):(void 0!==C.newListener&&(T.emit("newListener",M,k.listener?k.listener:k),C=T._events),O=C[M]),void 0===O)O=C[M]=k,++T._eventsCount;else if("function"==typeof O?O=C[M]=F?[k,O]:[O,k]:F?O.unshift(k):O.push(k),(j=c(T))>0&&O.length>j&&!O.warned){O.warned=!0;var H=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");H.name="MaxListenersExceededWarning",H.emitter=T,H.type=M,H.count=O.length,function u(T){console&&console.warn&&console.warn(T)}(H)}return T}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(T,M,k){var F={fired:!1,wrapFn:void 0,target:T,type:M,listener:k},j=d.bind(F);return j.listener=k,F.wrapFn=j,j}function I(T,M,k){var F=T._events;if(void 0===F)return[];var j=F[M];return void 0===j?[]:"function"==typeof j?k?[j.listener||j]:[j]:k?function D(T){for(var M=new Array(T.length),k=0;k0&&(O=k[0]),O instanceof Error)throw O;var H=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw H.context=O,H}var L=C[M];if(void 0===L)return!1;if("function"==typeof L)x(L,this,k);else{var K=L.length,ne=v(L,K);for(F=0;F=0;O--)if(F[O]===k||F[O].listener===k){H=F[O].listener,C=O;break}if(C<0)return this;0===C?F.shift():function p(T,M){for(;M+1=0;j--)this.removeListener(M,k[j]);return this},w.prototype.listeners=function(M){return I(this,M,!0)},w.prototype.rawListeners=function(M){return I(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):[]}},7965: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]}}},4814:(q,V,x)=>{const y=x(7965);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()}}},4591:q=>{q.exports=function(V){if(!V)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>=V&&(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)}}}},5972:q=>{"use strict";const V="[a-fA-F\\d:]",x=f=>f&&f.includeBoundaries?`(?:(?<=\\s|^)(?=${V})|(?<=${V})(?=\\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},2459:function(q){!function(V){"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,S,p=0,D=-1,A=(E.match(h.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(D=E.indexOf(":",D+1))>=0;)p++;if("::"===E.substr(0,2)&&p--,"::"===E.substr(-2,2)&&p--,p>v)return null;for(S=v-p,P=":";S--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:v=function(){const T=E.split(":"),M=[];for(let k=0;k0;){if(P=p-D,P<0&&(P=0),E[A]>>P!=v[A]>>P)return!1;D-=p,A+=1}return!0}function d(E){if(g.test(E))return parseInt(E,16);if("0"===E[0]&&!isNaN(parseInt(E[1],10))){if(u.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function b(E,v){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in D))return null;if(S=D[P],p&&0!==S)return null;8!==S&&(p=!0),v+=S}return 32-v},E.prototype.range=function(){return I.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return I.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),I.IPv4.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),D=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(p[P],10)|255^parseInt(D[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},I.IPv4.isIPv4=function(E){return null!==this.parser(E)},I.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},I.IPv4.isValidFourPartDecimal=function(E){return!(!I.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},I.IPv4.networkAddressFromCIDR=function(E){let v,p,D,A,P;try{for(v=this.parseCIDR(E),D=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<4;)A.push(parseInt(D[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},I.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)},I.IPv4.parseCIDR=function(E){let v;if(v=E.match(/^(.+)\/(\d+)$/)){const p=parseInt(v[2]);if(p>=0&&p<=32){const D=[this.parse(v[1]),p];return Object.defineProperty(D,"toString",{value:function(){return this.join("/")}}),D}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},I.IPv4.parser=function(E){let v,p,D;if(v=E.match(y.fourOctet))return function(){const A=v.slice(1,6),P=[];for(let S=0;S4294967295||D<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(D>>P&255);return A}().reverse()}return(v=E.match(y.twoOctet))?function(){const A=v.slice(1,4),P=[];if(D=d(A[1]),D>16777215||D<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(D>>16&255),P.push(D>>8&255),P.push(255&D),P}():(v=E.match(y.threeOctet))?function(){const A=v.slice(1,5),P=[];if(D=d(A[2]),D>65535||D<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(D>>8&255),P.push(255&D),P}():null},I.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 D=Math.floor(E/8);for(;p=0;S-=1){if(A=this.parts[S],!(A in D))return null;if(P=D[A],p&&0!==P)return null;16!==P&&(p=!0),v+=P}return 128-v},E.prototype.range=function(){return I.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let v;const p=[],D=this.parts;for(let A=0;A>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const D=[];for(let A=0;A>8,255&p,D>>8,255&D])},E.prototype.toNormalizedString=function(){const v=function(){const D=[];for(let A=0;AA&&(D=P.index,A=P[0].length);return A<0?p:`${p.substring(0,D)}::${p.substring(D+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),I.IPv6.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),D=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(p[P],10)|255^parseInt(D[P],10)),P++;return new this(A)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},I.IPv6.isIPv6=function(E){return null!==this.parser(E)},I.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const v=this.parser(E);return new this(v.parts,v.zoneId),!0}catch{return!1}},I.IPv6.networkAddressFromCIDR=function(E){let v,p,D,A,P;try{for(v=this.parseCIDR(E),D=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<16;)A.push(parseInt(D[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch(S){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${S})`)}},I.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)},I.IPv6.parseCIDR=function(E){let v,p,D;if((p=E.match(/^(.+)\/(\d+)$/))&&(v=parseInt(p[2]),v>=0&&v<=128))return D=[this.parse(p[1]),v],Object.defineProperty(D,"toString",{value:function(){return this.join("/")}}),D;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},I.IPv6.parser=function(E){let v,p,D,A,P,S;if(D=E.match(h.deprecatedTransitional))return this.parser(`::ffff:${D[1]}`);if(h.native.test(E))return c(E,8);if((D=E.match(h.transitional))&&(S=D[6]||"",v=c(D[1].slice(0,-1)+S,6),v.parts)){for(P=[parseInt(D[2]),parseInt(D[3]),parseInt(D[4]),parseInt(D[5])],p=0;p128)throw new Error("ipaddr: invalid IPv6 prefix length");const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let p=0;const D=Math.floor(E/8);for(;p{q.exports=function V(){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}},4129:(q,V,x)=>{"use strict";const y=x(5972),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},8582:q=>{"use strict";q.exports=V=>{if("[object Object]"!==Object.prototype.toString.call(V))return!1;const x=Object.getPrototypeOf(V);return null===x||x===Object.prototype}},5499:(q,V,x)=>{"use strict";const{URLWithLegacySupport:y,format:u,URLSearchParams:g,defaultBase:w}=x(6876),m=x(7912);q.exports={URL:y,URLSearchParams:g,format:u,relative:m,defaultBase:w}},7912:(q,V,x)=>{"use strict";const{URLWithLegacySupport:y,format:u}=x(6876);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()}},6876:q=>{"use strict";const V=typeof navigator<"u"&&"ReactNative"===navigator.product,y=self.URL,u=function x(){return V?"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:"",I=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||I+f}${m.path||p+E}${m.hash||""}`}}}},2797:(q,V,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 I,b=u(m);c=!(I=yield b.next()).done;c=!1)h.push(I.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)}}()},363:(q,V,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(I){c=!0,f=I}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},8080:(q,V,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,I=g(h);f=!(E=yield y(I.next())).done;f=!1){const v=E.value;(yield y(c(v)))&&(yield v)}}catch(v){d=!0,b=v}finally{try{f&&null!=I.return&&(yield y(I.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},247:(q,V,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(I){c=!0,f=I}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},7837:(q,V,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,I=g(h);f=!(E=yield y(I.next())).done;f=!1){const v=E.value;yield y(c(v)),yield v}}catch(v){d=!0,b=v}finally{try{f&&null!=I.return&&(yield y(I.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},3412:(q,V,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,I=g(h);f=!(E=yield y(I.next())).done;f=!1){const v=E.value;yield c(v)}}catch(v){d=!0,b=v}finally{try{f&&null!=I.return&&(yield y(I.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},4368:(q,V,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(8710);q.exports=function(){var f=u(function*(...d){const b=h();setTimeout(y(function*(){try{yield Promise.all(d.map(function(){var I=y(function*(E){var D,v=!1,p=!1;try{for(var P,A=w(E);v=!(P=yield A.next()).done;v=!1)b.push(P.value)}catch(S){p=!0,D=S}finally{try{v&&null!=A.return&&(yield A.return())}finally{if(p)throw D}}});return function(E){return I.apply(this,arguments)}}())),b.end()}catch(I){b.end(I)}}),0),yield*m(w(b),g)});return function(){return f.apply(this,arguments)}}()},8710:(q,V,x)=>{const y=x(4814);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),I=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 S=[];for(;!w.isEmpty();){if(P=w.shift(),P.error)throw P.error;S.push(P.value)}return{done:P.done,value:S}}const A=w.shift();if(A.error)throw A.error;return A}return c?{done:!0}:new Promise((A,P)=>{h=S=>(h=null,S.error?P(S.error):A(u.writev&&!S.done?{done:S.done,value:[S.value]}:S),m)})},return:()=>(w=new y,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:I,end:E},!g)return m;const D=m;return m={[Symbol.asyncIterator](){return this},next:()=>D.next(),throw:A=>(D.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(D.return(),g&&(g(),g=null),{done:!0}),push:I,end:A=>(D.end(A),g&&(g(A),g=null),m)},m}},9740:(q,V,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 I,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,I=p}finally{try{d&&null!=E.return&&(yield y(E.return()))}finally{if(b)throw I}}}});return function(c,f){return m.apply(this,arguments)}}()},191:function(q,V,x){"use strict";const y=x(8582),{hasOwnProperty:u}=Object.prototype,{propertyIsEnumerable:g}=Object,w=(p,D,A)=>Object.defineProperty(p,D,{value:A,writable:!0,enumerable:!0,configurable:!0}),m=this,h={concatArrays:!1,ignoreUndefined:!1},c=p=>{const D=[];for(const A in p)u.call(p,A)&&D.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(p);for(const P of A)g.call(p,P)&&D.push(P)}return D};function f(p){return Array.isArray(p)?function d(p){const D=p.slice(0,0);return c(p).forEach(A=>{w(D,A,f(p[A]))}),D}(p):y(p)?function b(p){const D=null===Object.getPrototypeOf(p)?Object.create(null):{};return c(p).forEach(A=>{w(D,A,f(p[A]))}),D}(p):p}const I=(p,D,A,P)=>(A.forEach(S=>{typeof D[S]>"u"&&P.ignoreUndefined||(S in p&&p[S]!==Object.getPrototypeOf(p)?w(p,S,v(p[S],D[S],P)):w(p,S,f(D[S])))}),p);function v(p,D,A){return A.concatArrays&&Array.isArray(p)&&Array.isArray(D)?((p,D,A)=>{let P=p.slice(0,0),S=0;return[p,D].forEach(T=>{const M=[];for(let k=0;k!M.includes(k)),A)}),P})(p,D,A):y(D)&&y(p)?I(p,D,c(D),A):f(D)}q.exports=function(...p){const D=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},D)}return A._}},1663:q=>{var V=1e3,x=60*V,y=60*x,u=24*y;function f(d,b,I,E){var v=b>=1.5*I;return Math.round(d/I)+" "+E+(v?"s":"")}q.exports=function(d,b){b=b||{};var I=typeof d;if("string"===I&&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 I=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*I;case"weeks":case"week":case"w":return 6048e5*I;case"days":case"day":case"d":return I*u;case"hours":case"hour":case"hrs":case"hr":case"h":return I*y;case"minutes":case"minute":case"mins":case"min":case"m":return I*x;case"seconds":case"second":case"secs":case"sec":case"s":return I*V;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return I;default:return}}}}(d);if("number"===I&&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>=V?f(d,b,V,"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>=V?Math.round(d/V)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1343:q=>{var V=1e3,x=60*V,y=60*x,u=24*y;function f(d,b,I,E){var v=b>=1.5*I;return Math.round(d/I)+" "+E+(v?"s":"")}q.exports=function(d,b){b=b||{};var I=typeof d;if("string"===I&&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 I=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*I;case"weeks":case"week":case"w":return 6048e5*I;case"days":case"day":case"d":return I*u;case"hours":case"hour":case"hrs":case"hr":case"h":return I*y;case"minutes":case"minute":case"mins":case"min":case"m":return I*x;case"seconds":case"second":case"secs":case"sec":case"s":return I*V;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return I;default:return}}}}(d);if("number"===I&&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>=V?f(d,b,V,"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>=V?Math.round(d/V)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1626:q=>{"use strict";function V(x){if(Array.isArray(x)){for(var y=0,u=Array(x.length);y>>24,(f&255<<16)>>>16,(65280&f)>>>8,255&f].join(".")},h=function(f){var d,I,E,v,p;for(d=[],I=E=0;E<=3&&0!==f.length;I=++E){if(I>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,I,E,v;for(E=0,d=10,b="9",I=0,f.length>1&&"0"===f[I]&&("x"===f[I+1]||"X"===f[I+1]?(I+=2,d=16):"0"<=f[I+1]&&f[I+1]<="9"&&(I++,d=8,b="7")),v=I;I>>0;else{if(16!==d)break;if("a"<=f[I]&&f[I]<="f")E=E*d+(10+u(f[I])-m)>>>0;else{if(!("A"<=f[I]&&f[I]<="F"))break;E=E*d+(10+u(f[I])-w)>>>0}}if(E>4294967295)throw new Error("too large");I++}if(I===v)throw new Error("empty octet");return[E,I]},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(D){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(D){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,I,E;for(E=h(this.first),I=h(this.last),b=0;E<=I;)d(c(E),E,b),b++,E++},f.prototype.toString=function(){return this.base+"/"+this.bitmask},f}(),V.ip2long=h,V.long2ip=c,V.Netmask=x}).call(this)},5841:(q,V,x)=>{var y=x(6608);function u(p,D){y.cipher.registerAlgorithm(p,function(){return new y.aes.Algorithm(p,D)})}x(1101),x(5256),x(8572),q.exports=y.aes=y.aes||{},y.aes.startEncrypting=function(p,D,A,P){var S=v({key:p,output:A,decrypt:!1,mode:P});return S.start(D),S},y.aes.createEncryptionCipher=function(p,D){return v({key:p,output:null,decrypt:!1,mode:D})},y.aes.startDecrypting=function(p,D,A,P){var S=v({key:p,output:A,decrypt:!0,mode:P});return S.start(D),S},y.aes.createDecryptionCipher=function(p,D){return v({key:p,output:null,decrypt:!0,mode:D})},y.aes.Algorithm=function(p,D){g||b();var A=this;A.name=p,A.mode=new D({blockSize:16,cipher:{encrypt:function(P,S){return E(A._w,P,S,!1)},decrypt:function(P,S){return E(A._w,P,S,!0)}}}),A._init=!1},y.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var A,D=p.key;if("string"!=typeof D||16!==D.length&&24!==D.length&&32!==D.length){if(y.util.isArray(D)&&(16===D.length||24===D.length||32===D.length)){A=D,D=y.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&k^99,h[k]=A,j=(F=p[k])<<24^k<<16^k<<8^k^F,C=((S=p[A])^(T=p[S])^(M=p[T]))<<24^(A^M)<<16^(A^T^M)<<8^A^S^M;for(var O=0;O<4;++O)f[O][A]=j,d[O][k]=C,j=j<<24|j>>>8,C=C<<24|C>>>8;0===A?A=P=1:(A=S^p[p[p[S^M]]],P^=p[p[P]])}}function I(p,D){for(var P,A=p.slice(0),S=1,T=A.length,k=4*(T+6+1),F=T;F>>16&255]<<24^m[P>>>8&255]<<16^m[255&P]<<8^m[P>>>24]^c[S]<<24,S++):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(D){for(var j,C=d[0],O=d[1],H=d[2],L=d[3],K=A.slice(0),ne=(F=0,(k=A.length)-4);F>>24]]^O[m[j>>>16&255]]^H[m[j>>>8&255]]^L[m[255&j]];A=K}return A}function E(p,D,A,P){var T,M,k,F,j,C,O,H,L,K,ne,G,S=p.length/4-1;P?(T=d[0],M=d[1],k=d[2],F=d[3],j=h):(T=f[0],M=f[1],k=f[2],F=f[3],j=m),C=D[0]^p[0],O=D[P?3:1]^p[1],H=D[2]^p[2],L=D[P?1:3]^p[3];for(var ee=3,Z=1;Z>>24]^M[O>>>16&255]^k[H>>>8&255]^F[255&L]^p[++ee],ne=T[O>>>24]^M[H>>>16&255]^k[L>>>8&255]^F[255&C]^p[++ee],G=T[H>>>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&H]^p[++ee],C=K,O=ne,H=G;A[0]=j[C>>>24]<<24^j[O>>>16&255]<<16^j[H>>>8&255]<<8^j[255&L]^p[++ee],A[P?3:1]=j[O>>>24]<<24^j[H>>>16&255]<<16^j[L>>>8&255]<<8^j[255&C]^p[++ee],A[2]=j[H>>>24]<<24^j[L>>>16&255]<<16^j[C>>>8&255]<<8^j[255&O]^p[++ee],A[P?1:3]=j[L>>>24]<<24^j[C>>>16&255]<<16^j[O>>>8&255]<<8^j[255&H]^p[++ee]}function v(p){var P,A="AES-"+((p=p||{}).mode||"CBC").toUpperCase(),S=(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,S.call(P,M)},P}},2266:(q,V,x)=>{var y=x(6608);x(8572),x(7565);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 I;g(c,f,2);var E=c.getByte();f--;var v=192&E,p=31&E;I=c.length();var D=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-=I-c.length(),void 0!==D&&D>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=D,A}D=f}var P,S,T=32==(32&E);if(T)if(P=[],void 0===D)for(;;){if(g(c,f,2),c.bytes(2)===String.fromCharCode(0,0)){c.getBytes(2),f-=2;break}I=c.length(),P.push(m(c,f,d+1,b)),f-=I-c.length()}else for(;D>0;)I=c.length(),P.push(m(c,D,d+1,b)),f-=I-c.length(),D-=I-c.length();if(void 0===P&&v===u.Class.UNIVERSAL&&p===u.Type.BITSTRING&&(S=c.bytes(D)),void 0===P&&b.decodeBitStrings&&v===u.Class.UNIVERSAL&&p===u.Type.BITSTRING&&D>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{I=c.length();var C=m(c,f,d+1,{strict:!0,decodeBitStrings:!0}),O=I-c.length();f-=O,p==u.Type.BITSTRING&&O++;var H=C.tagClass;O===D&&(H===u.Class.UNIVERSAL||H===u.Class.CONTEXT_SPECIFIC)&&(P=[C])}catch{}void 0===P&&(c.read=M,f=k)}if(void 0===P){if(void 0===D){if(b.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");D=f}if(p===u.Type.BMPSTRING)for(P="";D>0;D-=2)g(c,f,2),P+=String.fromCharCode(c.getInt16()),f-=2;else P=c.getBytes(D),f-=D}return u.create(v,p,T,P,void 0===S?null:{bitStringContents:S})}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,I){if(y.util.isArray(b)){for(var E=[],v=0;v1&&(0===c.value.charCodeAt(0)&&0==(128&c.value.charCodeAt(1))||255===c.value.charCodeAt(0)&&128==(128&c.value.charCodeAt(1)))?b.putBytes(c.value.substr(1)):b.putBytes(c.value);if(f.putByte(d),b.length()<=127)f.putByte(127&b.length());else{var v=b.length(),p="";do{p+=String.fromCharCode(255&v),v>>>=8}while(v>0);for(f.putByte(128|p.length),E=p.length-1;E>=0;--E)f.putByte(p.charCodeAt(E))}return f.putBuffer(b),f},u.oidToDer=function(c){var f=c.split("."),d=y.util.createBuffer();d.putByte(40*parseInt(f[0],10)+parseInt(f[1],10));for(var b,I,E,v,p=2;p>>=7,b||(v|=128),I.push(v),b=!1}while(E>0);for(var D=I.length-1;D>=0;--D)d.putByte(I[D])}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,I=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 D=c.charAt(10),A=10;"+"!==D&&"-"!==D&&(p=parseInt(c.substr(10,2),10),A+=2)}if(f.setUTCFullYear(d,b,I),f.setUTCHours(E,v,p,0),A&&("+"===(D=c.charAt(A))||"-"===D)){var T=60*parseInt(c.substr(A+1,2),10)+parseInt(c.substr(A+4,2),10);T*=6e4,f.setTime("+"===D?+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,I=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),D=0,A=0,P=!1;"Z"===c.charAt(c.length-1)&&(P=!0);var S=c.length-5,T=c.charAt(S);return"+"!==T&&"-"!==T||(A=60*parseInt(c.substr(S+1,2),10)+parseInt(c.substr(S+4,2),10),A*=6e4,"+"===T&&(A*=-1),P=!0),"."===c.charAt(14)&&(D=1e3*parseFloat(c.substr(14),10)),P?(f.setUTCFullYear(d,b,I),f.setUTCHours(E,v,p,D),f.setTime(+f+A)):(f.setFullYear(d,b,I),f.setHours(E,v,p,D)),f},u.dateToUtcTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push((""+c.getUTCFullYear()).substr(2)),d.push(""+(c.getUTCMonth()+1)),d.push(""+c.getUTCDate()),d.push(""+c.getUTCHours()),d.push(""+c.getUTCMinutes()),d.push(""+c.getUTCSeconds());for(var b=0;b=-128&&c<128)return f.putSignedInt(c,8);if(c>=-32768&&c<32768)return f.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return f.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return f.putSignedInt(c,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=c,d},u.derToInteger=function(c){"string"==typeof c&&(c=y.util.createBuffer(c));var f=8*c.length();if(f>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(f)},u.validate=function(c,f,d,b){var I=!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(I=!0,f.value&&y.util.isArray(f.value))for(var E=0,v=0;I&&v0&&(b+="\n");for(var I="",E=0;E1?"0x"+y.util.bytesToHex(c.value.slice(1)):"(none)",c.value.length>0){var A=c.value.charCodeAt(0);1==A?b+=" (1 unused bit shown)":A>1&&(b+=" ("+A+" unused bits shown)")}}else if(c.type===u.Type.OCTETSTRING)h.test(c.value)||(b+="("+c.value+") "),b+="0x"+y.util.bytesToHex(c.value);else if(c.type===u.Type.UTF8)try{b+=y.util.decodeUtf8(c.value)}catch(P){if("URI malformed"!==P.message)throw P;b+="0x"+y.util.bytesToHex(c.value)+" (malformed UTF8)"}else c.type===u.Type.PRINTABLESTRING||c.type===u.Type.IA5String?b+=c.value:h.test(c.value)?b+="0x"+y.util.bytesToHex(c.value):b+=0===c.value.length?"[null]":c.value}return b}},2486:q=>{var V={};q.exports=V;var x={};V.encode=function(u,g,w){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==w&&"number"!=typeof w)throw new TypeError('"maxline" must be a number.');var m="";if(u instanceof Uint8Array){var h=0,c=g.length,f=g.charAt(0),d=[0];for(h=0;h0;)d.push(I%c),I=I/c|0}for(h=0;0===u[h]&&h=0;--h)m+=g[d[h]]}else m=function y(u,g){var w=0,m=g.length,h=g.charAt(0),c=[0];for(w=0;w0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===u.at(w)&&w=0;--w)b+=g[c[w]];return b}(u,g);if(w){var E=new RegExp(".{1,"+w+"}","g");m=m.match(E).join("\r\n")}return m},V.decode=function(u,g){if("string"!=typeof u)throw new TypeError('"input" must be a string.');if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');var w=x[g];if(!w){w=x[g]=[];for(var m=0;m>=8;for(;I>0;)f.push(255&I),I>>=8}for(var E=0;u[E]===c&&E{var y=x(6608);x(8572),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))}},5256:(q,V,x)=>{var y=x(6608);x(8572),y.cipher=y.cipher||{};var u=q.exports=y.cipher.modes=y.cipher.modes||{};function g(h,c){if("string"==typeof h&&(h=y.util.createBuffer(h)),y.util.isArray(h)&&h.length>4){var f=h;h=y.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},u.cbc=function(h){h=h||{},this.name="CBC",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},u.cbc.prototype.start=function(h){if(null===h.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._prev=this._iv.slice(0)}},u.cbc.prototype.encrypt=function(h,c,f){if(h.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},u.cfb=function(h){h=h||{},this.name="CFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.cfb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.cfb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(I=this.blockSize-I),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!f)return c.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.cfb.prototype.decrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(I=this.blockSize-I),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!f)return c.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb=function(h){h=h||{},this.name="OFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.ofb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ofb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===h.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(I=this.blockSize-I),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!f)return c.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},u.ofb.prototype.decrypt=u.ofb.prototype.encrypt,u.ctr=function(h){h=h||{},this.name="CTR",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},u.ctr.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},u.ctr.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(I=this.blockSize-I),this._partialOutput.clear(),b=0;b0&&(h.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!f)return c.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}w(this._inBlock)},u.ctr.prototype.decrypt=u.ctr.prototype.encrypt,u.gcm=function(h){h=h||{},this.name="GCM",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0,this._R=3774873600},u.gcm.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");var f,c=y.util.createBuffer(h.iv);if(this._cipherLength=0,f="additionalData"in h?y.util.createBuffer(h.additionalData):y.util.createBuffer(),this._tagLength="tagLength"in h?h.tagLength:128,this._tag=null,h.decrypt&&(this._tag=y.util.createBuffer(h.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var d=c.length();if(12===d)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(m(8*d)))}this._inBlock=this._j0.slice(0),w(this._inBlock),this._partialBytes=0,f=y.util.createBuffer(f),this._aDataLength=m(8*f.length());var b=f.length()%this.blockSize;for(b&&f.fillWithByte(0,this.blockSize-b),this._s=[0,0,0,0];f.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()])},u.gcm.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var b=0;b0&&(I=this.blockSize-I),this._partialOutput.clear(),b=0;b0&&this._partialOutput.getBytes(this._partialBytes),I>0&&!f)return h.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(I-this._partialBytes)),this._partialBytes=I,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),w(this._inBlock)},u.gcm.prototype.decrypt=function(h,c,f){var d=h.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),w(this._inBlock),this._hashBlock[0]=h.getInt32(),this._hashBlock[1]=h.getInt32(),this._hashBlock[2]=h.getInt32(),this._hashBlock[3]=h.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var b=0;b0;--d)c[d]=h[d]>>>1|(1&h[d-1])<<31;c[0]=h[0]>>>1,f&&(c[0]^=this._R)},u.gcm.prototype.tableMultiply=function(h){for(var c=[0,0,0,0],f=0;f<32;++f){var I=this._m[f][h[f/8|0]>>>4*(7-f%8)&15];c[0]^=I[0],c[1]^=I[1],c[2]^=I[2],c[3]^=I[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,I=new Array(b),E=0;E>>1,b=new Array(f);b[d]=h.slice(0);for(var I=d>>>1;I>0;)this.pow(b[2*I],b[I]=[]),I>>=1;for(I=2;I{var y=x(6608);function u(p,D){y.cipher.registerAlgorithm(p,function(){return new y.des.Algorithm(p,D)})}x(1101),x(5256),x(8572),q.exports=y.des=y.des||{},y.des.startEncrypting=function(p,D,A,P){var S=v({key:p,output:A,decrypt:!1,mode:P||(null===D?"ECB":"CBC")});return S.start(D),S},y.des.createEncryptionCipher=function(p,D){return v({key:p,output:null,decrypt:!1,mode:D})},y.des.startDecrypting=function(p,D,A,P){var S=v({key:p,output:A,decrypt:!0,mode:P||(null===D?"ECB":"CBC")});return S.start(D),S},y.des.createDecryptionCipher=function(p,D){return v({key:p,output:null,decrypt:!0,mode:D})},y.des.Algorithm=function(p,D){var A=this;A.name=p,A.mode=new D({blockSize:8,cipher:{encrypt:function(P,S){return E(A._keys,P,S,!1)},decrypt:function(P,S){return E(A._keys,P,S,!0)}}}),A._init=!1},y.des.Algorithm.prototype.initialize=function(p){if(!this._init){var D=y.util.createBuffer(p.key);if(0===this.name.indexOf("3DES")&&24!==D.length())throw new Error("Invalid Triple-DES key size: "+8*D.length());this._keys=function I(p){for(var W,D=[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],S=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],T=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],M=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],k=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],F=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],j=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],C=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],O=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],H=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],K=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],ne=p.length()>8?3:1,G=[],ee=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],Z=0,te=0;te>>4^de))<<4,oe^=W=65535&((de^=W)>>>-16^oe),oe^=(W=858993459&(oe>>>2^(de^=W<<-16)))<<2,oe^=W=65535&((de^=W)>>>-16^oe),oe^=(W=1431655765&(oe>>>1^(de^=W<<-16)))<<1,oe^=W=16711935&((de^=W)>>>8^oe),W=(oe^=(W=1431655765&(oe>>>1^(de^=W<<8)))<<1)<<8|(de^=W)>>>20&240,oe=de<<24|de<<8&16711680|de>>>8&65280|de>>>24&240,de=W;for(var he=0;he>>26,de=de<<2|de>>>26):(oe=oe<<1|oe>>>27,de=de<<1|de>>>27);var Pe=D[(oe&=-15)>>>28]|A[oe>>>24&15]|P[oe>>>20&15]|S[oe>>>16&15]|T[oe>>>12&15]|M[oe>>>8&15]|k[oe>>>4&15],Se=F[(de&=-15)>>>28]|j[de>>>24&15]|C[de>>>20&15]|O[de>>>16&15]|H[de>>>12&15]|L[de>>>8&15]|K[de>>>4&15];G[Z++]=Pe^(W=65535&(Se>>>16^Pe)),G[Z++]=Se^W<<16}}return G}(D),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,D,A,P){var T,S=32===p.length?3:9;T=3===S?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=D[0],F=D[1];k^=(M=252645135&(k>>>4^F))<<4,k^=(M=65535&(k>>>16^(F^=M)))<<16,k^=M=858993459&((F^=M)>>>2^k),k^=M=16711935&((F^=M<<2)>>>8^k),k=(k^=(M=1431655765&(k>>>1^(F^=M<<8)))<<1)<<1|k>>>31,F=(F^=M)<<1|F>>>31;for(var j=0;j>>4|F<<28)^p[H+1];M=k,k=F,F=M^(w[L>>>24&63]|h[L>>>16&63]|f[L>>>8&63]|b[63&L]|g[K>>>24&63]|m[K>>>16&63]|c[K>>>8&63]|d[63&K])}M=k,k=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((k=k>>>1|k<<31)>>>1^F),F^=(M=16711935&(F>>>8^(k^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(k^=M)))<<2,F^=M=65535&((k^=M)>>>16^F),F^=M=252645135&((k^=M<<16)>>>4^F),A[0]=k^=M<<4,A[1]=F}function v(p){var P,A="DES-"+((p=p||{}).mode||"CBC").toUpperCase(),S=(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,S.call(P,M)},P}},6608:q=>{q.exports={options:{usePureJavaScript:!1}}},26:(q,V,x)=>{var y=x(6608);x(2395),x(8572),(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 I=0;Iw.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),I=0;I{var u,y=x(6608);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 qe=16383&Q,$e=Q>>14;--Oe>=0;){var Yt=16383&this.data[z],lr=this.data[z++]>>14,ui=$e*Yt+lr*qe;Re=((Yt=qe*Yt+((16383&ui)<<14)+J.data[ue]+Re)>>28)+(ui>>14)+$e*lr,J.data[ue++]=268435455&Yt}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 qe=32767&Q,$e=Q>>15;--Oe>=0;){var Yt=32767&this.data[z],lr=this.data[z++]>>15,ui=$e*Yt+lr*qe;Re=((Yt=qe*Yt+((32767&ui)<<15)+J.data[ue]+(1073741823&Re))>>>30)+(ui>>>15)+$e*lr+(Re>>>30),J.data[ue++]=1073741823&Yt}return Re},u=30):"Netscape"!=navigator.appName?(m.prototype.am=function c(z,Q,J,ue,Re,Oe){for(;--Oe>=0;){var qe=Q*this.data[z++]+J.data[ue]+Re;Re=Math.floor(qe/67108864),J.data[ue++]=67108863&qe}return Re},u=26):(m.prototype.am=d,u=28),m.prototype.DB=u,m.prototype.DM=(1<>>16)&&(z=J,Q+=16),0!=(J=z>>8)&&(z=J,Q+=8),0!=(J=z>>4)&&(z=J,Q+=4),0!=(J=z>>2)&&(z=J,Q+=2),0!=(J=z>>1)&&(z=J,Q+=1),Q}function he(z){this.m=z}function nt(z){this.m=z,this.mp=z.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,Q+=16),0==(255&z)&&(z>>=8,Q+=8),0==(15&z)&&(z>>=4,Q+=4),0==(3&z)&&(z>>=2,Q+=2),0==(1&z)&&++Q,Q}function on(z){for(var Q=0;0!=z;)z&=z-1,++Q;return Q}function me(){}function ft(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 Se(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 Rt(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 Bt(z){for(;z.t<=this.mt2;)z.data[z.t++]=0;for(var Q=0;Q>15)*this.mpl&this.um)<<15)&z.DM;for(z.data[J=Q+this.m.t]+=this.m.am(0,ue,z,Q,0,this.m.t);z.data[J]>=z.DV;)z.data[J]-=z.DV,z.data[++J]++}z.clamp(),z.drShiftTo(this.m.t,z),z.compareTo(this.m)>=0&&z.subTo(this.m,z)},nt.prototype.mulTo=function en(z,Q,J){z.multiplyTo(Q,J),this.reduce(J)},nt.prototype.sqrTo=function qt(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 S(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 qe=8==J?255&z[ue]:A(z,ue);qe<0?"-"==z.charAt(ue)&&(Re=!0):(Re=!1,0==Oe?this.data[this.t++]=qe:Oe+J>this.DB?(this.data[this.t-1]|=(qe&(1<>this.DB-Oe):this.data[this.t-1]|=qe<=this.DB&&(Oe-=this.DB))}8==J&&0!=(128&z[0])&&(this.s=-1,Oe>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==z;)--this.t},m.prototype.dlShiftTo=function K(z,Q){var J;for(J=this.t-1;J>=0;--J)Q.data[J+z]=this.data[J];for(J=z-1;J>=0;--J)Q.data[J]=0;Q.t=this.t+z,Q.s=this.s},m.prototype.drShiftTo=function ne(z,Q){for(var J=z;J=0;--$e)Q.data[$e+Oe+1]=this.data[$e]>>ue|qe,qe=(this.data[$e]&Re)<=0;--$e)Q.data[$e]=0;Q.data[Oe]=qe,Q.t=this.t+Oe+1,Q.s=this.s,Q.clamp()},m.prototype.rShiftTo=function ee(z,Q){Q.s=this.s;var J=Math.floor(z/this.DB);if(J>=this.t)Q.t=0;else{var ue=z%this.DB,Re=this.DB-ue,Oe=(1<>ue;for(var qe=J+1;qe>ue;ue>0&&(Q.data[this.t-J-1]|=(this.s&Oe)<>=this.DB;if(z.t>=this.DB;ue+=this.s}else{for(ue+=this.s;J>=this.DB;ue-=z.s}Q.s=ue<0?-1:0,ue<-1?Q.data[J++]=this.DV+ue:ue>0&&(Q.data[J++]=ue),Q.t=J,Q.clamp()},m.prototype.multiplyTo=function W(z,Q){var J=this.abs(),ue=z.abs(),Re=J.t;for(Q.t=Re+ue.t;--Re>=0;)Q.data[Re]=0;for(Re=0;Re=0;)z.data[J]=0;for(J=0;J=Q.DV&&(z.data[J+Q.t]-=Q.DV,z.data[J+Q.t+1]=1)}z.t>0&&(z.data[z.t-1]+=Q.am(J,Q.data[J],z,2*J,0,1)),z.s=0,z.clamp()},m.prototype.divRemTo=function oe(z,Q,J){var ue=z.abs();if(!(ue.t<=0)){var Re=this.abs();if(Re.t0?(ue.lShiftTo(Yt,Oe),Re.lShiftTo(Yt,J)):(ue.copyTo(Oe),Re.copyTo(J));var lr=Oe.t,ui=Oe.data[lr-1];if(0!=ui){var Zr=ui*(1<1?Oe.data[lr-2]>>this.F2:0),is=this.FV/Zr,_o=(1<=0&&(J.data[J.t++]=1,J.subTo(Bi,J)),m.ONE.dlShiftTo(lr,Bi),Bi.subTo(Oe,Oe);Oe.t=0;){var pu=J.data[--Xr]==ui?this.DM:Math.floor(J.data[Xr]*is+(J.data[Xr-1]+$t)*_o);if((J.data[Xr]+=Oe.am(0,pu,J,cn,0,lr))0&&J.rShiftTo(Yt,J),qe<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 sn(){return 0==(this.t>0?1&this.data[0]:this.s)},m.prototype.exp=function Un(z,Q){if(z>4294967295||z<1)return m.ONE;var J=h(),ue=h(),Re=Q.convert(this),Oe=H(z)-1;for(Re.copyTo(J);--Oe>=0;)if(Q.sqrTo(J,ue),(z&1<0)Q.mulTo(ue,Re,J);else{var qe=J;J=ue,ue=qe}return Q.revert(J)},m.prototype.toString=function F(z){if(this.s<0)return"-"+this.negate().toString(z);var Q;if(16==z)Q=4;else if(8==z)Q=3;else if(2==z)Q=1;else if(32==z)Q=5;else{if(4!=z)return this.toRadix(z);Q=2}var ue,J=(1<0)for($e>$e)>0&&(Re=!0,Oe=D(ue));qe>=0;)$e>($e+=this.DB-Q)):(ue=this.data[qe]>>($e-=Q)&J,$e<=0&&($e+=this.DB,--qe)),ue>0&&(Re=!0),Re&&(Oe+=D(ue));return Re?Oe:"0"},m.prototype.negate=function j(){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)+H(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 Ar(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=ft,me.prototype.revert=ft,me.prototype.mulTo=function St(z,Q,J){z.multiplyTo(Q,J)},me.prototype.sqrTo=function In(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 pt(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 Nt(z,Q,J){z.multiplyTo(Q,J),this.reduce(J)},Ke.prototype.sqrTo=function gt(z,Q){z.squareTo(Q),this.reduce(Q)};var Gn=[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],na=(1<<26)/Gn[Gn.length-1];m.prototype.chunkSize=function ie(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(),qe="";for(this.divRemTo(ue,Re,Oe);Re.signum()>0;)qe=(J+Oe.intValue()).toString(z).substr(1)+qe,Re.divRemTo(ue,Re,Oe);return Oe.intValue().toString(z)+qe},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,qe=0,$e=0;$e=J&&(this.dMultiply(ue),this.dAddOffset(qe,0),Oe=0,qe=0))}Oe>0&&(this.dMultiply(Math.pow(Q,Oe)),this.dAddOffset(qe,0)),Re&&m.ZERO.subTo(this,this)},m.prototype.fromNumber=function we(z,Q,J){if("number"==typeof Q)if(z<2)this.fromInt(1);else for(this.fromNumber(z,J),this.testBit(z-1)||this.bitwiseTo(m.ONE.shiftLeft(z-1),pe,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(Q);)this.dAddOffset(2,0),this.bitLength()>z&&this.subTo(m.ONE.shiftLeft(z-1),this);else{var ue=new Array,Re=7&z;ue.length=1+(z>>3),Q.nextBytes(ue),Re>0?ue[0]&=(1<>=this.DB;if(z.t>=this.DB;ue+=this.s}else{for(ue+=this.s;J>=this.DB;ue+=z.s}Q.s=ue<0?-1:0,ue>0?Q.data[J++]=ue:ue<-1&&(Q.data[J++]=this.DV+ue),Q.t=J,Q.clamp()},m.prototype.dMultiply=function rt(z){this.data[this.t]=this.am(0,z-1,this,0,0,this.t),++this.t,this.clamp()},m.prototype.dAddOffset=function ce(z,Q){if(0!=z){for(;this.t<=Q;)this.data[this.t++]=0;for(this.data[Q]+=z;this.data[Q]>=this.DV;)this.data[Q]-=this.DV,++Q>=this.t&&(this.data[this.t++]=0),++this.data[Q]}},m.prototype.multiplyLowerTo=function Ge(z,Q,J){var Re,ue=Math.min(this.t+z.t,Q);for(J.s=0,J.t=ue;ue>0;)J.data[--ue]=0;for(Re=J.t-this.t;ue=0;)J.data[ue]=0;for(ue=Math.max(Q-this.t,0);ue0)if(0==Q)J=this.data[0]%z;else for(var ue=this.t-1;ue>=0;--ue)J=(Q*J+this.data[ue])%z;return J},m.prototype.millerRabin=function rf(z){var Q=this.subtract(m.ONE),J=Q.getLowestSetBit();if(J<=0)return!1;for(var Oe,ue=Q.shiftRight(J),Re=function ra(){return{nextBytes:function(z){for(var Q=0;Q=0);var $e=Oe.modPow(ue,this);if(0!=$e.compareTo(m.ONE)&&0!=$e.compareTo(Q)){for(var Yt=1;Yt++>24},m.prototype.shortValue=function ns(){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 Ae(){var z=this.t,Q=new Array;Q[0]=this.s;var ue,J=this.DB-z*this.DB%8,Re=0;if(z-- >0)for(J>J)!=(this.s&this.DM)>>J&&(Q[Re++]=ue|this.s<=0;)J<8?(ue=(this.data[z]&(1<>(J+=this.DB-8)):(ue=this.data[z]>>(J-=8)&255,J<=0&&(J+=this.DB,--z)),0!=(128&ue)&&(ue|=-256),0==Re&&(128&this.s)!=(128&ue)&&++Re,(Re>0||ue!=this.s)&&(Q[Re++]=ue);return Q},m.prototype.equals=function ze(z){return 0==this.compareTo(z)},m.prototype.min=function je(z){return this.compareTo(z)<0?this:z},m.prototype.max=function et(z){return this.compareTo(z)>0?this:z},m.prototype.and=function Ee(z){var Q=h();return this.bitwiseTo(z,Fe,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 Pt(z){var Q=h();return this.bitwiseTo(z,at,Q),Q},m.prototype.not=function dt(){for(var z=h(),Q=0;Q=this.t?0!=this.s:0!=(this.data[Q]&1<1){var ui=h();for(Oe.sqrTo(qe[1],ui);$e<=lr;)qe[$e]=h(),Oe.mulTo(ui,qe[$e-2],qe[$e]),$e+=2}var is,Xr,Zr=z.t-1,_o=!0,$t=h();for(J=H(z.data[Zr])-1;Zr>=0;){for(J>=Yt?is=z.data[Zr]>>J-Yt&lr:(is=(z.data[Zr]&(1<0&&(is|=z.data[Zr-1]>>this.DB+J-Yt)),$e=ue;0==(1&is);)is>>=1,--$e;if((J-=$e)<0&&(J+=this.DB,--Zr),_o)qe[is].copyTo(Re),_o=!1;else{for(;$e>1;)Oe.sqrTo(Re,$t),Oe.sqrTo($t,Re),$e-=2;$e>0?Oe.sqrTo(Re,$t):(Xr=Re,Re=$t,$t=Xr),Oe.mulTo($t,qe[is],Re)}for(;Zr>=0&&0==(z.data[Zr]&1<=0?(J.subTo(ue,J),Q&&Re.subTo(qe,Re),Oe.subTo($e,Oe)):(ue.subTo(J,ue),Q&&qe.subTo(Re,qe),$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 gn(z){var Q=this.s<0?this.negate():this.clone(),J=z.s<0?z.negate():z.clone();if(Q.compareTo(J)<0){var ue=Q;Q=J,J=ue}var Re=Q.getLowestSetBit(),Oe=J.getLowestSetBit();if(Oe<0)return Q;for(Re0&&(Q.rShiftTo(Oe,Q),J.rShiftTo(Oe,J));Q.signum()>0;)(Re=Q.getLowestSetBit())>0&&Q.rShiftTo(Re,Q),(Re=J.getLowestSetBit())>0&&J.rShiftTo(Re,J),Q.compareTo(J)>=0?(Q.subTo(J,Q),Q.rShiftTo(1,Q)):(J.subTo(Q,J),J.rShiftTo(1,J));return Oe>0&&J.lShiftTo(Oe,J),J},m.prototype.isProbablePrime=function wo(z){var Q,J=this.abs();if(1==J.t&&J.data[0]<=Gn[Gn.length-1]){for(Q=0;Q{var y=x(6608);q.exports=y.md=y.md||{},y.md.algorithms=y.md.algorithms||{}},1911:(q,V,x)=>{var y=x(6608);x(3284),q.exports=y.mgf=y.mgf||{},y.mgf.mgf1=y.mgf1},3284:(q,V,x)=>{var y=x(6608);x(8572),y.mgf=y.mgf||{},(q.exports=y.mgf.mgf1=y.mgf1=y.mgf1||{}).create=function(g){return{generate:function(m,h){for(var c=new y.util.ByteBuffer,f=Math.ceil(h/g.digestLength),d=0;d{var y=x(6608);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")},8471:(q,V,x)=>{var y=x(6608);if(x(5841),x(2266),x(1577),x(2395),x(7565),x(7585),x(5379),x(5594),x(6566),x(8577),x(8572),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 D=new Error("Unsupported PRF OID.");throw D.oid=v,D.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],D}}else p="hmacWithSHA1";return I(p)}function I(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 D=new Error("Unsupported PRF algorithm.");throw D.algorithm=v,D.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],D}if(!p||!(v in p))throw new Error("Unknown hash algorithm: "+v);return p[v].create()}w.encryptPrivateKeyInfo=function(v,p,D){(D=D||{}).saltSize=D.saltSize||8,D.count=D.count||2048,D.algorithm=D.algorithm||"aes128",D.prfAlgorithm=D.prfAlgorithm||"sha1";var T,M,k,A=y.random.getBytesSync(D.saltSize),P=D.count,S=g.integerToDer(P);if(0===D.algorithm.indexOf("aes")||"des"===D.algorithm){var F,j,C;switch(D.algorithm){case"aes128":T=16,F=16,j=m["aes128-CBC"],C=y.aes.createEncryptionCipher;break;case"aes192":T=24,F=16,j=m["aes192-CBC"],C=y.aes.createEncryptionCipher;break;case"aes256":T=32,F=16,j=m["aes256-CBC"],C=y.aes.createEncryptionCipher;break;case"des":T=8,F=8,j=m.desCBC,C=y.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=D.algorithm,O}var H="hmacWith"+D.prfAlgorithm.toUpperCase(),L=I(H),K=y.pkcs5.pbkdf2(p,A,P,T,L),ne=y.random.getBytesSync(F);(G=C(K)).start(ne),G.update(g.toDer(v)),G.finish(),k=G.output.getBytes();var ee=function E(v,p,D,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(D.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,S,T,H);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(j).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,ne)])])])}else{var O;if("3des"!==D.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=D.algorithm,O;T=24;var G,Z=new y.util.ByteBuffer(A);K=w.pbe.generatePkcs12Key(p,Z,1,P,T),ne=w.pbe.generatePkcs12Key(p,Z,2,P,T),(G=y.des.createEncryptionCipher(K)).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,S.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 D=null,A={},P=[];if(!g.validate(v,h,A,P)){var S=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw S.errors=P,S}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()&&(D=g.fromDer(M.output)),D},w.encryptedPrivateKeyToPem=function(v,p){var D={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(v).getBytes()};return y.pem.encode(D,{maxline:p})},w.encryptedPrivateKeyFromPem=function(v){var p=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==p.type){var D=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw D.headerType=p.type,D}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,D){if(!(D=D||{}).legacy){var A=w.wrapRsaPrivateKey(w.privateKeyToAsn1(v));return A=w.encryptPrivateKeyInfo(A,p,D),w.encryptedPrivateKeyToPem(A)}var P,S,T,M;switch(D.algorithm){case"aes128":P="AES-128-CBC",T=16,S=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",T=24,S=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",T=32,S=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",T=24,S=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;case"des":P="DES-CBC",T=8,S=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;default:var k=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+D.algorithm+'".');throw k.algorithm=D.algorithm,k}var j=M(y.pbe.opensslDeriveBytes(p,S.substr(0,8),T));j.start(S),j.update(g.toDer(w.privateKeyToAsn1(v))),j.finish();var C={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:y.util.bytesToHex(S).toUpperCase()},body:j.output.getBytes()};return y.pem.encode(C)},w.decryptRsaPrivateKey=function(v,p){var D=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 S,T;switch(A.dekInfo.algorithm){case"DES-CBC":S=8,T=y.des.createDecryptionCipher;break;case"DES-EDE3-CBC":S=24,T=y.des.createDecryptionCipher;break;case"AES-128-CBC":S=16,T=y.aes.createDecryptionCipher;break;case"AES-192-CBC":S=24,T=y.aes.createDecryptionCipher;break;case"AES-256-CBC":S=32,T=y.aes.createDecryptionCipher;break;case"RC2-40-CBC":S=5,T=function(C){return y.rc2.createDecryptionCipher(C,40)};break;case"RC2-64-CBC":S=8,T=function(C){return y.rc2.createDecryptionCipher(C,64)};break;case"RC2-128-CBC":S=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),S));if(F.start(M),F.update(y.util.createBuffer(A.body)),!F.finish())return D;D=F.output.getBytes()}else D=A.body;return null!==(D="ENCRYPTED PRIVATE KEY"===A.type?w.decryptPrivateKeyInfo(g.fromDer(D),p):g.fromDer(D))&&(D=w.privateKeyFromAsn1(D)),D},w.pbe.generatePkcs12Key=function(v,p,D,A,P,S){var T,M;if(typeof S>"u"||null===S){if(!("sha1"in y.md))throw new Error('"sha1" hash algorithm unavailable.');S=y.md.sha1.create()}var k=S.digestLength,F=S.blockLength,j=new y.util.ByteBuffer,C=new y.util.ByteBuffer;if(null!=v){for(M=0;M=0;M--)ve>>=8,ve+=he.at(M)+Be.at(M),Be.setAt(M,255&ve);Se.putBuffer(Be)}Z=Se,j.putBuffer(oe)}return j.truncate(j.length()-P),j},w.pbe.getCipher=function(v,p,D){switch(v){case w.oids.pkcs5PBES2:return w.pbe.getCipherForPBES2(v,p,D);case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case w.oids["pbewithSHAAnd40BitRC2-CBC"]:return w.pbe.getCipherForPKCS12PBE(v,p,D);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,D){var S,A={},P=[];if(!g.validate(p,c,A,P))throw(S=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,S;if((v=g.derToOid(A.kdfOid))!==w.oids.pkcs5PBKDF2)throw(S=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=v,S.supportedOids=["pkcs5PBKDF2"],S;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(S=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=v,S.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],S;var k,F,T=A.kdfSalt,M=y.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),w.oids[v]){case"aes128-CBC":k=16,F=y.aes.createDecryptionCipher;break;case"aes192-CBC":k=24,F=y.aes.createDecryptionCipher;break;case"aes256-CBC":k=32,F=y.aes.createDecryptionCipher;break;case"des-EDE3-CBC":k=24,F=y.des.createDecryptionCipher;break;case"desCBC":k=8,F=y.des.createDecryptionCipher}var j=b(A.prfOid),C=y.pkcs5.pbkdf2(D,T,M,k,j),O=A.encIv,H=F(C);return H.start(O),H},w.pbe.getCipherForPKCS12PBE=function(v,p,D){var A={},P=[];if(!g.validate(p,f,A,P))throw(S=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,S;var k,F,j,T=y.util.createBuffer(A.salt),M=y.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),v){case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24,F=8,j=y.des.startDecrypting;break;case w.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5,F=8,j=function(K,ne){var G=y.rc2.createDecryptionCipher(K,40);return G.start(ne,null),G};break;default:var S;throw(S=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=v,S}var C=b(A.prfOid),O=w.pbe.generatePkcs12Key(D,T,1,M,k,C);return C.start(),j(O,w.pbe.generatePkcs12Key(D,T,2,M,F,C))},w.pbe.opensslDeriveBytes=function(v,p,D,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)],S=16,T=1;S{var y=x(6608);x(26),x(2395),x(8572);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(j,C){if(j)return d(j);d(null,C.toString("binary"))}):g.pbkdf2(w,m,h,c,f,function(j,C){if(j)return d(j);d(null,C.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(w,m,h,c).toString("binary"):g.pbkdf2Sync(w,m,h,c,f).toString("binary");if((typeof f>"u"||null===f)&&(f="sha1"),"string"==typeof f){if(!(f in y.md.algorithms))throw new Error("Unknown hash algorithm: "+f);f=y.md[f].create()}var b=f.digestLength;if(c>4294967295*b){var I=new Error("Derived key is too long.");if(d)return d(I);throw I}var E=Math.ceil(c/b),v=c-(E-1)*b,p=y.hmac.create();p.start(f,w);var A,P,S,D="";if(!d){for(var T=1;T<=E;++T){p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=S=p.digest().getBytes();for(var M=2;M<=h;++M)p.start(null,null),p.update(S),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),S=P;D+=TE)return d(null,D);p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=S=p.digest().getBytes(),M=2,F()}function F(){if(M<=h)return p.start(null,null),p.update(S),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),S=P,++M,y.util.setImmediate(F);D+=T{var y=x(6608);x(8572);var u=q.exports=y.pem=y.pem||{};function g(m){for(var h=m.name+": ",c=[],f=function(v,p){return" "+p},d=0;d65&&-1!==I){var E=h[I];","===E?(++I,h=h.substr(0,I)+"\r\n "+h.substr(I)):h=h.substr(0,I)+"\r\n"+E+h.substr(I+1),b=d-I-1,I=-1,++d}else(" "===h[d]||"\t"===h[d]||","===h[d])&&(I=d);return h}function w(m){return m.replace(/^\s+/,"")}u.encode=function(m,h){h=h||{};var f,c="-----BEGIN "+m.type+"-----\r\n";if(m.procType&&(c+=g(f={name:"Proc-Type",values:[String(m.procType.version),m.procType.type]})),m.contentDomain&&(c+=g(f={name:"Content-Domain",values:[m.contentDomain]})),m.dekInfo&&(f={name:"DEK-Info",values:[m.dekInfo.algorithm]},m.dekInfo.parameters&&f.values.push(m.dekInfo.parameters),c+=g(f)),m.headers)for(var d=0;d{var y=x(6608);x(8572),x(5594),x(4337);var u=q.exports=y.pkcs1=y.pkcs1||{};function g(w,m,h){h||(h=y.md.sha1.create());for(var c="",f=Math.ceil(m/h.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);h.start(),h.update(w+b),c+=h.digest().getBytes()}return c.substring(0,m)}u.encode_rsa_oaep=function(w,m,h){var c,f,d,b;"string"==typeof h?(c=h,f=arguments[3]||void 0,d=arguments[4]||void 0):h&&(c=h.label||void 0,f=h.seed||void 0,d=h.md||void 0,h.mgf1&&h.mgf1.md&&(b=h.mgf1.md)),d?d.start():d=y.md.sha1.create(),b||(b=d);var I=Math.ceil(w.n.bitLength()/8),E=I-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(),D="",A=E-m.length,P=0;P{var y=x(6608);x(5841),x(2266),x(1577),x(7565),x(5379),x(8518),x(5594),x(8572),x(626);var u=y.asn1,g=q.exports=y.pkcs7=y.pkcs7||{};function w(A){var P={},S=[];if(!u.validate(A,g.asn1.recipientInfoValidator,P,S)){var T=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw T.errors=S,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=[],S=0;S0){for(var S=u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T=S&&M0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,T)),k.length>0&&F.value[0].value.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,k)),F.value[0].value.push(u.create(u.Class.UNIVERSAL,u.Type.SET,!0,A.signerInfos)),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(A.type).getBytes()),F])},addSigner:function(T){var M=T.issuer,k=T.serialNumber;if(T.certificate){var F=T.certificate;"string"==typeof F&&(F=y.pki.certificateFromPem(F)),M=F.issuer.attributes,k=F.serialNumber}var j=T.key;if(!j)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof j&&(j=y.pki.privateKeyFromPem(j));var C=T.digestAlgorithm||y.pki.oids.sha1;switch(C){case y.pki.oids.sha1:case y.pki.oids.sha256:case y.pki.oids.sha384:case y.pki.oids.sha512:case y.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+C)}var O=T.authenticatedAttributes||[];if(O.length>0){for(var H=!1,L=!1,K=0;K{var y=x(6608);x(2266),x(8572);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"}]}},4110:(q,V,x)=>{var y=x(6608);x(8572),x(5988),x(5594),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,D){"function"==typeof p&&(D=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,D,A){return"workers"in D?function b(v,p,D,A){if(typeof Worker>"u")return f(v,p,D,A);var P=I(v,p),S=D.workers,T=D.workLoad||100,M=30*T/8,k=D.workerScript||"forge/prime.worker.js";if(-1===S)return y.util.estimateCores(function(j,C){j&&(C=2),S=C-1,F()});function F(){S=Math.max(1,S);for(var j=[],C=0;Cv&&(P=I(v,p));var ee=P.toString(16);K.target.postMessage({hex:ee,workLoad:T}),P.dAddOffset(M,0)}}}F()}(v,p,D,A):f(v,p,D,A)}(v,{nextBytes:function(T){for(var M=P.getBytesSync(T.length),k=0;kp&&(v=I(p,D)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(S<0||+new Date-M{var y=x(6608);x(8572);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 I();m.collect(m.seedFileSync(32-m.pools[0].messageLength<<5)),I()}function I(){m.reseeds=4294967295===m.reseeds?0:m.reseeds+1;var v=m.plugin.md.create();v.update(m.keyBytes);for(var p=1,D=0;D<32;++D)m.reseeds%p==0&&(v.update(m.pools[D].digest().getBytes()),m.pools[D].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,D=y.util.globalScope,A=D.crypto||D.msCrypto;A&&A.getRandomValues&&(p=function(O){return A.getRandomValues(O)});var P=y.util.createBuffer();if(p)for(;P.length()>16)))<<16,C=4294967295&(F=(2147483647&(F+=k>>15))+(F>>31)),M=0;M<3;++M)j=C>>>(M<<3),j^=Math.floor(256*Math.random()),P.putByte(255&j);return P.getBytes(v)}return m.pools=c,m.pool=0,m.generate=function(v,p){if(!p)return m.generateSync(v);var D=m.plugin.cipher,A=m.plugin.increment,P=m.plugin.formatKey,S=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 I(),v();m.seedFile(32-m.pools[0].messageLength<<5,function(D,A){if(D)return v(D);m.collect(A),I(),v()})}(M)});var F=D(m.key,m.seed);m.generated+=F.length,T.putBytes(F),m.key=P(D(m.key,A(m.seed))),m.seed=S(D(m.key,m.seed)),y.util.setImmediate(M)}()},m.generateSync=function(v){var p=m.plugin.cipher,D=m.plugin.increment,A=m.plugin.formatKey,P=m.plugin.formatSeed;m.key=null;for(var S=y.util.createBuffer();S.length()1048575&&(m.key=null),null===m.key&&b();var T=p(m.key,m.seed);m.generated+=T.length,S.putBytes(T),m.key=A(p(m.key,D(m.seed))),m.seed=P(p(m.key,m.seed))}return S.getBytes(v)},u?(m.seedFile=function(v,p){u.randomBytes(v,function(D,A){if(D)return p(D);p(null,A.toString())})},m.seedFileSync=function(v){return u.randomBytes(v).toString()}):(m.seedFile=function(v,p){try{p(null,E(v))}catch(D){p(D)}},m.seedFileSync=E),m.collect=function(v){for(var p=v.length,D=0;D>A&255);m.collect(D)},m.registerWorker=function(v){v===self?m.seedFile=function(D,A){self.addEventListener("message",function P(S){var T=S.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",P),A(T.forge.prng.err,T.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:D}}})}:v.addEventListener("message",function(D){var A=D.data;A.forge&&A.forge.prng&&m.seedFile(A.forge.prng.needed,function(P,S){v.postMessage({forge:{prng:{err:P,bytes:S}}})})})},m}},3051:(q,V,x)=>{var y=x(6608);x(5594),x(8572),(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(I,E){var v,P,p=E-1,D=Math.ceil(p/8),A=I.digest().getBytes();if(D>8*D-p&255;return(C=String.fromCharCode(C.charCodeAt(0)&~O)+C.substr(1))+T+String.fromCharCode(188)},verify:function(I,E,v){var p,D=v-1,A=Math.ceil(D/8);if(E=E.substr(-A),A>8*A-D&255;if(0!=(S.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var k=m.generate(T,P),F="";for(p=0;p{var y=x(6608);x(5841),x(6675),x(2752),x(8572),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,D){return v.generate(p,D)},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 I="";for(var E in navigator)try{"string"==typeof navigator[E]&&(I+=navigator[E])}catch{}c.collect(I),I=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)},6566:(q,V,x)=>{var y=x(6608);x(8572);var u=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],g=[1,2,3,5],w=function(c,f){return c<>16-f},m=function(c,f){return(65535&c)>>f|c<<16-f&65535};q.exports=y.rc2=y.rc2||{},y.rc2.expandKey=function(c,f){"string"==typeof c&&(c=y.util.createBuffer(c)),f=f||128;var p,d=c,b=c.length(),I=f,E=Math.ceil(I/8),v=255>>(7&I);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,D,A,P,b=!1,I=null,E=null,v=null,S=[];for(c=y.rc2.expandKey(c,f),A=0;A<64;A++)S.push(c.getInt16Le());d?(p=function(k){for(A=0;A<4;A++)k[A]+=S[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++},D=function(k){for(A=0;A<4;A++)k[A]+=S[63&k[(A+3)%4]]}):(p=function(k){for(A=3;A>=0;A--)k[A]=m(k[A],g[A]),k[A]-=S[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),P--},D=function(k){for(A=3;A>=0;A--)k[A]-=S[63&k[(A+3)%4]]});var T=function(k){var F=[];for(A=0;A<4;A++){var j=I.getInt16Le();null!==v&&(d?j^=v.getInt16Le():v.putInt16Le(j)),F.push(65535&j)}P=d?0:63;for(var C=0;C=8;)T([[5,p],[1,D],[6,p],[1,D],[5,p]])},finish:function(k){var F=!0;if(d)if(k)F=k(8,I,!d);else{var j=8===I.length()?8:8-I.length();I.fillWithByte(j,j)}if(F&&(b=!0,M.update()),!d&&(F=0===I.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)}},8577:(q,V,x)=>{var y=x(6608);if(x(2266),x(5988),x(7565),x(4395),x(4110),x(5594),x(8572),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"}]},I=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,K,ne){if(ne)return L.modPow(K.e,K.n);if(!K.p||!K.q)return L.modPow(K.d,K.n);var G;K.dP||(K.dP=K.d.mod(K.p.subtract(u.ONE))),K.dQ||(K.dQ=K.d.mod(K.q.subtract(u.ONE))),K.qInv||(K.qInv=K.q.modInverse(K.p));do{G=new u(y.util.bytesToHex(y.random.getBytes(K.n.bitLength()/8)),16)}while(G.compareTo(K.n)>=0||!G.gcd(K.n).equals(u.ONE));for(var ee=(L=L.multiply(G.modPow(K.e,K.n)).mod(K.n)).mod(K.p).modPow(K.dP,K.p),Z=L.mod(K.q).modPow(K.dQ,K.q);ee.compareTo(Z)<0;)ee=ee.add(K.p);var W=ee.subtract(Z).multiply(K.qInv).mod(K.p).multiply(K.q).add(Z);return W.multiply(G.modInverse(K.n)).mod(K.n)};function D(L,K,ne){var G=y.util.createBuffer(),ee=Math.ceil(K.n.bitLength()/8);if(L.length>ee-11){var Z=new Error("Message is too long for PKCS#1 v1.5 padding.");throw Z.length=L.length,Z.max=ee-11,Z}G.putByte(0),G.putByte(ne);var te,W=ee-3-L.length;if(0===ne||1===ne){te=0===ne?0:255;for(var oe=0;oe0;){var de=0,he=y.random.getBytes(W);for(oe=0;oe"u")throw new Error("Encryption block is invalid.");var oe=0;if(0===te){oe=ee-3-G;for(var de=0;de1;){if(255!==Z.getByte()){--Z.read;break}++oe}else if(2===te)for(oe=0;Z.length()>1;){if(0===Z.getByte()){--Z.read;break}++oe}if(0!==Z.getByte()||oe!==ee-3-Z.length())throw new Error("Encryption block is invalid.");return Z.getBytes()}function P(L,K,ne){"function"==typeof K&&(ne=K,K={});var G={algorithm:{name:(K=K||{}).algorithm||"PRIMEINC",options:{workers:K.workers||2,workLoad:K.workLoad||100,workerScript:K.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 K&&(G.prng=K.prng),ee()}function S(L){var K=L.toString(16);K[0]>="8"&&(K="00"+K);var ne=y.util.hexToBytes(K);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 j(L){for(var K=y.util.hexToBytes(L.toString(16)),ne=new Uint8Array(K.length),G=0;G0;)de.putByte(0),--he;return de.putBytes(y.util.hexToBytes(oe)),de.getBytes()},h.rsa.decrypt=function(L,K,ne,G){var ee=Math.ceil(K.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(K.n)>=0)throw new Error("Encrypted message is invalid.");for(var oe=p(W,K,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(),K,ne):de.getBytes()},h.rsa.createKeyPairGenerationState=function(L,K,ne){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var W,G=(ne=ne||{}).prng||y.random,ee={nextBytes:function(te){for(var oe=G.getBytesSync(te.length),de=0;de>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(W.eInt),W},h.rsa.stepKeyPairGenerationState=function(L,K){"algorithm"in L||(L.algorithm="PRIMEINC");var ne=new u(null);ne.fromInt(30);for(var W,G=0,ee=function(Pe,Se){return Pe|Se},Z=+new Date,te=0;null===L.keys&&(K<=0||teoe?L.pqState=0:L.num.isProbablePrime(T(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(c[G++%8],0):2===L.pqState?L.pqState=0===L.num.subtract(u.ONE).gcd(L.e).compareTo(u.ONE)?3:0:3===L.pqState&&(L.pqState=0,null===L.p?L.p=L.num:L.q=L.num,null!==L.p&&null!==L.q&&++L.state,L.num=null)}else if(1===L.state)L.p.compareTo(L.q)<0&&(L.num=L.p,L.p=L.q,L.q=L.num),++L.state;else if(2===L.state)L.p1=L.p.subtract(u.ONE),L.q1=L.q.subtract(u.ONE),L.phi=L.p1.multiply(L.q1),++L.state;else if(3===L.state)0===L.phi.gcd(L.e).compareTo(u.ONE)?++L.state:(L.p=null,L.q=null,L.state=0);else if(4===L.state)L.n=L.p.multiply(L.q),L.n.bitLength()===L.bits?++L.state:(L.q=null,L.state=0);else if(5===L.state){var he=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,he,L.p,L.q,he.mod(L.p1),he.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)}}te+=(W=+new Date)-Z,Z=W}return null!==L.keys},h.rsa.generateKeyPair=function(L,K,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 K?(G=K,K=void 0):"number"!=typeof K&&(ne=K,K=void 0):(ne=L,G=K,L=void 0,K=void 0):3===arguments.length&&("number"==typeof K?"function"==typeof ne&&(G=ne,ne=void 0):(G=ne,ne=K,K=void 0)),ne=ne||{},void 0===L&&(L=ne.bits||2048),void 0===K&&(K=ne.e||65537),!y.options.usePureJavaScript&&!ne.prng&&L>=256&&L<=16384&&(65537===K||3===K))if(G){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:K,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(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:j(K),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:j(K),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 Se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(he.target.result)));G(null,{privateKey:Se,publicKey:h.setRsaPublicKey(Se.n,Se.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:K,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,K,ne);if(!G)return h.rsa.stepKeyPairGenerationState(W,0),W.keys;P(W,ne,G)},h.setRsaPublicKey=h.rsa.setPublicKey=function(L,K){var ne={n:L,e:K,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 D(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={},Se=[];if(!w.validate(he,E,Pe,Se))throw(Be=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=Se,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,K,ne,G,ee,Z,W,te){var oe={n:L,e:K,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 Se=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(Se,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 Se=he.encode(de,oe.n.bitLength());return h.rsa.encrypt(Se,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,K={},ne=[];if(w.validate(L,f,K,ne)&&(L=w.fromDer(y.util.createBuffer(K.privateKey))),!w.validate(L,d,K={},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(K.privateKeyModulus).toHex(),Z=y.util.createBuffer(K.privateKeyPublicExponent).toHex(),W=y.util.createBuffer(K.privateKeyPrivateExponent).toHex(),te=y.util.createBuffer(K.privateKeyPrime1).toHex(),oe=y.util.createBuffer(K.privateKeyPrime2).toHex(),de=y.util.createBuffer(K.privateKeyExponent1).toHex(),he=y.util.createBuffer(K.privateKeyExponent2).toHex(),Pe=y.util.createBuffer(K.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,S(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.qInv))])},h.publicKeyFromAsn1=function(L){var K={},ne=[];if(w.validate(L,I,K,ne)){var ee,G=w.derToOid(K.publicKeyOid);if(G!==h.oids.rsaEncryption)throw(ee=new Error("Cannot read public key. Unknown OID.")).oid=G,ee;L=K.rsaPublicKey}if(!w.validate(L,b,K,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(K.publicKeyModulus).toHex(),W=y.util.createBuffer(K.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,S(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,S(L.e))])}},4337:(q,V,x)=>{var y=x(6608);x(2395),x(8572);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 I=b.messageLengthSize/4,E=0;E>>0,v>>>0];for(var p=b.fullMessageLength.length-1;p>=0;--p)b.fullMessageLength[p]+=v[1],v[1]=v[0]+(b.fullMessageLength[p]/4294967296>>>0),b.fullMessageLength[p]=b.fullMessageLength[p]>>>0,v[0]=v[1]/4294967296>>>0;return f.putBytes(I),h(c,d,f),(f.read>2048||0===f.length())&&f.compact(),b},b.digest=function(){var I=y.util.createBuffer();I.putBytes(f.bytes()),I.putBytes(g.substr(0,b.blockLength-(b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize&b.blockLength-1)));for(var p,A=8*b.fullMessageLength[0],P=0;P>>0)>>>0),A=p>>>0;I.putInt32(A);var S={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};h(S,d,I);var T=y.util.createBuffer();return T.putInt32(S.h0),T.putInt32(S.h1),T.putInt32(S.h2),T.putInt32(S.h3),T.putInt32(S.h4),T},b};var g=null,w=!1;function h(c,f,d){for(var b,I,E,v,p,D,P,S=d.length();S>=64;){for(I=c.h0,E=c.h1,v=c.h2,p=c.h3,D=c.h4,P=0;P<16;++P)b=d.getInt32(),f[P]=b,b=(I<<5|I>>>27)+(p^E&(v^p))+D+1518500249+b,D=p,p=v,v=(E<<30|E>>>2)>>>0,E=I,I=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=(I<<5|I>>>27)+(p^E&(v^p))+D+1518500249+b,D=p,p=v,v=(E<<30|E>>>2)>>>0,E=I,I=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=(I<<5|I>>>27)+(E^v^p)+D+1859775393+b,D=p,p=v,v=(E<<30|E>>>2)>>>0,E=I,I=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=(I<<5|I>>>27)+(E^v^p)+D+1859775393+b,D=p,p=v,v=(E<<30|E>>>2)>>>0,E=I,I=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=(I<<5|I>>>27)+(E&v|p&(E^v))+D+2400959708+b,D=p,p=v,v=(E<<30|E>>>2)>>>0,E=I,I=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=(I<<5|I>>>27)+(E^v^p)+D+3395469782+b,D=p,p=v,v=(E<<30|E>>>2)>>>0,E=I,I=b;c.h0=c.h0+I|0,c.h1=c.h1+E|0,c.h2=c.h2+v|0,c.h3=c.h3+p|0,c.h4=c.h4+D|0,S-=64}}},6675:(q,V,x)=>{var y=x(6608);x(2395),x(8572);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),I={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){I.messageLength=0,I.fullMessageLength=I.messageLength64=[];for(var E=I.messageLengthSize/4,v=0;v>>0,p>>>0];for(var D=I.fullMessageLength.length-1;D>=0;--D)I.fullMessageLength[D]+=p[1],p[1]=p[0]+(I.fullMessageLength[D]/4294967296>>>0),I.fullMessageLength[D]=I.fullMessageLength[D]>>>0,p[0]=p[1]/4294967296>>>0;return d.putBytes(E),c(f,b,d),(d.read>2048||0===d.length())&&d.compact(),I},I.digest=function(){var E=y.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,I.blockLength-(I.fullMessageLength[I.fullMessageLength.length-1]+I.messageLengthSize&I.blockLength-1)));for(var D,P=8*I.fullMessageLength[0],S=0;S>>0)>>>0),P=D>>>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},I};var g=null,w=!1,m=null;function c(f,d,b){for(var I,E,A,P,S,T,M,k,F,j,C,O,H=b.length();H>=64;){for(P=0;P<16;++P)d[P]=b.getInt32();for(;P<64;++P)d[P]=(I=((I=d[P-2])>>>17|I<<15)^(I>>>19|I<<13)^I>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(S=f.h0,T=f.h1,M=f.h2,k=f.h3,F=f.h4,j=f.h5,C=f.h6,O=f.h7,P=0;P<64;++P)A=S&T|M&(S^T),I=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(C^F&(j^C))+m[P]+d[P],O=C,C=j,j=F,F=k+I>>>0,k=M,M=T,T=S,S=I+(E=((S>>>2|S<<30)^(S>>>13|S<<19)^(S>>>22|S<<10))+A)>>>0;f.h0=f.h0+S|0,f.h1=f.h1+T|0,f.h2=f.h2+M|0,f.h3=f.h3+k|0,f.h4=f.h4+F|0,f.h5=f.h5+j|0,f.h6=f.h6+C|0,f.h7=f.h7+O|0,H-=64}}},6674:(q,V,x)=>{var y=x(6608);x(2395),x(8572);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 I=c[b],E=null,v=y.util.createBuffer(),p=new Array(80),D=0;D<80;++D)p[D]=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 S=P.messageLengthSize/4,T=0;T>>0,M>>>0];for(var k=P.fullMessageLength.length-1;k>=0;--k)P.fullMessageLength[k]+=M[1],M[1]=M[0]+(P.fullMessageLength[k]/4294967296>>>0),P.fullMessageLength[k]=P.fullMessageLength[k]>>>0,M[0]=M[1]/4294967296>>>0;return v.putBytes(S),d(E,p,v),(v.read>2048||0===v.length())&&v.compact(),P},P.digest=function(){var S=y.util.createBuffer();S.putBytes(v.bytes()),S.putBytes(w.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var k,j=8*P.fullMessageLength[0],C=0;C>>0)>>>0),j=k>>>0;S.putInt32(j);var O=new Array(E.length);for(C=0;C=128;){for(ve=0;ve<16;++ve)I[ve][0]=E.getInt32()>>>0,I[ve][1]=E.getInt32()>>>0;for(;ve<80;++ve)p=(((He=(nt=I[ve-2])[0])<<13|(ke=nt[1])>>>19)^(ke<<3|He>>>29)^(He<<26|ke>>>6))>>>0,I[ve][0]=(v=((He>>>19|ke<<13)^(ke>>>29|He<<3)^He>>>6)>>>0)+(Rt=I[ve-7])[0]+(D=(((He=(_t=I[ve-15])[0])>>>1|(ke=_t[1])<<31)^(He>>>8|ke<<24)^He>>>7)>>>0)+(Bt=I[ve-16])[0]+((ke=p+Rt[1]+(A=((He<<31|ke>>>1)^(He<<24|ke>>>8)^(He<<25|ke>>>7))>>>0)+Bt[1])/4294967296>>>0)>>>0,I[ve][1]=ke>>>0;for(O=b[0][0],H=b[0][1],L=b[1][0],K=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],Se=b[7][0],Be=b[7][1],ve=0;ve<80;++ve)v=Se+(((W>>>14|te<<18)^(W>>>18|te<<14)^(te>>>9|W<<23))>>>0)+((he^W&(oe^he))>>>0)+h[ve][0]+I[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]+I[ve][1])/4294967296>>>0)>>>0,p=ke>>>0,D=(((O>>>28|H<<4)^(H>>>2|O<<30)^(H>>>7|O<<25))>>>0)+((O&L|ne&(O^L))>>>0)+((ke=(((O<<4|H>>>28)^(H<<30|O>>>2)^(H<<25|O>>>7))>>>0)+((H&K|G&(H^K))>>>0))/4294967296>>>0)>>>0,A=ke>>>0,Se=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=K,L=O,K=H,O=v+D+((ke=p+A)/4294967296>>>0)>>>0,H=ke>>>0;b[0][0]=b[0][0]+O+((ke=b[0][1]+H)/4294967296>>>0)>>>0,b[0][1]=ke>>>0,b[1][0]=b[1][0]+L+((ke=b[1][1]+K)/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]+Se+((ke=b[7][1]+Be)/4294967296>>>0)>>>0,b[7][1]=ke>>>0,qt-=128}}},8572:(q,V,x)=>{var y=x(6608),u=x(2486),g=q.exports=y.util=y.util||{};function w(S){if(8!==S&&16!==S&&24!==S&&32!==S)throw new Error("Only 8, 16, 24, or 32 bits supported: "+S)}function m(S){if(this.data="",this.read=0,"string"==typeof S)this.data=S;else if(g.isArrayBuffer(S)||g.isArrayBufferView(S))if(typeof Buffer<"u"&&S instanceof Buffer)this.data=S.toString("binary");else{var T=new Uint8Array(S);try{this.data=String.fromCharCode.apply(null,T)}catch{for(var M=0;M15?(M=Date.now(),j(H)):(T.push(H),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(S){return"[object Array]"===Object.prototype.toString.call(S)},g.isArrayBuffer=function(S){return typeof ArrayBuffer<"u"&&S instanceof ArrayBuffer},g.isArrayBufferView=function(S){return S&&g.isArrayBuffer(S.buffer)&&void 0!==S.byteLength},g.ByteBuffer=m,g.ByteStringBuffer=m,g.ByteStringBuffer.prototype._optimizeConstructedString=function(S){this._constructedStringLength+=S,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(S){return this.putBytes(String.fromCharCode(S))},g.ByteStringBuffer.prototype.fillWithByte=function(S,T){S=String.fromCharCode(S);for(var M=this.data;T>0;)1&T&&(M+=S),(T>>>=1)>0&&(S+=S);return this.data=M,this._optimizeConstructedString(T),this},g.ByteStringBuffer.prototype.putBytes=function(S){return this.data+=S,this._optimizeConstructedString(S.length),this},g.ByteStringBuffer.prototype.putString=function(S){return this.putBytes(g.encodeUtf8(S))},g.ByteStringBuffer.prototype.putInt16=function(S){return this.putBytes(String.fromCharCode(S>>8&255)+String.fromCharCode(255&S))},g.ByteStringBuffer.prototype.putInt24=function(S){return this.putBytes(String.fromCharCode(S>>16&255)+String.fromCharCode(S>>8&255)+String.fromCharCode(255&S))},g.ByteStringBuffer.prototype.putInt32=function(S){return this.putBytes(String.fromCharCode(S>>24&255)+String.fromCharCode(S>>16&255)+String.fromCharCode(S>>8&255)+String.fromCharCode(255&S))},g.ByteStringBuffer.prototype.putInt16Le=function(S){return this.putBytes(String.fromCharCode(255&S)+String.fromCharCode(S>>8&255))},g.ByteStringBuffer.prototype.putInt24Le=function(S){return this.putBytes(String.fromCharCode(255&S)+String.fromCharCode(S>>8&255)+String.fromCharCode(S>>16&255))},g.ByteStringBuffer.prototype.putInt32Le=function(S){return this.putBytes(String.fromCharCode(255&S)+String.fromCharCode(S>>8&255)+String.fromCharCode(S>>16&255)+String.fromCharCode(S>>24&255))},g.ByteStringBuffer.prototype.putInt=function(S,T){w(T);var M="";do{T-=8,M+=String.fromCharCode(S>>T&255)}while(T>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(S,T){return S<0&&(S+=2<0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(S){var T=this.getInt(S),M=2<=M&&(T-=M<<1),T},g.ByteStringBuffer.prototype.getBytes=function(S){var T;return S?(S=Math.min(this.length(),S),T=this.data.slice(this.read,this.read+S),this.read+=S):0===S?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.ByteStringBuffer.prototype.bytes=function(S){return typeof S>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+S)},g.ByteStringBuffer.prototype.at=function(S){return this.data.charCodeAt(this.read+S)},g.ByteStringBuffer.prototype.setAt=function(S,T){return this.data=this.data.substr(0,this.read+S)+String.fromCharCode(T)+this.data.substr(this.read+S+1),this},g.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},g.ByteStringBuffer.prototype.copy=function(){var S=g.createBuffer(this.data);return S.read=this.read,S},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(S){var T=Math.max(0,this.length()-S);return this.data=this.data.substr(this.read,T),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var S="",T=this.read;T=S)return this;T=Math.max(T||this.growSize,S);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(S){return this.accommodate(1),this.data.setUint8(this.write++,S),this},g.DataBuffer.prototype.fillWithByte=function(S,T){this.accommodate(T);for(var M=0;M>8&65535),this.data.setInt8(this.write,S>>16&255),this.write+=3,this},g.DataBuffer.prototype.putInt32=function(S){return this.accommodate(4),this.data.setInt32(this.write,S),this.write+=4,this},g.DataBuffer.prototype.putInt16Le=function(S){return this.accommodate(2),this.data.setInt16(this.write,S,!0),this.write+=2,this},g.DataBuffer.prototype.putInt24Le=function(S){return this.accommodate(3),this.data.setInt8(this.write,S>>16&255),this.data.setInt16(this.write,S>>8&65535,!0),this.write+=3,this},g.DataBuffer.prototype.putInt32Le=function(S){return this.accommodate(4),this.data.setInt32(this.write,S,!0),this.write+=4,this},g.DataBuffer.prototype.putInt=function(S,T){w(T),this.accommodate(T/8);do{T-=8,this.data.setInt8(this.write++,S>>T&255)}while(T>0);return this},g.DataBuffer.prototype.putSignedInt=function(S,T){return w(T),this.accommodate(T/8),S<0&&(S+=2<0);return T},g.DataBuffer.prototype.getSignedInt=function(S){var T=this.getInt(S),M=2<=M&&(T-=M<<1),T},g.DataBuffer.prototype.getBytes=function(S){var T;return S?(S=Math.min(this.length(),S),T=this.data.slice(this.read,this.read+S),this.read+=S):0===S?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.DataBuffer.prototype.bytes=function(S){return typeof S>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+S)},g.DataBuffer.prototype.at=function(S){return this.data.getUint8(this.read+S)},g.DataBuffer.prototype.setAt=function(S,T){return this.data.setUint8(S,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 S=new Uint8Array(this.data.buffer,this.read),T=new Uint8Array(S.byteLength);T.set(S),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(S){return this.write=Math.max(0,this.length()-S),this.read=Math.min(this.read,this.write),this},g.DataBuffer.prototype.toHex=function(){for(var S="",T=this.read;T0;)1&T&&(M+=S),(T>>>=1)>0&&(S+=S);return M},g.xorBytes=function(S,T,M){for(var k="",F="",j="",C=0,O=0;M>0;--M,++C)F=S.charCodeAt(C)^T.charCodeAt(C),O>=10&&(k+=j,j="",O=0),j+=String.fromCharCode(F),++O;return k+j},g.hexToBytes=function(S){var T="",M=0;for(!0&S.length&&(M=1,T+=String.fromCharCode(parseInt(S[0],16)));M>24&255)+String.fromCharCode(S>>16&255)+String.fromCharCode(S>>8&255)+String.fromCharCode(255&S)};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(S,T){for(var F,j,C,M="",k="",O=0;O>2),M+=f.charAt((3&F)<<4|j>>4),isNaN(j)?M+="==":(M+=f.charAt((15&j)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.decode64=function(S){S=S.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,k,F,j,T="",C=0;C>4),64!==F&&(T+=String.fromCharCode((15&k)<<4|F>>2),64!==j&&(T+=String.fromCharCode((3&F)<<6|j)));return T},g.encodeUtf8=function(S){return unescape(encodeURIComponent(S))},g.decodeUtf8=function(S){return decodeURIComponent(escape(S))},g.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:u.encode,decode:u.decode}},g.binary.raw.encode=function(S){return String.fromCharCode.apply(null,S)},g.binary.raw.decode=function(S,T,M){var k=T;k||(k=new Uint8Array(S.length));for(var F=M=M||0,j=0;j>2),M+=f.charAt((3&F)<<4|j>>4),isNaN(j)?M+="==":(M+=f.charAt((15&j)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.binary.base64.decode=function(S,T,M){var k=T;k||(k=new Uint8Array(3*Math.ceil(S.length/4))),S=S.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,j,C,O,H=0,L=M=M||0;H>4,64!==C&&(k[L++]=(15&j)<<4|C>>2,64!==O&&(k[L++]=(3&C)<<6|O));return T?L-M:k.subarray(0,L)},g.binary.base58.encode=function(S,T){return g.binary.baseN.encode(S,b,T)},g.binary.base58.decode=function(S,T){return g.binary.baseN.decode(S,b,T)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(S,T,M){S=g.encodeUtf8(S);var k=T;k||(k=new Uint8Array(S.length));for(var F=M=M||0,j=0;j"u"&&(M=["web","flash"]);var F,j=!1,C=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===T[0])throw new Error("Flash local storage not available.");k=S.apply(this,T),j="flash"===F}("web"===F||"both"===F)&&(T[0]=localStorage,k=S.apply(this,T),j=!0)}catch(H){C=H}if(j)break}if(!j)throw C;return k};g.setItem=function(S,T,M,k,F){P(v,arguments,F)},g.getItem=function(S,T,M,k){return P(p,arguments,k)},g.removeItem=function(S,T,M,k){P(D,arguments,k)},g.clearItems=function(S,T,M){P(A,arguments,M)},g.isEmpty=function(S){for(var T in S)if(S.hasOwnProperty(T))return!1;return!0},g.format=function(S){for(var M,k,T=/%./g,F=0,j=[],C=0;M=T.exec(S);){(k=S.substring(C,T.lastIndex-2)).length>0&&j.push(k),C=T.lastIndex;var O=M[0][1];switch(O){case"s":case"o":j.push(F");break;case"%":j.push("%");break;default:j.push("<%"+O+"?>")}}return j.push(S.substring(C)),j.join("")},g.formatNumber=function(S,T,M,k){var F=S,j=isNaN(T=Math.abs(T))?2:T,C=void 0===M?",":M,O=void 0===k?".":k,H=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed(j),10)+"",K=L.length>3?L.length%3:0;return H+(K?L.substr(0,K)+O:"")+L.substr(K).replace(/(\d{3})(?=\d)/g,"$1"+O)+(j?C+Math.abs(F-L).toFixed(j).slice(2):"")},g.formatSize=function(S){return S>=1073741824?g.formatNumber(S/1073741824,2,".","")+" GiB":S>=1048576?g.formatNumber(S/1048576,2,".","")+" MiB":S>=1024?g.formatNumber(S/1024,0)+" KiB":g.formatNumber(S,0)+" bytes"},g.bytesFromIP=function(S){return-1!==S.indexOf(".")?g.bytesFromIPv4(S):-1!==S.indexOf(":")?g.bytesFromIPv6(S):null},g.bytesFromIPv4=function(S){if(4!==(S=S.split(".")).length)return null;for(var T=g.createBuffer(),M=0;MM[k].end-M[k].start&&(k=M.length-1)):M.push({start:O,end:O})}T.push(j)}if(M.length>0){var H=M[k];H.end-H.start>0&&(T.splice(H.start,H.end-H.start+1,""),0===H.start&&T.unshift(""),7===H.end&&T.push(""))}return T.join(":")},g.estimateCores=function(S,T){if("function"==typeof S&&(T=S,S={}),S=S||{},"cores"in g&&!S.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(),H=O+4;Date.now()ee.st&&K.stK.st&&ee.st{var y=x(6608);x(5841),x(2266),x(1577),x(2395),x(1911),x(7565),x(5379),x(3051),x(8577),x(8572);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 I(C,O){"string"==typeof O&&(O={shortName:O});for(var L,H=null,K=0;null===H&&K"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in m&&(O.name=g.oids[m[O.shortName]])),typeof O.type>"u"){if(!O.name||!(O.name in g.oids))throw(L=new Error("Attribute type not specified.")).attribute=O,L;O.type=g.oids[O.name]}if(typeof O.shortName>"u"&&O.name&&O.name in m&&(O.shortName=m[O.name]),O.type===w.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=u.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var K=0;K"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function S(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(H=new Error("Extension ID not specified.")).extension=C,H;C.id=g.oids[C.name]}if(typeof C.value<"u")return C;if("keyUsage"===C.name){var L=0,K=0,ne=0;C.digitalSignature&&(K|=128,L=7),C.nonRepudiation&&(K|=64,L=6),C.keyEncipherment&&(K|=32,L=5),C.dataEncipherment&&(K|=16,L=4),C.keyAgreement&&(K|=8,L=3),C.keyCertSign&&(K|=4,L=2),C.cRLSign&&(K|=2,L=1),C.encipherOnly&&(K|=1,L=0),C.decipherOnly&&(ne|=128,L=7);var G=String.fromCharCode(L);0!==ne?G+=String.fromCharCode(K)+String.fromCharCode(ne):0!==K&&(G+=String.fromCharCode(K)),C.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,G)}else if("basicConstraints"===C.name)C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),C.cA&&C.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in C&&C.value.value.push(u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.pathLenConstraint).getBytes()));else if("extKeyUsage"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);var 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,K=0,C.client&&(K|=128,L=7),C.server&&(K|=64,L=6),C.email&&(K|=32,L=5),C.objsign&&(K|=16,L=4),C.reserved&&(K|=8,L=3),C.sslCA&&(K|=4,L=2),C.emailCA&&(K|=2,L=1),C.objCA&&(K|=1,L=0),G=String.fromCharCode(L),0!==K&&(G+=String.fromCharCode(K)),C.value=u.create(u.Class.UNIVERSAL,u.Type.BITSTRING,!1,G);else if("subjectAltName"===C.name||"issuerAltName"===C.name){C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);for(var te=0;te128)throw new Error('Invalid "nsComment" content.');C.value=u.create(u.Class.UNIVERSAL,u.Type.IA5STRING,!1,C.comment)}else if("subjectKeyIdentifier"===C.name&&O.cert){var oe=O.cert.generateSubjectKeyIdentifier();C.subjectKeyIdentifier=oe.toHex(),C.value=u.create(u.Class.UNIVERSAL,u.Type.OCTETSTRING,!1,oe.getBytes())}else if("authorityKeyIdentifier"===C.name&&O.cert){if(C.value=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),ee=C.value.value,C.keyIdentifier){var de=!0===C.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():C.keyIdentifier;ee.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!1,de))}if(C.authorityCertIssuer){var he=[u.create(u.Class.CONTEXT_SPECIFIC,4,!0,[D(!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,Se=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]),Be=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);for(te=0;te"u")throw(H=new Error("Extension value not specified.")).extension=C,H;return C}function T(C,O){if(C===w["RSASSA-PSS"]){var H=[];return void 0!==O.hash.algorithmOid&&H.push(u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(O.hash.algorithmOid).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")])])),void 0!==O.mgf.algorithmOid&&H.push(u.create(u.Class.CONTEXT_SPECIFIC,1,!0,[u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(O.mgf.algorithmOid).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.OID,!1,u.oidToDer(O.mgf.hash.algorithmOid).getBytes()),u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")])])])),void 0!==O.saltLength&&H.push(u.create(u.Class.CONTEXT_SPECIFIC,2,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(O.saltLength).getBytes())])),u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,H)}return u.create(u.Class.UNIVERSAL,u.Type.NULL,!1,"")}function M(C){var O=u.create(u.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===C.attributes.length)return O;for(var H=C.attributes,L=0;L2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(Z.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(G.validity.notBefore=Z[0],G.validity.notAfter=Z[1],G.tbsCertificate=H.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(H.certIssuer);te.update(oe.getBytes()),G.issuer.getField=function(Pe){return I(G.issuer,Pe)},G.issuer.addField=function(Pe){P([Pe]),G.issuer.attributes.push(Pe)},G.issuer.attributes=g.RDNAttributesAsArray(H.certIssuer),H.certIssuerUniqueId&&(G.issuer.uniqueId=H.certIssuerUniqueId),G.issuer.hash=te.digest().toHex();var de=y.md.sha1.create(),he=u.toDer(H.certSubject);return de.update(he.getBytes()),G.subject.getField=function(Pe){return I(G.subject,Pe)},G.subject.addField=function(Pe){P([Pe]),G.subject.attributes.push(Pe)},G.subject.attributes=g.RDNAttributesAsArray(H.certSubject),H.certSubjectUniqueId&&(G.subject.uniqueId=H.certSubjectUniqueId),G.subject.hash=de.digest().toHex(),G.extensions=H.certExtensions?g.certificateExtensionsFromAsn1(H.certExtensions):[],G.publicKey=g.publicKeyFromAsn1(H.subjectPublicKeyInfo),G},g.certificateExtensionsFromAsn1=function(C){for(var O=[],H=0;H1&&(L=H.value.charCodeAt(1),K=H.value.length>2?H.value.charCodeAt(2):0),O.digitalSignature=128==(128&L),O.nonRepudiation=64==(64&L),O.keyEncipherment=32==(32&L),O.dataEncipherment=16==(16&L),O.keyAgreement=8==(8&L),O.keyCertSign=4==(4&L),O.cRLSign=2==(2&L),O.encipherOnly=1==(1&L),O.decipherOnly=128==(128&K)}else if("basicConstraints"===O.name){var H=u.fromDer(O.value);O.cA=H.value.length>0&&H.value[0].type===u.Type.BOOLEAN&&0!==H.value[0].value.charCodeAt(0);var ne=null;H.value.length>0&&H.value[0].type===u.Type.INTEGER?ne=H.value[0].value:H.value.length>1&&(ne=H.value[1].value),null!==ne&&(O.pathLenConstraint=u.derToInteger(ne))}else if("extKeyUsage"===O.name){H=u.fromDer(O.value);for(var G=0;G1&&(L=H.value.charCodeAt(1)),O.client=128==(128&L),O.server=64==(64&L),O.email=32==(32&L),O.objsign=16==(16&L),O.reserved=8==(8&L),O.sslCA=4==(4&L),O.emailCA=2==(2&L),O.objCA=1==(1&L);else if("subjectAltName"===O.name||"issuerAltName"===O.name){O.altNames=[],H=u.fromDer(O.value);for(var Z,W=0;W=k&&C0&&L.value.push(g.certificateExtensionsToAsn1(C.extensions)),L},g.getCertificationRequestInfo=function(C){return u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[u.create(u.Class.UNIVERSAL,u.Type.INTEGER,!1,u.integerToDer(C.version).getBytes()),D(C.subject),g.publicKeyToAsn1(C.publicKey),M(C)])},g.distinguishedNameToAsn1=function(C){return D(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,[]),H=u.create(u.Class.UNIVERSAL,u.Type.SEQUENCE,!0,[]);O.value.push(H);for(var L=0;L"u"&&(K=new Date);var ne=!0,G=null,ee=0;do{var Z=O.shift(),W=null,te=!1;if(K&&(KZ.validity.notAfter)&&(G={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:Z.validity.notBefore,notAfter:Z.validity.notAfter,now:K}),null===G){if(null===(W=O[0]||C.getIssuer(Z))&&Z.isIssuer(Z)&&(te=!0,W=Z),W){var oe=W;y.util.isArray(oe)||(oe=[oe]);for(var de=!1;!de&&oe.length>0;){W=oe.shift();try{de=W.verify(Z)}catch{}}de||(G={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===G&&(!W||te)&&!C.hasCertificate(Z)&&(G={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===G&&W&&!Z.isIssuer(W)&&(G={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===G)for(var he={keyUsage:!0,basicConstraints:!0},Pe=0;null===G&&PeBe.pathLenConstraint&&(G={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var ke=null===G||G.error,nt=H.verify?H.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}},1773:q=>{"use strict";q.exports=()=>{const x={};return x.promise=new Promise((y,u)=>{x.resolve=y,x.reject=u}),x}},6890:(q,V,x)=>{const y=x(4814),u=x(1773);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()}}},3863:(q,V,x)=>{"use strict";q.exports=x(5540).default},5540:function(q,V,x){"use strict";var y=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(V,"__esModule",{value:!0});const u=x(1223),g=y(x(5972)),w=y(x(4129)),m=x(2459),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)}V.default=b=>{if((0,m.isValid)(b)){const I=(0,m.parse)(b);if("ipv4"===I.kind())return function f(b){for(let I of c)if(I.contains(b))return!0;return!1}(I.toNormalizedString());if("ipv6"===I.kind())return d(b)}else if((0,w.default)(b)&&g.default.v6().test(b))return d(b)}},7596:(q,V,x)=>{"use strict";q.exports=x(9952)},9952:(q,V,x)=>{"use strict";var y=V;function u(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(8801),y.BufferWriter=x(8845),y.Reader=x(3553),y.BufferReader=x(4800),y.util=x(4628),y.rpc=x(4969),y.roots=x(4863),y.configure=u,u()},3553:(q,V,x)=>{"use strict";q.exports=h;var u,y=x(4628),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 I(){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,D=this.pos+v;if(D>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,D):p===D?new this.buf.constructor(0):this._slice.call(this.buf,p,D)},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 I.call(this)[v](!0)},sfixed64:function(){return I.call(this)[v](!1)}})}},4800:(q,V,x)=>{"use strict";q.exports=g;var y=x(3553);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(4628);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()},4863:q=>{"use strict";q.exports={}},4969:(q,V,x)=>{"use strict";V.Service=x(5921)},5921:(q,V,x)=>{"use strict";q.exports=u;var y=x(4628);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(I,E){if(I)return d.emit("error",I,w),f(I);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}},4922:(q,V,x)=>{"use strict";q.exports=u;var y=x(4628);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}},4628:function(q,V,x){"use strict";var y=V;function u(w,m,h){for(var c=Object.keys(m),f=0;f0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=u,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";q.exports=d;var u,y=x(4628),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,S,T){this.fn=P,this.len=S,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 I(P,S,T){S[T]=255&P}function v(P,S){this.len=P,this.next=void 0,this.val=S}function p(P,S,T){for(;P.hi;)S[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)S[T++]=127&P.lo|128,P.lo=P.lo>>>7;S[T++]=P.lo}function D(P,S,T){S[T]=255&P,S[T+1]=P>>>8&255,S[T+2]=P>>>16&255,S[T+3]=P>>>24}d.create=b(),d.alloc=function(S){return new y.Array(S)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(S,T,M){return this.tail=this.tail.next=new h(S,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,S,T){for(;P>127;)S[T++]=127&P|128,P>>>=7;S[T]=P},d.prototype.uint32=function(S){return this.len+=(this.tail=this.tail.next=new v((S>>>=0)<128?1:S<16384?2:S<2097152?3:S<268435456?4:5,S)).len,this},d.prototype.int32=function(S){return S<0?this._push(p,10,g.fromNumber(S)):this.uint32(S)},d.prototype.sint32=function(S){return this.uint32((S<<1^S>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(S){var T=g.from(S);return this._push(p,T.length(),T)},d.prototype.sint64=function(S){var T=g.from(S).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(S){return this._push(I,1,S?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(S){return this._push(D,4,S>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(S){var T=g.from(S);return this._push(D,4,T.lo)._push(D,4,T.hi)},d.prototype.float=function(S){return this._push(y.float.writeFloatLE,4,S)},d.prototype.double=function(S){return this._push(y.float.writeDoubleLE,8,S)};var A=y.Array.prototype.set?function(S,T,M){T.set(S,M)}:function(S,T,M){for(var k=0;k>>0;if(!T)return this._push(I,1,0);if(y.isString(S)){var M=d.alloc(T=w.length(S));w.decode(S,M,0),S=M}return this.uint32(T)._push(A,T,S)},d.prototype.string=function(S){var T=m.length(S);return T?this.uint32(T)._push(m.write,T,S):this._push(I,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 S=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=S.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var S=this.head.next,T=this.constructor.alloc(this.len),M=0;S;)S.fn(S.val,T,M),M+=S.len,S=S.next;return T},d._configure=function(P){u=P,d.create=b(),u._configure()}},8845:(q,V,x)=>{"use strict";q.exports=g;var y=x(8801);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(4628);function g(){y.call(this)}function w(m,h,c){m.length<40?u.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=u.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},8626:(q,V,x)=>{"use strict";q.exports=x(9908)},6618:q=>{"use strict";q.exports=x;var y,V=/\/|\./;function x(u,g){V.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}},9231:(q,V,x)=>{"use strict";var y=V,u=x(9242),g=x(1414);function w(h,c,f,d){var b=!1;if(c.resolvedType)if(c.resolvedType instanceof u){h("switch(d%s){",d);for(var I=c.resolvedType.values,E=Object.keys(I),v=0;v>>0",d,d);break;case"int32":case"sint32":case"sfixed32":h("m%s=d%s|0",d,d);break;case"uint64":p=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,p)('else if(typeof d%s==="string")',d)("m%s=parseInt(d%s,10)",d,d)('else if(typeof d%s==="number")',d)("m%s=d%s",d,d)('else if(typeof d%s==="object")',d)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",d,d,d,p?"true":"");break;case"bytes":h('if(typeof d%s==="string")',d)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",d,d,d)("else if(d%s.length >= 0)",d)("m%s=d%s",d,d);break;case"string":h("m%s=String(d%s)",d,d);break;case"bool":h("m%s=Boolean(d%s)",d,d)}}return h}function m(h,c,f,d){if(c.resolvedType)c.resolvedType instanceof u?h("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,f,d,d,f,d,d):h("d%s=types[%i].toObject(m%s,o)",d,f,d);else{var b=!1;switch(c.type){case"double":case"float":h("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":b=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h('if(typeof m%s==="number")',d)("d%s=o.longs===String?String(m%s):m%s",d,d,d)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",d,d,d,d,b?"true":"",d);break;case"bytes":h("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",d,d,d,d,d);break;default:h("d%s=m%s",d,d)}}return h}y.fromObject=function(c){var f=c.fieldsArray,d=g.codegen(["d"],c.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!f.length)return d("return new this.ctor");d("var m=new this.ctor");for(var b=0;b{"use strict";q.exports=function m(h){var c=g.codegen(["r","l"],h.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(h.fieldsArray.filter(function(v){return v.map}).length?",k,value":""))("while(r.pos>>3){");for(var f=0;f>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===u.basic[b]?c("value=types[%i].decode(r,r.uint32())",f):c("value=r.%s()",b),c("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c(void 0!==u.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",I)):d.repeated?(c("if(!(%s&&%s.length))",I,I)("%s=[]",I),void 0!==u.packed[b]&&c("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";q.exports=function m(h){for(var d,c=g.codegen(["m","w"],h.name+"$encode")("if(!w)")("w=Writer.create()"),b=h.fieldsArray.slice().sort(g.compareFieldsById),f=0;f>>0,8|u.mapKey[I.keyType],I.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("}")("}")):I.repeated?(c("if(%s!=null&&%s.length){",d,d),I.packed&&void 0!==u.packed[v]?c("w.uint32(%i).fork()",(I.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,I,E,d+"[i]"):c("w.uint32(%i).%s(%s[i])",(I.id<<3|p)>>>0,v,d)),c("}")):(I.optional&&c("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,I.name),void 0===p?w(c,I,E,d):c("w.uint32(%i).%s(%s)",(I.id<<3|p)>>>0,v,d))}return c("return w")};var y=x(9242),u=x(9725),g=x(1414);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)}},9242:(q,V,x)=>{"use strict";q.exports=w;var y=x(3183);((w.prototype=Object.create(y.prototype)).constructor=w).className="Enum";var u=x(5771),g=x(1414);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 I=Object.keys(h),E=0;E{"use strict";q.exports=c;var y=x(3183);((c.prototype=Object.create(y.prototype)).constructor=c).className="Field";var m,u=x(9242),g=x(9725),w=x(1414),h=/^required|optional|repeated$/;function c(f,d,b,I,E,v,p){if(w.isObject(I)?(p=E,v=I,I=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!==I&&!h.test(I=I.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"===I&&(I="optional"),this.rule=I&&"optional"!==I?I:void 0,this.type=b,this.id=d,this.extend=E||void 0,this.required="required"===I,this.optional=!this.required,this.repeated="repeated"===I,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!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,I){return"packed"===d&&(this._packed=null),y.prototype.setOption.call(this,d,b,I)},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,I,E){return"function"==typeof b?b=w.decorateType(b).name:b&&"object"==typeof b&&(b=w.decorateEnum(b).name),function(p,D){w.decorateType(p.constructor).add(new c(D,d,b,I,{default:E}))}},c._configure=function(d){m=d}},9834:(q,V,x)=>{"use strict";var y=q.exports=x(9807);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(7707),y.decoder=x(3137),y.verifier=x(6707),y.converter=x(9231),y.ReflectionObject=x(3183),y.Namespace=x(5771),y.Root=x(8759),y.Enum=x(9242),y.Type=x(7425),y.Field=x(8982),y.OneOf=x(4821),y.MapField=x(2950),y.Service=x(8623),y.Method=x(5354),y.Message=x(3378),y.wrappers=x(3754),y.types=x(9725),y.util=x(1414),y.ReflectionObject._configure(y.Root),y.Namespace._configure(y.Type,y.Service,y.Enum),y.Root._configure(y.Type),y.Field._configure(y.Type)},9807:(q,V,x)=>{"use strict";var y=V;function u(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(1018),y.BufferWriter=x(4483),y.Reader=x(662),y.BufferReader=x(6678),y.util=x(1106),y.rpc=x(1541),y.roots=x(7695),y.configure=u,u()},9908:(q,V,x)=>{"use strict";var y=q.exports=x(9834);y.build="full",y.tokenize=x(3852),y.parse=x(2223),y.common=x(6618),y.Root._configure(y.Type,y.parse,y.common)},2950:(q,V,x)=>{"use strict";q.exports=w;var y=x(8982);((w.prototype=Object.create(y.prototype)).constructor=w).className="MapField";var u=x(9725),g=x(1414);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,I){g.decorateType(b.constructor).add(new w(I,h,c,f))}}},3378:(q,V,x)=>{"use strict";q.exports=u;var y=x(1106);function u(g){if(g)for(var w=Object.keys(g),m=0;m{"use strict";q.exports=g;var y=x(3183);((g.prototype=Object.create(y.prototype)).constructor=g).className="Method";var u=x(1414);function g(w,m,h,c,f,d,b,I,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=I,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))}},5771:(q,V,x)=>{"use strict";q.exports=d;var y=x(3183);((d.prototype=Object.create(y.prototype)).constructor=d).className="Namespace";var m,h,c,u=x(8982),g=x(1414),w=x(4821);function f(I,E){if(I&&I.length){for(var v={},p=0;pv)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p0;){var D=E.shift();if(p.nested&&p.nested[D]){if(!((p=p.nested[D])instanceof d))throw Error("path conflicts with non-namespace objects")}else p.add(p=new d(D))}return v&&p.addJSON(v),p},d.prototype.resolveAll=function(){for(var E=this.nestedArray,v=0;v-1)return D}else if(D instanceof d&&(D=D.lookup(E.slice(1),v,!0)))return D}else for(var A=0;A{"use strict";q.exports=g,g.className="ReflectionObject";var u,y=x(1414);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 I={};I[m]=h,f.push(I)}return this},g.prototype.setOptions=function(m,h){if(m)for(var c=Object.keys(m),f=0;f{"use strict";q.exports=w;var y=x(3183);((w.prototype=Object.create(y.prototype)).constructor=w).className="OneOf";var u=x(8982),g=x(1414);function w(h,c,f,d){if(Array.isArray(c)||(f=c,c=void 0),y.call(this,h,f),void 0!==c&&!Array.isArray(c))throw TypeError("fieldNames must be an Array");this.oneof=c||[],this.fieldsArray=[],this.comment=d}function m(h){if(h.parent)for(var c=0;c-1&&this.oneof.splice(f,1),c.partOf=null,this},w.prototype.onAdd=function(c){y.prototype.onAdd.call(this,c);for(var d=0;d{"use strict";q.exports=F,F.filename=null,F.defaults={keepCase:!1};var y=x(3852),u=x(8759),g=x(7425),w=x(8982),m=x(2950),h=x(4821),c=x(9242),f=x(8623),d=x(5354),b=x(9725),I=x(1414),E=/^[1-9][0-9]*$/,v=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,D=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,S=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,T=/^[a-zA-Z_][a-zA-Z_0-9]*$/,M=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F(j,C,O){C instanceof u||(O=C,C=new u),O||(O=F.defaults);var te,oe,de,he,Fe,H=O.preferTrailingComment||!1,L=y(j,O.alternateCommentMode||!1),K=L.next,ne=L.push,G=L.peek,ee=L.skip,Z=L.cmnt,W=!0,Pe=!1,Se=C,Be=O.keepCase?function(Ee){return Ee}:I.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=K())&&"'"!==pe)throw ve(pe);Ee.push(K()),ee(pe),pe=G()}while('"'===pe||"'"===pe);return Ee.join("")}function ke(Ee){var pe=K();switch(pe){case"'":case'"':return ne(pe),He();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Rt(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(S.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(K()),ee("to",!0)?_t(K()):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(D.test(Ee))return parseInt(Ee,16);if(P.test(Ee))return parseInt(Ee,8);throw ve(Ee,"id")}function Bt(){if(void 0!==te)throw ve("package");if(te=K(),!M.test(te))throw ve(te,"name");Se=Se.define(te),ee(";")}function qt(){var pe,Ee=G();switch(Ee){case"weak":pe=de||(de=[]),K();break;case"public":K();default:pe=oe||(oe=[])}Ee=He(),ee(";"),pe.push(Ee)}function en(){if(ee("="),he=He(),!(Pe="proto3"===he)&&"proto2"!==he)throw ve(he,"syntax");ee(";")}function sn(Ee,pe){switch(pe){case"option":return ge(Ee,pe),ee(";"),!0;case"message":return Ar(Ee,pe),!0;case"enum":return ie(Ee,pe),!0;case"service":return function je(Ee,pe){if(!T.test(pe=K()))throw ve(pe,"service name");var _e=new f(pe);Un(_e,function(Ne){if(!sn(_e,Ne)){if("rpc"!==Ne)throw ve(Ne);!function et(Ee,pe){var _e=Z(),Le=pe;if(!T.test(pe=K()))throw ve(pe,"name");var at,Pt,dt,Ye,Ne=pe;if(ee("("),ee("stream",!0)&&(Pt=!0),!M.test(pe=K())||(at=pe,ee(")"),ee("returns"),ee("("),ee("stream",!0)&&(Ye=!0),!M.test(pe=K())))throw ve(pe);dt=pe,ee(")");var Vn=new d(Ne,Le,at,dt,Pt,Ye);Vn.comment=_e,Un(Vn,function(Sn){if("option"!==Sn)throw ve(Sn);ge(Vn,Sn),ee(";")}),Ee.add(Vn)}(_e,Ne)}}),Ee.add(_e)}(Ee,pe),!0;case"extend":return function Je(Ee,pe){if(!M.test(pe=K()))throw ve(pe,"reference");var _e=pe;Un(null,function(Ne){switch(Ne){case"required":case"repeated":vn(Ee,Ne,_e);break;case"optional":vn(Ee,Pe?"proto3_optional":"optional",_e);break;default:if(!Pe||!M.test(Ne))throw ve(Ne);ne(Ne),vn(Ee,"optional",_e)}})}(Ee,pe),!0}return!1}function Un(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=K());)pe(Ne);ee(";",!0)}else _e&&_e(),ee(";"),Ee&&("string"!=typeof Ee.comment||H)&&(Ee.comment=Z(Le)||Ee.comment)}function Ar(Ee,pe){if(!T.test(pe=K()))throw ve(pe,"type name");var _e=new g(pe);Un(_e,function(Ne){if(!sn(_e,Ne))switch(Ne){case"map":!function Qr(Ee){ee("<");var pe=K();if(void 0===b.mapKey[pe])throw ve(pe,"type");ee(",");var _e=K();if(!M.test(_e))throw ve(_e,"type");ee(">");var Le=K();if(!T.test(Le))throw ve(Le,"name");ee("=");var Ne=new m(Be(Le),_t(K()),pe,_e);Un(Ne,function(Pt){if("option"!==Pt)throw ve(Pt);ge(Ne,Pt),ee(";")},function(){ze(Ne)}),Ee.add(Ne)}(_e);break;case"required":case"repeated":vn(_e,Ne);break;case"optional":vn(_e,Pe?"proto3_optional":"optional");break;case"oneof":!function ns(Ee,pe){if(!T.test(pe=K()))throw ve(pe,"name");var _e=new h(Be(pe));Un(_e,function(Ne){"option"===Ne?(ge(_e,Ne),ee(";")):(ne(Ne),vn(_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),vn(_e,"optional")}}),Ee.add(_e)}function vn(Ee,pe,_e){var Le=K();if("group"!==Le){if(!M.test(Le))throw ve(Le,"type");var Ne=K();if(!T.test(Ne))throw ve(Ne,"name");Ne=Be(Ne),ee("=");var at=new w(Ne,_t(K()),Le,pe,_e);if(Un(at,function(Ye){if("option"!==Ye)throw ve(Ye);ge(at,Ye),ee(";")},function(){ze(at)}),"proto3_optional"===pe){var Pt=new h("_"+Ne);at.setOption("proto3_optional",!0),Pt.add(at),Ee.add(Pt)}else Ee.add(at);!Pe&&at.repeated&&(void 0!==b.packed[Le]||void 0===b.basic[Le])&&at.setOption("packed",!1,!0)}else!function Li(Ee,pe){var _e=K();if(!T.test(_e))throw ve(_e,"name");var Le=I.lcFirst(_e);_e===Le&&(_e=I.ucFirst(_e)),ee("=");var Ne=_t(K()),at=new g(_e);at.group=!0;var Pt=new w(Le,Ne,_e,pe);Pt.filename=F.filename,Un(at,function(Ye){switch(Ye){case"option":ge(at,Ye),ee(";");break;case"required":case"repeated":vn(at,Ye);break;case"optional":vn(at,Pe?"proto3_optional":"optional");break;case"message":Ar(at,Ye);break;case"enum":ie(at,Ye);break;default:throw ve(Ye)}}),Ee.add(at).add(Pt)}(Ee,pe)}function ie(Ee,pe){if(!T.test(pe=K()))throw ve(pe,"name");var _e=new c(pe);Un(_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(K(),!0),Le={options:void 0,setOption:function(Ne,at){void 0===this.options&&(this.options={}),this.options[Ne]=at}};Un(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=K()))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,K())),ee("="),function Ae(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(Fe=K()))throw ve(Fe,"name");var Le,Ne=Fe;if(ee(":",!0),"{"===G())Le=ye(Ee,pe+"."+Fe);else if("["===G()){var at;if(Le=[],ee("[",!0)){do{at=ke(!0),Le.push(at)}while(ee(",",!0));ee("]"),typeof at<"u"&&we(Ee,pe+"."+Fe,at)}}else Le=ke(!0),we(Ee,pe+"."+Fe,Le);var Pt=_e[Ne];Pt&&(Le=[].concat(Pt).concat(Le)),_e[Ne]=Le,ee(",",!0),ee(";",!0)}return _e}var dt=ke(!0);return we(Ee,pe,dt),dt}function we(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!==(Fe=K());)switch(Fe){case"package":if(!W)throw ve(Fe);Bt();break;case"import":if(!W)throw ve(Fe);qt();break;case"syntax":if(!W)throw ve(Fe);en();break;case"option":ge(Se,Fe),ee(";");break;default:if(sn(Se,Fe)){W=!1;continue}throw ve(Fe)}return F.filename=null,{package:te,imports:oe,weakImports:de,syntax:he,root:C}}},662:(q,V,x)=>{"use strict";q.exports=h;var u,y=x(1106),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 I(){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,D=this.pos+v;if(D>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,D):p===D?new this.buf.constructor(0):this._slice.call(this.buf,p,D)},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 I.call(this)[v](!0)},sfixed64:function(){return I.call(this)[v](!1)}})}},6678:(q,V,x)=>{"use strict";q.exports=g;var y=x(662);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(1106);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()},8759:(q,V,x)=>{"use strict";q.exports=d;var y=x(5771);((d.prototype=Object.create(y.prototype)).constructor=d).className="Root";var h,c,f,u=x(8982),g=x(9242),w=x(4821),m=x(1414);function d(v){y.call(this,"",v),this.deferred=[],this.files=[]}function b(){}d.fromJSON=function(p,D){return D||(D=new d),p.options&&D.setOptions(p.options),D.addJSON(p.nested)},d.prototype.resolvePath=m.path.resolve,d.prototype.fetch=m.fetch,d.prototype.load=function v(p,D,A){"function"==typeof D&&(A=D,D=void 0);var P=this;if(!A)return m.asPromise(v,P,p,D);var S=A===b;function T(H,L){if(A){var K=A;if(A=null,S)throw H;K(H,L)}}function M(H){var L=H.lastIndexOf("google/protobuf/");if(L>-1){var K=H.substring(L);if(K in f)return K}return null}function k(H,L){try{if(m.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),m.isString(L)){c.filename=H;var ne,K=c(L,P,D),G=0;if(K.imports)for(;G-1)){if(P.files.push(H),H in f)return void(S?k(H,f[H]):(++j,setTimeout(function(){--j,k(H,f[H])})));if(S){var K;try{K=m.fs.readFileSync(H).toString("utf8")}catch(ne){return void(L||T(ne))}k(H,K)}else++j,P.fetch(H,function(ne,G){if(--j,A){if(ne)return void(L?j||T(null,P):T(ne));k(H,G)}})}}var j=0;m.isString(p)&&(p=[p]);for(var O,C=0;C-1&&this.deferred.splice(D,1)}}else if(p instanceof g)I.test(p.name)&&delete p.parent[p.name];else if(p instanceof y){for(var A=0;A{"use strict";q.exports={}},1541:(q,V,x)=>{"use strict";V.Service=x(306)},306:(q,V,x)=>{"use strict";q.exports=u;var y=x(1106);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(I,E){if(I)return d.emit("error",I,w),f(I);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}},8623:(q,V,x)=>{"use strict";q.exports=m;var y=x(5771);((m.prototype=Object.create(y.prototype)).constructor=m).className="Service";var u=x(5354),g=x(1414),w=x(1541);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 I=Object.keys(d.methods),E=0;E{"use strict";q.exports=d;var V=/[\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(I,E){switch(E){case"\\":case"":return E;default:return c[E]||""}})}function d(b,I){b=b.toString();var E=0,v=b.length,p=1,D=0,A={},P=[],S=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-(I?2:3);do{if(--oe<0||"\n"===(de=b.charAt(oe))){W.lineEmpty=!0;break}}while(" "===de||"\t"===de);for(var he=b.substring(G,ee).split(w),Pe=0;Pe0)return P.shift();if(S)return function M(){var G="'"===S?y:x;G.lastIndex=E-1;var ee=G.exec(b);if(!ee)throw T("string");return E=G.lastIndex,H(S),S=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(I){if(W=E,te=!1,j(E)){te=!0;do{if((E=C(E))===v||(E++,!oe))break}while(j(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=I||"*"===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(V.lastIndex=0,!V.test(k(de++)))for(;de{"use strict";q.exports=A;var y=x(5771);((A.prototype=Object.create(y.prototype)).constructor=A).className="Type";var u=x(9242),g=x(4821),w=x(8982),m=x(2950),h=x(8623),c=x(3378),f=x(662),d=x(1018),b=x(1414),I=x(7707),E=x(3137),v=x(6707),p=x(9231),D=x(3754);function A(S,T){y.call(this,S,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(S){return S._fieldsById=S._fieldsArray=S._oneofsArray=null,delete S.encode,delete S.decode,delete S.verify,S}Object.defineProperties(A.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var S=Object.keys(this.fields),T=0;T{"use strict";var y=V,u=x(1414),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function w(m,h){var c=0,f={};for(h|=0;c{"use strict";var g,w,y=q.exports=x(1106),u=x(7695);y.codegen=x(3563),y.fetch=x(5467),y.path=x(4845),y.fs=y.inquire("fs"),y.toArray=function(b){if(b){for(var I=Object.keys(b),E=new Array(I.length),v=0;v0)p[P]=v(p[P]||{},D,A);else{var S=p[P];S&&(A=[].concat(S).concat(A)),p[P]=A}return p}(b,I=I.split("."),E)},Object.defineProperty(y,"decorateRoot",{get:function(){return u.decorated||(u.decorated=new(x(8759)))}})},6942:(q,V,x)=>{"use strict";q.exports=u;var y=x(1106);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}},1106:function(q,V,x){"use strict";var y=V;function u(w,m,h){for(var c=Object.keys(m),f=0;fw,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),m}y.asPromise=x(3037),y.base64=x(1942),y.EventEmitter=x(3575),y.float=x(9739),y.inquire=x(3292),y.utf8=x(7481),y.pool=x(8880),y.LongBits=x(6942),y.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),y.global=y.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,y.emptyArray=Object.freeze?Object.freeze([]):[],y.emptyObject=Object.freeze?Object.freeze({}):{},y.isInteger=Number.isInteger||function(m){return"number"==typeof m&&isFinite(m)&&Math.floor(m)===m},y.isString=function(m){return"string"==typeof m||m instanceof String},y.isObject=function(m){return m&&"object"==typeof m},y.isset=y.isSet=function(m,h){var c=m[h];return!(null==c||!m.hasOwnProperty(h))&&("object"!=typeof c||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=u,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";q.exports=function h(c){var f=u.codegen(["m"],c.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),b={};c.oneofsArray.length&&f("var p={}");for(var I=0;I{"use strict";var y=V,u=x(3378);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)}}},1018:(q,V,x)=>{"use strict";q.exports=d;var u,y=x(1106),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,S,T){this.fn=P,this.len=S,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 I(P,S,T){S[T]=255&P}function v(P,S){this.len=P,this.next=void 0,this.val=S}function p(P,S,T){for(;P.hi;)S[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)S[T++]=127&P.lo|128,P.lo=P.lo>>>7;S[T++]=P.lo}function D(P,S,T){S[T]=255&P,S[T+1]=P>>>8&255,S[T+2]=P>>>16&255,S[T+3]=P>>>24}d.create=b(),d.alloc=function(S){return new y.Array(S)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(S,T,M){return this.tail=this.tail.next=new h(S,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,S,T){for(;P>127;)S[T++]=127&P|128,P>>>=7;S[T]=P},d.prototype.uint32=function(S){return this.len+=(this.tail=this.tail.next=new v((S>>>=0)<128?1:S<16384?2:S<2097152?3:S<268435456?4:5,S)).len,this},d.prototype.int32=function(S){return S<0?this._push(p,10,g.fromNumber(S)):this.uint32(S)},d.prototype.sint32=function(S){return this.uint32((S<<1^S>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(S){var T=g.from(S);return this._push(p,T.length(),T)},d.prototype.sint64=function(S){var T=g.from(S).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(S){return this._push(I,1,S?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(S){return this._push(D,4,S>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(S){var T=g.from(S);return this._push(D,4,T.lo)._push(D,4,T.hi)},d.prototype.float=function(S){return this._push(y.float.writeFloatLE,4,S)},d.prototype.double=function(S){return this._push(y.float.writeDoubleLE,8,S)};var A=y.Array.prototype.set?function(S,T,M){T.set(S,M)}:function(S,T,M){for(var k=0;k>>0;if(!T)return this._push(I,1,0);if(y.isString(S)){var M=d.alloc(T=w.length(S));w.decode(S,M,0),S=M}return this.uint32(T)._push(A,T,S)},d.prototype.string=function(S){var T=m.length(S);return T?this.uint32(T)._push(m.write,T,S):this._push(I,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 S=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=S.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var S=this.head.next,T=this.constructor.alloc(this.len),M=0;S;)S.fn(S.val,T,M),M+=S.len,S=S.next;return T},d._configure=function(P){u=P,d.create=b(),u._configure()}},4483:(q,V,x)=>{"use strict";q.exports=g;var y=x(1018);(g.prototype=Object.create(y.prototype)).constructor=g;var u=x(1106);function g(){y.call(this)}function w(m,h,c){m.length<40?u.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=u._Buffer_allocUnsafe,g.writeBytesBuffer=u.Buffer&&u.Buffer.prototype instanceof Uint8Array&&"set"===u.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=u.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},9893:(q,V,x)=>{const y=x(1175),u=x(174),g=x(1522),w=x(2380),{RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c}=x(6481),f=x(5715),d=x(378),b=x(3838),I=x(7340),E=x(9585),v=x(1637),p=x(7983);q.exports={RateLimiterRedis:y,RateLimiterMongo:u,RateLimiterMySQL:g,RateLimiterPostgres:w,RateLimiterMemory:f,RateLimiterMemcache:d,RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c,RLWrapperBlackAndWhite:b,RateLimiterUnion:I,RateLimiterQueue:E,BurstyRateLimiter:v,RateLimiterRes:p}},1637:(q,V,x)=>{const y=x(7983);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}}},3838:(q,V,x)=>{const y=x(7983);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)}}},4578: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'!")}}},6481:(q,V,x)=>{const y=x(5238),u=x(9580),g=x(4578),w=x(5715),m=x(7983),h="rate_limiter_flexible";let c=null;const f=function(S,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},S.send({channel:h,keyPrefix:T.keyPrefix,promiseId:T.promiseId,type:M,data:F})},d=function(S){setTimeout(()=>{this._initiated?process.send(S):typeof this._promises[S.promiseId]<"u"&&d.call(this,S)},30)},b=function(S,T,M,k,F){const j={channel:h,keyPrefix:this.keyPrefix,func:S,promiseId:T,data:{key:M,arg:k,opts:F}};this._initiated?process.send(j):d.call(this,j)},I=function(S,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(S,T,"resolve",k)}).catch(k=>{f(S,T,"reject",k)})},E=function(S){if(!S||S.channel!==h||S.keyPrefix!==this.keyPrefix)return!1;if(this._promises[S.promiseId]){let T;switch(clearTimeout(this._promises[S.promiseId].timeoutId),T=null===S.data||!0===S.data||!1===S.data?S.data:new m(S.data.remainingPoints,S.data.msBeforeNext,S.data.consumedPoints,S.data.isFirstInDuration),S.type){case"resolve":this._promises[S.promiseId].resolve(T);break;case"reject":this._promises[S.promiseId].reject(T);break;default:throw new Error(`RateLimiterCluster: no such message type '${S.type}'`)}delete this._promises[S.promiseId]}},v=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},p=function(S,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:S,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 D{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})):I.call(this,T,M)}),c=this}},RateLimiterClusterMasterPM2:class A{constructor(T){if(c)return c;this._rateLimiters={},T.launchBus((M,k)=>{k.on("process:msg",F=>{const j=F.raw;j&&j.channel===h&&"init"===j.type?(typeof this._rateLimiters[j.opts.keyPrefix]>"u"&&(this._rateLimiters[j.opts.keyPrefix]=new w(j.opts)),T.sendDataToProcessId(F.process.pm_id,{data:{},topic:h,channel:h,type:"init",keyPrefix:j.opts.keyPrefix},(C,O)=>{C&&console.log(C,O)})):I.call(this,{send:O=>{const H=O;H.topic=h,typeof H.data>"u"&&(H.data={}),T.sendDataToProcessId(F.process.pm_id,H,(L,K)=>{L&&console.log(L,K)})}},j)})}),c=this}},RateLimiterCluster:class P extends g{get timeoutMs(){return this._timeoutMs}set timeoutMs(T){this._timeoutMs=typeof T>"u"?5e3:Math.abs(parseInt(T))}constructor(T={}){super(T),process.setMaxListeners(0),this.timeoutMs=T.timeoutMs,this._initiated=!1,process.on("message",M=>{M&&M.channel===h&&"init"===M.type&&M.keyPrefix===this.keyPrefix?this._initiated=!0:E.call(this,M)}),process.send({channel:h,type:"init",opts:v.call(this)}),this._promises={}}consume(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"consume",C,T,M,k)})}penalty(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"penalty",C,T,M,k)})}reward(T,M=1,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"reward",C,T,M,k)})}block(T,M,k={}){return new Promise((F,j)=>{const C=p.call(this,F,j);b.call(this,"block",C,T,M,k)})}get(T,M={}){return new Promise((k,F)=>{const j=p.call(this,k,F);b.call(this,"get",j,T,M)})}delete(T,M={}){return new Promise((k,F)=>{const j=p.call(this,k,F);b.call(this,"delete",j,T,M)})}}}},378:(q,V,x)=>{const y=x(3814),u=x(7983);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,I)=>{const E=Date.now(),v=Math.floor(c/1e3);f?this.client.set(m,h,v,p=>{p?I(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,D)=>{p||!1===D?this.client.add(m,h,v,(A,P)=>{if(A||!P)if(typeof d.attemptNumber>"u"||d.attemptNumber<3){const S=Object.assign({},d);S.attemptNumber=S.attemptNumber?S.attemptNumber+1:1,this._upsert(m,h,c,f,S).then(T=>b(T)).catch(T=>I(T))}else I(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)I(A);else{const S=!1===P?0:P,T={consumedPoints:D,msBeforeNext:S>=0?Math.max(S-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`,(I,E)=>{if(I)c(I);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)})})})}}},5715:(q,V,x)=>{const y=x(4578),u=x(4673),g=x(7983);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 I=this.getKey(h),E=this._getKeySecDuration(f);let v=this._memoryStorage.incrby(I,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(I,v.consumedPoints,this.blockDuration)),b(v);else if(this.execEvenly&&v.msBeforeNext>0&&!v.isFirstInDuration){let p=Math.ceil(v.msBeforeNext/(v.remainingPoints+2));p{const I=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,c,I);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 I=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,-c,I);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)))}}},174:(q,V,x)=>{const y=x(3814),u=x(7983);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 I=b.attrs||{};let E,v;d?(E={key:h},E=Object.assign(E,I),v={$set:{key:h,points:c,expire:f>0?new Date(Date.now()+f):null}},v.$set=Object.assign(v.$set,I)):(E={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:h},E=Object.assign(E,I),v={$setOnInsert:{key:h,expire:f>0?new Date(Date.now()+f):null},$inc:{points:c}},v.$setOnInsert=Object.assign(v.$setOnInsert,I));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((D,A)=>{this._collection.findOneAndUpdate(E,v,p).then(P=>{D(P)}).catch(P=>{if(P&&11e3===P.code){const S=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:h},I),T={$set:Object.assign({key:h,points:c,expire:f>0?new Date(Date.now()+f):null},I)};this._collection.findOneAndUpdate(S,T,p).then(M=>{D(M)}).catch(M=>{M&&11e3===M.code?this._upsert(h,c,f,d).then(k=>D(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},1522:(q,V,x)=>{const y=x(3814),u=x(7983);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,I)=>{m.query("BEGIN",E=>{if(E)return m.rollback(),I(E);const v=Date.now(),p=f>0?v+f:null;let D,A;d?(D="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",A=[this.dbName,this.tableName,h,c,p,c,p]):(D="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(D,A,P=>{if(P)return m.rollback(),I(P);m.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,h],(S,T)=>{if(S)return m.rollback(),I(S);m.query("COMMIT",M=>{if(M)return m.rollback(),I(M);b(T)})})})})})}_upsert(m,h,c,f=!1){return this.tableCreated?new Promise((d,b)=>{this._getConnection().then(I=>{this._upsertTransaction(I,m,h,c,f).then(E=>{d(E),this._releaseConnection(I)}).catch(E=>{b(E),this._releaseConnection(I)})}).catch(I=>{b(I)})}):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"))}}},2380:(q,V,x)=>{const y=x(3814),u=x(7983);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(I=>{f(I),this._releaseConnection(b)}).catch(I=>{d(I),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"))}}},9585:(q,V,x)=>{const y=x(1955),u=4294967295,g="limiter";q.exports=class{constructor(h,c={maxQueueSize:u}){this._queueLimiters={KEY_DEFAULT:new w(h,c)},this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(h=g){return this._queueLimiters[h]?this._queueLimiters[h].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(h,c=g){return this._queueLimiters[c]||(this._queueLimiters[c]=new w(this._limiterFlexible,{key:c,maxQueueSize:this._maxQueueSize})),this._queueLimiters[c].removeTokens(h)}};class w{constructor(h,c={maxQueueSize:u,key:g}){this._key=c.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(h=>null!==h?h.remainingPoints:this._limiterFlexible.points)}removeTokens(h){const c=this;return new Promise((f,d)=>{h>c._limiterFlexible.points?d(new y(`Requested tokens ${h} exceeds maximum ${c._limiterFlexible.points} tokens per interval`)):c._queue.length>0?c._queueRequest.call(c,f,d,h):c._limiterFlexible.consume(c._key,h).then(b=>{f(b.remainingPoints)}).catch(b=>{b instanceof Error?d(b):(c._queueRequest.call(c,f,d,h),null===c._waitTimeout&&(c._waitTimeout=setTimeout(c._processFIFO.bind(c),b.msBeforeNext)))})})}_queueRequest(h,c,f){const d=this;d._queue.length{c.resolve(f.remainingPoints),h._processFIFO.call(h)}).catch(f=>{f instanceof Error?(c.reject(f),h._processFIFO.call(h)):(h._queue.unshift(c),null===h._waitTimeout&&(h._waitTimeout=setTimeout(h._processFIFO.bind(h),f.msBeforeNext)))})}}},1175:(q,V,x)=>{const y=x(3814),u=x(7983),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,this._rejectIfRedisNotReady=!!h.rejectIfRedisNotReady,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:g})}_isRedisReady(){return!this._rejectIfRedisNotReady||!(this.client.status&&"ready"!==this.client.status||"function"==typeof this.client.isReady&&!this.client.isReady())}_getRateLimiterRes(h,c,f){let[d,b]=f;Array.isArray(d)&&([,d]=d,[,b]=b);const I=new u;return I.consumedPoints=parseInt(d),I.isFirstInDuration=I.consumedPoints===c,I.remainingPoints=Math.max(this.points-I.consumedPoints,0),I.msBeforeNext=b,I}_upsert(h,c,f,d=!1){return new Promise((b,I)=>{if(!this._isRedisReady())return I(new Error("Redis connection is not ready"));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,D)=>p?I(p):b(D));else if(E>0){const p=function(D,A){return D?I(D):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,D)=>p?I(p):b(D))})}_get(h){return new Promise((c,f)=>{if(!this._isRedisReady())return f(new Error("Redis connection is not ready"));this.client.multi().get(h).pttl(h).exec((d,b)=>{if(d)f(d);else{const[I]=b;if(null===I)return c(null);c(b)}})})}_delete(h){return new Promise((c,f)=>{this.client.del(h,(d,b)=>{d?f(d):c(b>0)})})}}},7983: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()}}},3814:(q,V,x)=>{const y=x(4578),u=x(5934),g=x(7983);q.exports=class extends y{constructor(m={}){super(m),this.inMemoryBlockOnConsumed=m.inMemoryBlockOnConsumed||m.inmemoryBlockOnConsumed,this.inMemoryBlockDuration=m.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 I=this._getRateLimiterRes(c,f,d);if(this.inMemoryBlockOnConsumed>0&&!(this.inMemoryBlockDuration>0)&&I.consumedPoints>=this.inMemoryBlockOnConsumed)return this._inMemoryBlockedKeys.addMs(c,I.msBeforeNext),I.consumedPoints>this.points?h(I):m(I);if(I.consumedPoints>this.points){let E=Promise.resolve();this.blockDuration>0&&I.consumedPoints<=this.points+f&&(I.msBeforeNext=this.msBlockDuration,E=this._block(c,I.consumedPoints,this.msBlockDuration,b)),this.inMemoryBlockOnConsumed>0&&I.consumedPoints>=this.inMemoryBlockOnConsumed&&(this._inMemoryBlockedKeys.add(c,this.inMemoryBlockDuration),I.msBeforeNext=this.msInMemoryBlockDuration),E.then(()=>{h(I)}).catch(v=>{h(v)})}else if(this.execEvenly&&I.msBeforeNext>0&&!I.isFirstInDuration){let E=Math.ceil(I.msBeforeNext/(I.remainingPoints+2));E{c(E)}).catch(E=>{f(E)}):f(m)}get _inmemoryBlockedKeys(){return this._inMemoryBlockedKeys}getInmemoryBlockMsBeforeExpire(m){return this.getInMemoryBlockMsBeforeExpire(m)}get inmemoryBlockOnConsumed(){return this.inMemoryBlockOnConsumed}set inmemoryBlockOnConsumed(m){this.inMemoryBlockOnConsumed=m}get inmemoryBlockDuration(){return this.inMemoryBlockDuration}set inmemoryBlockDuration(m){this.inMemoryBlockDuration=m}get msInmemoryBlockDuration(){return 1e3*this.inMemoryBlockDuration}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),I=this.getInMemoryBlockMsBeforeExpire(b);if(I>0)return d(new g(0,I));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(I=>{d(this._getRateLimiterRes(f,h,I))}).catch(I=>{this._handleError(I,"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(I=>{d(this._getRateLimiterRes(f,-h,I))}).catch(I=>{this._handleError(I,"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(I=>{this._handleError(I,"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(m,h,c,f=!1,d={}){throw new Error("You have to implement the method '_upsert'!")}}},7340:(q,V,x)=>{const y=x(4578);q.exports=class{constructor(...g){if(g.length<1)throw new Error("RateLimiterUnion: at least one limiter have to be passed");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(I=>{!0===I.rejected&&(b=!0)});for(let I=0;I{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]})}}},5934:(q,V,x)=>{const y=x(649);q.exports=y},4673:(q,V,x)=>{const y=x(9379),u=x(7983);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)}}},9379: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}}},1955: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)}}},1384:(q,V,x)=>{"use strict";q.exports=m;var y=x(1343),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}}},2113:(q,V,x)=>{"use strict";const y=x(7158);class u{constructor(m,h,c){const f=this;this._started=y(),this._rescheduled=0,this._scheduled=h,this._args=c,this._triggered=!1,this._timerWrapper=()=>{f._rescheduled>0?(f._scheduled=f._rescheduled-(y()-f._started),f._schedule(f._scheduled)):(f._triggered=!0,m.apply(null,f._args))},this._timer=setTimeout(this._timerWrapper,h)}reschedule(m){m||(m=this._scheduled);const h=y();h+m-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(m)):this._triggered?this._schedule(m):(this._started=h,this._rescheduled=m)}_schedule(m){this._triggered=!1,this._started=y(),this._rescheduled=0,this._scheduled=m,this._timer=setTimeout(this._timerWrapper,m)}clear(){clearTimeout(this._timer)}}q.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let w;if(arguments.length>0){w=new Array(arguments.length-2);for(var m=0;m{"use strict";q.exports=function(){return Date.now()}},5150:(q,V,x)=>{"use strict";var y=x(7605),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||"",I=c(f,b);return""===b?I:c(I,"")}},2338:(q,V,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(I){setTimeout(()=>{throw I},1);break}if(!u.get(b))break;yield new Promise(I=>{const E=setTimeout(I,d);u.set(b,E)})}})).apply(this,arguments)}q.exports={setDelayedInterval:function h(f,d,b){b=b||d;const I=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function w(f,d,b){m.apply(this,arguments)}(f,d,I)},b);return u.set(I,E),I},clearDelayedInterval:function c(f){const d=u.get(f);d&&(clearTimeout(d),u.delete(f))}}},7380:(q,V,x)=>{"use strict";const{AbortController:y}=globalThis,u=x(2113);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}},7605:(q,V,x)=>{"use strict";var y=x(3878),u=x(8332);q.exports=y.bind(null,u)},3878:q=>{"use strict";function x(y){return y>=56320&&y<=57343}q.exports=function(u,g,w){if("string"!=typeof g)throw new Error("Input must be string");for(var c,f,m=g.length,h=0,d=0;d=55296&&y<=56319&&x(g.charCodeAt(d+1))&&(f+=g[d+=1]),(h+=u(f))===w)return g.slice(0,d+1);if(h>w)return g.slice(0,d-f.length+1)}var y;return g}},8332:q=>{"use strict";function V(y){return y>=55296&&y<=56319}q.exports=function(u){if("string"!=typeof u)throw new Error("Input must be string");for(var g=u.length,w=0,m=null,h=null,c=0;c=56320&&y<=57343?null!=h&&V(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}},3772:q=>{q.exports=function y(u,m){var f,w=0,h=0,c=m=m||0,d=u.length;do{if(c>=d||h>49)throw y.bytes=0,new RangeError("Could not decode varint");f=u[c++],w+=h<28?(127&f)<=128);return y.bytes=c-m,w}},2448: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)},4725:(q,V,x)=>{q.exports={encode:x(2448),decode:x(3772),encodingLength:x(3067)}},3067:q=>{var V=Math.pow(2,7),x=Math.pow(2,14),y=Math.pow(2,21),u=Math.pow(2,28),g=Math.pow(2,35),w=Math.pow(2,42),m=Math.pow(2,49),h=Math.pow(2,56),c=Math.pow(2,63);q.exports=function(f){return f{"use strict";!function(ie){const le=ie.performance;function ge(Kt){le&&le.mark&&le.mark(Kt)}function ye(Kt,rt){le&&le.measure&&le.measure(Kt,rt)}ge("Zone");const we=ie.__Zone_symbol_prefix||"__zone_symbol__";function Ae(Kt){return we+Kt}const ze=!0===ie[Ae("forceDuplicateZoneCheck")];if(ie.Zone){if(ze||"function"!=typeof ie.Zone.__symbol__)throw new Error("Zone already loaded.");return ie.Zone}let je=(()=>{class Kt{constructor(ce,me){this._parent=ce,this._name=me?me.name||"unnamed":"",this._properties=me&&me.properties||{},this._zoneDelegate=new Je(this,this._parent&&this._parent._zoneDelegate,me)}static assertZonePatched(){if(ie.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=Kt.current;for(;ce.parent;)ce=ce.parent;return ce}static get current(){return An.zone}static get currentTask(){return Vr}static __load_patch(ce,me,ft=!1){if(wi.hasOwnProperty(ce)){if(!ft&&ze)throw Error("Already loaded patch: "+ce)}else if(!ie["__Zone_disable_"+ce]){const St="Zone:"+ce;ge(St),wi[ce]=me(ie,Kt,Wn),ye(St,St)}}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 ft=this._zoneDelegate.intercept(this,ce,me),St=this;return function(){return St.runGuarded(ft,this,arguments,me)}}run(ce,me,ft,St){An={parent:An,zone:this};try{return this._zoneDelegate.invoke(this,ce,me,ft,St)}finally{An=An.parent}}runGuarded(ce,me=null,ft,St){An={parent:An,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,me,ft,St)}catch(In){if(this._zoneDelegate.handleError(this,In))throw In}}finally{An=An.parent}}runTask(ce,me,ft){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||Vn).name+"; Execution: "+this.name+")");if(ce.state===Ht&&(ce.type===Rr||ce.type===bt))return;const St=ce.state!=ot;St&&ce._transitionTo(ot,on),ce.runCount++;const In=Vr;Vr=ce,An={parent:An,zone:this};try{ce.type==bt&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,me,ft)}catch(Ve){if(this._zoneDelegate.handleError(this,Ve))throw Ve}}finally{ce.state!==Ht&&ce.state!==tt&&(ce.type==Rr||ce.data&&ce.data.isPeriodic?St&&ce._transitionTo(on,ot):(ce.runCount=0,this._updateTaskCount(ce,-1),St&&ce._transitionTo(Ht,ot,Ht))),An=An.parent,Vr=In}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let ft=this;for(;ft;){if(ft===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);ft=ft.parent}}ce._transitionTo(Sn,Ht);const me=[];ce._zoneDelegates=me,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(ft){throw ce._transitionTo(tt,Sn,Ht),this._zoneDelegate.handleError(this,ft),ft}return ce._zoneDelegates===me&&this._updateTaskCount(ce,1),ce.state==Sn&&ce._transitionTo(on,Sn),ce}scheduleMicroTask(ce,me,ft,St){return this.scheduleTask(new Fe(Gt,ce,me,ft,St,void 0))}scheduleMacroTask(ce,me,ft,St,In){return this.scheduleTask(new Fe(bt,ce,me,ft,St,In))}scheduleEventTask(ce,me,ft,St,In){return this.scheduleTask(new Fe(Rr,ce,me,ft,St,In))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||Vn).name+"; Execution: "+this.name+")");ce._transitionTo(En,on,ot);try{this._zoneDelegate.cancelTask(this,ce)}catch(me){throw ce._transitionTo(tt,En),this._zoneDelegate.handleError(this,me),me}return this._updateTaskCount(ce,-1),ce._transitionTo(Ht,En),ce.runCount=0,ce}_updateTaskCount(ce,me){const ft=ce._zoneDelegates;-1==me&&(ce._zoneDelegates=null);for(let St=0;StKt.hasTask(ce,me),onScheduleTask:(Kt,rt,ce,me)=>Kt.scheduleTask(ce,me),onInvokeTask:(Kt,rt,ce,me,ft,St)=>Kt.invokeTask(ce,me,ft,St),onCancelTask:(Kt,rt,ce,me)=>Kt.cancelTask(ce,me)};class Je{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 ft=me&&me.onHasTask;(ft||ce&&ce._hasTaskZS)&&(this._hasTaskZS=ft?me:et,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=rt,me.onScheduleTask||(this._scheduleTaskZS=et,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),me.onInvokeTask||(this._invokeTaskZS=et,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),me.onCancelTask||(this._cancelTaskZS=et,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,ft,St){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,rt,ce,me,ft,St):ce.apply(me,ft)}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!=Gt)throw new Error("Task is missing scheduleFn.");dt(ce)}return me}invokeTask(rt,ce,me,ft){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,rt,ce,me,ft):ce.callback.apply(me,ft)}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,ft=me[rt],St=me[rt]=ft+ce;if(St<0)throw new Error("More tasks executed then were scheduled.");0!=ft&&0!=St||this.hasTask(this.zone,{microTask:me.microTask>0,macroTask:me.macroTask>0,eventTask:me.eventTask>0,change:rt})}}class Fe{constructor(rt,ce,me,ft,St,In){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=rt,this.source=ce,this.data=ft,this.scheduleFn=St,this.cancelFn=In,!me)throw new Error("callback is not defined");this.callback=me;const Ve=this;this.invoke=rt===Rr&&ft&&ft.useG?Fe.invokeTask:function(){return Fe.invokeTask.call(ie,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&&Ye(),_r--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(Ht,Sn)}_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==Ht&&(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=Ae("setTimeout"),pe=Ae("Promise"),_e=Ae("then");let at,Le=[],Ne=!1;function Pt(Kt){if(at||ie[pe]&&(at=ie[pe].resolve(0)),at){let rt=at[_e];rt||(rt=at.then),rt.call(at,Kt)}else ie[Ee](Kt,0)}function dt(Kt){0===_r&&0===Le.length&&Pt(Ye),Kt&&Le.push(Kt)}function Ye(){if(!Ne){for(Ne=!0;Le.length;){const Kt=Le;Le=[];for(let rt=0;rtAn,onUnhandledError:Rn,microtaskDrainDone:Rn,scheduleMicroTask:dt,showUncaughtError:()=>!je[Ae("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:Rn,patchMethod:()=>Rn,bindArguments:()=>[],patchThen:()=>Rn,patchMacroTask:()=>Rn,patchEventPrototype:()=>Rn,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>Rn,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>Rn,wrapWithCurrentZone:()=>Rn,filterProperties:()=>[],attachOriginToPatched:()=>Rn,_redefineProperty:()=>Rn,patchCallbacks:()=>Rn,nativeScheduleMicroTask:Pt};let An={parent:null,zone:new je(null,null)},Vr=null,_r=0;function Rn(){}ye("Zone","Zone"),ie.Zone=je}(typeof window<"u"&&window||typeof self<"u"&&self||global);const q=Object.getOwnPropertyDescriptor,V=Object.defineProperty,x=Object.getPrototypeOf,y=Object.create,u=Array.prototype.slice,g="addEventListener",w="removeEventListener",m=Zone.__symbol__(g),h=Zone.__symbol__(w),c="true",f="false",d=Zone.__symbol__("");function b(ie,le){return Zone.current.wrap(ie,le)}function I(ie,le,ge,ye,we){return Zone.current.scheduleMacroTask(ie,le,ge,ye,we)}const E=Zone.__symbol__,v=typeof window<"u",p=v?window:void 0,D=v&&p||"object"==typeof self&&self||global;function P(ie,le){for(let ge=ie.length-1;ge>=0;ge--)"function"==typeof ie[ge]&&(ie[ge]=b(ie[ge],le+"_"+ge));return ie}function T(ie){return!ie||!1!==ie.writable&&!("function"==typeof ie.get&&typeof ie.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,k=!("nw"in D)&&typeof D.process<"u"&&"[object process]"==={}.toString.call(D.process),F=!k&&!M&&!(!v||!p.HTMLElement),j=typeof D.process<"u"&&"[object process]"==={}.toString.call(D.process)&&!M&&!(!v||!p.HTMLElement),C={},O=function(ie){if(!(ie=ie||D.event))return;let le=C[ie.type];le||(le=C[ie.type]=E("ON_PROPERTY"+ie.type));const ge=this||ie.target||D,ye=ge[le];let we;if(F&&ge===p&&"error"===ie.type){const Ae=ie;we=ye&&ye.call(this,Ae.message,Ae.filename,Ae.lineno,Ae.colno,Ae.error),!0===we&&ie.preventDefault()}else we=ye&&ye.apply(this,arguments),null!=we&&!we&&ie.preventDefault();return we};function H(ie,le,ge){let ye=q(ie,le);if(!ye&&ge&&q(ge,le)&&(ye={enumerable:!0,configurable:!0}),!ye||!ye.configurable)return;const we=E("on"+le+"patched");if(ie.hasOwnProperty(we)&&ie[we])return;delete ye.writable,delete ye.value;const Ae=ye.get,ze=ye.set,je=le.slice(2);let et=C[je];et||(et=C[je]=E("ON_PROPERTY"+je)),ye.set=function(Je){let Fe=this;!Fe&&ie===D&&(Fe=D),Fe&&("function"==typeof Fe[et]&&Fe.removeEventListener(je,O),ze&&ze.call(Fe,null),Fe[et]=Je,"function"==typeof Je&&Fe.addEventListener(je,O,!1))},ye.get=function(){let Je=this;if(!Je&&ie===D&&(Je=D),!Je)return null;const Fe=Je[et];if(Fe)return Fe;if(Ae){let Ee=Ae.call(this);if(Ee)return ye.set.call(this,Ee),"function"==typeof Je.removeAttribute&&Je.removeAttribute(le),Ee}return null},V(ie,le,ye),ie[we]=!0}function L(ie,le,ge){if(le)for(let ye=0;yefunction(ze,je){const et=ge(ze,je);return et.cbIdx>=0&&"function"==typeof je[et.cbIdx]?I(et.name,je[et.cbIdx],et,we):Ae.apply(ze,je)})}function Z(ie,le){ie[E("OriginalDelegate")]=le}let W=!1,te=!1;function de(){if(W)return te;W=!0;try{const ie=p.navigator.userAgent;(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/")||-1!==ie.indexOf("Edge/"))&&(te=!0)}catch{}return te}Zone.__load_patch("ZoneAwarePromise",(ie,le,ge)=>{const ye=Object.getOwnPropertyDescriptor,we=Object.defineProperty,ze=ge.symbol,je=[],et=!0===ie[ze("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],Je=ze("Promise"),Fe=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 Pt=ze("state"),dt=ze("value"),Ye=ze("finally"),Vn=ze("parentPromiseValue"),Ht=ze("parentPromiseState"),on=null,En=!1;function Gt(Ve,Ge){return Ce=>{try{Wn(Ve,Ge,Ce)}catch(Ke){Wn(Ve,!1,Ke)}}}const bt=function(){let Ve=!1;return function(Ce){return function(){Ve||(Ve=!0,Ce.apply(null,arguments))}}},wi=ze("currentTaskTrace");function Wn(Ve,Ge,Ce){const Ke=bt();if(Ve===Ce)throw new TypeError("Promise resolved with itself");if(Ve[Pt]===on){let ct=null;try{("object"==typeof Ce||"function"==typeof Ce)&&(ct=Ce&&Ce.then)}catch(pt){return Ke(()=>{Wn(Ve,!1,pt)})(),Ve}if(Ge!==En&&Ce instanceof ce&&Ce.hasOwnProperty(Pt)&&Ce.hasOwnProperty(dt)&&Ce[Pt]!==on)Vr(Ce),Wn(Ve,Ce[Pt],Ce[dt]);else if(Ge!==En&&"function"==typeof ct)try{ct.call(Ce,Ke(Gt(Ve,Ge)),Ke(Gt(Ve,!1)))}catch(pt){Ke(()=>{Wn(Ve,!1,pt)})()}else{Ve[Pt]=Ge;const pt=Ve[dt];if(Ve[dt]=Ce,Ve[Ye]===Ye&&!0===Ge&&(Ve[Pt]=Ve[Ht],Ve[dt]=Ve[Vn]),Ge===En&&Ce instanceof Error){const it=le.currentTask&&le.currentTask.data&&le.currentTask.data.__creationTrace__;it&&we(Ce,wi,{configurable:!0,enumerable:!1,writable:!0,value:it})}for(let it=0;it{try{const gt=Ve[dt],Nt=!!Ce&&Ye===Ce[Ye];Nt&&(Ce[Vn]=gt,Ce[Ht]=pt);const Dt=Ge.run(it,void 0,Nt&&it!==at&&it!==Ne?[]:[gt]);Wn(Ce,!0,Dt)}catch(gt){Wn(Ce,!1,gt)}},Ce)}const Kt=function(){},rt=ie.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Ge){return Wn(new this(null),!0,Ge)}static reject(Ge){return Wn(new this(null),En,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 pt=[];return new ce((it,gt)=>{for(let Nt=0;Nt{ct||(ct=!0,it(Dt))},Dt=>{pt.push(Dt),Ke--,0===Ke&&(ct=!0,gt(new rt(pt,"All promises were rejected")))})})}static race(Ge){let Ce,Ke,ct=new this((gt,Nt)=>{Ce=gt,Ke=Nt});function pt(gt){Ce(gt)}function it(gt){Ke(gt)}for(let gt of Ge)Le(gt)||(gt=this.resolve(gt)),gt.then(pt,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,pt=new this((Dt,gn)=>{Ke=Dt,ct=gn}),it=2,gt=0;const Nt=[];for(let Dt of Ge){Le(Dt)||(Dt=this.resolve(Dt));const gn=gt;try{Dt.then(fn=>{Nt[gn]=Ce?Ce.thenCallback(fn):fn,it--,0===it&&Ke(Nt)},fn=>{Ce?(Nt[gn]=Ce.errorCallback(fn),it--,0===it&&Ke(Nt)):ct(fn)})}catch(fn){ct(fn)}it++,gt++}return it-=2,0===it&&Ke(Nt),pt}constructor(Ge){const Ce=this;if(!(Ce instanceof ce))throw new Error("Must be an instanceof Promise.");Ce[Pt]=on,Ce[dt]=[];try{const Ke=bt();Ge&&Ge(Ke(Gt(Ce,!0)),Ke(Gt(Ce,En)))}catch(Ke){Wn(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 pt=new ct(Kt),it=le.current;return this[Pt]==on?this[dt].push(it,pt,Ge,Ce):_r(this,it,pt,Ge,Ce),pt}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(Kt);ct[Ye]=Ye;const pt=le.current;return this[Pt]==on?this[dt].push(pt,ct,Ge,Ge):_r(this,pt,ct,Ge,Ge),ct}}ce.resolve=ce.resolve,ce.reject=ce.reject,ce.race=ce.race,ce.all=ce.all;const me=ie[Je]=ie.Promise;ie.Promise=ce;const ft=ze("thenPatched");function St(Ve){const Ge=Ve.prototype,Ce=ye(Ge,"then");if(Ce&&(!1===Ce.writable||!Ce.configurable))return;const Ke=Ge.then;Ge[Fe]=Ke,Ve.prototype.then=function(ct,pt){return new ce((gt,Nt)=>{Ke.call(this,gt,Nt)}).then(ct,pt)},Ve[ft]=!0}return ge.patchThen=St,me&&(St(me),G(ie,"fetch",Ve=>function In(Ve){return function(Ge,Ce){let Ke=Ve.apply(Ge,Ce);if(Ke instanceof ce)return Ke;let ct=Ke.constructor;return ct[ft]||St(ct),Ke}}(Ve))),Promise[le.__symbol__("uncaughtPromiseErrors")]=je,ce}),Zone.__load_patch("toString",ie=>{const le=Function.prototype.toString,ge=E("OriginalDelegate"),ye=E("Promise"),we=E("Error"),Ae=function(){if("function"==typeof this){const Je=this[ge];if(Je)return"function"==typeof Je?le.call(Je):Object.prototype.toString.call(Je);if(this===Promise){const Fe=ie[ye];if(Fe)return le.call(Fe)}if(this===Error){const Fe=ie[we];if(Fe)return le.call(Fe)}}return le.call(this)};Ae[ge]=le,Function.prototype.toString=Ae;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 ie=Object.defineProperty({},"passive",{get:function(){he=!0}});window.addEventListener("test",ie,ie),window.removeEventListener("test",ie,ie)}catch{he=!1}const Pe={useG:!0},Se={},Be={},ve=new RegExp("^"+d+"(\\w+)(true|false)$"),He=E("propagationStopped");function ke(ie,le){const ge=(le?le(ie):ie)+f,ye=(le?le(ie):ie)+c,we=d+ge,Ae=d+ye;Se[ie]={},Se[ie][f]=we,Se[ie][c]=Ae}function nt(ie,le,ge,ye){const we=ye&&ye.add||g,Ae=ye&&ye.rm||w,ze=ye&&ye.listeners||"eventListeners",je=ye&&ye.rmAll||"removeAllListeners",et=E(we),Je="."+we+":",pe=function(dt,Ye,Vn){if(dt.isRemoved)return;const Ht=dt.callback;let Sn;"object"==typeof Ht&&Ht.handleEvent&&(dt.callback=ot=>Ht.handleEvent(ot),dt.originalDelegate=Ht);try{dt.invoke(dt,Ye,[Vn])}catch(ot){Sn=ot}const on=dt.options;return on&&"object"==typeof on&&on.once&&Ye[Ae].call(Ye,Vn.type,dt.originalDelegate?dt.originalDelegate:dt.callback,on),Sn};function _e(dt,Ye,Vn){if(!(Ye=Ye||ie.event))return;const Ht=dt||Ye.target||ie,Sn=Ht[Se[Ye.type][Vn?c:f]];if(Sn){const on=[];if(1===Sn.length){const ot=pe(Sn[0],Ht,Ye);ot&&on.push(ot)}else{const ot=Sn.slice();for(let En=0;En{throw En})}}}const Le=function(dt){return _e(this,dt,!1)},Ne=function(dt){return _e(this,dt,!0)};function at(dt,Ye){if(!dt)return!1;let Vn=!0;Ye&&void 0!==Ye.useG&&(Vn=Ye.useG);const Ht=Ye&&Ye.vh;let Sn=!0;Ye&&void 0!==Ye.chkDup&&(Sn=Ye.chkDup);let on=!1;Ye&&void 0!==Ye.rt&&(on=Ye.rt);let ot=dt;for(;ot&&!ot.hasOwnProperty(we);)ot=x(ot);if(!ot&&dt[we]&&(ot=dt),!ot||ot[et])return!1;const En=Ye&&Ye.eventNameToString,tt={},Gt=ot[et]=ot[we],bt=ot[E(Ae)]=ot[Ae],Rr=ot[E(ze)]=ot[ze],wi=ot[E(je)]=ot[je];let Wn;function An(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}Ye&&Ye.prepend&&(Wn=ot[E(Ye.prepend)]=ot[Ye.prepend]);const ce=Vn?function(Ce){if(!tt.isExisting)return Gt.call(tt.target,tt.eventName,tt.capture?Ne:Le,tt.options)}:function(Ce){return Gt.call(tt.target,tt.eventName,Ce.invoke,tt.options)},me=Vn?function(Ce){if(!Ce.isRemoved){const Ke=Se[Ce.eventName];let ct;Ke&&(ct=Ke[Ce.capture?c:f]);const pt=ct&&Ce.target[ct];if(pt)for(let it=0;itfunction(we,Ae){we[He]=!0,ye&&ye.apply(we,Ae)})}function Bt(ie,le,ge,ye,we){const Ae=Zone.__symbol__(ye);if(le[Ae])return;const ze=le[Ae]=le[ye];le[ye]=function(je,et,Je){return et&&et.prototype&&we.forEach(function(Fe){const Ee=`${ge}.${ye}::`+Fe,pe=et.prototype;try{if(pe.hasOwnProperty(Fe)){const _e=ie.ObjectGetOwnPropertyDescriptor(pe,Fe);_e&&_e.value?(_e.value=ie.wrapWithCurrentZone(_e.value,Ee),ie._redefineProperty(et.prototype,Fe,_e)):pe[Fe]&&(pe[Fe]=ie.wrapWithCurrentZone(pe[Fe],Ee))}else pe[Fe]&&(pe[Fe]=ie.wrapWithCurrentZone(pe[Fe],Ee))}catch{}}),ze.call(le,je,et,Je)},ie.attachOriginToPatched(le[ye],ze)}function qt(ie,le,ge){if(!ge||0===ge.length)return le;const ye=ge.filter(Ae=>Ae.target===ie);if(!ye||0===ye.length)return le;const we=ye[0].ignoreProperties;return le.filter(Ae=>-1===we.indexOf(Ae))}function en(ie,le,ge,ye){ie&&L(ie,qt(ie,le,ge),ye)}function sn(ie){return Object.getOwnPropertyNames(ie).filter(le=>le.startsWith("on")&&le.length>2).map(le=>le.substring(2))}Zone.__load_patch("util",(ie,le,ge)=>{const ye=sn(ie);ge.patchOnProperties=L,ge.patchMethod=G,ge.bindArguments=P,ge.patchMacroTask=ee;const we=le.__symbol__("BLACK_LISTED_EVENTS"),Ae=le.__symbol__("UNPATCHED_EVENTS");ie[Ae]&&(ie[we]=ie[Ae]),ie[we]&&(le[we]=le[Ae]=ie[we]),ge.patchEventPrototype=_t,ge.patchEventTarget=nt,ge.isIEOrEdge=de,ge.ObjectDefineProperty=V,ge.ObjectGetOwnPropertyDescriptor=q,ge.ObjectCreate=y,ge.ArraySlice=u,ge.patchClass=ne,ge.wrapWithCurrentZone=b,ge.filterProperties=qt,ge.attachOriginToPatched=Z,ge._redefineProperty=Object.defineProperty,ge.patchCallbacks=Bt,ge.getGlobalObjects=()=>({globalSources:Be,zoneSymbolEventNames:Se,eventNames:ye,isBrowser:F,isMix:j,isNode:k,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:w})});const Ar=E("zoneTask");function vn(ie,le,ge,ye){let we=null,Ae=null;ge+=ye;const ze={};function je(Je){const Fe=Je.data;return Fe.args[0]=function(){return Je.invoke.apply(this,arguments)},Fe.handleId=we.apply(ie,Fe.args),Je}function et(Je){return Ae.call(ie,Je.data.handleId)}we=G(ie,le+=ye,Je=>function(Fe,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[Ar]=null))}};const Le=I(le,Ee[0],pe,je,et);if(!Le)return Le;const Ne=Le.data.handleId;return"number"==typeof Ne?ze[Ne]=Le:Ne&&(Ne[Ar]=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 Je.apply(ie,Ee)}),Ae=G(ie,ge,Je=>function(Fe,Ee){const pe=Ee[0];let _e;"number"==typeof pe?_e=ze[pe]:(_e=pe&&pe[Ar],_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[Ar]=null),_e.zone.cancelTask(_e)):Je.apply(ie,Ee)})}Zone.__load_patch("legacy",ie=>{const le=ie[Zone.__symbol__("legacyPatch")];le&&le()}),Zone.__load_patch("queueMicrotask",(ie,le,ge)=>{ge.patchMethod(ie,"queueMicrotask",ye=>function(we,Ae){le.current.scheduleMicroTask("queueMicrotask",Ae[0])})}),Zone.__load_patch("timers",ie=>{const ge="clear";vn(ie,"set",ge,"Timeout"),vn(ie,"set",ge,"Interval"),vn(ie,"set",ge,"Immediate")}),Zone.__load_patch("requestAnimationFrame",ie=>{vn(ie,"request","cancel","AnimationFrame"),vn(ie,"mozRequest","mozCancel","AnimationFrame"),vn(ie,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(ie,le)=>{const ge=["alert","prompt","confirm"];for(let ye=0;yefunction(et,Je){return le.current.run(Ae,ie,Je,je)})}),Zone.__load_patch("EventTarget",(ie,le,ge)=>{(function ns(ie,le){le.patchEventPrototype(ie,le)})(ie,ge),function Qr(ie,le){if(Zone[le.symbol("patchEventTarget")])return;const{eventNames:ge,zoneSymbolEventNames:ye,TRUE_STR:we,FALSE_STR:Ae,ZONE_SYMBOL_PREFIX:ze}=le.getGlobalObjects();for(let et=0;et{ne("MutationObserver"),ne("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(ie,le,ge)=>{ne("IntersectionObserver")}),Zone.__load_patch("FileReader",(ie,le,ge)=>{ne("FileReader")}),Zone.__load_patch("on_property",(ie,le,ge)=>{!function Un(ie,le){if(k&&!j||Zone[ie.symbol("patchEvents")])return;const ge=le.__Zone_ignore_on_properties;let ye=[];if(F){const we=window;ye=ye.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);const Ae=function oe(){try{const ie=p.navigator.userAgent;if(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/"))return!0}catch{}return!1}()?[{target:we,ignoreProperties:["error"]}]:[];en(we,sn(we),ge&&ge.concat(Ae),x(we))}ye=ye.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let we=0;we{!function Li(ie,le){const{isBrowser:ge,isMix:ye}=le.getGlobalObjects();(ge||ye)&&ie.customElements&&"customElements"in ie&&le.patchCallbacks(le,ie.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(ie,ge)}),Zone.__load_patch("XHR",(ie,le)=>{!function et(Je){const Fe=Je.XMLHttpRequest;if(!Fe)return;const Ee=Fe.prototype;let _e=Ee[m],Le=Ee[h];if(!_e){const tt=Je.XMLHttpRequestEventTarget;if(tt){const Gt=tt.prototype;_e=Gt[m],Le=Gt[h]}}const Ne="readystatechange",at="scheduled";function Pt(tt){const Gt=tt.data,bt=Gt.target;bt[Ae]=!1,bt[je]=!1;const Rr=bt[we];_e||(_e=bt[m],Le=bt[h]),Rr&&Le.call(bt,Ne,Rr);const wi=bt[we]=()=>{if(bt.readyState===bt.DONE)if(!Gt.aborted&&bt[Ae]&&tt.state===at){const An=bt[le.__symbol__("loadfalse")];if(0!==bt.status&&An&&An.length>0){const Vr=tt.invoke;tt.invoke=function(){const _r=bt[le.__symbol__("loadfalse")];for(let Rn=0;Rn<_r.length;Rn++)_r[Rn]===tt&&_r.splice(Rn,1);!Gt.aborted&&tt.state===at&&Vr.call(tt)},An.push(tt)}else tt.invoke()}else!Gt.aborted&&!1===bt[Ae]&&(bt[je]=!0)};return _e.call(bt,Ne,wi),bt[ge]||(bt[ge]=tt),ot.apply(bt,Gt.args),bt[Ae]=!0,tt}function dt(){}function Ye(tt){const Gt=tt.data;return Gt.aborted=!0,En.apply(Gt.target,Gt.args)}const Vn=G(Ee,"open",()=>function(tt,Gt){return tt[ye]=0==Gt[2],tt[ze]=Gt[1],Vn.apply(tt,Gt)}),Sn=E("fetchTaskAborting"),on=E("fetchTaskScheduling"),ot=G(Ee,"send",()=>function(tt,Gt){if(!0===le.current[on]||tt[ye])return ot.apply(tt,Gt);{const bt={target:tt,url:tt[ze],isPeriodic:!1,args:Gt,aborted:!1},Rr=I("XMLHttpRequest.send",dt,bt,Pt,Ye);tt&&!0===tt[je]&&!bt.aborted&&Rr.state===at&&Rr.invoke()}}),En=G(Ee,"abort",()=>function(tt,Gt){const bt=function pe(tt){return tt[ge]}(tt);if(bt&&"string"==typeof bt.type){if(null==bt.cancelFn||bt.data&&bt.data.aborted)return;bt.zone.cancelTask(bt)}else if(!0===le.current[Sn])return En.apply(tt,Gt)})}(ie);const ge=E("xhrTask"),ye=E("xhrSync"),we=E("xhrListener"),Ae=E("xhrScheduled"),ze=E("xhrURL"),je=E("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",ie=>{ie.navigator&&ie.navigator.geolocation&&function S(ie,le){const ge=ie.constructor.name;for(let ye=0;ye{const et=function(){return je.apply(this,P(arguments,ge+"."+we))};return Z(et,je),et})(Ae)}}}(ie.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(ie,le)=>{function ge(ye){return function(we){Rt(ie,ye).forEach(ze=>{const je=ie.PromiseRejectionEvent;if(je){const et=new je(ye,{promise:we.promise,reason:we.rejection});ze.invoke(et)}})}}ie.PromiseRejectionEvent&&(le[E("unhandledPromiseRejectionHandler")]=ge("unhandledrejection"),le[E("rejectionHandledHandler")]=ge("rejectionhandled"))})},9572:()=>{},4490:()=>{},985:()=>{},9437:()=>{},5238:()=>{},9580:()=>{},160:function(q,V,x){var u,g;u=[x(7596)],void 0!==(g=function(w){"use strict";var m=w.Reader,h=w.Writer,c=w.util,f=w.roots.default||(w.roots.default={});return f.RPC=function(){function d(I){if(this.subscriptions=[],this.messages=[],I)for(var E=Object.keys(I),v=0;v>>3){case 1:D.subscriptions&&D.subscriptions.length||(D.subscriptions=[]),D.subscriptions.push(f.RPC.SubOpts.decode(E,E.uint32()));break;case 2:D.messages&&D.messages.length||(D.messages=[]),D.messages.push(f.RPC.Message.decode(E,E.uint32()));break;case 3:D.control=f.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return D},d.fromObject=function(E){if(E instanceof f.RPC)return E;var v=new f.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");v.subscriptions=[];for(var p=0;p>>3){case 1:P.subscribe=p.bool();break;case 2:P.topic=p.string();break;default:p.skipType(7&S)}}return P},I.fromObject=function(p){if(p instanceof f.RPC.SubOpts)return p;var D=new f.RPC.SubOpts;return null!=p.subscribe&&(D.subscribe=Boolean(p.subscribe)),null!=p.topic&&(D.topic=String(p.topic)),D},I.toObject=function(p,D){D||(D={});var A={};return null!=p.subscribe&&p.hasOwnProperty("subscribe")&&(A.subscribe=p.subscribe,D.oneofs&&(A._subscribe="subscribe")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic,D.oneofs&&(A._topic="topic")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},I}(),d.Message=function(){function I(v){if(v)for(var p=Object.keys(v),D=0;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&S)}}if(!P.hasOwnProperty("topic"))throw c.ProtocolError("missing required 'topic'",{instance:P});return P},I.fromObject=function(p){if(p instanceof f.RPC.Message)return p;var D=new f.RPC.Message;return null!=p.from&&("string"==typeof p.from?c.base64.decode(p.from,D.from=c.newBuffer(c.base64.length(p.from)),0):p.from.length&&(D.from=p.from)),null!=p.data&&("string"==typeof p.data?c.base64.decode(p.data,D.data=c.newBuffer(c.base64.length(p.data)),0):p.data.length&&(D.data=p.data)),null!=p.seqno&&("string"==typeof p.seqno?c.base64.decode(p.seqno,D.seqno=c.newBuffer(c.base64.length(p.seqno)),0):p.seqno.length&&(D.seqno=p.seqno)),null!=p.topic&&(D.topic=String(p.topic)),null!=p.signature&&("string"==typeof p.signature?c.base64.decode(p.signature,D.signature=c.newBuffer(c.base64.length(p.signature)),0):p.signature.length&&(D.signature=p.signature)),null!=p.key&&("string"==typeof p.key?c.base64.decode(p.key,D.key=c.newBuffer(c.base64.length(p.key)),0):p.key.length&&(D.key=p.key)),D},I.toObject=function(p,D){D||(D={});var A={};return D.defaults&&(A.topic=""),null!=p.from&&p.hasOwnProperty("from")&&(A.from=D.bytes===String?c.base64.encode(p.from,0,p.from.length):D.bytes===Array?Array.prototype.slice.call(p.from):p.from,D.oneofs&&(A._from="from")),null!=p.data&&p.hasOwnProperty("data")&&(A.data=D.bytes===String?c.base64.encode(p.data,0,p.data.length):D.bytes===Array?Array.prototype.slice.call(p.data):p.data,D.oneofs&&(A._data="data")),null!=p.seqno&&p.hasOwnProperty("seqno")&&(A.seqno=D.bytes===String?c.base64.encode(p.seqno,0,p.seqno.length):D.bytes===Array?Array.prototype.slice.call(p.seqno):p.seqno,D.oneofs&&(A._seqno="seqno")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic),null!=p.signature&&p.hasOwnProperty("signature")&&(A.signature=D.bytes===String?c.base64.encode(p.signature,0,p.signature.length):D.bytes===Array?Array.prototype.slice.call(p.signature):p.signature,D.oneofs&&(A._signature="signature")),null!=p.key&&p.hasOwnProperty("key")&&(A.key=D.bytes===String?c.base64.encode(p.key,0,p.key.length):D.bytes===Array?Array.prototype.slice.call(p.key):p.key,D.oneofs&&(A._key="key")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},I}(),d.ControlMessage=function(){function I(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var v=Object.keys(E),p=0;p>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(f.RPC.ControlIHave.decode(v,v.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(f.RPC.ControlIWant.decode(v,v.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(f.RPC.ControlGraft.decode(v,v.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(f.RPC.ControlPrune.decode(v,v.uint32()));break;default:v.skipType(7&P)}}return A},I.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 D=0;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&S)}}return P},I.fromObject=function(p){if(p instanceof f.RPC.ControlIHave)return p;var D=new f.RPC.ControlIHave;if(null!=p.topicID&&(D.topicID=String(p.topicID)),p.messageIDs){if(!Array.isArray(p.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");D.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(v.bytes())):v.skipType(7&P)}return A},I.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 D=0;D>>3==1?P.topicID=p.string():p.skipType(7&S)}return P},I.fromObject=function(p){if(p instanceof f.RPC.ControlGraft)return p;var D=new f.RPC.ControlGraft;return null!=p.topicID&&(D.topicID=String(p.topicID)),D},I.toObject=function(p,D){D||(D={});var A={};return null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,D.oneofs&&(A._topicID="topicID")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},I}(),d.ControlPrune=function(){function I(v){if(this.peers=[],v)for(var p=Object.keys(v),D=0;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&S)}}return P},I.fromObject=function(p){if(p instanceof f.RPC.ControlPrune)return p;var D=new f.RPC.ControlPrune;if(null!=p.topicID&&(D.topicID=String(p.topicID)),p.peers){if(!Array.isArray(p.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");D.peers=[];for(var A=0;A>>0,p.backoff.high>>>0).toNumber(!0))),D},I.toObject=function(p,D){D||(D={});var A={};if((D.arrays||D.defaults)&&(A.peers=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,D.oneofs&&(A._topicID="topicID")),p.peers&&p.peers.length){A.peers=[];for(var P=0;P>>0,p.backoff.high>>>0).toNumber(!0):p.backoff,D.oneofs&&(A._backoff="backoff")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},I}(),d.PeerInfo=function(){function I(v){if(v)for(var p=Object.keys(v),D=0;D>>3){case 1:P.peerID=p.bytes();break;case 2:P.signedPeerRecord=p.bytes();break;default:p.skipType(7&S)}}return P},I.fromObject=function(p){if(p instanceof f.RPC.PeerInfo)return p;var D=new f.RPC.PeerInfo;return null!=p.peerID&&("string"==typeof p.peerID?c.base64.decode(p.peerID,D.peerID=c.newBuffer(c.base64.length(p.peerID)),0):p.peerID.length&&(D.peerID=p.peerID)),null!=p.signedPeerRecord&&("string"==typeof p.signedPeerRecord?c.base64.decode(p.signedPeerRecord,D.signedPeerRecord=c.newBuffer(c.base64.length(p.signedPeerRecord)),0):p.signedPeerRecord.length&&(D.signedPeerRecord=p.signedPeerRecord)),D},I.toObject=function(p,D){D||(D={});var A={};return null!=p.peerID&&p.hasOwnProperty("peerID")&&(A.peerID=D.bytes===String?c.base64.encode(p.peerID,0,p.peerID.length):D.bytes===Array?Array.prototype.slice.call(p.peerID):p.peerID,D.oneofs&&(A._peerID="peerID")),null!=p.signedPeerRecord&&p.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=D.bytes===String?c.base64.encode(p.signedPeerRecord,0,p.signedPeerRecord.length):D.bytes===Array?Array.prototype.slice.call(p.signedPeerRecord):p.signedPeerRecord,D.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},I.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},I}(),d}(),f}.apply(V,u))&&(q.exports=g)},7395:(q,V,x)=>{var y=x(6865);function u(g){var w,m;function c(d,b){try{var I=g[d](b),E=I.value,v=E instanceof y;Promise.resolve(v?E.wrapped:E).then(function(p){v?c("return"===d?"return":"next",p):f(I.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(I,E){var v={key:d,arg:b,resolve:I,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 V(x){this.wrapped=x},q.exports.__esModule=!0,q.exports.default=q.exports},4670:q=>{q.exports=function V(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 V(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 V(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){V(h,w,m,c,f,"next",d)}function f(d){V(h,w,m,c,f,"throw",d)}c(void 0)})}},q.exports.__esModule=!0,q.exports.default=q.exports},2449:(q,V,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,V,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=1882)}]);