libp2p 0.35.8-bf1fc32 → 0.35.8-d8ceb0b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2p = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- var Libp2p=(()=>{var EC=Object.create;var ka=Object.defineProperty;var wC=Object.getOwnPropertyDescriptor;var _C=Object.getOwnPropertyNames;var xC=Object.getPrototypeOf,SC=Object.prototype.hasOwnProperty;var Zd=t=>ka(t,"__esModule",{value:!0});var Jd=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var _e=(t,e)=>()=>(t&&(e=t(t=0)),e);var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),yt=(t,e)=>{Zd(t);for(var r in e)ka(t,r,{get:e[r],enumerable:!0})},AC=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of _C(e))!SC.call(t,n)&&n!=="default"&&ka(t,n,{get:()=>e[n],enumerable:!(r=wC(e,n))||r.enumerable});return t},_o=t=>AC(Zd(ka(t!=null?EC(xC(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Xu=w((f5,e0)=>{var cs=1e3,us=cs*60,ls=us*60,yi=ls*24,CC=yi*7,IC=yi*365.25;e0.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return TC(t);if(r==="number"&&isFinite(t))return e.long?BC(t):RC(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function TC(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!!e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*IC;case"weeks":case"week":case"w":return r*CC;case"days":case"day":case"d":return r*yi;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ls;case"minutes":case"minute":case"mins":case"min":case"m":return r*us;case"seconds":case"second":case"secs":case"sec":case"s":return r*cs;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function RC(t){var e=Math.abs(t);return e>=yi?Math.round(t/yi)+"d":e>=ls?Math.round(t/ls)+"h":e>=us?Math.round(t/us)+"m":e>=cs?Math.round(t/cs)+"s":t+"ms"}function BC(t){var e=Math.abs(t);return e>=yi?qa(t,e,yi,"day"):e>=ls?qa(t,e,ls,"hour"):e>=us?qa(t,e,us,"minute"):e>=cs?qa(t,e,cs,"second"):t+" ms"}function qa(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var r0=w((h5,t0)=>{function PC(t){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=i,r.enabled=o,r.humanize=Xu(),r.destroy=u,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let f=0;for(let h=0;h<l.length;h++)f=(f<<5)-f+l.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(l){let f,h=null,p,d;function g(...m){if(!g.enabled)return;let x=g,B=Number(new Date),L=B-(f||B);x.diff=L,x.prev=f,x.curr=B,f=B,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let H=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(q,re)=>{if(q==="%%")return"%";H++;let se=r.formatters[re];if(typeof se=="function"){let j=m[H];q=se.call(x,j),m.splice(H,1),H--}return q}),r.formatArgs.call(x,m),(x.log||r.log).apply(x,m)}return g.namespace=l,g.useColors=r.useColors(),g.color=r.selectColor(l),g.extend=n,g.destroy=r.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(p!==r.namespaces&&(p=r.namespaces,d=r.enabled(l)),d),set:m=>{h=m}}),typeof r.init=="function"&&r.init(g),g}function n(l,f){let h=r(this.namespace+(typeof f=="undefined"?":":f)+l);return h.log=this.log,h}function i(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let f,h=(typeof l=="string"?l:"").split(/[\s,]+/),p=h.length;for(f=0;f<p;f++)!h[f]||(l=h[f].replace(/\*/g,".*?"),l[0]==="-"?r.skips.push(new RegExp("^"+l.substr(1)+"$")):r.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(l))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function c(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}t0.exports=PC});var Be=w((nr,Ua)=>{nr.formatArgs=OC;nr.save=DC;nr.load=LC;nr.useColors=NC;nr.storage=kC();nr.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();nr.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"];function NC(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function OC(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Ua.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(r++,i==="%c"&&(n=r))}),t.splice(n,0,e)}nr.log=console.debug||console.log||(()=>{});function DC(t){try{t?nr.storage.setItem("debug",t):nr.storage.removeItem("debug")}catch(e){}}function LC(){let t;try{t=nr.storage.getItem("debug")}catch(e){}return!t&&typeof process!="undefined"&&"env"in process&&(t=process.env.DEBUG),t}function kC(){try{return localStorage}catch(t){}}Ua.exports=r0()(nr);var{formatters:qC}=Ua.exports;qC.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Qt=w((d5,Zu)=>{"use strict";var fs=typeof Reflect=="object"?Reflect:null,n0=fs&&typeof fs.apply=="function"?fs.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},Ma;fs&&typeof fs.ownKeys=="function"?Ma=fs.ownKeys:Object.getOwnPropertySymbols?Ma=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Ma=function(e){return Object.getOwnPropertyNames(e)};function UC(t){console&&console.warn&&console.warn(t)}var i0=Number.isNaN||function(e){return e!==e};function Me(){Me.init.call(this)}Zu.exports=Me;Zu.exports.once=VC;Me.EventEmitter=Me;Me.prototype._events=void 0;Me.prototype._eventsCount=0;Me.prototype._maxListeners=void 0;var s0=10;function Fa(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Me,"defaultMaxListeners",{enumerable:!0,get:function(){return s0},set:function(t){if(typeof t!="number"||t<0||i0(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s0=t}});Me.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Me.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||i0(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function o0(t){return t._maxListeners===void 0?Me.defaultMaxListeners:t._maxListeners}Me.prototype.getMaxListeners=function(){return o0(this)};Me.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")n0(c,this,r);else for(var u=c.length,l=f0(c,u),n=0;n<u;++n)n0(l[n],this,r);return!0};function a0(t,e,r,n){var i,s,o;if(Fa(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=o0(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,UC(a)}return t}Me.prototype.addListener=function(e,r){return a0(this,e,r,!1)};Me.prototype.on=Me.prototype.addListener;Me.prototype.prependListener=function(e,r){return a0(this,e,r,!0)};function MC(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c0(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=MC.bind(n);return i.listener=r,n.wrapFn=i,i}Me.prototype.once=function(e,r){return Fa(r),this.on(e,c0(this,e,r)),this};Me.prototype.prependOnceListener=function(e,r){return Fa(r),this.prependListener(e,c0(this,e,r)),this};Me.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Fa(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount==0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():FC(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};Me.prototype.off=Me.prototype.removeListener;Me.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function u0(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?KC(i):f0(i,i.length)}Me.prototype.listeners=function(e){return u0(this,e,!0)};Me.prototype.rawListeners=function(e){return u0(this,e,!1)};Me.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):l0.call(t,e)};Me.prototype.listenerCount=l0;function l0(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Me.prototype.eventNames=function(){return this._eventsCount>0?Ma(this._events):[]};function f0(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function FC(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function KC(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function VC(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}h0(t,e,s,{once:!0}),e!=="error"&&jC(t,i,{once:!0})})}function jC(t,e,r){typeof t.on=="function"&&h0(t,"error",e,r)}function h0(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var pe=w((p5,p0)=>{"use strict";function d0(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function $C(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return d0(t,r)}catch(n){r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),d0(new i,r)}}p0.exports=$C});function g0(t,e,r){e=e||[],r=r||0;for(var n=r;t>=WC;)e[r++]=t&255|y0,t/=128;for(;t&GC;)e[r++]=t&255|y0,t>>>=7;return e[r]=t|0,g0.bytes=r-n+1,e}function Ju(t,e){var r=0,e=e||0,n=0,i=e,s,o=t.length;do{if(i>=o)throw Ju.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=n<28?(s&m0)<<n:(s&m0)*Math.pow(2,n),n+=7}while(s>=QC);return Ju.bytes=i-e,r}var HC,y0,zC,GC,WC,YC,QC,m0,XC,ZC,JC,eI,tI,rI,nI,iI,sI,oI,aI,cI,xo,v0=_e(()=>{HC=g0,y0=128,zC=127,GC=~zC,WC=Math.pow(2,31);YC=Ju,QC=128,m0=127;XC=Math.pow(2,7),ZC=Math.pow(2,14),JC=Math.pow(2,21),eI=Math.pow(2,28),tI=Math.pow(2,35),rI=Math.pow(2,42),nI=Math.pow(2,49),iI=Math.pow(2,56),sI=Math.pow(2,63),oI=function(t){return t<XC?1:t<ZC?2:t<JC?3:t<eI?4:t<tI?5:t<rI?6:t<nI?7:t<iI?8:t<sI?9:10},aI={encode:HC,decode:YC,encodingLength:oI},cI=aI,xo=cI});var So,hs,ds,Ka=_e(()=>{v0();So=t=>[xo.decode(t),xo.decode.bytes],hs=(t,e,r=0)=>(xo.encode(t,e,r),e),ds=t=>xo.encodingLength(t)});var m5,E0,hn,w0,_0,In=_e(()=>{m5=new Uint8Array(0),E0=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},hn=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},w0=t=>new TextEncoder().encode(t),_0=t=>new TextDecoder().decode(t)});var Ao={};yt(Ao,{Digest:()=>ps,create:()=>Tn,decode:()=>el,equals:()=>tl});var Tn,el,tl,ps,gi=_e(()=>{In();Ka();Tn=(t,e)=>{let r=e.byteLength,n=ds(t),i=n+ds(r),s=new Uint8Array(i+r);return hs(t,s,0),hs(r,s,n),s.set(e,i),new ps(t,r,e,s)},el=t=>{let e=hn(t),[r,n]=So(e),[i,s]=So(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new ps(r,i,o,e)},tl=(t,e)=>t===e?!0:t.code===e.code&&t.size===e.size&&E0(t.bytes,e.bytes),ps=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}});function uI(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var g=0,m=0,x=0,B=d.length;x!==B&&d[x]===0;)x++,g++;for(var L=(B-x)*l+1>>>0,H=new Uint8Array(L);x!==B;){for(var U=d[x],q=0,re=L-1;(U!==0||q<m)&&re!==-1;re--,q++)U+=256*H[re]>>>0,H[re]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");m=q,x++}for(var se=L-m;se!==L&&H[se]===0;)se++;for(var j=c.repeat(g);se<L;++se)j+=t.charAt(H[se]);return j}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var g=0;if(d[g]!==" "){for(var m=0,x=0;d[g]===c;)m++,g++;for(var B=(d.length-g)*u+1>>>0,L=new Uint8Array(B);d[g];){var H=r[d.charCodeAt(g)];if(H===255)return;for(var U=0,q=B-1;(H!==0||U<x)&&q!==-1;q--,U++)H+=a*L[q]>>>0,L[q]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");x=U,g++}if(d[g]!==" "){for(var re=B-x;re!==B&&L[re]===0;)re++;for(var se=new Uint8Array(m+(B-re)),j=m;re!==B;)se[j++]=L[re++];return se}}}function p(d){var g=h(d);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:p}}var lI,fI,S0,A0=_e(()=>{lI=uI,fI=lI,S0=fI});var C0,I0,T0,R0,B0,Va,Rn,hI,dI,at,Fr=_e(()=>{A0();In();C0=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},I0=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseDecode=n}decode(e){if(typeof e=="string")switch(e[0]){case this.prefix:return this.baseDecode(e.slice(1));default:throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)}else throw Error("Can only multibase decode strings")}or(e){return R0(this,e)}},T0=class{constructor(e){this.decoders=e}or(e){return R0(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},R0=(t,e)=>new T0({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),B0=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new C0(e,r,n),this.decoder=new I0(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Va=({name:t,prefix:e,encode:r,decode:n})=>new B0(t,e,r,n),Rn=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=S0(r,e);return Va({prefix:t,name:e,encode:n,decode:s=>hn(i(s))})},hI=(t,e,r,n)=>{let i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,u=0;for(let l=0;l<s;++l){let f=i[t[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},dI=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},at=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Va({prefix:e,name:t,encode(i){return dI(i,n,r)},decode(i){return hI(i,n,r,t)}})});var Bn={};yt(Bn,{base58btc:()=>Kr,base58flickr:()=>pI});var Kr,pI,Pn=_e(()=>{Fr();Kr=Rn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pI=Rn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});var mi={};yt(mi,{base32:()=>ys,base32hex:()=>vI,base32hexpad:()=>EI,base32hexpadupper:()=>wI,base32hexupper:()=>bI,base32pad:()=>gI,base32padupper:()=>mI,base32upper:()=>yI,base32z:()=>_I});var ys,yI,gI,mI,vI,bI,EI,wI,_I,vi=_e(()=>{Fr();ys=at({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yI=at({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gI=at({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mI=at({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vI=at({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bI=at({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),EI=at({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wI=at({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_I=at({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});var Io={};yt(Io,{CID:()=>vt});var vt,xI,SI,AI,Co,CI,P0,N0,ja,$a,II,TI,RI,gs=_e(()=>{Ka();gi();Pn();vi();In();vt=class{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:$a,byteLength:$a,code:ja,version:ja,multihash:ja,bytes:ja,_baseCache:$a,asCID:$a})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:r}=this;if(e!==Co)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==CI)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return vt.createV0(r)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Tn(e,r);return vt.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&tl(this.multihash,e.multihash)}toString(e){let{bytes:r,version:n,_baseCache:i}=this;switch(n){case 0:return SI(r,i,e||Kr.encoder);default:return AI(r,i,e||ys.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return TI(/^0\.0/,RI),!!(e&&(e[N0]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof vt)return e;if(e!=null&&e.asCID===e){let{version:r,code:n,multihash:i,bytes:s}=e;return new vt(r,n,i,s||P0(r,n,i.bytes))}else if(e!=null&&e[N0]===!0){let{version:r,multihash:n,code:i}=e,s=el(n);return vt.create(r,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(r!==Co)throw new Error(`Version 0 CID must use dag-pb (code: ${Co}) block encoding`);return new vt(e,r,n,n.bytes)}case 1:{let i=P0(e,r,n.bytes);return new vt(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return vt.create(0,Co,e)}static createV1(e,r){return vt.create(1,e,r)}static decode(e){let[r,n]=vt.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=vt.inspectBytes(e),n=r.size-r.multihashSize,i=hn(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=i.subarray(r.multihashSize-r.digestSize),o=new ps(r.multihashCode,r.digestSize,s,i);return[r.version===0?vt.createV0(o):vt.createV1(r.codec,o),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=So(e.subarray(r));return r+=h,f},i=n(),s=Co;if(i===18?(i=0,r=0):i===1&&(s=n()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=r,a=n(),c=n(),u=r+c,l=u-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,i]=xI(e,r),s=vt.decode(i);return s._baseCache.set(n,e),s}},xI=(t,e)=>{switch(t[0]){case"Q":{let r=e||Kr;return[Kr.prefix,r.decode(`${Kr.prefix}${t}`)]}case Kr.prefix:{let r=e||Kr;return[Kr.prefix,r.decode(t)]}case ys.prefix:{let r=e||ys;return[ys.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},SI=(t,e,r)=>{let{prefix:n}=r;if(n!==Kr.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return i},AI=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let s=r.encode(t);return e.set(n,s),s}else return i},Co=112,CI=18,P0=(t,e,r)=>{let n=ds(t),i=n+ds(e),s=new Uint8Array(i+r.byteLength);return hs(t,s,0),hs(e,s,n),s.set(r,i),s},N0=Symbol.for("@ipld/js-cid/CID"),ja={writable:!1,configurable:!1,enumerable:!0},$a={writable:!1,enumerable:!1,configurable:!1},II="0.0.0-dev",TI=(t,e)=>{if(t.test(II))console.warn(e);else throw new Error(e)},RI=`CID.isCID(v) is deprecated and will be removed in the next major release.
2
+ var Libp2p=(()=>{var QC=Object.create;var ja=Object.defineProperty;var XC=Object.getOwnPropertyDescriptor;var ZC=Object.getOwnPropertyNames;var JC=Object.getPrototypeOf,eI=Object.prototype.hasOwnProperty;var f0=t=>ja(t,"__esModule",{value:!0});var h0=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var xe=(t,e)=>()=>(t&&(e=t(t=0)),e);var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gt=(t,e)=>{f0(t);for(var r in e)ja(t,r,{get:e[r],enumerable:!0})},tI=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ZC(e))!eI.call(t,n)&&n!=="default"&&ja(t,n,{get:()=>e[n],enumerable:!(r=XC(e,n))||r.enumerable});return t},Ro=t=>tI(f0(ja(t!=null?QC(JC(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ll=w((W5,d0)=>{var ls=1e3,fs=ls*60,hs=fs*60,gi=hs*24,rI=gi*7,nI=gi*365.25;d0.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return iI(t);if(r==="number"&&isFinite(t))return e.long?oI(t):sI(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function iI(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(!!e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*nI;case"weeks":case"week":case"w":return r*rI;case"days":case"day":case"d":return r*gi;case"hours":case"hour":case"hrs":case"hr":case"h":return r*hs;case"minutes":case"minute":case"mins":case"min":case"m":return r*fs;case"seconds":case"second":case"secs":case"sec":case"s":return r*ls;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function sI(t){var e=Math.abs(t);return e>=gi?Math.round(t/gi)+"d":e>=hs?Math.round(t/hs)+"h":e>=fs?Math.round(t/fs)+"m":e>=ls?Math.round(t/ls)+"s":t+"ms"}function oI(t){var e=Math.abs(t);return e>=gi?$a(t,e,gi,"day"):e>=hs?$a(t,e,hs,"hour"):e>=fs?$a(t,e,fs,"minute"):e>=ls?$a(t,e,ls,"second"):t+" ms"}function $a(t,e,r,n){var i=e>=r*1.5;return Math.round(t/r)+" "+n+(i?"s":"")}});var y0=w((Y5,p0)=>{function aI(t){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=i,r.enabled=o,r.humanize=ll(),r.destroy=u,Object.keys(t).forEach(l=>{r[l]=t[l]}),r.names=[],r.skips=[],r.formatters={};function e(l){let f=0;for(let h=0;h<l.length;h++)f=(f<<5)-f+l.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(l){let f,h=null,p,d;function g(...m){if(!g.enabled)return;let x=g,R=Number(new Date),L=R-(f||R);x.diff=L,x.prev=f,x.curr=R,f=R,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let H=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(k,J)=>{if(k==="%%")return"%";H++;let ie=r.formatters[J];if(typeof ie=="function"){let j=m[H];k=ie.call(x,j),m.splice(H,1),H--}return k}),r.formatArgs.call(x,m),(x.log||r.log).apply(x,m)}return g.namespace=l,g.useColors=r.useColors(),g.color=r.selectColor(l),g.extend=n,g.destroy=r.destroy,Object.defineProperty(g,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(p!==r.namespaces&&(p=r.namespaces,d=r.enabled(l)),d),set:m=>{h=m}}),typeof r.init=="function"&&r.init(g),g}function n(l,f){let h=r(this.namespace+(typeof f=="undefined"?":":f)+l);return h.log=this.log,h}function i(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let f,h=(typeof l=="string"?l:"").split(/[\s,]+/),p=h.length;for(f=0;f<p;f++)!h[f]||(l=h[f].replace(/\*/g,".*?"),l[0]==="-"?r.skips.push(new RegExp("^"+l.substr(1)+"$")):r.names.push(new RegExp("^"+l+"$")))}function s(){let l=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),l}function o(l){if(l[l.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(l))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].test(l))return!0;return!1}function a(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function c(l){return l instanceof Error?l.stack||l.message:l}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}p0.exports=aI});var Te=w((rr,Ha)=>{rr.formatArgs=uI;rr.save=lI;rr.load=fI;rr.useColors=cI;rr.storage=hI();rr.destroy=(()=>{let t=!1;return()=>{t||(t=!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`."))}})();rr.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"];function cI(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function uI(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Ha.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(r++,i==="%c"&&(n=r))}),t.splice(n,0,e)}rr.log=console.debug||console.log||(()=>{});function lI(t){try{t?rr.storage.setItem("debug",t):rr.storage.removeItem("debug")}catch(e){}}function fI(){let t;try{t=rr.storage.getItem("debug")}catch(e){}return!t&&typeof process!="undefined"&&"env"in process&&(t=process.env.DEBUG),t}function hI(){try{return localStorage}catch(t){}}Ha.exports=y0()(rr);var{formatters:dI}=Ha.exports;dI.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Qt=w((Q5,fl)=>{"use strict";var ds=typeof Reflect=="object"?Reflect:null,g0=ds&&typeof ds.apply=="function"?ds.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},za;ds&&typeof ds.ownKeys=="function"?za=ds.ownKeys:Object.getOwnPropertySymbols?za=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:za=function(e){return Object.getOwnPropertyNames(e)};function pI(t){console&&console.warn&&console.warn(t)}var m0=Number.isNaN||function(e){return e!==e};function Fe(){Fe.init.call(this)}fl.exports=Fe;fl.exports.once=vI;Fe.EventEmitter=Fe;Fe.prototype._events=void 0;Fe.prototype._eventsCount=0;Fe.prototype._maxListeners=void 0;var v0=10;function Ga(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(Fe,"defaultMaxListeners",{enumerable:!0,get:function(){return v0},set:function(t){if(typeof t!="number"||t<0||m0(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");v0=t}});Fe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Fe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||m0(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function b0(t){return t._maxListeners===void 0?Fe.defaultMaxListeners:t._maxListeners}Fe.prototype.getMaxListeners=function(){return b0(this)};Fe.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var o;if(r.length>0&&(o=r[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(c===void 0)return!1;if(typeof c=="function")g0(c,this,r);else for(var u=c.length,l=S0(c,u),n=0;n<u;++n)g0(l[n],this,r);return!0};function E0(t,e,r,n){var i,s,o;if(Ga(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),o=s[e]),o===void 0)o=s[e]=r,++t._eventsCount;else if(typeof o=="function"?o=s[e]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),i=b0(t),i>0&&o.length>i&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=t,a.type=e,a.count=o.length,pI(a)}return t}Fe.prototype.addListener=function(e,r){return E0(this,e,r,!1)};Fe.prototype.on=Fe.prototype.addListener;Fe.prototype.prependListener=function(e,r){return E0(this,e,r,!0)};function yI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function w0(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=yI.bind(n);return i.listener=r,n.wrapFn=i,i}Fe.prototype.once=function(e,r){return Ga(r),this.on(e,w0(this,e,r)),this};Fe.prototype.prependOnceListener=function(e,r){return Ga(r),this.prependListener(e,w0(this,e,r)),this};Fe.prototype.removeListener=function(e,r){var n,i,s,o,a;if(Ga(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount==0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,o=n.length-1;o>=0;o--)if(n[o]===r||n[o].listener===r){a=n[o].listener,s=o;break}if(s<0)return this;s===0?n.shift():gI(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,a||r)}return this};Fe.prototype.off=Fe.prototype.removeListener;Fe.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),o;for(i=0;i<s.length;++i)o=s[i],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function _0(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?mI(i):S0(i,i.length)}Fe.prototype.listeners=function(e){return _0(this,e,!0)};Fe.prototype.rawListeners=function(e){return _0(this,e,!1)};Fe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):x0.call(t,e)};Fe.prototype.listenerCount=x0;function x0(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}Fe.prototype.eventNames=function(){return this._eventsCount>0?za(this._events):[]};function S0(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function gI(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function mI(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function vI(t,e){return new Promise(function(r,n){function i(o){t.removeListener(e,s),n(o)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}A0(t,e,s,{once:!0}),e!=="error"&&bI(t,i,{once:!0})})}function bI(t,e,r){typeof t.on=="function"&&A0(t,"error",e,r)}function A0(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}});var he=w((X5,I0)=>{"use strict";function C0(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function EI(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return C0(t,r)}catch(n){r.message=t.message,r.stack=t.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(t)),C0(new i,r)}}I0.exports=EI});function R0(t,e,r){e=e||[],r=r||0;for(var n=r;t>=SI;)e[r++]=t&255|T0,t/=128;for(;t&xI;)e[r++]=t&255|T0,t>>>=7;return e[r]=t|0,R0.bytes=r-n+1,e}function hl(t,e){var r=0,e=e||0,n=0,i=e,s,o=t.length;do{if(i>=o)throw hl.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=n<28?(s&B0)<<n:(s&B0)*Math.pow(2,n),n+=7}while(s>=CI);return hl.bytes=i-e,r}var wI,T0,_I,xI,SI,AI,CI,B0,II,TI,RI,BI,PI,NI,OI,DI,LI,kI,qI,UI,Bo,P0=xe(()=>{wI=R0,T0=128,_I=127,xI=~_I,SI=Math.pow(2,31);AI=hl,CI=128,B0=127;II=Math.pow(2,7),TI=Math.pow(2,14),RI=Math.pow(2,21),BI=Math.pow(2,28),PI=Math.pow(2,35),NI=Math.pow(2,42),OI=Math.pow(2,49),DI=Math.pow(2,56),LI=Math.pow(2,63),kI=function(t){return t<II?1:t<TI?2:t<RI?3:t<BI?4:t<PI?5:t<NI?6:t<OI?7:t<DI?8:t<LI?9:10},qI={encode:wI,decode:AI,encodingLength:kI},UI=qI,Bo=UI});var Po,ps,ys,Wa=xe(()=>{P0();Po=t=>[Bo.decode(t),Bo.decode.bytes],ps=(t,e,r=0)=>(Bo.encode(t,e,r),e),ys=t=>Bo.encodingLength(t)});var eq,O0,dn,D0,L0,Pn=xe(()=>{eq=new Uint8Array(0),O0=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},dn=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},D0=t=>new TextEncoder().encode(t),L0=t=>new TextDecoder().decode(t)});var No={};gt(No,{Digest:()=>gs,create:()=>Nn,decode:()=>dl,equals:()=>pl});var Nn,dl,pl,gs,mi=xe(()=>{Pn();Wa();Nn=(t,e)=>{let r=e.byteLength,n=ys(t),i=n+ys(r),s=new Uint8Array(i+r);return ps(t,s,0),ps(r,s,n),s.set(e,i),new gs(t,r,e,s)},dl=t=>{let e=dn(t),[r,n]=Po(e),[i,s]=Po(e.subarray(n)),o=e.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new gs(r,i,o,e)},pl=(t,e)=>t===e?!0:t.code===e.code&&t.size===e.size&&O0(t.bytes,e.bytes),gs=class{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}});function MI(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var g=0,m=0,x=0,R=d.length;x!==R&&d[x]===0;)x++,g++;for(var L=(R-x)*l+1>>>0,H=new Uint8Array(L);x!==R;){for(var q=d[x],k=0,J=L-1;(q!==0||k<m)&&J!==-1;J--,k++)q+=256*H[J]>>>0,H[J]=q%a>>>0,q=q/a>>>0;if(q!==0)throw new Error("Non-zero carry");m=k,x++}for(var ie=L-m;ie!==L&&H[ie]===0;)ie++;for(var j=c.repeat(g);ie<L;++ie)j+=t.charAt(H[ie]);return j}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var g=0;if(d[g]!==" "){for(var m=0,x=0;d[g]===c;)m++,g++;for(var R=(d.length-g)*u+1>>>0,L=new Uint8Array(R);d[g];){var H=r[d.charCodeAt(g)];if(H===255)return;for(var q=0,k=R-1;(H!==0||q<x)&&k!==-1;k--,q++)H+=a*L[k]>>>0,L[k]=H%256>>>0,H=H/256>>>0;if(H!==0)throw new Error("Non-zero carry");x=q,g++}if(d[g]!==" "){for(var J=R-x;J!==R&&L[J]===0;)J++;for(var ie=new Uint8Array(m+(R-J)),j=m;J!==R;)ie[j++]=L[J++];return ie}}}function p(d){var g=h(d);if(g)return g;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:p}}var FI,KI,q0,U0=xe(()=>{FI=MI,KI=FI,q0=KI});var M0,F0,K0,V0,j0,Ya,On,VI,jI,ct,Kr=xe(()=>{U0();Pn();M0=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},F0=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseDecode=n}decode(e){if(typeof e=="string")switch(e[0]){case this.prefix:return this.baseDecode(e.slice(1));default:throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`)}else throw Error("Can only multibase decode strings")}or(e){return V0(this,e)}},K0=class{constructor(e){this.decoders=e}or(e){return V0(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},V0=(t,e)=>new K0({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),j0=class{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new M0(e,r,n),this.decoder=new F0(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ya=({name:t,prefix:e,encode:r,decode:n})=>new j0(t,e,r,n),On=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:i}=q0(r,e);return Ya({prefix:t,name:e,encode:n,decode:s=>dn(i(s))})},VI=(t,e,r,n)=>{let i={};for(let l=0;l<e.length;++l)i[e[l]]=l;let s=t.length;for(;t[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,u=0;for(let l=0;l<s;++l){let f=i[t[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},jI=(t,e,r)=>{let n=e[e.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},ct=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Ya({prefix:e,name:t,encode(i){return jI(i,n,r)},decode(i){return VI(i,n,r,t)}})});var Dn={};gt(Dn,{base58btc:()=>Vr,base58flickr:()=>$I});var Vr,$I,Ln=xe(()=>{Kr();Vr=On({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),$I=On({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});var vi={};gt(vi,{base32:()=>ms,base32hex:()=>WI,base32hexpad:()=>QI,base32hexpadupper:()=>XI,base32hexupper:()=>YI,base32pad:()=>zI,base32padupper:()=>GI,base32upper:()=>HI,base32z:()=>ZI});var ms,HI,zI,GI,WI,YI,QI,XI,ZI,bi=xe(()=>{Kr();ms=ct({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),HI=ct({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zI=ct({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),GI=ct({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),WI=ct({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),YI=ct({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),QI=ct({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),XI=ct({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ZI=ct({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})});var Do={};gt(Do,{CID:()=>bt});var bt,JI,eT,tT,Oo,rT,$0,H0,Qa,Xa,nT,iT,sT,vs=xe(()=>{Wa();mi();Ln();bi();Pn();bt=class{constructor(e,r,n,i){this.code=r,this.version=e,this.multihash=n,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Xa,byteLength:Xa,code:Qa,version:Qa,multihash:Qa,bytes:Qa,_baseCache:Xa,asCID:Xa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:r}=this;if(e!==Oo)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==rT)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return bt.createV0(r)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Nn(e,r);return bt.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&pl(this.multihash,e.multihash)}toString(e){let{bytes:r,version:n,_baseCache:i}=this;switch(n){case 0:return eT(r,i,e||Vr.encoder);default:return tT(r,i,e||ms.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return iT(/^0\.0/,sT),!!(e&&(e[H0]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof bt)return e;if(e!=null&&e.asCID===e){let{version:r,code:n,multihash:i,bytes:s}=e;return new bt(r,n,i,s||$0(r,n,i.bytes))}else if(e!=null&&e[H0]===!0){let{version:r,multihash:n,code:i}=e,s=dl(n);return bt.create(r,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(r!==Oo)throw new Error(`Version 0 CID must use dag-pb (code: ${Oo}) block encoding`);return new bt(e,r,n,n.bytes)}case 1:{let i=$0(e,r,n.bytes);return new bt(e,r,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return bt.create(0,Oo,e)}static createV1(e,r){return bt.create(1,e,r)}static decode(e){let[r,n]=bt.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=bt.inspectBytes(e),n=r.size-r.multihashSize,i=dn(e.subarray(n,n+r.multihashSize));if(i.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=i.subarray(r.multihashSize-r.digestSize),o=new gs(r.multihashCode,r.digestSize,s,i);return[r.version===0?bt.createV0(o):bt.createV1(r.codec,o),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=Po(e.subarray(r));return r+=h,f},i=n(),s=Oo;if(i===18?(i=0,r=0):i===1&&(s=n()),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let o=r,a=n(),c=n(),u=r+c,l=u-o;return{version:i,codec:s,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,i]=JI(e,r),s=bt.decode(i);return s._baseCache.set(n,e),s}},JI=(t,e)=>{switch(t[0]){case"Q":{let r=e||Vr;return[Vr.prefix,r.decode(`${Vr.prefix}${t}`)]}case Vr.prefix:{let r=e||Vr;return[Vr.prefix,r.decode(t)]}case ms.prefix:{let r=e||ms;return[ms.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},eT=(t,e,r)=>{let{prefix:n}=r;if(n!==Vr.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let i=e.get(n);if(i==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return i},tT=(t,e,r)=>{let{prefix:n}=r,i=e.get(n);if(i==null){let s=r.encode(t);return e.set(n,s),s}else return i},Oo=112,rT=18,$0=(t,e,r)=>{let n=ys(t),i=n+ys(e),s=new Uint8Array(i+r.byteLength);return ps(t,s,0),ps(e,s,n),s.set(r,i),s},H0=Symbol.for("@ipld/js-cid/CID"),Qa={writable:!1,configurable:!1,enumerable:!0},Xa={writable:!1,enumerable:!1,configurable:!1},nT="0.0.0-dev",iT=(t,e)=>{if(t.test(nT))console.warn(e);else throw new Error(e)},sT=`CID.isCID(v) is deprecated and will be removed in the next major release.
3
3
  Following code pattern:
4
4
 
5
5
  if (CID.isCID(value)) {
@@ -13,36 +13,36 @@ if (cid) {
13
13
  // Make sure to use cid instead of value
14
14
  doSomethingWithCID(cid)
15
15
  }
16
- `});var Ha={};yt(Ha,{base36:()=>BI,base36upper:()=>PI});var BI,PI,rl=_e(()=>{Fr();BI=Rn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),PI=Rn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});var ms={};yt(ms,{base64:()=>NI,base64pad:()=>OI,base64url:()=>DI,base64urlpad:()=>LI});var NI,OI,DI,LI,To=_e(()=>{Fr();NI=at({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),OI=at({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),DI=at({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),LI=at({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});var za={};yt(za,{base16:()=>kI,base16upper:()=>qI});var kI,qI,nl=_e(()=>{Fr();kI=at({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qI=at({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});var D0=w((D5,O0)=>{"use strict";O0.exports=UI;function UI(t,e){for(var r=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)r[n++]=arguments[i++];return new Promise(function(a,c){r[n]=function(l){if(s)if(s=!1,l)c(l);else{for(var f=new Array(arguments.length-1),h=0;h<f.length;)f[h++]=arguments[h];a.apply(null,f)}};try{t.apply(e||null,r)}catch(u){s&&(s=!1,c(u))}})}});var U0=w(q0=>{"use strict";var Ga=q0;Ga.length=function(e){var r=e.length;if(!r)return 0;for(var n=0;--r%4>1&&e.charAt(r)==="=";)++n;return Math.ceil(e.length*3)/4-n};var vs=new Array(64),L0=new Array(123);for(Br=0;Br<64;)L0[vs[Br]=Br<26?Br+65:Br<52?Br+71:Br<62?Br-4:Br-59|43]=Br++;var Br;Ga.encode=function(e,r,n){for(var i=null,s=[],o=0,a=0,c;r<n;){var u=e[r++];switch(a){case 0:s[o++]=vs[u>>2],c=(u&3)<<4,a=1;break;case 1:s[o++]=vs[c|u>>4],c=(u&15)<<2,a=2;break;case 2:s[o++]=vs[c|u>>6],s[o++]=vs[u&63],a=0;break}o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),o=0)}return a&&(s[o++]=vs[c],s[o++]=61,a===1&&(s[o++]=61)),i?(o&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))};var k0="invalid encoding";Ga.decode=function(e,r,n){for(var i=n,s=0,o,a=0;a<e.length;){var c=e.charCodeAt(a++);if(c===61&&s>1)break;if((c=L0[c])===void 0)throw Error(k0);switch(s){case 0:o=c,s=1;break;case 1:r[n++]=o<<2|(c&48)>>4,o=c,s=2;break;case 2:r[n++]=(o&15)<<4|(c&60)>>2,o=c,s=3;break;case 3:r[n++]=(o&3)<<6|c,s=0;break}}if(s===1)throw Error(k0);return n-i};Ga.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}});var F0=w((k5,M0)=>{"use strict";M0.exports=Wa;function Wa(){this._listeners={}}Wa.prototype.on=function(e,r,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:r,ctx:n||this}),this};Wa.prototype.off=function(e,r){if(e===void 0)this._listeners={};else if(r===void 0)this._listeners[e]=[];else for(var n=this._listeners[e],i=0;i<n.length;)n[i].fn===r?n.splice(i,1):++i;return this};Wa.prototype.emit=function(e){var r=this._listeners[e];if(r){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<r.length;)r[i].fn.apply(r[i++].ctx,n)}return this}});var G0=w((q5,z0)=>{"use strict";z0.exports=K0(K0);function K0(t){return typeof Float32Array!="undefined"?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),n=r[3]===128;function i(c,u,l){e[0]=c,u[l]=r[0],u[l+1]=r[1],u[l+2]=r[2],u[l+3]=r[3]}function s(c,u,l){e[0]=c,u[l]=r[3],u[l+1]=r[2],u[l+2]=r[1],u[l+3]=r[0]}t.writeFloatLE=n?i:s,t.writeFloatBE=n?s:i;function o(c,u){return r[0]=c[u],r[1]=c[u+1],r[2]=c[u+2],r[3]=c[u+3],e[0]}function a(c,u){return r[3]=c[u],r[2]=c[u+1],r[1]=c[u+2],r[0]=c[u+3],e[0]}t.readFloatLE=n?o:a,t.readFloatBE=n?a:o}():function(){function e(n,i,s,o){var a=i<0?1:0;if(a&&(i=-i),i===0)n(1/i>0?0:2147483648,s,o);else if(isNaN(i))n(2143289344,s,o);else if(i>34028234663852886e22)n((a<<31|2139095040)>>>0,s,o);else if(i<11754943508222875e-54)n((a<<31|Math.round(i/1401298464324817e-60))>>>0,s,o);else{var c=Math.floor(Math.log(i)/Math.LN2),u=Math.round(i*Math.pow(2,-c)*8388608)&8388607;n((a<<31|c+127<<23|u)>>>0,s,o)}}t.writeFloatLE=e.bind(null,V0),t.writeFloatBE=e.bind(null,j0);function r(n,i,s){var o=n(i,s),a=(o>>31)*2+1,c=o>>>23&255,u=o&8388607;return c===255?u?NaN:a*(1/0):c===0?a*1401298464324817e-60*u:a*Math.pow(2,c-150)*(u+8388608)}t.readFloatLE=r.bind(null,$0),t.readFloatBE=r.bind(null,H0)}(),typeof Float64Array!="undefined"?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),n=r[7]===128;function i(c,u,l){e[0]=c,u[l]=r[0],u[l+1]=r[1],u[l+2]=r[2],u[l+3]=r[3],u[l+4]=r[4],u[l+5]=r[5],u[l+6]=r[6],u[l+7]=r[7]}function s(c,u,l){e[0]=c,u[l]=r[7],u[l+1]=r[6],u[l+2]=r[5],u[l+3]=r[4],u[l+4]=r[3],u[l+5]=r[2],u[l+6]=r[1],u[l+7]=r[0]}t.writeDoubleLE=n?i:s,t.writeDoubleBE=n?s:i;function o(c,u){return r[0]=c[u],r[1]=c[u+1],r[2]=c[u+2],r[3]=c[u+3],r[4]=c[u+4],r[5]=c[u+5],r[6]=c[u+6],r[7]=c[u+7],e[0]}function a(c,u){return r[7]=c[u],r[6]=c[u+1],r[5]=c[u+2],r[4]=c[u+3],r[3]=c[u+4],r[2]=c[u+5],r[1]=c[u+6],r[0]=c[u+7],e[0]}t.readDoubleLE=n?o:a,t.readDoubleBE=n?a:o}():function(){function e(n,i,s,o,a,c){var u=o<0?1:0;if(u&&(o=-o),o===0)n(0,a,c+i),n(1/o>0?0:2147483648,a,c+s);else if(isNaN(o))n(0,a,c+i),n(2146959360,a,c+s);else if(o>17976931348623157e292)n(0,a,c+i),n((u<<31|2146435072)>>>0,a,c+s);else{var l;if(o<22250738585072014e-324)l=o/5e-324,n(l>>>0,a,c+i),n((u<<31|l/4294967296)>>>0,a,c+s);else{var f=Math.floor(Math.log(o)/Math.LN2);f===1024&&(f=1023),l=o*Math.pow(2,-f),n(l*4503599627370496>>>0,a,c+i),n((u<<31|f+1023<<20|l*1048576&1048575)>>>0,a,c+s)}}}t.writeDoubleLE=e.bind(null,V0,0,4),t.writeDoubleBE=e.bind(null,j0,4,0);function r(n,i,s,o,a){var c=n(o,a+i),u=n(o,a+s),l=(u>>31)*2+1,f=u>>>20&2047,h=4294967296*(u&1048575)+c;return f===2047?h?NaN:l*(1/0):f===0?l*5e-324*h:l*Math.pow(2,f-1075)*(h+4503599627370496)}t.readDoubleLE=r.bind(null,$0,0,4),t.readDoubleBE=r.bind(null,H0,4,0)}(),t}function V0(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function j0(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=t&255}function $0(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function H0(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}});var W0=w((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}});var Q0=w(Y0=>{"use strict";var il=Y0;il.length=function(e){for(var r=0,n=0,i=0;i<e.length;++i)n=e.charCodeAt(i),n<128?r+=1:n<2048?r+=2:(n&64512)==55296&&(e.charCodeAt(i+1)&64512)==56320?(++i,r+=4):r+=3;return r};il.read=function(e,r,n){var i=n-r;if(i<1)return"";for(var s=null,o=[],a=0,c;r<n;)c=e[r++],c<128?o[a++]=c:c>191&&c<224?o[a++]=(c&31)<<6|e[r++]&63:c>239&&c<365?(c=((c&7)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,o[a++]=55296+(c>>10),o[a++]=56320+(c&1023)):o[a++]=(c&15)<<12|(e[r++]&63)<<6|e[r++]&63,a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0);return s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};il.write=function(e,r,n){for(var i=n,s,o,a=0;a<e.length;++a)s=e.charCodeAt(a),s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=s&63|128):(s&64512)==55296&&((o=e.charCodeAt(a+1))&64512)==56320?(s=65536+((s&1023)<<10)+(o&1023),++a,r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128);return n-i}});var Z0=w((M5,X0)=>{"use strict";X0.exports=MI;function MI(t,e,r){var n=r||8192,i=n>>>1,s=null,o=n;return function(c){if(c<1||c>i)return t(c);o+c>n&&(s=t(n),o=0);var u=e.call(s,o,o+=c);return o&7&&(o=(o|7)+1),u}}});var ep=w((F5,J0)=>{"use strict";J0.exports=Et;var Ro=On();function Et(t,e){this.lo=t>>>0,this.hi=e>>>0}var bi=Et.zero=new Et(0,0);bi.toNumber=function(){return 0};bi.zzEncode=bi.zzDecode=function(){return this};bi.length=function(){return 1};var FI=Et.zeroHash="\0\0\0\0\0\0\0\0";Et.fromNumber=function(e){if(e===0)return bi;var r=e<0;r&&(e=-e);var n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new Et(n,i)};Et.from=function(e){if(typeof e=="number")return Et.fromNumber(e);if(Ro.isString(e))if(Ro.Long)e=Ro.Long.fromString(e);else return Et.fromNumber(parseInt(e,10));return e.low||e.high?new Et(e.low>>>0,e.high>>>0):bi};Et.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var r=~this.lo+1>>>0,n=~this.hi>>>0;return r||(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296};Et.prototype.toLong=function(e){return Ro.Long?new Ro.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var Nn=String.prototype.charCodeAt;Et.fromHash=function(e){return e===FI?bi:new Et((Nn.call(e,0)|Nn.call(e,1)<<8|Nn.call(e,2)<<16|Nn.call(e,3)<<24)>>>0,(Nn.call(e,4)|Nn.call(e,5)<<8|Nn.call(e,6)<<16|Nn.call(e,7)<<24)>>>0)};Et.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};Et.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this};Et.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};Et.prototype.length=function(){var e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}});var On=w(sl=>{"use strict";var oe=sl;oe.asPromise=D0();oe.base64=U0();oe.EventEmitter=F0();oe.float=G0();oe.inquire=W0();oe.utf8=Q0();oe.pool=Z0();oe.LongBits=ep();oe.isNode=Boolean(typeof globalThis!="undefined"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);oe.global=oe.isNode&&globalThis||typeof window!="undefined"&&window||typeof self!="undefined"&&self||sl;oe.emptyArray=Object.freeze?Object.freeze([]):[];oe.emptyObject=Object.freeze?Object.freeze({}):{};oe.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};oe.isString=function(e){return typeof e=="string"||e instanceof String};oe.isObject=function(e){return e&&typeof e=="object"};oe.isset=oe.isSet=function(e,r){var n=e[r];return n!=null&&e.hasOwnProperty(r)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};oe.Buffer=function(){try{var t=oe.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(e){return null}}();oe._Buffer_from=null;oe._Buffer_allocUnsafe=null;oe.newBuffer=function(e){return typeof e=="number"?oe.Buffer?oe._Buffer_allocUnsafe(e):new oe.Array(e):oe.Buffer?oe._Buffer_from(e):typeof Uint8Array=="undefined"?e:new Uint8Array(e)};oe.Array=typeof Uint8Array!="undefined"?Uint8Array:Array;oe.Long=oe.global.dcodeIO&&oe.global.dcodeIO.Long||oe.global.Long||oe.inquire("long");oe.key2Re=/^true|false|0|1$/;oe.key32Re=/^-?(?:0|[1-9][0-9]*)$/;oe.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;oe.longToHash=function(e){return e?oe.LongBits.from(e).toHash():oe.LongBits.zeroHash};oe.longFromHash=function(e,r){var n=oe.LongBits.fromHash(e);return oe.Long?oe.Long.fromBits(n.lo,n.hi,r):n.toNumber(Boolean(r))};function tp(t,e,r){for(var n=Object.keys(e),i=0;i<n.length;++i)(t[n[i]]===void 0||!r)&&(t[n[i]]=e[n[i]]);return t}oe.merge=tp;oe.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function rp(t){function e(r,n){if(!(this instanceof e))return new e(r,n);Object.defineProperty(this,"message",{get:function(){return r}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&tp(this,n)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return t}}),e.prototype.toString=function(){return this.name+": "+this.message},e}oe.newError=rp;oe.ProtocolError=rp("ProtocolError");oe.oneOfGetter=function(e){for(var r={},n=0;n<e.length;++n)r[e[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(r[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};oe.oneOfSetter=function(e){return function(r){for(var n=0;n<e.length;++n)e[n]!==r&&delete this[e[n]]}};oe.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};oe._configure=function(){var t=oe.Buffer;if(!t){oe._Buffer_from=oe._Buffer_allocUnsafe=null;return}oe._Buffer_from=t.from!==Uint8Array.from&&t.from||function(r,n){return new t(r,n)},oe._Buffer_allocUnsafe=t.allocUnsafe||function(r){return new t(r)}}});var hl=w((V5,op)=>{"use strict";op.exports=Te;var lr=On(),ol,Ya=lr.LongBits,np=lr.base64,ip=lr.utf8;function Bo(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function al(){}function KI(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function Te(){this.len=0,this.head=new Bo(al,0,0),this.tail=this.head,this.states=null}var sp=function(){return lr.Buffer?function(){return(Te.create=function(){return new ol})()}:function(){return new Te}};Te.create=sp();Te.alloc=function(e){return new lr.Array(e)};lr.Array!==Array&&(Te.alloc=lr.pool(Te.alloc,lr.Array.prototype.subarray));Te.prototype._push=function(e,r,n){return this.tail=this.tail.next=new Bo(e,r,n),this.len+=r,this};function cl(t,e,r){e[r]=t&255}function VI(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}function ul(t,e){this.len=t,this.next=void 0,this.val=e}ul.prototype=Object.create(Bo.prototype);ul.prototype.fn=VI;Te.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new ul((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};Te.prototype.int32=function(e){return e<0?this._push(ll,10,Ya.fromNumber(e)):this.uint32(e)};Te.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function ll(t,e,r){for(;t.hi;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}Te.prototype.uint64=function(e){var r=Ya.from(e);return this._push(ll,r.length(),r)};Te.prototype.int64=Te.prototype.uint64;Te.prototype.sint64=function(e){var r=Ya.from(e).zzEncode();return this._push(ll,r.length(),r)};Te.prototype.bool=function(e){return this._push(cl,1,e?1:0)};function fl(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}Te.prototype.fixed32=function(e){return this._push(fl,4,e>>>0)};Te.prototype.sfixed32=Te.prototype.fixed32;Te.prototype.fixed64=function(e){var r=Ya.from(e);return this._push(fl,4,r.lo)._push(fl,4,r.hi)};Te.prototype.sfixed64=Te.prototype.fixed64;Te.prototype.float=function(e){return this._push(lr.float.writeFloatLE,4,e)};Te.prototype.double=function(e){return this._push(lr.float.writeDoubleLE,8,e)};var jI=lr.Array.prototype.set?function(e,r,n){r.set(e,n)}:function(e,r,n){for(var i=0;i<e.length;++i)r[n+i]=e[i]};Te.prototype.bytes=function(e){var r=e.length>>>0;if(!r)return this._push(cl,1,0);if(lr.isString(e)){var n=Te.alloc(r=np.length(e));np.decode(e,n,0),e=n}return this.uint32(r)._push(jI,r,e)};Te.prototype.string=function(e){var r=ip.length(e);return r?this.uint32(r)._push(ip.write,r,e):this._push(cl,1,0)};Te.prototype.fork=function(){return this.states=new KI(this),this.head=this.tail=new Bo(al,0,0),this.len=0,this};Te.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 Bo(al,0,0),this.len=0),this};Te.prototype.ldelim=function(){var e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=r,this.len+=n),this};Te.prototype.finish=function(){for(var e=this.head.next,r=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r};Te._configure=function(t){ol=t,Te.create=sp(),ol._configure()}});var up=w((j5,cp)=>{"use strict";cp.exports=Vr;var ap=hl();(Vr.prototype=Object.create(ap.prototype)).constructor=Vr;var Dn=On();function Vr(){ap.call(this)}Vr._configure=function(){Vr.alloc=Dn._Buffer_allocUnsafe,Vr.writeBytesBuffer=Dn.Buffer&&Dn.Buffer.prototype instanceof Uint8Array&&Dn.Buffer.prototype.set.name==="set"?function(e,r,n){r.set(e,n)}:function(e,r,n){if(e.copy)e.copy(r,n,0,e.length);else for(var i=0;i<e.length;)r[n++]=e[i++]}};Vr.prototype.bytes=function(e){Dn.isString(e)&&(e=Dn._Buffer_from(e,"base64"));var r=e.length>>>0;return this.uint32(r),r&&this._push(Vr.writeBytesBuffer,r,e),this};function $I(t,e,r){t.length<40?Dn.utf8.write(t,e,r):e.utf8Write?e.utf8Write(t,r):e.write(t,r)}Vr.prototype.string=function(e){var r=Dn.Buffer.byteLength(e);return this.uint32(r),r&&this._push($I,r,e),this};Vr._configure()});var yl=w(($5,pp)=>{"use strict";pp.exports=ft;var jr=On(),dl,lp=jr.LongBits,HI=jr.utf8;function Pr(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function ft(t){this.buf=t,this.pos=0,this.len=t.length}var fp=typeof Uint8Array!="undefined"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new ft(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new ft(e);throw Error("illegal buffer")},hp=function(){return jr.Buffer?function(r){return(ft.create=function(i){return jr.Buffer.isBuffer(i)?new dl(i):fp(i)})(r)}:fp};ft.create=hp();ft.prototype._slice=jr.Array.prototype.subarray||jr.Array.prototype.slice;ft.prototype.uint32=function(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Pr(this,10);return e}}();ft.prototype.int32=function(){return this.uint32()|0};ft.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function pl(){var t=new lp(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Pr(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Pr(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}ft.prototype.bool=function(){return this.uint32()!==0};function Qa(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}ft.prototype.fixed32=function(){if(this.pos+4>this.len)throw Pr(this,4);return Qa(this.buf,this.pos+=4)};ft.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Pr(this,4);return Qa(this.buf,this.pos+=4)|0};function dp(){if(this.pos+8>this.len)throw Pr(this,8);return new lp(Qa(this.buf,this.pos+=4),Qa(this.buf,this.pos+=4))}ft.prototype.float=function(){if(this.pos+4>this.len)throw Pr(this,4);var e=jr.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};ft.prototype.double=function(){if(this.pos+8>this.len)throw Pr(this,4);var e=jr.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};ft.prototype.bytes=function(){var e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Pr(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(r,n):r===n?new this.buf.constructor(0):this._slice.call(this.buf,r,n)};ft.prototype.string=function(){var e=this.bytes();return HI.read(e,0,e.length)};ft.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Pr(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Pr(this);while(this.buf[this.pos++]&128);return this};ft.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!=4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this};ft._configure=function(t){dl=t,ft.create=hp(),dl._configure();var e=jr.Long?"toLong":"toNumber";jr.merge(ft.prototype,{int64:function(){return pl.call(this)[e](!1)},uint64:function(){return pl.call(this)[e](!0)},sint64:function(){return pl.call(this).zzDecode()[e](!1)},fixed64:function(){return dp.call(this)[e](!0)},sfixed64:function(){return dp.call(this)[e](!1)}})}});var vp=w((H5,mp)=>{"use strict";mp.exports=Ei;var yp=yl();(Ei.prototype=Object.create(yp.prototype)).constructor=Ei;var gp=On();function Ei(t){yp.call(this,t)}Ei._configure=function(){gp.Buffer&&(Ei.prototype._slice=gp.Buffer.prototype.slice)};Ei.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))};Ei._configure()});var Ep=w((z5,bp)=>{"use strict";bp.exports=Po;var gl=On();(Po.prototype=Object.create(gl.EventEmitter.prototype)).constructor=Po;function Po(t,e,r){if(typeof t!="function")throw TypeError("rpcImpl must be a function");gl.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(r)}Po.prototype.rpcCall=function t(e,r,n,i,s){if(!i)throw TypeError("request must be specified");var o=this;if(!s)return gl.asPromise(t,o,e,r,n,i);if(!o.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return o.rpcImpl(e,r[o.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(c,u){if(c)return o.emit("error",c,e),s(c);if(u===null){o.end(!0);return}if(!(u instanceof n))try{u=n[o.responseDelimited?"decodeDelimited":"decode"](u)}catch(l){return o.emit("error",l,e),s(l)}return o.emit("data",u,e),s(null,u)})}catch(a){o.emit("error",a,e),setTimeout(function(){s(a)},0);return}};Po.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var _p=w(wp=>{"use strict";var zI=wp;zI.Service=Ep()});var Sp=w((W5,xp)=>{"use strict";xp.exports={}});var Ip=w(Cp=>{"use strict";var Xt=Cp;Xt.build="minimal";Xt.Writer=hl();Xt.BufferWriter=up();Xt.Reader=yl();Xt.BufferReader=vp();Xt.util=On();Xt.rpc=_p();Xt.roots=Sp();Xt.configure=Ap;function Ap(){Xt.util._configure(),Xt.Writer._configure(Xt.BufferWriter),Xt.Reader._configure(Xt.BufferReader)}Ap()});var Ln=w((Q5,Tp)=>{"use strict";Tp.exports=Ip()});var Za=w((X5,Bp)=>{"use strict";var wi=Ln(),Xa=wi.Reader,Rp=wi.Writer,Bt=wi.util,fr=wi.roots["libp2p-crypto-keys"]||(wi.roots["libp2p-crypto-keys"]={});fr.KeyType=function(){var t={},e=Object.create(t);return e[t[0]="RSA"]=0,e[t[1]="Ed25519"]=1,e[t[2]="Secp256k1"]=2,e}();fr.PublicKey=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.Type=0,t.prototype.Data=Bt.newBuffer([]),t.encode=function(r,n){return n||(n=Rp.create()),n.uint32(8).int32(r.Type),n.uint32(18).bytes(r.Data),n},t.decode=function(r,n){r instanceof Xa||(r=Xa.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new fr.PublicKey;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.Type=r.int32();break;case 2:s.Data=r.bytes();break;default:r.skipType(o&7);break}}if(!s.hasOwnProperty("Type"))throw Bt.ProtocolError("missing required 'Type'",{instance:s});if(!s.hasOwnProperty("Data"))throw Bt.ProtocolError("missing required 'Data'",{instance:s});return s},t.fromObject=function(r){if(r instanceof fr.PublicKey)return r;var n=new fr.PublicKey;switch(r.Type){case"RSA":case 0:n.Type=0;break;case"Ed25519":case 1:n.Type=1;break;case"Secp256k1":case 2:n.Type=2;break}return r.Data!=null&&(typeof r.Data=="string"?Bt.base64.decode(r.Data,n.Data=Bt.newBuffer(Bt.base64.length(r.Data)),0):r.Data.length&&(n.Data=r.Data)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.Type=n.enums===String?"RSA":0,n.bytes===String?i.Data="":(i.Data=[],n.bytes!==Array&&(i.Data=Bt.newBuffer(i.Data)))),r.Type!=null&&r.hasOwnProperty("Type")&&(i.Type=n.enums===String?fr.KeyType[r.Type]:r.Type),r.Data!=null&&r.hasOwnProperty("Data")&&(i.Data=n.bytes===String?Bt.base64.encode(r.Data,0,r.Data.length):n.bytes===Array?Array.prototype.slice.call(r.Data):r.Data),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,wi.util.toJSONOptions)},t}();fr.PrivateKey=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.Type=0,t.prototype.Data=Bt.newBuffer([]),t.encode=function(r,n){return n||(n=Rp.create()),n.uint32(8).int32(r.Type),n.uint32(18).bytes(r.Data),n},t.decode=function(r,n){r instanceof Xa||(r=Xa.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new fr.PrivateKey;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.Type=r.int32();break;case 2:s.Data=r.bytes();break;default:r.skipType(o&7);break}}if(!s.hasOwnProperty("Type"))throw Bt.ProtocolError("missing required 'Type'",{instance:s});if(!s.hasOwnProperty("Data"))throw Bt.ProtocolError("missing required 'Data'",{instance:s});return s},t.fromObject=function(r){if(r instanceof fr.PrivateKey)return r;var n=new fr.PrivateKey;switch(r.Type){case"RSA":case 0:n.Type=0;break;case"Ed25519":case 1:n.Type=1;break;case"Secp256k1":case 2:n.Type=2;break}return r.Data!=null&&(typeof r.Data=="string"?Bt.base64.decode(r.Data,n.Data=Bt.newBuffer(Bt.base64.length(r.Data)),0):r.Data.length&&(n.Data=r.Data)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.Type=n.enums===String?"RSA":0,n.bytes===String?i.Data="":(i.Data=[],n.bytes!==Array&&(i.Data=Bt.newBuffer(i.Data)))),r.Type!=null&&r.hasOwnProperty("Type")&&(i.Type=n.enums===String?fr.KeyType[r.Type]:r.Type),r.Data!=null&&r.hasOwnProperty("Data")&&(i.Data=n.bytes===String?Bt.base64.encode(r.Data,0,r.Data.length):n.bytes===Array?Array.prototype.slice.call(r.Data):r.Data),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,wi.util.toJSONOptions)},t}();Bp.exports=fr});var Ee=w((Z5,Pp)=>{Pp.exports={options:{usePureJavaScript:!1}}});var Dp=w((J5,Op)=>{var ml={};Op.exports=ml;var Np={};ml.encode=function(t,e,r){if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');var n="";if(!(t instanceof Uint8Array))n=GI(t,e);else{var i=0,s=e.length,o=e.charAt(0),a=[0];for(i=0;i<t.length;++i){for(var c=0,u=t[i];c<a.length;++c)u+=a[c]<<8,a[c]=u%s,u=u/s|0;for(;u>0;)a.push(u%s),u=u/s|0}for(i=0;t[i]===0&&i<t.length-1;++i)n+=o;for(i=a.length-1;i>=0;--i)n+=e[a[i]]}if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join(`\r
17
- `)}return n};ml.decode=function(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');var r=Np[e];if(!r){r=Np[e]=[];for(var n=0;n<e.length;++n)r[e.charCodeAt(n)]=n}t=t.replace(/\s/g,"");for(var i=e.length,s=e.charAt(0),o=[0],n=0;n<t.length;n++){var a=r[t.charCodeAt(n)];if(a===void 0)return;for(var c=0,u=a;c<o.length;++c)u+=o[c]*i,o[c]=u&255,u>>=8;for(;u>0;)o.push(u&255),u>>=8}for(var l=0;t[l]===s&&l<t.length-1;++l)o.push(0);return typeof Buffer!="undefined"?Buffer.from(o.reverse()):new Uint8Array(o.reverse())};function GI(t,e){var r=0,n=e.length,i=e.charAt(0),s=[0];for(r=0;r<t.length();++r){for(var o=0,a=t.at(r);o<s.length;++o)a+=s[o]<<8,s[o]=a%n,a=a/n|0;for(;a>0;)s.push(a%n),a=a/n|0}var c="";for(r=0;t.at(r)===0&&r<t.length()-1;++r)c+=i;for(r=s.length-1;r>=0;--r)c+=e[s[r]];return c}});var je=w((eq,Up)=>{var Lp=Ee(),kp=Dp(),R=Up.exports=Lp.util=Lp.util||{};(function(){if(typeof process!="undefined"&&process.nextTick&&!process.browser){R.nextTick=process.nextTick,typeof setImmediate=="function"?R.setImmediate=setImmediate:R.setImmediate=R.nextTick;return}if(typeof setImmediate=="function"){R.setImmediate=function(){return setImmediate.apply(void 0,arguments)},R.nextTick=function(a){return setImmediate(a)};return}if(R.setImmediate=function(a){setTimeout(a,0)},typeof window!="undefined"&&typeof window.postMessage=="function"){let a=function(c){if(c.source===window&&c.data===t){c.stopPropagation();var u=e.slice();e.length=0,u.forEach(function(l){l()})}};var o=a,t="forge.setImmediate",e=[];R.setImmediate=function(c){e.push(c),e.length===1&&window.postMessage(t,"*")},window.addEventListener("message",a,!0)}if(typeof MutationObserver!="undefined"){var r=Date.now(),n=!0,i=document.createElement("div"),e=[];new MutationObserver(function(){var c=e.slice();e.length=0,c.forEach(function(u){u()})}).observe(i,{attributes:!0});var s=R.setImmediate;R.setImmediate=function(c){Date.now()-r>15?(r=Date.now(),s(c)):(e.push(c),e.length===1&&i.setAttribute("a",n=!n))}}R.nextTick=R.setImmediate})();R.isNodejs=typeof process!="undefined"&&process.versions&&process.versions.node;R.globalScope=function(){return R.isNodejs?globalThis:typeof self=="undefined"?window:self}();R.isArray=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"};R.isArrayBuffer=function(t){return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer};R.isArrayBufferView=function(t){return t&&R.isArrayBuffer(t.buffer)&&t.byteLength!==void 0};function No(t){if(!(t===8||t===16||t===24||t===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+t)}R.ByteBuffer=vl;function vl(t){if(this.data="",this.read=0,typeof t=="string")this.data=t;else if(R.isArrayBuffer(t)||R.isArrayBufferView(t))if(typeof Buffer!="undefined"&&t instanceof Buffer)this.data=t.toString("binary");else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch(n){for(var r=0;r<e.length;++r)this.putByte(e[r])}}else(t instanceof vl||typeof t=="object"&&typeof t.data=="string"&&typeof t.read=="number")&&(this.data=t.data,this.read=t.read);this._constructedStringLength=0}R.ByteStringBuffer=vl;var WI=4096;R.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>WI&&(this.data.substr(0,1),this._constructedStringLength=0)};R.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};R.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};R.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))};R.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this};R.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this};R.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(R.encodeUtf8(t))};R.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};R.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};R.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};R.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255))};R.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))};R.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))};R.ByteStringBuffer.prototype.putInt=function(t,e){No(e);var r="";do e-=8,r+=String.fromCharCode(t>>e&255);while(e>0);return this.putBytes(r)};R.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<<e-1),this.putInt(t,e)};R.ByteStringBuffer.prototype.putBuffer=function(t){return this.putBytes(t.getBytes())};R.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};R.ByteStringBuffer.prototype.getInt16=function(){var t=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,t};R.ByteStringBuffer.prototype.getInt24=function(){var t=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,t};R.ByteStringBuffer.prototype.getInt32=function(){var t=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,t};R.ByteStringBuffer.prototype.getInt16Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,t};R.ByteStringBuffer.prototype.getInt24Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,t};R.ByteStringBuffer.prototype.getInt32Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,t};R.ByteStringBuffer.prototype.getInt=function(t){No(t);var e=0;do e=(e<<8)+this.data.charCodeAt(this.read++),t-=8;while(t>0);return e};R.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};R.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};R.ByteStringBuffer.prototype.bytes=function(t){return typeof t=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};R.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)};R.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this};R.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};R.ByteStringBuffer.prototype.copy=function(){var t=R.createBuffer(this.data);return t.read=this.read,t};R.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};R.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};R.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this};R.ByteStringBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.length;++e){var r=this.data.charCodeAt(e);r<16&&(t+="0"),t+=r.toString(16)}return t};R.ByteStringBuffer.prototype.toString=function(){return R.decodeUtf8(this.bytes())};function YI(t,e){e=e||{},this.read=e.readOffset||0,this.growSize=e.growSize||1024;var r=R.isArrayBuffer(t),n=R.isArrayBufferView(t);if(r||n){r?this.data=new DataView(t):this.data=new DataView(t.buffer,t.byteOffset,t.byteLength),this.write="writeOffset"in e?e.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,t!=null&&this.putBytes(t),"writeOffset"in e&&(this.write=e.writeOffset)}R.DataBuffer=YI;R.DataBuffer.prototype.length=function(){return this.write-this.read};R.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};R.DataBuffer.prototype.accommodate=function(t,e){if(this.length()>=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+e);return n.set(r),this.data=new DataView(n.buffer),this};R.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this};R.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r<e;++r)this.data.setUint8(t);return this};R.DataBuffer.prototype.putBytes=function(t,e){if(R.isArrayBufferView(t)){var r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-r.byteOffset;this.accommodate(n);var i=new Uint8Array(this.data.buffer,this.write);return i.set(r),this.write+=n,this}if(R.isArrayBuffer(t)){var r=new Uint8Array(t);this.accommodate(r.byteLength);var i=new Uint8Array(this.data.buffer);return i.set(r,this.write),this.write+=r.byteLength,this}if(t instanceof R.DataBuffer||typeof t=="object"&&typeof t.read=="number"&&typeof t.write=="number"&&R.isArrayBufferView(t.data)){var r=new Uint8Array(t.data.byteLength,t.read,t.length());this.accommodate(r.byteLength);var i=new Uint8Array(t.data.byteLength,this.write);return i.set(r),this.write+=r.byteLength,this}if(t instanceof R.ByteStringBuffer&&(t=t.data,e="binary"),e=e||"binary",typeof t=="string"){var s;if(e==="hex")return this.accommodate(Math.ceil(t.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=R.binary.hex.decode(t,s,this.write),this;if(e==="base64")return this.accommodate(Math.ceil(t.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=R.binary.base64.decode(t,s,this.write),this;if(e==="utf8"&&(t=R.encodeUtf8(t),e="binary"),e==="binary"||e==="raw")return this.accommodate(t.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=R.binary.raw.decode(s),this;if(e==="utf16")return this.accommodate(t.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=R.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+e)}throw Error("Invalid parameter: "+t)};R.DataBuffer.prototype.putBuffer=function(t){return this.putBytes(t),t.clear(),this};R.DataBuffer.prototype.putString=function(t){return this.putBytes(t,"utf16")};R.DataBuffer.prototype.putInt16=function(t){return this.accommodate(2),this.data.setInt16(this.write,t),this.write+=2,this};R.DataBuffer.prototype.putInt24=function(t){return this.accommodate(3),this.data.setInt16(this.write,t>>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this};R.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this};R.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this};R.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this};R.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this};R.DataBuffer.prototype.putInt=function(t,e){No(e),this.accommodate(e/8);do e-=8,this.data.setInt8(this.write++,t>>e&255);while(e>0);return this};R.DataBuffer.prototype.putSignedInt=function(t,e){return No(e),this.accommodate(e/8),t<0&&(t+=2<<e-1),this.putInt(t,e)};R.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};R.DataBuffer.prototype.getInt16=function(){var t=this.data.getInt16(this.read);return this.read+=2,t};R.DataBuffer.prototype.getInt24=function(){var t=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,t};R.DataBuffer.prototype.getInt32=function(){var t=this.data.getInt32(this.read);return this.read+=4,t};R.DataBuffer.prototype.getInt16Le=function(){var t=this.data.getInt16(this.read,!0);return this.read+=2,t};R.DataBuffer.prototype.getInt24Le=function(){var t=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,t};R.DataBuffer.prototype.getInt32Le=function(){var t=this.data.getInt32(this.read,!0);return this.read+=4,t};R.DataBuffer.prototype.getInt=function(t){No(t);var e=0;do e=(e<<8)+this.data.getInt8(this.read++),t-=8;while(t>0);return e};R.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};R.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};R.DataBuffer.prototype.bytes=function(t){return typeof t=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};R.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)};R.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this};R.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};R.DataBuffer.prototype.copy=function(){return new R.DataBuffer(this)};R.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this};R.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};R.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this};R.DataBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.byteLength;++e){var r=this.data.getUint8(e);r<16&&(t+="0"),t+=r.toString(16)}return t};R.DataBuffer.prototype.toString=function(t){var e=new Uint8Array(this.data,this.read,this.length());if(t=t||"utf8",t==="binary"||t==="raw")return R.binary.raw.encode(e);if(t==="hex")return R.binary.hex.encode(e);if(t==="base64")return R.binary.base64.encode(e);if(t==="utf8")return R.text.utf8.decode(e);if(t==="utf16")return R.text.utf16.decode(e);throw new Error("Invalid encoding: "+t)};R.createBuffer=function(t,e){return e=e||"raw",t!==void 0&&e==="utf8"&&(t=R.encodeUtf8(t)),new R.ByteBuffer(t)};R.fillString=function(t,e){for(var r="";e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return r};R.xorBytes=function(t,e,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=t.charCodeAt(o)^e.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s,n};R.hexToBytes=function(t){var e="",r=0;for(t.length&!0&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r<t.length;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e};R.bytesToHex=function(t){return R.createBuffer(t).toHex()};R.int32ToBytes=function(t){return String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255)};var kn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",qn=[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],qp="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";R.encode64=function(t,e){for(var r="",n="",i,s,o,a=0;a<t.length;)i=t.charCodeAt(a++),s=t.charCodeAt(a++),o=t.charCodeAt(a++),r+=kn.charAt(i>>2),r+=kn.charAt((i&3)<<4|s>>4),isNaN(s)?r+="==":(r+=kn.charAt((s&15)<<2|o>>6),r+=isNaN(o)?"=":kn.charAt(o&63)),e&&r.length>e&&(n+=r.substr(0,e)+`\r
18
- `,r=r.substr(e));return n+=r,n};R.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e="",r,n,i,s,o=0;o<t.length;)r=qn[t.charCodeAt(o++)-43],n=qn[t.charCodeAt(o++)-43],i=qn[t.charCodeAt(o++)-43],s=qn[t.charCodeAt(o++)-43],e+=String.fromCharCode(r<<2|n>>4),i!==64&&(e+=String.fromCharCode((n&15)<<4|i>>2),s!==64&&(e+=String.fromCharCode((i&3)<<6|s)));return e};R.encodeUtf8=function(t){return unescape(encodeURIComponent(t))};R.decodeUtf8=function(t){return decodeURIComponent(escape(t))};R.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:kp.encode,decode:kp.decode}};R.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)};R.binary.raw.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length)),r=r||0;for(var i=r,s=0;s<t.length;++s)n[i++]=t.charCodeAt(s);return e?i-r:n};R.binary.hex.encode=R.bytesToHex;R.binary.hex.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(Math.ceil(t.length/2))),r=r||0;var i=0,s=r;for(t.length&1&&(i=1,n[s++]=parseInt(t[0],16));i<t.length;i+=2)n[s++]=parseInt(t.substr(i,2),16);return e?s-r:n};R.binary.base64.encode=function(t,e){for(var r="",n="",i,s,o,a=0;a<t.byteLength;)i=t[a++],s=t[a++],o=t[a++],r+=kn.charAt(i>>2),r+=kn.charAt((i&3)<<4|s>>4),isNaN(s)?r+="==":(r+=kn.charAt((s&15)<<2|o>>6),r+=isNaN(o)?"=":kn.charAt(o&63)),e&&r.length>e&&(n+=r.substr(0,e)+`\r
19
- `,r=r.substr(e));return n+=r,n};R.binary.base64.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(Math.ceil(t.length/4)*3)),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),r=r||0;for(var i,s,o,a,c=0,u=r;c<t.length;)i=qn[t.charCodeAt(c++)-43],s=qn[t.charCodeAt(c++)-43],o=qn[t.charCodeAt(c++)-43],a=qn[t.charCodeAt(c++)-43],n[u++]=i<<2|s>>4,o!==64&&(n[u++]=(s&15)<<4|o>>2,a!==64&&(n[u++]=(o&3)<<6|a));return e?u-r:n.subarray(0,u)};R.binary.base58.encode=function(t,e){return R.binary.baseN.encode(t,qp,e)};R.binary.base58.decode=function(t,e){return R.binary.baseN.decode(t,qp,e)};R.text={utf8:{},utf16:{}};R.text.utf8.encode=function(t,e,r){t=R.encodeUtf8(t);var n=e;n||(n=new Uint8Array(t.length)),r=r||0;for(var i=r,s=0;s<t.length;++s)n[i++]=t.charCodeAt(s);return e?i-r:n};R.text.utf8.decode=function(t){return R.decodeUtf8(String.fromCharCode.apply(null,t))};R.text.utf16.encode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length*2));var i=new Uint16Array(n.buffer);r=r||0;for(var s=r,o=r,a=0;a<t.length;++a)i[o++]=t.charCodeAt(a),s+=2;return e?s-r:n};R.text.utf16.decode=function(t){return String.fromCharCode.apply(null,new Uint16Array(t.buffer))};R.deflate=function(t,e,r){if(e=R.decode64(t.deflate(R.encode64(e)).rval),r){var n=2,i=e.charCodeAt(1);i&32&&(n=6),e=e.substring(n,e.length-4)}return e};R.inflate=function(t,e,r){var n=t.inflate(R.encode64(e)).rval;return n===null?null:R.decode64(n)};var bl=function(t,e,r){if(!t)throw new Error("WebStorage not available.");var n;if(r===null?n=t.removeItem(e):(r=R.encode64(JSON.stringify(r)),n=t.setItem(e,r)),typeof n!="undefined"&&n.rval!==!0){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},El=function(t,e){if(!t)throw new Error("WebStorage not available.");var r=t.getItem(e);if(t.init)if(r.rval===null){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return r!==null&&(r=JSON.parse(R.decode64(r))),r},QI=function(t,e,r,n){var i=El(t,e);i===null&&(i={}),i[r]=n,bl(t,e,i)},XI=function(t,e,r){var n=El(t,e);return n!==null&&(n=r in n?n[r]:null),n},ZI=function(t,e,r){var n=El(t,e);if(n!==null&&r in n){delete n[r];var i=!0;for(var s in n){i=!1;break}i&&(n=null),bl(t,e,n)}},JI=function(t,e){bl(t,e,null)},Ja=function(t,e,r){var n=null;typeof r=="undefined"&&(r=["web","flash"]);var i,s=!1,o=null;for(var a in r){i=r[a];try{if(i==="flash"||i==="both"){if(e[0]===null)throw new Error("Flash local storage not available.");n=t.apply(this,e),s=i==="flash"}(i==="web"||i==="both")&&(e[0]=localStorage,n=t.apply(this,e),s=!0)}catch(c){o=c}if(s)break}if(!s)throw o;return n};R.setItem=function(t,e,r,n,i){Ja(QI,arguments,i)};R.getItem=function(t,e,r,n){return Ja(XI,arguments,n)};R.removeItem=function(t,e,r,n){Ja(ZI,arguments,n)};R.clearItems=function(t,e,r){Ja(JI,arguments,r)};R.parseUrl=function(t){var e=/^(https?):\/\/([^:&^\/]*):?(\d*)(.*)$/g;e.lastIndex=0;var r=e.exec(t),n=r===null?null:{full:t,scheme:r[1],host:r[2],port:r[3],path:r[4]};return n&&(n.fullHost=n.host,n.port?(n.port!==80&&n.scheme==="http"||n.port!==443&&n.scheme==="https")&&(n.fullHost+=":"+n.port):n.scheme==="http"?n.port=80:n.scheme==="https"&&(n.port=443),n.full=n.scheme+"://"+n.fullHost),n};var ec=null;R.getQueryVariables=function(t){var e=function(n){for(var i={},s=n.split("&"),o=0;o<s.length;o++){var a=s[o].indexOf("="),c,u;a>0?(c=s[o].substring(0,a),u=s[o].substring(a+1)):(c=s[o],u=null),c in i||(i[c]=[]),!(c in Object.prototype)&&u!==null&&i[c].push(unescape(u))}return i},r;return typeof t=="undefined"?(ec===null&&(typeof window!="undefined"&&window.location&&window.location.search?ec=e(window.location.search.substring(1)):ec={}),r=ec):r=e(t),r};R.parseFragment=function(t){var e=t,r="",n=t.indexOf("?");n>0&&(e=t.substring(0,n),r=t.substring(n+1));var i=e.split("/");i.length>0&&i[0]===""&&i.shift();var s=r===""?{}:R.getQueryVariables(r);return{pathString:e,queryString:r,path:i,query:s}};R.makeRequest=function(t){var e=R.parseFragment(t),r={path:e.pathString,query:e.queryString,getPath:function(n){return typeof n=="undefined"?e.path:e.path[n]},getQuery:function(n,i){var s;return typeof n=="undefined"?s=e.query:(s=e.query[n],s&&typeof i!="undefined"&&(s=s[i])),s},getQueryLast:function(n,i){var s,o=r.getQuery(n);return o?s=o[o.length-1]:s=i,s}};return r};R.makeLink=function(t,e,r){t=jQuery.isArray(t)?t.join("/"):t;var n=jQuery.param(e||{});return r=r||"",t+(n.length>0?"?"+n:"")+(r.length>0?"#"+r:"")};R.isEmpty=function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0};R.format=function(t){for(var e=/%./g,r,n,i=0,s=[],o=0;r=e.exec(t);){n=t.substring(o,e.lastIndex-2),n.length>0&&s.push(n),o=e.lastIndex;var a=r[0][1];switch(a){case"s":case"o":i<arguments.length?s.push(arguments[i+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(t.substring(o)),s.join("")};R.formatNumber=function(t,e,r,n){var i=t,s=isNaN(e=Math.abs(e))?2:e,o=r===void 0?",":r,a=n===void 0?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-u).toFixed(s).slice(2):"")};R.formatSize=function(t){return t>=1073741824?t=R.formatNumber(t/1073741824,2,".","")+" GiB":t>=1048576?t=R.formatNumber(t/1048576,2,".","")+" MiB":t>=1024?t=R.formatNumber(t/1024,0)+" KiB":t=R.formatNumber(t,0)+" bytes",t};R.bytesFromIP=function(t){return t.indexOf(".")!==-1?R.bytesFromIPv4(t):t.indexOf(":")!==-1?R.bytesFromIPv6(t):null};R.bytesFromIPv4=function(t){if(t=t.split("."),t.length!==4)return null;for(var e=R.createBuffer(),r=0;r<t.length;++r){var n=parseInt(t[r],10);if(isNaN(n))return null;e.putByte(n)}return e.getBytes()};R.bytesFromIPv6=function(t){var e=0;t=t.split(":").filter(function(o){return o.length===0&&++e,!0});for(var r=(8-t.length+e)*2,n=R.createBuffer(),i=0;i<8;++i){if(!t[i]||t[i].length===0){n.fillWithByte(0,r),r=0;continue}var s=R.hexToBytes(t[i]);s.length<2&&n.putByte(0),n.putBytes(s)}return n.getBytes()};R.bytesToIP=function(t){return t.length===4?R.bytesToIPv4(t):t.length===16?R.bytesToIPv6(t):null};R.bytesToIPv4=function(t){if(t.length!==4)return null;for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e.join(".")};R.bytesToIPv6=function(t){if(t.length!==16)return null;for(var e=[],r=[],n=0,i=0;i<t.length;i+=2){for(var s=R.bytesToHex(t[i]+t[i+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var o=r[r.length-1],a=e.length;!o||a!==o.end+1?r.push({start:a,end:a}):(o.end=a,o.end-o.start>r[n].end-r[n].start&&(n=r.length-1))}e.push(s)}if(r.length>0){var c=r[n];c.end-c.start>0&&(e.splice(c.start,c.end-c.start+1,""),c.start===0&&e.unshift(""),c.end===7&&e.push(""))}return e.join(":")};R.estimateCores=function(t,e){if(typeof t=="function"&&(e=t,t={}),t=t||{},"cores"in R&&!t.update)return e(null,R.cores);if(typeof navigator!="undefined"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return R.cores=navigator.hardwareConcurrency,e(null,R.cores);if(typeof Worker=="undefined")return R.cores=1,e(null,R.cores);if(typeof Blob=="undefined")return R.cores=2,e(null,R.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(o){for(var a=Date.now(),c=a+4;Date.now()<c;);self.postMessage({st:a,et:c})})}.toString(),")()"],{type:"application/javascript"}));n([],5,16);function n(o,a,c){if(a===0){var u=Math.floor(o.reduce(function(l,f){return l+f},0)/o.length);return R.cores=Math.max(1,u),URL.revokeObjectURL(r),e(null,R.cores)}i(c,function(l,f){o.push(s(c,f)),n(o,a-1,c)})}function i(o,a){for(var c=[],u=[],l=0;l<o;++l){var f=new Worker(r);f.addEventListener("message",function(h){if(u.push(h.data),u.length===o){for(var p=0;p<o;++p)c[p].terminate();a(null,u)}}),c.push(f)}for(var l=0;l<o;++l)c[l].postMessage(l)}function s(o,a){for(var c=[],u=0;u<o;++u)for(var l=a[u],f=c[u]=[],h=0;h<o;++h)if(u!==h){var p=a[h];(l.st>p.st&&l.st<p.et||p.st>l.st&&p.st<l.et)&&f.push(h)}return c.reduce(function(d,g){return Math.max(d,g.length)},0)}}});var bs=w((tq,Mp)=>{var Oo=Ee();Oo.pki=Oo.pki||{};var wl=Mp.exports=Oo.pki.oids=Oo.oids=Oo.oids||{};function $(t,e){wl[t]=e,wl[e]=t}function Oe(t,e){wl[t]=e}$("1.2.840.113549.1.1.1","rsaEncryption");$("1.2.840.113549.1.1.4","md5WithRSAEncryption");$("1.2.840.113549.1.1.5","sha1WithRSAEncryption");$("1.2.840.113549.1.1.7","RSAES-OAEP");$("1.2.840.113549.1.1.8","mgf1");$("1.2.840.113549.1.1.9","pSpecified");$("1.2.840.113549.1.1.10","RSASSA-PSS");$("1.2.840.113549.1.1.11","sha256WithRSAEncryption");$("1.2.840.113549.1.1.12","sha384WithRSAEncryption");$("1.2.840.113549.1.1.13","sha512WithRSAEncryption");$("1.3.101.112","EdDSA25519");$("1.2.840.10040.4.3","dsa-with-sha1");$("1.3.14.3.2.7","desCBC");$("1.3.14.3.2.26","sha1");$("2.16.840.1.101.3.4.2.1","sha256");$("2.16.840.1.101.3.4.2.2","sha384");$("2.16.840.1.101.3.4.2.3","sha512");$("1.2.840.113549.2.5","md5");$("1.2.840.113549.1.7.1","data");$("1.2.840.113549.1.7.2","signedData");$("1.2.840.113549.1.7.3","envelopedData");$("1.2.840.113549.1.7.4","signedAndEnvelopedData");$("1.2.840.113549.1.7.5","digestedData");$("1.2.840.113549.1.7.6","encryptedData");$("1.2.840.113549.1.9.1","emailAddress");$("1.2.840.113549.1.9.2","unstructuredName");$("1.2.840.113549.1.9.3","contentType");$("1.2.840.113549.1.9.4","messageDigest");$("1.2.840.113549.1.9.5","signingTime");$("1.2.840.113549.1.9.6","counterSignature");$("1.2.840.113549.1.9.7","challengePassword");$("1.2.840.113549.1.9.8","unstructuredAddress");$("1.2.840.113549.1.9.14","extensionRequest");$("1.2.840.113549.1.9.20","friendlyName");$("1.2.840.113549.1.9.21","localKeyId");$("1.2.840.113549.1.9.22.1","x509Certificate");$("1.2.840.113549.1.12.10.1.1","keyBag");$("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");$("1.2.840.113549.1.12.10.1.3","certBag");$("1.2.840.113549.1.12.10.1.4","crlBag");$("1.2.840.113549.1.12.10.1.5","secretBag");$("1.2.840.113549.1.12.10.1.6","safeContentsBag");$("1.2.840.113549.1.5.13","pkcs5PBES2");$("1.2.840.113549.1.5.12","pkcs5PBKDF2");$("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");$("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");$("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");$("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");$("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");$("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");$("1.2.840.113549.2.7","hmacWithSHA1");$("1.2.840.113549.2.8","hmacWithSHA224");$("1.2.840.113549.2.9","hmacWithSHA256");$("1.2.840.113549.2.10","hmacWithSHA384");$("1.2.840.113549.2.11","hmacWithSHA512");$("1.2.840.113549.3.7","des-EDE3-CBC");$("2.16.840.1.101.3.4.1.2","aes128-CBC");$("2.16.840.1.101.3.4.1.22","aes192-CBC");$("2.16.840.1.101.3.4.1.42","aes256-CBC");$("2.5.4.3","commonName");$("2.5.4.5","serialName");$("2.5.4.6","countryName");$("2.5.4.7","localityName");$("2.5.4.8","stateOrProvinceName");$("2.5.4.9","streetAddress");$("2.5.4.10","organizationName");$("2.5.4.11","organizationalUnitName");$("2.5.4.13","description");$("2.5.4.15","businessCategory");$("2.5.4.17","postalCode");$("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");$("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");$("2.16.840.1.113730.1.1","nsCertType");$("2.16.840.1.113730.1.13","nsComment");Oe("2.5.29.1","authorityKeyIdentifier");Oe("2.5.29.2","keyAttributes");Oe("2.5.29.3","certificatePolicies");Oe("2.5.29.4","keyUsageRestriction");Oe("2.5.29.5","policyMapping");Oe("2.5.29.6","subtreesConstraint");Oe("2.5.29.7","subjectAltName");Oe("2.5.29.8","issuerAltName");Oe("2.5.29.9","subjectDirectoryAttributes");Oe("2.5.29.10","basicConstraints");Oe("2.5.29.11","nameConstraints");Oe("2.5.29.12","policyConstraints");Oe("2.5.29.13","basicConstraints");$("2.5.29.14","subjectKeyIdentifier");$("2.5.29.15","keyUsage");Oe("2.5.29.16","privateKeyUsagePeriod");$("2.5.29.17","subjectAltName");$("2.5.29.18","issuerAltName");$("2.5.29.19","basicConstraints");Oe("2.5.29.20","cRLNumber");Oe("2.5.29.21","cRLReason");Oe("2.5.29.22","expirationDate");Oe("2.5.29.23","instructionCode");Oe("2.5.29.24","invalidityDate");Oe("2.5.29.25","cRLDistributionPoints");Oe("2.5.29.26","issuingDistributionPoint");Oe("2.5.29.27","deltaCRLIndicator");Oe("2.5.29.28","issuingDistributionPoint");Oe("2.5.29.29","certificateIssuer");Oe("2.5.29.30","nameConstraints");$("2.5.29.31","cRLDistributionPoints");$("2.5.29.32","certificatePolicies");Oe("2.5.29.33","policyMappings");Oe("2.5.29.34","policyConstraints");$("2.5.29.35","authorityKeyIdentifier");Oe("2.5.29.36","policyConstraints");$("2.5.29.37","extKeyUsage");Oe("2.5.29.46","freshestCRL");Oe("2.5.29.54","inhibitAnyPolicy");$("1.3.6.1.4.1.11129.2.4.2","timestampList");$("1.3.6.1.5.5.7.1.1","authorityInfoAccess");$("1.3.6.1.5.5.7.3.1","serverAuth");$("1.3.6.1.5.5.7.3.2","clientAuth");$("1.3.6.1.5.5.7.3.3","codeSigning");$("1.3.6.1.5.5.7.3.4","emailProtection");$("1.3.6.1.5.5.7.3.8","timeStamping")});var Un=w((rq,Kp)=>{var Qe=Ee();je();bs();var Z=Kp.exports=Qe.asn1=Qe.asn1||{};Z.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};Z.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};Z.create=function(t,e,r,n,i){if(Qe.util.isArray(n)){for(var s=[],o=0;o<n.length;++o)n[o]!==void 0&&s.push(n[o]);n=s}var a={tagClass:t,type:e,constructed:r,composed:r||Qe.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(a.bitStringContents=i.bitStringContents,a.original=Z.copy(a)),a};Z.copy=function(t,e){var r;if(Qe.util.isArray(t)){r=[];for(var n=0;n<t.length;++n)r.push(Z.copy(t[n],e));return r}return typeof t=="string"?t:(r={tagClass:t.tagClass,type:t.type,constructed:t.constructed,composed:t.composed,value:Z.copy(t.value,e)},e&&!e.excludeBitStringContents&&(r.bitStringContents=t.bitStringContents),r)};Z.equals=function(t,e,r){if(Qe.util.isArray(t)){if(!Qe.util.isArray(e)||t.length!==e.length)return!1;for(var n=0;n<t.length;++n)if(!Z.equals(t[n],e[n]))return!1;return!0}if(typeof t!=typeof e)return!1;if(typeof t=="string")return t===e;var i=t.tagClass===e.tagClass&&t.type===e.type&&t.constructed===e.constructed&&t.composed===e.composed&&Z.equals(t.value,e.value);return r&&r.includeBitStringContents&&(i=i&&t.bitStringContents===e.bitStringContents),i};Z.getBerValueLength=function(t){var e=t.getByte();if(e!==128){var r,n=e&128;return n?r=t.getInt((e&127)<<3):r=e,r}};function Do(t,e,r){if(r>e){var n=new Error("Too few bytes to parse DER.");throw n.available=t.length(),n.remaining=e,n.requested=r,n}}var eT=function(t,e){var r=t.getByte();if(e--,r!==128){var n,i=r&128;if(!i)n=r;else{var s=r&127;Do(t,e,s),n=t.getInt(s<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};Z.fromDer=function(t,e){return e===void 0&&(e={strict:!0,decodeBitStrings:!0}),typeof e=="boolean"&&(e={strict:e,decodeBitStrings:!0}),"strict"in e||(e.strict=!0),"decodeBitStrings"in e||(e.decodeBitStrings=!0),typeof t=="string"&&(t=Qe.util.createBuffer(t)),tc(t,t.length(),0,e)};function tc(t,e,r,n){var i;Do(t,e,2);var s=t.getByte();e--;var o=s&192,a=s&31;i=t.length();var c=eT(t,e);if(e-=i-t.length(),c!==void 0&&c>e){if(n.strict){var u=new Error("Too few bytes to read ASN.1 value.");throw u.available=t.length(),u.remaining=e,u.requested=c,u}c=e}var l,f,h=(s&32)==32;if(h)if(l=[],c===void 0)for(;;){if(Do(t,e,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),e-=2;break}i=t.length(),l.push(tc(t,e,r+1,n)),e-=i-t.length()}else for(;c>0;)i=t.length(),l.push(tc(t,c,r+1,n)),e-=i-t.length(),c-=i-t.length();if(l===void 0&&o===Z.Class.UNIVERSAL&&a===Z.Type.BITSTRING&&(f=t.bytes(c)),l===void 0&&n.decodeBitStrings&&o===Z.Class.UNIVERSAL&&a===Z.Type.BITSTRING&&c>1){var p=t.read,d=e,g=0;if(a===Z.Type.BITSTRING&&(Do(t,e,1),g=t.getByte(),e--),g===0)try{i=t.length();var m={verbose:n.verbose,strict:!0,decodeBitStrings:!0},x=tc(t,e,r+1,m),B=i-t.length();e-=B,a==Z.Type.BITSTRING&&B++;var L=x.tagClass;B===c&&(L===Z.Class.UNIVERSAL||L===Z.Class.CONTEXT_SPECIFIC)&&(l=[x])}catch(U){}l===void 0&&(t.read=p,e=d)}if(l===void 0){if(c===void 0){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");c=e}if(a===Z.Type.BMPSTRING)for(l="";c>0;c-=2)Do(t,e,2),l+=String.fromCharCode(t.getInt16()),e-=2;else l=t.getBytes(c)}var H=f===void 0?null:{bitStringContents:f};return Z.create(o,a,h,l,H)}Z.toDer=function(t){var e=Qe.util.createBuffer(),r=t.tagClass|t.type,n=Qe.util.createBuffer(),i=!1;if("bitStringContents"in t&&(i=!0,t.original&&(i=Z.equals(t,t.original))),i)n.putBytes(t.bitStringContents);else if(t.composed){t.constructed?r|=32:n.putByte(0);for(var s=0;s<t.value.length;++s)t.value[s]!==void 0&&n.putBuffer(Z.toDer(t.value[s]))}else if(t.type===Z.Type.BMPSTRING)for(var s=0;s<t.value.length;++s)n.putInt16(t.value.charCodeAt(s));else t.type===Z.Type.INTEGER&&t.value.length>1&&(t.value.charCodeAt(0)===0&&(t.value.charCodeAt(1)&128)==0||t.value.charCodeAt(0)===255&&(t.value.charCodeAt(1)&128)==128)?n.putBytes(t.value.substr(1)):n.putBytes(t.value);if(e.putByte(r),n.length()<=127)e.putByte(n.length()&127);else{var o=n.length(),a="";do a+=String.fromCharCode(o&255),o=o>>>8;while(o>0);e.putByte(a.length|128);for(var s=a.length-1;s>=0;--s)e.putByte(a.charCodeAt(s))}return e.putBuffer(n),e};Z.oidToDer=function(t){var e=t.split("."),r=Qe.util.createBuffer();r.putByte(40*parseInt(e[0],10)+parseInt(e[1],10));for(var n,i,s,o,a=2;a<e.length;++a){n=!0,i=[],s=parseInt(e[a],10);do o=s&127,s=s>>>7,n||(o|=128),i.push(o),n=!1;while(s>0);for(var c=i.length-1;c>=0;--c)r.putByte(i[c])}return r};Z.derToOid=function(t){var e;typeof t=="string"&&(t=Qe.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+"."+r%40;for(var n=0;t.length()>0;)r=t.getByte(),n=n<<7,r&128?n+=r&127:(e+="."+(n+r),n=0);return e};Z.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(t.substr(2,2),10)-1,i=parseInt(t.substr(4,2),10),s=parseInt(t.substr(6,2),10),o=parseInt(t.substr(8,2),10),a=0;if(t.length>11){var c=t.charAt(10),u=10;c!=="+"&&c!=="-"&&(a=parseInt(t.substr(10,2),10),u+=2)}if(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,0),u&&(c=t.charAt(u),c==="+"||c==="-")){var l=parseInt(t.substr(u+1,2),10),f=parseInt(t.substr(u+4,2),10),h=l*60+f;h*=6e4,c==="+"?e.setTime(+e-h):e.setTime(+e+h)}return e};Z.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),n=parseInt(t.substr(4,2),10)-1,i=parseInt(t.substr(6,2),10),s=parseInt(t.substr(8,2),10),o=parseInt(t.substr(10,2),10),a=parseInt(t.substr(12,2),10),c=0,u=0,l=!1;t.charAt(t.length-1)==="Z"&&(l=!0);var f=t.length-5,h=t.charAt(f);if(h==="+"||h==="-"){var p=parseInt(t.substr(f+1,2),10),d=parseInt(t.substr(f+4,2),10);u=p*60+d,u*=6e4,h==="+"&&(u*=-1),l=!0}return t.charAt(14)==="."&&(c=parseFloat(t.substr(14),10)*1e3),l?(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,c),e.setTime(+e+u)):(e.setFullYear(r,n,i),e.setHours(s,o,a,c)),e};Z.dateToUtcTime=function(t){if(typeof t=="string")return t;var e="",r=[];r.push((""+t.getUTCFullYear()).substr(2)),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(e+="0"),e+=r[n];return e+="Z",e};Z.dateToGeneralizedTime=function(t){if(typeof t=="string")return t;var e="",r=[];r.push(""+t.getUTCFullYear()),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(e+="0"),e+=r[n];return e+="Z",e};Z.integerToDer=function(t){var e=Qe.util.createBuffer();if(t>=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=t,r};Z.derToInteger=function(t){typeof t=="string"&&(t=Qe.util.createBuffer(t));var e=t.length()*8;if(e>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(e)};Z.validate=function(t,e,r,n){var i=!1;if((t.tagClass===e.tagClass||typeof e.tagClass=="undefined")&&(t.type===e.type||typeof e.type=="undefined"))if(t.constructed===e.constructed||typeof e.constructed=="undefined"){if(i=!0,e.value&&Qe.util.isArray(e.value))for(var s=0,o=0;i&&o<e.value.length;++o)i=e.value[o].optional||!1,t.value[s]&&(i=Z.validate(t.value[s],e.value[o],r,n),i?++s:e.value[o].optional&&(i=!0)),!i&&n&&n.push("["+e.name+'] Tag class "'+e.tagClass+'", type "'+e.type+'" expected value length "'+e.value.length+'", got "'+t.value.length+'"');if(i&&r&&(e.capture&&(r[e.capture]=t.value),e.captureAsn1&&(r[e.captureAsn1]=t),e.captureBitStringContents&&"bitStringContents"in t&&(r[e.captureBitStringContents]=t.bitStringContents),e.captureBitStringValue&&"bitStringContents"in t)){var a;if(t.bitStringContents.length<2)r[e.captureBitStringValue]="";else{var c=t.bitStringContents.charCodeAt(0);if(c!==0)throw new Error("captureBitStringValue only supported for zero unused bits");r[e.captureBitStringValue]=t.bitStringContents.slice(1)}}}else n&&n.push("["+e.name+'] Expected constructed "'+e.constructed+'", got "'+t.constructed+'"');else n&&(t.tagClass!==e.tagClass&&n.push("["+e.name+'] Expected tag class "'+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&n.push("["+e.name+'] Expected type "'+e.type+'", got "'+t.type+'"'));return i};var Fp=/[^\\u0000-\\u00ff]/;Z.prettyPrint=function(t,e,r){var n="";e=e||0,r=r||2,e>0&&(n+=`
20
- `);for(var i="",s=0;s<e*r;++s)i+=" ";switch(n+=i+"Tag: ",t.tagClass){case Z.Class.UNIVERSAL:n+="Universal:";break;case Z.Class.APPLICATION:n+="Application:";break;case Z.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case Z.Class.PRIVATE:n+="Private:";break}if(t.tagClass===Z.Class.UNIVERSAL)switch(n+=t.type,t.type){case Z.Type.NONE:n+=" (None)";break;case Z.Type.BOOLEAN:n+=" (Boolean)";break;case Z.Type.INTEGER:n+=" (Integer)";break;case Z.Type.BITSTRING:n+=" (Bit string)";break;case Z.Type.OCTETSTRING:n+=" (Octet string)";break;case Z.Type.NULL:n+=" (Null)";break;case Z.Type.OID:n+=" (Object Identifier)";break;case Z.Type.ODESC:n+=" (Object Descriptor)";break;case Z.Type.EXTERNAL:n+=" (External or Instance of)";break;case Z.Type.REAL:n+=" (Real)";break;case Z.Type.ENUMERATED:n+=" (Enumerated)";break;case Z.Type.EMBEDDED:n+=" (Embedded PDV)";break;case Z.Type.UTF8:n+=" (UTF8)";break;case Z.Type.ROID:n+=" (Relative Object Identifier)";break;case Z.Type.SEQUENCE:n+=" (Sequence)";break;case Z.Type.SET:n+=" (Set)";break;case Z.Type.PRINTABLESTRING:n+=" (Printable String)";break;case Z.Type.IA5String:n+=" (IA5String (ASCII))";break;case Z.Type.UTCTIME:n+=" (UTC time)";break;case Z.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case Z.Type.BMPSTRING:n+=" (BMP String)";break}else n+=t.type;if(n+=`
16
+ `});var Za={};gt(Za,{base36:()=>oT,base36upper:()=>aT});var oT,aT,yl=xe(()=>{Kr();oT=On({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),aT=On({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})});var bs={};gt(bs,{base64:()=>cT,base64pad:()=>uT,base64url:()=>lT,base64urlpad:()=>fT});var cT,uT,lT,fT,Lo=xe(()=>{Kr();cT=ct({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),uT=ct({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),lT=ct({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fT=ct({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});var Ja={};gt(Ja,{base16:()=>hT,base16upper:()=>dT});var hT,dT,gl=xe(()=>{Kr();hT=ct({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dT=ct({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});var G0=w((mq,z0)=>{"use strict";z0.exports=pT;function pT(t,e){for(var r=new Array(arguments.length-1),n=0,i=2,s=!0;i<arguments.length;)r[n++]=arguments[i++];return new Promise(function(a,c){r[n]=function(l){if(s)if(s=!1,l)c(l);else{for(var f=new Array(arguments.length-1),h=0;h<f.length;)f[h++]=arguments[h];a.apply(null,f)}};try{t.apply(e||null,r)}catch(u){s&&(s=!1,c(u))}})}});var X0=w(Q0=>{"use strict";var ec=Q0;ec.length=function(e){var r=e.length;if(!r)return 0;for(var n=0;--r%4>1&&e.charAt(r)==="=";)++n;return Math.ceil(e.length*3)/4-n};var Es=new Array(64),W0=new Array(123);for(Rr=0;Rr<64;)W0[Es[Rr]=Rr<26?Rr+65:Rr<52?Rr+71:Rr<62?Rr-4:Rr-59|43]=Rr++;var Rr;ec.encode=function(e,r,n){for(var i=null,s=[],o=0,a=0,c;r<n;){var u=e[r++];switch(a){case 0:s[o++]=Es[u>>2],c=(u&3)<<4,a=1;break;case 1:s[o++]=Es[c|u>>4],c=(u&15)<<2,a=2;break;case 2:s[o++]=Es[c|u>>6],s[o++]=Es[u&63],a=0;break}o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),o=0)}return a&&(s[o++]=Es[c],s[o++]=61,a===1&&(s[o++]=61)),i?(o&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))};var Y0="invalid encoding";ec.decode=function(e,r,n){for(var i=n,s=0,o,a=0;a<e.length;){var c=e.charCodeAt(a++);if(c===61&&s>1)break;if((c=W0[c])===void 0)throw Error(Y0);switch(s){case 0:o=c,s=1;break;case 1:r[n++]=o<<2|(c&48)>>4,o=c,s=2;break;case 2:r[n++]=(o&15)<<4|(c&60)>>2,o=c,s=3;break;case 3:r[n++]=(o&3)<<6|c,s=0;break}}if(s===1)throw Error(Y0);return n-i};ec.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}});var J0=w((bq,Z0)=>{"use strict";Z0.exports=tc;function tc(){this._listeners={}}tc.prototype.on=function(e,r,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:r,ctx:n||this}),this};tc.prototype.off=function(e,r){if(e===void 0)this._listeners={};else if(r===void 0)this._listeners[e]=[];else for(var n=this._listeners[e],i=0;i<n.length;)n[i].fn===r?n.splice(i,1):++i;return this};tc.prototype.emit=function(e){var r=this._listeners[e];if(r){for(var n=[],i=1;i<arguments.length;)n.push(arguments[i++]);for(i=0;i<r.length;)r[i].fn.apply(r[i++].ctx,n)}return this}});var op=w((Eq,sp)=>{"use strict";sp.exports=ep(ep);function ep(t){return typeof Float32Array!="undefined"?function(){var e=new Float32Array([-0]),r=new Uint8Array(e.buffer),n=r[3]===128;function i(c,u,l){e[0]=c,u[l]=r[0],u[l+1]=r[1],u[l+2]=r[2],u[l+3]=r[3]}function s(c,u,l){e[0]=c,u[l]=r[3],u[l+1]=r[2],u[l+2]=r[1],u[l+3]=r[0]}t.writeFloatLE=n?i:s,t.writeFloatBE=n?s:i;function o(c,u){return r[0]=c[u],r[1]=c[u+1],r[2]=c[u+2],r[3]=c[u+3],e[0]}function a(c,u){return r[3]=c[u],r[2]=c[u+1],r[1]=c[u+2],r[0]=c[u+3],e[0]}t.readFloatLE=n?o:a,t.readFloatBE=n?a:o}():function(){function e(n,i,s,o){var a=i<0?1:0;if(a&&(i=-i),i===0)n(1/i>0?0:2147483648,s,o);else if(isNaN(i))n(2143289344,s,o);else if(i>34028234663852886e22)n((a<<31|2139095040)>>>0,s,o);else if(i<11754943508222875e-54)n((a<<31|Math.round(i/1401298464324817e-60))>>>0,s,o);else{var c=Math.floor(Math.log(i)/Math.LN2),u=Math.round(i*Math.pow(2,-c)*8388608)&8388607;n((a<<31|c+127<<23|u)>>>0,s,o)}}t.writeFloatLE=e.bind(null,tp),t.writeFloatBE=e.bind(null,rp);function r(n,i,s){var o=n(i,s),a=(o>>31)*2+1,c=o>>>23&255,u=o&8388607;return c===255?u?NaN:a*(1/0):c===0?a*1401298464324817e-60*u:a*Math.pow(2,c-150)*(u+8388608)}t.readFloatLE=r.bind(null,np),t.readFloatBE=r.bind(null,ip)}(),typeof Float64Array!="undefined"?function(){var e=new Float64Array([-0]),r=new Uint8Array(e.buffer),n=r[7]===128;function i(c,u,l){e[0]=c,u[l]=r[0],u[l+1]=r[1],u[l+2]=r[2],u[l+3]=r[3],u[l+4]=r[4],u[l+5]=r[5],u[l+6]=r[6],u[l+7]=r[7]}function s(c,u,l){e[0]=c,u[l]=r[7],u[l+1]=r[6],u[l+2]=r[5],u[l+3]=r[4],u[l+4]=r[3],u[l+5]=r[2],u[l+6]=r[1],u[l+7]=r[0]}t.writeDoubleLE=n?i:s,t.writeDoubleBE=n?s:i;function o(c,u){return r[0]=c[u],r[1]=c[u+1],r[2]=c[u+2],r[3]=c[u+3],r[4]=c[u+4],r[5]=c[u+5],r[6]=c[u+6],r[7]=c[u+7],e[0]}function a(c,u){return r[7]=c[u],r[6]=c[u+1],r[5]=c[u+2],r[4]=c[u+3],r[3]=c[u+4],r[2]=c[u+5],r[1]=c[u+6],r[0]=c[u+7],e[0]}t.readDoubleLE=n?o:a,t.readDoubleBE=n?a:o}():function(){function e(n,i,s,o,a,c){var u=o<0?1:0;if(u&&(o=-o),o===0)n(0,a,c+i),n(1/o>0?0:2147483648,a,c+s);else if(isNaN(o))n(0,a,c+i),n(2146959360,a,c+s);else if(o>17976931348623157e292)n(0,a,c+i),n((u<<31|2146435072)>>>0,a,c+s);else{var l;if(o<22250738585072014e-324)l=o/5e-324,n(l>>>0,a,c+i),n((u<<31|l/4294967296)>>>0,a,c+s);else{var f=Math.floor(Math.log(o)/Math.LN2);f===1024&&(f=1023),l=o*Math.pow(2,-f),n(l*4503599627370496>>>0,a,c+i),n((u<<31|f+1023<<20|l*1048576&1048575)>>>0,a,c+s)}}}t.writeDoubleLE=e.bind(null,tp,0,4),t.writeDoubleBE=e.bind(null,rp,4,0);function r(n,i,s,o,a){var c=n(o,a+i),u=n(o,a+s),l=(u>>31)*2+1,f=u>>>20&2047,h=4294967296*(u&1048575)+c;return f===2047?h?NaN:l*(1/0):f===0?l*5e-324*h:l*Math.pow(2,f-1075)*(h+4503599627370496)}t.readDoubleLE=r.bind(null,np,0,4),t.readDoubleBE=r.bind(null,ip,4,0)}(),t}function tp(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function rp(t,e,r){e[r]=t>>>24,e[r+1]=t>>>16&255,e[r+2]=t>>>8&255,e[r+3]=t&255}function np(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0}function ip(t,e){return(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}});var ap=w((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(t){}return null}});var up=w(cp=>{"use strict";var ml=cp;ml.length=function(e){for(var r=0,n=0,i=0;i<e.length;++i)n=e.charCodeAt(i),n<128?r+=1:n<2048?r+=2:(n&64512)==55296&&(e.charCodeAt(i+1)&64512)==56320?(++i,r+=4):r+=3;return r};ml.read=function(e,r,n){var i=n-r;if(i<1)return"";for(var s=null,o=[],a=0,c;r<n;)c=e[r++],c<128?o[a++]=c:c>191&&c<224?o[a++]=(c&31)<<6|e[r++]&63:c>239&&c<365?(c=((c&7)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,o[a++]=55296+(c>>10),o[a++]=56320+(c&1023)):o[a++]=(c&15)<<12|(e[r++]&63)<<6|e[r++]&63,a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0);return s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};ml.write=function(e,r,n){for(var i=n,s,o,a=0;a<e.length;++a)s=e.charCodeAt(a),s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=s&63|128):(s&64512)==55296&&((o=e.charCodeAt(a+1))&64512)==56320?(s=65536+((s&1023)<<10)+(o&1023),++a,r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128);return n-i}});var fp=w((_q,lp)=>{"use strict";lp.exports=yT;function yT(t,e,r){var n=r||8192,i=n>>>1,s=null,o=n;return function(c){if(c<1||c>i)return t(c);o+c>n&&(s=t(n),o=0);var u=e.call(s,o,o+=c);return o&7&&(o=(o|7)+1),u}}});var dp=w((xq,hp)=>{"use strict";hp.exports=wt;var ko=qn();function wt(t,e){this.lo=t>>>0,this.hi=e>>>0}var Ei=wt.zero=new wt(0,0);Ei.toNumber=function(){return 0};Ei.zzEncode=Ei.zzDecode=function(){return this};Ei.length=function(){return 1};var gT=wt.zeroHash="\0\0\0\0\0\0\0\0";wt.fromNumber=function(e){if(e===0)return Ei;var r=e<0;r&&(e=-e);var n=e>>>0,i=(e-n)/4294967296>>>0;return r&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new wt(n,i)};wt.from=function(e){if(typeof e=="number")return wt.fromNumber(e);if(ko.isString(e))if(ko.Long)e=ko.Long.fromString(e);else return wt.fromNumber(parseInt(e,10));return e.low||e.high?new wt(e.low>>>0,e.high>>>0):Ei};wt.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var r=~this.lo+1>>>0,n=~this.hi>>>0;return r||(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296};wt.prototype.toLong=function(e){return ko.Long?new ko.Long(this.lo|0,this.hi|0,Boolean(e)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(e)}};var kn=String.prototype.charCodeAt;wt.fromHash=function(e){return e===gT?Ei:new wt((kn.call(e,0)|kn.call(e,1)<<8|kn.call(e,2)<<16|kn.call(e,3)<<24)>>>0,(kn.call(e,4)|kn.call(e,5)<<8|kn.call(e,6)<<16|kn.call(e,7)<<24)>>>0)};wt.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};wt.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this};wt.prototype.zzDecode=function(){var e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this};wt.prototype.length=function(){var e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}});var qn=w(vl=>{"use strict";var se=vl;se.asPromise=G0();se.base64=X0();se.EventEmitter=J0();se.float=op();se.inquire=ap();se.utf8=up();se.pool=fp();se.LongBits=dp();se.isNode=Boolean(typeof globalThis!="undefined"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);se.global=se.isNode&&globalThis||typeof window!="undefined"&&window||typeof self!="undefined"&&self||vl;se.emptyArray=Object.freeze?Object.freeze([]):[];se.emptyObject=Object.freeze?Object.freeze({}):{};se.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};se.isString=function(e){return typeof e=="string"||e instanceof String};se.isObject=function(e){return e&&typeof e=="object"};se.isset=se.isSet=function(e,r){var n=e[r];return n!=null&&e.hasOwnProperty(r)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};se.Buffer=function(){try{var t=se.inquire("buffer").Buffer;return t.prototype.utf8Write?t:null}catch(e){return null}}();se._Buffer_from=null;se._Buffer_allocUnsafe=null;se.newBuffer=function(e){return typeof e=="number"?se.Buffer?se._Buffer_allocUnsafe(e):new se.Array(e):se.Buffer?se._Buffer_from(e):typeof Uint8Array=="undefined"?e:new Uint8Array(e)};se.Array=typeof Uint8Array!="undefined"?Uint8Array:Array;se.Long=se.global.dcodeIO&&se.global.dcodeIO.Long||se.global.Long||se.inquire("long");se.key2Re=/^true|false|0|1$/;se.key32Re=/^-?(?:0|[1-9][0-9]*)$/;se.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;se.longToHash=function(e){return e?se.LongBits.from(e).toHash():se.LongBits.zeroHash};se.longFromHash=function(e,r){var n=se.LongBits.fromHash(e);return se.Long?se.Long.fromBits(n.lo,n.hi,r):n.toNumber(Boolean(r))};function pp(t,e,r){for(var n=Object.keys(e),i=0;i<n.length;++i)(t[n[i]]===void 0||!r)&&(t[n[i]]=e[n[i]]);return t}se.merge=pp;se.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)};function yp(t){function e(r,n){if(!(this instanceof e))return new e(r,n);Object.defineProperty(this,"message",{get:function(){return r}}),Error.captureStackTrace?Error.captureStackTrace(this,e):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&pp(this,n)}return(e.prototype=Object.create(Error.prototype)).constructor=e,Object.defineProperty(e.prototype,"name",{get:function(){return t}}),e.prototype.toString=function(){return this.name+": "+this.message},e}se.newError=yp;se.ProtocolError=yp("ProtocolError");se.oneOfGetter=function(e){for(var r={},n=0;n<e.length;++n)r[e[n]]=1;return function(){for(var i=Object.keys(this),s=i.length-1;s>-1;--s)if(r[i[s]]===1&&this[i[s]]!==void 0&&this[i[s]]!==null)return i[s]}};se.oneOfSetter=function(e){return function(r){for(var n=0;n<e.length;++n)e[n]!==r&&delete this[e[n]]}};se.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};se._configure=function(){var t=se.Buffer;if(!t){se._Buffer_from=se._Buffer_allocUnsafe=null;return}se._Buffer_from=t.from!==Uint8Array.from&&t.from||function(r,n){return new t(r,n)},se._Buffer_allocUnsafe=t.allocUnsafe||function(r){return new t(r)}}});var Al=w((Aq,bp)=>{"use strict";bp.exports=Re;var ur=qn(),bl,rc=ur.LongBits,gp=ur.base64,mp=ur.utf8;function qo(t,e,r){this.fn=t,this.len=e,this.next=void 0,this.val=r}function El(){}function mT(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}function Re(){this.len=0,this.head=new qo(El,0,0),this.tail=this.head,this.states=null}var vp=function(){return ur.Buffer?function(){return(Re.create=function(){return new bl})()}:function(){return new Re}};Re.create=vp();Re.alloc=function(e){return new ur.Array(e)};ur.Array!==Array&&(Re.alloc=ur.pool(Re.alloc,ur.Array.prototype.subarray));Re.prototype._push=function(e,r,n){return this.tail=this.tail.next=new qo(e,r,n),this.len+=r,this};function wl(t,e,r){e[r]=t&255}function vT(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}function _l(t,e){this.len=t,this.next=void 0,this.val=e}_l.prototype=Object.create(qo.prototype);_l.prototype.fn=vT;Re.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new _l((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this};Re.prototype.int32=function(e){return e<0?this._push(xl,10,rc.fromNumber(e)):this.uint32(e)};Re.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)};function xl(t,e,r){for(;t.hi;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}Re.prototype.uint64=function(e){var r=rc.from(e);return this._push(xl,r.length(),r)};Re.prototype.int64=Re.prototype.uint64;Re.prototype.sint64=function(e){var r=rc.from(e).zzEncode();return this._push(xl,r.length(),r)};Re.prototype.bool=function(e){return this._push(wl,1,e?1:0)};function Sl(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}Re.prototype.fixed32=function(e){return this._push(Sl,4,e>>>0)};Re.prototype.sfixed32=Re.prototype.fixed32;Re.prototype.fixed64=function(e){var r=rc.from(e);return this._push(Sl,4,r.lo)._push(Sl,4,r.hi)};Re.prototype.sfixed64=Re.prototype.fixed64;Re.prototype.float=function(e){return this._push(ur.float.writeFloatLE,4,e)};Re.prototype.double=function(e){return this._push(ur.float.writeDoubleLE,8,e)};var bT=ur.Array.prototype.set?function(e,r,n){r.set(e,n)}:function(e,r,n){for(var i=0;i<e.length;++i)r[n+i]=e[i]};Re.prototype.bytes=function(e){var r=e.length>>>0;if(!r)return this._push(wl,1,0);if(ur.isString(e)){var n=Re.alloc(r=gp.length(e));gp.decode(e,n,0),e=n}return this.uint32(r)._push(bT,r,e)};Re.prototype.string=function(e){var r=mp.length(e);return r?this.uint32(r)._push(mp.write,r,e):this._push(wl,1,0)};Re.prototype.fork=function(){return this.states=new mT(this),this.head=this.tail=new qo(El,0,0),this.len=0,this};Re.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 qo(El,0,0),this.len=0),this};Re.prototype.ldelim=function(){var e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=r,this.len+=n),this};Re.prototype.finish=function(){for(var e=this.head.next,r=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r};Re._configure=function(t){bl=t,Re.create=vp(),bl._configure()}});var _p=w((Cq,wp)=>{"use strict";wp.exports=jr;var Ep=Al();(jr.prototype=Object.create(Ep.prototype)).constructor=jr;var Un=qn();function jr(){Ep.call(this)}jr._configure=function(){jr.alloc=Un._Buffer_allocUnsafe,jr.writeBytesBuffer=Un.Buffer&&Un.Buffer.prototype instanceof Uint8Array&&Un.Buffer.prototype.set.name==="set"?function(e,r,n){r.set(e,n)}:function(e,r,n){if(e.copy)e.copy(r,n,0,e.length);else for(var i=0;i<e.length;)r[n++]=e[i++]}};jr.prototype.bytes=function(e){Un.isString(e)&&(e=Un._Buffer_from(e,"base64"));var r=e.length>>>0;return this.uint32(r),r&&this._push(jr.writeBytesBuffer,r,e),this};function ET(t,e,r){t.length<40?Un.utf8.write(t,e,r):e.utf8Write?e.utf8Write(t,r):e.write(t,r)}jr.prototype.string=function(e){var r=Un.Buffer.byteLength(e);return this.uint32(r),r&&this._push(ET,r,e),this};jr._configure()});var Tl=w((Iq,Ip)=>{"use strict";Ip.exports=ht;var $r=qn(),Cl,xp=$r.LongBits,wT=$r.utf8;function Br(t,e){return RangeError("index out of range: "+t.pos+" + "+(e||1)+" > "+t.len)}function ht(t){this.buf=t,this.pos=0,this.len=t.length}var Sp=typeof Uint8Array!="undefined"?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new ht(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new ht(e);throw Error("illegal buffer")},Ap=function(){return $r.Buffer?function(r){return(ht.create=function(i){return $r.Buffer.isBuffer(i)?new Cl(i):Sp(i)})(r)}:Sp};ht.create=Ap();ht.prototype._slice=$r.Array.prototype.subarray||$r.Array.prototype.slice;ht.prototype.uint32=function(){var e=4294967295;return function(){if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Br(this,10);return e}}();ht.prototype.int32=function(){return this.uint32()|0};ht.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(e&1)|0};function Il(){var t=new xp(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Br(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Br(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}ht.prototype.bool=function(){return this.uint32()!==0};function nc(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}ht.prototype.fixed32=function(){if(this.pos+4>this.len)throw Br(this,4);return nc(this.buf,this.pos+=4)};ht.prototype.sfixed32=function(){if(this.pos+4>this.len)throw Br(this,4);return nc(this.buf,this.pos+=4)|0};function Cp(){if(this.pos+8>this.len)throw Br(this,8);return new xp(nc(this.buf,this.pos+=4),nc(this.buf,this.pos+=4))}ht.prototype.float=function(){if(this.pos+4>this.len)throw Br(this,4);var e=$r.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e};ht.prototype.double=function(){if(this.pos+8>this.len)throw Br(this,4);var e=$r.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e};ht.prototype.bytes=function(){var e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Br(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(r,n):r===n?new this.buf.constructor(0):this._slice.call(this.buf,r,n)};ht.prototype.string=function(){var e=this.bytes();return wT.read(e,0,e.length)};ht.prototype.skip=function(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Br(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Br(this);while(this.buf[this.pos++]&128);return this};ht.prototype.skipType=function(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!=4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+t+" at offset "+this.pos)}return this};ht._configure=function(t){Cl=t,ht.create=Ap(),Cl._configure();var e=$r.Long?"toLong":"toNumber";$r.merge(ht.prototype,{int64:function(){return Il.call(this)[e](!1)},uint64:function(){return Il.call(this)[e](!0)},sint64:function(){return Il.call(this).zzDecode()[e](!1)},fixed64:function(){return Cp.call(this)[e](!0)},sfixed64:function(){return Cp.call(this)[e](!1)}})}});var Pp=w((Tq,Bp)=>{"use strict";Bp.exports=wi;var Tp=Tl();(wi.prototype=Object.create(Tp.prototype)).constructor=wi;var Rp=qn();function wi(t){Tp.call(this,t)}wi._configure=function(){Rp.Buffer&&(wi.prototype._slice=Rp.Buffer.prototype.slice)};wi.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))};wi._configure()});var Op=w((Rq,Np)=>{"use strict";Np.exports=Uo;var Rl=qn();(Uo.prototype=Object.create(Rl.EventEmitter.prototype)).constructor=Uo;function Uo(t,e,r){if(typeof t!="function")throw TypeError("rpcImpl must be a function");Rl.EventEmitter.call(this),this.rpcImpl=t,this.requestDelimited=Boolean(e),this.responseDelimited=Boolean(r)}Uo.prototype.rpcCall=function t(e,r,n,i,s){if(!i)throw TypeError("request must be specified");var o=this;if(!s)return Rl.asPromise(t,o,e,r,n,i);if(!o.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return o.rpcImpl(e,r[o.requestDelimited?"encodeDelimited":"encode"](i).finish(),function(c,u){if(c)return o.emit("error",c,e),s(c);if(u===null){o.end(!0);return}if(!(u instanceof n))try{u=n[o.responseDelimited?"decodeDelimited":"decode"](u)}catch(l){return o.emit("error",l,e),s(l)}return o.emit("data",u,e),s(null,u)})}catch(a){o.emit("error",a,e),setTimeout(function(){s(a)},0);return}};Uo.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var Lp=w(Dp=>{"use strict";var _T=Dp;_T.Service=Op()});var qp=w((Pq,kp)=>{"use strict";kp.exports={}});var Fp=w(Mp=>{"use strict";var Xt=Mp;Xt.build="minimal";Xt.Writer=Al();Xt.BufferWriter=_p();Xt.Reader=Tl();Xt.BufferReader=Pp();Xt.util=qn();Xt.rpc=Lp();Xt.roots=qp();Xt.configure=Up;function Up(){Xt.util._configure(),Xt.Writer._configure(Xt.BufferWriter),Xt.Reader._configure(Xt.BufferReader)}Up()});var pn=w((Oq,Kp)=>{"use strict";Kp.exports=Fp()});var sc=w((Dq,jp)=>{"use strict";var _i=pn(),ic=_i.Reader,Vp=_i.Writer,Pt=_i.util,lr=_i.roots["libp2p-crypto-keys"]||(_i.roots["libp2p-crypto-keys"]={});lr.KeyType=function(){var t={},e=Object.create(t);return e[t[0]="RSA"]=0,e[t[1]="Ed25519"]=1,e[t[2]="Secp256k1"]=2,e}();lr.PublicKey=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.Type=0,t.prototype.Data=Pt.newBuffer([]),t.encode=function(r,n){return n||(n=Vp.create()),n.uint32(8).int32(r.Type),n.uint32(18).bytes(r.Data),n},t.decode=function(r,n){r instanceof ic||(r=ic.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new lr.PublicKey;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.Type=r.int32();break;case 2:s.Data=r.bytes();break;default:r.skipType(o&7);break}}if(!s.hasOwnProperty("Type"))throw Pt.ProtocolError("missing required 'Type'",{instance:s});if(!s.hasOwnProperty("Data"))throw Pt.ProtocolError("missing required 'Data'",{instance:s});return s},t.fromObject=function(r){if(r instanceof lr.PublicKey)return r;var n=new lr.PublicKey;switch(r.Type){case"RSA":case 0:n.Type=0;break;case"Ed25519":case 1:n.Type=1;break;case"Secp256k1":case 2:n.Type=2;break}return r.Data!=null&&(typeof r.Data=="string"?Pt.base64.decode(r.Data,n.Data=Pt.newBuffer(Pt.base64.length(r.Data)),0):r.Data.length&&(n.Data=r.Data)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.Type=n.enums===String?"RSA":0,n.bytes===String?i.Data="":(i.Data=[],n.bytes!==Array&&(i.Data=Pt.newBuffer(i.Data)))),r.Type!=null&&r.hasOwnProperty("Type")&&(i.Type=n.enums===String?lr.KeyType[r.Type]:r.Type),r.Data!=null&&r.hasOwnProperty("Data")&&(i.Data=n.bytes===String?Pt.base64.encode(r.Data,0,r.Data.length):n.bytes===Array?Array.prototype.slice.call(r.Data):r.Data),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,_i.util.toJSONOptions)},t}();lr.PrivateKey=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.Type=0,t.prototype.Data=Pt.newBuffer([]),t.encode=function(r,n){return n||(n=Vp.create()),n.uint32(8).int32(r.Type),n.uint32(18).bytes(r.Data),n},t.decode=function(r,n){r instanceof ic||(r=ic.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new lr.PrivateKey;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.Type=r.int32();break;case 2:s.Data=r.bytes();break;default:r.skipType(o&7);break}}if(!s.hasOwnProperty("Type"))throw Pt.ProtocolError("missing required 'Type'",{instance:s});if(!s.hasOwnProperty("Data"))throw Pt.ProtocolError("missing required 'Data'",{instance:s});return s},t.fromObject=function(r){if(r instanceof lr.PrivateKey)return r;var n=new lr.PrivateKey;switch(r.Type){case"RSA":case 0:n.Type=0;break;case"Ed25519":case 1:n.Type=1;break;case"Secp256k1":case 2:n.Type=2;break}return r.Data!=null&&(typeof r.Data=="string"?Pt.base64.decode(r.Data,n.Data=Pt.newBuffer(Pt.base64.length(r.Data)),0):r.Data.length&&(n.Data=r.Data)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.Type=n.enums===String?"RSA":0,n.bytes===String?i.Data="":(i.Data=[],n.bytes!==Array&&(i.Data=Pt.newBuffer(i.Data)))),r.Type!=null&&r.hasOwnProperty("Type")&&(i.Type=n.enums===String?lr.KeyType[r.Type]:r.Type),r.Data!=null&&r.hasOwnProperty("Data")&&(i.Data=n.bytes===String?Pt.base64.encode(r.Data,0,r.Data.length):n.bytes===Array?Array.prototype.slice.call(r.Data):r.Data),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,_i.util.toJSONOptions)},t}();jp.exports=lr});var be=w((Lq,$p)=>{$p.exports={options:{usePureJavaScript:!1}}});var Gp=w((kq,zp)=>{var Bl={};zp.exports=Bl;var Hp={};Bl.encode=function(t,e,r){if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');if(r!==void 0&&typeof r!="number")throw new TypeError('"maxline" must be a number.');var n="";if(!(t instanceof Uint8Array))n=xT(t,e);else{var i=0,s=e.length,o=e.charAt(0),a=[0];for(i=0;i<t.length;++i){for(var c=0,u=t[i];c<a.length;++c)u+=a[c]<<8,a[c]=u%s,u=u/s|0;for(;u>0;)a.push(u%s),u=u/s|0}for(i=0;t[i]===0&&i<t.length-1;++i)n+=o;for(i=a.length-1;i>=0;--i)n+=e[a[i]]}if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join(`\r
17
+ `)}return n};Bl.decode=function(t,e){if(typeof t!="string")throw new TypeError('"input" must be a string.');if(typeof e!="string")throw new TypeError('"alphabet" must be a string.');var r=Hp[e];if(!r){r=Hp[e]=[];for(var n=0;n<e.length;++n)r[e.charCodeAt(n)]=n}t=t.replace(/\s/g,"");for(var i=e.length,s=e.charAt(0),o=[0],n=0;n<t.length;n++){var a=r[t.charCodeAt(n)];if(a===void 0)return;for(var c=0,u=a;c<o.length;++c)u+=o[c]*i,o[c]=u&255,u>>=8;for(;u>0;)o.push(u&255),u>>=8}for(var l=0;t[l]===s&&l<t.length-1;++l)o.push(0);return typeof Buffer!="undefined"?Buffer.from(o.reverse()):new Uint8Array(o.reverse())};function xT(t,e){var r=0,n=e.length,i=e.charAt(0),s=[0];for(r=0;r<t.length();++r){for(var o=0,a=t.at(r);o<s.length;++o)a+=s[o]<<8,s[o]=a%n,a=a/n|0;for(;a>0;)s.push(a%n),a=a/n|0}var c="";for(r=0;t.at(r)===0&&r<t.length()-1;++r)c+=i;for(r=s.length-1;r>=0;--r)c+=e[s[r]];return c}});var $e=w((qq,Xp)=>{var Wp=be(),Yp=Gp(),P=Xp.exports=Wp.util=Wp.util||{};(function(){if(typeof process!="undefined"&&process.nextTick&&!process.browser){P.nextTick=process.nextTick,typeof setImmediate=="function"?P.setImmediate=setImmediate:P.setImmediate=P.nextTick;return}if(typeof setImmediate=="function"){P.setImmediate=function(){return setImmediate.apply(void 0,arguments)},P.nextTick=function(a){return setImmediate(a)};return}if(P.setImmediate=function(a){setTimeout(a,0)},typeof window!="undefined"&&typeof window.postMessage=="function"){let a=function(c){if(c.source===window&&c.data===t){c.stopPropagation();var u=e.slice();e.length=0,u.forEach(function(l){l()})}};var o=a,t="forge.setImmediate",e=[];P.setImmediate=function(c){e.push(c),e.length===1&&window.postMessage(t,"*")},window.addEventListener("message",a,!0)}if(typeof MutationObserver!="undefined"){var r=Date.now(),n=!0,i=document.createElement("div"),e=[];new MutationObserver(function(){var c=e.slice();e.length=0,c.forEach(function(u){u()})}).observe(i,{attributes:!0});var s=P.setImmediate;P.setImmediate=function(c){Date.now()-r>15?(r=Date.now(),s(c)):(e.push(c),e.length===1&&i.setAttribute("a",n=!n))}}P.nextTick=P.setImmediate})();P.isNodejs=typeof process!="undefined"&&process.versions&&process.versions.node;P.globalScope=function(){return P.isNodejs?globalThis:typeof self=="undefined"?window:self}();P.isArray=Array.isArray||function(t){return Object.prototype.toString.call(t)==="[object Array]"};P.isArrayBuffer=function(t){return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer};P.isArrayBufferView=function(t){return t&&P.isArrayBuffer(t.buffer)&&t.byteLength!==void 0};function Mo(t){if(!(t===8||t===16||t===24||t===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+t)}P.ByteBuffer=Pl;function Pl(t){if(this.data="",this.read=0,typeof t=="string")this.data=t;else if(P.isArrayBuffer(t)||P.isArrayBufferView(t))if(typeof Buffer!="undefined"&&t instanceof Buffer)this.data=t.toString("binary");else{var e=new Uint8Array(t);try{this.data=String.fromCharCode.apply(null,e)}catch(n){for(var r=0;r<e.length;++r)this.putByte(e[r])}}else(t instanceof Pl||typeof t=="object"&&typeof t.data=="string"&&typeof t.read=="number")&&(this.data=t.data,this.read=t.read);this._constructedStringLength=0}P.ByteStringBuffer=Pl;var ST=4096;P.ByteStringBuffer.prototype._optimizeConstructedString=function(t){this._constructedStringLength+=t,this._constructedStringLength>ST&&(this.data.substr(0,1),this._constructedStringLength=0)};P.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read};P.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0};P.ByteStringBuffer.prototype.putByte=function(t){return this.putBytes(String.fromCharCode(t))};P.ByteStringBuffer.prototype.fillWithByte=function(t,e){t=String.fromCharCode(t);for(var r=this.data;e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return this.data=r,this._optimizeConstructedString(e),this};P.ByteStringBuffer.prototype.putBytes=function(t){return this.data+=t,this._optimizeConstructedString(t.length),this};P.ByteStringBuffer.prototype.putString=function(t){return this.putBytes(P.encodeUtf8(t))};P.ByteStringBuffer.prototype.putInt16=function(t){return this.putBytes(String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};P.ByteStringBuffer.prototype.putInt24=function(t){return this.putBytes(String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};P.ByteStringBuffer.prototype.putInt32=function(t){return this.putBytes(String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255))};P.ByteStringBuffer.prototype.putInt16Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255))};P.ByteStringBuffer.prototype.putInt24Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255))};P.ByteStringBuffer.prototype.putInt32Le=function(t){return this.putBytes(String.fromCharCode(t&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>24&255))};P.ByteStringBuffer.prototype.putInt=function(t,e){Mo(e);var r="";do e-=8,r+=String.fromCharCode(t>>e&255);while(e>0);return this.putBytes(r)};P.ByteStringBuffer.prototype.putSignedInt=function(t,e){return t<0&&(t+=2<<e-1),this.putInt(t,e)};P.ByteStringBuffer.prototype.putBuffer=function(t){return this.putBytes(t.getBytes())};P.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};P.ByteStringBuffer.prototype.getInt16=function(){var t=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,t};P.ByteStringBuffer.prototype.getInt24=function(){var t=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,t};P.ByteStringBuffer.prototype.getInt32=function(){var t=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,t};P.ByteStringBuffer.prototype.getInt16Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,t};P.ByteStringBuffer.prototype.getInt24Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,t};P.ByteStringBuffer.prototype.getInt32Le=function(){var t=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,t};P.ByteStringBuffer.prototype.getInt=function(t){Mo(t);var e=0;do e=(e<<8)+this.data.charCodeAt(this.read++),t-=8;while(t>0);return e};P.ByteStringBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};P.ByteStringBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};P.ByteStringBuffer.prototype.bytes=function(t){return typeof t=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};P.ByteStringBuffer.prototype.at=function(t){return this.data.charCodeAt(this.read+t)};P.ByteStringBuffer.prototype.setAt=function(t,e){return this.data=this.data.substr(0,this.read+t)+String.fromCharCode(e)+this.data.substr(this.read+t+1),this};P.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};P.ByteStringBuffer.prototype.copy=function(){var t=P.createBuffer(this.data);return t.read=this.read,t};P.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this};P.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this};P.ByteStringBuffer.prototype.truncate=function(t){var e=Math.max(0,this.length()-t);return this.data=this.data.substr(this.read,e),this.read=0,this};P.ByteStringBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.length;++e){var r=this.data.charCodeAt(e);r<16&&(t+="0"),t+=r.toString(16)}return t};P.ByteStringBuffer.prototype.toString=function(){return P.decodeUtf8(this.bytes())};function AT(t,e){e=e||{},this.read=e.readOffset||0,this.growSize=e.growSize||1024;var r=P.isArrayBuffer(t),n=P.isArrayBufferView(t);if(r||n){r?this.data=new DataView(t):this.data=new DataView(t.buffer,t.byteOffset,t.byteLength),this.write="writeOffset"in e?e.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,t!=null&&this.putBytes(t),"writeOffset"in e&&(this.write=e.writeOffset)}P.DataBuffer=AT;P.DataBuffer.prototype.length=function(){return this.write-this.read};P.DataBuffer.prototype.isEmpty=function(){return this.length()<=0};P.DataBuffer.prototype.accommodate=function(t,e){if(this.length()>=t)return this;e=Math.max(e||this.growSize,t);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+e);return n.set(r),this.data=new DataView(n.buffer),this};P.DataBuffer.prototype.putByte=function(t){return this.accommodate(1),this.data.setUint8(this.write++,t),this};P.DataBuffer.prototype.fillWithByte=function(t,e){this.accommodate(e);for(var r=0;r<e;++r)this.data.setUint8(t);return this};P.DataBuffer.prototype.putBytes=function(t,e){if(P.isArrayBufferView(t)){var r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n=r.byteLength-r.byteOffset;this.accommodate(n);var i=new Uint8Array(this.data.buffer,this.write);return i.set(r),this.write+=n,this}if(P.isArrayBuffer(t)){var r=new Uint8Array(t);this.accommodate(r.byteLength);var i=new Uint8Array(this.data.buffer);return i.set(r,this.write),this.write+=r.byteLength,this}if(t instanceof P.DataBuffer||typeof t=="object"&&typeof t.read=="number"&&typeof t.write=="number"&&P.isArrayBufferView(t.data)){var r=new Uint8Array(t.data.byteLength,t.read,t.length());this.accommodate(r.byteLength);var i=new Uint8Array(t.data.byteLength,this.write);return i.set(r),this.write+=r.byteLength,this}if(t instanceof P.ByteStringBuffer&&(t=t.data,e="binary"),e=e||"binary",typeof t=="string"){var s;if(e==="hex")return this.accommodate(Math.ceil(t.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=P.binary.hex.decode(t,s,this.write),this;if(e==="base64")return this.accommodate(Math.ceil(t.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=P.binary.base64.decode(t,s,this.write),this;if(e==="utf8"&&(t=P.encodeUtf8(t),e="binary"),e==="binary"||e==="raw")return this.accommodate(t.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=P.binary.raw.decode(s),this;if(e==="utf16")return this.accommodate(t.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=P.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+e)}throw Error("Invalid parameter: "+t)};P.DataBuffer.prototype.putBuffer=function(t){return this.putBytes(t),t.clear(),this};P.DataBuffer.prototype.putString=function(t){return this.putBytes(t,"utf16")};P.DataBuffer.prototype.putInt16=function(t){return this.accommodate(2),this.data.setInt16(this.write,t),this.write+=2,this};P.DataBuffer.prototype.putInt24=function(t){return this.accommodate(3),this.data.setInt16(this.write,t>>8&65535),this.data.setInt8(this.write,t>>16&255),this.write+=3,this};P.DataBuffer.prototype.putInt32=function(t){return this.accommodate(4),this.data.setInt32(this.write,t),this.write+=4,this};P.DataBuffer.prototype.putInt16Le=function(t){return this.accommodate(2),this.data.setInt16(this.write,t,!0),this.write+=2,this};P.DataBuffer.prototype.putInt24Le=function(t){return this.accommodate(3),this.data.setInt8(this.write,t>>16&255),this.data.setInt16(this.write,t>>8&65535,!0),this.write+=3,this};P.DataBuffer.prototype.putInt32Le=function(t){return this.accommodate(4),this.data.setInt32(this.write,t,!0),this.write+=4,this};P.DataBuffer.prototype.putInt=function(t,e){Mo(e),this.accommodate(e/8);do e-=8,this.data.setInt8(this.write++,t>>e&255);while(e>0);return this};P.DataBuffer.prototype.putSignedInt=function(t,e){return Mo(e),this.accommodate(e/8),t<0&&(t+=2<<e-1),this.putInt(t,e)};P.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};P.DataBuffer.prototype.getInt16=function(){var t=this.data.getInt16(this.read);return this.read+=2,t};P.DataBuffer.prototype.getInt24=function(){var t=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,t};P.DataBuffer.prototype.getInt32=function(){var t=this.data.getInt32(this.read);return this.read+=4,t};P.DataBuffer.prototype.getInt16Le=function(){var t=this.data.getInt16(this.read,!0);return this.read+=2,t};P.DataBuffer.prototype.getInt24Le=function(){var t=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,t};P.DataBuffer.prototype.getInt32Le=function(){var t=this.data.getInt32(this.read,!0);return this.read+=4,t};P.DataBuffer.prototype.getInt=function(t){Mo(t);var e=0;do e=(e<<8)+this.data.getInt8(this.read++),t-=8;while(t>0);return e};P.DataBuffer.prototype.getSignedInt=function(t){var e=this.getInt(t),r=2<<t-2;return e>=r&&(e-=r<<1),e};P.DataBuffer.prototype.getBytes=function(t){var e;return t?(t=Math.min(this.length(),t),e=this.data.slice(this.read,this.read+t),this.read+=t):t===0?e="":(e=this.read===0?this.data:this.data.slice(this.read),this.clear()),e};P.DataBuffer.prototype.bytes=function(t){return typeof t=="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+t)};P.DataBuffer.prototype.at=function(t){return this.data.getUint8(this.read+t)};P.DataBuffer.prototype.setAt=function(t,e){return this.data.setUint8(t,e),this};P.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};P.DataBuffer.prototype.copy=function(){return new P.DataBuffer(this)};P.DataBuffer.prototype.compact=function(){if(this.read>0){var t=new Uint8Array(this.data.buffer,this.read),e=new Uint8Array(t.byteLength);e.set(t),this.data=new DataView(e),this.write-=this.read,this.read=0}return this};P.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this};P.DataBuffer.prototype.truncate=function(t){return this.write=Math.max(0,this.length()-t),this.read=Math.min(this.read,this.write),this};P.DataBuffer.prototype.toHex=function(){for(var t="",e=this.read;e<this.data.byteLength;++e){var r=this.data.getUint8(e);r<16&&(t+="0"),t+=r.toString(16)}return t};P.DataBuffer.prototype.toString=function(t){var e=new Uint8Array(this.data,this.read,this.length());if(t=t||"utf8",t==="binary"||t==="raw")return P.binary.raw.encode(e);if(t==="hex")return P.binary.hex.encode(e);if(t==="base64")return P.binary.base64.encode(e);if(t==="utf8")return P.text.utf8.decode(e);if(t==="utf16")return P.text.utf16.decode(e);throw new Error("Invalid encoding: "+t)};P.createBuffer=function(t,e){return e=e||"raw",t!==void 0&&e==="utf8"&&(t=P.encodeUtf8(t)),new P.ByteBuffer(t)};P.fillString=function(t,e){for(var r="";e>0;)e&1&&(r+=t),e>>>=1,e>0&&(t+=t);return r};P.xorBytes=function(t,e,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=t.charCodeAt(o)^e.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s,n};P.hexToBytes=function(t){var e="",r=0;for(t.length&!0&&(r=1,e+=String.fromCharCode(parseInt(t[0],16)));r<t.length;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e};P.bytesToHex=function(t){return P.createBuffer(t).toHex()};P.int32ToBytes=function(t){return String.fromCharCode(t>>24&255)+String.fromCharCode(t>>16&255)+String.fromCharCode(t>>8&255)+String.fromCharCode(t&255)};var Mn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Fn=[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],Qp="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";P.encode64=function(t,e){for(var r="",n="",i,s,o,a=0;a<t.length;)i=t.charCodeAt(a++),s=t.charCodeAt(a++),o=t.charCodeAt(a++),r+=Mn.charAt(i>>2),r+=Mn.charAt((i&3)<<4|s>>4),isNaN(s)?r+="==":(r+=Mn.charAt((s&15)<<2|o>>6),r+=isNaN(o)?"=":Mn.charAt(o&63)),e&&r.length>e&&(n+=r.substr(0,e)+`\r
18
+ `,r=r.substr(e));return n+=r,n};P.decode64=function(t){t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var e="",r,n,i,s,o=0;o<t.length;)r=Fn[t.charCodeAt(o++)-43],n=Fn[t.charCodeAt(o++)-43],i=Fn[t.charCodeAt(o++)-43],s=Fn[t.charCodeAt(o++)-43],e+=String.fromCharCode(r<<2|n>>4),i!==64&&(e+=String.fromCharCode((n&15)<<4|i>>2),s!==64&&(e+=String.fromCharCode((i&3)<<6|s)));return e};P.encodeUtf8=function(t){return unescape(encodeURIComponent(t))};P.decodeUtf8=function(t){return decodeURIComponent(escape(t))};P.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:Yp.encode,decode:Yp.decode}};P.binary.raw.encode=function(t){return String.fromCharCode.apply(null,t)};P.binary.raw.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length)),r=r||0;for(var i=r,s=0;s<t.length;++s)n[i++]=t.charCodeAt(s);return e?i-r:n};P.binary.hex.encode=P.bytesToHex;P.binary.hex.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(Math.ceil(t.length/2))),r=r||0;var i=0,s=r;for(t.length&1&&(i=1,n[s++]=parseInt(t[0],16));i<t.length;i+=2)n[s++]=parseInt(t.substr(i,2),16);return e?s-r:n};P.binary.base64.encode=function(t,e){for(var r="",n="",i,s,o,a=0;a<t.byteLength;)i=t[a++],s=t[a++],o=t[a++],r+=Mn.charAt(i>>2),r+=Mn.charAt((i&3)<<4|s>>4),isNaN(s)?r+="==":(r+=Mn.charAt((s&15)<<2|o>>6),r+=isNaN(o)?"=":Mn.charAt(o&63)),e&&r.length>e&&(n+=r.substr(0,e)+`\r
19
+ `,r=r.substr(e));return n+=r,n};P.binary.base64.decode=function(t,e,r){var n=e;n||(n=new Uint8Array(Math.ceil(t.length/4)*3)),t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),r=r||0;for(var i,s,o,a,c=0,u=r;c<t.length;)i=Fn[t.charCodeAt(c++)-43],s=Fn[t.charCodeAt(c++)-43],o=Fn[t.charCodeAt(c++)-43],a=Fn[t.charCodeAt(c++)-43],n[u++]=i<<2|s>>4,o!==64&&(n[u++]=(s&15)<<4|o>>2,a!==64&&(n[u++]=(o&3)<<6|a));return e?u-r:n.subarray(0,u)};P.binary.base58.encode=function(t,e){return P.binary.baseN.encode(t,Qp,e)};P.binary.base58.decode=function(t,e){return P.binary.baseN.decode(t,Qp,e)};P.text={utf8:{},utf16:{}};P.text.utf8.encode=function(t,e,r){t=P.encodeUtf8(t);var n=e;n||(n=new Uint8Array(t.length)),r=r||0;for(var i=r,s=0;s<t.length;++s)n[i++]=t.charCodeAt(s);return e?i-r:n};P.text.utf8.decode=function(t){return P.decodeUtf8(String.fromCharCode.apply(null,t))};P.text.utf16.encode=function(t,e,r){var n=e;n||(n=new Uint8Array(t.length*2));var i=new Uint16Array(n.buffer);r=r||0;for(var s=r,o=r,a=0;a<t.length;++a)i[o++]=t.charCodeAt(a),s+=2;return e?s-r:n};P.text.utf16.decode=function(t){return String.fromCharCode.apply(null,new Uint16Array(t.buffer))};P.deflate=function(t,e,r){if(e=P.decode64(t.deflate(P.encode64(e)).rval),r){var n=2,i=e.charCodeAt(1);i&32&&(n=6),e=e.substring(n,e.length-4)}return e};P.inflate=function(t,e,r){var n=t.inflate(P.encode64(e)).rval;return n===null?null:P.decode64(n)};var Nl=function(t,e,r){if(!t)throw new Error("WebStorage not available.");var n;if(r===null?n=t.removeItem(e):(r=P.encode64(JSON.stringify(r)),n=t.setItem(e,r)),typeof n!="undefined"&&n.rval!==!0){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},Ol=function(t,e){if(!t)throw new Error("WebStorage not available.");var r=t.getItem(e);if(t.init)if(r.rval===null){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return r!==null&&(r=JSON.parse(P.decode64(r))),r},CT=function(t,e,r,n){var i=Ol(t,e);i===null&&(i={}),i[r]=n,Nl(t,e,i)},IT=function(t,e,r){var n=Ol(t,e);return n!==null&&(n=r in n?n[r]:null),n},TT=function(t,e,r){var n=Ol(t,e);if(n!==null&&r in n){delete n[r];var i=!0;for(var s in n){i=!1;break}i&&(n=null),Nl(t,e,n)}},RT=function(t,e){Nl(t,e,null)},oc=function(t,e,r){var n=null;typeof r=="undefined"&&(r=["web","flash"]);var i,s=!1,o=null;for(var a in r){i=r[a];try{if(i==="flash"||i==="both"){if(e[0]===null)throw new Error("Flash local storage not available.");n=t.apply(this,e),s=i==="flash"}(i==="web"||i==="both")&&(e[0]=localStorage,n=t.apply(this,e),s=!0)}catch(c){o=c}if(s)break}if(!s)throw o;return n};P.setItem=function(t,e,r,n,i){oc(CT,arguments,i)};P.getItem=function(t,e,r,n){return oc(IT,arguments,n)};P.removeItem=function(t,e,r,n){oc(TT,arguments,n)};P.clearItems=function(t,e,r){oc(RT,arguments,r)};P.isEmpty=function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0};P.format=function(t){for(var e=/%./g,r,n,i=0,s=[],o=0;r=e.exec(t);){n=t.substring(o,e.lastIndex-2),n.length>0&&s.push(n),o=e.lastIndex;var a=r[0][1];switch(a){case"s":case"o":i<arguments.length?s.push(arguments[i+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(t.substring(o)),s.join("")};P.formatNumber=function(t,e,r,n){var i=t,s=isNaN(e=Math.abs(e))?2:e,o=r===void 0?",":r,a=n===void 0?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-u).toFixed(s).slice(2):"")};P.formatSize=function(t){return t>=1073741824?t=P.formatNumber(t/1073741824,2,".","")+" GiB":t>=1048576?t=P.formatNumber(t/1048576,2,".","")+" MiB":t>=1024?t=P.formatNumber(t/1024,0)+" KiB":t=P.formatNumber(t,0)+" bytes",t};P.bytesFromIP=function(t){return t.indexOf(".")!==-1?P.bytesFromIPv4(t):t.indexOf(":")!==-1?P.bytesFromIPv6(t):null};P.bytesFromIPv4=function(t){if(t=t.split("."),t.length!==4)return null;for(var e=P.createBuffer(),r=0;r<t.length;++r){var n=parseInt(t[r],10);if(isNaN(n))return null;e.putByte(n)}return e.getBytes()};P.bytesFromIPv6=function(t){var e=0;t=t.split(":").filter(function(o){return o.length===0&&++e,!0});for(var r=(8-t.length+e)*2,n=P.createBuffer(),i=0;i<8;++i){if(!t[i]||t[i].length===0){n.fillWithByte(0,r),r=0;continue}var s=P.hexToBytes(t[i]);s.length<2&&n.putByte(0),n.putBytes(s)}return n.getBytes()};P.bytesToIP=function(t){return t.length===4?P.bytesToIPv4(t):t.length===16?P.bytesToIPv6(t):null};P.bytesToIPv4=function(t){if(t.length!==4)return null;for(var e=[],r=0;r<t.length;++r)e.push(t.charCodeAt(r));return e.join(".")};P.bytesToIPv6=function(t){if(t.length!==16)return null;for(var e=[],r=[],n=0,i=0;i<t.length;i+=2){for(var s=P.bytesToHex(t[i]+t[i+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var o=r[r.length-1],a=e.length;!o||a!==o.end+1?r.push({start:a,end:a}):(o.end=a,o.end-o.start>r[n].end-r[n].start&&(n=r.length-1))}e.push(s)}if(r.length>0){var c=r[n];c.end-c.start>0&&(e.splice(c.start,c.end-c.start+1,""),c.start===0&&e.unshift(""),c.end===7&&e.push(""))}return e.join(":")};P.estimateCores=function(t,e){if(typeof t=="function"&&(e=t,t={}),t=t||{},"cores"in P&&!t.update)return e(null,P.cores);if(typeof navigator!="undefined"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return P.cores=navigator.hardwareConcurrency,e(null,P.cores);if(typeof Worker=="undefined")return P.cores=1,e(null,P.cores);if(typeof Blob=="undefined")return P.cores=2,e(null,P.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(o){for(var a=Date.now(),c=a+4;Date.now()<c;);self.postMessage({st:a,et:c})})}.toString(),")()"],{type:"application/javascript"}));n([],5,16);function n(o,a,c){if(a===0){var u=Math.floor(o.reduce(function(l,f){return l+f},0)/o.length);return P.cores=Math.max(1,u),URL.revokeObjectURL(r),e(null,P.cores)}i(c,function(l,f){o.push(s(c,f)),n(o,a-1,c)})}function i(o,a){for(var c=[],u=[],l=0;l<o;++l){var f=new Worker(r);f.addEventListener("message",function(h){if(u.push(h.data),u.length===o){for(var p=0;p<o;++p)c[p].terminate();a(null,u)}}),c.push(f)}for(var l=0;l<o;++l)c[l].postMessage(l)}function s(o,a){for(var c=[],u=0;u<o;++u)for(var l=a[u],f=c[u]=[],h=0;h<o;++h)if(u!==h){var p=a[h];(l.st>p.st&&l.st<p.et||p.st>l.st&&p.st<l.et)&&f.push(h)}return c.reduce(function(d,g){return Math.max(d,g.length)},0)}}});var ws=w((Uq,Zp)=>{var Fo=be();Fo.pki=Fo.pki||{};var Dl=Zp.exports=Fo.pki.oids=Fo.oids=Fo.oids||{};function $(t,e){Dl[t]=e,Dl[e]=t}function Oe(t,e){Dl[t]=e}$("1.2.840.113549.1.1.1","rsaEncryption");$("1.2.840.113549.1.1.4","md5WithRSAEncryption");$("1.2.840.113549.1.1.5","sha1WithRSAEncryption");$("1.2.840.113549.1.1.7","RSAES-OAEP");$("1.2.840.113549.1.1.8","mgf1");$("1.2.840.113549.1.1.9","pSpecified");$("1.2.840.113549.1.1.10","RSASSA-PSS");$("1.2.840.113549.1.1.11","sha256WithRSAEncryption");$("1.2.840.113549.1.1.12","sha384WithRSAEncryption");$("1.2.840.113549.1.1.13","sha512WithRSAEncryption");$("1.3.101.112","EdDSA25519");$("1.2.840.10040.4.3","dsa-with-sha1");$("1.3.14.3.2.7","desCBC");$("1.3.14.3.2.26","sha1");$("1.3.14.3.2.29","sha1WithRSASignature");$("2.16.840.1.101.3.4.2.1","sha256");$("2.16.840.1.101.3.4.2.2","sha384");$("2.16.840.1.101.3.4.2.3","sha512");$("1.2.840.113549.2.5","md5");$("1.2.840.113549.1.7.1","data");$("1.2.840.113549.1.7.2","signedData");$("1.2.840.113549.1.7.3","envelopedData");$("1.2.840.113549.1.7.4","signedAndEnvelopedData");$("1.2.840.113549.1.7.5","digestedData");$("1.2.840.113549.1.7.6","encryptedData");$("1.2.840.113549.1.9.1","emailAddress");$("1.2.840.113549.1.9.2","unstructuredName");$("1.2.840.113549.1.9.3","contentType");$("1.2.840.113549.1.9.4","messageDigest");$("1.2.840.113549.1.9.5","signingTime");$("1.2.840.113549.1.9.6","counterSignature");$("1.2.840.113549.1.9.7","challengePassword");$("1.2.840.113549.1.9.8","unstructuredAddress");$("1.2.840.113549.1.9.14","extensionRequest");$("1.2.840.113549.1.9.20","friendlyName");$("1.2.840.113549.1.9.21","localKeyId");$("1.2.840.113549.1.9.22.1","x509Certificate");$("1.2.840.113549.1.12.10.1.1","keyBag");$("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag");$("1.2.840.113549.1.12.10.1.3","certBag");$("1.2.840.113549.1.12.10.1.4","crlBag");$("1.2.840.113549.1.12.10.1.5","secretBag");$("1.2.840.113549.1.12.10.1.6","safeContentsBag");$("1.2.840.113549.1.5.13","pkcs5PBES2");$("1.2.840.113549.1.5.12","pkcs5PBKDF2");$("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4");$("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4");$("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC");$("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC");$("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC");$("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC");$("1.2.840.113549.2.7","hmacWithSHA1");$("1.2.840.113549.2.8","hmacWithSHA224");$("1.2.840.113549.2.9","hmacWithSHA256");$("1.2.840.113549.2.10","hmacWithSHA384");$("1.2.840.113549.2.11","hmacWithSHA512");$("1.2.840.113549.3.7","des-EDE3-CBC");$("2.16.840.1.101.3.4.1.2","aes128-CBC");$("2.16.840.1.101.3.4.1.22","aes192-CBC");$("2.16.840.1.101.3.4.1.42","aes256-CBC");$("2.5.4.3","commonName");$("2.5.4.4","surname");$("2.5.4.5","serialNumber");$("2.5.4.6","countryName");$("2.5.4.7","localityName");$("2.5.4.8","stateOrProvinceName");$("2.5.4.9","streetAddress");$("2.5.4.10","organizationName");$("2.5.4.11","organizationalUnitName");$("2.5.4.12","title");$("2.5.4.13","description");$("2.5.4.15","businessCategory");$("2.5.4.17","postalCode");$("2.5.4.42","givenName");$("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName");$("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName");$("2.16.840.1.113730.1.1","nsCertType");$("2.16.840.1.113730.1.13","nsComment");Oe("2.5.29.1","authorityKeyIdentifier");Oe("2.5.29.2","keyAttributes");Oe("2.5.29.3","certificatePolicies");Oe("2.5.29.4","keyUsageRestriction");Oe("2.5.29.5","policyMapping");Oe("2.5.29.6","subtreesConstraint");Oe("2.5.29.7","subjectAltName");Oe("2.5.29.8","issuerAltName");Oe("2.5.29.9","subjectDirectoryAttributes");Oe("2.5.29.10","basicConstraints");Oe("2.5.29.11","nameConstraints");Oe("2.5.29.12","policyConstraints");Oe("2.5.29.13","basicConstraints");$("2.5.29.14","subjectKeyIdentifier");$("2.5.29.15","keyUsage");Oe("2.5.29.16","privateKeyUsagePeriod");$("2.5.29.17","subjectAltName");$("2.5.29.18","issuerAltName");$("2.5.29.19","basicConstraints");Oe("2.5.29.20","cRLNumber");Oe("2.5.29.21","cRLReason");Oe("2.5.29.22","expirationDate");Oe("2.5.29.23","instructionCode");Oe("2.5.29.24","invalidityDate");Oe("2.5.29.25","cRLDistributionPoints");Oe("2.5.29.26","issuingDistributionPoint");Oe("2.5.29.27","deltaCRLIndicator");Oe("2.5.29.28","issuingDistributionPoint");Oe("2.5.29.29","certificateIssuer");Oe("2.5.29.30","nameConstraints");$("2.5.29.31","cRLDistributionPoints");$("2.5.29.32","certificatePolicies");Oe("2.5.29.33","policyMappings");Oe("2.5.29.34","policyConstraints");$("2.5.29.35","authorityKeyIdentifier");Oe("2.5.29.36","policyConstraints");$("2.5.29.37","extKeyUsage");Oe("2.5.29.46","freshestCRL");Oe("2.5.29.54","inhibitAnyPolicy");$("1.3.6.1.4.1.11129.2.4.2","timestampList");$("1.3.6.1.5.5.7.1.1","authorityInfoAccess");$("1.3.6.1.5.5.7.3.1","serverAuth");$("1.3.6.1.5.5.7.3.2","clientAuth");$("1.3.6.1.5.5.7.3.3","codeSigning");$("1.3.6.1.5.5.7.3.4","emailProtection");$("1.3.6.1.5.5.7.3.8","timeStamping")});var Kn=w((Mq,ey)=>{var Qe=be();$e();ws();var X=ey.exports=Qe.asn1=Qe.asn1||{};X.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};X.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};X.create=function(t,e,r,n,i){if(Qe.util.isArray(n)){for(var s=[],o=0;o<n.length;++o)n[o]!==void 0&&s.push(n[o]);n=s}var a={tagClass:t,type:e,constructed:r,composed:r||Qe.util.isArray(n),value:n};return i&&"bitStringContents"in i&&(a.bitStringContents=i.bitStringContents,a.original=X.copy(a)),a};X.copy=function(t,e){var r;if(Qe.util.isArray(t)){r=[];for(var n=0;n<t.length;++n)r.push(X.copy(t[n],e));return r}return typeof t=="string"?t:(r={tagClass:t.tagClass,type:t.type,constructed:t.constructed,composed:t.composed,value:X.copy(t.value,e)},e&&!e.excludeBitStringContents&&(r.bitStringContents=t.bitStringContents),r)};X.equals=function(t,e,r){if(Qe.util.isArray(t)){if(!Qe.util.isArray(e)||t.length!==e.length)return!1;for(var n=0;n<t.length;++n)if(!X.equals(t[n],e[n]))return!1;return!0}if(typeof t!=typeof e)return!1;if(typeof t=="string")return t===e;var i=t.tagClass===e.tagClass&&t.type===e.type&&t.constructed===e.constructed&&t.composed===e.composed&&X.equals(t.value,e.value);return r&&r.includeBitStringContents&&(i=i&&t.bitStringContents===e.bitStringContents),i};X.getBerValueLength=function(t){var e=t.getByte();if(e!==128){var r,n=e&128;return n?r=t.getInt((e&127)<<3):r=e,r}};function Ko(t,e,r){if(r>e){var n=new Error("Too few bytes to parse DER.");throw n.available=t.length(),n.remaining=e,n.requested=r,n}}var BT=function(t,e){var r=t.getByte();if(e--,r!==128){var n,i=r&128;if(!i)n=r;else{var s=r&127;Ko(t,e,s),n=t.getInt(s<<3)}if(n<0)throw new Error("Negative length: "+n);return n}};X.fromDer=function(t,e){return e===void 0&&(e={strict:!0,decodeBitStrings:!0}),typeof e=="boolean"&&(e={strict:e,decodeBitStrings:!0}),"strict"in e||(e.strict=!0),"decodeBitStrings"in e||(e.decodeBitStrings=!0),typeof t=="string"&&(t=Qe.util.createBuffer(t)),ac(t,t.length(),0,e)};function ac(t,e,r,n){var i;Ko(t,e,2);var s=t.getByte();e--;var o=s&192,a=s&31;i=t.length();var c=BT(t,e);if(e-=i-t.length(),c!==void 0&&c>e){if(n.strict){var u=new Error("Too few bytes to read ASN.1 value.");throw u.available=t.length(),u.remaining=e,u.requested=c,u}c=e}var l,f,h=(s&32)==32;if(h)if(l=[],c===void 0)for(;;){if(Ko(t,e,2),t.bytes(2)===String.fromCharCode(0,0)){t.getBytes(2),e-=2;break}i=t.length(),l.push(ac(t,e,r+1,n)),e-=i-t.length()}else for(;c>0;)i=t.length(),l.push(ac(t,c,r+1,n)),e-=i-t.length(),c-=i-t.length();if(l===void 0&&o===X.Class.UNIVERSAL&&a===X.Type.BITSTRING&&(f=t.bytes(c)),l===void 0&&n.decodeBitStrings&&o===X.Class.UNIVERSAL&&a===X.Type.BITSTRING&&c>1){var p=t.read,d=e,g=0;if(a===X.Type.BITSTRING&&(Ko(t,e,1),g=t.getByte(),e--),g===0)try{i=t.length();var m={verbose:n.verbose,strict:!0,decodeBitStrings:!0},x=ac(t,e,r+1,m),R=i-t.length();e-=R,a==X.Type.BITSTRING&&R++;var L=x.tagClass;R===c&&(L===X.Class.UNIVERSAL||L===X.Class.CONTEXT_SPECIFIC)&&(l=[x])}catch(q){}l===void 0&&(t.read=p,e=d)}if(l===void 0){if(c===void 0){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");c=e}if(a===X.Type.BMPSTRING)for(l="";c>0;c-=2)Ko(t,e,2),l+=String.fromCharCode(t.getInt16()),e-=2;else l=t.getBytes(c)}var H=f===void 0?null:{bitStringContents:f};return X.create(o,a,h,l,H)}X.toDer=function(t){var e=Qe.util.createBuffer(),r=t.tagClass|t.type,n=Qe.util.createBuffer(),i=!1;if("bitStringContents"in t&&(i=!0,t.original&&(i=X.equals(t,t.original))),i)n.putBytes(t.bitStringContents);else if(t.composed){t.constructed?r|=32:n.putByte(0);for(var s=0;s<t.value.length;++s)t.value[s]!==void 0&&n.putBuffer(X.toDer(t.value[s]))}else if(t.type===X.Type.BMPSTRING)for(var s=0;s<t.value.length;++s)n.putInt16(t.value.charCodeAt(s));else t.type===X.Type.INTEGER&&t.value.length>1&&(t.value.charCodeAt(0)===0&&(t.value.charCodeAt(1)&128)==0||t.value.charCodeAt(0)===255&&(t.value.charCodeAt(1)&128)==128)?n.putBytes(t.value.substr(1)):n.putBytes(t.value);if(e.putByte(r),n.length()<=127)e.putByte(n.length()&127);else{var o=n.length(),a="";do a+=String.fromCharCode(o&255),o=o>>>8;while(o>0);e.putByte(a.length|128);for(var s=a.length-1;s>=0;--s)e.putByte(a.charCodeAt(s))}return e.putBuffer(n),e};X.oidToDer=function(t){var e=t.split("."),r=Qe.util.createBuffer();r.putByte(40*parseInt(e[0],10)+parseInt(e[1],10));for(var n,i,s,o,a=2;a<e.length;++a){n=!0,i=[],s=parseInt(e[a],10);do o=s&127,s=s>>>7,n||(o|=128),i.push(o),n=!1;while(s>0);for(var c=i.length-1;c>=0;--c)r.putByte(i[c])}return r};X.derToOid=function(t){var e;typeof t=="string"&&(t=Qe.util.createBuffer(t));var r=t.getByte();e=Math.floor(r/40)+"."+r%40;for(var n=0;t.length()>0;)r=t.getByte(),n=n<<7,r&128?n+=r&127:(e+="."+(n+r),n=0);return e};X.utcTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(t.substr(2,2),10)-1,i=parseInt(t.substr(4,2),10),s=parseInt(t.substr(6,2),10),o=parseInt(t.substr(8,2),10),a=0;if(t.length>11){var c=t.charAt(10),u=10;c!=="+"&&c!=="-"&&(a=parseInt(t.substr(10,2),10),u+=2)}if(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,0),u&&(c=t.charAt(u),c==="+"||c==="-")){var l=parseInt(t.substr(u+1,2),10),f=parseInt(t.substr(u+4,2),10),h=l*60+f;h*=6e4,c==="+"?e.setTime(+e-h):e.setTime(+e+h)}return e};X.generalizedTimeToDate=function(t){var e=new Date,r=parseInt(t.substr(0,4),10),n=parseInt(t.substr(4,2),10)-1,i=parseInt(t.substr(6,2),10),s=parseInt(t.substr(8,2),10),o=parseInt(t.substr(10,2),10),a=parseInt(t.substr(12,2),10),c=0,u=0,l=!1;t.charAt(t.length-1)==="Z"&&(l=!0);var f=t.length-5,h=t.charAt(f);if(h==="+"||h==="-"){var p=parseInt(t.substr(f+1,2),10),d=parseInt(t.substr(f+4,2),10);u=p*60+d,u*=6e4,h==="+"&&(u*=-1),l=!0}return t.charAt(14)==="."&&(c=parseFloat(t.substr(14),10)*1e3),l?(e.setUTCFullYear(r,n,i),e.setUTCHours(s,o,a,c),e.setTime(+e+u)):(e.setFullYear(r,n,i),e.setHours(s,o,a,c)),e};X.dateToUtcTime=function(t){if(typeof t=="string")return t;var e="",r=[];r.push((""+t.getUTCFullYear()).substr(2)),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(e+="0"),e+=r[n];return e+="Z",e};X.dateToGeneralizedTime=function(t){if(typeof t=="string")return t;var e="",r=[];r.push(""+t.getUTCFullYear()),r.push(""+(t.getUTCMonth()+1)),r.push(""+t.getUTCDate()),r.push(""+t.getUTCHours()),r.push(""+t.getUTCMinutes()),r.push(""+t.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(e+="0"),e+=r[n];return e+="Z",e};X.integerToDer=function(t){var e=Qe.util.createBuffer();if(t>=-128&&t<128)return e.putSignedInt(t,8);if(t>=-32768&&t<32768)return e.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return e.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return e.putSignedInt(t,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=t,r};X.derToInteger=function(t){typeof t=="string"&&(t=Qe.util.createBuffer(t));var e=t.length()*8;if(e>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(e)};X.validate=function(t,e,r,n){var i=!1;if((t.tagClass===e.tagClass||typeof e.tagClass=="undefined")&&(t.type===e.type||typeof e.type=="undefined"))if(t.constructed===e.constructed||typeof e.constructed=="undefined"){if(i=!0,e.value&&Qe.util.isArray(e.value))for(var s=0,o=0;i&&o<e.value.length;++o)i=e.value[o].optional||!1,t.value[s]&&(i=X.validate(t.value[s],e.value[o],r,n),i?++s:e.value[o].optional&&(i=!0)),!i&&n&&n.push("["+e.name+'] Tag class "'+e.tagClass+'", type "'+e.type+'" expected value length "'+e.value.length+'", got "'+t.value.length+'"');if(i&&r&&(e.capture&&(r[e.capture]=t.value),e.captureAsn1&&(r[e.captureAsn1]=t),e.captureBitStringContents&&"bitStringContents"in t&&(r[e.captureBitStringContents]=t.bitStringContents),e.captureBitStringValue&&"bitStringContents"in t)){var a;if(t.bitStringContents.length<2)r[e.captureBitStringValue]="";else{var c=t.bitStringContents.charCodeAt(0);if(c!==0)throw new Error("captureBitStringValue only supported for zero unused bits");r[e.captureBitStringValue]=t.bitStringContents.slice(1)}}}else n&&n.push("["+e.name+'] Expected constructed "'+e.constructed+'", got "'+t.constructed+'"');else n&&(t.tagClass!==e.tagClass&&n.push("["+e.name+'] Expected tag class "'+e.tagClass+'", got "'+t.tagClass+'"'),t.type!==e.type&&n.push("["+e.name+'] Expected type "'+e.type+'", got "'+t.type+'"'));return i};var Jp=/[^\\u0000-\\u00ff]/;X.prettyPrint=function(t,e,r){var n="";e=e||0,r=r||2,e>0&&(n+=`
20
+ `);for(var i="",s=0;s<e*r;++s)i+=" ";switch(n+=i+"Tag: ",t.tagClass){case X.Class.UNIVERSAL:n+="Universal:";break;case X.Class.APPLICATION:n+="Application:";break;case X.Class.CONTEXT_SPECIFIC:n+="Context-Specific:";break;case X.Class.PRIVATE:n+="Private:";break}if(t.tagClass===X.Class.UNIVERSAL)switch(n+=t.type,t.type){case X.Type.NONE:n+=" (None)";break;case X.Type.BOOLEAN:n+=" (Boolean)";break;case X.Type.INTEGER:n+=" (Integer)";break;case X.Type.BITSTRING:n+=" (Bit string)";break;case X.Type.OCTETSTRING:n+=" (Octet string)";break;case X.Type.NULL:n+=" (Null)";break;case X.Type.OID:n+=" (Object Identifier)";break;case X.Type.ODESC:n+=" (Object Descriptor)";break;case X.Type.EXTERNAL:n+=" (External or Instance of)";break;case X.Type.REAL:n+=" (Real)";break;case X.Type.ENUMERATED:n+=" (Enumerated)";break;case X.Type.EMBEDDED:n+=" (Embedded PDV)";break;case X.Type.UTF8:n+=" (UTF8)";break;case X.Type.ROID:n+=" (Relative Object Identifier)";break;case X.Type.SEQUENCE:n+=" (Sequence)";break;case X.Type.SET:n+=" (Set)";break;case X.Type.PRINTABLESTRING:n+=" (Printable String)";break;case X.Type.IA5String:n+=" (IA5String (ASCII))";break;case X.Type.UTCTIME:n+=" (UTC time)";break;case X.Type.GENERALIZEDTIME:n+=" (Generalized time)";break;case X.Type.BMPSTRING:n+=" (BMP String)";break}else n+=t.type;if(n+=`
21
21
  `,n+=i+"Constructed: "+t.constructed+`
22
- `,t.composed){for(var o=0,a="",s=0;s<t.value.length;++s)t.value[s]!==void 0&&(o+=1,a+=Z.prettyPrint(t.value[s],e+1,r),s+1<t.value.length&&(a+=","));n+=i+"Sub values: "+o+a}else{if(n+=i+"Value: ",t.type===Z.Type.OID){var c=Z.derToOid(t.value);n+=c,Qe.pki&&Qe.pki.oids&&c in Qe.pki.oids&&(n+=" ("+Qe.pki.oids[c]+") ")}if(t.type===Z.Type.INTEGER)try{n+=Z.derToInteger(t.value)}catch(l){n+="0x"+Qe.util.bytesToHex(t.value)}else if(t.type===Z.Type.BITSTRING){if(t.value.length>1?n+="0x"+Qe.util.bytesToHex(t.value.slice(1)):n+="(none)",t.value.length>0){var u=t.value.charCodeAt(0);u==1?n+=" (1 unused bit shown)":u>1&&(n+=" ("+u+" unused bits shown)")}}else t.type===Z.Type.OCTETSTRING?(Fp.test(t.value)||(n+="("+t.value+") "),n+="0x"+Qe.util.bytesToHex(t.value)):t.type===Z.Type.UTF8?n+=Qe.util.decodeUtf8(t.value):t.type===Z.Type.PRINTABLESTRING||t.type===Z.Type.IA5String?n+=t.value:Fp.test(t.value)?n+="0x"+Qe.util.bytesToHex(t.value):t.value.length===0?n+="[null]":n+=t.value}return n}});var xl=w((nq,Vp)=>{var wt=Ee();je();Vp.exports=wt.cipher=wt.cipher||{};wt.cipher.algorithms=wt.cipher.algorithms||{};wt.cipher.createCipher=function(t,e){var r=t;if(typeof r=="string"&&(r=wt.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new wt.cipher.BlockCipher({algorithm:r,key:e,decrypt:!1})};wt.cipher.createDecipher=function(t,e){var r=t;if(typeof r=="string"&&(r=wt.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new wt.cipher.BlockCipher({algorithm:r,key:e,decrypt:!0})};wt.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),wt.cipher.algorithms[t]=e};wt.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in wt.cipher.algorithms?wt.cipher.algorithms[t]:null};var _l=wt.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};_l.prototype.start=function(t){t=t||{};var e={};for(var r in t)e[r]=t[r];e.decrypt=this._decrypt,this._finish=!1,this._input=wt.util.createBuffer(),this.output=t.output||wt.util.createBuffer(),this.mode.start(e)};_l.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};_l.prototype.finish=function(t){t&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(r){return t(this.blockSize,r,!1)},this.mode.unpad=function(r){return t(this.blockSize,r,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,e))}});var Al=w((iq,jp)=>{var _t=Ee();je();_t.cipher=_t.cipher||{};var we=jp.exports=_t.cipher.modes=_t.cipher.modes||{};we.ecb=function(t){t=t||{},this.name="ECB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};we.ecb.prototype.start=function(t){};we.ecb.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};we.ecb.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};we.ecb.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};we.ecb.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),n=t.at(r-1);return n>this.blockSize<<2?!1:(t.truncate(n),!0)};we.cbc=function(t){t=t||{},this.name="CBC",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};we.cbc.prototype.start=function(t){if(t.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in t)this._iv=rc(t.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};we.cbc.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n]);this._prev=this._outBlock};we.cbc.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)};we.cbc.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};we.cbc.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),n=t.at(r-1);return n>this.blockSize<<2?!1:(t.truncate(n),!0)};we.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=_t.util.createBuffer(),this._partialBytes=0};we.cfb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=rc(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};we.cfb.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32()^this._outBlock[i],e.putInt32(this._inBlock[i]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=t.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(s>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};we.cfb.prototype.decrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32(),e.putInt32(this._inBlock[i]^this._outBlock[i]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=t.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(s>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};we.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=_t.util.createBuffer(),this._partialBytes=0};we.ofb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=rc(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};we.ofb.prototype.encrypt=function(t,e,r){var n=t.length();if(t.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(t.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(s>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};we.ofb.prototype.decrypt=we.ofb.prototype.encrypt;we.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=_t.util.createBuffer(),this._partialBytes=0};we.ctr.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=rc(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};we.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize)for(var i=0;i<this._ints;++i)e.putInt32(t.getInt32()^this._outBlock[i]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(s>0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}nc(this._inBlock)};we.ctr.prototype.decrypt=we.ctr.prototype.encrypt;we.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=_t.util.createBuffer(),this._partialBytes=0,this._R=3774873600};we.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var e=_t.util.createBuffer(t.iv);this._cipherLength=0;var r;if("additionalData"in t?r=_t.util.createBuffer(t.additionalData):r=_t.util.createBuffer(),"tagLength"in t?this._tagLength=t.tagLength:this._tagLength=128,this._tag=null,t.decrypt&&(this._tag=_t.util.createBuffer(t.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 n=e.length();if(n===12)this._j0=[e.getInt32(),e.getInt32(),e.getInt32(),1];else{for(this._j0=[0,0,0,0];e.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(Sl(n*8)))}this._inBlock=this._j0.slice(0),nc(this._inBlock),this._partialBytes=0,r=_t.util.createBuffer(r),this._aDataLength=Sl(r.length()*8);var i=r.length()%this.blockSize;for(i&&r.fillWithByte(0,this.blockSize-i),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])};we.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^=t.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(s<=0||r){if(r){var o=n%this.blockSize;this._cipherLength+=o,this._partialOutput.truncate(this.blockSize-o)}else this._cipherLength+=this.blockSize;for(var i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),nc(this._inBlock)};we.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),nc(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize};we.gcm.prototype.afterFinish=function(t,e){var r=!0;e.decrypt&&e.overflow&&t.truncate(this.blockSize-e.overflow),this.tag=_t.util.createBuffer();var n=this._aDataLength.concat(Sl(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^i[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),e.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r};we.gcm.prototype.multiply=function(t,e){for(var r=[0,0,0,0],n=e.slice(0),i=0;i<128;++i){var s=t[i/32|0]&1<<31-i%32;s&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r};we.gcm.prototype.pow=function(t,e){for(var r=t[3]&1,n=3;n>0;--n)e[n]=t[n]>>>1|(t[n-1]&1)<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)};we.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var n=r/8|0,i=t[n]>>>(7-r%8)*4&15,s=this._m[r][i];e[0]^=s[0],e[1]^=s[1],e[2]^=s[2],e[3]^=s[3]}return e};we.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)};we.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,n=4*r,i=16*r,s=new Array(i),o=0;o<i;++o){var a=[0,0,0,0],c=o/n|0,u=(n-1-o%n)*e;a[c]=1<<e-1<<u,s[o]=this.generateSubHashTable(this.multiply(a,t),e)}return s};we.gcm.prototype.generateSubHashTable=function(t,e){var r=1<<e,n=r>>>1,i=new Array(r);i[n]=t.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s<n;){for(var o=1;o<s;++o){var a=i[s],c=i[o];i[s+o]=[a[0]^c[0],a[1]^c[1],a[2]^c[2],a[3]^c[3]]}s*=2}for(i[0]=[0,0,0,0],s=n+1;s<r;++s){var u=i[s^n];i[s]=[t[0]^u[0],t[1]^u[1],t[2]^u[2],t[3]^u[3]]}return i};function rc(t,e){if(typeof t=="string"&&(t=_t.util.createBuffer(t)),_t.util.isArray(t)&&t.length>4){var r=t;t=_t.util.createBuffer();for(var n=0;n<r.length;++n)t.putByte(r[n])}if(t.length()<e)throw new Error("Invalid IV length; got "+t.length()+" bytes and expected "+e+" bytes.");if(!_t.util.isArray(t)){for(var i=[],s=e/4,n=0;n<s;++n)i.push(t.getInt32());t=i}return t}function nc(t){t[t.length-1]=t[t.length-1]+1&4294967295}function Sl(t){return[t/4294967296|0,t&4294967295]}});var _s=w((sq,Gp)=>{var $e=Ee();xl();Al();je();Gp.exports=$e.aes=$e.aes||{};$e.aes.startEncrypting=function(t,e,r,n){var i=ic({key:t,output:r,decrypt:!1,mode:n});return i.start(e),i};$e.aes.createEncryptionCipher=function(t,e){return ic({key:t,output:null,decrypt:!1,mode:e})};$e.aes.startDecrypting=function(t,e,r,n){var i=ic({key:t,output:r,decrypt:!0,mode:n});return i.start(e),i};$e.aes.createDecryptionCipher=function(t,e){return ic({key:t,output:null,decrypt:!0,mode:e})};$e.aes.Algorithm=function(t,e){Cl||Hp();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(n,i){return Tl(r._w,n,i,!1)},decrypt:function(n,i){return Tl(r._w,n,i,!0)}}}),r._init=!1};$e.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e=t.key,r;if(typeof e=="string"&&(e.length===16||e.length===24||e.length===32))e=$e.util.createBuffer(e);else if($e.util.isArray(e)&&(e.length===16||e.length===24||e.length===32)){r=e,e=$e.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(!$e.util.isArray(e)){r=e,e=[];var i=r.length();if(i===16||i===24||i===32){i=i>>>2;for(var n=0;n<i;++n)e.push(r.getInt32())}}if(!$e.util.isArray(e)||!(e.length===4||e.length===6||e.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,o=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=zp(e,t.decrypt&&!o),this._init=!0}};$e.aes._expandKey=function(t,e){return Cl||Hp(),zp(t,e)};$e.aes._updateBlock=Tl;Es("AES-ECB",$e.cipher.modes.ecb);Es("AES-CBC",$e.cipher.modes.cbc);Es("AES-CFB",$e.cipher.modes.cfb);Es("AES-OFB",$e.cipher.modes.ofb);Es("AES-CTR",$e.cipher.modes.ctr);Es("AES-GCM",$e.cipher.modes.gcm);function Es(t,e){var r=function(){return new $e.aes.Algorithm(t,e)};$e.cipher.registerAlgorithm(t,r)}var Cl=!1,ws=4,Vt,Il,$p,_i,Nr;function Hp(){Cl=!0,$p=[0,1,2,4,8,16,32,64,128,27,54];for(var t=new Array(256),e=0;e<128;++e)t[e]=e<<1,t[e+128]=e+128<<1^283;Vt=new Array(256),Il=new Array(256),_i=new Array(4),Nr=new Array(4);for(var e=0;e<4;++e)_i[e]=new Array(256),Nr[e]=new Array(256);for(var r=0,n=0,i,s,o,a,c,u,l,e=0;e<256;++e){a=n^n<<1^n<<2^n<<3^n<<4,a=a>>8^a&255^99,Vt[r]=a,Il[a]=r,c=t[a],i=t[r],s=t[i],o=t[s],u=c<<24^a<<16^a<<8^(a^c),l=(i^s^o)<<24^(r^o)<<16^(r^s^o)<<8^(r^i^o);for(var f=0;f<4;++f)_i[f][r]=u,Nr[f][a]=l,u=u<<24|u>>>8,l=l<<24|l>>>8;r===0?r=n=1:(r=i^t[t[t[i^o]]],n^=t[t[n]])}}function zp(t,e){for(var r=t.slice(0),n,i=1,s=r.length,o=s+6+1,a=ws*o,c=s;c<a;++c)n=r[c-1],c%s==0?(n=Vt[n>>>16&255]<<24^Vt[n>>>8&255]<<16^Vt[n&255]<<8^Vt[n>>>24]^$p[i]<<24,i++):s>6&&c%s==4&&(n=Vt[n>>>24]<<24^Vt[n>>>16&255]<<16^Vt[n>>>8&255]<<8^Vt[n&255]),r[c]=r[c-s]^n;if(e){var u,l=Nr[0],f=Nr[1],h=Nr[2],p=Nr[3],d=r.slice(0);a=r.length;for(var c=0,g=a-ws;c<a;c+=ws,g-=ws)if(c===0||c===a-ws)d[c]=r[g],d[c+1]=r[g+3],d[c+2]=r[g+2],d[c+3]=r[g+1];else for(var m=0;m<ws;++m)u=r[g+m],d[c+(3&-m)]=l[Vt[u>>>24]]^f[Vt[u>>>16&255]]^h[Vt[u>>>8&255]]^p[Vt[u&255]];r=d}return r}function Tl(t,e,r,n){var i=t.length/4-1,s,o,a,c,u;n?(s=Nr[0],o=Nr[1],a=Nr[2],c=Nr[3],u=Il):(s=_i[0],o=_i[1],a=_i[2],c=_i[3],u=Vt);var l,f,h,p,d,g,m;l=e[0]^t[0],f=e[n?3:1]^t[1],h=e[2]^t[2],p=e[n?1:3]^t[3];for(var x=3,B=1;B<i;++B)d=s[l>>>24]^o[f>>>16&255]^a[h>>>8&255]^c[p&255]^t[++x],g=s[f>>>24]^o[h>>>16&255]^a[p>>>8&255]^c[l&255]^t[++x],m=s[h>>>24]^o[p>>>16&255]^a[l>>>8&255]^c[f&255]^t[++x],p=s[p>>>24]^o[l>>>16&255]^a[f>>>8&255]^c[h&255]^t[++x],l=d,f=g,h=m;r[0]=u[l>>>24]<<24^u[f>>>16&255]<<16^u[h>>>8&255]<<8^u[p&255]^t[++x],r[n?3:1]=u[f>>>24]<<24^u[h>>>16&255]<<16^u[p>>>8&255]<<8^u[l&255]^t[++x],r[2]=u[h>>>24]<<24^u[p>>>16&255]<<16^u[l>>>8&255]<<8^u[f&255]^t[++x],r[n?1:3]=u[p>>>24]<<24^u[l>>>16&255]<<16^u[f>>>8&255]<<8^u[h&255]^t[++x]}function ic(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="AES-"+e,n;t.decrypt?n=$e.cipher.createDecipher(r,t.key):n=$e.cipher.createCipher(r,t.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof $e.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var oc=w((oq,Yp)=>{var Xe=Ee();xl();Al();je();Yp.exports=Xe.des=Xe.des||{};Xe.des.startEncrypting=function(t,e,r,n){var i=sc({key:t,output:r,decrypt:!1,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};Xe.des.createEncryptionCipher=function(t,e){return sc({key:t,output:null,decrypt:!1,mode:e})};Xe.des.startDecrypting=function(t,e,r,n){var i=sc({key:t,output:r,decrypt:!0,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};Xe.des.createDecryptionCipher=function(t,e){return sc({key:t,output:null,decrypt:!0,mode:e})};Xe.des.Algorithm=function(t,e){var r=this;r.name=t,r.mode=new e({blockSize:8,cipher:{encrypt:function(n,i){return Wp(r._keys,n,i,!1)},decrypt:function(n,i){return Wp(r._keys,n,i,!0)}}}),r._init=!1};Xe.des.Algorithm.prototype.initialize=function(t){if(!this._init){var e=Xe.util.createBuffer(t.key);if(this.name.indexOf("3DES")===0&&e.length()!==24)throw new Error("Invalid Triple-DES key size: "+e.length()*8);this._keys=uT(e),this._init=!0}};$r("DES-ECB",Xe.cipher.modes.ecb);$r("DES-CBC",Xe.cipher.modes.cbc);$r("DES-CFB",Xe.cipher.modes.cfb);$r("DES-OFB",Xe.cipher.modes.ofb);$r("DES-CTR",Xe.cipher.modes.ctr);$r("3DES-ECB",Xe.cipher.modes.ecb);$r("3DES-CBC",Xe.cipher.modes.cbc);$r("3DES-CFB",Xe.cipher.modes.cfb);$r("3DES-OFB",Xe.cipher.modes.ofb);$r("3DES-CTR",Xe.cipher.modes.ctr);function $r(t,e){var r=function(){return new Xe.des.Algorithm(t,e)};Xe.cipher.registerAlgorithm(t,r)}var tT=[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],rT=[-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],nT=[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],iT=[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],sT=[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],oT=[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],aT=[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],cT=[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 uT(t){for(var e=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],a=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[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],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],d=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=t.length()>8?3:1,m=[],x=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],B=0,L,H=0;H<g;H++){var U=t.getInt32(),q=t.getInt32();L=(U>>>4^q)&252645135,q^=L,U^=L<<4,L=(q>>>-16^U)&65535,U^=L,q^=L<<-16,L=(U>>>2^q)&858993459,q^=L,U^=L<<2,L=(q>>>-16^U)&65535,U^=L,q^=L<<-16,L=(U>>>1^q)&1431655765,q^=L,U^=L<<1,L=(q>>>8^U)&16711935,U^=L,q^=L<<8,L=(U>>>1^q)&1431655765,q^=L,U^=L<<1,L=U<<8|q>>>20&240,U=q<<24|q<<8&16711680|q>>>8&65280|q>>>24&240,q=L;for(var re=0;re<x.length;++re){x[re]?(U=U<<2|U>>>26,q=q<<2|q>>>26):(U=U<<1|U>>>27,q=q<<1|q>>>27),U&=-15,q&=-15;var se=e[U>>>28]|r[U>>>24&15]|n[U>>>20&15]|i[U>>>16&15]|s[U>>>12&15]|o[U>>>8&15]|a[U>>>4&15],j=c[q>>>28]|u[q>>>24&15]|l[q>>>20&15]|f[q>>>16&15]|h[q>>>12&15]|p[q>>>8&15]|d[q>>>4&15];L=(j>>>16^se)&65535,m[B++]=se^L,m[B++]=j^L<<16}}return m}function Wp(t,e,r,n){var i=t.length===32?3:9,s;i===3?s=n?[30,-2,-2]:[0,32,2]:s=n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var o,a=e[0],c=e[1];o=(a>>>4^c)&252645135,c^=o,a^=o<<4,o=(a>>>16^c)&65535,c^=o,a^=o<<16,o=(c>>>2^a)&858993459,a^=o,c^=o<<2,o=(c>>>8^a)&16711935,a^=o,c^=o<<8,o=(a>>>1^c)&1431655765,c^=o,a^=o<<1,a=a<<1|a>>>31,c=c<<1|c>>>31;for(var u=0;u<i;u+=3){for(var l=s[u+1],f=s[u+2],h=s[u];h!=l;h+=f){var p=c^t[h],d=(c>>>4|c<<28)^t[h+1];o=a,a=c,c=o^(rT[p>>>24&63]|iT[p>>>16&63]|oT[p>>>8&63]|cT[p&63]|tT[d>>>24&63]|nT[d>>>16&63]|sT[d>>>8&63]|aT[d&63])}o=a,a=c,c=o}a=a>>>1|a<<31,c=c>>>1|c<<31,o=(a>>>1^c)&1431655765,c^=o,a^=o<<1,o=(c>>>8^a)&16711935,a^=o,c^=o<<8,o=(c>>>2^a)&858993459,a^=o,c^=o<<2,o=(a>>>16^c)&65535,c^=o,a^=o<<16,o=(a>>>4^c)&252645135,c^=o,a^=o<<4,r[0]=a,r[1]=c}function sc(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="DES-"+e,n;t.decrypt?n=Xe.cipher.createDecipher(r,t.key):n=Xe.cipher.createCipher(r,t.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof Xe.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var Mn=w((aq,Qp)=>{var ac=Ee();Qp.exports=ac.md=ac.md||{};ac.md.algorithms=ac.md.algorithms||{}});var Zp=w((cq,Xp)=>{var dn=Ee();Mn();je();var lT=Xp.exports=dn.hmac=dn.hmac||{};lT.create=function(){var t=null,e=null,r=null,n=null,i={};return i.start=function(s,o){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in dn.md.algorithms)e=dn.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else e=s;if(o===null)o=t;else{if(typeof o=="string")o=dn.util.createBuffer(o);else if(dn.util.isArray(o)){var a=o;o=dn.util.createBuffer();for(var c=0;c<a.length;++c)o.putByte(a[c])}var u=o.length();u>e.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),r=dn.util.createBuffer(),n=dn.util.createBuffer(),u=o.length();for(var c=0;c<u;++c){var a=o.at(c);r.putByte(54^a),n.putByte(92^a)}if(u<e.blockLength)for(var a=e.blockLength-u,c=0;c<a;++c)r.putByte(54),n.putByte(92);t=o,r=r.bytes(),n=n.bytes()}e.start(),e.update(r)},i.update=function(s){e.update(s)},i.getMac=function(){var s=e.digest().bytes();return e.start(),e.update(n),e.update(s),e.digest()},i.digest=i.getMac,i}});var xs=w(()=>{});var Rl=w((fq,Jp)=>{var jt=Ee();Zp();Mn();je();var fT=jt.pkcs5=jt.pkcs5||{},pn;jt.util.isNodejs&&!jt.options.usePureJavaScript&&(pn=xs());Jp.exports=jt.pbkdf2=fT.pbkdf2=function(t,e,r,n,i,s){if(typeof i=="function"&&(s=i,i=null),jt.util.isNodejs&&!jt.options.usePureJavaScript&&pn.pbkdf2&&(i===null||typeof i!="object")&&(pn.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),t=Buffer.from(t,"binary"),e=Buffer.from(e,"binary"),s?pn.pbkdf2Sync.length===4?pn.pbkdf2(t,e,r,n,function(L,H){if(L)return s(L);s(null,H.toString("binary"))}):pn.pbkdf2(t,e,r,n,i,function(L,H){if(L)return s(L);s(null,H.toString("binary"))}):pn.pbkdf2Sync.length===4?pn.pbkdf2Sync(t,e,r,n).toString("binary"):pn.pbkdf2Sync(t,e,r,n,i).toString("binary");if((typeof i=="undefined"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in jt.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=jt.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var a=new Error("Derived key is too long.");if(s)return s(a);throw a}var c=Math.ceil(n/o),u=n-(c-1)*o,l=jt.hmac.create();l.start(i,t);var f="",h,p,d;if(!s){for(var g=1;g<=c;++g){l.start(null,null),l.update(e),l.update(jt.util.int32ToBytes(g)),h=d=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(d),p=l.digest().getBytes(),h=jt.util.xorBytes(h,p,o),d=p;f+=g<c?h:h.substr(0,u)}return f}var g=1,m;function x(){if(g>c)return s(null,f);l.start(null,null),l.update(e),l.update(jt.util.int32ToBytes(g)),h=d=l.digest().getBytes(),m=2,B()}function B(){if(m<=r)return l.start(null,null),l.update(d),p=l.digest().getBytes(),h=jt.util.xorBytes(h,p,o),d=p,++m,jt.util.setImmediate(B);f+=g<c?h:h.substr(0,u),++g,x()}x()}});var lc=w((hq,ty)=>{var cc=Ee();je();var ey=ty.exports=cc.pem=cc.pem||{};ey.encode=function(t,e){e=e||{};var r="-----BEGIN "+t.type+`-----\r
23
- `,n;if(t.procType&&(n={name:"Proc-Type",values:[String(t.procType.version),t.procType.type]},r+=uc(n)),t.contentDomain&&(n={name:"Content-Domain",values:[t.contentDomain]},r+=uc(n)),t.dekInfo&&(n={name:"DEK-Info",values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&n.values.push(t.dekInfo.parameters),r+=uc(n)),t.headers)for(var i=0;i<t.headers.length;++i)r+=uc(t.headers[i]);return t.procType&&(r+=`\r
24
- `),r+=cc.util.encode64(t.body,e.maxline||64)+`\r
22
+ `,t.composed){for(var o=0,a="",s=0;s<t.value.length;++s)t.value[s]!==void 0&&(o+=1,a+=X.prettyPrint(t.value[s],e+1,r),s+1<t.value.length&&(a+=","));n+=i+"Sub values: "+o+a}else{if(n+=i+"Value: ",t.type===X.Type.OID){var c=X.derToOid(t.value);n+=c,Qe.pki&&Qe.pki.oids&&c in Qe.pki.oids&&(n+=" ("+Qe.pki.oids[c]+") ")}if(t.type===X.Type.INTEGER)try{n+=X.derToInteger(t.value)}catch(l){n+="0x"+Qe.util.bytesToHex(t.value)}else if(t.type===X.Type.BITSTRING){if(t.value.length>1?n+="0x"+Qe.util.bytesToHex(t.value.slice(1)):n+="(none)",t.value.length>0){var u=t.value.charCodeAt(0);u==1?n+=" (1 unused bit shown)":u>1&&(n+=" ("+u+" unused bits shown)")}}else t.type===X.Type.OCTETSTRING?(Jp.test(t.value)||(n+="("+t.value+") "),n+="0x"+Qe.util.bytesToHex(t.value)):t.type===X.Type.UTF8?n+=Qe.util.decodeUtf8(t.value):t.type===X.Type.PRINTABLESTRING||t.type===X.Type.IA5String?n+=t.value:Jp.test(t.value)?n+="0x"+Qe.util.bytesToHex(t.value):t.value.length===0?n+="[null]":n+=t.value}return n}});var kl=w((Fq,ty)=>{var _t=be();$e();ty.exports=_t.cipher=_t.cipher||{};_t.cipher.algorithms=_t.cipher.algorithms||{};_t.cipher.createCipher=function(t,e){var r=t;if(typeof r=="string"&&(r=_t.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new _t.cipher.BlockCipher({algorithm:r,key:e,decrypt:!1})};_t.cipher.createDecipher=function(t,e){var r=t;if(typeof r=="string"&&(r=_t.cipher.getAlgorithm(r),r&&(r=r())),!r)throw new Error("Unsupported algorithm: "+t);return new _t.cipher.BlockCipher({algorithm:r,key:e,decrypt:!0})};_t.cipher.registerAlgorithm=function(t,e){t=t.toUpperCase(),_t.cipher.algorithms[t]=e};_t.cipher.getAlgorithm=function(t){return t=t.toUpperCase(),t in _t.cipher.algorithms?_t.cipher.algorithms[t]:null};var Ll=_t.cipher.BlockCipher=function(t){this.algorithm=t.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=t.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=t.decrypt,this.algorithm.initialize(t)};Ll.prototype.start=function(t){t=t||{};var e={};for(var r in t)e[r]=t[r];e.decrypt=this._decrypt,this._finish=!1,this._input=_t.util.createBuffer(),this.output=t.output||_t.util.createBuffer(),this.mode.start(e)};Ll.prototype.update=function(t){for(t&&this._input.putBuffer(t);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()};Ll.prototype.finish=function(t){t&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(r){return t(this.blockSize,r,!1)},this.mode.unpad=function(r){return t(this.blockSize,r,!0)});var e={};return e.decrypt=this._decrypt,e.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,e)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,e))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,e))}});var Ul=w((Kq,ry)=>{var xt=be();$e();xt.cipher=xt.cipher||{};var Ee=ry.exports=xt.cipher.modes=xt.cipher.modes||{};Ee.ecb=function(t){t=t||{},this.name="ECB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};Ee.ecb.prototype.start=function(t){};Ee.ecb.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};Ee.ecb.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n])};Ee.ecb.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};Ee.ecb.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),n=t.at(r-1);return n>this.blockSize<<2?!1:(t.truncate(n),!0)};Ee.cbc=function(t){t=t||{},this.name="CBC",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)};Ee.cbc.prototype.start=function(t){if(t.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in t)this._iv=cc(t.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")};Ee.cbc.prototype.encrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^t.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._outBlock[n]);this._prev=this._outBlock};Ee.cbc.prototype.decrypt=function(t,e,r){if(t.length()<this.blockSize&&!(r&&t.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=t.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var n=0;n<this._ints;++n)e.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)};Ee.cbc.prototype.pad=function(t,e){var r=t.length()===this.blockSize?this.blockSize:this.blockSize-t.length();return t.fillWithByte(r,r),!0};Ee.cbc.prototype.unpad=function(t,e){if(e.overflow>0)return!1;var r=t.length(),n=t.at(r-1);return n>this.blockSize<<2?!1:(t.truncate(n),!0)};Ee.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=xt.util.createBuffer(),this._partialBytes=0};Ee.cfb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=cc(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};Ee.cfb.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32()^this._outBlock[i],e.putInt32(this._inBlock[i]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=t.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(s>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};Ee.cfb.prototype.decrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)this._inBlock[i]=t.getInt32(),e.putInt32(this._inBlock[i]^this._outBlock[i]);return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialBlock[i]=t.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(s>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};Ee.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=xt.util.createBuffer(),this._partialBytes=0};Ee.ofb.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=cc(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};Ee.ofb.prototype.encrypt=function(t,e,r){var n=t.length();if(t.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(t.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];return}var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(s>0)t.read-=this.blockSize;else for(var i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0};Ee.ofb.prototype.decrypt=Ee.ofb.prototype.encrypt;Ee.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=xt.util.createBuffer(),this._partialBytes=0};Ee.ctr.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");this._iv=cc(t.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0};Ee.ctr.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize)for(var i=0;i<this._ints;++i)e.putInt32(t.getInt32()^this._outBlock[i]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(s>0&&(t.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}uc(this._inBlock)};Ee.ctr.prototype.decrypt=Ee.ctr.prototype.encrypt;Ee.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=xt.util.createBuffer(),this._partialBytes=0,this._R=3774873600};Ee.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var e=xt.util.createBuffer(t.iv);this._cipherLength=0;var r;if("additionalData"in t?r=xt.util.createBuffer(t.additionalData):r=xt.util.createBuffer(),"tagLength"in t?this._tagLength=t.tagLength:this._tagLength=128,this._tag=null,t.decrypt&&(this._tag=xt.util.createBuffer(t.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 n=e.length();if(n===12)this._j0=[e.getInt32(),e.getInt32(),e.getInt32(),1];else{for(this._j0=[0,0,0,0];e.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[e.getInt32(),e.getInt32(),e.getInt32(),e.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(ql(n*8)))}this._inBlock=this._j0.slice(0),uc(this._inBlock),this._partialBytes=0,r=xt.util.createBuffer(r),this._aDataLength=ql(r.length()*8);var i=r.length()%this.blockSize;for(i&&r.fillWithByte(0,this.blockSize-i),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])};Ee.gcm.prototype.encrypt=function(t,e,r){var n=t.length();if(n===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&n>=this.blockSize){for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^=t.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var i=0;i<this._ints;++i)this._partialOutput.putInt32(t.getInt32()^this._outBlock[i]);if(s<=0||r){if(r){var o=n%this.blockSize;this._cipherLength+=o,this._partialOutput.truncate(this.blockSize-o)}else this._cipherLength+=this.blockSize;for(var i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.read-=this.blockSize,e.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;e.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),uc(this._inBlock)};Ee.gcm.prototype.decrypt=function(t,e,r){var n=t.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),uc(this._inBlock),this._hashBlock[0]=t.getInt32(),this._hashBlock[1]=t.getInt32(),this._hashBlock[2]=t.getInt32(),this._hashBlock[3]=t.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)e.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize};Ee.gcm.prototype.afterFinish=function(t,e){var r=!0;e.decrypt&&e.overflow&&t.truncate(this.blockSize-e.overflow),this.tag=xt.util.createBuffer();var n=this._aDataLength.concat(ql(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,n);var i=[];this.cipher.encrypt(this._j0,i);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^i[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),e.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r};Ee.gcm.prototype.multiply=function(t,e){for(var r=[0,0,0,0],n=e.slice(0),i=0;i<128;++i){var s=t[i/32|0]&1<<31-i%32;s&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r};Ee.gcm.prototype.pow=function(t,e){for(var r=t[3]&1,n=3;n>0;--n)e[n]=t[n]>>>1|(t[n-1]&1)<<31;e[0]=t[0]>>>1,r&&(e[0]^=this._R)};Ee.gcm.prototype.tableMultiply=function(t){for(var e=[0,0,0,0],r=0;r<32;++r){var n=r/8|0,i=t[n]>>>(7-r%8)*4&15,s=this._m[r][i];e[0]^=s[0],e[1]^=s[1],e[2]^=s[2],e[3]^=s[3]}return e};Ee.gcm.prototype.ghash=function(t,e,r){return e[0]^=r[0],e[1]^=r[1],e[2]^=r[2],e[3]^=r[3],this.tableMultiply(e)};Ee.gcm.prototype.generateHashTable=function(t,e){for(var r=8/e,n=4*r,i=16*r,s=new Array(i),o=0;o<i;++o){var a=[0,0,0,0],c=o/n|0,u=(n-1-o%n)*e;a[c]=1<<e-1<<u,s[o]=this.generateSubHashTable(this.multiply(a,t),e)}return s};Ee.gcm.prototype.generateSubHashTable=function(t,e){var r=1<<e,n=r>>>1,i=new Array(r);i[n]=t.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s<n;){for(var o=1;o<s;++o){var a=i[s],c=i[o];i[s+o]=[a[0]^c[0],a[1]^c[1],a[2]^c[2],a[3]^c[3]]}s*=2}for(i[0]=[0,0,0,0],s=n+1;s<r;++s){var u=i[s^n];i[s]=[t[0]^u[0],t[1]^u[1],t[2]^u[2],t[3]^u[3]]}return i};function cc(t,e){if(typeof t=="string"&&(t=xt.util.createBuffer(t)),xt.util.isArray(t)&&t.length>4){var r=t;t=xt.util.createBuffer();for(var n=0;n<r.length;++n)t.putByte(r[n])}if(t.length()<e)throw new Error("Invalid IV length; got "+t.length()+" bytes and expected "+e+" bytes.");if(!xt.util.isArray(t)){for(var i=[],s=e/4,n=0;n<s;++n)i.push(t.getInt32());t=i}return t}function uc(t){t[t.length-1]=t[t.length-1]+1&4294967295}function ql(t){return[t/4294967296|0,t&4294967295]}});var Ss=w((Vq,oy)=>{var He=be();kl();Ul();$e();oy.exports=He.aes=He.aes||{};He.aes.startEncrypting=function(t,e,r,n){var i=lc({key:t,output:r,decrypt:!1,mode:n});return i.start(e),i};He.aes.createEncryptionCipher=function(t,e){return lc({key:t,output:null,decrypt:!1,mode:e})};He.aes.startDecrypting=function(t,e,r,n){var i=lc({key:t,output:r,decrypt:!0,mode:n});return i.start(e),i};He.aes.createDecryptionCipher=function(t,e){return lc({key:t,output:null,decrypt:!0,mode:e})};He.aes.Algorithm=function(t,e){Ml||iy();var r=this;r.name=t,r.mode=new e({blockSize:16,cipher:{encrypt:function(n,i){return Kl(r._w,n,i,!1)},decrypt:function(n,i){return Kl(r._w,n,i,!0)}}}),r._init=!1};He.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var e=t.key,r;if(typeof e=="string"&&(e.length===16||e.length===24||e.length===32))e=He.util.createBuffer(e);else if(He.util.isArray(e)&&(e.length===16||e.length===24||e.length===32)){r=e,e=He.util.createBuffer();for(var n=0;n<r.length;++n)e.putByte(r[n])}if(!He.util.isArray(e)){r=e,e=[];var i=r.length();if(i===16||i===24||i===32){i=i>>>2;for(var n=0;n<i;++n)e.push(r.getInt32())}}if(!He.util.isArray(e)||!(e.length===4||e.length===6||e.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,o=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=sy(e,t.decrypt&&!o),this._init=!0}};He.aes._expandKey=function(t,e){return Ml||iy(),sy(t,e)};He.aes._updateBlock=Kl;_s("AES-ECB",He.cipher.modes.ecb);_s("AES-CBC",He.cipher.modes.cbc);_s("AES-CFB",He.cipher.modes.cfb);_s("AES-OFB",He.cipher.modes.ofb);_s("AES-CTR",He.cipher.modes.ctr);_s("AES-GCM",He.cipher.modes.gcm);function _s(t,e){var r=function(){return new He.aes.Algorithm(t,e)};He.cipher.registerAlgorithm(t,r)}var Ml=!1,xs=4,jt,Fl,ny,xi,Pr;function iy(){Ml=!0,ny=[0,1,2,4,8,16,32,64,128,27,54];for(var t=new Array(256),e=0;e<128;++e)t[e]=e<<1,t[e+128]=e+128<<1^283;jt=new Array(256),Fl=new Array(256),xi=new Array(4),Pr=new Array(4);for(var e=0;e<4;++e)xi[e]=new Array(256),Pr[e]=new Array(256);for(var r=0,n=0,i,s,o,a,c,u,l,e=0;e<256;++e){a=n^n<<1^n<<2^n<<3^n<<4,a=a>>8^a&255^99,jt[r]=a,Fl[a]=r,c=t[a],i=t[r],s=t[i],o=t[s],u=c<<24^a<<16^a<<8^(a^c),l=(i^s^o)<<24^(r^o)<<16^(r^s^o)<<8^(r^i^o);for(var f=0;f<4;++f)xi[f][r]=u,Pr[f][a]=l,u=u<<24|u>>>8,l=l<<24|l>>>8;r===0?r=n=1:(r=i^t[t[t[i^o]]],n^=t[t[n]])}}function sy(t,e){for(var r=t.slice(0),n,i=1,s=r.length,o=s+6+1,a=xs*o,c=s;c<a;++c)n=r[c-1],c%s==0?(n=jt[n>>>16&255]<<24^jt[n>>>8&255]<<16^jt[n&255]<<8^jt[n>>>24]^ny[i]<<24,i++):s>6&&c%s==4&&(n=jt[n>>>24]<<24^jt[n>>>16&255]<<16^jt[n>>>8&255]<<8^jt[n&255]),r[c]=r[c-s]^n;if(e){var u,l=Pr[0],f=Pr[1],h=Pr[2],p=Pr[3],d=r.slice(0);a=r.length;for(var c=0,g=a-xs;c<a;c+=xs,g-=xs)if(c===0||c===a-xs)d[c]=r[g],d[c+1]=r[g+3],d[c+2]=r[g+2],d[c+3]=r[g+1];else for(var m=0;m<xs;++m)u=r[g+m],d[c+(3&-m)]=l[jt[u>>>24]]^f[jt[u>>>16&255]]^h[jt[u>>>8&255]]^p[jt[u&255]];r=d}return r}function Kl(t,e,r,n){var i=t.length/4-1,s,o,a,c,u;n?(s=Pr[0],o=Pr[1],a=Pr[2],c=Pr[3],u=Fl):(s=xi[0],o=xi[1],a=xi[2],c=xi[3],u=jt);var l,f,h,p,d,g,m;l=e[0]^t[0],f=e[n?3:1]^t[1],h=e[2]^t[2],p=e[n?1:3]^t[3];for(var x=3,R=1;R<i;++R)d=s[l>>>24]^o[f>>>16&255]^a[h>>>8&255]^c[p&255]^t[++x],g=s[f>>>24]^o[h>>>16&255]^a[p>>>8&255]^c[l&255]^t[++x],m=s[h>>>24]^o[p>>>16&255]^a[l>>>8&255]^c[f&255]^t[++x],p=s[p>>>24]^o[l>>>16&255]^a[f>>>8&255]^c[h&255]^t[++x],l=d,f=g,h=m;r[0]=u[l>>>24]<<24^u[f>>>16&255]<<16^u[h>>>8&255]<<8^u[p&255]^t[++x],r[n?3:1]=u[f>>>24]<<24^u[h>>>16&255]<<16^u[p>>>8&255]<<8^u[l&255]^t[++x],r[2]=u[h>>>24]<<24^u[p>>>16&255]<<16^u[l>>>8&255]<<8^u[f&255]^t[++x],r[n?1:3]=u[p>>>24]<<24^u[l>>>16&255]<<16^u[f>>>8&255]<<8^u[h&255]^t[++x]}function lc(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="AES-"+e,n;t.decrypt?n=He.cipher.createDecipher(r,t.key):n=He.cipher.createCipher(r,t.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof He.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var hc=w((jq,cy)=>{var Xe=be();kl();Ul();$e();cy.exports=Xe.des=Xe.des||{};Xe.des.startEncrypting=function(t,e,r,n){var i=fc({key:t,output:r,decrypt:!1,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};Xe.des.createEncryptionCipher=function(t,e){return fc({key:t,output:null,decrypt:!1,mode:e})};Xe.des.startDecrypting=function(t,e,r,n){var i=fc({key:t,output:r,decrypt:!0,mode:n||(e===null?"ECB":"CBC")});return i.start(e),i};Xe.des.createDecryptionCipher=function(t,e){return fc({key:t,output:null,decrypt:!0,mode:e})};Xe.des.Algorithm=function(t,e){var r=this;r.name=t,r.mode=new e({blockSize:8,cipher:{encrypt:function(n,i){return ay(r._keys,n,i,!1)},decrypt:function(n,i){return ay(r._keys,n,i,!0)}}}),r._init=!1};Xe.des.Algorithm.prototype.initialize=function(t){if(!this._init){var e=Xe.util.createBuffer(t.key);if(this.name.indexOf("3DES")===0&&e.length()!==24)throw new Error("Invalid Triple-DES key size: "+e.length()*8);this._keys=MT(e),this._init=!0}};Hr("DES-ECB",Xe.cipher.modes.ecb);Hr("DES-CBC",Xe.cipher.modes.cbc);Hr("DES-CFB",Xe.cipher.modes.cfb);Hr("DES-OFB",Xe.cipher.modes.ofb);Hr("DES-CTR",Xe.cipher.modes.ctr);Hr("3DES-ECB",Xe.cipher.modes.ecb);Hr("3DES-CBC",Xe.cipher.modes.cbc);Hr("3DES-CFB",Xe.cipher.modes.cfb);Hr("3DES-OFB",Xe.cipher.modes.ofb);Hr("3DES-CTR",Xe.cipher.modes.ctr);function Hr(t,e){var r=function(){return new Xe.des.Algorithm(t,e)};Xe.cipher.registerAlgorithm(t,r)}var PT=[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],NT=[-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],OT=[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],DT=[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],LT=[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],kT=[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],qT=[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],UT=[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 MT(t){for(var e=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],a=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[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],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],d=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],g=t.length()>8?3:1,m=[],x=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],R=0,L,H=0;H<g;H++){var q=t.getInt32(),k=t.getInt32();L=(q>>>4^k)&252645135,k^=L,q^=L<<4,L=(k>>>-16^q)&65535,q^=L,k^=L<<-16,L=(q>>>2^k)&858993459,k^=L,q^=L<<2,L=(k>>>-16^q)&65535,q^=L,k^=L<<-16,L=(q>>>1^k)&1431655765,k^=L,q^=L<<1,L=(k>>>8^q)&16711935,q^=L,k^=L<<8,L=(q>>>1^k)&1431655765,k^=L,q^=L<<1,L=q<<8|k>>>20&240,q=k<<24|k<<8&16711680|k>>>8&65280|k>>>24&240,k=L;for(var J=0;J<x.length;++J){x[J]?(q=q<<2|q>>>26,k=k<<2|k>>>26):(q=q<<1|q>>>27,k=k<<1|k>>>27),q&=-15,k&=-15;var ie=e[q>>>28]|r[q>>>24&15]|n[q>>>20&15]|i[q>>>16&15]|s[q>>>12&15]|o[q>>>8&15]|a[q>>>4&15],j=c[k>>>28]|u[k>>>24&15]|l[k>>>20&15]|f[k>>>16&15]|h[k>>>12&15]|p[k>>>8&15]|d[k>>>4&15];L=(j>>>16^ie)&65535,m[R++]=ie^L,m[R++]=j^L<<16}}return m}function ay(t,e,r,n){var i=t.length===32?3:9,s;i===3?s=n?[30,-2,-2]:[0,32,2]:s=n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var o,a=e[0],c=e[1];o=(a>>>4^c)&252645135,c^=o,a^=o<<4,o=(a>>>16^c)&65535,c^=o,a^=o<<16,o=(c>>>2^a)&858993459,a^=o,c^=o<<2,o=(c>>>8^a)&16711935,a^=o,c^=o<<8,o=(a>>>1^c)&1431655765,c^=o,a^=o<<1,a=a<<1|a>>>31,c=c<<1|c>>>31;for(var u=0;u<i;u+=3){for(var l=s[u+1],f=s[u+2],h=s[u];h!=l;h+=f){var p=c^t[h],d=(c>>>4|c<<28)^t[h+1];o=a,a=c,c=o^(NT[p>>>24&63]|DT[p>>>16&63]|kT[p>>>8&63]|UT[p&63]|PT[d>>>24&63]|OT[d>>>16&63]|LT[d>>>8&63]|qT[d&63])}o=a,a=c,c=o}a=a>>>1|a<<31,c=c>>>1|c<<31,o=(a>>>1^c)&1431655765,c^=o,a^=o<<1,o=(c>>>8^a)&16711935,a^=o,c^=o<<8,o=(c>>>2^a)&858993459,a^=o,c^=o<<2,o=(a>>>16^c)&65535,c^=o,a^=o<<16,o=(a>>>4^c)&252645135,c^=o,a^=o<<4,r[0]=a,r[1]=c}function fc(t){t=t||{};var e=(t.mode||"CBC").toUpperCase(),r="DES-"+e,n;t.decrypt?n=Xe.cipher.createDecipher(r,t.key):n=Xe.cipher.createCipher(r,t.key);var i=n.start;return n.start=function(s,o){var a=null;o instanceof Xe.util.ByteBuffer&&(a=o,o={}),o=o||{},o.output=a,o.iv=s,i.call(n,o)},n}});var Vn=w(($q,uy)=>{var dc=be();uy.exports=dc.md=dc.md||{};dc.md.algorithms=dc.md.algorithms||{}});var fy=w((Hq,ly)=>{var yn=be();Vn();$e();var FT=ly.exports=yn.hmac=yn.hmac||{};FT.create=function(){var t=null,e=null,r=null,n=null,i={};return i.start=function(s,o){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in yn.md.algorithms)e=yn.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else e=s;if(o===null)o=t;else{if(typeof o=="string")o=yn.util.createBuffer(o);else if(yn.util.isArray(o)){var a=o;o=yn.util.createBuffer();for(var c=0;c<a.length;++c)o.putByte(a[c])}var u=o.length();u>e.blockLength&&(e.start(),e.update(o.bytes()),o=e.digest()),r=yn.util.createBuffer(),n=yn.util.createBuffer(),u=o.length();for(var c=0;c<u;++c){var a=o.at(c);r.putByte(54^a),n.putByte(92^a)}if(u<e.blockLength)for(var a=e.blockLength-u,c=0;c<a;++c)r.putByte(54),n.putByte(92);t=o,r=r.bytes(),n=n.bytes()}e.start(),e.update(r)},i.update=function(s){e.update(s)},i.getMac=function(){var s=e.digest().bytes();return e.start(),e.update(n),e.update(s),e.digest()},i.digest=i.getMac,i}});var As=w(()=>{});var Vl=w((Wq,hy)=>{var $t=be();fy();Vn();$e();var KT=$t.pkcs5=$t.pkcs5||{},gn;$t.util.isNodejs&&!$t.options.usePureJavaScript&&(gn=As());hy.exports=$t.pbkdf2=KT.pbkdf2=function(t,e,r,n,i,s){if(typeof i=="function"&&(s=i,i=null),$t.util.isNodejs&&!$t.options.usePureJavaScript&&gn.pbkdf2&&(i===null||typeof i!="object")&&(gn.pbkdf2Sync.length>4||!i||i==="sha1"))return typeof i!="string"&&(i="sha1"),t=Buffer.from(t,"binary"),e=Buffer.from(e,"binary"),s?gn.pbkdf2Sync.length===4?gn.pbkdf2(t,e,r,n,function(L,H){if(L)return s(L);s(null,H.toString("binary"))}):gn.pbkdf2(t,e,r,n,i,function(L,H){if(L)return s(L);s(null,H.toString("binary"))}):gn.pbkdf2Sync.length===4?gn.pbkdf2Sync(t,e,r,n).toString("binary"):gn.pbkdf2Sync(t,e,r,n,i).toString("binary");if((typeof i=="undefined"||i===null)&&(i="sha1"),typeof i=="string"){if(!(i in $t.md.algorithms))throw new Error("Unknown hash algorithm: "+i);i=$t.md[i].create()}var o=i.digestLength;if(n>4294967295*o){var a=new Error("Derived key is too long.");if(s)return s(a);throw a}var c=Math.ceil(n/o),u=n-(c-1)*o,l=$t.hmac.create();l.start(i,t);var f="",h,p,d;if(!s){for(var g=1;g<=c;++g){l.start(null,null),l.update(e),l.update($t.util.int32ToBytes(g)),h=d=l.digest().getBytes();for(var m=2;m<=r;++m)l.start(null,null),l.update(d),p=l.digest().getBytes(),h=$t.util.xorBytes(h,p,o),d=p;f+=g<c?h:h.substr(0,u)}return f}var g=1,m;function x(){if(g>c)return s(null,f);l.start(null,null),l.update(e),l.update($t.util.int32ToBytes(g)),h=d=l.digest().getBytes(),m=2,R()}function R(){if(m<=r)return l.start(null,null),l.update(d),p=l.digest().getBytes(),h=$t.util.xorBytes(h,p,o),d=p,++m,$t.util.setImmediate(R);f+=g<c?h:h.substr(0,u),++g,x()}x()}});var gc=w((Yq,py)=>{var pc=be();$e();var dy=py.exports=pc.pem=pc.pem||{};dy.encode=function(t,e){e=e||{};var r="-----BEGIN "+t.type+`-----\r
23
+ `,n;if(t.procType&&(n={name:"Proc-Type",values:[String(t.procType.version),t.procType.type]},r+=yc(n)),t.contentDomain&&(n={name:"Content-Domain",values:[t.contentDomain]},r+=yc(n)),t.dekInfo&&(n={name:"DEK-Info",values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&n.values.push(t.dekInfo.parameters),r+=yc(n)),t.headers)for(var i=0;i<t.headers.length;++i)r+=yc(t.headers[i]);return t.procType&&(r+=`\r
24
+ `),r+=pc.util.encode64(t.body,e.maxline||64)+`\r
25
25
  `,r+="-----END "+t.type+`-----\r
26
- `,r};ey.decode=function(t){for(var e=[],r=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,n=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,i=/\r?\n/,s;s=r.exec(t),!!s;){var o={type:s[1],procType:null,contentDomain:null,dekInfo:null,headers:[],body:cc.util.decode64(s[3])};if(e.push(o),!!s[2]){for(var a=s[2].split(i),c=0;s&&c<a.length;){for(var u=a[c].replace(/\s+$/,""),l=c+1;l<a.length;++l){var f=a[l];if(!/\s/.test(f[0]))break;u+=f,c=l}if(s=u.match(n),s){for(var h={name:s[1],values:[]},p=s[2].split(","),d=0;d<p.length;++d)h.values.push(hT(p[d]));if(o.procType)if(!o.contentDomain&&h.name==="Content-Domain")o.contentDomain=p[0]||"";else if(!o.dekInfo&&h.name==="DEK-Info"){if(h.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');o.dekInfo={algorithm:p[0],parameters:p[1]||null}}else o.headers.push(h);else{if(h.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(h.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');o.procType={version:p[0],type:p[1]}}}++c}if(o.procType==="ENCRYPTED"&&!o.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(e.length===0)throw new Error("Invalid PEM formatted message.");return e};function uc(t){for(var e=t.name+": ",r=[],n=function(c,u){return" "+u},i=0;i<t.values.length;++i)r.push(t.values[i].replace(/^(\S+\r\n)/,n));e+=r.join(",")+`\r
26
+ `,r};dy.decode=function(t){for(var e=[],r=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,n=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,i=/\r?\n/,s;s=r.exec(t),!!s;){var o=s[1];o==="NEW CERTIFICATE REQUEST"&&(o="CERTIFICATE REQUEST");var a={type:o,procType:null,contentDomain:null,dekInfo:null,headers:[],body:pc.util.decode64(s[3])};if(e.push(a),!!s[2]){for(var c=s[2].split(i),u=0;s&&u<c.length;){for(var l=c[u].replace(/\s+$/,""),f=u+1;f<c.length;++f){var h=c[f];if(!/\s/.test(h[0]))break;l+=h,u=f}if(s=l.match(n),s){for(var p={name:s[1],values:[]},d=s[2].split(","),g=0;g<d.length;++g)p.values.push(VT(d[g]));if(a.procType)if(!a.contentDomain&&p.name==="Content-Domain")a.contentDomain=d[0]||"";else if(!a.dekInfo&&p.name==="DEK-Info"){if(p.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');a.dekInfo={algorithm:d[0],parameters:d[1]||null}}else a.headers.push(p);else{if(p.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(p.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');a.procType={version:d[0],type:d[1]}}}++u}if(a.procType==="ENCRYPTED"&&!a.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(e.length===0)throw new Error("Invalid PEM formatted message.");return e};function yc(t){for(var e=t.name+": ",r=[],n=function(c,u){return" "+u},i=0;i<t.values.length;++i)r.push(t.values[i].replace(/^(\S+\r\n)/,n));e+=r.join(",")+`\r
27
27
  `;for(var s=0,o=-1,i=0;i<e.length;++i,++s)if(s>65&&o!==-1){var a=e[o];a===","?(++o,e=e.substr(0,o)+`\r
28
28
  `+e.substr(o)):e=e.substr(0,o)+`\r
29
- `+a+e.substr(o+1),s=i-o-1,o=-1,++i}else(e[i]===" "||e[i]===" "||e[i]===",")&&(o=i);return e}function hT(t){return t.replace(/^\s+/,"")}});var ay=w((dq,oy)=>{var Hr=Ee();Mn();je();var ry=oy.exports=Hr.sha256=Hr.sha256||{};Hr.md.sha256=Hr.md.algorithms.sha256=ry;ry.create=function(){ny||dT();var t=null,e=Hr.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=Hr.util.createBuffer(),t={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=Hr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),sy(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=Hr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(Bl.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};sy(f,r,i);var h=Hr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h.putInt32(f.h5),h.putInt32(f.h6),h.putInt32(f.h7),h},n};var Bl=null,ny=!1,iy=null;function dT(){Bl=String.fromCharCode(128),Bl+=Hr.util.fillString(String.fromCharCode(0),64),iy=[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],ny=!0}function sy(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,p,d,g,m,x,B=r.length();B>=64;){for(u=0;u<16;++u)e[u]=r.getInt32();for(;u<64;++u)n=e[u-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=e[u-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[u]=n+e[u-7]+i+e[u-16]|0;for(l=t.h0,f=t.h1,h=t.h2,p=t.h3,d=t.h4,g=t.h5,m=t.h6,x=t.h7,u=0;u<64;++u)o=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7),a=m^d&(g^m),s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),c=l&f|h&(l^f),n=x+o+a+iy[u]+e[u],i=s+c,x=m,m=g,g=d,d=p+n>>>0,p=h,h=f,f=l,l=n+i>>>0;t.h0=t.h0+l|0,t.h1=t.h1+f|0,t.h2=t.h2+h|0,t.h3=t.h3+p|0,t.h4=t.h4+d|0,t.h5=t.h5+g|0,t.h6=t.h6+m|0,t.h7=t.h7+x|0,B-=64}}});var uy=w((pq,cy)=>{var zr=Ee();je();var fc=null;zr.util.isNodejs&&!zr.options.usePureJavaScript&&!process.versions["node-webkit"]&&(fc=xs());var pT=cy.exports=zr.prng=zr.prng||{};pT.create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();e.pools=n,e.pool=0,e.generate=function(u,l){if(!l)return e.generateSync(u);var f=e.plugin.cipher,h=e.plugin.increment,p=e.plugin.formatKey,d=e.plugin.formatSeed,g=zr.util.createBuffer();e.key=null,m();function m(x){if(x)return l(x);if(g.length()>=u)return l(null,g.getBytes(u));if(e.generated>1048575&&(e.key=null),e.key===null)return zr.util.nextTick(function(){s(m)});var B=f(e.key,e.seed);e.generated+=B.length,g.putBytes(B),e.key=p(f(e.key,h(e.seed))),e.seed=d(f(e.key,e.seed)),zr.util.setImmediate(m)}},e.generateSync=function(u){var l=e.plugin.cipher,f=e.plugin.increment,h=e.plugin.formatKey,p=e.plugin.formatSeed;e.key=null;for(var d=zr.util.createBuffer();d.length()<u;){e.generated>1048575&&(e.key=null),e.key===null&&o();var g=l(e.key,e.seed);e.generated+=g.length,d.putBytes(g),e.key=h(l(e.key,f(e.seed))),e.seed=p(l(e.key,e.seed))}return d.getBytes(u)};function s(u){if(e.pools[0].messageLength>=32)return a(),u();var l=32-e.pools[0].messageLength<<5;e.seedFile(l,function(f,h){if(f)return u(f);e.collect(h),a(),u()})}function o(){if(e.pools[0].messageLength>=32)return a();var u=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(u)),a()}function a(){e.reseeds=e.reseeds===4294967295?0:e.reseeds+1;var u=e.plugin.md.create();u.update(e.keyBytes);for(var l=1,f=0;f<32;++f)e.reseeds%l==0&&(u.update(e.pools[f].digest().getBytes()),e.pools[f].start()),l=l<<1;e.keyBytes=u.digest().getBytes(),u.start(),u.update(e.keyBytes);var h=u.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(h),e.generated=0}function c(u){var l=null,f=zr.util.globalScope,h=f.crypto||f.msCrypto;h&&h.getRandomValues&&(l=function(U){return h.getRandomValues(U)});var p=zr.util.createBuffer();if(l)for(;p.length()<u;){var d=Math.max(1,Math.min(u-p.length(),65536)/4),g=new Uint32Array(Math.floor(d));try{l(g);for(var m=0;m<g.length;++m)p.putInt32(g[m])}catch(U){if(!(typeof QuotaExceededError!="undefined"&&U instanceof QuotaExceededError))throw U}}if(p.length()<u)for(var x,B,L,H=Math.floor(Math.random()*65536);p.length()<u;){B=16807*(H&65535),x=16807*(H>>16),B+=(x&32767)<<16,B+=x>>15,B=(B&2147483647)+(B>>31),H=B&4294967295;for(var m=0;m<3;++m)L=H>>>(m<<3),L^=Math.floor(Math.random()*256),p.putByte(String.fromCharCode(L&255))}return p.getBytes(u)}return fc?(e.seedFile=function(u,l){fc.randomBytes(u,function(f,h){if(f)return l(f);l(null,h.toString())})},e.seedFileSync=function(u){return fc.randomBytes(u).toString()}):(e.seedFile=function(u,l){try{l(null,c(u))}catch(f){l(f)}},e.seedFileSync=c),e.collect=function(u){for(var l=u.length,f=0;f<l;++f)e.pools[e.pool].update(u.substr(f,1)),e.pool=e.pool===31?0:e.pool+1},e.collectInt=function(u,l){for(var f="",h=0;h<l;h+=8)f+=String.fromCharCode(u>>h&255);e.collect(f)},e.registerWorker=function(u){if(u===self)e.seedFile=function(f,h){function p(d){var g=d.data;g.forge&&g.forge.prng&&(self.removeEventListener("message",p),h(g.forge.prng.err,g.forge.prng.bytes))}self.addEventListener("message",p),self.postMessage({forge:{prng:{needed:f}}})};else{var l=function(f){var h=f.data;h.forge&&h.forge.prng&&e.seedFile(h.forge.prng.needed,function(p,d){u.postMessage({forge:{prng:{err:p,bytes:d}}})})};u.addEventListener("message",l)}},e}});var xi=w((yq,Pl)=>{var xt=Ee();_s();ay();uy();je();(function(){if(xt.random&&xt.random.getBytes){Pl.exports=xt.random;return}(function(t){var e={},r=new Array(4),n=xt.util.createBuffer();e.formatKey=function(f){var h=xt.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),xt.aes._expandKey(f,!1)},e.formatSeed=function(f){var h=xt.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),f},e.cipher=function(f,h){return xt.aes._updateBlock(f,h,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},e.increment=function(f){return++f[3],f},e.md=xt.md.sha256;function i(){var f=xt.prng.create(e);return f.getBytes=function(h,p){return f.generate(h,p)},f.getBytesSync=function(h){return f.generate(h)},f}var s=i(),o=null,a=xt.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(o=function(f){return c.getRandomValues(f)}),xt.options.usePureJavaScript||!xt.util.isNodejs&&!o){if(typeof window=="undefined"||window.document===void 0,s.collectInt(+new Date,32),typeof navigator!="undefined"){var u="";for(var l in navigator)try{typeof navigator[l]=="string"&&(u+=navigator[l])}catch(f){}s.collect(u),u=null}t&&(t().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),t().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!xt.random)xt.random=s;else for(var l in s)xt.random[l]=s[l];xt.random.createInstance=i,Pl.exports=xt.random})(typeof jQuery!="undefined"?jQuery:null)})()});var dy=w((gq,hy)=>{var Zt=Ee();je();var Nl=[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],ly=[1,2,3,5],yT=function(t,e){return t<<e&65535|(t&65535)>>16-e},gT=function(t,e){return(t&65535)>>e|t<<16-e&65535};hy.exports=Zt.rc2=Zt.rc2||{};Zt.rc2.expandKey=function(t,e){typeof t=="string"&&(t=Zt.util.createBuffer(t)),e=e||128;var r=t,n=t.length(),i=e,s=Math.ceil(i/8),o=255>>(i&7),a;for(a=n;a<128;a++)r.putByte(Nl[r.at(a-1)+r.at(a-n)&255]);for(r.setAt(128-s,Nl[r.at(128-s)&o]),a=127-s;a>=0;a--)r.setAt(a,Nl[r.at(a+1)^r.at(a+s)]);return r};var fy=function(t,e,r){var n=!1,i=null,s=null,o=null,a,c,u,l,f=[];for(t=Zt.rc2.expandKey(t,e),u=0;u<64;u++)f.push(t.getInt16Le());r?(a=function(d){for(u=0;u<4;u++)d[u]+=f[l]+(d[(u+3)%4]&d[(u+2)%4])+(~d[(u+3)%4]&d[(u+1)%4]),d[u]=yT(d[u],ly[u]),l++},c=function(d){for(u=0;u<4;u++)d[u]+=f[d[(u+3)%4]&63]}):(a=function(d){for(u=3;u>=0;u--)d[u]=gT(d[u],ly[u]),d[u]-=f[l]+(d[(u+3)%4]&d[(u+2)%4])+(~d[(u+3)%4]&d[(u+1)%4]),l--},c=function(d){for(u=3;u>=0;u--)d[u]-=f[d[(u+3)%4]&63]});var h=function(d){var g=[];for(u=0;u<4;u++){var m=i.getInt16Le();o!==null&&(r?m^=o.getInt16Le():o.putInt16Le(m)),g.push(m&65535)}l=r?0:63;for(var x=0;x<d.length;x++)for(var B=0;B<d[x][0];B++)d[x][1](g);for(u=0;u<4;u++)o!==null&&(r?o.putInt16Le(g[u]):g[u]^=o.getInt16Le()),s.putInt16Le(g[u])},p=null;return p={start:function(d,g){d&&typeof d=="string"&&(d=Zt.util.createBuffer(d)),n=!1,i=Zt.util.createBuffer(),s=g||new Zt.util.createBuffer,o=d,p.output=s},update:function(d){for(n||i.putBuffer(d);i.length()>=8;)h([[5,a],[1,c],[6,a],[1,c],[5,a]])},finish:function(d){var g=!0;if(r)if(d)g=d(8,i,!r);else{var m=i.length()===8?8:8-i.length();i.fillWithByte(m,m)}if(g&&(n=!0,p.update()),!r&&(g=i.length()===0,g))if(d)g=d(8,s,!r);else{var x=s.length(),B=s.at(x-1);B>x?g=!1:s.truncate(B)}return g}},p};Zt.rc2.startEncrypting=function(t,e,r){var n=Zt.rc2.createEncryptionCipher(t,128);return n.start(e,r),n};Zt.rc2.createEncryptionCipher=function(t,e){return fy(t,e,!0)};Zt.rc2.startDecrypting=function(t,e,r){var n=Zt.rc2.createDecryptionCipher(t,128);return n.start(e,r),n};Zt.rc2.createDecryptionCipher=function(t,e){return fy(t,e,!1)}});var pc=w((mq,wy)=>{var Ol=Ee();wy.exports=Ol.jsbn=Ol.jsbn||{};var yn,mT=244837814094590,py=(mT&16777215)==15715070;function K(t,e,r){this.data=[],t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}Ol.jsbn.BigInteger=K;function Re(){return new K(null)}function vT(t,e,r,n,i,s){for(;--s>=0;){var o=e*this.data[t++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=o&67108863}return i}function bT(t,e,r,n,i,s){for(var o=e&32767,a=e>>15;--s>=0;){var c=this.data[t]&32767,u=this.data[t++]>>15,l=a*c+u*o;c=o*c+((l&32767)<<15)+r.data[n]+(i&1073741823),i=(c>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=c&1073741823}return i}function yy(t,e,r,n,i,s){for(var o=e&16383,a=e>>14;--s>=0;){var c=this.data[t]&16383,u=this.data[t++]>>14,l=a*c+u*o;c=o*c+((l&16383)<<14)+r.data[n]+i,i=(c>>28)+(l>>14)+a*u,r.data[n++]=c&268435455}return i}typeof navigator=="undefined"?(K.prototype.am=yy,yn=28):py&&navigator.appName=="Microsoft Internet Explorer"?(K.prototype.am=bT,yn=30):py&&navigator.appName!="Netscape"?(K.prototype.am=vT,yn=26):(K.prototype.am=yy,yn=28);K.prototype.DB=yn;K.prototype.DM=(1<<yn)-1;K.prototype.DV=1<<yn;var Dl=52;K.prototype.FV=Math.pow(2,Dl);K.prototype.F1=Dl-yn;K.prototype.F2=2*yn-Dl;var ET="0123456789abcdefghijklmnopqrstuvwxyz",hc=new Array,Ss,hr;Ss="0".charCodeAt(0);for(hr=0;hr<=9;++hr)hc[Ss++]=hr;Ss="a".charCodeAt(0);for(hr=10;hr<36;++hr)hc[Ss++]=hr;Ss="A".charCodeAt(0);for(hr=10;hr<36;++hr)hc[Ss++]=hr;function gy(t){return ET.charAt(t)}function my(t,e){var r=hc[t.charCodeAt(e)];return r??-1}function wT(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s}function _T(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0}function Fn(t){var e=Re();return e.fromInt(t),e}function xT(t,e){var r;if(e==16)r=4;else if(e==8)r=3;else if(e==256)r=8;else if(e==2)r=1;else if(e==32)r=5;else if(e==4)r=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var o=r==8?t[n]&255:my(t,n);if(o<0){t.charAt(n)=="-"&&(i=!0);continue}i=!1,s==0?this.data[this.t++]=o:s+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this.data[this.t++]=o>>this.DB-s):this.data[this.t-1]|=o<<s,s+=r,s>=this.DB&&(s-=this.DB)}r==8&&(t[0]&128)!=0&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&K.ZERO.subTo(this,this)}function ST(){for(var t=this.s&this.DM;this.t>0&&this.data[this.t-1]==t;)--this.t}function AT(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var r=(1<<e)-1,n,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(n=this.data[o]>>a)>0&&(i=!0,s=gy(n));o>=0;)a<e?(n=(this.data[o]&(1<<a)-1)<<e-a,n|=this.data[--o]>>(a+=this.DB-e)):(n=this.data[o]>>(a-=e)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=gy(n));return i?s:"0"}function CT(){var t=Re();return K.ZERO.subTo(this,t),t}function IT(){return this.s<0?this.negate():this}function TT(t){var e=this.s-t.s;if(e!=0)return e;var r=this.t;if(e=r-t.t,e!=0)return this.s<0?-e:e;for(;--r>=0;)if((e=this.data[r]-t.data[r])!=0)return e;return 0}function dc(t){var e=1,r;return(r=t>>>16)!=0&&(t=r,e+=16),(r=t>>8)!=0&&(t=r,e+=8),(r=t>>4)!=0&&(t=r,e+=4),(r=t>>2)!=0&&(t=r,e+=2),(r=t>>1)!=0&&(t=r,e+=1),e}function RT(){return this.t<=0?0:this.DB*(this.t-1)+dc(this.data[this.t-1]^this.s&this.DM)}function BT(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s}function PT(t,e){for(var r=t;r<this.t;++r)e.data[r-t]=this.data[r];e.t=Math.max(this.t-t,0),e.s=this.s}function NT(t,e){var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a;for(a=this.t-1;a>=0;--a)e.data[a+s+1]=this.data[a]>>n|o,o=(this.data[a]&i)<<r;for(a=s-1;a>=0;--a)e.data[a]=0;e.data[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()}function OT(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t){e.t=0;return}var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)e.data[o-r-1]|=(this.data[o]&s)<<i,e.data[o-r]=this.data[o]>>n;n>0&&(e.data[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}function DT(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]-t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()}function LT(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i<n.t;++i)e.data[i+r.t]=r.am(0,n.data[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&K.ZERO.subTo(e,e)}function kT(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t.data[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e.data[r],t,2*r,0,1);(t.data[r+e.t]+=e.am(r+1,2*e.data[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()}function qT(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t){e!=null&&e.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=Re());var s=Re(),o=this.s,a=t.s,c=this.DB-dc(n.data[n.t-1]);c>0?(n.lShiftTo(c,s),i.lShiftTo(c,r)):(n.copyTo(s),i.copyTo(r));var u=s.t,l=s.data[u-1];if(l!=0){var f=l*(1<<this.F1)+(u>1?s.data[u-2]>>this.F2:0),h=this.FV/f,p=(1<<this.F1)/f,d=1<<this.F2,g=r.t,m=g-u,x=e??Re();for(s.dlShiftTo(m,x),r.compareTo(x)>=0&&(r.data[r.t++]=1,r.subTo(x,r)),K.ONE.dlShiftTo(u,x),x.subTo(s,s);s.t<u;)s.data[s.t++]=0;for(;--m>=0;){var B=r.data[--g]==l?this.DM:Math.floor(r.data[g]*h+(r.data[g-1]+d)*p);if((r.data[g]+=s.am(0,B,r,m,0,u))<B)for(s.dlShiftTo(m,x),r.subTo(x,r);r.data[g]<--B;)r.subTo(x,r)}e!=null&&(r.drShiftTo(u,e),o!=a&&K.ZERO.subTo(e,e)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&K.ZERO.subTo(r,r)}}}function UT(t){var e=Re();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(K.ZERO)>0&&t.subTo(e,e),e}function Si(t){this.m=t}function MT(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function FT(t){return t}function KT(t){t.divRemTo(this.m,null,t)}function VT(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function jT(t,e){t.squareTo(e),this.reduce(e)}Si.prototype.convert=MT;Si.prototype.revert=FT;Si.prototype.reduce=KT;Si.prototype.mulTo=VT;Si.prototype.sqrTo=jT;function $T(){if(this.t<1)return 0;var t=this.data[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function Ai(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function HT(t){var e=Re();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(K.ZERO)>0&&this.m.subTo(e,e),e}function zT(t){var e=Re();return t.copyTo(e),this.reduce(e),e}function GT(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=t.data[e]&32767,n=r*this.mpl+((r*this.mph+(t.data[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function WT(t,e){t.squareTo(e),this.reduce(e)}function YT(t,e,r){t.multiplyTo(e,r),this.reduce(r)}Ai.prototype.convert=HT;Ai.prototype.revert=zT;Ai.prototype.reduce=GT;Ai.prototype.mulTo=YT;Ai.prototype.sqrTo=WT;function QT(){return(this.t>0?this.data[0]&1:this.s)==0}function XT(t,e){if(t>4294967295||t<1)return K.ONE;var r=Re(),n=Re(),i=e.convert(this),s=dc(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<<s)>0)e.mulTo(n,i,r);else{var o=r;r=n,n=o}return e.revert(r)}function ZT(t,e){var r;return t<256||e.isEven()?r=new Si(e):r=new Ai(e),this.exp(t,r)}K.prototype.copyTo=wT;K.prototype.fromInt=_T;K.prototype.fromString=xT;K.prototype.clamp=ST;K.prototype.dlShiftTo=BT;K.prototype.drShiftTo=PT;K.prototype.lShiftTo=NT;K.prototype.rShiftTo=OT;K.prototype.subTo=DT;K.prototype.multiplyTo=LT;K.prototype.squareTo=kT;K.prototype.divRemTo=qT;K.prototype.invDigit=$T;K.prototype.isEven=QT;K.prototype.exp=XT;K.prototype.toString=AT;K.prototype.negate=CT;K.prototype.abs=IT;K.prototype.compareTo=TT;K.prototype.bitLength=RT;K.prototype.mod=UT;K.prototype.modPowInt=ZT;K.ZERO=Fn(0);K.ONE=Fn(1);function JT(){var t=Re();return this.copyTo(t),t}function eR(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function tR(){return this.t==0?this.s:this.data[0]<<24>>24}function rR(){return this.t==0?this.s:this.data[0]<<16>>16}function nR(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function iR(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function sR(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=Fn(r),i=Re(),s=Re(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o}function oR(t,e){this.fromInt(0),e==null&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,o=0,a=0;a<t.length;++a){var c=my(t,a);if(c<0){t.charAt(a)=="-"&&this.signum()==0&&(i=!0);continue}o=e*o+c,++s>=r&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0)}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&K.ZERO.subTo(this,this)}function aR(t,e,r){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(K.ONE.shiftLeft(t-1),Ll,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(K.ONE.shiftLeft(t-1),this);else{var n=new Array,i=t&7;n.length=(t>>3)+1,e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}function cR(){var t=this.t,e=new Array;e[0]=this.s;var r=this.DB-t*this.DB%8,n,i=0;if(t-- >0)for(r<this.DB&&(n=this.data[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this.data[t]&(1<<r)-1)<<8-r,n|=this.data[--t]>>(r+=this.DB-8)):(n=this.data[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),(n&128)!=0&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e}function uR(t){return this.compareTo(t)==0}function lR(t){return this.compareTo(t)<0?this:t}function fR(t){return this.compareTo(t)>0?this:t}function hR(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r.data[n]=e(this.data[n],t.data[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r.data[n]=e(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r.data[n]=e(i,t.data[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function dR(t,e){return t&e}function pR(t){var e=Re();return this.bitwiseTo(t,dR,e),e}function Ll(t,e){return t|e}function yR(t){var e=Re();return this.bitwiseTo(t,Ll,e),e}function vy(t,e){return t^e}function gR(t){var e=Re();return this.bitwiseTo(t,vy,e),e}function by(t,e){return t&~e}function mR(t){var e=Re();return this.bitwiseTo(t,by,e),e}function vR(){for(var t=Re(),e=0;e<this.t;++e)t.data[e]=this.DM&~this.data[e];return t.t=this.t,t.s=~this.s,t}function bR(t){var e=Re();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function ER(t){var e=Re();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function wR(t){if(t==0)return-1;var e=0;return(t&65535)==0&&(t>>=16,e+=16),(t&255)==0&&(t>>=8,e+=8),(t&15)==0&&(t>>=4,e+=4),(t&3)==0&&(t>>=2,e+=2),(t&1)==0&&++e,e}function _R(){for(var t=0;t<this.t;++t)if(this.data[t]!=0)return t*this.DB+wR(this.data[t]);return this.s<0?this.t*this.DB:-1}function xR(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function SR(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=xR(this.data[r]^e);return t}function AR(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<t%this.DB)!=0}function CR(t,e){var r=K.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}function IR(t){return this.changeBit(t,Ll)}function TR(t){return this.changeBit(t,by)}function RR(t){return this.changeBit(t,vy)}function BR(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]+t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()}function PR(t){var e=Re();return this.addTo(t,e),e}function NR(t){var e=Re();return this.subTo(t,e),e}function OR(t){var e=Re();return this.multiplyTo(t,e),e}function DR(t){var e=Re();return this.divRemTo(t,e,null),e}function LR(t){var e=Re();return this.divRemTo(t,null,e),e}function kR(t){var e=Re(),r=Re();return this.divRemTo(t,e,r),new Array(e,r)}function qR(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function UR(t,e){if(t!=0){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}}function Lo(){}function Ey(t){return t}function MR(t,e,r){t.multiplyTo(e,r)}function FR(t,e){t.squareTo(e)}Lo.prototype.convert=Ey;Lo.prototype.revert=Ey;Lo.prototype.mulTo=MR;Lo.prototype.sqrTo=FR;function KR(t){return this.exp(t,new Lo)}function VR(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var i;for(i=r.t-this.t;n<i;++n)r.data[n+this.t]=this.am(0,t.data[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t.data[n],r,n,0,e-n);r.clamp()}function jR(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r.data[this.t+n-e]=this.am(e-n,t.data[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}function As(t){this.r2=Re(),this.q3=Re(),K.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function $R(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=Re();return t.copyTo(e),this.reduce(e),e}function HR(t){return t}function zR(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function GR(t,e){t.squareTo(e),this.reduce(e)}function WR(t,e,r){t.multiplyTo(e,r),this.reduce(r)}As.prototype.convert=$R;As.prototype.revert=HR;As.prototype.reduce=zR;As.prototype.mulTo=WR;As.prototype.sqrTo=GR;function YR(t,e){var r=t.bitLength(),n,i=Fn(1),s;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?s=new Si(e):e.isEven()?s=new As(e):s=new Ai(e);var o=new Array,a=3,c=n-1,u=(1<<n)-1;if(o[1]=s.convert(this),n>1){var l=Re();for(s.sqrTo(o[1],l);a<=u;)o[a]=Re(),s.mulTo(l,o[a-2],o[a]),a+=2}var f=t.t-1,h,p=!0,d=Re(),g;for(r=dc(t.data[f])-1;f>=0;){for(r>=c?h=t.data[f]>>r-c&u:(h=(t.data[f]&(1<<r+1)-1)<<c-r,f>0&&(h|=t.data[f-1]>>this.DB+r-c)),a=n;(h&1)==0;)h>>=1,--a;if((r-=a)<0&&(r+=this.DB,--f),p)o[h].copyTo(i),p=!1;else{for(;a>1;)s.sqrTo(i,d),s.sqrTo(d,i),a-=2;a>0?s.sqrTo(i,d):(g=i,i=d,d=g),s.mulTo(d,o[h],i)}for(;f>=0&&(t.data[f]&1<<r)==0;)s.sqrTo(i,d),g=i,i=d,d=g,--r<0&&(r=this.DB-1,--f)}return s.revert(i)}function QR(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function XR(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(e==0)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r}function ZR(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return K.ZERO;for(var r=t.clone(),n=this.clone(),i=Fn(1),s=Fn(0),o=Fn(0),a=Fn(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),e?((!i.isEven()||!s.isEven())&&(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(o,i),s.subTo(a,s)):(n.subTo(r,n),e&&o.subTo(i,o),a.subTo(s,a))}if(n.compareTo(K.ONE)!=0)return K.ZERO;if(a.compareTo(t)>=0)return a.subtract(t);if(a.signum()<0)a.addTo(t,a);else return a;return a.signum()<0?a.add(t):a}var Or=[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],JR=(1<<26)/Or[Or.length-1];function e4(t){var e,r=this.abs();if(r.t==1&&r.data[0]<=Or[Or.length-1]){for(e=0;e<Or.length;++e)if(r.data[0]==Or[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<Or.length;){for(var n=Or[e],i=e+1;i<Or.length&&n<JR;)n*=Or[i++];for(n=r.modInt(n);e<i;)if(n%Or[e++]==0)return!1}return r.millerRabin(t)}function t4(t){var e=this.subtract(K.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n=e.shiftRight(r),i=r4(),s,o=0;o<t;++o){do s=new K(this.bitLength(),i);while(s.compareTo(K.ONE)<=0||s.compareTo(e)>=0);var a=s.modPow(n,this);if(a.compareTo(K.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<r&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(K.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function r4(){return{nextBytes:function(t){for(var e=0;e<t.length;++e)t[e]=Math.floor(Math.random()*256)}}}K.prototype.chunkSize=nR;K.prototype.toRadix=sR;K.prototype.fromRadix=oR;K.prototype.fromNumber=aR;K.prototype.bitwiseTo=hR;K.prototype.changeBit=CR;K.prototype.addTo=BR;K.prototype.dMultiply=qR;K.prototype.dAddOffset=UR;K.prototype.multiplyLowerTo=VR;K.prototype.multiplyUpperTo=jR;K.prototype.modInt=XR;K.prototype.millerRabin=t4;K.prototype.clone=JT;K.prototype.intValue=eR;K.prototype.byteValue=tR;K.prototype.shortValue=rR;K.prototype.signum=iR;K.prototype.toByteArray=cR;K.prototype.equals=uR;K.prototype.min=lR;K.prototype.max=fR;K.prototype.and=pR;K.prototype.or=yR;K.prototype.xor=gR;K.prototype.andNot=mR;K.prototype.not=vR;K.prototype.shiftLeft=bR;K.prototype.shiftRight=ER;K.prototype.getLowestSetBit=_R;K.prototype.bitCount=SR;K.prototype.testBit=AR;K.prototype.setBit=IR;K.prototype.clearBit=TR;K.prototype.flipBit=RR;K.prototype.add=PR;K.prototype.subtract=NR;K.prototype.multiply=OR;K.prototype.divide=DR;K.prototype.remainder=LR;K.prototype.divideAndRemainder=kR;K.prototype.modPow=YR;K.prototype.modInverse=ZR;K.prototype.pow=KR;K.prototype.gcd=QR;K.prototype.isProbablePrime=e4});var Cy=w((vq,Ay)=>{var Gr=Ee();Mn();je();var _y=Ay.exports=Gr.sha1=Gr.sha1||{};Gr.md.sha1=Gr.md.algorithms.sha1=_y;_y.create=function(){xy||n4();var t=null,e=Gr.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=Gr.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=Gr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),Sy(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=Gr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(kl.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};Sy(f,r,i);var h=Gr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h},n};var kl=null,xy=!1;function n4(){kl=String.fromCharCode(128),kl+=Gr.util.fillString(String.fromCharCode(0),64),xy=!0}function Sy(t,e,r){for(var n,i,s,o,a,c,u,l,f=r.length();f>=64;){for(i=t.h0,s=t.h1,o=t.h2,a=t.h3,c=t.h4,l=0;l<16;++l)n=r.getInt32(),e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<20;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<32;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<40;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<60;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s&o|a&(s^o),n=(i<<5|i>>>27)+u+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<80;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+s|0,t.h2=t.h2+o|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,f-=64}}});var Ry=w((bq,Ty)=>{var Wr=Ee();je();xi();Cy();var Iy=Ty.exports=Wr.pkcs1=Wr.pkcs1||{};Iy.encode_rsa_oaep=function(t,e,r){var n,i,s,o;typeof r=="string"?(n=r,i=arguments[3]||void 0,s=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(o=r.mgf1.md)),s?s.start():s=Wr.md.sha1.create(),o||(o=s);var a=Math.ceil(t.n.bitLength()/8),c=a-2*s.digestLength-2;if(e.length>c){var u=new Error("RSAES-OAEP input message length is too long.");throw u.length=e.length,u.maxLength=c,u}n||(n=""),s.update(n,"raw");for(var l=s.digest(),f="",h=c-e.length,p=0;p<h;p++)f+="\0";var d=l.getBytes()+f+""+e;if(!i)i=Wr.random.getBytes(s.digestLength);else if(i.length!==s.digestLength){var u=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw u.seedLength=i.length,u.digestLength=s.digestLength,u}var g=yc(i,a-s.digestLength-1,o),m=Wr.util.xorBytes(d,g,d.length),x=yc(m,s.digestLength,o),B=Wr.util.xorBytes(i,x,i.length);return"\0"+B+m};Iy.decode_rsa_oaep=function(t,e,r){var n,i,s;typeof r=="string"?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md));var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var m=new Error("RSAES-OAEP encoded message length is invalid.");throw m.length=e.length,m.expectedLength=o,m}if(i===void 0?i=Wr.md.sha1.create():i.start(),s||(s=i),o<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var a=i.digest().getBytes(),c=e.charAt(0),u=e.substring(1,i.digestLength+1),l=e.substring(1+i.digestLength),f=yc(l,i.digestLength,s),h=Wr.util.xorBytes(u,f,u.length),p=yc(h,o-i.digestLength-1,s),d=Wr.util.xorBytes(l,p,l.length),g=d.substring(0,i.digestLength),m=c!=="\0",x=0;x<i.digestLength;++x)m|=a.charAt(x)!==g.charAt(x);for(var B=1,L=i.digestLength,H=i.digestLength;H<d.length;H++){var U=d.charCodeAt(H),q=U&1^1,re=B?65534:0;m|=U&re,B=B&q,L+=B}if(m||d.charCodeAt(L)!==1)throw new Error("Invalid RSAES-OAEP padding.");return d.substring(L+1)};function yc(t,e,r){r||(r=Wr.md.sha1.create());for(var n="",i=Math.ceil(e/r.digestLength),s=0;s<i;++s){var o=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);r.start(),r.update(t+o),n+=r.digest().getBytes()}return n.substring(0,e)}});var By=w((Eq,ql)=>{var Kn=Ee();je();pc();xi();(function(){if(Kn.prime){ql.exports=Kn.prime;return}var t=ql.exports=Kn.prime=Kn.prime||{},e=Kn.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new e(null);n.fromInt(30);var i=function(f,h){return f|h};t.generateProbablePrime=function(f,h,p){typeof h=="function"&&(p=h,h={}),h=h||{};var d=h.algorithm||"PRIMEINC";typeof d=="string"&&(d={name:d}),d.options=d.options||{};var g=h.prng||Kn.random,m={nextBytes:function(x){for(var B=g.getBytesSync(x.length),L=0;L<x.length;++L)x[L]=B.charCodeAt(L)}};if(d.name==="PRIMEINC")return s(f,m,d.options,p);throw new Error("Invalid prime generation algorithm: "+d.name)};function s(f,h,p,d){return"workers"in p?c(f,h,p,d):o(f,h,p,d)}function o(f,h,p,d){var g=u(f,h),m=0,x=l(g.bitLength());"millerRabinTests"in p&&(x=p.millerRabinTests);var B=10;"maxBlockTime"in p&&(B=p.maxBlockTime),a(g,f,h,m,x,B,d)}function a(f,h,p,d,g,m,x){var B=+new Date;do{if(f.bitLength()>h&&(f=u(h,p)),f.isProbablePrime(g))return x(null,f);f.dAddOffset(r[d++%8],0)}while(m<0||+new Date-B<m);Kn.util.setImmediate(function(){a(f,h,p,d,g,m,x)})}function c(f,h,p,d){if(typeof Worker=="undefined")return o(f,h,p,d);var g=u(f,h),m=p.workers,x=p.workLoad||100,B=x*30/8,L=p.workerScript||"forge/prime.worker.js";if(m===-1)return Kn.util.estimateCores(function(U,q){U&&(q=2),m=q-1,H()});H();function H(){m=Math.max(1,m);for(var U=[],q=0;q<m;++q)U[q]=new Worker(L);for(var re=m,q=0;q<m;++q)U[q].addEventListener("message",j);var se=!1;function j(Ce){if(!se){--re;var ve=Ce.data;if(ve.found){for(var ye=0;ye<U.length;++ye)U[ye].terminate();return se=!0,d(null,new e(ve.prime,16))}g.bitLength()>f&&(g=u(f,h));var nt=g.toString(16);Ce.target.postMessage({hex:nt,workLoad:x}),g.dAddOffset(B,0)}}}}function u(f,h){var p=new e(f,h),d=f-1;return p.testBit(d)||p.bitwiseTo(e.ONE.shiftLeft(d),i,p),p.dAddOffset(31-p.mod(n).byteValue(),0),p}function l(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})()});var ko=w((wq,qy)=>{var he=Ee();Un();pc();bs();Ry();By();xi();je();typeof xe=="undefined"&&(xe=he.jsbn.BigInteger);var xe,Ul=he.util.isNodejs?xs():null,D=he.asn1,dr=he.util;he.pki=he.pki||{};qy.exports=he.pki.rsa=he.rsa=he.rsa||{};var de=he.pki,i4=[6,4,2,4,2,4,6,2],s4={name:"PrivateKeyInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},o4={name:"RSAPrivateKey",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},a4={name:"RSAPublicKey",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},c4=he.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:D.Class.UNIVERSAL,type:D.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},u4=function(t){var e;if(t.algorithm in de.oids)e=de.oids[t.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}var n=D.oidToDer(e).getBytes(),i=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[]),s=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[]);s.value.push(D.create(D.Class.UNIVERSAL,D.Type.OID,!1,n)),s.value.push(D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,""));var o=D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(s),i.value.push(o),D.toDer(i).getBytes()},Py=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);e.dP||(e.dP=e.d.mod(e.p.subtract(xe.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(xe.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new xe(he.util.bytesToHex(he.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(xe.ONE));t=t.multiply(n.modPow(e.e,e.n)).mod(e.n);for(var i=t.mod(e.p).modPow(e.dP,e.p),s=t.mod(e.q).modPow(e.dQ,e.q);i.compareTo(s)<0;)i=i.add(e.p);var o=i.subtract(s).multiply(e.qInv).mod(e.p).multiply(e.q).add(s);return o=o.multiply(n.modInverse(e.n)).mod(e.n),o};de.rsa.encrypt=function(t,e,r){var n=r,i,s=Math.ceil(e.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,i=Ny(t,e,r)):(i=he.util.createBuffer(),i.putBytes(t));for(var o=new xe(i.toHex(),16),a=Py(o,e,n),c=a.toString(16),u=he.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(he.util.hexToBytes(c)),u.getBytes()};de.rsa.decrypt=function(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var s=new Error("Encrypted message length is invalid.");throw s.length=t.length,s.expected=i,s}var o=new xe(he.util.createBuffer(t).toHex(),16);if(o.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=Py(o,e,r),c=a.toString(16),u=he.util.createBuffer(),l=i-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(he.util.hexToBytes(c)),n!==!1?gc(u.getBytes(),e,r):u.getBytes()};de.rsa.createKeyPairGenerationState=function(t,e,r){typeof t=="string"&&(t=parseInt(t,10)),t=t||2048,r=r||{};var n=r.prng||he.random,i={nextBytes:function(a){for(var c=n.getBytesSync(a.length),u=0;u<a.length;++u)a[u]=c.charCodeAt(u)}},s=r.algorithm||"PRIMEINC",o;if(s==="PRIMEINC")o={algorithm:s,state:0,bits:t,rng:i,eInt:e||65537,e:new xe(null),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,keys:null},o.e.fromInt(o.eInt);else throw new Error("Invalid key generation algorithm: "+s);return o};de.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new xe(null);r.fromInt(30);for(var n=0,i=function(f,h){return f|h},s=+new Date,o,a=0;t.keys===null&&(e<=0||a<e);){if(t.state===0){var c=t.p===null?t.pBits:t.qBits,u=c-1;t.pqState===0?(t.num=new xe(c,t.rng),t.num.testBit(u)||t.num.bitwiseTo(xe.ONE.shiftLeft(u),i,t.num),t.num.dAddOffset(31-t.num.mod(r).byteValue(),0),n=0,++t.pqState):t.pqState===1?t.num.bitLength()>c?t.pqState=0:t.num.isProbablePrime(f4(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(i4[n++%8],0):t.pqState===2?t.pqState=t.num.subtract(xe.ONE).gcd(t.e).compareTo(xe.ONE)===0?3:0:t.pqState===3&&(t.pqState=0,t.p===null?t.p=t.num:t.q=t.num,t.p!==null&&t.q!==null&&++t.state,t.num=null)}else if(t.state===1)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(t.state===2)t.p1=t.p.subtract(xe.ONE),t.q1=t.q.subtract(xe.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(t.state===3)t.phi.gcd(t.e).compareTo(xe.ONE)===0?++t.state:(t.p=null,t.q=null,t.state=0);else if(t.state===4)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(t.state===5){var l=t.e.modInverse(t.phi);t.keys={privateKey:de.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:de.rsa.setPublicKey(t.n,t.e)}}o=+new Date,a+=o-s,s=o}return t.keys!==null};de.rsa.generateKeyPair=function(t,e,r,n){if(arguments.length===1?typeof t=="object"?(r=t,t=void 0):typeof t=="function"&&(n=t,t=void 0):arguments.length===2?typeof t=="number"?typeof e=="function"?(n=e,e=void 0):typeof e!="number"&&(r=e,e=void 0):(r=t,n=e,t=void 0,e=void 0):arguments.length===3&&(typeof e=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=e,e=void 0)),r=r||{},t===void 0&&(t=r.bits||2048),e===void 0&&(e=r.e||65537),!he.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(e===65537||e===3)){if(n){if(Oy("generateKeyPair"))return Ul.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(a,c,u){if(a)return n(a);n(null,{privateKey:de.privateKeyFromPem(u),publicKey:de.publicKeyFromPem(c)})});if(Dy("generateKey")&&Dy("exportKey"))return dr.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:ky(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return dr.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=de.privateKeyFromAsn1(D.fromDer(he.util.createBuffer(a)));n(null,{privateKey:c,publicKey:de.setRsaPublicKey(c.n,c.e)})}});if(Ly("generateKey")&&Ly("exportKey")){var i=dr.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:ky(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,u=dr.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);u.oncomplete=function(l){var f=l.target.result,h=de.privateKeyFromAsn1(D.fromDer(he.util.createBuffer(f)));n(null,{privateKey:h,publicKey:de.setRsaPublicKey(h.n,h.e)})},u.onerror=function(l){n(l)}},i.onerror=function(a){n(a)};return}}else if(Oy("generateKeyPairSync")){var s=Ul.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:de.privateKeyFromPem(s.privateKey),publicKey:de.publicKeyFromPem(s.publicKey)}}}var o=de.rsa.createKeyPairGenerationState(t,e,r);if(!n)return de.rsa.stepKeyPairGenerationState(o,0),o.keys;l4(o,r,n)};de.setRsaPublicKey=de.rsa.setPublicKey=function(t,e){var r={n:t,e};return r.encrypt=function(n,i,s){if(typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSAES-PKCS1-V1_5"),i==="RSAES-PKCS1-V1_5")i={encode:function(a,c,u){return Ny(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return he.pkcs1.encode_rsa_oaep(c,a,s)}};else if(["RAW","NONE","NULL",null].indexOf(i)!==-1)i={encode:function(a){return a}};else if(typeof i=="string")throw new Error('Unsupported encryption scheme: "'+i+'".');var o=i.encode(n,r,!0);return de.rsa.encrypt(o,r,!0)},r.verify=function(n,i,s){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),s==="RSASSA-PKCS1-V1_5"?s={verify:function(a,c){c=gc(c,r,!0);var u=D.fromDer(c);return a===u.value[1].value}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(a,c){return c=gc(c,r,!0),a===c}});var o=de.rsa.decrypt(i,r,!0,!1);return s.verify(n,o,r.n.bitLength())},r};de.setRsaPrivateKey=de.rsa.setPrivateKey=function(t,e,r,n,i,s,o,a){var c={n:t,e,d:r,p:n,q:i,dP:s,dQ:o,qInv:a};return c.decrypt=function(u,l,f){typeof l=="string"?l=l.toUpperCase():l===void 0&&(l="RSAES-PKCS1-V1_5");var h=de.rsa.decrypt(u,c,!1,!1);if(l==="RSAES-PKCS1-V1_5")l={decode:gc};else if(l==="RSA-OAEP"||l==="RSAES-OAEP")l={decode:function(p,d){return he.pkcs1.decode_rsa_oaep(d,p,f)}};else if(["RAW","NONE","NULL",null].indexOf(l)!==-1)l={decode:function(p){return p}};else throw new Error('Unsupported encryption scheme: "'+l+'".');return l.decode(h,c,!1)},c.sign=function(u,l){var f=!1;typeof l=="string"&&(l=l.toUpperCase()),l===void 0||l==="RSASSA-PKCS1-V1_5"?(l={encode:u4},f=1):(l==="NONE"||l==="NULL"||l===null)&&(l={encode:function(){return u}},f=1);var h=l.encode(u,c.n.bitLength());return de.rsa.encrypt(h,c,f)},c};de.wrapRsaPrivateKey=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,D.integerToDer(0).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(de.oids.rsaEncryption).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,"")]),D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,D.toDer(t).getBytes())])};de.privateKeyFromAsn1=function(t){var e={},r=[];if(D.validate(t,s4,e,r)&&(t=D.fromDer(he.util.createBuffer(e.privateKey))),e={},r=[],!D.validate(t,o4,e,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var i,s,o,a,c,u,l,f;return i=he.util.createBuffer(e.privateKeyModulus).toHex(),s=he.util.createBuffer(e.privateKeyPublicExponent).toHex(),o=he.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=he.util.createBuffer(e.privateKeyPrime1).toHex(),c=he.util.createBuffer(e.privateKeyPrime2).toHex(),u=he.util.createBuffer(e.privateKeyExponent1).toHex(),l=he.util.createBuffer(e.privateKeyExponent2).toHex(),f=he.util.createBuffer(e.privateKeyCoefficient).toHex(),de.setRsaPrivateKey(new xe(i,16),new xe(s,16),new xe(o,16),new xe(a,16),new xe(c,16),new xe(u,16),new xe(l,16),new xe(f,16))};de.privateKeyToAsn1=de.privateKeyToRSAPrivateKey=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,D.integerToDer(0).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.n)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.e)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.d)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.p)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.q)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.dP)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.dQ)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.qInv))])};de.publicKeyFromAsn1=function(t){var e={},r=[];if(D.validate(t,c4,e,r)){var n=D.derToOid(e.publicKeyOid);if(n!==de.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}t=e.rsaPublicKey}if(r=[],!D.validate(t,a4,e,r)){var i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw i.errors=r,i}var s=he.util.createBuffer(e.publicKeyModulus).toHex(),o=he.util.createBuffer(e.publicKeyExponent).toHex();return de.setRsaPublicKey(new xe(s,16),new xe(o,16))};de.publicKeyToAsn1=de.publicKeyToSubjectPublicKeyInfo=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(de.oids.rsaEncryption).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,"")]),D.create(D.Class.UNIVERSAL,D.Type.BITSTRING,!1,[de.publicKeyToRSAPublicKey(t)])])};de.publicKeyToRSAPublicKey=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.n)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Yr(t.e))])};function Ny(t,e,r){var n=he.util.createBuffer(),i=Math.ceil(e.n.bitLength()/8);if(t.length>i-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=t.length,s.max=i-11,s}n.putByte(0),n.putByte(r);var o=i-3-t.length,a;if(r===0||r===1){a=r===0?0:255;for(var c=0;c<o;++c)n.putByte(a)}else for(;o>0;){for(var u=0,l=he.random.getBytes(o),c=0;c<o;++c)a=l.charCodeAt(c),a===0?++u:n.putByte(a);o=u}return n.putByte(0),n.putBytes(t),n}function gc(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8),s=he.util.createBuffer(t),o=s.getByte(),a=s.getByte();if(o!==0||r&&a!==0&&a!==1||!r&&a!=2||r&&a===0&&typeof n=="undefined")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var u=0;u<c;++u)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(a===1)for(c=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++c}else if(a===2)for(c=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++c}var l=s.getByte();if(l!==0||c!==i-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function l4(t,e,r){typeof e=="function"&&(r=e,e={}),e=e||{};var n={algorithm:{name:e.algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};"prng"in e&&(n.prng=e.prng),i();function i(){s(t.pBits,function(a,c){if(a)return r(a);if(t.p=c,t.q!==null)return o(a,t.q);s(t.qBits,o)})}function s(a,c){he.prime.generateProbablePrime(a,n,c)}function o(a,c){if(a)return r(a);if(t.q=c,t.p.compareTo(t.q)<0){var u=t.p;t.p=t.q,t.q=u}if(t.p.subtract(xe.ONE).gcd(t.e).compareTo(xe.ONE)!==0){t.p=null,i();return}if(t.q.subtract(xe.ONE).gcd(t.e).compareTo(xe.ONE)!==0){t.q=null,s(t.qBits,o);return}if(t.p1=t.p.subtract(xe.ONE),t.q1=t.q.subtract(xe.ONE),t.phi=t.p1.multiply(t.q1),t.phi.gcd(t.e).compareTo(xe.ONE)!==0){t.p=t.q=null,i();return}if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits){t.q=null,s(t.qBits,o);return}var l=t.e.modInverse(t.phi);t.keys={privateKey:de.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:de.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}}function Yr(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=he.util.hexToBytes(e);return r.length>1&&(r.charCodeAt(0)===0&&(r.charCodeAt(1)&128)==0||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)==128)?r.substr(1):r}function f4(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function Oy(t){return he.util.isNodejs&&typeof Ul[t]=="function"}function Dy(t){return typeof dr.globalScope!="undefined"&&typeof dr.globalScope.crypto=="object"&&typeof dr.globalScope.crypto.subtle=="object"&&typeof dr.globalScope.crypto.subtle[t]=="function"}function Ly(t){return typeof dr.globalScope!="undefined"&&typeof dr.globalScope.msCrypto=="object"&&typeof dr.globalScope.msCrypto.subtle=="object"&&typeof dr.globalScope.msCrypto.subtle[t]=="function"}function ky(t){for(var e=he.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}});var Ml=w((_q,Vy)=>{var te=Ee();_s();Un();oc();Mn();bs();Rl();lc();xi();dy();ko();je();typeof Uy=="undefined"&&(Uy=te.jsbn.BigInteger);var Uy,M=te.asn1,me=te.pki=te.pki||{};Vy.exports=me.pbe=te.pbe=te.pbe||{};var Ci=me.oids,h4={name:"EncryptedPrivateKeyInfo",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},d4={name:"PBES2Algorithms",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},p4={name:"pkcs-12PbeParams",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,capture:"iterations"}]};me.encryptPrivateKeyInfo=function(t,e,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=te.random.getBytesSync(r.saltSize),i=r.count,s=M.integerToDer(i),o,a,c;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var u,l,f;switch(r.algorithm){case"aes128":o=16,u=16,l=Ci["aes128-CBC"],f=te.aes.createEncryptionCipher;break;case"aes192":o=24,u=16,l=Ci["aes192-CBC"],f=te.aes.createEncryptionCipher;break;case"aes256":o=32,u=16,l=Ci["aes256-CBC"],f=te.aes.createEncryptionCipher;break;case"des":o=8,u=8,l=Ci.desCBC,f=te.des.createEncryptionCipher;break;default:var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var p="hmacWith"+r.prfAlgorithm.toUpperCase(),d=Ky(p),g=te.pkcs5.pbkdf2(e,n,i,o,d),m=te.random.getBytesSync(u),x=f(g);x.start(m),x.update(M.toDer(t)),x.finish(),c=x.output.getBytes();var B=y4(n,s,o,p);a=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(Ci.pkcs5PBES2).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(Ci.pkcs5PBKDF2).getBytes()),B]),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(l).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,m)])])])}else if(r.algorithm==="3des"){o=24;var L=new te.util.ByteBuffer(n),g=me.pbe.generatePkcs12Key(e,L,1,i,o),m=me.pbe.generatePkcs12Key(e,L,2,i,o),x=te.des.createEncryptionCipher(g);x.start(m),x.update(M.toDer(t)),x.finish(),c=x.output.getBytes(),a=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(Ci["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,n),M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,s.getBytes())])])}else{var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var H=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[a,M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,c)]);return H};me.decryptPrivateKeyInfo=function(t,e){var r=null,n={},i=[];if(!M.validate(t,h4,n,i)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=M.derToOid(n.encryptionOid),a=me.pbe.getCipher(o,n.encryptionParams,e),c=te.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(r=M.fromDer(a.output)),r};me.encryptedPrivateKeyToPem=function(t,e){var r={type:"ENCRYPTED PRIVATE KEY",body:M.toDer(t).getBytes()};return te.pem.encode(r,{maxline:e})};me.encryptedPrivateKeyFromPem=function(t){var e=te.pem.decode(t)[0];if(e.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return M.fromDer(e.body)};me.encryptRsaPrivateKey=function(t,e,r){if(r=r||{},!r.legacy){var n=me.wrapRsaPrivateKey(me.privateKeyToAsn1(t));return n=me.encryptPrivateKeyInfo(n,e,r),me.encryptedPrivateKeyToPem(n)}var i,s,o,a;switch(r.algorithm){case"aes128":i="AES-128-CBC",o=16,s=te.random.getBytesSync(16),a=te.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,s=te.random.getBytesSync(16),a=te.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,s=te.random.getBytesSync(16),a=te.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,s=te.random.getBytesSync(8),a=te.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,s=te.random.getBytesSync(8),a=te.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=te.pbe.opensslDeriveBytes(e,s.substr(0,8),o),l=a(u);l.start(s),l.update(M.toDer(me.privateKeyToAsn1(t))),l.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:te.util.bytesToHex(s).toUpperCase()},body:l.output.getBytes()};return te.pem.encode(f)};me.decryptRsaPrivateKey=function(t,e){var r=null,n=te.pem.decode(t)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw i.headerType=i,i}if(n.procType&&n.procType.type==="ENCRYPTED"){var s,o;switch(n.dekInfo.algorithm){case"DES-CBC":s=8,o=te.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,o=te.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,o=te.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,o=te.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,o=te.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,o=function(f){return te.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,o=function(f){return te.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,o=function(f){return te.rc2.createDecryptionCipher(f,128)};break;default:var i=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw i.algorithm=n.dekInfo.algorithm,i}var a=te.util.hexToBytes(n.dekInfo.parameters),c=te.pbe.opensslDeriveBytes(e,a.substr(0,8),s),u=o(c);if(u.start(a),u.update(te.util.createBuffer(n.body)),u.finish())r=u.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=me.decryptPrivateKeyInfo(M.fromDer(r),e):r=M.fromDer(r),r!==null&&(r=me.privateKeyFromAsn1(r)),r};me.pbe.generatePkcs12Key=function(t,e,r,n,i,s){var o,a;if(typeof s=="undefined"||s===null){if(!("sha1"in te.md))throw new Error('"sha1" hash algorithm unavailable.');s=te.md.sha1.create()}var c=s.digestLength,u=s.blockLength,l=new te.util.ByteBuffer,f=new te.util.ByteBuffer;if(t!=null){for(a=0;a<t.length;a++)f.putInt16(t.charCodeAt(a));f.putInt16(0)}var h=f.length(),p=e.length(),d=new te.util.ByteBuffer;d.fillWithByte(r,u);var g=u*Math.ceil(p/u),m=new te.util.ByteBuffer;for(a=0;a<g;a++)m.putByte(e.at(a%p));var x=u*Math.ceil(h/u),B=new te.util.ByteBuffer;for(a=0;a<x;a++)B.putByte(f.at(a%h));var L=m;L.putBuffer(B);for(var H=Math.ceil(i/c),U=1;U<=H;U++){var q=new te.util.ByteBuffer;q.putBytes(d.bytes()),q.putBytes(L.bytes());for(var re=0;re<n;re++)s.start(),s.update(q.getBytes()),q=s.digest();var se=new te.util.ByteBuffer;for(a=0;a<u;a++)se.putByte(q.at(a%c));var j=Math.ceil(p/u)+Math.ceil(h/u),Ce=new te.util.ByteBuffer;for(o=0;o<j;o++){var ve=new te.util.ByteBuffer(L.getBytes(u)),ye=511;for(a=se.length()-1;a>=0;a--)ye=ye>>8,ye+=se.at(a)+ve.at(a),ve.setAt(a,ye&255);Ce.putBuffer(ve)}L=Ce,l.putBuffer(q)}return l.truncate(l.length()-i),l};me.pbe.getCipher=function(t,e,r){switch(t){case me.oids.pkcs5PBES2:return me.pbe.getCipherForPBES2(t,e,r);case me.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case me.oids["pbewithSHAAnd40BitRC2-CBC"]:return me.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};me.pbe.getCipherForPBES2=function(t,e,r){var n={},i=[];if(!M.validate(e,d4,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}if(t=M.derToOid(n.kdfOid),t!==me.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=t,s.supportedOids=["pkcs5PBKDF2"],s}if(t=M.derToOid(n.encOid),t!==me.oids["aes128-CBC"]&&t!==me.oids["aes192-CBC"]&&t!==me.oids["aes256-CBC"]&&t!==me.oids["des-EDE3-CBC"]&&t!==me.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=t,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var o=n.kdfSalt,a=te.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,u;switch(me.oids[t]){case"aes128-CBC":c=16,u=te.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,u=te.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,u=te.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,u=te.des.createDecryptionCipher;break;case"desCBC":c=8,u=te.des.createDecryptionCipher;break}var l=Fy(n.prfOid),f=te.pkcs5.pbkdf2(r,o,a,c,l),h=n.encIv,p=u(f);return p.start(h),p};me.pbe.getCipherForPKCS12PBE=function(t,e,r){var n={},i=[];if(!M.validate(e,p4,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=te.util.createBuffer(n.salt),a=te.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,u,l;switch(t){case me.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,l=te.des.startDecrypting;break;case me.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,l=function(g,m){var x=te.rc2.createDecryptionCipher(g,40);return x.start(m,null),x};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=t,s}var f=Fy(n.prfOid),h=me.pbe.generatePkcs12Key(r,o,1,a,c,f);f.start();var p=me.pbe.generatePkcs12Key(r,o,2,a,u,f);return l(h,p)};me.pbe.opensslDeriveBytes=function(t,e,r,n){if(typeof n=="undefined"||n===null){if(!("md5"in te.md))throw new Error('"md5" hash algorithm unavailable.');n=te.md.md5.create()}e===null&&(e="");for(var i=[My(n,t+e)],s=16,o=1;s<r;++o,s+=16)i.push(My(n,i[o-1]+t+e));return i.join("").substr(0,r)};function My(t,e){return t.start().update(e).digest().getBytes()}function Fy(t){var e;if(!t)e="hmacWithSHA1";else if(e=me.oids[M.derToOid(t)],!e){var r=new Error("Unsupported PRF OID.");throw r.oid=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}return Ky(e)}function Ky(t){var e=te.md;switch(t){case"hmacWithSHA224":e=te.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":t=t.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!e||!(t in e))throw new Error("Unknown hash algorithm: "+t);return e[t].create()}function y4(t,e,r,n){var i=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,t),M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,te.util.hexToBytes(r.toString(16))),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids[n]).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.NULL,!1,"")])),i}});var Fl={};yt(Fl,{identity:()=>g4});var g4,jy=_e(()=>{Fr();In();g4=Va({prefix:"\0",name:"identity",encode:t=>_0(t),decode:t=>w0(t)})});var Kl={};yt(Kl,{base2:()=>m4});var m4,$y=_e(()=>{Fr();m4=at({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})});var Vl={};yt(Vl,{base8:()=>v4});var v4,Hy=_e(()=>{Fr();v4=at({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})});var jl={};yt(jl,{base10:()=>b4});var b4,zy=_e(()=>{Fr();b4=Rn({prefix:"9",name:"base10",alphabet:"0123456789"})});var $l,Gy,Hl=_e(()=>{gi();$l=({name:t,code:e,encode:r})=>new Gy(t,e,r),Gy=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Tn(this.code,r):r.then(n=>Tn(this.code,n))}else throw Error("Unknown type, must be binary type")}}});var Vn={};yt(Vn,{sha256:()=>E4,sha512:()=>w4});var Yy,E4,w4,Ii=_e(()=>{Hl();Yy=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),E4=$l({name:"sha2-256",code:18,encode:Yy("SHA-256")}),w4=$l({name:"sha2-512",code:19,encode:Yy("SHA-512")})});var qo={};yt(qo,{identity:()=>S4});var Qy,_4,x4,S4,mc=_e(()=>{In();gi();Qy=0,_4="identity",x4=t=>Tn(Qy,hn(t)),S4={code:Qy,name:_4,digest:x4}});var Xy=_e(()=>{In()});var Oq,Dq,Zy=_e(()=>{Oq=new TextEncoder,Dq=new TextDecoder});var Jy=_e(()=>{gs();Ka();In();Hl();gi()});var zl,Uq,eg=_e(()=>{jy();$y();Hy();zy();nl();vi();rl();Pn();To();Ii();mc();Xy();Zy();Jy();zl={...Fl,...Kl,...Vl,...jl,...za,...mi,...Ha,...Bn,...ms},Uq={...Vn,...qo}});function tg(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var rg,Gl,I4,vc,Wl=_e(()=>{eg();rg=tg("utf8","u",t=>{let e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),Gl=tg("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),I4={utf8:rg,"utf-8":rg,hex:zl.base16,latin1:Gl,ascii:Gl,binary:Gl,...zl},vc=I4});var Pt={};yt(Pt,{fromString:()=>Yl});function Yl(t,e="utf8"){let r=vc[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}var Ct=_e(()=>{Wl()});var jn={};yt(jn,{concat:()=>T4});function T4(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));let r=new Uint8Array(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}var $n=_e(()=>{});var Uo=w(ng=>{"use strict";ng.get=(t=globalThis)=>{let e=t.crypto;if(!e||!e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}});var Ql=w(($q,sg)=>{"use strict";var{concat:R4}=($n(),jn),{fromString:ig}=(Ct(),Pt),B4=Uo();function P4({algorithm:t="AES-GCM",nonceLength:e=12,keyLength:r=16,digest:n="SHA-256",saltLength:i=16,iterations:s=32767}={}){let o=B4.get();r*=8;async function a(u,l){let f=o.getRandomValues(new Uint8Array(i)),h=o.getRandomValues(new Uint8Array(e)),p={name:t,iv:h},d={name:"PBKDF2",salt:f,iterations:s,hash:{name:n}},g=await o.subtle.importKey("raw",ig(l),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),m=await o.subtle.deriveKey(d,g,{name:t,length:r},!0,["encrypt"]),x=await o.subtle.encrypt(p,m,u);return R4([f,p.iv,new Uint8Array(x)])}async function c(u,l){let f=u.slice(0,i),h=u.slice(i,i+e),p=u.slice(i+e),d={name:t,iv:h},g={name:"PBKDF2",salt:f,iterations:s,hash:{name:n}},m=await o.subtle.importKey("raw",ig(l),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),x=await o.subtle.deriveKey(g,m,{name:t,length:r},!0,["decrypt"]),B=await o.subtle.decrypt(d,x,p);return new Uint8Array(B)}return{encrypt:a,decrypt:c}}sg.exports={create:P4}});var ag=w((Hq,og)=>{"use strict";var{base64:N4}=(To(),ms),O4=Ql();og.exports={import:async function(t,e){let r=N4.decode(t);return await O4.create().decrypt(r,e)}}});var pr={};yt(pr,{equals:()=>D4});function D4(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var yr=_e(()=>{});var Nt={};yt(Nt,{toString:()=>Xl});function Xl(t,e="utf8"){let r=vc[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var It=_e(()=>{Wl()});var ef=w((Gq,fg)=>{var We=Ee();Mn();je();var Mo=fg.exports=We.sha512=We.sha512||{};We.md.sha512=We.md.algorithms.sha512=Mo;var cg=We.sha384=We.sha512.sha384=We.sha512.sha384||{};cg.create=function(){return Mo.create("SHA-384")};We.md.sha384=We.md.algorithms.sha384=cg;We.sha512.sha256=We.sha512.sha256||{create:function(){return Mo.create("SHA-512/256")}};We.md["sha512/256"]=We.md.algorithms["sha512/256"]=We.sha512.sha256;We.sha512.sha224=We.sha512.sha224||{create:function(){return Mo.create("SHA-512/224")}};We.md["sha512/224"]=We.md.algorithms["sha512/224"]=We.sha512.sha224;Mo.create=function(t){if(ug||L4(),typeof t=="undefined"&&(t="SHA-512"),!(t in Ti))throw new Error("Invalid SHA-512 algorithm: "+t);for(var e=Ti[t],r=null,n=We.util.createBuffer(),i=new Array(80),s=0;s<80;++s)i[s]=new Array(2);var o=64;switch(t){case"SHA-384":o=48;break;case"SHA-512/256":o=32;break;case"SHA-512/224":o=28;break}var a={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:o,messageLength:0,fullMessageLength:null,messageLengthSize:16};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength128=[];for(var c=a.messageLengthSize/4,u=0;u<c;++u)a.fullMessageLength.push(0);n=We.util.createBuffer(),r=new Array(e.length);for(var u=0;u<e.length;++u)r[u]=e[u].slice(0);return a},a.start(),a.update=function(c,u){u==="utf8"&&(c=We.util.encodeUtf8(c));var l=c.length;a.messageLength+=l,l=[l/4294967296>>>0,l>>>0];for(var f=a.fullMessageLength.length-1;f>=0;--f)a.fullMessageLength[f]+=l[1],l[1]=l[0]+(a.fullMessageLength[f]/4294967296>>>0),a.fullMessageLength[f]=a.fullMessageLength[f]>>>0,l[0]=l[1]/4294967296>>>0;return n.putBytes(c),lg(r,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=We.util.createBuffer();c.putBytes(n.bytes());var u=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,l=u&a.blockLength-1;c.putBytes(Zl.substr(0,a.blockLength-l));for(var f,h,p=a.fullMessageLength[0]*8,d=0;d<a.fullMessageLength.length-1;++d)f=a.fullMessageLength[d+1]*8,h=f/4294967296>>>0,p+=h,c.putInt32(p>>>0),p=f>>>0;c.putInt32(p);for(var g=new Array(r.length),d=0;d<r.length;++d)g[d]=r[d].slice(0);lg(g,i,c);var m=We.util.createBuffer(),x;t==="SHA-512"?x=g.length:t==="SHA-384"?x=g.length-2:x=g.length-4;for(var d=0;d<x;++d)m.putInt32(g[d][0]),(d!==x-1||t!=="SHA-512/224")&&m.putInt32(g[d][1]);return m},a};var Zl=null,ug=!1,Jl=null,Ti=null;function L4(){Zl=String.fromCharCode(128),Zl+=We.util.fillString(String.fromCharCode(0),128),Jl=[[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]],Ti={},Ti["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Ti["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Ti["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Ti["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],ug=!0}function lg(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,p,d,g,m,x,B,L,H,U,q,re,se,j,Ce,ve,ye,nt,it,Ie,Ue,ie,rr,Wt,ln,Yt,fn=r.length();fn>=128;){for(Ie=0;Ie<16;++Ie)e[Ie][0]=r.getInt32()>>>0,e[Ie][1]=r.getInt32()>>>0;for(;Ie<80;++Ie)rr=e[Ie-2],Ue=rr[0],ie=rr[1],n=((Ue>>>19|ie<<13)^(ie>>>29|Ue<<3)^Ue>>>6)>>>0,i=((Ue<<13|ie>>>19)^(ie<<3|Ue>>>29)^(Ue<<26|ie>>>6))>>>0,ln=e[Ie-15],Ue=ln[0],ie=ln[1],s=((Ue>>>1|ie<<31)^(Ue>>>8|ie<<24)^Ue>>>7)>>>0,o=((Ue<<31|ie>>>1)^(Ue<<24|ie>>>8)^(Ue<<25|ie>>>7))>>>0,Wt=e[Ie-7],Yt=e[Ie-16],ie=i+Wt[1]+o+Yt[1],e[Ie][0]=n+Wt[0]+s+Yt[0]+(ie/4294967296>>>0)>>>0,e[Ie][1]=ie>>>0;for(g=t[0][0],m=t[0][1],x=t[1][0],B=t[1][1],L=t[2][0],H=t[2][1],U=t[3][0],q=t[3][1],re=t[4][0],se=t[4][1],j=t[5][0],Ce=t[5][1],ve=t[6][0],ye=t[6][1],nt=t[7][0],it=t[7][1],Ie=0;Ie<80;++Ie)u=((re>>>14|se<<18)^(re>>>18|se<<14)^(se>>>9|re<<23))>>>0,l=((re<<18|se>>>14)^(re<<14|se>>>18)^(se<<23|re>>>9))>>>0,f=(ve^re&(j^ve))>>>0,h=(ye^se&(Ce^ye))>>>0,a=((g>>>28|m<<4)^(m>>>2|g<<30)^(m>>>7|g<<25))>>>0,c=((g<<4|m>>>28)^(m<<30|g>>>2)^(m<<25|g>>>7))>>>0,p=(g&x|L&(g^x))>>>0,d=(m&B|H&(m^B))>>>0,ie=it+l+h+Jl[Ie][1]+e[Ie][1],n=nt+u+f+Jl[Ie][0]+e[Ie][0]+(ie/4294967296>>>0)>>>0,i=ie>>>0,ie=c+d,s=a+p+(ie/4294967296>>>0)>>>0,o=ie>>>0,nt=ve,it=ye,ve=j,ye=Ce,j=re,Ce=se,ie=q+i,re=U+n+(ie/4294967296>>>0)>>>0,se=ie>>>0,U=L,q=H,L=x,H=B,x=g,B=m,ie=i+o,g=n+s+(ie/4294967296>>>0)>>>0,m=ie>>>0;ie=t[0][1]+m,t[0][0]=t[0][0]+g+(ie/4294967296>>>0)>>>0,t[0][1]=ie>>>0,ie=t[1][1]+B,t[1][0]=t[1][0]+x+(ie/4294967296>>>0)>>>0,t[1][1]=ie>>>0,ie=t[2][1]+H,t[2][0]=t[2][0]+L+(ie/4294967296>>>0)>>>0,t[2][1]=ie>>>0,ie=t[3][1]+q,t[3][0]=t[3][0]+U+(ie/4294967296>>>0)>>>0,t[3][1]=ie>>>0,ie=t[4][1]+se,t[4][0]=t[4][0]+re+(ie/4294967296>>>0)>>>0,t[4][1]=ie>>>0,ie=t[5][1]+Ce,t[5][0]=t[5][0]+j+(ie/4294967296>>>0)>>>0,t[5][1]=ie>>>0,ie=t[6][1]+ye,t[6][0]=t[6][0]+ve+(ie/4294967296>>>0)>>>0,t[6][1]=ie>>>0,ie=t[7][1]+it,t[7][0]=t[7][0]+nt+(ie/4294967296>>>0)>>>0,t[7][1]=ie>>>0,fn-=128}}});var dg=w((Wq,hg)=>{"use strict";var bc=65536;function k4(t){let e=new Uint8Array(t),r=0;if(t>0)if(t>bc)for(;r<t;)r+bc>t?(crypto.getRandomValues(e.subarray(r,r+(t-r))),r+=t-r):(crypto.getRandomValues(e.subarray(r,r+bc)),r+=bc);else crypto.getRandomValues(e);return e}hg.exports=k4});var Ec=w((Yq,pg)=>{"use strict";var q4=dg(),U4=pe();pg.exports=function(t){if(isNaN(t)||t<=0)throw U4(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return q4(t)}});var wc=w(Fo=>{"use strict";je();pc();var M4=Ee(),{fromString:F4}=(Ct(),Pt),{toString:yg}=(It(),Nt),{concat:gg}=($n(),jn);Fo.bigIntegerToUintBase64url=(t,e)=>{let r=Uint8Array.from(t.abs().toByteArray());if(r=r[0]===0?r.slice(1):r,e!=null){if(r.length>e)throw new Error("byte array longer than desired length");r=gg([new Uint8Array(e-r.length),r])}return yg(r,"base64url")};Fo.base64urlToBigInteger=t=>{let e=Fo.base64urlToBuffer(t);return new M4.jsbn.BigInteger(yg(e,"base16"),16)};Fo.base64urlToBuffer=(t,e)=>{let r=F4(t,"base64urlpad");if(e!=null){if(r.length>e)throw new Error("byte array longer than desired length");r=gg([new Uint8Array(e-r.length),r])}return r}});var bg=w(Ko=>{"use strict";Un();ko();var Hn=Ee(),{bigIntegerToUintBase64url:Qr,base64urlToBigInteger:Xr}=wc(),{fromString:mg}=(Ct(),Pt),{toString:vg}=(It(),Nt);Ko.pkcs1ToJwk=function(t){let e=Hn.asn1.fromDer(vg(t,"ascii")),r=Hn.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Qr(r.n),e:Qr(r.e),d:Qr(r.d),p:Qr(r.p),q:Qr(r.q),dp:Qr(r.dP),dq:Qr(r.dQ),qi:Qr(r.qInv),alg:"RS256",kid:"2011-04-29"}};Ko.jwkToPkcs1=function(t){let e=Hn.pki.privateKeyToAsn1({n:Xr(t.n),e:Xr(t.e),d:Xr(t.d),p:Xr(t.p),q:Xr(t.q),dP:Xr(t.dp),dQ:Xr(t.dq),qInv:Xr(t.qi)});return mg(Hn.asn1.toDer(e).getBytes(),"ascii")};Ko.pkixToJwk=function(t){let e=Hn.asn1.fromDer(vg(t,"ascii")),r=Hn.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Qr(r.n),e:Qr(r.e),alg:"RS256",kid:"2011-04-29"}};Ko.jwkToPkix=function(t){let e=Hn.pki.publicKeyToAsn1({n:Xr(t.n),e:Xr(t.e)});return mg(Hn.asn1.toDer(e).getBytes(),"ascii")}});var xg=w((Zq,_g)=>{"use strict";ko();var Eg=Ee(),{base64urlToBigInteger:K4}=wc();function wg(t,e){return e.map(r=>K4(t[r]))}function V4(t){return Eg.pki.setRsaPrivateKey(...wg(t,["n","e","d","p","q","dp","dq","qi"]))}function j4(t){return Eg.pki.setRsaPublicKey(...wg(t,["n","e"]))}_g.exports={jwk2pub:j4,jwk2priv:V4}});var Cg=w(mn=>{"use strict";var gn=Uo(),$4=Ec(),{toString:H4}=(It(),Nt),{fromString:z4}=(Ct(),Pt);mn.utils=bg();mn.generateKey=async function(t){let e=await gn.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Sg(e);return{privateKey:r[0],publicKey:r[1]}};mn.unmarshalPrivateKey=async function(t){let r=[await gn.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await G4(t)],n=await Sg({privateKey:r[0],publicKey:r[1]});return{privateKey:n[0],publicKey:n[1]}};mn.getRandomValues=$4;mn.hashAndSign=async function(t,e){let r=await gn.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await gn.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(e));return new Uint8Array(n,n.byteOffset,n.byteLength)};mn.hashAndVerify=async function(t,e,r){let n=await gn.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return gn.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r)};function Sg(t){return Promise.all([gn.get().subtle.exportKey("jwk",t.privateKey),gn.get().subtle.exportKey("jwk",t.publicKey)])}function G4(t){return gn.get().subtle.importKey("jwk",{kty:t.kty,n:t.n,e:t.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}var{jwk2pub:W4,jwk2priv:Y4}=xg();function Ag(t,e,r,n){let i=e?W4(t):Y4(t),s=H4(Uint8Array.from(r),"ascii"),o=n(s,i);return z4(o,"ascii")}mn.encrypt=function(t,e){return Ag(t,!0,e,(r,n)=>n.encrypt(r))};mn.decrypt=function(t,e){return Ag(t,!1,e,(r,n)=>n.decrypt(r))}});var _c=w((eU,Ig)=>{"use strict";var{base64:Q4}=(To(),ms),X4=Ql();Ig.exports={export:async function(t,e){let n=await X4.create().encrypt(t,e);return Q4.encode(n)}}});var Ng=w((tU,Pg)=>{"use strict";var{sha256:Tg}=(Ii(),Vn),Rg=pe(),{equals:Bg}=(yr(),pr),{toString:Z4}=(It(),Nt);ef();var xc=Ee(),gr=Cg(),Sc=Za(),J4=_c(),Ac=class{constructor(e){this._key=e}async verify(e,r){return gr.hashAndVerify(this._key,r,e)}marshal(){return gr.utils.jwkToPkix(this._key)}get bytes(){return Sc.PublicKey.encode({Type:Sc.KeyType.RSA,Data:this.marshal()}).finish()}encrypt(e){return gr.encrypt(this._key,e)}equals(e){return Bg(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Tg.digest(this.bytes);return e}},Vo=class{constructor(e,r){this._key=e,this._publicKey=r}genSecret(){return gr.getRandomValues(16)}async sign(e){return gr.hashAndSign(this._key,e)}get public(){if(!this._publicKey)throw Rg(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Ac(this._publicKey)}decrypt(e){return gr.decrypt(this._key,e)}marshal(){return gr.utils.jwkToPkcs1(this._key)}get bytes(){return Sc.PrivateKey.encode({Type:Sc.KeyType.RSA,Data:this.marshal()}).finish()}equals(e){return Bg(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Tg.digest(this.bytes);return e}async id(){let e=await this.public.hash();return Z4(e,"base58btc")}async export(e,r="pkcs-8"){if(r==="pkcs-8"){let n=new xc.util.ByteBuffer(this.marshal()),i=xc.asn1.fromDer(n),s=xc.pki.privateKeyFromAsn1(i),o={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return xc.pki.encryptRsaPrivateKey(s,e,o)}else{if(r==="libp2p-key")return J4.export(this.bytes,e);throw Rg(new Error(`export format '${r}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}};async function eB(t){let e=gr.utils.pkcs1ToJwk(t),r=await gr.unmarshalPrivateKey(e);return new Vo(r.privateKey,r.publicKey)}function tB(t){let e=gr.utils.pkixToJwk(t);return new Ac(e)}async function rB(t){let e=await gr.unmarshalPrivateKey(t);return new Vo(e.privateKey,e.publicKey)}async function nB(t){let e=await gr.generateKey(t);return new Vo(e.privateKey,e.publicKey)}Pg.exports={RsaPublicKey:Ac,RsaPrivateKey:Vo,unmarshalRsaPublicKey:tB,unmarshalRsaPrivateKey:eB,generateKeyPair:nB,fromJwk:rB}});var Kg=w(Ye=>{"use strict";var iB=Ye&&Ye.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ye,"__esModule",{value:!0});Ye.utils=Ye.verify=Ye.sign=Ye.getPublicKey=Ye.SignResult=Ye.Signature=Ye.Point=Ye.ExtendedPoint=Ye.CURVE=void 0;var sB=iB(xs()),Ot=BigInt(0),Se=BigInt(1),Jt=BigInt(2),Og=BigInt(255),ht={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:Jt**Og-BigInt(19),n:Jt**BigInt(252)+BigInt("27742317777372353535851937790883648493"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")};Ye.CURVE=ht;var $t=32,jo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),oB=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),aB=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),cB=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),uB=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ke=class{constructor(e,r,n,i){this.x=e,this.y=r,this.z=n,this.t=i}static fromAffine(e){if(!(e instanceof Ze))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(Ze.ZERO)?Ke.ZERO:new Ke(e.x,e.y,Se,V(e.x*e.y))}static toAffineBatch(e){let r=hB(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(r[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}static fromRistrettoHash(e){if(typeof e=="string"&&(e=Gn(e)),e.length!==64)throw new Error("Invalid ristretto hash, need 64 bytes");let r=sf(e.slice(0,$t)),n=this.calcElligatorRistrettoMap(r),i=sf(e.slice($t,$t*2)),s=this.calcElligatorRistrettoMap(i);return n.add(s)}static calcElligatorRistrettoMap(e){let{d:r}=ht,n=V(jo*e*e),i=V((n+Se)*cB),s=BigInt(-1),o=V((s-r*n)*V(n+r)),{isValid:a,value:c}=af(i,o),u=V(c*e);Wn(u)||(u=V(-u)),a||(c=u),a||(s=n);let l=V(s*(n-Se)*uB-o),f=c*c,h=V((c+c)*o),p=V(l*oB),d=V(Se-f),g=V(Se+f);return new Ke(V(h*g),V(d*p),V(p*g),V(h*d))}static fromRistrettoBytes(e){if(typeof e=="string"&&(e=Gn(e)),e.length!==32)throw new Error("Invalid ristretto hash, need 64 bytes");let{a:r,d:n}=ht,i="ExtendedPoint.fromRistrettoBytes: Cannot convert bytes to Ristretto Point",s=sf(e);if(!yB(Lg(s,$t),e)||Wn(s))throw new Error(i);let o=V(s*s),a=V(Se+r*o),c=V(Se-r*o),u=V(a*a),l=V(c*c),f=V(r*n*u-l),{isValid:h,value:p}=kg(V(f*l)),d=V(p*c),g=V(p*d*f),m=V((s+s)*d);Wn(m)&&(m=V(-m));let x=V(a*g),B=V(m*x);if(!h||Wn(B)||x===Ot)throw new Error(i);return new Ke(m,x,Se,B)}toRistrettoBytes(){let{x:e,y:r,z:n,t:i}=this,s=V(V(n+r)*V(n-r)),o=V(e*r),{value:a}=kg(V(s*o**Jt)),c=V(a*s),u=V(a*o),l=V(c*u*i),f;if(Wn(i*l)){let p=V(r*jo),d=V(e*jo);e=p,r=d,f=V(c*aB)}else f=u;Wn(e*l)&&(r=V(-r));let h=V((n-r)*f);return Wn(h)&&(h=V(-h)),Lg(h,$t)}equals(e){let r=this,n=e;return V(r.t*n.z)===V(n.t*r.z)}negate(){return new Ke(V(-this.x),this.y,this.z,V(-this.t))}double(){let e=this.x,r=this.y,n=this.z,{a:i}=ht,s=V(e**Jt),o=V(r**Jt),a=V(Jt*n**Jt),c=V(i*s),u=V((e+r)**Jt-s-o),l=V(c+o),f=V(l-a),h=V(c-o),p=V(u*f),d=V(l*h),g=V(u*h),m=V(f*l);return new Ke(p,d,m,g)}add(e){let r=this.x,n=this.y,i=this.z,s=this.t,o=e.x,a=e.y,c=e.z,u=e.t,l=V((n-r)*(a+o)),f=V((n+r)*(a-o)),h=V(f-l);if(h===Ot)return this.double();let p=V(i*Jt*u),d=V(s*Jt*c),g=V(d+p),m=V(f+l),x=V(d-p),B=V(g*h),L=V(m*x),H=V(g*x),U=V(h*m);return new Ke(B,L,U,H)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let r=Fg(e);if(r===Se)return this;let n=Ke.ZERO,i=this;for(;r>Ot;)r&Se&&(n=n.add(i)),i=i.double(),r>>=Se;return n}precomputeWindow(e){let r=256/e+1,n=[],i=this,s=i;for(let o=0;o<r;o++){s=i,n.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,r){!r&&this.equals(Ke.BASE)&&(r=Ze.BASE);let n=r&&r._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=r&&tf.get(r);i||(i=this.precomputeWindow(n),r&&n!==1&&(i=Ke.normalizeZ(i),tf.set(r,i)));let s=Ke.ZERO,o=Ke.ZERO,a=256/n+1,c=2**(n-1),u=BigInt(2**n-1),l=2**n,f=BigInt(n);for(let h=0;h<a;h++){let p=h*c,d=Number(e&u);if(e>>=f,d>c&&(d-=l,e+=Se),d===0){let g=i[p];h%2&&(g=g.negate()),o=o.add(g)}else{let g=i[p+Math.abs(d)-1];d<0&&(g=g.negate()),s=s.add(g)}}return[s,o]}multiply(e,r){let n=Fg(e);return Ke.normalizeZ(this.wNAF(n,r))[0]}toAffine(e=of(this.z)){let r=V(this.x*e),n=V(this.y*e);return new Ze(r,n)}};Ye.ExtendedPoint=Ke;Ke.BASE=new Ke(ht.Gx,ht.Gy,Se,V(ht.Gx*ht.Gy));Ke.ZERO=new Ke(Ot,Se,Se,Ot);var tf=new WeakMap,Ze=class{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,tf.delete(this)}static fromHex(e){let{d:r,P:n}=ht,i=e instanceof Uint8Array?e:Gn(e);if(i.length!==32)throw new Error("Point.fromHex: expected 32 bytes");let s=i[31],o=s&~128,a=(s&128)!=0,c=Uint8Array.from(Array.from(i.slice(0,31)).concat(o)),u=$o(c);if(u>=n)throw new Error("Point.fromHex expects hex <= Fp");let l=V(u*u),f=V(l-Se),h=V(r*l+Se),{isValid:p,value:d}=af(f,h);if(!p)throw new Error("Point.fromHex: invalid y coordinate");let g=(d&Se)===Se;return a!==g&&(d=V(-d)),new Ze(d,u)}static async fromPrivateKey(e){let r=await Mg(e);return Ze.BASE.multiply(qg(r))}toRawBytes(){let e=nf(this.y),r=new Uint8Array($t);for(let i=e.length-2,s=0;s<$t&&i>=0;i-=2,s++)r[s]=Dg(e[i]+e[i+1]);let n=this.x&Se?128:0;return r[$t-1]|=n,r}toHex(){return rf(this.toRawBytes())}toX25519(){return V((Se+this.y)*of(Se-this.y))}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Ze(V(-this.x),this.y)}add(e){return Ke.fromAffine(this).add(Ke.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ke.fromAffine(this).multiply(e,this).toAffine()}};Ye.Point=Ze;Ze.BASE=new Ze(ht.Gx,ht.Gy);Ze.ZERO=new Ze(Ot,Se);var zn=class{constructor(e,r){this.r=e,this.s=r}static fromHex(e){e=uf(e);let r=Ze.fromHex(e.slice(0,32)),n=$o(e.slice(32));if(!Ug(n))throw new Error("Signature.fromHex expects s <= CURVE.n");return new zn(r,n)}toRawBytes(){let e=Gn(nf(this.s)).reverse(),r=new Uint8Array($t);r.set(e);let n=new Uint8Array($t*2);return n.set(this.r.toRawBytes()),n.set(r,32),n}toHex(){return rf(this.toRawBytes())}};Ye.Signature=zn;Ye.SignResult=zn;function lB(...t){if(t.length===1)return t[0];let e=t.reduce((n,i)=>n+i.length,0),r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var fB=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function rf(t){let e="";for(let r=0;r<t.length;r++)e+=fB[t[r]];return e}function Dg(t){let e=Number.parseInt(t,16);if(Number.isNaN(e))throw new Error("Invalid byte sequence");return e}function Gn(t){if(typeof t!="string")throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){let n=r*2;e[r]=Dg(t.slice(n,n+2))}return e}function nf(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Lg(t,e=$t){let r=nf(t).padStart(e*2,"0");return Gn(r).reverse()}function Wn(t){return(V(t)&Se)===Se}function $o(t){let e=Ot;for(let r=0;r<t.length;r++)e+=BigInt(t[r])<<BigInt(8)*BigInt(r);return e}function sf(t){return V($o(t)&Jt**Og-Se)}function V(t,e=ht.P){let r=t%e;return r>=Ot?r:e+r}function of(t,e=ht.P){if(t===Ot||e<=Ot)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=V(t,e),n=e,i=Ot,s=Se,o=Se,a=Ot;for(;r!==Ot;){let u=n/r,l=n%r,f=i-o*u,h=s-a*u;n=r,r=l,i=o,s=a,o=f,a=h}if(n!==Se)throw new Error("invert: does not exist");return V(i,e)}function hB(t,e=ht.P){let r=t.length,n=new Array(r),i=Se;for(let s=0;s<r;s++)t[s]!==Ot&&(n[s]=i,i=V(i*t[s],e));i=of(i,e);for(let s=r-1;s>=0;s--){if(t[s]===Ot)continue;let o=V(i*t[s],e);t[s]=V(i*n[s],e),i=o}return t}function Zr(t,e){let{P:r}=ht,n=t;for(;e-- >Ot;)n*=n,n%=r;return n}function dB(t){let{P:e}=ht,[r,n,i,s,o]=[5,10,20,40,80].map(L=>BigInt(L)),c=t*t%e*t%e,u=Zr(c,Jt)*c%e,l=Zr(u,Se)*t%e,f=Zr(l,r)*l%e,h=Zr(f,n)*f%e,p=Zr(h,i)*h%e,d=Zr(p,s)*p%e,g=Zr(d,o)*d%e,m=Zr(g,o)*d%e,x=Zr(m,n)*f%e;return Zr(x,Jt)*t%e}function af(t,e){let r=V(e*e*e),n=V(r*r*e),i=V(t*r*dB(t*n)),s=V(e*i*i),o=i,a=V(i*jo),c=s===t,u=s===V(-t),l=s===V(-t*jo);return c&&(i=o),(u||l)&&(i=a),Wn(i)&&(i=V(-i)),{isValid:c||u,value:i}}function kg(t){return af(Se,t)}async function cf(...t){let e=lB(...t),r=await Ye.utils.sha512(e),n=$o(r);return V(n,ht.n)}function pB(t){return t.slice($t)}function qg(t){let e=$t-1,r=t.slice(0,$t);return r[0]&=248,r[e]&=127,r[e]|=64,V($o(r),ht.n)}function yB(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function uf(t){return t instanceof Uint8Array?t:Gn(t)}function Ug(t){return 0<t&&t<ht.n}var gB=Jt**BigInt(256)-Se;function mB(t){let e,r="Expected 32 bytes of private key";if(typeof t=="bigint"||typeof t=="number"&&Number.isSafeInteger(t)){let n=BigInt(t);if(n<0||n>gB)throw new Error(r);e=Gn(n.toString(16).padStart($t*2,"0"))}else if(typeof t=="string"){if(t.length!==64)throw new Error(r);e=Gn(t)}else if(t instanceof Uint8Array){if(t.length!==32)throw new Error(r);e=t}else throw new TypeError("Expected valid private key");return e}async function Mg(t){return await Ye.utils.sha512(mB(t))}function Fg(t){if(typeof t=="number"&&t>0&&Number.isSafeInteger(t))return BigInt(t);if(typeof t=="bigint"&&Ug(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}async function vB(t){return(await Ze.fromPrivateKey(t)).toRawBytes()}Ye.getPublicKey=vB;async function bB(t,e){let r=await Mg(e),n=qg(r),i=Ze.BASE.multiply(n),s=uf(t),o=await cf(pB(r),s),a=Ze.BASE.multiply(o),c=await cf(a.toRawBytes(),i.toRawBytes(),s),u=V(o+c*n,ht.n);return new zn(a,u).toRawBytes()}Ye.sign=bB;async function EB(t,e,r){e=uf(e),r instanceof Ze||(r=Ze.fromHex(r)),t instanceof zn||(t=zn.fromHex(t));let n=await cf(t.r.toRawBytes(),r.toRawBytes(),e),i=Ke.fromAffine(r).multiplyUnsafe(n),s=Ke.BASE.multiply(t.s);return Ke.fromAffine(t.r).add(i).subtract(s).multiplyUnsafe(ht.h).equals(Ke.ZERO)}Ye.verify=EB;Ze.BASE._setWindowSize(8);var Yn={node:sB.default,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};Ye.utils={TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],bytesToHex:rf,randomBytes:(t=32)=>{if(Yn.web)return Yn.web.getRandomValues(new Uint8Array(t));if(Yn.node){let{randomBytes:e}=Yn.node;return new Uint8Array(e(t).buffer)}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Ye.utils.randomBytes(32),sha512:async t=>{if(Yn.web){let e=await Yn.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(e)}else{if(Yn.node)return Uint8Array.from(Yn.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")}},precompute(t=8,e=Ze.BASE){let r=e.equals(Ze.BASE)?e:new Ze(e.x,e.y);return r._setWindowSize(t),r.multiply(Se),r}}});var jg=w(Qn=>{"use strict";var Ho=Kg(),wB=32,_B=64,Cc=32;Qn.publicKeyLength=wB;Qn.privateKeyLength=_B;Qn.generateKey=async function(){let t=Ho.utils.randomPrivateKey(),e=await Ho.getPublicKey(t);return{privateKey:Vg(t,e),publicKey:e}};Qn.generateKeyFromSeed=async function(t){if(t.length!==Cc)throw new TypeError('"seed" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=t,r=await Ho.getPublicKey(e);return{privateKey:Vg(e,r),publicKey:r}};Qn.hashAndSign=function(t,e){let r=t.slice(0,Cc);return Ho.sign(e,r)};Qn.hashAndVerify=function(t,e,r){return Ho.verify(e,r,t)};function Vg(t,e){let r=new Uint8Array(Qn.privateKeyLength);for(let n=0;n<Cc;n++)r[n]=t[n],r[Cc+n]=e[n];return r}});var Wg=w((iU,Gg)=>{"use strict";var $g=pe(),{equals:Hg}=(yr(),pr),{sha256:zg}=(Ii(),Vn),{base58btc:xB}=(Pn(),Bn),{identity:SB}=(mc(),qo),Dt=jg(),Ic=Za(),AB=_c(),Tc=class{constructor(e){this._key=Is(e,Dt.publicKeyLength)}async verify(e,r){return Dt.hashAndVerify(this._key,r,e)}marshal(){return this._key}get bytes(){return Ic.PublicKey.encode({Type:Ic.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return Hg(this.bytes,e.bytes)}async hash(){let{bytes:e}=await zg.digest(this.bytes);return e}},Cs=class{constructor(e,r){this._key=Is(e,Dt.privateKeyLength),this._publicKey=Is(r,Dt.publicKeyLength)}async sign(e){return Dt.hashAndSign(this._key,e)}get public(){return new Tc(this._publicKey)}marshal(){return this._key}get bytes(){return Ic.PrivateKey.encode({Type:Ic.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return Hg(this.bytes,e.bytes)}async hash(){let{bytes:e}=await zg.digest(this.bytes);return e}async id(){let e=await SB.digest(this.public.bytes);return xB.encode(e.bytes).substring(1)}async export(e,r="libp2p-key"){if(r==="libp2p-key")return AB.export(this.bytes,e);throw $g(new Error(`export format '${r}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}};function CB(t){if(t.length>Dt.privateKeyLength){t=Is(t,Dt.privateKeyLength+Dt.publicKeyLength);let n=t.slice(0,Dt.privateKeyLength),i=t.slice(Dt.privateKeyLength,t.length);return new Cs(n,i)}t=Is(t,Dt.privateKeyLength);let e=t.slice(0,Dt.privateKeyLength),r=t.slice(Dt.publicKeyLength);return new Cs(e,r)}function IB(t){return t=Is(t,Dt.publicKeyLength),new Tc(t)}async function TB(){let{privateKey:t,publicKey:e}=await Dt.generateKey();return new Cs(t,e)}async function RB(t){let{privateKey:e,publicKey:r}=await Dt.generateKeyFromSeed(t);return new Cs(e,r)}function Is(t,e){if(t=Uint8Array.from(t||[]),t.length!==e)throw $g(new Error(`Key must be a Uint8Array of length ${e}, got ${t.length}`),"ERR_INVALID_KEY_TYPE");return t}Gg.exports={Ed25519PublicKey:Tc,Ed25519PrivateKey:Cs,unmarshalEd25519PrivateKey:CB,unmarshalEd25519PublicKey:IB,generateKeyPair:TB,generateKeyPairFromSeed:RB}});var lm=w(Ae=>{"use strict";var BB=Ae&&Ae.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.utils=Ae.schnorr=Ae.verify=Ae.signSync=Ae.sign=Ae.getSharedSecret=Ae.recoverPublicKey=Ae.getPublicKey=Ae.Signature=Ae.Point=Ae.CURVE=void 0;var PB=BB(xs()),Ne=BigInt(0),ct=BigInt(1),dt=BigInt(2),zo=BigInt(3),NB=BigInt(8),lf=dt**BigInt(256),Ve={a:Ne,b:BigInt(7),P:lf-dt**BigInt(32)-BigInt(977),n:lf-BigInt("432420386565659656852420866394968145599"),h:ct,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")};Ae.CURVE=Ve;function Yg(t){let{a:e,b:r}=Ve,n=ne(t*t),i=ne(n*t);return ne(i+e*t+r)}var Rc=Ve.a===Ne,Pe=class{constructor(e,r,n){this.x=e,this.y=r,this.z=n}static fromAffine(e){if(!(e instanceof De))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Pe(e.x,e.y,ct)}static toAffineBatch(e){let r=kB(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(r[i]))}static normalizeZ(e){return Pe.toAffineBatch(e).map(Pe.fromAffine)}equals(e){let r=this,n=e,i=ne(r.z*r.z),s=ne(r.z*i),o=ne(n.z*n.z),a=ne(n.z*o);return ne(r.x*o)===ne(i*n.x)&&ne(r.y*a)===ne(s*n.y)}negate(){return new Pe(this.x,ne(-this.y),this.z)}double(){let e=this.x,r=this.y,n=this.z,i=ne(e**dt),s=ne(r**dt),o=ne(s**dt),a=ne(dt*(ne(ne((e+s)**dt))-i-o)),c=ne(zo*i),u=ne(c**dt),l=ne(u-dt*a),f=ne(c*(a-l)-NB*o),h=ne(dt*r*n);return new Pe(l,f,h)}add(e){if(!(e instanceof Pe))throw new TypeError("JacobianPoint#add: expected JacobianPoint");let r=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z;if(s===Ne||o===Ne)return this;if(r===Ne||n===Ne)return e;let c=ne(i**dt),u=ne(a**dt),l=ne(r*u),f=ne(s*c),h=ne(n*a*u),p=ne(ne(o*i)*c),d=ne(f-l),g=ne(p-h);if(d===Ne)return g===Ne?this.double():Pe.ZERO;let m=ne(d**dt),x=ne(d*m),B=ne(l*m),L=ne(g**dt-x-dt*B),H=ne(g*(B-L)-h*x),U=ne(i*a*d);return new Pe(L,H,U)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let r=Zg(e);if(!Rc){let l=Pe.ZERO,f=this;for(;r>Ne;)r&ct&&(l=l.add(f)),f=f.double(),r>>=ct;return l}let{k1neg:n,k1:i,k2neg:s,k2:o}=em(r),a=Pe.ZERO,c=Pe.ZERO,u=this;for(;i>Ne||o>Ne;)i&ct&&(a=a.add(u)),o&ct&&(c=c.add(u)),u=u.double(),i>>=ct,o>>=ct;return n&&(a=a.negate()),s&&(c=c.negate()),c=new Pe(ne(c.x*Ve.beta),c.y,c.z),a.add(c)}precomputeWindow(e){let r=Rc?128/e+1:256/e+1,n=[],i=this,s=i;for(let o=0;o<r;o++){s=i,n.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,r){!r&&this.equals(Pe.BASE)&&(r=De.BASE);let n=r&&r._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=r&&ff.get(r);i||(i=this.precomputeWindow(n),r&&n!==1&&(i=Pe.normalizeZ(i),ff.set(r,i)));let s=Pe.ZERO,o=Pe.ZERO,a=Rc?128/n+1:256/n+1,c=2**(n-1),u=BigInt(2**n-1),l=2**n,f=BigInt(n);for(let h=0;h<a;h++){let p=h*c,d=Number(e&u);if(e>>=f,d>c&&(d-=l,e+=ct),d===0){let g=i[p];h%2&&(g=g.negate()),o=o.add(g)}else{let g=i[p+Math.abs(d)-1];d<0&&(g=g.negate()),s=s.add(g)}}return{p:s,f:o}}multiply(e,r){let n=Zg(e),i,s;if(Rc){let{k1neg:o,k1:a,k2neg:c,k2:u}=em(n),{p:l,f}=this.wNAF(a,r),{p:h,f:p}=this.wNAF(u,r);o&&(l=l.negate()),c&&(h=h.negate()),h=new Pe(ne(h.x*Ve.beta),h.y,h.z),i=l.add(h),s=f.add(p)}else{let{p:o,f:a}=this.wNAF(n,r);i=o,s=a}return Pe.normalizeZ([i,s])[0]}toAffine(e=Wo(this.z)){let r=e**dt,n=ne(this.x*r),i=ne(this.y*r*e);return new De(n,i)}};Pe.BASE=new Pe(Ve.Gx,Ve.Gy,ct);Pe.ZERO=new Pe(Ne,ct,Ne);var ff=new WeakMap,De=class{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,ff.delete(this)}static fromCompressedHex(e){let r=e.length===32,n=ir(r?e:e.slice(1)),i=Yg(n),s=LB(i),o=(s&ct)===ct;r?o&&(s=ne(-s)):(e[0]&1)==1!==o&&(s=ne(-s));let a=new De(n,s);return a.assertValidity(),a}static fromUncompressedHex(e){let r=ir(e.slice(1,33)),n=ir(e.slice(33)),i=new De(r,n);return i.assertValidity(),i}static fromHex(e){let r=Bi(e),n=r[0];if(r.length===32||r.length===33&&(n===2||n===3))return this.fromCompressedHex(r);if(r.length===65&&n===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r.length}`)}static fromPrivateKey(e){return De.BASE.multiply(Yo(e))}static fromSignature(e,r,n){let i=e instanceof Uint8Array?ir(e):Ts(e),s=rm(r),{r:o,s:a}=s;if(n!==0&&n!==1)throw new Error("Cannot recover signature: invalid recovery bit");let c=2+(n&1),u=De.fromHex(`0${c}${vn(o)}`),l=Pe.fromAffine(u).multiplyUnsafe(a),f=Pe.BASE.multiply(i),h=Wo(o,Ve.n),d=l.subtract(f).multiplyUnsafe(h).toAffine();return d.assertValidity(),d}toRawBytes(e=!1){return Xn(this.toHex(e))}toHex(e=!1){let r=vn(this.x);return e?`${this.y&ct?"03":"02"}${r}`:`04${r}${vn(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){let e="Point is not on elliptic curve",{x:r,y:n}=this;if(!yf(r)||!yf(n))throw new Error(e);let i=ne(n*n),s=Yg(r);if(ne(i-s)!==Ne)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new De(this.x,ne(-this.y))}double(){return Pe.fromAffine(this).double().toAffine()}add(e){return Pe.fromAffine(this).add(Pe.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Pe.fromAffine(this).multiply(e,this).toAffine()}};Ae.Point=De;De.BASE=new De(Ve.Gx,Ve.Gy);De.ZERO=new De(Ne,Ne);function Qg(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function Xg(t){if(t.length<2||t[0]!==2)throw new Error(`Invalid signature integer tag: ${Ri(t)}`);let e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:ir(r),left:t.subarray(e+2)}}function OB(t){if(t.length<2||t[0]!=48)throw new Error(`Invalid signature tag: ${Ri(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");let{data:e,left:r}=Xg(t.subarray(2)),{data:n,left:i}=Xg(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Ri(i)}`);return{r:e,s:n}}var Jr=class{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){let r=e instanceof Uint8Array,n="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${n}: Expected string or Uint8Array`);let i=r?Ri(e):e;if(i.length!==128)throw new Error(`${n}: Expected 64-byte hex`);return new Jr(Ts(i.slice(0,64)),Ts(i.slice(64,128)))}static fromDER(e){let r=e instanceof Uint8Array;if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");let{r:n,s:i}=OB(r?e:Xn(e));return new Jr(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){let{r:e,s:r}=this;if(!Pi(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Pi(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){let e=Ve.n>>ct;return this.s>e}normalizeS(){return this.hasHighS()?new Jr(this.r,Ve.n-this.s):this}toDERRawBytes(e=!1){return Xn(this.toDERHex(e))}toDERHex(e=!1){let r=Qg(Go(this.s));if(e)return r;let n=Qg(Go(this.r)),i=Go(n.length/2),s=Go(r.length/2);return`30${Go(n.length/2+r.length/2+4)}02${i}${n}02${s}${r}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Xn(this.toCompactHex())}toCompactHex(){return vn(this.r)+vn(this.s)}};Ae.Signature=Jr;function hf(...t){if(!t.every(n=>n instanceof Uint8Array))throw new Error("Uint8Array list expected");if(t.length===1)return t[0];let e=t.reduce((n,i)=>n+i.length,0),r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var DB=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ri(t){let e="";for(let r=0;r<t.length;r++)e+=DB[t[r]];return e}function vn(t){if(t>lf)throw new Error("pad64: invalid number");return t.toString(16).padStart(64,"0")}function df(t){return Xn(vn(t))}function Go(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function Ts(t){if(typeof t!="string")throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function Xn(t){if(typeof t!="string")throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){let n=r*2,i=t.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s))throw new Error("Invalid byte sequence");e[r]=s}return e}function Bi(t){return t instanceof Uint8Array?t:Xn(t)}function ir(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return Ts(Ri(t))}function Zg(t){if(typeof t=="number"&&t>0&&Number.isSafeInteger(t))return BigInt(t);if(typeof t=="bigint"&&Pi(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function ne(t,e=Ve.P){let r=t%e;return r>=0?r:e+r}function mr(t,e){let{P:r}=Ve,n=t;for(;e-- >Ne;)n*=n,n%=r;return n}function LB(t){let{P:e}=Ve,r=BigInt(6),n=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),c=t*t*t%e,u=c*c*t%e,l=mr(u,zo)*u%e,f=mr(l,zo)*u%e,h=mr(f,dt)*c%e,p=mr(h,n)*h%e,d=mr(p,i)*p%e,g=mr(d,o)*d%e,m=mr(g,a)*g%e,x=mr(m,o)*d%e,B=mr(x,zo)*u%e,L=mr(B,s)*p%e,H=mr(L,r)*c%e;return mr(H,dt)}function Wo(t,e=Ve.P){if(t===Ne||e<=Ne)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ne(t,e),n=e,i=Ne,s=ct,o=ct,a=Ne;for(;r!==Ne;){let u=n/r,l=n%r,f=i-o*u,h=s-a*u;n=r,r=l,i=o,s=a,o=f,a=h}if(n!==ct)throw new Error("invert: does not exist");return ne(i,e)}function kB(t,e=Ve.P){let r=t.length,n=new Array(r),i=ct;for(let s=0;s<r;s++)t[s]!==Ne&&(n[s]=i,i=ne(i*t[s],e));i=Wo(i,e);for(let s=r-1;s>=0;s--){if(t[s]===Ne)continue;let o=ne(i*t[s],e);t[s]=ne(i*n[s],e),i=o}return t}var Jg=(t,e)=>(t+e/dt)/e,Bc=dt**BigInt(128);function em(t){let{n:e}=Ve,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ct*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=Jg(s*t,e),a=Jg(-n*t,e),c=ne(t-o*r-a*i,e),u=ne(-o*n-a*s,e),l=c>Bc,f=u>Bc;if(l&&(c=e-c),f&&(u=e-u),c>Bc||u>Bc)throw new Error("splitScalarEndo: Endomorphism failed");return{k1neg:l,k1:c,k2neg:f,k2:u}}function qB(t){typeof t!="string"&&(t=Ri(t));let e=Ts(t||"0"),n=t.length/2*8-256;return n>0&&(e=e>>BigInt(n)),e>=Ve.n&&(e-=Ve.n),e}var pf=class{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Ae.utils.hmacSha256(this.k,...e)}hmacSync(...e){if(typeof Ae.utils.hmacSha256Sync!="function")throw new Error("utils.hmacSha256Sync is undefined, you need to set it");let r=Ae.utils.hmacSha256Sync(this.k,...e);if(r instanceof Promise)throw new Error("To use sync sign(), ensure utils.hmacSha256 is sync");return r}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),e.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){return this.incr(),this.v=await this.hmac(this.v),this.v}generateSync(){return this.incr(),this.v=this.hmacSync(this.v),this.v}};function Pi(t){return Ne<t&&t<Ve.n}function yf(t){return 0n<t&&t<Ve.P}function tm(t,e,r){let n=ir(t);if(!Pi(n))return;let{n:i}=Ve,s=De.BASE.multiply(n),o=ne(s.x,i);if(o===Ne)return;let a=ne(Wo(n,i)*ne(e+r*o,i),i);if(a===Ne)return;let c=new Jr(o,a),u=(s.x===c.r?0:2)|Number(s.y&ct);return{sig:c,recovery:u}}function Yo(t){let e;if(typeof t=="bigint")e=t;else if(typeof t=="number"&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if(typeof t=="string"){if(t.length!==64)throw new Error("Expected 32 bytes of private key");e=Ts(t)}else if(t instanceof Uint8Array){if(t.length!==32)throw new Error("Expected 32 bytes of private key");e=ir(t)}else throw new TypeError("Expected valid private key");if(!Pi(e))throw new Error("Expected private key: 0 < key < n");return e}function gf(t){return t instanceof De?(t.assertValidity(),t):De.fromHex(t)}function rm(t){if(t instanceof Jr)return t.assertValidity(),t;try{return Jr.fromDER(t)}catch(e){return Jr.fromCompact(t)}}function UB(t,e=!1){return De.fromPrivateKey(t).toRawBytes(e)}Ae.getPublicKey=UB;function MB(t,e,r){return De.fromSignature(t,e,r).toRawBytes()}Ae.recoverPublicKey=MB;function nm(t){let e=t instanceof Uint8Array,r=typeof t=="string",n=(e||r)&&t.length;return e?n===33||n===65:r?n===66||n===130:t instanceof De}function FB(t,e,r=!1){if(nm(t))throw new TypeError("getSharedSecret: first arg must be private key");if(!nm(e))throw new TypeError("getSharedSecret: second arg must be public key");let n=gf(e);return n.assertValidity(),n.multiply(Yo(t)).toRawBytes(r)}Ae.getSharedSecret=FB;function im(t){let e=t.length>32?t.slice(0,32):t;return ir(e)}function KB(t){let e=im(t),r=ne(e,Ve.n);return sm(r<Ne?e:r)}function sm(t){if(typeof t!="bigint")throw new Error("Expected bigint");let e=vn(t);return Xn(e)}function om(t,e,r){if(t==null)throw new Error(`sign: expected valid msgHash, not "${t}"`);let n=Bi(t),i=Yo(e),s=[sm(i),KB(n)];if(r!=null){r===!0&&(r=Ae.utils.randomBytes(32));let c=df(ir(Bi(r)));if(c.length!==32)throw new Error("secp256k1: Expected 32 bytes of extra data");s.push(c)}let o=hf(...s),a=im(n);return{seed:o,m:a,d:i}}function am(t,e){let{sig:r,recovery:n}=t,{canonical:i,der:s,recovered:o}=Object.assign({canonical:!0,der:!0},e);i&&r.hasHighS()&&(r=r.normalizeS(),n^=1);let a=s?r.toDERRawBytes():r.toCompactRawBytes();return o?[a,n]:a}async function VB(t,e,r={}){let{seed:n,m:i,d:s}=om(t,e,r.extraEntropy),o,a=new pf;for(await a.reseed(n);!(o=tm(await a.generate(),i,s));)await a.reseed();return am(o,r)}Ae.sign=VB;function jB(t,e,r={}){let{seed:n,m:i,d:s}=om(t,e,r.extraEntropy),o,a=new pf;for(a.reseedSync(n);!(o=tm(a.generateSync(),i,s));)a.reseedSync();return am(o,r)}Ae.signSync=jB;var $B={strict:!0};function HB(t,e,r,n=$B){let i;try{i=rm(t)}catch(x){return!1}let{r:s,s:o}=i;if(n.strict&&i.hasHighS())return!1;let a=qB(e);if(a===Ne)return!1;let c;try{c=Pe.fromAffine(gf(r))}catch(x){return!1}let{n:u}=Ve,l=Wo(o,u),f=ne(a*l,u),h=ne(s*l,u),p=Pe.BASE.multiply(f),d=c.multiplyUnsafe(h),g=p.add(d).toAffine();return ne(g.x,u)===s}Ae.verify=HB;async function mf(t,...e){let r=new Uint8Array(t.split("").map(s=>s.charCodeAt(0))),n=await Ae.utils.sha256(r),i=await Ae.utils.sha256(hf(n,n,...e));return ir(i)}async function cm(t,e,r){let n=df(t),i=await mf("BIP0340/challenge",n,e.toRawX(),r);return ne(i,Ve.n)}function vf(t){return ne(t.y,dt)===Ne}var Ni=class{constructor(e,r){if(this.r=e,this.s=r,!yf(e)||!Pi(r))throw new Error("Invalid signature")}static fromHex(e){let r=Bi(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);let n=ir(r.slice(0,32)),i=ir(r.slice(32,64));return new Ni(n,i)}toHex(){return vn(this.r)+vn(this.s)}toRawBytes(){return Xn(this.toHex())}};function zB(t){return De.fromPrivateKey(t).toRawX()}async function GB(t,e,r=Ae.utils.randomBytes()){if(t==null)throw new TypeError(`sign: Expected valid message, not "${t}"`);let{n}=Ve,i=Bi(t),s=Yo(e),o=Bi(r);if(o.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness");let a=De.fromPrivateKey(s),c=vf(a)?s:n-s,u=await mf("BIP0340/aux",o),l=c^u,f=await mf("BIP0340/nonce",df(l),a.toRawX(),i),h=ne(f,n);if(h===Ne)throw new Error("sign: Creation of signature failed. k is zero");let p=De.fromPrivateKey(h),d=vf(p)?h:n-h,g=await cm(p.x,a,i),m=new Ni(p.x,ne(d+g*c,n));if(!await um(m.toRawBytes(),i,a.toRawX()))throw new Error("sign: Invalid signature produced");return m.toRawBytes()}async function um(t,e,r){let n=t instanceof Ni?t:Ni.fromHex(t),i=Bi(e),s=gf(r),o=await cm(n.r,s,i),a=De.fromPrivateKey(n.s),c=s.multiply(o),u=a.subtract(c);return!(u.equals(De.BASE)||!vf(u)||u.x!==n.r)}Ae.schnorr={Signature:Ni,getPublicKey:zB,sign:GB,verify:um};De.BASE._setWindowSize(8);var sr={node:PB.default,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};Ae.utils={isValidPrivateKey(t){try{return Yo(t),!0}catch(e){return!1}},randomBytes:(t=32)=>{if(sr.web)return sr.web.getRandomValues(new Uint8Array(t));if(sr.node){let{randomBytes:e}=sr.node;return Uint8Array.from(e(t))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>{let t=8;for(;t--;){let e=Ae.utils.randomBytes(32),r=ir(e);if(Pi(r)&&r!==ct)return e}throw new Error("Valid private key was not found in 8 iterations. PRNG is broken")},bytesToHex:Ri,sha256:async t=>{if(sr.web){let e=await sr.web.subtle.digest("SHA-256",t.buffer);return new Uint8Array(e)}else if(sr.node){let{createHash:e}=sr.node;return Uint8Array.from(e("sha256").update(t).digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(sr.web){let r=await sr.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=hf(...e),i=await sr.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}else if(sr.node){let{createHmac:r}=sr.node,n=r("sha256",t);return e.forEach(i=>n.update(i)),Uint8Array.from(n.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,precompute(t=8,e=De.BASE){let r=e===De.BASE?e:new De(e.x,e.y);return r._setWindowSize(t),r.multiply(zo),r}}});var dm=w((oU,hm)=>{"use strict";var Qo=pe(),Zn=lm(),{sha256:fm}=(Ii(),Vn);hm.exports=()=>{let t=32;function e(){return Zn.utils.randomPrivateKey()}async function r(u,l){let{digest:f}=await fm.digest(l);try{return await Zn.sign(f,u)}catch(h){throw Qo(h,"ERR_INVALID_INPUT")}}async function n(u,l,f){try{let{digest:h}=await fm.digest(f);return Zn.verify(l,h,u)}catch(h){throw Qo(h,"ERR_INVALID_INPUT")}}function i(u){return Zn.Point.fromHex(u).toRawBytes(!0)}function s(u){return Zn.Point.fromHex(u).toRawBytes(!1)}function o(u){try{Zn.getPublicKey(u,!0)}catch(l){throw Qo(l,"ERR_INVALID_PRIVATE_KEY")}}function a(u){try{Zn.Point.fromHex(u)}catch(l){throw Qo(l,"ERR_INVALID_PUBLIC_KEY")}}function c(u){try{return Zn.getPublicKey(u,!0)}catch(l){throw Qo(l,"ERR_INVALID_PRIVATE_KEY")}}return{generateKey:e,privateKeyLength:t,hashAndSign:r,hashAndVerify:n,compressPublicKey:i,decompressPublicKey:s,validatePrivateKey:o,validatePublicKey:a,computePublicKey:c}}});var mm=w((aU,gm)=>{"use strict";var{sha256:pm}=(Ii(),Vn),WB=pe(),{equals:ym}=(yr(),pr),{toString:YB}=(It(),Nt),QB=_c();gm.exports=(t,e,r)=>{r=r||dm()();class n{constructor(u){r.validatePublicKey(u),this._key=u}verify(u,l){return r.hashAndVerify(this._key,l,u)}marshal(){return r.compressPublicKey(this._key)}get bytes(){return t.PublicKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(u){return ym(this.bytes,u.bytes)}async hash(){let{bytes:u}=await pm.digest(this.bytes);return u}}class i{constructor(u,l){this._key=u,this._publicKey=l||r.computePublicKey(u),r.validatePrivateKey(this._key),r.validatePublicKey(this._publicKey)}sign(u){return r.hashAndSign(this._key,u)}get public(){return new n(this._publicKey)}marshal(){return this._key}get bytes(){return t.PrivateKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(u){return ym(this.bytes,u.bytes)}async hash(){let{bytes:u}=await pm.digest(this.bytes);return u}async id(){let u=await this.public.hash();return YB(u,"base58btc")}async export(u,l="libp2p-key"){if(l==="libp2p-key")return QB.export(this.bytes,u);throw WB(new Error(`export format '${l}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}function s(c){return new i(c)}function o(c){return new n(c)}async function a(){let c=await r.generateKey();return new i(c)}return{Secp256k1PublicKey:n,Secp256k1PrivateKey:i,unmarshalSecp256k1PrivateKey:s,unmarshalSecp256k1PublicKey:o,generateKeyPair:a}}});var bm=w((cU,vm)=>{"use strict";vm.exports={SHA1:20,SHA256:32,SHA512:64}});var bf=w(wm=>{"use strict";var Em=Uo(),XB=bm(),ZB={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},JB=async(t,e)=>{let r=await Em.get().subtle.sign({name:"HMAC"},t,e);return new Uint8Array(r,r.byteOffset,r.byteLength)};wm.create=async function(t,e){let r=ZB[t],n=await Em.get().subtle.importKey("raw",e,{name:"HMAC",hash:{name:r}},!1,["sign"]);return{async digest(i){return JB(n,i)},length:XB[t]}}});var Cm=w((lU,Am)=>{"use strict";var _m=pe(),{concat:xm}=($n(),jn),{fromString:e8}=(Ct(),Pt),t8=bf(),Sm={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};Am.exports=async(t,e,r)=>{let n=Sm[t];if(!n){let B=Object.keys(Sm).join(" / ");throw _m(new Error(`unknown cipher type '${t}'. Must be ${B}`),"ERR_INVALID_CIPHER_TYPE")}if(!e)throw _m(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");let i=n.keySize,s=n.ivSize,o=20,a=e8("key expansion"),c=2*(s+i+o),u=await t8.create(e,r),l=await u.digest(a),f=[],h=0;for(;h<c;){let B=await u.digest(xm([l,a])),L=B.length;h+L>c&&(L=c-h),f.push(B),h+=L,l=await u.digest(l)}let p=c/2,d=xm(f),g=d.slice(0,p),m=d.slice(p,c),x=B=>({iv:B.slice(0,s),cipherKey:B.slice(s,s+i),macKey:B.slice(s+i)});return{k1:x(g),k2:x(m)}}});var Tm=w((fU,Im)=>{"use strict";var r8=pe();Im.exports=function(t,e){if(!t.includes(e)){let r=t.join(" / ");throw r8(new Error(`Unknown curve: ${e}. Must be ${r}`),"ERR_INVALID_CURVE")}}});var Dm=w(Om=>{"use strict";var n8=pe(),Xo=Uo(),{base64urlToBuffer:Rm}=wc(),i8=Tm(),{toString:Ef}=(It(),Nt),{concat:s8}=($n(),jn),{equals:o8}=(yr(),pr),Bm={"P-256":256,"P-384":384,"P-521":521};Om.generateEphmeralKeyPair=async function(t){i8(Object.keys(Bm),t);let e=await Xo.get().subtle.generateKey({name:"ECDH",namedCurve:t},!0,["deriveBits"]),r=async(i,s)=>{let o;s?o=await Xo.get().subtle.importKey("jwk",c8(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):o=e.privateKey;let a=[await Xo.get().subtle.importKey("jwk",Nm(t,i),{name:"ECDH",namedCurve:t},!1,[]),o],c=await Xo.get().subtle.deriveBits({name:"ECDH",namedCurve:t,public:a[0]},a[1],Bm[t]);return new Uint8Array(c,c.byteOffset,c.byteLength)},n=await Xo.get().subtle.exportKey("jwk",e.publicKey);return{key:a8(n),genSharedKey:r}};var Pm={"P-256":32,"P-384":48,"P-521":66};function a8(t){let e=Pm[t.crv];return s8([Uint8Array.from([4]),Rm(t.x,e),Rm(t.y,e)],1+e*2)}function Nm(t,e){let r=Pm[t];if(o8(!e.slice(0,1),Uint8Array.from([4])))throw n8(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:t,x:Ef(e.slice(1,r+1),"base64url"),y:Ef(e.slice(1+r),"base64url"),ext:!0}}var c8=(t,e)=>({...Nm(t,e.public),d:Ef(e.private,"base64url")})});var km=w((dU,Lm)=>{"use strict";var u8=Dm();Lm.exports=async t=>u8.generateEphmeralKeyPair(t)});var Nc=w((pU,Um)=>{"use strict";var en=Za();Un();Ml();var wf=Ee(),Zo=pe(),{fromString:l8}=(Ct(),Pt),f8=ag(),vr={rsa:Ng(),ed25519:Wg(),secp256k1:mm()(en,Ec())},Pc={message:"secp256k1 support requires libp2p-crypto-secp256k1 package",code:"ERR_MISSING_PACKAGE"};function Rs(t){let e=vr[t.toLowerCase()];if(!e){let r=Object.keys(vr).join(" / ");throw Zo(new Error(`invalid or unsupported key type ${t}. Must be ${r}`),"ERR_UNSUPPORTED_KEY_TYPE")}return e}var h8=async(t,e)=>Rs(t).generateKeyPair(e),d8=async(t,e,r)=>{let n=Rs(t);if(t.toLowerCase()!=="ed25519")throw Zo(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return n.generateKeyPairFromSeed(e,r)},p8=t=>{let e=en.PublicKey.decode(t),r=e.Data;switch(e.Type){case en.KeyType.RSA:return vr.rsa.unmarshalRsaPublicKey(r);case en.KeyType.Ed25519:return vr.ed25519.unmarshalEd25519PublicKey(r);case en.KeyType.Secp256k1:if(vr.secp256k1)return vr.secp256k1.unmarshalSecp256k1PublicKey(r);throw Zo(new Error(Pc.message),Pc.code);default:Rs(e.Type)}},y8=(t,e)=>(e=(e||"rsa").toLowerCase(),Rs(e),t.bytes),qm=async t=>{let e=en.PrivateKey.decode(t),r=e.Data;switch(e.Type){case en.KeyType.RSA:return vr.rsa.unmarshalRsaPrivateKey(r);case en.KeyType.Ed25519:return vr.ed25519.unmarshalEd25519PrivateKey(r);case en.KeyType.Secp256k1:if(vr.secp256k1)return vr.secp256k1.unmarshalSecp256k1PrivateKey(r);throw Zo(new Error(Pc.message),Pc.code);default:Rs(e.Type)}},g8=(t,e)=>(e=(e||"rsa").toLowerCase(),Rs(e),t.bytes),m8=async(t,e)=>{try{let i=await f8.import(t,e);return qm(i)}catch(i){}let r=wf.pki.decryptRsaPrivateKey(t,e);if(r===null)throw Zo(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let n=wf.asn1.toDer(wf.pki.privateKeyToAsn1(r));return n=l8(n.getBytes(),"ascii"),vr.rsa.unmarshalRsaPrivateKey(n)};Um.exports={supportedKeys:vr,keysPBM:en,keyStretcher:Cm(),generateEphemeralKeyPair:km(),generateKeyPair:h8,generateKeyPairFromSeed:d8,unmarshalPublicKey:p8,marshalPublicKey:y8,unmarshalPrivateKey:qm,marshalPrivateKey:g8,import:m8}});var Mm=w((yU,_f)=>{"use strict";function v8(t,{className:e,symbolName:r}){let n=Symbol.for(r),i={[e]:class extends t{constructor(...s){super(...s);Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return e}}}[e];return i[`is${e}`]=s=>!!(s&&s[n]),i}function b8(t,{className:e,symbolName:r,withoutNew:n}){let i=Symbol.for(r),s={[e]:function(...o){if(n&&!(this instanceof s))return new s(...o);let a=t.call(this,...o)||this;return a&&!a[i]&&Object.defineProperty(a,i,{value:!0}),a}}[e];return s.prototype=Object.create(t.prototype),s.prototype.constructor=s,Object.defineProperty(s.prototype,Symbol.toStringTag,{get(){return e}}),s[`is${e}`]=o=>!!(o&&o[i]),s}_f.exports=v8;_f.exports.proto=b8});var Vm=w((gU,Km)=>{"use strict";var Bs=Ln(),Fm=Bs.Reader,E8=Bs.Writer,bt=Bs.util,Jo=Bs.roots["libp2p-peer-id"]||(Bs.roots["libp2p-peer-id"]={});Jo.PeerIdProto=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.id=bt.newBuffer([]),t.prototype.pubKey=bt.newBuffer([]),t.prototype.privKey=bt.newBuffer([]),t.encode=function(r,n){return n||(n=E8.create()),n.uint32(10).bytes(r.id),r.pubKey!=null&&Object.hasOwnProperty.call(r,"pubKey")&&n.uint32(18).bytes(r.pubKey),r.privKey!=null&&Object.hasOwnProperty.call(r,"privKey")&&n.uint32(26).bytes(r.privKey),n},t.decode=function(r,n){r instanceof Fm||(r=Fm.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new Jo.PeerIdProto;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.id=r.bytes();break;case 2:s.pubKey=r.bytes();break;case 3:s.privKey=r.bytes();break;default:r.skipType(o&7);break}}if(!s.hasOwnProperty("id"))throw bt.ProtocolError("missing required 'id'",{instance:s});return s},t.fromObject=function(r){if(r instanceof Jo.PeerIdProto)return r;var n=new Jo.PeerIdProto;return r.id!=null&&(typeof r.id=="string"?bt.base64.decode(r.id,n.id=bt.newBuffer(bt.base64.length(r.id)),0):r.id.length&&(n.id=r.id)),r.pubKey!=null&&(typeof r.pubKey=="string"?bt.base64.decode(r.pubKey,n.pubKey=bt.newBuffer(bt.base64.length(r.pubKey)),0):r.pubKey.length&&(n.pubKey=r.pubKey)),r.privKey!=null&&(typeof r.privKey=="string"?bt.base64.decode(r.privKey,n.privKey=bt.newBuffer(bt.base64.length(r.privKey)),0):r.privKey.length&&(n.privKey=r.privKey)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(n.bytes===String?i.id="":(i.id=[],n.bytes!==Array&&(i.id=bt.newBuffer(i.id))),n.bytes===String?i.pubKey="":(i.pubKey=[],n.bytes!==Array&&(i.pubKey=bt.newBuffer(i.pubKey))),n.bytes===String?i.privKey="":(i.privKey=[],n.bytes!==Array&&(i.privKey=bt.newBuffer(i.privKey)))),r.id!=null&&r.hasOwnProperty("id")&&(i.id=n.bytes===String?bt.base64.encode(r.id,0,r.id.length):n.bytes===Array?Array.prototype.slice.call(r.id):r.id),r.pubKey!=null&&r.hasOwnProperty("pubKey")&&(i.pubKey=n.bytes===String?bt.base64.encode(r.pubKey,0,r.pubKey.length):n.bytes===Array?Array.prototype.slice.call(r.pubKey):r.pubKey),r.privKey!=null&&r.hasOwnProperty("privKey")&&(i.privKey=n.bytes===String?bt.base64.encode(r.privKey,0,r.privKey.length):n.bytes===Array?Array.prototype.slice.call(r.privKey):r.privKey),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,Bs.util.toJSONOptions)},t}();Km.exports=Jo});var Tt=w((Lt,Qm)=>{"use strict";var{CID:xf}=(gs(),Io),w8=(vi(),mi),_8=(rl(),Ha),x8=(Pn(),Bn),S8=(To(),ms),{base58btc:Sf}=(Pn(),Bn),{base32:A8}=(vi(),mi),{base16:jm}=(nl(),za),ea=(gi(),Ao),tn=Nc(),C8=Mm(),{PeerIdProto:$m}=Vm(),{equals:Oi}=(yr(),pr),{fromString:ta}=(Ct(),Pt),{toString:I8}=(It(),Nt),{identity:Oc}=(mc(),qo),Hm={...w8,..._8,...x8,...S8},T8=Object.keys(Hm).reduce((t,e)=>t.or(Hm[e]),A8.decoder),R8=112,zm=114,Gm=class{constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("invalid id provided");if(r&&n&&!Oi(r.public.bytes,n.bytes))throw new Error("inconsistent arguments");this._id=e,this._idB58String=Sf.encode(this.id).substring(1),this._privKey=r,this._pubKey=n}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){if(this._pubKey)return this._pubKey;if(this._privKey)return this._privKey.public;try{let e=ea.decode(this.id);e.code===Oc.code&&(this._pubKey=tn.unmarshalPublicKey(e.digest))}catch(e){}return this._pubKey}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return tn.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return tn.marshalPrivateKey(this.privKey)}marshal(e){return $m.encode({id:this.toBytes(),pubKey:this.marshalPubKey(),privKey:e?null:this.marshalPrivKey()}).finish()}toPrint(){let e=this.toB58String();e.startsWith("Qm")&&(e=e.slice(2));let r=6;return e.length<r&&(r=e.length),"<peer.ID "+e.substr(0,r)+">"}toJSON(){return{id:this.toB58String(),privKey:Ym(this.marshalPrivKey()),pubKey:Ym(this.marshalPubKey())}}toHexString(){return jm.encode(this.id).substring(1)}toBytes(){return this.id}toB58String(){return this._idB58String}toString(){if(!this._idCIDString){let e=xf.createV1(zm,ea.decode(this.id));Object.defineProperty(this,"_idCIDString",{value:e.toString(),enumerable:!1})}return this._idCIDString}equals(e){if(e instanceof Uint8Array)return Oi(this.id,e);if(e.id)return Oi(this.id,e.id);throw new Error("not valid Id")}isEqual(e){return this.equals(e)}isValid(){return Boolean(this.privKey&&this.privKey.public&&this.privKey.public.bytes&&this.pubKey.bytes instanceof Uint8Array&&Oi(this.privKey.public.bytes,this.pubKey.bytes))}hasInlinePublicKey(){try{if(ea.decode(this.id).code===Oc.code)return!0}catch(e){}return!1}},rn=C8(Gm,{className:"PeerId",symbolName:"@libp2p/js-peer-id/PeerId"});Lt=Qm.exports=rn;var ra=t=>t.bytes.length<=42?ea.create(Oc.code,t.bytes).bytes:t.hash(),Af=async(t,e)=>{let r=await ra(e);return new rn(r,t,e)};Lt.create=async t=>{t=t||{},t.bits=t.bits||2048,t.keyType=t.keyType||"RSA";let e=await tn.generateKeyPair(t.keyType,t.bits);return Af(e,e.public)};Lt.createFromHexString=t=>new rn(jm.decode("f"+t));Lt.createFromBytes=t=>{try{let e=xf.decode(t);if(!Wm(e))throw new Error("Supplied PeerID CID is invalid");return Lt.createFromCID(e)}catch{if(ea.decode(t).code!==Oc.code)throw new Error("Supplied PeerID CID is invalid");return new rn(t)}};Lt.createFromB58String=t=>Lt.createFromBytes(Sf.decode("z"+t));var Wm=t=>t.code===zm||t.code===R8;Lt.createFromCID=t=>{if(t=xf.asCID(t),!t||!Wm(t))throw new Error("Supplied PeerID CID is invalid");return new rn(t.multihash.bytes)};Lt.createFromPubKey=async t=>{let e=t;if(typeof e=="string"&&(e=ta(t,"base64pad")),!(e instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");let r=await tn.unmarshalPublicKey(e);return Af(void 0,r)};Lt.createFromPrivKey=async t=>{if(typeof t=="string"&&(t=ta(t,"base64pad")),!(t instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");let e=await tn.unmarshalPrivateKey(t);return Af(e,e.public)};Lt.createFromJSON=async t=>{let e=Sf.decode("z"+t.id),r=t.privKey&&ta(t.privKey,"base64pad"),n=t.pubKey&&ta(t.pubKey,"base64pad"),i=n&&await tn.unmarshalPublicKey(n);if(!r)return new rn(e,void 0,i);let s=await tn.unmarshalPrivateKey(r),o=await ra(s.public),a;if(i&&(a=await ra(i)),i&&!Oi(o,a))throw new Error("Public and private key do not match");if(e&&!Oi(o,e))throw new Error("Id and private key do not match");return new rn(e,s,i)};Lt.createFromProtobuf=async t=>{typeof t=="string"&&(t=ta(t,"base16"));let{id:e,privKey:r,pubKey:n}=$m.decode(t);r=r?await tn.unmarshalPrivateKey(r):!1,n=n?await tn.unmarshalPublicKey(n):!1;let i,s;if(r&&(s=await ra(r.public)),n&&(i=await ra(n)),r){if(n&&!Oi(s,i))throw new Error("Public and private key do not match");return new rn(s,r,r.public)}if(n)return new rn(i,void 0,n);if(e)return new rn(e);throw new Error("Protobuf did not contain any usable key material")};Lt.parse=t=>((t.charAt(0)==="1"||t.charAt(0)==="Q")&&(t=`z${t}`),Lt.createFromBytes(T8.decode(t)));Lt.isPeerId=t=>Boolean(typeof t=="object"&&t._id&&t._idB58String);function Ym(t){if(t)return I8(t,"base64pad")}});var If=w((mU,Zm)=>{"use strict";var Xm="[a-fA-F\\d:]",Jn=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${Xm})|(?<=${Xm})(?=\\s|$))`:"",Dr="(?: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}",gt="[a-fA-F\\d]{1,4}",Dc=`
29
+ `+a+e.substr(o+1),s=i-o-1,o=-1,++i}else(e[i]===" "||e[i]===" "||e[i]===",")&&(o=i);return e}function VT(t){return t.replace(/^\s+/,"")}});var Ey=w((Qq,by)=>{var zr=be();Vn();$e();var yy=by.exports=zr.sha256=zr.sha256||{};zr.md.sha256=zr.md.algorithms.sha256=yy;yy.create=function(){gy||jT();var t=null,e=zr.util.createBuffer(),r=new Array(64),n={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=zr.util.createBuffer(),t={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=zr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),vy(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=zr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(jl.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};vy(f,r,i);var h=zr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h.putInt32(f.h5),h.putInt32(f.h6),h.putInt32(f.h7),h},n};var jl=null,gy=!1,my=null;function jT(){jl=String.fromCharCode(128),jl+=zr.util.fillString(String.fromCharCode(0),64),my=[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],gy=!0}function vy(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,p,d,g,m,x,R=r.length();R>=64;){for(u=0;u<16;++u)e[u]=r.getInt32();for(;u<64;++u)n=e[u-2],n=(n>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=e[u-15],i=(i>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,e[u]=n+e[u-7]+i+e[u-16]|0;for(l=t.h0,f=t.h1,h=t.h2,p=t.h3,d=t.h4,g=t.h5,m=t.h6,x=t.h7,u=0;u<64;++u)o=(d>>>6|d<<26)^(d>>>11|d<<21)^(d>>>25|d<<7),a=m^d&(g^m),s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),c=l&f|h&(l^f),n=x+o+a+my[u]+e[u],i=s+c,x=m,m=g,g=d,d=p+n>>>0,p=h,h=f,f=l,l=n+i>>>0;t.h0=t.h0+l|0,t.h1=t.h1+f|0,t.h2=t.h2+h|0,t.h3=t.h3+p|0,t.h4=t.h4+d|0,t.h5=t.h5+g|0,t.h6=t.h6+m|0,t.h7=t.h7+x|0,R-=64}}});var _y=w((Xq,wy)=>{var Gr=be();$e();var mc=null;Gr.util.isNodejs&&!Gr.options.usePureJavaScript&&!process.versions["node-webkit"]&&(mc=As());var $T=wy.exports=Gr.prng=Gr.prng||{};$T.create=function(t){for(var e={plugin:t,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=t.md,n=new Array(32),i=0;i<32;++i)n[i]=r.create();e.pools=n,e.pool=0,e.generate=function(u,l){if(!l)return e.generateSync(u);var f=e.plugin.cipher,h=e.plugin.increment,p=e.plugin.formatKey,d=e.plugin.formatSeed,g=Gr.util.createBuffer();e.key=null,m();function m(x){if(x)return l(x);if(g.length()>=u)return l(null,g.getBytes(u));if(e.generated>1048575&&(e.key=null),e.key===null)return Gr.util.nextTick(function(){s(m)});var R=f(e.key,e.seed);e.generated+=R.length,g.putBytes(R),e.key=p(f(e.key,h(e.seed))),e.seed=d(f(e.key,e.seed)),Gr.util.setImmediate(m)}},e.generateSync=function(u){var l=e.plugin.cipher,f=e.plugin.increment,h=e.plugin.formatKey,p=e.plugin.formatSeed;e.key=null;for(var d=Gr.util.createBuffer();d.length()<u;){e.generated>1048575&&(e.key=null),e.key===null&&o();var g=l(e.key,e.seed);e.generated+=g.length,d.putBytes(g),e.key=h(l(e.key,f(e.seed))),e.seed=p(l(e.key,e.seed))}return d.getBytes(u)};function s(u){if(e.pools[0].messageLength>=32)return a(),u();var l=32-e.pools[0].messageLength<<5;e.seedFile(l,function(f,h){if(f)return u(f);e.collect(h),a(),u()})}function o(){if(e.pools[0].messageLength>=32)return a();var u=32-e.pools[0].messageLength<<5;e.collect(e.seedFileSync(u)),a()}function a(){e.reseeds=e.reseeds===4294967295?0:e.reseeds+1;var u=e.plugin.md.create();u.update(e.keyBytes);for(var l=1,f=0;f<32;++f)e.reseeds%l==0&&(u.update(e.pools[f].digest().getBytes()),e.pools[f].start()),l=l<<1;e.keyBytes=u.digest().getBytes(),u.start(),u.update(e.keyBytes);var h=u.digest().getBytes();e.key=e.plugin.formatKey(e.keyBytes),e.seed=e.plugin.formatSeed(h),e.generated=0}function c(u){var l=null,f=Gr.util.globalScope,h=f.crypto||f.msCrypto;h&&h.getRandomValues&&(l=function(q){return h.getRandomValues(q)});var p=Gr.util.createBuffer();if(l)for(;p.length()<u;){var d=Math.max(1,Math.min(u-p.length(),65536)/4),g=new Uint32Array(Math.floor(d));try{l(g);for(var m=0;m<g.length;++m)p.putInt32(g[m])}catch(q){if(!(typeof QuotaExceededError!="undefined"&&q instanceof QuotaExceededError))throw q}}if(p.length()<u)for(var x,R,L,H=Math.floor(Math.random()*65536);p.length()<u;){R=16807*(H&65535),x=16807*(H>>16),R+=(x&32767)<<16,R+=x>>15,R=(R&2147483647)+(R>>31),H=R&4294967295;for(var m=0;m<3;++m)L=H>>>(m<<3),L^=Math.floor(Math.random()*256),p.putByte(L&255)}return p.getBytes(u)}return mc?(e.seedFile=function(u,l){mc.randomBytes(u,function(f,h){if(f)return l(f);l(null,h.toString())})},e.seedFileSync=function(u){return mc.randomBytes(u).toString()}):(e.seedFile=function(u,l){try{l(null,c(u))}catch(f){l(f)}},e.seedFileSync=c),e.collect=function(u){for(var l=u.length,f=0;f<l;++f)e.pools[e.pool].update(u.substr(f,1)),e.pool=e.pool===31?0:e.pool+1},e.collectInt=function(u,l){for(var f="",h=0;h<l;h+=8)f+=String.fromCharCode(u>>h&255);e.collect(f)},e.registerWorker=function(u){if(u===self)e.seedFile=function(f,h){function p(d){var g=d.data;g.forge&&g.forge.prng&&(self.removeEventListener("message",p),h(g.forge.prng.err,g.forge.prng.bytes))}self.addEventListener("message",p),self.postMessage({forge:{prng:{needed:f}}})};else{var l=function(f){var h=f.data;h.forge&&h.forge.prng&&e.seedFile(h.forge.prng.needed,function(p,d){u.postMessage({forge:{prng:{err:p,bytes:d}}})})};u.addEventListener("message",l)}},e}});var Si=w((Zq,$l)=>{var St=be();Ss();Ey();_y();$e();(function(){if(St.random&&St.random.getBytes){$l.exports=St.random;return}(function(t){var e={},r=new Array(4),n=St.util.createBuffer();e.formatKey=function(f){var h=St.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),St.aes._expandKey(f,!1)},e.formatSeed=function(f){var h=St.util.createBuffer(f);return f=new Array(4),f[0]=h.getInt32(),f[1]=h.getInt32(),f[2]=h.getInt32(),f[3]=h.getInt32(),f},e.cipher=function(f,h){return St.aes._updateBlock(f,h,r,!1),n.putInt32(r[0]),n.putInt32(r[1]),n.putInt32(r[2]),n.putInt32(r[3]),n.getBytes()},e.increment=function(f){return++f[3],f},e.md=St.md.sha256;function i(){var f=St.prng.create(e);return f.getBytes=function(h,p){return f.generate(h,p)},f.getBytesSync=function(h){return f.generate(h)},f}var s=i(),o=null,a=St.util.globalScope,c=a.crypto||a.msCrypto;if(c&&c.getRandomValues&&(o=function(f){return c.getRandomValues(f)}),St.options.usePureJavaScript||!St.util.isNodejs&&!o){if(typeof window=="undefined"||window.document===void 0,s.collectInt(+new Date,32),typeof navigator!="undefined"){var u="";for(var l in navigator)try{typeof navigator[l]=="string"&&(u+=navigator[l])}catch(f){}s.collect(u),u=null}t&&(t().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),t().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!St.random)St.random=s;else for(var l in s)St.random[l]=s[l];St.random.createInstance=i,$l.exports=St.random})(typeof jQuery!="undefined"?jQuery:null)})()});var Cy=w((Jq,Ay)=>{var Zt=be();$e();var Hl=[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],xy=[1,2,3,5],HT=function(t,e){return t<<e&65535|(t&65535)>>16-e},zT=function(t,e){return(t&65535)>>e|t<<16-e&65535};Ay.exports=Zt.rc2=Zt.rc2||{};Zt.rc2.expandKey=function(t,e){typeof t=="string"&&(t=Zt.util.createBuffer(t)),e=e||128;var r=t,n=t.length(),i=e,s=Math.ceil(i/8),o=255>>(i&7),a;for(a=n;a<128;a++)r.putByte(Hl[r.at(a-1)+r.at(a-n)&255]);for(r.setAt(128-s,Hl[r.at(128-s)&o]),a=127-s;a>=0;a--)r.setAt(a,Hl[r.at(a+1)^r.at(a+s)]);return r};var Sy=function(t,e,r){var n=!1,i=null,s=null,o=null,a,c,u,l,f=[];for(t=Zt.rc2.expandKey(t,e),u=0;u<64;u++)f.push(t.getInt16Le());r?(a=function(d){for(u=0;u<4;u++)d[u]+=f[l]+(d[(u+3)%4]&d[(u+2)%4])+(~d[(u+3)%4]&d[(u+1)%4]),d[u]=HT(d[u],xy[u]),l++},c=function(d){for(u=0;u<4;u++)d[u]+=f[d[(u+3)%4]&63]}):(a=function(d){for(u=3;u>=0;u--)d[u]=zT(d[u],xy[u]),d[u]-=f[l]+(d[(u+3)%4]&d[(u+2)%4])+(~d[(u+3)%4]&d[(u+1)%4]),l--},c=function(d){for(u=3;u>=0;u--)d[u]-=f[d[(u+3)%4]&63]});var h=function(d){var g=[];for(u=0;u<4;u++){var m=i.getInt16Le();o!==null&&(r?m^=o.getInt16Le():o.putInt16Le(m)),g.push(m&65535)}l=r?0:63;for(var x=0;x<d.length;x++)for(var R=0;R<d[x][0];R++)d[x][1](g);for(u=0;u<4;u++)o!==null&&(r?o.putInt16Le(g[u]):g[u]^=o.getInt16Le()),s.putInt16Le(g[u])},p=null;return p={start:function(d,g){d&&typeof d=="string"&&(d=Zt.util.createBuffer(d)),n=!1,i=Zt.util.createBuffer(),s=g||new Zt.util.createBuffer,o=d,p.output=s},update:function(d){for(n||i.putBuffer(d);i.length()>=8;)h([[5,a],[1,c],[6,a],[1,c],[5,a]])},finish:function(d){var g=!0;if(r)if(d)g=d(8,i,!r);else{var m=i.length()===8?8:8-i.length();i.fillWithByte(m,m)}if(g&&(n=!0,p.update()),!r&&(g=i.length()===0,g))if(d)g=d(8,s,!r);else{var x=s.length(),R=s.at(x-1);R>x?g=!1:s.truncate(R)}return g}},p};Zt.rc2.startEncrypting=function(t,e,r){var n=Zt.rc2.createEncryptionCipher(t,128);return n.start(e,r),n};Zt.rc2.createEncryptionCipher=function(t,e){return Sy(t,e,!0)};Zt.rc2.startDecrypting=function(t,e,r){var n=Zt.rc2.createDecryptionCipher(t,128);return n.start(e,r),n};Zt.rc2.createDecryptionCipher=function(t,e){return Sy(t,e,!1)}});var Ec=w((eU,Dy)=>{var zl=be();Dy.exports=zl.jsbn=zl.jsbn||{};var mn,GT=244837814094590,Iy=(GT&16777215)==15715070;function V(t,e,r){this.data=[],t!=null&&(typeof t=="number"?this.fromNumber(t,e,r):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}zl.jsbn.BigInteger=V;function Be(){return new V(null)}function WT(t,e,r,n,i,s){for(;--s>=0;){var o=e*this.data[t++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=o&67108863}return i}function YT(t,e,r,n,i,s){for(var o=e&32767,a=e>>15;--s>=0;){var c=this.data[t]&32767,u=this.data[t++]>>15,l=a*c+u*o;c=o*c+((l&32767)<<15)+r.data[n]+(i&1073741823),i=(c>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=c&1073741823}return i}function Ty(t,e,r,n,i,s){for(var o=e&16383,a=e>>14;--s>=0;){var c=this.data[t]&16383,u=this.data[t++]>>14,l=a*c+u*o;c=o*c+((l&16383)<<14)+r.data[n]+i,i=(c>>28)+(l>>14)+a*u,r.data[n++]=c&268435455}return i}typeof navigator=="undefined"?(V.prototype.am=Ty,mn=28):Iy&&navigator.appName=="Microsoft Internet Explorer"?(V.prototype.am=YT,mn=30):Iy&&navigator.appName!="Netscape"?(V.prototype.am=WT,mn=26):(V.prototype.am=Ty,mn=28);V.prototype.DB=mn;V.prototype.DM=(1<<mn)-1;V.prototype.DV=1<<mn;var Gl=52;V.prototype.FV=Math.pow(2,Gl);V.prototype.F1=Gl-mn;V.prototype.F2=2*mn-Gl;var QT="0123456789abcdefghijklmnopqrstuvwxyz",vc=new Array,Cs,fr;Cs="0".charCodeAt(0);for(fr=0;fr<=9;++fr)vc[Cs++]=fr;Cs="a".charCodeAt(0);for(fr=10;fr<36;++fr)vc[Cs++]=fr;Cs="A".charCodeAt(0);for(fr=10;fr<36;++fr)vc[Cs++]=fr;function Ry(t){return QT.charAt(t)}function By(t,e){var r=vc[t.charCodeAt(e)];return r??-1}function XT(t){for(var e=this.t-1;e>=0;--e)t.data[e]=this.data[e];t.t=this.t,t.s=this.s}function ZT(t){this.t=1,this.s=t<0?-1:0,t>0?this.data[0]=t:t<-1?this.data[0]=t+this.DV:this.t=0}function jn(t){var e=Be();return e.fromInt(t),e}function JT(t,e){var r;if(e==16)r=4;else if(e==8)r=3;else if(e==256)r=8;else if(e==2)r=1;else if(e==32)r=5;else if(e==4)r=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var n=t.length,i=!1,s=0;--n>=0;){var o=r==8?t[n]&255:By(t,n);if(o<0){t.charAt(n)=="-"&&(i=!0);continue}i=!1,s==0?this.data[this.t++]=o:s+r>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this.data[this.t++]=o>>this.DB-s):this.data[this.t-1]|=o<<s,s+=r,s>=this.DB&&(s-=this.DB)}r==8&&(t[0]&128)!=0&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),i&&V.ZERO.subTo(this,this)}function eR(){for(var t=this.s&this.DM;this.t>0&&this.data[this.t-1]==t;)--this.t}function tR(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var r=(1<<e)-1,n,i=!1,s="",o=this.t,a=this.DB-o*this.DB%e;if(o-- >0)for(a<this.DB&&(n=this.data[o]>>a)>0&&(i=!0,s=Ry(n));o>=0;)a<e?(n=(this.data[o]&(1<<a)-1)<<e-a,n|=this.data[--o]>>(a+=this.DB-e)):(n=this.data[o]>>(a-=e)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=Ry(n));return i?s:"0"}function rR(){var t=Be();return V.ZERO.subTo(this,t),t}function nR(){return this.s<0?this.negate():this}function iR(t){var e=this.s-t.s;if(e!=0)return e;var r=this.t;if(e=r-t.t,e!=0)return this.s<0?-e:e;for(;--r>=0;)if((e=this.data[r]-t.data[r])!=0)return e;return 0}function bc(t){var e=1,r;return(r=t>>>16)!=0&&(t=r,e+=16),(r=t>>8)!=0&&(t=r,e+=8),(r=t>>4)!=0&&(t=r,e+=4),(r=t>>2)!=0&&(t=r,e+=2),(r=t>>1)!=0&&(t=r,e+=1),e}function sR(){return this.t<=0?0:this.DB*(this.t-1)+bc(this.data[this.t-1]^this.s&this.DM)}function oR(t,e){var r;for(r=this.t-1;r>=0;--r)e.data[r+t]=this.data[r];for(r=t-1;r>=0;--r)e.data[r]=0;e.t=this.t+t,e.s=this.s}function aR(t,e){for(var r=t;r<this.t;++r)e.data[r-t]=this.data[r];e.t=Math.max(this.t-t,0),e.s=this.s}function cR(t,e){var r=t%this.DB,n=this.DB-r,i=(1<<n)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a;for(a=this.t-1;a>=0;--a)e.data[a+s+1]=this.data[a]>>n|o,o=(this.data[a]&i)<<r;for(a=s-1;a>=0;--a)e.data[a]=0;e.data[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()}function uR(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t){e.t=0;return}var n=t%this.DB,i=this.DB-n,s=(1<<n)-1;e.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)e.data[o-r-1]|=(this.data[o]&s)<<i,e.data[o-r]=this.data[o]>>n;n>0&&(e.data[this.t-r-1]|=(this.s&s)<<i),e.t=this.t-r,e.clamp()}function lR(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]-t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n-=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n-=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n-=t.s}e.s=n<0?-1:0,n<-1?e.data[r++]=this.DV+n:n>0&&(e.data[r++]=n),e.t=r,e.clamp()}function fR(t,e){var r=this.abs(),n=t.abs(),i=r.t;for(e.t=i+n.t;--i>=0;)e.data[i]=0;for(i=0;i<n.t;++i)e.data[i+r.t]=r.am(0,n.data[i],e,i,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&V.ZERO.subTo(e,e)}function hR(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t.data[r]=0;for(r=0;r<e.t-1;++r){var n=e.am(r,e.data[r],t,2*r,0,1);(t.data[r+e.t]+=e.am(r+1,2*e.data[r],t,2*r+1,n,e.t-r-1))>=e.DV&&(t.data[r+e.t]-=e.DV,t.data[r+e.t+1]=1)}t.t>0&&(t.data[t.t-1]+=e.am(r,e.data[r],t,2*r,0,1)),t.s=0,t.clamp()}function dR(t,e,r){var n=t.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t){e!=null&&e.fromInt(0),r!=null&&this.copyTo(r);return}r==null&&(r=Be());var s=Be(),o=this.s,a=t.s,c=this.DB-bc(n.data[n.t-1]);c>0?(n.lShiftTo(c,s),i.lShiftTo(c,r)):(n.copyTo(s),i.copyTo(r));var u=s.t,l=s.data[u-1];if(l!=0){var f=l*(1<<this.F1)+(u>1?s.data[u-2]>>this.F2:0),h=this.FV/f,p=(1<<this.F1)/f,d=1<<this.F2,g=r.t,m=g-u,x=e??Be();for(s.dlShiftTo(m,x),r.compareTo(x)>=0&&(r.data[r.t++]=1,r.subTo(x,r)),V.ONE.dlShiftTo(u,x),x.subTo(s,s);s.t<u;)s.data[s.t++]=0;for(;--m>=0;){var R=r.data[--g]==l?this.DM:Math.floor(r.data[g]*h+(r.data[g-1]+d)*p);if((r.data[g]+=s.am(0,R,r,m,0,u))<R)for(s.dlShiftTo(m,x),r.subTo(x,r);r.data[g]<--R;)r.subTo(x,r)}e!=null&&(r.drShiftTo(u,e),o!=a&&V.ZERO.subTo(e,e)),r.t=u,r.clamp(),c>0&&r.rShiftTo(c,r),o<0&&V.ZERO.subTo(r,r)}}}function pR(t){var e=Be();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(V.ZERO)>0&&t.subTo(e,e),e}function Ai(t){this.m=t}function yR(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t}function gR(t){return t}function mR(t){t.divRemTo(this.m,null,t)}function vR(t,e,r){t.multiplyTo(e,r),this.reduce(r)}function bR(t,e){t.squareTo(e),this.reduce(e)}Ai.prototype.convert=yR;Ai.prototype.revert=gR;Ai.prototype.reduce=mR;Ai.prototype.mulTo=vR;Ai.prototype.sqrTo=bR;function ER(){if(this.t<1)return 0;var t=this.data[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e}function Ci(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function wR(t){var e=Be();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(V.ZERO)>0&&this.m.subTo(e,e),e}function _R(t){var e=Be();return t.copyTo(e),this.reduce(e),e}function xR(t){for(;t.t<=this.mt2;)t.data[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=t.data[e]&32767,n=r*this.mpl+((r*this.mph+(t.data[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(r=e+this.m.t,t.data[r]+=this.m.am(0,n,t,e,0,this.m.t);t.data[r]>=t.DV;)t.data[r]-=t.DV,t.data[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)}function SR(t,e){t.squareTo(e),this.reduce(e)}function AR(t,e,r){t.multiplyTo(e,r),this.reduce(r)}Ci.prototype.convert=wR;Ci.prototype.revert=_R;Ci.prototype.reduce=xR;Ci.prototype.mulTo=AR;Ci.prototype.sqrTo=SR;function CR(){return(this.t>0?this.data[0]&1:this.s)==0}function IR(t,e){if(t>4294967295||t<1)return V.ONE;var r=Be(),n=Be(),i=e.convert(this),s=bc(t)-1;for(i.copyTo(r);--s>=0;)if(e.sqrTo(r,n),(t&1<<s)>0)e.mulTo(n,i,r);else{var o=r;r=n,n=o}return e.revert(r)}function TR(t,e){var r;return t<256||e.isEven()?r=new Ai(e):r=new Ci(e),this.exp(t,r)}V.prototype.copyTo=XT;V.prototype.fromInt=ZT;V.prototype.fromString=JT;V.prototype.clamp=eR;V.prototype.dlShiftTo=oR;V.prototype.drShiftTo=aR;V.prototype.lShiftTo=cR;V.prototype.rShiftTo=uR;V.prototype.subTo=lR;V.prototype.multiplyTo=fR;V.prototype.squareTo=hR;V.prototype.divRemTo=dR;V.prototype.invDigit=ER;V.prototype.isEven=CR;V.prototype.exp=IR;V.prototype.toString=tR;V.prototype.negate=rR;V.prototype.abs=nR;V.prototype.compareTo=iR;V.prototype.bitLength=sR;V.prototype.mod=pR;V.prototype.modPowInt=TR;V.ZERO=jn(0);V.ONE=jn(1);function RR(){var t=Be();return this.copyTo(t),t}function BR(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function PR(){return this.t==0?this.s:this.data[0]<<24>>24}function NR(){return this.t==0?this.s:this.data[0]<<16>>16}function OR(t){return Math.floor(Math.LN2*this.DB/Math.log(t))}function DR(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function LR(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),n=jn(r),i=Be(),s=Be(),o="";for(this.divRemTo(n,i,s);i.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,i.divRemTo(n,i,s);return s.intValue().toString(t)+o}function kR(t,e){this.fromInt(0),e==null&&(e=10);for(var r=this.chunkSize(e),n=Math.pow(e,r),i=!1,s=0,o=0,a=0;a<t.length;++a){var c=By(t,a);if(c<0){t.charAt(a)=="-"&&this.signum()==0&&(i=!0);continue}o=e*o+c,++s>=r&&(this.dMultiply(n),this.dAddOffset(o,0),s=0,o=0)}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),i&&V.ZERO.subTo(this,this)}function qR(t,e,r){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(V.ONE.shiftLeft(t-1),Wl,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(V.ONE.shiftLeft(t-1),this);else{var n=new Array,i=t&7;n.length=(t>>3)+1,e.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}}function UR(){var t=this.t,e=new Array;e[0]=this.s;var r=this.DB-t*this.DB%8,n,i=0;if(t-- >0)for(r<this.DB&&(n=this.data[t]>>r)!=(this.s&this.DM)>>r&&(e[i++]=n|this.s<<this.DB-r);t>=0;)r<8?(n=(this.data[t]&(1<<r)-1)<<8-r,n|=this.data[--t]>>(r+=this.DB-8)):(n=this.data[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),(n&128)!=0&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(e[i++]=n);return e}function MR(t){return this.compareTo(t)==0}function FR(t){return this.compareTo(t)<0?this:t}function KR(t){return this.compareTo(t)>0?this:t}function VR(t,e,r){var n,i,s=Math.min(t.t,this.t);for(n=0;n<s;++n)r.data[n]=e(this.data[n],t.data[n]);if(t.t<this.t){for(i=t.s&this.DM,n=s;n<this.t;++n)r.data[n]=e(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<t.t;++n)r.data[n]=e(i,t.data[n]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()}function jR(t,e){return t&e}function $R(t){var e=Be();return this.bitwiseTo(t,jR,e),e}function Wl(t,e){return t|e}function HR(t){var e=Be();return this.bitwiseTo(t,Wl,e),e}function Py(t,e){return t^e}function zR(t){var e=Be();return this.bitwiseTo(t,Py,e),e}function Ny(t,e){return t&~e}function GR(t){var e=Be();return this.bitwiseTo(t,Ny,e),e}function WR(){for(var t=Be(),e=0;e<this.t;++e)t.data[e]=this.DM&~this.data[e];return t.t=this.t,t.s=~this.s,t}function YR(t){var e=Be();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e}function QR(t){var e=Be();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e}function XR(t){if(t==0)return-1;var e=0;return(t&65535)==0&&(t>>=16,e+=16),(t&255)==0&&(t>>=8,e+=8),(t&15)==0&&(t>>=4,e+=4),(t&3)==0&&(t>>=2,e+=2),(t&1)==0&&++e,e}function ZR(){for(var t=0;t<this.t;++t)if(this.data[t]!=0)return t*this.DB+XR(this.data[t]);return this.s<0?this.t*this.DB:-1}function JR(t){for(var e=0;t!=0;)t&=t-1,++e;return e}function e4(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=JR(this.data[r]^e);return t}function t4(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this.data[e]&1<<t%this.DB)!=0}function r4(t,e){var r=V.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r}function n4(t){return this.changeBit(t,Wl)}function i4(t){return this.changeBit(t,Ny)}function s4(t){return this.changeBit(t,Py)}function o4(t,e){for(var r=0,n=0,i=Math.min(t.t,this.t);r<i;)n+=this.data[r]+t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;if(t.t<this.t){for(n+=t.s;r<this.t;)n+=this.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<t.t;)n+=t.data[r],e.data[r++]=n&this.DM,n>>=this.DB;n+=t.s}e.s=n<0?-1:0,n>0?e.data[r++]=n:n<-1&&(e.data[r++]=this.DV+n),e.t=r,e.clamp()}function a4(t){var e=Be();return this.addTo(t,e),e}function c4(t){var e=Be();return this.subTo(t,e),e}function u4(t){var e=Be();return this.multiplyTo(t,e),e}function l4(t){var e=Be();return this.divRemTo(t,e,null),e}function f4(t){var e=Be();return this.divRemTo(t,null,e),e}function h4(t){var e=Be(),r=Be();return this.divRemTo(t,e,r),new Array(e,r)}function d4(t){this.data[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()}function p4(t,e){if(t!=0){for(;this.t<=e;)this.data[this.t++]=0;for(this.data[e]+=t;this.data[e]>=this.DV;)this.data[e]-=this.DV,++e>=this.t&&(this.data[this.t++]=0),++this.data[e]}}function Vo(){}function Oy(t){return t}function y4(t,e,r){t.multiplyTo(e,r)}function g4(t,e){t.squareTo(e)}Vo.prototype.convert=Oy;Vo.prototype.revert=Oy;Vo.prototype.mulTo=y4;Vo.prototype.sqrTo=g4;function m4(t){return this.exp(t,new Vo)}function v4(t,e,r){var n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r.data[--n]=0;var i;for(i=r.t-this.t;n<i;++n)r.data[n+this.t]=this.am(0,t.data[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t.data[n],r,n,0,e-n);r.clamp()}function b4(t,e,r){--e;var n=r.t=this.t+t.t-e;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(e-this.t,0);n<t.t;++n)r.data[this.t+n-e]=this.am(e-n,t.data[n],r,0,0,this.t+n-e);r.clamp(),r.drShiftTo(1,r)}function Is(t){this.r2=Be(),this.q3=Be(),V.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}function E4(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=Be();return t.copyTo(e),this.reduce(e),e}function w4(t){return t}function _4(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)}function x4(t,e){t.squareTo(e),this.reduce(e)}function S4(t,e,r){t.multiplyTo(e,r),this.reduce(r)}Is.prototype.convert=E4;Is.prototype.revert=w4;Is.prototype.reduce=_4;Is.prototype.mulTo=S4;Is.prototype.sqrTo=x4;function A4(t,e){var r=t.bitLength(),n,i=jn(1),s;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?s=new Ai(e):e.isEven()?s=new Is(e):s=new Ci(e);var o=new Array,a=3,c=n-1,u=(1<<n)-1;if(o[1]=s.convert(this),n>1){var l=Be();for(s.sqrTo(o[1],l);a<=u;)o[a]=Be(),s.mulTo(l,o[a-2],o[a]),a+=2}var f=t.t-1,h,p=!0,d=Be(),g;for(r=bc(t.data[f])-1;f>=0;){for(r>=c?h=t.data[f]>>r-c&u:(h=(t.data[f]&(1<<r+1)-1)<<c-r,f>0&&(h|=t.data[f-1]>>this.DB+r-c)),a=n;(h&1)==0;)h>>=1,--a;if((r-=a)<0&&(r+=this.DB,--f),p)o[h].copyTo(i),p=!1;else{for(;a>1;)s.sqrTo(i,d),s.sqrTo(d,i),a-=2;a>0?s.sqrTo(i,d):(g=i,i=d,d=g),s.mulTo(d,o[h],i)}for(;f>=0&&(t.data[f]&1<<r)==0;)s.sqrTo(i,d),g=i,i=d,d=g,--r<0&&(r=this.DB-1,--f)}return s.revert(i)}function C4(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var n=e;e=r,r=n}var i=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(i<s&&(s=i),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(i=e.getLowestSetBit())>0&&e.rShiftTo(i,e),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r}function I4(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(e==0)r=this.data[0]%t;else for(var n=this.t-1;n>=0;--n)r=(e*r+this.data[n])%t;return r}function T4(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return V.ZERO;for(var r=t.clone(),n=this.clone(),i=jn(1),s=jn(0),o=jn(0),a=jn(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),e?((!i.isEven()||!s.isEven())&&(i.addTo(this,i),s.subTo(t,s)),i.rShiftTo(1,i)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?((!o.isEven()||!a.isEven())&&(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),e&&i.subTo(o,i),s.subTo(a,s)):(n.subTo(r,n),e&&o.subTo(i,o),a.subTo(s,a))}if(n.compareTo(V.ONE)!=0)return V.ZERO;if(a.compareTo(t)>=0)return a.subtract(t);if(a.signum()<0)a.addTo(t,a);else return a;return a.signum()<0?a.add(t):a}var Nr=[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],R4=(1<<26)/Nr[Nr.length-1];function B4(t){var e,r=this.abs();if(r.t==1&&r.data[0]<=Nr[Nr.length-1]){for(e=0;e<Nr.length;++e)if(r.data[0]==Nr[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<Nr.length;){for(var n=Nr[e],i=e+1;i<Nr.length&&n<R4;)n*=Nr[i++];for(n=r.modInt(n);e<i;)if(n%Nr[e++]==0)return!1}return r.millerRabin(t)}function P4(t){var e=this.subtract(V.ONE),r=e.getLowestSetBit();if(r<=0)return!1;for(var n=e.shiftRight(r),i=N4(),s,o=0;o<t;++o){do s=new V(this.bitLength(),i);while(s.compareTo(V.ONE)<=0||s.compareTo(e)>=0);var a=s.modPow(n,this);if(a.compareTo(V.ONE)!=0&&a.compareTo(e)!=0){for(var c=1;c++<r&&a.compareTo(e)!=0;)if(a=a.modPowInt(2,this),a.compareTo(V.ONE)==0)return!1;if(a.compareTo(e)!=0)return!1}}return!0}function N4(){return{nextBytes:function(t){for(var e=0;e<t.length;++e)t[e]=Math.floor(Math.random()*256)}}}V.prototype.chunkSize=OR;V.prototype.toRadix=LR;V.prototype.fromRadix=kR;V.prototype.fromNumber=qR;V.prototype.bitwiseTo=VR;V.prototype.changeBit=r4;V.prototype.addTo=o4;V.prototype.dMultiply=d4;V.prototype.dAddOffset=p4;V.prototype.multiplyLowerTo=v4;V.prototype.multiplyUpperTo=b4;V.prototype.modInt=I4;V.prototype.millerRabin=P4;V.prototype.clone=RR;V.prototype.intValue=BR;V.prototype.byteValue=PR;V.prototype.shortValue=NR;V.prototype.signum=DR;V.prototype.toByteArray=UR;V.prototype.equals=MR;V.prototype.min=FR;V.prototype.max=KR;V.prototype.and=$R;V.prototype.or=HR;V.prototype.xor=zR;V.prototype.andNot=GR;V.prototype.not=WR;V.prototype.shiftLeft=YR;V.prototype.shiftRight=QR;V.prototype.getLowestSetBit=ZR;V.prototype.bitCount=e4;V.prototype.testBit=t4;V.prototype.setBit=n4;V.prototype.clearBit=i4;V.prototype.flipBit=s4;V.prototype.add=a4;V.prototype.subtract=c4;V.prototype.multiply=u4;V.prototype.divide=l4;V.prototype.remainder=f4;V.prototype.divideAndRemainder=h4;V.prototype.modPow=A4;V.prototype.modInverse=T4;V.prototype.pow=m4;V.prototype.gcd=C4;V.prototype.isProbablePrime=B4});var My=w((tU,Uy)=>{var Wr=be();Vn();$e();var Ly=Uy.exports=Wr.sha1=Wr.sha1||{};Wr.md.sha1=Wr.md.algorithms.sha1=Ly;Ly.create=function(){ky||O4();var t=null,e=Wr.util.createBuffer(),r=new Array(80),n={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return n.start=function(){n.messageLength=0,n.fullMessageLength=n.messageLength64=[];for(var i=n.messageLengthSize/4,s=0;s<i;++s)n.fullMessageLength.push(0);return e=Wr.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},n},n.start(),n.update=function(i,s){s==="utf8"&&(i=Wr.util.encodeUtf8(i));var o=i.length;n.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=n.fullMessageLength.length-1;a>=0;--a)n.fullMessageLength[a]+=o[1],o[1]=o[0]+(n.fullMessageLength[a]/4294967296>>>0),n.fullMessageLength[a]=n.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return e.putBytes(i),qy(t,r,e),(e.read>2048||e.length()===0)&&e.compact(),n},n.digest=function(){var i=Wr.util.createBuffer();i.putBytes(e.bytes());var s=n.fullMessageLength[n.fullMessageLength.length-1]+n.messageLengthSize,o=s&n.blockLength-1;i.putBytes(Yl.substr(0,n.blockLength-o));for(var a,c,u=n.fullMessageLength[0]*8,l=0;l<n.fullMessageLength.length-1;++l)a=n.fullMessageLength[l+1]*8,c=a/4294967296>>>0,u+=c,i.putInt32(u>>>0),u=a>>>0;i.putInt32(u);var f={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};qy(f,r,i);var h=Wr.util.createBuffer();return h.putInt32(f.h0),h.putInt32(f.h1),h.putInt32(f.h2),h.putInt32(f.h3),h.putInt32(f.h4),h},n};var Yl=null,ky=!1;function O4(){Yl=String.fromCharCode(128),Yl+=Wr.util.fillString(String.fromCharCode(0),64),ky=!0}function qy(t,e,r){for(var n,i,s,o,a,c,u,l,f=r.length();f>=64;){for(i=t.h0,s=t.h1,o=t.h2,a=t.h3,c=t.h4,l=0;l<16;++l)n=r.getInt32(),e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<20;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=a^s&(o^a),n=(i<<5|i>>>27)+u+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<32;++l)n=e[l-3]^e[l-8]^e[l-14]^e[l-16],n=n<<1|n>>>31,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<40;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<60;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s&o|a&(s^o),n=(i<<5|i>>>27)+u+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<80;++l)n=e[l-6]^e[l-16]^e[l-28]^e[l-32],n=n<<2|n>>>30,e[l]=n,u=s^o^a,n=(i<<5|i>>>27)+u+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;t.h0=t.h0+i|0,t.h1=t.h1+s|0,t.h2=t.h2+o|0,t.h3=t.h3+a|0,t.h4=t.h4+c|0,f-=64}}});var Vy=w((rU,Ky)=>{var Yr=be();$e();Si();My();var Fy=Ky.exports=Yr.pkcs1=Yr.pkcs1||{};Fy.encode_rsa_oaep=function(t,e,r){var n,i,s,o;typeof r=="string"?(n=r,i=arguments[3]||void 0,s=arguments[4]||void 0):r&&(n=r.label||void 0,i=r.seed||void 0,s=r.md||void 0,r.mgf1&&r.mgf1.md&&(o=r.mgf1.md)),s?s.start():s=Yr.md.sha1.create(),o||(o=s);var a=Math.ceil(t.n.bitLength()/8),c=a-2*s.digestLength-2;if(e.length>c){var u=new Error("RSAES-OAEP input message length is too long.");throw u.length=e.length,u.maxLength=c,u}n||(n=""),s.update(n,"raw");for(var l=s.digest(),f="",h=c-e.length,p=0;p<h;p++)f+="\0";var d=l.getBytes()+f+""+e;if(!i)i=Yr.random.getBytes(s.digestLength);else if(i.length!==s.digestLength){var u=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw u.seedLength=i.length,u.digestLength=s.digestLength,u}var g=wc(i,a-s.digestLength-1,o),m=Yr.util.xorBytes(d,g,d.length),x=wc(m,s.digestLength,o),R=Yr.util.xorBytes(i,x,i.length);return"\0"+R+m};Fy.decode_rsa_oaep=function(t,e,r){var n,i,s;typeof r=="string"?(n=r,i=arguments[3]||void 0):r&&(n=r.label||void 0,i=r.md||void 0,r.mgf1&&r.mgf1.md&&(s=r.mgf1.md));var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var m=new Error("RSAES-OAEP encoded message length is invalid.");throw m.length=e.length,m.expectedLength=o,m}if(i===void 0?i=Yr.md.sha1.create():i.start(),s||(s=i),o<2*i.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");n||(n=""),i.update(n,"raw");for(var a=i.digest().getBytes(),c=e.charAt(0),u=e.substring(1,i.digestLength+1),l=e.substring(1+i.digestLength),f=wc(l,i.digestLength,s),h=Yr.util.xorBytes(u,f,u.length),p=wc(h,o-i.digestLength-1,s),d=Yr.util.xorBytes(l,p,l.length),g=d.substring(0,i.digestLength),m=c!=="\0",x=0;x<i.digestLength;++x)m|=a.charAt(x)!==g.charAt(x);for(var R=1,L=i.digestLength,H=i.digestLength;H<d.length;H++){var q=d.charCodeAt(H),k=q&1^1,J=R?65534:0;m|=q&J,R=R&k,L+=R}if(m||d.charCodeAt(L)!==1)throw new Error("Invalid RSAES-OAEP padding.");return d.substring(L+1)};function wc(t,e,r){r||(r=Yr.md.sha1.create());for(var n="",i=Math.ceil(e/r.digestLength),s=0;s<i;++s){var o=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);r.start(),r.update(t+o),n+=r.digest().getBytes()}return n.substring(0,e)}});var jy=w((nU,Ql)=>{var $n=be();$e();Ec();Si();(function(){if($n.prime){Ql.exports=$n.prime;return}var t=Ql.exports=$n.prime=$n.prime||{},e=$n.jsbn.BigInteger,r=[6,4,2,4,2,4,6,2],n=new e(null);n.fromInt(30);var i=function(f,h){return f|h};t.generateProbablePrime=function(f,h,p){typeof h=="function"&&(p=h,h={}),h=h||{};var d=h.algorithm||"PRIMEINC";typeof d=="string"&&(d={name:d}),d.options=d.options||{};var g=h.prng||$n.random,m={nextBytes:function(x){for(var R=g.getBytesSync(x.length),L=0;L<x.length;++L)x[L]=R.charCodeAt(L)}};if(d.name==="PRIMEINC")return s(f,m,d.options,p);throw new Error("Invalid prime generation algorithm: "+d.name)};function s(f,h,p,d){return"workers"in p?c(f,h,p,d):o(f,h,p,d)}function o(f,h,p,d){var g=u(f,h),m=0,x=l(g.bitLength());"millerRabinTests"in p&&(x=p.millerRabinTests);var R=10;"maxBlockTime"in p&&(R=p.maxBlockTime),a(g,f,h,m,x,R,d)}function a(f,h,p,d,g,m,x){var R=+new Date;do{if(f.bitLength()>h&&(f=u(h,p)),f.isProbablePrime(g))return x(null,f);f.dAddOffset(r[d++%8],0)}while(m<0||+new Date-R<m);$n.util.setImmediate(function(){a(f,h,p,d,g,m,x)})}function c(f,h,p,d){if(typeof Worker=="undefined")return o(f,h,p,d);var g=u(f,h),m=p.workers,x=p.workLoad||100,R=x*30/8,L=p.workerScript||"forge/prime.worker.js";if(m===-1)return $n.util.estimateCores(function(q,k){q&&(k=2),m=k-1,H()});H();function H(){m=Math.max(1,m);for(var q=[],k=0;k<m;++k)q[k]=new Worker(L);for(var J=m,k=0;k<m;++k)q[k].addEventListener("message",j);var ie=!1;function j(we){if(!ie){--J;var le=we.data;if(le.found){for(var ye=0;ye<q.length;++ye)q[ye].terminate();return ie=!0,d(null,new e(le.prime,16))}g.bitLength()>f&&(g=u(f,h));var nt=g.toString(16);we.target.postMessage({hex:nt,workLoad:x}),g.dAddOffset(R,0)}}}}function u(f,h){var p=new e(f,h),d=f-1;return p.testBit(d)||p.bitwiseTo(e.ONE.shiftLeft(d),i,p),p.dAddOffset(31-p.mod(n).byteValue(),0),p}function l(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})()});var jo=w((iU,Qy)=>{var de=be();Kn();Ec();ws();Vy();jy();Si();$e();typeof Se=="undefined"&&(Se=de.jsbn.BigInteger);var Se,Xl=de.util.isNodejs?As():null,D=de.asn1,hr=de.util;de.pki=de.pki||{};Qy.exports=de.pki.rsa=de.rsa=de.rsa||{};var pe=de.pki,D4=[6,4,2,4,2,4,6,2],L4={name:"PrivateKeyInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},k4={name:"RSAPrivateKey",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},q4={name:"RSAPublicKey",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:D.Class.UNIVERSAL,type:D.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},U4=de.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:D.Class.UNIVERSAL,type:D.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:D.Class.UNIVERSAL,type:D.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:D.Class.UNIVERSAL,type:D.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},M4=function(t){var e;if(t.algorithm in pe.oids)e=pe.oids[t.algorithm];else{var r=new Error("Unknown message digest algorithm.");throw r.algorithm=t.algorithm,r}var n=D.oidToDer(e).getBytes(),i=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[]),s=D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[]);s.value.push(D.create(D.Class.UNIVERSAL,D.Type.OID,!1,n)),s.value.push(D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,""));var o=D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,t.digest().getBytes());return i.value.push(s),i.value.push(o),D.toDer(i).getBytes()},$y=function(t,e,r){if(r)return t.modPow(e.e,e.n);if(!e.p||!e.q)return t.modPow(e.d,e.n);e.dP||(e.dP=e.d.mod(e.p.subtract(Se.ONE))),e.dQ||(e.dQ=e.d.mod(e.q.subtract(Se.ONE))),e.qInv||(e.qInv=e.q.modInverse(e.p));var n;do n=new Se(de.util.bytesToHex(de.random.getBytes(e.n.bitLength()/8)),16);while(n.compareTo(e.n)>=0||!n.gcd(e.n).equals(Se.ONE));t=t.multiply(n.modPow(e.e,e.n)).mod(e.n);for(var i=t.mod(e.p).modPow(e.dP,e.p),s=t.mod(e.q).modPow(e.dQ,e.q);i.compareTo(s)<0;)i=i.add(e.p);var o=i.subtract(s).multiply(e.qInv).mod(e.p).multiply(e.q).add(s);return o=o.multiply(n.modInverse(e.n)).mod(e.n),o};pe.rsa.encrypt=function(t,e,r){var n=r,i,s=Math.ceil(e.n.bitLength()/8);r!==!1&&r!==!0?(n=r===2,i=Hy(t,e,r)):(i=de.util.createBuffer(),i.putBytes(t));for(var o=new Se(i.toHex(),16),a=$y(o,e,n),c=a.toString(16),u=de.util.createBuffer(),l=s-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(de.util.hexToBytes(c)),u.getBytes()};pe.rsa.decrypt=function(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var s=new Error("Encrypted message length is invalid.");throw s.length=t.length,s.expected=i,s}var o=new Se(de.util.createBuffer(t).toHex(),16);if(o.compareTo(e.n)>=0)throw new Error("Encrypted message is invalid.");for(var a=$y(o,e,r),c=a.toString(16),u=de.util.createBuffer(),l=i-Math.ceil(c.length/2);l>0;)u.putByte(0),--l;return u.putBytes(de.util.hexToBytes(c)),n!==!1?_c(u.getBytes(),e,r):u.getBytes()};pe.rsa.createKeyPairGenerationState=function(t,e,r){typeof t=="string"&&(t=parseInt(t,10)),t=t||2048,r=r||{};var n=r.prng||de.random,i={nextBytes:function(a){for(var c=n.getBytesSync(a.length),u=0;u<a.length;++u)a[u]=c.charCodeAt(u)}},s=r.algorithm||"PRIMEINC",o;if(s==="PRIMEINC")o={algorithm:s,state:0,bits:t,rng:i,eInt:e||65537,e:new Se(null),p:null,q:null,qBits:t>>1,pBits:t-(t>>1),pqState:0,num:null,keys:null},o.e.fromInt(o.eInt);else throw new Error("Invalid key generation algorithm: "+s);return o};pe.rsa.stepKeyPairGenerationState=function(t,e){"algorithm"in t||(t.algorithm="PRIMEINC");var r=new Se(null);r.fromInt(30);for(var n=0,i=function(f,h){return f|h},s=+new Date,o,a=0;t.keys===null&&(e<=0||a<e);){if(t.state===0){var c=t.p===null?t.pBits:t.qBits,u=c-1;t.pqState===0?(t.num=new Se(c,t.rng),t.num.testBit(u)||t.num.bitwiseTo(Se.ONE.shiftLeft(u),i,t.num),t.num.dAddOffset(31-t.num.mod(r).byteValue(),0),n=0,++t.pqState):t.pqState===1?t.num.bitLength()>c?t.pqState=0:t.num.isProbablePrime(K4(t.num.bitLength()))?++t.pqState:t.num.dAddOffset(D4[n++%8],0):t.pqState===2?t.pqState=t.num.subtract(Se.ONE).gcd(t.e).compareTo(Se.ONE)===0?3:0:t.pqState===3&&(t.pqState=0,t.p===null?t.p=t.num:t.q=t.num,t.p!==null&&t.q!==null&&++t.state,t.num=null)}else if(t.state===1)t.p.compareTo(t.q)<0&&(t.num=t.p,t.p=t.q,t.q=t.num),++t.state;else if(t.state===2)t.p1=t.p.subtract(Se.ONE),t.q1=t.q.subtract(Se.ONE),t.phi=t.p1.multiply(t.q1),++t.state;else if(t.state===3)t.phi.gcd(t.e).compareTo(Se.ONE)===0?++t.state:(t.p=null,t.q=null,t.state=0);else if(t.state===4)t.n=t.p.multiply(t.q),t.n.bitLength()===t.bits?++t.state:(t.q=null,t.state=0);else if(t.state===5){var l=t.e.modInverse(t.phi);t.keys={privateKey:pe.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:pe.rsa.setPublicKey(t.n,t.e)}}o=+new Date,a+=o-s,s=o}return t.keys!==null};pe.rsa.generateKeyPair=function(t,e,r,n){if(arguments.length===1?typeof t=="object"?(r=t,t=void 0):typeof t=="function"&&(n=t,t=void 0):arguments.length===2?typeof t=="number"?typeof e=="function"?(n=e,e=void 0):typeof e!="number"&&(r=e,e=void 0):(r=t,n=e,t=void 0,e=void 0):arguments.length===3&&(typeof e=="number"?typeof r=="function"&&(n=r,r=void 0):(n=r,r=e,e=void 0)),r=r||{},t===void 0&&(t=r.bits||2048),e===void 0&&(e=r.e||65537),!de.options.usePureJavaScript&&!r.prng&&t>=256&&t<=16384&&(e===65537||e===3)){if(n){if(zy("generateKeyPair"))return Xl.generateKeyPair("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(a,c,u){if(a)return n(a);n(null,{privateKey:pe.privateKeyFromPem(u),publicKey:pe.publicKeyFromPem(c)})});if(Gy("generateKey")&&Gy("exportKey"))return hr.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:Yy(e),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(a){return hr.globalScope.crypto.subtle.exportKey("pkcs8",a.privateKey)}).then(void 0,function(a){n(a)}).then(function(a){if(a){var c=pe.privateKeyFromAsn1(D.fromDer(de.util.createBuffer(a)));n(null,{privateKey:c,publicKey:pe.setRsaPublicKey(c.n,c.e)})}});if(Wy("generateKey")&&Wy("exportKey")){var i=hr.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:Yy(e),hash:{name:"SHA-256"}},!0,["sign","verify"]);i.oncomplete=function(a){var c=a.target.result,u=hr.globalScope.msCrypto.subtle.exportKey("pkcs8",c.privateKey);u.oncomplete=function(l){var f=l.target.result,h=pe.privateKeyFromAsn1(D.fromDer(de.util.createBuffer(f)));n(null,{privateKey:h,publicKey:pe.setRsaPublicKey(h.n,h.e)})},u.onerror=function(l){n(l)}},i.onerror=function(a){n(a)};return}}else if(zy("generateKeyPairSync")){var s=Xl.generateKeyPairSync("rsa",{modulusLength:t,publicExponent:e,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:pe.privateKeyFromPem(s.privateKey),publicKey:pe.publicKeyFromPem(s.publicKey)}}}var o=pe.rsa.createKeyPairGenerationState(t,e,r);if(!n)return pe.rsa.stepKeyPairGenerationState(o,0),o.keys;F4(o,r,n)};pe.setRsaPublicKey=pe.rsa.setPublicKey=function(t,e){var r={n:t,e};return r.encrypt=function(n,i,s){if(typeof i=="string"?i=i.toUpperCase():i===void 0&&(i="RSAES-PKCS1-V1_5"),i==="RSAES-PKCS1-V1_5")i={encode:function(a,c,u){return Hy(a,c,2).getBytes()}};else if(i==="RSA-OAEP"||i==="RSAES-OAEP")i={encode:function(a,c){return de.pkcs1.encode_rsa_oaep(c,a,s)}};else if(["RAW","NONE","NULL",null].indexOf(i)!==-1)i={encode:function(a){return a}};else if(typeof i=="string")throw new Error('Unsupported encryption scheme: "'+i+'".');var o=i.encode(n,r,!0);return pe.rsa.encrypt(o,r,!0)},r.verify=function(n,i,s){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),s==="RSASSA-PKCS1-V1_5"?s={verify:function(a,c){c=_c(c,r,!0);var u=D.fromDer(c);return a===u.value[1].value}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(a,c){return c=_c(c,r,!0),a===c}});var o=pe.rsa.decrypt(i,r,!0,!1);return s.verify(n,o,r.n.bitLength())},r};pe.setRsaPrivateKey=pe.rsa.setPrivateKey=function(t,e,r,n,i,s,o,a){var c={n:t,e,d:r,p:n,q:i,dP:s,dQ:o,qInv:a};return c.decrypt=function(u,l,f){typeof l=="string"?l=l.toUpperCase():l===void 0&&(l="RSAES-PKCS1-V1_5");var h=pe.rsa.decrypt(u,c,!1,!1);if(l==="RSAES-PKCS1-V1_5")l={decode:_c};else if(l==="RSA-OAEP"||l==="RSAES-OAEP")l={decode:function(p,d){return de.pkcs1.decode_rsa_oaep(d,p,f)}};else if(["RAW","NONE","NULL",null].indexOf(l)!==-1)l={decode:function(p){return p}};else throw new Error('Unsupported encryption scheme: "'+l+'".');return l.decode(h,c,!1)},c.sign=function(u,l){var f=!1;typeof l=="string"&&(l=l.toUpperCase()),l===void 0||l==="RSASSA-PKCS1-V1_5"?(l={encode:M4},f=1):(l==="NONE"||l==="NULL"||l===null)&&(l={encode:function(){return u}},f=1);var h=l.encode(u,c.n.bitLength());return pe.rsa.encrypt(h,c,f)},c};pe.wrapRsaPrivateKey=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,D.integerToDer(0).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(pe.oids.rsaEncryption).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,"")]),D.create(D.Class.UNIVERSAL,D.Type.OCTETSTRING,!1,D.toDer(t).getBytes())])};pe.privateKeyFromAsn1=function(t){var e={},r=[];if(D.validate(t,L4,e,r)&&(t=D.fromDer(de.util.createBuffer(e.privateKey))),e={},r=[],!D.validate(t,k4,e,r)){var n=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw n.errors=r,n}var i,s,o,a,c,u,l,f;return i=de.util.createBuffer(e.privateKeyModulus).toHex(),s=de.util.createBuffer(e.privateKeyPublicExponent).toHex(),o=de.util.createBuffer(e.privateKeyPrivateExponent).toHex(),a=de.util.createBuffer(e.privateKeyPrime1).toHex(),c=de.util.createBuffer(e.privateKeyPrime2).toHex(),u=de.util.createBuffer(e.privateKeyExponent1).toHex(),l=de.util.createBuffer(e.privateKeyExponent2).toHex(),f=de.util.createBuffer(e.privateKeyCoefficient).toHex(),pe.setRsaPrivateKey(new Se(i,16),new Se(s,16),new Se(o,16),new Se(a,16),new Se(c,16),new Se(u,16),new Se(l,16),new Se(f,16))};pe.privateKeyToAsn1=pe.privateKeyToRSAPrivateKey=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,D.integerToDer(0).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.n)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.e)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.d)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.p)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.q)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.dP)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.dQ)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.qInv))])};pe.publicKeyFromAsn1=function(t){var e={},r=[];if(D.validate(t,U4,e,r)){var n=D.derToOid(e.publicKeyOid);if(n!==pe.oids.rsaEncryption){var i=new Error("Cannot read public key. Unknown OID.");throw i.oid=n,i}t=e.rsaPublicKey}if(r=[],!D.validate(t,q4,e,r)){var i=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw i.errors=r,i}var s=de.util.createBuffer(e.publicKeyModulus).toHex(),o=de.util.createBuffer(e.publicKeyExponent).toHex();return pe.setRsaPublicKey(new Se(s,16),new Se(o,16))};pe.publicKeyToAsn1=pe.publicKeyToSubjectPublicKeyInfo=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.OID,!1,D.oidToDer(pe.oids.rsaEncryption).getBytes()),D.create(D.Class.UNIVERSAL,D.Type.NULL,!1,"")]),D.create(D.Class.UNIVERSAL,D.Type.BITSTRING,!1,[pe.publicKeyToRSAPublicKey(t)])])};pe.publicKeyToRSAPublicKey=function(t){return D.create(D.Class.UNIVERSAL,D.Type.SEQUENCE,!0,[D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.n)),D.create(D.Class.UNIVERSAL,D.Type.INTEGER,!1,Qr(t.e))])};function Hy(t,e,r){var n=de.util.createBuffer(),i=Math.ceil(e.n.bitLength()/8);if(t.length>i-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=t.length,s.max=i-11,s}n.putByte(0),n.putByte(r);var o=i-3-t.length,a;if(r===0||r===1){a=r===0?0:255;for(var c=0;c<o;++c)n.putByte(a)}else for(;o>0;){for(var u=0,l=de.random.getBytes(o),c=0;c<o;++c)a=l.charCodeAt(c),a===0?++u:n.putByte(a);o=u}return n.putByte(0),n.putBytes(t),n}function _c(t,e,r,n){var i=Math.ceil(e.n.bitLength()/8),s=de.util.createBuffer(t),o=s.getByte(),a=s.getByte();if(o!==0||r&&a!==0&&a!==1||!r&&a!=2||r&&a===0&&typeof n=="undefined")throw new Error("Encryption block is invalid.");var c=0;if(a===0){c=i-3-n;for(var u=0;u<c;++u)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(a===1)for(c=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++c}else if(a===2)for(c=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++c}var l=s.getByte();if(l!==0||c!==i-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function F4(t,e,r){typeof e=="function"&&(r=e,e={}),e=e||{};var n={algorithm:{name:e.algorithm||"PRIMEINC",options:{workers:e.workers||2,workLoad:e.workLoad||100,workerScript:e.workerScript}}};"prng"in e&&(n.prng=e.prng),i();function i(){s(t.pBits,function(a,c){if(a)return r(a);if(t.p=c,t.q!==null)return o(a,t.q);s(t.qBits,o)})}function s(a,c){de.prime.generateProbablePrime(a,n,c)}function o(a,c){if(a)return r(a);if(t.q=c,t.p.compareTo(t.q)<0){var u=t.p;t.p=t.q,t.q=u}if(t.p.subtract(Se.ONE).gcd(t.e).compareTo(Se.ONE)!==0){t.p=null,i();return}if(t.q.subtract(Se.ONE).gcd(t.e).compareTo(Se.ONE)!==0){t.q=null,s(t.qBits,o);return}if(t.p1=t.p.subtract(Se.ONE),t.q1=t.q.subtract(Se.ONE),t.phi=t.p1.multiply(t.q1),t.phi.gcd(t.e).compareTo(Se.ONE)!==0){t.p=t.q=null,i();return}if(t.n=t.p.multiply(t.q),t.n.bitLength()!==t.bits){t.q=null,s(t.qBits,o);return}var l=t.e.modInverse(t.phi);t.keys={privateKey:pe.rsa.setPrivateKey(t.n,t.e,l,t.p,t.q,l.mod(t.p1),l.mod(t.q1),t.q.modInverse(t.p)),publicKey:pe.rsa.setPublicKey(t.n,t.e)},r(null,t.keys)}}function Qr(t){var e=t.toString(16);e[0]>="8"&&(e="00"+e);var r=de.util.hexToBytes(e);return r.length>1&&(r.charCodeAt(0)===0&&(r.charCodeAt(1)&128)==0||r.charCodeAt(0)===255&&(r.charCodeAt(1)&128)==128)?r.substr(1):r}function K4(t){return t<=100?27:t<=150?18:t<=200?15:t<=250?12:t<=300?9:t<=350?8:t<=400?7:t<=500?6:t<=600?5:t<=800?4:t<=1250?3:2}function zy(t){return de.util.isNodejs&&typeof Xl[t]=="function"}function Gy(t){return typeof hr.globalScope!="undefined"&&typeof hr.globalScope.crypto=="object"&&typeof hr.globalScope.crypto.subtle=="object"&&typeof hr.globalScope.crypto.subtle[t]=="function"}function Wy(t){return typeof hr.globalScope!="undefined"&&typeof hr.globalScope.msCrypto=="object"&&typeof hr.globalScope.msCrypto.subtle=="object"&&typeof hr.globalScope.msCrypto.subtle[t]=="function"}function Yy(t){for(var e=de.util.hexToBytes(t.toString(16)),r=new Uint8Array(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}});var Zl=w((sU,tg)=>{var te=be();Ss();Kn();hc();Vn();ws();Vl();gc();Si();Cy();jo();$e();typeof Xy=="undefined"&&(Xy=te.jsbn.BigInteger);var Xy,M=te.asn1,me=te.pki=te.pki||{};tg.exports=me.pbe=te.pbe=te.pbe||{};var Ii=me.oids,V4={name:"EncryptedPrivateKeyInfo",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},j4={name:"PBES2Algorithms",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:M.Class.UNIVERSAL,type:M.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},$4={name:"pkcs-12PbeParams",tagClass:M.Class.UNIVERSAL,type:M.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:M.Class.UNIVERSAL,type:M.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:M.Class.UNIVERSAL,type:M.Type.INTEGER,constructed:!1,capture:"iterations"}]};me.encryptPrivateKeyInfo=function(t,e,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var n=te.random.getBytesSync(r.saltSize),i=r.count,s=M.integerToDer(i),o,a,c;if(r.algorithm.indexOf("aes")===0||r.algorithm==="des"){var u,l,f;switch(r.algorithm){case"aes128":o=16,u=16,l=Ii["aes128-CBC"],f=te.aes.createEncryptionCipher;break;case"aes192":o=24,u=16,l=Ii["aes192-CBC"],f=te.aes.createEncryptionCipher;break;case"aes256":o=32,u=16,l=Ii["aes256-CBC"],f=te.aes.createEncryptionCipher;break;case"des":o=8,u=8,l=Ii.desCBC,f=te.des.createEncryptionCipher;break;default:var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var p="hmacWith"+r.prfAlgorithm.toUpperCase(),d=eg(p),g=te.pkcs5.pbkdf2(e,n,i,o,d),m=te.random.getBytesSync(u),x=f(g);x.start(m),x.update(M.toDer(t)),x.finish(),c=x.output.getBytes();var R=H4(n,s,o,p);a=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(Ii.pkcs5PBES2).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(Ii.pkcs5PBKDF2).getBytes()),R]),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(l).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,m)])])])}else if(r.algorithm==="3des"){o=24;var L=new te.util.ByteBuffer(n),g=me.pbe.generatePkcs12Key(e,L,1,i,o),m=me.pbe.generatePkcs12Key(e,L,2,i,o),x=te.des.createEncryptionCipher(g);x.start(m),x.update(M.toDer(t)),x.finish(),c=x.output.getBytes(),a=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(Ii["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,n),M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,s.getBytes())])])}else{var h=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw h.algorithm=r.algorithm,h}var H=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[a,M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,c)]);return H};me.decryptPrivateKeyInfo=function(t,e){var r=null,n={},i=[];if(!M.validate(t,V4,n,i)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=M.derToOid(n.encryptionOid),a=me.pbe.getCipher(o,n.encryptionParams,e),c=te.util.createBuffer(n.encryptedData);return a.update(c),a.finish()&&(r=M.fromDer(a.output)),r};me.encryptedPrivateKeyToPem=function(t,e){var r={type:"ENCRYPTED PRIVATE KEY",body:M.toDer(t).getBytes()};return te.pem.encode(r,{maxline:e})};me.encryptedPrivateKeyFromPem=function(t){var e=te.pem.decode(t)[0];if(e.type!=="ENCRYPTED PRIVATE KEY"){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return M.fromDer(e.body)};me.encryptRsaPrivateKey=function(t,e,r){if(r=r||{},!r.legacy){var n=me.wrapRsaPrivateKey(me.privateKeyToAsn1(t));return n=me.encryptPrivateKeyInfo(n,e,r),me.encryptedPrivateKeyToPem(n)}var i,s,o,a;switch(r.algorithm){case"aes128":i="AES-128-CBC",o=16,s=te.random.getBytesSync(16),a=te.aes.createEncryptionCipher;break;case"aes192":i="AES-192-CBC",o=24,s=te.random.getBytesSync(16),a=te.aes.createEncryptionCipher;break;case"aes256":i="AES-256-CBC",o=32,s=te.random.getBytesSync(16),a=te.aes.createEncryptionCipher;break;case"3des":i="DES-EDE3-CBC",o=24,s=te.random.getBytesSync(8),a=te.des.createEncryptionCipher;break;case"des":i="DES-CBC",o=8,s=te.random.getBytesSync(8),a=te.des.createEncryptionCipher;break;default:var c=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw c.algorithm=r.algorithm,c}var u=te.pbe.opensslDeriveBytes(e,s.substr(0,8),o),l=a(u);l.start(s),l.update(M.toDer(me.privateKeyToAsn1(t))),l.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:i,parameters:te.util.bytesToHex(s).toUpperCase()},body:l.output.getBytes()};return te.pem.encode(f)};me.decryptRsaPrivateKey=function(t,e){var r=null,n=te.pem.decode(t)[0];if(n.type!=="ENCRYPTED PRIVATE KEY"&&n.type!=="PRIVATE KEY"&&n.type!=="RSA PRIVATE KEY"){var i=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw i.headerType=i,i}if(n.procType&&n.procType.type==="ENCRYPTED"){var s,o;switch(n.dekInfo.algorithm){case"DES-CBC":s=8,o=te.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,o=te.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,o=te.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,o=te.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,o=te.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,o=function(f){return te.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,o=function(f){return te.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,o=function(f){return te.rc2.createDecryptionCipher(f,128)};break;default:var i=new Error('Could not decrypt private key; unsupported encryption algorithm "'+n.dekInfo.algorithm+'".');throw i.algorithm=n.dekInfo.algorithm,i}var a=te.util.hexToBytes(n.dekInfo.parameters),c=te.pbe.opensslDeriveBytes(e,a.substr(0,8),s),u=o(c);if(u.start(a),u.update(te.util.createBuffer(n.body)),u.finish())r=u.output.getBytes();else return r}else r=n.body;return n.type==="ENCRYPTED PRIVATE KEY"?r=me.decryptPrivateKeyInfo(M.fromDer(r),e):r=M.fromDer(r),r!==null&&(r=me.privateKeyFromAsn1(r)),r};me.pbe.generatePkcs12Key=function(t,e,r,n,i,s){var o,a;if(typeof s=="undefined"||s===null){if(!("sha1"in te.md))throw new Error('"sha1" hash algorithm unavailable.');s=te.md.sha1.create()}var c=s.digestLength,u=s.blockLength,l=new te.util.ByteBuffer,f=new te.util.ByteBuffer;if(t!=null){for(a=0;a<t.length;a++)f.putInt16(t.charCodeAt(a));f.putInt16(0)}var h=f.length(),p=e.length(),d=new te.util.ByteBuffer;d.fillWithByte(r,u);var g=u*Math.ceil(p/u),m=new te.util.ByteBuffer;for(a=0;a<g;a++)m.putByte(e.at(a%p));var x=u*Math.ceil(h/u),R=new te.util.ByteBuffer;for(a=0;a<x;a++)R.putByte(f.at(a%h));var L=m;L.putBuffer(R);for(var H=Math.ceil(i/c),q=1;q<=H;q++){var k=new te.util.ByteBuffer;k.putBytes(d.bytes()),k.putBytes(L.bytes());for(var J=0;J<n;J++)s.start(),s.update(k.getBytes()),k=s.digest();var ie=new te.util.ByteBuffer;for(a=0;a<u;a++)ie.putByte(k.at(a%c));var j=Math.ceil(p/u)+Math.ceil(h/u),we=new te.util.ByteBuffer;for(o=0;o<j;o++){var le=new te.util.ByteBuffer(L.getBytes(u)),ye=511;for(a=ie.length()-1;a>=0;a--)ye=ye>>8,ye+=ie.at(a)+le.at(a),le.setAt(a,ye&255);we.putBuffer(le)}L=we,l.putBuffer(k)}return l.truncate(l.length()-i),l};me.pbe.getCipher=function(t,e,r){switch(t){case me.oids.pkcs5PBES2:return me.pbe.getCipherForPBES2(t,e,r);case me.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case me.oids["pbewithSHAAnd40BitRC2-CBC"]:return me.pbe.getCipherForPKCS12PBE(t,e,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=t,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}};me.pbe.getCipherForPBES2=function(t,e,r){var n={},i=[];if(!M.validate(e,j4,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}if(t=M.derToOid(n.kdfOid),t!==me.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=t,s.supportedOids=["pkcs5PBKDF2"],s}if(t=M.derToOid(n.encOid),t!==me.oids["aes128-CBC"]&&t!==me.oids["aes192-CBC"]&&t!==me.oids["aes256-CBC"]&&t!==me.oids["des-EDE3-CBC"]&&t!==me.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=t,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var o=n.kdfSalt,a=te.util.createBuffer(n.kdfIterationCount);a=a.getInt(a.length()<<3);var c,u;switch(me.oids[t]){case"aes128-CBC":c=16,u=te.aes.createDecryptionCipher;break;case"aes192-CBC":c=24,u=te.aes.createDecryptionCipher;break;case"aes256-CBC":c=32,u=te.aes.createDecryptionCipher;break;case"des-EDE3-CBC":c=24,u=te.des.createDecryptionCipher;break;case"desCBC":c=8,u=te.des.createDecryptionCipher;break}var l=Jy(n.prfOid),f=te.pkcs5.pbkdf2(r,o,a,c,l),h=n.encIv,p=u(f);return p.start(h),p};me.pbe.getCipherForPKCS12PBE=function(t,e,r){var n={},i=[];if(!M.validate(e,$4,n,i)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=i,s}var o=te.util.createBuffer(n.salt),a=te.util.createBuffer(n.iterations);a=a.getInt(a.length()<<3);var c,u,l;switch(t){case me.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,l=te.des.startDecrypting;break;case me.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,l=function(g,m){var x=te.rc2.createDecryptionCipher(g,40);return x.start(m,null),x};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=t,s}var f=Jy(n.prfOid),h=me.pbe.generatePkcs12Key(r,o,1,a,c,f);f.start();var p=me.pbe.generatePkcs12Key(r,o,2,a,u,f);return l(h,p)};me.pbe.opensslDeriveBytes=function(t,e,r,n){if(typeof n=="undefined"||n===null){if(!("md5"in te.md))throw new Error('"md5" hash algorithm unavailable.');n=te.md.md5.create()}e===null&&(e="");for(var i=[Zy(n,t+e)],s=16,o=1;s<r;++o,s+=16)i.push(Zy(n,i[o-1]+t+e));return i.join("").substr(0,r)};function Zy(t,e){return t.start().update(e).digest().getBytes()}function Jy(t){var e;if(!t)e="hmacWithSHA1";else if(e=me.oids[M.derToOid(t)],!e){var r=new Error("Unsupported PRF OID.");throw r.oid=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}return eg(e)}function eg(t){var e=te.md;switch(t){case"hmacWithSHA224":e=te.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":t=t.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=t,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!e||!(t in e))throw new Error("Unknown hash algorithm: "+t);return e[t].create()}function H4(t,e,r,n){var i=M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OCTETSTRING,!1,t),M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,e.getBytes())]);return n!=="hmacWithSHA1"&&i.value.push(M.create(M.Class.UNIVERSAL,M.Type.INTEGER,!1,te.util.hexToBytes(r.toString(16))),M.create(M.Class.UNIVERSAL,M.Type.SEQUENCE,!0,[M.create(M.Class.UNIVERSAL,M.Type.OID,!1,M.oidToDer(me.oids[n]).getBytes()),M.create(M.Class.UNIVERSAL,M.Type.NULL,!1,"")])),i}});var Jl={};gt(Jl,{identity:()=>z4});var z4,rg=xe(()=>{Kr();Pn();z4=Ya({prefix:"\0",name:"identity",encode:t=>L0(t),decode:t=>D0(t)})});var ef={};gt(ef,{base2:()=>G4});var G4,ng=xe(()=>{Kr();G4=ct({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})});var tf={};gt(tf,{base8:()=>W4});var W4,ig=xe(()=>{Kr();W4=ct({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})});var rf={};gt(rf,{base10:()=>Y4});var Y4,sg=xe(()=>{Kr();Y4=On({prefix:"9",name:"base10",alphabet:"0123456789"})});var nf,og,sf=xe(()=>{mi();nf=({name:t,code:e,encode:r})=>new og(t,e,r),og=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Nn(this.code,r):r.then(n=>Nn(this.code,n))}else throw Error("Unknown type, must be binary type")}}});var Hn={};gt(Hn,{sha256:()=>Q4,sha512:()=>X4});var cg,Q4,X4,Ti=xe(()=>{sf();cg=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Q4=nf({name:"sha2-256",code:18,encode:cg("SHA-256")}),X4=nf({name:"sha2-512",code:19,encode:cg("SHA-512")})});var $o={};gt($o,{identity:()=>eB});var ug,Z4,lg,J4,eB,xc=xe(()=>{Pn();mi();ug=0,Z4="identity",lg=dn,J4=t=>Nn(ug,lg(t)),eB={code:ug,name:Z4,encode:lg,digest:J4}});var fg=xe(()=>{Pn()});var gU,mU,hg=xe(()=>{gU=new TextEncoder,mU=new TextDecoder});var dg=xe(()=>{vs();Wa();Pn();sf();mi()});var of,wU,pg=xe(()=>{rg();ng();ig();sg();gl();bi();yl();Ln();Lo();Ti();xc();fg();hg();dg();of={...Jl,...ef,...tf,...rf,...Ja,...vi,...Za,...Dn,...bs},wU={...Hn,...$o}});function yg(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var gg,af,nB,Sc,cf=xe(()=>{pg();gg=yg("utf8","u",t=>{let e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),af=yg("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),nB={utf8:gg,"utf-8":gg,hex:of.base16,latin1:af,ascii:af,binary:af,...of},Sc=nB});var Nt={};gt(Nt,{fromString:()=>uf});function uf(t,e="utf8"){let r=Sc[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}var It=xe(()=>{cf()});var zn={};gt(zn,{concat:()=>iB});function iB(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));let r=new Uint8Array(e),n=0;for(let i of t)r.set(i,n),n+=i.length;return r}var Gn=xe(()=>{});var Ho=w(mg=>{"use strict";mg.get=(t=globalThis)=>{let e=t.crypto;if(!e||!e.subtle)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p-crypto/blob/master/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}});var lf=w((IU,bg)=>{"use strict";var{concat:sB}=(Gn(),zn),{fromString:vg}=(It(),Nt),oB=Ho();function aB({algorithm:t="AES-GCM",nonceLength:e=12,keyLength:r=16,digest:n="SHA-256",saltLength:i=16,iterations:s=32767}={}){let o=oB.get();r*=8;async function a(u,l){let f=o.getRandomValues(new Uint8Array(i)),h=o.getRandomValues(new Uint8Array(e)),p={name:t,iv:h},d={name:"PBKDF2",salt:f,iterations:s,hash:{name:n}},g=await o.subtle.importKey("raw",vg(l),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),m=await o.subtle.deriveKey(d,g,{name:t,length:r},!0,["encrypt"]),x=await o.subtle.encrypt(p,m,u);return sB([f,p.iv,new Uint8Array(x)])}async function c(u,l){let f=u.slice(0,i),h=u.slice(i,i+e),p=u.slice(i+e),d={name:t,iv:h},g={name:"PBKDF2",salt:f,iterations:s,hash:{name:n}},m=await o.subtle.importKey("raw",vg(l),{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),x=await o.subtle.deriveKey(g,m,{name:t,length:r},!0,["decrypt"]),R=await o.subtle.decrypt(d,x,p);return new Uint8Array(R)}return{encrypt:a,decrypt:c}}bg.exports={create:aB}});var wg=w((TU,Eg)=>{"use strict";var{base64:cB}=(Lo(),bs),uB=lf();Eg.exports={import:async function(t,e){let r=cB.decode(t);return await uB.create().decrypt(r,e)}}});var dr={};gt(dr,{equals:()=>lB});function lB(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var pr=xe(()=>{});var Ot={};gt(Ot,{toString:()=>ff});function ff(t,e="utf8"){let r=Sc[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var Tt=xe(()=>{cf()});var pf=w((BU,Ag)=>{var Ye=be();Vn();$e();var zo=Ag.exports=Ye.sha512=Ye.sha512||{};Ye.md.sha512=Ye.md.algorithms.sha512=zo;var _g=Ye.sha384=Ye.sha512.sha384=Ye.sha512.sha384||{};_g.create=function(){return zo.create("SHA-384")};Ye.md.sha384=Ye.md.algorithms.sha384=_g;Ye.sha512.sha256=Ye.sha512.sha256||{create:function(){return zo.create("SHA-512/256")}};Ye.md["sha512/256"]=Ye.md.algorithms["sha512/256"]=Ye.sha512.sha256;Ye.sha512.sha224=Ye.sha512.sha224||{create:function(){return zo.create("SHA-512/224")}};Ye.md["sha512/224"]=Ye.md.algorithms["sha512/224"]=Ye.sha512.sha224;zo.create=function(t){if(xg||fB(),typeof t=="undefined"&&(t="SHA-512"),!(t in Ri))throw new Error("Invalid SHA-512 algorithm: "+t);for(var e=Ri[t],r=null,n=Ye.util.createBuffer(),i=new Array(80),s=0;s<80;++s)i[s]=new Array(2);var o=64;switch(t){case"SHA-384":o=48;break;case"SHA-512/256":o=32;break;case"SHA-512/224":o=28;break}var a={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:o,messageLength:0,fullMessageLength:null,messageLengthSize:16};return a.start=function(){a.messageLength=0,a.fullMessageLength=a.messageLength128=[];for(var c=a.messageLengthSize/4,u=0;u<c;++u)a.fullMessageLength.push(0);n=Ye.util.createBuffer(),r=new Array(e.length);for(var u=0;u<e.length;++u)r[u]=e[u].slice(0);return a},a.start(),a.update=function(c,u){u==="utf8"&&(c=Ye.util.encodeUtf8(c));var l=c.length;a.messageLength+=l,l=[l/4294967296>>>0,l>>>0];for(var f=a.fullMessageLength.length-1;f>=0;--f)a.fullMessageLength[f]+=l[1],l[1]=l[0]+(a.fullMessageLength[f]/4294967296>>>0),a.fullMessageLength[f]=a.fullMessageLength[f]>>>0,l[0]=l[1]/4294967296>>>0;return n.putBytes(c),Sg(r,i,n),(n.read>2048||n.length()===0)&&n.compact(),a},a.digest=function(){var c=Ye.util.createBuffer();c.putBytes(n.bytes());var u=a.fullMessageLength[a.fullMessageLength.length-1]+a.messageLengthSize,l=u&a.blockLength-1;c.putBytes(hf.substr(0,a.blockLength-l));for(var f,h,p=a.fullMessageLength[0]*8,d=0;d<a.fullMessageLength.length-1;++d)f=a.fullMessageLength[d+1]*8,h=f/4294967296>>>0,p+=h,c.putInt32(p>>>0),p=f>>>0;c.putInt32(p);for(var g=new Array(r.length),d=0;d<r.length;++d)g[d]=r[d].slice(0);Sg(g,i,c);var m=Ye.util.createBuffer(),x;t==="SHA-512"?x=g.length:t==="SHA-384"?x=g.length-2:x=g.length-4;for(var d=0;d<x;++d)m.putInt32(g[d][0]),(d!==x-1||t!=="SHA-512/224")&&m.putInt32(g[d][1]);return m},a};var hf=null,xg=!1,df=null,Ri=null;function fB(){hf=String.fromCharCode(128),hf+=Ye.util.fillString(String.fromCharCode(0),128),df=[[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]],Ri={},Ri["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Ri["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Ri["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Ri["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],xg=!0}function Sg(t,e,r){for(var n,i,s,o,a,c,u,l,f,h,p,d,g,m,x,R,L,H,q,k,J,ie,j,we,le,ye,nt,it,Ie,Me,ne,tr,Wt,fn,Yt,hn=r.length();hn>=128;){for(Ie=0;Ie<16;++Ie)e[Ie][0]=r.getInt32()>>>0,e[Ie][1]=r.getInt32()>>>0;for(;Ie<80;++Ie)tr=e[Ie-2],Me=tr[0],ne=tr[1],n=((Me>>>19|ne<<13)^(ne>>>29|Me<<3)^Me>>>6)>>>0,i=((Me<<13|ne>>>19)^(ne<<3|Me>>>29)^(Me<<26|ne>>>6))>>>0,fn=e[Ie-15],Me=fn[0],ne=fn[1],s=((Me>>>1|ne<<31)^(Me>>>8|ne<<24)^Me>>>7)>>>0,o=((Me<<31|ne>>>1)^(Me<<24|ne>>>8)^(Me<<25|ne>>>7))>>>0,Wt=e[Ie-7],Yt=e[Ie-16],ne=i+Wt[1]+o+Yt[1],e[Ie][0]=n+Wt[0]+s+Yt[0]+(ne/4294967296>>>0)>>>0,e[Ie][1]=ne>>>0;for(g=t[0][0],m=t[0][1],x=t[1][0],R=t[1][1],L=t[2][0],H=t[2][1],q=t[3][0],k=t[3][1],J=t[4][0],ie=t[4][1],j=t[5][0],we=t[5][1],le=t[6][0],ye=t[6][1],nt=t[7][0],it=t[7][1],Ie=0;Ie<80;++Ie)u=((J>>>14|ie<<18)^(J>>>18|ie<<14)^(ie>>>9|J<<23))>>>0,l=((J<<18|ie>>>14)^(J<<14|ie>>>18)^(ie<<23|J>>>9))>>>0,f=(le^J&(j^le))>>>0,h=(ye^ie&(we^ye))>>>0,a=((g>>>28|m<<4)^(m>>>2|g<<30)^(m>>>7|g<<25))>>>0,c=((g<<4|m>>>28)^(m<<30|g>>>2)^(m<<25|g>>>7))>>>0,p=(g&x|L&(g^x))>>>0,d=(m&R|H&(m^R))>>>0,ne=it+l+h+df[Ie][1]+e[Ie][1],n=nt+u+f+df[Ie][0]+e[Ie][0]+(ne/4294967296>>>0)>>>0,i=ne>>>0,ne=c+d,s=a+p+(ne/4294967296>>>0)>>>0,o=ne>>>0,nt=le,it=ye,le=j,ye=we,j=J,we=ie,ne=k+i,J=q+n+(ne/4294967296>>>0)>>>0,ie=ne>>>0,q=L,k=H,L=x,H=R,x=g,R=m,ne=i+o,g=n+s+(ne/4294967296>>>0)>>>0,m=ne>>>0;ne=t[0][1]+m,t[0][0]=t[0][0]+g+(ne/4294967296>>>0)>>>0,t[0][1]=ne>>>0,ne=t[1][1]+R,t[1][0]=t[1][0]+x+(ne/4294967296>>>0)>>>0,t[1][1]=ne>>>0,ne=t[2][1]+H,t[2][0]=t[2][0]+L+(ne/4294967296>>>0)>>>0,t[2][1]=ne>>>0,ne=t[3][1]+k,t[3][0]=t[3][0]+q+(ne/4294967296>>>0)>>>0,t[3][1]=ne>>>0,ne=t[4][1]+ie,t[4][0]=t[4][0]+J+(ne/4294967296>>>0)>>>0,t[4][1]=ne>>>0,ne=t[5][1]+we,t[5][0]=t[5][0]+j+(ne/4294967296>>>0)>>>0,t[5][1]=ne>>>0,ne=t[6][1]+ye,t[6][0]=t[6][0]+le+(ne/4294967296>>>0)>>>0,t[6][1]=ne>>>0,ne=t[7][1]+it,t[7][0]=t[7][0]+nt+(ne/4294967296>>>0)>>>0,t[7][1]=ne>>>0,hn-=128}}});var Ig=w((PU,Cg)=>{"use strict";var Ac=65536;function hB(t){let e=new Uint8Array(t),r=0;if(t>0)if(t>Ac)for(;r<t;)r+Ac>t?(crypto.getRandomValues(e.subarray(r,r+(t-r))),r+=t-r):(crypto.getRandomValues(e.subarray(r,r+Ac)),r+=Ac);else crypto.getRandomValues(e);return e}Cg.exports=hB});var Cc=w((NU,Tg)=>{"use strict";var dB=Ig(),pB=he();Tg.exports=function(t){if(isNaN(t)||t<=0)throw pB(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return dB(t)}});var Ic=w(Go=>{"use strict";$e();Ec();var yB=be(),{fromString:gB}=(It(),Nt),{toString:Rg}=(Tt(),Ot),{concat:Bg}=(Gn(),zn);Go.bigIntegerToUintBase64url=(t,e)=>{let r=Uint8Array.from(t.abs().toByteArray());if(r=r[0]===0?r.slice(1):r,e!=null){if(r.length>e)throw new Error("byte array longer than desired length");r=Bg([new Uint8Array(e-r.length),r])}return Rg(r,"base64url")};Go.base64urlToBigInteger=t=>{let e=Go.base64urlToBuffer(t);return new yB.jsbn.BigInteger(Rg(e,"base16"),16)};Go.base64urlToBuffer=(t,e)=>{let r=gB(t,"base64urlpad");if(e!=null){if(r.length>e)throw new Error("byte array longer than desired length");r=Bg([new Uint8Array(e-r.length),r])}return r}});var Og=w(Wo=>{"use strict";Kn();jo();var Wn=be(),{bigIntegerToUintBase64url:Xr,base64urlToBigInteger:Zr}=Ic(),{fromString:Pg}=(It(),Nt),{toString:Ng}=(Tt(),Ot);Wo.pkcs1ToJwk=function(t){let e=Wn.asn1.fromDer(Ng(t,"ascii")),r=Wn.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Xr(r.n),e:Xr(r.e),d:Xr(r.d),p:Xr(r.p),q:Xr(r.q),dp:Xr(r.dP),dq:Xr(r.dQ),qi:Xr(r.qInv),alg:"RS256",kid:"2011-04-29"}};Wo.jwkToPkcs1=function(t){let e=Wn.pki.privateKeyToAsn1({n:Zr(t.n),e:Zr(t.e),d:Zr(t.d),p:Zr(t.p),q:Zr(t.q),dP:Zr(t.dp),dQ:Zr(t.dq),qInv:Zr(t.qi)});return Pg(Wn.asn1.toDer(e).getBytes(),"ascii")};Wo.pkixToJwk=function(t){let e=Wn.asn1.fromDer(Ng(t,"ascii")),r=Wn.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Xr(r.n),e:Xr(r.e),alg:"RS256",kid:"2011-04-29"}};Wo.jwkToPkix=function(t){let e=Wn.pki.publicKeyToAsn1({n:Zr(t.n),e:Zr(t.e)});return Pg(Wn.asn1.toDer(e).getBytes(),"ascii")}});var qg=w((LU,kg)=>{"use strict";jo();var Dg=be(),{base64urlToBigInteger:mB}=Ic();function Lg(t,e){return e.map(r=>mB(t[r]))}function vB(t){return Dg.pki.setRsaPrivateKey(...Lg(t,["n","e","d","p","q","dp","dq","qi"]))}function bB(t){return Dg.pki.setRsaPublicKey(...Lg(t,["n","e"]))}kg.exports={jwk2pub:bB,jwk2priv:vB}});var Fg=w(bn=>{"use strict";var vn=Ho(),EB=Cc(),{toString:wB}=(Tt(),Ot),{fromString:_B}=(It(),Nt);bn.utils=Og();bn.generateKey=async function(t){let e=await vn.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:t,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Ug(e);return{privateKey:r[0],publicKey:r[1]}};bn.unmarshalPrivateKey=async function(t){let r=[await vn.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await xB(t)],n=await Ug({privateKey:r[0],publicKey:r[1]});return{privateKey:n[0],publicKey:n[1]}};bn.getRandomValues=EB;bn.hashAndSign=async function(t,e){let r=await vn.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await vn.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,Uint8Array.from(e));return new Uint8Array(n,n.byteOffset,n.byteLength)};bn.hashAndVerify=async function(t,e,r){let n=await vn.get().subtle.importKey("jwk",t,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return vn.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,r)};function Ug(t){return Promise.all([vn.get().subtle.exportKey("jwk",t.privateKey),vn.get().subtle.exportKey("jwk",t.publicKey)])}function xB(t){return vn.get().subtle.importKey("jwk",{kty:t.kty,n:t.n,e:t.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}var{jwk2pub:SB,jwk2priv:AB}=qg();function Mg(t,e,r,n){let i=e?SB(t):AB(t),s=wB(Uint8Array.from(r),"ascii"),o=n(s,i);return _B(o,"ascii")}bn.encrypt=function(t,e){return Mg(t,!0,e,(r,n)=>n.encrypt(r))};bn.decrypt=function(t,e){return Mg(t,!1,e,(r,n)=>n.decrypt(r))}});var Tc=w((qU,Kg)=>{"use strict";var{base64:CB}=(Lo(),bs),IB=lf();Kg.exports={export:async function(t,e){let n=await IB.create().encrypt(t,e);return CB.encode(n)}}});var zg=w((UU,Hg)=>{"use strict";var{sha256:Vg}=(Ti(),Hn),jg=he(),{equals:$g}=(pr(),dr),{toString:TB}=(Tt(),Ot);pf();var Rc=be(),yr=Fg(),Bc=sc(),RB=Tc(),Pc=class{constructor(e){this._key=e}async verify(e,r){return yr.hashAndVerify(this._key,r,e)}marshal(){return yr.utils.jwkToPkix(this._key)}get bytes(){return Bc.PublicKey.encode({Type:Bc.KeyType.RSA,Data:this.marshal()}).finish()}encrypt(e){return yr.encrypt(this._key,e)}equals(e){return $g(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Vg.digest(this.bytes);return e}},Yo=class{constructor(e,r){this._key=e,this._publicKey=r}genSecret(){return yr.getRandomValues(16)}async sign(e){return yr.hashAndSign(this._key,e)}get public(){if(!this._publicKey)throw jg(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Pc(this._publicKey)}decrypt(e){return yr.decrypt(this._key,e)}marshal(){return yr.utils.jwkToPkcs1(this._key)}get bytes(){return Bc.PrivateKey.encode({Type:Bc.KeyType.RSA,Data:this.marshal()}).finish()}equals(e){return $g(this.bytes,e.bytes)}async hash(){let{bytes:e}=await Vg.digest(this.bytes);return e}async id(){let e=await this.public.hash();return TB(e,"base58btc")}async export(e,r="pkcs-8"){if(r==="pkcs-8"){let n=new Rc.util.ByteBuffer(this.marshal()),i=Rc.asn1.fromDer(n),s=Rc.pki.privateKeyFromAsn1(i),o={algorithm:"aes256",count:1e4,saltSize:128/8,prfAlgorithm:"sha512"};return Rc.pki.encryptRsaPrivateKey(s,e,o)}else{if(r==="libp2p-key")return RB.export(this.bytes,e);throw jg(new Error(`export format '${r}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}};async function BB(t){let e=yr.utils.pkcs1ToJwk(t),r=await yr.unmarshalPrivateKey(e);return new Yo(r.privateKey,r.publicKey)}function PB(t){let e=yr.utils.pkixToJwk(t);return new Pc(e)}async function NB(t){let e=await yr.unmarshalPrivateKey(t);return new Yo(e.privateKey,e.publicKey)}async function OB(t){let e=await yr.generateKey(t);return new Yo(e.privateKey,e.publicKey)}Hg.exports={RsaPublicKey:Pc,RsaPrivateKey:Yo,unmarshalRsaPublicKey:PB,unmarshalRsaPrivateKey:BB,generateKeyPair:OB,fromJwk:NB}});var em=w(qe=>{"use strict";var DB=qe&&qe.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(qe,"__esModule",{value:!0});qe.utils=qe.curve25519=qe.getSharedSecret=qe.verify=qe.sign=qe.getPublicKey=qe.Signature=qe.Point=qe.ExtendedPoint=qe.CURVE=void 0;var LB=DB(As()),dt=BigInt(0),_e=BigInt(1),Dt=BigInt(2),Gg=BigInt(255),st={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:Dt**Gg-BigInt(19),n:Dt**BigInt(252)+BigInt("27742317777372353535851937790883648493"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")};qe.CURVE=st;var Qo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),MU=BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),kB=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),qB=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),UB=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),MB=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),Ve=class{constructor(e,r,n,i){this.x=e,this.y=r,this.z=n,this.t=i}static fromAffine(e){if(!(e instanceof Ze))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(Ze.ZERO)?Ve.ZERO:new Ve(e.x,e.y,_e,K(e.x*e.y))}static toAffineBatch(e){let r=VB(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(r[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}static fromRistrettoHash(e){e=En(e),Pi(64,e);let r=mf(e.slice(0,32)),n=this.calcElligatorRistrettoMap(r),i=mf(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return n.add(s)}static calcElligatorRistrettoMap(e){let{d:r}=st,n=K(Qo*e*e),i=K((n+_e)*UB),s=BigInt(-1),o=K((s-r*n)*K(n+r)),{isValid:a,value:c}=bf(i,o),u=K(c*e);Yn(u)||(u=K(-u)),a||(c=u),a||(s=n);let l=K(s*(n-_e)*MB-o),f=c*c,h=K((c+c)*o),p=K(l*kB),d=K(_e-f),g=K(_e+f);return new Ve(K(h*g),K(d*p),K(p*g),K(h*d))}static fromRistrettoBytes(e){e=En(e),Pi(32,e);let{a:r,d:n}=st,i="ExtendedPoint.fromRistrettoBytes: Cannot convert bytes to Ristretto Point",s=mf(e);if(!jB(Xo(s,32),e)||Yn(s))throw new Error(i);let o=K(s*s),a=K(_e+r*o),c=K(_e-r*o),u=K(a*a),l=K(c*c),f=K(r*n*u-l),{isValid:h,value:p}=Xg(K(f*l)),d=K(p*c),g=K(p*d*f),m=K((s+s)*d);Yn(m)&&(m=K(-m));let x=K(a*g),R=K(m*x);if(!h||Yn(R)||x===dt)throw new Error(i);return new Ve(m,x,_e,R)}toRistrettoBytes(){let{x:e,y:r,z:n,t:i}=this,s=K(K(n+r)*K(n-r)),o=K(e*r),{value:a}=Xg(K(s*o**Dt)),c=K(a*s),u=K(a*o),l=K(c*u*i),f;if(Yn(i*l)){let p=K(r*Qo),d=K(e*Qo);e=p,r=d,f=K(c*qB)}else f=u;Yn(e*l)&&(r=K(-r));let h=K((n-r)*f);return Yn(h)&&(h=K(-h)),Xo(h,32)}equals(e){let r=this,n=e;return K(r.t*n.z)===K(n.t*r.z)}negate(){return new Ve(K(-this.x),this.y,this.z,K(-this.t))}double(){let e=this.x,r=this.y,n=this.z,{a:i}=st,s=K(e**Dt),o=K(r**Dt),a=K(Dt*n**Dt),c=K(i*s),u=K((e+r)**Dt-s-o),l=K(c+o),f=K(l-a),h=K(c-o),p=K(u*f),d=K(l*h),g=K(u*h),m=K(f*l);return new Ve(p,d,m,g)}add(e){let r=this.x,n=this.y,i=this.z,s=this.t,o=e.x,a=e.y,c=e.z,u=e.t,l=K((n-r)*(a+o)),f=K((n+r)*(a-o)),h=K(f-l);if(h===dt)return this.double();let p=K(i*Dt*u),d=K(s*Dt*c),g=K(d+p),m=K(f+l),x=K(d-p),R=K(g*h),L=K(m*x),H=K(g*x),q=K(h*m);return new Ve(R,L,q,H)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let r=Rs(e),n=Ve.ZERO;if(this.equals(n)||r===_e)return this;let i=n,s=this;for(;r>dt;)r&_e&&(i=i.add(s)),s=s.double(),r>>=_e;return i}precomputeWindow(e){let r=256/e+1,n=[],i=this,s=i;for(let o=0;o<r;o++){s=i,n.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,r){!r&&this.equals(Ve.BASE)&&(r=Ze.BASE);let n=r&&r._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=r&&yf.get(r);i||(i=this.precomputeWindow(n),r&&n!==1&&(i=Ve.normalizeZ(i),yf.set(r,i)));let s=Ve.ZERO,o=Ve.ZERO,a=256/n+1,c=2**(n-1),u=BigInt(2**n-1),l=2**n,f=BigInt(n);for(let h=0;h<a;h++){let p=h*c,d=Number(e&u);if(e>>=f,d>c&&(d-=l,e+=_e),d===0){let g=i[p];h%2&&(g=g.negate()),o=o.add(g)}else{let g=i[p+Math.abs(d)-1];d<0&&(g=g.negate()),s=s.add(g)}}return[s,o]}multiply(e,r){let n=Rs(e);return Ve.normalizeZ(this.wNAF(n,r))[0]}toAffine(e=vf(this.z)){let r=K(this.x*e),n=K(this.y*e);return new Ze(r,n)}};qe.ExtendedPoint=Ve;Ve.BASE=new Ve(st.Gx,st.Gy,_e,K(st.Gx*st.Gy));Ve.ZERO=new Ve(dt,_e,_e,dt);var yf=new WeakMap,Ze=class{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,yf.delete(this)}static fromHex(e){let{d:r,P:n}=st,i=En(e);Pi(32,i);let s=i.slice();s[31]=i[31]&~128;let o=Ts(s);if(o>=n)throw new Error("Point.fromHex expects hex <= Fp");let a=K(o*o),c=K(a-_e),u=K(r*a+_e),{isValid:l,value:f}=bf(c,u);if(!l)throw new Error("Point.fromHex: invalid y coordinate");let h=(f&_e)===_e;return(i[31]&128)!=0!==h&&(f=K(-f)),new Ze(f,o)}static async fromPrivateKey(e){return(await Zo(e)).point}toRawBytes(){let e=Xo(this.y,32);return e[31]|=this.x&_e?128:0,e}toHex(){return gf(this.toRawBytes())}toX25519(){let{y:e}=this;return K((_e+e)*vf(_e-e))}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Ze(K(-this.x),this.y)}add(e){return Ve.fromAffine(this).add(Ve.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ve.fromAffine(this).multiply(e,this).toAffine()}};qe.Point=Ze;Ze.BASE=new Ze(st.Gx,st.Gy);Ze.ZERO=new Ze(dt,_e);var Bi=class{constructor(e,r){if(this.r=e,!(e instanceof Ze))throw new Error("Expected Point instance");this.s=Rs(r)}static fromHex(e){let r=En(e);Pi(64,r);let n=Ze.fromHex(r.slice(0,32)),i=Ts(r.slice(32,64));return new Bi(n,i)}toRawBytes(){let e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Xo(this.s,32),32),e}toHex(){return gf(this.toRawBytes())}};qe.Signature=Bi;function FB(...t){if(!t.every(n=>n instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(t.length===1)return t[0];let e=t.reduce((n,i)=>n+i.length,0),r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}var KB=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function gf(t){let e="";for(let r=0;r<t.length;r++)e+=KB[t[r]];return e}function Wg(t){if(typeof t!="string")throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){let n=r*2,i=t.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s))throw new Error("Invalid byte sequence");e[r]=s}return e}function Yg(t,e){let r=t.toString(16).padStart(e*2,"0");return Wg(r)}function Xo(t,e){return Yg(t,e).reverse()}function Yn(t){return(K(t)&_e)===_e}function Ts(t){if(!(t instanceof Uint8Array))throw new Error(`bytesToNumberLE: expected Uint8Array, got ${t}`);let e=dt,r=BigInt(8);for(let n=0;n<t.length;n++)e+=BigInt(t[n])<<r*BigInt(n);return e}function mf(t){return K(Ts(t)&Dt**Gg-_e)}function K(t,e=st.P){let r=t%e;return r>=dt?r:e+r}function vf(t,e=st.P){if(t===dt||e<=dt)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=K(t,e),n=e,i=dt,s=_e,o=_e,a=dt;for(;r!==dt;){let u=n/r,l=n%r,f=i-o*u,h=s-a*u;n=r,r=l,i=o,s=a,o=f,a=h}if(n!==_e)throw new Error("invert: does not exist");return K(i,e)}function VB(t,e=st.P){let r=t.length,n=new Array(r),i=_e;for(let s=0;s<r;s++)t[s]!==dt&&(n[s]=i,i=K(i*t[s],e));i=vf(i,e);for(let s=r-1;s>=0;s--){if(t[s]===dt)continue;let o=K(i*t[s],e);t[s]=K(i*n[s],e),i=o}return t}function Or(t,e){let{P:r}=st,n=t;for(;e-- >dt;)n*=n,n%=r;return n}function Qg(t){let{P:e}=st,r=BigInt(5),n=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),c=t*t%e*t%e,u=Or(c,Dt)*c%e,l=Or(u,_e)*t%e,f=Or(l,r)*l%e,h=Or(f,n)*f%e,p=Or(h,i)*h%e,d=Or(p,s)*p%e,g=Or(d,o)*d%e,m=Or(g,o)*d%e,x=Or(m,n)*f%e;return{pow_p_5_8:Or(x,Dt)*t%e,b2:c}}function bf(t,e){let r=K(e*e*e),n=K(r*r*e),i=Qg(t*n).pow_p_5_8,s=K(t*r*i),o=K(e*s*s),a=s,c=K(s*Qo),u=o===t,l=o===K(-t),f=o===K(-t*Qo);return u&&(s=a),(l||f)&&(s=c),Yn(s)&&(s=K(-s)),{isValid:u||l,value:s}}function Xg(t){return bf(_e,t)}async function Ef(...t){let e=FB(...t),r=await qe.utils.sha512(e),n=Ts(r);return K(n,st.n)}function jB(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function En(t){return t instanceof Uint8Array?Uint8Array.from(t):Wg(t)}function Pi(t,e){if(e.length!==t)throw new Error(`Expected ${t} bytes`)}function Rs(t,e=st.n){if(typeof t=="number"&&t>0&&Number.isSafeInteger(t))return BigInt(t);if(typeof t=="bigint"&&dt<t&&t<e)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}function $B(t){let e=typeof t=="bigint"||typeof t=="number"?Yg(Rs(t,Dt**BigInt(256)),32):En(t);return Pi(32,e),e}function Zg(t){return t=En(t),Pi(32,t),t[0]&=248,t[31]&=127,t[31]|=64,Ts(t)}async function Zo(t){let e=await qe.utils.sha512($B(t)),r=e.slice(0,32),n=e.slice(32,64),i=K(Zg(r),st.n),s=Ze.BASE.multiply(i),o=s.toRawBytes();return{head:r,prefix:n,scalar:i,point:s,pubBytes:o}}async function HB(t){return(await Zo(t)).pubBytes}qe.getPublicKey=HB;async function zB(t,e){let r=En(t),{prefix:n,scalar:i,pubBytes:s}=await Zo(e),o=await Ef(n,r),a=Ze.BASE.multiply(o),c=await Ef(a.toRawBytes(),s,r),u=K(o+c*i,st.n);return new Bi(a,u).toRawBytes()}qe.sign=zB;async function GB(t,e,r){e=En(e),r instanceof Ze||(r=Ze.fromHex(r)),t instanceof Bi||(t=Bi.fromHex(t));let n=Ve.BASE.multiply(t.s),i=await Ef(t.r.toRawBytes(),r.toRawBytes(),e),s=Ve.fromAffine(r).multiplyUnsafe(i);return Ve.fromAffine(t.r).add(s).subtract(n).multiplyUnsafe(st.h).equals(Ve.ZERO)}qe.verify=GB;async function WB(t,e){let{scalar:r}=await Zo(t),n=Ze.fromHex(e).toX25519();return Jg(r,n)}qe.getSharedSecret=WB;Ze.BASE._setWindowSize(8);function Nc(t,e,r){let n=K(t*(e-r));return e=K(e-n),r=K(r+n),[e,r]}function YB(t,e){let{P:r,n}=st,i=Rs(t,r),s=Rs(e,r),o=BigInt(121665),a=i,c=_e,u=dt,l=i,f=_e,h=dt,p;for(let x=BigInt(255-1);x>=dt;x--){let R=s>>x&_e;h^=R,p=Nc(h,c,l),c=p[0],l=p[1],p=Nc(h,u,f),u=p[0],f=p[1],h=R;let L=K(c+u),H=K(L*L),q=K(c-u),k=K(q*q),J=K(H-k),ie=K(l+f),j=K(l-f),we=K(j*L),le=K(ie*q);l=K(K(we+le)**Dt),f=K(a*K(we-le)**Dt),c=K(H*k),u=K(J*(H+K(o*J)))}p=Nc(h,c,l),c=p[0],l=p[1],p=Nc(h,u,f),u=p[0],f=p[1];let{pow_p_5_8:d,b2:g}=Qg(u),m=K(Or(d,BigInt(3))*g);return K(c*m)}function QB(t){return Xo(K(t,st.P),32)}function Jg(t,e){let r=YB(t,e);if(r===dt)throw new Error("Invalid private or public key received");return QB(r)}function XB(t){let e=En(t);return Pi(32,e),e[31]&=127,Ts(e)}qe.curve25519={BASE_POINT_U:"0900000000000000000000000000000000000000000000000000000000000000",scalarMult(t,e){let r=XB(e),n=Zg(t);return Jg(r,n)},scalarMultBase(t){return qe.curve25519.scalarMult(t,qe.curve25519.BASE_POINT_U)}};var Qn={node:LB.default,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};qe.utils={TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],bytesToHex:gf,getExtendedPublicKey:Zo,randomBytes:(t=32)=>{if(Qn.web)return Qn.web.getRandomValues(new Uint8Array(t));if(Qn.node){let{randomBytes:e}=Qn.node;return new Uint8Array(e(t).buffer)}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>qe.utils.randomBytes(32),sha512:async t=>{if(Qn.web){let e=await Qn.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(e)}else{if(Qn.node)return Uint8Array.from(Qn.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")}},precompute(t=8,e=Ze.BASE){let r=e.equals(Ze.BASE)?e:new Ze(e.x,e.y);return r._setWindowSize(t),r.multiply(_e),r}}});var rm=w(Xn=>{"use strict";var Jo=em(),ZB=32,JB=64,Oc=32;Xn.publicKeyLength=ZB;Xn.privateKeyLength=JB;Xn.generateKey=async function(){let t=Jo.utils.randomPrivateKey(),e=await Jo.getPublicKey(t);return{privateKey:tm(t,e),publicKey:e}};Xn.generateKeyFromSeed=async function(t){if(t.length!==Oc)throw new TypeError('"seed" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=t,r=await Jo.getPublicKey(e);return{privateKey:tm(e,r),publicKey:r}};Xn.hashAndSign=function(t,e){let r=t.slice(0,Oc);return Jo.sign(e,r)};Xn.hashAndVerify=function(t,e,r){return Jo.verify(e,r,t)};function tm(t,e){let r=new Uint8Array(Xn.privateKeyLength);for(let n=0;n<Oc;n++)r[n]=t[n],r[Oc+n]=e[n];return r}});var am=w((VU,om)=>{"use strict";var nm=he(),{equals:im}=(pr(),dr),{sha256:sm}=(Ti(),Hn),{base58btc:e8}=(Ln(),Dn),{identity:t8}=(xc(),$o),Lt=rm(),Dc=sc(),r8=Tc(),Lc=class{constructor(e){this._key=Ps(e,Lt.publicKeyLength)}async verify(e,r){return Lt.hashAndVerify(this._key,r,e)}marshal(){return this._key}get bytes(){return Dc.PublicKey.encode({Type:Dc.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return im(this.bytes,e.bytes)}async hash(){let{bytes:e}=await sm.digest(this.bytes);return e}},Bs=class{constructor(e,r){this._key=Ps(e,Lt.privateKeyLength),this._publicKey=Ps(r,Lt.publicKeyLength)}async sign(e){return Lt.hashAndSign(this._key,e)}get public(){return new Lc(this._publicKey)}marshal(){return this._key}get bytes(){return Dc.PrivateKey.encode({Type:Dc.KeyType.Ed25519,Data:this.marshal()}).finish()}equals(e){return im(this.bytes,e.bytes)}async hash(){let{bytes:e}=await sm.digest(this.bytes);return e}async id(){let e=await t8.digest(this.public.bytes);return e8.encode(e.bytes).substring(1)}async export(e,r="libp2p-key"){if(r==="libp2p-key")return r8.export(this.bytes,e);throw nm(new Error(`export format '${r}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}};function n8(t){if(t.length>Lt.privateKeyLength){t=Ps(t,Lt.privateKeyLength+Lt.publicKeyLength);let n=t.slice(0,Lt.privateKeyLength),i=t.slice(Lt.privateKeyLength,t.length);return new Bs(n,i)}t=Ps(t,Lt.privateKeyLength);let e=t.slice(0,Lt.privateKeyLength),r=t.slice(Lt.publicKeyLength);return new Bs(e,r)}function i8(t){return t=Ps(t,Lt.publicKeyLength),new Lc(t)}async function s8(){let{privateKey:t,publicKey:e}=await Lt.generateKey();return new Bs(t,e)}async function o8(t){let{privateKey:e,publicKey:r}=await Lt.generateKeyFromSeed(t);return new Bs(e,r)}function Ps(t,e){if(t=Uint8Array.from(t||[]),t.length!==e)throw nm(new Error(`Key must be a Uint8Array of length ${e}, got ${t.length}`),"ERR_INVALID_KEY_TYPE");return t}om.exports={Ed25519PublicKey:Lc,Ed25519PrivateKey:Bs,unmarshalEd25519PrivateKey:n8,unmarshalEd25519PublicKey:i8,generateKeyPair:s8,generateKeyPairFromSeed:o8}});var Am=w(Ae=>{"use strict";var a8=Ae&&Ae.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(Ae,"__esModule",{value:!0});Ae.utils=Ae.schnorr=Ae.verify=Ae.signSync=Ae.sign=Ae.getSharedSecret=Ae.recoverPublicKey=Ae.getPublicKey=Ae.Signature=Ae.Point=Ae.CURVE=void 0;var c8=a8(As()),Pe=BigInt(0),ut=BigInt(1),pt=BigInt(2),ea=BigInt(3),u8=BigInt(8),wf=pt**BigInt(256),ze={a:Pe,b:BigInt(7),P:wf-pt**BigInt(32)-BigInt(977),n:wf-BigInt("432420386565659656852420866394968145599"),h:ut,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")};Ae.CURVE=ze;function cm(t){let{a:e,b:r}=ze,n=re(t*t),i=re(n*t);return re(i+e*t+r)}var kc=ze.a===Pe,Ne=class{constructor(e,r,n){this.x=e,this.y=r,this.z=n}static fromAffine(e){if(!(e instanceof De))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Ne(e.x,e.y,ut)}static toAffineBatch(e){let r=d8(e.map(n=>n.z));return e.map((n,i)=>n.toAffine(r[i]))}static normalizeZ(e){return Ne.toAffineBatch(e).map(Ne.fromAffine)}equals(e){let r=this,n=e,i=re(r.z*r.z),s=re(r.z*i),o=re(n.z*n.z),a=re(n.z*o);return re(r.x*o)===re(i*n.x)&&re(r.y*a)===re(s*n.y)}negate(){return new Ne(this.x,re(-this.y),this.z)}double(){let e=this.x,r=this.y,n=this.z,i=re(e**pt),s=re(r**pt),o=re(s**pt),a=re(pt*(re(re((e+s)**pt))-i-o)),c=re(ea*i),u=re(c**pt),l=re(u-pt*a),f=re(c*(a-l)-u8*o),h=re(pt*r*n);return new Ne(l,f,h)}add(e){if(!(e instanceof Ne))throw new TypeError("JacobianPoint#add: expected JacobianPoint");let r=this.x,n=this.y,i=this.z,s=e.x,o=e.y,a=e.z;if(s===Pe||o===Pe)return this;if(r===Pe||n===Pe)return e;let c=re(i**pt),u=re(a**pt),l=re(r*u),f=re(s*c),h=re(n*a*u),p=re(re(o*i)*c),d=re(f-l),g=re(p-h);if(d===Pe)return g===Pe?this.double():Ne.ZERO;let m=re(d**pt),x=re(d*m),R=re(l*m),L=re(g**pt-x-pt*R),H=re(g*(R-L)-h*x),q=re(i*a*d);return new Ne(L,H,q)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){let r=hm(e);if(!kc){let l=Ne.ZERO,f=this;for(;r>Pe;)r&ut&&(l=l.add(f)),f=f.double(),r>>=ut;return l}let{k1neg:n,k1:i,k2neg:s,k2:o}=pm(r),a=Ne.ZERO,c=Ne.ZERO,u=this;for(;i>Pe||o>Pe;)i&ut&&(a=a.add(u)),o&ut&&(c=c.add(u)),u=u.double(),i>>=ut,o>>=ut;return n&&(a=a.negate()),s&&(c=c.negate()),c=new Ne(re(c.x*ze.beta),c.y,c.z),a.add(c)}precomputeWindow(e){let r=kc?128/e+1:256/e+1,n=[],i=this,s=i;for(let o=0;o<r;o++){s=i,n.push(s);for(let a=1;a<2**(e-1);a++)s=s.add(i),n.push(s);i=s.double()}return n}wNAF(e,r){!r&&this.equals(Ne.BASE)&&(r=De.BASE);let n=r&&r._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let i=r&&_f.get(r);i||(i=this.precomputeWindow(n),r&&n!==1&&(i=Ne.normalizeZ(i),_f.set(r,i)));let s=Ne.ZERO,o=Ne.ZERO,a=kc?128/n+1:256/n+1,c=2**(n-1),u=BigInt(2**n-1),l=2**n,f=BigInt(n);for(let h=0;h<a;h++){let p=h*c,d=Number(e&u);if(e>>=f,d>c&&(d-=l,e+=ut),d===0){let g=i[p];h%2&&(g=g.negate()),o=o.add(g)}else{let g=i[p+Math.abs(d)-1];d<0&&(g=g.negate()),s=s.add(g)}}return{p:s,f:o}}multiply(e,r){let n=hm(e),i,s;if(kc){let{k1neg:o,k1:a,k2neg:c,k2:u}=pm(n),{p:l,f}=this.wNAF(a,r),{p:h,f:p}=this.wNAF(u,r);o&&(l=l.negate()),c&&(h=h.negate()),h=new Ne(re(h.x*ze.beta),h.y,h.z),i=l.add(h),s=f.add(p)}else{let{p:o,f:a}=this.wNAF(n,r);i=o,s=a}return Ne.normalizeZ([i,s])[0]}toAffine(e=ra(this.z)){let r=e**pt,n=re(this.x*r),i=re(this.y*r*e);return new De(n,i)}};Ne.BASE=new Ne(ze.Gx,ze.Gy,ut);Ne.ZERO=new Ne(Pe,ut,Pe);var _f=new WeakMap,De=class{constructor(e,r){this.x=e,this.y=r}_setWindowSize(e){this._WINDOW_SIZE=e,_f.delete(this)}static fromCompressedHex(e){let r=e.length===32,n=gr(r?e:e.slice(1)),i=cm(n),s=h8(i),o=(s&ut)===ut;return r?o&&(s=re(-s)):(e[0]&1)==1!==o&&(s=re(-s)),new De(n,s)}static fromUncompressedHex(e){let r=gr(e.slice(1,33)),n=gr(e.slice(33)),i=new De(r,n);return i.assertValidity(),i}static fromHex(e){let r=_n(e),n=r[0];if(r.length===32||r.length===33&&(n===2||n===3))return this.fromCompressedHex(r);if(r.length===65&&n===4)return this.fromUncompressedHex(r);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r.length}`)}static fromPrivateKey(e){return De.BASE.multiply(na(e))}static fromSignature(e,r,n){e=_n(e);let i=ym(e),{r:s,s:o}=mm(r);if(n!==0&&n!==1)throw new Error("Cannot recover signature: invalid recovery bit");if(i===Pe)throw new Error("Cannot recover signature: msgHash cannot be 0");let a=2+(n&1),c=De.fromHex(`0${a}${wn(s)}`),u=Ne.fromAffine(c).multiplyUnsafe(o),l=Ne.BASE.multiply(i),f=ra(s,ze.n),p=u.subtract(l).multiplyUnsafe(f).toAffine();return p.assertValidity(),p}toRawBytes(e=!1){return Zn(this.toHex(e))}toHex(e=!1){let r=wn(this.x);return e?`${this.y&ut?"03":"02"}${r}`:`04${r}${wn(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){let e="Point is not on elliptic curve",{x:r,y:n}=this;if(!Af(r)||!Af(n))throw new Error(e);let i=re(n*n),s=cm(r);if(re(i-s)!==Pe)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new De(this.x,re(-this.y))}double(){return Ne.fromAffine(this).double().toAffine()}add(e){return Ne.fromAffine(this).add(Ne.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Ne.fromAffine(this).multiply(e,this).toAffine()}};Ae.Point=De;De.BASE=new De(ze.Gx,ze.Gy);De.ZERO=new De(Pe,Pe);function um(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function lm(t){if(t.length<2||t[0]!==2)throw new Error(`Invalid signature integer tag: ${Ns(t)}`);let e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(r[0]===0&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:gr(r),left:t.subarray(e+2)}}function l8(t){if(t.length<2||t[0]!=48)throw new Error(`Invalid signature tag: ${Ns(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");let{data:e,left:r}=lm(t.subarray(2)),{data:n,left:i}=lm(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Ns(i)}`);return{r:e,s:n}}var Jr=class{constructor(e,r){this.r=e,this.s=r,this.assertValidity()}static fromCompact(e){let r=Ni(e),n="Signature.fromCompact";if(typeof e!="string"&&!r)throw new TypeError(`${n}: Expected string or Uint8Array`);let i=r?Ns(e):e;if(i.length!==128)throw new Error(`${n}: Expected 64-byte hex`);return new Jr(qc(i.slice(0,64)),qc(i.slice(64,128)))}static fromDER(e){let r=Ni(e);if(typeof e!="string"&&!r)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");let{r:n,s:i}=l8(r?e:Zn(e));return new Jr(n,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){let{r:e,s:r}=this;if(!Oi(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Oi(r))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){let e=ze.n>>ut;return this.s>e}normalizeS(){return this.hasHighS()?new Jr(this.r,ze.n-this.s):this}toDERRawBytes(e=!1){return Zn(this.toDERHex(e))}toDERHex(e=!1){let r=um(ta(this.s));if(e)return r;let n=um(ta(this.r)),i=ta(n.length/2),s=ta(r.length/2);return`30${ta(n.length/2+r.length/2+4)}02${i}${n}02${s}${r}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Zn(this.toCompactHex())}toCompactHex(){return wn(this.r)+wn(this.s)}};Ae.Signature=Jr;function xf(...t){if(!t.every(Ni))throw new Error("Uint8Array list expected");if(t.length===1)return t[0];let e=t.reduce((n,i)=>n+i.length,0),r=new Uint8Array(e);for(let n=0,i=0;n<t.length;n++){let s=t[n];r.set(s,i),i+=s.length}return r}function Ni(t){return t instanceof Uint8Array}var f8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Ns(t){if(!Ni(t))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=f8[t[r]];return e}function wn(t){if(t>wf)throw new Error("Expected number < 2^256");return t.toString(16).padStart(64,"0")}function fm(t){return Zn(wn(t))}function ta(t){let e=t.toString(16);return e.length&1?`0${e}`:e}function qc(t){if(typeof t!="string")throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function Zn(t){if(typeof t!="string")throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);let e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){let n=r*2,i=t.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s))throw new Error("Invalid byte sequence");e[r]=s}return e}function gr(t){return qc(Ns(t))}function _n(t){return Ni(t)?Uint8Array.from(t):Zn(t)}function hm(t){if(typeof t=="number"&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if(typeof t=="bigint"&&Oi(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function re(t,e=ze.P){let r=t%e;return r>=0?r:e+r}function mr(t,e){let{P:r}=ze,n=t;for(;e-- >Pe;)n*=n,n%=r;return n}function h8(t){let{P:e}=ze,r=BigInt(6),n=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),c=t*t*t%e,u=c*c*t%e,l=mr(u,ea)*u%e,f=mr(l,ea)*u%e,h=mr(f,pt)*c%e,p=mr(h,n)*h%e,d=mr(p,i)*p%e,g=mr(d,o)*d%e,m=mr(g,a)*g%e,x=mr(m,o)*d%e,R=mr(x,ea)*u%e,L=mr(R,s)*p%e,H=mr(L,r)*c%e;return mr(H,pt)}function ra(t,e=ze.P){if(t===Pe||e<=Pe)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=re(t,e),n=e,i=Pe,s=ut,o=ut,a=Pe;for(;r!==Pe;){let u=n/r,l=n%r,f=i-o*u,h=s-a*u;n=r,r=l,i=o,s=a,o=f,a=h}if(n!==ut)throw new Error("invert: does not exist");return re(i,e)}function d8(t,e=ze.P){let r=t.length,n=new Array(r),i=ut;for(let s=0;s<r;s++)t[s]!==Pe&&(n[s]=i,i=re(i*t[s],e));i=ra(i,e);for(let s=r-1;s>=0;s--){if(t[s]===Pe)continue;let o=re(i*t[s],e);t[s]=re(i*n[s],e),i=o}return t}var dm=(t,e)=>(t+e/pt)/e,Uc=pt**BigInt(128);function pm(t){let{n:e}=ze,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ut*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=dm(s*t,e),a=dm(-n*t,e),c=re(t-o*r-a*i,e),u=re(-o*n-a*s,e),l=c>Uc,f=u>Uc;if(l&&(c=e-c),f&&(u=e-u),c>Uc||u>Uc)throw new Error("splitScalarEndo: Endomorphism failed");return{k1neg:l,k1:c,k2neg:f,k2:u}}function ym(t){let{n:e}=ze,n=t.length*8-256,i=gr(t);return n>0&&(i=i>>BigInt(n)),i>=e&&(i-=e),i}var Sf=class{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Ae.utils.hmacSha256(this.k,...e)}hmacSync(...e){if(typeof Ae.utils.hmacSha256Sync!="function")throw new Error("utils.hmacSha256Sync is undefined, you need to set it");let r=Ae.utils.hmacSha256Sync(this.k,...e);if(r instanceof Promise)throw new Error("To use sync sign(), ensure utils.hmacSha256 is sync");return r}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(e=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),e.length!==0&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(e=new Uint8Array){this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),e.length!==0&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){return this.incr(),this.v=await this.hmac(this.v),this.v}generateSync(){return this.incr(),this.v=this.hmacSync(this.v),this.v}};function Oi(t){return Pe<t&&t<ze.n}function Af(t){return Pe<t&&t<ze.P}function gm(t,e,r){let n=gr(t);if(!Oi(n))return;let{n:i}=ze,s=De.BASE.multiply(n),o=re(s.x,i);if(o===Pe)return;let a=re(ra(n,i)*re(e+r*o,i),i);if(a===Pe)return;let c=new Jr(o,a),u=(s.x===c.r?0:2)|Number(s.y&ut);return{sig:c,recovery:u}}function na(t){let e;if(typeof t=="bigint")e=t;else if(typeof t=="number"&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if(typeof t=="string"){if(t.length!==64)throw new Error("Expected 32 bytes of private key");e=qc(t)}else if(Ni(t)){if(t.length!==32)throw new Error("Expected 32 bytes of private key");e=gr(t)}else throw new TypeError("Expected valid private key");if(!Oi(e))throw new Error("Expected private key: 0 < key < n");return e}function Cf(t){return t instanceof De?(t.assertValidity(),t):De.fromHex(t)}function mm(t){if(t instanceof Jr)return t.assertValidity(),t;try{return Jr.fromDER(t)}catch(e){return Jr.fromCompact(t)}}function p8(t,e=!1){return De.fromPrivateKey(t).toRawBytes(e)}Ae.getPublicKey=p8;function y8(t,e,r){return De.fromSignature(t,e,r).toRawBytes()}Ae.recoverPublicKey=y8;function vm(t){let e=Ni(t),r=typeof t=="string",n=(e||r)&&t.length;return e?n===33||n===65:r?n===66||n===130:t instanceof De}function g8(t,e,r=!1){if(vm(t))throw new TypeError("getSharedSecret: first arg must be private key");if(!vm(e))throw new TypeError("getSharedSecret: second arg must be public key");let n=Cf(e);return n.assertValidity(),n.multiply(na(t)).toRawBytes(r)}Ae.getSharedSecret=g8;function bm(t){let e=t.length>32?t.slice(0,32):t;return gr(e)}function m8(t){let e=bm(t),r=re(e,ze.n);return Em(r<Pe?e:r)}function Em(t){if(typeof t!="bigint")throw new Error("Expected bigint");let e=wn(t);return Zn(e)}function wm(t,e,r){if(t==null)throw new Error(`sign: expected valid message hash, not "${t}"`);let n=_n(t),i=na(e),s=[Em(i),m8(n)];if(r!=null){r===!0&&(r=Ae.utils.randomBytes(32));let c=_n(r);if(c.length!==32)throw new Error("sign: Expected 32 bytes of extra data");s.push(c)}let o=xf(...s),a=bm(n);return{seed:o,m:a,d:i}}function _m(t,e){let{sig:r,recovery:n}=t,{canonical:i,der:s,recovered:o}=Object.assign({canonical:!0,der:!0},e);i&&r.hasHighS()&&(r=r.normalizeS(),n^=1);let a=s?r.toDERRawBytes():r.toCompactRawBytes();return o?[a,n]:a}async function v8(t,e,r={}){let{seed:n,m:i,d:s}=wm(t,e,r.extraEntropy),o,a=new Sf;for(await a.reseed(n);!(o=gm(await a.generate(),i,s));)await a.reseed();return _m(o,r)}Ae.sign=v8;function b8(t,e,r={}){let{seed:n,m:i,d:s}=wm(t,e,r.extraEntropy),o,a=new Sf;for(a.reseedSync(n);!(o=gm(a.generateSync(),i,s));)a.reseedSync();return _m(o,r)}Ae.signSync=b8;var E8={strict:!0};function w8(t,e,r,n=E8){let i;try{i=mm(t),e=_n(e)}catch(x){return!1}let{r:s,s:o}=i;if(n.strict&&i.hasHighS())return!1;let a=ym(e);if(a===Pe)return!1;let c;try{c=Ne.fromAffine(Cf(r))}catch(x){return!1}let{n:u}=ze,l=ra(o,u),f=re(a*l,u),h=re(s*l,u),p=Ne.BASE.multiply(f),d=c.multiplyUnsafe(h),g=p.add(d).toAffine();return re(g.x,u)===s}Ae.verify=w8;async function If(t,...e){let r=new Uint8Array(t.split("").map(s=>s.charCodeAt(0))),n=await Ae.utils.sha256(r),i=await Ae.utils.sha256(xf(n,n,...e));return gr(i)}async function xm(t,e,r){let n=fm(t),i=await If("BIP0340/challenge",n,e.toRawX(),r);return re(i,ze.n)}function Tf(t){return re(t.y,pt)===Pe}var Di=class{constructor(e,r){if(this.r=e,this.s=r,!Af(e)||!Oi(r))throw new Error("Invalid signature")}static fromHex(e){let r=_n(e);if(r.length!==64)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${r.length}`);let n=gr(r.slice(0,32)),i=gr(r.slice(32,64));return new Di(n,i)}toHex(){return wn(this.r)+wn(this.s)}toRawBytes(){return Zn(this.toHex())}};function _8(t){return De.fromPrivateKey(t).toRawX()}async function x8(t,e,r=Ae.utils.randomBytes()){if(t==null)throw new TypeError(`sign: Expected valid message, not "${t}"`);let{n}=ze,i=_n(t),s=na(e),o=_n(r);if(o.length!==32)throw new TypeError("sign: Expected 32 bytes of aux randomness");let a=De.fromPrivateKey(s),c=Tf(a)?s:n-s,u=await If("BIP0340/aux",o),l=c^u,f=await If("BIP0340/nonce",fm(l),a.toRawX(),i),h=re(f,n);if(h===Pe)throw new Error("sign: Creation of signature failed. k is zero");let p=De.fromPrivateKey(h),d=Tf(p)?h:n-h,g=await xm(p.x,a,i),m=new Di(p.x,re(d+g*c,n));if(!await Sm(m.toRawBytes(),i,a.toRawX()))throw new Error("sign: Invalid signature produced");return m.toRawBytes()}async function Sm(t,e,r){let n=t instanceof Di?t:Di.fromHex(t),i=_n(e),s=Cf(r),o=await xm(n.r,s,i),a=De.fromPrivateKey(n.s),c=s.multiply(o),u=a.subtract(c);return!(u.equals(De.BASE)||!Tf(u)||u.x!==n.r)}Ae.schnorr={Signature:Di,getPublicKey:_8,sign:x8,verify:Sm};De.BASE._setWindowSize(8);var nr={node:c8.default,web:typeof self=="object"&&"crypto"in self?self.crypto:void 0};Ae.utils={isValidPrivateKey(t){try{return na(t),!0}catch(e){return!1}},randomBytes:(t=32)=>{if(nr.web)return nr.web.getRandomValues(new Uint8Array(t));if(nr.node){let{randomBytes:e}=nr.node;return Uint8Array.from(e(t))}else throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>{let t=8;for(;t--;){let e=Ae.utils.randomBytes(32),r=gr(e);if(Oi(r)&&r!==ut)return e}throw new Error("Valid private key was not found in 8 iterations. PRNG is broken")},bytesToHex:Ns,mod:re,sha256:async t=>{if(nr.web){let e=await nr.web.subtle.digest("SHA-256",t.buffer);return new Uint8Array(e)}else if(nr.node){let{createHash:e}=nr.node;return Uint8Array.from(e("sha256").update(t).digest())}else throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(nr.web){let r=await nr.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=xf(...e),i=await nr.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}else if(nr.node){let{createHmac:r}=nr.node,n=r("sha256",t);return e.forEach(i=>n.update(i)),Uint8Array.from(n.digest())}else throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,precompute(t=8,e=De.BASE){let r=e===De.BASE?e:new De(e.x,e.y);return r._setWindowSize(t),r.multiply(ea),r}}});var Tm=w(($U,Im)=>{"use strict";var ia=he(),Jn=Am(),{sha256:Cm}=(Ti(),Hn);Im.exports=()=>{let t=32;function e(){return Jn.utils.randomPrivateKey()}async function r(u,l){let{digest:f}=await Cm.digest(l);try{return await Jn.sign(f,u)}catch(h){throw ia(h,"ERR_INVALID_INPUT")}}async function n(u,l,f){try{let{digest:h}=await Cm.digest(f);return Jn.verify(l,h,u)}catch(h){throw ia(h,"ERR_INVALID_INPUT")}}function i(u){return Jn.Point.fromHex(u).toRawBytes(!0)}function s(u){return Jn.Point.fromHex(u).toRawBytes(!1)}function o(u){try{Jn.getPublicKey(u,!0)}catch(l){throw ia(l,"ERR_INVALID_PRIVATE_KEY")}}function a(u){try{Jn.Point.fromHex(u)}catch(l){throw ia(l,"ERR_INVALID_PUBLIC_KEY")}}function c(u){try{return Jn.getPublicKey(u,!0)}catch(l){throw ia(l,"ERR_INVALID_PRIVATE_KEY")}}return{generateKey:e,privateKeyLength:t,hashAndSign:r,hashAndVerify:n,compressPublicKey:i,decompressPublicKey:s,validatePrivateKey:o,validatePublicKey:a,computePublicKey:c}}});var Nm=w((HU,Pm)=>{"use strict";var{sha256:Rm}=(Ti(),Hn),S8=he(),{equals:Bm}=(pr(),dr),{toString:A8}=(Tt(),Ot),C8=Tc();Pm.exports=(t,e,r)=>{r=r||Tm()();class n{constructor(u){r.validatePublicKey(u),this._key=u}verify(u,l){return r.hashAndVerify(this._key,l,u)}marshal(){return r.compressPublicKey(this._key)}get bytes(){return t.PublicKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(u){return Bm(this.bytes,u.bytes)}async hash(){let{bytes:u}=await Rm.digest(this.bytes);return u}}class i{constructor(u,l){this._key=u,this._publicKey=l||r.computePublicKey(u),r.validatePrivateKey(this._key),r.validatePublicKey(this._publicKey)}sign(u){return r.hashAndSign(this._key,u)}get public(){return new n(this._publicKey)}marshal(){return this._key}get bytes(){return t.PrivateKey.encode({Type:t.KeyType.Secp256k1,Data:this.marshal()}).finish()}equals(u){return Bm(this.bytes,u.bytes)}async hash(){let{bytes:u}=await Rm.digest(this.bytes);return u}async id(){let u=await this.public.hash();return A8(u,"base58btc")}async export(u,l="libp2p-key"){if(l==="libp2p-key")return C8.export(this.bytes,u);throw S8(new Error(`export format '${l}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")}}function s(c){return new i(c)}function o(c){return new n(c)}async function a(){let c=await r.generateKey();return new i(c)}return{Secp256k1PublicKey:n,Secp256k1PrivateKey:i,unmarshalSecp256k1PrivateKey:s,unmarshalSecp256k1PublicKey:o,generateKeyPair:a}}});var Dm=w((zU,Om)=>{"use strict";Om.exports={SHA1:20,SHA256:32,SHA512:64}});var Rf=w(km=>{"use strict";var Lm=Ho(),I8=Dm(),T8={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},R8=async(t,e)=>{let r=await Lm.get().subtle.sign({name:"HMAC"},t,e);return new Uint8Array(r,r.byteOffset,r.byteLength)};km.create=async function(t,e){let r=T8[t],n=await Lm.get().subtle.importKey("raw",e,{name:"HMAC",hash:{name:r}},!1,["sign"]);return{async digest(i){return R8(n,i)},length:I8[t]}}});var Km=w((WU,Fm)=>{"use strict";var qm=he(),{concat:Um}=(Gn(),zn),{fromString:B8}=(It(),Nt),P8=Rf(),Mm={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,cipherKeySize:32}};Fm.exports=async(t,e,r)=>{let n=Mm[t];if(!n){let R=Object.keys(Mm).join(" / ");throw qm(new Error(`unknown cipher type '${t}'. Must be ${R}`),"ERR_INVALID_CIPHER_TYPE")}if(!e)throw qm(new Error("missing hash type"),"ERR_MISSING_HASH_TYPE");let i=n.keySize,s=n.ivSize,o=20,a=B8("key expansion"),c=2*(s+i+o),u=await P8.create(e,r),l=await u.digest(a),f=[],h=0;for(;h<c;){let R=await u.digest(Um([l,a])),L=R.length;h+L>c&&(L=c-h),f.push(R),h+=L,l=await u.digest(l)}let p=c/2,d=Um(f),g=d.slice(0,p),m=d.slice(p,c),x=R=>({iv:R.slice(0,s),cipherKey:R.slice(s,s+i),macKey:R.slice(s+i)});return{k1:x(g),k2:x(m)}}});var jm=w((YU,Vm)=>{"use strict";var N8=he();Vm.exports=function(t,e){if(!t.includes(e)){let r=t.join(" / ");throw N8(new Error(`Unknown curve: ${e}. Must be ${r}`),"ERR_INVALID_CURVE")}}});var Ym=w(Wm=>{"use strict";var O8=he(),sa=Ho(),{base64urlToBuffer:$m}=Ic(),D8=jm(),{toString:Bf}=(Tt(),Ot),{concat:L8}=(Gn(),zn),{equals:k8}=(pr(),dr),Hm={"P-256":256,"P-384":384,"P-521":521};Wm.generateEphmeralKeyPair=async function(t){D8(Object.keys(Hm),t);let e=await sa.get().subtle.generateKey({name:"ECDH",namedCurve:t},!0,["deriveBits"]),r=async(i,s)=>{let o;s?o=await sa.get().subtle.importKey("jwk",U8(t,s),{name:"ECDH",namedCurve:t},!1,["deriveBits"]):o=e.privateKey;let a=[await sa.get().subtle.importKey("jwk",Gm(t,i),{name:"ECDH",namedCurve:t},!1,[]),o],c=await sa.get().subtle.deriveBits({name:"ECDH",namedCurve:t,public:a[0]},a[1],Hm[t]);return new Uint8Array(c,c.byteOffset,c.byteLength)},n=await sa.get().subtle.exportKey("jwk",e.publicKey);return{key:q8(n),genSharedKey:r}};var zm={"P-256":32,"P-384":48,"P-521":66};function q8(t){let e=zm[t.crv];return L8([Uint8Array.from([4]),$m(t.x,e),$m(t.y,e)],1+e*2)}function Gm(t,e){let r=zm[t];if(k8(!e.slice(0,1),Uint8Array.from([4])))throw O8(new Error("Cannot unmarshal public key - invalid key format"),"ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:t,x:Bf(e.slice(1,r+1),"base64url"),y:Bf(e.slice(1+r),"base64url"),ext:!0}}var U8=(t,e)=>({...Gm(t,e.public),d:Bf(e.private,"base64url")})});var Xm=w((XU,Qm)=>{"use strict";var M8=Ym();Qm.exports=async t=>M8.generateEphmeralKeyPair(t)});var Fc=w((ZU,Jm)=>{"use strict";var en=sc();Kn();Zl();var Pf=be(),oa=he(),{fromString:F8}=(It(),Nt),K8=wg(),vr={rsa:zg(),ed25519:am(),secp256k1:Nm()(en,Cc())},Mc={message:"secp256k1 support requires libp2p-crypto-secp256k1 package",code:"ERR_MISSING_PACKAGE"};function Os(t){let e=vr[t.toLowerCase()];if(!e){let r=Object.keys(vr).join(" / ");throw oa(new Error(`invalid or unsupported key type ${t}. Must be ${r}`),"ERR_UNSUPPORTED_KEY_TYPE")}return e}var V8=async(t,e)=>Os(t).generateKeyPair(e),j8=async(t,e,r)=>{let n=Os(t);if(t.toLowerCase()!=="ed25519")throw oa(new Error("Seed key derivation is unimplemented for RSA or secp256k1"),"ERR_UNSUPPORTED_KEY_DERIVATION_TYPE");return n.generateKeyPairFromSeed(e,r)},$8=t=>{let e=en.PublicKey.decode(t),r=e.Data;switch(e.Type){case en.KeyType.RSA:return vr.rsa.unmarshalRsaPublicKey(r);case en.KeyType.Ed25519:return vr.ed25519.unmarshalEd25519PublicKey(r);case en.KeyType.Secp256k1:if(vr.secp256k1)return vr.secp256k1.unmarshalSecp256k1PublicKey(r);throw oa(new Error(Mc.message),Mc.code);default:Os(e.Type)}},H8=(t,e)=>(e=(e||"rsa").toLowerCase(),Os(e),t.bytes),Zm=async t=>{let e=en.PrivateKey.decode(t),r=e.Data;switch(e.Type){case en.KeyType.RSA:return vr.rsa.unmarshalRsaPrivateKey(r);case en.KeyType.Ed25519:return vr.ed25519.unmarshalEd25519PrivateKey(r);case en.KeyType.Secp256k1:if(vr.secp256k1)return vr.secp256k1.unmarshalSecp256k1PrivateKey(r);throw oa(new Error(Mc.message),Mc.code);default:Os(e.Type)}},z8=(t,e)=>(e=(e||"rsa").toLowerCase(),Os(e),t.bytes),G8=async(t,e)=>{try{let i=await K8.import(t,e);return Zm(i)}catch(i){}let r=Pf.pki.decryptRsaPrivateKey(t,e);if(r===null)throw oa(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let n=Pf.asn1.toDer(Pf.pki.privateKeyToAsn1(r));return n=F8(n.getBytes(),"ascii"),vr.rsa.unmarshalRsaPrivateKey(n)};Jm.exports={supportedKeys:vr,keysPBM:en,keyStretcher:Km(),generateEphemeralKeyPair:Xm(),generateKeyPair:V8,generateKeyPairFromSeed:j8,unmarshalPublicKey:$8,marshalPublicKey:H8,unmarshalPrivateKey:Zm,marshalPrivateKey:z8,import:G8}});var ev=w((JU,Nf)=>{"use strict";function W8(t,{className:e,symbolName:r}){let n=Symbol.for(r),i={[e]:class extends t{constructor(...s){super(...s);Object.defineProperty(this,n,{value:!0})}get[Symbol.toStringTag](){return e}}}[e];return i[`is${e}`]=s=>!!(s&&s[n]),i}function Y8(t,{className:e,symbolName:r,withoutNew:n}){let i=Symbol.for(r),s={[e]:function(...o){if(n&&!(this instanceof s))return new s(...o);let a=t.call(this,...o)||this;return a&&!a[i]&&Object.defineProperty(a,i,{value:!0}),a}}[e];return s.prototype=Object.create(t.prototype),s.prototype.constructor=s,Object.defineProperty(s.prototype,Symbol.toStringTag,{get(){return e}}),s[`is${e}`]=o=>!!(o&&o[i]),s}Nf.exports=W8;Nf.exports.proto=Y8});var nv=w((eM,rv)=>{"use strict";var Ds=pn(),tv=Ds.Reader,Q8=Ds.Writer,Et=Ds.util,aa=Ds.roots["libp2p-peer-id"]||(Ds.roots["libp2p-peer-id"]={});aa.PeerIdProto=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.id=Et.newBuffer([]),t.prototype.pubKey=Et.newBuffer([]),t.prototype.privKey=Et.newBuffer([]),t.encode=function(r,n){return n||(n=Q8.create()),n.uint32(10).bytes(r.id),r.pubKey!=null&&Object.hasOwnProperty.call(r,"pubKey")&&n.uint32(18).bytes(r.pubKey),r.privKey!=null&&Object.hasOwnProperty.call(r,"privKey")&&n.uint32(26).bytes(r.privKey),n},t.decode=function(r,n){r instanceof tv||(r=tv.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new aa.PeerIdProto;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.id=r.bytes();break;case 2:s.pubKey=r.bytes();break;case 3:s.privKey=r.bytes();break;default:r.skipType(o&7);break}}if(!s.hasOwnProperty("id"))throw Et.ProtocolError("missing required 'id'",{instance:s});return s},t.fromObject=function(r){if(r instanceof aa.PeerIdProto)return r;var n=new aa.PeerIdProto;return r.id!=null&&(typeof r.id=="string"?Et.base64.decode(r.id,n.id=Et.newBuffer(Et.base64.length(r.id)),0):r.id.length&&(n.id=r.id)),r.pubKey!=null&&(typeof r.pubKey=="string"?Et.base64.decode(r.pubKey,n.pubKey=Et.newBuffer(Et.base64.length(r.pubKey)),0):r.pubKey.length&&(n.pubKey=r.pubKey)),r.privKey!=null&&(typeof r.privKey=="string"?Et.base64.decode(r.privKey,n.privKey=Et.newBuffer(Et.base64.length(r.privKey)),0):r.privKey.length&&(n.privKey=r.privKey)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(n.bytes===String?i.id="":(i.id=[],n.bytes!==Array&&(i.id=Et.newBuffer(i.id))),n.bytes===String?i.pubKey="":(i.pubKey=[],n.bytes!==Array&&(i.pubKey=Et.newBuffer(i.pubKey))),n.bytes===String?i.privKey="":(i.privKey=[],n.bytes!==Array&&(i.privKey=Et.newBuffer(i.privKey)))),r.id!=null&&r.hasOwnProperty("id")&&(i.id=n.bytes===String?Et.base64.encode(r.id,0,r.id.length):n.bytes===Array?Array.prototype.slice.call(r.id):r.id),r.pubKey!=null&&r.hasOwnProperty("pubKey")&&(i.pubKey=n.bytes===String?Et.base64.encode(r.pubKey,0,r.pubKey.length):n.bytes===Array?Array.prototype.slice.call(r.pubKey):r.pubKey),r.privKey!=null&&r.hasOwnProperty("privKey")&&(i.privKey=n.bytes===String?Et.base64.encode(r.privKey,0,r.privKey.length):n.bytes===Array?Array.prototype.slice.call(r.privKey):r.privKey),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,Ds.util.toJSONOptions)},t}();rv.exports=aa});var Rt=w((kt,fv)=>{"use strict";var{CID:Of}=(vs(),Do),X8=(bi(),vi),Z8=(yl(),Za),J8=(Ln(),Dn),eP=(Lo(),bs),{base58btc:Df}=(Ln(),Dn),{base32:tP}=(bi(),vi),{base16:iv}=(gl(),Ja),ca=(mi(),No),tn=Fc(),rP=ev(),{PeerIdProto:sv}=nv(),{equals:Li}=(pr(),dr),{fromString:ua}=(It(),Nt),{toString:nP}=(Tt(),Ot),{identity:Kc}=(xc(),$o),ov={...X8,...Z8,...J8,...eP},iP=Object.keys(ov).reduce((t,e)=>t.or(ov[e]),tP.decoder),sP=112,av=114,cv=class{constructor(e,r,n){if(!(e instanceof Uint8Array))throw new Error("invalid id provided");if(r&&n&&!Li(r.public.bytes,n.bytes))throw new Error("inconsistent arguments");this._id=e,this._idB58String=Df.encode(this.id).substring(1),this._privKey=r,this._pubKey=n}get id(){return this._id}set id(e){throw new Error("Id is immutable")}get privKey(){return this._privKey}set privKey(e){this._privKey=e}get pubKey(){if(this._pubKey)return this._pubKey;if(this._privKey)return this._privKey.public;try{let e=ca.decode(this.id);e.code===Kc.code&&(this._pubKey=tn.unmarshalPublicKey(e.digest))}catch(e){}return this._pubKey}set pubKey(e){this._pubKey=e}marshalPubKey(){if(this.pubKey)return tn.marshalPublicKey(this.pubKey)}marshalPrivKey(){if(this.privKey)return tn.marshalPrivateKey(this.privKey)}marshal(e){return sv.encode({id:this.toBytes(),pubKey:this.marshalPubKey(),privKey:e?null:this.marshalPrivKey()}).finish()}toPrint(){let e=this.toB58String();e.startsWith("Qm")&&(e=e.slice(2));let r=6;return e.length<r&&(r=e.length),"<peer.ID "+e.substr(0,r)+">"}toJSON(){return{id:this.toB58String(),privKey:lv(this.marshalPrivKey()),pubKey:lv(this.marshalPubKey())}}toHexString(){return iv.encode(this.id).substring(1)}toBytes(){return this.id}toB58String(){return this._idB58String}toString(){if(!this._idCIDString){let e=Of.createV1(av,ca.decode(this.id));Object.defineProperty(this,"_idCIDString",{value:e.toString(),enumerable:!1})}return this._idCIDString}equals(e){if(e instanceof Uint8Array)return Li(this.id,e);if(e.id)return Li(this.id,e.id);throw new Error("not valid Id")}isEqual(e){return this.equals(e)}isValid(){return Boolean(this.privKey&&this.privKey.public&&this.privKey.public.bytes&&this.pubKey.bytes instanceof Uint8Array&&Li(this.privKey.public.bytes,this.pubKey.bytes))}hasInlinePublicKey(){try{if(ca.decode(this.id).code===Kc.code)return!0}catch(e){}return!1}},rn=rP(cv,{className:"PeerId",symbolName:"@libp2p/js-peer-id/PeerId"});kt=fv.exports=rn;var la=t=>t.bytes.length<=42?ca.create(Kc.code,t.bytes).bytes:t.hash(),Lf=async(t,e)=>{let r=await la(e);return new rn(r,t,e)};kt.create=async t=>{t=t||{},t.bits=t.bits||2048,t.keyType=t.keyType||"RSA";let e=await tn.generateKeyPair(t.keyType,t.bits);return Lf(e,e.public)};kt.createFromHexString=t=>new rn(iv.decode("f"+t));kt.createFromBytes=t=>{try{let e=Of.decode(t);if(!uv(e))throw new Error("Supplied PeerID CID is invalid");return kt.createFromCID(e)}catch{if(ca.decode(t).code!==Kc.code)throw new Error("Supplied PeerID CID is invalid");return new rn(t)}};kt.createFromB58String=t=>kt.createFromBytes(Df.decode("z"+t));var uv=t=>t.code===av||t.code===sP;kt.createFromCID=t=>{if(t=Of.asCID(t),!t||!uv(t))throw new Error("Supplied PeerID CID is invalid");return new rn(t.multihash.bytes)};kt.createFromPubKey=async t=>{let e=t;if(typeof e=="string"&&(e=ua(t,"base64pad")),!(e instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");let r=await tn.unmarshalPublicKey(e);return Lf(void 0,r)};kt.createFromPrivKey=async t=>{if(typeof t=="string"&&(t=ua(t,"base64pad")),!(t instanceof Uint8Array))throw new Error("Supplied key is neither a base64 string nor a Uint8Array");let e=await tn.unmarshalPrivateKey(t);return Lf(e,e.public)};kt.createFromJSON=async t=>{let e=Df.decode("z"+t.id),r=t.privKey&&ua(t.privKey,"base64pad"),n=t.pubKey&&ua(t.pubKey,"base64pad"),i=n&&await tn.unmarshalPublicKey(n);if(!r)return new rn(e,void 0,i);let s=await tn.unmarshalPrivateKey(r),o=await la(s.public),a;if(i&&(a=await la(i)),i&&!Li(o,a))throw new Error("Public and private key do not match");if(e&&!Li(o,e))throw new Error("Id and private key do not match");return new rn(e,s,i)};kt.createFromProtobuf=async t=>{typeof t=="string"&&(t=ua(t,"base16"));let{id:e,privKey:r,pubKey:n}=sv.decode(t);r=r?await tn.unmarshalPrivateKey(r):!1,n=n?await tn.unmarshalPublicKey(n):!1;let i,s;if(r&&(s=await la(r.public)),n&&(i=await la(n)),r){if(n&&!Li(s,i))throw new Error("Public and private key do not match");return new rn(s,r,r.public)}if(n)return new rn(i,void 0,n);if(e)return new rn(e);throw new Error("Protobuf did not contain any usable key material")};kt.parse=t=>((t.charAt(0)==="1"||t.charAt(0)==="Q")&&(t=`z${t}`),kt.createFromBytes(iP.decode(t)));kt.isPeerId=t=>Boolean(typeof t=="object"&&t._id&&t._idB58String);function lv(t){if(t)return nP(t,"base64pad")}});var qf=w((tM,dv)=>{"use strict";var hv="[a-fA-F\\d:]",ei=t=>t&&t.includeBoundaries?`(?:(?<=\\s|^)(?=${hv})|(?<=${hv})(?=\\s|$))`:"",Dr="(?: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}",mt="[a-fA-F\\d]{1,4}",Vc=`
30
30
  (?:
31
- (?:${gt}:){7}(?:${gt}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
32
- (?:${gt}:){6}(?:${Dr}|:${gt}|:)| // 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
33
- (?:${gt}:){5}(?::${Dr}|(?::${gt}){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
34
- (?:${gt}:){4}(?:(?::${gt}){0,1}:${Dr}|(?::${gt}){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
35
- (?:${gt}:){3}(?:(?::${gt}){0,2}:${Dr}|(?::${gt}){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
36
- (?:${gt}:){2}(?:(?::${gt}){0,3}:${Dr}|(?::${gt}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
37
- (?:${gt}:){1}(?:(?::${gt}){0,4}:${Dr}|(?::${gt}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
38
- (?::(?:(?::${gt}){0,5}:${Dr}|(?::${gt}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
31
+ (?:${mt}:){7}(?:${mt}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
32
+ (?:${mt}:){6}(?:${Dr}|:${mt}|:)| // 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
33
+ (?:${mt}:){5}(?::${Dr}|(?::${mt}){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
34
+ (?:${mt}:){4}(?:(?::${mt}){0,1}:${Dr}|(?::${mt}){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
35
+ (?:${mt}:){3}(?:(?::${mt}){0,2}:${Dr}|(?::${mt}){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
36
+ (?:${mt}:){2}(?:(?::${mt}){0,3}:${Dr}|(?::${mt}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
37
+ (?:${mt}:){1}(?:(?::${mt}){0,4}:${Dr}|(?::${mt}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
38
+ (?::(?:(?::${mt}){0,5}:${Dr}|(?::${mt}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
39
39
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
40
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),B8=new RegExp(`(?:^${Dr}$)|(?:^${Dc}$)`),P8=new RegExp(`^${Dr}$`),N8=new RegExp(`^${Dc}$`),Cf=t=>t&&t.exact?B8:new RegExp(`(?:${Jn(t)}${Dr}${Jn(t)})|(?:${Jn(t)}${Dc}${Jn(t)})`,"g");Cf.v4=t=>t&&t.exact?P8:new RegExp(`${Jn(t)}${Dr}${Jn(t)}`,"g");Cf.v6=t=>t&&t.exact?N8:new RegExp(`${Jn(t)}${Dc}${Jn(t)}`,"g");Zm.exports=Cf});var Rf=w((vU,Jm)=>{"use strict";var Tf=If(),Ps=t=>Tf({exact:!0}).test(t);Ps.v4=t=>Tf.v4({exact:!0}).test(t);Ps.v6=t=>Tf.v6({exact:!0}).test(t);Ps.version=t=>Ps(t)?Ps.v4(t)?4:6:void 0;Jm.exports=Ps});var iv=w((bU,nv)=>{"use strict";var Bf=Rf(),{toString:ev}=(It(),Nt),O8=Bf,Pf=Bf.v4,tv=Bf.v6,rv=function(t,e,r){r=~~r;let n;if(Pf(t))n=e||new Uint8Array(r+4),t.split(/\./g).map(function(i){n[r++]=parseInt(i,10)&255});else if(tv(t)){let i=t.split(":",8),s;for(s=0;s<i.length;s++){let o=Pf(i[s]),a;o&&(a=rv(i[s]),i[s]=ev(a.slice(0,2),"base16")),a&&++s<8&&i.splice(s,0,ev(a.slice(2,4),"base16"))}if(i[0]==="")for(;i.length<8;)i.unshift("0");else if(i[i.length-1]==="")for(;i.length<8;)i.push("0");else if(i.length<8){for(s=0;s<i.length&&i[s]!=="";s++);let o=[s,"1"];for(s=9-i.length;s>0;s--)o.push("0");i.splice.apply(i,o)}for(n=e||new Uint8Array(r+16),s=0;s<i.length;s++){let o=parseInt(i[s],16);n[r++]=o>>8&255,n[r++]=o&255}}if(!n)throw Error("Invalid ip address: "+t);return n},D8=function(t,e,r){e=~~e,r=r||t.length-e;let n=[],i,s=new DataView(t.buffer);if(r===4){for(let o=0;o<r;o++)n.push(t[e+o]);i=n.join(".")}else if(r===16){for(let o=0;o<r;o+=2)n.push(s.getUint16(e+o).toString(16));i=n.join(":"),i=i.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3"),i=i.replace(/:{3,4}/,"::")}return i};nv.exports={isIP:O8,isV4:Pf,isV6:tv,toBytes:rv,toString:D8}});var na=w((EU,ov)=>{"use strict";function er(t){if(typeof t=="number"){if(er.codes[t])return er.codes[t];throw new Error("no protocol with code: "+t)}else if(typeof t=="string"){if(er.names[t])return er.names[t];throw new Error("no protocol with name: "+t)}throw new Error("invalid protocol id type: "+t)}var br=-1;er.lengthPrefixedVarSize=br;er.V=br;er.table=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,br,"ip6zone"],[53,br,"dns","resolvable"],[54,br,"dns4","resolvable"],[55,br,"dns6","resolvable"],[56,br,"dnsaddr","resolvable"],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,br,"unix",!1,"path"],[421,br,"ipfs"],[421,br,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,br,"garlic64"],[460,0,"quic"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,br,"memory"]];er.names={};er.codes={};er.table.map(t=>{let e=sv.apply(null,t);return er.codes[e.code]=e,er.names[e.name]=e,null});er.object=sv;function sv(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:Boolean(n),path:Boolean(i)}}ov.exports=er});var uv=w((wU,cv)=>{cv.exports=Nf;var av=128,L8=127,k8=~L8,q8=Math.pow(2,31);function Nf(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw Nf.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=q8;)e[r++]=t&255|av,t/=128;for(;t&k8;)e[r++]=t&255|av,t>>>=7;return e[r]=t|0,Nf.bytes=r-n+1,e}});var hv=w((_U,fv)=>{fv.exports=Of;var U8=128,lv=127;function Of(t,e){var r=0,e=e||0,n=0,i=e,s,o=t.length;do{if(i>=o||n>49)throw Of.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=n<28?(s&lv)<<n:(s&lv)*Math.pow(2,n),n+=7}while(s>=U8);return Of.bytes=i-e,r}});var pv=w((xU,dv)=>{var M8=Math.pow(2,7),F8=Math.pow(2,14),K8=Math.pow(2,21),V8=Math.pow(2,28),j8=Math.pow(2,35),$8=Math.pow(2,42),H8=Math.pow(2,49),z8=Math.pow(2,56),G8=Math.pow(2,63);dv.exports=function(t){return t<M8?1:t<F8?2:t<K8?3:t<V8?4:t<j8?5:t<$8?6:t<H8?7:t<z8?8:t<G8?9:10}});var Di=w((SU,yv)=>{yv.exports={encode:uv(),decode:hv(),encodingLength:pv()}});var xv=w((AU,_v)=>{"use strict";var Lc=iv(),gv=na(),{CID:W8}=(gs(),Io),{base32:mv}=(vi(),mi),{base58btc:Y8}=(Pn(),Bn),Q8=(gi(),Ao),Ns=Di(),{toString:kc}=(It(),Nt),{fromString:vv}=(Ct(),Pt),{concat:qc}=($n(),jn);_v.exports=ia;function ia(t,e){return e instanceof Uint8Array?ia.toString(t,e):ia.toBytes(t,e)}ia.toString=function(e,r){switch(gv(e).code){case 4:case 41:return X8(r);case 6:case 273:case 33:case 132:return Ev(r).toString();case 53:case 54:case 55:case 56:case 400:case 777:return J8(r);case 421:return tP(r);case 444:return wv(r);case 445:return wv(r);default:return kc(r,"base16")}};ia.toBytes=function(e,r){switch(gv(e).code){case 4:return bv(r);case 41:return bv(r);case 6:case 273:case 33:case 132:return Df(parseInt(r,10));case 53:case 54:case 55:case 56:case 400:case 777:return Z8(r);case 421:return eP(r);case 444:return rP(r);case 445:return nP(r);default:return vv(r,"base16")}};function bv(t){if(!Lc.isIP(t))throw new Error("invalid ip address");return Lc.toBytes(t)}function X8(t){let e=Lc.toString(t);if(!e||!Lc.isIP(e))throw new Error("invalid ip address");return e}function Df(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Ev(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Z8(t){let e=vv(t),r=Uint8Array.from(Ns.encode(e.length));return qc([r,e],r.length+e.length)}function J8(t){let e=Ns.decode(t);if(t=t.slice(Ns.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return kc(t)}function eP(t){let e;t[0]==="Q"||t[0]==="1"?e=Q8.decode(Y8.decode(`z${t}`)).bytes:e=W8.parse(t).multihash.bytes;let r=Uint8Array.from(Ns.encode(e.length));return qc([r,e],r.length+e.length)}function tP(t){let e=Ns.decode(t),r=t.slice(Ns.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return kc(r,"base58btc")}function rP(t){let e=t.split(":");if(e.length!==2)throw new Error("failed to parse onion addr: "+e+" does not contain a port number");if(e[0].length!==16)throw new Error("failed to parse onion addr: "+e[0]+" not a Tor onion address.");let r=mv.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Df(n);return qc([r,i],r.length+i.length)}function nP(t){let e=t.split(":");if(e.length!==2)throw new Error("failed to parse onion addr: "+e+" does not contain a port number");if(e[0].length!==56)throw new Error("failed to parse onion addr: "+e[0]+" not a Tor onion3 address.");let r=mv.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Df(n);return qc([r,i],r.length+i.length)}function wv(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=kc(e,"base32"),i=Ev(r);return n+":"+i}});var Lv=w((CU,Dv)=>{"use strict";var Sv=xv(),Lf=na(),sa=Di(),{concat:Av}=($n(),jn),{toString:iP}=(It(),Nt);Dv.exports={stringToStringTuples:Cv,stringTuplesToString:Iv,tuplesToStringTuples:Rv,stringTuplesToTuples:Tv,bytesToTuples:kf,tuplesToBytes:Bv,bytesToString:sP,stringToBytes:Nv,fromString:oP,fromBytes:Ov,validateBytes:qf,isValidBytes:aP,cleanPath:Uc,ParseError:Uf,protoFromTuple:oa,sizeForAddr:Pv};function Cv(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let i=r[n],s=Lf(i);if(s.size===0){e.push([i]);continue}if(n++,n>=r.length)throw Uf("invalid address: "+t);if(s.path){e.push([i,Uc(r.slice(n).join("/"))]);break}e.push([i,r[n]])}return e}function Iv(t){let e=[];return t.map(r=>{let n=oa(r);return e.push(n.name),r.length>1&&e.push(r[1]),null}),Uc(e.join("/"))}function Tv(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=oa(e);return e.length>1?[r.code,Sv.toBytes(r.code,e[1])]:[r.code]})}function Rv(t){return t.map(e=>{let r=oa(e);return e[1]?[r.code,Sv.toString(r.code,e[1])]:[r.code]})}function Bv(t){return Ov(Av(t.map(e=>{let r=oa(e),n=Uint8Array.from(sa.encode(r.code));return e.length>1&&(n=Av([n,e[1]])),n})))}function Pv(t,e){return t.size>0?t.size/8:t.size===0?0:sa.decode(e)+sa.decode.bytes}function kf(t){let e=[],r=0;for(;r<t.length;){let n=sa.decode(t,r),i=sa.decode.bytes,s=Lf(n),o=Pv(s,t.slice(r+i));if(o===0){e.push([n]),r+=i;continue}let a=t.slice(r+i,r+i+o);if(r+=o+i,r>t.length)throw Uf("Invalid address Uint8Array: "+iP(t,"base16"));e.push([n,a])}return e}function sP(t){let e=kf(t),r=Rv(e);return Iv(r)}function Nv(t){t=Uc(t);let e=Cv(t),r=Tv(e);return Bv(r)}function oP(t){return Nv(t)}function Ov(t){let e=qf(t);if(e)throw e;return Uint8Array.from(t)}function qf(t){try{kf(t)}catch(e){return e}}function aP(t){return qf(t)===void 0}function Uc(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Uf(t){return new Error("Error parsing address: "+t)}function oa(t){return Lf(t[0])}});var kt=w((IU,Uv)=>{"use strict";var Lr=Lv(),Os=na(),kv=Di(),{CID:cP}=(gs(),Io),{base58btc:uP}=(Pn(),Bn),lP=pe(),fP=Symbol.for("nodejs.util.inspect.custom"),{toString:Mc}=(It(),Nt),{equals:hP}=(yr(),pr),Mf=new Map,qv=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ht=class{constructor(e){if(e==null&&(e=""),Object.defineProperty(this,qv,{value:!0}),e instanceof Uint8Array)this.bytes=Lr.fromBytes(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Lr.fromString(e)}else if(Ht.isMultiaddr(e))this.bytes=Lr.fromBytes(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Lr.bytesToString(this.bytes)}toJSON(){return this.toString()}toOptions(){let e={},r=this.toString().split("/");return e.family=r[1]==="ip4"?4:6,e.host=r[2],e.transport=r[3],e.port=parseInt(r[4]),e}protos(){return this.protoCodes().map(e=>Object.assign({},Os(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let i=kv.decode(r,n),s=kv.decode.bytes,o=Os(i);n+=Lr.sizeForAddr(o,r.slice(n+s))+s,e.push(i)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Lr.bytesToTuples(this.bytes)}stringTuples(){let e=Lr.bytesToTuples(this.bytes);return Lr.tuplesToStringTuples(e)}encapsulate(e){return e=new Ht(e),new Ht(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),i=n.lastIndexOf(r);if(i<0)throw new Error("Address "+this+" does not contain subaddress: "+e);return new Ht(n.slice(0,i))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new Ht(Lr.tuplesToBytes(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Os.names.ipfs.code).pop();if(r&&r[1]){let n=r[1];return n[0]==="Q"||n[0]==="1"?Mc(uP.decode(`z${n}`),"base58btc"):Mc(cP.parse(n).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>!!Os(r[0]).path)[0][1],e||(e=null)}catch(r){e=null}return e}equals(e){return hP(this.bytes,e.bytes)}async resolve(){let e=this.protos().find(i=>i.resolvable);if(!e)return[this];let r=Mf.get(e.name);if(!r)throw lP(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this)).map(i=>new Ht(i))}nodeAddress(){let e=this.protoCodes(),r=this.protoNames(),n=this.toString().split("/").slice(1);if(n.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(e[0]!==4&&e[0]!==41&&e[0]!==54&&e[0]!==55)throw new Error(`no protocol with name: "'${r[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if(n[2]!=="tcp"&&n[2]!=="udp")throw new Error(`no protocol with name: "'${r[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:e[0]===41||e[0]===55?6:4,address:n[1],port:parseInt(n[3])}}isThinWaistAddress(e){let r=(e||this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}static fromNodeAddress(e,r){if(!e)throw new Error("requires node address object");if(!r)throw new Error("requires transport protocol");let n;switch(e.family){case 4:n="ip4";break;case 6:n="ip6";break;default:throw Error(`Invalid addr family. Got '${e.family}' instead of 4 or 6`)}return new Ht("/"+[n,e.address,r,e.port].join("/"))}static isName(e){return Ht.isMultiaddr(e)?e.protos().some(r=>r.resolvable):!1}static isMultiaddr(e){return e instanceof Ht||Boolean(e&&e[qv])}[fP](){return"<Multiaddr "+Mc(this.bytes,"base16")+" - "+Lr.bytesToString(this.bytes)+">"}inspect(){return"<Multiaddr "+Mc(this.bytes,"base16")+" - "+Lr.bytesToString(this.bytes)+">"}};Ht.protocols=Os;Ht.resolvers=Mf;function dP(t){return new Ht(t)}Uv.exports={Multiaddr:Ht,multiaddr:dP,protocols:Os,resolvers:Mf}});var Ff=w((TU,Mv)=>{"use strict";var pP=async t=>{let e=[];for await(let r of t)e.push(r);return e};Mv.exports=pP});var Fv,Kf,Kv=_e(()=>{Fv=_o(Ff()),Kf=(t,e)=>async function*(){yield*(await(0,Fv.default)(t)).sort(e)}()});var aa=w((BU,Vv)=>{"use strict";var yP=async t=>{for await(let e of t);};Vv.exports=yP});var Fc=w((PU,jv)=>{"use strict";var gP=async function*(t,e){for await(let r of t)await e(r)&&(yield r)};jv.exports=gP});var Vf=w((NU,$v)=>{"use strict";var mP=async function*(t,e){let r=0;if(!(e<1)){for await(let n of t)if(yield n,r++,r===e)return}};$v.exports=mP});var jf,Li,$f,Hf,Hv=_e(()=>{Kv();jf=_o(aa()),Li=_o(Fc()),$f=_o(Vf()),Hf=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}get(e,r){return Promise.reject(new Error(".get is not implemented"))}has(e,r){return Promise.reject(new Error(".has is not implemented"))}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,r={}){for await(let{key:n,value:i}of e)await this.put(n,i,r),yield{key:n,value:i}}async*getMany(e,r={}){for await(let n of e)yield this.get(n,r)}async*deleteMany(e,r={}){for await(let n of e)await this.delete(n,r),yield n}batch(){let e=[],r=[];return{put(n,i){e.push({key:n,value:i})},delete(n){r.push(n)},commit:async n=>{await(0,jf.default)(this.putMany(e,n)),e=[],await(0,jf.default)(this.deleteMany(r,n)),r=[]}}}async*_all(e,r){throw new Error("._all is not implemented")}async*_allKeys(e,r){throw new Error("._allKeys is not implemented")}query(e,r){let n=this._all(e,r);if(e.prefix!=null&&(n=(0,Li.default)(n,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Li.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Kf(i,s),n)),e.offset!=null){let i=0;n=(0,Li.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,$f.default)(n,e.limit)),n}queryKeys(e,r){let n=this._allKeys(e,r);if(e.prefix!=null&&(n=(0,Li.default)(n,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,Li.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Kf(i,s),n)),e.offset!=null){let i=0;n=(0,Li.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,$f.default)(n,e.limit)),n}}});var zv,Gv=_e(()=>{zv="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"});var Gf={};yt(Gf,{customAlphabet:()=>vP,customRandom:()=>Yv,nanoid:()=>zf,random:()=>Wv,urlAlphabet:()=>zv});var Wv,Yv,vP,zf,Kc=_e(()=>{Gv();Wv=t=>crypto.getRandomValues(new Uint8Array(t)),Yv=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*n*e/t.length);return()=>{let s="";for(;;){let o=r(i),a=i;for(;a--;)if(s+=t[o[a]&n]||"",s.length===e)return s}}},vP=(t,e)=>Yv(t,e,Wv),zf=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=r[t]&63;n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n<63?e+="_":e+="-"}return e}});var Wf={};yt(Wf,{Key:()=>Rt});function bP(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function EP(t){let e=t.split(":");return e[e.length-1]}function wP(t){return[].concat(...t)}var bn,Qv,Vc,Rt,jc=_e(()=>{Kc();It();Ct();bn="/",Qv=new TextEncoder().encode(bn),Vc=Qv[0],Rt=class{constructor(e,r){if(typeof e=="string")this._buf=Yl(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Vc)throw new Error("Invalid key")}toString(e="utf8"){return Xl(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Rt(e.join(bn))}static random(){return new Rt(zf().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new Rt(e):e.uint8Array?new Rt(e.uint8Array()):null}clean(){if((!this._buf||this._buf.byteLength===0)&&(this._buf=Qv),this._buf[0]!==Vc){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Vc,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Vc;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let i=0;i<r.length;i++){if(n.length<i+1)return!1;let s=r[i],o=n[i];if(s<o)return!0;if(s>o)return!1}return r.length<n.length}reverse(){return Rt.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(bn).slice(1)}type(){return bP(this.baseNamespace())}name(){return EP(this.baseNamespace())}instance(e){return new Rt(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(bn)||(e+=bn),e+=this.type(),new Rt(e)}parent(){let e=this.list();return e.length===1?new Rt(bn):new Rt(e.slice(0,-1).join(bn))}child(e){return this.toString()===bn?e:e.toString()===bn?this:new Rt(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return Rt.withNamespaces([...this.namespaces(),...wP(e.map(r=>r.namespaces()))])}}});function Zv(t){return t=t||new Error("Not Found"),(0,Xv.default)(t,"ERR_NOT_FOUND")}var Xv,Jv=_e(()=>{Xv=_o(pe())});var t1={};yt(t1,{MemoryDatastore:()=>e1});var e1,r1=_e(()=>{Hv();jc();Jv();e1=class extends Hf{constructor(){super();this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,r){this.data[e.toString()]=r}async get(e){if(!await this.has(e))throw Zv();return this.data[e.toString()]}async has(e){return this.data[e.toString()]!==void 0}async delete(e){delete this.data[e.toString()]}async*_all(){yield*Object.entries(this.data).map(([e,r])=>({key:new Rt(e),value:r}))}async*_allKeys(){yield*Object.entries(this.data).map(([e])=>new Rt(e))}}});var He=w(Yf=>{"use strict";Yf.messages={NOT_STARTED_YET:"The libp2p node is not started yet",DHT_DISABLED:"DHT is not available",CONN_ENCRYPTION_REQUIRED:"At least one connection encryption module is required",NOT_FOUND:"Not found"};Yf.codes={DHT_DISABLED:"ERR_DHT_DISABLED",PUBSUB_NOT_STARTED:"ERR_PUBSUB_NOT_STARTED",DHT_NOT_STARTED:"ERR_DHT_NOT_STARTED",CONN_ENCRYPTION_REQUIRED:"ERR_CONN_ENCRYPTION_REQUIRED",ERR_INVALID_PROTOCOLS_FOR_STREAM:"ERR_INVALID_PROTOCOLS_FOR_STREAM",ERR_CONNECTION_ENDED:"ERR_CONNECTION_ENDED",ERR_CONNECTION_FAILED:"ERR_CONNECTION_FAILED",ERR_NODE_NOT_STARTED:"ERR_NODE_NOT_STARTED",ERR_ALREADY_ABORTED:"ERR_ALREADY_ABORTED",ERR_TOO_MANY_ADDRESSES:"ERR_TOO_MANY_ADDRESSES",ERR_NO_VALID_ADDRESSES:"ERR_NO_VALID_ADDRESSES",ERR_RELAYED_DIAL:"ERR_RELAYED_DIAL",ERR_DIALED_SELF:"ERR_DIALED_SELF",ERR_DISCOVERED_SELF:"ERR_DISCOVERED_SELF",ERR_DUPLICATE_TRANSPORT:"ERR_DUPLICATE_TRANSPORT",ERR_ENCRYPTION_FAILED:"ERR_ENCRYPTION_FAILED",ERR_HOP_REQUEST_FAILED:"ERR_HOP_REQUEST_FAILED",ERR_INVALID_KEY:"ERR_INVALID_KEY",ERR_INVALID_MESSAGE:"ERR_INVALID_MESSAGE",ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_INVALID_PEER:"ERR_INVALID_PEER",ERR_MUXER_UNAVAILABLE:"ERR_MUXER_UNAVAILABLE",ERR_NOT_FOUND:"ERR_NOT_FOUND",ERR_TIMEOUT:"ERR_TIMEOUT",ERR_TRANSPORT_UNAVAILABLE:"ERR_TRANSPORT_UNAVAILABLE",ERR_TRANSPORT_DIAL_FAILED:"ERR_TRANSPORT_DIAL_FAILED",ERR_UNSUPPORTED_PROTOCOL:"ERR_UNSUPPORTED_PROTOCOL",ERR_INVALID_MULTIADDR:"ERR_INVALID_MULTIADDR",ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID",ERR_FIND_SELF:"ERR_FIND_SELF",ERR_NO_ROUTERS_AVAILABLE:"ERR_NO_ROUTERS_AVAILABLE",ERR_CONNECTION_NOT_MULTIPLEXED:"ERR_CONNECTION_NOT_MULTIPLEXED",ERR_NO_DIAL_TOKENS:"ERR_NO_DIAL_TOKENS",ERR_KEYCHAIN_REQUIRED:"ERR_KEYCHAIN_REQUIRED",ERR_INVALID_CMS:"ERR_INVALID_CMS",ERR_MISSING_KEYS:"ERR_MISSING_KEYS",ERR_NO_KEY:"ERR_NO_KEY",ERR_INVALID_KEY_NAME:"ERR_INVALID_KEY_NAME",ERR_INVALID_KEY_TYPE:"ERR_INVALID_KEY_TYPE",ERR_KEY_ALREADY_EXISTS:"ERR_KEY_ALREADY_EXISTS",ERR_INVALID_KEY_SIZE:"ERR_INVALID_KEY_SIZE",ERR_KEY_NOT_FOUND:"ERR_KEY_NOT_FOUND",ERR_OLD_KEY_NAME_INVALID:"ERR_OLD_KEY_NAME_INVALID",ERR_NEW_KEY_NAME_INVALID:"ERR_NEW_KEY_NAME_INVALID",ERR_PASSWORD_REQUIRED:"ERR_PASSWORD_REQUIRED",ERR_PEM_REQUIRED:"ERR_PEM_REQUIRED",ERR_CANNOT_READ_KEY:"ERR_CANNOT_READ_KEY",ERR_MISSING_PRIVATE_KEY:"ERR_MISSING_PRIVATE_KEY",ERR_INVALID_OLD_PASS_TYPE:"ERR_INVALID_OLD_PASS_TYPE",ERR_INVALID_NEW_PASS_TYPE:"ERR_INVALID_NEW_PASS_TYPE",ERR_INVALID_PASS_LENGTH:"ERR_INVALID_PASS_LENGTH",ERR_NOT_IMPLEMENTED:"ERR_NOT_IMPLEMENTED",ERR_WRONG_PING_ACK:"ERR_WRONG_PING_ACK"}});var i1=w((HU,n1)=>{"use strict";var _P=async function*(t,e){for await(let r of t)yield e(r)};n1.exports=_P});var Qf=w((zU,s1)=>{"use strict";var xP=pe(),SP=Fc(),AP=i1(),CP=Vf();async function*IP(t,e){yield*AP(t,async r=>(await e.addressBook.add(r.id,r.multiaddrs),r))}function TP(t){let e=new Set;return SP(t,r=>e.has(r.id.toString())?!1:(e.add(r.id.toString()),!0))}async function*RP(t,e=1){let r=0;for await(let n of t)r++,yield n;if(r<e)throw xP(new Error("not found"),"NOT_FOUND")}function BP(t,e){return e?CP(t,e):t}s1.exports={storeAddresses:IP,uniquePeers:TP,requirePeers:RP,maybeLimitSource:BP}});var a1=w((GU,o1)=>{"use strict";o1.exports=function(){return Date.now()}});var ca=w((WU,u1)=>{"use strict";var $c=a1(),c1=class{constructor(e,r,n){let i=this;this._started=$c(),this._rescheduled=0,this._scheduled=r,this._args=n,this._triggered=!1,this._timerWrapper=()=>{i._rescheduled>0?(i._scheduled=i._rescheduled-($c()-i._started),i._schedule(i._scheduled)):(i._triggered=!0,e.apply(null,i._args))},this._timer=setTimeout(this._timerWrapper,r)}reschedule(e){e||(e=this._scheduled);let r=$c();r+e-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(e)):this._triggered?this._schedule(e):(this._started=r,this._rescheduled=e)}_schedule(e){this._triggered=!1,this._started=$c(),this._rescheduled=0,this._scheduled=e,this._timer=setTimeout(this._timerWrapper,e)}clear(){clearTimeout(this._timer)}};function PP(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("timeout needed");let t;if(arguments.length>0){t=new Array(arguments.length-2);for(var e=0;e<t.length;e++)t[e]=arguments[e+2]}return new c1(arguments[0],arguments[1],t)}u1.exports=PP});var Xf=w((YU,f1)=>{"use strict";var{AbortController:NP}=globalThis,l1=ca(),Hc=class extends NP{constructor(e){super();this._ms=e,this._timer=l1(()=>this.abort(),e),Object.setPrototypeOf(this,Hc.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=l1(()=>this.abort(),this._ms)}};f1.exports={TimeoutController:Hc}});var d1=w((XU,h1)=>{h1.exports=class{constructor(e){if(!(e>0)||(e-1&e)!=0)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 this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}}});var Zf=w((JU,y1)=>{var p1=d1();y1.exports=class{constructor(e){this.hwm=e||16,this.head=new p1(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){let r=this.head;this.head=r.next=new p1(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next){let r=this.tail.next;return this.tail.next=null,this.tail=r,this.tail.shift()}return e}isEmpty(){return this.head.isEmpty()}}});var eh=w((eM,g1)=>{var Jf=Zf();g1.exports=t=>{t=t||{};let e;typeof t=="function"?(e=t,t={}):e=t.onEnd;let r=new Jf,n,i,s,o=()=>{if(!r.isEmpty()){if(t.writev){let g,m=[];for(;!r.isEmpty();){if(g=r.shift(),g.error)throw g.error;m.push(g.value)}return{done:g.done,value:m}}let d=r.shift();if(d.error)throw d.error;return d}return s?{done:!0}:new Promise((d,g)=>{i=m=>(i=null,m.error?g(m.error):t.writev&&!m.done?d({done:m.done,value:[m.value]}):d(m),n)})},a=d=>i?i(d):(r.push(d),n),c=d=>(r=new Jf,i?i({error:d}):(r.push({error:d}),n)),u=d=>s?n:a({done:!1,value:d}),l=d=>s?n:(s=!0,d?c(d):a({done:!0})),f=()=>(r=new Jf,l(),{done:!0}),h=d=>(l(d),{done:!0});if(n={[Symbol.asyncIterator](){return this},next:o,return:f,throw:h,push:u,end:l},!e)return n;let p=n;return n={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(d){return p.throw(d),e&&(e(d),e=null),{done:!0}},return(){return p.return(),e&&(e(),e=null),{done:!0}},push:u,end(d){return p.end(d),e&&(e(d),e=null),n}},n}});var th=w((tM,m1)=>{"use strict";var OP=eh(),DP=async function*(...t){let e=OP();setTimeout(async()=>{try{await Promise.all(t.map(async r=>{for await(let n of r)e.push(n)})),e.end()}catch(r){e.end(r)}},0),yield*e};m1.exports=DP});var nn=w((rM,Ds)=>{var v1=(...t)=>{let e;for(;t.length;)e=t.shift()(e);return e},rh=t=>t&&(typeof t[Symbol.asyncIterator]=="function"||typeof t[Symbol.iterator]=="function"||typeof t.next=="function"),zc=t=>t&&typeof t.sink=="function"&&rh(t.source),LP=t=>e=>(t.sink(e),t.source),b1=(...t)=>{if(zc(t[0])){let e=t[0];t[0]=()=>e.source}else if(rh(t[0])){let e=t[0];t[0]=()=>e}if(t.length>1&&zc(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let e=1;e<t.length-1;e++)zc(t[e])&&(t[e]=LP(t[e]));return v1(...t)};Ds.exports=b1;Ds.exports.pipe=b1;Ds.exports.rawPipe=v1;Ds.exports.isIterable=rh;Ds.exports.isDuplex=zc});var nh=w((nM,E1)=>{"use strict";var kP=async t=>{for await(let e of t)return e};E1.exports=kP});var ih=w((iM,w1)=>{"use strict";var Ls=new Map,qP=()=>`${Date.now()}:${Math.floor(Math.random()*1e6)}`;async function UP(t,e,r){for(;Ls.get(r);){try{await t()}catch(n){setTimeout(()=>{throw n},1);break}if(!Ls.get(r))break;await new Promise(n=>{let i=setTimeout(n,e);Ls.set(r,i)})}}function MP(t,e,r){r=r||e;let n=qP(),i=setTimeout(()=>{UP(t,e,n)},r);return Ls.set(n,i),n}function FP(t){let e=Ls.get(t);e&&(clearTimeout(e),Ls.delete(t))}w1.exports={setDelayedInterval:MP,clearDelayedInterval:FP}});var S1=w((sM,x1)=>{"use strict";var KP=pe(),{messages:VP,codes:jP}=He(),_1=class{constructor(e){this._dht=e}async findPeer(e,r={}){for await(let n of this._dht.findPeer(e,r))if(n.name==="FINAL_PEER")return n.peer;throw KP(new Error(VP.NOT_FOUND),jP.ERR_NOT_FOUND)}async*getClosestPeers(e,r={}){for await(let n of this._dht.getClosestPeers(e,r))n.name==="PEER_RESPONSE"&&(yield*n.closer)}};x1.exports={DHTPeerRouting:_1}});var O1=w((oM,N1)=>{"use strict";var A1=Be(),C1=Object.assign(A1("libp2p:peer-routing"),{error:A1("libp2p:peer-routing:err")}),Gc=pe(),ua=He(),{storeAddresses:I1,uniquePeers:$P,requirePeers:HP}=Qf(),{TimeoutController:zP}=Xf(),T1=th(),{pipe:R1}=nn(),GP=nh(),WP=aa(),YP=Fc(),{setDelayedInterval:QP,clearDelayedInterval:XP}=ih(),{DHTPeerRouting:ZP}=S1(),{setMaxListeners:B1}=Qt(),P1=class{constructor(e){this._peerId=e.peerId,this._peerStore=e.peerStore,this._routers=e._modules.peerRouting||[],e._dht&&e._config.dht.enabled&&this._routers.push(new ZP(e._dht)),this._refreshManagerOptions=e._options.peerRouting.refreshManager,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}start(){!this._routers.length||this._timeoutId||!this._refreshManagerOptions.enabled||(this._timeoutId=QP(this._findClosestPeersTask,this._refreshManagerOptions.interval,this._refreshManagerOptions.bootDelay))}async _findClosestPeersTask(){try{await WP(this.getClosestPeers(this._peerId.id,{timeout:this._refreshManagerOptions.timeout||1e4}))}catch(e){C1.error(e)}}stop(){XP(this._timeoutId)}async findPeer(e,r){if(!this._routers.length)throw Gc(new Error("No peer routers available"),ua.codes.ERR_NO_ROUTERS_AVAILABLE);if(e.toB58String()===this._peerId.toB58String())throw Gc(new Error("Should not try to find self"),ua.codes.ERR_FIND_SELF);let n=await R1(T1(...this._routers.map(i=>async function*(){try{yield await i.findPeer(e,r)}catch(s){C1.error(s)}}())),i=>YP(i,Boolean),i=>I1(i,this._peerStore),i=>GP(i));if(n)return n;throw Gc(new Error(ua.messages.NOT_FOUND),ua.codes.ERR_NOT_FOUND)}async*getClosestPeers(e,r={timeout:3e4}){if(!this._routers.length)throw Gc(new Error("No peer routers available"),ua.codes.ERR_NO_ROUTERS_AVAILABLE);if(r.timeout){let n=new zP(r.timeout);try{B1&&B1(1/0,n.signal)}catch{}r.signal=n.signal}yield*R1(T1(...this._routers.map(n=>n.getClosestPeers(e,r))),n=>I1(n,this._peerStore),n=>$P(n),n=>HP(n))}};N1.exports=P1});var k1=w((aM,L1)=>{"use strict";var JP=aa(),D1=class{constructor(e){this._dht=e}async provide(e){await JP(this._dht.provide(e))}async*findProviders(e,r){for await(let n of this._dht.findProviders(e,r))n.name==="PROVIDER"&&(yield*n.providers)}};L1.exports={DHTContentRouting:D1}});var M1=w((cM,U1)=>{"use strict";var ki=pe(),{messages:la,codes:qi}=He(),{storeAddresses:eN,uniquePeers:tN,requirePeers:rN,maybeLimitSource:nN}=Qf(),iN=aa(),sN=th(),{pipe:oN}=nn(),{DHTContentRouting:aN}=k1(),q1=class{constructor(e){this.libp2p=e,this.routers=e._modules.contentRouting||[],this.dht=e._dht,this.dht&&e._config.dht.enabled&&this.routers.push(new aN(this.dht))}async*findProviders(e,r={}){if(!this.routers.length)throw ki(new Error("No content this.routers available"),qi.ERR_NO_ROUTERS_AVAILABLE);yield*oN(sN(...this.routers.map(n=>n.findProviders(e,r))),n=>eN(n,this.libp2p.peerStore),n=>tN(n),n=>nN(n,r.maxNumProviders),n=>rN(n))}async provide(e){if(!this.routers.length)throw ki(new Error("No content routers available"),qi.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(r=>r.provide(e)))}async put(e,r,n){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw ki(new Error(la.NOT_STARTED_YET),qi.DHT_NOT_STARTED);await iN(this.dht.put(e,r,n))}async get(e,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw ki(new Error(la.NOT_STARTED_YET),qi.DHT_NOT_STARTED);for await(let n of this.dht.get(e,r))if(n.name==="VALUE")return{from:n.peerId,val:n.value};throw ki(new Error(la.NOT_FOUND),qi.ERR_NOT_FOUND)}async*getMany(e,r,n){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw ki(new Error(la.NOT_STARTED_YET),qi.DHT_NOT_STARTED);if(!r)return;let i=0;for await(let s of this.dht.get(e,n))if(s.name==="VALUE"&&(yield{from:s.peerId,val:s.value},i++,i===r))break;if(i===0)throw ki(new Error(la.NOT_FOUND),qi.ERR_NOT_FOUND)}};U1.exports=q1});var sh=w((uM,j1)=>{"use strict";var cN=Tt(),{Multiaddr:F1}=kt(),K1=pe(),{codes:V1}=He();function uN(t){typeof t=="string"&&(t=new F1(t));let e;if(F1.isMultiaddr(t)){e=t;let r=t.getPeerId();if(!r)throw K1(new Error(`${t} does not have a valid peer type`),V1.ERR_INVALID_MULTIADDR);try{t=cN.createFromB58String(r)}catch(n){throw K1(new Error(`${t} is not a valid peer type`),V1.ERR_INVALID_MULTIADDR)}}return{id:t,multiaddrs:e?[e]:void 0}}j1.exports=uN});var H1=w((lM,$1)=>{"use strict";$1.exports=t=>{if(Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}});var Us=w((Y1,Q1)=>{"use strict";var Wc=H1(),{hasOwnProperty:z1}=Object.prototype,{propertyIsEnumerable:lN}=Object,ks=(t,e,r)=>Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0}),fN=Y1,G1={concatArrays:!1,ignoreUndefined:!1},Yc=t=>{let e=[];for(let r in t)z1.call(t,r)&&e.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(t);for(let n of r)lN.call(t,n)&&e.push(n)}return e};function qs(t){return Array.isArray(t)?hN(t):Wc(t)?dN(t):t}function hN(t){let e=t.slice(0,0);return Yc(t).forEach(r=>{ks(e,r,qs(t[r]))}),e}function dN(t){let e=Object.getPrototypeOf(t)===null?Object.create(null):{};return Yc(t).forEach(r=>{ks(e,r,qs(t[r]))}),e}var W1=(t,e,r,n)=>(r.forEach(i=>{typeof e[i]=="undefined"&&n.ignoreUndefined||(i in t&&t[i]!==Object.getPrototypeOf(t)?ks(t,i,oh(t[i],e[i],n)):ks(t,i,qs(e[i])))}),t),pN=(t,e,r)=>{let n=t.slice(0,0),i=0;return[t,e].forEach(s=>{let o=[];for(let a=0;a<s.length;a++)!z1.call(s,a)||(o.push(String(a)),s===t?ks(n,i++,s[a]):ks(n,i++,qs(s[a])));n=W1(n,s,Yc(s).filter(a=>!o.includes(a)),r)}),n};function oh(t,e,r){return r.concatArrays&&Array.isArray(t)&&Array.isArray(e)?pN(t,e,r):!Wc(e)||!Wc(t)?qs(e):W1(t,e,Yc(e),r)}Q1.exports=function(...t){let e=oh(qs(G1),this!==fN&&this||{},G1),r={_:{}};for(let n of t)if(n!==void 0){if(!Wc(n))throw new TypeError("`"+n+"` is not an Option Object");r=oh(r,{_:n},e)}return r._}});var J1=w((fM,Z1)=>{"use strict";Z1.exports=X1;var yN=Xu(),ei=X1.prototype,gN=new Date%1e9;function mN(){return(Math.random()*1e9>>>0)+gN++}function X1(t){t=t||{},this.id=t.id||mN(),this.max=t.max||1/0,this.items=t.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(t.lastModified||new Date);for(var e,r,n=this.items.length;n--;)e=this.items[n],r=new Date(e.expires)-new Date,this._lookup[e.key]=e,r>0?this.expire(e.key,r):r<=0&&this.delete(e.key)}ei.has=function(t){return t in this._lookup};ei.get=function(t){if(!this.has(t))return null;var e=this._lookup[t];return e.refresh&&this.expire(t,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};ei.meta=function(t){if(!this.has(t))return null;var e=this._lookup[t];return"meta"in e?e.meta:null};ei.set=function(t,e,r){var n=this._lookup[t],i=this._lookup[t]={key:t,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,i)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(i),this.size++),r&&("ttl"in r&&this.expire(t,r.ttl),"meta"in r&&(i.meta=r.meta),r.refresh&&(i.refresh=r.ttl)),this};ei.delete=function(t){var e=this._lookup[t];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[t],this.size--,this):!1};ei.expire=function(t,e){var r=e||0,n=this._lookup[t];if(!n)return this;if(typeof r=="string"&&(r=yN(e)),typeof r!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this};ei.clear=function(){for(var t=this.items.length;t--;)this.delete(this.items[t].key);return this};ei.toJSON=function(){for(var t=new Array(this.items.length),e,r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}});var fa=w((Ms,eb)=>{"use strict";var vN=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof En!="undefined")return En;throw new Error("unable to locate global object")},En=vN();eb.exports=Ms=En.fetch;En.fetch&&(Ms.default=En.fetch.bind(En));Ms.Headers=En.Headers;Ms.Request=En.Request;Ms.Response=En.Response});var tb=w((hM,ah)=>{"use strict";globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?ah.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:ah.exports={default:fa().default,Headers:fa().Headers,Request:fa().Request,Response:fa().Response}});var nb=w((dM,rb)=>{"use strict";var{default:bN,Headers:EN}=tb();function wN({serverResolver:t,hostname:e,recordType:r}){return`${t}?name=${e}&type=${r}`}function _N(t){return bN(t,{headers:new EN({accept:"application/dns-json"})})}function xN(t,e){return`${e}_${t}`}rb.exports={buildResource:wN,fetch:_N,getCacheKey:xN}});var ob=w((pM,sb)=>{"use strict";var ib=Be(),Qc=ib("dns-over-http-resolver");Qc.error=ib("dns-over-http-resolver:error");var SN=J1(),Er=nb(),Xc=class{constructor({maxCache:e=100}={}){this._cache=new SN({max:e}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"]}getServers(){return this._servers}_getShuffledServers(){let e=[].concat(this._servers);for(let r=e.length-1;r>0;r--){let n=Math.floor(Math.random()*r),i=e[r];e[r]=e[n],e[n]=i}return e}setServers(e){this._servers=e}resolve(e,r="A"){switch(r){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(`${r} is not supported`)}}async resolve4(e){let r="A",n=this._cache.get(Er.getCacheKey(e,r));if(n)return n;for(let i of this._getShuffledServers())try{let o=await(await Er.fetch(Er.buildResource({serverResolver:i,hostname:e,recordType:r}))).json(),a=o.Answer.map(u=>u.data),c=Math.min(o.Answer.map(u=>u.TTL));return this._cache.set(Er.getCacheKey(e,r),a,{ttl:c}),a}catch(s){Qc.error(`${i} could not resolve ${e} record ${r}`)}throw new Error(`Could not resolve ${e} record ${r}`)}async resolve6(e){let r="AAAA",n=this._cache.get(Er.getCacheKey(e,r));if(n)return n;for(let i of this._getShuffledServers())try{let o=await(await Er.fetch(Er.buildResource({serverResolver:i,hostname:e,recordType:r}))).json(),a=o.Answer.map(u=>u.data),c=Math.min(o.Answer.map(u=>u.TTL));return this._cache.set(Er.getCacheKey(e,r),a,{ttl:c}),a}catch(s){Qc.error(`${i} could not resolve ${e} record ${r}`)}throw new Error(`Could not resolve ${e} record ${r}`)}async resolveTxt(e){let r="TXT",n=this._cache.get(Er.getCacheKey(e,r));if(n)return n;for(let i of this._getShuffledServers())try{let o=await(await Er.fetch(Er.buildResource({serverResolver:i,hostname:e,recordType:r}))).json(),a=o.Answer.map(u=>[u.data.replace(/['"]+/g,"")]),c=Math.min(o.Answer.map(u=>u.TTL));return this._cache.set(Er.getCacheKey(e,r),a,{ttl:c}),a}catch(s){Qc.error(`${i} could not resolve ${e} record ${r}`)}throw new Error(`Could not resolve ${e} record ${r}`)}};Xc.Resolver=Xc;sb.exports=Xc});var cb=w((yM,ab)=>{"use strict";var AN=ob();ab.exports=AN});var lb=w((gM,ub)=>{"use strict";var CN=na(),{code:IN}=CN("dnsaddr");async function TN(t){let e=cb(),r=new e,n=t.getPeerId(),[,i]=t.stringTuples().find(([a])=>a===IN)||[],o=(await r.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return n&&(o=o.filter(a=>a.includes(n))),o}ub.exports={dnsaddrResolver:TN}});var Zc=w((mM,fb)=>{"use strict";fb.exports={DIAL_TIMEOUT:3e4,MAX_PARALLEL_DIALS:100,MAX_PER_PEER_DIALS:4,MAX_ADDRS_TO_DIAL:25,METRICS:{computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[60*1e3,5*60*1e3,15*60*1e3],maxOldPeersRetention:50}}});var ch=w((vM,RN)=>{RN.exports={name:"libp2p",version:"0.35.8-bf1fc32",description:"JavaScript implementation of libp2p, a modular peer to peer network stack",leadMaintainer:"Jacob Heun <jacobheun@gmail.com>",main:"src/index.js",types:"dist/src/index.d.ts",typesVersions:{"*":{"src/*":["dist/src/*","dist/src/*/index"]}},files:["dist","src"],scripts:{lint:"aegir lint",build:"aegir build","build:proto":"npm run build:proto:circuit && npm run build:proto:identify && npm run build:proto:plaintext && npm run build:proto:address-book && npm run build:proto:proto-book && npm run build:proto:peer && npm run build:proto:peer-record && npm run build:proto:envelope","build:proto:circuit":"pbjs -t static-module -w commonjs -r libp2p-circuit --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/circuit/protocol/index.js ./src/circuit/protocol/index.proto","build:proto:identify":"pbjs -t static-module -w commonjs -r libp2p-identify --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/identify/message.js ./src/identify/message.proto","build:proto:plaintext":"pbjs -t static-module -w commonjs -r libp2p-plaintext --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/insecure/proto.js ./src/insecure/proto.proto","build:proto:peer":"pbjs -t static-module -w commonjs -r libp2p-peer --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/peer-store/pb/peer.js ./src/peer-store/pb/peer.proto","build:proto:peer-record":"pbjs -t static-module -w commonjs -r libp2p-peer-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/peer-record/peer-record.js ./src/record/peer-record/peer-record.proto","build:proto:envelope":"pbjs -t static-module -w commonjs -r libp2p-envelope --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/envelope/envelope.js ./src/record/envelope/envelope.proto","build:proto-types":"npm run build:proto-types:circuit && npm run build:proto-types:identify && npm run build:proto-types:plaintext && npm run build:proto-types:address-book && npm run build:proto-types:proto-book && npm run build:proto-types:peer && npm run build:proto-types:peer-record && npm run build:proto-types:envelope","build:proto-types:circuit":"pbts -o src/circuit/protocol/index.d.ts src/circuit/protocol/index.js","build:proto-types:identify":"pbts -o src/identify/message.d.ts src/identify/message.js","build:proto-types:plaintext":"pbts -o src/insecure/proto.d.ts src/insecure/proto.js","build:proto-types:peer":"pbts -o src/peer-store/pb/peer.d.ts src/peer-store/pb/peer.js","build:proto-types:peer-record":"pbts -o src/record/peer-record/peer-record.d.ts src/record/peer-record/peer-record.js","build:proto-types:envelope":"pbts -o src/record/envelope/envelope.d.ts src/record/envelope/envelope.js",test:"aegir test","test:ts":"aegir build --no-bundle && npm run test --prefix test/ts-use","test:node":'aegir test -t node -f "./test/**/*.{node,spec}.js"',"test:browser":"aegir test -t browser","test:examples":"cd examples && npm run test:all","test:interop":"LIBP2P_JS=$PWD npx aegir test -t node -f ./node_modules/libp2p-interop/test/*",prepare:"npm run build",coverage:"nyc --reporter=text --reporter=lcov npm run test:node"},repository:{type:"git",url:"https://github.com/libp2p/js-libp2p.git"},keywords:["libp2p","network","p2p","peer","peer-to-peer","IPFS"],bugs:{url:"https://github.com/libp2p/js-libp2p/issues"},homepage:"https://libp2p.io",license:"MIT",engines:{node:">=15.0.0"},browser:{"nat-api":!1},eslintConfig:{extends:"ipfs",ignorePatterns:["!.aegir.js","test/ts-use","*.d.ts"]},dependencies:{"@vascosantos/moving-average":"^1.1.0","abortable-iterator":"^3.0.0","aggregate-error":"^3.1.0","any-signal":"^3.0.0","bignumber.js":"^9.0.1","class-is":"^1.1.0","datastore-core":"^7.0.0",debug:"^4.3.1","err-code":"^3.0.0","es6-promisify":"^7.0.0",events:"^3.3.0",hashlru:"^2.3.0","interface-datastore":"^6.0.2","it-all":"^1.0.4","it-buffer":"^0.1.2","it-drain":"^1.0.3","it-filter":"^1.0.1","it-first":"^1.0.4","it-handshake":"^2.0.0","it-length-prefixed":"^5.0.2","it-map":"^1.0.4","it-merge":"^1.0.0","it-pipe":"^1.1.0","it-take":"^1.0.0","libp2p-crypto":"^0.21.1","libp2p-interfaces":"^4.0.0","libp2p-utils":"^0.4.0",mafmt:"^10.0.0","merge-options":"^3.0.4",mortice:"^2.0.1",multiaddr:"^10.0.0",multiformats:"^9.0.0","multistream-select":"^2.0.0","mutable-proxy":"^1.0.0","nat-api":"^0.3.1","node-forge":"^0.10.0","p-any":"^3.0.0","p-fifo":"^1.0.0","p-retry":"^4.4.0","p-settle":"^4.1.1","peer-id":"^0.16.0","private-ip":"^2.1.0",protobufjs:"^6.10.2",retimer:"^3.0.0","sanitize-filename":"^1.6.3","set-delayed-interval":"^1.0.0","streaming-iterables":"^6.0.0","timeout-abort-controller":"^3.0.0",uint8arrays:"^3.0.0",varint:"^6.0.0",wherearewe:"^1.0.0",xsalsa20:"^1.1.0"},devDependencies:{"@chainsafe/libp2p-noise":"^5.0.0","@nodeutils/defaults-deep":"^1.1.0","@types/es6-promisify":"^6.0.0","@types/node":"^16.0.1","@types/node-forge":"^0.10.1","@types/varint":"^6.0.0",aegir:"^36.0.0",buffer:"^6.0.3",delay:"^5.0.0","into-stream":"^6.0.0","ipfs-http-client":"^54.0.2","it-concat":"^2.0.0","it-pair":"^1.0.0","it-pushable":"^1.4.0",libp2p:".","libp2p-bootstrap":"^0.14.0","libp2p-delegated-content-routing":"^0.11.0","libp2p-delegated-peer-routing":"^0.11.1","libp2p-interfaces-compliance-tests":"^4.0.8","libp2p-interop":"^0.7.1","libp2p-kad-dht":"^0.28.6","libp2p-mdns":"^0.18.0","libp2p-mplex":"^0.10.4","libp2p-tcp":"^0.17.0","libp2p-webrtc-star":"^0.25.0","libp2p-websockets":"^0.16.0",nock:"^13.0.3","p-defer":"^3.0.0","p-times":"^3.0.0","p-wait-for":"^3.2.0",rimraf:"^3.0.2",sinon:"^12.0.1",util:"^0.12.3"},contributors:["Vasco Santos <vasco.santos@moxy.studio>","David Dias <daviddias.p@gmail.com>","Jacob Heun <jacobheun@gmail.com>","Alex Potsides <alex@achingbrain.net>","Alan Shaw <alan@tableflip.io>","Cayman <caymannava@gmail.com>","Pedro Teixeira <i@pgte.me>","Friedel Ziegelmayer <dignifiedquire@gmail.com>","Maciej Kr\xFCger <mkg20001@gmail.com>","Hugo Dias <mail@hugodias.me>","dirkmc <dirkmdev@gmail.com>","Volker Mische <volker.mische@gmail.com>","Chris Dostert <chrisdostert@users.noreply.github.com>","zeim839 <50573884+zeim839@users.noreply.github.com>","Robert Kiel <robert.kiel@hoprnet.org>","Richard Littauer <richard.littauer@gmail.com>","a1300 <matthias-knopp@gmx.net>","Ryan Bell <ryan@piing.net>","\u1D20\u026A\u1D04\u1D1B\u1D0F\u0280 \u0299\u1D0A\u1D07\u029F\u1D0B\u029C\u1D0F\u029F\u1D0D <victorbjelkholm@gmail.com>","Andrew Nesbitt <andrewnez@gmail.com>","Franck Royer <franck@royer.one>","Thomas Eizinger <thomas@eizinger.io>","V\xEDt Habada <vithabada93@gmail.com>","Giovanni T. Parra <fiatjaf@gmail.com>","acolytec3 <17355484+acolytec3@users.noreply.github.com>","Alan Smithee <ggnore.alan.smithee@gmail.com>","Elven <mon.samuel@qq.com>","Samlior <samlior@foxmail.com>","Didrik Nordstr\xF6m <didrik.nordstrom@gmail.com>","Aditya Bose <13054902+adbose@users.noreply.github.com>","TJKoury <TJKoury@gmail.com>","TheStarBoys <41286328+TheStarBoys@users.noreply.github.com>","Tiago Alves <alvesjtiago@gmail.com>","Tim Daubensch\xFCtz <tim@daubenschuetz.de>","XiaoZhang <zxinmyth@gmail.com>","Yusef Napora <yusef@napora.org>","Zane Starr <zcstarr@gmail.com>","ebinks <elizabethjbinks@gmail.com>","greenSnot <greenSnot@users.noreply.github.com>","isan_rivkin <isanrivkin@gmail.com>","mayerwin <mayerwin@users.noreply.github.com>","mcclure <andi.m.mcclure@gmail.com>","patrickwoodhead <91056047+patrickwoodhead@users.noreply.github.com>","phillmac <phillmac@users.noreply.github.com>","robertkiel <robert.kiel@validitylabs.org>","shresthagrawal <34920931+shresthagrawal@users.noreply.github.com>","swedneck <40505480+swedneck@users.noreply.github.com>","tuyennhv <vutuyen2636@gmail.com>","S\xF6nke Hahn <soenkehahn@gmail.com>","Aleksei <vozhdb@gmail.com>","Bernd Strehl <bernd.strehl@gmail.com>","Chris Bratlien <chrisbratlien@gmail.com>","Cindy Wu <ciindy.wu@gmail.com>","Daijiro Wachi <daijiro.wachi@gmail.com>","Diogo Silva <fsdiogo@gmail.com>","Dmitriy Ryajov <dryajov@gmail.com>","Ethan Lam <elmemphis2000@gmail.com>","Fei Liu <liu.feiwood@gmail.com>","Felipe Martins <felipebrasil93@gmail.com>","Florian-Merle <florian.david.merle@gmail.com>","Francis Gulotta <wizard@roborooter.com>","Guy Sviry <32539816+guysv@users.noreply.github.com>","Henrique Dias <hacdias@gmail.com>","Irakli Gozalishvili <rfobic@gmail.com>","Joel Gustafson <joelg@mit.edu>","John Rees <johnrees@users.noreply.github.com>","Jo\xE3o Santos <joaosantos15@users.noreply.github.com>","Julien Bouquillon <contact@revolunet.com>","Kevin Kwok <antimatter15@gmail.com>","Kevin Lacker <lacker@gmail.com>","Lars Gierth <lgierth@users.noreply.github.com>","Leask Wong <i@leaskh.com>","Marcin Tojek <mtojek@users.noreply.github.com>","Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com>","Michael Burns <5170+mburns@users.noreply.github.com>","Miguel Mota <miguelmota2@gmail.com>","Nuno Nogueira <nunofmn@gmail.com>","Philipp Muens <raute1337@gmx.de>","RasmusErik Voel Jensen <github@solsort.com>","Smite Chow <xiaopengyou@live.com>","Soeren <nikorpoulsen@gmail.com>"]}});var uh=w((bM,sn)=>{"use strict";var BN=ch().version;sn.exports.PROTOCOL_VERSION="ipfs/0.1.0";sn.exports.AGENT_VERSION=`js-libp2p/${BN}`;sn.exports.MULTICODEC_IDENTIFY="/ipfs/id/1.0.0";sn.exports.MULTICODEC_IDENTIFY_PUSH="/ipfs/id/push/1.0.0";sn.exports.IDENTIFY_PROTOCOL_VERSION="0.1.0";sn.exports.MULTICODEC_IDENTIFY_PROTOCOL_NAME="id";sn.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME="id/push";sn.exports.MULTICODEC_IDENTIFY_PROTOCOL_VERSION="1.0.0";sn.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION="1.0.0"});var Jc=w((EM,db)=>{"use strict";var hb=60*1e3;db.exports={ADVERTISE_BOOT_DELAY:15*hb,ADVERTISE_TTL:30*hb,CIRCUIT_PROTO_CODE:290,HOP_METADATA_KEY:"hop_relay",HOP_METADATA_VALUE:"true",RELAY_RENDEZVOUS_NS:"/libp2p/relay"}});var pb=w(ha=>{(function(){var t,e,r,n,i,s,o,a;a=function(c){var u,l,f,h;return u=(c&255<<24)>>>24,l=(c&255<<16)>>>16,f=(c&255<<8)>>>8,h=c&255,[u,l,f,h].join(".")},o=function(c){var u,l,f,h,p,d;for(u=[],f=h=0;h<=3&&c.length!==0;f=++h){if(f>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}d=e(c),p=d[0],l=d[1],c=c.substring(l),u.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(u.length){case 1:if(u[0]>4294967295)throw new Error("Invalid IP");return u[0]>>>0;case 2:if(u[0]>255||u[1]>16777215)throw new Error("Invalid IP");return(u[0]<<24|u[1])>>>0;case 3:if(u[0]>255||u[1]>255||u[2]>65535)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2])>>>0;case 4:if(u[0]>255||u[1]>255||u[2]>255||u[3]>255)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2]<<8|u[3])>>>0;default:throw new Error("Invalid IP")}},r=function(c){return c.charCodeAt(0)},n=r("0"),s=r("a"),i=r("A"),e=function(c){var u,l,f,h,p;for(h=0,u=10,l="9",f=0,c.length>1&&c[f]==="0"&&(c[f+1]==="x"||c[f+1]==="X"?(f+=2,u=16):"0"<=c[f+1]&&c[f+1]<="9"&&(f++,u=8,l="7")),p=f;f<c.length;){if("0"<=c[f]&&c[f]<=l)h=h*u+(r(c[f])-n)>>>0;else if(u===16)if("a"<=c[f]&&c[f]<="f")h=h*u+(10+r(c[f])-s)>>>0;else if("A"<=c[f]&&c[f]<="F")h=h*u+(10+r(c[f])-i)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===p)throw new Error("empty octet");return[h,f]},t=function(){function c(u,l){var f,h,p,d;if(typeof u!="string")throw new Error("Missing `net' parameter");if(l||(d=u.split("/",2),u=d[0],l=d[1]),l||(l=32),typeof l=="string"&&l.indexOf(".")>-1){try{this.maskLong=o(l)}catch(g){throw f=g,new Error("Invalid mask: "+l)}for(h=p=32;p>=0;h=--p)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(l||l===0)this.bitmask=parseInt(l,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(u)&this.maskLong)>>>0}catch(g){throw f=g,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+l);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(o(u)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var l,f,h;for(h=o(this.first),f=o(this.last),l=0;h<=f;)u(a(h),h,l),l++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),ha.ip2long=o,ha.long2ip=a,ha.Netmask=t}).call(ha)});var gb=w((yb,eu)=>{(function(t){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(s,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${s})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${s})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${e}\\.${e}\\.${e}\\.${e}(${s})?$`,"i")};function c(p,d){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let g=0,m=-1,x=(p.match(a.zoneIndex)||[])[0],B,L;for(x&&(x=x.substring(1),p=p.replace(/%.+$/,""));(m=p.indexOf(":",m+1))>=0;)g++;if(p.substr(0,2)==="::"&&g--,p.substr(-2,2)==="::"&&g--,g>d)return null;for(L=d-g,B=":";L--;)B+="0:";return p=p.replace("::",B),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),d=function(){let H=p.split(":"),U=[];for(let q=0;q<H.length;q++)U.push(parseInt(H[q],16));return U}(),{parts:d,zoneId:x}}function u(p,d,g,m){if(p.length!==d.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let x=0,B;for(;m>0;){if(B=g-m,B<0&&(B=0),p[x]>>B!=d[x]>>B)return!1;m-=g,x+=1}return!0}function l(p){if(i.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(n.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function f(p,d){for(;p.length<d;)p=`0${p}`;return p}let h={};h.IPv4=function(){function p(d){if(d.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let g,m;for(g=0;g<d.length;g++)if(m=d[g],!(0<=m&&m<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=d}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(d,g){let m;if(g===void 0&&(m=d,d=m[0],g=m[1]),d.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,d.octets,8,g)},p.prototype.prefixLengthFromSubnetMask=function(){let d=0,g=!1,m={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},x,B,L;for(x=3;x>=0;x-=1)if(B=this.octets[x],B in m){if(L=m[B],g&&L!==0)return null;L!==8&&(g=!0),d+=L}else return null;return 32-d},p.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return h.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),h.IPv4.broadcastAddressFromCIDR=function(p){try{let d=this.parseCIDR(p),g=d[0].toByteArray(),m=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],B=0;for(;B<4;)x.push(parseInt(g[B],10)|parseInt(m[B],10)^255),B++;return new this(x)}catch(d){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.isIPv4=function(p){return this.parser(p)!==null},h.IPv4.isValid=function(p){try{return new this(this.parser(p)),!0}catch(d){return!1}},h.IPv4.isValidFourPartDecimal=function(p){return!!(h.IPv4.isValid(p)&&p.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},h.IPv4.networkAddressFromCIDR=function(p){let d,g,m,x,B;try{for(d=this.parseCIDR(p),m=d[0].toByteArray(),B=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],g=0;g<4;)x.push(parseInt(m[g],10)&parseInt(B[g],10)),g++;return new this(x)}catch(L){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.parse=function(p){let d=this.parser(p);if(d===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(d)},h.IPv4.parseCIDR=function(p){let d;if(d=p.match(/^(.+)\/(\d+)$/)){let g=parseInt(d[2]);if(g>=0&&g<=32){let m=[this.parse(d[1]),g];return Object.defineProperty(m,"toString",{value:function(){return this.join("/")}}),m}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},h.IPv4.parser=function(p){let d,g,m;if(d=p.match(r.fourOctet))return function(){let x=d.slice(1,6),B=[];for(let L=0;L<x.length;L++)g=x[L],B.push(l(g));return B}();if(d=p.match(r.longValue)){if(m=l(d[1]),m>4294967295||m<0)throw new Error("ipaddr: address outside defined range");return function(){let x=[],B;for(B=0;B<=24;B+=8)x.push(m>>B&255);return x}().reverse()}else return(d=p.match(r.twoOctet))?function(){let x=d.slice(1,4),B=[];if(m=l(x[1]),m>16777215||m<0)throw new Error("ipaddr: address outside defined range");return B.push(l(x[0])),B.push(m>>16&255),B.push(m>>8&255),B.push(m&255),B}():(d=p.match(r.threeOctet))?function(){let x=d.slice(1,5),B=[];if(m=l(x[2]),m>65535||m<0)throw new Error("ipaddr: address outside defined range");return B.push(l(x[0])),B.push(l(x[1])),B.push(m>>8&255),B.push(m&255),B}():null},h.IPv4.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>32)throw new Error("ipaddr: invalid IPv4 prefix length");let d=[0,0,0,0],g=0,m=Math.floor(p/8);for(;g<m;)d[g]=255,g++;return m<4&&(d[m]=Math.pow(2,p%8)-1<<8-p%8),new this(d)},h.IPv6=function(){function p(d,g){let m,x;if(d.length===16)for(this.parts=[],m=0;m<=14;m+=2)this.parts.push(d[m]<<8|d[m+1]);else if(d.length===8)this.parts=d;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(m=0;m<this.parts.length;m++)if(x=this.parts[m],!(0<=x&&x<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");g&&(this.zoneId=g)}return p.prototype.SpecialRanges={unspecified:[new p([0,0,0,0,0,0,0,0]),128],linkLocal:[new p([65152,0,0,0,0,0,0,0]),10],multicast:[new p([65280,0,0,0,0,0,0,0]),8],loopback:[new p([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new p([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new p([0,0,0,0,0,65535,0,0]),96],rfc6145:[new p([0,0,0,0,65535,0,0,0]),96],rfc6052:[new p([100,65435,0,0,0,0,0,0]),96],"6to4":[new p([8194,0,0,0,0,0,0,0]),16],teredo:[new p([8193,0,0,0,0,0,0,0]),32],reserved:[[new p([8193,3512,0,0,0,0,0,0]),32]]},p.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},p.prototype.kind=function(){return"ipv6"},p.prototype.match=function(d,g){let m;if(g===void 0&&(m=d,d=m[0],g=m[1]),d.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,d.parts,16,g)},p.prototype.prefixLengthFromSubnetMask=function(){let d=0,g=!1,m={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},x,B;for(let L=7;L>=0;L-=1)if(x=this.parts[L],x in m){if(B=m[x],g&&B!==0)return null;B!==16&&(g=!0),d+=B}else return null;return 128-d},p.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let d,g=[],m=this.parts;for(let x=0;x<m.length;x++)d=m[x],g.push(d>>8),g.push(d&255);return g},p.prototype.toFixedLengthString=function(){let d=function(){let m=[];for(let x=0;x<this.parts.length;x++)m.push(f(this.parts[x].toString(16),4));return m}.call(this).join(":"),g="";return this.zoneId&&(g=`%${this.zoneId}`),d+g},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let d=this.parts.slice(-2),g=d[0],m=d[1];return new h.IPv4([g>>8,g&255,m>>8,m&255])},p.prototype.toNormalizedString=function(){let d=function(){let m=[];for(let x=0;x<this.parts.length;x++)m.push(this.parts[x].toString(16));return m}.call(this).join(":"),g="";return this.zoneId&&(g=`%${this.zoneId}`),d+g},p.prototype.toRFC5952String=function(){let d=/((^|:)(0(:|$)){2,})/g,g=this.toNormalizedString(),m=0,x=-1,B;for(;B=d.exec(g);)B[0].length>x&&(m=B.index,x=B[0].length);return x<0?g:`${g.substring(0,m)}::${g.substring(m+x)}`},p.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},p}(),h.IPv6.broadcastAddressFromCIDR=function(p){try{let d=this.parseCIDR(p),g=d[0].toByteArray(),m=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],B=0;for(;B<16;)x.push(parseInt(g[B],10)|parseInt(m[B],10)^255),B++;return new this(x)}catch(d){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${d})`)}},h.IPv6.isIPv6=function(p){return this.parser(p)!==null},h.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{let d=this.parser(p);return new this(d.parts,d.zoneId),!0}catch(d){return!1}},h.IPv6.networkAddressFromCIDR=function(p){let d,g,m,x,B;try{for(d=this.parseCIDR(p),m=d[0].toByteArray(),B=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],g=0;g<16;)x.push(parseInt(m[g],10)&parseInt(B[g],10)),g++;return new this(x)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},h.IPv6.parse=function(p){let d=this.parser(p);if(d.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(d.parts,d.zoneId)},h.IPv6.parseCIDR=function(p){let d,g,m;if((g=p.match(/^(.+)\/(\d+)$/))&&(d=parseInt(g[2]),d>=0&&d<=128))return m=[this.parse(g[1]),d],Object.defineProperty(m,"toString",{value:function(){return this.join("/")}}),m;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},h.IPv6.parser=function(p){let d,g,m,x,B,L;if(m=p.match(a.deprecatedTransitional))return this.parser(`::ffff:${m[1]}`);if(a.native.test(p))return c(p,8);if((m=p.match(a.transitional))&&(L=m[6]||"",d=c(m[1].slice(0,-1)+L,6),d.parts)){for(B=[parseInt(m[2]),parseInt(m[3]),parseInt(m[4]),parseInt(m[5])],g=0;g<B.length;g++)if(x=B[g],!(0<=x&&x<=255))return null;return d.parts.push(B[0]<<8|B[1]),d.parts.push(B[2]<<8|B[3]),{parts:d.parts,zoneId:d.zoneId}}return null},h.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");let d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g=0,m=Math.floor(p/8);for(;g<m;)d[g]=255,g++;return m<16&&(d[m]=Math.pow(2,p%8)-1<<8-p%8),new this(d)},h.fromByteArray=function(p){let d=p.length;if(d===4)return new h.IPv4(p);if(d===16)return new h.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},h.isValid=function(p){return h.IPv6.isValid(p)||h.IPv4.isValid(p)},h.parse=function(p){if(h.IPv6.isValid(p))return h.IPv6.parse(p);if(h.IPv4.isValid(p))return h.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},h.parseCIDR=function(p){try{return h.IPv6.parseCIDR(p)}catch(d){try{return h.IPv4.parseCIDR(p)}catch(g){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},h.process=function(p){let d=this.parse(p);return d.kind()==="ipv6"&&d.isIPv4MappedAddress()?d.toIPv4Address():d},h.subnetMatch=function(p,d,g){let m,x,B,L;g==null&&(g="unicast");for(x in d)if(Object.prototype.hasOwnProperty.call(d,x)){for(B=d[x],B[0]&&!(B[0]instanceof Array)&&(B=[B]),m=0;m<B.length;m++)if(L=B[m],p.kind()===L[0].kind()&&p.match.apply(p,L))return x}return g},typeof eu!="undefined"&&eu.exports?eu.exports=h:t.ipaddr=h})(yb)});var Eb=w(da=>{"use strict";var mb=da&&da.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(da,"__esModule",{value:!0});var PN=pb(),NN=mb(If()),ON=mb(Rf()),vb=gb(),DN=["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"],LN=DN.map(t=>new PN.Netmask(t));function kN(t){for(let e of LN)if(e.contains(t))return!0;return!1}function bb(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}da.default=t=>{if(vb.isValid(t)){let e=vb.parse(t);if(e.kind()==="ipv4")return kN(e.toNormalizedString());if(e.kind()==="ipv6")return bb(t)}else if(ON.default(t)&&NN.default.v6().test(t))return bb(t)}});var lh=w((xM,wb)=>{"use strict";wb.exports=Eb().default});var xb=w((SM,_b)=>{"use strict";var qN=lh();function UN(t){let{address:e}=t.nodeAddress();return qN(e)}_b.exports=UN});var fh=w((AM,Ab)=>{"use strict";var Sb=xb();function MN(t,e){let r=Sb(t.multiaddr),n=Sb(e.multiaddr);return r&&!n?1:!r&&n||t.isCertified&&!e.isCertified?-1:!t.isCertified&&e.isCertified?1:0}function FN(t){return[...t].sort(MN)}Ab.exports.publicAddressesFirst=FN});var Ib=w((CM,hh)=>{"use strict";var Cb=async t=>{try{let e=await t;return{isFulfilled:!0,isRejected:!1,value:e}}catch(e){return{isFulfilled:!1,isRejected:!0,reason:e}}};hh.exports=Cb;hh.exports.default=Cb});var Rb=w((IM,dh)=>{"use strict";var Tb=(t,...e)=>new Promise(r=>{r(t(...e))});dh.exports=Tb;dh.exports.default=Tb});var Pb=w((TM,ph)=>{"use strict";var KN=Rb(),Bb=t=>{if(!((Number.isInteger(t)||t===1/0)&&t>0))return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));let e=[],r=0,n=()=>{r--,e.length>0&&e.shift()()},i=(a,c,...u)=>{r++;let l=KN(a,...u);c(l),l.then(n,n)},s=(a,c,...u)=>{r<t?i(a,c,...u):e.push(i.bind(null,a,c,...u))},o=(a,...c)=>new Promise(u=>s(a,u,...c));return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>e.length},clearQueue:{value:()=>{e.length=0}}}),o};ph.exports=Bb;ph.exports.default=Bb});var Ob=w((RM,Nb)=>{"use strict";var yh=Ib(),VN=Pb();Nb.exports=async(t,e={})=>{let{concurrency:r=1/0}=e,n=VN(r);return Promise.all(t.map(i=>i&&typeof i.then=="function"?yh(i):yh(typeof i=="function"?n(()=>i()):Promise.resolve(i))))}});var kb=w((BM,Lb)=>{"use strict";var Fs=Ln(),Db=Fs.Reader,jN=Fs.Writer,Je=Fs.util,pa=Fs.roots["libp2p-envelope"]||(Fs.roots["libp2p-envelope"]={});pa.Envelope=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.publicKey=Je.newBuffer([]),t.prototype.payloadType=Je.newBuffer([]),t.prototype.payload=Je.newBuffer([]),t.prototype.signature=Je.newBuffer([]),t.encode=function(r,n){return n||(n=jN.create()),r.publicKey!=null&&Object.hasOwnProperty.call(r,"publicKey")&&n.uint32(10).bytes(r.publicKey),r.payloadType!=null&&Object.hasOwnProperty.call(r,"payloadType")&&n.uint32(18).bytes(r.payloadType),r.payload!=null&&Object.hasOwnProperty.call(r,"payload")&&n.uint32(26).bytes(r.payload),r.signature!=null&&Object.hasOwnProperty.call(r,"signature")&&n.uint32(42).bytes(r.signature),n},t.decode=function(r,n){r instanceof Db||(r=Db.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new pa.Envelope;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.publicKey=r.bytes();break;case 2:s.payloadType=r.bytes();break;case 3:s.payload=r.bytes();break;case 5:s.signature=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof pa.Envelope)return r;var n=new pa.Envelope;return r.publicKey!=null&&(typeof r.publicKey=="string"?Je.base64.decode(r.publicKey,n.publicKey=Je.newBuffer(Je.base64.length(r.publicKey)),0):r.publicKey.length&&(n.publicKey=r.publicKey)),r.payloadType!=null&&(typeof r.payloadType=="string"?Je.base64.decode(r.payloadType,n.payloadType=Je.newBuffer(Je.base64.length(r.payloadType)),0):r.payloadType.length&&(n.payloadType=r.payloadType)),r.payload!=null&&(typeof r.payload=="string"?Je.base64.decode(r.payload,n.payload=Je.newBuffer(Je.base64.length(r.payload)),0):r.payload.length&&(n.payload=r.payload)),r.signature!=null&&(typeof r.signature=="string"?Je.base64.decode(r.signature,n.signature=Je.newBuffer(Je.base64.length(r.signature)),0):r.signature.length&&(n.signature=r.signature)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(n.bytes===String?i.publicKey="":(i.publicKey=[],n.bytes!==Array&&(i.publicKey=Je.newBuffer(i.publicKey))),n.bytes===String?i.payloadType="":(i.payloadType=[],n.bytes!==Array&&(i.payloadType=Je.newBuffer(i.payloadType))),n.bytes===String?i.payload="":(i.payload=[],n.bytes!==Array&&(i.payload=Je.newBuffer(i.payload))),n.bytes===String?i.signature="":(i.signature=[],n.bytes!==Array&&(i.signature=Je.newBuffer(i.signature)))),r.publicKey!=null&&r.hasOwnProperty("publicKey")&&(i.publicKey=n.bytes===String?Je.base64.encode(r.publicKey,0,r.publicKey.length):n.bytes===Array?Array.prototype.slice.call(r.publicKey):r.publicKey),r.payloadType!=null&&r.hasOwnProperty("payloadType")&&(i.payloadType=n.bytes===String?Je.base64.encode(r.payloadType,0,r.payloadType.length):n.bytes===Array?Array.prototype.slice.call(r.payloadType):r.payloadType),r.payload!=null&&r.hasOwnProperty("payload")&&(i.payload=n.bytes===String?Je.base64.encode(r.payload,0,r.payload.length):n.bytes===Array?Array.prototype.slice.call(r.payload):r.payload),r.signature!=null&&r.hasOwnProperty("signature")&&(i.signature=n.bytes===String?Je.base64.encode(r.signature,0,r.signature.length):n.bytes===Array?Array.prototype.slice.call(r.signature):r.signature),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,Fs.util.toJSONOptions)},t}();Lb.exports=pa});var ru=w((PM,Mb)=>{"use strict";var $N=pe(),{concat:HN}=($n(),jn),{fromString:zN}=(Ct(),Pt),GN=Nc(),WN=Tt(),gh=Di(),{equals:tu}=(yr(),pr),{codes:YN}=He(),{Envelope:qb}=kb(),ti=class{constructor({peerId:e,payloadType:r,payload:n,signature:i}){this.peerId=e,this.payloadType=r,this.payload=n,this.signature=i,this._marshal=void 0}marshal(){if(this._marshal)return this._marshal;let e=GN.marshalPublicKey(this.peerId.pubKey);return this._marshal=qb.encode({publicKey:e,payloadType:this.payloadType,payload:this.payload,signature:this.signature}).finish(),this._marshal}equals(e){return tu(this.peerId.pubKey.bytes,e.peerId.pubKey.bytes)&&tu(this.payloadType,e.payloadType)&&tu(this.payload,e.payload)&&tu(this.signature,e.signature)}validate(e){let r=Ub(e,this.payloadType,this.payload);return this.peerId.pubKey.verify(r,this.signature)}},Ub=(t,e,r)=>{let n=zN(t),i=gh.encode(n.byteLength),s=gh.encode(e.length),o=gh.encode(r.length);return HN([new Uint8Array(i),n,new Uint8Array(s),e,new Uint8Array(o),r])};ti.createFromProtobuf=async t=>{let e=qb.decode(t),r=await WN.createFromPubKey(e.publicKey);return new ti({peerId:r,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};ti.seal=async(t,e)=>{let r=t.domain,n=t.codec,i=t.marshal(),s=Ub(r,n,i),o=await e.privKey.sign(s);return new ti({peerId:e,payloadType:n,payload:i,signature:o})};ti.openAndCertify=async(t,e)=>{let r=await ti.createFromProtobuf(t);if(!await r.validate(e))throw $N(new Error("envelope signature is not valid for the given domain"),YN.ERR_SIGNATURE_NOT_VALID);return r};Mb.exports=ti});var Kb=w((NM,Fb)=>{"use strict";function QN(t,e){return t.length===e.length&&e.sort()&&t.sort().every((r,n)=>e[n].equals(r))}Fb.exports=QN});var $b=w((OM,jb)=>{"use strict";var Ui=Ln(),nu=Ui.Reader,Vb=Ui.Writer,ut=Ui.util,wr=Ui.roots["libp2p-peer-record"]||(Ui.roots["libp2p-peer-record"]={});wr.PeerRecord=function(){function t(e){if(this.addresses=[],e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.peerId=ut.newBuffer([]),t.prototype.seq=ut.Long?ut.Long.fromBits(0,0,!0):0,t.prototype.addresses=ut.emptyArray,t.encode=function(r,n){if(n||(n=Vb.create()),r.peerId!=null&&Object.hasOwnProperty.call(r,"peerId")&&n.uint32(10).bytes(r.peerId),r.seq!=null&&Object.hasOwnProperty.call(r,"seq")&&n.uint32(16).uint64(r.seq),r.addresses!=null&&r.addresses.length)for(var i=0;i<r.addresses.length;++i)wr.PeerRecord.AddressInfo.encode(r.addresses[i],n.uint32(26).fork()).ldelim();return n},t.decode=function(r,n){r instanceof nu||(r=nu.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new wr.PeerRecord;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses&&s.addresses.length||(s.addresses=[]),s.addresses.push(wr.PeerRecord.AddressInfo.decode(r,r.uint32()));break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof wr.PeerRecord)return r;var n=new wr.PeerRecord;if(r.peerId!=null&&(typeof r.peerId=="string"?ut.base64.decode(r.peerId,n.peerId=ut.newBuffer(ut.base64.length(r.peerId)),0):r.peerId.length&&(n.peerId=r.peerId)),r.seq!=null&&(ut.Long?(n.seq=ut.Long.fromValue(r.seq)).unsigned=!0:typeof r.seq=="string"?n.seq=parseInt(r.seq,10):typeof r.seq=="number"?n.seq=r.seq:typeof r.seq=="object"&&(n.seq=new ut.LongBits(r.seq.low>>>0,r.seq.high>>>0).toNumber(!0))),r.addresses){if(!Array.isArray(r.addresses))throw TypeError(".PeerRecord.addresses: array expected");n.addresses=[];for(var i=0;i<r.addresses.length;++i){if(typeof r.addresses[i]!="object")throw TypeError(".PeerRecord.addresses: object expected");n.addresses[i]=wr.PeerRecord.AddressInfo.fromObject(r.addresses[i])}}return n},t.toObject=function(r,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.addresses=[]),n.defaults)if(n.bytes===String?i.peerId="":(i.peerId=[],n.bytes!==Array&&(i.peerId=ut.newBuffer(i.peerId))),ut.Long){var s=new ut.Long(0,0,!0);i.seq=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.seq=n.longs===String?"0":0;if(r.peerId!=null&&r.hasOwnProperty("peerId")&&(i.peerId=n.bytes===String?ut.base64.encode(r.peerId,0,r.peerId.length):n.bytes===Array?Array.prototype.slice.call(r.peerId):r.peerId),r.seq!=null&&r.hasOwnProperty("seq")&&(typeof r.seq=="number"?i.seq=n.longs===String?String(r.seq):r.seq:i.seq=n.longs===String?ut.Long.prototype.toString.call(r.seq):n.longs===Number?new ut.LongBits(r.seq.low>>>0,r.seq.high>>>0).toNumber(!0):r.seq),r.addresses&&r.addresses.length){i.addresses=[];for(var o=0;o<r.addresses.length;++o)i.addresses[o]=wr.PeerRecord.AddressInfo.toObject(r.addresses[o],n)}return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,Ui.util.toJSONOptions)},t.AddressInfo=function(){function e(r){if(r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}return e.prototype.multiaddr=ut.newBuffer([]),e.encode=function(n,i){return i||(i=Vb.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),i},e.decode=function(n,i){n instanceof nu||(n=nu.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new wr.PeerRecord.AddressInfo;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.multiaddr=n.bytes();break;default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof wr.PeerRecord.AddressInfo)return n;var i=new wr.PeerRecord.AddressInfo;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?ut.base64.decode(n.multiaddr,i.multiaddr=ut.newBuffer(ut.base64.length(n.multiaddr)),0):n.multiaddr.length&&(i.multiaddr=n.multiaddr)),i},e.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.multiaddr="":(s.multiaddr=[],i.bytes!==Array&&(s.multiaddr=ut.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?ut.base64.encode(n.multiaddr,0,n.multiaddr.length):i.bytes===Array?Array.prototype.slice.call(n.multiaddr):n.multiaddr),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Ui.util.toJSONOptions)},e}(),t}();jb.exports=wr});var zb=w((DM,Hb)=>{"use strict";var XN="libp2p-peer-record",ZN=Uint8Array.from([3,1]);Hb.exports={ENVELOPE_DOMAIN_PEER_RECORD:XN,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:ZN}});var iu=w((LM,Yb)=>{"use strict";var{Multiaddr:JN}=kt(),e3=Tt(),t3=Kb(),{PeerRecord:Gb}=$b(),{ENVELOPE_DOMAIN_PEER_RECORD:Wb,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:r3}=zb(),Mi=class{constructor({peerId:e,multiaddrs:r=[],seqNumber:n=Date.now()}){this.domain=Wb,this.codec=r3,this.peerId=e,this.multiaddrs=r,this.seqNumber=n,this._marshal=void 0}marshal(){return this._marshal?this._marshal:(this._marshal=Gb.encode({peerId:this.peerId.toBytes(),seq:this.seqNumber,addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))}).finish(),this._marshal)}equals(e){return!(!(e instanceof Mi)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!t3(this.multiaddrs,e.multiaddrs))}};Mi.createFromProtobuf=t=>{let e=Gb.decode(t),r=e3.createFromBytes(e.peerId),n=(e.addresses||[]).map(s=>new JN(s.multiaddr)),i=Number(e.seq);return new Mi({peerId:r,multiaddrs:n,seqNumber:i})};Mi.DOMAIN=Wb;Yb.exports=Mi});var mh=w((kM,Qb)=>{"use strict";var n3=ru(),i3=iu();async function s3(t){let e=new i3({peerId:t.peerId,multiaddrs:t.multiaddrs}),r=await n3.seal(e,t.peerId);await t.peerStore.addressBook.consumePeerRecord(r)}Qb.exports.updateSelfPeerRecord=s3});var bh=w((qM,Jb)=>{"use strict";var Xb=Be(),Fi=Object.assign(Xb("libp2p:transports"),{error:Xb("libp2p:transports:err")}),o3=Ob(),{codes:Ks}=He(),ya=pe(),{updateSelfPeerRecord:Zb}=mh(),vh=class{constructor({libp2p:e,upgrader:r,faultTolerance:n=su.FATAL_ALL}){this.libp2p=e,this.upgrader=r,this._transports=new Map,this._listeners=new Map,this._listenerOptions=new Map,this.faultTolerance=n}add(e,r,n={}){if(Fi("adding %s",e),!e)throw ya(new Error(`Transport must have a valid key, was given '${e}'`),Ks.ERR_INVALID_KEY);if(this._transports.has(e))throw ya(new Error("There is already a transport with this key"),Ks.ERR_DUPLICATE_TRANSPORT);let i=new r({...n,libp2p:this.libp2p,upgrader:this.upgrader});this._transports.set(e,i),this._listenerOptions.set(e,n.listenerOptions||{}),this._listeners.has(e)||this._listeners.set(e,[])}async close(){let e=[];for(let[r,n]of this._listeners)for(Fi("closing listeners for %s",r);n.length;){let i=n.pop();i.removeAllListeners("listening"),i.removeAllListeners("close"),e.push(i.close())}await Promise.all(e),Fi("all listeners closed");for(let r of this._listeners.keys())this._listeners.set(r,[])}async dial(e,r){let n=this.transportForMultiaddr(e);if(!n)throw ya(new Error(`No transport available for address ${String(e)}`),Ks.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(e,r)}catch(i){throw i.code||(i.code=Ks.ERR_TRANSPORT_DIAL_FAILED),i}}getAddrs(){let e=[];for(let r of this._listeners.values())for(let n of r)e=[...e,...n.getAddrs()];return e}getTransports(){return this._transports.values()}transportForMultiaddr(e){for(let r of this._transports.values())if(r.filter([e]).length)return r;return null}async listen(e){if(!e||e.length===0){Fi("no addresses were provided for listening, this node is dial only");return}let r=[];for(let[n,i]of this._transports.entries()){let s=i.filter(e),o=[];for(let u of s){Fi("creating listener for %s on %s",n,u);let l=i.createListener(this._listenerOptions.get(n));this._listeners.get(n).push(l),l.on("listening",()=>Zb(this.libp2p)),l.on("close",()=>Zb(this.libp2p)),o.push(l.listen(u))}if(o.length===0){r.push(n);continue}if(!(await o3(o)).find(u=>u.isFulfilled===!0)&&this.faultTolerance!==su.NO_FATAL)throw ya(new Error(`Transport (${n}) could not listen on any available address`),Ks.ERR_NO_VALID_ADDRESSES)}if(r.length===this._transports.size){let n=`no valid addresses were provided for transports [${r}]`;if(this.faultTolerance===su.FATAL_ALL)throw ya(new Error(n),Ks.ERR_NO_VALID_ADDRESSES);Fi(`libp2p in dial mode only: ${n}`)}}async remove(e){if(Fi("removing %s",e),this._listeners.has(e))for(let r of this._listeners.get(e))r.removeAllListeners("listening"),r.removeAllListeners("close"),await r.close();this._transports.delete(e),this._listeners.delete(e)}async removeAll(){let e=[];for(let r of this._transports.keys())e.push(this.remove(r));await Promise.all(e)}},su={FATAL_ALL:0,NO_FATAL:1};vh.FaultTolerance=su;Jb.exports=vh});var rE=w((UM,tE)=>{"use strict";var a3=Us(),{dnsaddrResolver:c3}=lb(),Eh=Zc(),{AGENT_VERSION:u3}=uh(),eE=Jc(),{publicAddressesFirst:l3}=fh(),{FaultTolerance:f3}=bh(),h3={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:t=>t},connectionManager:{minConnections:25},transportManager:{faultTolerance:f3.FATAL_ALL},dialer:{maxParallelDials:Eh.MAX_PARALLEL_DIALS,maxDialsPerPeer:Eh.MAX_PER_PEER_DIALS,dialTimeout:Eh.DIAL_TIMEOUT,resolvers:{dnsaddr:c3},addressSorter:l3},host:{agentVersion:u3},metrics:{enabled:!1},peerStore:{persistence:!1,threshold:5},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},config:{protocolPrefix:"ipfs",dht:{enabled:!1,kBucketSize:20},nat:{enabled:!0,ttl:7200,keepAlive:!0,gateway:null,externalIp:null,pmp:{enabled:!1}},peerDiscovery:{autoDial:!0},pubsub:{enabled:!0},relay:{enabled:!0,advertise:{bootDelay:eE.ADVERTISE_BOOT_DELAY,enabled:!1,ttl:eE.ADVERTISE_TTL},hop:{enabled:!1,active:!1},autoRelay:{enabled:!1,maxListeners:2}},transport:{}}};tE.exports.validate=t=>{let e=a3(h3,t);if(e.modules.transport.length<1)throw new Error("'options.modules.transport' must contain at least 1 transport");return e}});var sE=w((MM,iE)=>{"use strict";var{EventEmitter:d3}=Qt(),{Multiaddr:ga}=kt(),p3=Tt(),nE=class extends d3{constructor(e,{listen:r=[],announce:n=[]}={}){super();this.peerId=e,this.listen=new Set(r.map(i=>i.toString())),this.announce=new Set(n.map(i=>i.toString())),this.observed=new Set}getListenAddrs(){return Array.from(this.listen).map(e=>new ga(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new ga(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new ga(e))}addObservedAddr(e){let r=new ga(e),n=r.getPeerId();n&&p3.createFromB58String(n).equals(this.peerId)&&(r=r.decapsulate(new ga(`/p2p/${this.peerId}`)));let i=r.toString();this.observed.has(i)||(this.observed.add(i),this.emit("change:addresses"))}};iE.exports=nE});var cE=w((FM,aE)=>{"use strict";var{EventEmitter:y3}=Qt(),wh=Be()("latency-monitor:VisibilityChangeEmitter"),oE=class extends y3{constructor(){super();if(typeof document=="undefined"){wh('This is not a browser, no "document" found. Stopping.');return}this._initializeVisibilityVarNames(),this._addVisibilityChangeListener()}_initializeVisibilityVarNames(){let e,r;typeof document.hidden!="undefined"?(e="hidden",r="visibilitychange"):typeof document.mozHidden!="undefined"?(e="mozHidden",r="mozvisibilitychange"):typeof document.msHidden!="undefined"?(e="msHidden",r="msvisibilitychange"):typeof document.webkitHidden!="undefined"&&(e="webkitHidden",r="webkitvisibilitychange"),this._hidden=e,this._visibilityChange=r}_addVisibilityChangeListener(){typeof document.addEventListener=="undefined"||typeof document[this._hidden]=="undefined"?wh("Checking page visibility requires a browser that supports the Page Visibility API."):document.addEventListener(this._visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(!(this._hidden===void 0||document[this._hidden]===void 0))return!document[this._hidden]}_handleVisibilityChange(){let e=!document[this._hidden];wh(e?"Page Visible":"Page Hidden"),this.emit("visibilityChange",e)}};aE.exports=oE});var fE=w((KM,lE)=>{"use strict";var{EventEmitter:g3}=Qt(),m3=cE(),wn=Be()("latency-monitor:LatencyMonitor"),uE=class extends g3{constructor({latencyCheckIntervalMs:e,dataEmitIntervalMs:r,asyncTestFn:n,latencyRandomPercentage:i}={}){super();let s=this;s.latencyCheckIntervalMs=e||500,s.latencyRandomPercentage=i||10,s._latecyCheckMultiply=2*(s.latencyRandomPercentage/100)*s.latencyCheckIntervalMs,s._latecyCheckSubtract=s._latecyCheckMultiply/2,s.dataEmitIntervalMs=r===null||r===0?void 0:r||5*1e3,wn("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",s.latencyCheckIntervalMs,s.dataEmitIntervalMs),s.dataEmitIntervalMs?wn("Expecting ~%s events per summary",s.latencyCheckIntervalMs/s.dataEmitIntervalMs):wn("Not emitting summaries"),s.asyncTestFn=n}start(){globalThis.process&&globalThis.process.hrtime?(wn("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=e=>{let r=this.now(e);return r[0]*1e3+r[1]/1e6}):typeof window!="undefined"&&window.performance&&window.performance.now?(wn("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=e=>Math.round(this.now()-e)):(wn("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=e=>this.now()-e),this._latencyData=this._initLatencyData(),v3()&&(this._visibilityChangeEmitter=new m3,this._visibilityChangeEmitter.on("visibilityChange",e=>{e?this._startTimers():(this._emitSummary(),this._stopTimers())})),(!this._visibilityChangeEmitter||this._visibilityChangeEmitter.isVisible())&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),typeof this._emitIntervalID.unref=="function"&&this._emitIntervalID.unref()))}_stopTimers(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}_emitSummary(){let e=this.getSummary();e.events>0&&this.emit("data",e)}getSummary(){let e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),wn("Summary: %O",e),e}_checkLatency(){let e=this,r=Math.random()*e._latecyCheckMultiply-e._latecyCheckSubtract,n={deltaOffset:Math.ceil(e.latencyCheckIntervalMs+r),startTime:e.now()},i=()=>{if(!this._checkLatencyID)return;let s=e.getDeltaMS(n.startTime)-n.deltaOffset;e._checkLatency(),e._latencyData.events++,e._latencyData.minMs=Math.min(e._latencyData.minMs,s),e._latencyData.maxMs=Math.max(e._latencyData.maxMs,s),e._latencyData.totalMs+=s,wn("MS: %s Data: %O",s,e._latencyData)};wn("localData: %O",n),this._checkLatencyID=setTimeout(()=>{e.asyncTestFn?(n.deltaOffset=0,n.startTime=e.now(),e.asyncTestFn(i)):(n.deltaOffset-=1,i())},n.deltaOffset),typeof this._checkLatencyID.unref=="function"&&this._checkLatencyID.unref()}_initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}};function v3(){return typeof window!="undefined"}lE.exports=uE});var _h=w((VM,dE)=>{"use strict";var hE=class extends Map{constructor(e){super();let{system:r,component:n,metric:i,metrics:s}=e;this._system=r,this._component=n,this._metric=i,this._metrics=s,this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size})}set(e,r){return super.set(e,r),this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size}),this}delete(e){let r=super.delete(e);return this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size}),r}clear(){super.clear(),this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size})}};dE.exports=({system:t="libp2p",component:e,metric:r,metrics:n})=>{let i;return n?i=new hE({system:t,component:e,metric:r,metrics:n}):i=new Map,i}});var _E=w((jM,wE)=>{"use strict";var pE=Be(),kr=Object.assign(pE("libp2p:connection-manager"),{error:pE("libp2p:connection-manager:err")}),yE=pe(),b3=Us(),E3=fE(),gE=ca(),{EventEmitter:w3}=Qt(),mE=_h(),_3=Tt(),{codes:{ERR_INVALID_PARAMETERS:vE}}=He(),x3={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,defaultPeerValue:1},bE="connection-manager",S3="peer-connections",A3="peer-values",EE=class extends w3{constructor(e,r={}){super();if(this._libp2p=e,this._peerId=e.peerId.toB58String(),this._options=b3.call({ignoreUndefined:!0},x3,r),this._options.maxConnections<this._options.minConnections)throw yE(new Error("Connection Manager maxConnections must be greater than minConnections"),vE);kr("options: %j",this._options),this._peerValues=mE({component:bE,metric:A3,metrics:this._libp2p.metrics}),this.connections=mE({component:bE,metric:S3,metrics:this._libp2p.metrics}),this._started=!1,this._timer=null,this._checkMetrics=this._checkMetrics.bind(this),this._latencyMonitor=new E3({latencyCheckIntervalMs:this._options.pollInterval,dataEmitIntervalMs:this._options.pollInterval})}get size(){return Array.from(this.connections.values()).reduce((e,r)=>e+r.length,0)}start(){this._libp2p.metrics&&(this._timer=this._timer||gE(this._checkMetrics,this._options.pollInterval)),this._latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure),this._started=!0,kr("started")}async stop(){this._timer&&this._timer.clear(),this._latencyMonitor.removeListener("data",this._onLatencyMeasure),this._latencyMonitor.stop(),this._started=!1,await this._close(),kr("stopped")}async _close(){let e=[];for(let r of this.connections.values())for(let n of r)e.push(n.close());await Promise.all(e),this.connections.clear()}setPeerValue(e,r){if(r<0||r>1)throw new Error("value should be a number between 0 and 1");this._peerValues.set(e.toB58String(),r)}async _checkMetrics(){if(this._libp2p.metrics)try{let e=this._libp2p.metrics.global.movingAverages,r=e.dataReceived[this._options.movingAverageInterval].movingAverage();await this._checkMaxLimit("maxReceivedData",r);let n=e.dataSent[this._options.movingAverageInterval].movingAverage();await this._checkMaxLimit("maxSentData",n);let i=r+n;await this._checkMaxLimit("maxData",i),kr("metrics update",i)}finally{this._timer=gE(this._checkMetrics,this._options.pollInterval)}}async onConnect(e){let r=e.remotePeer,n=r.toB58String(),i=this.connections.get(n);this.emit("peer:connect",e),i?i.push(e):this.connections.set(n,[e]),await this._libp2p.peerStore.keyBook.set(r,r.pubKey),this._peerValues.has(n)||this._peerValues.set(n,this._options.defaultPeerValue),await this._checkMaxLimit("maxConnections",this.size)}onDisconnect(e){let r=e.remotePeer.toB58String(),n=this.connections.get(r);n&&n.length>1?(n=n.filter(i=>i.id!==e.id),this.connections.set(r,n)):n&&(this.connections.delete(r),this._peerValues.delete(e.remotePeer.toB58String()),this.emit("peer:disconnect",e),this._libp2p.metrics&&this._libp2p.metrics.onPeerDisconnected(e.remotePeer))}get(e){let r=this.getAll(e);return r.length?r[0]:null}getAll(e){if(!_3.isPeerId(e))throw yE(new Error("peerId must be an instance of peer-id"),vE);let r=e.toB58String(),n=this.connections.get(r);return n?n.filter(i=>i.stat.status==="open"):[]}_onLatencyMeasure(e){this._checkMaxLimit("maxEventLoopDelay",e.avgMs).catch(r=>{kr.error(r)})}async _checkMaxLimit(e,r){let n=this._options[e];kr("checking limit of %s. current value: %d of %d",e,r,n),r>n&&(kr("%s: limit exceeded: %s, %d",this._peerId,e,r),await this._maybeDisconnectOne())}async _maybeDisconnectOne(){if(this._options.minConnections<this.connections.size){let e=Array.from(new Map([...this._peerValues.entries()].sort((n,i)=>n[1]-i[1])));kr("%s: sorted peer values: %j",this._peerId,e);let r=e[0];if(r){let n=r[0];kr("%s: lowest value peer is %s",this._peerId,n),kr("%s: closing a connection to %j",this._peerId,n);for(let i of this.connections.values())if(i[0].remotePeer.toB58String()===n){i[0].close().catch(s=>{kr.error(s)}),this.onDisconnect(i[0]);break}}}}};wE.exports=EE});var IE=w(($M,CE)=>{"use strict";var xE=Be(),C3=Us(),SE=ca(),I3=Ff(),ri=Object.assign(xE("libp2p:connection-manager:auto-dialler"),{error:xE("libp2p:connection-manager:auto-dialler:err")}),T3={enabled:!0,minConnections:0,autoDialInterval:1e4},AE=class{constructor(e,r={}){this._options=C3.call({ignoreUndefined:!0},T3,r),this._libp2p=e,this._running=!1,this._autoDialTimeout=null,this._autoDial=this._autoDial.bind(this),ri("options: %j",this._options)}async start(){if(!this._options.enabled){ri("not enabled");return}this._running=!0,this._autoDial().catch(e=>{ri.error("could start autodial",e)}),ri("started")}async stop(){if(!this._options.enabled){ri("not enabled");return}this._running=!1,this._autoDialTimeout&&this._autoDialTimeout.clear(),ri("stopped")}async _autoDial(){let e=this._options.minConnections;if(this._libp2p.connections.size>=e){this._autoDialTimeout=SE(this._autoDial,this._options.autoDialInterval);return}let r=(await I3(this._libp2p.peerStore.getPeers())).sort((n,i)=>i.protocols&&i.protocols.length&&(!n.protocols||!n.protocols.length)||i.id.pubKey&&!n.id.pubKey?1:-1);for(let n=0;this._running&&n<r.length&&this._libp2p.connections.size<e;n++)if(!this._libp2p.connectionManager.get(r[n].id)){ri("connecting to a peerStore stored peer %s",r[n].id.toB58String());try{await this._libp2p.dialer.connectToPeer(r[n].id)}catch(i){ri.error("could not connect to peerStore stored peer",i)}}!this._running||(this._autoDialTimeout=SE(this._autoDial,this._options.autoDialInterval))}};CE.exports=AE});var UE=w((HM,qE)=>{"use strict";var{Multiaddr:xh}=kt(),TE=ce("dns4"),RE=ce("dns6"),BE=ce("dnsaddr"),Ki=qt(ce("dns"),BE,TE,RE),ma=qt(ce("ip4"),ce("ip6")),Vs=qt(be(ma,ce("tcp")),be(Ki,ce("tcp"))),Sh=be(ma,ce("udp")),PE=be(Sh,ce("utp")),NE=be(Sh,ce("quic")),js=qt(be(Vs,ce("ws")),be(Ki,ce("ws"))),$s=qt(be(Vs,ce("wss")),be(Ki,ce("wss"))),ou=qt(be(Vs,ce("http")),be(ma,ce("http")),be(Ki,ce("http"))),au=qt(be(Vs,ce("https")),be(ma,ce("https")),be(Ki,ce("https"))),Ah=qt(be(js,ce("p2p-webrtc-star"),ce("p2p")),be($s,ce("p2p-webrtc-star"),ce("p2p")),be(js,ce("p2p-webrtc-star")),be($s,ce("p2p-webrtc-star"))),R3=qt(be(js,ce("p2p-websocket-star"),ce("p2p")),be($s,ce("p2p-websocket-star"),ce("p2p")),be(js,ce("p2p-websocket-star")),be($s,ce("p2p-websocket-star"))),Ch=qt(be(ou,ce("p2p-webrtc-direct"),ce("p2p")),be(au,ce("p2p-webrtc-direct"),ce("p2p")),be(ou,ce("p2p-webrtc-direct")),be(au,ce("p2p-webrtc-direct"))),Hs=qt(js,$s,ou,au,Ah,Ch,Vs,PE,NE,Ki),B3=qt(be(Hs,ce("p2p-stardust"),ce("p2p")),be(Hs,ce("p2p-stardust"))),ni=qt(be(Hs,ce("p2p")),Ah,Ch,ce("p2p")),OE=qt(be(ni,ce("p2p-circuit"),ni),be(ni,ce("p2p-circuit")),be(ce("p2p-circuit"),ni),be(Hs,ce("p2p-circuit")),be(ce("p2p-circuit"),Hs),ce("p2p-circuit")),DE=()=>qt(be(OE,DE),OE),zs=DE(),LE=qt(be(zs,ni,zs),be(ni,zs),be(zs,ni),zs,ni);qE.exports={DNS:Ki,DNS4:TE,DNS6:RE,DNSADDR:BE,IP:ma,TCP:Vs,UDP:Sh,QUIC:NE,UTP:PE,HTTP:ou,HTTPS:au,WebSockets:js,WebSocketsSecure:$s,WebSocketStar:R3,WebRTCStar:Ah,WebRTCDirect:Ch,Reliable:Hs,Stardust:B3,Circuit:zs,P2P:LE,IPFS:LE};function kE(t){function e(r){if(!xh.isMultiaddr(r))try{r=new xh(r)}catch(i){return!1}let n=t(r.protoNames());return n===null?!1:n===!0||n===!1?n:n.length===0}return e}function be(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(i=>(n=typeof i=="function"?i().partialMatch(r):i.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:kE(e),partialMatch:e}}function qt(...t){function e(n){let i=null;return t.some(s=>{let o=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return o?(i=o,!0):!1}),i}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:kE(e),partialMatch:e}}function ce(t){let e=t;function r(i){let s;if(typeof i=="string"||i instanceof Uint8Array)try{s=new xh(i)}catch(a){return!1}else s=i;let o=s.protoNames();return o.length===1&&o[0]===e}function n(i){return i.length===0?null:i[0]===e?i.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}});var Gs=w((zM,FE)=>{"use strict";var Vi=Ln(),cu=Vi.Reader,ME=Vi.Writer,_r=Vi.util,St=Vi.roots["libp2p-circuit"]||(Vi.roots["libp2p-circuit"]={});St.CircuitRelay=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.type=1,t.prototype.srcPeer=null,t.prototype.dstPeer=null,t.prototype.code=100,t.encode=function(r,n){return n||(n=ME.create()),r.type!=null&&Object.hasOwnProperty.call(r,"type")&&n.uint32(8).int32(r.type),r.srcPeer!=null&&Object.hasOwnProperty.call(r,"srcPeer")&&St.CircuitRelay.Peer.encode(r.srcPeer,n.uint32(18).fork()).ldelim(),r.dstPeer!=null&&Object.hasOwnProperty.call(r,"dstPeer")&&St.CircuitRelay.Peer.encode(r.dstPeer,n.uint32(26).fork()).ldelim(),r.code!=null&&Object.hasOwnProperty.call(r,"code")&&n.uint32(32).int32(r.code),n},t.decode=function(r,n){r instanceof cu||(r=cu.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new St.CircuitRelay;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.type=r.int32();break;case 2:s.srcPeer=St.CircuitRelay.Peer.decode(r,r.uint32());break;case 3:s.dstPeer=St.CircuitRelay.Peer.decode(r,r.uint32());break;case 4:s.code=r.int32();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof St.CircuitRelay)return r;var n=new St.CircuitRelay;switch(r.type){case"HOP":case 1:n.type=1;break;case"STOP":case 2:n.type=2;break;case"STATUS":case 3:n.type=3;break;case"CAN_HOP":case 4:n.type=4;break}if(r.srcPeer!=null){if(typeof r.srcPeer!="object")throw TypeError(".CircuitRelay.srcPeer: object expected");n.srcPeer=St.CircuitRelay.Peer.fromObject(r.srcPeer)}if(r.dstPeer!=null){if(typeof r.dstPeer!="object")throw TypeError(".CircuitRelay.dstPeer: object expected");n.dstPeer=St.CircuitRelay.Peer.fromObject(r.dstPeer)}switch(r.code){case"SUCCESS":case 100:n.code=100;break;case"HOP_SRC_ADDR_TOO_LONG":case 220:n.code=220;break;case"HOP_DST_ADDR_TOO_LONG":case 221:n.code=221;break;case"HOP_SRC_MULTIADDR_INVALID":case 250:n.code=250;break;case"HOP_DST_MULTIADDR_INVALID":case 251:n.code=251;break;case"HOP_NO_CONN_TO_DST":case 260:n.code=260;break;case"HOP_CANT_DIAL_DST":case 261:n.code=261;break;case"HOP_CANT_OPEN_DST_STREAM":case 262:n.code=262;break;case"HOP_CANT_SPEAK_RELAY":case 270:n.code=270;break;case"HOP_CANT_RELAY_TO_SELF":case 280:n.code=280;break;case"STOP_SRC_ADDR_TOO_LONG":case 320:n.code=320;break;case"STOP_DST_ADDR_TOO_LONG":case 321:n.code=321;break;case"STOP_SRC_MULTIADDR_INVALID":case 350:n.code=350;break;case"STOP_DST_MULTIADDR_INVALID":case 351:n.code=351;break;case"STOP_RELAY_REFUSED":case 390:n.code=390;break;case"MALFORMED_MESSAGE":case 400:n.code=400;break}return n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.type=n.enums===String?"HOP":1,i.srcPeer=null,i.dstPeer=null,i.code=n.enums===String?"SUCCESS":100),r.type!=null&&r.hasOwnProperty("type")&&(i.type=n.enums===String?St.CircuitRelay.Type[r.type]:r.type),r.srcPeer!=null&&r.hasOwnProperty("srcPeer")&&(i.srcPeer=St.CircuitRelay.Peer.toObject(r.srcPeer,n)),r.dstPeer!=null&&r.hasOwnProperty("dstPeer")&&(i.dstPeer=St.CircuitRelay.Peer.toObject(r.dstPeer,n)),r.code!=null&&r.hasOwnProperty("code")&&(i.code=n.enums===String?St.CircuitRelay.Status[r.code]:r.code),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,Vi.util.toJSONOptions)},t.Status=function(){var e={},r=Object.create(e);return r[e[100]="SUCCESS"]=100,r[e[220]="HOP_SRC_ADDR_TOO_LONG"]=220,r[e[221]="HOP_DST_ADDR_TOO_LONG"]=221,r[e[250]="HOP_SRC_MULTIADDR_INVALID"]=250,r[e[251]="HOP_DST_MULTIADDR_INVALID"]=251,r[e[260]="HOP_NO_CONN_TO_DST"]=260,r[e[261]="HOP_CANT_DIAL_DST"]=261,r[e[262]="HOP_CANT_OPEN_DST_STREAM"]=262,r[e[270]="HOP_CANT_SPEAK_RELAY"]=270,r[e[280]="HOP_CANT_RELAY_TO_SELF"]=280,r[e[320]="STOP_SRC_ADDR_TOO_LONG"]=320,r[e[321]="STOP_DST_ADDR_TOO_LONG"]=321,r[e[350]="STOP_SRC_MULTIADDR_INVALID"]=350,r[e[351]="STOP_DST_MULTIADDR_INVALID"]=351,r[e[390]="STOP_RELAY_REFUSED"]=390,r[e[400]="MALFORMED_MESSAGE"]=400,r}(),t.Type=function(){var e={},r=Object.create(e);return r[e[1]="HOP"]=1,r[e[2]="STOP"]=2,r[e[3]="STATUS"]=3,r[e[4]="CAN_HOP"]=4,r}(),t.Peer=function(){function e(r){if(this.addrs=[],r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}return e.prototype.id=_r.newBuffer([]),e.prototype.addrs=_r.emptyArray,e.encode=function(n,i){if(i||(i=ME.create()),i.uint32(10).bytes(n.id),n.addrs!=null&&n.addrs.length)for(var s=0;s<n.addrs.length;++s)i.uint32(18).bytes(n.addrs[s]);return i},e.decode=function(n,i){n instanceof cu||(n=cu.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new St.CircuitRelay.Peer;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.id=n.bytes();break;case 2:o.addrs&&o.addrs.length||(o.addrs=[]),o.addrs.push(n.bytes());break;default:n.skipType(a&7);break}}if(!o.hasOwnProperty("id"))throw _r.ProtocolError("missing required 'id'",{instance:o});return o},e.fromObject=function(n){if(n instanceof St.CircuitRelay.Peer)return n;var i=new St.CircuitRelay.Peer;if(n.id!=null&&(typeof n.id=="string"?_r.base64.decode(n.id,i.id=_r.newBuffer(_r.base64.length(n.id)),0):n.id.length&&(i.id=n.id)),n.addrs){if(!Array.isArray(n.addrs))throw TypeError(".CircuitRelay.Peer.addrs: array expected");i.addrs=[];for(var s=0;s<n.addrs.length;++s)typeof n.addrs[s]=="string"?_r.base64.decode(n.addrs[s],i.addrs[s]=_r.newBuffer(_r.base64.length(n.addrs[s])),0):n.addrs[s].length&&(i.addrs[s]=n.addrs[s])}return i},e.toObject=function(n,i){i||(i={});var s={};if((i.arrays||i.defaults)&&(s.addrs=[]),i.defaults&&(i.bytes===String?s.id="":(s.id=[],i.bytes!==Array&&(s.id=_r.newBuffer(s.id)))),n.id!=null&&n.hasOwnProperty("id")&&(s.id=i.bytes===String?_r.base64.encode(n.id,0,n.id.length):i.bytes===Array?Array.prototype.slice.call(n.id):n.id),n.addrs&&n.addrs.length){s.addrs=[];for(var o=0;o<n.addrs.length;++o)s.addrs[o]=i.bytes===String?_r.base64.encode(n.addrs[o],0,n.addrs[o].length):i.bytes===Array?Array.prototype.slice.call(n.addrs[o]):n.addrs[o]}return s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Vi.util.toJSONOptions)},e}(),t}();FE.exports=St});var VE=w((GM,KE)=>{KE.exports=function(e){if(e){if(typeof e[Symbol.iterator]=="function")return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]=="function")return e[Symbol.asyncIterator]();if(typeof e.next=="function")return e}throw new Error("argument is not an iterator or iterable")}});var $E=w((YM,jE)=>{jE.exports=class extends Error{constructor(e,r){super(e||"The operation was aborted");this.type="aborted",this.code=r||"ABORT_ERR"}}});var Rh=w((QM,ji)=>{var P3=VE(),Ih=$E(),HE=(t,e,r)=>Th(t,Array.isArray(e)?e:[{signal:e,options:r}]),Th=(t,e)=>{t=P3(t),e=e.map(({signal:n,options:i})=>({signal:n,options:i||{}}));async function*r(){let n,i=()=>{n&&n()};for(let{signal:s}of e)s.addEventListener("abort",i);for(;;){let s;try{for(let{signal:a,options:c}of e)if(a.aborted){let{abortMessage:u,abortCode:l}=c;throw new Ih(u,l)}let o=new Promise((a,c)=>{n=()=>{let{options:u}=e.find(({signal:h})=>h.aborted),{abortMessage:l,abortCode:f}=u;c(new Ih(l,f))}});s=await Promise.race([o,t.next()]),n=null}catch(o){for(let{signal:u}of e)u.removeEventListener("abort",i);let a=e.find(({signal:u})=>u.aborted),c=o.type==="aborted"&&a;if(c&&a.options.onAbort&&await a.options.onAbort(t),typeof t.return=="function")try{let u=t.return();u instanceof Promise&&u.catch(l=>{a.options.onReturnError!=null&&a.options.onReturnError(l)})}catch(u){a.options.onReturnError!=null&&a.options.onReturnError(u)}if(c&&a.options.returnOnAbort)return;throw o}if(s.done)break;yield s.value}for(let{signal:s}of e)s.removeEventListener("abort",i)}return r()},zE=(t,e,r)=>GE(t,Array.isArray(e)?e:[{signal:e,options:r}]),GE=(t,e)=>r=>t(Th(r,e)),N3=(t,e,r)=>O3(t,Array.isArray(e)?e:[{signal:e,options:r}]),O3=(t,e)=>({sink:GE(t.sink,e),source:Th(t.source,e)});ji.exports=HE;ji.exports.AbortError=Ih;ji.exports.source=HE;ji.exports.sink=zE;ji.exports.transform=zE;ji.exports.duplex=N3});var QE=w((XM,YE)=>{"use strict";var{source:WE}=Rh(),D3=Be(),L3=D3("libp2p:stream:converter");function k3({stream:t,remoteAddr:e,localAddr:r},n={}){let{sink:i,source:s}=t,o={async sink(c){n.signal&&(c=WE(c,n.signal));try{await i(c)}catch(u){u.type!=="aborted"&&L3(u)}a()},source:n.signal?WE(s,n.signal):s,conn:t,localAddr:r,remoteAddr:e,timeline:{open:Date.now(),close:void 0},close(){return i(new Uint8Array(0)),a()}};function a(){return o.timeline.close||(o.timeline.close=Date.now()),Promise.resolve()}return o}YE.exports=k3});var va=w((ZM,XE)=>{"use strict";XE.exports={relay:"/libp2p/circuit/relay/0.1.0"}});var JE=w((JM,ZE)=>{"use strict";var{EventEmitter:q3}=Qt(),{Multiaddr:U3}=kt();ZE.exports=t=>{let e=new Map;async function r(s){let o=String(s).split("/p2p-circuit").find(u=>u!==""),a=await t.dial(new U3(o)),c=a.remoteAddr.encapsulate("/p2p-circuit");e.set(a.remotePeer.toB58String(),c),i.emit("listening")}function n(){let s=[];for(let o of e.values())s.push(o);return s}let i=Object.assign(new q3,{close:()=>Promise.resolve(),listen:r,getAddrs:n});return t.connectionManager.on("peer:disconnect",s=>{e.delete(s.remotePeer.toB58String())&&i.emit("close")}),i}});var Bh=w((eF,rw)=>{"use strict";var{Multiaddr:ew}=kt(),{CircuitRelay:$i}=Gs();function tw(t,e){t.write({type:$i.Type.STATUS,code:e})}function M3(t,e){try{t.dstPeer&&t.dstPeer.addrs&&t.dstPeer.addrs.forEach(r=>new ew(r))}catch(r){throw tw(e,t.type===$i.Type.HOP?$i.Status.HOP_DST_MULTIADDR_INVALID:$i.Status.STOP_DST_MULTIADDR_INVALID),r}try{t.srcPeer&&t.srcPeer.addrs&&t.srcPeer.addrs.forEach(r=>new ew(r))}catch(r){throw tw(e,t.type===$i.Type.HOP?$i.Status.HOP_SRC_MULTIADDR_INVALID:$i.Status.STOP_SRC_MULTIADDR_INVALID),r}}rw.exports={validateAddrs:M3}});var sw=w(uu=>{"use strict";uu.byteLength=K3;uu.toByteArray=j3;uu.fromByteArray=z3;var on=[],xr=[],F3=typeof Uint8Array!="undefined"?Uint8Array:Array,Ph="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Hi=0,nw=Ph.length;Hi<nw;++Hi)on[Hi]=Ph[Hi],xr[Ph.charCodeAt(Hi)]=Hi;var Hi,nw;xr["-".charCodeAt(0)]=62;xr["_".charCodeAt(0)]=63;function iw(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function K3(t){var e=iw(t),r=e[0],n=e[1];return(r+n)*3/4-n}function V3(t,e,r){return(e+r)*3/4-r}function j3(t){var e,r=iw(t),n=r[0],i=r[1],s=new F3(V3(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=xr[t.charCodeAt(c)]<<18|xr[t.charCodeAt(c+1)]<<12|xr[t.charCodeAt(c+2)]<<6|xr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=xr[t.charCodeAt(c)]<<2|xr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=xr[t.charCodeAt(c)]<<10|xr[t.charCodeAt(c+1)]<<4|xr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function $3(t){return on[t>>18&63]+on[t>>12&63]+on[t>>6&63]+on[t&63]}function H3(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push($3(n));return i.join("")}function z3(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(H3(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(on[e>>2]+on[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(on[e>>10]+on[e>>4&63]+on[e<<2&63]+"=")),i.join("")}});var ow=w(Nh=>{Nh.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,u=c>>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=s*256+t[e+f],f+=h,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+f],f+=h,l-=8);if(s===0)s=1-u;else{if(s===c)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-u}return(p?-1:1)*o*Math.pow(2,s-n)};Nh.write=function(t,e,r,n,i,s){var o,a,c,u=s*8-i-1,l=(1<<u)-1,f=l>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?e+=h/c:e+=h*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=a&255,p+=d,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+p]=o&255,p+=d,o/=256,u-=8);t[r+p-d]|=g*128}});var si=w(Xs=>{"use strict";var Oh=sw(),Ws=ow(),aw=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Xs.Buffer=F;Xs.SlowBuffer=Z3;Xs.INSPECT_MAX_BYTES=50;var lu=2147483647;Xs.kMaxLength=lu;F.TYPED_ARRAY_SUPPORT=G3();!F.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function G3(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch(t){return!1}}Object.defineProperty(F.prototype,"parent",{enumerable:!0,get:function(){if(!!F.isBuffer(this))return this.buffer}});Object.defineProperty(F.prototype,"offset",{enumerable:!0,get:function(){if(!!F.isBuffer(this))return this.byteOffset}});function _n(t){if(t>lu)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,F.prototype),e}function F(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Dh(t)}return cw(t,e,r)}F.poolSize=8192;function cw(t,e,r){if(typeof t=="string")return Y3(t,e);if(ArrayBuffer.isView(t))return Q3(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(an(t,ArrayBuffer)||t&&an(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(an(t,SharedArrayBuffer)||t&&an(t.buffer,SharedArrayBuffer)))return kh(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return F.from(n,e,r);let i=X3(t);if(i)return i;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return F.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}F.from=function(t,e,r){return cw(t,e,r)};Object.setPrototypeOf(F.prototype,Uint8Array.prototype);Object.setPrototypeOf(F,Uint8Array);function uw(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function W3(t,e,r){return uw(t),t<=0?_n(t):e!==void 0?typeof r=="string"?_n(t).fill(e,r):_n(t).fill(e):_n(t)}F.alloc=function(t,e,r){return W3(t,e,r)};function Dh(t){return uw(t),_n(t<0?0:qh(t)|0)}F.allocUnsafe=function(t){return Dh(t)};F.allocUnsafeSlow=function(t){return Dh(t)};function Y3(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!F.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=lw(t,e)|0,n=_n(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function Lh(t){let e=t.length<0?0:qh(t.length)|0,r=_n(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function Q3(t){if(an(t,Uint8Array)){let e=new Uint8Array(t);return kh(e.buffer,e.byteOffset,e.byteLength)}return Lh(t)}function kh(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,F.prototype),n}function X3(t){if(F.isBuffer(t)){let e=qh(t.length)|0,r=_n(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Fh(t.length)?_n(0):Lh(t);if(t.type==="Buffer"&&Array.isArray(t.data))return Lh(t.data)}function qh(t){if(t>=lu)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+lu.toString(16)+" bytes");return t|0}function Z3(t){return+t!=t&&(t=0),F.alloc(+t)}F.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==F.prototype};F.compare=function(e,r){if(an(e,Uint8Array)&&(e=F.from(e,e.offset,e.byteLength)),an(r,Uint8Array)&&(r=F.from(r,r.offset,r.byteLength)),!F.isBuffer(e)||!F.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};F.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};F.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return F.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=F.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(an(o,Uint8Array))s+o.length>i.length?(F.isBuffer(o)||(o=F.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(F.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function lw(t,e){if(F.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||an(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Mh(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return _w(t).length;default:if(i)return n?-1:Mh(t).length;e=(""+e).toLowerCase(),i=!0}}F.byteLength=lw;function J3(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return uO(this,e,r);case"utf8":case"utf-8":return dw(this,e,r);case"ascii":return aO(this,e,r);case"latin1":case"binary":return cO(this,e,r);case"base64":return sO(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return lO(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}F.prototype._isBuffer=!0;function zi(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}F.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)zi(this,r,r+1);return this};F.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)zi(this,r,r+3),zi(this,r+1,r+2);return this};F.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)zi(this,r,r+7),zi(this,r+1,r+6),zi(this,r+2,r+5),zi(this,r+3,r+4);return this};F.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?dw(this,0,e):J3.apply(this,arguments)};F.prototype.toLocaleString=F.prototype.toString;F.prototype.equals=function(e){if(!F.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:F.compare(this,e)===0};F.prototype.inspect=function(){let e="",r=Xs.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};aw&&(F.prototype[aw]=F.prototype.inspect);F.prototype.compare=function(e,r,n,i,s){if(an(e,Uint8Array)&&(e=F.from(e,e.offset,e.byteLength)),!F.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),u=this.slice(i,s),l=e.slice(r,n);for(let f=0;f<c;++f)if(u[f]!==l[f]){o=u[f],a=l[f];break}return o<a?-1:a<o?1:0};function fw(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Fh(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=F.from(e,n)),F.isBuffer(e))return e.length===0?-1:hw(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):hw(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function hw(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(l,f){return s===1?l[f]:l.readUInt16BE(f*s)}let u;if(i){let l=-1;for(u=r;u<o;u++)if(c(t,u)===c(e,l===-1?0:u-l)){if(l===-1&&(l=u),u-l+1===a)return l*s}else l!==-1&&(u-=u-l),l=-1}else for(r+a>o&&(r=o-a),u=r;u>=0;u--){let l=!0;for(let f=0;f<a;f++)if(c(t,u+f)!==c(e,f)){l=!1;break}if(l)return u}return-1}F.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};F.prototype.indexOf=function(e,r,n){return fw(this,e,r,n,!0)};F.prototype.lastIndexOf=function(e,r,n){return fw(this,e,r,n,!1)};function eO(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Fh(a))return o;t[r+o]=a}return o}function tO(t,e,r,n){return fu(Mh(e,t.length-r),t,r,n)}function rO(t,e,r,n){return fu(pO(e),t,r,n)}function nO(t,e,r,n){return fu(_w(e),t,r,n)}function iO(t,e,r,n){return fu(yO(e,t.length-r),t,r,n)}F.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return eO(this,e,r,n);case"utf8":case"utf-8":return tO(this,e,r,n);case"ascii":case"latin1":case"binary":return rO(this,e,r,n);case"base64":return nO(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return iO(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};F.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function sO(t,e,r){return e===0&&r===t.length?Oh.fromByteArray(t):Oh.fromByteArray(t.slice(e,r))}function dw(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,u,l,f;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)==128&&(f=(s&31)<<6|c&63,f>127&&(o=f));break;case 3:c=t[i+1],u=t[i+2],(c&192)==128&&(u&192)==128&&(f=(s&15)<<12|(c&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:c=t[i+1],u=t[i+2],l=t[i+3],(c&192)==128&&(u&192)==128&&(l&192)==128&&(f=(s&15)<<18|(c&63)<<12|(u&63)<<6|l&63,f>65535&&f<1114112&&(o=f))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return oO(n)}var pw=4096;function oO(t){let e=t.length;if(e<=pw)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=pw));return r}function aO(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function cO(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function uO(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=gO[t[s]];return i}function lO(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}F.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,F.prototype),i};function At(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}F.prototype.readUintLE=F.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||At(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};F.prototype.readUintBE=F.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||At(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};F.prototype.readUint8=F.prototype.readUInt8=function(e,r){return e=e>>>0,r||At(e,1,this.length),this[e]};F.prototype.readUint16LE=F.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||At(e,2,this.length),this[e]|this[e+1]<<8};F.prototype.readUint16BE=F.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||At(e,2,this.length),this[e]<<8|this[e+1]};F.prototype.readUint32LE=F.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||At(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};F.prototype.readUint32BE=F.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||At(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};F.prototype.readBigUInt64LE=ii(function(e){e=e>>>0,Qs(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ba(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});F.prototype.readBigUInt64BE=ii(function(e){e=e>>>0,Qs(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ba(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});F.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||At(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};F.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||At(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};F.prototype.readInt8=function(e,r){return e=e>>>0,r||At(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};F.prototype.readInt16LE=function(e,r){e=e>>>0,r||At(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};F.prototype.readInt16BE=function(e,r){e=e>>>0,r||At(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};F.prototype.readInt32LE=function(e,r){return e=e>>>0,r||At(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};F.prototype.readInt32BE=function(e,r){return e=e>>>0,r||At(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};F.prototype.readBigInt64LE=ii(function(e){e=e>>>0,Qs(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ba(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});F.prototype.readBigInt64BE=ii(function(e){e=e>>>0,Qs(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&ba(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});F.prototype.readFloatLE=function(e,r){return e=e>>>0,r||At(e,4,this.length),Ws.read(this,e,!0,23,4)};F.prototype.readFloatBE=function(e,r){return e=e>>>0,r||At(e,4,this.length),Ws.read(this,e,!1,23,4)};F.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||At(e,8,this.length),Ws.read(this,e,!0,52,8)};F.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||At(e,8,this.length),Ws.read(this,e,!1,52,8)};function tr(t,e,r,n,i,s){if(!F.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}F.prototype.writeUintLE=F.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;tr(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};F.prototype.writeUintBE=F.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;tr(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};F.prototype.writeUint8=F.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,1,255,0),this[r]=e&255,r+1};F.prototype.writeUint16LE=F.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};F.prototype.writeUint16BE=F.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};F.prototype.writeUint32LE=F.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};F.prototype.writeUint32BE=F.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function yw(t,e,r,n,i){ww(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function gw(t,e,r,n,i){ww(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}F.prototype.writeBigUInt64LE=ii(function(e,r=0){return yw(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});F.prototype.writeBigUInt64BE=ii(function(e,r=0){return gw(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});F.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);tr(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};F.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);tr(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};F.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};F.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};F.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};F.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};F.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||tr(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};F.prototype.writeBigInt64LE=ii(function(e,r=0){return yw(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});F.prototype.writeBigInt64BE=ii(function(e,r=0){return gw(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function mw(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function vw(t,e,r,n,i){return e=+e,r=r>>>0,i||mw(t,e,r,4,34028234663852886e22,-34028234663852886e22),Ws.write(t,e,r,n,23,4),r+4}F.prototype.writeFloatLE=function(e,r,n){return vw(this,e,r,!0,n)};F.prototype.writeFloatBE=function(e,r,n){return vw(this,e,r,!1,n)};function bw(t,e,r,n,i){return e=+e,r=r>>>0,i||mw(t,e,r,8,17976931348623157e292,-17976931348623157e292),Ws.write(t,e,r,n,52,8),r+8}F.prototype.writeDoubleLE=function(e,r,n){return bw(this,e,r,!0,n)};F.prototype.writeDoubleBE=function(e,r,n){return bw(this,e,r,!1,n)};F.prototype.copy=function(e,r,n,i){if(!F.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};F.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!F.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=F.isBuffer(e)?e:F.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var Ys={};function Uh(t,e,r){Ys[t]=class extends r{constructor(){super();Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}Uh("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);Uh("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);Uh("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Ew(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Ew(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Ew(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function fO(t,e,r){Qs(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&ba(e,t.length-(r+1))}function ww(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new Ys.ERR_OUT_OF_RANGE("value",a,t)}fO(n,i,s)}function Qs(t,e){if(typeof t!="number")throw new Ys.ERR_INVALID_ARG_TYPE(e,"number",t)}function ba(t,e,r){throw Math.floor(t)!==t?(Qs(t,r),new Ys.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Ys.ERR_BUFFER_OUT_OF_BOUNDS:new Ys.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var hO=/[^+/0-9A-Za-z-_]/g;function dO(t){if(t=t.split("=")[0],t=t.trim().replace(hO,""),t.length<2)return"";for(;t.length%4!=0;)t=t+"=";return t}function Mh(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function pO(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function yO(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function _w(t){return Oh.toByteArray(dO(t))}function fu(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function an(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Fh(t){return t!==t}var gO=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function ii(t){return typeof BigInt=="undefined"?mO:t}function mO(){throw new Error("BigInt not supported")}});var Gi=w((sF,Sw)=>{"use strict";var{Buffer:qr}=si(),xw=Symbol.for("BufferList");function ze(t){if(!(this instanceof ze))return new ze(t);ze._init.call(this,t)}ze._init=function(e){Object.defineProperty(this,xw,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)};ze.prototype._new=function(e){return new ze(e)};ze.prototype._offset=function(e){if(e===0)return[0,0];let r=0;for(let n=0;n<this._bufs.length;n++){let i=r+this._bufs[n].length;if(e<i||n===this._bufs.length-1)return[n,e-r];r=i}};ze.prototype._reverseOffset=function(t){let e=t[0],r=t[1];for(let n=0;n<e;n++)r+=this._bufs[n].length;return r};ze.prototype.get=function(e){if(e>this.length||e<0)return;let r=this._offset(e);return this._bufs[r[0]][r[1]]};ze.prototype.slice=function(e,r){return typeof e=="number"&&e<0&&(e+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,e,r)};ze.prototype.copy=function(e,r,n,i){if((typeof n!="number"||n<0)&&(n=0),(typeof i!="number"||i>this.length)&&(i=this.length),n>=this.length||i<=0)return e||qr.alloc(0);let s=!!e,o=this._offset(n),a=i-n,c=a,u=s&&r||0,l=o[1];if(n===0&&i===this.length){if(!s)return this._bufs.length===1?this._bufs[0]:qr.concat(this._bufs,this.length);for(let f=0;f<this._bufs.length;f++)this._bufs[f].copy(e,u),u+=this._bufs[f].length;return e}if(c<=this._bufs[o[0]].length-l)return s?this._bufs[o[0]].copy(e,r,l,l+c):this._bufs[o[0]].slice(l,l+c);s||(e=qr.allocUnsafe(a));for(let f=o[0];f<this._bufs.length;f++){let h=this._bufs[f].length-l;if(c>h)this._bufs[f].copy(e,u,l),u+=h;else{this._bufs[f].copy(e,u,l,l+c),u+=h;break}c-=h,l&&(l=0)}return e.length>u?e.slice(0,u):e};ze.prototype.shallowSlice=function(e,r){if(e=e||0,r=typeof r!="number"?this.length:r,e<0&&(e+=this.length),r<0&&(r+=this.length),e===r)return this._new();let n=this._offset(e),i=this._offset(r),s=this._bufs.slice(n[0],i[0]+1);return i[1]===0?s.pop():s[s.length-1]=s[s.length-1].slice(0,i[1]),n[1]!==0&&(s[0]=s[0].slice(n[1])),this._new(s)};ze.prototype.toString=function(e,r,n){return this.slice(r,n).toString(e)};ze.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;)if(e>=this._bufs[0].length)e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}return this};ze.prototype.duplicate=function(){let e=this._new();for(let r=0;r<this._bufs.length;r++)e.append(this._bufs[r]);return e};ze.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(qr.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let r=0;r<e.length;r++)this.append(e[r]);else if(this._isBufferList(e))for(let r=0;r<e._bufs.length;r++)this.append(e._bufs[r]);else typeof e=="number"&&(e=e.toString()),this._appendBuffer(qr.from(e));return this};ze.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length};ze.prototype.indexOf=function(t,e,r){if(r===void 0&&typeof e=="string"&&(r=e,e=void 0),typeof t=="function"||Array.isArray(t))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof t=="number"?t=qr.from([t]):typeof t=="string"?t=qr.from(t,r):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=qr.from(t.buffer,t.byteOffset,t.byteLength):qr.isBuffer(t)||(t=qr.from(t)),e=Number(e||0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let n=this._offset(e),i=n[0],s=n[1];for(;i<this._bufs.length;i++){let o=this._bufs[i];for(;s<o.length;)if(o.length-s>=t.length){let c=o.indexOf(t,s);if(c!==-1)return this._reverseOffset([i,c]);s=o.length-t.length+1}else{let c=this._reverseOffset([i,s]);if(this._match(c,t))return c;s++}s=0}return-1};ze.prototype._match=function(t,e){if(this.length-t<e.length)return!1;for(let r=0;r<e.length;r++)if(this.get(t+r)!==e[r])return!1;return!0};(function(){let t={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let e in t)(function(r){t[r]===null?ze.prototype[r]=function(n,i){return this.slice(n,n+i)[r](0,i)}:ze.prototype[r]=function(n=0){return this.slice(n,n+t[r])[r](0)}})(e)})();ze.prototype._isBufferList=function(e){return e instanceof ze||ze.isBufferList(e)};ze.isBufferList=function(e){return e!=null&&e[xw]};Sw.exports=ze});var Kh=w((oF,Iw)=>{"use strict";var Aw=Di(),{Buffer:vO}=si(),Cw=(t,e,r)=>{let n=Aw.encode(t,e,r);return Cw.bytes=Aw.encode.bytes,e||vO.from(n)};Iw.exports=Cw});var Ow=w((aF,hu)=>{"use strict";var{Buffer:Tw}=si(),Rw=Gi(),Bw=Kh(),Vh=8,Pw=10*1024;function Nw(t){t=t||{};let e=Math.max(t.poolSize||Pw,t.minPoolSize||Vh),r=t.lengthEncoder||Bw;return async function*(i){let s=Tw.alloc(e),o=0;for await(let a of i){r(a.length,s,o);let c=s.slice(o,o+r.bytes);o+=r.bytes,s.length-o<Vh&&(s=Tw.alloc(e),o=0),yield new Rw().append(c).append(a)}}}Nw.single=(t,e)=>{e=e||{};let r=e.lengthEncoder||Bw;return new Rw([r(t.length),t.slice()])};hu.exports=Nw;hu.exports.MIN_POOL_SIZE=Vh;hu.exports.DEFAULT_POOL_SIZE=Pw});var jh=w((cF,kw)=>{"use strict";var Dw=Di(),{Buffer:bO}=si(),EO=t=>new Proxy({},{get:(e,r)=>r[0]==="l"?t[r]:t.get(parseInt(r))}),Lw=t=>{let e=Dw.decode(bO.isBuffer(t)?t:EO(t));return Lw.bytes=Dw.decode.bytes,e};kw.exports=Lw});var Fw=w((uF,du)=>{"use strict";var{Buffer:wO}=si(),$h=Gi(),_O=jh(),qw=8,Uw=1024*1024*4,Mw=wO.alloc(0),oi={LENGTH:"readLength",DATA:"readData"},xO={[oi.LENGTH]:(t,e,r,n)=>{e=e.append(t);let i;try{i=n.lengthDecoder(e)}catch(s){if(e.length>n.maxLengthLength)throw Object.assign(s,{message:"message length too long",code:"ERR_MSG_LENGTH_TOO_LONG"});if(s instanceof RangeError)return{mode:oi.LENGTH,buffer:e,chunk:void 0,state:void 0,data:void 0};throw s}if(i>n.maxDataLength)throw Object.assign(new Error("message data too long"),{code:"ERR_MSG_DATA_TOO_LONG"});return t=e.shallowSlice(n.lengthDecoder.bytes),e=new $h,n.onLength&&n.onLength(i),i<=0?(n.onData&&n.onData(Mw),{mode:oi.LENGTH,chunk:t,buffer:e,data:Mw}):{mode:oi.DATA,chunk:t,buffer:e,state:{dataLength:i},data:void 0}},[oi.DATA]:(t,e,r,n)=>{if(e=e.append(t),!r)throw new Error("state is required");if(e.length<r.dataLength)return{mode:oi.DATA,buffer:e,state:r,chunk:void 0,data:void 0};let{dataLength:i}=r,s=e.shallowSlice(0,i),o=e.length>i?e.shallowSlice(i):void 0;return e=new $h,n.onData&&n.onData(s),{mode:oi.LENGTH,chunk:o,buffer:e,state:void 0,data:s}}};function Hh(t){t=t||{};let e={lengthDecoder:t.lengthDecoder||_O,maxLengthLength:t.maxLengthLength||qw,maxDataLength:t.maxDataLength||Uw,onLength:t.onLength,onData:t.onData};return async function*(n){let i=new $h,s=oi.LENGTH,o;for await(let a of n){let c=a;for(;c;){let u=xO[s](c,i,o,e);s=u.mode,c=u.chunk,i=u.buffer,o=u.state,u.data&&(yield u.data)}}if(i.length)throw Object.assign(new Error("unexpected end of input"),{code:"ERR_UNEXPECTED_EOF"})}}Hh.fromReader=(t,e)=>{let r=1,n={[Symbol.asyncIterator](){return this},next:async()=>{try{return await t.next(r)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{r=1}}};return Hh({...e||{},onLength:s=>{r=s}})(n)};du.exports=Hh;du.exports.MAX_LENGTH_LENGTH=qw;du.exports.MAX_DATA_LENGTH=Uw});var jw=w((lF,Vw)=>{"use strict";var{Buffer:SO}=si(),Kw=(t,e,r)=>(e=e||SO.allocUnsafe(4),e.writeInt32BE(t,r),e);Kw.bytes=4;Vw.exports=Kw});var zw=w((fF,Hw)=>{"use strict";var $w=t=>{if(t.length<4)throw RangeError("Could not decode int32BE");return t.readInt32BE(0)};$w.bytes=4;Hw.exports=$w});var Ea=w(Wi=>{"use strict";Wi.encode=Ow();Wi.decode=Fw();Wi.varintEncode=Kh();Wi.varintDecode=jh();Wi.int32BEEncode=jw();Wi.int32BEDecode=zw()});var Gh=w((dF,Gw)=>{var zh=Gi();Gw.exports=t=>{let e=async function*(){let r=yield,n=new zh;for await(let i of t){if(!r){r=yield n.append(i),n=new zh;continue}for(n.append(i);n.length>=r;){let s=n.shallowSlice(0,r);if(n.consume(r),r=yield s,!r){n.length&&(r=yield n,n=new zh);break}}}if(r)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}});var Wh=w((pF,Ww)=>{"use strict";var AO=()=>{let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t};Ww.exports=AO});var wa=w((yF,Yw)=>{"use strict";var CO=Gh(),IO=eh(),TO=Wh();Yw.exports=t=>{let e=IO(),r=CO(t.source),n=TO(),i,s=t.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{i=a}),{reader:r,writer:e,stream:{sink:a=>i?Promise.reject(i):(n.resolve(a),s),source:r},rest:()=>e.end(),write:e.push,read:async()=>(await r.next()).value}}});var yu=w((gF,e2)=>{"use strict";var Qw=Be(),pu=Object.assign(Qw("libp2p:circuit:stream-handler"),{error:Qw("libp2p:circuit:stream-handler:err")}),Xw=Ea(),RO=wa(),{CircuitRelay:Zw}=Gs(),Jw=class{constructor({stream:e,maxLength:r=4096}){this.stream=e,this.shake=RO(this.stream),this.decoder=Xw.decode.fromReader(this.shake.reader,{maxDataLength:r})}async read(){let e=await this.decoder.next();if(e.value){let r=Zw.decode(e.value.slice());return pu("read message type",r.type),r}pu("read received no value, closing stream"),this.close()}write(e){pu("write message type %s",e.type),this.shake.write(Xw.encode.single(Zw.encode(e).finish()))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){pu("closing the stream"),this.rest().sink([])}};e2.exports=Jw});var Xh=w((mF,Qh)=>{"use strict";var t2=Be(),_a=Object.assign(t2("libp2p:circuit:stop"),{error:t2("libp2p:circuit:stop:err")}),{CircuitRelay:Yh}=Gs(),BO=va(),PO=yu(),{validateAddrs:NO}=Bh();Qh.exports.handleStop=function({connection:e,request:r,streamHandler:n}){try{NO(r,n)}catch(i){return _a.error("invalid stop request via peer %s",e.remotePeer.toB58String(),i)}return _a("stop request is valid"),n.write({type:Yh.Type.STATUS,code:Yh.Status.SUCCESS}),n.rest()};Qh.exports.stop=async function({connection:e,request:r}){let{stream:n}=await e.newStream([BO.relay]);_a("starting stop request to %s",e.remotePeer.toB58String());let i=new PO({stream:n});i.write(r);let s=await i.read();if(!s)return i.close();if(s.code===Yh.Status.SUCCESS)return _a("stop request to %s was successful",e.remotePeer.toB58String()),i.rest();_a("stop request failed with code %d",s.code),i.close()}});var Zh=w((vF,a2)=>{"use strict";var r2=Be(),xn=Object.assign(r2("libp2p:circuit:hop"),{error:r2("libp2p:circuit:hop:err")}),n2=pe(),OO=Tt(),{validateAddrs:DO}=Bh(),i2=yu(),{CircuitRelay:or}=Gs(),{pipe:LO}=nn(),{codes:s2}=He(),{stop:kO}=Xh(),o2=va();async function qO({connection:t,request:e,streamHandler:r,circuit:n}){if(!n._options.hop.enabled)return xn("HOP request received but we are not acting as a relay"),r.end({type:or.Type.STATUS,code:or.Status.HOP_CANT_SPEAK_RELAY});try{DO(e,r)}catch(u){return xn.error("invalid hop request via peer %s",t.remotePeer.toB58String(),u)}if(!e.dstPeer){xn("HOP request received but we do not receive a dstPeer");return}let i=new OO(e.dstPeer.id),s=n._connectionManager.get(i);if(!s&&!n._options.hop.active)return xn("HOP request received but we are not connected to the destination peer"),r.end({type:or.Type.STATUS,code:or.Status.HOP_NO_CONN_TO_DST});if(!s)return;let o={type:or.Type.STOP,dstPeer:e.dstPeer,srcPeer:e.srcPeer},a;try{a=await kO({connection:s,request:o})}catch(u){return xn.error(u)}xn("hop request from %s is valid",t.remotePeer.toB58String()),r.write({type:or.Type.STATUS,code:or.Status.SUCCESS});let c=r.rest();return LO(c,a,c)}async function UO({connection:t,request:e}){let{stream:r}=await t.newStream([o2.relay]),n=new i2({stream:r});n.write(e);let i=await n.read();if(!i)throw n2(new Error("HOP request had no response"),s2.ERR_HOP_REQUEST_FAILED);if(i.code===or.Status.SUCCESS)return xn("hop request was successful"),n.rest();throw xn("hop request failed with code %d, closing stream",i.code),n.close(),n2(new Error(`HOP request failed with code ${i.code}`),s2.ERR_HOP_REQUEST_FAILED)}async function MO({connection:t}){let{stream:e}=await t.newStream([o2.relay]),r=new i2({stream:e});r.write({type:or.Type.CAN_HOP});let n=await r.read();return await r.close(),!(!n||n.code!==or.Status.SUCCESS)}function FO({connection:t,streamHandler:e,circuit:r}){let n=r._options.hop.enabled;xn("can hop (%s) request from %s",n,t.remotePeer.toB58String()),e.end({type:or.Type.STATUS,code:n?or.Status.SUCCESS:or.Status.HOP_CANT_SPEAK_RELAY})}a2.exports={handleHop:qO,hop:UO,canHop:MO,handleCanHop:FO}});var d2=w((bF,h2)=>{"use strict";var c2=Be(),Sn=Object.assign(c2("libp2p:circuit"),{error:c2("libp2p:circuit:err")}),KO=pe(),VO=UE(),{Multiaddr:xa}=kt(),u2=Tt(),{CircuitRelay:Sa}=Gs(),{codes:jO}=He(),l2=QE(),{relay:$O}=va(),HO=JE(),{handleCanHop:zO,handleHop:GO,hop:WO}=Zh(),{handleStop:YO}=Xh(),QO=yu(),XO=Symbol.for("@libp2p/js-libp2p-circuit/circuit"),f2=class{constructor({libp2p:e,upgrader:r}){this._dialer=e.dialer,this._registrar=e.registrar,this._connectionManager=e.connectionManager,this._upgrader=r,this._options=e._config.relay,this._libp2p=e,this.peerId=e.peerId,this._registrar.handle($O,this._onProtocol.bind(this))}async _onProtocol({connection:e,stream:r}){let n=new QO({stream:r}),i=await n.read();if(!i)return;let s=this,o;switch(i.type){case Sa.Type.CAN_HOP:{Sn("received CAN_HOP request from %s",e.remotePeer.toB58String()),await zO({circuit:s,connection:e,streamHandler:n});break}case Sa.Type.HOP:{Sn("received HOP request from %s",e.remotePeer.toB58String()),o=await GO({connection:e,request:i,streamHandler:n,circuit:s});break}case Sa.Type.STOP:{Sn("received STOP request from %s",e.remotePeer.toB58String()),o=await YO({connection:e,request:i,streamHandler:n});break}default:Sn("Request of type %s not supported",i.type)}if(o){let a=new xa(i.dstPeer.addrs[0]),c=new xa(i.srcPeer.addrs[0]),u=l2({stream:o,remoteAddr:a,localAddr:c}),l=i.type===Sa.Type.HOP?"relay":"inbound";Sn("new %s connection %s",l,u.remoteAddr);let f=await this._upgrader.upgradeInbound(u);Sn("%s connection %s upgraded",l,u.remoteAddr),this.handler&&this.handler(f)}}async dial(e,r){let n=e.toString().split("/p2p-circuit"),i=new xa(n[0]),s=new xa(n[n.length-1]),o=i.getPeerId(),a=s.getPeerId();if(!o||!a){let h="Circuit relay dial failed as addresses did not have peer id";throw Sn.error(h),KO(new Error(h),jO.ERR_RELAYED_DIAL)}let c=u2.createFromB58String(o),u=u2.createFromB58String(a),l=!1,f=this._connectionManager.get(c);f||(f=await this._dialer.connectToPeer(i,r),l=!0);try{let h=await WO({connection:f,request:{type:Sa.Type.HOP,srcPeer:{id:this.peerId.toBytes(),addrs:this._libp2p.multiaddrs.map(g=>g.bytes)},dstPeer:{id:u.toBytes(),addrs:[new xa(s).bytes]}}}),p=i.encapsulate(`/p2p-circuit/p2p/${this.peerId.toB58String()}`),d=l2({stream:h,remoteAddr:e,localAddr:p});return Sn("new outbound connection %s",d.remoteAddr),this._upgrader.upgradeOutbound(d)}catch(h){throw Sn.error("Circuit relay dial failed",h),l&&await f.close(),h}}createListener(e,r){return typeof e=="function"&&(r=e,e={}),this.handler=r,HO(this._libp2p)}filter(e){return e=Array.isArray(e)?e:[e],e.filter(r=>VO.Circuit.matches(r))}get[Symbol.toStringTag](){return"Circuit"}static isTransport(e){return Boolean(e&&e[XO])}};h2.exports=f2});var Jh=w((EF,p2)=>{"use strict";var{CID:ZO}=(gs(),Io),{sha256:JO}=(Ii(),Vn);p2.exports.namespaceToCid=async t=>{let e=new TextEncoder().encode(t),r=await JO.digest(e);return ZO.createV0(r)}});var E2=w((wF,b2)=>{"use strict";var y2=Be(),ed=Object.assign(y2("libp2p:auto-relay"),{error:y2("libp2p:auto-relay:err")}),{fromString:eD}=(Ct(),Pt),{toString:tD}=(It(),Nt),{Multiaddr:rD}=kt(),{relay:nD}=va(),{canHop:iD}=Zh(),{namespaceToCid:sD}=Jh(),{CIRCUIT_PROTO_CODE:oD,HOP_METADATA_KEY:g2,HOP_METADATA_VALUE:m2,RELAY_RENDEZVOUS_NS:aD}=Jc(),v2=class{constructor({libp2p:e,maxListeners:r=1,onError:n}){this._libp2p=e,this._peerId=e.peerId,this._peerStore=e.peerStore,this._connectionManager=e.connectionManager,this._transportManager=e.transportManager,this._addressSorter=e.dialer.addressSorter,this.maxListeners=r,this._listenRelays=new Set,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this._peerStore.on("change:protocols",this._onProtocolChange),this._connectionManager.on("peer:disconnect",this._onPeerDisconnected),this._onError=(i,s)=>{ed.error(s||i),n&&n(i,s)}}async _onProtocolChange({peerId:e,protocols:r}){let n=e.toB58String(),i=r.find(s=>s===nD);if(!i&&this._listenRelays.has(n)){await this._removeListenRelay(n);return}else if(!i||this._listenRelays.has(n))return;try{let s=this._connectionManager.get(e);if(!s)return;if(s.remoteAddr.protoCodes().includes(oD)){ed(`relayed connection to ${n} will not be used to hop on`);return}await iD({connection:s})&&(await this._peerStore.metadataBook.setValue(e,g2,eD(m2)),await this._addListenRelay(s,n))}catch(s){this._onError(s)}}_onPeerDisconnected(e){let n=e.remotePeer.toB58String();!this._listenRelays.has(n)||this._removeListenRelay(n).catch(i=>{ed.error(i)})}async _addListenRelay(e,r){if(this._listenRelays.size>=this.maxListeners)return;let n=await this._peerStore.addressBook.getMultiaddrsForPeer(e.remotePeer,this._addressSorter);if(!n||!n.length)return;let i=`${n[0].toString()}/p2p-circuit`;this._listenRelays.add(r);try{await this._transportManager.listen([new rD(i)])}catch(s){this._onError(s),this._listenRelays.delete(r)}}async _removeListenRelay(e){this._listenRelays.delete(e)&&await this._listenOnAvailableHopRelays([e])}async _listenOnAvailableHopRelays(e=[]){if(this._listenRelays.size>=this.maxListeners)return;let r=[];for await(let{id:n,metadata:i}of this._peerStore.getPeers()){let s=n.toB58String();if(this._listenRelays.has(s)||e.includes(s))continue;let o=i.get(g2);if(!o||tD(o)!==m2)continue;let a=this._connectionManager.get(n);if(!a){r.push(n);continue}if(await this._addListenRelay(a,s),this._listenRelays.size>=this.maxListeners)return}for(let n of r)if(await this._tryToListenOnRelay(n),this._listenRelays.size>=this.maxListeners)return;try{let n=await sD(aD);for await(let i of this._libp2p.contentRouting.findProviders(n)){if(!i.multiaddrs.length)continue;let s=i.id;if(await this._peerStore.addressBook.add(s,i.multiaddrs),await this._tryToListenOnRelay(s),this._listenRelays.size>=this.maxListeners)return}}catch(n){this._onError(n)}}async _tryToListenOnRelay(e){try{let r=await this._libp2p.dial(e);await this._addListenRelay(r,e.toB58String())}catch(r){this._onError(r,`could not connect and listen on known hop relay ${e.toB58String()}`)}}};b2.exports=v2});var A2=w((_F,S2)=>{"use strict";var w2=Be(),_2=Object.assign(w2("libp2p:relay"),{error:w2("libp2p:relay:err")}),{codes:cD}=He(),{setDelayedInterval:uD,clearDelayedInterval:lD}=ih(),fD=E2(),{namespaceToCid:hD}=Jh(),{RELAY_RENDEZVOUS_NS:dD}=Jc(),x2=class{constructor(e){this._libp2p=e,this._options={...e._config.relay},this._autoRelay=this._options.autoRelay.enabled&&new fD({libp2p:e,...this._options.autoRelay}),this._advertiseService=this._advertiseService.bind(this)}start(){this._options.hop.enabled&&this._options.advertise.enabled&&(this._timeout=uD(this._advertiseService,this._options.advertise.ttl,this._options.advertise.bootDelay))}stop(){lD(this._timeout)}async _advertiseService(){try{let e=await hD(dD);await this._libp2p.contentRouting.provide(e)}catch(e){e.code===cD.ERR_NO_ROUTERS_AVAILABLE?(_2.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),this.stop()):_2.error(e)}}};S2.exports=x2});var rd=w((xF,td)=>{var{AbortController:pD}=globalThis;function C2(t){let e=new pD;function r(){e.abort();for(let n of t)!n||!n.removeEventListener||n.removeEventListener("abort",r)}for(let n of t)if(!(!n||!n.addEventListener)){if(n.aborted){r();break}n.addEventListener("abort",r)}return e.signal}td.exports=C2;td.exports.anySignal=C2});var B2=w((AF,R2)=>{var I2=Zf(),T2=Wh();R2.exports=class{constructor(){this._buffer=new I2,this._waitingConsumers=new I2}push(e){let{promise:r,resolve:n}=T2();return this._buffer.push({chunk:e,resolve:n}),this._consume(),r}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){let e=this._waitingConsumers.shift(),r=this._buffer.shift();e.resolve(r.chunk),r.resolve()}}shift(){let{promise:e,resolve:r}=T2();return this._waitingConsumers.push({resolve:r}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}});var N2=w((CF,P2)=>{"use strict";P2.exports=(t,e=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},typeof t!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(typeof r.indent!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(e===0)return t;let n=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return t.replace(n,r.indent.repeat(e))}});var O2=w(()=>{});var q2=w((RF,k2)=>{"use strict";var D2=O2(),L2=/\s+at.*(?:\(|\s)(.*)\)?/,yD=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,gD=typeof D2.homedir=="undefined"?"":D2.homedir();k2.exports=(t,e)=>(e=Object.assign({pretty:!1},e),t.replace(/\\/g,"/").split(`
41
- `).filter(r=>{let n=r.match(L2);if(n===null||!n[1])return!0;let i=n[1];return i.includes(".app/Contents/Resources/electron.asar")||i.includes(".app/Contents/Resources/default_app.asar")?!1:!yD.test(i)}).filter(r=>r.trim()!=="").map(r=>e.pretty?r.replace(L2,(n,i)=>n.replace(i,i.replace(gD,"~"))):r).join(`
42
- `))});var F2=w((BF,M2)=>{"use strict";var mD=N2(),vD=q2(),bD=t=>t.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""),U2=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);e=[...e].map(n=>n instanceof Error?n:n!==null&&typeof n=="object"?Object.assign(new Error(n.message),n):new Error(n));let r=e.map(n=>typeof n.stack=="string"?bD(vD(n.stack)):String(n)).join(`
40
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),oP=new RegExp(`(?:^${Dr}$)|(?:^${Vc}$)`),aP=new RegExp(`^${Dr}$`),cP=new RegExp(`^${Vc}$`),kf=t=>t&&t.exact?oP:new RegExp(`(?:${ei(t)}${Dr}${ei(t)})|(?:${ei(t)}${Vc}${ei(t)})`,"g");kf.v4=t=>t&&t.exact?aP:new RegExp(`${ei(t)}${Dr}${ei(t)}`,"g");kf.v6=t=>t&&t.exact?cP:new RegExp(`${ei(t)}${Vc}${ei(t)}`,"g");dv.exports=kf});var Mf=w((rM,pv)=>{"use strict";var Uf=qf(),Ls=t=>Uf({exact:!0}).test(t);Ls.v4=t=>Uf.v4({exact:!0}).test(t);Ls.v6=t=>Uf.v6({exact:!0}).test(t);Ls.version=t=>Ls(t)?Ls.v4(t)?4:6:void 0;pv.exports=Ls});var bv=w((nM,vv)=>{"use strict";var Ff=Mf(),{toString:yv}=(Tt(),Ot),uP=Ff,Kf=Ff.v4,gv=Ff.v6,mv=function(t,e,r){r=~~r;let n;if(Kf(t))n=e||new Uint8Array(r+4),t.split(/\./g).map(function(i){n[r++]=parseInt(i,10)&255});else if(gv(t)){let i=t.split(":",8),s;for(s=0;s<i.length;s++){let o=Kf(i[s]),a;o&&(a=mv(i[s]),i[s]=yv(a.slice(0,2),"base16")),a&&++s<8&&i.splice(s,0,yv(a.slice(2,4),"base16"))}if(i[0]==="")for(;i.length<8;)i.unshift("0");else if(i[i.length-1]==="")for(;i.length<8;)i.push("0");else if(i.length<8){for(s=0;s<i.length&&i[s]!=="";s++);let o=[s,"1"];for(s=9-i.length;s>0;s--)o.push("0");i.splice.apply(i,o)}for(n=e||new Uint8Array(r+16),s=0;s<i.length;s++){let o=parseInt(i[s],16);n[r++]=o>>8&255,n[r++]=o&255}}if(!n)throw Error("Invalid ip address: "+t);return n},lP=function(t,e,r){e=~~e,r=r||t.length-e;let n=[],i,s=new DataView(t.buffer);if(r===4){for(let o=0;o<r;o++)n.push(t[e+o]);i=n.join(".")}else if(r===16){for(let o=0;o<r;o+=2)n.push(s.getUint16(e+o).toString(16));i=n.join(":"),i=i.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3"),i=i.replace(/:{3,4}/,"::")}return i};vv.exports={isIP:uP,isV4:Kf,isV6:gv,toBytes:mv,toString:lP}});var fa=w((iM,wv)=>{"use strict";function Jt(t){if(typeof t=="number"){if(Jt.codes[t])return Jt.codes[t];throw new Error("no protocol with code: "+t)}else if(typeof t=="string"){if(Jt.names[t])return Jt.names[t];throw new Error("no protocol with name: "+t)}throw new Error("invalid protocol id type: "+t)}var br=-1;Jt.lengthPrefixedVarSize=br;Jt.V=br;Jt.table=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,br,"ip6zone"],[53,br,"dns","resolvable"],[54,br,"dns4","resolvable"],[55,br,"dns6","resolvable"],[56,br,"dnsaddr","resolvable"],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,br,"unix",!1,"path"],[421,br,"ipfs"],[421,br,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,br,"garlic64"],[460,0,"quic"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,br,"memory"]];Jt.names={};Jt.codes={};Jt.table.map(t=>{let e=Ev.apply(null,t);return Jt.codes[e.code]=e,Jt.names[e.name]=e,null});Jt.object=Ev;function Ev(t,e,r,n,i){return{code:t,size:e,name:r,resolvable:Boolean(n),path:Boolean(i)}}wv.exports=Jt});var Sv=w((sM,xv)=>{xv.exports=Vf;var _v=128,fP=127,hP=~fP,dP=Math.pow(2,31);function Vf(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw Vf.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=dP;)e[r++]=t&255|_v,t/=128;for(;t&hP;)e[r++]=t&255|_v,t>>>=7;return e[r]=t|0,Vf.bytes=r-n+1,e}});var Iv=w((oM,Cv)=>{Cv.exports=jf;var pP=128,Av=127;function jf(t,e){var r=0,e=e||0,n=0,i=e,s,o=t.length;do{if(i>=o||n>49)throw jf.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=n<28?(s&Av)<<n:(s&Av)*Math.pow(2,n),n+=7}while(s>=pP);return jf.bytes=i-e,r}});var Rv=w((aM,Tv)=>{var yP=Math.pow(2,7),gP=Math.pow(2,14),mP=Math.pow(2,21),vP=Math.pow(2,28),bP=Math.pow(2,35),EP=Math.pow(2,42),wP=Math.pow(2,49),_P=Math.pow(2,56),xP=Math.pow(2,63);Tv.exports=function(t){return t<yP?1:t<gP?2:t<mP?3:t<vP?4:t<bP?5:t<EP?6:t<wP?7:t<_P?8:t<xP?9:10}});var ki=w((cM,Bv)=>{Bv.exports={encode:Sv(),decode:Iv(),encodingLength:Rv()}});var Uv=w((uM,qv)=>{"use strict";var jc=bv(),Pv=fa(),{CID:SP}=(vs(),Do),{base32:Nv}=(bi(),vi),{base58btc:AP}=(Ln(),Dn),CP=(mi(),No),ks=ki(),{toString:$c}=(Tt(),Ot),{fromString:Ov}=(It(),Nt),{concat:Hc}=(Gn(),zn);qv.exports=ha;function ha(t,e){return e instanceof Uint8Array?ha.toString(t,e):ha.toBytes(t,e)}ha.toString=function(e,r){switch(Pv(e).code){case 4:case 41:return IP(r);case 6:case 273:case 33:case 132:return Lv(r).toString();case 53:case 54:case 55:case 56:case 400:case 777:return RP(r);case 421:return PP(r);case 444:return kv(r);case 445:return kv(r);default:return $c(r,"base16")}};ha.toBytes=function(e,r){switch(Pv(e).code){case 4:return Dv(r);case 41:return Dv(r);case 6:case 273:case 33:case 132:return $f(parseInt(r,10));case 53:case 54:case 55:case 56:case 400:case 777:return TP(r);case 421:return BP(r);case 444:return NP(r);case 445:return OP(r);default:return Ov(r,"base16")}};function Dv(t){if(!jc.isIP(t))throw new Error("invalid ip address");return jc.toBytes(t)}function IP(t){let e=jc.toString(t);if(!e||!jc.isIP(e))throw new Error("invalid ip address");return e}function $f(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Lv(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function TP(t){let e=Ov(t),r=Uint8Array.from(ks.encode(e.length));return Hc([r,e],r.length+e.length)}function RP(t){let e=ks.decode(t);if(t=t.slice(ks.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return $c(t)}function BP(t){let e;t[0]==="Q"||t[0]==="1"?e=CP.decode(AP.decode(`z${t}`)).bytes:e=SP.parse(t).multihash.bytes;let r=Uint8Array.from(ks.encode(e.length));return Hc([r,e],r.length+e.length)}function PP(t){let e=ks.decode(t),r=t.slice(ks.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return $c(r,"base58btc")}function NP(t){let e=t.split(":");if(e.length!==2)throw new Error("failed to parse onion addr: "+e+" does not contain a port number");if(e[0].length!==16)throw new Error("failed to parse onion addr: "+e[0]+" not a Tor onion address.");let r=Nv.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=$f(n);return Hc([r,i],r.length+i.length)}function OP(t){let e=t.split(":");if(e.length!==2)throw new Error("failed to parse onion addr: "+e+" does not contain a port number");if(e[0].length!==56)throw new Error("failed to parse onion addr: "+e[0]+" not a Tor onion3 address.");let r=Nv.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=$f(n);return Hc([r,i],r.length+i.length)}function kv(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=$c(e,"base32"),i=Lv(r);return n+":"+i}});var Qv=w((lM,Yv)=>{"use strict";var Mv=Uv(),Hf=fa(),da=ki(),{concat:Fv}=(Gn(),zn),{toString:DP}=(Tt(),Ot);Yv.exports={stringToStringTuples:Kv,stringTuplesToString:Vv,tuplesToStringTuples:$v,stringTuplesToTuples:jv,bytesToTuples:zf,tuplesToBytes:Hv,bytesToString:LP,stringToBytes:Gv,fromString:kP,fromBytes:Wv,validateBytes:Gf,isValidBytes:qP,cleanPath:zc,ParseError:Wf,protoFromTuple:pa,sizeForAddr:zv};function Kv(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let i=r[n],s=Hf(i);if(s.size===0){e.push([i]);continue}if(n++,n>=r.length)throw Wf("invalid address: "+t);if(s.path){e.push([i,zc(r.slice(n).join("/"))]);break}e.push([i,r[n]])}return e}function Vv(t){let e=[];return t.map(r=>{let n=pa(r);return e.push(n.name),r.length>1&&e.push(r[1]),null}),zc(e.join("/"))}function jv(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=pa(e);return e.length>1?[r.code,Mv.toBytes(r.code,e[1])]:[r.code]})}function $v(t){return t.map(e=>{let r=pa(e);return e[1]?[r.code,Mv.toString(r.code,e[1])]:[r.code]})}function Hv(t){return Wv(Fv(t.map(e=>{let r=pa(e),n=Uint8Array.from(da.encode(r.code));return e.length>1&&(n=Fv([n,e[1]])),n})))}function zv(t,e){return t.size>0?t.size/8:t.size===0?0:da.decode(e)+da.decode.bytes}function zf(t){let e=[],r=0;for(;r<t.length;){let n=da.decode(t,r),i=da.decode.bytes,s=Hf(n),o=zv(s,t.slice(r+i));if(o===0){e.push([n]),r+=i;continue}let a=t.slice(r+i,r+i+o);if(r+=o+i,r>t.length)throw Wf("Invalid address Uint8Array: "+DP(t,"base16"));e.push([n,a])}return e}function LP(t){let e=zf(t),r=$v(e);return Vv(r)}function Gv(t){t=zc(t);let e=Kv(t),r=jv(e);return Hv(r)}function kP(t){return Gv(t)}function Wv(t){let e=Gf(t);if(e)throw e;return Uint8Array.from(t)}function Gf(t){try{zf(t)}catch(e){return e}}function qP(t){return Gf(t)===void 0}function zc(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Wf(t){return new Error("Error parsing address: "+t)}function pa(t){return Hf(t[0])}});var qt=w((fM,Jv)=>{"use strict";var Lr=Qv(),qs=fa(),Xv=ki(),{CID:UP}=(vs(),Do),{base58btc:MP}=(Ln(),Dn),FP=he(),KP=Symbol.for("nodejs.util.inspect.custom"),{toString:Gc}=(Tt(),Ot),{equals:VP}=(pr(),dr),Yf=new Map,Zv=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ht=class{constructor(e){if(e==null&&(e=""),Object.defineProperty(this,Zv,{value:!0}),e instanceof Uint8Array)this.bytes=Lr.fromBytes(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Lr.fromString(e)}else if(Ht.isMultiaddr(e))this.bytes=Lr.fromBytes(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return Lr.bytesToString(this.bytes)}toJSON(){return this.toString()}toOptions(){let e={},r=this.toString().split("/");return e.family=r[1]==="ip4"?4:6,e.host=r[2],e.transport=r[3],e.port=parseInt(r[4]),e}protos(){return this.protoCodes().map(e=>Object.assign({},qs(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let i=Xv.decode(r,n),s=Xv.decode.bytes,o=qs(i);n+=Lr.sizeForAddr(o,r.slice(n+s))+s,e.push(i)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return Lr.bytesToTuples(this.bytes)}stringTuples(){let e=Lr.bytesToTuples(this.bytes);return Lr.tuplesToStringTuples(e)}encapsulate(e){return e=new Ht(e),new Ht(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),i=n.lastIndexOf(r);if(i<0)throw new Error("Address "+this+" does not contain subaddress: "+e);return new Ht(n.slice(0,i))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new Ht(Lr.tuplesToBytes(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===qs.names.ipfs.code).pop();if(r&&r[1]){let n=r[1];return n[0]==="Q"||n[0]==="1"?Gc(MP.decode(`z${n}`),"base58btc"):Gc(UP.parse(n).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){let e=null;try{e=this.stringTuples().filter(r=>!!qs(r[0]).path)[0][1],e||(e=null)}catch(r){e=null}return e}equals(e){return VP(this.bytes,e.bytes)}async resolve(){let e=this.protos().find(i=>i.resolvable);if(!e)return[this];let r=Yf.get(e.name);if(!r)throw FP(new Error(`no available resolver for ${e.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await r(this)).map(i=>new Ht(i))}nodeAddress(){let e=this.protoCodes(),r=this.protoNames(),n=this.toString().split("/").slice(1);if(n.length<4)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6}/{address}/{tcp, udp}/{port}".');if(e[0]!==4&&e[0]!==41&&e[0]!==54&&e[0]!==55)throw new Error(`no protocol with name: "'${r[0]}'". Must have a valid family name: "{ip4, ip6, dns4, dns6}".`);if(n[2]!=="tcp"&&n[2]!=="udp")throw new Error(`no protocol with name: "'${r[1]}'". Must have a valid transport protocol: "{tcp, udp}".`);return{family:e[0]===41||e[0]===55?6:4,address:n[1],port:parseInt(n[3])}}isThinWaistAddress(e){let r=(e||this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}static fromNodeAddress(e,r){if(!e)throw new Error("requires node address object");if(!r)throw new Error("requires transport protocol");let n;switch(e.family){case 4:n="ip4";break;case 6:n="ip6";break;default:throw Error(`Invalid addr family. Got '${e.family}' instead of 4 or 6`)}return new Ht("/"+[n,e.address,r,e.port].join("/"))}static isName(e){return Ht.isMultiaddr(e)?e.protos().some(r=>r.resolvable):!1}static isMultiaddr(e){return e instanceof Ht||Boolean(e&&e[Zv])}[KP](){return"<Multiaddr "+Gc(this.bytes,"base16")+" - "+Lr.bytesToString(this.bytes)+">"}inspect(){return"<Multiaddr "+Gc(this.bytes,"base16")+" - "+Lr.bytesToString(this.bytes)+">"}};Ht.protocols=qs;Ht.resolvers=Yf;function jP(t){return new Ht(t)}Jv.exports={Multiaddr:Ht,multiaddr:jP,protocols:qs,resolvers:Yf}});var Wc=w((hM,e1)=>{"use strict";var $P=async t=>{let e=[];for await(let r of t)e.push(r);return e};e1.exports=$P});var t1,Qf,r1=xe(()=>{t1=Ro(Wc()),Qf=(t,e)=>async function*(){yield*(await(0,t1.default)(t)).sort(e)}()});var ya=w((pM,n1)=>{"use strict";var HP=async t=>{for await(let e of t);};n1.exports=HP});var Yc=w((yM,i1)=>{"use strict";var zP=async function*(t,e){for await(let r of t)await e(r)&&(yield r)};i1.exports=zP});var Xf=w((gM,s1)=>{"use strict";var GP=async function*(t,e){let r=0;if(!(e<1)){for await(let n of t)if(yield n,r++,r===e)return}};s1.exports=GP});var Zf,qi,Jf,eh,o1=xe(()=>{r1();Zf=Ro(ya()),qi=Ro(Yc()),Jf=Ro(Xf()),eh=class{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}get(e,r){return Promise.reject(new Error(".get is not implemented"))}has(e,r){return Promise.reject(new Error(".has is not implemented"))}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,r={}){for await(let{key:n,value:i}of e)await this.put(n,i,r),yield{key:n,value:i}}async*getMany(e,r={}){for await(let n of e)yield this.get(n,r)}async*deleteMany(e,r={}){for await(let n of e)await this.delete(n,r),yield n}batch(){let e=[],r=[];return{put(n,i){e.push({key:n,value:i})},delete(n){r.push(n)},commit:async n=>{await(0,Zf.default)(this.putMany(e,n)),e=[],await(0,Zf.default)(this.deleteMany(r,n)),r=[]}}}async*_all(e,r){throw new Error("._all is not implemented")}async*_allKeys(e,r){throw new Error("._allKeys is not implemented")}query(e,r){let n=this._all(e,r);if(e.prefix!=null&&(n=(0,qi.default)(n,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,qi.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Qf(i,s),n)),e.offset!=null){let i=0;n=(0,qi.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Jf.default)(n,e.limit)),n}queryKeys(e,r){let n=this._allKeys(e,r);if(e.prefix!=null&&(n=(0,qi.default)(n,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(n=e.filters.reduce((i,s)=>(0,qi.default)(i,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((i,s)=>Qf(i,s),n)),e.offset!=null){let i=0;n=(0,qi.default)(n,()=>i++>=e.offset)}return e.limit!=null&&(n=(0,Jf.default)(n,e.limit)),n}}});var a1,c1=xe(()=>{a1="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"});var rh={};gt(rh,{customAlphabet:()=>WP,customRandom:()=>l1,nanoid:()=>th,random:()=>u1,urlAlphabet:()=>a1});var u1,l1,WP,th,Qc=xe(()=>{c1();u1=t=>crypto.getRandomValues(new Uint8Array(t)),l1=(t,e,r)=>{let n=(2<<Math.log(t.length-1)/Math.LN2)-1,i=-~(1.6*n*e/t.length);return()=>{let s="";for(;;){let o=r(i),a=i;for(;a--;)if(s+=t[o[a]&n]||"",s.length===e)return s}}},WP=(t,e)=>l1(t,e,u1),th=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;){let n=r[t]&63;n<36?e+=n.toString(36):n<62?e+=(n-26).toString(36).toUpperCase():n<63?e+="_":e+="-"}return e}});var nh={};gt(nh,{Key:()=>Bt});function YP(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function QP(t){let e=t.split(":");return e[e.length-1]}function XP(t){return[].concat(...t)}var xn,f1,Xc,Bt,Zc=xe(()=>{Qc();Tt();It();xn="/",f1=new TextEncoder().encode(xn),Xc=f1[0],Bt=class{constructor(e,r){if(typeof e=="string")this._buf=uf(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==Xc)throw new Error("Invalid key")}toString(e="utf8"){return ff(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Bt(e.join(xn))}static random(){return new Bt(th().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new Bt(e):e.uint8Array?new Bt(e.uint8Array()):null}clean(){if((!this._buf||this._buf.byteLength===0)&&(this._buf=f1),this._buf[0]!==Xc){let e=new Uint8Array(this._buf.byteLength+1);e.fill(Xc,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Xc;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let i=0;i<r.length;i++){if(n.length<i+1)return!1;let s=r[i],o=n[i];if(s<o)return!0;if(s>o)return!1}return r.length<n.length}reverse(){return Bt.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(xn).slice(1)}type(){return YP(this.baseNamespace())}name(){return QP(this.baseNamespace())}instance(e){return new Bt(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(xn)||(e+=xn),e+=this.type(),new Bt(e)}parent(){let e=this.list();return e.length===1?new Bt(xn):new Bt(e.slice(0,-1).join(xn))}child(e){return this.toString()===xn?e:e.toString()===xn?this:new Bt(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return Bt.withNamespaces([...this.namespaces(),...XP(e.map(r=>r.namespaces()))])}}});function d1(t){return t=t||new Error("Not Found"),(0,h1.default)(t,"ERR_NOT_FOUND")}var h1,p1=xe(()=>{h1=Ro(he())});var g1={};gt(g1,{MemoryDatastore:()=>y1});var y1,m1=xe(()=>{o1();Zc();p1();y1=class extends eh{constructor(){super();this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}async put(e,r){this.data[e.toString()]=r}async get(e){if(!await this.has(e))throw d1();return this.data[e.toString()]}async has(e){return this.data[e.toString()]!==void 0}async delete(e){delete this.data[e.toString()]}async*_all(){yield*Object.entries(this.data).map(([e,r])=>({key:new Bt(e),value:r}))}async*_allKeys(){yield*Object.entries(this.data).map(([e])=>new Bt(e))}}});var je=w(ih=>{"use strict";ih.messages={NOT_STARTED_YET:"The libp2p node is not started yet",DHT_DISABLED:"DHT is not available",CONN_ENCRYPTION_REQUIRED:"At least one connection encryption module is required",NOT_FOUND:"Not found"};ih.codes={DHT_DISABLED:"ERR_DHT_DISABLED",PUBSUB_NOT_STARTED:"ERR_PUBSUB_NOT_STARTED",DHT_NOT_STARTED:"ERR_DHT_NOT_STARTED",CONN_ENCRYPTION_REQUIRED:"ERR_CONN_ENCRYPTION_REQUIRED",ERR_INVALID_PROTOCOLS_FOR_STREAM:"ERR_INVALID_PROTOCOLS_FOR_STREAM",ERR_CONNECTION_ENDED:"ERR_CONNECTION_ENDED",ERR_CONNECTION_FAILED:"ERR_CONNECTION_FAILED",ERR_NODE_NOT_STARTED:"ERR_NODE_NOT_STARTED",ERR_ALREADY_ABORTED:"ERR_ALREADY_ABORTED",ERR_TOO_MANY_ADDRESSES:"ERR_TOO_MANY_ADDRESSES",ERR_NO_VALID_ADDRESSES:"ERR_NO_VALID_ADDRESSES",ERR_RELAYED_DIAL:"ERR_RELAYED_DIAL",ERR_DIALED_SELF:"ERR_DIALED_SELF",ERR_DISCOVERED_SELF:"ERR_DISCOVERED_SELF",ERR_DUPLICATE_TRANSPORT:"ERR_DUPLICATE_TRANSPORT",ERR_ENCRYPTION_FAILED:"ERR_ENCRYPTION_FAILED",ERR_HOP_REQUEST_FAILED:"ERR_HOP_REQUEST_FAILED",ERR_INVALID_KEY:"ERR_INVALID_KEY",ERR_INVALID_MESSAGE:"ERR_INVALID_MESSAGE",ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS",ERR_INVALID_PEER:"ERR_INVALID_PEER",ERR_MUXER_UNAVAILABLE:"ERR_MUXER_UNAVAILABLE",ERR_NOT_FOUND:"ERR_NOT_FOUND",ERR_TIMEOUT:"ERR_TIMEOUT",ERR_TRANSPORT_UNAVAILABLE:"ERR_TRANSPORT_UNAVAILABLE",ERR_TRANSPORT_DIAL_FAILED:"ERR_TRANSPORT_DIAL_FAILED",ERR_UNSUPPORTED_PROTOCOL:"ERR_UNSUPPORTED_PROTOCOL",ERR_INVALID_MULTIADDR:"ERR_INVALID_MULTIADDR",ERR_SIGNATURE_NOT_VALID:"ERR_SIGNATURE_NOT_VALID",ERR_FIND_SELF:"ERR_FIND_SELF",ERR_NO_ROUTERS_AVAILABLE:"ERR_NO_ROUTERS_AVAILABLE",ERR_CONNECTION_NOT_MULTIPLEXED:"ERR_CONNECTION_NOT_MULTIPLEXED",ERR_NO_DIAL_TOKENS:"ERR_NO_DIAL_TOKENS",ERR_KEYCHAIN_REQUIRED:"ERR_KEYCHAIN_REQUIRED",ERR_INVALID_CMS:"ERR_INVALID_CMS",ERR_MISSING_KEYS:"ERR_MISSING_KEYS",ERR_NO_KEY:"ERR_NO_KEY",ERR_INVALID_KEY_NAME:"ERR_INVALID_KEY_NAME",ERR_INVALID_KEY_TYPE:"ERR_INVALID_KEY_TYPE",ERR_KEY_ALREADY_EXISTS:"ERR_KEY_ALREADY_EXISTS",ERR_INVALID_KEY_SIZE:"ERR_INVALID_KEY_SIZE",ERR_KEY_NOT_FOUND:"ERR_KEY_NOT_FOUND",ERR_OLD_KEY_NAME_INVALID:"ERR_OLD_KEY_NAME_INVALID",ERR_NEW_KEY_NAME_INVALID:"ERR_NEW_KEY_NAME_INVALID",ERR_PASSWORD_REQUIRED:"ERR_PASSWORD_REQUIRED",ERR_PEM_REQUIRED:"ERR_PEM_REQUIRED",ERR_CANNOT_READ_KEY:"ERR_CANNOT_READ_KEY",ERR_MISSING_PRIVATE_KEY:"ERR_MISSING_PRIVATE_KEY",ERR_INVALID_OLD_PASS_TYPE:"ERR_INVALID_OLD_PASS_TYPE",ERR_INVALID_NEW_PASS_TYPE:"ERR_INVALID_NEW_PASS_TYPE",ERR_INVALID_PASS_LENGTH:"ERR_INVALID_PASS_LENGTH",ERR_NOT_IMPLEMENTED:"ERR_NOT_IMPLEMENTED",ERR_WRONG_PING_ACK:"ERR_WRONG_PING_ACK"}});var b1=w((RM,v1)=>{"use strict";var ZP=async function*(t,e){for await(let r of t)yield e(r)};v1.exports=ZP});var sh=w((BM,E1)=>{"use strict";var JP=he(),eN=Yc(),tN=b1(),rN=Xf();async function*nN(t,e){yield*tN(t,async r=>(await e.addressBook.add(r.id,r.multiaddrs),r))}function iN(t){let e=new Set;return eN(t,r=>e.has(r.id.toString())?!1:(e.add(r.id.toString()),!0))}async function*sN(t,e=1){let r=0;for await(let n of t)r++,yield n;if(r<e)throw JP(new Error("not found"),"NOT_FOUND")}function oN(t,e){return e?rN(t,e):t}E1.exports={storeAddresses:nN,uniquePeers:iN,requirePeers:sN,maybeLimitSource:oN}});var _1=w((PM,w1)=>{"use strict";w1.exports=function(){return Date.now()}});var ga=w((NM,S1)=>{"use strict";var Jc=_1(),x1=class{constructor(e,r,n){let i=this;this._started=Jc(),this._rescheduled=0,this._scheduled=r,this._args=n,this._triggered=!1,this._timerWrapper=()=>{i._rescheduled>0?(i._scheduled=i._rescheduled-(Jc()-i._started),i._schedule(i._scheduled)):(i._triggered=!0,e.apply(null,i._args))},this._timer=setTimeout(this._timerWrapper,r)}reschedule(e){e||(e=this._scheduled);let r=Jc();r+e-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(e)):this._triggered?this._schedule(e):(this._started=r,this._rescheduled=e)}_schedule(e){this._triggered=!1,this._started=Jc(),this._rescheduled=0,this._scheduled=e,this._timer=setTimeout(this._timerWrapper,e)}clear(){clearTimeout(this._timer)}};function aN(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("timeout needed");let t;if(arguments.length>0){t=new Array(arguments.length-2);for(var e=0;e<t.length;e++)t[e]=arguments[e+2]}return new x1(arguments[0],arguments[1],t)}S1.exports=aN});var oh=w((OM,C1)=>{"use strict";var{AbortController:cN}=globalThis,A1=ga(),eu=class extends cN{constructor(e){super();this._ms=e,this._timer=A1(()=>this.abort(),e),Object.setPrototypeOf(this,eu.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=A1(()=>this.abort(),this._ms)}};C1.exports={TimeoutController:eu}});var T1=w((LM,I1)=>{I1.exports=class{constructor(e){if(!(e>0)||(e-1&e)!=0)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 this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}});var ah=w((qM,B1)=>{var R1=T1();B1.exports=class{constructor(e){this.hwm=e||16,this.head=new R1(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){let r=this.head;this.head=r.next=new R1(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next){let r=this.tail.next;return this.tail.next=null,this.tail=r,this.tail.shift()}return e}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}});var uh=w((UM,P1)=>{var ch=ah();P1.exports=t=>{t=t||{};let e;typeof t=="function"?(e=t,t={}):e=t.onEnd;let r=new ch,n,i,s,o=()=>{if(!r.isEmpty()){if(t.writev){let g,m=[];for(;!r.isEmpty();){if(g=r.shift(),g.error)throw g.error;m.push(g.value)}return{done:g.done,value:m}}let d=r.shift();if(d.error)throw d.error;return d}return s?{done:!0}:new Promise((d,g)=>{i=m=>(i=null,m.error?g(m.error):t.writev&&!m.done?d({done:m.done,value:[m.value]}):d(m),n)})},a=d=>i?i(d):(r.push(d),n),c=d=>(r=new ch,i?i({error:d}):(r.push({error:d}),n)),u=d=>s?n:a({done:!1,value:d}),l=d=>s?n:(s=!0,d?c(d):a({done:!0})),f=()=>(r=new ch,l(),{done:!0}),h=d=>(l(d),{done:!0});if(n={[Symbol.asyncIterator](){return this},next:o,return:f,throw:h,push:u,end:l},!e)return n;let p=n;return n={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(d){return p.throw(d),e&&(e(d),e=null),{done:!0}},return(){return p.return(),e&&(e(),e=null),{done:!0}},push:u,end(d){return p.end(d),e&&(e(d),e=null),n}},n}});var lh=w((MM,N1)=>{"use strict";var uN=uh(),lN=async function*(...t){let e=uN();setTimeout(async()=>{try{await Promise.all(t.map(async r=>{for await(let n of r)e.push(n)})),e.end()}catch(r){e.end(r)}},0),yield*e};N1.exports=lN});var nn=w((FM,Us)=>{var O1=(...t)=>{let e;for(;t.length;)e=t.shift()(e);return e},fh=t=>t&&(typeof t[Symbol.asyncIterator]=="function"||typeof t[Symbol.iterator]=="function"||typeof t.next=="function"),tu=t=>t&&typeof t.sink=="function"&&fh(t.source),fN=t=>e=>(t.sink(e),t.source),D1=(...t)=>{if(tu(t[0])){let e=t[0];t[0]=()=>e.source}else if(fh(t[0])){let e=t[0];t[0]=()=>e}if(t.length>1&&tu(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let e=1;e<t.length-1;e++)tu(t[e])&&(t[e]=fN(t[e]));return O1(...t)};Us.exports=D1;Us.exports.pipe=D1;Us.exports.rawPipe=O1;Us.exports.isIterable=fh;Us.exports.isDuplex=tu});var hh=w((KM,L1)=>{"use strict";var hN=async t=>{for await(let e of t)return e};L1.exports=hN});var dh=w((VM,k1)=>{"use strict";var Ms=new Map,dN=()=>`${Date.now()}:${Math.floor(Math.random()*1e6)}`;async function pN(t,e,r){for(;Ms.get(r);){try{await t()}catch(n){setTimeout(()=>{throw n},1);break}if(!Ms.get(r))break;await new Promise(n=>{let i=setTimeout(n,e);Ms.set(r,i)})}}function yN(t,e,r){r=r||e;let n=dN(),i=setTimeout(()=>{pN(t,e,n)},r);return Ms.set(n,i),n}function gN(t){let e=Ms.get(t);e&&(clearTimeout(e),Ms.delete(t))}k1.exports={setDelayedInterval:yN,clearDelayedInterval:gN}});var M1=w((jM,U1)=>{"use strict";var mN=he(),{messages:vN,codes:bN}=je(),q1=class{constructor(e){this._dht=e}async findPeer(e,r={}){for await(let n of this._dht.findPeer(e,r))if(n.name==="FINAL_PEER")return n.peer;throw mN(new Error(vN.NOT_FOUND),bN.ERR_NOT_FOUND)}async*getClosestPeers(e,r={}){for await(let n of this._dht.getClosestPeers(e,r))n.name==="PEER_RESPONSE"&&(yield*n.closer)}};U1.exports={DHTPeerRouting:q1}});var W1=w(($M,G1)=>{"use strict";var F1=Te(),K1=Object.assign(F1("libp2p:peer-routing"),{error:F1("libp2p:peer-routing:err")}),ru=he(),ma=je(),{storeAddresses:V1,uniquePeers:EN,requirePeers:wN}=sh(),{TimeoutController:_N}=oh(),j1=lh(),{pipe:$1}=nn(),xN=hh(),SN=ya(),AN=Yc(),{setDelayedInterval:CN,clearDelayedInterval:IN}=dh(),{DHTPeerRouting:TN}=M1(),{setMaxListeners:H1}=Qt(),z1=class{constructor(e){this._peerId=e.peerId,this._peerStore=e.peerStore,this._routers=e._modules.peerRouting||[],e._dht&&e._config.dht.enabled&&this._routers.push(new TN(e._dht)),this._refreshManagerOptions=e._options.peerRouting.refreshManager,this._findClosestPeersTask=this._findClosestPeersTask.bind(this)}start(){!this._routers.length||this._timeoutId||!this._refreshManagerOptions.enabled||(this._timeoutId=CN(this._findClosestPeersTask,this._refreshManagerOptions.interval,this._refreshManagerOptions.bootDelay))}async _findClosestPeersTask(){try{await SN(this.getClosestPeers(this._peerId.id,{timeout:this._refreshManagerOptions.timeout||1e4}))}catch(e){K1.error(e)}}stop(){IN(this._timeoutId)}async findPeer(e,r){if(!this._routers.length)throw ru(new Error("No peer routers available"),ma.codes.ERR_NO_ROUTERS_AVAILABLE);if(e.toB58String()===this._peerId.toB58String())throw ru(new Error("Should not try to find self"),ma.codes.ERR_FIND_SELF);let n=await $1(j1(...this._routers.map(i=>async function*(){try{yield await i.findPeer(e,r)}catch(s){K1.error(s)}}())),i=>AN(i,Boolean),i=>V1(i,this._peerStore),i=>xN(i));if(n)return n;throw ru(new Error(ma.messages.NOT_FOUND),ma.codes.ERR_NOT_FOUND)}async*getClosestPeers(e,r={timeout:3e4}){if(!this._routers.length)throw ru(new Error("No peer routers available"),ma.codes.ERR_NO_ROUTERS_AVAILABLE);if(r.timeout){let n=new _N(r.timeout);try{H1&&H1(1/0,n.signal)}catch{}r.signal=n.signal}yield*$1(j1(...this._routers.map(n=>n.getClosestPeers(e,r))),n=>V1(n,this._peerStore),n=>EN(n),n=>wN(n))}};G1.exports=z1});var X1=w((HM,Q1)=>{"use strict";var RN=ya(),Y1=class{constructor(e){this._dht=e}async provide(e){await RN(this._dht.provide(e))}async*findProviders(e,r){for await(let n of this._dht.findProviders(e,r))n.name==="PROVIDER"&&(yield*n.providers)}};Q1.exports={DHTContentRouting:Y1}});var eb=w((zM,J1)=>{"use strict";var Ui=he(),{messages:va,codes:Mi}=je(),{storeAddresses:BN,uniquePeers:PN,requirePeers:NN,maybeLimitSource:ON}=sh(),DN=ya(),LN=lh(),{pipe:kN}=nn(),{DHTContentRouting:qN}=X1(),Z1=class{constructor(e){this.libp2p=e,this.routers=e._modules.contentRouting||[],this.dht=e._dht,this.dht&&e._config.dht.enabled&&this.routers.push(new qN(this.dht))}async*findProviders(e,r={}){if(!this.routers.length)throw Ui(new Error("No content this.routers available"),Mi.ERR_NO_ROUTERS_AVAILABLE);yield*kN(LN(...this.routers.map(n=>n.findProviders(e,r))),n=>BN(n,this.libp2p.peerStore),n=>PN(n),n=>ON(n,r.maxNumProviders),n=>NN(n))}async provide(e){if(!this.routers.length)throw Ui(new Error("No content routers available"),Mi.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map(r=>r.provide(e)))}async put(e,r,n){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw Ui(new Error(va.NOT_STARTED_YET),Mi.DHT_NOT_STARTED);await DN(this.dht.put(e,r,n))}async get(e,r){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw Ui(new Error(va.NOT_STARTED_YET),Mi.DHT_NOT_STARTED);for await(let n of this.dht.get(e,r))if(n.name==="VALUE")return{from:n.peerId,val:n.value};throw Ui(new Error(va.NOT_FOUND),Mi.ERR_NOT_FOUND)}async*getMany(e,r,n){if(!this.libp2p.isStarted()||!this.dht.isStarted)throw Ui(new Error(va.NOT_STARTED_YET),Mi.DHT_NOT_STARTED);if(!r)return;let i=0;for await(let s of this.dht.get(e,n))if(s.name==="VALUE"&&(yield{from:s.peerId,val:s.value},i++,i===r))break;if(i===0)throw Ui(new Error(va.NOT_FOUND),Mi.ERR_NOT_FOUND)}};J1.exports=Z1});var ph=w((GM,ib)=>{"use strict";var UN=Rt(),{Multiaddr:tb}=qt(),rb=he(),{codes:nb}=je();function MN(t){typeof t=="string"&&(t=new tb(t));let e;if(tb.isMultiaddr(t)){e=t;let r=t.getPeerId();if(!r)throw rb(new Error(`${t} does not have a valid peer type`),nb.ERR_INVALID_MULTIADDR);try{t=UN.createFromB58String(r)}catch(n){throw rb(new Error(`${t} is not a valid peer type`),nb.ERR_INVALID_MULTIADDR)}}return{id:t,multiaddrs:e?[e]:void 0}}ib.exports=MN});var ob=w((WM,sb)=>{"use strict";sb.exports=t=>{if(Object.prototype.toString.call(t)!=="[object Object]")return!1;let e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}});var Vs=w((lb,fb)=>{"use strict";var nu=ob(),{hasOwnProperty:ab}=Object.prototype,{propertyIsEnumerable:FN}=Object,Fs=(t,e,r)=>Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0}),KN=lb,cb={concatArrays:!1,ignoreUndefined:!1},iu=t=>{let e=[];for(let r in t)ab.call(t,r)&&e.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(t);for(let n of r)FN.call(t,n)&&e.push(n)}return e};function Ks(t){return Array.isArray(t)?VN(t):nu(t)?jN(t):t}function VN(t){let e=t.slice(0,0);return iu(t).forEach(r=>{Fs(e,r,Ks(t[r]))}),e}function jN(t){let e=Object.getPrototypeOf(t)===null?Object.create(null):{};return iu(t).forEach(r=>{Fs(e,r,Ks(t[r]))}),e}var ub=(t,e,r,n)=>(r.forEach(i=>{typeof e[i]=="undefined"&&n.ignoreUndefined||(i in t&&t[i]!==Object.getPrototypeOf(t)?Fs(t,i,yh(t[i],e[i],n)):Fs(t,i,Ks(e[i])))}),t),$N=(t,e,r)=>{let n=t.slice(0,0),i=0;return[t,e].forEach(s=>{let o=[];for(let a=0;a<s.length;a++)!ab.call(s,a)||(o.push(String(a)),s===t?Fs(n,i++,s[a]):Fs(n,i++,Ks(s[a])));n=ub(n,s,iu(s).filter(a=>!o.includes(a)),r)}),n};function yh(t,e,r){return r.concatArrays&&Array.isArray(t)&&Array.isArray(e)?$N(t,e,r):!nu(e)||!nu(t)?Ks(e):ub(t,e,iu(e),r)}fb.exports=function(...t){let e=yh(Ks(cb),this!==KN&&this||{},cb),r={_:{}};for(let n of t)if(n!==void 0){if(!nu(n))throw new TypeError("`"+n+"` is not an Option Object");r=yh(r,{_:n},e)}return r._}});var pb=w((YM,db)=>{"use strict";db.exports=hb;var HN=ll(),ti=hb.prototype,zN=new Date%1e9;function GN(){return(Math.random()*1e9>>>0)+zN++}function hb(t){t=t||{},this.id=t.id||GN(),this.max=t.max||1/0,this.items=t.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(t.lastModified||new Date);for(var e,r,n=this.items.length;n--;)e=this.items[n],r=new Date(e.expires)-new Date,this._lookup[e.key]=e,r>0?this.expire(e.key,r):r<=0&&this.delete(e.key)}ti.has=function(t){return t in this._lookup};ti.get=function(t){if(!this.has(t))return null;var e=this._lookup[t];return e.refresh&&this.expire(t,e.refresh),this.items.splice(this.items.indexOf(e),1),this.items.push(e),e.value};ti.meta=function(t){if(!this.has(t))return null;var e=this._lookup[t];return"meta"in e?e.meta:null};ti.set=function(t,e,r){var n=this._lookup[t],i=this._lookup[t]={key:t,value:e};return this.lastModified=new Date,n?(clearTimeout(n.timeout),this.items.splice(this.items.indexOf(n),1,i)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(i),this.size++),r&&("ttl"in r&&this.expire(t,r.ttl),"meta"in r&&(i.meta=r.meta),r.refresh&&(i.refresh=r.ttl)),this};ti.delete=function(t){var e=this._lookup[t];return e?(this.lastModified=new Date,this.items.splice(this.items.indexOf(e),1),clearTimeout(e.timeout),delete this._lookup[t],this.size--,this):!1};ti.expire=function(t,e){var r=e||0,n=this._lookup[t];if(!n)return this;if(typeof r=="string"&&(r=HN(e)),typeof r!="number")throw new TypeError("Expiration time must be a string or number.");return clearTimeout(n.timeout),n.timeout=setTimeout(this.delete.bind(this,n.key),r),n.expires=Number(new Date)+r,this};ti.clear=function(){for(var t=this.items.length;t--;)this.delete(this.items[t].key);return this};ti.toJSON=function(){for(var t=new Array(this.items.length),e,r=t.length;r--;)e=this.items[r],t[r]={key:e.key,meta:e.meta,value:e.value,expires:e.expires,refresh:e.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:t}}});var ba=w((js,yb)=>{"use strict";var WN=function(){if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof Sn!="undefined")return Sn;throw new Error("unable to locate global object")},Sn=WN();yb.exports=js=Sn.fetch;Sn.fetch&&(js.default=Sn.fetch.bind(Sn));js.Headers=Sn.Headers;js.Request=Sn.Request;js.Response=Sn.Response});var gb=w((QM,gh)=>{"use strict";globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?gh.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:gh.exports={default:ba().default,Headers:ba().Headers,Request:ba().Request,Response:ba().Response}});var vb=w((XM,mb)=>{"use strict";var{default:YN,Headers:QN}=gb();function XN({serverResolver:t,hostname:e,recordType:r}){return`${t}?name=${e}&type=${r}`}function ZN(t){return YN(t,{headers:new QN({accept:"application/dns-json"})})}function JN(t,e){return`${e}_${t}`}mb.exports={buildResource:XN,fetch:ZN,getCacheKey:JN}});var wb=w((ZM,Eb)=>{"use strict";var bb=Te(),su=bb("dns-over-http-resolver");su.error=bb("dns-over-http-resolver:error");var e3=pb(),Er=vb(),ou=class{constructor({maxCache:e=100}={}){this._cache=new e3({max:e}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"]}getServers(){return this._servers}_getShuffledServers(){let e=[].concat(this._servers);for(let r=e.length-1;r>0;r--){let n=Math.floor(Math.random()*r),i=e[r];e[r]=e[n],e[n]=i}return e}setServers(e){this._servers=e}resolve(e,r="A"){switch(r){case"A":return this.resolve4(e);case"AAAA":return this.resolve6(e);case"TXT":return this.resolveTxt(e);default:throw new Error(`${r} is not supported`)}}async resolve4(e){let r="A",n=this._cache.get(Er.getCacheKey(e,r));if(n)return n;for(let i of this._getShuffledServers())try{let o=await(await Er.fetch(Er.buildResource({serverResolver:i,hostname:e,recordType:r}))).json(),a=o.Answer.map(u=>u.data),c=Math.min(o.Answer.map(u=>u.TTL));return this._cache.set(Er.getCacheKey(e,r),a,{ttl:c}),a}catch(s){su.error(`${i} could not resolve ${e} record ${r}`)}throw new Error(`Could not resolve ${e} record ${r}`)}async resolve6(e){let r="AAAA",n=this._cache.get(Er.getCacheKey(e,r));if(n)return n;for(let i of this._getShuffledServers())try{let o=await(await Er.fetch(Er.buildResource({serverResolver:i,hostname:e,recordType:r}))).json(),a=o.Answer.map(u=>u.data),c=Math.min(o.Answer.map(u=>u.TTL));return this._cache.set(Er.getCacheKey(e,r),a,{ttl:c}),a}catch(s){su.error(`${i} could not resolve ${e} record ${r}`)}throw new Error(`Could not resolve ${e} record ${r}`)}async resolveTxt(e){let r="TXT",n=this._cache.get(Er.getCacheKey(e,r));if(n)return n;for(let i of this._getShuffledServers())try{let o=await(await Er.fetch(Er.buildResource({serverResolver:i,hostname:e,recordType:r}))).json(),a=o.Answer.map(u=>[u.data.replace(/['"]+/g,"")]),c=Math.min(o.Answer.map(u=>u.TTL));return this._cache.set(Er.getCacheKey(e,r),a,{ttl:c}),a}catch(s){su.error(`${i} could not resolve ${e} record ${r}`)}throw new Error(`Could not resolve ${e} record ${r}`)}};ou.Resolver=ou;Eb.exports=ou});var xb=w((JM,_b)=>{"use strict";var t3=wb();_b.exports=t3});var Ab=w((eF,Sb)=>{"use strict";var r3=fa(),{code:n3}=r3("dnsaddr");async function i3(t){let e=xb(),r=new e,n=t.getPeerId(),[,i]=t.stringTuples().find(([a])=>a===n3)||[],o=(await r.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return n&&(o=o.filter(a=>a.includes(n))),o}Sb.exports={dnsaddrResolver:i3}});var au=w((tF,Cb)=>{"use strict";Cb.exports={DIAL_TIMEOUT:3e4,MAX_PARALLEL_DIALS:100,MAX_PER_PEER_DIALS:4,MAX_ADDRS_TO_DIAL:25,METRICS:{computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[60*1e3,5*60*1e3,15*60*1e3],maxOldPeersRetention:50}}});var mh=w((rF,s3)=>{s3.exports={name:"libp2p",version:"0.35.8-d8ceb0b",description:"JavaScript implementation of libp2p, a modular peer to peer network stack",leadMaintainer:"Jacob Heun <jacobheun@gmail.com>",main:"src/index.js",types:"dist/src/index.d.ts",typesVersions:{"*":{"src/*":["dist/src/*","dist/src/*/index"]}},files:["dist","src"],scripts:{lint:"aegir lint",build:"aegir build","build:proto":"npm run build:proto:circuit && npm run build:proto:fetch && npm run build:proto:identify && npm run build:proto:plaintext && npm run build:proto:address-book && npm run build:proto:proto-book && npm run build:proto:peer && npm run build:proto:peer-record && npm run build:proto:envelope","build:proto:circuit":"pbjs -t static-module -w commonjs -r libp2p-circuit --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/circuit/protocol/index.js ./src/circuit/protocol/index.proto","build:proto:fetch":"pbjs -t static-module -w commonjs -r libp2p-fetch --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/fetch/proto.js ./src/fetch/proto.proto","build:proto:identify":"pbjs -t static-module -w commonjs -r libp2p-identify --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/identify/message.js ./src/identify/message.proto","build:proto:plaintext":"pbjs -t static-module -w commonjs -r libp2p-plaintext --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/insecure/proto.js ./src/insecure/proto.proto","build:proto:peer":"pbjs -t static-module -w commonjs -r libp2p-peer --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/peer-store/pb/peer.js ./src/peer-store/pb/peer.proto","build:proto:peer-record":"pbjs -t static-module -w commonjs -r libp2p-peer-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/peer-record/peer-record.js ./src/record/peer-record/peer-record.proto","build:proto:envelope":"pbjs -t static-module -w commonjs -r libp2p-envelope --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/envelope/envelope.js ./src/record/envelope/envelope.proto","build:proto-types":"npm run build:proto-types:circuit && npm run build:proto-types:fetch && npm run build:proto-types:identify && npm run build:proto-types:plaintext && npm run build:proto-types:address-book && npm run build:proto-types:proto-book && npm run build:proto-types:peer && npm run build:proto-types:peer-record && npm run build:proto-types:envelope","build:proto-types:circuit":"pbts -o src/circuit/protocol/index.d.ts src/circuit/protocol/index.js","build:proto-types:fetch":"pbts -o src/fetch/proto.d.ts src/fetch/proto.js","build:proto-types:identify":"pbts -o src/identify/message.d.ts src/identify/message.js","build:proto-types:plaintext":"pbts -o src/insecure/proto.d.ts src/insecure/proto.js","build:proto-types:peer":"pbts -o src/peer-store/pb/peer.d.ts src/peer-store/pb/peer.js","build:proto-types:peer-record":"pbts -o src/record/peer-record/peer-record.d.ts src/record/peer-record/peer-record.js","build:proto-types:envelope":"pbts -o src/record/envelope/envelope.d.ts src/record/envelope/envelope.js",test:"aegir test","test:ts":"aegir build --no-bundle && npm run test --prefix test/ts-use","test:node":'aegir test -t node -f "./test/**/*.{node,spec}.js"',"test:browser":"aegir test -t browser","test:examples":"cd examples && npm run test:all","test:interop":"LIBP2P_JS=$PWD npx aegir test -t node -f ./node_modules/libp2p-interop/test/*",prepare:"npm run build",coverage:"nyc --reporter=text --reporter=lcov npm run test:node"},repository:{type:"git",url:"https://github.com/libp2p/js-libp2p.git"},keywords:["libp2p","network","p2p","peer","peer-to-peer","IPFS"],bugs:{url:"https://github.com/libp2p/js-libp2p/issues"},homepage:"https://libp2p.io",license:"MIT",engines:{node:">=15.0.0"},browser:{"nat-api":!1},eslintConfig:{extends:"ipfs",ignorePatterns:["!.aegir.js","test/ts-use","*.d.ts"]},dependencies:{"@vascosantos/moving-average":"^1.1.0","abortable-iterator":"^3.0.0","aggregate-error":"^3.1.0","any-signal":"^3.0.0","bignumber.js":"^9.0.1","class-is":"^1.1.0","datastore-core":"^7.0.0",debug:"^4.3.1","err-code":"^3.0.0","es6-promisify":"^7.0.0",events:"^3.3.0",hashlru:"^2.3.0","interface-datastore":"^6.0.2","it-all":"^1.0.4","it-buffer":"^0.1.2","it-drain":"^1.0.3","it-filter":"^1.0.1","it-first":"^1.0.4","it-handshake":"^2.0.0","it-length-prefixed":"^5.0.2","it-map":"^1.0.4","it-merge":"^1.0.0","it-pipe":"^1.1.0","it-take":"^1.0.0","libp2p-crypto":"^0.21.2","libp2p-interfaces":"^4.0.0","libp2p-utils":"^0.4.0",mafmt:"^10.0.0","merge-options":"^3.0.4",mortice:"^2.0.1",multiaddr:"^10.0.0",multiformats:"^9.0.0","multistream-select":"^3.0.0","mutable-proxy":"^1.0.0","nat-api":"^0.3.1","node-forge":"^1.2.1","p-any":"^3.0.0","p-fifo":"^1.0.0","p-retry":"^4.4.0","p-settle":"^4.1.1","peer-id":"^0.16.0","private-ip":"^2.1.0",protobufjs:"^6.10.2",retimer:"^3.0.0","sanitize-filename":"^1.6.3","set-delayed-interval":"^1.0.0","streaming-iterables":"^6.0.0","timeout-abort-controller":"^3.0.0",uint8arrays:"^3.0.0",varint:"^6.0.0",wherearewe:"^1.0.0",xsalsa20:"^1.1.0"},devDependencies:{"@chainsafe/libp2p-noise":"^5.0.0","@nodeutils/defaults-deep":"^1.1.0","@types/es6-promisify":"^6.0.0","@types/node":"^16.0.1","@types/node-forge":"^1.0.0","@types/varint":"^6.0.0",aegir:"^36.0.0",buffer:"^6.0.3",delay:"^5.0.0","into-stream":"^6.0.0","ipfs-http-client":"^54.0.2","it-concat":"^2.0.0","it-pair":"^1.0.0","it-pushable":"^1.4.0",libp2p:".","libp2p-bootstrap":"^0.14.0","libp2p-delegated-content-routing":"^0.11.0","libp2p-delegated-peer-routing":"^0.11.1","libp2p-interfaces-compliance-tests":"^4.0.8","libp2p-interop":"^0.7.1","libp2p-kad-dht":"^0.28.6","libp2p-mdns":"^0.18.0","libp2p-mplex":"^0.10.4","libp2p-tcp":"^0.17.0","libp2p-webrtc-star":"^0.25.0","libp2p-websockets":"^0.16.0",nock:"^13.0.3","p-defer":"^3.0.0","p-times":"^3.0.0","p-wait-for":"^3.2.0",rimraf:"^3.0.2",sinon:"^12.0.1",util:"^0.12.3"},contributors:["Vasco Santos <vasco.santos@moxy.studio>","David Dias <daviddias.p@gmail.com>","Jacob Heun <jacobheun@gmail.com>","Alex Potsides <alex@achingbrain.net>","Alan Shaw <alan@tableflip.io>","Cayman <caymannava@gmail.com>","Pedro Teixeira <i@pgte.me>","Friedel Ziegelmayer <dignifiedquire@gmail.com>","Maciej Kr\xFCger <mkg20001@gmail.com>","Hugo Dias <mail@hugodias.me>","dirkmc <dirkmdev@gmail.com>","Volker Mische <volker.mische@gmail.com>","Chris Dostert <chrisdostert@users.noreply.github.com>","zeim839 <50573884+zeim839@users.noreply.github.com>","Robert Kiel <robert.kiel@hoprnet.org>","Richard Littauer <richard.littauer@gmail.com>","a1300 <matthias-knopp@gmx.net>","Ryan Bell <ryan@piing.net>","\u1D20\u026A\u1D04\u1D1B\u1D0F\u0280 \u0299\u1D0A\u1D07\u029F\u1D0B\u029C\u1D0F\u029F\u1D0D <victorbjelkholm@gmail.com>","Andrew Nesbitt <andrewnez@gmail.com>","Franck Royer <franck@royer.one>","Thomas Eizinger <thomas@eizinger.io>","V\xEDt Habada <vithabada93@gmail.com>","Giovanni T. Parra <fiatjaf@gmail.com>","acolytec3 <17355484+acolytec3@users.noreply.github.com>","Alan Smithee <ggnore.alan.smithee@gmail.com>","Elven <mon.samuel@qq.com>","Samlior <samlior@foxmail.com>","Didrik Nordstr\xF6m <didrik.nordstrom@gmail.com>","Aditya Bose <13054902+adbose@users.noreply.github.com>","TJKoury <TJKoury@gmail.com>","TheStarBoys <41286328+TheStarBoys@users.noreply.github.com>","Tiago Alves <alvesjtiago@gmail.com>","Tim Daubensch\xFCtz <tim@daubenschuetz.de>","XiaoZhang <zxinmyth@gmail.com>","Yusef Napora <yusef@napora.org>","Zane Starr <zcstarr@gmail.com>","ebinks <elizabethjbinks@gmail.com>","greenSnot <greenSnot@users.noreply.github.com>","isan_rivkin <isanrivkin@gmail.com>","mayerwin <mayerwin@users.noreply.github.com>","mcclure <andi.m.mcclure@gmail.com>","patrickwoodhead <91056047+patrickwoodhead@users.noreply.github.com>","phillmac <phillmac@users.noreply.github.com>","robertkiel <robert.kiel@validitylabs.org>","shresthagrawal <34920931+shresthagrawal@users.noreply.github.com>","swedneck <40505480+swedneck@users.noreply.github.com>","tuyennhv <vutuyen2636@gmail.com>","S\xF6nke Hahn <soenkehahn@gmail.com>","Aleksei <vozhdb@gmail.com>","Bernd Strehl <bernd.strehl@gmail.com>","Chris Bratlien <chrisbratlien@gmail.com>","Cindy Wu <ciindy.wu@gmail.com>","Daijiro Wachi <daijiro.wachi@gmail.com>","Diogo Silva <fsdiogo@gmail.com>","Dmitriy Ryajov <dryajov@gmail.com>","Ethan Lam <elmemphis2000@gmail.com>","Fei Liu <liu.feiwood@gmail.com>","Felipe Martins <felipebrasil93@gmail.com>","Florian-Merle <florian.david.merle@gmail.com>","Francis Gulotta <wizard@roborooter.com>","Guy Sviry <32539816+guysv@users.noreply.github.com>","Henrique Dias <hacdias@gmail.com>","Irakli Gozalishvili <rfobic@gmail.com>","Joel Gustafson <joelg@mit.edu>","John Rees <johnrees@users.noreply.github.com>","Jo\xE3o Santos <joaosantos15@users.noreply.github.com>","Julien Bouquillon <contact@revolunet.com>","Kevin Kwok <antimatter15@gmail.com>","Kevin Lacker <lacker@gmail.com>","Lars Gierth <lgierth@users.noreply.github.com>","Leask Wong <i@leaskh.com>","Marcin Tojek <mtojek@users.noreply.github.com>","Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com>","Michael Burns <5170+mburns@users.noreply.github.com>","Miguel Mota <miguelmota2@gmail.com>","Nuno Nogueira <nunofmn@gmail.com>","Philipp Muens <raute1337@gmx.de>","RasmusErik Voel Jensen <github@solsort.com>","Smite Chow <xiaopengyou@live.com>","Soeren <nikorpoulsen@gmail.com>"]}});var vh=w((nF,sn)=>{"use strict";var o3=mh().version;sn.exports.PROTOCOL_VERSION="ipfs/0.1.0";sn.exports.AGENT_VERSION=`js-libp2p/${o3}`;sn.exports.MULTICODEC_IDENTIFY="/ipfs/id/1.0.0";sn.exports.MULTICODEC_IDENTIFY_PUSH="/ipfs/id/push/1.0.0";sn.exports.IDENTIFY_PROTOCOL_VERSION="0.1.0";sn.exports.MULTICODEC_IDENTIFY_PROTOCOL_NAME="id";sn.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME="id/push";sn.exports.MULTICODEC_IDENTIFY_PROTOCOL_VERSION="1.0.0";sn.exports.MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION="1.0.0"});var cu=w((iF,Tb)=>{"use strict";var Ib=60*1e3;Tb.exports={ADVERTISE_BOOT_DELAY:15*Ib,ADVERTISE_TTL:30*Ib,CIRCUIT_PROTO_CODE:290,HOP_METADATA_KEY:"hop_relay",HOP_METADATA_VALUE:"true",RELAY_RENDEZVOUS_NS:"/libp2p/relay"}});var Rb=w(Ea=>{(function(){var t,e,r,n,i,s,o,a;a=function(c){var u,l,f,h;return u=(c&255<<24)>>>24,l=(c&255<<16)>>>16,f=(c&255<<8)>>>8,h=c&255,[u,l,f,h].join(".")},o=function(c){var u,l,f,h,p,d;for(u=[],f=h=0;h<=3&&c.length!==0;f=++h){if(f>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}d=e(c),p=d[0],l=d[1],c=c.substring(l),u.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(u.length){case 1:if(u[0]>4294967295)throw new Error("Invalid IP");return u[0]>>>0;case 2:if(u[0]>255||u[1]>16777215)throw new Error("Invalid IP");return(u[0]<<24|u[1])>>>0;case 3:if(u[0]>255||u[1]>255||u[2]>65535)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2])>>>0;case 4:if(u[0]>255||u[1]>255||u[2]>255||u[3]>255)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2]<<8|u[3])>>>0;default:throw new Error("Invalid IP")}},r=function(c){return c.charCodeAt(0)},n=r("0"),s=r("a"),i=r("A"),e=function(c){var u,l,f,h,p;for(h=0,u=10,l="9",f=0,c.length>1&&c[f]==="0"&&(c[f+1]==="x"||c[f+1]==="X"?(f+=2,u=16):"0"<=c[f+1]&&c[f+1]<="9"&&(f++,u=8,l="7")),p=f;f<c.length;){if("0"<=c[f]&&c[f]<=l)h=h*u+(r(c[f])-n)>>>0;else if(u===16)if("a"<=c[f]&&c[f]<="f")h=h*u+(10+r(c[f])-s)>>>0;else if("A"<=c[f]&&c[f]<="F")h=h*u+(10+r(c[f])-i)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===p)throw new Error("empty octet");return[h,f]},t=function(){function c(u,l){var f,h,p,d;if(typeof u!="string")throw new Error("Missing `net' parameter");if(l||(d=u.split("/",2),u=d[0],l=d[1]),l||(l=32),typeof l=="string"&&l.indexOf(".")>-1){try{this.maskLong=o(l)}catch(g){throw f=g,new Error("Invalid mask: "+l)}for(h=p=32;p>=0;h=--p)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(l||l===0)this.bitmask=parseInt(l,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(u)&this.maskLong)>>>0}catch(g){throw f=g,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+l);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(o(u)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var l,f,h;for(h=o(this.first),f=o(this.last),l=0;h<=f;)u(a(h),h,l),l++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Ea.ip2long=o,Ea.long2ip=a,Ea.Netmask=t}).call(Ea)});var Pb=w((Bb,uu)=>{(function(t){"use strict";let e="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${e}\\.${e}\\.${e}\\.${e}$`,"i"),threeOctet:new RegExp(`^${e}\\.${e}\\.${e}$`,"i"),twoOctet:new RegExp(`^${e}\\.${e}$`,"i"),longValue:new RegExp(`^${e}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),s="%[0-9a-z]{1,}",o="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(s,"i"),native:new RegExp(`^(::)?(${o})?([0-9a-f]+)?(::)?(${s})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${e}\\.${e}\\.${e}\\.${e}(${s})?)$`,"i"),transitional:new RegExp(`^((?:${o})|(?:::)(?:${o})?)${e}\\.${e}\\.${e}\\.${e}(${s})?$`,"i")};function c(p,d){if(p.indexOf("::")!==p.lastIndexOf("::"))return null;let g=0,m=-1,x=(p.match(a.zoneIndex)||[])[0],R,L;for(x&&(x=x.substring(1),p=p.replace(/%.+$/,""));(m=p.indexOf(":",m+1))>=0;)g++;if(p.substr(0,2)==="::"&&g--,p.substr(-2,2)==="::"&&g--,g>d)return null;for(L=d-g,R=":";L--;)R+="0:";return p=p.replace("::",R),p[0]===":"&&(p=p.slice(1)),p[p.length-1]===":"&&(p=p.slice(0,-1)),d=function(){let H=p.split(":"),q=[];for(let k=0;k<H.length;k++)q.push(parseInt(H[k],16));return q}(),{parts:d,zoneId:x}}function u(p,d,g,m){if(p.length!==d.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let x=0,R;for(;m>0;){if(R=g-m,R<0&&(R=0),p[x]>>R!=d[x]>>R)return!1;m-=g,x+=1}return!0}function l(p){if(i.test(p))return parseInt(p,16);if(p[0]==="0"&&!isNaN(parseInt(p[1],10))){if(n.test(p))return parseInt(p,8);throw new Error(`ipaddr: cannot parse ${p} as octal`)}return parseInt(p,10)}function f(p,d){for(;p.length<d;)p=`0${p}`;return p}let h={};h.IPv4=function(){function p(d){if(d.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let g,m;for(g=0;g<d.length;g++)if(m=d[g],!(0<=m&&m<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=d}return p.prototype.SpecialRanges={unspecified:[[new p([0,0,0,0]),8]],broadcast:[[new p([255,255,255,255]),32]],multicast:[[new p([224,0,0,0]),4]],linkLocal:[[new p([169,254,0,0]),16]],loopback:[[new p([127,0,0,0]),8]],carrierGradeNat:[[new p([100,64,0,0]),10]],private:[[new p([10,0,0,0]),8],[new p([172,16,0,0]),12],[new p([192,168,0,0]),16]],reserved:[[new p([192,0,0,0]),24],[new p([192,0,2,0]),24],[new p([192,88,99,0]),24],[new p([198,51,100,0]),24],[new p([203,0,113,0]),24],[new p([240,0,0,0]),4]]},p.prototype.kind=function(){return"ipv4"},p.prototype.match=function(d,g){let m;if(g===void 0&&(m=d,d=m[0],g=m[1]),d.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return u(this.octets,d.octets,8,g)},p.prototype.prefixLengthFromSubnetMask=function(){let d=0,g=!1,m={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},x,R,L;for(x=3;x>=0;x-=1)if(R=this.octets[x],R in m){if(L=m[R],g&&L!==0)return null;L!==8&&(g=!0),d+=L}else return null;return 32-d},p.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){return this.octets.slice(0)},p.prototype.toIPv4MappedAddress=function(){return h.IPv6.parse(`::ffff:${this.toString()}`)},p.prototype.toNormalizedString=function(){return this.toString()},p.prototype.toString=function(){return this.octets.join(".")},p}(),h.IPv4.broadcastAddressFromCIDR=function(p){try{let d=this.parseCIDR(p),g=d[0].toByteArray(),m=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],R=0;for(;R<4;)x.push(parseInt(g[R],10)|parseInt(m[R],10)^255),R++;return new this(x)}catch(d){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.isIPv4=function(p){return this.parser(p)!==null},h.IPv4.isValid=function(p){try{return new this(this.parser(p)),!0}catch(d){return!1}},h.IPv4.isValidFourPartDecimal=function(p){return!!(h.IPv4.isValid(p)&&p.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},h.IPv4.networkAddressFromCIDR=function(p){let d,g,m,x,R;try{for(d=this.parseCIDR(p),m=d[0].toByteArray(),R=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],g=0;g<4;)x.push(parseInt(m[g],10)&parseInt(R[g],10)),g++;return new this(x)}catch(L){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},h.IPv4.parse=function(p){let d=this.parser(p);if(d===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(d)},h.IPv4.parseCIDR=function(p){let d;if(d=p.match(/^(.+)\/(\d+)$/)){let g=parseInt(d[2]);if(g>=0&&g<=32){let m=[this.parse(d[1]),g];return Object.defineProperty(m,"toString",{value:function(){return this.join("/")}}),m}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},h.IPv4.parser=function(p){let d,g,m;if(d=p.match(r.fourOctet))return function(){let x=d.slice(1,6),R=[];for(let L=0;L<x.length;L++)g=x[L],R.push(l(g));return R}();if(d=p.match(r.longValue)){if(m=l(d[1]),m>4294967295||m<0)throw new Error("ipaddr: address outside defined range");return function(){let x=[],R;for(R=0;R<=24;R+=8)x.push(m>>R&255);return x}().reverse()}else return(d=p.match(r.twoOctet))?function(){let x=d.slice(1,4),R=[];if(m=l(x[1]),m>16777215||m<0)throw new Error("ipaddr: address outside defined range");return R.push(l(x[0])),R.push(m>>16&255),R.push(m>>8&255),R.push(m&255),R}():(d=p.match(r.threeOctet))?function(){let x=d.slice(1,5),R=[];if(m=l(x[2]),m>65535||m<0)throw new Error("ipaddr: address outside defined range");return R.push(l(x[0])),R.push(l(x[1])),R.push(m>>8&255),R.push(m&255),R}():null},h.IPv4.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>32)throw new Error("ipaddr: invalid IPv4 prefix length");let d=[0,0,0,0],g=0,m=Math.floor(p/8);for(;g<m;)d[g]=255,g++;return m<4&&(d[m]=Math.pow(2,p%8)-1<<8-p%8),new this(d)},h.IPv6=function(){function p(d,g){let m,x;if(d.length===16)for(this.parts=[],m=0;m<=14;m+=2)this.parts.push(d[m]<<8|d[m+1]);else if(d.length===8)this.parts=d;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(m=0;m<this.parts.length;m++)if(x=this.parts[m],!(0<=x&&x<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");g&&(this.zoneId=g)}return p.prototype.SpecialRanges={unspecified:[new p([0,0,0,0,0,0,0,0]),128],linkLocal:[new p([65152,0,0,0,0,0,0,0]),10],multicast:[new p([65280,0,0,0,0,0,0,0]),8],loopback:[new p([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new p([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new p([0,0,0,0,0,65535,0,0]),96],rfc6145:[new p([0,0,0,0,65535,0,0,0]),96],rfc6052:[new p([100,65435,0,0,0,0,0,0]),96],"6to4":[new p([8194,0,0,0,0,0,0,0]),16],teredo:[new p([8193,0,0,0,0,0,0,0]),32],reserved:[[new p([8193,3512,0,0,0,0,0,0]),32]]},p.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},p.prototype.kind=function(){return"ipv6"},p.prototype.match=function(d,g){let m;if(g===void 0&&(m=d,d=m[0],g=m[1]),d.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return u(this.parts,d.parts,16,g)},p.prototype.prefixLengthFromSubnetMask=function(){let d=0,g=!1,m={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},x,R;for(let L=7;L>=0;L-=1)if(x=this.parts[L],x in m){if(R=m[x],g&&R!==0)return null;R!==16&&(g=!0),d+=R}else return null;return 128-d},p.prototype.range=function(){return h.subnetMatch(this,this.SpecialRanges)},p.prototype.toByteArray=function(){let d,g=[],m=this.parts;for(let x=0;x<m.length;x++)d=m[x],g.push(d>>8),g.push(d&255);return g},p.prototype.toFixedLengthString=function(){let d=function(){let m=[];for(let x=0;x<this.parts.length;x++)m.push(f(this.parts[x].toString(16),4));return m}.call(this).join(":"),g="";return this.zoneId&&(g=`%${this.zoneId}`),d+g},p.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let d=this.parts.slice(-2),g=d[0],m=d[1];return new h.IPv4([g>>8,g&255,m>>8,m&255])},p.prototype.toNormalizedString=function(){let d=function(){let m=[];for(let x=0;x<this.parts.length;x++)m.push(this.parts[x].toString(16));return m}.call(this).join(":"),g="";return this.zoneId&&(g=`%${this.zoneId}`),d+g},p.prototype.toRFC5952String=function(){let d=/((^|:)(0(:|$)){2,})/g,g=this.toNormalizedString(),m=0,x=-1,R;for(;R=d.exec(g);)R[0].length>x&&(m=R.index,x=R[0].length);return x<0?g:`${g.substring(0,m)}::${g.substring(m+x)}`},p.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},p}(),h.IPv6.broadcastAddressFromCIDR=function(p){try{let d=this.parseCIDR(p),g=d[0].toByteArray(),m=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],R=0;for(;R<16;)x.push(parseInt(g[R],10)|parseInt(m[R],10)^255),R++;return new this(x)}catch(d){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${d})`)}},h.IPv6.isIPv6=function(p){return this.parser(p)!==null},h.IPv6.isValid=function(p){if(typeof p=="string"&&p.indexOf(":")===-1)return!1;try{let d=this.parser(p);return new this(d.parts,d.zoneId),!0}catch(d){return!1}},h.IPv6.networkAddressFromCIDR=function(p){let d,g,m,x,R;try{for(d=this.parseCIDR(p),m=d[0].toByteArray(),R=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),x=[],g=0;g<16;)x.push(parseInt(m[g],10)&parseInt(R[g],10)),g++;return new this(x)}catch(L){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${L})`)}},h.IPv6.parse=function(p){let d=this.parser(p);if(d.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(d.parts,d.zoneId)},h.IPv6.parseCIDR=function(p){let d,g,m;if((g=p.match(/^(.+)\/(\d+)$/))&&(d=parseInt(g[2]),d>=0&&d<=128))return m=[this.parse(g[1]),d],Object.defineProperty(m,"toString",{value:function(){return this.join("/")}}),m;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},h.IPv6.parser=function(p){let d,g,m,x,R,L;if(m=p.match(a.deprecatedTransitional))return this.parser(`::ffff:${m[1]}`);if(a.native.test(p))return c(p,8);if((m=p.match(a.transitional))&&(L=m[6]||"",d=c(m[1].slice(0,-1)+L,6),d.parts)){for(R=[parseInt(m[2]),parseInt(m[3]),parseInt(m[4]),parseInt(m[5])],g=0;g<R.length;g++)if(x=R[g],!(0<=x&&x<=255))return null;return d.parts.push(R[0]<<8|R[1]),d.parts.push(R[2]<<8|R[3]),{parts:d.parts,zoneId:d.zoneId}}return null},h.IPv6.subnetMaskFromPrefixLength=function(p){if(p=parseInt(p),p<0||p>128)throw new Error("ipaddr: invalid IPv6 prefix length");let d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g=0,m=Math.floor(p/8);for(;g<m;)d[g]=255,g++;return m<16&&(d[m]=Math.pow(2,p%8)-1<<8-p%8),new this(d)},h.fromByteArray=function(p){let d=p.length;if(d===4)return new h.IPv4(p);if(d===16)return new h.IPv6(p);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},h.isValid=function(p){return h.IPv6.isValid(p)||h.IPv4.isValid(p)},h.parse=function(p){if(h.IPv6.isValid(p))return h.IPv6.parse(p);if(h.IPv4.isValid(p))return h.IPv4.parse(p);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},h.parseCIDR=function(p){try{return h.IPv6.parseCIDR(p)}catch(d){try{return h.IPv4.parseCIDR(p)}catch(g){throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},h.process=function(p){let d=this.parse(p);return d.kind()==="ipv6"&&d.isIPv4MappedAddress()?d.toIPv4Address():d},h.subnetMatch=function(p,d,g){let m,x,R,L;g==null&&(g="unicast");for(x in d)if(Object.prototype.hasOwnProperty.call(d,x)){for(R=d[x],R[0]&&!(R[0]instanceof Array)&&(R=[R]),m=0;m<R.length;m++)if(L=R[m],p.kind()===L[0].kind()&&p.match.apply(p,L))return x}return g},typeof uu!="undefined"&&uu.exports?uu.exports=h:t.ipaddr=h})(Bb)});var Lb=w(wa=>{"use strict";var Nb=wa&&wa.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(wa,"__esModule",{value:!0});var a3=Rb(),c3=Nb(qf()),u3=Nb(Mf()),Ob=Pb(),l3=["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"],f3=l3.map(t=>new a3.Netmask(t));function h3(t){for(let e of f3)if(e.contains(t))return!0;return!1}function Db(t){return/^::$/.test(t)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^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(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}wa.default=t=>{if(Ob.isValid(t)){let e=Ob.parse(t);if(e.kind()==="ipv4")return h3(e.toNormalizedString());if(e.kind()==="ipv6")return Db(t)}else if(u3.default(t)&&c3.default.v6().test(t))return Db(t)}});var bh=w((aF,kb)=>{"use strict";kb.exports=Lb().default});var Ub=w((cF,qb)=>{"use strict";var d3=bh();function p3(t){let{address:e}=t.nodeAddress();return d3(e)}qb.exports=p3});var Eh=w((uF,Fb)=>{"use strict";var Mb=Ub();function y3(t,e){let r=Mb(t.multiaddr),n=Mb(e.multiaddr);return r&&!n?1:!r&&n||t.isCertified&&!e.isCertified?-1:!t.isCertified&&e.isCertified?1:0}function g3(t){return[...t].sort(y3)}Fb.exports.publicAddressesFirst=g3});var Vb=w((lF,wh)=>{"use strict";var Kb=async t=>{try{let e=await t;return{isFulfilled:!0,isRejected:!1,value:e}}catch(e){return{isFulfilled:!1,isRejected:!0,reason:e}}};wh.exports=Kb;wh.exports.default=Kb});var $b=w((fF,_h)=>{"use strict";var jb=(t,...e)=>new Promise(r=>{r(t(...e))});_h.exports=jb;_h.exports.default=jb});var zb=w((hF,xh)=>{"use strict";var m3=$b(),Hb=t=>{if(!((Number.isInteger(t)||t===1/0)&&t>0))return Promise.reject(new TypeError("Expected `concurrency` to be a number from 1 and up"));let e=[],r=0,n=()=>{r--,e.length>0&&e.shift()()},i=(a,c,...u)=>{r++;let l=m3(a,...u);c(l),l.then(n,n)},s=(a,c,...u)=>{r<t?i(a,c,...u):e.push(i.bind(null,a,c,...u))},o=(a,...c)=>new Promise(u=>s(a,u,...c));return Object.defineProperties(o,{activeCount:{get:()=>r},pendingCount:{get:()=>e.length},clearQueue:{value:()=>{e.length=0}}}),o};xh.exports=Hb;xh.exports.default=Hb});var Wb=w((dF,Gb)=>{"use strict";var Sh=Vb(),v3=zb();Gb.exports=async(t,e={})=>{let{concurrency:r=1/0}=e,n=v3(r);return Promise.all(t.map(i=>i&&typeof i.then=="function"?Sh(i):Sh(typeof i=="function"?n(()=>i()):Promise.resolve(i))))}});var Xb=w((pF,Qb)=>{"use strict";var $s=pn(),Yb=$s.Reader,b3=$s.Writer,Je=$s.util,_a=$s.roots["libp2p-envelope"]||($s.roots["libp2p-envelope"]={});_a.Envelope=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.publicKey=Je.newBuffer([]),t.prototype.payloadType=Je.newBuffer([]),t.prototype.payload=Je.newBuffer([]),t.prototype.signature=Je.newBuffer([]),t.encode=function(r,n){return n||(n=b3.create()),r.publicKey!=null&&Object.hasOwnProperty.call(r,"publicKey")&&n.uint32(10).bytes(r.publicKey),r.payloadType!=null&&Object.hasOwnProperty.call(r,"payloadType")&&n.uint32(18).bytes(r.payloadType),r.payload!=null&&Object.hasOwnProperty.call(r,"payload")&&n.uint32(26).bytes(r.payload),r.signature!=null&&Object.hasOwnProperty.call(r,"signature")&&n.uint32(42).bytes(r.signature),n},t.decode=function(r,n){r instanceof Yb||(r=Yb.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new _a.Envelope;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.publicKey=r.bytes();break;case 2:s.payloadType=r.bytes();break;case 3:s.payload=r.bytes();break;case 5:s.signature=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof _a.Envelope)return r;var n=new _a.Envelope;return r.publicKey!=null&&(typeof r.publicKey=="string"?Je.base64.decode(r.publicKey,n.publicKey=Je.newBuffer(Je.base64.length(r.publicKey)),0):r.publicKey.length&&(n.publicKey=r.publicKey)),r.payloadType!=null&&(typeof r.payloadType=="string"?Je.base64.decode(r.payloadType,n.payloadType=Je.newBuffer(Je.base64.length(r.payloadType)),0):r.payloadType.length&&(n.payloadType=r.payloadType)),r.payload!=null&&(typeof r.payload=="string"?Je.base64.decode(r.payload,n.payload=Je.newBuffer(Je.base64.length(r.payload)),0):r.payload.length&&(n.payload=r.payload)),r.signature!=null&&(typeof r.signature=="string"?Je.base64.decode(r.signature,n.signature=Je.newBuffer(Je.base64.length(r.signature)),0):r.signature.length&&(n.signature=r.signature)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(n.bytes===String?i.publicKey="":(i.publicKey=[],n.bytes!==Array&&(i.publicKey=Je.newBuffer(i.publicKey))),n.bytes===String?i.payloadType="":(i.payloadType=[],n.bytes!==Array&&(i.payloadType=Je.newBuffer(i.payloadType))),n.bytes===String?i.payload="":(i.payload=[],n.bytes!==Array&&(i.payload=Je.newBuffer(i.payload))),n.bytes===String?i.signature="":(i.signature=[],n.bytes!==Array&&(i.signature=Je.newBuffer(i.signature)))),r.publicKey!=null&&r.hasOwnProperty("publicKey")&&(i.publicKey=n.bytes===String?Je.base64.encode(r.publicKey,0,r.publicKey.length):n.bytes===Array?Array.prototype.slice.call(r.publicKey):r.publicKey),r.payloadType!=null&&r.hasOwnProperty("payloadType")&&(i.payloadType=n.bytes===String?Je.base64.encode(r.payloadType,0,r.payloadType.length):n.bytes===Array?Array.prototype.slice.call(r.payloadType):r.payloadType),r.payload!=null&&r.hasOwnProperty("payload")&&(i.payload=n.bytes===String?Je.base64.encode(r.payload,0,r.payload.length):n.bytes===Array?Array.prototype.slice.call(r.payload):r.payload),r.signature!=null&&r.hasOwnProperty("signature")&&(i.signature=n.bytes===String?Je.base64.encode(r.signature,0,r.signature.length):n.bytes===Array?Array.prototype.slice.call(r.signature):r.signature),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,$s.util.toJSONOptions)},t}();Qb.exports=_a});var fu=w((yF,eE)=>{"use strict";var E3=he(),{concat:w3}=(Gn(),zn),{fromString:_3}=(It(),Nt),x3=Fc(),S3=Rt(),Ah=ki(),{equals:lu}=(pr(),dr),{codes:A3}=je(),{Envelope:Zb}=Xb(),ri=class{constructor({peerId:e,payloadType:r,payload:n,signature:i}){this.peerId=e,this.payloadType=r,this.payload=n,this.signature=i,this._marshal=void 0}marshal(){if(this._marshal)return this._marshal;let e=x3.marshalPublicKey(this.peerId.pubKey);return this._marshal=Zb.encode({publicKey:e,payloadType:this.payloadType,payload:this.payload,signature:this.signature}).finish(),this._marshal}equals(e){return lu(this.peerId.pubKey.bytes,e.peerId.pubKey.bytes)&&lu(this.payloadType,e.payloadType)&&lu(this.payload,e.payload)&&lu(this.signature,e.signature)}validate(e){let r=Jb(e,this.payloadType,this.payload);return this.peerId.pubKey.verify(r,this.signature)}},Jb=(t,e,r)=>{let n=_3(t),i=Ah.encode(n.byteLength),s=Ah.encode(e.length),o=Ah.encode(r.length);return w3([new Uint8Array(i),n,new Uint8Array(s),e,new Uint8Array(o),r])};ri.createFromProtobuf=async t=>{let e=Zb.decode(t),r=await S3.createFromPubKey(e.publicKey);return new ri({peerId:r,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};ri.seal=async(t,e)=>{let r=t.domain,n=t.codec,i=t.marshal(),s=Jb(r,n,i),o=await e.privKey.sign(s);return new ri({peerId:e,payloadType:n,payload:i,signature:o})};ri.openAndCertify=async(t,e)=>{let r=await ri.createFromProtobuf(t);if(!await r.validate(e))throw E3(new Error("envelope signature is not valid for the given domain"),A3.ERR_SIGNATURE_NOT_VALID);return r};eE.exports=ri});var rE=w((gF,tE)=>{"use strict";function C3(t,e){return t.length===e.length&&e.sort()&&t.sort().every((r,n)=>e[n].equals(r))}tE.exports=C3});var sE=w((mF,iE)=>{"use strict";var Fi=pn(),hu=Fi.Reader,nE=Fi.Writer,lt=Fi.util,wr=Fi.roots["libp2p-peer-record"]||(Fi.roots["libp2p-peer-record"]={});wr.PeerRecord=function(){function t(e){if(this.addresses=[],e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.peerId=lt.newBuffer([]),t.prototype.seq=lt.Long?lt.Long.fromBits(0,0,!0):0,t.prototype.addresses=lt.emptyArray,t.encode=function(r,n){if(n||(n=nE.create()),r.peerId!=null&&Object.hasOwnProperty.call(r,"peerId")&&n.uint32(10).bytes(r.peerId),r.seq!=null&&Object.hasOwnProperty.call(r,"seq")&&n.uint32(16).uint64(r.seq),r.addresses!=null&&r.addresses.length)for(var i=0;i<r.addresses.length;++i)wr.PeerRecord.AddressInfo.encode(r.addresses[i],n.uint32(26).fork()).ldelim();return n},t.decode=function(r,n){r instanceof hu||(r=hu.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new wr.PeerRecord;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses&&s.addresses.length||(s.addresses=[]),s.addresses.push(wr.PeerRecord.AddressInfo.decode(r,r.uint32()));break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof wr.PeerRecord)return r;var n=new wr.PeerRecord;if(r.peerId!=null&&(typeof r.peerId=="string"?lt.base64.decode(r.peerId,n.peerId=lt.newBuffer(lt.base64.length(r.peerId)),0):r.peerId.length&&(n.peerId=r.peerId)),r.seq!=null&&(lt.Long?(n.seq=lt.Long.fromValue(r.seq)).unsigned=!0:typeof r.seq=="string"?n.seq=parseInt(r.seq,10):typeof r.seq=="number"?n.seq=r.seq:typeof r.seq=="object"&&(n.seq=new lt.LongBits(r.seq.low>>>0,r.seq.high>>>0).toNumber(!0))),r.addresses){if(!Array.isArray(r.addresses))throw TypeError(".PeerRecord.addresses: array expected");n.addresses=[];for(var i=0;i<r.addresses.length;++i){if(typeof r.addresses[i]!="object")throw TypeError(".PeerRecord.addresses: object expected");n.addresses[i]=wr.PeerRecord.AddressInfo.fromObject(r.addresses[i])}}return n},t.toObject=function(r,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.addresses=[]),n.defaults)if(n.bytes===String?i.peerId="":(i.peerId=[],n.bytes!==Array&&(i.peerId=lt.newBuffer(i.peerId))),lt.Long){var s=new lt.Long(0,0,!0);i.seq=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else i.seq=n.longs===String?"0":0;if(r.peerId!=null&&r.hasOwnProperty("peerId")&&(i.peerId=n.bytes===String?lt.base64.encode(r.peerId,0,r.peerId.length):n.bytes===Array?Array.prototype.slice.call(r.peerId):r.peerId),r.seq!=null&&r.hasOwnProperty("seq")&&(typeof r.seq=="number"?i.seq=n.longs===String?String(r.seq):r.seq:i.seq=n.longs===String?lt.Long.prototype.toString.call(r.seq):n.longs===Number?new lt.LongBits(r.seq.low>>>0,r.seq.high>>>0).toNumber(!0):r.seq),r.addresses&&r.addresses.length){i.addresses=[];for(var o=0;o<r.addresses.length;++o)i.addresses[o]=wr.PeerRecord.AddressInfo.toObject(r.addresses[o],n)}return i},t.prototype.toJSON=function(){return this.constructor.toObject(this,Fi.util.toJSONOptions)},t.AddressInfo=function(){function e(r){if(r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}return e.prototype.multiaddr=lt.newBuffer([]),e.encode=function(n,i){return i||(i=nE.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),i},e.decode=function(n,i){n instanceof hu||(n=hu.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new wr.PeerRecord.AddressInfo;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.multiaddr=n.bytes();break;default:n.skipType(a&7);break}}return o},e.fromObject=function(n){if(n instanceof wr.PeerRecord.AddressInfo)return n;var i=new wr.PeerRecord.AddressInfo;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?lt.base64.decode(n.multiaddr,i.multiaddr=lt.newBuffer(lt.base64.length(n.multiaddr)),0):n.multiaddr.length&&(i.multiaddr=n.multiaddr)),i},e.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.multiaddr="":(s.multiaddr=[],i.bytes!==Array&&(s.multiaddr=lt.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?lt.base64.encode(n.multiaddr,0,n.multiaddr.length):i.bytes===Array?Array.prototype.slice.call(n.multiaddr):n.multiaddr),s},e.prototype.toJSON=function(){return this.constructor.toObject(this,Fi.util.toJSONOptions)},e}(),t}();iE.exports=wr});var aE=w((vF,oE)=>{"use strict";var I3="libp2p-peer-record",T3=Uint8Array.from([3,1]);oE.exports={ENVELOPE_DOMAIN_PEER_RECORD:I3,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:T3}});var du=w((bF,lE)=>{"use strict";var{Multiaddr:R3}=qt(),B3=Rt(),P3=rE(),{PeerRecord:cE}=sE(),{ENVELOPE_DOMAIN_PEER_RECORD:uE,ENVELOPE_PAYLOAD_TYPE_PEER_RECORD:N3}=aE(),Ki=class{constructor({peerId:e,multiaddrs:r=[],seqNumber:n=Date.now()}){this.domain=uE,this.codec=N3,this.peerId=e,this.multiaddrs=r,this.seqNumber=n,this._marshal=void 0}marshal(){return this._marshal?this._marshal:(this._marshal=cE.encode({peerId:this.peerId.toBytes(),seq:this.seqNumber,addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))}).finish(),this._marshal)}equals(e){return!(!(e instanceof Ki)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!P3(this.multiaddrs,e.multiaddrs))}};Ki.createFromProtobuf=t=>{let e=cE.decode(t),r=B3.createFromBytes(e.peerId),n=(e.addresses||[]).map(s=>new R3(s.multiaddr)),i=Number(e.seq);return new Ki({peerId:r,multiaddrs:n,seqNumber:i})};Ki.DOMAIN=uE;lE.exports=Ki});var Ch=w((EF,fE)=>{"use strict";var O3=fu(),D3=du();async function L3(t){let e=new D3({peerId:t.peerId,multiaddrs:t.multiaddrs}),r=await O3.seal(e,t.peerId);await t.peerStore.addressBook.consumePeerRecord(r)}fE.exports.updateSelfPeerRecord=L3});var Th=w((wF,pE)=>{"use strict";var hE=Te(),Vi=Object.assign(hE("libp2p:transports"),{error:hE("libp2p:transports:err")}),k3=Wb(),{codes:Hs}=je(),xa=he(),{updateSelfPeerRecord:dE}=Ch(),Ih=class{constructor({libp2p:e,upgrader:r,faultTolerance:n=pu.FATAL_ALL}){this.libp2p=e,this.upgrader=r,this._transports=new Map,this._listeners=new Map,this._listenerOptions=new Map,this.faultTolerance=n}add(e,r,n={}){if(Vi("adding %s",e),!e)throw xa(new Error(`Transport must have a valid key, was given '${e}'`),Hs.ERR_INVALID_KEY);if(this._transports.has(e))throw xa(new Error("There is already a transport with this key"),Hs.ERR_DUPLICATE_TRANSPORT);let i=new r({...n,libp2p:this.libp2p,upgrader:this.upgrader});this._transports.set(e,i),this._listenerOptions.set(e,n.listenerOptions||{}),this._listeners.has(e)||this._listeners.set(e,[])}async close(){let e=[];for(let[r,n]of this._listeners)for(Vi("closing listeners for %s",r);n.length;){let i=n.pop();i.removeAllListeners("listening"),i.removeAllListeners("close"),e.push(i.close())}await Promise.all(e),Vi("all listeners closed");for(let r of this._listeners.keys())this._listeners.set(r,[])}async dial(e,r){let n=this.transportForMultiaddr(e);if(!n)throw xa(new Error(`No transport available for address ${String(e)}`),Hs.ERR_TRANSPORT_UNAVAILABLE);try{return await n.dial(e,r)}catch(i){throw i.code||(i.code=Hs.ERR_TRANSPORT_DIAL_FAILED),i}}getAddrs(){let e=[];for(let r of this._listeners.values())for(let n of r)e=[...e,...n.getAddrs()];return e}getTransports(){return this._transports.values()}transportForMultiaddr(e){for(let r of this._transports.values())if(r.filter([e]).length)return r;return null}async listen(e){if(!e||e.length===0){Vi("no addresses were provided for listening, this node is dial only");return}let r=[];for(let[n,i]of this._transports.entries()){let s=i.filter(e),o=[];for(let u of s){Vi("creating listener for %s on %s",n,u);let l=i.createListener(this._listenerOptions.get(n));this._listeners.get(n).push(l),l.on("listening",()=>dE(this.libp2p)),l.on("close",()=>dE(this.libp2p)),o.push(l.listen(u))}if(o.length===0){r.push(n);continue}if(!(await k3(o)).find(u=>u.isFulfilled===!0)&&this.faultTolerance!==pu.NO_FATAL)throw xa(new Error(`Transport (${n}) could not listen on any available address`),Hs.ERR_NO_VALID_ADDRESSES)}if(r.length===this._transports.size){let n=`no valid addresses were provided for transports [${r}]`;if(this.faultTolerance===pu.FATAL_ALL)throw xa(new Error(n),Hs.ERR_NO_VALID_ADDRESSES);Vi(`libp2p in dial mode only: ${n}`)}}async remove(e){if(Vi("removing %s",e),this._listeners.has(e))for(let r of this._listeners.get(e))r.removeAllListeners("listening"),r.removeAllListeners("close"),await r.close();this._transports.delete(e),this._listeners.delete(e)}async removeAll(){let e=[];for(let r of this._transports.keys())e.push(this.remove(r));await Promise.all(e)}},pu={FATAL_ALL:0,NO_FATAL:1};Ih.FaultTolerance=pu;pE.exports=Ih});var mE=w((_F,gE)=>{"use strict";var q3=Vs(),{dnsaddrResolver:U3}=Ab(),Rh=au(),{AGENT_VERSION:M3}=vh(),yE=cu(),{publicAddressesFirst:F3}=Eh(),{FaultTolerance:K3}=Th(),V3={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:t=>t},connectionManager:{minConnections:25},transportManager:{faultTolerance:K3.FATAL_ALL},dialer:{maxParallelDials:Rh.MAX_PARALLEL_DIALS,maxDialsPerPeer:Rh.MAX_PER_PEER_DIALS,dialTimeout:Rh.DIAL_TIMEOUT,resolvers:{dnsaddr:U3},addressSorter:F3},host:{agentVersion:M3},metrics:{enabled:!1},peerStore:{persistence:!1,threshold:5},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},config:{protocolPrefix:"ipfs",dht:{enabled:!1,kBucketSize:20},nat:{enabled:!0,ttl:7200,keepAlive:!0,gateway:null,externalIp:null,pmp:{enabled:!1}},peerDiscovery:{autoDial:!0},pubsub:{enabled:!0},relay:{enabled:!0,advertise:{bootDelay:yE.ADVERTISE_BOOT_DELAY,enabled:!1,ttl:yE.ADVERTISE_TTL},hop:{enabled:!1,active:!1},autoRelay:{enabled:!1,maxListeners:2}},transport:{}}};gE.exports.validate=t=>{let e=q3(V3,t);if(e.modules.transport.length<1)throw new Error("'options.modules.transport' must contain at least 1 transport");return e}});var EE=w((xF,bE)=>{"use strict";var{EventEmitter:j3}=Qt(),{Multiaddr:Sa}=qt(),$3=Rt(),vE=class extends j3{constructor(e,{listen:r=[],announce:n=[]}={}){super();this.peerId=e,this.listen=new Set(r.map(i=>i.toString())),this.announce=new Set(n.map(i=>i.toString())),this.observed=new Set}getListenAddrs(){return Array.from(this.listen).map(e=>new Sa(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new Sa(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new Sa(e))}addObservedAddr(e){let r=new Sa(e),n=r.getPeerId();n&&$3.createFromB58String(n).equals(this.peerId)&&(r=r.decapsulate(new Sa(`/p2p/${this.peerId}`)));let i=r.toString();this.observed.has(i)||(this.observed.add(i),this.emit("change:addresses"))}};bE.exports=vE});var xE=w((SF,_E)=>{"use strict";var{EventEmitter:H3}=Qt(),Bh=Te()("latency-monitor:VisibilityChangeEmitter"),wE=class extends H3{constructor(){super();if(typeof document=="undefined"){Bh('This is not a browser, no "document" found. Stopping.');return}this._initializeVisibilityVarNames(),this._addVisibilityChangeListener()}_initializeVisibilityVarNames(){let e,r;typeof document.hidden!="undefined"?(e="hidden",r="visibilitychange"):typeof document.mozHidden!="undefined"?(e="mozHidden",r="mozvisibilitychange"):typeof document.msHidden!="undefined"?(e="msHidden",r="msvisibilitychange"):typeof document.webkitHidden!="undefined"&&(e="webkitHidden",r="webkitvisibilitychange"),this._hidden=e,this._visibilityChange=r}_addVisibilityChangeListener(){typeof document.addEventListener=="undefined"||typeof document[this._hidden]=="undefined"?Bh("Checking page visibility requires a browser that supports the Page Visibility API."):document.addEventListener(this._visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(!(this._hidden===void 0||document[this._hidden]===void 0))return!document[this._hidden]}_handleVisibilityChange(){let e=!document[this._hidden];Bh(e?"Page Visible":"Page Hidden"),this.emit("visibilityChange",e)}};_E.exports=wE});var CE=w((AF,AE)=>{"use strict";var{EventEmitter:z3}=Qt(),G3=xE(),An=Te()("latency-monitor:LatencyMonitor"),SE=class extends z3{constructor({latencyCheckIntervalMs:e,dataEmitIntervalMs:r,asyncTestFn:n,latencyRandomPercentage:i}={}){super();let s=this;s.latencyCheckIntervalMs=e||500,s.latencyRandomPercentage=i||10,s._latecyCheckMultiply=2*(s.latencyRandomPercentage/100)*s.latencyCheckIntervalMs,s._latecyCheckSubtract=s._latecyCheckMultiply/2,s.dataEmitIntervalMs=r===null||r===0?void 0:r||5*1e3,An("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",s.latencyCheckIntervalMs,s.dataEmitIntervalMs),s.dataEmitIntervalMs?An("Expecting ~%s events per summary",s.latencyCheckIntervalMs/s.dataEmitIntervalMs):An("Not emitting summaries"),s.asyncTestFn=n}start(){globalThis.process&&globalThis.process.hrtime?(An("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=e=>{let r=this.now(e);return r[0]*1e3+r[1]/1e6}):typeof window!="undefined"&&window.performance&&window.performance.now?(An("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=e=>Math.round(this.now()-e)):(An("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=e=>this.now()-e),this._latencyData=this._initLatencyData(),W3()&&(this._visibilityChangeEmitter=new G3,this._visibilityChangeEmitter.on("visibilityChange",e=>{e?this._startTimers():(this._emitSummary(),this._stopTimers())})),(!this._visibilityChangeEmitter||this._visibilityChangeEmitter.isVisible())&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){this._checkLatencyID||(this._checkLatency(),this.dataEmitIntervalMs&&(this._emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),typeof this._emitIntervalID.unref=="function"&&this._emitIntervalID.unref()))}_stopTimers(){this._checkLatencyID&&(clearTimeout(this._checkLatencyID),this._checkLatencyID=void 0),this._emitIntervalID&&(clearInterval(this._emitIntervalID),this._emitIntervalID=void 0)}_emitSummary(){let e=this.getSummary();e.events>0&&this.emit("data",e)}getSummary(){let e={events:this._latencyData.events,minMs:this._latencyData.minMs,maxMs:this._latencyData.maxMs,avgMs:this._latencyData.events?this._latencyData.totalMs/this._latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this._latencyData.startTime)};return this._latencyData=this._initLatencyData(),An("Summary: %O",e),e}_checkLatency(){let e=this,r=Math.random()*e._latecyCheckMultiply-e._latecyCheckSubtract,n={deltaOffset:Math.ceil(e.latencyCheckIntervalMs+r),startTime:e.now()},i=()=>{if(!this._checkLatencyID)return;let s=e.getDeltaMS(n.startTime)-n.deltaOffset;e._checkLatency(),e._latencyData.events++,e._latencyData.minMs=Math.min(e._latencyData.minMs,s),e._latencyData.maxMs=Math.max(e._latencyData.maxMs,s),e._latencyData.totalMs+=s,An("MS: %s Data: %O",s,e._latencyData)};An("localData: %O",n),this._checkLatencyID=setTimeout(()=>{e.asyncTestFn?(n.deltaOffset=0,n.startTime=e.now(),e.asyncTestFn(i)):(n.deltaOffset-=1,i())},n.deltaOffset),typeof this._checkLatencyID.unref=="function"&&this._checkLatencyID.unref()}_initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}};function W3(){return typeof window!="undefined"}AE.exports=SE});var Ph=w((CF,TE)=>{"use strict";var IE=class extends Map{constructor(e){super();let{system:r,component:n,metric:i,metrics:s}=e;this._system=r,this._component=n,this._metric=i,this._metrics=s,this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size})}set(e,r){return super.set(e,r),this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size}),this}delete(e){let r=super.delete(e);return this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size}),r}clear(){super.clear(),this._metrics.updateComponentMetric({system:this._system,component:this._component,metric:this._metric,value:this.size})}};TE.exports=({system:t="libp2p",component:e,metric:r,metrics:n})=>{let i;return n?i=new IE({system:t,component:e,metric:r,metrics:n}):i=new Map,i}});var qE=w((IF,kE)=>{"use strict";var RE=Te(),kr=Object.assign(RE("libp2p:connection-manager"),{error:RE("libp2p:connection-manager:err")}),BE=he(),Y3=Vs(),Q3=CE(),PE=ga(),{EventEmitter:X3}=Qt(),NE=Ph(),Z3=Rt(),{codes:{ERR_INVALID_PARAMETERS:OE}}=je(),J3={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4,defaultPeerValue:1},DE="connection-manager",eO="peer-connections",tO="peer-values",LE=class extends X3{constructor(e,r={}){super();if(this._libp2p=e,this._peerId=e.peerId.toB58String(),this._options=Y3.call({ignoreUndefined:!0},J3,r),this._options.maxConnections<this._options.minConnections)throw BE(new Error("Connection Manager maxConnections must be greater than minConnections"),OE);kr("options: %j",this._options),this._peerValues=NE({component:DE,metric:tO,metrics:this._libp2p.metrics}),this.connections=NE({component:DE,metric:eO,metrics:this._libp2p.metrics}),this._started=!1,this._timer=null,this._checkMetrics=this._checkMetrics.bind(this),this._latencyMonitor=new Q3({latencyCheckIntervalMs:this._options.pollInterval,dataEmitIntervalMs:this._options.pollInterval}),this.setMaxListeners(1/0)}get size(){return Array.from(this.connections.values()).reduce((e,r)=>e+r.length,0)}start(){this._libp2p.metrics&&(this._timer=this._timer||PE(this._checkMetrics,this._options.pollInterval)),this._latencyMonitor.start(),this._onLatencyMeasure=this._onLatencyMeasure.bind(this),this._latencyMonitor.on("data",this._onLatencyMeasure),this._started=!0,kr("started")}async stop(){this._timer&&this._timer.clear(),this._latencyMonitor.removeListener("data",this._onLatencyMeasure),this._latencyMonitor.stop(),this._started=!1,await this._close(),kr("stopped")}async _close(){let e=[];for(let r of this.connections.values())for(let n of r)e.push(n.close());await Promise.all(e),this.connections.clear()}setPeerValue(e,r){if(r<0||r>1)throw new Error("value should be a number between 0 and 1");this._peerValues.set(e.toB58String(),r)}async _checkMetrics(){if(this._libp2p.metrics)try{let e=this._libp2p.metrics.global.movingAverages,r=e.dataReceived[this._options.movingAverageInterval].movingAverage();await this._checkMaxLimit("maxReceivedData",r);let n=e.dataSent[this._options.movingAverageInterval].movingAverage();await this._checkMaxLimit("maxSentData",n);let i=r+n;await this._checkMaxLimit("maxData",i),kr("metrics update",i)}finally{this._timer=PE(this._checkMetrics,this._options.pollInterval)}}async onConnect(e){let r=e.remotePeer,n=r.toB58String(),i=this.connections.get(n);this.emit("peer:connect",e),i?i.push(e):this.connections.set(n,[e]),await this._libp2p.peerStore.keyBook.set(r,r.pubKey),this._peerValues.has(n)||this._peerValues.set(n,this._options.defaultPeerValue),await this._checkMaxLimit("maxConnections",this.size)}onDisconnect(e){let r=e.remotePeer.toB58String(),n=this.connections.get(r);n&&n.length>1?(n=n.filter(i=>i.id!==e.id),this.connections.set(r,n)):n&&(this.connections.delete(r),this._peerValues.delete(e.remotePeer.toB58String()),this.emit("peer:disconnect",e),this._libp2p.metrics&&this._libp2p.metrics.onPeerDisconnected(e.remotePeer))}get(e){let r=this.getAll(e);return r.length?r[0]:null}getAll(e){if(!Z3.isPeerId(e))throw BE(new Error("peerId must be an instance of peer-id"),OE);let r=e.toB58String(),n=this.connections.get(r);return n?n.filter(i=>i.stat.status==="open"):[]}_onLatencyMeasure(e){this._checkMaxLimit("maxEventLoopDelay",e.avgMs).catch(r=>{kr.error(r)})}async _checkMaxLimit(e,r){let n=this._options[e];kr("checking limit of %s. current value: %d of %d",e,r,n),r>n&&(kr("%s: limit exceeded: %s, %d",this._peerId,e,r),await this._maybeDisconnectOne())}async _maybeDisconnectOne(){if(this._options.minConnections<this.connections.size){let e=Array.from(new Map([...this._peerValues.entries()].sort((n,i)=>n[1]-i[1])));kr("%s: sorted peer values: %j",this._peerId,e);let r=e[0];if(r){let n=r[0];kr("%s: lowest value peer is %s",this._peerId,n),kr("%s: closing a connection to %j",this._peerId,n);for(let i of this.connections.values())if(i[0].remotePeer.toB58String()===n){i[0].close().catch(s=>{kr.error(s)}),this.onDisconnect(i[0]);break}}}}};kE.exports=LE});var VE=w((TF,KE)=>{"use strict";var UE=Te(),rO=Vs(),ME=ga(),nO=Wc(),ni=Object.assign(UE("libp2p:connection-manager:auto-dialler"),{error:UE("libp2p:connection-manager:auto-dialler:err")}),iO={enabled:!0,minConnections:0,autoDialInterval:1e4},FE=class{constructor(e,r={}){this._options=rO.call({ignoreUndefined:!0},iO,r),this._libp2p=e,this._running=!1,this._autoDialTimeout=null,this._autoDial=this._autoDial.bind(this),ni("options: %j",this._options)}async start(){if(!this._options.enabled){ni("not enabled");return}this._running=!0,this._autoDial().catch(e=>{ni.error("could start autodial",e)}),ni("started")}async stop(){if(!this._options.enabled){ni("not enabled");return}this._running=!1,this._autoDialTimeout&&this._autoDialTimeout.clear(),ni("stopped")}async _autoDial(){let e=this._options.minConnections;if(this._libp2p.connections.size>=e){this._autoDialTimeout=ME(this._autoDial,this._options.autoDialInterval);return}let r=(await nO(this._libp2p.peerStore.getPeers())).sort((n,i)=>i.protocols&&i.protocols.length&&(!n.protocols||!n.protocols.length)||i.id.pubKey&&!n.id.pubKey?1:-1);for(let n=0;this._running&&n<r.length&&this._libp2p.connections.size<e;n++)if(!this._libp2p.connectionManager.get(r[n].id)){ni("connecting to a peerStore stored peer %s",r[n].id.toB58String());try{await this._libp2p.dialer.connectToPeer(r[n].id)}catch(i){ni.error("could not connect to peerStore stored peer",i)}}!this._running||(this._autoDialTimeout=ME(this._autoDial,this._options.autoDialInterval))}};KE.exports=FE});var JE=w((RF,ZE)=>{"use strict";var{Multiaddr:Nh}=qt(),jE=ce("dns4"),$E=ce("dns6"),HE=ce("dnsaddr"),ji=Ut(ce("dns"),HE,jE,$E),Aa=Ut(ce("ip4"),ce("ip6")),zs=Ut(ve(Aa,ce("tcp")),ve(ji,ce("tcp"))),Oh=ve(Aa,ce("udp")),zE=ve(Oh,ce("utp")),GE=ve(Oh,ce("quic")),Gs=Ut(ve(zs,ce("ws")),ve(ji,ce("ws"))),Ws=Ut(ve(zs,ce("wss")),ve(ji,ce("wss"))),yu=Ut(ve(zs,ce("http")),ve(Aa,ce("http")),ve(ji,ce("http"))),gu=Ut(ve(zs,ce("https")),ve(Aa,ce("https")),ve(ji,ce("https"))),Dh=Ut(ve(Gs,ce("p2p-webrtc-star"),ce("p2p")),ve(Ws,ce("p2p-webrtc-star"),ce("p2p")),ve(Gs,ce("p2p-webrtc-star")),ve(Ws,ce("p2p-webrtc-star"))),sO=Ut(ve(Gs,ce("p2p-websocket-star"),ce("p2p")),ve(Ws,ce("p2p-websocket-star"),ce("p2p")),ve(Gs,ce("p2p-websocket-star")),ve(Ws,ce("p2p-websocket-star"))),Lh=Ut(ve(yu,ce("p2p-webrtc-direct"),ce("p2p")),ve(gu,ce("p2p-webrtc-direct"),ce("p2p")),ve(yu,ce("p2p-webrtc-direct")),ve(gu,ce("p2p-webrtc-direct"))),Ys=Ut(Gs,Ws,yu,gu,Dh,Lh,zs,zE,GE,ji),oO=Ut(ve(Ys,ce("p2p-stardust"),ce("p2p")),ve(Ys,ce("p2p-stardust"))),ii=Ut(ve(Ys,ce("p2p")),Dh,Lh,ce("p2p")),WE=Ut(ve(ii,ce("p2p-circuit"),ii),ve(ii,ce("p2p-circuit")),ve(ce("p2p-circuit"),ii),ve(Ys,ce("p2p-circuit")),ve(ce("p2p-circuit"),Ys),ce("p2p-circuit")),YE=()=>Ut(ve(WE,YE),WE),Qs=YE(),QE=Ut(ve(Qs,ii,Qs),ve(ii,Qs),ve(Qs,ii),Qs,ii);ZE.exports={DNS:ji,DNS4:jE,DNS6:$E,DNSADDR:HE,IP:Aa,TCP:zs,UDP:Oh,QUIC:GE,UTP:zE,HTTP:yu,HTTPS:gu,WebSockets:Gs,WebSocketsSecure:Ws,WebSocketStar:sO,WebRTCStar:Dh,WebRTCDirect:Lh,Reliable:Ys,Stardust:oO,Circuit:Qs,P2P:QE,IPFS:QE};function XE(t){function e(r){if(!Nh.isMultiaddr(r))try{r=new Nh(r)}catch(i){return!1}let n=t(r.protoNames());return n===null?!1:n===!0||n===!1?n:n.length===0}return e}function ve(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(i=>(n=typeof i=="function"?i().partialMatch(r):i.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:XE(e),partialMatch:e}}function Ut(...t){function e(n){let i=null;return t.some(s=>{let o=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return o?(i=o,!0):!1}),i}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:XE(e),partialMatch:e}}function ce(t){let e=t;function r(i){let s;if(typeof i=="string"||i instanceof Uint8Array)try{s=new Nh(i)}catch(a){return!1}else s=i;let o=s.protoNames();return o.length===1&&o[0]===e}function n(i){return i.length===0?null:i[0]===e?i.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}});var Xs=w((BF,tw)=>{"use strict";var $i=pn(),mu=$i.Reader,ew=$i.Writer,_r=$i.util,At=$i.roots["libp2p-circuit"]||($i.roots["libp2p-circuit"]={});At.CircuitRelay=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.type=1,t.prototype.srcPeer=null,t.prototype.dstPeer=null,t.prototype.code=100,t.encode=function(r,n){return n||(n=ew.create()),r.type!=null&&Object.hasOwnProperty.call(r,"type")&&n.uint32(8).int32(r.type),r.srcPeer!=null&&Object.hasOwnProperty.call(r,"srcPeer")&&At.CircuitRelay.Peer.encode(r.srcPeer,n.uint32(18).fork()).ldelim(),r.dstPeer!=null&&Object.hasOwnProperty.call(r,"dstPeer")&&At.CircuitRelay.Peer.encode(r.dstPeer,n.uint32(26).fork()).ldelim(),r.code!=null&&Object.hasOwnProperty.call(r,"code")&&n.uint32(32).int32(r.code),n},t.decode=function(r,n){r instanceof mu||(r=mu.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new At.CircuitRelay;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.type=r.int32();break;case 2:s.srcPeer=At.CircuitRelay.Peer.decode(r,r.uint32());break;case 3:s.dstPeer=At.CircuitRelay.Peer.decode(r,r.uint32());break;case 4:s.code=r.int32();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof At.CircuitRelay)return r;var n=new At.CircuitRelay;switch(r.type){case"HOP":case 1:n.type=1;break;case"STOP":case 2:n.type=2;break;case"STATUS":case 3:n.type=3;break;case"CAN_HOP":case 4:n.type=4;break}if(r.srcPeer!=null){if(typeof r.srcPeer!="object")throw TypeError(".CircuitRelay.srcPeer: object expected");n.srcPeer=At.CircuitRelay.Peer.fromObject(r.srcPeer)}if(r.dstPeer!=null){if(typeof r.dstPeer!="object")throw TypeError(".CircuitRelay.dstPeer: object expected");n.dstPeer=At.CircuitRelay.Peer.fromObject(r.dstPeer)}switch(r.code){case"SUCCESS":case 100:n.code=100;break;case"HOP_SRC_ADDR_TOO_LONG":case 220:n.code=220;break;case"HOP_DST_ADDR_TOO_LONG":case 221:n.code=221;break;case"HOP_SRC_MULTIADDR_INVALID":case 250:n.code=250;break;case"HOP_DST_MULTIADDR_INVALID":case 251:n.code=251;break;case"HOP_NO_CONN_TO_DST":case 260:n.code=260;break;case"HOP_CANT_DIAL_DST":case 261:n.code=261;break;case"HOP_CANT_OPEN_DST_STREAM":case 262:n.code=262;break;case"HOP_CANT_SPEAK_RELAY":case 270:n.code=270;break;case"HOP_CANT_RELAY_TO_SELF":case 280:n.code=280;break;case"STOP_SRC_ADDR_TOO_LONG":case 320:n.code=320;break;case"STOP_DST_ADDR_TOO_LONG":case 321:n.code=321;break;case"STOP_SRC_MULTIADDR_INVALID":case 350:n.code=350;break;case"STOP_DST_MULTIADDR_INVALID":case 351:n.code=351;break;case"STOP_RELAY_REFUSED":case 390:n.code=390;break;case"MALFORMED_MESSAGE":case 400:n.code=400;break}return n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.type=n.enums===String?"HOP":1,i.srcPeer=null,i.dstPeer=null,i.code=n.enums===String?"SUCCESS":100),r.type!=null&&r.hasOwnProperty("type")&&(i.type=n.enums===String?At.CircuitRelay.Type[r.type]:r.type),r.srcPeer!=null&&r.hasOwnProperty("srcPeer")&&(i.srcPeer=At.CircuitRelay.Peer.toObject(r.srcPeer,n)),r.dstPeer!=null&&r.hasOwnProperty("dstPeer")&&(i.dstPeer=At.CircuitRelay.Peer.toObject(r.dstPeer,n)),r.code!=null&&r.hasOwnProperty("code")&&(i.code=n.enums===String?At.CircuitRelay.Status[r.code]:r.code),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,$i.util.toJSONOptions)},t.Status=function(){var e={},r=Object.create(e);return r[e[100]="SUCCESS"]=100,r[e[220]="HOP_SRC_ADDR_TOO_LONG"]=220,r[e[221]="HOP_DST_ADDR_TOO_LONG"]=221,r[e[250]="HOP_SRC_MULTIADDR_INVALID"]=250,r[e[251]="HOP_DST_MULTIADDR_INVALID"]=251,r[e[260]="HOP_NO_CONN_TO_DST"]=260,r[e[261]="HOP_CANT_DIAL_DST"]=261,r[e[262]="HOP_CANT_OPEN_DST_STREAM"]=262,r[e[270]="HOP_CANT_SPEAK_RELAY"]=270,r[e[280]="HOP_CANT_RELAY_TO_SELF"]=280,r[e[320]="STOP_SRC_ADDR_TOO_LONG"]=320,r[e[321]="STOP_DST_ADDR_TOO_LONG"]=321,r[e[350]="STOP_SRC_MULTIADDR_INVALID"]=350,r[e[351]="STOP_DST_MULTIADDR_INVALID"]=351,r[e[390]="STOP_RELAY_REFUSED"]=390,r[e[400]="MALFORMED_MESSAGE"]=400,r}(),t.Type=function(){var e={},r=Object.create(e);return r[e[1]="HOP"]=1,r[e[2]="STOP"]=2,r[e[3]="STATUS"]=3,r[e[4]="CAN_HOP"]=4,r}(),t.Peer=function(){function e(r){if(this.addrs=[],r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}return e.prototype.id=_r.newBuffer([]),e.prototype.addrs=_r.emptyArray,e.encode=function(n,i){if(i||(i=ew.create()),i.uint32(10).bytes(n.id),n.addrs!=null&&n.addrs.length)for(var s=0;s<n.addrs.length;++s)i.uint32(18).bytes(n.addrs[s]);return i},e.decode=function(n,i){n instanceof mu||(n=mu.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new At.CircuitRelay.Peer;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.id=n.bytes();break;case 2:o.addrs&&o.addrs.length||(o.addrs=[]),o.addrs.push(n.bytes());break;default:n.skipType(a&7);break}}if(!o.hasOwnProperty("id"))throw _r.ProtocolError("missing required 'id'",{instance:o});return o},e.fromObject=function(n){if(n instanceof At.CircuitRelay.Peer)return n;var i=new At.CircuitRelay.Peer;if(n.id!=null&&(typeof n.id=="string"?_r.base64.decode(n.id,i.id=_r.newBuffer(_r.base64.length(n.id)),0):n.id.length&&(i.id=n.id)),n.addrs){if(!Array.isArray(n.addrs))throw TypeError(".CircuitRelay.Peer.addrs: array expected");i.addrs=[];for(var s=0;s<n.addrs.length;++s)typeof n.addrs[s]=="string"?_r.base64.decode(n.addrs[s],i.addrs[s]=_r.newBuffer(_r.base64.length(n.addrs[s])),0):n.addrs[s].length&&(i.addrs[s]=n.addrs[s])}return i},e.toObject=function(n,i){i||(i={});var s={};if((i.arrays||i.defaults)&&(s.addrs=[]),i.defaults&&(i.bytes===String?s.id="":(s.id=[],i.bytes!==Array&&(s.id=_r.newBuffer(s.id)))),n.id!=null&&n.hasOwnProperty("id")&&(s.id=i.bytes===String?_r.base64.encode(n.id,0,n.id.length):i.bytes===Array?Array.prototype.slice.call(n.id):n.id),n.addrs&&n.addrs.length){s.addrs=[];for(var o=0;o<n.addrs.length;++o)s.addrs[o]=i.bytes===String?_r.base64.encode(n.addrs[o],0,n.addrs[o].length):i.bytes===Array?Array.prototype.slice.call(n.addrs[o]):n.addrs[o]}return s},e.prototype.toJSON=function(){return this.constructor.toObject(this,$i.util.toJSONOptions)},e}(),t}();tw.exports=At});var nw=w((PF,rw)=>{rw.exports=function(e){if(e){if(typeof e[Symbol.iterator]=="function")return e[Symbol.iterator]();if(typeof e[Symbol.asyncIterator]=="function")return e[Symbol.asyncIterator]();if(typeof e.next=="function")return e}throw new Error("argument is not an iterator or iterable")}});var sw=w((OF,iw)=>{iw.exports=class extends Error{constructor(e,r){super(e||"The operation was aborted");this.type="aborted",this.code=r||"ABORT_ERR"}}});var vu=w((DF,Hi)=>{var aO=nw(),kh=sw(),ow=(t,e,r)=>qh(t,Array.isArray(e)?e:[{signal:e,options:r}]),qh=(t,e)=>{t=aO(t),e=e.map(({signal:n,options:i})=>({signal:n,options:i||{}}));async function*r(){let n,i=()=>{n&&n()};for(let{signal:s}of e)s.addEventListener("abort",i);for(;;){let s;try{for(let{signal:a,options:c}of e)if(a.aborted){let{abortMessage:u,abortCode:l}=c;throw new kh(u,l)}let o=new Promise((a,c)=>{n=()=>{let{options:u}=e.find(({signal:h})=>h.aborted),{abortMessage:l,abortCode:f}=u;c(new kh(l,f))}});s=await Promise.race([o,t.next()]),n=null}catch(o){for(let{signal:u}of e)u.removeEventListener("abort",i);let a=e.find(({signal:u})=>u.aborted),c=o.type==="aborted"&&a;if(c&&a.options.onAbort&&await a.options.onAbort(t),typeof t.return=="function")try{let u=t.return();u instanceof Promise&&u.catch(l=>{a.options.onReturnError!=null&&a.options.onReturnError(l)})}catch(u){a.options.onReturnError!=null&&a.options.onReturnError(u)}if(c&&a.options.returnOnAbort)return;throw o}if(s.done)break;yield s.value}for(let{signal:s}of e)s.removeEventListener("abort",i)}return r()},aw=(t,e,r)=>cw(t,Array.isArray(e)?e:[{signal:e,options:r}]),cw=(t,e)=>r=>t(qh(r,e)),cO=(t,e,r)=>uO(t,Array.isArray(e)?e:[{signal:e,options:r}]),uO=(t,e)=>({sink:cw(t.sink,e),source:qh(t.source,e)});Hi.exports=ow;Hi.exports.AbortError=kh;Hi.exports.source=ow;Hi.exports.sink=aw;Hi.exports.transform=aw;Hi.exports.duplex=cO});var fw=w((LF,lw)=>{"use strict";var{source:uw}=vu(),lO=Te(),fO=lO("libp2p:stream:converter");function hO({stream:t,remoteAddr:e,localAddr:r},n={}){let{sink:i,source:s}=t,o={async sink(c){n.signal&&(c=uw(c,n.signal));try{await i(c)}catch(u){u.type!=="aborted"&&fO(u)}a()},source:n.signal?uw(s,n.signal):s,conn:t,localAddr:r,remoteAddr:e,timeline:{open:Date.now(),close:void 0},close(){return i(new Uint8Array(0)),a()}};function a(){return o.timeline.close||(o.timeline.close=Date.now()),Promise.resolve()}return o}lw.exports=hO});var Ca=w((kF,hw)=>{"use strict";hw.exports={relay:"/libp2p/circuit/relay/0.1.0"}});var pw=w((qF,dw)=>{"use strict";var{EventEmitter:dO}=Qt(),{Multiaddr:pO}=qt();dw.exports=t=>{let e=new Map;async function r(s){let o=String(s).split("/p2p-circuit").find(u=>u!==""),a=await t.dial(new pO(o)),c=a.remoteAddr.encapsulate("/p2p-circuit");e.set(a.remotePeer.toB58String(),c),i.emit("listening")}function n(){let s=[];for(let o of e.values())s.push(o);return s}let i=Object.assign(new dO,{close:()=>Promise.resolve(),listen:r,getAddrs:n});return t.connectionManager.on("peer:disconnect",s=>{e.delete(s.remotePeer.toB58String())&&i.emit("close")}),i}});var Uh=w((UF,mw)=>{"use strict";var{Multiaddr:yw}=qt(),{CircuitRelay:zi}=Xs();function gw(t,e){t.write({type:zi.Type.STATUS,code:e})}function yO(t,e){try{t.dstPeer&&t.dstPeer.addrs&&t.dstPeer.addrs.forEach(r=>new yw(r))}catch(r){throw gw(e,t.type===zi.Type.HOP?zi.Status.HOP_DST_MULTIADDR_INVALID:zi.Status.STOP_DST_MULTIADDR_INVALID),r}try{t.srcPeer&&t.srcPeer.addrs&&t.srcPeer.addrs.forEach(r=>new yw(r))}catch(r){throw gw(e,t.type===zi.Type.HOP?zi.Status.HOP_SRC_MULTIADDR_INVALID:zi.Status.STOP_SRC_MULTIADDR_INVALID),r}}mw.exports={validateAddrs:yO}});var Ew=w(bu=>{"use strict";bu.byteLength=mO;bu.toByteArray=bO;bu.fromByteArray=_O;var on=[],xr=[],gO=typeof Uint8Array!="undefined"?Uint8Array:Array,Mh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Gi=0,vw=Mh.length;Gi<vw;++Gi)on[Gi]=Mh[Gi],xr[Mh.charCodeAt(Gi)]=Gi;var Gi,vw;xr["-".charCodeAt(0)]=62;xr["_".charCodeAt(0)]=63;function bw(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function mO(t){var e=bw(t),r=e[0],n=e[1];return(r+n)*3/4-n}function vO(t,e,r){return(e+r)*3/4-r}function bO(t){var e,r=bw(t),n=r[0],i=r[1],s=new gO(vO(t,n,i)),o=0,a=i>0?n-4:n,c;for(c=0;c<a;c+=4)e=xr[t.charCodeAt(c)]<<18|xr[t.charCodeAt(c+1)]<<12|xr[t.charCodeAt(c+2)]<<6|xr[t.charCodeAt(c+3)],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=e&255;return i===2&&(e=xr[t.charCodeAt(c)]<<2|xr[t.charCodeAt(c+1)]>>4,s[o++]=e&255),i===1&&(e=xr[t.charCodeAt(c)]<<10|xr[t.charCodeAt(c+1)]<<4|xr[t.charCodeAt(c+2)]>>2,s[o++]=e>>8&255,s[o++]=e&255),s}function EO(t){return on[t>>18&63]+on[t>>12&63]+on[t>>6&63]+on[t&63]}function wO(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),i.push(EO(n));return i.join("")}function _O(t){for(var e,r=t.length,n=r%3,i=[],s=16383,o=0,a=r-n;o<a;o+=s)i.push(wO(t,o,o+s>a?a:o+s));return n===1?(e=t[r-1],i.push(on[e>>2]+on[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],i.push(on[e>>10]+on[e>>4&63]+on[e<<2&63]+"=")),i.join("")}});var ww=w(Fh=>{Fh.read=function(t,e,r,n,i){var s,o,a=i*8-n-1,c=(1<<a)-1,u=c>>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,s=p&(1<<-l)-1,p>>=-l,l+=a;l>0;s=s*256+t[e+f],f+=h,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=n;l>0;o=o*256+t[e+f],f+=h,l-=8);if(s===0)s=1-u;else{if(s===c)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,n),s=s-u}return(p?-1:1)*o*Math.pow(2,s-n)};Fh.write=function(t,e,r,n,i,s){var o,a,c,u=s*8-i-1,l=(1<<u)-1,f=l>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:s-1,d=n?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=l):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+f>=1?e+=h/c:e+=h*Math.pow(2,1-f),e*c>=2&&(o++,c/=2),o+f>=l?(a=0,o=l):o+f>=1?(a=(e*c-1)*Math.pow(2,i),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),o=0));i>=8;t[r+p]=a&255,p+=d,a/=256,i-=8);for(o=o<<i|a,u+=i;u>0;t[r+p]=o&255,p+=d,o/=256,u-=8);t[r+p-d]|=g*128}});var oi=w(to=>{"use strict";var Kh=Ew(),Zs=ww(),_w=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;to.Buffer=F;to.SlowBuffer=TO;to.INSPECT_MAX_BYTES=50;var Eu=2147483647;to.kMaxLength=Eu;F.TYPED_ARRAY_SUPPORT=xO();!F.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function xO(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch(t){return!1}}Object.defineProperty(F.prototype,"parent",{enumerable:!0,get:function(){if(!!F.isBuffer(this))return this.buffer}});Object.defineProperty(F.prototype,"offset",{enumerable:!0,get:function(){if(!!F.isBuffer(this))return this.byteOffset}});function Cn(t){if(t>Eu)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,F.prototype),e}function F(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Vh(t)}return xw(t,e,r)}F.poolSize=8192;function xw(t,e,r){if(typeof t=="string")return AO(t,e);if(ArrayBuffer.isView(t))return CO(t);if(t==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(an(t,ArrayBuffer)||t&&an(t.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(an(t,SharedArrayBuffer)||t&&an(t.buffer,SharedArrayBuffer)))return $h(t,e,r);if(typeof t=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=t.valueOf&&t.valueOf();if(n!=null&&n!==t)return F.from(n,e,r);let i=IO(t);if(i)return i;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof t[Symbol.toPrimitive]=="function")return F.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}F.from=function(t,e,r){return xw(t,e,r)};Object.setPrototypeOf(F.prototype,Uint8Array.prototype);Object.setPrototypeOf(F,Uint8Array);function Sw(t){if(typeof t!="number")throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function SO(t,e,r){return Sw(t),t<=0?Cn(t):e!==void 0?typeof r=="string"?Cn(t).fill(e,r):Cn(t).fill(e):Cn(t)}F.alloc=function(t,e,r){return SO(t,e,r)};function Vh(t){return Sw(t),Cn(t<0?0:Hh(t)|0)}F.allocUnsafe=function(t){return Vh(t)};F.allocUnsafeSlow=function(t){return Vh(t)};function AO(t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!F.isEncoding(e))throw new TypeError("Unknown encoding: "+e);let r=Aw(t,e)|0,n=Cn(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function jh(t){let e=t.length<0?0:Hh(t.length)|0,r=Cn(e);for(let n=0;n<e;n+=1)r[n]=t[n]&255;return r}function CO(t){if(an(t,Uint8Array)){let e=new Uint8Array(t);return $h(e.buffer,e.byteOffset,e.byteLength)}return jh(t)}function $h(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return e===void 0&&r===void 0?n=new Uint8Array(t):r===void 0?n=new Uint8Array(t,e):n=new Uint8Array(t,e,r),Object.setPrototypeOf(n,F.prototype),n}function IO(t){if(F.isBuffer(t)){let e=Hh(t.length)|0,r=Cn(e);return r.length===0||t.copy(r,0,0,e),r}if(t.length!==void 0)return typeof t.length!="number"||Wh(t.length)?Cn(0):jh(t);if(t.type==="Buffer"&&Array.isArray(t.data))return jh(t.data)}function Hh(t){if(t>=Eu)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Eu.toString(16)+" bytes");return t|0}function TO(t){return+t!=t&&(t=0),F.alloc(+t)}F.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==F.prototype};F.compare=function(e,r){if(an(e,Uint8Array)&&(e=F.from(e,e.offset,e.byteLength)),an(r,Uint8Array)&&(r=F.from(r,r.offset,r.byteLength)),!F.isBuffer(e)||!F.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===r)return 0;let n=e.length,i=r.length;for(let s=0,o=Math.min(n,i);s<o;++s)if(e[s]!==r[s]){n=e[s],i=r[s];break}return n<i?-1:i<n?1:0};F.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};F.concat=function(e,r){if(!Array.isArray(e))throw new TypeError('"list" argument must be an Array of Buffers');if(e.length===0)return F.alloc(0);let n;if(r===void 0)for(r=0,n=0;n<e.length;++n)r+=e[n].length;let i=F.allocUnsafe(r),s=0;for(n=0;n<e.length;++n){let o=e[n];if(an(o,Uint8Array))s+o.length>i.length?(F.isBuffer(o)||(o=F.from(o)),o.copy(i,s)):Uint8Array.prototype.set.call(i,o,s);else if(F.isBuffer(o))o.copy(i,s);else throw new TypeError('"list" argument must be an Array of Buffers');s+=o.length}return i};function Aw(t,e){if(F.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||an(t,ArrayBuffer))return t.byteLength;if(typeof t!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);let r=t.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return Gh(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return qw(t).length;default:if(i)return n?-1:Gh(t).length;e=(""+e).toLowerCase(),i=!0}}F.byteLength=Aw;function RO(t,e,r){let n=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,e>>>=0,r<=e))return"";for(t||(t="utf8");;)switch(t){case"hex":return MO(this,e,r);case"utf8":case"utf-8":return Tw(this,e,r);case"ascii":return qO(this,e,r);case"latin1":case"binary":return UO(this,e,r);case"base64":return LO(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return FO(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}F.prototype._isBuffer=!0;function Wi(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}F.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;r<e;r+=2)Wi(this,r,r+1);return this};F.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let r=0;r<e;r+=4)Wi(this,r,r+3),Wi(this,r+1,r+2);return this};F.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let r=0;r<e;r+=8)Wi(this,r,r+7),Wi(this,r+1,r+6),Wi(this,r+2,r+5),Wi(this,r+3,r+4);return this};F.prototype.toString=function(){let e=this.length;return e===0?"":arguments.length===0?Tw(this,0,e):RO.apply(this,arguments)};F.prototype.toLocaleString=F.prototype.toString;F.prototype.equals=function(e){if(!F.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:F.compare(this,e)===0};F.prototype.inspect=function(){let e="",r=to.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"};_w&&(F.prototype[_w]=F.prototype.inspect);F.prototype.compare=function(e,r,n,i,s){if(an(e,Uint8Array)&&(e=F.from(e,e.offset,e.byteLength)),!F.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(r===void 0&&(r=0),n===void 0&&(n=e?e.length:0),i===void 0&&(i=0),s===void 0&&(s=this.length),r<0||n>e.length||i<0||s>this.length)throw new RangeError("out of range index");if(i>=s&&r>=n)return 0;if(i>=s)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,s>>>=0,this===e)return 0;let o=s-i,a=n-r,c=Math.min(o,a),u=this.slice(i,s),l=e.slice(r,n);for(let f=0;f<c;++f)if(u[f]!==l[f]){o=u[f],a=l[f];break}return o<a?-1:a<o?1:0};function Cw(t,e,r,n,i){if(t.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Wh(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof e=="string"&&(e=F.from(e,n)),F.isBuffer(e))return e.length===0?-1:Iw(t,e,r,n,i);if(typeof e=="number")return e=e&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):Iw(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function Iw(t,e,r,n,i){let s=1,o=t.length,a=e.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(t.length<2||e.length<2)return-1;s=2,o/=2,a/=2,r/=2}function c(l,f){return s===1?l[f]:l.readUInt16BE(f*s)}let u;if(i){let l=-1;for(u=r;u<o;u++)if(c(t,u)===c(e,l===-1?0:u-l)){if(l===-1&&(l=u),u-l+1===a)return l*s}else l!==-1&&(u-=u-l),l=-1}else for(r+a>o&&(r=o-a),u=r;u>=0;u--){let l=!0;for(let f=0;f<a;f++)if(c(t,u+f)!==c(e,f)){l=!1;break}if(l)return u}return-1}F.prototype.includes=function(e,r,n){return this.indexOf(e,r,n)!==-1};F.prototype.indexOf=function(e,r,n){return Cw(this,e,r,n,!0)};F.prototype.lastIndexOf=function(e,r,n){return Cw(this,e,r,n,!1)};function BO(t,e,r,n){r=Number(r)||0;let i=t.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;let s=e.length;n>s/2&&(n=s/2);let o;for(o=0;o<n;++o){let a=parseInt(e.substr(o*2,2),16);if(Wh(a))return o;t[r+o]=a}return o}function PO(t,e,r,n){return wu(Gh(e,t.length-r),t,r,n)}function NO(t,e,r,n){return wu($O(e),t,r,n)}function OO(t,e,r,n){return wu(qw(e),t,r,n)}function DO(t,e,r,n){return wu(HO(e,t.length-r),t,r,n)}F.prototype.write=function(e,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r>>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let s=this.length-r;if((n===void 0||n>s)&&(n=s),e.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return BO(this,e,r,n);case"utf8":case"utf-8":return PO(this,e,r,n);case"ascii":case"latin1":case"binary":return NO(this,e,r,n);case"base64":return OO(this,e,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return DO(this,e,r,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}};F.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function LO(t,e,r){return e===0&&r===t.length?Kh.fromByteArray(t):Kh.fromByteArray(t.slice(e,r))}function Tw(t,e,r){r=Math.min(t.length,r);let n=[],i=e;for(;i<r;){let s=t[i],o=null,a=s>239?4:s>223?3:s>191?2:1;if(i+a<=r){let c,u,l,f;switch(a){case 1:s<128&&(o=s);break;case 2:c=t[i+1],(c&192)==128&&(f=(s&31)<<6|c&63,f>127&&(o=f));break;case 3:c=t[i+1],u=t[i+2],(c&192)==128&&(u&192)==128&&(f=(s&15)<<12|(c&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:c=t[i+1],u=t[i+2],l=t[i+3],(c&192)==128&&(u&192)==128&&(l&192)==128&&(f=(s&15)<<18|(c&63)<<12|(u&63)<<6|l&63,f>65535&&f<1114112&&(o=f))}}o===null?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|o&1023),n.push(o),i+=a}return kO(n)}var Rw=4096;function kO(t){let e=t.length;if(e<=Rw)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Rw));return r}function qO(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]&127);return n}function UO(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function MO(t,e,r){let n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let s=e;s<r;++s)i+=zO[t[s]];return i}function FO(t,e,r){let n=t.slice(e,r),i="";for(let s=0;s<n.length-1;s+=2)i+=String.fromCharCode(n[s]+n[s+1]*256);return i}F.prototype.slice=function(e,r){let n=this.length;e=~~e,r=r===void 0?n:~~r,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<e&&(r=e);let i=this.subarray(e,r);return Object.setPrototypeOf(i,F.prototype),i};function Ct(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}F.prototype.readUintLE=F.prototype.readUIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Ct(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return i};F.prototype.readUintBE=F.prototype.readUIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Ct(e,r,this.length);let i=this[e+--r],s=1;for(;r>0&&(s*=256);)i+=this[e+--r]*s;return i};F.prototype.readUint8=F.prototype.readUInt8=function(e,r){return e=e>>>0,r||Ct(e,1,this.length),this[e]};F.prototype.readUint16LE=F.prototype.readUInt16LE=function(e,r){return e=e>>>0,r||Ct(e,2,this.length),this[e]|this[e+1]<<8};F.prototype.readUint16BE=F.prototype.readUInt16BE=function(e,r){return e=e>>>0,r||Ct(e,2,this.length),this[e]<<8|this[e+1]};F.prototype.readUint32LE=F.prototype.readUInt32LE=function(e,r){return e=e>>>0,r||Ct(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};F.prototype.readUint32BE=F.prototype.readUInt32BE=function(e,r){return e=e>>>0,r||Ct(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};F.prototype.readBigUInt64LE=si(function(e){e=e>>>0,eo(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ia(e,this.length-8);let i=r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24,s=this[++e]+this[++e]*2**8+this[++e]*2**16+n*2**24;return BigInt(i)+(BigInt(s)<<BigInt(32))});F.prototype.readBigUInt64BE=si(function(e){e=e>>>0,eo(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ia(e,this.length-8);let i=r*2**24+this[++e]*2**16+this[++e]*2**8+this[++e],s=this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n;return(BigInt(i)<<BigInt(32))+BigInt(s)});F.prototype.readIntLE=function(e,r,n){e=e>>>0,r=r>>>0,n||Ct(e,r,this.length);let i=this[e],s=1,o=0;for(;++o<r&&(s*=256);)i+=this[e+o]*s;return s*=128,i>=s&&(i-=Math.pow(2,8*r)),i};F.prototype.readIntBE=function(e,r,n){e=e>>>0,r=r>>>0,n||Ct(e,r,this.length);let i=r,s=1,o=this[e+--i];for(;i>0&&(s*=256);)o+=this[e+--i]*s;return s*=128,o>=s&&(o-=Math.pow(2,8*r)),o};F.prototype.readInt8=function(e,r){return e=e>>>0,r||Ct(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};F.prototype.readInt16LE=function(e,r){e=e>>>0,r||Ct(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n};F.prototype.readInt16BE=function(e,r){e=e>>>0,r||Ct(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n};F.prototype.readInt32LE=function(e,r){return e=e>>>0,r||Ct(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};F.prototype.readInt32BE=function(e,r){return e=e>>>0,r||Ct(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};F.prototype.readBigInt64LE=si(function(e){e=e>>>0,eo(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ia(e,this.length-8);let i=this[e+4]+this[e+5]*2**8+this[e+6]*2**16+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(r+this[++e]*2**8+this[++e]*2**16+this[++e]*2**24)});F.prototype.readBigInt64BE=si(function(e){e=e>>>0,eo(e,"offset");let r=this[e],n=this[e+7];(r===void 0||n===void 0)&&Ia(e,this.length-8);let i=(r<<24)+this[++e]*2**16+this[++e]*2**8+this[++e];return(BigInt(i)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*2**8+n)});F.prototype.readFloatLE=function(e,r){return e=e>>>0,r||Ct(e,4,this.length),Zs.read(this,e,!0,23,4)};F.prototype.readFloatBE=function(e,r){return e=e>>>0,r||Ct(e,4,this.length),Zs.read(this,e,!1,23,4)};F.prototype.readDoubleLE=function(e,r){return e=e>>>0,r||Ct(e,8,this.length),Zs.read(this,e,!0,52,8)};F.prototype.readDoubleBE=function(e,r){return e=e>>>0,r||Ct(e,8,this.length),Zs.read(this,e,!1,52,8)};function er(t,e,r,n,i,s){if(!F.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}F.prototype.writeUintLE=F.prototype.writeUIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;er(this,e,r,n,a,0)}let s=1,o=0;for(this[r]=e&255;++o<n&&(s*=256);)this[r+o]=e/s&255;return r+n};F.prototype.writeUintBE=F.prototype.writeUIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,n=n>>>0,!i){let a=Math.pow(2,8*n)-1;er(this,e,r,n,a,0)}let s=n-1,o=1;for(this[r+s]=e&255;--s>=0&&(o*=256);)this[r+s]=e/o&255;return r+n};F.prototype.writeUint8=F.prototype.writeUInt8=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,1,255,0),this[r]=e&255,r+1};F.prototype.writeUint16LE=F.prototype.writeUInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,2,65535,0),this[r]=e&255,this[r+1]=e>>>8,r+2};F.prototype.writeUint16BE=F.prototype.writeUInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,2,65535,0),this[r]=e>>>8,this[r+1]=e&255,r+2};F.prototype.writeUint32LE=F.prototype.writeUInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,4,4294967295,0),this[r+3]=e>>>24,this[r+2]=e>>>16,this[r+1]=e>>>8,this[r]=e&255,r+4};F.prototype.writeUint32BE=F.prototype.writeUInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,4,4294967295,0),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};function Bw(t,e,r,n,i){kw(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s,s=s>>8,t[r++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,o=o>>8,t[r++]=o,r}function Pw(t,e,r,n,i){kw(e,n,i,t,r,7);let s=Number(e&BigInt(4294967295));t[r+7]=s,s=s>>8,t[r+6]=s,s=s>>8,t[r+5]=s,s=s>>8,t[r+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=o,o=o>>8,t[r+2]=o,o=o>>8,t[r+1]=o,o=o>>8,t[r]=o,r+8}F.prototype.writeBigUInt64LE=si(function(e,r=0){return Bw(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});F.prototype.writeBigUInt64BE=si(function(e,r=0){return Pw(this,e,r,BigInt(0),BigInt("0xffffffffffffffff"))});F.prototype.writeIntLE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);er(this,e,r,n,c-1,-c)}let s=0,o=1,a=0;for(this[r]=e&255;++s<n&&(o*=256);)e<0&&a===0&&this[r+s-1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};F.prototype.writeIntBE=function(e,r,n,i){if(e=+e,r=r>>>0,!i){let c=Math.pow(2,8*n-1);er(this,e,r,n,c-1,-c)}let s=n-1,o=1,a=0;for(this[r+s]=e&255;--s>=0&&(o*=256);)e<0&&a===0&&this[r+s+1]!==0&&(a=1),this[r+s]=(e/o>>0)-a&255;return r+n};F.prototype.writeInt8=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,1,127,-128),e<0&&(e=255+e+1),this[r]=e&255,r+1};F.prototype.writeInt16LE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,2,32767,-32768),this[r]=e&255,this[r+1]=e>>>8,r+2};F.prototype.writeInt16BE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,2,32767,-32768),this[r]=e>>>8,this[r+1]=e&255,r+2};F.prototype.writeInt32LE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,4,2147483647,-2147483648),this[r]=e&255,this[r+1]=e>>>8,this[r+2]=e>>>16,this[r+3]=e>>>24,r+4};F.prototype.writeInt32BE=function(e,r,n){return e=+e,r=r>>>0,n||er(this,e,r,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[r]=e>>>24,this[r+1]=e>>>16,this[r+2]=e>>>8,this[r+3]=e&255,r+4};F.prototype.writeBigInt64LE=si(function(e,r=0){return Bw(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});F.prototype.writeBigInt64BE=si(function(e,r=0){return Pw(this,e,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Nw(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Ow(t,e,r,n,i){return e=+e,r=r>>>0,i||Nw(t,e,r,4,34028234663852886e22,-34028234663852886e22),Zs.write(t,e,r,n,23,4),r+4}F.prototype.writeFloatLE=function(e,r,n){return Ow(this,e,r,!0,n)};F.prototype.writeFloatBE=function(e,r,n){return Ow(this,e,r,!1,n)};function Dw(t,e,r,n,i){return e=+e,r=r>>>0,i||Nw(t,e,r,8,17976931348623157e292,-17976931348623157e292),Zs.write(t,e,r,n,52,8),r+8}F.prototype.writeDoubleLE=function(e,r,n){return Dw(this,e,r,!0,n)};F.prototype.writeDoubleBE=function(e,r,n){return Dw(this,e,r,!1,n)};F.prototype.copy=function(e,r,n,i){if(!F.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=e.length&&(r=e.length),r||(r=0),i>0&&i<n&&(i=n),i===n||e.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-r<i-n&&(i=e.length-r+n);let s=i-n;return this===e&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(r,n,i):Uint8Array.prototype.set.call(e,this.subarray(n,i),r),s};F.prototype.fill=function(e,r,n,i){if(typeof e=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!F.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(e.length===1){let o=e.charCodeAt(0);(i==="utf8"&&o<128||i==="latin1")&&(e=o)}}else typeof e=="number"?e=e&255:typeof e=="boolean"&&(e=Number(e));if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,e||(e=0);let s;if(typeof e=="number")for(s=r;s<n;++s)this[s]=e;else{let o=F.isBuffer(e)?e:F.from(e,i),a=o.length;if(a===0)throw new TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<n-r;++s)this[s+r]=o[s%a]}return this};var Js={};function zh(t,e,r){Js[t]=class extends r{constructor(){super();Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(i){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:i,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}zh("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError);zh("ERR_INVALID_ARG_TYPE",function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError);zh("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=Lw(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=Lw(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);function Lw(t){let e="",r=t.length,n=t[0]==="-"?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function KO(t,e,r){eo(e,"offset"),(t[e]===void 0||t[e+r]===void 0)&&Ia(e,t.length-(r+1))}function kw(t,e,r,n,i,s){if(t>r||t<e){let o=typeof e=="bigint"?"n":"",a;throw s>3?e===0||e===BigInt(0)?a=`>= 0${o} and < 2${o} ** ${(s+1)*8}${o}`:a=`>= -(2${o} ** ${(s+1)*8-1}${o}) and < 2 ** ${(s+1)*8-1}${o}`:a=`>= ${e}${o} and <= ${r}${o}`,new Js.ERR_OUT_OF_RANGE("value",a,t)}KO(n,i,s)}function eo(t,e){if(typeof t!="number")throw new Js.ERR_INVALID_ARG_TYPE(e,"number",t)}function Ia(t,e,r){throw Math.floor(t)!==t?(eo(t,r),new Js.ERR_OUT_OF_RANGE(r||"offset","an integer",t)):e<0?new Js.ERR_BUFFER_OUT_OF_BOUNDS:new Js.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}var VO=/[^+/0-9A-Za-z-_]/g;function jO(t){if(t=t.split("=")[0],t=t.trim().replace(VO,""),t.length<2)return"";for(;t.length%4!=0;)t=t+"=";return t}function Gh(t,e){e=e||1/0;let r,n=t.length,i=null,s=[];for(let o=0;o<n;++o){if(r=t.charCodeAt(o),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}else if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function $O(t){let e=[];for(let r=0;r<t.length;++r)e.push(t.charCodeAt(r)&255);return e}function HO(t,e){let r,n,i,s=[];for(let o=0;o<t.length&&!((e-=2)<0);++o)r=t.charCodeAt(o),n=r>>8,i=r%256,s.push(i),s.push(n);return s}function qw(t){return Kh.toByteArray(jO(t))}function wu(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function an(t,e){return t instanceof e||t!=null&&t.constructor!=null&&t.constructor.name!=null&&t.constructor.name===e.name}function Wh(t){return t!==t}var zO=function(){let t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function si(t){return typeof BigInt=="undefined"?GO:t}function GO(){throw new Error("BigInt not supported")}});var Yi=w((jF,Mw)=>{"use strict";var{Buffer:qr}=oi(),Uw=Symbol.for("BufferList");function Ge(t){if(!(this instanceof Ge))return new Ge(t);Ge._init.call(this,t)}Ge._init=function(e){Object.defineProperty(this,Uw,{value:!0}),this._bufs=[],this.length=0,e&&this.append(e)};Ge.prototype._new=function(e){return new Ge(e)};Ge.prototype._offset=function(e){if(e===0)return[0,0];let r=0;for(let n=0;n<this._bufs.length;n++){let i=r+this._bufs[n].length;if(e<i||n===this._bufs.length-1)return[n,e-r];r=i}};Ge.prototype._reverseOffset=function(t){let e=t[0],r=t[1];for(let n=0;n<e;n++)r+=this._bufs[n].length;return r};Ge.prototype.get=function(e){if(e>this.length||e<0)return;let r=this._offset(e);return this._bufs[r[0]][r[1]]};Ge.prototype.slice=function(e,r){return typeof e=="number"&&e<0&&(e+=this.length),typeof r=="number"&&r<0&&(r+=this.length),this.copy(null,0,e,r)};Ge.prototype.copy=function(e,r,n,i){if((typeof n!="number"||n<0)&&(n=0),(typeof i!="number"||i>this.length)&&(i=this.length),n>=this.length||i<=0)return e||qr.alloc(0);let s=!!e,o=this._offset(n),a=i-n,c=a,u=s&&r||0,l=o[1];if(n===0&&i===this.length){if(!s)return this._bufs.length===1?this._bufs[0]:qr.concat(this._bufs,this.length);for(let f=0;f<this._bufs.length;f++)this._bufs[f].copy(e,u),u+=this._bufs[f].length;return e}if(c<=this._bufs[o[0]].length-l)return s?this._bufs[o[0]].copy(e,r,l,l+c):this._bufs[o[0]].slice(l,l+c);s||(e=qr.allocUnsafe(a));for(let f=o[0];f<this._bufs.length;f++){let h=this._bufs[f].length-l;if(c>h)this._bufs[f].copy(e,u,l),u+=h;else{this._bufs[f].copy(e,u,l,l+c),u+=h;break}c-=h,l&&(l=0)}return e.length>u?e.slice(0,u):e};Ge.prototype.shallowSlice=function(e,r){if(e=e||0,r=typeof r!="number"?this.length:r,e<0&&(e+=this.length),r<0&&(r+=this.length),e===r)return this._new();let n=this._offset(e),i=this._offset(r),s=this._bufs.slice(n[0],i[0]+1);return i[1]===0?s.pop():s[s.length-1]=s[s.length-1].slice(0,i[1]),n[1]!==0&&(s[0]=s[0].slice(n[1])),this._new(s)};Ge.prototype.toString=function(e,r,n){return this.slice(r,n).toString(e)};Ge.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;)if(e>=this._bufs[0].length)e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift();else{this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}return this};Ge.prototype.duplicate=function(){let e=this._new();for(let r=0;r<this._bufs.length;r++)e.append(this._bufs[r]);return e};Ge.prototype.append=function(e){if(e==null)return this;if(e.buffer)this._appendBuffer(qr.from(e.buffer,e.byteOffset,e.byteLength));else if(Array.isArray(e))for(let r=0;r<e.length;r++)this.append(e[r]);else if(this._isBufferList(e))for(let r=0;r<e._bufs.length;r++)this.append(e._bufs[r]);else typeof e=="number"&&(e=e.toString()),this._appendBuffer(qr.from(e));return this};Ge.prototype._appendBuffer=function(e){this._bufs.push(e),this.length+=e.length};Ge.prototype.indexOf=function(t,e,r){if(r===void 0&&typeof e=="string"&&(r=e,e=void 0),typeof t=="function"||Array.isArray(t))throw new TypeError('The "value" argument must be one of type string, Buffer, BufferList, or Uint8Array.');if(typeof t=="number"?t=qr.from([t]):typeof t=="string"?t=qr.from(t,r):this._isBufferList(t)?t=t.slice():Array.isArray(t.buffer)?t=qr.from(t.buffer,t.byteOffset,t.byteLength):qr.isBuffer(t)||(t=qr.from(t)),e=Number(e||0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let n=this._offset(e),i=n[0],s=n[1];for(;i<this._bufs.length;i++){let o=this._bufs[i];for(;s<o.length;)if(o.length-s>=t.length){let c=o.indexOf(t,s);if(c!==-1)return this._reverseOffset([i,c]);s=o.length-t.length+1}else{let c=this._reverseOffset([i,s]);if(this._match(c,t))return c;s++}s=0}return-1};Ge.prototype._match=function(t,e){if(this.length-t<e.length)return!1;for(let r=0;r<e.length;r++)if(this.get(t+r)!==e[r])return!1;return!0};(function(){let t={readDoubleBE:8,readDoubleLE:8,readFloatBE:4,readFloatLE:4,readInt32BE:4,readInt32LE:4,readUInt32BE:4,readUInt32LE:4,readInt16BE:2,readInt16LE:2,readUInt16BE:2,readUInt16LE:2,readInt8:1,readUInt8:1,readIntBE:null,readIntLE:null,readUIntBE:null,readUIntLE:null};for(let e in t)(function(r){t[r]===null?Ge.prototype[r]=function(n,i){return this.slice(n,n+i)[r](0,i)}:Ge.prototype[r]=function(n=0){return this.slice(n,n+t[r])[r](0)}})(e)})();Ge.prototype._isBufferList=function(e){return e instanceof Ge||Ge.isBufferList(e)};Ge.isBufferList=function(e){return e!=null&&e[Uw]};Mw.exports=Ge});var Yh=w(($F,Vw)=>{"use strict";var Fw=ki(),{Buffer:WO}=oi(),Kw=(t,e,r)=>{let n=Fw.encode(t,e,r);return Kw.bytes=Fw.encode.bytes,e||WO.from(n)};Vw.exports=Kw});var Ww=w((HF,_u)=>{"use strict";var{Buffer:jw}=oi(),$w=Yi(),Hw=Yh(),Qh=8,zw=10*1024;function Gw(t){t=t||{};let e=Math.max(t.poolSize||zw,t.minPoolSize||Qh),r=t.lengthEncoder||Hw;return async function*(i){let s=jw.alloc(e),o=0;for await(let a of i){r(a.length,s,o);let c=s.slice(o,o+r.bytes);o+=r.bytes,s.length-o<Qh&&(s=jw.alloc(e),o=0),yield new $w().append(c).append(a)}}}Gw.single=(t,e)=>{e=e||{};let r=e.lengthEncoder||Hw;return new $w([r(t.length),t.slice()])};_u.exports=Gw;_u.exports.MIN_POOL_SIZE=Qh;_u.exports.DEFAULT_POOL_SIZE=zw});var Xh=w((zF,Xw)=>{"use strict";var Yw=ki(),{Buffer:YO}=oi(),QO=t=>new Proxy({},{get:(e,r)=>r[0]==="l"?t[r]:t.get(parseInt(r))}),Qw=t=>{let e=Yw.decode(YO.isBuffer(t)?t:QO(t));return Qw.bytes=Yw.decode.bytes,e};Xw.exports=Qw});var t2=w((GF,xu)=>{"use strict";var{Buffer:XO}=oi(),Zh=Yi(),ZO=Xh(),Zw=8,Jw=1024*1024*4,e2=XO.alloc(0),ai={LENGTH:"readLength",DATA:"readData"},JO={[ai.LENGTH]:(t,e,r,n)=>{e=e.append(t);let i;try{i=n.lengthDecoder(e)}catch(s){if(e.length>n.maxLengthLength)throw Object.assign(s,{message:"message length too long",code:"ERR_MSG_LENGTH_TOO_LONG"});if(s instanceof RangeError)return{mode:ai.LENGTH,buffer:e,chunk:void 0,state:void 0,data:void 0};throw s}if(i>n.maxDataLength)throw Object.assign(new Error("message data too long"),{code:"ERR_MSG_DATA_TOO_LONG"});return t=e.shallowSlice(n.lengthDecoder.bytes),e=new Zh,n.onLength&&n.onLength(i),i<=0?(n.onData&&n.onData(e2),{mode:ai.LENGTH,chunk:t,buffer:e,data:e2}):{mode:ai.DATA,chunk:t,buffer:e,state:{dataLength:i},data:void 0}},[ai.DATA]:(t,e,r,n)=>{if(e=e.append(t),!r)throw new Error("state is required");if(e.length<r.dataLength)return{mode:ai.DATA,buffer:e,state:r,chunk:void 0,data:void 0};let{dataLength:i}=r,s=e.shallowSlice(0,i),o=e.length>i?e.shallowSlice(i):void 0;return e=new Zh,n.onData&&n.onData(s),{mode:ai.LENGTH,chunk:o,buffer:e,state:void 0,data:s}}};function Jh(t){t=t||{};let e={lengthDecoder:t.lengthDecoder||ZO,maxLengthLength:t.maxLengthLength||Zw,maxDataLength:t.maxDataLength||Jw,onLength:t.onLength,onData:t.onData};return async function*(n){let i=new Zh,s=ai.LENGTH,o;for await(let a of n){let c=a;for(;c;){let u=JO[s](c,i,o,e);s=u.mode,c=u.chunk,i=u.buffer,o=u.state,u.data&&(yield u.data)}}if(i.length)throw Object.assign(new Error("unexpected end of input"),{code:"ERR_UNEXPECTED_EOF"})}}Jh.fromReader=(t,e)=>{let r=1,n={[Symbol.asyncIterator](){return this},next:async()=>{try{return await t.next(r)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{r=1}}};return Jh({...e||{},onLength:s=>{r=s}})(n)};xu.exports=Jh;xu.exports.MAX_LENGTH_LENGTH=Zw;xu.exports.MAX_DATA_LENGTH=Jw});var i2=w((WF,n2)=>{"use strict";var{Buffer:eD}=oi(),r2=(t,e,r)=>(e=e||eD.allocUnsafe(4),e.writeInt32BE(t,r),e);r2.bytes=4;n2.exports=r2});var a2=w((YF,o2)=>{"use strict";var s2=t=>{if(t.length<4)throw RangeError("Could not decode int32BE");return t.readInt32BE(0)};s2.bytes=4;o2.exports=s2});var ro=w(Qi=>{"use strict";Qi.encode=Ww();Qi.decode=t2();Qi.varintEncode=Yh();Qi.varintDecode=Xh();Qi.int32BEEncode=i2();Qi.int32BEDecode=a2()});var td=w((XF,c2)=>{var ed=Yi();c2.exports=t=>{let e=async function*(){let r=yield,n=new ed;for await(let i of t){if(!r){r=yield n.append(i),n=new ed;continue}for(n.append(i);n.length>=r;){let s=n.shallowSlice(0,r);if(n.consume(r),r=yield s,!r){n.length&&(r=yield n,n=new ed);break}}}if(r)throw Object.assign(new Error(`stream ended before ${r} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}});var rd=w((ZF,u2)=>{"use strict";var tD=()=>{let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t};u2.exports=tD});var no=w((JF,l2)=>{"use strict";var rD=td(),nD=uh(),iD=rd();l2.exports=t=>{let e=nD(),r=rD(t.source),n=iD(),i,s=t.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{i=a}),{reader:r,writer:e,stream:{sink:a=>i?Promise.reject(i):(n.resolve(a),s),source:r},rest:()=>e.end(),write:e.push,read:async()=>(await r.next()).value}}});var Au=w((eK,y2)=>{"use strict";var f2=Te(),Su=Object.assign(f2("libp2p:circuit:stream-handler"),{error:f2("libp2p:circuit:stream-handler:err")}),h2=ro(),sD=no(),{CircuitRelay:d2}=Xs(),p2=class{constructor({stream:e,maxLength:r=4096}){this.stream=e,this.shake=sD(this.stream),this.decoder=h2.decode.fromReader(this.shake.reader,{maxDataLength:r})}async read(){let e=await this.decoder.next();if(e.value){let r=d2.decode(e.value.slice());return Su("read message type",r.type),r}Su("read received no value, closing stream"),this.close()}write(e){Su("write message type %s",e.type),this.shake.write(h2.encode.single(d2.encode(e).finish()))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){Su("closing the stream"),this.rest().sink([])}};y2.exports=p2});var sd=w((tK,id)=>{"use strict";var g2=Te(),Ta=Object.assign(g2("libp2p:circuit:stop"),{error:g2("libp2p:circuit:stop:err")}),{CircuitRelay:nd}=Xs(),oD=Ca(),aD=Au(),{validateAddrs:cD}=Uh();id.exports.handleStop=function({connection:e,request:r,streamHandler:n}){try{cD(r,n)}catch(i){return Ta.error("invalid stop request via peer %s",e.remotePeer.toB58String(),i)}return Ta("stop request is valid"),n.write({type:nd.Type.STATUS,code:nd.Status.SUCCESS}),n.rest()};id.exports.stop=async function({connection:e,request:r}){let{stream:n}=await e.newStream([oD.relay]);Ta("starting stop request to %s",e.remotePeer.toB58String());let i=new aD({stream:n});i.write(r);let s=await i.read();if(!s)return i.close();if(s.code===nd.Status.SUCCESS)return Ta("stop request to %s was successful",e.remotePeer.toB58String()),i.rest();Ta("stop request failed with code %d",s.code),i.close()}});var od=w((rK,_2)=>{"use strict";var m2=Te(),In=Object.assign(m2("libp2p:circuit:hop"),{error:m2("libp2p:circuit:hop:err")}),v2=he(),uD=Rt(),{validateAddrs:lD}=Uh(),b2=Au(),{CircuitRelay:ir}=Xs(),{pipe:fD}=nn(),{codes:E2}=je(),{stop:hD}=sd(),w2=Ca();async function dD({connection:t,request:e,streamHandler:r,circuit:n}){if(!n._options.hop.enabled)return In("HOP request received but we are not acting as a relay"),r.end({type:ir.Type.STATUS,code:ir.Status.HOP_CANT_SPEAK_RELAY});try{lD(e,r)}catch(u){return In.error("invalid hop request via peer %s",t.remotePeer.toB58String(),u)}if(!e.dstPeer){In("HOP request received but we do not receive a dstPeer");return}let i=new uD(e.dstPeer.id),s=n._connectionManager.get(i);if(!s&&!n._options.hop.active)return In("HOP request received but we are not connected to the destination peer"),r.end({type:ir.Type.STATUS,code:ir.Status.HOP_NO_CONN_TO_DST});if(!s)return;let o={type:ir.Type.STOP,dstPeer:e.dstPeer,srcPeer:e.srcPeer},a;try{a=await hD({connection:s,request:o})}catch(u){return In.error(u)}In("hop request from %s is valid",t.remotePeer.toB58String()),r.write({type:ir.Type.STATUS,code:ir.Status.SUCCESS});let c=r.rest();return fD(c,a,c)}async function pD({connection:t,request:e}){let{stream:r}=await t.newStream([w2.relay]),n=new b2({stream:r});n.write(e);let i=await n.read();if(!i)throw v2(new Error("HOP request had no response"),E2.ERR_HOP_REQUEST_FAILED);if(i.code===ir.Status.SUCCESS)return In("hop request was successful"),n.rest();throw In("hop request failed with code %d, closing stream",i.code),n.close(),v2(new Error(`HOP request failed with code ${i.code}`),E2.ERR_HOP_REQUEST_FAILED)}async function yD({connection:t}){let{stream:e}=await t.newStream([w2.relay]),r=new b2({stream:e});r.write({type:ir.Type.CAN_HOP});let n=await r.read();return await r.close(),!(!n||n.code!==ir.Status.SUCCESS)}function gD({connection:t,streamHandler:e,circuit:r}){let n=r._options.hop.enabled;In("can hop (%s) request from %s",n,t.remotePeer.toB58String()),e.end({type:ir.Type.STATUS,code:n?ir.Status.SUCCESS:ir.Status.HOP_CANT_SPEAK_RELAY})}_2.exports={handleHop:dD,hop:pD,canHop:yD,handleCanHop:gD}});var T2=w((nK,I2)=>{"use strict";var x2=Te(),Tn=Object.assign(x2("libp2p:circuit"),{error:x2("libp2p:circuit:err")}),mD=he(),vD=JE(),{Multiaddr:Ra}=qt(),S2=Rt(),{CircuitRelay:Ba}=Xs(),{codes:bD}=je(),A2=fw(),{relay:ED}=Ca(),wD=pw(),{handleCanHop:_D,handleHop:xD,hop:SD}=od(),{handleStop:AD}=sd(),CD=Au(),ID=Symbol.for("@libp2p/js-libp2p-circuit/circuit"),C2=class{constructor({libp2p:e,upgrader:r}){this._dialer=e.dialer,this._registrar=e.registrar,this._connectionManager=e.connectionManager,this._upgrader=r,this._options=e._config.relay,this._libp2p=e,this.peerId=e.peerId,this._registrar.handle(ED,this._onProtocol.bind(this))}async _onProtocol({connection:e,stream:r}){let n=new CD({stream:r}),i=await n.read();if(!i)return;let s=this,o;switch(i.type){case Ba.Type.CAN_HOP:{Tn("received CAN_HOP request from %s",e.remotePeer.toB58String()),await _D({circuit:s,connection:e,streamHandler:n});break}case Ba.Type.HOP:{Tn("received HOP request from %s",e.remotePeer.toB58String()),o=await xD({connection:e,request:i,streamHandler:n,circuit:s});break}case Ba.Type.STOP:{Tn("received STOP request from %s",e.remotePeer.toB58String()),o=await AD({connection:e,request:i,streamHandler:n});break}default:Tn("Request of type %s not supported",i.type)}if(o){let a=new Ra(i.dstPeer.addrs[0]),c=new Ra(i.srcPeer.addrs[0]),u=A2({stream:o,remoteAddr:a,localAddr:c}),l=i.type===Ba.Type.HOP?"relay":"inbound";Tn("new %s connection %s",l,u.remoteAddr);let f=await this._upgrader.upgradeInbound(u);Tn("%s connection %s upgraded",l,u.remoteAddr),this.handler&&this.handler(f)}}async dial(e,r){let n=e.toString().split("/p2p-circuit"),i=new Ra(n[0]),s=new Ra(n[n.length-1]),o=i.getPeerId(),a=s.getPeerId();if(!o||!a){let h="Circuit relay dial failed as addresses did not have peer id";throw Tn.error(h),mD(new Error(h),bD.ERR_RELAYED_DIAL)}let c=S2.createFromB58String(o),u=S2.createFromB58String(a),l=!1,f=this._connectionManager.get(c);f||(f=await this._dialer.connectToPeer(i,r),l=!0);try{let h=await SD({connection:f,request:{type:Ba.Type.HOP,srcPeer:{id:this.peerId.toBytes(),addrs:this._libp2p.multiaddrs.map(g=>g.bytes)},dstPeer:{id:u.toBytes(),addrs:[new Ra(s).bytes]}}}),p=i.encapsulate(`/p2p-circuit/p2p/${this.peerId.toB58String()}`),d=A2({stream:h,remoteAddr:e,localAddr:p});return Tn("new outbound connection %s",d.remoteAddr),this._upgrader.upgradeOutbound(d)}catch(h){throw Tn.error("Circuit relay dial failed",h),l&&await f.close(),h}}createListener(e,r){return typeof e=="function"&&(r=e,e={}),this.handler=r,wD(this._libp2p)}filter(e){return e=Array.isArray(e)?e:[e],e.filter(r=>vD.Circuit.matches(r))}get[Symbol.toStringTag](){return"Circuit"}static isTransport(e){return Boolean(e&&e[ID])}};I2.exports=C2});var ad=w((iK,R2)=>{"use strict";var{CID:TD}=(vs(),Do),{sha256:RD}=(Ti(),Hn);R2.exports.namespaceToCid=async t=>{let e=new TextEncoder().encode(t),r=await RD.digest(e);return TD.createV0(r)}});var L2=w((sK,D2)=>{"use strict";var B2=Te(),cd=Object.assign(B2("libp2p:auto-relay"),{error:B2("libp2p:auto-relay:err")}),{fromString:BD}=(It(),Nt),{toString:PD}=(Tt(),Ot),{Multiaddr:ND}=qt(),OD=Wc(),{relay:DD}=Ca(),{canHop:LD}=od(),{namespaceToCid:kD}=ad(),{CIRCUIT_PROTO_CODE:qD,HOP_METADATA_KEY:P2,HOP_METADATA_VALUE:N2,RELAY_RENDEZVOUS_NS:UD}=cu(),O2=class{constructor({libp2p:e,maxListeners:r=1,onError:n}){this._libp2p=e,this._peerId=e.peerId,this._peerStore=e.peerStore,this._connectionManager=e.connectionManager,this._transportManager=e.transportManager,this._addressSorter=e.dialer.addressSorter,this.maxListeners=r,this._listenRelays=new Set,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this._peerStore.on("change:protocols",this._onProtocolChange),this._connectionManager.on("peer:disconnect",this._onPeerDisconnected),this._onError=(i,s)=>{cd.error(s||i),n&&n(i,s)}}async _onProtocolChange({peerId:e,protocols:r}){let n=e.toB58String(),i=r.find(s=>s===DD);if(!i&&this._listenRelays.has(n)){await this._removeListenRelay(n);return}else if(!i||this._listenRelays.has(n))return;try{let s=this._connectionManager.get(e);if(!s)return;if(s.remoteAddr.protoCodes().includes(qD)){cd(`relayed connection to ${n} will not be used to hop on`);return}await LD({connection:s})&&(await this._peerStore.metadataBook.setValue(e,P2,BD(N2)),await this._addListenRelay(s,n))}catch(s){this._onError(s)}}_onPeerDisconnected(e){let n=e.remotePeer.toB58String();!this._listenRelays.has(n)||this._removeListenRelay(n).catch(i=>{cd.error(i)})}async _addListenRelay(e,r){try{if(this._listenRelays.size>=this.maxListeners)return;let n=await this._peerStore.addressBook.getMultiaddrsForPeer(e.remotePeer,this._addressSorter);(await Promise.all(n.map(async s=>{try{return await this._transportManager.listen([new ND(`${s.toString()}/p2p-circuit`)]),!0}catch(o){this._onError(o)}return!1}))).includes(!0)&&this._listenRelays.add(r)}catch(n){this._onError(n),this._listenRelays.delete(r)}}async _removeListenRelay(e){this._listenRelays.delete(e)&&await this._listenOnAvailableHopRelays([e])}async _listenOnAvailableHopRelays(e=[]){if(this._listenRelays.size>=this.maxListeners)return;let r=[],n=await OD(this._peerStore.getPeers());for await(let{id:i,metadata:s}of n){let o=i.toB58String();if(this._listenRelays.has(o)||e.includes(o))continue;let a=s.get(P2);if(!a||PD(a)!==N2)continue;let c=this._connectionManager.get(i);if(!c){r.push(i);continue}if(await this._addListenRelay(c,o),this._listenRelays.size>=this.maxListeners)return}for(let i of r)if(await this._tryToListenOnRelay(i),this._listenRelays.size>=this.maxListeners)return;try{let i=await kD(UD);for await(let s of this._libp2p.contentRouting.findProviders(i)){if(!s.multiaddrs.length)continue;let o=s.id;if(await this._peerStore.addressBook.add(o,s.multiaddrs),await this._tryToListenOnRelay(o),this._listenRelays.size>=this.maxListeners)return}}catch(i){this._onError(i)}}async _tryToListenOnRelay(e){try{let r=await this._libp2p.dial(e);await this._addListenRelay(r,e.toB58String())}catch(r){this._onError(r,`could not connect and listen on known hop relay ${e.toB58String()}`)}}};D2.exports=O2});var F2=w((oK,M2)=>{"use strict";var k2=Te(),q2=Object.assign(k2("libp2p:relay"),{error:k2("libp2p:relay:err")}),{codes:MD}=je(),{setDelayedInterval:FD,clearDelayedInterval:KD}=dh(),VD=L2(),{namespaceToCid:jD}=ad(),{RELAY_RENDEZVOUS_NS:$D}=cu(),U2=class{constructor(e){this._libp2p=e,this._options={...e._config.relay},this._autoRelay=this._options.autoRelay.enabled&&new VD({libp2p:e,...this._options.autoRelay}),this._advertiseService=this._advertiseService.bind(this)}start(){this._options.hop.enabled&&this._options.advertise.enabled&&(this._timeout=FD(this._advertiseService,this._options.advertise.ttl,this._options.advertise.bootDelay))}stop(){KD(this._timeout)}async _advertiseService(){try{let e=await jD($D);await this._libp2p.contentRouting.provide(e)}catch(e){e.code===MD.ERR_NO_ROUTERS_AVAILABLE?(q2.error("a content router, such as a DHT, must be provided in order to advertise the relay service",e),this.stop()):q2.error(e)}}};M2.exports=U2});var ld=w((aK,ud)=>{var{AbortController:HD}=globalThis;function K2(t){let e=new HD;function r(){e.abort();for(let n of t)!n||!n.removeEventListener||n.removeEventListener("abort",r)}for(let n of t)if(!(!n||!n.addEventListener)){if(n.aborted){r();break}n.addEventListener("abort",r)}return e.signal}ud.exports=K2;ud.exports.anySignal=K2});var H2=w((uK,$2)=>{var V2=ah(),j2=rd();$2.exports=class{constructor(){this._buffer=new V2,this._waitingConsumers=new V2}push(e){let{promise:r,resolve:n}=j2();return this._buffer.push({chunk:e,resolve:n}),this._consume(),r}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){let e=this._waitingConsumers.shift(),r=this._buffer.shift();e.resolve(r.chunk),r.resolve()}}shift(){let{promise:e,resolve:r}=j2();return this._waitingConsumers.push({resolve:r}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}});var G2=w((lK,z2)=>{"use strict";z2.exports=(t,e=1,r)=>{if(r={indent:" ",includeEmptyLines:!1,...r},typeof t!="string")throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof t}\``);if(typeof e!="number")throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof e}\``);if(typeof r.indent!="string")throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof r.indent}\``);if(e===0)return t;let n=r.includeEmptyLines?/^/gm:/^(?!\s*$)/gm;return t.replace(n,r.indent.repeat(e))}});var W2=w(()=>{});var Z2=w((dK,X2)=>{"use strict";var Y2=W2(),Q2=/\s+at.*(?:\(|\s)(.*)\)?/,zD=/^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)\.js:\d+:\d+)|native)/,GD=typeof Y2.homedir=="undefined"?"":Y2.homedir();X2.exports=(t,e)=>(e=Object.assign({pretty:!1},e),t.replace(/\\/g,"/").split(`
41
+ `).filter(r=>{let n=r.match(Q2);if(n===null||!n[1])return!0;let i=n[1];return i.includes(".app/Contents/Resources/electron.asar")||i.includes(".app/Contents/Resources/default_app.asar")?!1:!zD.test(i)}).filter(r=>r.trim()!=="").map(r=>e.pretty?r.replace(Q2,(n,i)=>n.replace(i,i.replace(GD,"~"))):r).join(`
42
+ `))});var t_=w((pK,e_)=>{"use strict";var WD=G2(),YD=Z2(),QD=t=>t.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,""),J2=class extends Error{constructor(e){if(!Array.isArray(e))throw new TypeError(`Expected input to be an Array, got ${typeof e}`);e=[...e].map(n=>n instanceof Error?n:n!==null&&typeof n=="object"?Object.assign(new Error(n.message),n):new Error(n));let r=e.map(n=>typeof n.stack=="string"?QD(YD(n.stack)):String(n)).join(`
43
43
  `);r=`
44
- `+mD(r,4);super(r);this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(let e of this._errors)yield e}};M2.exports=U2});var K2=w((PF,id)=>{"use strict";var nd=class extends Error{constructor(e){super(e||"Promise was canceled");this.name="CancelError"}get isCanceled(){return!0}},Aa=class{static fn(e){return(...r)=>new Aa((n,i,s)=>{r.push(s),e(...r).then(n,i)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,n)=>{this._reject=n;let i=a=>{(!this._isCanceled||!o.shouldReject)&&(this._isPending=!1,r(a))},s=a=>{this._isPending=!1,n(a)},o=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(o,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),e(i,s,o)})}then(e,r){return this._promise.then(e,r)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(!(!this._isPending||this._isCanceled)){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(let r of this._cancelHandlers)r()}catch(r){this._reject(r);return}this._rejectOnCancel&&this._reject(new nd(e))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(Aa.prototype,Promise.prototype);id.exports=Aa;id.exports.CancelError=nd});var j2=w((NF,gu)=>{"use strict";var V2=F2(),ED=K2(),sd=class extends Error{},wD=(t,e)=>new ED((r,n,i)=>{let{count:s,filter:o=()=>!0}=e;if(!Number.isFinite(s)){n(new TypeError(`Expected a finite number, got ${typeof e.count}`));return}let a=[],c=[],u=0,l=!1,f=new Set,h=()=>(a.length===s&&(r(a),l=!0),u-c.length<s&&(n(new V2(c)),l=!0),l),p=()=>{for(let d of t)!f.has(d)&&typeof d.cancel=="function"&&d.cancel()};i(p);for(let d of t)u++,(async()=>{try{let g=await d;if(l)return;if(!o(g))throw new sd("Value does not satisfy filter");a.push(g)}catch(g){c.push(g)}finally{f.add(d),!l&&h()&&p()}})();s>u&&(n(new RangeError(`Expected input to contain at least ${e.count} items, but contains ${u} items`)),p())});gu.exports=wD;gu.exports.AggregateError=V2;gu.exports.FilterError=sd});var $2=w((OF,ad)=>{"use strict";var od=class extends Error{constructor(e){super(e||"Promise was canceled");this.name="CancelError"}get isCanceled(){return!0}},Ca=class{static fn(e){return(...r)=>new Ca((n,i,s)=>{r.push(s),e(...r).then(n,i)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,n)=>{this._reject=n;let i=a=>{(!this._isCanceled||!o.shouldReject)&&(this._isPending=!1,r(a))},s=a=>{this._isPending=!1,n(a)},o=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(o,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),e(i,s,o)})}then(e,r){return this._promise.then(e,r)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(!(!this._isPending||this._isCanceled)){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(let r of this._cancelHandlers)r()}catch(r){this._reject(r);return}this._rejectOnCancel&&this._reject(new od(e))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(Ca.prototype,Promise.prototype);ad.exports=Ca;ad.exports.CancelError=od});var z2=w((DF,cd)=>{"use strict";var H2=j2(),_D=$2();cd.exports=(t,e)=>{let r=H2(t,{...e,count:1});return _D.fn(async n=>{n(()=>{r.cancel()});let[i]=await r;return i})()};cd.exports.AggregateError=H2.AggregateError});var Q2=w((LF,Y2)=>{"use strict";var xD=pe(),{anySignal:SD}=rd(),AD=B2(),CD=z2(),{setMaxListeners:G2}=Qt(),{codes:ID}=He(),W2=class{constructor({addrs:e,dialAction:r,dialer:n}){this.addrs=e,this.dialer=n,this.dialAction=r}async run(e={}){let r=this.dialer.getTokens(this.addrs.length);if(r.length<1)throw xD(new Error("No dial tokens available"),ID.ERR_NO_DIAL_TOKENS);let n=new AD;r.forEach(o=>n.push(o));let i=this.addrs.map(()=>{let o=new AbortController;try{G2&&G2(1/0,o.signal)}catch{}return o}),s=0;try{return await CD(this.addrs.map(async(o,a)=>{let c=await n.shift(),u;try{let l=i[a].signal;u=await this.dialAction(o,{...e,signal:e.signal?SD([l,e.signal]):l}),i.splice(a,1)}finally{s++,this.addrs.length-s>=r.length?n.push(c):this.dialer.releaseToken(r.splice(r.indexOf(c),1)[0])}return u}))}finally{i.map(o=>o.abort()),r.forEach(o=>this.dialer.releaseToken(o))}}};Y2.exports=W2});var n_=w((kF,r_)=>{"use strict";var X2=Be(),Zs=Object.assign(X2("libp2p:dialer"),{error:X2("libp2p:dialer:err")}),ud=pe(),{Multiaddr:ld}=kt(),{TimeoutController:TD}=Xf(),{AbortError:RD}=Rh(),{anySignal:BD}=rd(),{setMaxListeners:Z2}=Qt(),PD=Q2(),{publicAddressesFirst:ND}=fh(),OD=sh(),J2=_h(),{codes:mu}=He(),{DIAL_TIMEOUT:DD,MAX_PARALLEL_DIALS:LD,MAX_PER_PEER_DIALS:kD,MAX_ADDRS_TO_DIAL:qD}=Zc(),e_="dialler",UD="pending-dials",MD="pending-dial-targets",t_=class{constructor({transportManager:e,peerStore:r,addressSorter:n=ND,maxParallelDials:i=LD,maxAddrsToDial:s=qD,dialTimeout:o=DD,maxDialsPerPeer:a=kD,resolvers:c={},metrics:u}){this.transportManager=e,this.peerStore=r,this.addressSorter=n,this.maxParallelDials=i,this.maxAddrsToDial=s,this.timeout=o,this.maxDialsPerPeer=a,this.tokens=[...new Array(i)].map((l,f)=>f),this._pendingDials=J2({component:e_,metric:UD,metrics:u}),this._pendingDialTargets=J2({component:e_,metric:MD,metrics:u});for(let[l,f]of Object.entries(c))ld.resolvers.set(l,f)}destroy(){for(let e of this._pendingDials.values())try{e.controller.abort()}catch(r){Zs.error(r)}this._pendingDials.clear();for(let e of this._pendingDialTargets.values())e.reject(new RD("Dialer was destroyed"));this._pendingDialTargets.clear()}async connectToPeer(e,r={}){let n=await this._createCancellableDialTarget(e);if(!n.addrs.length)throw ud(new Error("The dial request has no valid addresses"),mu.ERR_NO_VALID_ADDRESSES);let i=this._pendingDials.get(n.id)||this._createPendingDial(n,r);try{let s=await i.promise;return Zs("dial succeeded to %s",n.id),s}catch(s){throw i.controller.signal.aborted&&(s.code=mu.ERR_TIMEOUT),Zs.error(s),s}finally{i.destroy()}}async _createCancellableDialTarget(e){let r=`${parseInt(String(Math.random()*1e9),10).toString()+Date.now()}`,n=new Promise((i,s)=>{this._pendingDialTargets.set(r,{resolve:i,reject:s})});try{return await Promise.race([this._createDialTarget(e),n])}finally{this._pendingDialTargets.delete(r)}}async _createDialTarget(e){let{id:r,multiaddrs:n}=OD(e);n&&await this.peerStore.addressBook.add(r,n);let i=await this.peerStore.addressBook.getMultiaddrsForPeer(r,this.addressSorter)||[];ld.isMultiaddr(e)&&(i=i.filter(a=>!e.equals(a)),i.unshift(e));let s=[];for(let a of i)(await this._resolve(a)).forEach(u=>s.push(u));let o=s.filter(a=>this.transportManager.transportForMultiaddr(a));if(o.length>this.maxAddrsToDial)throw await this.peerStore.delete(r),ud(new Error("dial with more addresses than allowed"),mu.ERR_TOO_MANY_ADDRESSES);return{id:r.toB58String(),addrs:o}}_createPendingDial(e,r={}){let n=(u,l)=>{if(l.signal.aborted)throw ud(new Error("already aborted"),mu.ERR_ALREADY_ABORTED);return this.transportManager.dial(u,l)},i=new PD({addrs:e.addrs,dialAction:n,dialer:this}),s=new TD(this.timeout),o=[s.signal];r.signal&&o.push(r.signal);let a=BD(o);try{Z2&&Z2(1/0,a)}catch{}let c={dialRequest:i,controller:s,promise:i.run({...r,signal:a}),destroy:()=>{s.clear(),this._pendingDials.delete(e.id)}};return this._pendingDials.set(e.id,c),c}getTokens(e){let r=Math.min(e,this.maxDialsPerPeer,this.tokens.length),n=this.tokens.splice(0,r);return Zs("%d tokens request, returning %d, %d remaining",e,r,this.tokens.length),n}releaseToken(e){this.tokens.indexOf(e)>-1||(Zs("token %d released",e),this.tokens.push(e))}async _resolve(e){if(!e.protoNames().includes("dnsaddr"))return[e];let n=await this._resolveRecord(e);return(await Promise.all(n.map(o=>this._resolve(o)))).flat().reduce((o,a)=>(o.find(c=>c.equals(a))||o.push(a),o),[])}async _resolveRecord(e){try{return e=new ld(e.toString()),await e.resolve()}catch(r){return Zs.error(`multiaddr ${e} could not be resolved`),[]}}};r_.exports=t_});var s_=w((qF,i_)=>{"use strict";function FD(t){return t>=55296&&t<=56319}function KD(t){return t>=56320&&t<=57343}i_.exports=function(e,r,n){if(typeof r!="string")throw new Error("Input must be string");for(var i=r.length,s=0,o,a,c=0;c<i;c+=1){if(o=r.charCodeAt(c),a=r[c],FD(o)&&KD(r.charCodeAt(c+1))&&(c+=1,a+=r[c]),s+=e(a),s===n)return r.slice(0,c+1);if(s>n)return r.slice(0,c-a.length+1)}return r}});var a_=w((UF,o_)=>{"use strict";function VD(t){return t>=55296&&t<=56319}function jD(t){return t>=56320&&t<=57343}o_.exports=function(e){if(typeof e!="string")throw new Error("Input must be string");for(var r=e.length,n=0,i=null,s=null,o=0;o<r;o++)i=e.charCodeAt(o),jD(i)?s!=null&&VD(s)?n+=1:n+=3:i<=127?n+=1:i>=128&&i<=2047?n+=2:i>=2048&&i<=65535&&(n+=3),s=i;return n}});var u_=w((MF,c_)=>{"use strict";var $D=s_(),HD=a_();c_.exports=$D.bind(null,HD)});var h_=w((FF,f_)=>{"use strict";var zD=u_(),GD=/[\/\?<>\\:\*\|"]/g,WD=/[\x00-\x1f\x80-\x9f]/g,YD=/^\.+$/,QD=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,XD=/[\. ]+$/;function l_(t,e){if(typeof t!="string")throw new Error("Input must be string");var r=t.replace(GD,e).replace(WD,e).replace(YD,e).replace(QD,e).replace(XD,e);return zD(r,255)}f_.exports=function(t,e){var r=e&&e.replacement||"",n=l_(t,r);return r===""?n:l_(n,"")}});var y_=w((KF,p_)=>{"use strict";_s();var vu=Ee(),{toString:Js}=(It(),Nt),{fromString:d_}=(Ct(),Pt);p_.exports={createCipheriv:(t,e,r)=>{let n=vu.cipher.createCipher("AES-CTR",Js(e,"ascii"));return n.start({iv:Js(r,"ascii")}),{update:i=>(n.update(vu.util.createBuffer(Js(i,"ascii"))),d_(n.output.getBytes(),"ascii"))}},createDecipheriv:(t,e,r)=>{let n=vu.cipher.createDecipher("AES-CTR",Js(e,"ascii"));return n.start({iv:Js(r,"ascii")}),{update:i=>(n.update(vu.util.createBuffer(Js(i,"ascii"))),d_(n.output.getBytes(),"ascii"))}}}});var v_=w((VF,m_)=>{"use strict";var ZD=pe(),g_={16:"aes-128-ctr",32:"aes-256-ctr"};m_.exports=function(t){let e=g_[t.length];if(!e){let r=Object.entries(g_).map(([n,i])=>`${n} (${i})`).join(" / ");throw ZD(new Error(`Invalid key length ${t.length} bytes. Must be ${r}`),"ERR_INVALID_KEY_LENGTH")}return e}});var w_=w(E_=>{"use strict";var b_=y_(),JD=v_();E_.create=async function(t,e){let r=JD(t),n=b_.createCipheriv(r,t,e),i=b_.createDecipheriv(r,t,e);return{async encrypt(o){return n.update(o)},async decrypt(o){return i.update(o)}}}});var S_=w(($F,x_)=>{"use strict";var eL=Rl(),tL=je(),rL=pe(),__={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function nL(t,e,r,n,i){let s=__[i];if(!s){let a=Object.keys(__).join(" / ");throw rL(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}let o=eL(t,e,r,n,s);return tL.encode64(o)}x_.exports=nL});var bu=w(eo=>{"use strict";var iL=bf(),sL=w_(),oL=Nc();eo.aes=sL;eo.hmac=iL;eo.keys=oL;eo.randomBytes=Ec();eo.pbkdf2=S_()});var T_=w((zF,I_)=>{var to=Ee();Un();je();var J=to.asn1,ro=I_.exports=to.pkcs7asn1=to.pkcs7asn1||{};to.pkcs7=to.pkcs7||{};to.pkcs7.asn1=ro;var A_={name:"ContentInfo",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:J.Class.UNIVERSAL,type:J.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:J.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};ro.contentInfoValidator=A_;var C_={name:"EncryptedContentInfo",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:J.Class.UNIVERSAL,type:J.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:J.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:J.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};ro.envelopedDataValidator={name:"EnvelopedData",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:J.Class.UNIVERSAL,type:J.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(C_)};ro.encryptedDataValidator={name:"EncryptedData",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1,capture:"version"}].concat(C_)};var aL={name:"SignerInfo",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:J.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:J.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:J.Class.UNIVERSAL,type:J.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:J.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};ro.signedDataValidator={name:"SignedData",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:J.Class.UNIVERSAL,type:J.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},A_,{name:"SignedData.Certificates",tagClass:J.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:J.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:J.Class.UNIVERSAL,type:J.Type.SET,capture:"signerInfos",optional:!0,value:[aL]}]};ro.recipientInfoValidator={name:"RecipientInfo",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:J.Class.UNIVERSAL,type:J.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:J.Class.UNIVERSAL,type:J.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:J.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter"}]},{name:"RecipientInfo.encryptedKey",tagClass:J.Class.UNIVERSAL,type:J.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var B_=w((GF,R_)=>{var Yi=Ee();je();Yi.mgf=Yi.mgf||{};var cL=R_.exports=Yi.mgf.mgf1=Yi.mgf1=Yi.mgf1||{};cL.create=function(t){var e={generate:function(r,n){for(var i=new Yi.util.ByteBuffer,s=Math.ceil(n/t.digestLength),o=0;o<s;o++){var a=new Yi.util.ByteBuffer;a.putInt32(o),t.start(),t.update(r+a.getBytes()),i.putBuffer(t.digest())}return i.truncate(i.length()-n),i.getBytes()}};return e}});var N_=w((WF,P_)=>{var Eu=Ee();B_();P_.exports=Eu.mgf=Eu.mgf||{};Eu.mgf.mgf1=Eu.mgf1});var D_=w((YF,O_)=>{var Qi=Ee();xi();je();var uL=O_.exports=Qi.pss=Qi.pss||{};uL.create=function(t){arguments.length===3&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e=t.md,r=t.mgf,n=e.digestLength,i=t.salt||null;typeof i=="string"&&(i=Qi.util.createBuffer(i));var s;if("saltLength"in t)s=t.saltLength;else if(i!==null)s=i.length();else throw new Error("Salt length not specified or specific salt not given.");if(i!==null&&i.length()!==s)throw new Error("Given salt length does not match length of given salt.");var o=t.prng||Qi.random,a={};return a.encode=function(c,u){var l,f=u-1,h=Math.ceil(f/8),p=c.digest().getBytes();if(h<n+s+2)throw new Error("Message is too long to encrypt.");var d;i===null?d=o.getBytesSync(s):d=i.bytes();var g=new Qi.util.ByteBuffer;g.fillWithByte(0,8),g.putBytes(p),g.putBytes(d),e.start(),e.update(g.getBytes());var m=e.digest().getBytes(),x=new Qi.util.ByteBuffer;x.fillWithByte(0,h-s-n-2),x.putByte(1),x.putBytes(d);var B=x.getBytes(),L=h-n-1,H=r.generate(m,L),U="";for(l=0;l<L;l++)U+=String.fromCharCode(B.charCodeAt(l)^H.charCodeAt(l));var q=65280>>8*h-f&255;return U=String.fromCharCode(U.charCodeAt(0)&~q)+U.substr(1),U+m+String.fromCharCode(188)},a.verify=function(c,u,l){var f,h=l-1,p=Math.ceil(h/8);if(u=u.substr(-p),p<n+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(u.charCodeAt(p-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var d=p-n-1,g=u.substr(0,d),m=u.substr(d,n),x=65280>>8*p-h&255;if((g.charCodeAt(0)&x)!=0)throw new Error("Bits beyond keysize not zero as expected.");var B=r.generate(m,d),L="";for(f=0;f<d;f++)L+=String.fromCharCode(g.charCodeAt(f)^B.charCodeAt(f));L=String.fromCharCode(L.charCodeAt(0)&~x)+L.substr(1);var H=p-n-s-2;for(f=0;f<H;f++)if(L.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(L.charCodeAt(H)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var U=L.substr(-s),q=new Qi.util.ByteBuffer;q.fillWithByte(0,8),q.putBytes(c),q.putBytes(U),e.start(),e.update(q.getBytes());var re=e.digest().getBytes();return m===re},a}});var hd=w((QF,U_)=>{var Y=Ee();_s();Un();oc();Mn();N_();bs();lc();D_();ko();je();var y=Y.asn1,G=U_.exports=Y.pki=Y.pki||{},le=G.oids,lt={};lt.CN=le.commonName;lt.commonName="CN";lt.C=le.countryName;lt.countryName="C";lt.L=le.localityName;lt.localityName="L";lt.ST=le.stateOrProvinceName;lt.stateOrProvinceName="ST";lt.O=le.organizationName;lt.organizationName="O";lt.OU=le.organizationalUnitName;lt.organizationalUnitName="OU";lt.E=le.emailAddress;lt.emailAddress="E";var L_=Y.pki.rsa.publicKeyValidator,lL={name:"Certificate",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:y.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:y.Class.UNIVERSAL,type:y.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:y.Class.UNIVERSAL,type:y.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:y.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:y.Class.UNIVERSAL,type:y.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:y.Class.UNIVERSAL,type:y.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:y.Class.UNIVERSAL,type:y.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:y.Class.UNIVERSAL,type:y.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},L_,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:y.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:y.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:y.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:y.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},fL={name:"rsapss",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:y.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:y.Class.UNIVERSAL,type:y.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:y.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:y.Class.UNIVERSAL,type:y.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:y.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:y.Class.UNIVERSAL,type:y.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:y.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:y.Class.UNIVERSAL,type:y.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},hL={name:"CertificationRequestInfo",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:y.Class.UNIVERSAL,type:y.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},L_,{name:"CertificationRequestInfo.attributes",tagClass:y.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:y.Class.UNIVERSAL,type:y.Type.SET,constructed:!0}]}]}]},dL={name:"CertificationRequest",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[hL,{name:"CertificationRequest.signatureAlgorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:y.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};G.RDNAttributesAsArray=function(t,e){for(var r=[],n,i,s,o=0;o<t.value.length;++o){n=t.value[o];for(var a=0;a<n.value.length;++a)s={},i=n.value[a],s.type=y.derToOid(i.value[0].value),s.value=i.value[1].value,s.valueTagClass=i.value[1].type,s.type in le&&(s.name=le[s.type],s.name in lt&&(s.shortName=lt[s.name])),e&&(e.update(s.type),e.update(s.value)),r.push(s)}return r};G.CRIAttributesAsArray=function(t){for(var e=[],r=0;r<t.length;++r)for(var n=t[r],i=y.derToOid(n.value[0].value),s=n.value[1].value,o=0;o<s.length;++o){var a={};if(a.type=i,a.value=s[o].value,a.valueTagClass=s[o].type,a.type in le&&(a.name=le[a.type],a.name in lt&&(a.shortName=lt[a.name])),a.type===le.extensionRequest){a.extensions=[];for(var c=0;c<a.value.length;++c)a.extensions.push(G.certificateExtensionFromAsn1(a.value[c]))}e.push(a)}return e};function ai(t,e){typeof e=="string"&&(e={shortName:e});for(var r=null,n,i=0;r===null&&i<t.attributes.length;++i)n=t.attributes[i],(e.type&&e.type===n.type||e.name&&e.name===n.name||e.shortName&&e.shortName===n.shortName)&&(r=n);return r}var wu=function(t,e,r){var n={};if(t!==le["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:le.sha1},mgf:{algorithmOid:le.mgf1,hash:{algorithmOid:le.sha1}},saltLength:20});var i={},s=[];if(!y.validate(e,fL,i,s)){var o=new Error("Cannot read RSASSA-PSS parameter block.");throw o.errors=s,o}return i.hashOid!==void 0&&(n.hash=n.hash||{},n.hash.algorithmOid=y.derToOid(i.hashOid)),i.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=y.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=y.derToOid(i.maskGenHashOid)),i.saltLength!==void 0&&(n.saltLength=i.saltLength.charCodeAt(0)),n};G.certificateFromPem=function(t,e,r){var n=Y.pem.decode(t)[0];if(n.type!=="CERTIFICATE"&&n.type!=="X509 CERTIFICATE"&&n.type!=="TRUSTED CERTIFICATE"){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=y.fromDer(n.body,r);return G.certificateFromAsn1(s,e)};G.certificateToPem=function(t,e){var r={type:"CERTIFICATE",body:y.toDer(G.certificateToAsn1(t)).getBytes()};return Y.pem.encode(r,{maxline:e})};G.publicKeyFromPem=function(t){var e=Y.pem.decode(t)[0];if(e.type!=="PUBLIC KEY"&&e.type!=="RSA PUBLIC KEY"){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=y.fromDer(e.body);return G.publicKeyFromAsn1(n)};G.publicKeyToPem=function(t,e){var r={type:"PUBLIC KEY",body:y.toDer(G.publicKeyToAsn1(t)).getBytes()};return Y.pem.encode(r,{maxline:e})};G.publicKeyToRSAPublicKeyPem=function(t,e){var r={type:"RSA PUBLIC KEY",body:y.toDer(G.publicKeyToRSAPublicKey(t)).getBytes()};return Y.pem.encode(r,{maxline:e})};G.getPublicKeyFingerprint=function(t,e){e=e||{};var r=e.md||Y.md.sha1.create(),n=e.type||"RSAPublicKey",i;switch(n){case"RSAPublicKey":i=y.toDer(G.publicKeyToRSAPublicKey(t)).getBytes();break;case"SubjectPublicKeyInfo":i=y.toDer(G.publicKeyToAsn1(t)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+e.type+'".')}r.start(),r.update(i);var s=r.digest();if(e.encoding==="hex"){var o=s.toHex();return e.delimiter?o.match(/.{2}/g).join(e.delimiter):o}else{if(e.encoding==="binary")return s.getBytes();if(e.encoding)throw new Error('Unknown encoding "'+e.encoding+'".')}return s};G.certificationRequestFromPem=function(t,e,r){var n=Y.pem.decode(t)[0];if(n.type!=="CERTIFICATE REQUEST"){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=y.fromDer(n.body,r);return G.certificationRequestFromAsn1(s,e)};G.certificationRequestToPem=function(t,e){var r={type:"CERTIFICATE REQUEST",body:y.toDer(G.certificationRequestToAsn1(t)).getBytes()};return Y.pem.encode(r,{maxline:e})};G.createCertificate=function(){var t={};return t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return ai(t.issuer,e)},t.issuer.addField=function(e){Sr([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return ai(t.subject,e)},t.subject.addField=function(e){Sr([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null,t.setSubject=function(e,r){Sr(e),t.subject.attributes=e,delete t.subject.uniqueId,r&&(t.subject.uniqueId=r),t.subject.hash=null},t.setIssuer=function(e,r){Sr(e),t.issuer.attributes=e,delete t.issuer.uniqueId,r&&(t.issuer.uniqueId=r),t.issuer.hash=null},t.setExtensions=function(e){for(var r=0;r<e.length;++r)k_(e[r],{cert:t});t.extensions=e},t.getExtension=function(e){typeof e=="string"&&(e={name:e});for(var r=null,n,i=0;r===null&&i<t.extensions.length;++i)n=t.extensions[i],(e.id&&n.id===e.id||e.name&&n.name===e.name)&&(r=n);return r},t.sign=function(e,r){t.md=r||Y.md.sha1.create();var n=le[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.tbsCertificate=G.getTBSCertificate(t);var s=y.toDer(t.tbsCertificate);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(e){var r=!1;if(!t.issued(e)){var n=e.issuer,i=t.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=n.attributes,s.actualIssuer=i.attributes,s}var o=e.md;if(o===null){if(e.signatureOid in le){var a=le[e.signatureOid];switch(a){case"sha1WithRSAEncryption":o=Y.md.sha1.create();break;case"md5WithRSAEncryption":o=Y.md.md5.create();break;case"sha256WithRSAEncryption":o=Y.md.sha256.create();break;case"sha384WithRSAEncryption":o=Y.md.sha384.create();break;case"sha512WithRSAEncryption":o=Y.md.sha512.create();break;case"RSASSA-PSS":o=Y.md.sha256.create();break}}if(o===null){var s=new Error("Could not compute certificate digest. Unknown signature OID.");throw s.signatureOid=e.signatureOid,s}var c=e.tbsCertificate||G.getTBSCertificate(e),u=y.toDer(c);o.update(u.getBytes())}if(o!==null){var l;switch(e.signatureOid){case le.sha1WithRSAEncryption:l=void 0;break;case le["RSASSA-PSS"]:var f,h;if(f=le[e.signatureParameters.mgf.hash.algorithmOid],f===void 0||Y.md[f]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=e.signatureParameters.mgf.hash.algorithmOid,s.name=f,s}if(h=le[e.signatureParameters.mgf.algorithmOid],h===void 0||Y.mgf[h]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=e.signatureParameters.mgf.algorithmOid,s.name=h,s}if(h=Y.mgf[h].create(Y.md[f].create()),f=le[e.signatureParameters.hash.algorithmOid],f===void 0||Y.md[f]===void 0)throw{message:"Unsupported RSASSA-PSS hash function.",oid:e.signatureParameters.hash.algorithmOid,name:f};l=Y.pss.create(Y.md[f].create(),h,e.signatureParameters.saltLength);break}r=t.publicKey.verify(o.digest().getBytes(),e.signature,l)}return r},t.isIssuer=function(e){var r=!1,n=t.issuer,i=e.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){r=!0;for(var s,o,a=0;r&&a<n.attributes.length;++a)s=n.attributes[a],o=i.attributes[a],(s.type!==o.type||s.value!==o.value)&&(r=!1)}return r},t.issued=function(e){return e.isIssuer(t)},t.generateSubjectKeyIdentifier=function(){return G.getPublicKeyFingerprint(t.publicKey,{type:"RSAPublicKey"})},t.verifySubjectKeyIdentifier=function(){for(var e=le.subjectKeyIdentifier,r=0;r<t.extensions.length;++r){var n=t.extensions[r];if(n.id===e){var i=t.generateSubjectKeyIdentifier().getBytes();return Y.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},t};G.certificateFromAsn1=function(t,e){var r={},n=[];if(!y.validate(t,lL,r,n)){var i=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw i.errors=n,i}var s=y.derToOid(r.publicKeyOid);if(s!==G.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=G.createCertificate();o.version=r.certVersion?r.certVersion.charCodeAt(0):0;var a=Y.util.createBuffer(r.certSerialNumber);o.serialNumber=a.toHex(),o.signatureOid=Y.asn1.derToOid(r.certSignatureOid),o.signatureParameters=wu(o.signatureOid,r.certSignatureParams,!0),o.siginfo.algorithmOid=Y.asn1.derToOid(r.certinfoSignatureOid),o.siginfo.parameters=wu(o.siginfo.algorithmOid,r.certinfoSignatureParams,!1),o.signature=r.certSignature;var c=[];if(r.certValidity1UTCTime!==void 0&&c.push(y.utcTimeToDate(r.certValidity1UTCTime)),r.certValidity2GeneralizedTime!==void 0&&c.push(y.generalizedTimeToDate(r.certValidity2GeneralizedTime)),r.certValidity3UTCTime!==void 0&&c.push(y.utcTimeToDate(r.certValidity3UTCTime)),r.certValidity4GeneralizedTime!==void 0&&c.push(y.generalizedTimeToDate(r.certValidity4GeneralizedTime)),c.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(o.validity.notBefore=c[0],o.validity.notAfter=c[1],o.tbsCertificate=r.tbsCertificate,e){if(o.md=null,o.signatureOid in le){var s=le[o.signatureOid];switch(s){case"sha1WithRSAEncryption":o.md=Y.md.sha1.create();break;case"md5WithRSAEncryption":o.md=Y.md.md5.create();break;case"sha256WithRSAEncryption":o.md=Y.md.sha256.create();break;case"sha384WithRSAEncryption":o.md=Y.md.sha384.create();break;case"sha512WithRSAEncryption":o.md=Y.md.sha512.create();break;case"RSASSA-PSS":o.md=Y.md.sha256.create();break}}if(o.md===null){var i=new Error("Could not compute certificate digest. Unknown signature OID.");throw i.signatureOid=o.signatureOid,i}var u=y.toDer(o.tbsCertificate);o.md.update(u.getBytes())}var l=Y.md.sha1.create();o.issuer.getField=function(h){return ai(o.issuer,h)},o.issuer.addField=function(h){Sr([h]),o.issuer.attributes.push(h)},o.issuer.attributes=G.RDNAttributesAsArray(r.certIssuer,l),r.certIssuerUniqueId&&(o.issuer.uniqueId=r.certIssuerUniqueId),o.issuer.hash=l.digest().toHex();var f=Y.md.sha1.create();return o.subject.getField=function(h){return ai(o.subject,h)},o.subject.addField=function(h){Sr([h]),o.subject.attributes.push(h)},o.subject.attributes=G.RDNAttributesAsArray(r.certSubject,f),r.certSubjectUniqueId&&(o.subject.uniqueId=r.certSubjectUniqueId),o.subject.hash=f.digest().toHex(),r.certExtensions?o.extensions=G.certificateExtensionsFromAsn1(r.certExtensions):o.extensions=[],o.publicKey=G.publicKeyFromAsn1(r.subjectPublicKeyInfo),o};G.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r<t.value.length;++r)for(var n=t.value[r],i=0;i<n.value.length;++i)e.push(G.certificateExtensionFromAsn1(n.value[i]));return e};G.certificateExtensionFromAsn1=function(t){var e={};if(e.id=y.derToOid(t.value[0].value),e.critical=!1,t.value[1].type===y.Type.BOOLEAN?(e.critical=t.value[1].value.charCodeAt(0)!==0,e.value=t.value[2].value):e.value=t.value[1].value,e.id in le){if(e.name=le[e.id],e.name==="keyUsage"){var r=y.fromDer(e.value),n=0,i=0;r.value.length>1&&(n=r.value.charCodeAt(1),i=r.value.length>2?r.value.charCodeAt(2):0),e.digitalSignature=(n&128)==128,e.nonRepudiation=(n&64)==64,e.keyEncipherment=(n&32)==32,e.dataEncipherment=(n&16)==16,e.keyAgreement=(n&8)==8,e.keyCertSign=(n&4)==4,e.cRLSign=(n&2)==2,e.encipherOnly=(n&1)==1,e.decipherOnly=(i&128)==128}else if(e.name==="basicConstraints"){var r=y.fromDer(e.value);r.value.length>0&&r.value[0].type===y.Type.BOOLEAN?e.cA=r.value[0].value.charCodeAt(0)!==0:e.cA=!1;var s=null;r.value.length>0&&r.value[0].type===y.Type.INTEGER?s=r.value[0].value:r.value.length>1&&(s=r.value[1].value),s!==null&&(e.pathLenConstraint=y.derToInteger(s))}else if(e.name==="extKeyUsage")for(var r=y.fromDer(e.value),o=0;o<r.value.length;++o){var a=y.derToOid(r.value[o].value);a in le?e[le[a]]=!0:e[a]=!0}else if(e.name==="nsCertType"){var r=y.fromDer(e.value),n=0;r.value.length>1&&(n=r.value.charCodeAt(1)),e.client=(n&128)==128,e.server=(n&64)==64,e.email=(n&32)==32,e.objsign=(n&16)==16,e.reserved=(n&8)==8,e.sslCA=(n&4)==4,e.emailCA=(n&2)==2,e.objCA=(n&1)==1}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.altNames=[];for(var c,r=y.fromDer(e.value),u=0;u<r.value.length;++u){c=r.value[u];var l={type:c.type,value:c.value};switch(e.altNames.push(l),c.type){case 1:case 2:case 6:break;case 7:l.ip=Y.util.bytesToIP(c.value);break;case 8:l.oid=y.derToOid(c.value);break;default:}}}else if(e.name==="subjectKeyIdentifier"){var r=y.fromDer(e.value);e.subjectKeyIdentifier=Y.util.bytesToHex(r.value)}}return e};G.certificationRequestFromAsn1=function(t,e){var r={},n=[];if(!y.validate(t,dL,r,n)){var i=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw i.errors=n,i}var s=y.derToOid(r.publicKeyOid);if(s!==G.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=G.createCertificationRequest();if(o.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,o.signatureOid=Y.asn1.derToOid(r.csrSignatureOid),o.signatureParameters=wu(o.signatureOid,r.csrSignatureParams,!0),o.siginfo.algorithmOid=Y.asn1.derToOid(r.csrSignatureOid),o.siginfo.parameters=wu(o.siginfo.algorithmOid,r.csrSignatureParams,!1),o.signature=r.csrSignature,o.certificationRequestInfo=r.certificationRequestInfo,e){if(o.md=null,o.signatureOid in le){var s=le[o.signatureOid];switch(s){case"sha1WithRSAEncryption":o.md=Y.md.sha1.create();break;case"md5WithRSAEncryption":o.md=Y.md.md5.create();break;case"sha256WithRSAEncryption":o.md=Y.md.sha256.create();break;case"sha384WithRSAEncryption":o.md=Y.md.sha384.create();break;case"sha512WithRSAEncryption":o.md=Y.md.sha512.create();break;case"RSASSA-PSS":o.md=Y.md.sha256.create();break}}if(o.md===null){var i=new Error("Could not compute certification request digest. Unknown signature OID.");throw i.signatureOid=o.signatureOid,i}var a=y.toDer(o.certificationRequestInfo);o.md.update(a.getBytes())}var c=Y.md.sha1.create();return o.subject.getField=function(u){return ai(o.subject,u)},o.subject.addField=function(u){Sr([u]),o.subject.attributes.push(u)},o.subject.attributes=G.RDNAttributesAsArray(r.certificationRequestInfoSubject,c),o.subject.hash=c.digest().toHex(),o.publicKey=G.publicKeyFromAsn1(r.subjectPublicKeyInfo),o.getAttribute=function(u){return ai(o,u)},o.addAttribute=function(u){Sr([u]),o.attributes.push(u)},o.attributes=G.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),o};G.createCertificationRequest=function(){var t={};return t.version=0,t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.subject={},t.subject.getField=function(e){return ai(t.subject,e)},t.subject.addField=function(e){Sr([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.publicKey=null,t.attributes=[],t.getAttribute=function(e){return ai(t,e)},t.addAttribute=function(e){Sr([e]),t.attributes.push(e)},t.md=null,t.setSubject=function(e){Sr(e),t.subject.attributes=e,t.subject.hash=null},t.setAttributes=function(e){Sr(e),t.attributes=e},t.sign=function(e,r){t.md=r||Y.md.sha1.create();var n=le[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.certificationRequestInfo=G.getCertificationRequestInfo(t);var s=y.toDer(t.certificationRequestInfo);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(){var e=!1,r=t.md;if(r===null){if(t.signatureOid in le){var n=le[t.signatureOid];switch(n){case"sha1WithRSAEncryption":r=Y.md.sha1.create();break;case"md5WithRSAEncryption":r=Y.md.md5.create();break;case"sha256WithRSAEncryption":r=Y.md.sha256.create();break;case"sha384WithRSAEncryption":r=Y.md.sha384.create();break;case"sha512WithRSAEncryption":r=Y.md.sha512.create();break;case"RSASSA-PSS":r=Y.md.sha256.create();break}}if(r===null){var i=new Error("Could not compute certification request digest. Unknown signature OID.");throw i.signatureOid=t.signatureOid,i}var s=t.certificationRequestInfo||G.getCertificationRequestInfo(t),o=y.toDer(s);r.update(o.getBytes())}if(r!==null){var a;switch(t.signatureOid){case le.sha1WithRSAEncryption:break;case le["RSASSA-PSS"]:var c,u;if(c=le[t.signatureParameters.mgf.hash.algorithmOid],c===void 0||Y.md[c]===void 0){var i=new Error("Unsupported MGF hash function.");throw i.oid=t.signatureParameters.mgf.hash.algorithmOid,i.name=c,i}if(u=le[t.signatureParameters.mgf.algorithmOid],u===void 0||Y.mgf[u]===void 0){var i=new Error("Unsupported MGF function.");throw i.oid=t.signatureParameters.mgf.algorithmOid,i.name=u,i}if(u=Y.mgf[u].create(Y.md[c].create()),c=le[t.signatureParameters.hash.algorithmOid],c===void 0||Y.md[c]===void 0){var i=new Error("Unsupported RSASSA-PSS hash function.");throw i.oid=t.signatureParameters.hash.algorithmOid,i.name=c,i}a=Y.pss.create(Y.md[c].create(),u,t.signatureParameters.saltLength);break}e=t.publicKey.verify(r.digest().getBytes(),t.signature,a)}return e},t};function no(t){for(var e=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]),r,n,i=t.attributes,s=0;s<i.length;++s){r=i[s];var o=r.value,a=y.Type.PRINTABLESTRING;"valueTagClass"in r&&(a=r.valueTagClass,a===y.Type.UTF8&&(o=Y.util.encodeUtf8(o))),n=y.create(y.Class.UNIVERSAL,y.Type.SET,!0,[y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(r.type).getBytes()),y.create(y.Class.UNIVERSAL,a,!1,o)])]),e.value.push(n)}return e}function Sr(t){for(var e,r=0;r<t.length;++r){if(e=t[r],typeof e.name=="undefined"&&(e.type&&e.type in G.oids?e.name=G.oids[e.type]:e.shortName&&e.shortName in lt&&(e.name=G.oids[lt[e.shortName]])),typeof e.type=="undefined")if(e.name&&e.name in G.oids)e.type=G.oids[e.name];else{var n=new Error("Attribute type not specified.");throw n.attribute=e,n}if(typeof e.shortName=="undefined"&&e.name&&e.name in lt&&(e.shortName=lt[e.name]),e.type===le.extensionRequest&&(e.valueConstructed=!0,e.valueTagClass=y.Type.SEQUENCE,!e.value&&e.extensions)){e.value=[];for(var i=0;i<e.extensions.length;++i)e.value.push(G.certificateExtensionToAsn1(k_(e.extensions[i])))}if(typeof e.value=="undefined"){var n=new Error("Attribute value not specified.");throw n.attribute=e,n}}}function k_(t,e){if(e=e||{},typeof t.name=="undefined"&&t.id&&t.id in G.oids&&(t.name=G.oids[t.id]),typeof t.id=="undefined")if(t.name&&t.name in G.oids)t.id=G.oids[t.name];else{var r=new Error("Extension ID not specified.");throw r.extension=t,r}if(typeof t.value!="undefined")return t;if(t.name==="keyUsage"){var n=0,i=0,s=0;t.digitalSignature&&(i|=128,n=7),t.nonRepudiation&&(i|=64,n=6),t.keyEncipherment&&(i|=32,n=5),t.dataEncipherment&&(i|=16,n=4),t.keyAgreement&&(i|=8,n=3),t.keyCertSign&&(i|=4,n=2),t.cRLSign&&(i|=2,n=1),t.encipherOnly&&(i|=1,n=0),t.decipherOnly&&(s|=128,n=7);var o=String.fromCharCode(n);s!==0?o+=String.fromCharCode(i)+String.fromCharCode(s):i!==0&&(o+=String.fromCharCode(i)),t.value=y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,o)}else if(t.name==="basicConstraints")t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]),t.cA&&t.value.value.push(y.create(y.Class.UNIVERSAL,y.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in t&&t.value.value.push(y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(t.pathLenConstraint).getBytes()));else if(t.name==="extKeyUsage"){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);var a=t.value.value;for(var c in t)t[c]===!0&&(c in le?a.push(y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(le[c]).getBytes())):c.indexOf(".")!==-1&&a.push(y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(c).getBytes())))}else if(t.name==="nsCertType"){var n=0,i=0;t.client&&(i|=128,n=7),t.server&&(i|=64,n=6),t.email&&(i|=32,n=5),t.objsign&&(i|=16,n=4),t.reserved&&(i|=8,n=3),t.sslCA&&(i|=4,n=2),t.emailCA&&(i|=2,n=1),t.objCA&&(i|=1,n=0);var o=String.fromCharCode(n);i!==0&&(o+=String.fromCharCode(i)),t.value=y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,o)}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);for(var u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=Y.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=y.oidToDer(y.oidToDer(u.oid)):o=y.oidToDer(o));t.value.value.push(y.create(y.Class.CONTEXT_SPECIFIC,u.type,!1,o))}}else if(t.name==="nsComment"&&e.cert){if(!/^[\x00-\x7F]*$/.test(t.comment)||t.comment.length<1||t.comment.length>128)throw new Error('Invalid "nsComment" content.');t.value=y.create(y.Class.UNIVERSAL,y.Type.IA5STRING,!1,t.comment)}else if(t.name==="subjectKeyIdentifier"&&e.cert){var f=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=f.toHex(),t.value=y.create(y.Class.UNIVERSAL,y.Type.OCTETSTRING,!1,f.getBytes())}else if(t.name==="authorityKeyIdentifier"&&e.cert){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);var a=t.value.value;if(t.keyIdentifier){var h=t.keyIdentifier===!0?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;a.push(y.create(y.Class.CONTEXT_SPECIFIC,0,!1,h))}if(t.authorityCertIssuer){var p=[y.create(y.Class.CONTEXT_SPECIFIC,4,!0,[no(t.authorityCertIssuer===!0?e.cert.issuer:t.authorityCertIssuer)])];a.push(y.create(y.Class.CONTEXT_SPECIFIC,1,!0,p))}if(t.serialNumber){var d=Y.util.hexToBytes(t.serialNumber===!0?e.cert.serialNumber:t.serialNumber);a.push(y.create(y.Class.CONTEXT_SPECIFIC,2,!1,d))}}else if(t.name==="cRLDistributionPoints"){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);for(var a=t.value.value,g=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]),m=y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[]),u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=Y.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=y.oidToDer(y.oidToDer(u.oid)):o=y.oidToDer(o));m.value.push(y.create(y.Class.CONTEXT_SPECIFIC,u.type,!1,o))}g.value.push(y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[m])),a.push(g)}if(typeof t.value=="undefined"){var r=new Error("Extension value not specified.");throw r.extension=t,r}return t}function fd(t,e){switch(t){case le["RSASSA-PSS"]:var r=[];return e.hash.algorithmOid!==void 0&&r.push(y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(e.hash.algorithmOid).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.NULL,!1,"")])])),e.mgf.algorithmOid!==void 0&&r.push(y.create(y.Class.CONTEXT_SPECIFIC,1,!0,[y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(e.mgf.algorithmOid).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(e.mgf.hash.algorithmOid).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.NULL,!1,"")])])])),e.saltLength!==void 0&&r.push(y.create(y.Class.CONTEXT_SPECIFIC,2,!0,[y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(e.saltLength).getBytes())])),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,r);default:return y.create(y.Class.UNIVERSAL,y.Type.NULL,!1,"")}}function pL(t){var e=y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[]);if(t.attributes.length===0)return e;for(var r=t.attributes,n=0;n<r.length;++n){var i=r[n],s=i.value,o=y.Type.UTF8;"valueTagClass"in i&&(o=i.valueTagClass),o===y.Type.UTF8&&(s=Y.util.encodeUtf8(s));var a=!1;"valueConstructed"in i&&(a=i.valueConstructed);var c=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(i.type).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.SET,!0,[y.create(y.Class.UNIVERSAL,o,a,s)])]);e.value.push(c)}return e}var yL=new Date("1950-01-01T00:00:00Z"),gL=new Date("2050-01-01T00:00:00Z");function q_(t){return t>=yL&&t<gL?y.create(y.Class.UNIVERSAL,y.Type.UTCTIME,!1,y.dateToUtcTime(t)):y.create(y.Class.UNIVERSAL,y.Type.GENERALIZEDTIME,!1,y.dateToGeneralizedTime(t))}G.getTBSCertificate=function(t){var e=q_(t.validity.notBefore),r=q_(t.validity.notAfter),n=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(t.version).getBytes())]),y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,Y.util.hexToBytes(t.serialNumber)),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.siginfo.algorithmOid).getBytes()),fd(t.siginfo.algorithmOid,t.siginfo.parameters)]),no(t.issuer),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[e,r]),no(t.subject),G.publicKeyToAsn1(t.publicKey)]);return t.issuer.uniqueId&&n.value.push(y.create(y.Class.CONTEXT_SPECIFIC,1,!0,[y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.issuer.uniqueId)])),t.subject.uniqueId&&n.value.push(y.create(y.Class.CONTEXT_SPECIFIC,2,!0,[y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.subject.uniqueId)])),t.extensions.length>0&&n.value.push(G.certificateExtensionsToAsn1(t.extensions)),n};G.getCertificationRequestInfo=function(t){var e=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(t.version).getBytes()),no(t.subject),G.publicKeyToAsn1(t.publicKey),pL(t)]);return e};G.distinguishedNameToAsn1=function(t){return no(t)};G.certificateToAsn1=function(t){var e=t.tbsCertificate||G.getTBSCertificate(t);return y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[e,y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.signatureOid).getBytes()),fd(t.signatureOid,t.signatureParameters)]),y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};G.certificateExtensionsToAsn1=function(t){var e=y.create(y.Class.CONTEXT_SPECIFIC,3,!0,[]),r=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);e.value.push(r);for(var n=0;n<t.length;++n)r.value.push(G.certificateExtensionToAsn1(t[n]));return e};G.certificateExtensionToAsn1=function(t){var e=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);e.value.push(y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.id).getBytes())),t.critical&&e.value.push(y.create(y.Class.UNIVERSAL,y.Type.BOOLEAN,!1,String.fromCharCode(255)));var r=t.value;return typeof t.value!="string"&&(r=y.toDer(r).getBytes()),e.value.push(y.create(y.Class.UNIVERSAL,y.Type.OCTETSTRING,!1,r)),e};G.certificationRequestToAsn1=function(t){var e=t.certificationRequestInfo||G.getCertificationRequestInfo(t);return y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[e,y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.signatureOid).getBytes()),fd(t.signatureOid,t.signatureParameters)]),y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};G.createCaStore=function(t){var e={certs:{}};e.getIssuer=function(o){var a=r(o.issuer);return a},e.addCertificate=function(o){if(typeof o=="string"&&(o=Y.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))if(o.subject.hash in e.certs){var a=e.certs[o.subject.hash];Y.util.isArray(a)||(a=[a]),a.push(o),e.certs[o.subject.hash]=a}else e.certs[o.subject.hash]=o},e.hasCertificate=function(o){typeof o=="string"&&(o=Y.pki.certificateFromPem(o));var a=r(o.subject);if(!a)return!1;Y.util.isArray(a)||(a=[a]);for(var c=y.toDer(G.certificateToAsn1(o)).getBytes(),u=0;u<a.length;++u){var l=y.toDer(G.certificateToAsn1(a[u])).getBytes();if(c===l)return!0}return!1},e.listAllCertificates=function(){var o=[];for(var a in e.certs)if(e.certs.hasOwnProperty(a)){var c=e.certs[a];if(!Y.util.isArray(c))o.push(c);else for(var u=0;u<c.length;++u)o.push(c[u])}return o},e.removeCertificate=function(o){var a;if(typeof o=="string"&&(o=Y.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))return null;var c=r(o.subject);if(!Y.util.isArray(c))return a=e.certs[o.subject.hash],delete e.certs[o.subject.hash],a;for(var u=y.toDer(G.certificateToAsn1(o)).getBytes(),l=0;l<c.length;++l){var f=y.toDer(G.certificateToAsn1(c[l])).getBytes();u===f&&(a=c[l],c.splice(l,1))}return c.length===0&&delete e.certs[o.subject.hash],a};function r(o){return n(o),e.certs[o.hash]||null}function n(o){if(!o.hash){var a=Y.md.sha1.create();o.attributes=G.RDNAttributesAsArray(no(o),a),o.hash=a.digest().toHex()}}if(t)for(var i=0;i<t.length;++i){var s=t[i];e.addCertificate(s)}return e};G.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};G.verifyCertificateChain=function(t,e,r){typeof r=="function"&&(r={verify:r}),r=r||{},e=e.slice(0);var n=e.slice(0),i=r.validityCheckDate;typeof i=="undefined"&&(i=new Date);var s=!0,o=null,a=0;do{var c=e.shift(),u=null,l=!1;if(i&&(i<c.validity.notBefore||i>c.validity.notAfter)&&(o={message:"Certificate is not valid yet or has expired.",error:G.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:i}),o===null){if(u=e[0]||t.getIssuer(c),u===null&&c.isIssuer(c)&&(l=!0,u=c),u){var f=u;Y.util.isArray(f)||(f=[f]);for(var h=!1;!h&&f.length>0;){u=f.shift();try{h=u.verify(c)}catch(U){}}h||(o={message:"Certificate signature is invalid.",error:G.certificateError.bad_certificate})}o===null&&(!u||l)&&!t.hasCertificate(c)&&(o={message:"Certificate is not trusted.",error:G.certificateError.unknown_ca})}if(o===null&&u&&!c.isIssuer(u)&&(o={message:"Certificate issuer is invalid.",error:G.certificateError.bad_certificate}),o===null)for(var p={keyUsage:!0,basicConstraints:!0},d=0;o===null&&d<c.extensions.length;++d){var g=c.extensions[d];g.critical&&!(g.name in p)&&(o={message:"Certificate has an unsupported critical extension.",error:G.certificateError.unsupported_certificate})}if(o===null&&(!s||e.length===0&&(!u||l))){var m=c.getExtension("basicConstraints"),x=c.getExtension("keyUsage");if(x!==null&&(!x.keyCertSign||m===null)&&(o={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:G.certificateError.bad_certificate}),o===null&&m!==null&&!m.cA&&(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:G.certificateError.bad_certificate}),o===null&&x!==null&&"pathLenConstraint"in m){var B=a-1;B>m.pathLenConstraint&&(o={message:"Certificate basicConstraints pathLenConstraint violated.",error:G.certificateError.bad_certificate})}}var L=o===null?!0:o.error,H=r.verify?r.verify(L,a,n):L;if(H===!0)o=null;else throw L===!0&&(o={message:"The application rejected the certificate.",error:G.certificateError.bad_certificate}),(H||H===0)&&(typeof H=="object"&&!Y.util.isArray(H)?(H.message&&(o.message=H.message),H.error&&(o.error=H.error)):typeof H=="string"&&(o.error=H)),o;s=!1,++a}while(e.length>0);return!0}});var K_=w((XF,F_)=>{var Q=Ee();_s();Un();oc();bs();lc();T_();xi();je();hd();var T=Q.asn1,zt=F_.exports=Q.pkcs7=Q.pkcs7||{};zt.messageFromPem=function(t){var e=Q.pem.decode(t)[0];if(e.type!=="PKCS7"){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=T.fromDer(e.body);return zt.messageFromAsn1(n)};zt.messageToPem=function(t,e){var r={type:"PKCS7",body:T.toDer(t.toAsn1()).getBytes()};return Q.pem.encode(r,{maxline:e})};zt.messageFromAsn1=function(t){var e={},r=[];if(!T.validate(t,zt.asn1.contentInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var i=T.derToOid(e.contentType),s;switch(i){case Q.pki.oids.envelopedData:s=zt.createEnvelopedData();break;case Q.pki.oids.encryptedData:s=zt.createEncryptedData();break;case Q.pki.oids.signedData:s=zt.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+i+" is not (yet) supported.")}return s.fromAsn1(e.content.value[0]),s};zt.createSignedData=function(){var t=null;return t={type:Q.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(pd(t,n,zt.asn1.signedDataValidator),t.certificates=[],t.crls=[],t.digestAlgorithmIdentifiers=[],t.contentInfo=null,t.signerInfos=[],t.rawCapture.certificates)for(var i=t.rawCapture.certificates.value,s=0;s<i.length;++s)t.certificates.push(Q.pki.certificateFromAsn1(i[s]))},toAsn1:function(){t.contentInfo||t.sign();for(var n=[],i=0;i<t.certificates.length;++i)n.push(Q.pki.certificateToAsn1(t.certificates[i]));var s=[],o=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,t.digestAlgorithmIdentifiers),t.contentInfo])]);return n.length>0&&o.value[0].value.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&o.value[0].value.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(T.create(T.Class.UNIVERSAL,T.Type.SET,!0,t.signerInfos)),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.type).getBytes()),o])},addSigner:function(n){var i=n.issuer,s=n.serialNumber;if(n.certificate){var o=n.certificate;typeof o=="string"&&(o=Q.pki.certificateFromPem(o)),i=o.issuer.attributes,s=o.serialNumber}var a=n.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof a=="string"&&(a=Q.pki.privateKeyFromPem(a));var c=n.digestAlgorithm||Q.pki.oids.sha1;switch(c){case Q.pki.oids.sha1:case Q.pki.oids.sha256:case Q.pki.oids.sha384:case Q.pki.oids.sha512:case Q.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+c)}var u=n.authenticatedAttributes||[];if(u.length>0){for(var l=!1,f=!1,h=0;h<u.length;++h){var p=u[h];if(!l&&p.type===Q.pki.oids.contentType){if(l=!0,f)break;continue}if(!f&&p.type===Q.pki.oids.messageDigest){if(f=!0,l)break;continue}}if(!l||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}t.signers.push({key:a,version:1,issuer:i,serialNumber:s,digestAlgorithm:c,signatureAlgorithm:Q.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:u,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof t.content!="object"||t.contentInfo===null)&&(t.contentInfo=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(Q.pki.oids.data).getBytes())]),"content"in t)){var i;t.content instanceof Q.util.ByteBuffer?i=t.content.bytes():typeof t.content=="string"&&(i=Q.util.encodeUtf8(t.content)),n.detached?t.detachedContent=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,i):t.contentInfo.value.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,i)]))}if(t.signers.length!==0){var s=e();r(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(n){typeof n=="string"&&(n=Q.pki.certificateFromPem(n)),t.certificates.push(n)},addCertificateRevokationList:function(n){throw new Error("PKCS#7 CRL support not yet implemented.")}},t;function e(){for(var n={},i=0;i<t.signers.length;++i){var s=t.signers[i],o=s.digestAlgorithm;o in n||(n[o]=Q.md[Q.pki.oids[o]].create()),s.authenticatedAttributes.length===0?s.md=n[o]:s.md=Q.md[Q.pki.oids[o]].create()}t.digestAlgorithmIdentifiers=[];for(var o in n)t.digestAlgorithmIdentifiers.push(T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(o).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]));return n}function r(n){var i;if(t.detachedContent?i=t.detachedContent:(i=t.contentInfo.value[1],i=i.value[0]),!i)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=T.derToOid(t.contentInfo.value[0].value),o=T.toDer(i);o.getByte(),T.getBerValueLength(o),o=o.getBytes();for(var a in n)n[a].start().update(o);for(var c=new Date,u=0;u<t.signers.length;++u){var l=t.signers[u];if(l.authenticatedAttributes.length===0){if(s!==Q.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{l.authenticatedAttributesAsn1=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[]),h=0;h<l.authenticatedAttributes.length;++h){var p=l.authenticatedAttributes[h];p.type===Q.pki.oids.messageDigest?p.value=n[l.digestAlgorithm].digest():p.type===Q.pki.oids.signingTime&&(p.value||(p.value=c)),f.value.push(dd(p)),l.authenticatedAttributesAsn1.value.push(dd(p))}o=T.toDer(f).getBytes(),l.md.start().update(o)}l.signature=l.key.sign(l.md,"RSASSA-PKCS1-V1_5")}t.signerInfos=_L(t.signers)}};zt.createEncryptedData=function(){var t=null;return t={type:Q.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:Q.pki.oids["aes256-CBC"]},fromAsn1:function(e){pd(t,e,zt.asn1.encryptedDataValidator)},decrypt:function(e){e!==void 0&&(t.encryptedContent.key=e),M_(t)}},t};zt.createEnvelopedData=function(){var t=null;return t={type:Q.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:Q.pki.oids["aes256-CBC"]},fromAsn1:function(e){var r=pd(t,e,zt.asn1.envelopedDataValidator);t.recipients=bL(r.recipientInfos.value)},toAsn1:function(){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.type).getBytes()),T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,EL(t.recipients)),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,xL(t.encryptedContent))])])])},findRecipient:function(e){for(var r=e.issuer.attributes,n=0;n<t.recipients.length;++n){var i=t.recipients[n],s=i.issuer;if(i.serialNumber===e.serialNumber&&s.length===r.length){for(var o=!0,a=0;a<r.length;++a)if(s[a].type!==r[a].type||s[a].value!==r[a].value){o=!1;break}if(o)return i}}return null},decrypt:function(e,r){if(t.encryptedContent.key===void 0&&e!==void 0&&r!==void 0)switch(e.encryptedContent.algorithm){case Q.pki.oids.rsaEncryption:case Q.pki.oids.desCBC:var n=r.decrypt(e.encryptedContent.content);t.encryptedContent.key=Q.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+e.encryptedContent.algorithm)}M_(t)},addRecipient:function(e){t.recipients.push({version:0,issuer:e.issuer.attributes,serialNumber:e.serialNumber,encryptedContent:{algorithm:Q.pki.oids.rsaEncryption,key:e.publicKey}})},encrypt:function(e,r){if(t.encryptedContent.content===void 0){r=r||t.encryptedContent.algorithm,e=e||t.encryptedContent.key;var n,i,s;switch(r){case Q.pki.oids["aes128-CBC"]:n=16,i=16,s=Q.aes.createEncryptionCipher;break;case Q.pki.oids["aes192-CBC"]:n=24,i=16,s=Q.aes.createEncryptionCipher;break;case Q.pki.oids["aes256-CBC"]:n=32,i=16,s=Q.aes.createEncryptionCipher;break;case Q.pki.oids["des-EDE3-CBC"]:n=24,i=8,s=Q.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(e===void 0)e=Q.util.createBuffer(Q.random.getBytes(n));else if(e.length()!=n)throw new Error("Symmetric key has wrong length; got "+e.length()+" bytes, expected "+n+".");t.encryptedContent.algorithm=r,t.encryptedContent.key=e,t.encryptedContent.parameter=Q.util.createBuffer(Q.random.getBytes(i));var o=s(e);if(o.start(t.encryptedContent.parameter.copy()),o.update(t.content),!o.finish())throw new Error("Symmetric encryption failed.");t.encryptedContent.content=o.output}for(var a=0;a<t.recipients.length;++a){var c=t.recipients[a];if(c.encryptedContent.content===void 0)switch(c.encryptedContent.algorithm){case Q.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(t.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}},t};function mL(t){var e={},r=[];if(!T.validate(t,zt.asn1.recipientInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:e.version.charCodeAt(0),issuer:Q.pki.RDNAttributesAsArray(e.issuer),serialNumber:Q.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:T.derToOid(e.encAlgorithm),parameter:e.encParameter.value,content:e.encKey}}}function vL(t){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[Q.pki.distinguishedNameToAsn1({attributes:t.issuer}),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,Q.util.hexToBytes(t.serialNumber))]),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.encryptedContent.algorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.encryptedContent.content)])}function bL(t){for(var e=[],r=0;r<t.length;++r)e.push(mL(t[r]));return e}function EL(t){for(var e=[],r=0;r<t.length;++r)e.push(vL(t[r]));return e}function wL(t){var e=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[Q.pki.distinguishedNameToAsn1({attributes:t.issuer}),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,Q.util.hexToBytes(t.serialNumber))]),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.digestAlgorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])]);if(t.authenticatedAttributesAsn1&&e.value.push(t.authenticatedAttributesAsn1),e.value.push(T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.signatureAlgorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])),e.value.push(T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.signature)),t.unauthenticatedAttributes.length>0){for(var r=T.create(T.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<t.unauthenticatedAttributes.length;++n){var i=t.unauthenticatedAttributes[n];r.values.push(dd(i))}e.value.push(r)}return e}function _L(t){for(var e=[],r=0;r<t.length;++r)e.push(wL(t[r]));return e}function dd(t){var e;if(t.type===Q.pki.oids.contentType)e=T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.value).getBytes());else if(t.type===Q.pki.oids.messageDigest)e=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.value.bytes());else if(t.type===Q.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=t.value;if(typeof i=="string"){var s=Date.parse(i);isNaN(s)?i.length===13?i=T.utcTimeToDate(i):i=T.generalizedTimeToDate(i):i=new Date(s)}i>=r&&i<n?e=T.create(T.Class.UNIVERSAL,T.Type.UTCTIME,!1,T.dateToUtcTime(i)):e=T.create(T.Class.UNIVERSAL,T.Type.GENERALIZEDTIME,!1,T.dateToGeneralizedTime(i))}return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.type).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[e])])}function xL(t){return[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(Q.pki.oids.data).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.algorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.parameter.getBytes())]),T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.content.getBytes())])]}function pd(t,e,r){var n={},i=[];if(!T.validate(e,r,n,i)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var o=T.derToOid(n.contentType);if(o!==Q.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(Q.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==T.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[c].value}else a=n.encryptedContent;t.encryptedContent={algorithm:T.derToOid(n.encAlgorithm),parameter:Q.util.createBuffer(n.encParameter.value),content:Q.util.createBuffer(a)}}if(n.content){var a="";if(Q.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==T.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[c].value}else a=n.content;t.content=Q.util.createBuffer(a)}return t.version=n.version.charCodeAt(0),t.rawCapture=n,n}function M_(t){if(t.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(t.content===void 0){var e;switch(t.encryptedContent.algorithm){case Q.pki.oids["aes128-CBC"]:case Q.pki.oids["aes192-CBC"]:case Q.pki.oids["aes256-CBC"]:e=Q.aes.createDecryptionCipher(t.encryptedContent.key);break;case Q.pki.oids.desCBC:case Q.pki.oids["des-EDE3-CBC"]:e=Q.des.createDecryptionCipher(t.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+t.encryptedContent.algorithm)}if(e.start(t.encryptedContent.parameter),e.update(t.encryptedContent.content),!e.finish())throw new Error("Symmetric decryption failed.");t.content=e.output}}});var $_=w((ZF,j_)=>{"use strict";hd();var SL=Ee(),V_=SL.pki,AL=(t,e)=>{let r=V_.setRsaPublicKey(e.n,e.e),n=V_.createCertificate();n.publicKey=r,n.serialNumber="01",n.validity.notBefore=new Date,n.validity.notAfter=new Date,n.validity.notAfter.setFullYear(n.validity.notBefore.getFullYear()+10);let i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:t.id}];return n.setSubject(i),n.setIssuer(i),n.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}]),n.sign(e),n};async function CL(t,e){let r=t.map(e),i=(await Promise.all(r)).findIndex(s=>s);return t[i]}j_.exports={certificateForKey:AL,findAsync:CL}});var W_=w((JF,G_)=>{"use strict";K_();Ml();var ci=Ee(),{certificateForKey:IL,findAsync:TL}=$_(),io=pe(),{fromString:H_}=(Ct(),Pt),{toString:RL}=(It(),Nt),{codes:so}=He(),yd=new WeakMap,z_=class{constructor(e,r){if(!e)throw io(new Error("keychain is required"),so.ERR_KEYCHAIN_REQUIRED);this.keychain=e,yd.set(this,{dek:r})}async encrypt(e,r){if(!(r instanceof Uint8Array))throw io(new Error("Plain data must be a Uint8Array"),so.ERR_INVALID_PARAMETERS);let n=await this.keychain.findKeyByName(e),i=await this.keychain._getPrivateKey(e),s=yd.get(this).dek,o=ci.pki.decryptRsaPrivateKey(i,s),a=await IL(n,o),c=ci.pkcs7.createEnvelopedData();c.addRecipient(a),c.content=ci.util.createBuffer(r),c.encrypt();let u=ci.asn1.toDer(c.toAsn1()).getBytes();return H_(u,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw io(new Error("CMS data is required"),so.ERR_INVALID_PARAMETERS);let r;try{let u=ci.util.createBuffer(RL(e,"ascii")),l=ci.asn1.fromDer(u);r=ci.pkcs7.messageFromAsn1(l)}catch(u){throw io(new Error("Invalid CMS: "+u.message),so.ERR_INVALID_CMS)}let n=r.recipients.filter(u=>u.issuer.find(l=>l.shortName==="O"&&l.value==="ipfs")).filter(u=>u.issuer.find(l=>l.shortName==="CN")).map(u=>({recipient:u,keyId:u.issuer.find(l=>l.shortName==="CN").value})),i=await TL(n,async u=>{try{if(await this.keychain.findKeyById(u.keyId))return!0}catch(l){return!1}return!1});if(!i){let u=n.map(l=>l.keyId);throw io(new Error("Decryption needs one of the key(s): "+u.join(", ")),so.ERR_MISSING_KEYS,{missingKeys:u})}let s=await this.keychain.findKeyById(i.keyId);if(!s)throw io(new Error("No key available to decrypto"),so.ERR_NO_KEY);let o=await this.keychain._getPrivateKey(s.name),a=yd.get(this).dek,c=ci.pki.decryptRsaPrivateKey(o,a);return r.decrypt(i.recipient,c),H_(r.content.getBytes(),"ascii")}};G_.exports=z_});var tx=w((eK,ex)=>{"use strict";var Y_=Be(),Q_=Object.assign(Y_("libp2p:keychain"),{error:Y_("libp2p:keychain:err")}),BL=h_(),PL=Us(),Xi=bu(),{Key:X_}=(jc(),Wf),NL=W_(),et=pe(),{codes:tt}=He(),{toString:Zi}=(It(),Nt),{fromString:An}=(Ct(),Pt);ef();var OL="/pkcs8/",Z_="/info/",ui=new WeakMap,Ji={minKeyLength:112/8,minSaltLength:128/8,minIterationCount:1e3},gd={dek:{keyLength:512/8,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function Cn(t){return!t||typeof t!="string"?!1:t===BL(t.trim())}async function Le(t){let e=200,r=1e3,n=Math.random()*(r-e)+e;throw await new Promise(i=>setTimeout(i,n)),t}function cn(t){return new X_(OL+t)}function li(t){return new X_(Z_+t)}var J_=class{constructor(e,r){if(!e)throw new Error("store is required");if(this.store=e,this.opts=PL(gd,r),this.opts.pass&&this.opts.pass.length<20)throw new Error("pass must be least 20 characters");if(this.opts.dek.keyLength<Ji.minKeyLength)throw new Error(`dek.keyLength must be least ${Ji.minKeyLength} bytes`);if(this.opts.dek.salt.length<Ji.minSaltLength)throw new Error(`dek.saltLength must be least ${Ji.minSaltLength} bytes`);if(this.opts.dek.iterationCount<Ji.minIterationCount)throw new Error(`dek.iterationCount must be least ${Ji.minIterationCount}`);let n=this.opts.pass?Xi.pbkdf2(this.opts.pass,this.opts.dek.salt,this.opts.dek.iterationCount,this.opts.dek.keyLength,this.opts.dek.hash):"";ui.set(this,{dek:n})}get cms(){return new NL(this,ui.get(this).dek)}static generateOptions(){let e=Object.assign({},gd),r=Math.ceil(Ji.minSaltLength/3)*3;return e.dek.salt=Zi(Xi.randomBytes(r),"base64"),e}static get options(){return gd}async createKey(e,r,n=2048){let i=this;if(!Cn(e)||e==="self")return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(typeof r!="string")return Le(et(new Error(`Invalid key type '${r}'`),tt.ERR_INVALID_KEY_TYPE));let s=cn(e);if(await i.store.has(s))return Le(et(new Error(`Key '${e}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));switch(r.toLowerCase()){case"rsa":if(!Number.isSafeInteger(n)||n<2048)return Le(et(new Error(`Invalid RSA key size ${n}`),tt.ERR_INVALID_KEY_SIZE));break;default:break}let a;try{let c=await Xi.keys.generateKeyPair(r,n),u=await c.id(),l=ui.get(this).dek,f=await c.export(l);a={name:e,id:u};let h=i.store.batch();h.put(s,An(f)),h.put(li(e),An(JSON.stringify(a))),await h.commit()}catch(c){return Le(c)}return a}async listKeys(){let e=this,r={prefix:Z_},n=[];for await(let i of e.store.query(r))n.push(JSON.parse(Zi(i.value)));return n}async findKeyById(e){try{return(await this.listKeys()).find(n=>n.id===e)}catch(r){return Le(r)}}async findKeyByName(e){if(!Cn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));let r=li(e);try{let n=await this.store.get(r);return JSON.parse(Zi(n))}catch(n){return Le(et(new Error(`Key '${e}' does not exist. ${n.message}`),tt.ERR_KEY_NOT_FOUND))}}async removeKey(e){let r=this;if(!Cn(e)||e==="self")return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));let n=cn(e),i=await r.findKeyByName(e),s=r.store.batch();return s.delete(n),s.delete(li(e)),await s.commit(),i}async renameKey(e,r){let n=this;if(!Cn(e)||e==="self")return Le(et(new Error(`Invalid old key name '${e}'`),tt.ERR_OLD_KEY_NAME_INVALID));if(!Cn(r)||r==="self")return Le(et(new Error(`Invalid new key name '${r}'`),tt.ERR_NEW_KEY_NAME_INVALID));let i=cn(e),s=cn(r),o=li(e),a=li(r);if(await n.store.has(s))return Le(et(new Error(`Key '${r}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));try{let u=await n.store.get(i),l=await n.store.get(o),f=JSON.parse(Zi(l));f.name=r;let h=n.store.batch();return h.put(s,u),h.put(a,An(JSON.stringify(f))),h.delete(i),h.delete(o),await h.commit(),f}catch(u){return Le(u)}}async exportKey(e,r){if(!Cn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(!r)return Le(et(new Error("Password is required"),tt.ERR_PASSWORD_REQUIRED));let n=cn(e);try{let i=await this.store.get(n),s=Zi(i),o=ui.get(this).dek;return(await Xi.keys.import(s,o)).export(r)}catch(i){return Le(i)}}async importKey(e,r,n){let i=this;if(!Cn(e)||e==="self")return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(!r)return Le(et(new Error("PEM encoded key is required"),tt.ERR_PEM_REQUIRED));let s=cn(e);if(await i.store.has(s))return Le(et(new Error(`Key '${e}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));let a;try{a=await Xi.keys.import(r,n)}catch(f){return Le(et(new Error("Cannot read the key, most likely the password is wrong"),tt.ERR_CANNOT_READ_KEY))}let c;try{c=await a.id();let f=ui.get(this).dek;r=await a.export(f)}catch(f){return Le(f)}let u={name:e,id:c},l=i.store.batch();return l.put(s,An(r)),l.put(li(e),An(JSON.stringify(u))),await l.commit(),u}async importPeer(e,r){let n=this;if(!Cn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(!r||!r.privKey)return Le(et(new Error("Peer.privKey is required"),tt.ERR_MISSING_PRIVATE_KEY));let i=r.privKey,s=cn(e);if(await n.store.has(s))return Le(et(new Error(`Key '${e}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));try{let a=await i.id(),c=ui.get(this).dek,u=await i.export(c),l={name:e,id:a},f=n.store.batch();return f.put(s,An(u)),f.put(li(e),An(JSON.stringify(l))),await f.commit(),l}catch(a){return Le(a)}}async _getPrivateKey(e){if(!Cn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));try{let r=cn(e),n=await this.store.get(r);return Zi(n)}catch(r){return Le(et(new Error(`Key '${e}' does not exist. ${r.message}`),tt.ERR_KEY_NOT_FOUND))}}async rotateKeychainPass(e,r){if(typeof e!="string")return Le(et(new Error(`Invalid old pass type '${typeof e}'`),tt.ERR_INVALID_OLD_PASS_TYPE));if(typeof r!="string")return Le(et(new Error(`Invalid new pass type '${typeof r}'`),tt.ERR_INVALID_NEW_PASS_TYPE));if(r.length<20)return Le(et(new Error(`Invalid pass length ${r.length}`),tt.ERR_INVALID_PASS_LENGTH));Q_("recreating keychain");let n=ui.get(this).dek;this.opts.pass=r;let i=r?Xi.pbkdf2(r,this.opts.dek.salt,this.opts.dek.iterationCount,this.opts.dek.keyLength,this.opts.dek.hash):"";ui.set(this,{dek:i});let s=await this.listKeys();for(let o of s){let a=await this.store.get(cn(o.name)),c=Zi(a),u=await Xi.keys.import(c,n),l=i.toString(),f=await u.export(l),h=this.store.batch(),p={name:o.name,id:o.id};h.put(cn(o.name),An(f)),h.put(li(o.name),An(JSON.stringify(p))),await h.commit()}Q_("keychain reconstructed")}};ex.exports=J_});var xu=w((_u,rx)=>{(function(t,e){typeof _u=="object"&&typeof rx!="undefined"?e(_u):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.streamingIterables={}))})(_u,function(t){"use strict";async function*e(b,v){let _=[];for await(let C of v)_.push(C),_.length===b&&(yield _,_=[]);_.length>0&&(yield _)}function*r(b,v){let _=[];for(let C of v)_.push(C),_.length===b&&(yield _,_=[]);_.length>0&&(yield _)}function n(b,v){return v===void 0?_=>n(b,_):v[Symbol.asyncIterator]?e(b,v):r(b,v)}function i(b){if(typeof b.next=="function")return b;if(typeof b[Symbol.iterator]=="function")return b[Symbol.iterator]();if(typeof b[Symbol.asyncIterator]=="function")return b[Symbol.asyncIterator]();throw new TypeError('"values" does not to conform to any of the iterator or iterable protocols')}function s(){let b,v;return{promise:new Promise((C,A)=>{v=C,b=A}),reject:b,resolve:v}}function o(b,v){let _=i(v),C=[],A=[],P=!1,N=!1;function O(){for(;A.length>0&&C.length>0;){let ee=A.shift(),{error:fe,value:ke}=C.shift();fe?ee.reject(fe):ee.resolve({done:!1,value:ke})}for(;A.length>0&&N;){let{resolve:ee}=A.shift();ee({done:!0,value:void 0})}}async function k(){if(!N&&!P&&!(C.length>=b)){P=!0;try{let{done:ee,value:fe}=await _.next();ee?N=!0:C.push({value:fe})}catch(ee){N=!0,C.push({error:ee})}O(),P=!1,k()}}async function W(){if(C.length>0){let{error:fe,value:ke}=C.shift();if(fe)throw fe;return k(),{done:!1,value:ke}}if(N)return{done:!0,value:void 0};let ee=s();return A.push(ee),k(),ee.promise}let X={next:W,[Symbol.asyncIterator]:()=>X};return X}function*a(b,v){let _=[],C;try{for(let A of v)_.push(A),!(_.length<=b)&&(yield _.shift())}catch(A){C=A}for(let A of _)yield A;if(C)throw C}function c(b,v){return v===void 0?_=>c(b,_):b===0?v:v[Symbol.asyncIterator]?o(b,v):a(b,v)}async function u(b){let v=[];for await(let _ of b)v.push(_);return v}function l(b){return b[Symbol.asyncIterator]?u(b):Array.from(b)}async function*f(b){for await(let v of b)yield*v}function*h(b){for(let v of b)yield*v}function p(...b){return b.find(_=>_[Symbol.asyncIterator]!==void 0)?f(b):h(b)}async function d(b){for await(let v of b);}function g(b){if(b[Symbol.asyncIterator])return d(b);for(let v of b);}async function*m(b,v){for await(let _ of v)await b(_)&&(yield _)}function x(b,v){return v===void 0?_=>m(b,_):m(b,v)}async function*B(b){for await(let v of b)v&&typeof v!="string"&&(v[Symbol.iterator]||v[Symbol.asyncIterator])?yield*B(v):yield v}async function*L(b,v){for await(let _ of v)yield await b(_)}function H(b,v){return v===void 0?_=>L(b,_):L(b,v)}function U(b,v){return v===void 0?_=>U(b,_):x(_=>_!=null,B(H(b,v)))}function q(b,v,_){let C=i(_),A=[],P=[],N=!1,O=!1,k=0,W=null;function X(){for(;P.length>0&&A.length>0;){let{resolve:ae}=P.shift(),ue=A.shift();ae({done:!1,value:ue})}for(;P.length>0&&k===0&&N;){let{resolve:ae,reject:ue}=P.shift();W?(ue(W),W=null):ae({done:!0,value:void 0})}}async function ee(){if(N){X();return}if(!O&&!(k+A.length>=b)){O=!0,k++;try{let{done:ae,value:ue}=await C.next();ae?(N=!0,k--,X()):fe(ue)}catch(ae){N=!0,k--,W=ae,X()}O=!1,ee()}}async function fe(ae){try{let ue=await v(ae);if(ue&&ue[Symbol.asyncIterator])for await(let as of ue)A.push(as);else A.push(ue)}catch(ue){N=!0,W=ue}k--,X(),ee()}async function ke(){if(A.length===0){let ue=s();return P.push(ue),ee(),ue.promise}let ae=A.shift();return ee(),{done:!1,value:ae}}let ge={next:ke,[Symbol.asyncIterator]:()=>ge};return ge}function re(b,v,_){return v===void 0?(C,A)=>A?re(b,C,A):re(b,C):_===void 0?C=>re(b,v,C):x(C=>C!=null,B(q(b,v,_)))}async function se(b){return new Promise(v=>{b.once("readable",()=>{v()})})}async function*j(b){for(;;){let v=b.read();if(v!==null){yield v;continue}if(b._readableState.ended)break;await se(b)}}function Ce(b){return typeof b[Symbol.asyncIterator]=="function"?b:j(b)}async function*ve(...b){let v=new Set(b.map(i));for(;v.size>0;)for(let _ of v){let C=await _.next();C.done?v.delete(_):yield C.value}}function ye(b,...v){let _=b();for(let C of v)_=C(_);return _}async function*nt(b,v,_){let C=null,A=k=>({value:v(k)}),P=async function*(k){for await(let W of k){if(C)return;yield W}},N=ye(()=>_,c(1),P,H(A),c(b-1)),O=i(N);for(;;){let{value:k,done:W}=await O.next();if(W)break;try{let X=await k.value;C||(yield X)}catch(X){C=X}}if(C)throw C}function it(b,v,_){return v===void 0?(C,A)=>it(b,C,A):_===void 0?C=>it(b,v,C):b===1?H(v,_):nt(b,v,_)}function Ie(b,v,_){return v===void 0?(C,A)=>A?Ie(b,C,A):Ie(b,C):_===void 0?C=>Ie(b,v,C):x(C=>C!=null,B(it(b,v,_)))}async function*Ue(...b){let v=b.map(i),_=new Set,C=new Map,A=null,P=null,N=null,O=ee=>{A=ee,P&&P(ee)},k=ee=>{N&&N(ee)},W=()=>new Promise((ee,fe)=>{if(A&&fe(A),C.size>0)return ee();N=ee,P=fe}),X=ee=>{let fe=Promise.resolve(ee.next()).then(async({done:ke,value:ge})=>{ke||C.set(ee,ge),_.delete(fe)});_.add(fe),fe.then(k,O)};for(let ee of v)X(ee);for(;;){if(_.size===0&&C.size===0)return;await W();for(let[ee,fe]of C)C.delete(ee),yield fe,X(ee)}}async function ie(b,v,_){let C=v;for await(let A of _)C=await b(C,A);return C}function rr(b,v,_){return v===void 0?(C,A)=>A?ie(b,C,A):rr(b,C):_===void 0?C=>rr(b,v,C):ie(b,v,_)}async function*Wt(b,v){let _=0;for await(let C of v)if(yield await C,_++,_>=b)break}function*ln(b,v){let _=0;for(let C of v)if(yield C,_++,_>=b)break}function Yt(b,v){return v===void 0?_=>Yt(b,_):v[Symbol.asyncIterator]?Wt(b,v):ln(b,v)}async function*fn(b,v){for await(let _ of v)await b(_),yield _}function z(b,v){return v===void 0?_=>fn(b,_):fn(b,v)}function os(b,v){let _=b[0]+v[0],C=b[1]+v[1];if(C>=1e9){let A=C%1e9;_+=(C-A)/1e9,C=A}return[_,C]}async function*La(b,v){let _=v[Symbol.asyncIterator](),C=[0,0];for(;;){let A=process.hrtime(),{value:P,done:N}=await _.next(),O=process.hrtime(A);if(C=os(C,O),b.progress&&b.progress(O,C),N)return b.total&&b.total(C),P;yield P}}function*Eo(b,v){let _=v[Symbol.iterator](),C=[0,0];for(;;){let A=process.hrtime(),{value:P,done:N}=_.next(),O=process.hrtime(A);if(C=os(C,O),b.progress&&b.progress(O,C),N)return b.total&&b.total(C),P;yield P}}function Ft(b={},v){return v===void 0?_=>Ft(b,_):v[Symbol.asyncIterator]!==void 0?La(b,v):Eo(b,v)}function Rr(b,v,_){let C=i(_),A=[],P=[],N=!1,O=!1,k=0,W=null;function X(){for(;P.length>0&&A.length>0;){let{resolve:ae}=P.shift(),ue=A.shift();ae({done:!1,value:ue})}for(;P.length>0&&k===0&&N;){let{resolve:ae,reject:ue}=P.shift();W?(ue(W),W=null):ae({done:!0,value:void 0})}}async function ee(){if(N){X();return}if(!O&&!(k+A.length>=b)){O=!0,k++;try{let{done:ae,value:ue}=await C.next();ae?(N=!0,k--,X()):fe(ue)}catch(ae){N=!0,k--,W=ae,X()}O=!1,ee()}}async function fe(ae){try{let ue=await v(ae);A.push(ue)}catch(ue){N=!0,W=ue}k--,X(),ee()}async function ke(){if(A.length===0){let ue=s();return P.push(ue),ee(),ue.promise}let ae=A.shift();return ee(),{done:!1,value:ae}}let ge={next:ke,[Symbol.asyncIterator]:()=>ge};return ge}function E(b,v,_){return v===void 0?(C,A)=>A?E(b,C,A):E(b,C):_===void 0?C=>E(b,v,C):Rr(b,v,_)}async function S(b,v){let _=null,C=null,A=null,P=W=>{_=W,C&&C(W)},N=()=>{A&&A()},O=()=>{b.removeListener("error",P),b.removeListener("drain",N)};b.once("error",P);let k=()=>new Promise((W,X)=>{if(_)return X(_);b.once("drain",N),A=W,C=X});for await(let W of v)if(b.write(W)===!1&&await k(),_)break;if(O(),_)throw _}function I(b,v){return v===void 0?_=>S(b,_):S(b,v)}t.batch=n,t.buffer=c,t.collect=l,t.concat=p,t.consume=g,t.filter=x,t.flatMap=U,t.flatTransform=re,t.flatten=B,t.fromStream=Ce,t.getIterator=i,t.map=H,t.merge=ve,t.parallelFlatMap=Ie,t.parallelMap=it,t.parallelMerge=Ue,t.pipeline=ye,t.reduce=rr,t.take=Yt,t.tap=z,t.time=Ft,t.transform=E,t.writeToStream=I,Object.defineProperty(t,"__esModule",{value:!0})})});var ix=w((tK,nx)=>{nx.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function i(s,o){r[s]=o,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(s){return r[s]!==void 0||n[s]!==void 0},remove:function(s){r[s]!==void 0&&(r[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set:function(s,o){r[s]!==void 0?r[s]=o:i(s,o)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var ox=w((rK,sx)=>{"use strict";var DL=ix();sx.exports=t=>{let e=DL(t);return e.delete=e.remove,e}});var cx=w((ax,Su)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,u=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],f=1e7,h=1e9;function p(U){var q,re,se,j=z.prototype={constructor:z,toString:null,valueOf:null},Ce=new z(1),ve=20,ye=4,nt=-7,it=21,Ie=-1e7,Ue=1e7,ie=!1,rr=1,Wt=0,ln={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Yt="0123456789abcdefghijklmnopqrstuvwxyz",fn=!0;function z(E,S){var I,b,v,_,C,A,P,N,O=this;if(!(O instanceof z))return new z(E,S);if(S==null){if(E&&E._isBigNumber===!0){O.s=E.s,!E.c||E.e>Ue?O.c=O.e=null:E.e<Ie?O.c=[O.e=0]:(O.e=E.e,O.c=E.c.slice());return}if((A=typeof E=="number")&&E*0==0){if(O.s=1/E<0?(E=-E,-1):1,E===~~E){for(_=0,C=E;C>=10;C/=10,_++);_>Ue?O.c=O.e=null:(O.e=_,O.c=[E]);return}N=String(E)}else{if(!r.test(N=String(E)))return se(O,N,A);O.s=N.charCodeAt(0)==45?(N=N.slice(1),-1):1}(_=N.indexOf("."))>-1&&(N=N.replace(".","")),(C=N.search(/e/i))>0?(_<0&&(_=C),_+=+N.slice(C+1),N=N.substring(0,C)):_<0&&(_=N.length)}else{if(x(S,2,Yt.length,"Base"),S==10&&fn)return O=new z(E),Ft(O,ve+O.e+1,ye);if(N=String(E),A=typeof E=="number"){if(E*0!=0)return se(O,N,A,S);if(O.s=1/E<0?(N=N.slice(1),-1):1,z.DEBUG&&N.replace(/^0\.0*|\./,"").length>15)throw Error(o+E)}else O.s=N.charCodeAt(0)===45?(N=N.slice(1),-1):1;for(I=Yt.slice(0,S),_=C=0,P=N.length;C<P;C++)if(I.indexOf(b=N.charAt(C))<0){if(b=="."){if(C>_){_=P;continue}}else if(!v&&(N==N.toUpperCase()&&(N=N.toLowerCase())||N==N.toLowerCase()&&(N=N.toUpperCase()))){v=!0,C=-1,_=0;continue}return se(O,String(E),A,S)}A=!1,N=re(N,S,10,O.s),(_=N.indexOf("."))>-1?N=N.replace(".",""):_=N.length}for(C=0;N.charCodeAt(C)===48;C++);for(P=N.length;N.charCodeAt(--P)===48;);if(N=N.slice(C,++P)){if(P-=C,A&&z.DEBUG&&P>15&&(E>u||E!==i(E)))throw Error(o+O.s*E);if((_=_-C-1)>Ue)O.c=O.e=null;else if(_<Ie)O.c=[O.e=0];else{if(O.e=_,O.c=[],C=(_+1)%c,_<0&&(C+=c),C<P){for(C&&O.c.push(+N.slice(0,C)),P-=c;C<P;)O.c.push(+N.slice(C,C+=c));C=c-(N=N.slice(C)).length}else C-=P;for(;C--;N+="0");O.c.push(+N)}}else O.c=[O.e=0]}z.clone=p,z.ROUND_UP=0,z.ROUND_DOWN=1,z.ROUND_CEIL=2,z.ROUND_FLOOR=3,z.ROUND_HALF_UP=4,z.ROUND_HALF_DOWN=5,z.ROUND_HALF_EVEN=6,z.ROUND_HALF_CEIL=7,z.ROUND_HALF_FLOOR=8,z.EUCLID=9,z.config=z.set=function(E){var S,I;if(E!=null)if(typeof E=="object"){if(E.hasOwnProperty(S="DECIMAL_PLACES")&&(I=E[S],x(I,0,h,S),ve=I),E.hasOwnProperty(S="ROUNDING_MODE")&&(I=E[S],x(I,0,8,S),ye=I),E.hasOwnProperty(S="EXPONENTIAL_AT")&&(I=E[S],I&&I.pop?(x(I[0],-h,0,S),x(I[1],0,h,S),nt=I[0],it=I[1]):(x(I,-h,h,S),nt=-(it=I<0?-I:I))),E.hasOwnProperty(S="RANGE"))if(I=E[S],I&&I.pop)x(I[0],-h,-1,S),x(I[1],1,h,S),Ie=I[0],Ue=I[1];else if(x(I,-h,h,S),I)Ie=-(Ue=I<0?-I:I);else throw Error(s+S+" cannot be zero: "+I);if(E.hasOwnProperty(S="CRYPTO"))if(I=E[S],I===!!I)if(I)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))ie=I;else throw ie=!I,Error(s+"crypto unavailable");else ie=I;else throw Error(s+S+" not true or false: "+I);if(E.hasOwnProperty(S="MODULO_MODE")&&(I=E[S],x(I,0,9,S),rr=I),E.hasOwnProperty(S="POW_PRECISION")&&(I=E[S],x(I,0,h,S),Wt=I),E.hasOwnProperty(S="FORMAT"))if(I=E[S],typeof I=="object")ln=I;else throw Error(s+S+" not an object: "+I);if(E.hasOwnProperty(S="ALPHABET"))if(I=E[S],typeof I=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(I))fn=I.slice(0,10)=="0123456789",Yt=I;else throw Error(s+S+" invalid: "+I)}else throw Error(s+"Object expected: "+E);return{DECIMAL_PLACES:ve,ROUNDING_MODE:ye,EXPONENTIAL_AT:[nt,it],RANGE:[Ie,Ue],CRYPTO:ie,MODULO_MODE:rr,POW_PRECISION:Wt,FORMAT:ln,ALPHABET:Yt}},z.isBigNumber=function(E){if(!E||E._isBigNumber!==!0)return!1;if(!z.DEBUG)return!0;var S,I,b=E.c,v=E.e,_=E.s;e:if({}.toString.call(b)=="[object Array]"){if((_===1||_===-1)&&v>=-h&&v<=h&&v===i(v)){if(b[0]===0){if(v===0&&b.length===1)return!0;break e}if(S=(v+1)%c,S<1&&(S+=c),String(b[0]).length==S){for(S=0;S<b.length;S++)if(I=b[S],I<0||I>=a||I!==i(I))break e;if(I!==0)return!0}}}else if(b===null&&v===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+E)},z.maximum=z.max=function(){return La(arguments,j.lt)},z.minimum=z.min=function(){return La(arguments,j.gt)},z.random=function(){var E=9007199254740992,S=Math.random()*E&2097151?function(){return i(Math.random()*E)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(I){var b,v,_,C,A,P=0,N=[],O=new z(Ce);if(I==null?I=ve:x(I,0,h),C=n(I/c),ie)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(C*=2));P<C;)A=b[P]*131072+(b[P+1]>>>11),A>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),b[P]=v[0],b[P+1]=v[1]):(N.push(A%1e14),P+=2);P=C/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(C*=7);P<C;)A=(b[P]&31)*281474976710656+b[P+1]*1099511627776+b[P+2]*4294967296+b[P+3]*16777216+(b[P+4]<<16)+(b[P+5]<<8)+b[P+6],A>=9e15?crypto.randomBytes(7).copy(b,P):(N.push(A%1e14),P+=7);P=C/7}else throw ie=!1,Error(s+"crypto unavailable");if(!ie)for(;P<C;)A=S(),A<9e15&&(N[P++]=A%1e14);for(C=N[--P],I%=c,C&&I&&(A=l[c-I],N[P]=i(C/A)*A);N[P]===0;N.pop(),P--);if(P<0)N=[_=0];else{for(_=-1;N[0]===0;N.splice(0,1),_-=c);for(P=1,A=N[0];A>=10;A/=10,P++);P<c&&(_-=c-P)}return O.e=_,O.c=N,O}}(),z.sum=function(){for(var E=1,S=arguments,I=new z(S[0]);E<S.length;)I=I.plus(S[E++]);return I},re=function(){var E="0123456789";function S(I,b,v,_){for(var C,A=[0],P,N=0,O=I.length;N<O;){for(P=A.length;P--;A[P]*=b);for(A[0]+=_.indexOf(I.charAt(N++)),C=0;C<A.length;C++)A[C]>v-1&&(A[C+1]==null&&(A[C+1]=0),A[C+1]+=A[C]/v|0,A[C]%=v)}return A.reverse()}return function(I,b,v,_,C){var A,P,N,O,k,W,X,ee,fe=I.indexOf("."),ke=ve,ge=ye;for(fe>=0&&(O=Wt,Wt=0,I=I.replace(".",""),ee=new z(b),W=ee.pow(I.length-fe),Wt=O,ee.c=S(H(g(W.c),W.e,"0"),10,v,E),ee.e=ee.c.length),X=S(I,b,v,C?(A=Yt,E):(A=E,Yt)),N=O=X.length;X[--O]==0;X.pop());if(!X[0])return A.charAt(0);if(fe<0?--N:(W.c=X,W.e=N,W.s=_,W=q(W,ee,ke,ge,v),X=W.c,k=W.r,N=W.e),P=N+ke+1,fe=X[P],O=v/2,k=k||P<0||X[P+1]!=null,k=ge<4?(fe!=null||k)&&(ge==0||ge==(W.s<0?3:2)):fe>O||fe==O&&(ge==4||k||ge==6&&X[P-1]&1||ge==(W.s<0?8:7)),P<1||!X[0])I=k?H(A.charAt(1),-ke,A.charAt(0)):A.charAt(0);else{if(X.length=P,k)for(--v;++X[--P]>v;)X[P]=0,P||(++N,X=[1].concat(X));for(O=X.length;!X[--O];);for(fe=0,I="";fe<=O;I+=A.charAt(X[fe++]));I=H(I,N,A.charAt(0))}return I}}(),q=function(){function E(b,v,_){var C,A,P,N,O=0,k=b.length,W=v%f,X=v/f|0;for(b=b.slice();k--;)P=b[k]%f,N=b[k]/f|0,C=X*P+N*W,A=W*P+C%f*f+O,O=(A/_|0)+(C/f|0)+X*N,b[k]=A%_;return O&&(b=[O].concat(b)),b}function S(b,v,_,C){var A,P;if(_!=C)P=_>C?1:-1;else for(A=P=0;A<_;A++)if(b[A]!=v[A]){P=b[A]>v[A]?1:-1;break}return P}function I(b,v,_,C){for(var A=0;_--;)b[_]-=A,A=b[_]<v[_]?1:0,b[_]=A*C+b[_]-v[_];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,v,_,C,A){var P,N,O,k,W,X,ee,fe,ke,ge,ae,ue,as,Yu,Qu,Mr,wo,ur=b.s==v.s?1:-1,Kt=b.c,ot=v.c;if(!Kt||!Kt[0]||!ot||!ot[0])return new z(!b.s||!v.s||(Kt?ot&&Kt[0]==ot[0]:!ot)?NaN:Kt&&Kt[0]==0||!ot?ur*0:ur/0);for(fe=new z(ur),ke=fe.c=[],N=b.e-v.e,ur=_+N+1,A||(A=a,N=d(b.e/c)-d(v.e/c),ur=ur/c|0),O=0;ot[O]==(Kt[O]||0);O++);if(ot[O]>(Kt[O]||0)&&N--,ur<0)ke.push(1),k=!0;else{for(Yu=Kt.length,Mr=ot.length,O=0,ur+=2,W=i(A/(ot[0]+1)),W>1&&(ot=E(ot,W,A),Kt=E(Kt,W,A),Mr=ot.length,Yu=Kt.length),as=Mr,ge=Kt.slice(0,Mr),ae=ge.length;ae<Mr;ge[ae++]=0);wo=ot.slice(),wo=[0].concat(wo),Qu=ot[0],ot[1]>=A/2&&Qu++;do{if(W=0,P=S(ot,ge,Mr,ae),P<0){if(ue=ge[0],Mr!=ae&&(ue=ue*A+(ge[1]||0)),W=i(ue/Qu),W>1)for(W>=A&&(W=A-1),X=E(ot,W,A),ee=X.length,ae=ge.length;S(X,ge,ee,ae)==1;)W--,I(X,Mr<ee?wo:ot,ee,A),ee=X.length,P=1;else W==0&&(P=W=1),X=ot.slice(),ee=X.length;if(ee<ae&&(X=[0].concat(X)),I(ge,X,ae,A),ae=ge.length,P==-1)for(;S(ot,ge,Mr,ae)<1;)W++,I(ge,Mr<ae?wo:ot,ae,A),ae=ge.length}else P===0&&(W++,ge=[0]);ke[O++]=W,ge[0]?ge[ae++]=Kt[as]||0:(ge=[Kt[as]],ae=1)}while((as++<Yu||ge[0]!=null)&&ur--);k=ge[0]!=null,ke[0]||ke.splice(0,1)}if(A==a){for(O=1,ur=ke[0];ur>=10;ur/=10,O++);Ft(fe,_+(fe.e=O+N*c-1)+1,C,k)}else fe.e=N,fe.r=+k;return fe}}();function os(E,S,I,b){var v,_,C,A,P;if(I==null?I=ye:x(I,0,8),!E.c)return E.toString();if(v=E.c[0],C=E.e,S==null)P=g(E.c),P=b==1||b==2&&(C<=nt||C>=it)?L(P,C):H(P,C,"0");else if(E=Ft(new z(E),S,I),_=E.e,P=g(E.c),A=P.length,b==1||b==2&&(S<=_||_<=nt)){for(;A<S;P+="0",A++);P=L(P,_)}else if(S-=C,P=H(P,_,"0"),_+1>A){if(--S>0)for(P+=".";S--;P+="0");}else if(S+=_-A,S>0)for(_+1==A&&(P+=".");S--;P+="0");return E.s<0&&v?"-"+P:P}function La(E,S){for(var I,b=1,v=new z(E[0]);b<E.length;b++)if(I=new z(E[b]),I.s)S.call(v,I)&&(v=I);else{v=I;break}return v}function Eo(E,S,I){for(var b=1,v=S.length;!S[--v];S.pop());for(v=S[0];v>=10;v/=10,b++);return(I=b+I*c-1)>Ue?E.c=E.e=null:I<Ie?E.c=[E.e=0]:(E.e=I,E.c=S),E}se=function(){var E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,I=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,C,A,P){var N,O=A?C:C.replace(v,"");if(b.test(O))_.s=isNaN(O)?null:O<0?-1:1;else{if(!A&&(O=O.replace(E,function(k,W,X){return N=(X=X.toLowerCase())=="x"?16:X=="b"?2:8,!P||P==N?W:k}),P&&(N=P,O=O.replace(S,"$1").replace(I,"0.$1")),C!=O))return new z(O,N);if(z.DEBUG)throw Error(s+"Not a"+(P?" base "+P:"")+" number: "+C);_.s=null}_.c=_.e=null}}();function Ft(E,S,I,b){var v,_,C,A,P,N,O,k=E.c,W=l;if(k){e:{for(v=1,A=k[0];A>=10;A/=10,v++);if(_=S-v,_<0)_+=c,C=S,P=k[N=0],O=P/W[v-C-1]%10|0;else if(N=n((_+1)/c),N>=k.length)if(b){for(;k.length<=N;k.push(0));P=O=0,v=1,_%=c,C=_-c+1}else break e;else{for(P=A=k[N],v=1;A>=10;A/=10,v++);_%=c,C=_-c+v,O=C<0?0:P/W[v-C-1]%10|0}if(b=b||S<0||k[N+1]!=null||(C<0?P:P%W[v-C-1]),b=I<4?(O||b)&&(I==0||I==(E.s<0?3:2)):O>5||O==5&&(I==4||b||I==6&&(_>0?C>0?P/W[v-C]:0:k[N-1])%10&1||I==(E.s<0?8:7)),S<1||!k[0])return k.length=0,b?(S-=E.e+1,k[0]=W[(c-S%c)%c],E.e=-S||0):k[0]=E.e=0,E;if(_==0?(k.length=N,A=1,N--):(k.length=N+1,A=W[c-_],k[N]=C>0?i(P/W[v-C]%W[C])*A:0),b)for(;;)if(N==0){for(_=1,C=k[0];C>=10;C/=10,_++);for(C=k[0]+=A,A=1;C>=10;C/=10,A++);_!=A&&(E.e++,k[0]==a&&(k[0]=1));break}else{if(k[N]+=A,k[N]!=a)break;k[N--]=0,A=1}for(_=k.length;k[--_]===0;k.pop());}E.e>Ue?E.c=E.e=null:E.e<Ie&&(E.c=[E.e=0])}return E}function Rr(E){var S,I=E.e;return I===null?E.toString():(S=g(E.c),S=I<=nt||I>=it?L(S,I):H(S,I,"0"),E.s<0?"-"+S:S)}return j.absoluteValue=j.abs=function(){var E=new z(this);return E.s<0&&(E.s=1),E},j.comparedTo=function(E,S){return m(this,new z(E,S))},j.decimalPlaces=j.dp=function(E,S){var I,b,v,_=this;if(E!=null)return x(E,0,h),S==null?S=ye:x(S,0,8),Ft(new z(_),E+_.e+1,S);if(!(I=_.c))return null;if(b=((v=I.length-1)-d(this.e/c))*c,v=I[v])for(;v%10==0;v/=10,b--);return b<0&&(b=0),b},j.dividedBy=j.div=function(E,S){return q(this,new z(E,S),ve,ye)},j.dividedToIntegerBy=j.idiv=function(E,S){return q(this,new z(E,S),0,1)},j.exponentiatedBy=j.pow=function(E,S){var I,b,v,_,C,A,P,N,O,k=this;if(E=new z(E),E.c&&!E.isInteger())throw Error(s+"Exponent not an integer: "+Rr(E));if(S!=null&&(S=new z(S)),A=E.e>14,!k.c||!k.c[0]||k.c[0]==1&&!k.e&&k.c.length==1||!E.c||!E.c[0])return O=new z(Math.pow(+Rr(k),A?2-B(E):+Rr(E))),S?O.mod(S):O;if(P=E.s<0,S){if(S.c?!S.c[0]:!S.s)return new z(NaN);b=!P&&k.isInteger()&&S.isInteger(),b&&(k=k.mod(S))}else{if(E.e>9&&(k.e>0||k.e<-1||(k.e==0?k.c[0]>1||A&&k.c[1]>=24e7:k.c[0]<8e13||A&&k.c[0]<=9999975e7)))return _=k.s<0&&B(E)?-0:0,k.e>-1&&(_=1/_),new z(P?1/_:_);Wt&&(_=n(Wt/c+2))}for(A?(I=new z(.5),P&&(E.s=1),N=B(E)):(v=Math.abs(+Rr(E)),N=v%2),O=new z(Ce);;){if(N){if(O=O.times(k),!O.c)break;_?O.c.length>_&&(O.c.length=_):b&&(O=O.mod(S))}if(v){if(v=i(v/2),v===0)break;N=v%2}else if(E=E.times(I),Ft(E,E.e+1,1),E.e>14)N=B(E);else{if(v=+Rr(E),v===0)break;N=v%2}k=k.times(k),_?k.c&&k.c.length>_&&(k.c.length=_):b&&(k=k.mod(S))}return b?O:(P&&(O=Ce.div(O)),S?O.mod(S):_?Ft(O,Wt,ye,C):O)},j.integerValue=function(E){var S=new z(this);return E==null?E=ye:x(E,0,8),Ft(S,S.e+1,E)},j.isEqualTo=j.eq=function(E,S){return m(this,new z(E,S))===0},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(E,S){return m(this,new z(E,S))>0},j.isGreaterThanOrEqualTo=j.gte=function(E,S){return(S=m(this,new z(E,S)))===1||S===0},j.isInteger=function(){return!!this.c&&d(this.e/c)>this.c.length-2},j.isLessThan=j.lt=function(E,S){return m(this,new z(E,S))<0},j.isLessThanOrEqualTo=j.lte=function(E,S){return(S=m(this,new z(E,S)))===-1||S===0},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&this.c[0]==0},j.minus=function(E,S){var I,b,v,_,C=this,A=C.s;if(E=new z(E,S),S=E.s,!A||!S)return new z(NaN);if(A!=S)return E.s=-S,C.plus(E);var P=C.e/c,N=E.e/c,O=C.c,k=E.c;if(!P||!N){if(!O||!k)return O?(E.s=-S,E):new z(k?C:NaN);if(!O[0]||!k[0])return k[0]?(E.s=-S,E):new z(O[0]?C:ye==3?-0:0)}if(P=d(P),N=d(N),O=O.slice(),A=P-N){for((_=A<0)?(A=-A,v=O):(N=P,v=k),v.reverse(),S=A;S--;v.push(0));v.reverse()}else for(b=(_=(A=O.length)<(S=k.length))?A:S,A=S=0;S<b;S++)if(O[S]!=k[S]){_=O[S]<k[S];break}if(_&&(v=O,O=k,k=v,E.s=-E.s),S=(b=k.length)-(I=O.length),S>0)for(;S--;O[I++]=0);for(S=a-1;b>A;){if(O[--b]<k[b]){for(I=b;I&&!O[--I];O[I]=S);--O[I],O[b]+=a}O[b]-=k[b]}for(;O[0]==0;O.splice(0,1),--N);return O[0]?Eo(E,O,N):(E.s=ye==3?-1:1,E.c=[E.e=0],E)},j.modulo=j.mod=function(E,S){var I,b,v=this;return E=new z(E,S),!v.c||!E.s||E.c&&!E.c[0]?new z(NaN):!E.c||v.c&&!v.c[0]?new z(v):(rr==9?(b=E.s,E.s=1,I=q(v,E,0,3),E.s=b,I.s*=b):I=q(v,E,0,rr),E=v.minus(I.times(E)),!E.c[0]&&rr==1&&(E.s=v.s),E)},j.multipliedBy=j.times=function(E,S){var I,b,v,_,C,A,P,N,O,k,W,X,ee,fe,ke,ge=this,ae=ge.c,ue=(E=new z(E,S)).c;if(!ae||!ue||!ae[0]||!ue[0])return!ge.s||!E.s||ae&&!ae[0]&&!ue||ue&&!ue[0]&&!ae?E.c=E.e=E.s=null:(E.s*=ge.s,!ae||!ue?E.c=E.e=null:(E.c=[0],E.e=0)),E;for(b=d(ge.e/c)+d(E.e/c),E.s*=ge.s,P=ae.length,k=ue.length,P<k&&(ee=ae,ae=ue,ue=ee,v=P,P=k,k=v),v=P+k,ee=[];v--;ee.push(0));for(fe=a,ke=f,v=k;--v>=0;){for(I=0,W=ue[v]%ke,X=ue[v]/ke|0,C=P,_=v+C;_>v;)N=ae[--C]%ke,O=ae[C]/ke|0,A=X*N+O*W,N=W*N+A%ke*ke+ee[_]+I,I=(N/fe|0)+(A/ke|0)+X*O,ee[_--]=N%fe;ee[_]=I}return I?++b:ee.splice(0,1),Eo(E,ee,b)},j.negated=function(){var E=new z(this);return E.s=-E.s||null,E},j.plus=function(E,S){var I,b=this,v=b.s;if(E=new z(E,S),S=E.s,!v||!S)return new z(NaN);if(v!=S)return E.s=-S,b.minus(E);var _=b.e/c,C=E.e/c,A=b.c,P=E.c;if(!_||!C){if(!A||!P)return new z(v/0);if(!A[0]||!P[0])return P[0]?E:new z(A[0]?b:v*0)}if(_=d(_),C=d(C),A=A.slice(),v=_-C){for(v>0?(C=_,I=P):(v=-v,I=A),I.reverse();v--;I.push(0));I.reverse()}for(v=A.length,S=P.length,v-S<0&&(I=P,P=A,A=I,S=v),v=0;S;)v=(A[--S]=A[S]+P[S]+v)/a|0,A[S]=a===A[S]?0:A[S]%a;return v&&(A=[v].concat(A),++C),Eo(E,A,C)},j.precision=j.sd=function(E,S){var I,b,v,_=this;if(E!=null&&E!==!!E)return x(E,1,h),S==null?S=ye:x(S,0,8),Ft(new z(_),E,S);if(!(I=_.c))return null;if(v=I.length-1,b=v*c+1,v=I[v]){for(;v%10==0;v/=10,b--);for(v=I[0];v>=10;v/=10,b++);}return E&&_.e+1>b&&(b=_.e+1),b},j.shiftedBy=function(E){return x(E,-u,u),this.times("1e"+E)},j.squareRoot=j.sqrt=function(){var E,S,I,b,v,_=this,C=_.c,A=_.s,P=_.e,N=ve+4,O=new z("0.5");if(A!==1||!C||!C[0])return new z(!A||A<0&&(!C||C[0])?NaN:C?_:1/0);if(A=Math.sqrt(+Rr(_)),A==0||A==1/0?(S=g(C),(S.length+P)%2==0&&(S+="0"),A=Math.sqrt(+S),P=d((P+1)/2)-(P<0||P%2),A==1/0?S="5e"+P:(S=A.toExponential(),S=S.slice(0,S.indexOf("e")+1)+P),I=new z(S)):I=new z(A+""),I.c[0]){for(P=I.e,A=P+N,A<3&&(A=0);;)if(v=I,I=O.times(v.plus(q(_,v,N,1))),g(v.c).slice(0,A)===(S=g(I.c)).slice(0,A))if(I.e<P&&--A,S=S.slice(A-3,A+1),S=="9999"||!b&&S=="4999"){if(!b&&(Ft(v,v.e+ve+2,0),v.times(v).eq(_))){I=v;break}N+=4,A+=4,b=1}else{(!+S||!+S.slice(1)&&S.charAt(0)=="5")&&(Ft(I,I.e+ve+2,1),E=!I.times(I).eq(_));break}}return Ft(I,I.e+ve+1,ye,E)},j.toExponential=function(E,S){return E!=null&&(x(E,0,h),E++),os(this,E,S,1)},j.toFixed=function(E,S){return E!=null&&(x(E,0,h),E=E+this.e+1),os(this,E,S)},j.toFormat=function(E,S,I){var b,v=this;if(I==null)E!=null&&S&&typeof S=="object"?(I=S,S=null):E&&typeof E=="object"?(I=E,E=S=null):I=ln;else if(typeof I!="object")throw Error(s+"Argument not an object: "+I);if(b=v.toFixed(E,S),v.c){var _,C=b.split("."),A=+I.groupSize,P=+I.secondaryGroupSize,N=I.groupSeparator||"",O=C[0],k=C[1],W=v.s<0,X=W?O.slice(1):O,ee=X.length;if(P&&(_=A,A=P,P=_,ee-=_),A>0&&ee>0){for(_=ee%A||A,O=X.substr(0,_);_<ee;_+=A)O+=N+X.substr(_,A);P>0&&(O+=N+X.slice(_)),W&&(O="-"+O)}b=k?O+(I.decimalSeparator||"")+((P=+I.fractionGroupSize)?k.replace(new RegExp("\\d{"+P+"}\\B","g"),"$&"+(I.fractionGroupSeparator||"")):k):O}return(I.prefix||"")+b+(I.suffix||"")},j.toFraction=function(E){var S,I,b,v,_,C,A,P,N,O,k,W,X=this,ee=X.c;if(E!=null&&(A=new z(E),!A.isInteger()&&(A.c||A.s!==1)||A.lt(Ce)))throw Error(s+"Argument "+(A.isInteger()?"out of range: ":"not an integer: ")+Rr(A));if(!ee)return new z(X);for(S=new z(Ce),N=I=new z(Ce),b=P=new z(Ce),W=g(ee),_=S.e=W.length-X.e-1,S.c[0]=l[(C=_%c)<0?c+C:C],E=!E||A.comparedTo(S)>0?_>0?S:N:A,C=Ue,Ue=1/0,A=new z(W),P.c[0]=0;O=q(A,S,0,1),v=I.plus(O.times(b)),v.comparedTo(E)!=1;)I=b,b=v,N=P.plus(O.times(v=N)),P=v,S=A.minus(O.times(v=S)),A=v;return v=q(E.minus(I),b,0,1),P=P.plus(v.times(N)),I=I.plus(v.times(b)),P.s=N.s=X.s,_=_*2,k=q(N,b,_,ye).minus(X).abs().comparedTo(q(P,I,_,ye).minus(X).abs())<1?[N,b]:[P,I],Ue=C,k},j.toNumber=function(){return+Rr(this)},j.toPrecision=function(E,S){return E!=null&&x(E,1,h),os(this,E,S,2)},j.toString=function(E){var S,I=this,b=I.s,v=I.e;return v===null?b?(S="Infinity",b<0&&(S="-"+S)):S="NaN":(E==null?S=v<=nt||v>=it?L(g(I.c),v):H(g(I.c),v,"0"):E===10&&fn?(I=Ft(new z(I),ve+v+1,ye),S=H(g(I.c),I.e,"0")):(x(E,2,Yt.length,"Base"),S=re(H(g(I.c),v,"0"),10,E,b,!0)),b<0&&I.c[0]&&(S="-"+S)),S},j.valueOf=j.toJSON=function(){return Rr(this)},j._isBigNumber=!0,U!=null&&z.set(U),z}function d(U){var q=U|0;return U>0||U===q?q:q-1}function g(U){for(var q,re,se=1,j=U.length,Ce=U[0]+"";se<j;){for(q=U[se++]+"",re=c-q.length;re--;q="0"+q);Ce+=q}for(j=Ce.length;Ce.charCodeAt(--j)===48;);return Ce.slice(0,j+1||1)}function m(U,q){var re,se,j=U.c,Ce=q.c,ve=U.s,ye=q.s,nt=U.e,it=q.e;if(!ve||!ye)return null;if(re=j&&!j[0],se=Ce&&!Ce[0],re||se)return re?se?0:-ye:ve;if(ve!=ye)return ve;if(re=ve<0,se=nt==it,!j||!Ce)return se?0:!j^re?1:-1;if(!se)return nt>it^re?1:-1;for(ye=(nt=j.length)<(it=Ce.length)?nt:it,ve=0;ve<ye;ve++)if(j[ve]!=Ce[ve])return j[ve]>Ce[ve]^re?1:-1;return nt==it?0:nt>it^re?1:-1}function x(U,q,re,se){if(U<q||U>re||U!==i(U))throw Error(s+(se||"Argument")+(typeof U=="number"?U<q||U>re?" out of range: ":" not an integer: ":" not a primitive number: ")+String(U))}function B(U){var q=U.c.length-1;return d(U.e/c)==q&&U.c[q]%2!=0}function L(U,q){return(U.length>1?U.charAt(0)+"."+U.slice(1):U)+(q<0?"e":"e+")+q}function H(U,q,re){var se,j;if(q<0){for(j=re+".";++q;j+=re);U=j+U}else if(se=U.length,++q>se){for(j=re,q-=se;--q;j+=re);U+=j}else q<se&&(U=U.slice(0,q)+"."+U.slice(q));return U}e=p(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Su!="undefined"&&Su.exports?Su.exports=e:(t||(t=typeof self!="undefined"&&self?self:window),t.BigNumber=e)})(ax)});var fx=w((ux,lx)=>{"use strict";var LL=Math.exp;ux=lx.exports=function(e){if(typeof e!="number")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");let r,n=0,i=0,s=0,o,a={};function c(u,l){return 1-LL(-(u-l)/e)}return a.push=function(l,f){if(o){let h=c(l,o),p=f-r,d=h*p;r=h*f+(1-h)*r,n=(1-h)*(n+p*d),i=Math.sqrt(n),s=r+h*p}else r=f;o=l},a.movingAverage=function(){return r},a.variance=function(){return n},a.deviation=function(){return i},a.forecast=function(){return s},a}});var yx=w((nK,px)=>{"use strict";var{EventEmitter:kL}=Qt(),{BigNumber:Au}=cx(),hx=fx(),qL=ca(),dx=class extends kL{constructor(e,r){super();this._options=r,this._queue=[],this._stats={dataReceived:Au(0),dataSent:Au(0)},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this);let n=this._options.movingAverageIntervals;for(let i=0;i<e.length;i++){let s=e[i];this._stats[s]=Au(0),this._movingAverages[s]={};for(let o=0;o<n.length;o++){let a=n[o];(this._movingAverages[s][a]=hx(a)).push(this._frequencyLastTime,0)}}}start(){this._queue.length&&this._resetComputeTimeout()}stop(){this._timeout&&(this._timeout.clear(),this._timeout=null)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}toJSON(){let e=this.snapshot,r=this.movingAverages,n={dataReceived:e.dataReceived.toString(),dataSent:e.dataSent.toString(),movingAverages:{}},i=Object.keys(r);for(let s of i){n.movingAverages[s]={};for(let o of Object.keys(r[s]))n.movingAverages[s][o]=r[s][o].movingAverage()}return n}push(e,r){this._queue.push([e,r,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this._timeout=qL(this._update,this._nextTimeout())}_nextTimeout(){let e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(e of this._queue)this._applyOp(e);this._queue=[],this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){let r=e-this._frequencyLastTime;Object.keys(this._stats).forEach(n=>{this._updateFrequencyFor(n,r,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,r,n){let i=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;let o=i/(r||1)*1e3,a=this._movingAverages[e];a||(a=this._movingAverages[e]={});let c=this._options.movingAverageIntervals;for(let u=0;u<c.length;u++){let l=c[u],f=a[l];f||(f=a[l]=hx(l)),f.push(n,o)}}_applyOp(e){let r=e[0],n=e[1];if(typeof n!="number")throw new Error(`invalid increment number: ${n}`);let i;Object.prototype.hasOwnProperty.call(this._stats,r)?i=this._stats[r]:i=this._stats[r]=Au(0),this._stats[r]=i.plus(n),this._frequencyAccumulators[r]||(this._frequencyAccumulators[r]=0),this._frequencyAccumulators[r]+=n}};px.exports=dx});var vx=w((iK,mx)=>{"use strict";var UL=Us(),{pipe:ML}=nn(),{tap:gx}=xu(),FL=ox(),{METRICS:KL}=Zc(),md=yx(),vd=["dataReceived","dataSent"],VL={in:"dataReceived",out:"dataSent"},Cu=class{constructor(e){this._options=UL(KL,e),this._globalStats=new md(vd,this._options),this._peerStats=new Map,this._protocolStats=new Map,this._oldPeers=FL(this._options.maxOldPeersRetention),this._running=!1,this._onMessage=this._onMessage.bind(this),this._systems=new Map}start(){this._running=!0}stop(){this._running=!1,this._globalStats.stop();for(let e of this._peerStats.values())e.stop();for(let e of this._protocolStats.values())e.stop()}get global(){return this._globalStats}get peers(){return Array.from(this._peerStats.keys())}getComponentMetrics(){return this._systems}updateComponentMetric({system:e="libp2p",component:r,metric:n,value:i}){this._systems.has(e)||this._systems.set(e,new Map);let s=this._systems.get(e);s.has(r)||s.set(r,new Map),s.get(r).set(n,i)}forPeer(e){let r=e.toB58String();return this._peerStats.get(r)||this._oldPeers.get(r)}get protocols(){return Array.from(this._protocolStats.keys())}forProtocol(e){return this._protocolStats.get(e)}onPeerDisconnected(e){let r=e.toB58String(),n=this._peerStats.get(r);n&&(n.stop(),this._peerStats.delete(r),this._oldPeers.set(r,n))}_onMessage({remotePeer:e,protocol:r,direction:n,dataLength:i}){if(!this._running)return;let s=VL[n],o=this.forPeer(e);if(o||(o=new md(vd,this._options),this._peerStats.set(e.toB58String(),o)),o.push(s,i),this._globalStats.push(s,i),r){let a=this.forProtocol(r);a||(a=new md(vd,this._options),this._protocolStats.set(r,a)),a.push(s,i)}}updatePlaceholder(e,r){if(!this._running)return;let n=this.forPeer(e),i=r.toB58String(),s=this.forPeer(r),o=n;s&&(o=Cu.mergeStats(s,o),this._oldPeers.delete(i)),this._peerStats.delete(e.toB58String()),this._peerStats.set(i,o),o.start()}trackStream({stream:e,remotePeer:r,protocol:n}){let i=this,s=e.source;e.source=gx(a=>i._onMessage({remotePeer:r,protocol:n,direction:"in",dataLength:a.length}))(s);let o=e.sink;return e.sink=a=>ML(a,gx(c=>i._onMessage({remotePeer:r,protocol:n,direction:"out",dataLength:c.length})),o),e}static mergeStats(e,r){return e.stop(),r.stop(),e._queue=[...e._queue,...r._queue],e}};mx.exports=Cu});var Iu=w(es=>{"use strict";var bx=Gi(),Ex=Ea(),jL=nn(),$L=pe(),{fromString:HL}=(Ct(),Pt),zL=nh(),wx=HL(`
45
- `);es.encode=t=>Ex.encode.single(new bx([t,wx]));es.write=(t,e)=>t.push(es.encode(e));es.writeAll=(t,e)=>{t.push(e.reduce((r,n)=>r.append(es.encode(n)),new bx))};es.read=async t=>{let e=1,r={[Symbol.asyncIterator](){return this},next:()=>t.next(e)},n=s=>{e=s},i=await jL(r,Ex.decode({onLength:n}),zL);if(i.get(i.length-1)!==wx[0])throw $L(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return i.shallowSlice(0,-1)}});var xx=w((oK,_x)=>{"use strict";var oo=Be()("mss:select"),GL=pe(),ao=Iu(),WL=wa();_x.exports=async(t,e,r)=>{e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:i,rest:s,stream:o}=WL(t),a=e.shift();r?(oo('select: write ["%s", "%s"]',r,a),ao.writeAll(i,[r,a])):(oo('select: write "%s"',a),ao.write(i,a));let c=(await ao.read(n)).toString();if(oo('select: read "%s"',c),c===r&&(c=(await ao.read(n)).toString(),oo('select: read "%s"',c)),c===a)return s(),{stream:o,protocol:a};for(let u of e){oo('select: write "%s"',u),ao.write(i,u);let l=(await ao.read(n)).toString();if(oo('select: read "%s" for "%s"',l,u),l===u)return s(),{stream:o,protocol:u}}throw s(),GL(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}});var bd=w(Sx=>{"use strict";Sx.PROTOCOL_ID="/multistream/1.0.0"});var Cx=w((cK,Ax)=>{"use strict";var Ia=Be()("mss:handle"),YL=Gi(),co=Iu(),QL=wa(),{PROTOCOL_ID:Ed}=bd();Ax.exports=async(t,e)=>{e=Array.isArray(e)?e:[e];let{writer:r,reader:n,rest:i,stream:s}=QL(t);for(;;){let o=(await co.read(n)).toString();if(Ia('read "%s"',o),o===Ed){Ia('respond with "%s" for "%s"',Ed,o),co.write(r,Ed);continue}if(e.includes(o))return co.write(r,o),Ia('respond with "%s" for "%s"',o,o),i(),{stream:s,protocol:o};if(o==="ls"){co.write(r,new YL(e.map(a=>co.encode(a)))),Ia('respond with "%s" for %s',e,o);continue}co.write(r,"na"),Ia('respond with "na" for "%s"',o)}}});var Rx=w((uK,Tx)=>{"use strict";var XL=Gh(),ZL=Be()("it-multistream-select:ls"),Ix=Iu(),JL=wa(),e6=Ea(),t6=nn();Tx.exports=async t=>{let{reader:e,writer:r,rest:n,stream:i}=JL(t);ZL('write "ls"'),Ix.write(r,"ls"),n();let s=await Ix.read(e),o=XL([s]),a=[];return await t6(o,e6.decode(),async c=>{for await(let u of c)a.push(u.shallowSlice(0,-1).toString())}),{stream:i,protocols:a}}});var Ox=w(Tu=>{"use strict";var Bx=xx(),r6=Cx(),n6=Rx(),{PROTOCOL_ID:wd}=bd();Tu.PROTOCOL_ID=wd;var _d=class{constructor(e){this._stream=e,this._shaken=!1}async _handshake(){if(this._shaken)return;let{stream:e}=await Bx(this._stream,wd);this._stream=e,this._shaken=!0}},Px=class extends _d{select(e){return Bx(this._stream,e,this._shaken?null:wd)}async ls(){await this._handshake();let{stream:e,protocols:r}=await n6(this._stream);return this._stream=e,r}};Tu.Dialer=Px;var Nx=class extends _d{handle(e){return r6(this._stream,e)}};Tu.Listener=Nx});var Lx=w((fK,Dx)=>{"use strict";var i6={OPEN:"open",CLOSING:"closing",CLOSED:"closed"};Dx.exports=i6});var Kx=w((hK,Fx)=>{"use strict";var kx=Tt(),{Multiaddr:s6}=kt(),ar=pe(),{OPEN:o6,CLOSING:qx,CLOSED:xd}=Lx(),Ux=Symbol.for("@libp2p/interface-connection/connection"),Mx=class{constructor({localAddr:e,remoteAddr:r,localPeer:n,remotePeer:i,newStream:s,close:o,getStreams:a,stat:c}){a6(e,n,i,s,o,a,c),this.id=parseInt(String(Math.random()*1e9)).toString(36)+Date.now(),this.localAddr=e,this.remoteAddr=r,this.localPeer=n,this.remotePeer=i,this._stat={...c,status:o6},this._newStream=s,this._close=o,this._getStreams=a,this.registry=new Map,this.tags=[]}get[Symbol.toStringTag](){return"Connection"}get[Ux](){return!0}static isConnection(e){return Boolean(e&&e[Ux])}get stat(){return this._stat}get streams(){return this._getStreams()}async newStream(e){if(this.stat.status===qx)throw ar(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===xd)throw ar(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);let{stream:r,protocol:n}=await this._newStream(e);return this.addStream(r,{protocol:n}),{stream:r,protocol:n}}addStream(e,{protocol:r,metadata:n={}}){this.registry.set(e.id,{protocol:r,...n})}removeStream(e){this.registry.delete(e)}async close(){if(this.stat.status!==xd){if(this._closing)return this._closing;this.stat.status=qx,this._closing=await this._close(),this._stat.timeline.close=Date.now(),this.stat.status=xd}}};Fx.exports=Mx;function a6(t,e,r,n,i,s,o){if(t&&!s6.isMultiaddr(t))throw ar(new Error("localAddr must be an instance of multiaddr"),"ERR_INVALID_PARAMETERS");if(!kx.isPeerId(e))throw ar(new Error("localPeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(!kx.isPeerId(r))throw ar(new Error("remotePeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(typeof n!="function")throw ar(new Error("new stream must be a function"),"ERR_INVALID_PARAMETERS");if(typeof i!="function")throw ar(new Error("close must be a function"),"ERR_INVALID_PARAMETERS");if(typeof s!="function")throw ar(new Error("getStreams must be a function"),"ERR_INVALID_PARAMETERS");if(!o)throw ar(new Error("connection metadata object must be provided"),"ERR_INVALID_PARAMETERS");if(o.direction!=="inbound"&&o.direction!=="outbound")throw ar(new Error('direction must be "inbound" or "outbound"'),"ERR_INVALID_PARAMETERS");if(!o.timeline)throw ar(new Error("connection timeline object must be provided in the stat object"),"ERR_INVALID_PARAMETERS");if(!o.timeline.open)throw ar(new Error("connection open timestamp must be provided"),"ERR_INVALID_PARAMETERS");if(!o.timeline.upgraded)throw ar(new Error("connection upgraded timestamp must be provided"),"ERR_INVALID_PARAMETERS")}});var jx=w(Vx=>{"use strict";Vx.Connection=Kx()});var Hx=w((pK,$x)=>{"use strict";function c6(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}else return Array.from(t)}$x.exports=function(e){var r=void 0,n=void 0;function i(a){if(!(a instanceof Object))throw new Error('Target "'+a+'" is not an object');n=a}function s(a){Object.keys(a).forEach(function(c){var u=a[c];if(typeof u!="function")throw new Error('Trap "'+c+": "+u+'" is not a function');if(!Reflect[c])throw new Error('Trap "'+c+": "+u+'" is not a valid trap')}),r=a}i(function(){}),e&&i(e),s(Reflect);var o=new Proxy({},{get:function(c,u){return function(){for(var l=arguments.length,f=Array(l),h=0;h<l;h++)f[h]=arguments[h];return r[u].apply(null,[n].concat(c6(f.slice(1))))}}});return{setTarget:i,setHandler:s,getTarget:function(){return n},getHandler:function(){return r},proxy:new Proxy(n,o)}}});var Qx=w((yK,Yx)=>{"use strict";var zx=Be(),mt=Object.assign(zx("libp2p:upgrader"),{error:zx("libp2p:upgrader:err")}),ts=pe(),uo=Ox(),{Connection:u6}=jx(),l6=Tt(),{pipe:f6}=nn(),Gx=Hx(),{codes:rs}=He(),Wx=class{constructor({localPeer:e,metrics:r,cryptos:n=new Map,muxers:i=new Map,onConnectionEnd:s=()=>{},onConnection:o=()=>{}}){this.localPeer=e,this.metrics=r,this.cryptos=n,this.muxers=i,this.protector=null,this.protocols=new Map,this.onConnection=o,this.onConnectionEnd=s}async upgradeInbound(e){let r,n,i,s,o,a,c;if(this.metrics){({setTarget:a,proxy:c}=Gx());let l=(Math.random()*1e9).toString(36)+Date.now();a({toB58String:()=>l}),e=this.metrics.trackStream({stream:e,remotePeer:c})}mt("Starting the inbound connection upgrade");let u=e;this.protector&&(u=await this.protector.protect(e));try{({conn:r,remotePeer:n,protocol:o}=await this._encryptInbound(this.localPeer,u,this.cryptos)),this.muxers.size?{stream:i,Muxer:s}=await this._multiplexInbound(r,this.muxers):i=r}catch(l){throw mt.error("Failed to upgrade inbound connection",l),await e.close(l),l}return this.metrics&&(this.metrics.updatePlaceholder(c,n),a(n)),mt("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:e,upgradedConn:i,Muxer:s,remotePeer:n})}async upgradeOutbound(e){let r=e.remoteAddr.getPeerId();if(!r)throw ts(new Error("outbound connection must have a peer id"),rs.ERR_INVALID_MULTIADDR);let n=l6.createFromB58String(r),i,s,o,a,c,u,l;if(this.metrics){({setTarget:u,proxy:l}=Gx());let h=(Math.random()*1e9).toString(36)+Date.now();u({toB58String:()=>h}),e=this.metrics.trackStream({stream:e,remotePeer:l})}mt("Starting the outbound connection upgrade");let f=e;this.protector&&(f=await this.protector.protect(e));try{({conn:i,remotePeer:s,protocol:a}=await this._encryptOutbound(this.localPeer,f,n,this.cryptos)),this.muxers.size?{stream:o,Muxer:c}=await this._multiplexOutbound(i,this.muxers):o=i}catch(h){throw mt.error("Failed to upgrade outbound connection",h),await e.close(h),h}return this.metrics&&(this.metrics.updatePlaceholder(l,s),u(s)),mt("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:a,direction:"outbound",maConn:e,upgradedConn:o,Muxer:c,remotePeer:s})}_createConnection({cryptoProtocol:e,direction:r,maConn:n,upgradedConn:i,Muxer:s,remotePeer:o}){let a,c,u;s&&(a=new s({onStream:async h=>{if(!u)return;let p=new uo.Listener(h);try{let{stream:d,protocol:g}=await p.handle(Array.from(this.protocols.keys()));mt("%s: incoming stream opened on %s",r,g),this.metrics&&this.metrics.trackStream({stream:d,remotePeer:o,protocol:g}),u.addStream(h,{protocol:g}),this._onStream({connection:u,stream:{...h,...d},protocol:g})}catch(d){mt.error(d)}},onStreamEnd:h=>{u.removeStream(h.id)}}),c=async h=>{mt("%s: starting new stream on %s",r,h);let p=a.newStream(),d=new uo.Dialer(p);try{let{stream:g,protocol:m}=await d.select(h);return this.metrics&&this.metrics.trackStream({stream:g,remotePeer:o,protocol:m}),{stream:{...p,...g},protocol:m}}catch(g){throw mt.error("could not create new stream",g),ts(g,rs.ERR_UNSUPPORTED_PROTOCOL)}},f6(i,a,i).catch(mt.error));let l=n.timeline;n.timeline=new Proxy(l,{set:(...h)=>(u&&h[1]==="close"&&h[2]&&!l.close&&(async()=>{try{u.stat.status==="open"&&await u.close()}catch(p){mt.error(p)}finally{this.onConnectionEnd(u)}})().catch(p=>{mt.error(p)}),Reflect.set(...h))}),n.timeline.upgraded=Date.now();let f=()=>{throw ts(new Error("connection is not multiplexed"),rs.ERR_CONNECTION_NOT_MULTIPLEXED)};return u=new u6({localAddr:n.localAddr,remoteAddr:n.remoteAddr,localPeer:this.localPeer,remotePeer:o,stat:{direction:r,timeline:n.timeline,multiplexer:s&&s.multicodec,encryption:e},newStream:c||f,getStreams:()=>a?a.streams:f(),close:async()=>{await n.close(),a&&a.streams.map(h=>h.abort())}}),this.onConnection(u),u}_onStream({connection:e,stream:r,protocol:n}){this.protocols.get(n)({connection:e,stream:r,protocol:n})}async _encryptInbound(e,r,n){let i=new uo.Listener(r),s=Array.from(n.keys());mt("handling inbound crypto protocol selection",s);try{let{stream:o,protocol:a}=await i.handle(s),c=n.get(a);if(mt("encrypting inbound connection..."),!c)throw new Error(`no crypto module found for ${a}`);return{...await c.secureInbound(e,o),protocol:a}}catch(o){throw ts(o,rs.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,r,n,i){let s=new uo.Dialer(r),o=Array.from(i.keys());mt("selecting outbound crypto protocol",o);try{let{stream:a,protocol:c}=await s.select(o),u=i.get(c);if(mt("encrypting outbound connection to %j",n),!u)throw new Error(`no crypto module found for ${c}`);return{...await u.secureOutbound(e,a,n),protocol:c}}catch(a){throw ts(a,rs.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,r){let n=new uo.Dialer(e),i=Array.from(r.keys());mt("outbound selecting muxer %s",i);try{let{stream:s,protocol:o}=await n.select(i);mt("%s selected as muxer protocol",o);let a=r.get(o);return{stream:s,Muxer:a}}catch(s){throw ts(s,rs.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,r){let n=new uo.Listener(e),i=Array.from(r.keys());mt("inbound handling muxers %s",i);try{let{stream:s,protocol:o}=await n.handle(i),a=r.get(o);return{stream:s,Muxer:a}}catch(s){throw ts(s,rs.ERR_MUXER_UNAVAILABLE)}}};Yx.exports=Wx});var rS=w((gK,tS)=>{"use strict";var Xx=Be(),lo=pe(),{Multiaddr:h6}=kt(),Ru=Tt(),{codes:un}=He(),Zx=iu(),Jx=ru(),Fe=Object.assign(Xx("libp2p:peer-store:address-book"),{error:Xx("libp2p:peer-store:address-book:err")}),Bu="change:multiaddrs",eS=class{constructor(e,r){this._emit=e,this._store=r}async consumePeerRecord(e){Fe("consumePeerRecord await write lock");let r=await this._store.lock.writeLock();Fe("consumePeerRecord got write lock");let n,i;try{let s;try{s=Zx.createFromProtobuf(e.payload)}catch(a){return Fe.error("invalid peer record received"),!1}n=s.peerId;let o=s.multiaddrs;if(!n.equals(e.peerId))return Fe("signing key does not match PeerId in the PeerRecord"),!1;if(!o||!o.length)return!1;if(await this._store.has(n)){let a=await this._store.load(n);if(a.peerRecordEnvelope){let c=await Jx.createFromProtobuf(a.peerRecordEnvelope);if(Zx.createFromProtobuf(c.payload).seqNumber>=s.seqNumber)return!1}}i=await this._store.patchOrCreate(n,{addresses:Sd(o,!0),peerRecordEnvelope:e.marshal()}),Fe(`stored provided peer record for ${s.peerId.toB58String()}`)}finally{Fe("consumePeerRecord release write lock"),r()}return this._emit(Bu,{peerId:n,multiaddrs:i.addresses.map(({multiaddr:s})=>s)}),!0}async getRawEnvelope(e){Fe("getRawEnvelope await read lock");let r=await this._store.lock.readLock();Fe("getRawEnvelope got read lock");try{return(await this._store.load(e)).peerRecordEnvelope}catch(n){if(n.code!==un.ERR_NOT_FOUND)throw n}finally{Fe("getRawEnvelope release read lock"),r()}}async getPeerRecord(e){let r=await this.getRawEnvelope(e);if(!!r)return Jx.createFromProtobuf(r)}async get(e){if(!Ru.isPeerId(e))throw Fe.error("peerId must be an instance of peer-id to store data"),lo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Fe("get wait for read lock");let r=await this._store.lock.readLock();Fe("get got read lock");try{return(await this._store.load(e)).addresses}catch(n){if(n.code!==un.ERR_NOT_FOUND)throw n}finally{Fe("get release read lock"),r()}return[]}async set(e,r){if(!Ru.isPeerId(e))throw Fe.error("peerId must be an instance of peer-id to store data"),lo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Fe("set await write lock");let n=await this._store.lock.writeLock();Fe("set got write lock");let i=!1,s;try{let o=Sd(r);if(!o.length)return;try{let a=await this._store.load(e);if(i=!0,new Set([...o.map(({multiaddr:c})=>c.toString()),...a.addresses.map(({multiaddr:c})=>c.toString())]).size===a.addresses.length&&o.length===a.addresses.length)return}catch(a){if(a.code!==un.ERR_NOT_FOUND)throw a}s=await this._store.patchOrCreate(e,{addresses:o}),Fe(`set multiaddrs for ${e.toB58String()}`)}finally{Fe("set release write lock"),n()}this._emit(Bu,{peerId:e,multiaddrs:s.addresses.map(o=>o.multiaddr)}),i||this._emit("peer",e)}async add(e,r){if(!Ru.isPeerId(e))throw Fe.error("peerId must be an instance of peer-id to store data"),lo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Fe("add await write lock");let n=await this._store.lock.writeLock();Fe("add got write lock");let i,s;try{let o=Sd(r);if(!o.length)return;try{let a=await this._store.load(e);if(i=!0,new Set([...o.map(({multiaddr:c})=>c.toString()),...a.addresses.map(({multiaddr:c})=>c.toString())]).size===a.addresses.length)return}catch(a){if(a.code!==un.ERR_NOT_FOUND)throw a}s=await this._store.mergeOrCreate(e,{addresses:o}),Fe(`added multiaddrs for ${e}`)}finally{Fe("set release write lock"),n()}this._emit(Bu,{peerId:e,multiaddrs:s.addresses.map(o=>o.multiaddr)}),i||this._emit("peer",e)}async delete(e){if(!Ru.isPeerId(e))throw Fe.error("peerId must be an instance of peer-id to store data"),lo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Fe("delete await write lock");let r=await this._store.lock.writeLock();Fe("delete got write lock");let n;try{n=await this._store.has(e),await this._store.patchOrCreate(e,{addresses:[]})}finally{Fe("delete release write lock"),r()}n&&this._emit(Bu,{peerId:e,multiaddrs:[]})}async getMultiaddrsForPeer(e,r=n=>n){let n=await this.get(e);return r(n).map(i=>{let s=i.multiaddr,o=s.getPeerId();return o&&o===e.toB58String()?s:s.encapsulate(`/p2p/${e.toB58String()}`)})}};function Sd(t,e=!1){if(!t)throw Fe.error("multiaddrs must be provided to store data"),lo(new Error("multiaddrs must be provided"),un.ERR_INVALID_PARAMETERS);return Array.from(new Set(t.map(r=>r.toString()))).map(r=>{try{return{multiaddr:new h6(r),isCertified:e}}catch(n){throw lo(n,un.ERR_INVALID_PARAMETERS)}})}tS.exports=eS});var aS=w((mK,oS)=>{"use strict";var nS=Be(),Pu=pe(),{codes:fo}=He(),Ad=Tt(),{equals:d6}=(yr(),pr),cr=Object.assign(nS("libp2p:peer-store:key-book"),{error:nS("libp2p:peer-store:key-book:err")}),iS="change:pubkey",sS=class{constructor(e,r){this._emit=e,this._store=r}async set(e,r){if(!Ad.isPeerId(e))throw cr.error("peerId must be an instance of peer-id to store data"),Pu(new Error("peerId must be an instance of peer-id"),fo.ERR_INVALID_PARAMETERS);if(!r)throw cr.error("publicKey must be an instance of PublicKey to store data"),Pu(new Error("publicKey must be an instance of PublicKey"),fo.ERR_INVALID_PARAMETERS);cr("set await write lock");let n=await this._store.lock.writeLock();cr("set got write lock");let i=!1;try{try{let s=await this._store.load(e);if(s.pubKey&&d6(s.pubKey.bytes,r.bytes))return}catch(s){if(s.code!==fo.ERR_NOT_FOUND)throw s}await this._store.patchOrCreate(e,{pubKey:r}),i=!0}finally{cr("set release write lock"),n()}i&&this._emit(iS,{peerId:e,pubKey:r})}async get(e){if(!Ad.isPeerId(e))throw cr.error("peerId must be an instance of peer-id to store data"),Pu(new Error("peerId must be an instance of peer-id"),fo.ERR_INVALID_PARAMETERS);cr("get await write lock");let r=await this._store.lock.readLock();cr("get got write lock");try{return(await this._store.load(e)).pubKey}catch(n){if(n.code!==fo.ERR_NOT_FOUND)throw n}finally{cr("get release write lock"),r()}}async delete(e){if(!Ad.isPeerId(e))throw cr.error("peerId must be an instance of peer-id to store data"),Pu(new Error("peerId must be an instance of peer-id"),fo.ERR_INVALID_PARAMETERS);cr("delete await write lock");let r=await this._store.lock.writeLock();cr("delete got write lock");try{await this._store.patchOrCreate(e,{pubKey:void 0})}finally{cr("delete release write lock"),r()}this._emit(iS,{peerId:e,pubKey:void 0})}};oS.exports=sS});var fS=w((vK,lS)=>{"use strict";var cS=Be(),fi=pe(),{codes:Ar}=He(),ho=Tt(),{equals:p6}=(yr(),pr),Ge=Object.assign(cS("libp2p:peer-store:metadata-book"),{error:cS("libp2p:peer-store:metadata-book:err")}),Nu="change:metadata",uS=class{constructor(e,r){this._emit=e,this._store=r}async get(e){if(!ho.isPeerId(e))throw Ge.error("peerId must be an instance of peer-id to store data"),fi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);Ge("get await read lock");let r=await this._store.lock.readLock();Ge("get got read lock");try{return(await this._store.load(e)).metadata}catch(n){if(n.code!==Ar.ERR_NOT_FOUND)throw n}finally{Ge("get release read lock"),r()}return new Map}async getValue(e,r){if(!ho.isPeerId(e))throw Ge.error("peerId must be an instance of peer-id to store data"),fi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);Ge("getValue await read lock");let n=await this._store.lock.readLock();Ge("getValue got read lock");try{return(await this._store.load(e)).metadata.get(r)}catch(i){if(i.code!==Ar.ERR_NOT_FOUND)throw i}finally{Ge("getValue release write lock"),n()}}async set(e,r){if(!ho.isPeerId(e))throw Ge.error("peerId must be an instance of peer-id to store data"),fi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);if(!r||!(r instanceof Map))throw Ge.error("valid metadata must be provided to store data"),fi(new Error("valid metadata must be provided"),Ar.ERR_INVALID_PARAMETERS);Ge("set await write lock");let n=await this._store.lock.writeLock();Ge("set got write lock");try{await this._store.mergeOrCreate(e,{metadata:r})}finally{Ge("set release write lock"),n()}this._emit(Nu,{peerId:e,metadata:r})}async setValue(e,r,n){if(!ho.isPeerId(e))throw Ge.error("peerId must be an instance of peer-id to store data"),fi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);if(typeof r!="string"||!(n instanceof Uint8Array))throw Ge.error("valid key and value must be provided to store data"),fi(new Error("valid key and value must be provided"),Ar.ERR_INVALID_PARAMETERS);Ge("setValue await write lock");let i=await this._store.lock.writeLock();Ge("setValue got write lock");let s;try{try{let a=(await this._store.load(e)).metadata.get(r);if(a!=null&&p6(n,a))return}catch(o){if(o.code!==Ar.ERR_NOT_FOUND)throw o}s=await this._store.mergeOrCreate(e,{metadata:new Map([[r,n]])})}finally{Ge("setValue release write lock"),i()}this._emit(Nu,{peerId:e,metadata:s.metadata})}async delete(e){if(!ho.isPeerId(e))throw Ge.error("peerId must be an instance of peer-id to store data"),fi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);Ge("delete await write lock");let r=await this._store.lock.writeLock();Ge("delete got write lock");let n;try{n=await this._store.has(e),n&&await this._store.patch(e,{metadata:new Map})}finally{Ge("delete release write lock"),r()}n&&this._emit(Nu,{peerId:e,metadata:new Map})}async deleteValue(e,r){if(!ho.isPeerId(e))throw Ge.error("peerId must be an instance of peer-id to store data"),fi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);Ge("deleteValue await write lock");let n=await this._store.lock.writeLock();Ge("deleteValue got write lock");let i;try{i=(await this._store.load(e)).metadata,i.delete(r),await this._store.patch(e,{metadata:i})}catch(s){if(s.code!==Ar.ERR_NOT_FOUND)throw s}finally{Ge("deleteValue release write lock"),n()}i&&this._emit(Nu,{peerId:e,metadata:i})}};lS.exports=uS});var yS=w((bK,pS)=>{"use strict";var hS=Be(),po=pe(),{codes:Ur}=He(),Cd=Tt(),st=Object.assign(hS("libp2p:peer-store:proto-book"),{error:hS("libp2p:peer-store:proto-book:err")}),Ou="change:protocols",dS=class{constructor(e,r){this._emit=e,this._store=r}async get(e){st("get wait for read lock");let r=await this._store.lock.readLock();st("get got read lock");try{return(await this._store.load(e)).protocols}catch(n){if(n.code!==Ur.ERR_NOT_FOUND)throw n}finally{st("get release read lock"),r()}return[]}async set(e,r){if(!Cd.isPeerId(e))throw st.error("peerId must be an instance of peer-id to store data"),po(new Error("peerId must be an instance of peer-id"),Ur.ERR_INVALID_PARAMETERS);if(!Array.isArray(r))throw st.error("protocols must be provided to store data"),po(new Error("protocols must be provided"),Ur.ERR_INVALID_PARAMETERS);st("set await write lock");let n=await this._store.lock.writeLock();st("set got write lock");let i;try{try{let s=await this._store.load(e);if(new Set([...r]).size===s.protocols.length)return}catch(s){if(s.code!==Ur.ERR_NOT_FOUND)throw s}i=await this._store.patchOrCreate(e,{protocols:r}),st(`stored provided protocols for ${e.toB58String()}`)}finally{st("set release write lock"),n()}this._emit(Ou,{peerId:e,protocols:i.protocols})}async add(e,r){if(!Cd.isPeerId(e))throw st.error("peerId must be an instance of peer-id to store data"),po(new Error("peerId must be an instance of peer-id"),Ur.ERR_INVALID_PARAMETERS);if(!Array.isArray(r))throw st.error("protocols must be provided to store data"),po(new Error("protocols must be provided"),Ur.ERR_INVALID_PARAMETERS);st("add await write lock");let n=await this._store.lock.writeLock();st("add got write lock");let i;try{try{let s=await this._store.load(e);if(new Set([...s.protocols,...r]).size===s.protocols.length)return}catch(s){if(s.code!==Ur.ERR_NOT_FOUND)throw s}i=await this._store.mergeOrCreate(e,{protocols:r}),st(`added provided protocols for ${e.toB58String()}`)}finally{st("add release write lock"),n()}this._emit(Ou,{peerId:e,protocols:i.protocols})}async remove(e,r){if(!Cd.isPeerId(e))throw st.error("peerId must be an instance of peer-id to store data"),po(new Error("peerId must be an instance of peer-id"),Ur.ERR_INVALID_PARAMETERS);if(!Array.isArray(r))throw st.error("protocols must be provided to store data"),po(new Error("protocols must be provided"),Ur.ERR_INVALID_PARAMETERS);st("remove await write lock");let n=await this._store.lock.writeLock();st("remove got write lock");let i;try{try{let s=await this._store.load(e),o=new Set(s.protocols);for(let a of r)o.delete(a);if(s.protocols.length===o.size)return;r=Array.from(o)}catch(s){if(s.code!==Ur.ERR_NOT_FOUND)throw s}i=await this._store.patchOrCreate(e,{protocols:r})}finally{st("remove release write lock"),n()}this._emit(Ou,{peerId:e,protocols:i.protocols})}async delete(e){st("delete await write lock");let r=await this._store.lock.writeLock();st("delete got write lock");let n;try{n=await this._store.has(e),await this._store.patchOrCreate(e,{protocols:[]})}catch(i){if(i.code!==Ur.ERR_NOT_FOUND)throw i}finally{st("delete release write lock"),r()}n&&this._emit(Ou,{peerId:e,protocols:[]})}};pS.exports=dS});var mS=w((EK,gS)=>{"use strict";var hi=Ln(),yo=hi.Reader,Id=hi.Writer,qe=hi.util,pt=hi.roots["libp2p-peer"]||(hi.roots["libp2p-peer"]={});pt.Peer=function(){function t(r){if(this.addresses=[],this.protocols=[],this.metadata=[],r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}t.prototype.addresses=qe.emptyArray,t.prototype.protocols=qe.emptyArray,t.prototype.metadata=qe.emptyArray,t.prototype.pubKey=null,t.prototype.peerRecordEnvelope=null;var e;return Object.defineProperty(t.prototype,"_pubKey",{get:qe.oneOfGetter(e=["pubKey"]),set:qe.oneOfSetter(e)}),Object.defineProperty(t.prototype,"_peerRecordEnvelope",{get:qe.oneOfGetter(e=["peerRecordEnvelope"]),set:qe.oneOfSetter(e)}),t.encode=function(n,i){if(i||(i=Id.create()),n.addresses!=null&&n.addresses.length)for(var s=0;s<n.addresses.length;++s)pt.Address.encode(n.addresses[s],i.uint32(10).fork()).ldelim();if(n.protocols!=null&&n.protocols.length)for(var s=0;s<n.protocols.length;++s)i.uint32(18).string(n.protocols[s]);if(n.metadata!=null&&n.metadata.length)for(var s=0;s<n.metadata.length;++s)pt.Metadata.encode(n.metadata[s],i.uint32(26).fork()).ldelim();return n.pubKey!=null&&Object.hasOwnProperty.call(n,"pubKey")&&i.uint32(34).bytes(n.pubKey),n.peerRecordEnvelope!=null&&Object.hasOwnProperty.call(n,"peerRecordEnvelope")&&i.uint32(42).bytes(n.peerRecordEnvelope),i},t.decode=function(n,i){n instanceof yo||(n=yo.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new pt.Peer;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.addresses&&o.addresses.length||(o.addresses=[]),o.addresses.push(pt.Address.decode(n,n.uint32()));break;case 2:o.protocols&&o.protocols.length||(o.protocols=[]),o.protocols.push(n.string());break;case 3:o.metadata&&o.metadata.length||(o.metadata=[]),o.metadata.push(pt.Metadata.decode(n,n.uint32()));break;case 4:o.pubKey=n.bytes();break;case 5:o.peerRecordEnvelope=n.bytes();break;default:n.skipType(a&7);break}}return o},t.fromObject=function(n){if(n instanceof pt.Peer)return n;var i=new pt.Peer;if(n.addresses){if(!Array.isArray(n.addresses))throw TypeError(".Peer.addresses: array expected");i.addresses=[];for(var s=0;s<n.addresses.length;++s){if(typeof n.addresses[s]!="object")throw TypeError(".Peer.addresses: object expected");i.addresses[s]=pt.Address.fromObject(n.addresses[s])}}if(n.protocols){if(!Array.isArray(n.protocols))throw TypeError(".Peer.protocols: array expected");i.protocols=[];for(var s=0;s<n.protocols.length;++s)i.protocols[s]=String(n.protocols[s])}if(n.metadata){if(!Array.isArray(n.metadata))throw TypeError(".Peer.metadata: array expected");i.metadata=[];for(var s=0;s<n.metadata.length;++s){if(typeof n.metadata[s]!="object")throw TypeError(".Peer.metadata: object expected");i.metadata[s]=pt.Metadata.fromObject(n.metadata[s])}}return n.pubKey!=null&&(typeof n.pubKey=="string"?qe.base64.decode(n.pubKey,i.pubKey=qe.newBuffer(qe.base64.length(n.pubKey)),0):n.pubKey.length&&(i.pubKey=n.pubKey)),n.peerRecordEnvelope!=null&&(typeof n.peerRecordEnvelope=="string"?qe.base64.decode(n.peerRecordEnvelope,i.peerRecordEnvelope=qe.newBuffer(qe.base64.length(n.peerRecordEnvelope)),0):n.peerRecordEnvelope.length&&(i.peerRecordEnvelope=n.peerRecordEnvelope)),i},t.toObject=function(n,i){i||(i={});var s={};if((i.arrays||i.defaults)&&(s.addresses=[],s.protocols=[],s.metadata=[]),n.addresses&&n.addresses.length){s.addresses=[];for(var o=0;o<n.addresses.length;++o)s.addresses[o]=pt.Address.toObject(n.addresses[o],i)}if(n.protocols&&n.protocols.length){s.protocols=[];for(var o=0;o<n.protocols.length;++o)s.protocols[o]=n.protocols[o]}if(n.metadata&&n.metadata.length){s.metadata=[];for(var o=0;o<n.metadata.length;++o)s.metadata[o]=pt.Metadata.toObject(n.metadata[o],i)}return n.pubKey!=null&&n.hasOwnProperty("pubKey")&&(s.pubKey=i.bytes===String?qe.base64.encode(n.pubKey,0,n.pubKey.length):i.bytes===Array?Array.prototype.slice.call(n.pubKey):n.pubKey,i.oneofs&&(s._pubKey="pubKey")),n.peerRecordEnvelope!=null&&n.hasOwnProperty("peerRecordEnvelope")&&(s.peerRecordEnvelope=i.bytes===String?qe.base64.encode(n.peerRecordEnvelope,0,n.peerRecordEnvelope.length):i.bytes===Array?Array.prototype.slice.call(n.peerRecordEnvelope):n.peerRecordEnvelope,i.oneofs&&(s._peerRecordEnvelope="peerRecordEnvelope")),s},t.prototype.toJSON=function(){return this.constructor.toObject(this,hi.util.toJSONOptions)},t}();pt.Address=function(){function t(r){if(r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}t.prototype.multiaddr=qe.newBuffer([]),t.prototype.isCertified=null;var e;return Object.defineProperty(t.prototype,"_isCertified",{get:qe.oneOfGetter(e=["isCertified"]),set:qe.oneOfSetter(e)}),t.encode=function(n,i){return i||(i=Id.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),n.isCertified!=null&&Object.hasOwnProperty.call(n,"isCertified")&&i.uint32(16).bool(n.isCertified),i},t.decode=function(n,i){n instanceof yo||(n=yo.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new pt.Address;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.multiaddr=n.bytes();break;case 2:o.isCertified=n.bool();break;default:n.skipType(a&7);break}}return o},t.fromObject=function(n){if(n instanceof pt.Address)return n;var i=new pt.Address;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?qe.base64.decode(n.multiaddr,i.multiaddr=qe.newBuffer(qe.base64.length(n.multiaddr)),0):n.multiaddr.length&&(i.multiaddr=n.multiaddr)),n.isCertified!=null&&(i.isCertified=Boolean(n.isCertified)),i},t.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.multiaddr="":(s.multiaddr=[],i.bytes!==Array&&(s.multiaddr=qe.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?qe.base64.encode(n.multiaddr,0,n.multiaddr.length):i.bytes===Array?Array.prototype.slice.call(n.multiaddr):n.multiaddr),n.isCertified!=null&&n.hasOwnProperty("isCertified")&&(s.isCertified=n.isCertified,i.oneofs&&(s._isCertified="isCertified")),s},t.prototype.toJSON=function(){return this.constructor.toObject(this,hi.util.toJSONOptions)},t}();pt.Metadata=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.key="",t.prototype.value=qe.newBuffer([]),t.encode=function(r,n){return n||(n=Id.create()),r.key!=null&&Object.hasOwnProperty.call(r,"key")&&n.uint32(10).string(r.key),r.value!=null&&Object.hasOwnProperty.call(r,"value")&&n.uint32(18).bytes(r.value),n},t.decode=function(r,n){r instanceof yo||(r=yo.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new pt.Metadata;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.key=r.string();break;case 2:s.value=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof pt.Metadata)return r;var n=new pt.Metadata;return r.key!=null&&(n.key=String(r.key)),r.value!=null&&(typeof r.value=="string"?qe.base64.decode(r.value,n.value=qe.newBuffer(qe.base64.length(r.value)),0):r.value.length&&(n.value=r.value)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.key="",n.bytes===String?i.value="":(i.value=[],n.bytes!==Array&&(i.value=qe.newBuffer(i.value)))),r.key!=null&&r.hasOwnProperty("key")&&(i.key=r.key),r.value!=null&&r.hasOwnProperty("value")&&(i.value=n.bytes===String?qe.base64.encode(r.value,0,r.value.length):n.bytes===Array?Array.prototype.slice.call(r.value):r.value),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,hi.util.toJSONOptions)},t}();gS.exports=pt});var Td=w((wK,vS)=>{vS.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}});var bS=w(()=>{});var RS=w((SK,TS)=>{var y6=Qt().EventEmitter,{nanoid:g6}=(Kc(),Gf),{WORKER_REQUEST_READ_LOCK:ES,WORKER_RELEASE_READ_LOCK:wS,MASTER_GRANT_READ_LOCK:_S,WORKER_REQUEST_WRITE_LOCK:xS,WORKER_RELEASE_WRITE_LOCK:SS,MASTER_GRANT_WRITE_LOCK:AS}=Td(),Ta,CS=(t,e,r,n,i)=>(s,o)=>{o&&o.type===r&&t.emit(e,o.name,()=>(s.send({type:i,name:o.name,identifier:o.identifier}),new Promise(a=>{let c=u=>{u&&u.type===n&&u.identifier===o.identifier&&(s.removeListener("message",c),a())};s.on("message",c)})))},IS=(t,e,r,n)=>()=>{let i=g6();return process.send({type:e,identifier:i,name:t}),new Promise(s=>{let o=a=>{a&&a.type===r&&a.identifier===i&&(process.removeListener("message",o),s(()=>{process.send({type:n,identifier:i,name:t})}))};process.on("message",o)})};TS.exports=t=>{try{if(Ta=bS(),!Object.keys(Ta).length)return}catch(e){return}if(Ta.isMaster||t.singleProcess){let e=new y6;return Ta.on("message",CS(e,"requestReadLock",ES,wS,_S)),Ta.on("message",CS(e,"requestWriteLock",xS,SS,AS)),e}return{isWorker:!0,readLock:e=>IS(e,ES,_S,wS),writeLock:e=>IS(e,xS,AS,SS)}}});var Rd=w((AK,BS)=>{var di={},go=t=>{t.addEventListener("message",e=>{go.dispatchEvent("message",t,e)}),t.port&&t.port.addEventListener("message",e=>{go.dispatchEvent("message",t,e)})};go.addEventListener=(t,e)=>{di[t]||(di[t]=[]),di[t].push(e)};go.removeEventListener=(t,e)=>{!di[t]||(di[t]=di[t].filter(r=>r===e))};go.dispatchEvent=function(){let t=Array.prototype.slice.call(arguments),e=t.shift();!di[e]||di[e].forEach(r=>r.apply(null,t))};BS.exports=go});var KS=w((CK,FS)=>{var m6=Qt().EventEmitter,{nanoid:v6}=(Kc(),Gf),{WORKER_REQUEST_READ_LOCK:PS,WORKER_RELEASE_READ_LOCK:NS,MASTER_GRANT_READ_LOCK:OS,WORKER_REQUEST_WRITE_LOCK:DS,WORKER_RELEASE_WRITE_LOCK:LS,MASTER_GRANT_WRITE_LOCK:kS}=Td(),qS=Rd(),US=(t,e,r,n,i)=>(s,o)=>{if(!o||!o.data||o.data.type!==r)return;let a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};t.emit(e,a.name,()=>(s.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(c=>{let u=l=>{if(!l||!l.data)return;let f={type:l.data.type,name:l.data.name,identifier:l.data.identifier};f&&f.type===n&&f.identifier===a.identifier&&(s.removeEventListener("message",u),c())};s.addEventListener("message",u)})))},MS=(t,e,r,n)=>()=>{let i=v6();return globalThis.postMessage({type:e,identifier:i,name:t}),new Promise(s=>{let o=a=>{if(!a||!a.data)return;let c={type:a.data.type,identifier:a.data.identifier};c&&c.type===r&&c.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:n,identifier:i,name:t})}))};globalThis.addEventListener("message",o)})},b6={singleProcess:!1};FS.exports=t=>{if(t=Object.assign({},b6,t),!!globalThis.document||t.singleProcess){let r=new m6;return qS.addEventListener("message",US(r,"requestReadLock",PS,NS,OS)),qS.addEventListener("message",US(r,"requestWriteLock",DS,LS,kS)),r}return{isWorker:!0,readLock:r=>MS(r,PS,OS,NS),writeLock:r=>MS(r,DS,kS,LS)}}});var jS=w((IK,Bd)=>{"use strict";var E6=Object.prototype.hasOwnProperty,Gt="~";function Ra(){}Object.create&&(Ra.prototype=Object.create(null),new Ra().__proto__||(Gt=!1));function w6(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function VS(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new w6(r,n||t,i),o=Gt?Gt+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],s]:t._events[o].push(s):(t._events[o]=s,t._eventsCount++),t}function Du(t,e){--t._eventsCount==0?t._events=new Ra:delete t._events[e]}function Ut(){this._events=new Ra,this._eventsCount=0}Ut.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)E6.call(r,n)&&e.push(Gt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};Ut.prototype.listeners=function(e){var r=Gt?Gt+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Ut.prototype.listenerCount=function(e){var r=Gt?Gt+e:e,n=this._events[r];return n?n.fn?1:n.length:0};Ut.prototype.emit=function(e,r,n,i,s,o){var a=Gt?Gt+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,l,f;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,s),!0;case 6:return c.fn.call(c.context,r,n,i,s,o),!0}for(f=1,l=new Array(u-1);f<u;f++)l[f-1]=arguments[f];c.fn.apply(c.context,l)}else{var h=c.length,p;for(f=0;f<h;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),u){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,i);break;default:if(!l)for(p=1,l=new Array(u-1);p<u;p++)l[p-1]=arguments[p];c[f].fn.apply(c[f].context,l)}}return!0};Ut.prototype.on=function(e,r,n){return VS(this,e,r,n,!1)};Ut.prototype.once=function(e,r,n){return VS(this,e,r,n,!0)};Ut.prototype.removeListener=function(e,r,n,i){var s=Gt?Gt+e:e;if(!this._events[s])return this;if(!r)return Du(this,s),this;var o=this._events[s];if(o.fn)o.fn===r&&(!i||o.once)&&(!n||o.context===n)&&Du(this,s);else{for(var a=0,c=[],u=o.length;a<u;a++)(o[a].fn!==r||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:Du(this,s)}return this};Ut.prototype.removeAllListeners=function(e){var r;return e?(r=Gt?Gt+e:e,this._events[r]&&Du(this,r)):(this._events=new Ra,this._eventsCount=0),this};Ut.prototype.off=Ut.prototype.removeListener;Ut.prototype.addListener=Ut.prototype.on;Ut.prefixed=Gt;Ut.EventEmitter=Ut;typeof Bd!="undefined"&&(Bd.exports=Ut)});var HS=w((TK,$S)=>{"use strict";$S.exports=(t,e)=>(e=e||(()=>{}),t.then(r=>new Promise(n=>{n(e())}).then(()=>r),r=>new Promise(n=>{n(e())}).then(()=>{throw r})))});var GS=w((RK,Lu)=>{"use strict";var _6=HS(),Pd=class extends Error{constructor(e){super(e);this.name="TimeoutError"}},zS=(t,e,r)=>new Promise((n,i)=>{if(typeof e!="number"||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0){n(t);return}let s=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let o=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,a=r instanceof Error?r:new Pd(o);typeof t.cancel=="function"&&t.cancel(),i(a)},e);_6(t.then(n,i),()=>{clearTimeout(s)})});Lu.exports=zS;Lu.exports.default=zS;Lu.exports.TimeoutError=Pd});var WS=w(Nd=>{"use strict";Object.defineProperty(Nd,"__esModule",{value:!0});function x6(t,e,r){let n=0,i=t.length;for(;i>0;){let s=i/2|0,o=n+s;r(t[o],e)<=0?(n=++o,i-=s+1):i=s}return n}Nd.default=x6});var QS=w(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:!0});var S6=WS(),YS=class{constructor(){this._queue=[]}enqueue(e,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=S6.default(this._queue,n,(s,o)=>o.priority-s.priority);this._queue.splice(i,0,n)}dequeue(){let e=this._queue.shift();return e==null?void 0:e.run}filter(e){return this._queue.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this._queue.length}};Od.default=YS});var JS=w(Dd=>{"use strict";Object.defineProperty(Dd,"__esModule",{value:!0});var A6=jS(),XS=GS(),C6=QS(),ku=()=>{},I6=new XS.TimeoutError,ZS=class extends A6{constructor(e){var r,n,i,s;super();if(this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=ku,this._resolveIdle=ku,e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:C6.default},e),!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||e.interval===0,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=e.throwOnTimeout===!0,this._isPaused=e.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=ku,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=ku,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let e=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-e;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),e&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,r={}){return new Promise((n,i)=>{let s=async()=>{this._pendingCount++,this._intervalCount++;try{let o=this._timeout===void 0&&r.timeout===void 0?e():XS.default(Promise.resolve(e()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(I6)});n(await o)}catch(o){i(o)}this._next()};this._queue.enqueue(s,r),this._tryToStartAnother(),this.emit("add")})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(e=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),e()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(e=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),e()}})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}};Dd.default=ZS});var eA=w((DK,Ld)=>{"use strict";var qu,OK=Ld.exports.timeout=function(t,e){var r=new qu,n;return Promise.race([t,new Promise(function(i,s){n=setTimeout(function(){s(r)},e)})]).then(function(i){return clearTimeout(n),i},function(i){throw clearTimeout(n),i})};qu=Ld.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"};qu.prototype=Object.create(Error.prototype);qu.prototype.name="TimeoutError"});var rA=w((LK,qd)=>{var T6=RS(),R6=KS(),{default:tA}=JS(),{timeout:B6}=eA(),P6=Rd(),ns={},pi;function kd(t,e){let r,n=new Promise(i=>{r=i});return t.add(()=>B6((()=>new Promise(i=>{r(()=>{i()})}))(),e.timeout)),n}var N6=(t,e)=>{if(pi.isWorker)return{readLock:pi.readLock(t,e),writeLock:pi.writeLock(t,e)};let r=new tA({concurrency:1}),n=null;return{readLock:()=>{if(n)return kd(n,e);n=new tA({concurrency:e.concurrency,autoStart:!1});let i=n,s=kd(n,e);return r.add(()=>(i.start(),i.onIdle().then(()=>{n===i&&(n=null)}))),s},writeLock:()=>(n=null,kd(r,e))}},O6={concurrency:1/0,timeout:846e5,global:globalThis,singleProcess:!1};qd.exports=(t,e)=>(e||(e={}),typeof t=="object"&&(e=t,t="lock"),t||(t="lock"),e=Object.assign({},O6,e),pi||(pi=T6(e)||R6(e),pi.isWorker||(pi.on("requestReadLock",(r,n)=>{!ns[r]||ns[r].readLock().then(i=>n().finally(()=>i()))}),pi.on("requestWriteLock",async(r,n)=>{!ns[r]||ns[r].writeLock().then(i=>n().finally(()=>i()))}))),ns[t]||(ns[t]=N6(t,e)),ns[t]);qd.exports.Worker=function(t,e){e=e||globalThis.Worker;let r;try{r=new e(t)}catch(n){n.message.includes("not a constructor")&&(r=e(t))}if(!r)throw new Error("Could not create Worker from",e);return P6(r),r}});var hA=w((kK,fA)=>{"use strict";var nA=Be(),iA=Tt(),sA=pe(),{codes:Uu}=He(),{Key:D6}=(jc(),Wf),{base32:L6}=(vi(),mi),{keys:{unmarshalPublicKey:k6,marshalPublicKey:q6}}=bu(),{Multiaddr:oA}=kt(),{Peer:aA}=mS(),U6=rA(),{equals:M6}=(yr(),pr),cA=Object.assign(nA("libp2p:peer-store:store"),{error:nA("libp2p:peer-store:store:err")}),uA="/peers/",lA=class{constructor(e){this._datastore=e,this.lock=U6("peer-store",{singleProcess:!0})}_peerIdToDatastoreKey(e){if(!iA.isPeerId(e))throw cA.error("peerId must be an instance of peer-id to store data"),sA(new Error("peerId must be an instance of peer-id"),Uu.ERR_INVALID_PARAMETERS);let r=e.toString();return new D6(`${uA}${r}`)}async has(e){return this._datastore.has(this._peerIdToDatastoreKey(e))}async delete(e){await this._datastore.delete(this._peerIdToDatastoreKey(e))}async load(e){let r=await this._datastore.get(this._peerIdToDatastoreKey(e)),n=aA.decode(r),i=n.pubKey?k6(n.pubKey):e.pubKey,s=new Map;for(let o of n.metadata)s.set(o.key,o.value);return{...n,id:e,pubKey:i,addresses:n.addresses.map(({multiaddr:o,isCertified:a})=>({multiaddr:new oA(o),isCertified:a||!1})),metadata:s,peerRecordEnvelope:n.peerRecordEnvelope||void 0}}async save(e){if(e.pubKey!=null&&e.id.pubKey!=null&&!M6(e.pubKey.bytes,e.id.pubKey.bytes))throw cA.error("peer publicKey bytes do not match peer id publicKey bytes"),sA(new Error("publicKey bytes do not match peer id publicKey bytes"),Uu.ERR_INVALID_PARAMETERS);let r=aA.encode({addresses:e.addresses.sort((n,i)=>n.multiaddr.toString().localeCompare(i.multiaddr.toString())).map(({multiaddr:n,isCertified:i})=>({multiaddr:n.bytes,isCertified:i})),protocols:e.protocols.sort(),pubKey:e.pubKey?q6(e.pubKey):void 0,metadata:[...e.metadata.keys()].sort().map(n=>({key:n,value:e.metadata.get(n)})),peerRecordEnvelope:e.peerRecordEnvelope}).finish();return await this._datastore.put(this._peerIdToDatastoreKey(e.id),r),this.load(e.id)}async patch(e,r){let n=await this.load(e);return await this._patch(e,r,n)}async patchOrCreate(e,r){let n;try{n=await this.load(e)}catch(i){if(i.code!==Uu.ERR_NOT_FOUND)throw i;n={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._patch(e,r,n)}async _patch(e,r,n){return await this.save({...n,...r,id:e})}async merge(e,r){let n=await this.load(e);return this._merge(e,r,n)}async mergeOrCreate(e,r){let n;try{n=await this.load(e)}catch(i){if(i.code!==Uu.ERR_NOT_FOUND)throw i;n={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._merge(e,r,n)}async _merge(e,r,n){let i=new Map;return(r.addresses||[]).forEach(s=>{i.set(s.multiaddr.toString(),s.isCertified)}),n.addresses.forEach(({multiaddr:s,isCertified:o})=>{let a=s.toString();i.set(a,Boolean(i.get(a)||o))}),await this.save({id:e,addresses:Array.from(i.entries()).map(([s,o])=>({multiaddr:new oA(s),isCertified:o})),protocols:Array.from(new Set([...n.protocols||[],...r.protocols||[]])),metadata:new Map([...n.metadata?n.metadata.entries():[],...r.metadata?r.metadata.entries():[]]),pubKey:r.pubKey||(n!=null?n.pubKey:void 0),peerRecordEnvelope:r.peerRecordEnvelope||(n!=null?n.peerRecordEnvelope:void 0)})}async*all(){for await(let e of this._datastore.queryKeys({prefix:uA})){let r=e.toString().split("/")[2],n=L6.decode(r);yield this.load(iA.createFromBytes(n))}}};fA.exports=lA});var gA=w((qK,yA)=>{"use strict";var dA=Be(),{EventEmitter:F6}=Qt(),K6=rS(),V6=aS(),j6=fS(),$6=yS(),H6=hA(),Cr=Object.assign(dA("libp2p:peer-store"),{error:dA("libp2p:peer-store:err")}),pA=class extends F6{constructor({peerId:e,datastore:r}){super();this._peerId=e,this._store=new H6(r),this.addressBook=new K6(this.emit.bind(this),this._store),this.keyBook=new V6(this.emit.bind(this),this._store),this.metadataBook=new j6(this.emit.bind(this),this._store),this.protoBook=new $6(this.emit.bind(this),this._store)}async*getPeers(){Cr("getPeers await read lock");let e=await this._store.lock.readLock();Cr("getPeers got read lock");try{for await(let r of this._store.all())r.id.toB58String()!==this._peerId.toB58String()&&(yield r)}finally{Cr("getPeers release read lock"),e()}}async delete(e){Cr("delete await write lock");let r=await this._store.lock.writeLock();Cr("delete got write lock");try{await this._store.delete(e)}finally{Cr("delete release write lock"),r()}}async get(e){Cr("get await read lock");let r=await this._store.lock.readLock();Cr("get got read lock");try{return this._store.load(e)}finally{Cr("get release read lock"),r()}}async has(e){Cr("has await read lock");let r=await this._store.lock.readLock();Cr("has got read lock");try{return this._store.has(e)}finally{Cr("has release read lock"),r()}}};yA.exports=pA});var vA=w((UK,mA)=>{"use strict";function z6(t,e,r){let n=new t(e,r);n._subscribeAdapter=n.subscribe,n._unsubscribeAdapter=n.unsubscribe;function i(o,a){a&&n.on(o,a),n._subscribeAdapter(o)}function s(o,a){a?n.removeListener(o,a):n.removeAllListeners(o),n.listenerCount(o)===0&&n._unsubscribeAdapter(o)}return n.subscribe=i,n.unsubscribe=s,n}mA.exports=z6});var xA=w((MK,_A)=>{"use strict";var bA=()=>{},EA=Symbol.for("@libp2p/js-interfaces/topology"),wA=class{constructor({min:e=0,max:r=1/0,handlers:n={}}){this.min=e,this.max=r,this._onConnect=n.onConnect||bA,this._onDisconnect=n.onDisconnect||bA,this.peers=new Set}get[Symbol.toStringTag](){return"Topology"}get[EA](){return!0}static isTopology(e){return Boolean(e&&e[EA])}async setRegistrar(e){this._registrar=e}disconnect(e){this._onDisconnect(e)}};_A.exports=wA});var IA=w((FK,CA)=>{"use strict";var SA=Be(),G6=Object.assign(SA("libp2p:registrar"),{error:SA("libp2p:registrar:err")}),W6=pe(),{codes:{ERR_INVALID_PARAMETERS:Y6}}=He(),Q6=xA(),AA=class{constructor({peerStore:e,connectionManager:r}){this.peerStore=e,this.connectionManager=r,this.topologies=new Map,this._handle=void 0,this._onDisconnect=this._onDisconnect.bind(this),this.connectionManager.on("peer:disconnect",this._onDisconnect)}get handle(){return this._handle}set handle(e){this._handle=e}getConnection(e){return this.connectionManager.get(e)}async register(e){if(!Q6.isTopology(e))throw G6.error("topology must be an instance of interfaces/topology"),W6(new Error("topology must be an instance of interfaces/topology"),Y6);let r=(Math.random()*1e9).toString(36)+Date.now();return this.topologies.set(r,e),await e.setRegistrar(this),r}unregister(e){return this.topologies.delete(e)}_onDisconnect(e){for(let[,r]of this.topologies)r.disconnect(e.remotePeer)}};CA.exports=AA});var Ud=w((KK,Ba)=>{"use strict";var{Buffer:Mu}=si(),Fu=Gi();Ba.exports=async function*(t){for await(let e of t)Mu.isBuffer(e)?yield e:Fu.isBufferList(e)?yield e.slice():yield Mu.from(e)};Ba.exports.toBuffer=Ba.exports;Ba.exports.toList=async function*(t){for await(let e of t)Mu.isBuffer(e)?yield new Fu().append(e):Fu.isBufferList(e)?yield e:yield new Fu().append(Mu.from(e))}});var RA=w((VK,TA)=>{"use strict";TA.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32,PROTOCOL_VERSION:"1.0.0",PROTOCOL_NAME:"ping"}});var OA=w((Ku,NA)=>{"use strict";var BA=Be(),Md=Object.assign(BA("libp2p:ping"),{error:BA("libp2p:ping:err")}),X6=pe(),{codes:Z6}=He(),J6=bu(),{pipe:PA}=nn(),{toBuffer:ek}=Ud(),{collect:tk,take:rk}=xu(),{equals:nk}=(yr(),pr),{PROTOCOL_NAME:Fd,PING_LENGTH:ik,PROTOCOL_VERSION:Kd}=RA();async function sk(t,e){let r=`/${t._config.protocolPrefix}/${Fd}/${Kd}`;Md("dialing %s to %s",r,e.toB58String?e.toB58String():e);let n=await t.dial(e),{stream:i}=await n.newStream(r),s=Date.now(),o=J6.randomBytes(ik),[a]=await PA([o],i,u=>rk(1,u),ek,tk),c=Date.now();if(!nk(o,a))throw X6(new Error("Received wrong ping ack"),Z6.ERR_WRONG_PING_ACK);return c-s}function ok(t){t.handle(`/${t._config.protocolPrefix}/${Fd}/${Kd}`,({stream:e})=>PA(e,e)).catch(e=>{Md.error(e)})}function ak(t){t.unhandle(`/${t._config.protocolPrefix}/${Fd}/${Kd}`).catch(e=>{Md.error(e)})}Ku=NA.exports=sk;Ku.mount=ok;Ku.unmount=ak});var kA=w((jK,LA)=>{"use strict";var mo=Ln(),DA=mo.Reader,ck=mo.Writer,rt=mo.util,Pa=mo.roots["libp2p-identify"]||(mo.roots["libp2p-identify"]={});Pa.Identify=function(){function t(e){if(this.listenAddrs=[],this.protocols=[],e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.protocolVersion="",t.prototype.agentVersion="",t.prototype.publicKey=rt.newBuffer([]),t.prototype.listenAddrs=rt.emptyArray,t.prototype.observedAddr=rt.newBuffer([]),t.prototype.protocols=rt.emptyArray,t.prototype.signedPeerRecord=rt.newBuffer([]),t.encode=function(r,n){if(n||(n=ck.create()),r.publicKey!=null&&Object.hasOwnProperty.call(r,"publicKey")&&n.uint32(10).bytes(r.publicKey),r.listenAddrs!=null&&r.listenAddrs.length)for(var i=0;i<r.listenAddrs.length;++i)n.uint32(18).bytes(r.listenAddrs[i]);if(r.protocols!=null&&r.protocols.length)for(var i=0;i<r.protocols.length;++i)n.uint32(26).string(r.protocols[i]);return r.observedAddr!=null&&Object.hasOwnProperty.call(r,"observedAddr")&&n.uint32(34).bytes(r.observedAddr),r.protocolVersion!=null&&Object.hasOwnProperty.call(r,"protocolVersion")&&n.uint32(42).string(r.protocolVersion),r.agentVersion!=null&&Object.hasOwnProperty.call(r,"agentVersion")&&n.uint32(50).string(r.agentVersion),r.signedPeerRecord!=null&&Object.hasOwnProperty.call(r,"signedPeerRecord")&&n.uint32(66).bytes(r.signedPeerRecord),n},t.decode=function(r,n){r instanceof DA||(r=DA.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new Pa.Identify;r.pos<i;){var o=r.uint32();switch(o>>>3){case 5:s.protocolVersion=r.string();break;case 6:s.agentVersion=r.string();break;case 1:s.publicKey=r.bytes();break;case 2:s.listenAddrs&&s.listenAddrs.length||(s.listenAddrs=[]),s.listenAddrs.push(r.bytes());break;case 4:s.observedAddr=r.bytes();break;case 3:s.protocols&&s.protocols.length||(s.protocols=[]),s.protocols.push(r.string());break;case 8:s.signedPeerRecord=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof Pa.Identify)return r;var n=new Pa.Identify;if(r.protocolVersion!=null&&(n.protocolVersion=String(r.protocolVersion)),r.agentVersion!=null&&(n.agentVersion=String(r.agentVersion)),r.publicKey!=null&&(typeof r.publicKey=="string"?rt.base64.decode(r.publicKey,n.publicKey=rt.newBuffer(rt.base64.length(r.publicKey)),0):r.publicKey.length&&(n.publicKey=r.publicKey)),r.listenAddrs){if(!Array.isArray(r.listenAddrs))throw TypeError(".Identify.listenAddrs: array expected");n.listenAddrs=[];for(var i=0;i<r.listenAddrs.length;++i)typeof r.listenAddrs[i]=="string"?rt.base64.decode(r.listenAddrs[i],n.listenAddrs[i]=rt.newBuffer(rt.base64.length(r.listenAddrs[i])),0):r.listenAddrs[i].length&&(n.listenAddrs[i]=r.listenAddrs[i])}if(r.observedAddr!=null&&(typeof r.observedAddr=="string"?rt.base64.decode(r.observedAddr,n.observedAddr=rt.newBuffer(rt.base64.length(r.observedAddr)),0):r.observedAddr.length&&(n.observedAddr=r.observedAddr)),r.protocols){if(!Array.isArray(r.protocols))throw TypeError(".Identify.protocols: array expected");n.protocols=[];for(var i=0;i<r.protocols.length;++i)n.protocols[i]=String(r.protocols[i])}return r.signedPeerRecord!=null&&(typeof r.signedPeerRecord=="string"?rt.base64.decode(r.signedPeerRecord,n.signedPeerRecord=rt.newBuffer(rt.base64.length(r.signedPeerRecord)),0):r.signedPeerRecord.length&&(n.signedPeerRecord=r.signedPeerRecord)),n},t.toObject=function(r,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.listenAddrs=[],i.protocols=[]),n.defaults&&(n.bytes===String?i.publicKey="":(i.publicKey=[],n.bytes!==Array&&(i.publicKey=rt.newBuffer(i.publicKey))),n.bytes===String?i.observedAddr="":(i.observedAddr=[],n.bytes!==Array&&(i.observedAddr=rt.newBuffer(i.observedAddr))),i.protocolVersion="",i.agentVersion="",n.bytes===String?i.signedPeerRecord="":(i.signedPeerRecord=[],n.bytes!==Array&&(i.signedPeerRecord=rt.newBuffer(i.signedPeerRecord)))),r.publicKey!=null&&r.hasOwnProperty("publicKey")&&(i.publicKey=n.bytes===String?rt.base64.encode(r.publicKey,0,r.publicKey.length):n.bytes===Array?Array.prototype.slice.call(r.publicKey):r.publicKey),r.listenAddrs&&r.listenAddrs.length){i.listenAddrs=[];for(var s=0;s<r.listenAddrs.length;++s)i.listenAddrs[s]=n.bytes===String?rt.base64.encode(r.listenAddrs[s],0,r.listenAddrs[s].length):n.bytes===Array?Array.prototype.slice.call(r.listenAddrs[s]):r.listenAddrs[s]}if(r.protocols&&r.protocols.length){i.protocols=[];for(var s=0;s<r.protocols.length;++s)i.protocols[s]=r.protocols[s]}return r.observedAddr!=null&&r.hasOwnProperty("observedAddr")&&(i.observedAddr=n.bytes===String?rt.base64.encode(r.observedAddr,0,r.observedAddr.length):n.bytes===Array?Array.prototype.slice.call(r.observedAddr):r.observedAddr),r.protocolVersion!=null&&r.hasOwnProperty("protocolVersion")&&(i.protocolVersion=r.protocolVersion),r.agentVersion!=null&&r.hasOwnProperty("agentVersion")&&(i.agentVersion=r.agentVersion),r.signedPeerRecord!=null&&r.hasOwnProperty("signedPeerRecord")&&(i.signedPeerRecord=n.bytes===String?rt.base64.encode(r.signedPeerRecord,0,r.signedPeerRecord.length):n.bytes===Array?Array.prototype.slice.call(r.signedPeerRecord):r.signedPeerRecord),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,mo.util.toJSONOptions)},t}();LA.exports=Pa});var HA=w(($K,$A)=>{"use strict";var qA=Be(),Ir=Object.assign(qA("libp2p:identify"),{error:qA("libp2p:identify:err")}),Vd=pe(),Vu=Ea(),{pipe:ju}=nn(),{collect:UA,take:MA,consume:FA}=xu(),{fromString:vo}=(Ct(),Pt),uk=Tt(),{Multiaddr:jd}=kt(),{toBuffer:KA}=Ud(),Na=kA(),VA=ru(),jA=iu(),{MULTICODEC_IDENTIFY:lk,MULTICODEC_IDENTIFY_PUSH:fk,IDENTIFY_PROTOCOL_VERSION:hk,MULTICODEC_IDENTIFY_PROTOCOL_NAME:dk,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME:pk,MULTICODEC_IDENTIFY_PROTOCOL_VERSION:yk,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION:gk}=uh(),{codes:$d}=He(),is=class{static getProtocolStr(e){return{identifyProtocolStr:`/${e._config.protocolPrefix}/${dk}/${yk}`,identifyPushProtocolStr:`/${e._config.protocolPrefix}/${pk}/${gk}`}}constructor({libp2p:e}){this._libp2p=e,this.peerStore=e.peerStore,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.peerId=e.peerId,this.handleMessage=this.handleMessage.bind(this);let r=is.getProtocolStr(e);this.identifyProtocolStr=r.identifyProtocolStr,this.identifyPushProtocolStr=r.identifyPushProtocolStr,this._host={protocolVersion:`${e._config.protocolPrefix}/${hk}`,...e._options.host},this.connectionManager.on("peer:connect",n=>{this.identify(n).catch(Ir.error)}),this.peerStore.on("change:multiaddrs",({peerId:n})=>{n.toString()===this.peerId.toString()&&this.pushToPeerStore().catch(i=>Ir.error(i))}),this.peerStore.on("change:protocols",({peerId:n})=>{n.toString()===this.peerId.toString()&&this.pushToPeerStore().catch(i=>Ir.error(i))})}async start(){await this.peerStore.metadataBook.setValue(this.peerId,"AgentVersion",vo(this._host.agentVersion)),await this.peerStore.metadataBook.setValue(this.peerId,"ProtocolVersion",vo(this._host.protocolVersion))}async stop(){}async push(e){let r=await this.peerStore.addressBook.getRawEnvelope(this.peerId),n=this._libp2p.multiaddrs.map(o=>o.bytes),i=await this.peerStore.protoBook.get(this.peerId),s=e.map(async o=>{try{let{stream:a}=await o.newStream(this.identifyPushProtocolStr);await ju([Na.Identify.encode({listenAddrs:n,signedPeerRecord:r,protocols:i}).finish()],Vu.encode(),a,FA)}catch(a){Ir.error("could not push identify update to peer",a)}});return Promise.all(s)}async pushToPeerStore(){if(!this._libp2p.isStarted())return;let e=[],r;for await(let n of this.peerStore.getPeers())n.protocols.includes(this.identifyPushProtocolStr)&&(r=this.connectionManager.get(n.id))&&e.push(r);await this.push(e)}async identify(e){let{stream:r}=await e.newStream(this.identifyProtocolStr),[n]=await ju([],r,Vu.decode(),MA(1),KA,UA);if(!n)throw Vd(new Error("No data could be retrieved"),$d.ERR_CONNECTION_ENDED);let i;try{i=Na.Identify.decode(n)}catch(h){throw Vd(h,$d.ERR_INVALID_MESSAGE)}let{publicKey:s,listenAddrs:o,protocols:a,observedAddr:c,signedPeerRecord:u}=i,l=await uk.createFromPubKey(s);if(e.remotePeer.toB58String()!==l.toB58String())throw Vd(new Error("identified peer does not match the expected peer"),$d.ERR_INVALID_PEER);let f=is.getCleanMultiaddr(c);try{let h=await VA.openAndCertify(u,jA.DOMAIN);if(await this.peerStore.addressBook.consumePeerRecord(h)){await this.peerStore.protoBook.set(l,a),await this.peerStore.metadataBook.setValue(l,"AgentVersion",vo(i.agentVersion)),await this.peerStore.metadataBook.setValue(l,"ProtocolVersion",vo(i.protocolVersion));return}}catch(h){Ir("received invalid envelope, discard it and fallback to listenAddrs is available",h)}try{await this.peerStore.addressBook.set(l,o.map(h=>new jd(h)))}catch(h){Ir.error("received invalid addrs",h)}await this.peerStore.protoBook.set(l,a),await this.peerStore.metadataBook.setValue(l,"AgentVersion",vo(i.agentVersion)),await this.peerStore.metadataBook.setValue(l,"ProtocolVersion",vo(i.protocolVersion)),Ir("received observed address of %s",f)}handleMessage({connection:e,stream:r,protocol:n}){switch(n){case this.identifyProtocolStr:return this._handleIdentify({connection:e,stream:r});case this.identifyPushProtocolStr:return this._handlePush({connection:e,stream:r});default:Ir.error("cannot handle unknown protocol %s",n)}}async _handleIdentify({connection:e,stream:r}){let n=new Uint8Array(0);this.peerId.pubKey&&(n=this.peerId.pubKey.bytes);let i=await this.peerStore.addressBook.getRawEnvelope(this.peerId),s=await this.peerStore.protoBook.get(this.peerId),o=Na.Identify.encode({protocolVersion:this._host.protocolVersion,agentVersion:this._host.agentVersion,publicKey:n,listenAddrs:this._libp2p.multiaddrs.map(a=>a.bytes),signedPeerRecord:i,observedAddr:e.remoteAddr.bytes,protocols:s}).finish();try{await ju([o],Vu.encode(),r,FA)}catch(a){Ir.error("could not respond to identify request",a)}}async _handlePush({connection:e,stream:r}){let n;try{let[s]=await ju([],r,Vu.decode(),MA(1),KA,UA);n=Na.Identify.decode(s)}catch(s){return Ir.error("received invalid message",s)}let i=e.remotePeer;try{let s=await VA.openAndCertify(n.signedPeerRecord,jA.DOMAIN);if(await this.peerStore.addressBook.consumePeerRecord(s)){await this.peerStore.protoBook.set(i,n.protocols);return}}catch(s){Ir("received invalid envelope, discard it and fallback to listenAddrs is available",s)}try{await this.peerStore.addressBook.set(i,n.listenAddrs.map(s=>new jd(s)))}catch(s){Ir.error("received invalid addrs",s)}await this.peerStore.protoBook.set(i,n.protocols)}static getCleanMultiaddr(e){if(e&&e.length>0)try{return new jd(e)}catch(r){return null}return null}},mk={IDENTIFY:lk,IDENTIFY_PUSH:fk};is.multicodecs=mk;is.Messsage=Na;$A.exports=is});var zA=w(()=>{});var GA=w(Hd=>{"use strict";Object.defineProperty(Hd,"__esModule",{value:!0}),Hd.promisify=$u;var vk="__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";function $u(t){if(typeof t!="function")throw new TypeError("Argument to promisify must be a function");var e=t[vk],r=$u.Promise||Promise;if(typeof r!="function")throw new Error("No Promise implementation found; do you need a polyfill?");return function(){for(var n=this,i=arguments.length,s=Array(i),o=0;o<i;o++)s[o]=arguments[o];return new r(function(a,c){s.push(function(u){if(u)return c(u);for(var l=arguments.length,f=Array(1<l?l-1:0),h=1;h<l;h++)f[h-1]=arguments[h];if(f.length===1||!e)return a(f[0]);var p={};f.forEach(function(d,g){var m=e[g];m&&(p[m]=d)}),a(p)}),t.apply(n,s)})}}$u.argumentNames="__ES6-PROMISIFY--CUSTOM-ARGUMENTS__",$u.Promise=void 0});var YA=w((WK,WA)=>{function bk(){return typeof window!="undefined"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process!="undefined"&&typeof process.versions=="object"&&!!process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0}WA.exports=bk});var XA=w((YK,QA)=>{"use strict";var Ek=YA(),Hu=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Oa=Ek(),wk=Hu&&!Oa,_k=Oa&&!Hu,xk=Oa&&Hu,Sk=typeof Jd=="function"&&typeof process!="undefined"&&typeof process.release!="undefined"&&process.release.name==="node"&&!Oa,Ak=typeof importScripts=="function"&&typeof self!="undefined"&&typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope,Ck=typeof process!="undefined"&&typeof process.env!="undefined"&&!1;QA.exports={isTest:Ck,isElectron:Oa,isElectronMain:_k,isElectronRenderer:xk,isNode:Sk,isBrowser:wk,isWebWorker:Ak,isEnvWithDom:Hu}});var JA=w((QK,ZA)=>{function Tr(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}ZA.exports=Tr;Tr.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Tr.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};Tr.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0};Tr.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Tr.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};Tr.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};Tr.prototype.start=Tr.prototype.try;Tr.prototype.errors=function(){return this._errors};Tr.prototype.attempts=function(){return this._attempts};Tr.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],s=i.message,o=(t[s]||0)+1;t[s]=o,o>=r&&(e=i,r=o)}return e}});var eC=w(ss=>{var Ik=JA();ss.operation=function(t){var e=ss.timeouts(t);return new Ik(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};ss.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in t)e[r]=t[r];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<e.retries;i++)n.push(this.createTimeout(i,e));return t&&t.forever&&!n.length&&n.push(this.createTimeout(i,e)),n.sort(function(s,o){return s-o}),n};ss.createTimeout=function(t,e){var r=e.randomize?Math.random()+1:1,n=Math.round(r*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return n=Math.min(n,e.maxTimeout),n};ss.wrap=function(t,e,r){if(e instanceof Array&&(r=e,e=null),!r){r=[];for(var n in t)typeof t[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var s=r[i],o=t[s];t[s]=function(c){var u=ss.operation(e),l=Array.prototype.slice.call(arguments,1),f=l.pop();l.push(function(h){u.retry(h)||(h&&(arguments[0]=u.mainError()),f.apply(this,arguments))}),u.attempt(function(){c.apply(t,l)})}.bind(t,o),t[s].options=e}}});var rC=w((ZK,tC)=>{tC.exports=eC()});var iC=w((JK,zu)=>{"use strict";var Tk=rC(),Rk=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"],zd=class extends Error{constructor(e){super();e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},Bk=(t,e,r)=>{let n=r.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=n,t},Pk=t=>Rk.includes(t),nC=(t,e)=>new Promise((r,n)=>{e={onFailedAttempt:()=>{},retries:10,...e};let i=Tk.operation(e);i.attempt(async s=>{try{r(await t(s))}catch(o){if(!(o instanceof Error)){n(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));return}if(o instanceof zd)i.stop(),n(o.originalError);else if(o instanceof TypeError&&!Pk(o.message))i.stop(),n(o);else{Bk(o,s,e);try{await e.onFailedAttempt(o)}catch(a){n(a);return}i.retry(o)||n(i.mainError())}}})});zu.exports=nC;zu.exports.default=nC;zu.exports.AbortError=zd});var oC=w((eV,sC)=>{"use strict";function Nk(t){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^::1$/.test(t)}sC.exports=Nk});var cC=w((tV,aC)=>{"use strict";var Ok=oC();function Dk(t){let{address:e}=t.nodeAddress();return Ok(e)}aC.exports=Dk});var pC=w((rV,dC)=>{"use strict";var Lk=zA(),uC=Be(),{promisify:Gd}=GA(),{Multiaddr:kk}=kt(),bo=Object.assign(uC("libp2p:nat"),{error:uC("libp2p:nat:err")}),{isBrowser:lC}=XA(),Wd=iC(),qk=lh(),fC=ch(),Uk=pe(),{codes:{ERR_INVALID_PARAMETERS:Mk}}=He(),Fk=cC(),Yd=7200;function Kk(t=1024,e=65535){return Math.floor(Math.random()*(e-t+1)+t)}var hC=class{constructor({peerId:e,addressManager:r,transportManager:n,...i}){if(this._peerId=e,this._addressManager=r,this._transportManager=n,this._enabled=i.enabled,this._externalIp=i.externalIp,this._options={description:i.description||`${fC.name}@${fC.version} ${this._peerId}`,ttl:i.ttl||Yd,autoUpdate:i.keepAlive||!0,gateway:i.gateway,enablePMP:Boolean(i.pmp&&i.pmp.enabled)},this._options.ttl<Yd)throw Uk(new Error(`NatManager ttl should be at least ${Yd} seconds`),Mk)}start(){lC||!this._enabled||this._start().catch(e=>{bo.error(e)})}async _start(){let e=this._transportManager.getAddrs();for(let r of e){let{family:n,host:i,port:s,transport:o}=r.toOptions();if(!r.isThinWaistAddress()||o!=="tcp"||Fk(r)||n!==4)continue;let a=this._getClient(),c=this._externalIp||await a.externalIp();if(qk(c))throw new Error(`${c} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);let u=Kk();bo(`opening uPnP connection from ${c}:${u} to ${i}:${s}`),await a.map({publicPort:u,privatePort:s,protocol:o.toUpperCase()}),this._addressManager.addObservedAddr(kk.fromNodeAddress({family:4,address:c,port:u},o))}}_getClient(){if(this._client)return this._client;let e=new Lk(this._options),r=Gd(e.map.bind(e)),n=Gd(e.destroy.bind(e)),i=Gd(e.externalIp.bind(e));return this._client={map:(...s)=>Wd(()=>r(...s),{onFailedAttempt:bo.error,unref:!0}),destroy:(...s)=>Wd(()=>n(...s),{onFailedAttempt:bo.error,unref:!0}),externalIp:(...s)=>Wd(()=>i(...s),{onFailedAttempt:bo.error,unref:!0})},this._client}async stop(){if(!(lC||!this._client))try{await this._client.destroy(),this._client=null}catch(e){bo.error(e)}}};dC.exports=hC});var u5=w((nV,bC)=>{"use strict";var yC=Be(),Mt=Object.assign(yC("libp2p"),{error:yC("libp2p:err")}),{EventEmitter:Vk}=Qt(),Qd=pe(),jk=Tt(),{Multiaddr:$k}=kt(),{MemoryDatastore:Hk}=(r1(),t1),zk=O1(),Gk=M1(),Xd=sh(),{validate:Wk}=rE(),{codes:Gu,messages:Yk}=He(),Qk=sE(),Xk=_E(),Zk=IE(),gC=d2(),Jk=A2(),e5=n_(),mC=tx(),t5=vx(),r5=bh(),n5=Qx(),i5=gA(),s5=vA(),o5=IA(),Wu=OA(),vC=HA(),a5=pC(),{updateSelfPeerRecord:c5}=mh(),Da=class extends Vk{static async create(e){if(e.peerId)return new Da(e);let r=await jk.create();return e.peerId=r,new Da(e)}constructor(e){super();if(this._options=Wk(e),this.peerId=this._options.peerId,this.datastore=this._options.datastore,this._options.metrics.enabled){let n=new t5({...this._options.metrics});this.metrics=n}if(this.peerStore=new i5({peerId:this.peerId,datastore:this.datastore&&this._options.peerStore.persistence?this.datastore:new Hk}),this.addresses=this._options.addresses,this.addressManager=new Qk(this.peerId,this._options.addresses),this.addressManager.on("change:addresses",()=>{c5(this).catch(n=>{Mt.error("Error updating self peer record",n)})}),this._modules=this._options.modules,this._config=this._options.config,this._transport=[],this._discovery=new Map,this.connectionManager=new Xk(this,{...this._options.connectionManager}),this._autodialler=new Zk(this,{enabled:this._config.peerDiscovery.autoDial,minConnections:this._options.connectionManager.minConnections,autoDialInterval:this._options.connectionManager.autoDialInterval}),this._options.keychain&&this._options.keychain.datastore){Mt("creating keychain");let n=mC.generateOptions();this.keychain=new mC(this._options.keychain.datastore,{...n,...this._options.keychain}),Mt("keychain constructed")}if(this.upgrader=new n5({localPeer:this.peerId,metrics:this.metrics,onConnection:n=>this.connectionManager.onConnect(n),onConnectionEnd:n=>this.connectionManager.onDisconnect(n)}),this.transportManager=new r5({libp2p:this,upgrader:this.upgrader,faultTolerance:this._options.transportManager.faultTolerance}),this.natManager=new a5({peerId:this.peerId,addressManager:this.addressManager,transportManager:this.transportManager,...this._options.config.nat}),this.registrar=new o5({peerStore:this.peerStore,connectionManager:this.connectionManager}),this.handle=this.handle.bind(this),this.registrar.handle=this.handle,!this._modules.connEncryption||!this._modules.connEncryption.length)throw Qd(new Error(Yk.CONN_ENCRYPTION_REQUIRED),Gu.CONN_ENCRYPTION_REQUIRED);if(this._modules.connEncryption.forEach(n=>{this.upgrader.cryptos.set(n.protocol,n)}),this.dialer=new e5({transportManager:this.transportManager,peerStore:this.peerStore,metrics:this.metrics,...this._options.dialer}),this._modules.transport.forEach(n=>{let i=n.prototype[Symbol.toStringTag],s=this._config.transport[i];this.transportManager.add(i,n,s)}),this._config.relay.enabled&&(this.transportManager.add(gC.prototype[Symbol.toStringTag],gC),this.relay=new Jk(this)),this._modules.streamMuxer&&(this._modules.streamMuxer.forEach(i=>{this.upgrader.muxers.set(i.multicodec,i)}),this.identifyService=new vC({libp2p:this})),this._modules.connProtector)this.upgrader.protector=this._modules.connProtector;else if(globalThis.process!==void 0&&globalThis.process.env&&globalThis.process.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._modules.dht){let n=this._modules.dht;this._dht=n.create({libp2p:this,...this._config.dht})}if(this._modules.pubsub){let n=this._modules.pubsub;this.pubsub=s5(n,this,this._config.pubsub)}this.peerRouting=new zk(this),this.contentRouting=new Gk(this),Wu.mount(this),this._onDiscoveryPeer=this._onDiscoveryPeer.bind(this)}emit(e,...r){return e==="error"&&!this._events.error?(Mt.error(r),!1):super.emit(e,...r)}async start(){Mt("libp2p is starting"),this.identifyService&&await this.handle(Object.values(vC.getProtocolStr(this)),this.identifyService.handleMessage);try{await this._onStarting(),await this._onDidStart(),Mt("libp2p has started")}catch(e){throw this.emit("error",e),Mt.error("An error occurred starting libp2p",e),await this.stop(),e}}async stop(){Mt("libp2p is stopping");try{this._isStarted=!1,this.identifyService&&await this.identifyService.stop(),this.relay&&this.relay.stop(),this.peerRouting.stop(),await this._autodialler.stop(),await(this._dht&&this._dht.stop());for(let e of this._discovery.values())e.removeListener("peer",this._onDiscoveryPeer);await Promise.all(Array.from(this._discovery.values(),e=>e.stop())),this._discovery=new Map,await this.connectionManager.stop(),await Promise.all([this.pubsub&&this.pubsub.stop(),this.metrics&&this.metrics.stop()]),await this.natManager.stop(),await this.transportManager.close(),Wu.unmount(this),this.dialer.destroy()}catch(e){e&&(Mt.error(e),this.emit("error",e))}Mt("libp2p has stopped")}async loadKeychain(){if(!!this.keychain)try{await this.keychain.findKeyByName("self")}catch(e){await this.keychain.importPeer("self",this.peerId)}}isStarted(){return this._isStarted}get connections(){return this.connectionManager.connections}dial(e,r){return this._dial(e,r)}async dialProtocol(e,r,n){if(!r||!r.length)throw Qd(new Error("no protocols were provided to open a stream"),Gu.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this._dial(e,n)).newStream(r)}async _dial(e,r){let{id:n,multiaddrs:i}=Xd(e);if(n.equals(this.peerId))throw Qd(new Error("Cannot dial self"),Gu.ERR_DIALED_SELF);let s=this.connectionManager.get(n);return s?i&&await this.peerStore.addressBook.add(n,i):s=await this.dialer.connectToPeer(e,r),s}get multiaddrs(){let e=this.addressManager.getAnnounceAddrs().map(i=>i.toString());e.length||(e=this.transportManager.getAddrs().map(i=>i.toString())),e=e.concat(this.addressManager.getObservedAddrs().map(i=>i.toString()));let r=this._options.addresses.announceFilter,n=new Set(e);return r(Array.from(n).map(i=>new $k(i)))}async hangUp(e){let{id:r}=Xd(e),n=this.connectionManager.connections.get(r.toB58String());!n||await Promise.all(n.map(i=>i.close()))}ping(e){let{id:r,multiaddrs:n}=Xd(e);return n?Wu(this,n[0]):Wu(this,r)}async handle(e,r){e=Array.isArray(e)?e:[e],e.forEach(n=>{this.upgrader.protocols.set(n,r)}),await this.peerStore.protoBook.add(this.peerId,e)}async unhandle(e){e=Array.isArray(e)?e:[e],e.forEach(r=>{this.upgrader.protocols.delete(r)}),await this.peerStore.protoBook.remove(this.peerId,e)}async _onStarting(){let e=this.addressManager.getListenAddrs();await this.transportManager.listen(e),this.natManager.start(),this._config.pubsub.enabled&&this.pubsub&&await this.pubsub.start(),this._config.dht.enabled&&(this._dht&&await this._dht.start(),this._dht.on("peer",this._onDiscoveryPeer)),this.metrics&&this.metrics.start(),this.identifyService&&await this.identifyService.start()}async _onDidStart(){this._isStarted=!0,this.peerStore.on("peer",e=>{this.emit("peer:discovery",e),this._maybeConnect(e).catch(r=>{Mt.error(r)})});for await(let e of this.peerStore.getPeers())this.emit("peer:discovery",e.id);this.connectionManager.start(),await this._autodialler.start(),await this._setupPeerDiscovery(),this.relay&&this.relay.start(),this.peerRouting.start()}_onDiscoveryPeer(e){if(e.id.toB58String()===this.peerId.toB58String()){Mt.error(new Error(Gu.ERR_DISCOVERED_SELF));return}e.multiaddrs&&this.peerStore.addressBook.add(e.id,e.multiaddrs).catch(r=>Mt.error(r)),e.protocols&&this.peerStore.protoBook.set(e.id,e.protocols).catch(r=>Mt.error(r))}async _maybeConnect(e){if(this._config.peerDiscovery.autoDial===!0&&!this.connectionManager.get(e)&&(this._options.connectionManager.minConnections||0)>this.connectionManager.size){Mt("connecting to discovered peer %s",e.toB58String());try{await this.dialer.connectToPeer(e)}catch(n){Mt.error(`could not connect to discovered peer ${e.toB58String()} with ${n}`)}}}async _setupPeerDiscovery(){let e=r=>{let n={enabled:!0};if(r.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[r.tag]&&(n={...n,...this._config.peerDiscovery[r.tag]}),n.enabled&&!this._discovery.has(r.tag)){let i;typeof r=="function"?i=new r(Object.assign({},n,{peerId:this.peerId,libp2p:this})):i=r,i.on("peer",this._onDiscoveryPeer),this._discovery.set(r.tag,i)}};for(let r of this._modules.peerDiscovery||[])e(r);for(let r of this.transportManager.getTransports())r.discovery&&e(r.discovery);await Promise.all(Array.from(this._discovery.values(),r=>r.start()))}};bC.exports=Da});return u5();})();
44
+ `+WD(r,4);super(r);this.name="AggregateError",Object.defineProperty(this,"_errors",{value:e})}*[Symbol.iterator](){for(let e of this._errors)yield e}};e_.exports=J2});var r_=w((yK,hd)=>{"use strict";var fd=class extends Error{constructor(e){super(e||"Promise was canceled");this.name="CancelError"}get isCanceled(){return!0}},Pa=class{static fn(e){return(...r)=>new Pa((n,i,s)=>{r.push(s),e(...r).then(n,i)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,n)=>{this._reject=n;let i=a=>{(!this._isCanceled||!o.shouldReject)&&(this._isPending=!1,r(a))},s=a=>{this._isPending=!1,n(a)},o=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(o,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),e(i,s,o)})}then(e,r){return this._promise.then(e,r)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(!(!this._isPending||this._isCanceled)){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(let r of this._cancelHandlers)r()}catch(r){this._reject(r);return}this._rejectOnCancel&&this._reject(new fd(e))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(Pa.prototype,Promise.prototype);hd.exports=Pa;hd.exports.CancelError=fd});var i_=w((gK,Cu)=>{"use strict";var n_=t_(),XD=r_(),dd=class extends Error{},ZD=(t,e)=>new XD((r,n,i)=>{let{count:s,filter:o=()=>!0}=e;if(!Number.isFinite(s)){n(new TypeError(`Expected a finite number, got ${typeof e.count}`));return}let a=[],c=[],u=0,l=!1,f=new Set,h=()=>(a.length===s&&(r(a),l=!0),u-c.length<s&&(n(new n_(c)),l=!0),l),p=()=>{for(let d of t)!f.has(d)&&typeof d.cancel=="function"&&d.cancel()};i(p);for(let d of t)u++,(async()=>{try{let g=await d;if(l)return;if(!o(g))throw new dd("Value does not satisfy filter");a.push(g)}catch(g){c.push(g)}finally{f.add(d),!l&&h()&&p()}})();s>u&&(n(new RangeError(`Expected input to contain at least ${e.count} items, but contains ${u} items`)),p())});Cu.exports=ZD;Cu.exports.AggregateError=n_;Cu.exports.FilterError=dd});var s_=w((mK,yd)=>{"use strict";var pd=class extends Error{constructor(e){super(e||"Promise was canceled");this.name="CancelError"}get isCanceled(){return!0}},Na=class{static fn(e){return(...r)=>new Na((n,i,s)=>{r.push(s),e(...r).then(n,i)})}constructor(e){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((r,n)=>{this._reject=n;let i=a=>{(!this._isCanceled||!o.shouldReject)&&(this._isPending=!1,r(a))},s=a=>{this._isPending=!1,n(a)},o=a=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(a)};return Object.defineProperties(o,{shouldReject:{get:()=>this._rejectOnCancel,set:a=>{this._rejectOnCancel=a}}}),e(i,s,o)})}then(e,r){return this._promise.then(e,r)}catch(e){return this._promise.catch(e)}finally(e){return this._promise.finally(e)}cancel(e){if(!(!this._isPending||this._isCanceled)){if(this._isCanceled=!0,this._cancelHandlers.length>0)try{for(let r of this._cancelHandlers)r()}catch(r){this._reject(r);return}this._rejectOnCancel&&this._reject(new pd(e))}}get isCanceled(){return this._isCanceled}};Object.setPrototypeOf(Na.prototype,Promise.prototype);yd.exports=Na;yd.exports.CancelError=pd});var a_=w((vK,gd)=>{"use strict";var o_=i_(),JD=s_();gd.exports=(t,e)=>{let r=o_(t,{...e,count:1});return JD.fn(async n=>{n(()=>{r.cancel()});let[i]=await r;return i})()};gd.exports.AggregateError=o_.AggregateError});var f_=w((bK,l_)=>{"use strict";var eL=he(),{anySignal:tL}=ld(),rL=H2(),nL=a_(),{setMaxListeners:c_}=Qt(),{codes:iL}=je(),u_=class{constructor({addrs:e,dialAction:r,dialer:n}){this.addrs=e,this.dialer=n,this.dialAction=r}async run(e={}){let r=this.dialer.getTokens(this.addrs.length);if(r.length<1)throw eL(new Error("No dial tokens available"),iL.ERR_NO_DIAL_TOKENS);let n=new rL;r.forEach(o=>n.push(o));let i=this.addrs.map(()=>{let o=new AbortController;try{c_&&c_(1/0,o.signal)}catch{}return o}),s=0;try{return await nL(this.addrs.map(async(o,a)=>{let c=await n.shift(),u;try{let l=i[a].signal;u=await this.dialAction(o,{...e,signal:e.signal?tL([l,e.signal]):l}),i.splice(a,1)}finally{s++,this.addrs.length-s>=r.length?n.push(c):this.dialer.releaseToken(r.splice(r.indexOf(c),1)[0])}return u}))}finally{i.map(o=>o.abort()),r.forEach(o=>this.dialer.releaseToken(o))}}};l_.exports=u_});var v_=w((EK,m_)=>{"use strict";var h_=Te(),io=Object.assign(h_("libp2p:dialer"),{error:h_("libp2p:dialer:err")}),md=he(),{Multiaddr:vd}=qt(),{TimeoutController:sL}=oh(),{AbortError:oL}=vu(),{anySignal:aL}=ld(),{setMaxListeners:d_}=Qt(),cL=f_(),{publicAddressesFirst:uL}=Eh(),lL=ph(),p_=Ph(),{codes:Iu}=je(),{DIAL_TIMEOUT:fL,MAX_PARALLEL_DIALS:hL,MAX_PER_PEER_DIALS:dL,MAX_ADDRS_TO_DIAL:pL}=au(),y_="dialler",yL="pending-dials",gL="pending-dial-targets",g_=class{constructor({transportManager:e,peerStore:r,addressSorter:n=uL,maxParallelDials:i=hL,maxAddrsToDial:s=pL,dialTimeout:o=fL,maxDialsPerPeer:a=dL,resolvers:c={},metrics:u}){this.transportManager=e,this.peerStore=r,this.addressSorter=n,this.maxParallelDials=i,this.maxAddrsToDial=s,this.timeout=o,this.maxDialsPerPeer=a,this.tokens=[...new Array(i)].map((l,f)=>f),this._pendingDials=p_({component:y_,metric:yL,metrics:u}),this._pendingDialTargets=p_({component:y_,metric:gL,metrics:u});for(let[l,f]of Object.entries(c))vd.resolvers.set(l,f)}destroy(){for(let e of this._pendingDials.values())try{e.controller.abort()}catch(r){io.error(r)}this._pendingDials.clear();for(let e of this._pendingDialTargets.values())e.reject(new oL("Dialer was destroyed"));this._pendingDialTargets.clear()}async connectToPeer(e,r={}){let n=await this._createCancellableDialTarget(e);if(!n.addrs.length)throw md(new Error("The dial request has no valid addresses"),Iu.ERR_NO_VALID_ADDRESSES);let i=this._pendingDials.get(n.id)||this._createPendingDial(n,r);try{let s=await i.promise;return io("dial succeeded to %s",n.id),s}catch(s){throw i.controller.signal.aborted&&(s.code=Iu.ERR_TIMEOUT),io.error(s),s}finally{i.destroy()}}async _createCancellableDialTarget(e){let r=`${parseInt(String(Math.random()*1e9),10).toString()+Date.now()}`,n=new Promise((i,s)=>{this._pendingDialTargets.set(r,{resolve:i,reject:s})});try{return await Promise.race([this._createDialTarget(e),n])}finally{this._pendingDialTargets.delete(r)}}async _createDialTarget(e){let{id:r,multiaddrs:n}=lL(e);n&&await this.peerStore.addressBook.add(r,n);let i=await this.peerStore.addressBook.getMultiaddrsForPeer(r,this.addressSorter)||[];vd.isMultiaddr(e)&&(i=i.filter(a=>!e.equals(a)),i.unshift(e));let s=[];for(let a of i)(await this._resolve(a)).forEach(u=>s.push(u));let o=s.filter(a=>this.transportManager.transportForMultiaddr(a));if(o.length>this.maxAddrsToDial)throw await this.peerStore.delete(r),md(new Error("dial with more addresses than allowed"),Iu.ERR_TOO_MANY_ADDRESSES);return{id:r.toB58String(),addrs:o}}_createPendingDial(e,r={}){let n=(u,l)=>{if(l.signal.aborted)throw md(new Error("already aborted"),Iu.ERR_ALREADY_ABORTED);return this.transportManager.dial(u,l)},i=new cL({addrs:e.addrs,dialAction:n,dialer:this}),s=new sL(this.timeout),o=[s.signal];r.signal&&o.push(r.signal);let a=aL(o);try{d_&&d_(1/0,a)}catch{}let c={dialRequest:i,controller:s,promise:i.run({...r,signal:a}),destroy:()=>{s.clear(),this._pendingDials.delete(e.id)}};return this._pendingDials.set(e.id,c),c}getTokens(e){let r=Math.min(e,this.maxDialsPerPeer,this.tokens.length),n=this.tokens.splice(0,r);return io("%d tokens request, returning %d, %d remaining",e,r,this.tokens.length),n}releaseToken(e){this.tokens.indexOf(e)>-1||(io("token %d released",e),this.tokens.push(e))}async _resolve(e){if(!e.protoNames().includes("dnsaddr"))return[e];let n=await this._resolveRecord(e);return(await Promise.all(n.map(o=>this._resolve(o)))).flat().reduce((o,a)=>(o.find(c=>c.equals(a))||o.push(a),o),[])}async _resolveRecord(e){try{return e=new vd(e.toString()),await e.resolve()}catch(r){return io.error(`multiaddr ${e} could not be resolved`),[]}}};m_.exports=g_});var E_=w((wK,b_)=>{"use strict";function mL(t){return t>=55296&&t<=56319}function vL(t){return t>=56320&&t<=57343}b_.exports=function(e,r,n){if(typeof r!="string")throw new Error("Input must be string");for(var i=r.length,s=0,o,a,c=0;c<i;c+=1){if(o=r.charCodeAt(c),a=r[c],mL(o)&&vL(r.charCodeAt(c+1))&&(c+=1,a+=r[c]),s+=e(a),s===n)return r.slice(0,c+1);if(s>n)return r.slice(0,c-a.length+1)}return r}});var __=w((_K,w_)=>{"use strict";function bL(t){return t>=55296&&t<=56319}function EL(t){return t>=56320&&t<=57343}w_.exports=function(e){if(typeof e!="string")throw new Error("Input must be string");for(var r=e.length,n=0,i=null,s=null,o=0;o<r;o++)i=e.charCodeAt(o),EL(i)?s!=null&&bL(s)?n+=1:n+=3:i<=127?n+=1:i>=128&&i<=2047?n+=2:i>=2048&&i<=65535&&(n+=3),s=i;return n}});var S_=w((xK,x_)=>{"use strict";var wL=E_(),_L=__();x_.exports=wL.bind(null,_L)});var I_=w((SK,C_)=>{"use strict";var xL=S_(),SL=/[\/\?<>\\:\*\|"]/g,AL=/[\x00-\x1f\x80-\x9f]/g,CL=/^\.+$/,IL=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,TL=/[\. ]+$/;function A_(t,e){if(typeof t!="string")throw new Error("Input must be string");var r=t.replace(SL,e).replace(AL,e).replace(CL,e).replace(IL,e).replace(TL,e);return xL(r,255)}C_.exports=function(t,e){var r=e&&e.replacement||"",n=A_(t,r);return r===""?n:A_(n,"")}});var B_=w((AK,R_)=>{"use strict";Ss();var Tu=be(),{toString:so}=(Tt(),Ot),{fromString:T_}=(It(),Nt);R_.exports={createCipheriv:(t,e,r)=>{let n=Tu.cipher.createCipher("AES-CTR",so(e,"ascii"));return n.start({iv:so(r,"ascii")}),{update:i=>(n.update(Tu.util.createBuffer(so(i,"ascii"))),T_(n.output.getBytes(),"ascii"))}},createDecipheriv:(t,e,r)=>{let n=Tu.cipher.createDecipher("AES-CTR",so(e,"ascii"));return n.start({iv:so(r,"ascii")}),{update:i=>(n.update(Tu.util.createBuffer(so(i,"ascii"))),T_(n.output.getBytes(),"ascii"))}}}});var O_=w((CK,N_)=>{"use strict";var RL=he(),P_={16:"aes-128-ctr",32:"aes-256-ctr"};N_.exports=function(t){let e=P_[t.length];if(!e){let r=Object.entries(P_).map(([n,i])=>`${n} (${i})`).join(" / ");throw RL(new Error(`Invalid key length ${t.length} bytes. Must be ${r}`),"ERR_INVALID_KEY_LENGTH")}return e}});var k_=w(L_=>{"use strict";var D_=B_(),BL=O_();L_.create=async function(t,e){let r=BL(t),n=D_.createCipheriv(r,t,e),i=D_.createDecipheriv(r,t,e);return{async encrypt(o){return n.update(o)},async decrypt(o){return i.update(o)}}}});var M_=w((TK,U_)=>{"use strict";var PL=Vl(),NL=$e(),OL=he(),q_={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function DL(t,e,r,n,i){let s=q_[i];if(!s){let a=Object.keys(q_).join(" / ");throw OL(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}let o=PL(t,e,r,n,s);return NL.encode64(o)}U_.exports=DL});var Ru=w(oo=>{"use strict";var LL=Rf(),kL=k_(),qL=Fc();oo.aes=kL;oo.hmac=LL;oo.keys=qL;oo.randomBytes=Cc();oo.pbkdf2=M_()});var j_=w((BK,V_)=>{var ao=be();Kn();$e();var Z=ao.asn1,co=V_.exports=ao.pkcs7asn1=ao.pkcs7asn1||{};ao.pkcs7=ao.pkcs7||{};ao.pkcs7.asn1=co;var F_={name:"ContentInfo",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:Z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};co.contentInfoValidator=F_;var K_={name:"EncryptedContentInfo",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:Z.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:Z.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};co.envelopedDataValidator={name:"EnvelopedData",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(K_)};co.encryptedDataValidator={name:"EncryptedData",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1,capture:"version"}].concat(K_)};var UL={name:"SignerInfo",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:Z.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:Z.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:Z.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};co.signedDataValidator={name:"SignedData",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},F_,{name:"SignedData.Certificates",tagClass:Z.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:Z.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SET,capture:"signerInfos",optional:!0,value:[UL]}]};co.recipientInfoValidator={name:"RecipientInfo",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:Z.Class.UNIVERSAL,type:Z.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:Z.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:Z.Class.UNIVERSAL,type:Z.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}});var H_=w((PK,$_)=>{var Xi=be();$e();Xi.mgf=Xi.mgf||{};var ML=$_.exports=Xi.mgf.mgf1=Xi.mgf1=Xi.mgf1||{};ML.create=function(t){var e={generate:function(r,n){for(var i=new Xi.util.ByteBuffer,s=Math.ceil(n/t.digestLength),o=0;o<s;o++){var a=new Xi.util.ByteBuffer;a.putInt32(o),t.start(),t.update(r+a.getBytes()),i.putBuffer(t.digest())}return i.truncate(i.length()-n),i.getBytes()}};return e}});var G_=w((NK,z_)=>{var Bu=be();H_();z_.exports=Bu.mgf=Bu.mgf||{};Bu.mgf.mgf1=Bu.mgf1});var Y_=w((OK,W_)=>{var Zi=be();Si();$e();var FL=W_.exports=Zi.pss=Zi.pss||{};FL.create=function(t){arguments.length===3&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var e=t.md,r=t.mgf,n=e.digestLength,i=t.salt||null;typeof i=="string"&&(i=Zi.util.createBuffer(i));var s;if("saltLength"in t)s=t.saltLength;else if(i!==null)s=i.length();else throw new Error("Salt length not specified or specific salt not given.");if(i!==null&&i.length()!==s)throw new Error("Given salt length does not match length of given salt.");var o=t.prng||Zi.random,a={};return a.encode=function(c,u){var l,f=u-1,h=Math.ceil(f/8),p=c.digest().getBytes();if(h<n+s+2)throw new Error("Message is too long to encrypt.");var d;i===null?d=o.getBytesSync(s):d=i.bytes();var g=new Zi.util.ByteBuffer;g.fillWithByte(0,8),g.putBytes(p),g.putBytes(d),e.start(),e.update(g.getBytes());var m=e.digest().getBytes(),x=new Zi.util.ByteBuffer;x.fillWithByte(0,h-s-n-2),x.putByte(1),x.putBytes(d);var R=x.getBytes(),L=h-n-1,H=r.generate(m,L),q="";for(l=0;l<L;l++)q+=String.fromCharCode(R.charCodeAt(l)^H.charCodeAt(l));var k=65280>>8*h-f&255;return q=String.fromCharCode(q.charCodeAt(0)&~k)+q.substr(1),q+m+String.fromCharCode(188)},a.verify=function(c,u,l){var f,h=l-1,p=Math.ceil(h/8);if(u=u.substr(-p),p<n+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(u.charCodeAt(p-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var d=p-n-1,g=u.substr(0,d),m=u.substr(d,n),x=65280>>8*p-h&255;if((g.charCodeAt(0)&x)!=0)throw new Error("Bits beyond keysize not zero as expected.");var R=r.generate(m,d),L="";for(f=0;f<d;f++)L+=String.fromCharCode(g.charCodeAt(f)^R.charCodeAt(f));L=String.fromCharCode(L.charCodeAt(0)&~x)+L.substr(1);var H=p-n-s-2;for(f=0;f<H;f++)if(L.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(L.charCodeAt(H)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var q=L.substr(-s),k=new Zi.util.ByteBuffer;k.fillWithByte(0,8),k.putBytes(c),k.putBytes(q),e.start(),e.update(k.getBytes());var J=e.digest().getBytes();return m===J},a}});var Ed=w((DK,ex)=>{var oe=be();Ss();Kn();hc();Vn();G_();ws();gc();Y_();jo();$e();var y=oe.asn1,G=ex.exports=oe.pki=oe.pki||{},Ce=G.oids,ft={};ft.CN=Ce.commonName;ft.commonName="CN";ft.C=Ce.countryName;ft.countryName="C";ft.L=Ce.localityName;ft.localityName="L";ft.ST=Ce.stateOrProvinceName;ft.stateOrProvinceName="ST";ft.O=Ce.organizationName;ft.organizationName="O";ft.OU=Ce.organizationalUnitName;ft.organizationalUnitName="OU";ft.E=Ce.emailAddress;ft.emailAddress="E";var Q_=oe.pki.rsa.publicKeyValidator,KL={name:"Certificate",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:y.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:y.Class.UNIVERSAL,type:y.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:y.Class.UNIVERSAL,type:y.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:y.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:y.Class.UNIVERSAL,type:y.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:y.Class.UNIVERSAL,type:y.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:y.Class.UNIVERSAL,type:y.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:y.Class.UNIVERSAL,type:y.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},Q_,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:y.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:y.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:y.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:y.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},VL={name:"rsapss",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:y.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:y.Class.UNIVERSAL,type:y.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:y.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:y.Class.UNIVERSAL,type:y.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:y.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:y.Class.UNIVERSAL,type:y.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:y.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:y.Class.UNIVERSAL,type:y.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},jL={name:"CertificationRequestInfo",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:y.Class.UNIVERSAL,type:y.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},Q_,{name:"CertificationRequestInfo.attributes",tagClass:y.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:y.Class.UNIVERSAL,type:y.Type.SET,constructed:!0}]}]}]},$L={name:"CertificationRequest",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[jL,{name:"CertificationRequest.signatureAlgorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:y.Class.UNIVERSAL,type:y.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:y.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:y.Class.UNIVERSAL,type:y.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};G.RDNAttributesAsArray=function(t,e){for(var r=[],n,i,s,o=0;o<t.value.length;++o){n=t.value[o];for(var a=0;a<n.value.length;++a)s={},i=n.value[a],s.type=y.derToOid(i.value[0].value),s.value=i.value[1].value,s.valueTagClass=i.value[1].type,s.type in Ce&&(s.name=Ce[s.type],s.name in ft&&(s.shortName=ft[s.name])),e&&(e.update(s.type),e.update(s.value)),r.push(s)}return r};G.CRIAttributesAsArray=function(t){for(var e=[],r=0;r<t.length;++r)for(var n=t[r],i=y.derToOid(n.value[0].value),s=n.value[1].value,o=0;o<s.length;++o){var a={};if(a.type=i,a.value=s[o].value,a.valueTagClass=s[o].type,a.type in Ce&&(a.name=Ce[a.type],a.name in ft&&(a.shortName=ft[a.name])),a.type===Ce.extensionRequest){a.extensions=[];for(var c=0;c<a.value.length;++c)a.extensions.push(G.certificateExtensionFromAsn1(a.value[c]))}e.push(a)}return e};function ci(t,e){typeof e=="string"&&(e={shortName:e});for(var r=null,n,i=0;r===null&&i<t.attributes.length;++i)n=t.attributes[i],(e.type&&e.type===n.type||e.name&&e.name===n.name||e.shortName&&e.shortName===n.shortName)&&(r=n);return r}var Pu=function(t,e,r){var n={};if(t!==Ce["RSASSA-PSS"])return n;r&&(n={hash:{algorithmOid:Ce.sha1},mgf:{algorithmOid:Ce.mgf1,hash:{algorithmOid:Ce.sha1}},saltLength:20});var i={},s=[];if(!y.validate(e,VL,i,s)){var o=new Error("Cannot read RSASSA-PSS parameter block.");throw o.errors=s,o}return i.hashOid!==void 0&&(n.hash=n.hash||{},n.hash.algorithmOid=y.derToOid(i.hashOid)),i.maskGenOid!==void 0&&(n.mgf=n.mgf||{},n.mgf.algorithmOid=y.derToOid(i.maskGenOid),n.mgf.hash=n.mgf.hash||{},n.mgf.hash.algorithmOid=y.derToOid(i.maskGenHashOid)),i.saltLength!==void 0&&(n.saltLength=i.saltLength.charCodeAt(0)),n},Nu=function(t){switch(Ce[t.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return oe.md.sha1.create();case"md5WithRSAEncryption":return oe.md.md5.create();case"sha256WithRSAEncryption":return oe.md.sha256.create();case"sha384WithRSAEncryption":return oe.md.sha384.create();case"sha512WithRSAEncryption":return oe.md.sha512.create();case"RSASSA-PSS":return oe.md.sha256.create();default:var e=new Error("Could not compute "+t.type+" digest. Unknown signature OID.");throw e.signatureOid=t.signatureOid,e}},X_=function(t){var e=t.certificate,r;switch(e.signatureOid){case Ce.sha1WithRSAEncryption:case Ce.sha1WithRSASignature:break;case Ce["RSASSA-PSS"]:var n,i;if(n=Ce[e.signatureParameters.mgf.hash.algorithmOid],n===void 0||oe.md[n]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=e.signatureParameters.mgf.hash.algorithmOid,s.name=n,s}if(i=Ce[e.signatureParameters.mgf.algorithmOid],i===void 0||oe.mgf[i]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=e.signatureParameters.mgf.algorithmOid,s.name=i,s}if(i=oe.mgf[i].create(oe.md[n].create()),n=Ce[e.signatureParameters.hash.algorithmOid],n===void 0||oe.md[n]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=e.signatureParameters.hash.algorithmOid,s.name=n,s}r=oe.pss.create(oe.md[n].create(),i,e.signatureParameters.saltLength);break}return e.publicKey.verify(t.md.digest().getBytes(),t.signature,r)};G.certificateFromPem=function(t,e,r){var n=oe.pem.decode(t)[0];if(n.type!=="CERTIFICATE"&&n.type!=="X509 CERTIFICATE"&&n.type!=="TRUSTED CERTIFICATE"){var i=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=y.fromDer(n.body,r);return G.certificateFromAsn1(s,e)};G.certificateToPem=function(t,e){var r={type:"CERTIFICATE",body:y.toDer(G.certificateToAsn1(t)).getBytes()};return oe.pem.encode(r,{maxline:e})};G.publicKeyFromPem=function(t){var e=oe.pem.decode(t)[0];if(e.type!=="PUBLIC KEY"&&e.type!=="RSA PUBLIC KEY"){var r=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var n=y.fromDer(e.body);return G.publicKeyFromAsn1(n)};G.publicKeyToPem=function(t,e){var r={type:"PUBLIC KEY",body:y.toDer(G.publicKeyToAsn1(t)).getBytes()};return oe.pem.encode(r,{maxline:e})};G.publicKeyToRSAPublicKeyPem=function(t,e){var r={type:"RSA PUBLIC KEY",body:y.toDer(G.publicKeyToRSAPublicKey(t)).getBytes()};return oe.pem.encode(r,{maxline:e})};G.getPublicKeyFingerprint=function(t,e){e=e||{};var r=e.md||oe.md.sha1.create(),n=e.type||"RSAPublicKey",i;switch(n){case"RSAPublicKey":i=y.toDer(G.publicKeyToRSAPublicKey(t)).getBytes();break;case"SubjectPublicKeyInfo":i=y.toDer(G.publicKeyToAsn1(t)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+e.type+'".')}r.start(),r.update(i);var s=r.digest();if(e.encoding==="hex"){var o=s.toHex();return e.delimiter?o.match(/.{2}/g).join(e.delimiter):o}else{if(e.encoding==="binary")return s.getBytes();if(e.encoding)throw new Error('Unknown encoding "'+e.encoding+'".')}return s};G.certificationRequestFromPem=function(t,e,r){var n=oe.pem.decode(t)[0];if(n.type!=="CERTIFICATE REQUEST"){var i=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw i.headerType=n.type,i}if(n.procType&&n.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=y.fromDer(n.body,r);return G.certificationRequestFromAsn1(s,e)};G.certificationRequestToPem=function(t,e){var r={type:"CERTIFICATE REQUEST",body:y.toDer(G.certificationRequestToAsn1(t)).getBytes()};return oe.pem.encode(r,{maxline:e})};G.createCertificate=function(){var t={};return t.version=2,t.serialNumber="00",t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.validity={},t.validity.notBefore=new Date,t.validity.notAfter=new Date,t.issuer={},t.issuer.getField=function(e){return ci(t.issuer,e)},t.issuer.addField=function(e){Sr([e]),t.issuer.attributes.push(e)},t.issuer.attributes=[],t.issuer.hash=null,t.subject={},t.subject.getField=function(e){return ci(t.subject,e)},t.subject.addField=function(e){Sr([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.extensions=[],t.publicKey=null,t.md=null,t.setSubject=function(e,r){Sr(e),t.subject.attributes=e,delete t.subject.uniqueId,r&&(t.subject.uniqueId=r),t.subject.hash=null},t.setIssuer=function(e,r){Sr(e),t.issuer.attributes=e,delete t.issuer.uniqueId,r&&(t.issuer.uniqueId=r),t.issuer.hash=null},t.setExtensions=function(e){for(var r=0;r<e.length;++r)Z_(e[r],{cert:t});t.extensions=e},t.getExtension=function(e){typeof e=="string"&&(e={name:e});for(var r=null,n,i=0;r===null&&i<t.extensions.length;++i)n=t.extensions[i],(e.id&&n.id===e.id||e.name&&n.name===e.name)&&(r=n);return r},t.sign=function(e,r){t.md=r||oe.md.sha1.create();var n=Ce[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.tbsCertificate=G.getTBSCertificate(t);var s=y.toDer(t.tbsCertificate);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(e){var r=!1;if(!t.issued(e)){var n=e.issuer,i=t.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=i.attributes,s.actualIssuer=n.attributes,s}var o=e.md;if(o===null){o=Nu({signatureOid:e.signatureOid,type:"certificate"});var a=e.tbsCertificate||G.getTBSCertificate(e),c=y.toDer(a);o.update(c.getBytes())}return o!==null&&(r=X_({certificate:t,md:o,signature:e.signature})),r},t.isIssuer=function(e){var r=!1,n=t.issuer,i=e.subject;if(n.hash&&i.hash)r=n.hash===i.hash;else if(n.attributes.length===i.attributes.length){r=!0;for(var s,o,a=0;r&&a<n.attributes.length;++a)s=n.attributes[a],o=i.attributes[a],(s.type!==o.type||s.value!==o.value)&&(r=!1)}return r},t.issued=function(e){return e.isIssuer(t)},t.generateSubjectKeyIdentifier=function(){return G.getPublicKeyFingerprint(t.publicKey,{type:"RSAPublicKey"})},t.verifySubjectKeyIdentifier=function(){for(var e=Ce.subjectKeyIdentifier,r=0;r<t.extensions.length;++r){var n=t.extensions[r];if(n.id===e){var i=t.generateSubjectKeyIdentifier().getBytes();return oe.util.hexToBytes(n.subjectKeyIdentifier)===i}}return!1},t};G.certificateFromAsn1=function(t,e){var r={},n=[];if(!y.validate(t,KL,r,n)){var i=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw i.errors=n,i}var s=y.derToOid(r.publicKeyOid);if(s!==G.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=G.createCertificate();o.version=r.certVersion?r.certVersion.charCodeAt(0):0;var a=oe.util.createBuffer(r.certSerialNumber);o.serialNumber=a.toHex(),o.signatureOid=oe.asn1.derToOid(r.certSignatureOid),o.signatureParameters=Pu(o.signatureOid,r.certSignatureParams,!0),o.siginfo.algorithmOid=oe.asn1.derToOid(r.certinfoSignatureOid),o.siginfo.parameters=Pu(o.siginfo.algorithmOid,r.certinfoSignatureParams,!1),o.signature=r.certSignature;var c=[];if(r.certValidity1UTCTime!==void 0&&c.push(y.utcTimeToDate(r.certValidity1UTCTime)),r.certValidity2GeneralizedTime!==void 0&&c.push(y.generalizedTimeToDate(r.certValidity2GeneralizedTime)),r.certValidity3UTCTime!==void 0&&c.push(y.utcTimeToDate(r.certValidity3UTCTime)),r.certValidity4GeneralizedTime!==void 0&&c.push(y.generalizedTimeToDate(r.certValidity4GeneralizedTime)),c.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(c.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(o.validity.notBefore=c[0],o.validity.notAfter=c[1],o.tbsCertificate=r.tbsCertificate,e){o.md=Nu({signatureOid:o.signatureOid,type:"certificate"});var u=y.toDer(o.tbsCertificate);o.md.update(u.getBytes())}var l=oe.md.sha1.create(),f=y.toDer(r.certIssuer);l.update(f.getBytes()),o.issuer.getField=function(d){return ci(o.issuer,d)},o.issuer.addField=function(d){Sr([d]),o.issuer.attributes.push(d)},o.issuer.attributes=G.RDNAttributesAsArray(r.certIssuer),r.certIssuerUniqueId&&(o.issuer.uniqueId=r.certIssuerUniqueId),o.issuer.hash=l.digest().toHex();var h=oe.md.sha1.create(),p=y.toDer(r.certSubject);return h.update(p.getBytes()),o.subject.getField=function(d){return ci(o.subject,d)},o.subject.addField=function(d){Sr([d]),o.subject.attributes.push(d)},o.subject.attributes=G.RDNAttributesAsArray(r.certSubject),r.certSubjectUniqueId&&(o.subject.uniqueId=r.certSubjectUniqueId),o.subject.hash=h.digest().toHex(),r.certExtensions?o.extensions=G.certificateExtensionsFromAsn1(r.certExtensions):o.extensions=[],o.publicKey=G.publicKeyFromAsn1(r.subjectPublicKeyInfo),o};G.certificateExtensionsFromAsn1=function(t){for(var e=[],r=0;r<t.value.length;++r)for(var n=t.value[r],i=0;i<n.value.length;++i)e.push(G.certificateExtensionFromAsn1(n.value[i]));return e};G.certificateExtensionFromAsn1=function(t){var e={};if(e.id=y.derToOid(t.value[0].value),e.critical=!1,t.value[1].type===y.Type.BOOLEAN?(e.critical=t.value[1].value.charCodeAt(0)!==0,e.value=t.value[2].value):e.value=t.value[1].value,e.id in Ce){if(e.name=Ce[e.id],e.name==="keyUsage"){var r=y.fromDer(e.value),n=0,i=0;r.value.length>1&&(n=r.value.charCodeAt(1),i=r.value.length>2?r.value.charCodeAt(2):0),e.digitalSignature=(n&128)==128,e.nonRepudiation=(n&64)==64,e.keyEncipherment=(n&32)==32,e.dataEncipherment=(n&16)==16,e.keyAgreement=(n&8)==8,e.keyCertSign=(n&4)==4,e.cRLSign=(n&2)==2,e.encipherOnly=(n&1)==1,e.decipherOnly=(i&128)==128}else if(e.name==="basicConstraints"){var r=y.fromDer(e.value);r.value.length>0&&r.value[0].type===y.Type.BOOLEAN?e.cA=r.value[0].value.charCodeAt(0)!==0:e.cA=!1;var s=null;r.value.length>0&&r.value[0].type===y.Type.INTEGER?s=r.value[0].value:r.value.length>1&&(s=r.value[1].value),s!==null&&(e.pathLenConstraint=y.derToInteger(s))}else if(e.name==="extKeyUsage")for(var r=y.fromDer(e.value),o=0;o<r.value.length;++o){var a=y.derToOid(r.value[o].value);a in Ce?e[Ce[a]]=!0:e[a]=!0}else if(e.name==="nsCertType"){var r=y.fromDer(e.value),n=0;r.value.length>1&&(n=r.value.charCodeAt(1)),e.client=(n&128)==128,e.server=(n&64)==64,e.email=(n&32)==32,e.objsign=(n&16)==16,e.reserved=(n&8)==8,e.sslCA=(n&4)==4,e.emailCA=(n&2)==2,e.objCA=(n&1)==1}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.altNames=[];for(var c,r=y.fromDer(e.value),u=0;u<r.value.length;++u){c=r.value[u];var l={type:c.type,value:c.value};switch(e.altNames.push(l),c.type){case 1:case 2:case 6:break;case 7:l.ip=oe.util.bytesToIP(c.value);break;case 8:l.oid=y.derToOid(c.value);break;default:}}}else if(e.name==="subjectKeyIdentifier"){var r=y.fromDer(e.value);e.subjectKeyIdentifier=oe.util.bytesToHex(r.value)}}return e};G.certificationRequestFromAsn1=function(t,e){var r={},n=[];if(!y.validate(t,$L,r,n)){var i=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw i.errors=n,i}var s=y.derToOid(r.publicKeyOid);if(s!==G.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var o=G.createCertificationRequest();if(o.version=r.csrVersion?r.csrVersion.charCodeAt(0):0,o.signatureOid=oe.asn1.derToOid(r.csrSignatureOid),o.signatureParameters=Pu(o.signatureOid,r.csrSignatureParams,!0),o.siginfo.algorithmOid=oe.asn1.derToOid(r.csrSignatureOid),o.siginfo.parameters=Pu(o.siginfo.algorithmOid,r.csrSignatureParams,!1),o.signature=r.csrSignature,o.certificationRequestInfo=r.certificationRequestInfo,e){o.md=Nu({signatureOid:o.signatureOid,type:"certification request"});var a=y.toDer(o.certificationRequestInfo);o.md.update(a.getBytes())}var c=oe.md.sha1.create();return o.subject.getField=function(u){return ci(o.subject,u)},o.subject.addField=function(u){Sr([u]),o.subject.attributes.push(u)},o.subject.attributes=G.RDNAttributesAsArray(r.certificationRequestInfoSubject,c),o.subject.hash=c.digest().toHex(),o.publicKey=G.publicKeyFromAsn1(r.subjectPublicKeyInfo),o.getAttribute=function(u){return ci(o,u)},o.addAttribute=function(u){Sr([u]),o.attributes.push(u)},o.attributes=G.CRIAttributesAsArray(r.certificationRequestInfoAttributes||[]),o};G.createCertificationRequest=function(){var t={};return t.version=0,t.signatureOid=null,t.signature=null,t.siginfo={},t.siginfo.algorithmOid=null,t.subject={},t.subject.getField=function(e){return ci(t.subject,e)},t.subject.addField=function(e){Sr([e]),t.subject.attributes.push(e)},t.subject.attributes=[],t.subject.hash=null,t.publicKey=null,t.attributes=[],t.getAttribute=function(e){return ci(t,e)},t.addAttribute=function(e){Sr([e]),t.attributes.push(e)},t.md=null,t.setSubject=function(e){Sr(e),t.subject.attributes=e,t.subject.hash=null},t.setAttributes=function(e){Sr(e),t.attributes=e},t.sign=function(e,r){t.md=r||oe.md.sha1.create();var n=Ce[t.md.algorithm+"WithRSAEncryption"];if(!n){var i=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw i.algorithm=t.md.algorithm,i}t.signatureOid=t.siginfo.algorithmOid=n,t.certificationRequestInfo=G.getCertificationRequestInfo(t);var s=y.toDer(t.certificationRequestInfo);t.md.update(s.getBytes()),t.signature=e.sign(t.md)},t.verify=function(){var e=!1,r=t.md;if(r===null){r=Nu({signatureOid:t.signatureOid,type:"certification request"});var n=t.certificationRequestInfo||G.getCertificationRequestInfo(t),i=y.toDer(n);r.update(i.getBytes())}return r!==null&&(e=X_({certificate:t,md:r,signature:t.signature})),e},t};function uo(t){for(var e=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]),r,n,i=t.attributes,s=0;s<i.length;++s){r=i[s];var o=r.value,a=y.Type.PRINTABLESTRING;"valueTagClass"in r&&(a=r.valueTagClass,a===y.Type.UTF8&&(o=oe.util.encodeUtf8(o))),n=y.create(y.Class.UNIVERSAL,y.Type.SET,!0,[y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(r.type).getBytes()),y.create(y.Class.UNIVERSAL,a,!1,o)])]),e.value.push(n)}return e}function Sr(t){for(var e,r=0;r<t.length;++r){if(e=t[r],typeof e.name=="undefined"&&(e.type&&e.type in G.oids?e.name=G.oids[e.type]:e.shortName&&e.shortName in ft&&(e.name=G.oids[ft[e.shortName]])),typeof e.type=="undefined")if(e.name&&e.name in G.oids)e.type=G.oids[e.name];else{var n=new Error("Attribute type not specified.");throw n.attribute=e,n}if(typeof e.shortName=="undefined"&&e.name&&e.name in ft&&(e.shortName=ft[e.name]),e.type===Ce.extensionRequest&&(e.valueConstructed=!0,e.valueTagClass=y.Type.SEQUENCE,!e.value&&e.extensions)){e.value=[];for(var i=0;i<e.extensions.length;++i)e.value.push(G.certificateExtensionToAsn1(Z_(e.extensions[i])))}if(typeof e.value=="undefined"){var n=new Error("Attribute value not specified.");throw n.attribute=e,n}}}function Z_(t,e){if(e=e||{},typeof t.name=="undefined"&&t.id&&t.id in G.oids&&(t.name=G.oids[t.id]),typeof t.id=="undefined")if(t.name&&t.name in G.oids)t.id=G.oids[t.name];else{var r=new Error("Extension ID not specified.");throw r.extension=t,r}if(typeof t.value!="undefined")return t;if(t.name==="keyUsage"){var n=0,i=0,s=0;t.digitalSignature&&(i|=128,n=7),t.nonRepudiation&&(i|=64,n=6),t.keyEncipherment&&(i|=32,n=5),t.dataEncipherment&&(i|=16,n=4),t.keyAgreement&&(i|=8,n=3),t.keyCertSign&&(i|=4,n=2),t.cRLSign&&(i|=2,n=1),t.encipherOnly&&(i|=1,n=0),t.decipherOnly&&(s|=128,n=7);var o=String.fromCharCode(n);s!==0?o+=String.fromCharCode(i)+String.fromCharCode(s):i!==0&&(o+=String.fromCharCode(i)),t.value=y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,o)}else if(t.name==="basicConstraints")t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]),t.cA&&t.value.value.push(y.create(y.Class.UNIVERSAL,y.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in t&&t.value.value.push(y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(t.pathLenConstraint).getBytes()));else if(t.name==="extKeyUsage"){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);var a=t.value.value;for(var c in t)t[c]===!0&&(c in Ce?a.push(y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(Ce[c]).getBytes())):c.indexOf(".")!==-1&&a.push(y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(c).getBytes())))}else if(t.name==="nsCertType"){var n=0,i=0;t.client&&(i|=128,n=7),t.server&&(i|=64,n=6),t.email&&(i|=32,n=5),t.objsign&&(i|=16,n=4),t.reserved&&(i|=8,n=3),t.sslCA&&(i|=4,n=2),t.emailCA&&(i|=2,n=1),t.objCA&&(i|=1,n=0);var o=String.fromCharCode(n);i!==0&&(o+=String.fromCharCode(i)),t.value=y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,o)}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);for(var u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=oe.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=y.oidToDer(y.oidToDer(u.oid)):o=y.oidToDer(o));t.value.value.push(y.create(y.Class.CONTEXT_SPECIFIC,u.type,!1,o))}}else if(t.name==="nsComment"&&e.cert){if(!/^[\x00-\x7F]*$/.test(t.comment)||t.comment.length<1||t.comment.length>128)throw new Error('Invalid "nsComment" content.');t.value=y.create(y.Class.UNIVERSAL,y.Type.IA5STRING,!1,t.comment)}else if(t.name==="subjectKeyIdentifier"&&e.cert){var f=e.cert.generateSubjectKeyIdentifier();t.subjectKeyIdentifier=f.toHex(),t.value=y.create(y.Class.UNIVERSAL,y.Type.OCTETSTRING,!1,f.getBytes())}else if(t.name==="authorityKeyIdentifier"&&e.cert){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);var a=t.value.value;if(t.keyIdentifier){var h=t.keyIdentifier===!0?e.cert.generateSubjectKeyIdentifier().getBytes():t.keyIdentifier;a.push(y.create(y.Class.CONTEXT_SPECIFIC,0,!1,h))}if(t.authorityCertIssuer){var p=[y.create(y.Class.CONTEXT_SPECIFIC,4,!0,[uo(t.authorityCertIssuer===!0?e.cert.issuer:t.authorityCertIssuer)])];a.push(y.create(y.Class.CONTEXT_SPECIFIC,1,!0,p))}if(t.serialNumber){var d=oe.util.hexToBytes(t.serialNumber===!0?e.cert.serialNumber:t.serialNumber);a.push(y.create(y.Class.CONTEXT_SPECIFIC,2,!1,d))}}else if(t.name==="cRLDistributionPoints"){t.value=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);for(var a=t.value.value,g=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]),m=y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[]),u,l=0;l<t.altNames.length;++l){u=t.altNames[l];var o=u.value;if(u.type===7&&u.ip){if(o=oe.util.bytesFromIP(u.ip),o===null){var r=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw r.extension=t,r}}else u.type===8&&(u.oid?o=y.oidToDer(y.oidToDer(u.oid)):o=y.oidToDer(o));m.value.push(y.create(y.Class.CONTEXT_SPECIFIC,u.type,!1,o))}g.value.push(y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[m])),a.push(g)}if(typeof t.value=="undefined"){var r=new Error("Extension value not specified.");throw r.extension=t,r}return t}function bd(t,e){switch(t){case Ce["RSASSA-PSS"]:var r=[];return e.hash.algorithmOid!==void 0&&r.push(y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(e.hash.algorithmOid).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.NULL,!1,"")])])),e.mgf.algorithmOid!==void 0&&r.push(y.create(y.Class.CONTEXT_SPECIFIC,1,!0,[y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(e.mgf.algorithmOid).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(e.mgf.hash.algorithmOid).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.NULL,!1,"")])])])),e.saltLength!==void 0&&r.push(y.create(y.Class.CONTEXT_SPECIFIC,2,!0,[y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(e.saltLength).getBytes())])),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,r);default:return y.create(y.Class.UNIVERSAL,y.Type.NULL,!1,"")}}function HL(t){var e=y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[]);if(t.attributes.length===0)return e;for(var r=t.attributes,n=0;n<r.length;++n){var i=r[n],s=i.value,o=y.Type.UTF8;"valueTagClass"in i&&(o=i.valueTagClass),o===y.Type.UTF8&&(s=oe.util.encodeUtf8(s));var a=!1;"valueConstructed"in i&&(a=i.valueConstructed);var c=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(i.type).getBytes()),y.create(y.Class.UNIVERSAL,y.Type.SET,!0,[y.create(y.Class.UNIVERSAL,o,a,s)])]);e.value.push(c)}return e}var zL=new Date("1950-01-01T00:00:00Z"),GL=new Date("2050-01-01T00:00:00Z");function J_(t){return t>=zL&&t<GL?y.create(y.Class.UNIVERSAL,y.Type.UTCTIME,!1,y.dateToUtcTime(t)):y.create(y.Class.UNIVERSAL,y.Type.GENERALIZEDTIME,!1,y.dateToGeneralizedTime(t))}G.getTBSCertificate=function(t){var e=J_(t.validity.notBefore),r=J_(t.validity.notAfter),n=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.CONTEXT_SPECIFIC,0,!0,[y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(t.version).getBytes())]),y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,oe.util.hexToBytes(t.serialNumber)),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.siginfo.algorithmOid).getBytes()),bd(t.siginfo.algorithmOid,t.siginfo.parameters)]),uo(t.issuer),y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[e,r]),uo(t.subject),G.publicKeyToAsn1(t.publicKey)]);return t.issuer.uniqueId&&n.value.push(y.create(y.Class.CONTEXT_SPECIFIC,1,!0,[y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.issuer.uniqueId)])),t.subject.uniqueId&&n.value.push(y.create(y.Class.CONTEXT_SPECIFIC,2,!0,[y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.subject.uniqueId)])),t.extensions.length>0&&n.value.push(G.certificateExtensionsToAsn1(t.extensions)),n};G.getCertificationRequestInfo=function(t){var e=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.INTEGER,!1,y.integerToDer(t.version).getBytes()),uo(t.subject),G.publicKeyToAsn1(t.publicKey),HL(t)]);return e};G.distinguishedNameToAsn1=function(t){return uo(t)};G.certificateToAsn1=function(t){var e=t.tbsCertificate||G.getTBSCertificate(t);return y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[e,y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.signatureOid).getBytes()),bd(t.signatureOid,t.signatureParameters)]),y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};G.certificateExtensionsToAsn1=function(t){var e=y.create(y.Class.CONTEXT_SPECIFIC,3,!0,[]),r=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);e.value.push(r);for(var n=0;n<t.length;++n)r.value.push(G.certificateExtensionToAsn1(t[n]));return e};G.certificateExtensionToAsn1=function(t){var e=y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[]);e.value.push(y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.id).getBytes())),t.critical&&e.value.push(y.create(y.Class.UNIVERSAL,y.Type.BOOLEAN,!1,String.fromCharCode(255)));var r=t.value;return typeof t.value!="string"&&(r=y.toDer(r).getBytes()),e.value.push(y.create(y.Class.UNIVERSAL,y.Type.OCTETSTRING,!1,r)),e};G.certificationRequestToAsn1=function(t){var e=t.certificationRequestInfo||G.getCertificationRequestInfo(t);return y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[e,y.create(y.Class.UNIVERSAL,y.Type.SEQUENCE,!0,[y.create(y.Class.UNIVERSAL,y.Type.OID,!1,y.oidToDer(t.signatureOid).getBytes()),bd(t.signatureOid,t.signatureParameters)]),y.create(y.Class.UNIVERSAL,y.Type.BITSTRING,!1,String.fromCharCode(0)+t.signature)])};G.createCaStore=function(t){var e={certs:{}};e.getIssuer=function(o){var a=r(o.issuer);return a},e.addCertificate=function(o){if(typeof o=="string"&&(o=oe.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))if(o.subject.hash in e.certs){var a=e.certs[o.subject.hash];oe.util.isArray(a)||(a=[a]),a.push(o),e.certs[o.subject.hash]=a}else e.certs[o.subject.hash]=o},e.hasCertificate=function(o){typeof o=="string"&&(o=oe.pki.certificateFromPem(o));var a=r(o.subject);if(!a)return!1;oe.util.isArray(a)||(a=[a]);for(var c=y.toDer(G.certificateToAsn1(o)).getBytes(),u=0;u<a.length;++u){var l=y.toDer(G.certificateToAsn1(a[u])).getBytes();if(c===l)return!0}return!1},e.listAllCertificates=function(){var o=[];for(var a in e.certs)if(e.certs.hasOwnProperty(a)){var c=e.certs[a];if(!oe.util.isArray(c))o.push(c);else for(var u=0;u<c.length;++u)o.push(c[u])}return o},e.removeCertificate=function(o){var a;if(typeof o=="string"&&(o=oe.pki.certificateFromPem(o)),n(o.subject),!e.hasCertificate(o))return null;var c=r(o.subject);if(!oe.util.isArray(c))return a=e.certs[o.subject.hash],delete e.certs[o.subject.hash],a;for(var u=y.toDer(G.certificateToAsn1(o)).getBytes(),l=0;l<c.length;++l){var f=y.toDer(G.certificateToAsn1(c[l])).getBytes();u===f&&(a=c[l],c.splice(l,1))}return c.length===0&&delete e.certs[o.subject.hash],a};function r(o){return n(o),e.certs[o.hash]||null}function n(o){if(!o.hash){var a=oe.md.sha1.create();o.attributes=G.RDNAttributesAsArray(uo(o),a),o.hash=a.digest().toHex()}}if(t)for(var i=0;i<t.length;++i){var s=t[i];e.addCertificate(s)}return e};G.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"};G.verifyCertificateChain=function(t,e,r){typeof r=="function"&&(r={verify:r}),r=r||{},e=e.slice(0);var n=e.slice(0),i=r.validityCheckDate;typeof i=="undefined"&&(i=new Date);var s=!0,o=null,a=0;do{var c=e.shift(),u=null,l=!1;if(i&&(i<c.validity.notBefore||i>c.validity.notAfter)&&(o={message:"Certificate is not valid yet or has expired.",error:G.certificateError.certificate_expired,notBefore:c.validity.notBefore,notAfter:c.validity.notAfter,now:i}),o===null){if(u=e[0]||t.getIssuer(c),u===null&&c.isIssuer(c)&&(l=!0,u=c),u){var f=u;oe.util.isArray(f)||(f=[f]);for(var h=!1;!h&&f.length>0;){u=f.shift();try{h=u.verify(c)}catch(q){}}h||(o={message:"Certificate signature is invalid.",error:G.certificateError.bad_certificate})}o===null&&(!u||l)&&!t.hasCertificate(c)&&(o={message:"Certificate is not trusted.",error:G.certificateError.unknown_ca})}if(o===null&&u&&!c.isIssuer(u)&&(o={message:"Certificate issuer is invalid.",error:G.certificateError.bad_certificate}),o===null)for(var p={keyUsage:!0,basicConstraints:!0},d=0;o===null&&d<c.extensions.length;++d){var g=c.extensions[d];g.critical&&!(g.name in p)&&(o={message:"Certificate has an unsupported critical extension.",error:G.certificateError.unsupported_certificate})}if(o===null&&(!s||e.length===0&&(!u||l))){var m=c.getExtension("basicConstraints"),x=c.getExtension("keyUsage");if(x!==null&&(!x.keyCertSign||m===null)&&(o={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:G.certificateError.bad_certificate}),o===null&&m!==null&&!m.cA&&(o={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:G.certificateError.bad_certificate}),o===null&&x!==null&&"pathLenConstraint"in m){var R=a-1;R>m.pathLenConstraint&&(o={message:"Certificate basicConstraints pathLenConstraint violated.",error:G.certificateError.bad_certificate})}}var L=o===null?!0:o.error,H=r.verify?r.verify(L,a,n):L;if(H===!0)o=null;else throw L===!0&&(o={message:"The application rejected the certificate.",error:G.certificateError.bad_certificate}),(H||H===0)&&(typeof H=="object"&&!oe.util.isArray(H)?(H.message&&(o.message=H.message),H.error&&(o.error=H.error)):typeof H=="string"&&(o.error=H)),o;s=!1,++a}while(e.length>0);return!0}});var nx=w((LK,rx)=>{var Y=be();Ss();Kn();hc();ws();gc();j_();Si();$e();Ed();var T=Y.asn1,zt=rx.exports=Y.pkcs7=Y.pkcs7||{};zt.messageFromPem=function(t){var e=Y.pem.decode(t)[0];if(e.type!=="PKCS7"){var r=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw r.headerType=e.type,r}if(e.procType&&e.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var n=T.fromDer(e.body);return zt.messageFromAsn1(n)};zt.messageToPem=function(t,e){var r={type:"PKCS7",body:T.toDer(t.toAsn1()).getBytes()};return Y.pem.encode(r,{maxline:e})};zt.messageFromAsn1=function(t){var e={},r=[];if(!T.validate(t,zt.asn1.contentInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw n.errors=r,n}var i=T.derToOid(e.contentType),s;switch(i){case Y.pki.oids.envelopedData:s=zt.createEnvelopedData();break;case Y.pki.oids.encryptedData:s=zt.createEncryptedData();break;case Y.pki.oids.signedData:s=zt.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+i+" is not (yet) supported.")}return s.fromAsn1(e.content.value[0]),s};zt.createSignedData=function(){var t=null;return t={type:Y.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(n){if(_d(t,n,zt.asn1.signedDataValidator),t.certificates=[],t.crls=[],t.digestAlgorithmIdentifiers=[],t.contentInfo=null,t.signerInfos=[],t.rawCapture.certificates)for(var i=t.rawCapture.certificates.value,s=0;s<i.length;++s)t.certificates.push(Y.pki.certificateFromAsn1(i[s]))},toAsn1:function(){t.contentInfo||t.sign();for(var n=[],i=0;i<t.certificates.length;++i)n.push(Y.pki.certificateToAsn1(t.certificates[i]));var s=[],o=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,t.digestAlgorithmIdentifiers),t.contentInfo])]);return n.length>0&&o.value[0].value.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,n)),s.length>0&&o.value[0].value.push(T.create(T.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(T.create(T.Class.UNIVERSAL,T.Type.SET,!0,t.signerInfos)),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.type).getBytes()),o])},addSigner:function(n){var i=n.issuer,s=n.serialNumber;if(n.certificate){var o=n.certificate;typeof o=="string"&&(o=Y.pki.certificateFromPem(o)),i=o.issuer.attributes,s=o.serialNumber}var a=n.key;if(!a)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof a=="string"&&(a=Y.pki.privateKeyFromPem(a));var c=n.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 u=n.authenticatedAttributes||[];if(u.length>0){for(var l=!1,f=!1,h=0;h<u.length;++h){var p=u[h];if(!l&&p.type===Y.pki.oids.contentType){if(l=!0,f)break;continue}if(!f&&p.type===Y.pki.oids.messageDigest){if(f=!0,l)break;continue}}if(!l||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}t.signers.push({key:a,version:1,issuer:i,serialNumber:s,digestAlgorithm:c,signatureAlgorithm:Y.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:u,unauthenticatedAttributes:[]})},sign:function(n){if(n=n||{},(typeof t.content!="object"||t.contentInfo===null)&&(t.contentInfo=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(Y.pki.oids.data).getBytes())]),"content"in t)){var i;t.content instanceof Y.util.ByteBuffer?i=t.content.bytes():typeof t.content=="string"&&(i=Y.util.encodeUtf8(t.content)),n.detached?t.detachedContent=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,i):t.contentInfo.value.push(T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,i)]))}if(t.signers.length!==0){var s=e();r(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(n){typeof n=="string"&&(n=Y.pki.certificateFromPem(n)),t.certificates.push(n)},addCertificateRevokationList:function(n){throw new Error("PKCS#7 CRL support not yet implemented.")}},t;function e(){for(var n={},i=0;i<t.signers.length;++i){var s=t.signers[i],o=s.digestAlgorithm;o in n||(n[o]=Y.md[Y.pki.oids[o]].create()),s.authenticatedAttributes.length===0?s.md=n[o]:s.md=Y.md[Y.pki.oids[o]].create()}t.digestAlgorithmIdentifiers=[];for(var o in n)t.digestAlgorithmIdentifiers.push(T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(o).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]));return n}function r(n){var i;if(t.detachedContent?i=t.detachedContent:(i=t.contentInfo.value[1],i=i.value[0]),!i)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=T.derToOid(t.contentInfo.value[0].value),o=T.toDer(i);o.getByte(),T.getBerValueLength(o),o=o.getBytes();for(var a in n)n[a].start().update(o);for(var c=new Date,u=0;u<t.signers.length;++u){var l=t.signers[u];if(l.authenticatedAttributes.length===0){if(s!==Y.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{l.authenticatedAttributesAsn1=T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[]),h=0;h<l.authenticatedAttributes.length;++h){var p=l.authenticatedAttributes[h];p.type===Y.pki.oids.messageDigest?p.value=n[l.digestAlgorithm].digest():p.type===Y.pki.oids.signingTime&&(p.value||(p.value=c)),f.value.push(wd(p)),l.authenticatedAttributesAsn1.value.push(wd(p))}o=T.toDer(f).getBytes(),l.md.start().update(o)}l.signature=l.key.sign(l.md,"RSASSA-PKCS1-V1_5")}t.signerInfos=JL(t.signers)}};zt.createEncryptedData=function(){var t=null;return t={type:Y.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:Y.pki.oids["aes256-CBC"]},fromAsn1:function(e){_d(t,e,zt.asn1.encryptedDataValidator)},decrypt:function(e){e!==void 0&&(t.encryptedContent.key=e),tx(t)}},t};zt.createEnvelopedData=function(){var t=null;return t={type:Y.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:Y.pki.oids["aes256-CBC"]},fromAsn1:function(e){var r=_d(t,e,zt.asn1.envelopedDataValidator);t.recipients=QL(r.recipientInfos.value)},toAsn1:function(){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.type).getBytes()),T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,XL(t.recipients)),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,ek(t.encryptedContent))])])])},findRecipient:function(e){for(var r=e.issuer.attributes,n=0;n<t.recipients.length;++n){var i=t.recipients[n],s=i.issuer;if(i.serialNumber===e.serialNumber&&s.length===r.length){for(var o=!0,a=0;a<r.length;++a)if(s[a].type!==r[a].type||s[a].value!==r[a].value){o=!1;break}if(o)return i}}return null},decrypt:function(e,r){if(t.encryptedContent.key===void 0&&e!==void 0&&r!==void 0)switch(e.encryptedContent.algorithm){case Y.pki.oids.rsaEncryption:case Y.pki.oids.desCBC:var n=r.decrypt(e.encryptedContent.content);t.encryptedContent.key=Y.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+e.encryptedContent.algorithm)}tx(t)},addRecipient:function(e){t.recipients.push({version:0,issuer:e.issuer.attributes,serialNumber:e.serialNumber,encryptedContent:{algorithm:Y.pki.oids.rsaEncryption,key:e.publicKey}})},encrypt:function(e,r){if(t.encryptedContent.content===void 0){r=r||t.encryptedContent.algorithm,e=e||t.encryptedContent.key;var n,i,s;switch(r){case Y.pki.oids["aes128-CBC"]:n=16,i=16,s=Y.aes.createEncryptionCipher;break;case Y.pki.oids["aes192-CBC"]:n=24,i=16,s=Y.aes.createEncryptionCipher;break;case Y.pki.oids["aes256-CBC"]:n=32,i=16,s=Y.aes.createEncryptionCipher;break;case Y.pki.oids["des-EDE3-CBC"]:n=24,i=8,s=Y.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(e===void 0)e=Y.util.createBuffer(Y.random.getBytes(n));else if(e.length()!=n)throw new Error("Symmetric key has wrong length; got "+e.length()+" bytes, expected "+n+".");t.encryptedContent.algorithm=r,t.encryptedContent.key=e,t.encryptedContent.parameter=Y.util.createBuffer(Y.random.getBytes(i));var o=s(e);if(o.start(t.encryptedContent.parameter.copy()),o.update(t.content),!o.finish())throw new Error("Symmetric encryption failed.");t.encryptedContent.content=o.output}for(var a=0;a<t.recipients.length;++a){var c=t.recipients[a];if(c.encryptedContent.content===void 0)switch(c.encryptedContent.algorithm){case Y.pki.oids.rsaEncryption:c.encryptedContent.content=c.encryptedContent.key.encrypt(t.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+c.encryptedContent.algorithm)}}}},t};function WL(t){var e={},r=[];if(!T.validate(t,zt.asn1.recipientInfoValidator,e,r)){var n=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw n.errors=r,n}return{version:e.version.charCodeAt(0),issuer:Y.pki.RDNAttributesAsArray(e.issuer),serialNumber:Y.util.createBuffer(e.serial).toHex(),encryptedContent:{algorithm:T.derToOid(e.encAlgorithm),parameter:e.encParameter?e.encParameter.value:void 0,content:e.encKey}}}function YL(t){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[Y.pki.distinguishedNameToAsn1({attributes:t.issuer}),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,Y.util.hexToBytes(t.serialNumber))]),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.encryptedContent.algorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.encryptedContent.content)])}function QL(t){for(var e=[],r=0;r<t.length;++r)e.push(WL(t[r]));return e}function XL(t){for(var e=[],r=0;r<t.length;++r)e.push(YL(t[r]));return e}function ZL(t){var e=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(t.version).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[Y.pki.distinguishedNameToAsn1({attributes:t.issuer}),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,Y.util.hexToBytes(t.serialNumber))]),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.digestAlgorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])]);if(t.authenticatedAttributesAsn1&&e.value.push(t.authenticatedAttributesAsn1),e.value.push(T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.signatureAlgorithm).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")])),e.value.push(T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.signature)),t.unauthenticatedAttributes.length>0){for(var r=T.create(T.Class.CONTEXT_SPECIFIC,1,!0,[]),n=0;n<t.unauthenticatedAttributes.length;++n){var i=t.unauthenticatedAttributes[n];r.values.push(wd(i))}e.value.push(r)}return e}function JL(t){for(var e=[],r=0;r<t.length;++r)e.push(ZL(t[r]));return e}function wd(t){var e;if(t.type===Y.pki.oids.contentType)e=T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.value).getBytes());else if(t.type===Y.pki.oids.messageDigest)e=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.value.bytes());else if(t.type===Y.pki.oids.signingTime){var r=new Date("1950-01-01T00:00:00Z"),n=new Date("2050-01-01T00:00:00Z"),i=t.value;if(typeof i=="string"){var s=Date.parse(i);isNaN(s)?i.length===13?i=T.utcTimeToDate(i):i=T.generalizedTimeToDate(i):i=new Date(s)}i>=r&&i<n?e=T.create(T.Class.UNIVERSAL,T.Type.UTCTIME,!1,T.dateToUtcTime(i)):e=T.create(T.Class.UNIVERSAL,T.Type.GENERALIZEDTIME,!1,T.dateToGeneralizedTime(i))}return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.type).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SET,!0,[e])])}function ek(t){return[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(Y.pki.oids.data).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(t.algorithm).getBytes()),t.parameter?T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.parameter.getBytes()):void 0]),T.create(T.Class.CONTEXT_SPECIFIC,0,!0,[T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,t.content.getBytes())])]}function _d(t,e,r){var n={},i=[];if(!T.validate(e,r,n,i)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var o=T.derToOid(n.contentType);if(o!==Y.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(n.encryptedContent){var a="";if(Y.util.isArray(n.encryptedContent))for(var c=0;c<n.encryptedContent.length;++c){if(n.encryptedContent[c].type!==T.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");a+=n.encryptedContent[c].value}else a=n.encryptedContent;t.encryptedContent={algorithm:T.derToOid(n.encAlgorithm),parameter:Y.util.createBuffer(n.encParameter.value),content:Y.util.createBuffer(a)}}if(n.content){var a="";if(Y.util.isArray(n.content))for(var c=0;c<n.content.length;++c){if(n.content[c].type!==T.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");a+=n.content[c].value}else a=n.content;t.content=Y.util.createBuffer(a)}return t.version=n.version.charCodeAt(0),t.rawCapture=n,n}function tx(t){if(t.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(t.content===void 0){var e;switch(t.encryptedContent.algorithm){case Y.pki.oids["aes128-CBC"]:case Y.pki.oids["aes192-CBC"]:case Y.pki.oids["aes256-CBC"]:e=Y.aes.createDecryptionCipher(t.encryptedContent.key);break;case Y.pki.oids.desCBC:case Y.pki.oids["des-EDE3-CBC"]:e=Y.des.createDecryptionCipher(t.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+t.encryptedContent.algorithm)}if(e.start(t.encryptedContent.parameter),e.update(t.encryptedContent.content),!e.finish())throw new Error("Symmetric decryption failed.");t.content=e.output}}});var ox=w((kK,sx)=>{"use strict";Ed();var tk=be(),ix=tk.pki,rk=(t,e)=>{let r=ix.setRsaPublicKey(e.n,e.e),n=ix.createCertificate();n.publicKey=r,n.serialNumber="01",n.validity.notBefore=new Date,n.validity.notAfter=new Date,n.validity.notAfter.setFullYear(n.validity.notBefore.getFullYear()+10);let i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:t.id}];return n.setSubject(i),n.setIssuer(i),n.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}]),n.sign(e),n};async function nk(t,e){let r=t.map(e),i=(await Promise.all(r)).findIndex(s=>s);return t[i]}sx.exports={certificateForKey:rk,findAsync:nk}});var lx=w((qK,ux)=>{"use strict";nx();Zl();var ui=be(),{certificateForKey:ik,findAsync:sk}=ox(),lo=he(),{fromString:ax}=(It(),Nt),{toString:ok}=(Tt(),Ot),{codes:fo}=je(),xd=new WeakMap,cx=class{constructor(e,r){if(!e)throw lo(new Error("keychain is required"),fo.ERR_KEYCHAIN_REQUIRED);this.keychain=e,xd.set(this,{dek:r})}async encrypt(e,r){if(!(r instanceof Uint8Array))throw lo(new Error("Plain data must be a Uint8Array"),fo.ERR_INVALID_PARAMETERS);let n=await this.keychain.findKeyByName(e),i=await this.keychain._getPrivateKey(e),s=xd.get(this).dek,o=ui.pki.decryptRsaPrivateKey(i,s),a=await ik(n,o),c=ui.pkcs7.createEnvelopedData();c.addRecipient(a),c.content=ui.util.createBuffer(r),c.encrypt();let u=ui.asn1.toDer(c.toAsn1()).getBytes();return ax(u,"ascii")}async decrypt(e){if(!(e instanceof Uint8Array))throw lo(new Error("CMS data is required"),fo.ERR_INVALID_PARAMETERS);let r;try{let u=ui.util.createBuffer(ok(e,"ascii")),l=ui.asn1.fromDer(u);r=ui.pkcs7.messageFromAsn1(l)}catch(u){throw lo(new Error("Invalid CMS: "+u.message),fo.ERR_INVALID_CMS)}let n=r.recipients.filter(u=>u.issuer.find(l=>l.shortName==="O"&&l.value==="ipfs")).filter(u=>u.issuer.find(l=>l.shortName==="CN")).map(u=>({recipient:u,keyId:u.issuer.find(l=>l.shortName==="CN").value})),i=await sk(n,async u=>{try{if(await this.keychain.findKeyById(u.keyId))return!0}catch(l){return!1}return!1});if(!i){let u=n.map(l=>l.keyId);throw lo(new Error("Decryption needs one of the key(s): "+u.join(", ")),fo.ERR_MISSING_KEYS,{missingKeys:u})}let s=await this.keychain.findKeyById(i.keyId);if(!s)throw lo(new Error("No key available to decrypto"),fo.ERR_NO_KEY);let o=await this.keychain._getPrivateKey(s.name),a=xd.get(this).dek,c=ui.pki.decryptRsaPrivateKey(o,a);return r.decrypt(i.recipient,c),ax(r.content.getBytes(),"ascii")}};ux.exports=cx});var mx=w((UK,gx)=>{"use strict";var fx=Te(),hx=Object.assign(fx("libp2p:keychain"),{error:fx("libp2p:keychain:err")}),ak=I_(),ck=Vs(),Ji=Ru(),{Key:dx}=(Zc(),nh),uk=lx(),et=he(),{codes:tt}=je(),{toString:es}=(Tt(),Ot),{fromString:Rn}=(It(),Nt);pf();var lk="/pkcs8/",px="/info/",li=new WeakMap,ts={minKeyLength:112/8,minSaltLength:128/8,minIterationCount:1e3},Sd={dek:{keyLength:512/8,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function Bn(t){return!t||typeof t!="string"?!1:t===ak(t.trim())}async function Le(t){let e=200,r=1e3,n=Math.random()*(r-e)+e;throw await new Promise(i=>setTimeout(i,n)),t}function cn(t){return new dx(lk+t)}function fi(t){return new dx(px+t)}var yx=class{constructor(e,r){if(!e)throw new Error("store is required");if(this.store=e,this.opts=ck(Sd,r),this.opts.pass&&this.opts.pass.length<20)throw new Error("pass must be least 20 characters");if(this.opts.dek.keyLength<ts.minKeyLength)throw new Error(`dek.keyLength must be least ${ts.minKeyLength} bytes`);if(this.opts.dek.salt.length<ts.minSaltLength)throw new Error(`dek.saltLength must be least ${ts.minSaltLength} bytes`);if(this.opts.dek.iterationCount<ts.minIterationCount)throw new Error(`dek.iterationCount must be least ${ts.minIterationCount}`);let n=this.opts.pass?Ji.pbkdf2(this.opts.pass,this.opts.dek.salt,this.opts.dek.iterationCount,this.opts.dek.keyLength,this.opts.dek.hash):"";li.set(this,{dek:n})}get cms(){return new uk(this,li.get(this).dek)}static generateOptions(){let e=Object.assign({},Sd),r=Math.ceil(ts.minSaltLength/3)*3;return e.dek.salt=es(Ji.randomBytes(r),"base64"),e}static get options(){return Sd}async createKey(e,r,n=2048){let i=this;if(!Bn(e)||e==="self")return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(typeof r!="string")return Le(et(new Error(`Invalid key type '${r}'`),tt.ERR_INVALID_KEY_TYPE));let s=cn(e);if(await i.store.has(s))return Le(et(new Error(`Key '${e}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));switch(r.toLowerCase()){case"rsa":if(!Number.isSafeInteger(n)||n<2048)return Le(et(new Error(`Invalid RSA key size ${n}`),tt.ERR_INVALID_KEY_SIZE));break;default:break}let a;try{let c=await Ji.keys.generateKeyPair(r,n),u=await c.id(),l=li.get(this).dek,f=await c.export(l);a={name:e,id:u};let h=i.store.batch();h.put(s,Rn(f)),h.put(fi(e),Rn(JSON.stringify(a))),await h.commit()}catch(c){return Le(c)}return a}async listKeys(){let e=this,r={prefix:px},n=[];for await(let i of e.store.query(r))n.push(JSON.parse(es(i.value)));return n}async findKeyById(e){try{return(await this.listKeys()).find(n=>n.id===e)}catch(r){return Le(r)}}async findKeyByName(e){if(!Bn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));let r=fi(e);try{let n=await this.store.get(r);return JSON.parse(es(n))}catch(n){return Le(et(new Error(`Key '${e}' does not exist. ${n.message}`),tt.ERR_KEY_NOT_FOUND))}}async removeKey(e){let r=this;if(!Bn(e)||e==="self")return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));let n=cn(e),i=await r.findKeyByName(e),s=r.store.batch();return s.delete(n),s.delete(fi(e)),await s.commit(),i}async renameKey(e,r){let n=this;if(!Bn(e)||e==="self")return Le(et(new Error(`Invalid old key name '${e}'`),tt.ERR_OLD_KEY_NAME_INVALID));if(!Bn(r)||r==="self")return Le(et(new Error(`Invalid new key name '${r}'`),tt.ERR_NEW_KEY_NAME_INVALID));let i=cn(e),s=cn(r),o=fi(e),a=fi(r);if(await n.store.has(s))return Le(et(new Error(`Key '${r}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));try{let u=await n.store.get(i),l=await n.store.get(o),f=JSON.parse(es(l));f.name=r;let h=n.store.batch();return h.put(s,u),h.put(a,Rn(JSON.stringify(f))),h.delete(i),h.delete(o),await h.commit(),f}catch(u){return Le(u)}}async exportKey(e,r){if(!Bn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(!r)return Le(et(new Error("Password is required"),tt.ERR_PASSWORD_REQUIRED));let n=cn(e);try{let i=await this.store.get(n),s=es(i),o=li.get(this).dek;return(await Ji.keys.import(s,o)).export(r)}catch(i){return Le(i)}}async importKey(e,r,n){let i=this;if(!Bn(e)||e==="self")return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(!r)return Le(et(new Error("PEM encoded key is required"),tt.ERR_PEM_REQUIRED));let s=cn(e);if(await i.store.has(s))return Le(et(new Error(`Key '${e}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));let a;try{a=await Ji.keys.import(r,n)}catch(f){return Le(et(new Error("Cannot read the key, most likely the password is wrong"),tt.ERR_CANNOT_READ_KEY))}let c;try{c=await a.id();let f=li.get(this).dek;r=await a.export(f)}catch(f){return Le(f)}let u={name:e,id:c},l=i.store.batch();return l.put(s,Rn(r)),l.put(fi(e),Rn(JSON.stringify(u))),await l.commit(),u}async importPeer(e,r){let n=this;if(!Bn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));if(!r||!r.privKey)return Le(et(new Error("Peer.privKey is required"),tt.ERR_MISSING_PRIVATE_KEY));let i=r.privKey,s=cn(e);if(await n.store.has(s))return Le(et(new Error(`Key '${e}' already exists`),tt.ERR_KEY_ALREADY_EXISTS));try{let a=await i.id(),c=li.get(this).dek,u=await i.export(c),l={name:e,id:a},f=n.store.batch();return f.put(s,Rn(u)),f.put(fi(e),Rn(JSON.stringify(l))),await f.commit(),l}catch(a){return Le(a)}}async _getPrivateKey(e){if(!Bn(e))return Le(et(new Error(`Invalid key name '${e}'`),tt.ERR_INVALID_KEY_NAME));try{let r=cn(e),n=await this.store.get(r);return es(n)}catch(r){return Le(et(new Error(`Key '${e}' does not exist. ${r.message}`),tt.ERR_KEY_NOT_FOUND))}}async rotateKeychainPass(e,r){if(typeof e!="string")return Le(et(new Error(`Invalid old pass type '${typeof e}'`),tt.ERR_INVALID_OLD_PASS_TYPE));if(typeof r!="string")return Le(et(new Error(`Invalid new pass type '${typeof r}'`),tt.ERR_INVALID_NEW_PASS_TYPE));if(r.length<20)return Le(et(new Error(`Invalid pass length ${r.length}`),tt.ERR_INVALID_PASS_LENGTH));hx("recreating keychain");let n=li.get(this).dek;this.opts.pass=r;let i=r?Ji.pbkdf2(r,this.opts.dek.salt,this.opts.dek.iterationCount,this.opts.dek.keyLength,this.opts.dek.hash):"";li.set(this,{dek:i});let s=await this.listKeys();for(let o of s){let a=await this.store.get(cn(o.name)),c=es(a),u=await Ji.keys.import(c,n),l=i.toString(),f=await u.export(l),h=this.store.batch(),p={name:o.name,id:o.id};h.put(cn(o.name),Rn(f)),h.put(fi(o.name),Rn(JSON.stringify(p))),await h.commit()}hx("keychain reconstructed")}};gx.exports=yx});var Du=w((Ou,vx)=>{(function(t,e){typeof Ou=="object"&&typeof vx!="undefined"?e(Ou):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.streamingIterables={}))})(Ou,function(t){"use strict";async function*e(b,v){let _=[];for await(let C of v)_.push(C),_.length===b&&(yield _,_=[]);_.length>0&&(yield _)}function*r(b,v){let _=[];for(let C of v)_.push(C),_.length===b&&(yield _,_=[]);_.length>0&&(yield _)}function n(b,v){return v===void 0?_=>n(b,_):v[Symbol.asyncIterator]?e(b,v):r(b,v)}function i(b){if(typeof b.next=="function")return b;if(typeof b[Symbol.iterator]=="function")return b[Symbol.iterator]();if(typeof b[Symbol.asyncIterator]=="function")return b[Symbol.asyncIterator]();throw new TypeError('"values" does not to conform to any of the iterator or iterable protocols')}function s(){let b,v;return{promise:new Promise((C,A)=>{v=C,b=A}),reject:b,resolve:v}}function o(b,v){let _=i(v),C=[],A=[],B=!1,N=!1;function O(){for(;A.length>0&&C.length>0;){let ee=A.shift(),{error:fe,value:ke}=C.shift();fe?ee.reject(fe):ee.resolve({done:!1,value:ke})}for(;A.length>0&&N;){let{resolve:ee}=A.shift();ee({done:!0,value:void 0})}}async function U(){if(!N&&!B&&!(C.length>=b)){B=!0;try{let{done:ee,value:fe}=await _.next();ee?N=!0:C.push({value:fe})}catch(ee){N=!0,C.push({error:ee})}O(),B=!1,U()}}async function W(){if(C.length>0){let{error:fe,value:ke}=C.shift();if(fe)throw fe;return U(),{done:!1,value:ke}}if(N)return{done:!0,value:void 0};let ee=s();return A.push(ee),U(),ee.promise}let Q={next:W,[Symbol.asyncIterator]:()=>Q};return Q}function*a(b,v){let _=[],C;try{for(let A of v)_.push(A),!(_.length<=b)&&(yield _.shift())}catch(A){C=A}for(let A of _)yield A;if(C)throw C}function c(b,v){return v===void 0?_=>c(b,_):b===0?v:v[Symbol.asyncIterator]?o(b,v):a(b,v)}async function u(b){let v=[];for await(let _ of b)v.push(_);return v}function l(b){return b[Symbol.asyncIterator]?u(b):Array.from(b)}async function*f(b){for await(let v of b)yield*v}function*h(b){for(let v of b)yield*v}function p(...b){return b.find(_=>_[Symbol.asyncIterator]!==void 0)?f(b):h(b)}async function d(b){for await(let v of b);}function g(b){if(b[Symbol.asyncIterator])return d(b);for(let v of b);}async function*m(b,v){for await(let _ of v)await b(_)&&(yield _)}function x(b,v){return v===void 0?_=>m(b,_):m(b,v)}async function*R(b){for await(let v of b)v&&typeof v!="string"&&(v[Symbol.iterator]||v[Symbol.asyncIterator])?yield*R(v):yield v}async function*L(b,v){for await(let _ of v)yield await b(_)}function H(b,v){return v===void 0?_=>L(b,_):L(b,v)}function q(b,v){return v===void 0?_=>q(b,_):x(_=>_!=null,R(H(b,v)))}function k(b,v,_){let C=i(_),A=[],B=[],N=!1,O=!1,U=0,W=null;function Q(){for(;B.length>0&&A.length>0;){let{resolve:ae}=B.shift(),ue=A.shift();ae({done:!1,value:ue})}for(;B.length>0&&U===0&&N;){let{resolve:ae,reject:ue}=B.shift();W?(ue(W),W=null):ae({done:!0,value:void 0})}}async function ee(){if(N){Q();return}if(!O&&!(U+A.length>=b)){O=!0,U++;try{let{done:ae,value:ue}=await C.next();ae?(N=!0,U--,Q()):fe(ue)}catch(ae){N=!0,U--,W=ae,Q()}O=!1,ee()}}async function fe(ae){try{let ue=await v(ae);if(ue&&ue[Symbol.asyncIterator])for await(let us of ue)A.push(us);else A.push(ue)}catch(ue){N=!0,W=ue}U--,Q(),ee()}async function ke(){if(A.length===0){let ue=s();return B.push(ue),ee(),ue.promise}let ae=A.shift();return ee(),{done:!1,value:ae}}let ge={next:ke,[Symbol.asyncIterator]:()=>ge};return ge}function J(b,v,_){return v===void 0?(C,A)=>A?J(b,C,A):J(b,C):_===void 0?C=>J(b,v,C):x(C=>C!=null,R(k(b,v,_)))}async function ie(b){return new Promise(v=>{b.once("readable",()=>{v()})})}async function*j(b){for(;;){let v=b.read();if(v!==null){yield v;continue}if(b._readableState.ended)break;await ie(b)}}function we(b){return typeof b[Symbol.asyncIterator]=="function"?b:j(b)}async function*le(...b){let v=new Set(b.map(i));for(;v.size>0;)for(let _ of v){let C=await _.next();C.done?v.delete(_):yield C.value}}function ye(b,...v){let _=b();for(let C of v)_=C(_);return _}async function*nt(b,v,_){let C=null,A=U=>({value:v(U)}),B=async function*(U){for await(let W of U){if(C)return;yield W}},N=ye(()=>_,c(1),B,H(A),c(b-1)),O=i(N);for(;;){let{value:U,done:W}=await O.next();if(W)break;try{let Q=await U.value;C||(yield Q)}catch(Q){C=Q}}if(C)throw C}function it(b,v,_){return v===void 0?(C,A)=>it(b,C,A):_===void 0?C=>it(b,v,C):b===1?H(v,_):nt(b,v,_)}function Ie(b,v,_){return v===void 0?(C,A)=>A?Ie(b,C,A):Ie(b,C):_===void 0?C=>Ie(b,v,C):x(C=>C!=null,R(it(b,v,_)))}async function*Me(...b){let v=b.map(i),_=new Set,C=new Map,A=null,B=null,N=null,O=ee=>{A=ee,B&&B(ee)},U=ee=>{N&&N(ee)},W=()=>new Promise((ee,fe)=>{if(A&&fe(A),C.size>0)return ee();N=ee,B=fe}),Q=ee=>{let fe=Promise.resolve(ee.next()).then(async({done:ke,value:ge})=>{ke||C.set(ee,ge),_.delete(fe)});_.add(fe),fe.then(U,O)};for(let ee of v)Q(ee);for(;;){if(_.size===0&&C.size===0)return;await W();for(let[ee,fe]of C)C.delete(ee),yield fe,Q(ee)}}async function ne(b,v,_){let C=v;for await(let A of _)C=await b(C,A);return C}function tr(b,v,_){return v===void 0?(C,A)=>A?ne(b,C,A):tr(b,C):_===void 0?C=>tr(b,v,C):ne(b,v,_)}async function*Wt(b,v){let _=0;for await(let C of v)if(yield await C,_++,_>=b)break}function*fn(b,v){let _=0;for(let C of v)if(yield C,_++,_>=b)break}function Yt(b,v){return v===void 0?_=>Yt(b,_):v[Symbol.asyncIterator]?Wt(b,v):fn(b,v)}async function*hn(b,v){for await(let _ of v)await b(_),yield _}function z(b,v){return v===void 0?_=>hn(b,_):hn(b,v)}function cs(b,v){let _=b[0]+v[0],C=b[1]+v[1];if(C>=1e9){let A=C%1e9;_+=(C-A)/1e9,C=A}return[_,C]}async function*Va(b,v){let _=v[Symbol.asyncIterator](),C=[0,0];for(;;){let A=process.hrtime(),{value:B,done:N}=await _.next(),O=process.hrtime(A);if(C=cs(C,O),b.progress&&b.progress(O,C),N)return b.total&&b.total(C),B;yield B}}function*Io(b,v){let _=v[Symbol.iterator](),C=[0,0];for(;;){let A=process.hrtime(),{value:B,done:N}=_.next(),O=process.hrtime(A);if(C=cs(C,O),b.progress&&b.progress(O,C),N)return b.total&&b.total(C),B;yield B}}function Kt(b={},v){return v===void 0?_=>Kt(b,_):v[Symbol.asyncIterator]!==void 0?Va(b,v):Io(b,v)}function Tr(b,v,_){let C=i(_),A=[],B=[],N=!1,O=!1,U=0,W=null;function Q(){for(;B.length>0&&A.length>0;){let{resolve:ae}=B.shift(),ue=A.shift();ae({done:!1,value:ue})}for(;B.length>0&&U===0&&N;){let{resolve:ae,reject:ue}=B.shift();W?(ue(W),W=null):ae({done:!0,value:void 0})}}async function ee(){if(N){Q();return}if(!O&&!(U+A.length>=b)){O=!0,U++;try{let{done:ae,value:ue}=await C.next();ae?(N=!0,U--,Q()):fe(ue)}catch(ae){N=!0,U--,W=ae,Q()}O=!1,ee()}}async function fe(ae){try{let ue=await v(ae);A.push(ue)}catch(ue){N=!0,W=ue}U--,Q(),ee()}async function ke(){if(A.length===0){let ue=s();return B.push(ue),ee(),ue.promise}let ae=A.shift();return ee(),{done:!1,value:ae}}let ge={next:ke,[Symbol.asyncIterator]:()=>ge};return ge}function E(b,v,_){return v===void 0?(C,A)=>A?E(b,C,A):E(b,C):_===void 0?C=>E(b,v,C):Tr(b,v,_)}async function S(b,v){let _=null,C=null,A=null,B=W=>{_=W,C&&C(W)},N=()=>{A&&A()},O=()=>{b.removeListener("error",B),b.removeListener("drain",N)};b.once("error",B);let U=()=>new Promise((W,Q)=>{if(_)return Q(_);b.once("drain",N),A=W,C=Q});for await(let W of v)if(b.write(W)===!1&&await U(),_)break;if(O(),_)throw _}function I(b,v){return v===void 0?_=>S(b,_):S(b,v)}t.batch=n,t.buffer=c,t.collect=l,t.concat=p,t.consume=g,t.filter=x,t.flatMap=q,t.flatTransform=J,t.flatten=R,t.fromStream=we,t.getIterator=i,t.map=H,t.merge=le,t.parallelFlatMap=Ie,t.parallelMap=it,t.parallelMerge=Me,t.pipeline=ye,t.reduce=tr,t.take=Yt,t.tap=z,t.time=Kt,t.transform=E,t.writeToStream=I,Object.defineProperty(t,"__esModule",{value:!0})})});var Ex=w((MK,bx)=>{bx.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function i(s,o){r[s]=o,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(s){return r[s]!==void 0||n[s]!==void 0},remove:function(s){r[s]!==void 0&&(r[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var o=r[s];if(o!==void 0)return o;if((o=n[s])!==void 0)return i(s,o),o},set:function(s,o){r[s]!==void 0?r[s]=o:i(s,o)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var _x=w((FK,wx)=>{"use strict";var fk=Ex();wx.exports=t=>{let e=fk(t);return e.delete=e.remove,e}});var Sx=w((xx,Lu)=>{(function(t){"use strict";var e,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,i=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",a=1e14,c=14,u=9007199254740991,l=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],f=1e7,h=1e9;function p(q){var k,J,ie,j=z.prototype={constructor:z,toString:null,valueOf:null},we=new z(1),le=20,ye=4,nt=-7,it=21,Ie=-1e7,Me=1e7,ne=!1,tr=1,Wt=0,fn={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Yt="0123456789abcdefghijklmnopqrstuvwxyz",hn=!0;function z(E,S){var I,b,v,_,C,A,B,N,O=this;if(!(O instanceof z))return new z(E,S);if(S==null){if(E&&E._isBigNumber===!0){O.s=E.s,!E.c||E.e>Me?O.c=O.e=null:E.e<Ie?O.c=[O.e=0]:(O.e=E.e,O.c=E.c.slice());return}if((A=typeof E=="number")&&E*0==0){if(O.s=1/E<0?(E=-E,-1):1,E===~~E){for(_=0,C=E;C>=10;C/=10,_++);_>Me?O.c=O.e=null:(O.e=_,O.c=[E]);return}N=String(E)}else{if(!r.test(N=String(E)))return ie(O,N,A);O.s=N.charCodeAt(0)==45?(N=N.slice(1),-1):1}(_=N.indexOf("."))>-1&&(N=N.replace(".","")),(C=N.search(/e/i))>0?(_<0&&(_=C),_+=+N.slice(C+1),N=N.substring(0,C)):_<0&&(_=N.length)}else{if(x(S,2,Yt.length,"Base"),S==10&&hn)return O=new z(E),Kt(O,le+O.e+1,ye);if(N=String(E),A=typeof E=="number"){if(E*0!=0)return ie(O,N,A,S);if(O.s=1/E<0?(N=N.slice(1),-1):1,z.DEBUG&&N.replace(/^0\.0*|\./,"").length>15)throw Error(o+E)}else O.s=N.charCodeAt(0)===45?(N=N.slice(1),-1):1;for(I=Yt.slice(0,S),_=C=0,B=N.length;C<B;C++)if(I.indexOf(b=N.charAt(C))<0){if(b=="."){if(C>_){_=B;continue}}else if(!v&&(N==N.toUpperCase()&&(N=N.toLowerCase())||N==N.toLowerCase()&&(N=N.toUpperCase()))){v=!0,C=-1,_=0;continue}return ie(O,String(E),A,S)}A=!1,N=J(N,S,10,O.s),(_=N.indexOf("."))>-1?N=N.replace(".",""):_=N.length}for(C=0;N.charCodeAt(C)===48;C++);for(B=N.length;N.charCodeAt(--B)===48;);if(N=N.slice(C,++B)){if(B-=C,A&&z.DEBUG&&B>15&&(E>u||E!==i(E)))throw Error(o+O.s*E);if((_=_-C-1)>Me)O.c=O.e=null;else if(_<Ie)O.c=[O.e=0];else{if(O.e=_,O.c=[],C=(_+1)%c,_<0&&(C+=c),C<B){for(C&&O.c.push(+N.slice(0,C)),B-=c;C<B;)O.c.push(+N.slice(C,C+=c));C=c-(N=N.slice(C)).length}else C-=B;for(;C--;N+="0");O.c.push(+N)}}else O.c=[O.e=0]}z.clone=p,z.ROUND_UP=0,z.ROUND_DOWN=1,z.ROUND_CEIL=2,z.ROUND_FLOOR=3,z.ROUND_HALF_UP=4,z.ROUND_HALF_DOWN=5,z.ROUND_HALF_EVEN=6,z.ROUND_HALF_CEIL=7,z.ROUND_HALF_FLOOR=8,z.EUCLID=9,z.config=z.set=function(E){var S,I;if(E!=null)if(typeof E=="object"){if(E.hasOwnProperty(S="DECIMAL_PLACES")&&(I=E[S],x(I,0,h,S),le=I),E.hasOwnProperty(S="ROUNDING_MODE")&&(I=E[S],x(I,0,8,S),ye=I),E.hasOwnProperty(S="EXPONENTIAL_AT")&&(I=E[S],I&&I.pop?(x(I[0],-h,0,S),x(I[1],0,h,S),nt=I[0],it=I[1]):(x(I,-h,h,S),nt=-(it=I<0?-I:I))),E.hasOwnProperty(S="RANGE"))if(I=E[S],I&&I.pop)x(I[0],-h,-1,S),x(I[1],1,h,S),Ie=I[0],Me=I[1];else if(x(I,-h,h,S),I)Ie=-(Me=I<0?-I:I);else throw Error(s+S+" cannot be zero: "+I);if(E.hasOwnProperty(S="CRYPTO"))if(I=E[S],I===!!I)if(I)if(typeof crypto!="undefined"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))ne=I;else throw ne=!I,Error(s+"crypto unavailable");else ne=I;else throw Error(s+S+" not true or false: "+I);if(E.hasOwnProperty(S="MODULO_MODE")&&(I=E[S],x(I,0,9,S),tr=I),E.hasOwnProperty(S="POW_PRECISION")&&(I=E[S],x(I,0,h,S),Wt=I),E.hasOwnProperty(S="FORMAT"))if(I=E[S],typeof I=="object")fn=I;else throw Error(s+S+" not an object: "+I);if(E.hasOwnProperty(S="ALPHABET"))if(I=E[S],typeof I=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(I))hn=I.slice(0,10)=="0123456789",Yt=I;else throw Error(s+S+" invalid: "+I)}else throw Error(s+"Object expected: "+E);return{DECIMAL_PLACES:le,ROUNDING_MODE:ye,EXPONENTIAL_AT:[nt,it],RANGE:[Ie,Me],CRYPTO:ne,MODULO_MODE:tr,POW_PRECISION:Wt,FORMAT:fn,ALPHABET:Yt}},z.isBigNumber=function(E){if(!E||E._isBigNumber!==!0)return!1;if(!z.DEBUG)return!0;var S,I,b=E.c,v=E.e,_=E.s;e:if({}.toString.call(b)=="[object Array]"){if((_===1||_===-1)&&v>=-h&&v<=h&&v===i(v)){if(b[0]===0){if(v===0&&b.length===1)return!0;break e}if(S=(v+1)%c,S<1&&(S+=c),String(b[0]).length==S){for(S=0;S<b.length;S++)if(I=b[S],I<0||I>=a||I!==i(I))break e;if(I!==0)return!0}}}else if(b===null&&v===null&&(_===null||_===1||_===-1))return!0;throw Error(s+"Invalid BigNumber: "+E)},z.maximum=z.max=function(){return Va(arguments,j.lt)},z.minimum=z.min=function(){return Va(arguments,j.gt)},z.random=function(){var E=9007199254740992,S=Math.random()*E&2097151?function(){return i(Math.random()*E)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(I){var b,v,_,C,A,B=0,N=[],O=new z(we);if(I==null?I=le:x(I,0,h),C=n(I/c),ne)if(crypto.getRandomValues){for(b=crypto.getRandomValues(new Uint32Array(C*=2));B<C;)A=b[B]*131072+(b[B+1]>>>11),A>=9e15?(v=crypto.getRandomValues(new Uint32Array(2)),b[B]=v[0],b[B+1]=v[1]):(N.push(A%1e14),B+=2);B=C/2}else if(crypto.randomBytes){for(b=crypto.randomBytes(C*=7);B<C;)A=(b[B]&31)*281474976710656+b[B+1]*1099511627776+b[B+2]*4294967296+b[B+3]*16777216+(b[B+4]<<16)+(b[B+5]<<8)+b[B+6],A>=9e15?crypto.randomBytes(7).copy(b,B):(N.push(A%1e14),B+=7);B=C/7}else throw ne=!1,Error(s+"crypto unavailable");if(!ne)for(;B<C;)A=S(),A<9e15&&(N[B++]=A%1e14);for(C=N[--B],I%=c,C&&I&&(A=l[c-I],N[B]=i(C/A)*A);N[B]===0;N.pop(),B--);if(B<0)N=[_=0];else{for(_=-1;N[0]===0;N.splice(0,1),_-=c);for(B=1,A=N[0];A>=10;A/=10,B++);B<c&&(_-=c-B)}return O.e=_,O.c=N,O}}(),z.sum=function(){for(var E=1,S=arguments,I=new z(S[0]);E<S.length;)I=I.plus(S[E++]);return I},J=function(){var E="0123456789";function S(I,b,v,_){for(var C,A=[0],B,N=0,O=I.length;N<O;){for(B=A.length;B--;A[B]*=b);for(A[0]+=_.indexOf(I.charAt(N++)),C=0;C<A.length;C++)A[C]>v-1&&(A[C+1]==null&&(A[C+1]=0),A[C+1]+=A[C]/v|0,A[C]%=v)}return A.reverse()}return function(I,b,v,_,C){var A,B,N,O,U,W,Q,ee,fe=I.indexOf("."),ke=le,ge=ye;for(fe>=0&&(O=Wt,Wt=0,I=I.replace(".",""),ee=new z(b),W=ee.pow(I.length-fe),Wt=O,ee.c=S(H(g(W.c),W.e,"0"),10,v,E),ee.e=ee.c.length),Q=S(I,b,v,C?(A=Yt,E):(A=E,Yt)),N=O=Q.length;Q[--O]==0;Q.pop());if(!Q[0])return A.charAt(0);if(fe<0?--N:(W.c=Q,W.e=N,W.s=_,W=k(W,ee,ke,ge,v),Q=W.c,U=W.r,N=W.e),B=N+ke+1,fe=Q[B],O=v/2,U=U||B<0||Q[B+1]!=null,U=ge<4?(fe!=null||U)&&(ge==0||ge==(W.s<0?3:2)):fe>O||fe==O&&(ge==4||U||ge==6&&Q[B-1]&1||ge==(W.s<0?8:7)),B<1||!Q[0])I=U?H(A.charAt(1),-ke,A.charAt(0)):A.charAt(0);else{if(Q.length=B,U)for(--v;++Q[--B]>v;)Q[B]=0,B||(++N,Q=[1].concat(Q));for(O=Q.length;!Q[--O];);for(fe=0,I="";fe<=O;I+=A.charAt(Q[fe++]));I=H(I,N,A.charAt(0))}return I}}(),k=function(){function E(b,v,_){var C,A,B,N,O=0,U=b.length,W=v%f,Q=v/f|0;for(b=b.slice();U--;)B=b[U]%f,N=b[U]/f|0,C=Q*B+N*W,A=W*B+C%f*f+O,O=(A/_|0)+(C/f|0)+Q*N,b[U]=A%_;return O&&(b=[O].concat(b)),b}function S(b,v,_,C){var A,B;if(_!=C)B=_>C?1:-1;else for(A=B=0;A<_;A++)if(b[A]!=v[A]){B=b[A]>v[A]?1:-1;break}return B}function I(b,v,_,C){for(var A=0;_--;)b[_]-=A,A=b[_]<v[_]?1:0,b[_]=A*C+b[_]-v[_];for(;!b[0]&&b.length>1;b.splice(0,1));}return function(b,v,_,C,A){var B,N,O,U,W,Q,ee,fe,ke,ge,ae,ue,us,cl,ul,Fr,To,cr=b.s==v.s?1:-1,Vt=b.c,at=v.c;if(!Vt||!Vt[0]||!at||!at[0])return new z(!b.s||!v.s||(Vt?at&&Vt[0]==at[0]:!at)?NaN:Vt&&Vt[0]==0||!at?cr*0:cr/0);for(fe=new z(cr),ke=fe.c=[],N=b.e-v.e,cr=_+N+1,A||(A=a,N=d(b.e/c)-d(v.e/c),cr=cr/c|0),O=0;at[O]==(Vt[O]||0);O++);if(at[O]>(Vt[O]||0)&&N--,cr<0)ke.push(1),U=!0;else{for(cl=Vt.length,Fr=at.length,O=0,cr+=2,W=i(A/(at[0]+1)),W>1&&(at=E(at,W,A),Vt=E(Vt,W,A),Fr=at.length,cl=Vt.length),us=Fr,ge=Vt.slice(0,Fr),ae=ge.length;ae<Fr;ge[ae++]=0);To=at.slice(),To=[0].concat(To),ul=at[0],at[1]>=A/2&&ul++;do{if(W=0,B=S(at,ge,Fr,ae),B<0){if(ue=ge[0],Fr!=ae&&(ue=ue*A+(ge[1]||0)),W=i(ue/ul),W>1)for(W>=A&&(W=A-1),Q=E(at,W,A),ee=Q.length,ae=ge.length;S(Q,ge,ee,ae)==1;)W--,I(Q,Fr<ee?To:at,ee,A),ee=Q.length,B=1;else W==0&&(B=W=1),Q=at.slice(),ee=Q.length;if(ee<ae&&(Q=[0].concat(Q)),I(ge,Q,ae,A),ae=ge.length,B==-1)for(;S(at,ge,Fr,ae)<1;)W++,I(ge,Fr<ae?To:at,ae,A),ae=ge.length}else B===0&&(W++,ge=[0]);ke[O++]=W,ge[0]?ge[ae++]=Vt[us]||0:(ge=[Vt[us]],ae=1)}while((us++<cl||ge[0]!=null)&&cr--);U=ge[0]!=null,ke[0]||ke.splice(0,1)}if(A==a){for(O=1,cr=ke[0];cr>=10;cr/=10,O++);Kt(fe,_+(fe.e=O+N*c-1)+1,C,U)}else fe.e=N,fe.r=+U;return fe}}();function cs(E,S,I,b){var v,_,C,A,B;if(I==null?I=ye:x(I,0,8),!E.c)return E.toString();if(v=E.c[0],C=E.e,S==null)B=g(E.c),B=b==1||b==2&&(C<=nt||C>=it)?L(B,C):H(B,C,"0");else if(E=Kt(new z(E),S,I),_=E.e,B=g(E.c),A=B.length,b==1||b==2&&(S<=_||_<=nt)){for(;A<S;B+="0",A++);B=L(B,_)}else if(S-=C,B=H(B,_,"0"),_+1>A){if(--S>0)for(B+=".";S--;B+="0");}else if(S+=_-A,S>0)for(_+1==A&&(B+=".");S--;B+="0");return E.s<0&&v?"-"+B:B}function Va(E,S){for(var I,b=1,v=new z(E[0]);b<E.length;b++)if(I=new z(E[b]),I.s)S.call(v,I)&&(v=I);else{v=I;break}return v}function Io(E,S,I){for(var b=1,v=S.length;!S[--v];S.pop());for(v=S[0];v>=10;v/=10,b++);return(I=b+I*c-1)>Me?E.c=E.e=null:I<Ie?E.c=[E.e=0]:(E.e=I,E.c=S),E}ie=function(){var E=/^(-?)0([xbo])(?=\w[\w.]*$)/i,S=/^([^.]+)\.$/,I=/^\.([^.]+)$/,b=/^-?(Infinity|NaN)$/,v=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(_,C,A,B){var N,O=A?C:C.replace(v,"");if(b.test(O))_.s=isNaN(O)?null:O<0?-1:1;else{if(!A&&(O=O.replace(E,function(U,W,Q){return N=(Q=Q.toLowerCase())=="x"?16:Q=="b"?2:8,!B||B==N?W:U}),B&&(N=B,O=O.replace(S,"$1").replace(I,"0.$1")),C!=O))return new z(O,N);if(z.DEBUG)throw Error(s+"Not a"+(B?" base "+B:"")+" number: "+C);_.s=null}_.c=_.e=null}}();function Kt(E,S,I,b){var v,_,C,A,B,N,O,U=E.c,W=l;if(U){e:{for(v=1,A=U[0];A>=10;A/=10,v++);if(_=S-v,_<0)_+=c,C=S,B=U[N=0],O=B/W[v-C-1]%10|0;else if(N=n((_+1)/c),N>=U.length)if(b){for(;U.length<=N;U.push(0));B=O=0,v=1,_%=c,C=_-c+1}else break e;else{for(B=A=U[N],v=1;A>=10;A/=10,v++);_%=c,C=_-c+v,O=C<0?0:B/W[v-C-1]%10|0}if(b=b||S<0||U[N+1]!=null||(C<0?B:B%W[v-C-1]),b=I<4?(O||b)&&(I==0||I==(E.s<0?3:2)):O>5||O==5&&(I==4||b||I==6&&(_>0?C>0?B/W[v-C]:0:U[N-1])%10&1||I==(E.s<0?8:7)),S<1||!U[0])return U.length=0,b?(S-=E.e+1,U[0]=W[(c-S%c)%c],E.e=-S||0):U[0]=E.e=0,E;if(_==0?(U.length=N,A=1,N--):(U.length=N+1,A=W[c-_],U[N]=C>0?i(B/W[v-C]%W[C])*A:0),b)for(;;)if(N==0){for(_=1,C=U[0];C>=10;C/=10,_++);for(C=U[0]+=A,A=1;C>=10;C/=10,A++);_!=A&&(E.e++,U[0]==a&&(U[0]=1));break}else{if(U[N]+=A,U[N]!=a)break;U[N--]=0,A=1}for(_=U.length;U[--_]===0;U.pop());}E.e>Me?E.c=E.e=null:E.e<Ie&&(E.c=[E.e=0])}return E}function Tr(E){var S,I=E.e;return I===null?E.toString():(S=g(E.c),S=I<=nt||I>=it?L(S,I):H(S,I,"0"),E.s<0?"-"+S:S)}return j.absoluteValue=j.abs=function(){var E=new z(this);return E.s<0&&(E.s=1),E},j.comparedTo=function(E,S){return m(this,new z(E,S))},j.decimalPlaces=j.dp=function(E,S){var I,b,v,_=this;if(E!=null)return x(E,0,h),S==null?S=ye:x(S,0,8),Kt(new z(_),E+_.e+1,S);if(!(I=_.c))return null;if(b=((v=I.length-1)-d(this.e/c))*c,v=I[v])for(;v%10==0;v/=10,b--);return b<0&&(b=0),b},j.dividedBy=j.div=function(E,S){return k(this,new z(E,S),le,ye)},j.dividedToIntegerBy=j.idiv=function(E,S){return k(this,new z(E,S),0,1)},j.exponentiatedBy=j.pow=function(E,S){var I,b,v,_,C,A,B,N,O,U=this;if(E=new z(E),E.c&&!E.isInteger())throw Error(s+"Exponent not an integer: "+Tr(E));if(S!=null&&(S=new z(S)),A=E.e>14,!U.c||!U.c[0]||U.c[0]==1&&!U.e&&U.c.length==1||!E.c||!E.c[0])return O=new z(Math.pow(+Tr(U),A?2-R(E):+Tr(E))),S?O.mod(S):O;if(B=E.s<0,S){if(S.c?!S.c[0]:!S.s)return new z(NaN);b=!B&&U.isInteger()&&S.isInteger(),b&&(U=U.mod(S))}else{if(E.e>9&&(U.e>0||U.e<-1||(U.e==0?U.c[0]>1||A&&U.c[1]>=24e7:U.c[0]<8e13||A&&U.c[0]<=9999975e7)))return _=U.s<0&&R(E)?-0:0,U.e>-1&&(_=1/_),new z(B?1/_:_);Wt&&(_=n(Wt/c+2))}for(A?(I=new z(.5),B&&(E.s=1),N=R(E)):(v=Math.abs(+Tr(E)),N=v%2),O=new z(we);;){if(N){if(O=O.times(U),!O.c)break;_?O.c.length>_&&(O.c.length=_):b&&(O=O.mod(S))}if(v){if(v=i(v/2),v===0)break;N=v%2}else if(E=E.times(I),Kt(E,E.e+1,1),E.e>14)N=R(E);else{if(v=+Tr(E),v===0)break;N=v%2}U=U.times(U),_?U.c&&U.c.length>_&&(U.c.length=_):b&&(U=U.mod(S))}return b?O:(B&&(O=we.div(O)),S?O.mod(S):_?Kt(O,Wt,ye,C):O)},j.integerValue=function(E){var S=new z(this);return E==null?E=ye:x(E,0,8),Kt(S,S.e+1,E)},j.isEqualTo=j.eq=function(E,S){return m(this,new z(E,S))===0},j.isFinite=function(){return!!this.c},j.isGreaterThan=j.gt=function(E,S){return m(this,new z(E,S))>0},j.isGreaterThanOrEqualTo=j.gte=function(E,S){return(S=m(this,new z(E,S)))===1||S===0},j.isInteger=function(){return!!this.c&&d(this.e/c)>this.c.length-2},j.isLessThan=j.lt=function(E,S){return m(this,new z(E,S))<0},j.isLessThanOrEqualTo=j.lte=function(E,S){return(S=m(this,new z(E,S)))===-1||S===0},j.isNaN=function(){return!this.s},j.isNegative=function(){return this.s<0},j.isPositive=function(){return this.s>0},j.isZero=function(){return!!this.c&&this.c[0]==0},j.minus=function(E,S){var I,b,v,_,C=this,A=C.s;if(E=new z(E,S),S=E.s,!A||!S)return new z(NaN);if(A!=S)return E.s=-S,C.plus(E);var B=C.e/c,N=E.e/c,O=C.c,U=E.c;if(!B||!N){if(!O||!U)return O?(E.s=-S,E):new z(U?C:NaN);if(!O[0]||!U[0])return U[0]?(E.s=-S,E):new z(O[0]?C:ye==3?-0:0)}if(B=d(B),N=d(N),O=O.slice(),A=B-N){for((_=A<0)?(A=-A,v=O):(N=B,v=U),v.reverse(),S=A;S--;v.push(0));v.reverse()}else for(b=(_=(A=O.length)<(S=U.length))?A:S,A=S=0;S<b;S++)if(O[S]!=U[S]){_=O[S]<U[S];break}if(_&&(v=O,O=U,U=v,E.s=-E.s),S=(b=U.length)-(I=O.length),S>0)for(;S--;O[I++]=0);for(S=a-1;b>A;){if(O[--b]<U[b]){for(I=b;I&&!O[--I];O[I]=S);--O[I],O[b]+=a}O[b]-=U[b]}for(;O[0]==0;O.splice(0,1),--N);return O[0]?Io(E,O,N):(E.s=ye==3?-1:1,E.c=[E.e=0],E)},j.modulo=j.mod=function(E,S){var I,b,v=this;return E=new z(E,S),!v.c||!E.s||E.c&&!E.c[0]?new z(NaN):!E.c||v.c&&!v.c[0]?new z(v):(tr==9?(b=E.s,E.s=1,I=k(v,E,0,3),E.s=b,I.s*=b):I=k(v,E,0,tr),E=v.minus(I.times(E)),!E.c[0]&&tr==1&&(E.s=v.s),E)},j.multipliedBy=j.times=function(E,S){var I,b,v,_,C,A,B,N,O,U,W,Q,ee,fe,ke,ge=this,ae=ge.c,ue=(E=new z(E,S)).c;if(!ae||!ue||!ae[0]||!ue[0])return!ge.s||!E.s||ae&&!ae[0]&&!ue||ue&&!ue[0]&&!ae?E.c=E.e=E.s=null:(E.s*=ge.s,!ae||!ue?E.c=E.e=null:(E.c=[0],E.e=0)),E;for(b=d(ge.e/c)+d(E.e/c),E.s*=ge.s,B=ae.length,U=ue.length,B<U&&(ee=ae,ae=ue,ue=ee,v=B,B=U,U=v),v=B+U,ee=[];v--;ee.push(0));for(fe=a,ke=f,v=U;--v>=0;){for(I=0,W=ue[v]%ke,Q=ue[v]/ke|0,C=B,_=v+C;_>v;)N=ae[--C]%ke,O=ae[C]/ke|0,A=Q*N+O*W,N=W*N+A%ke*ke+ee[_]+I,I=(N/fe|0)+(A/ke|0)+Q*O,ee[_--]=N%fe;ee[_]=I}return I?++b:ee.splice(0,1),Io(E,ee,b)},j.negated=function(){var E=new z(this);return E.s=-E.s||null,E},j.plus=function(E,S){var I,b=this,v=b.s;if(E=new z(E,S),S=E.s,!v||!S)return new z(NaN);if(v!=S)return E.s=-S,b.minus(E);var _=b.e/c,C=E.e/c,A=b.c,B=E.c;if(!_||!C){if(!A||!B)return new z(v/0);if(!A[0]||!B[0])return B[0]?E:new z(A[0]?b:v*0)}if(_=d(_),C=d(C),A=A.slice(),v=_-C){for(v>0?(C=_,I=B):(v=-v,I=A),I.reverse();v--;I.push(0));I.reverse()}for(v=A.length,S=B.length,v-S<0&&(I=B,B=A,A=I,S=v),v=0;S;)v=(A[--S]=A[S]+B[S]+v)/a|0,A[S]=a===A[S]?0:A[S]%a;return v&&(A=[v].concat(A),++C),Io(E,A,C)},j.precision=j.sd=function(E,S){var I,b,v,_=this;if(E!=null&&E!==!!E)return x(E,1,h),S==null?S=ye:x(S,0,8),Kt(new z(_),E,S);if(!(I=_.c))return null;if(v=I.length-1,b=v*c+1,v=I[v]){for(;v%10==0;v/=10,b--);for(v=I[0];v>=10;v/=10,b++);}return E&&_.e+1>b&&(b=_.e+1),b},j.shiftedBy=function(E){return x(E,-u,u),this.times("1e"+E)},j.squareRoot=j.sqrt=function(){var E,S,I,b,v,_=this,C=_.c,A=_.s,B=_.e,N=le+4,O=new z("0.5");if(A!==1||!C||!C[0])return new z(!A||A<0&&(!C||C[0])?NaN:C?_:1/0);if(A=Math.sqrt(+Tr(_)),A==0||A==1/0?(S=g(C),(S.length+B)%2==0&&(S+="0"),A=Math.sqrt(+S),B=d((B+1)/2)-(B<0||B%2),A==1/0?S="5e"+B:(S=A.toExponential(),S=S.slice(0,S.indexOf("e")+1)+B),I=new z(S)):I=new z(A+""),I.c[0]){for(B=I.e,A=B+N,A<3&&(A=0);;)if(v=I,I=O.times(v.plus(k(_,v,N,1))),g(v.c).slice(0,A)===(S=g(I.c)).slice(0,A))if(I.e<B&&--A,S=S.slice(A-3,A+1),S=="9999"||!b&&S=="4999"){if(!b&&(Kt(v,v.e+le+2,0),v.times(v).eq(_))){I=v;break}N+=4,A+=4,b=1}else{(!+S||!+S.slice(1)&&S.charAt(0)=="5")&&(Kt(I,I.e+le+2,1),E=!I.times(I).eq(_));break}}return Kt(I,I.e+le+1,ye,E)},j.toExponential=function(E,S){return E!=null&&(x(E,0,h),E++),cs(this,E,S,1)},j.toFixed=function(E,S){return E!=null&&(x(E,0,h),E=E+this.e+1),cs(this,E,S)},j.toFormat=function(E,S,I){var b,v=this;if(I==null)E!=null&&S&&typeof S=="object"?(I=S,S=null):E&&typeof E=="object"?(I=E,E=S=null):I=fn;else if(typeof I!="object")throw Error(s+"Argument not an object: "+I);if(b=v.toFixed(E,S),v.c){var _,C=b.split("."),A=+I.groupSize,B=+I.secondaryGroupSize,N=I.groupSeparator||"",O=C[0],U=C[1],W=v.s<0,Q=W?O.slice(1):O,ee=Q.length;if(B&&(_=A,A=B,B=_,ee-=_),A>0&&ee>0){for(_=ee%A||A,O=Q.substr(0,_);_<ee;_+=A)O+=N+Q.substr(_,A);B>0&&(O+=N+Q.slice(_)),W&&(O="-"+O)}b=U?O+(I.decimalSeparator||"")+((B=+I.fractionGroupSize)?U.replace(new RegExp("\\d{"+B+"}\\B","g"),"$&"+(I.fractionGroupSeparator||"")):U):O}return(I.prefix||"")+b+(I.suffix||"")},j.toFraction=function(E){var S,I,b,v,_,C,A,B,N,O,U,W,Q=this,ee=Q.c;if(E!=null&&(A=new z(E),!A.isInteger()&&(A.c||A.s!==1)||A.lt(we)))throw Error(s+"Argument "+(A.isInteger()?"out of range: ":"not an integer: ")+Tr(A));if(!ee)return new z(Q);for(S=new z(we),N=I=new z(we),b=B=new z(we),W=g(ee),_=S.e=W.length-Q.e-1,S.c[0]=l[(C=_%c)<0?c+C:C],E=!E||A.comparedTo(S)>0?_>0?S:N:A,C=Me,Me=1/0,A=new z(W),B.c[0]=0;O=k(A,S,0,1),v=I.plus(O.times(b)),v.comparedTo(E)!=1;)I=b,b=v,N=B.plus(O.times(v=N)),B=v,S=A.minus(O.times(v=S)),A=v;return v=k(E.minus(I),b,0,1),B=B.plus(v.times(N)),I=I.plus(v.times(b)),B.s=N.s=Q.s,_=_*2,U=k(N,b,_,ye).minus(Q).abs().comparedTo(k(B,I,_,ye).minus(Q).abs())<1?[N,b]:[B,I],Me=C,U},j.toNumber=function(){return+Tr(this)},j.toPrecision=function(E,S){return E!=null&&x(E,1,h),cs(this,E,S,2)},j.toString=function(E){var S,I=this,b=I.s,v=I.e;return v===null?b?(S="Infinity",b<0&&(S="-"+S)):S="NaN":(E==null?S=v<=nt||v>=it?L(g(I.c),v):H(g(I.c),v,"0"):E===10&&hn?(I=Kt(new z(I),le+v+1,ye),S=H(g(I.c),I.e,"0")):(x(E,2,Yt.length,"Base"),S=J(H(g(I.c),v,"0"),10,E,b,!0)),b<0&&I.c[0]&&(S="-"+S)),S},j.valueOf=j.toJSON=function(){return Tr(this)},j._isBigNumber=!0,q!=null&&z.set(q),z}function d(q){var k=q|0;return q>0||q===k?k:k-1}function g(q){for(var k,J,ie=1,j=q.length,we=q[0]+"";ie<j;){for(k=q[ie++]+"",J=c-k.length;J--;k="0"+k);we+=k}for(j=we.length;we.charCodeAt(--j)===48;);return we.slice(0,j+1||1)}function m(q,k){var J,ie,j=q.c,we=k.c,le=q.s,ye=k.s,nt=q.e,it=k.e;if(!le||!ye)return null;if(J=j&&!j[0],ie=we&&!we[0],J||ie)return J?ie?0:-ye:le;if(le!=ye)return le;if(J=le<0,ie=nt==it,!j||!we)return ie?0:!j^J?1:-1;if(!ie)return nt>it^J?1:-1;for(ye=(nt=j.length)<(it=we.length)?nt:it,le=0;le<ye;le++)if(j[le]!=we[le])return j[le]>we[le]^J?1:-1;return nt==it?0:nt>it^J?1:-1}function x(q,k,J,ie){if(q<k||q>J||q!==i(q))throw Error(s+(ie||"Argument")+(typeof q=="number"?q<k||q>J?" out of range: ":" not an integer: ":" not a primitive number: ")+String(q))}function R(q){var k=q.c.length-1;return d(q.e/c)==k&&q.c[k]%2!=0}function L(q,k){return(q.length>1?q.charAt(0)+"."+q.slice(1):q)+(k<0?"e":"e+")+k}function H(q,k,J){var ie,j;if(k<0){for(j=J+".";++k;j+=J);q=j+q}else if(ie=q.length,++k>ie){for(j=J,k-=ie;--k;j+=J);q+=j}else k<ie&&(q=q.slice(0,k)+"."+q.slice(k));return q}e=p(),e.default=e.BigNumber=e,typeof define=="function"&&define.amd?define(function(){return e}):typeof Lu!="undefined"&&Lu.exports?Lu.exports=e:(t||(t=typeof self!="undefined"&&self?self:window),t.BigNumber=e)})(xx)});var Ix=w((Ax,Cx)=>{"use strict";var hk=Math.exp;Ax=Cx.exports=function(e){if(typeof e!="number")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");let r,n=0,i=0,s=0,o,a={};function c(u,l){return 1-hk(-(u-l)/e)}return a.push=function(l,f){if(o){let h=c(l,o),p=f-r,d=h*p;r=h*f+(1-h)*r,n=(1-h)*(n+p*d),i=Math.sqrt(n),s=r+h*p}else r=f;o=l},a.movingAverage=function(){return r},a.variance=function(){return n},a.deviation=function(){return i},a.forecast=function(){return s},a}});var Px=w((KK,Bx)=>{"use strict";var{EventEmitter:dk}=Qt(),{BigNumber:ku}=Sx(),Tx=Ix(),pk=ga(),Rx=class extends dk{constructor(e,r){super();this._options=r,this._queue=[],this._stats={dataReceived:ku(0),dataSent:ku(0)},this._frequencyLastTime=Date.now(),this._frequencyAccumulators={},this._movingAverages={},this._update=this._update.bind(this);let n=this._options.movingAverageIntervals;for(let i=0;i<e.length;i++){let s=e[i];this._stats[s]=ku(0),this._movingAverages[s]={};for(let o=0;o<n.length;o++){let a=n[o];(this._movingAverages[s][a]=Tx(a)).push(this._frequencyLastTime,0)}}}start(){this._queue.length&&this._resetComputeTimeout()}stop(){this._timeout&&(this._timeout.clear(),this._timeout=null)}get snapshot(){return Object.assign({},this._stats)}get movingAverages(){return Object.assign({},this._movingAverages)}toJSON(){let e=this.snapshot,r=this.movingAverages,n={dataReceived:e.dataReceived.toString(),dataSent:e.dataSent.toString(),movingAverages:{}},i=Object.keys(r);for(let s of i){n.movingAverages[s]={};for(let o of Object.keys(r[s]))n.movingAverages[s][o]=r[s][o].movingAverage()}return n}push(e,r){this._queue.push([e,r,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this._timeout=pk(this._update,this._nextTimeout())}_nextTimeout(){let e=this._queue.length/this._options.computeThrottleMaxQueueSize;return Math.max(this._options.computeThrottleTimeout*(1-e),0)}_update(){if(this._timeout=null,this._queue.length){let e;for(e of this._queue)this._applyOp(e);this._queue=[],this._updateFrequency(e[2]),this.emit("update",this._stats)}}_updateFrequency(e){let r=e-this._frequencyLastTime;Object.keys(this._stats).forEach(n=>{this._updateFrequencyFor(n,r,e)}),this._frequencyLastTime=e}_updateFrequencyFor(e,r,n){let i=this._frequencyAccumulators[e]||0;this._frequencyAccumulators[e]=0;let o=i/(r||1)*1e3,a=this._movingAverages[e];a||(a=this._movingAverages[e]={});let c=this._options.movingAverageIntervals;for(let u=0;u<c.length;u++){let l=c[u],f=a[l];f||(f=a[l]=Tx(l)),f.push(n,o)}}_applyOp(e){let r=e[0],n=e[1];if(typeof n!="number")throw new Error(`invalid increment number: ${n}`);let i;Object.prototype.hasOwnProperty.call(this._stats,r)?i=this._stats[r]:i=this._stats[r]=ku(0),this._stats[r]=i.plus(n),this._frequencyAccumulators[r]||(this._frequencyAccumulators[r]=0),this._frequencyAccumulators[r]+=n}};Bx.exports=Rx});var Dx=w((VK,Ox)=>{"use strict";var yk=Vs(),{pipe:gk}=nn(),{tap:Nx}=Du(),mk=_x(),{METRICS:vk}=au(),Ad=Px(),Cd=["dataReceived","dataSent"],bk={in:"dataReceived",out:"dataSent"},qu=class{constructor(e){this._options=yk(vk,e),this._globalStats=new Ad(Cd,this._options),this._peerStats=new Map,this._protocolStats=new Map,this._oldPeers=mk(this._options.maxOldPeersRetention),this._running=!1,this._onMessage=this._onMessage.bind(this),this._systems=new Map}start(){this._running=!0}stop(){this._running=!1,this._globalStats.stop();for(let e of this._peerStats.values())e.stop();for(let e of this._protocolStats.values())e.stop()}get global(){return this._globalStats}get peers(){return Array.from(this._peerStats.keys())}getComponentMetrics(){return this._systems}updateComponentMetric({system:e="libp2p",component:r,metric:n,value:i}){this._systems.has(e)||this._systems.set(e,new Map);let s=this._systems.get(e);s.has(r)||s.set(r,new Map),s.get(r).set(n,i)}forPeer(e){let r=e.toB58String();return this._peerStats.get(r)||this._oldPeers.get(r)}get protocols(){return Array.from(this._protocolStats.keys())}forProtocol(e){return this._protocolStats.get(e)}onPeerDisconnected(e){let r=e.toB58String(),n=this._peerStats.get(r);n&&(n.stop(),this._peerStats.delete(r),this._oldPeers.set(r,n))}_onMessage({remotePeer:e,protocol:r,direction:n,dataLength:i}){if(!this._running)return;let s=bk[n],o=this.forPeer(e);if(o||(o=new Ad(Cd,this._options),this._peerStats.set(e.toB58String(),o)),o.push(s,i),this._globalStats.push(s,i),r){let a=this.forProtocol(r);a||(a=new Ad(Cd,this._options),this._protocolStats.set(r,a)),a.push(s,i)}}updatePlaceholder(e,r){if(!this._running)return;let n=this.forPeer(e),i=r.toB58String(),s=this.forPeer(r),o=n;s&&(o=qu.mergeStats(s,o),this._oldPeers.delete(i)),this._peerStats.delete(e.toB58String()),this._peerStats.set(i,o),o.start()}trackStream({stream:e,remotePeer:r,protocol:n}){let i=this,s=e.source;e.source=Nx(a=>i._onMessage({remotePeer:r,protocol:n,direction:"in",dataLength:a.length}))(s);let o=e.sink;return e.sink=a=>gk(a,Nx(c=>i._onMessage({remotePeer:r,protocol:n,direction:"out",dataLength:c.length})),o),e}static mergeStats(e,r){return e.stop(),r.stop(),e._queue=[...e._queue,...r._queue],e}};Ox.exports=qu});var Uu=w((jK,Ux)=>{"use strict";var Lx=Yi(),kx=ro(),{pipe:Ek}=nn(),wk=he(),{fromString:_k}=(It(),Nt),xk=hh(),{source:Sk}=vu(),qx=_k(`
45
+ `);function Id(t){return kx.encode.single(new Lx([t,qx]))}function Ak(t,e){t.push(Id(e))}async function Ck(t,e){t.push(e.reduce((r,n)=>r.append(Id(n)),new Lx))}async function Ik(t,e){let r=1,n={[Symbol.asyncIterator](){return this},next:()=>t.next(r)},i=n;e&&e.signal&&(i=Sk(n,e.signal));let s=a=>{r=a},o=await Ek(i,kx.decode({onLength:s}),xk);if(o.get(o.length-1)!==qx[0])throw wk(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.shallowSlice(0,-1)}Ux.exports={encode:Id,write:Ak,writeAll:Ck,read:Ik}});var Kx=w(($K,Fx)=>{"use strict";var Mx=Te(),Tk=he(),ho=Uu(),Rk=no(),po=Object.assign(Mx("mss:select"),{error:Mx("mss:select:error")});Fx.exports=async function(e,r,n,i){r=Array.isArray(r)?[...r]:[r];let{reader:s,writer:o,rest:a,stream:c}=Rk(e),u=r.shift();if(!u)throw new Error("At least one protocol must be specified");n?(po('select: write ["%s", "%s"]',n,u),ho.writeAll(o,[n,u])):(po('select: write "%s"',u),ho.write(o,u));let l=(await ho.read(s,i)).toString();if(po('select: read "%s"',l),l===n&&(l=(await ho.read(s,i)).toString(),po('select: read "%s"',l)),l===u)return a(),{stream:c,protocol:u};for(let f of r){po('select: write "%s"',f),ho.write(o,f);let h=(await ho.read(s,i)).toString();if(po('select: read "%s" for "%s"',h,f),h===f)return a(),{stream:c,protocol:f}}throw a(),Tk(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}});var Td=w(Vx=>{"use strict";Vx.PROTOCOL_ID="/multistream/1.0.0"});var Hx=w((zK,$x)=>{"use strict";var jx=Te(),Bk=Yi(),yo=Uu(),Pk=no(),{PROTOCOL_ID:Rd}=Td(),Oa=Object.assign(jx("mss:handle"),{error:jx("mss:handle:error")});$x.exports=async function(e,r,n){r=Array.isArray(r)?r:[r];let{writer:i,reader:s,rest:o,stream:a}=Pk(e);for(;;){let c=(await yo.read(s,n)).toString();if(Oa('read "%s"',c),c===Rd){Oa('respond with "%s" for "%s"',Rd,c),yo.write(i,Rd);continue}if(r.includes(c))return yo.write(i,c),Oa('respond with "%s" for "%s"',c,c),o(),{stream:a,protocol:c};if(c==="ls"){yo.write(i,new Bk(r.map(u=>yo.encode(u)))),Oa('respond with "%s" for %s',r,c);continue}yo.write(i,"na"),Oa('respond with "na" for "%s"',c)}}});var Yx=w((GK,Wx)=>{"use strict";var Nk=td(),zx=Te(),Gx=Uu(),Ok=no(),Dk=ro(),{pipe:Lk}=nn(),kk=Object.assign(zx("mss:ls"),{error:zx("mss:ls:error")});Wx.exports=async function(e,r){let{reader:n,writer:i,rest:s,stream:o}=Ok(e);kk('write "ls"'),Gx.write(i,"ls"),s();let a=await Gx.read(n,r),c=Nk([a]),u=[];return await Lk(c,Dk.decode(),async f=>{for await(let h of f)u.push(h.shallowSlice(0,-1).toString())}),{stream:o,protocols:u}}});var Jx=w(Mu=>{"use strict";var Qx=Kx(),qk=Hx(),Uk=Yx(),{PROTOCOL_ID:Bd}=Td();Mu.PROTOCOL_ID=Bd;var Pd=class{constructor(e){this._stream=e,this._shaken=!1}async _handshake(e){if(this._shaken)return;let{stream:r}=await Qx(this._stream,Bd,void 0,e);this._stream=r,this._shaken=!0}},Xx=class extends Pd{select(e,r){return Qx(this._stream,e,this._shaken?void 0:Bd,r)}async ls(e){await this._handshake(e);let r=await Uk(this._stream,e),{stream:n,protocols:i}=r;return this._stream=n,i}};Mu.Dialer=Xx;var Zx=class extends Pd{handle(e,r){return qk(this._stream,e,r)}};Mu.Listener=Zx});var tS=w((YK,eS)=>{"use strict";var Mk={OPEN:"open",CLOSING:"closing",CLOSED:"closed"};eS.exports=Mk});var aS=w((QK,oS)=>{"use strict";var rS=Rt(),{Multiaddr:Fk}=qt(),sr=he(),{OPEN:Kk,CLOSING:nS,CLOSED:Nd}=tS(),iS=Symbol.for("@libp2p/interface-connection/connection"),sS=class{constructor({localAddr:e,remoteAddr:r,localPeer:n,remotePeer:i,newStream:s,close:o,getStreams:a,stat:c}){Vk(e,n,i,s,o,a,c),this.id=parseInt(String(Math.random()*1e9)).toString(36)+Date.now(),this.localAddr=e,this.remoteAddr=r,this.localPeer=n,this.remotePeer=i,this._stat={...c,status:Kk},this._newStream=s,this._close=o,this._getStreams=a,this.registry=new Map,this.tags=[]}get[Symbol.toStringTag](){return"Connection"}get[iS](){return!0}static isConnection(e){return Boolean(e&&e[iS])}get stat(){return this._stat}get streams(){return this._getStreams()}async newStream(e){if(this.stat.status===nS)throw sr(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(this.stat.status===Nd)throw sr(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);let{stream:r,protocol:n}=await this._newStream(e);return this.addStream(r,{protocol:n}),{stream:r,protocol:n}}addStream(e,{protocol:r,metadata:n={}}){this.registry.set(e.id,{protocol:r,...n})}removeStream(e){this.registry.delete(e)}async close(){if(this.stat.status!==Nd){if(this._closing)return this._closing;this.stat.status=nS,this._closing=await this._close(),this._stat.timeline.close=Date.now(),this.stat.status=Nd}}};oS.exports=sS;function Vk(t,e,r,n,i,s,o){if(t&&!Fk.isMultiaddr(t))throw sr(new Error("localAddr must be an instance of multiaddr"),"ERR_INVALID_PARAMETERS");if(!rS.isPeerId(e))throw sr(new Error("localPeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(!rS.isPeerId(r))throw sr(new Error("remotePeer must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");if(typeof n!="function")throw sr(new Error("new stream must be a function"),"ERR_INVALID_PARAMETERS");if(typeof i!="function")throw sr(new Error("close must be a function"),"ERR_INVALID_PARAMETERS");if(typeof s!="function")throw sr(new Error("getStreams must be a function"),"ERR_INVALID_PARAMETERS");if(!o)throw sr(new Error("connection metadata object must be provided"),"ERR_INVALID_PARAMETERS");if(o.direction!=="inbound"&&o.direction!=="outbound")throw sr(new Error('direction must be "inbound" or "outbound"'),"ERR_INVALID_PARAMETERS");if(!o.timeline)throw sr(new Error("connection timeline object must be provided in the stat object"),"ERR_INVALID_PARAMETERS");if(!o.timeline.open)throw sr(new Error("connection open timestamp must be provided"),"ERR_INVALID_PARAMETERS");if(!o.timeline.upgraded)throw sr(new Error("connection upgraded timestamp must be provided"),"ERR_INVALID_PARAMETERS")}});var uS=w(cS=>{"use strict";cS.Connection=aS()});var fS=w((ZK,lS)=>{"use strict";function jk(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}else return Array.from(t)}lS.exports=function(e){var r=void 0,n=void 0;function i(a){if(!(a instanceof Object))throw new Error('Target "'+a+'" is not an object');n=a}function s(a){Object.keys(a).forEach(function(c){var u=a[c];if(typeof u!="function")throw new Error('Trap "'+c+": "+u+'" is not a function');if(!Reflect[c])throw new Error('Trap "'+c+": "+u+'" is not a valid trap')}),r=a}i(function(){}),e&&i(e),s(Reflect);var o=new Proxy({},{get:function(c,u){return function(){for(var l=arguments.length,f=Array(l),h=0;h<l;h++)f[h]=arguments[h];return r[u].apply(null,[n].concat(jk(f.slice(1))))}}});return{setTarget:i,setHandler:s,getTarget:function(){return n},getHandler:function(){return r},proxy:new Proxy(n,o)}}});var gS=w((JK,yS)=>{"use strict";var hS=Te(),vt=Object.assign(hS("libp2p:upgrader"),{error:hS("libp2p:upgrader:err")}),rs=he(),go=Jx(),{Connection:$k}=uS(),Hk=Rt(),{pipe:zk}=nn(),dS=fS(),{codes:ns}=je(),pS=class{constructor({localPeer:e,metrics:r,cryptos:n=new Map,muxers:i=new Map,onConnectionEnd:s=()=>{},onConnection:o=()=>{}}){this.localPeer=e,this.metrics=r,this.cryptos=n,this.muxers=i,this.protector=null,this.protocols=new Map,this.onConnection=o,this.onConnectionEnd=s}async upgradeInbound(e){let r,n,i,s,o,a,c;if(this.metrics){({setTarget:a,proxy:c}=dS());let l=(Math.random()*1e9).toString(36)+Date.now();a({toB58String:()=>l}),e=this.metrics.trackStream({stream:e,remotePeer:c})}vt("Starting the inbound connection upgrade");let u=e;this.protector&&(u=await this.protector.protect(e));try{({conn:r,remotePeer:n,protocol:o}=await this._encryptInbound(this.localPeer,u,this.cryptos)),this.muxers.size?{stream:i,Muxer:s}=await this._multiplexInbound(r,this.muxers):i=r}catch(l){throw vt.error("Failed to upgrade inbound connection",l),await e.close(l),l}return this.metrics&&(this.metrics.updatePlaceholder(c,n),a(n)),vt("Successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:e,upgradedConn:i,Muxer:s,remotePeer:n})}async upgradeOutbound(e){let r=e.remoteAddr.getPeerId();if(!r)throw rs(new Error("outbound connection must have a peer id"),ns.ERR_INVALID_MULTIADDR);let n=Hk.createFromB58String(r),i,s,o,a,c,u,l;if(this.metrics){({setTarget:u,proxy:l}=dS());let h=(Math.random()*1e9).toString(36)+Date.now();u({toB58String:()=>h}),e=this.metrics.trackStream({stream:e,remotePeer:l})}vt("Starting the outbound connection upgrade");let f=e;this.protector&&(f=await this.protector.protect(e));try{({conn:i,remotePeer:s,protocol:a}=await this._encryptOutbound(this.localPeer,f,n,this.cryptos)),this.muxers.size?{stream:o,Muxer:c}=await this._multiplexOutbound(i,this.muxers):o=i}catch(h){throw vt.error("Failed to upgrade outbound connection",h),await e.close(h),h}return this.metrics&&(this.metrics.updatePlaceholder(l,s),u(s)),vt("Successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:a,direction:"outbound",maConn:e,upgradedConn:o,Muxer:c,remotePeer:s})}_createConnection({cryptoProtocol:e,direction:r,maConn:n,upgradedConn:i,Muxer:s,remotePeer:o}){let a,c,u;s&&(a=new s({onStream:async h=>{if(!u)return;let p=new go.Listener(h);try{let{stream:d,protocol:g}=await p.handle(Array.from(this.protocols.keys()));vt("%s: incoming stream opened on %s",r,g),this.metrics&&this.metrics.trackStream({stream:d,remotePeer:o,protocol:g}),u.addStream(h,{protocol:g}),this._onStream({connection:u,stream:{...h,...d},protocol:g})}catch(d){vt.error(d)}},onStreamEnd:h=>{u.removeStream(h.id)}}),c=async h=>{vt("%s: starting new stream on %s",r,h);let p=a.newStream(),d=new go.Dialer(p);try{let{stream:g,protocol:m}=await d.select(h);return this.metrics&&this.metrics.trackStream({stream:g,remotePeer:o,protocol:m}),{stream:{...p,...g},protocol:m}}catch(g){throw vt.error("could not create new stream",g),rs(g,ns.ERR_UNSUPPORTED_PROTOCOL)}},zk(i,a,i).catch(vt.error));let l=n.timeline;n.timeline=new Proxy(l,{set:(...h)=>(u&&h[1]==="close"&&h[2]&&!l.close&&(async()=>{try{u.stat.status==="open"&&await u.close()}catch(p){vt.error(p)}finally{this.onConnectionEnd(u)}})().catch(p=>{vt.error(p)}),Reflect.set(...h))}),n.timeline.upgraded=Date.now();let f=()=>{throw rs(new Error("connection is not multiplexed"),ns.ERR_CONNECTION_NOT_MULTIPLEXED)};return u=new $k({localAddr:n.localAddr,remoteAddr:n.remoteAddr,localPeer:this.localPeer,remotePeer:o,stat:{direction:r,timeline:n.timeline,multiplexer:s&&s.multicodec,encryption:e},newStream:c||f,getStreams:()=>a?a.streams:f(),close:async()=>{await n.close(),a&&a.streams.map(h=>h.abort())}}),this.onConnection(u),u}_onStream({connection:e,stream:r,protocol:n}){this.protocols.get(n)({connection:e,stream:r,protocol:n})}async _encryptInbound(e,r,n){let i=new go.Listener(r),s=Array.from(n.keys());vt("handling inbound crypto protocol selection",s);try{let{stream:o,protocol:a}=await i.handle(s),c=n.get(a);if(vt("encrypting inbound connection..."),!c)throw new Error(`no crypto module found for ${a}`);return{...await c.secureInbound(e,o),protocol:a}}catch(o){throw rs(o,ns.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,r,n,i){let s=new go.Dialer(r),o=Array.from(i.keys());vt("selecting outbound crypto protocol",o);try{let{stream:a,protocol:c}=await s.select(o),u=i.get(c);if(vt("encrypting outbound connection to %j",n),!u)throw new Error(`no crypto module found for ${c}`);return{...await u.secureOutbound(e,a,n),protocol:c}}catch(a){throw rs(a,ns.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,r){let n=new go.Dialer(e),i=Array.from(r.keys());vt("outbound selecting muxer %s",i);try{let{stream:s,protocol:o}=await n.select(i);vt("%s selected as muxer protocol",o);let a=r.get(o);return{stream:s,Muxer:a}}catch(s){throw rs(s,ns.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,r){let n=new go.Listener(e),i=Array.from(r.keys());vt("inbound handling muxers %s",i);try{let{stream:s,protocol:o}=await n.handle(i),a=r.get(o);return{stream:s,Muxer:a}}catch(s){throw rs(s,ns.ERR_MUXER_UNAVAILABLE)}}};yS.exports=pS});var _S=w((eV,wS)=>{"use strict";var mS=Te(),mo=he(),{Multiaddr:Gk}=qt(),Fu=Rt(),{codes:un}=je(),vS=du(),bS=fu(),Ke=Object.assign(mS("libp2p:peer-store:address-book"),{error:mS("libp2p:peer-store:address-book:err")}),Ku="change:multiaddrs",ES=class{constructor(e,r){this._emit=e,this._store=r}async consumePeerRecord(e){Ke("consumePeerRecord await write lock");let r=await this._store.lock.writeLock();Ke("consumePeerRecord got write lock");let n,i;try{let s;try{s=vS.createFromProtobuf(e.payload)}catch(a){return Ke.error("invalid peer record received"),!1}n=s.peerId;let o=s.multiaddrs;if(!n.equals(e.peerId))return Ke("signing key does not match PeerId in the PeerRecord"),!1;if(!o||!o.length)return!1;if(await this._store.has(n)){let a=await this._store.load(n);if(a.peerRecordEnvelope){let c=await bS.createFromProtobuf(a.peerRecordEnvelope);if(vS.createFromProtobuf(c.payload).seqNumber>=s.seqNumber)return!1}}i=await this._store.patchOrCreate(n,{addresses:Od(o,!0),peerRecordEnvelope:e.marshal()}),Ke(`stored provided peer record for ${s.peerId.toB58String()}`)}finally{Ke("consumePeerRecord release write lock"),r()}return this._emit(Ku,{peerId:n,multiaddrs:i.addresses.map(({multiaddr:s})=>s)}),!0}async getRawEnvelope(e){Ke("getRawEnvelope await read lock");let r=await this._store.lock.readLock();Ke("getRawEnvelope got read lock");try{return(await this._store.load(e)).peerRecordEnvelope}catch(n){if(n.code!==un.ERR_NOT_FOUND)throw n}finally{Ke("getRawEnvelope release read lock"),r()}}async getPeerRecord(e){let r=await this.getRawEnvelope(e);if(!!r)return bS.createFromProtobuf(r)}async get(e){if(!Fu.isPeerId(e))throw Ke.error("peerId must be an instance of peer-id to store data"),mo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Ke("get wait for read lock");let r=await this._store.lock.readLock();Ke("get got read lock");try{return(await this._store.load(e)).addresses}catch(n){if(n.code!==un.ERR_NOT_FOUND)throw n}finally{Ke("get release read lock"),r()}return[]}async set(e,r){if(!Fu.isPeerId(e))throw Ke.error("peerId must be an instance of peer-id to store data"),mo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Ke("set await write lock");let n=await this._store.lock.writeLock();Ke("set got write lock");let i=!1,s;try{let o=Od(r);if(!o.length)return;try{let a=await this._store.load(e);if(i=!0,new Set([...o.map(({multiaddr:c})=>c.toString()),...a.addresses.map(({multiaddr:c})=>c.toString())]).size===a.addresses.length&&o.length===a.addresses.length)return}catch(a){if(a.code!==un.ERR_NOT_FOUND)throw a}s=await this._store.patchOrCreate(e,{addresses:o}),Ke(`set multiaddrs for ${e.toB58String()}`)}finally{Ke("set release write lock"),n()}this._emit(Ku,{peerId:e,multiaddrs:s.addresses.map(o=>o.multiaddr)}),i||this._emit("peer",e)}async add(e,r){if(!Fu.isPeerId(e))throw Ke.error("peerId must be an instance of peer-id to store data"),mo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Ke("add await write lock");let n=await this._store.lock.writeLock();Ke("add got write lock");let i,s;try{let o=Od(r);if(!o.length)return;try{let a=await this._store.load(e);if(i=!0,new Set([...o.map(({multiaddr:c})=>c.toString()),...a.addresses.map(({multiaddr:c})=>c.toString())]).size===a.addresses.length)return}catch(a){if(a.code!==un.ERR_NOT_FOUND)throw a}s=await this._store.mergeOrCreate(e,{addresses:o}),Ke(`added multiaddrs for ${e}`)}finally{Ke("set release write lock"),n()}this._emit(Ku,{peerId:e,multiaddrs:s.addresses.map(o=>o.multiaddr)}),i||this._emit("peer",e)}async delete(e){if(!Fu.isPeerId(e))throw Ke.error("peerId must be an instance of peer-id to store data"),mo(new Error("peerId must be an instance of peer-id"),un.ERR_INVALID_PARAMETERS);Ke("delete await write lock");let r=await this._store.lock.writeLock();Ke("delete got write lock");let n;try{n=await this._store.has(e),await this._store.patchOrCreate(e,{addresses:[]})}finally{Ke("delete release write lock"),r()}n&&this._emit(Ku,{peerId:e,multiaddrs:[]})}async getMultiaddrsForPeer(e,r=n=>n){let n=await this.get(e);return r(n).map(i=>{let s=i.multiaddr,o=s.getPeerId();return o&&o===e.toB58String()?s:s.encapsulate(`/p2p/${e.toB58String()}`)})}};function Od(t,e=!1){if(!t)throw Ke.error("multiaddrs must be provided to store data"),mo(new Error("multiaddrs must be provided"),un.ERR_INVALID_PARAMETERS);return Array.from(new Set(t.map(r=>r.toString()))).map(r=>{try{return{multiaddr:new Gk(r),isCertified:e}}catch(n){throw mo(n,un.ERR_INVALID_PARAMETERS)}})}wS.exports=ES});var IS=w((tV,CS)=>{"use strict";var xS=Te(),Vu=he(),{codes:vo}=je(),Dd=Rt(),{equals:Wk}=(pr(),dr),or=Object.assign(xS("libp2p:peer-store:key-book"),{error:xS("libp2p:peer-store:key-book:err")}),SS="change:pubkey",AS=class{constructor(e,r){this._emit=e,this._store=r}async set(e,r){if(!Dd.isPeerId(e))throw or.error("peerId must be an instance of peer-id to store data"),Vu(new Error("peerId must be an instance of peer-id"),vo.ERR_INVALID_PARAMETERS);if(!r)throw or.error("publicKey must be an instance of PublicKey to store data"),Vu(new Error("publicKey must be an instance of PublicKey"),vo.ERR_INVALID_PARAMETERS);or("set await write lock");let n=await this._store.lock.writeLock();or("set got write lock");let i=!1;try{try{let s=await this._store.load(e);if(s.pubKey&&Wk(s.pubKey.bytes,r.bytes))return}catch(s){if(s.code!==vo.ERR_NOT_FOUND)throw s}await this._store.patchOrCreate(e,{pubKey:r}),i=!0}finally{or("set release write lock"),n()}i&&this._emit(SS,{peerId:e,pubKey:r})}async get(e){if(!Dd.isPeerId(e))throw or.error("peerId must be an instance of peer-id to store data"),Vu(new Error("peerId must be an instance of peer-id"),vo.ERR_INVALID_PARAMETERS);or("get await write lock");let r=await this._store.lock.readLock();or("get got write lock");try{return(await this._store.load(e)).pubKey}catch(n){if(n.code!==vo.ERR_NOT_FOUND)throw n}finally{or("get release write lock"),r()}}async delete(e){if(!Dd.isPeerId(e))throw or.error("peerId must be an instance of peer-id to store data"),Vu(new Error("peerId must be an instance of peer-id"),vo.ERR_INVALID_PARAMETERS);or("delete await write lock");let r=await this._store.lock.writeLock();or("delete got write lock");try{await this._store.patchOrCreate(e,{pubKey:void 0})}finally{or("delete release write lock"),r()}this._emit(SS,{peerId:e,pubKey:void 0})}};CS.exports=AS});var PS=w((rV,BS)=>{"use strict";var TS=Te(),hi=he(),{codes:Ar}=je(),bo=Rt(),{equals:Yk}=(pr(),dr),We=Object.assign(TS("libp2p:peer-store:metadata-book"),{error:TS("libp2p:peer-store:metadata-book:err")}),ju="change:metadata",RS=class{constructor(e,r){this._emit=e,this._store=r}async get(e){if(!bo.isPeerId(e))throw We.error("peerId must be an instance of peer-id to store data"),hi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);We("get await read lock");let r=await this._store.lock.readLock();We("get got read lock");try{return(await this._store.load(e)).metadata}catch(n){if(n.code!==Ar.ERR_NOT_FOUND)throw n}finally{We("get release read lock"),r()}return new Map}async getValue(e,r){if(!bo.isPeerId(e))throw We.error("peerId must be an instance of peer-id to store data"),hi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);We("getValue await read lock");let n=await this._store.lock.readLock();We("getValue got read lock");try{return(await this._store.load(e)).metadata.get(r)}catch(i){if(i.code!==Ar.ERR_NOT_FOUND)throw i}finally{We("getValue release write lock"),n()}}async set(e,r){if(!bo.isPeerId(e))throw We.error("peerId must be an instance of peer-id to store data"),hi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);if(!r||!(r instanceof Map))throw We.error("valid metadata must be provided to store data"),hi(new Error("valid metadata must be provided"),Ar.ERR_INVALID_PARAMETERS);We("set await write lock");let n=await this._store.lock.writeLock();We("set got write lock");try{await this._store.mergeOrCreate(e,{metadata:r})}finally{We("set release write lock"),n()}this._emit(ju,{peerId:e,metadata:r})}async setValue(e,r,n){if(!bo.isPeerId(e))throw We.error("peerId must be an instance of peer-id to store data"),hi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);if(typeof r!="string"||!(n instanceof Uint8Array))throw We.error("valid key and value must be provided to store data"),hi(new Error("valid key and value must be provided"),Ar.ERR_INVALID_PARAMETERS);We("setValue await write lock");let i=await this._store.lock.writeLock();We("setValue got write lock");let s;try{try{let a=(await this._store.load(e)).metadata.get(r);if(a!=null&&Yk(n,a))return}catch(o){if(o.code!==Ar.ERR_NOT_FOUND)throw o}s=await this._store.mergeOrCreate(e,{metadata:new Map([[r,n]])})}finally{We("setValue release write lock"),i()}this._emit(ju,{peerId:e,metadata:s.metadata})}async delete(e){if(!bo.isPeerId(e))throw We.error("peerId must be an instance of peer-id to store data"),hi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);We("delete await write lock");let r=await this._store.lock.writeLock();We("delete got write lock");let n;try{n=await this._store.has(e),n&&await this._store.patch(e,{metadata:new Map})}finally{We("delete release write lock"),r()}n&&this._emit(ju,{peerId:e,metadata:new Map})}async deleteValue(e,r){if(!bo.isPeerId(e))throw We.error("peerId must be an instance of peer-id to store data"),hi(new Error("peerId must be an instance of peer-id"),Ar.ERR_INVALID_PARAMETERS);We("deleteValue await write lock");let n=await this._store.lock.writeLock();We("deleteValue got write lock");let i;try{i=(await this._store.load(e)).metadata,i.delete(r),await this._store.patch(e,{metadata:i})}catch(s){if(s.code!==Ar.ERR_NOT_FOUND)throw s}finally{We("deleteValue release write lock"),n()}i&&this._emit(ju,{peerId:e,metadata:i})}};BS.exports=RS});var LS=w((nV,DS)=>{"use strict";var NS=Te(),Eo=he(),{codes:Ur}=je(),Ld=Rt(),ot=Object.assign(NS("libp2p:peer-store:proto-book"),{error:NS("libp2p:peer-store:proto-book:err")}),$u="change:protocols",OS=class{constructor(e,r){this._emit=e,this._store=r}async get(e){ot("get wait for read lock");let r=await this._store.lock.readLock();ot("get got read lock");try{return(await this._store.load(e)).protocols}catch(n){if(n.code!==Ur.ERR_NOT_FOUND)throw n}finally{ot("get release read lock"),r()}return[]}async set(e,r){if(!Ld.isPeerId(e))throw ot.error("peerId must be an instance of peer-id to store data"),Eo(new Error("peerId must be an instance of peer-id"),Ur.ERR_INVALID_PARAMETERS);if(!Array.isArray(r))throw ot.error("protocols must be provided to store data"),Eo(new Error("protocols must be provided"),Ur.ERR_INVALID_PARAMETERS);ot("set await write lock");let n=await this._store.lock.writeLock();ot("set got write lock");let i;try{try{let s=await this._store.load(e);if(new Set([...r]).size===s.protocols.length)return}catch(s){if(s.code!==Ur.ERR_NOT_FOUND)throw s}i=await this._store.patchOrCreate(e,{protocols:r}),ot(`stored provided protocols for ${e.toB58String()}`)}finally{ot("set release write lock"),n()}this._emit($u,{peerId:e,protocols:i.protocols})}async add(e,r){if(!Ld.isPeerId(e))throw ot.error("peerId must be an instance of peer-id to store data"),Eo(new Error("peerId must be an instance of peer-id"),Ur.ERR_INVALID_PARAMETERS);if(!Array.isArray(r))throw ot.error("protocols must be provided to store data"),Eo(new Error("protocols must be provided"),Ur.ERR_INVALID_PARAMETERS);ot("add await write lock");let n=await this._store.lock.writeLock();ot("add got write lock");let i;try{try{let s=await this._store.load(e);if(new Set([...s.protocols,...r]).size===s.protocols.length)return}catch(s){if(s.code!==Ur.ERR_NOT_FOUND)throw s}i=await this._store.mergeOrCreate(e,{protocols:r}),ot(`added provided protocols for ${e.toB58String()}`)}finally{ot("add release write lock"),n()}this._emit($u,{peerId:e,protocols:i.protocols})}async remove(e,r){if(!Ld.isPeerId(e))throw ot.error("peerId must be an instance of peer-id to store data"),Eo(new Error("peerId must be an instance of peer-id"),Ur.ERR_INVALID_PARAMETERS);if(!Array.isArray(r))throw ot.error("protocols must be provided to store data"),Eo(new Error("protocols must be provided"),Ur.ERR_INVALID_PARAMETERS);ot("remove await write lock");let n=await this._store.lock.writeLock();ot("remove got write lock");let i;try{try{let s=await this._store.load(e),o=new Set(s.protocols);for(let a of r)o.delete(a);if(s.protocols.length===o.size)return;r=Array.from(o)}catch(s){if(s.code!==Ur.ERR_NOT_FOUND)throw s}i=await this._store.patchOrCreate(e,{protocols:r})}finally{ot("remove release write lock"),n()}this._emit($u,{peerId:e,protocols:i.protocols})}async delete(e){ot("delete await write lock");let r=await this._store.lock.writeLock();ot("delete got write lock");let n;try{n=await this._store.has(e),await this._store.patchOrCreate(e,{protocols:[]})}catch(i){if(i.code!==Ur.ERR_NOT_FOUND)throw i}finally{ot("delete release write lock"),r()}n&&this._emit($u,{peerId:e,protocols:[]})}};DS.exports=OS});var qS=w((iV,kS)=>{"use strict";var di=pn(),wo=di.Reader,kd=di.Writer,Ue=di.util,yt=di.roots["libp2p-peer"]||(di.roots["libp2p-peer"]={});yt.Peer=function(){function t(r){if(this.addresses=[],this.protocols=[],this.metadata=[],r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}t.prototype.addresses=Ue.emptyArray,t.prototype.protocols=Ue.emptyArray,t.prototype.metadata=Ue.emptyArray,t.prototype.pubKey=null,t.prototype.peerRecordEnvelope=null;var e;return Object.defineProperty(t.prototype,"_pubKey",{get:Ue.oneOfGetter(e=["pubKey"]),set:Ue.oneOfSetter(e)}),Object.defineProperty(t.prototype,"_peerRecordEnvelope",{get:Ue.oneOfGetter(e=["peerRecordEnvelope"]),set:Ue.oneOfSetter(e)}),t.encode=function(n,i){if(i||(i=kd.create()),n.addresses!=null&&n.addresses.length)for(var s=0;s<n.addresses.length;++s)yt.Address.encode(n.addresses[s],i.uint32(10).fork()).ldelim();if(n.protocols!=null&&n.protocols.length)for(var s=0;s<n.protocols.length;++s)i.uint32(18).string(n.protocols[s]);if(n.metadata!=null&&n.metadata.length)for(var s=0;s<n.metadata.length;++s)yt.Metadata.encode(n.metadata[s],i.uint32(26).fork()).ldelim();return n.pubKey!=null&&Object.hasOwnProperty.call(n,"pubKey")&&i.uint32(34).bytes(n.pubKey),n.peerRecordEnvelope!=null&&Object.hasOwnProperty.call(n,"peerRecordEnvelope")&&i.uint32(42).bytes(n.peerRecordEnvelope),i},t.decode=function(n,i){n instanceof wo||(n=wo.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new yt.Peer;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.addresses&&o.addresses.length||(o.addresses=[]),o.addresses.push(yt.Address.decode(n,n.uint32()));break;case 2:o.protocols&&o.protocols.length||(o.protocols=[]),o.protocols.push(n.string());break;case 3:o.metadata&&o.metadata.length||(o.metadata=[]),o.metadata.push(yt.Metadata.decode(n,n.uint32()));break;case 4:o.pubKey=n.bytes();break;case 5:o.peerRecordEnvelope=n.bytes();break;default:n.skipType(a&7);break}}return o},t.fromObject=function(n){if(n instanceof yt.Peer)return n;var i=new yt.Peer;if(n.addresses){if(!Array.isArray(n.addresses))throw TypeError(".Peer.addresses: array expected");i.addresses=[];for(var s=0;s<n.addresses.length;++s){if(typeof n.addresses[s]!="object")throw TypeError(".Peer.addresses: object expected");i.addresses[s]=yt.Address.fromObject(n.addresses[s])}}if(n.protocols){if(!Array.isArray(n.protocols))throw TypeError(".Peer.protocols: array expected");i.protocols=[];for(var s=0;s<n.protocols.length;++s)i.protocols[s]=String(n.protocols[s])}if(n.metadata){if(!Array.isArray(n.metadata))throw TypeError(".Peer.metadata: array expected");i.metadata=[];for(var s=0;s<n.metadata.length;++s){if(typeof n.metadata[s]!="object")throw TypeError(".Peer.metadata: object expected");i.metadata[s]=yt.Metadata.fromObject(n.metadata[s])}}return n.pubKey!=null&&(typeof n.pubKey=="string"?Ue.base64.decode(n.pubKey,i.pubKey=Ue.newBuffer(Ue.base64.length(n.pubKey)),0):n.pubKey.length&&(i.pubKey=n.pubKey)),n.peerRecordEnvelope!=null&&(typeof n.peerRecordEnvelope=="string"?Ue.base64.decode(n.peerRecordEnvelope,i.peerRecordEnvelope=Ue.newBuffer(Ue.base64.length(n.peerRecordEnvelope)),0):n.peerRecordEnvelope.length&&(i.peerRecordEnvelope=n.peerRecordEnvelope)),i},t.toObject=function(n,i){i||(i={});var s={};if((i.arrays||i.defaults)&&(s.addresses=[],s.protocols=[],s.metadata=[]),n.addresses&&n.addresses.length){s.addresses=[];for(var o=0;o<n.addresses.length;++o)s.addresses[o]=yt.Address.toObject(n.addresses[o],i)}if(n.protocols&&n.protocols.length){s.protocols=[];for(var o=0;o<n.protocols.length;++o)s.protocols[o]=n.protocols[o]}if(n.metadata&&n.metadata.length){s.metadata=[];for(var o=0;o<n.metadata.length;++o)s.metadata[o]=yt.Metadata.toObject(n.metadata[o],i)}return n.pubKey!=null&&n.hasOwnProperty("pubKey")&&(s.pubKey=i.bytes===String?Ue.base64.encode(n.pubKey,0,n.pubKey.length):i.bytes===Array?Array.prototype.slice.call(n.pubKey):n.pubKey,i.oneofs&&(s._pubKey="pubKey")),n.peerRecordEnvelope!=null&&n.hasOwnProperty("peerRecordEnvelope")&&(s.peerRecordEnvelope=i.bytes===String?Ue.base64.encode(n.peerRecordEnvelope,0,n.peerRecordEnvelope.length):i.bytes===Array?Array.prototype.slice.call(n.peerRecordEnvelope):n.peerRecordEnvelope,i.oneofs&&(s._peerRecordEnvelope="peerRecordEnvelope")),s},t.prototype.toJSON=function(){return this.constructor.toObject(this,di.util.toJSONOptions)},t}();yt.Address=function(){function t(r){if(r)for(var n=Object.keys(r),i=0;i<n.length;++i)r[n[i]]!=null&&(this[n[i]]=r[n[i]])}t.prototype.multiaddr=Ue.newBuffer([]),t.prototype.isCertified=null;var e;return Object.defineProperty(t.prototype,"_isCertified",{get:Ue.oneOfGetter(e=["isCertified"]),set:Ue.oneOfSetter(e)}),t.encode=function(n,i){return i||(i=kd.create()),n.multiaddr!=null&&Object.hasOwnProperty.call(n,"multiaddr")&&i.uint32(10).bytes(n.multiaddr),n.isCertified!=null&&Object.hasOwnProperty.call(n,"isCertified")&&i.uint32(16).bool(n.isCertified),i},t.decode=function(n,i){n instanceof wo||(n=wo.create(n));for(var s=i===void 0?n.len:n.pos+i,o=new yt.Address;n.pos<s;){var a=n.uint32();switch(a>>>3){case 1:o.multiaddr=n.bytes();break;case 2:o.isCertified=n.bool();break;default:n.skipType(a&7);break}}return o},t.fromObject=function(n){if(n instanceof yt.Address)return n;var i=new yt.Address;return n.multiaddr!=null&&(typeof n.multiaddr=="string"?Ue.base64.decode(n.multiaddr,i.multiaddr=Ue.newBuffer(Ue.base64.length(n.multiaddr)),0):n.multiaddr.length&&(i.multiaddr=n.multiaddr)),n.isCertified!=null&&(i.isCertified=Boolean(n.isCertified)),i},t.toObject=function(n,i){i||(i={});var s={};return i.defaults&&(i.bytes===String?s.multiaddr="":(s.multiaddr=[],i.bytes!==Array&&(s.multiaddr=Ue.newBuffer(s.multiaddr)))),n.multiaddr!=null&&n.hasOwnProperty("multiaddr")&&(s.multiaddr=i.bytes===String?Ue.base64.encode(n.multiaddr,0,n.multiaddr.length):i.bytes===Array?Array.prototype.slice.call(n.multiaddr):n.multiaddr),n.isCertified!=null&&n.hasOwnProperty("isCertified")&&(s.isCertified=n.isCertified,i.oneofs&&(s._isCertified="isCertified")),s},t.prototype.toJSON=function(){return this.constructor.toObject(this,di.util.toJSONOptions)},t}();yt.Metadata=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.key="",t.prototype.value=Ue.newBuffer([]),t.encode=function(r,n){return n||(n=kd.create()),r.key!=null&&Object.hasOwnProperty.call(r,"key")&&n.uint32(10).string(r.key),r.value!=null&&Object.hasOwnProperty.call(r,"value")&&n.uint32(18).bytes(r.value),n},t.decode=function(r,n){r instanceof wo||(r=wo.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new yt.Metadata;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.key=r.string();break;case 2:s.value=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof yt.Metadata)return r;var n=new yt.Metadata;return r.key!=null&&(n.key=String(r.key)),r.value!=null&&(typeof r.value=="string"?Ue.base64.decode(r.value,n.value=Ue.newBuffer(Ue.base64.length(r.value)),0):r.value.length&&(n.value=r.value)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.key="",n.bytes===String?i.value="":(i.value=[],n.bytes!==Array&&(i.value=Ue.newBuffer(i.value)))),r.key!=null&&r.hasOwnProperty("key")&&(i.key=r.key),r.value!=null&&r.hasOwnProperty("value")&&(i.value=n.bytes===String?Ue.base64.encode(r.value,0,r.value.length):n.bytes===Array?Array.prototype.slice.call(r.value):r.value),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,di.util.toJSONOptions)},t}();kS.exports=yt});var qd=w((sV,US)=>{US.exports={WORKER_REQUEST_READ_LOCK:"lock:worker:request-read",WORKER_RELEASE_READ_LOCK:"lock:worker:release-read",MASTER_GRANT_READ_LOCK:"lock:master:grant-read",WORKER_REQUEST_WRITE_LOCK:"lock:worker:request-write",WORKER_RELEASE_WRITE_LOCK:"lock:worker:release-write",MASTER_GRANT_WRITE_LOCK:"lock:master:grant-write"}});var MS=w(()=>{});var YS=w((cV,WS)=>{var Qk=Qt().EventEmitter,{nanoid:Xk}=(Qc(),rh),{WORKER_REQUEST_READ_LOCK:FS,WORKER_RELEASE_READ_LOCK:KS,MASTER_GRANT_READ_LOCK:VS,WORKER_REQUEST_WRITE_LOCK:jS,WORKER_RELEASE_WRITE_LOCK:$S,MASTER_GRANT_WRITE_LOCK:HS}=qd(),Da,zS=(t,e,r,n,i)=>(s,o)=>{o&&o.type===r&&t.emit(e,o.name,()=>(s.send({type:i,name:o.name,identifier:o.identifier}),new Promise(a=>{let c=u=>{u&&u.type===n&&u.identifier===o.identifier&&(s.removeListener("message",c),a())};s.on("message",c)})))},GS=(t,e,r,n)=>()=>{let i=Xk();return process.send({type:e,identifier:i,name:t}),new Promise(s=>{let o=a=>{a&&a.type===r&&a.identifier===i&&(process.removeListener("message",o),s(()=>{process.send({type:n,identifier:i,name:t})}))};process.on("message",o)})};WS.exports=t=>{try{if(Da=MS(),!Object.keys(Da).length)return}catch(e){return}if(Da.isMaster||t.singleProcess){let e=new Qk;return Da.on("message",zS(e,"requestReadLock",FS,KS,VS)),Da.on("message",zS(e,"requestWriteLock",jS,$S,HS)),e}return{isWorker:!0,readLock:e=>GS(e,FS,VS,KS),writeLock:e=>GS(e,jS,HS,$S)}}});var Ud=w((uV,QS)=>{var pi={},_o=t=>{t.addEventListener("message",e=>{_o.dispatchEvent("message",t,e)}),t.port&&t.port.addEventListener("message",e=>{_o.dispatchEvent("message",t,e)})};_o.addEventListener=(t,e)=>{pi[t]||(pi[t]=[]),pi[t].push(e)};_o.removeEventListener=(t,e)=>{!pi[t]||(pi[t]=pi[t].filter(r=>r===e))};_o.dispatchEvent=function(){let t=Array.prototype.slice.call(arguments),e=t.shift();!pi[e]||pi[e].forEach(r=>r.apply(null,t))};QS.exports=_o});var aA=w((lV,oA)=>{var Zk=Qt().EventEmitter,{nanoid:Jk}=(Qc(),rh),{WORKER_REQUEST_READ_LOCK:XS,WORKER_RELEASE_READ_LOCK:ZS,MASTER_GRANT_READ_LOCK:JS,WORKER_REQUEST_WRITE_LOCK:eA,WORKER_RELEASE_WRITE_LOCK:tA,MASTER_GRANT_WRITE_LOCK:rA}=qd(),nA=Ud(),iA=(t,e,r,n,i)=>(s,o)=>{if(!o||!o.data||o.data.type!==r)return;let a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};t.emit(e,a.name,()=>(s.postMessage({type:i,name:a.name,identifier:a.identifier}),new Promise(c=>{let u=l=>{if(!l||!l.data)return;let f={type:l.data.type,name:l.data.name,identifier:l.data.identifier};f&&f.type===n&&f.identifier===a.identifier&&(s.removeEventListener("message",u),c())};s.addEventListener("message",u)})))},sA=(t,e,r,n)=>()=>{let i=Jk();return globalThis.postMessage({type:e,identifier:i,name:t}),new Promise(s=>{let o=a=>{if(!a||!a.data)return;let c={type:a.data.type,identifier:a.data.identifier};c&&c.type===r&&c.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:n,identifier:i,name:t})}))};globalThis.addEventListener("message",o)})},e6={singleProcess:!1};oA.exports=t=>{if(t=Object.assign({},e6,t),!!globalThis.document||t.singleProcess){let r=new Zk;return nA.addEventListener("message",iA(r,"requestReadLock",XS,ZS,JS)),nA.addEventListener("message",iA(r,"requestWriteLock",eA,tA,rA)),r}return{isWorker:!0,readLock:r=>sA(r,XS,JS,ZS),writeLock:r=>sA(r,eA,rA,tA)}}});var uA=w((fV,Md)=>{"use strict";var t6=Object.prototype.hasOwnProperty,Gt="~";function La(){}Object.create&&(La.prototype=Object.create(null),new La().__proto__||(Gt=!1));function r6(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function cA(t,e,r,n,i){if(typeof r!="function")throw new TypeError("The listener must be a function");var s=new r6(r,n||t,i),o=Gt?Gt+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],s]:t._events[o].push(s):(t._events[o]=s,t._eventsCount++),t}function Hu(t,e){--t._eventsCount==0?t._events=new La:delete t._events[e]}function Mt(){this._events=new La,this._eventsCount=0}Mt.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)t6.call(r,n)&&e.push(Gt?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};Mt.prototype.listeners=function(e){var r=Gt?Gt+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o};Mt.prototype.listenerCount=function(e){var r=Gt?Gt+e:e,n=this._events[r];return n?n.fn?1:n.length:0};Mt.prototype.emit=function(e,r,n,i,s,o){var a=Gt?Gt+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,l,f;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,i),!0;case 5:return c.fn.call(c.context,r,n,i,s),!0;case 6:return c.fn.call(c.context,r,n,i,s,o),!0}for(f=1,l=new Array(u-1);f<u;f++)l[f-1]=arguments[f];c.fn.apply(c.context,l)}else{var h=c.length,p;for(f=0;f<h;f++)switch(c[f].once&&this.removeListener(e,c[f].fn,void 0,!0),u){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,i);break;default:if(!l)for(p=1,l=new Array(u-1);p<u;p++)l[p-1]=arguments[p];c[f].fn.apply(c[f].context,l)}}return!0};Mt.prototype.on=function(e,r,n){return cA(this,e,r,n,!1)};Mt.prototype.once=function(e,r,n){return cA(this,e,r,n,!0)};Mt.prototype.removeListener=function(e,r,n,i){var s=Gt?Gt+e:e;if(!this._events[s])return this;if(!r)return Hu(this,s),this;var o=this._events[s];if(o.fn)o.fn===r&&(!i||o.once)&&(!n||o.context===n)&&Hu(this,s);else{for(var a=0,c=[],u=o.length;a<u;a++)(o[a].fn!==r||i&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[s]=c.length===1?c[0]:c:Hu(this,s)}return this};Mt.prototype.removeAllListeners=function(e){var r;return e?(r=Gt?Gt+e:e,this._events[r]&&Hu(this,r)):(this._events=new La,this._eventsCount=0),this};Mt.prototype.off=Mt.prototype.removeListener;Mt.prototype.addListener=Mt.prototype.on;Mt.prefixed=Gt;Mt.EventEmitter=Mt;typeof Md!="undefined"&&(Md.exports=Mt)});var fA=w((hV,lA)=>{"use strict";lA.exports=(t,e)=>(e=e||(()=>{}),t.then(r=>new Promise(n=>{n(e())}).then(()=>r),r=>new Promise(n=>{n(e())}).then(()=>{throw r})))});var dA=w((dV,zu)=>{"use strict";var n6=fA(),Fd=class extends Error{constructor(e){super(e);this.name="TimeoutError"}},hA=(t,e,r)=>new Promise((n,i)=>{if(typeof e!="number"||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0){n(t);return}let s=setTimeout(()=>{if(typeof r=="function"){try{n(r())}catch(c){i(c)}return}let o=typeof r=="string"?r:`Promise timed out after ${e} milliseconds`,a=r instanceof Error?r:new Fd(o);typeof t.cancel=="function"&&t.cancel(),i(a)},e);n6(t.then(n,i),()=>{clearTimeout(s)})});zu.exports=hA;zu.exports.default=hA;zu.exports.TimeoutError=Fd});var pA=w(Kd=>{"use strict";Object.defineProperty(Kd,"__esModule",{value:!0});function i6(t,e,r){let n=0,i=t.length;for(;i>0;){let s=i/2|0,o=n+s;r(t[o],e)<=0?(n=++o,i-=s+1):i=s}return n}Kd.default=i6});var gA=w(Vd=>{"use strict";Object.defineProperty(Vd,"__esModule",{value:!0});var s6=pA(),yA=class{constructor(){this._queue=[]}enqueue(e,r){r=Object.assign({priority:0},r);let n={priority:r.priority,run:e};if(this.size&&this._queue[this.size-1].priority>=r.priority){this._queue.push(n);return}let i=s6.default(this._queue,n,(s,o)=>o.priority-s.priority);this._queue.splice(i,0,n)}dequeue(){let e=this._queue.shift();return e==null?void 0:e.run}filter(e){return this._queue.filter(r=>r.priority===e.priority).map(r=>r.run)}get size(){return this._queue.length}};Vd.default=yA});var bA=w(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:!0});var o6=uA(),mA=dA(),a6=gA(),Gu=()=>{},c6=new mA.TimeoutError,vA=class extends o6{constructor(e){var r,n,i,s;super();if(this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=Gu,this._resolveIdle=Gu,e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:a6.default},e),!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(n=(r=e.intervalCap)===null||r===void 0?void 0:r.toString())!==null&&n!==void 0?n:""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(s=(i=e.interval)===null||i===void 0?void 0:i.toString())!==null&&s!==void 0?s:""}\` (${typeof e.interval})`);this._carryoverConcurrencyCount=e.carryoverConcurrencyCount,this._isIntervalIgnored=e.intervalCap===1/0||e.interval===0,this._intervalCap=e.intervalCap,this._interval=e.interval,this._queue=new e.queueClass,this._queueClass=e.queueClass,this.concurrency=e.concurrency,this._timeout=e.timeout,this._throwOnTimeout=e.throwOnTimeout===!0,this._isPaused=e.autoStart===!1}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=Gu,this._pendingCount===0&&(this._resolveIdle(),this._resolveIdle=Gu,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){let e=Date.now();if(this._intervalId===void 0){let r=this._intervalEnd-e;if(r<0)this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0;else return this._timeoutId===void 0&&(this._timeoutId=setTimeout(()=>{this._onResumeInterval()},r)),!0}return!1}_tryToStartAnother(){if(this._queue.size===0)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){let e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother){let r=this._queue.dequeue();return r?(this.emit("active"),r(),e&&this._initializeIntervalIfNeeded(),!0):!1}}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||this._intervalId!==void 0||(this._intervalId=setInterval(()=>{this._onInterval()},this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){this._intervalCount===0&&this._pendingCount===0&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this._concurrency=e,this._processQueue()}async add(e,r={}){return new Promise((n,i)=>{let s=async()=>{this._pendingCount++,this._intervalCount++;try{let o=this._timeout===void 0&&r.timeout===void 0?e():mA.default(Promise.resolve(e()),r.timeout===void 0?this._timeout:r.timeout,()=>{(r.throwOnTimeout===void 0?this._throwOnTimeout:r.throwOnTimeout)&&i(c6)});n(await o)}catch(o){i(o)}this._next()};this._queue.enqueue(s,r),this._tryToStartAnother(),this.emit("add")})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(this._queue.size!==0)return new Promise(e=>{let r=this._resolveEmpty;this._resolveEmpty=()=>{r(),e()}})}async onIdle(){if(!(this._pendingCount===0&&this._queue.size===0))return new Promise(e=>{let r=this._resolveIdle;this._resolveIdle=()=>{r(),e()}})}get size(){return this._queue.size}sizeBy(e){return this._queue.filter(e).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(e){this._timeout=e}};jd.default=vA});var EA=w((vV,$d)=>{"use strict";var Wu,mV=$d.exports.timeout=function(t,e){var r=new Wu,n;return Promise.race([t,new Promise(function(i,s){n=setTimeout(function(){s(r)},e)})]).then(function(i){return clearTimeout(n),i},function(i){throw clearTimeout(n),i})};Wu=$d.exports.TimeoutError=function(){Error.call(this),this.stack=Error().stack,this.message="Timeout"};Wu.prototype=Object.create(Error.prototype);Wu.prototype.name="TimeoutError"});var _A=w((bV,zd)=>{var u6=YS(),l6=aA(),{default:wA}=bA(),{timeout:f6}=EA(),h6=Ud(),is={},yi;function Hd(t,e){let r,n=new Promise(i=>{r=i});return t.add(()=>f6((()=>new Promise(i=>{r(()=>{i()})}))(),e.timeout)),n}var d6=(t,e)=>{if(yi.isWorker)return{readLock:yi.readLock(t,e),writeLock:yi.writeLock(t,e)};let r=new wA({concurrency:1}),n=null;return{readLock:()=>{if(n)return Hd(n,e);n=new wA({concurrency:e.concurrency,autoStart:!1});let i=n,s=Hd(n,e);return r.add(()=>(i.start(),i.onIdle().then(()=>{n===i&&(n=null)}))),s},writeLock:()=>(n=null,Hd(r,e))}},p6={concurrency:1/0,timeout:846e5,global:globalThis,singleProcess:!1};zd.exports=(t,e)=>(e||(e={}),typeof t=="object"&&(e=t,t="lock"),t||(t="lock"),e=Object.assign({},p6,e),yi||(yi=u6(e)||l6(e),yi.isWorker||(yi.on("requestReadLock",(r,n)=>{!is[r]||is[r].readLock().then(i=>n().finally(()=>i()))}),yi.on("requestWriteLock",async(r,n)=>{!is[r]||is[r].writeLock().then(i=>n().finally(()=>i()))}))),is[t]||(is[t]=d6(t,e)),is[t]);zd.exports.Worker=function(t,e){e=e||globalThis.Worker;let r;try{r=new e(t)}catch(n){n.message.includes("not a constructor")&&(r=e(t))}if(!r)throw new Error("Could not create Worker from",e);return h6(r),r}});var NA=w((EV,PA)=>{"use strict";var xA=Te(),SA=Rt(),AA=he(),{codes:Yu}=je(),{Key:y6}=(Zc(),nh),{base32:g6}=(bi(),vi),{keys:{unmarshalPublicKey:m6,marshalPublicKey:v6}}=Ru(),{Multiaddr:CA}=qt(),{Peer:IA}=qS(),b6=_A(),{equals:E6}=(pr(),dr),TA=Object.assign(xA("libp2p:peer-store:store"),{error:xA("libp2p:peer-store:store:err")}),RA="/peers/",BA=class{constructor(e){this._datastore=e,this.lock=b6("peer-store",{singleProcess:!0})}_peerIdToDatastoreKey(e){if(!SA.isPeerId(e))throw TA.error("peerId must be an instance of peer-id to store data"),AA(new Error("peerId must be an instance of peer-id"),Yu.ERR_INVALID_PARAMETERS);let r=e.toString();return new y6(`${RA}${r}`)}async has(e){return this._datastore.has(this._peerIdToDatastoreKey(e))}async delete(e){await this._datastore.delete(this._peerIdToDatastoreKey(e))}async load(e){let r=await this._datastore.get(this._peerIdToDatastoreKey(e)),n=IA.decode(r),i=n.pubKey?m6(n.pubKey):e.pubKey,s=new Map;for(let o of n.metadata)s.set(o.key,o.value);return{...n,id:e,pubKey:i,addresses:n.addresses.map(({multiaddr:o,isCertified:a})=>({multiaddr:new CA(o),isCertified:a||!1})),metadata:s,peerRecordEnvelope:n.peerRecordEnvelope||void 0}}async save(e){if(e.pubKey!=null&&e.id.pubKey!=null&&!E6(e.pubKey.bytes,e.id.pubKey.bytes))throw TA.error("peer publicKey bytes do not match peer id publicKey bytes"),AA(new Error("publicKey bytes do not match peer id publicKey bytes"),Yu.ERR_INVALID_PARAMETERS);let r=IA.encode({addresses:e.addresses.sort((n,i)=>n.multiaddr.toString().localeCompare(i.multiaddr.toString())).map(({multiaddr:n,isCertified:i})=>({multiaddr:n.bytes,isCertified:i})),protocols:e.protocols.sort(),pubKey:e.pubKey?v6(e.pubKey):void 0,metadata:[...e.metadata.keys()].sort().map(n=>({key:n,value:e.metadata.get(n)})),peerRecordEnvelope:e.peerRecordEnvelope}).finish();return await this._datastore.put(this._peerIdToDatastoreKey(e.id),r),this.load(e.id)}async patch(e,r){let n=await this.load(e);return await this._patch(e,r,n)}async patchOrCreate(e,r){let n;try{n=await this.load(e)}catch(i){if(i.code!==Yu.ERR_NOT_FOUND)throw i;n={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._patch(e,r,n)}async _patch(e,r,n){return await this.save({...n,...r,id:e})}async merge(e,r){let n=await this.load(e);return this._merge(e,r,n)}async mergeOrCreate(e,r){let n;try{n=await this.load(e)}catch(i){if(i.code!==Yu.ERR_NOT_FOUND)throw i;n={id:e,addresses:[],protocols:[],metadata:new Map}}return await this._merge(e,r,n)}async _merge(e,r,n){let i=new Map;return(r.addresses||[]).forEach(s=>{i.set(s.multiaddr.toString(),s.isCertified)}),n.addresses.forEach(({multiaddr:s,isCertified:o})=>{let a=s.toString();i.set(a,Boolean(i.get(a)||o))}),await this.save({id:e,addresses:Array.from(i.entries()).map(([s,o])=>({multiaddr:new CA(s),isCertified:o})),protocols:Array.from(new Set([...n.protocols||[],...r.protocols||[]])),metadata:new Map([...n.metadata?n.metadata.entries():[],...r.metadata?r.metadata.entries():[]]),pubKey:r.pubKey||(n!=null?n.pubKey:void 0),peerRecordEnvelope:r.peerRecordEnvelope||(n!=null?n.peerRecordEnvelope:void 0)})}async*all(){for await(let e of this._datastore.queryKeys({prefix:RA})){let r=e.toString().split("/")[2],n=g6.decode(r);yield this.load(SA.createFromBytes(n))}}};PA.exports=BA});var kA=w((wV,LA)=>{"use strict";var OA=Te(),{EventEmitter:w6}=Qt(),_6=_S(),x6=IS(),S6=PS(),A6=LS(),C6=NA(),Cr=Object.assign(OA("libp2p:peer-store"),{error:OA("libp2p:peer-store:err")}),DA=class extends w6{constructor({peerId:e,datastore:r}){super();this._peerId=e,this._store=new C6(r),this.addressBook=new _6(this.emit.bind(this),this._store),this.keyBook=new x6(this.emit.bind(this),this._store),this.metadataBook=new S6(this.emit.bind(this),this._store),this.protoBook=new A6(this.emit.bind(this),this._store)}async*getPeers(){Cr("getPeers await read lock");let e=await this._store.lock.readLock();Cr("getPeers got read lock");try{for await(let r of this._store.all())r.id.toB58String()!==this._peerId.toB58String()&&(yield r)}finally{Cr("getPeers release read lock"),e()}}async delete(e){Cr("delete await write lock");let r=await this._store.lock.writeLock();Cr("delete got write lock");try{await this._store.delete(e)}finally{Cr("delete release write lock"),r()}}async get(e){Cr("get await read lock");let r=await this._store.lock.readLock();Cr("get got read lock");try{return this._store.load(e)}finally{Cr("get release read lock"),r()}}async has(e){Cr("has await read lock");let r=await this._store.lock.readLock();Cr("has got read lock");try{return this._store.has(e)}finally{Cr("has release read lock"),r()}}};LA.exports=DA});var UA=w((_V,qA)=>{"use strict";function I6(t,e,r){let n=new t(e,r);n._subscribeAdapter=n.subscribe,n._unsubscribeAdapter=n.unsubscribe;function i(o,a){a&&n.on(o,a),n._subscribeAdapter(o)}function s(o,a){a?n.removeListener(o,a):n.removeAllListeners(o),n.listenerCount(o)===0&&n._unsubscribeAdapter(o)}return n.subscribe=i,n.unsubscribe=s,n}qA.exports=I6});var jA=w((xV,VA)=>{"use strict";var MA=()=>{},FA=Symbol.for("@libp2p/js-interfaces/topology"),KA=class{constructor({min:e=0,max:r=1/0,handlers:n={}}){this.min=e,this.max=r,this._onConnect=n.onConnect||MA,this._onDisconnect=n.onDisconnect||MA,this.peers=new Set}get[Symbol.toStringTag](){return"Topology"}get[FA](){return!0}static isTopology(e){return Boolean(e&&e[FA])}async setRegistrar(e){this._registrar=e}disconnect(e){this._onDisconnect(e)}};VA.exports=KA});var GA=w((SV,zA)=>{"use strict";var $A=Te(),T6=Object.assign($A("libp2p:registrar"),{error:$A("libp2p:registrar:err")}),R6=he(),{codes:{ERR_INVALID_PARAMETERS:B6}}=je(),P6=jA(),HA=class{constructor({peerStore:e,connectionManager:r}){this.peerStore=e,this.connectionManager=r,this.topologies=new Map,this._handle=void 0,this._onDisconnect=this._onDisconnect.bind(this),this.connectionManager.on("peer:disconnect",this._onDisconnect)}get handle(){return this._handle}set handle(e){this._handle=e}getConnection(e){return this.connectionManager.get(e)}async register(e){if(!P6.isTopology(e))throw T6.error("topology must be an instance of interfaces/topology"),R6(new Error("topology must be an instance of interfaces/topology"),B6);let r=(Math.random()*1e9).toString(36)+Date.now();return this.topologies.set(r,e),await e.setRegistrar(this),r}unregister(e){return this.topologies.delete(e)}_onDisconnect(e){for(let[,r]of this.topologies)r.disconnect(e.remotePeer)}};zA.exports=HA});var Gd=w((AV,ka)=>{"use strict";var{Buffer:Qu}=oi(),Xu=Yi();ka.exports=async function*(t){for await(let e of t)Qu.isBuffer(e)?yield e:Xu.isBufferList(e)?yield e.slice():yield Qu.from(e)};ka.exports.toBuffer=ka.exports;ka.exports.toList=async function*(t){for await(let e of t)Qu.isBuffer(e)?yield new Xu().append(e):Xu.isBufferList(e)?yield e:yield new Xu().append(Qu.from(e))}});var YA=w((CV,WA)=>{"use strict";WA.exports={PROTOCOL:"/ipfs/ping/1.0.0",PING_LENGTH:32,PROTOCOL_VERSION:"1.0.0",PROTOCOL_NAME:"ping"}});var JA=w((Zu,ZA)=>{"use strict";var QA=Te(),Wd=Object.assign(QA("libp2p:ping"),{error:QA("libp2p:ping:err")}),N6=he(),{codes:O6}=je(),D6=Ru(),{pipe:XA}=nn(),{toBuffer:L6}=Gd(),{collect:k6,take:q6}=Du(),{equals:U6}=(pr(),dr),{PROTOCOL_NAME:Yd,PING_LENGTH:M6,PROTOCOL_VERSION:Qd}=YA();async function F6(t,e){let r=`/${t._config.protocolPrefix}/${Yd}/${Qd}`;Wd("dialing %s to %s",r,e.toB58String?e.toB58String():e);let n=await t.dial(e),{stream:i}=await n.newStream(r),s=Date.now(),o=D6.randomBytes(M6),[a]=await XA([o],i,u=>q6(1,u),L6,k6),c=Date.now();if(!U6(o,a))throw N6(new Error("Received wrong ping ack"),O6.ERR_WRONG_PING_ACK);return c-s}function K6(t){t.handle(`/${t._config.protocolPrefix}/${Yd}/${Qd}`,({stream:e})=>XA(e,e)).catch(e=>{Wd.error(e)})}function V6(t){t.unhandle(`/${t._config.protocolPrefix}/${Yd}/${Qd}`).catch(e=>{Wd.error(e)})}Zu=ZA.exports=F6;Zu.mount=K6;Zu.unmount=V6});var rC=w((IV,tC)=>{"use strict";var xo=pn(),eC=xo.Reader,j6=xo.Writer,rt=xo.util,qa=xo.roots["libp2p-identify"]||(xo.roots["libp2p-identify"]={});qa.Identify=function(){function t(e){if(this.listenAddrs=[],this.protocols=[],e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.protocolVersion="",t.prototype.agentVersion="",t.prototype.publicKey=rt.newBuffer([]),t.prototype.listenAddrs=rt.emptyArray,t.prototype.observedAddr=rt.newBuffer([]),t.prototype.protocols=rt.emptyArray,t.prototype.signedPeerRecord=rt.newBuffer([]),t.encode=function(r,n){if(n||(n=j6.create()),r.publicKey!=null&&Object.hasOwnProperty.call(r,"publicKey")&&n.uint32(10).bytes(r.publicKey),r.listenAddrs!=null&&r.listenAddrs.length)for(var i=0;i<r.listenAddrs.length;++i)n.uint32(18).bytes(r.listenAddrs[i]);if(r.protocols!=null&&r.protocols.length)for(var i=0;i<r.protocols.length;++i)n.uint32(26).string(r.protocols[i]);return r.observedAddr!=null&&Object.hasOwnProperty.call(r,"observedAddr")&&n.uint32(34).bytes(r.observedAddr),r.protocolVersion!=null&&Object.hasOwnProperty.call(r,"protocolVersion")&&n.uint32(42).string(r.protocolVersion),r.agentVersion!=null&&Object.hasOwnProperty.call(r,"agentVersion")&&n.uint32(50).string(r.agentVersion),r.signedPeerRecord!=null&&Object.hasOwnProperty.call(r,"signedPeerRecord")&&n.uint32(66).bytes(r.signedPeerRecord),n},t.decode=function(r,n){r instanceof eC||(r=eC.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new qa.Identify;r.pos<i;){var o=r.uint32();switch(o>>>3){case 5:s.protocolVersion=r.string();break;case 6:s.agentVersion=r.string();break;case 1:s.publicKey=r.bytes();break;case 2:s.listenAddrs&&s.listenAddrs.length||(s.listenAddrs=[]),s.listenAddrs.push(r.bytes());break;case 4:s.observedAddr=r.bytes();break;case 3:s.protocols&&s.protocols.length||(s.protocols=[]),s.protocols.push(r.string());break;case 8:s.signedPeerRecord=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof qa.Identify)return r;var n=new qa.Identify;if(r.protocolVersion!=null&&(n.protocolVersion=String(r.protocolVersion)),r.agentVersion!=null&&(n.agentVersion=String(r.agentVersion)),r.publicKey!=null&&(typeof r.publicKey=="string"?rt.base64.decode(r.publicKey,n.publicKey=rt.newBuffer(rt.base64.length(r.publicKey)),0):r.publicKey.length&&(n.publicKey=r.publicKey)),r.listenAddrs){if(!Array.isArray(r.listenAddrs))throw TypeError(".Identify.listenAddrs: array expected");n.listenAddrs=[];for(var i=0;i<r.listenAddrs.length;++i)typeof r.listenAddrs[i]=="string"?rt.base64.decode(r.listenAddrs[i],n.listenAddrs[i]=rt.newBuffer(rt.base64.length(r.listenAddrs[i])),0):r.listenAddrs[i].length&&(n.listenAddrs[i]=r.listenAddrs[i])}if(r.observedAddr!=null&&(typeof r.observedAddr=="string"?rt.base64.decode(r.observedAddr,n.observedAddr=rt.newBuffer(rt.base64.length(r.observedAddr)),0):r.observedAddr.length&&(n.observedAddr=r.observedAddr)),r.protocols){if(!Array.isArray(r.protocols))throw TypeError(".Identify.protocols: array expected");n.protocols=[];for(var i=0;i<r.protocols.length;++i)n.protocols[i]=String(r.protocols[i])}return r.signedPeerRecord!=null&&(typeof r.signedPeerRecord=="string"?rt.base64.decode(r.signedPeerRecord,n.signedPeerRecord=rt.newBuffer(rt.base64.length(r.signedPeerRecord)),0):r.signedPeerRecord.length&&(n.signedPeerRecord=r.signedPeerRecord)),n},t.toObject=function(r,n){n||(n={});var i={};if((n.arrays||n.defaults)&&(i.listenAddrs=[],i.protocols=[]),n.defaults&&(n.bytes===String?i.publicKey="":(i.publicKey=[],n.bytes!==Array&&(i.publicKey=rt.newBuffer(i.publicKey))),n.bytes===String?i.observedAddr="":(i.observedAddr=[],n.bytes!==Array&&(i.observedAddr=rt.newBuffer(i.observedAddr))),i.protocolVersion="",i.agentVersion="",n.bytes===String?i.signedPeerRecord="":(i.signedPeerRecord=[],n.bytes!==Array&&(i.signedPeerRecord=rt.newBuffer(i.signedPeerRecord)))),r.publicKey!=null&&r.hasOwnProperty("publicKey")&&(i.publicKey=n.bytes===String?rt.base64.encode(r.publicKey,0,r.publicKey.length):n.bytes===Array?Array.prototype.slice.call(r.publicKey):r.publicKey),r.listenAddrs&&r.listenAddrs.length){i.listenAddrs=[];for(var s=0;s<r.listenAddrs.length;++s)i.listenAddrs[s]=n.bytes===String?rt.base64.encode(r.listenAddrs[s],0,r.listenAddrs[s].length):n.bytes===Array?Array.prototype.slice.call(r.listenAddrs[s]):r.listenAddrs[s]}if(r.protocols&&r.protocols.length){i.protocols=[];for(var s=0;s<r.protocols.length;++s)i.protocols[s]=r.protocols[s]}return r.observedAddr!=null&&r.hasOwnProperty("observedAddr")&&(i.observedAddr=n.bytes===String?rt.base64.encode(r.observedAddr,0,r.observedAddr.length):n.bytes===Array?Array.prototype.slice.call(r.observedAddr):r.observedAddr),r.protocolVersion!=null&&r.hasOwnProperty("protocolVersion")&&(i.protocolVersion=r.protocolVersion),r.agentVersion!=null&&r.hasOwnProperty("agentVersion")&&(i.agentVersion=r.agentVersion),r.signedPeerRecord!=null&&r.hasOwnProperty("signedPeerRecord")&&(i.signedPeerRecord=n.bytes===String?rt.base64.encode(r.signedPeerRecord,0,r.signedPeerRecord.length):n.bytes===Array?Array.prototype.slice.call(r.signedPeerRecord):r.signedPeerRecord),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,xo.util.toJSONOptions)},t}();tC.exports=qa});var fC=w((TV,lC)=>{"use strict";var nC=Te(),ar=Object.assign(nC("libp2p:identify"),{error:nC("libp2p:identify:err")}),Xd=he(),Ju=ro(),{pipe:el}=nn(),{collect:iC,take:sC,consume:oC}=Du(),{fromString:So}=(It(),Nt),$6=Rt(),{Multiaddr:Zd}=qt(),{toBuffer:aC}=Gd(),Ua=rC(),cC=fu(),uC=du(),{MULTICODEC_IDENTIFY:H6,MULTICODEC_IDENTIFY_PUSH:z6,IDENTIFY_PROTOCOL_VERSION:G6,MULTICODEC_IDENTIFY_PROTOCOL_NAME:W6,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_NAME:Y6,MULTICODEC_IDENTIFY_PROTOCOL_VERSION:Q6,MULTICODEC_IDENTIFY_PUSH_PROTOCOL_VERSION:X6}=vh(),{codes:Jd}=je(),ss=class{static getProtocolStr(e){return{identifyProtocolStr:`/${e._config.protocolPrefix}/${W6}/${Q6}`,identifyPushProtocolStr:`/${e._config.protocolPrefix}/${Y6}/${X6}`}}constructor({libp2p:e}){this._libp2p=e,this.peerStore=e.peerStore,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.peerId=e.peerId,this.handleMessage=this.handleMessage.bind(this);let r=ss.getProtocolStr(e);this.identifyProtocolStr=r.identifyProtocolStr,this.identifyPushProtocolStr=r.identifyPushProtocolStr,this._host={protocolVersion:`${e._config.protocolPrefix}/${G6}`,...e._options.host},this.connectionManager.on("peer:connect",n=>{this.identify(n).catch(ar.error)}),this.peerStore.on("change:multiaddrs",({peerId:n})=>{n.toString()===this.peerId.toString()&&this.pushToPeerStore().catch(i=>ar.error(i))}),this.peerStore.on("change:protocols",({peerId:n})=>{n.toString()===this.peerId.toString()&&this.pushToPeerStore().catch(i=>ar.error(i))})}async start(){await this.peerStore.metadataBook.setValue(this.peerId,"AgentVersion",So(this._host.agentVersion)),await this.peerStore.metadataBook.setValue(this.peerId,"ProtocolVersion",So(this._host.protocolVersion))}async stop(){}async push(e){let r=await this.peerStore.addressBook.getRawEnvelope(this.peerId),n=this._libp2p.multiaddrs.map(o=>o.bytes),i=await this.peerStore.protoBook.get(this.peerId),s=e.map(async o=>{try{let{stream:a}=await o.newStream(this.identifyPushProtocolStr);await el([Ua.Identify.encode({listenAddrs:n,signedPeerRecord:r,protocols:i}).finish()],Ju.encode(),a,oC)}catch(a){ar.error("could not push identify update to peer",a)}});return Promise.all(s)}async pushToPeerStore(){if(!this._libp2p.isStarted())return;let e=[],r;for await(let n of this.peerStore.getPeers())n.protocols.includes(this.identifyPushProtocolStr)&&(r=this.connectionManager.get(n.id))&&e.push(r);await this.push(e)}async identify(e){let{stream:r}=await e.newStream(this.identifyProtocolStr),[n]=await el([],r,Ju.decode(),sC(1),aC,iC);if(!n)throw Xd(new Error("No data could be retrieved"),Jd.ERR_CONNECTION_ENDED);let i;try{i=Ua.Identify.decode(n)}catch(h){throw Xd(h,Jd.ERR_INVALID_MESSAGE)}let{publicKey:s,listenAddrs:o,protocols:a,observedAddr:c,signedPeerRecord:u}=i,l=await $6.createFromPubKey(s);if(e.remotePeer.toB58String()!==l.toB58String())throw Xd(new Error("identified peer does not match the expected peer"),Jd.ERR_INVALID_PEER);let f=ss.getCleanMultiaddr(c);try{let h=await cC.openAndCertify(u,uC.DOMAIN);if(await this.peerStore.addressBook.consumePeerRecord(h)){await this.peerStore.protoBook.set(l,a),await this.peerStore.metadataBook.setValue(l,"AgentVersion",So(i.agentVersion)),await this.peerStore.metadataBook.setValue(l,"ProtocolVersion",So(i.protocolVersion));return}}catch(h){ar("received invalid envelope, discard it and fallback to listenAddrs is available",h)}try{await this.peerStore.addressBook.set(l,o.map(h=>new Zd(h)))}catch(h){ar.error("received invalid addrs",h)}await this.peerStore.protoBook.set(l,a),await this.peerStore.metadataBook.setValue(l,"AgentVersion",So(i.agentVersion)),await this.peerStore.metadataBook.setValue(l,"ProtocolVersion",So(i.protocolVersion)),ar("received observed address of %s",f)}handleMessage({connection:e,stream:r,protocol:n}){switch(n){case this.identifyProtocolStr:return this._handleIdentify({connection:e,stream:r});case this.identifyPushProtocolStr:return this._handlePush({connection:e,stream:r});default:ar.error("cannot handle unknown protocol %s",n)}}async _handleIdentify({connection:e,stream:r}){try{let n=new Uint8Array(0);this.peerId.pubKey&&(n=this.peerId.pubKey.bytes);let i=await this.peerStore.addressBook.getRawEnvelope(this.peerId),s=await this.peerStore.protoBook.get(this.peerId),o=Ua.Identify.encode({protocolVersion:this._host.protocolVersion,agentVersion:this._host.agentVersion,publicKey:n,listenAddrs:this._libp2p.multiaddrs.map(a=>a.bytes),signedPeerRecord:i,observedAddr:e.remoteAddr.bytes,protocols:s}).finish();await el([o],Ju.encode(),r,oC)}catch(n){ar.error("could not respond to identify request",n)}}async _handlePush({connection:e,stream:r}){let n;try{let[s]=await el([],r,Ju.decode(),sC(1),aC,iC);n=Ua.Identify.decode(s)}catch(s){return ar.error("received invalid message",s)}let i=e.remotePeer;try{let s=await cC.openAndCertify(n.signedPeerRecord,uC.DOMAIN);if(await this.peerStore.addressBook.consumePeerRecord(s)){await this.peerStore.protoBook.set(i,n.protocols);return}}catch(s){ar("received invalid envelope, discard it and fallback to listenAddrs is available",s)}try{await this.peerStore.addressBook.set(i,n.listenAddrs.map(s=>new Zd(s)))}catch(s){ar.error("received invalid addrs",s)}try{await this.peerStore.protoBook.set(i,n.protocols)}catch(s){ar.error("received invalid protocols",s)}}static getCleanMultiaddr(e){if(e&&e.length>0)try{return new Zd(e)}catch(r){return null}return null}},Z6={IDENTIFY:H6,IDENTIFY_PUSH:z6};ss.multicodecs=Z6;ss.Messsage=Ua;lC.exports=ss});var pC=w((RV,dC)=>{"use strict";var os=pn(),tl=os.Reader,hC=os.Writer,Ao=os.util,ln=os.roots["libp2p-fetch"]||(os.roots["libp2p-fetch"]={});ln.FetchRequest=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.identifier="",t.encode=function(r,n){return n||(n=hC.create()),r.identifier!=null&&Object.hasOwnProperty.call(r,"identifier")&&n.uint32(10).string(r.identifier),n},t.decode=function(r,n){r instanceof tl||(r=tl.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new ln.FetchRequest;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.identifier=r.string();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof ln.FetchRequest)return r;var n=new ln.FetchRequest;return r.identifier!=null&&(n.identifier=String(r.identifier)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.identifier=""),r.identifier!=null&&r.hasOwnProperty("identifier")&&(i.identifier=r.identifier),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,os.util.toJSONOptions)},t}();ln.FetchResponse=function(){function t(e){if(e)for(var r=Object.keys(e),n=0;n<r.length;++n)e[r[n]]!=null&&(this[r[n]]=e[r[n]])}return t.prototype.status=0,t.prototype.data=Ao.newBuffer([]),t.encode=function(r,n){return n||(n=hC.create()),r.status!=null&&Object.hasOwnProperty.call(r,"status")&&n.uint32(8).int32(r.status),r.data!=null&&Object.hasOwnProperty.call(r,"data")&&n.uint32(18).bytes(r.data),n},t.decode=function(r,n){r instanceof tl||(r=tl.create(r));for(var i=n===void 0?r.len:r.pos+n,s=new ln.FetchResponse;r.pos<i;){var o=r.uint32();switch(o>>>3){case 1:s.status=r.int32();break;case 2:s.data=r.bytes();break;default:r.skipType(o&7);break}}return s},t.fromObject=function(r){if(r instanceof ln.FetchResponse)return r;var n=new ln.FetchResponse;switch(r.status){case"OK":case 0:n.status=0;break;case"NOT_FOUND":case 1:n.status=1;break;case"ERROR":case 2:n.status=2;break}return r.data!=null&&(typeof r.data=="string"?Ao.base64.decode(r.data,n.data=Ao.newBuffer(Ao.base64.length(r.data)),0):r.data.length&&(n.data=r.data)),n},t.toObject=function(r,n){n||(n={});var i={};return n.defaults&&(i.status=n.enums===String?"OK":0,n.bytes===String?i.data="":(i.data=[],n.bytes!==Array&&(i.data=Ao.newBuffer(i.data)))),r.status!=null&&r.hasOwnProperty("status")&&(i.status=n.enums===String?ln.FetchResponse.StatusCode[r.status]:r.status),r.data!=null&&r.hasOwnProperty("data")&&(i.data=n.bytes===String?Ao.base64.encode(r.data,0,r.data.length):n.bytes===Array?Array.prototype.slice.call(r.data):r.data),i},t.prototype.toJSON=function(){return this.constructor.toObject(this,os.util.toJSONOptions)},t.StatusCode=function(){var e={},r=Object.create(e);return r[e[0]="OK"]=0,r[e[1]="NOT_FOUND"]=1,r[e[2]="ERROR"]=2,r}(),t}();dC.exports=ln});var gC=w((BV,yC)=>{"use strict";yC.exports={PROTOCOL:"/libp2p/fetch/0.0.1"}});var wC=w((bC,EC)=>{"use strict";var mC=Te(),J6=Object.assign(mC("libp2p:fetch"),{error:mC("libp2p:fetch:err")}),e0=he(),{codes:t0}=je(),rl=ro(),{FetchRequest:r0,FetchResponse:Mr}=pC(),vC=no(),{PROTOCOL:e5}=gC(),Ma=class{constructor(e){this._lookupFunctions=new Map,this._libp2p=e,this.handleMessage=this.handleMessage.bind(this)}async fetch(e,r){J6("dialing %s to %s",this._protocol,e.toB58String?e.toB58String():e);let n=await this._libp2p.dial(e),{stream:i}=await n.newStream(Ma.PROTOCOL),s=vC(i),o=new r0({identifier:r});s.write(rl.encode.single(r0.encode(o).finish()));let a=Mr.decode((await rl.decode.fromReader(s.reader).next()).value.slice());switch(a.status){case Mr.StatusCode.OK:return a.data;case Mr.StatusCode.NOT_FOUND:return null;case Mr.StatusCode.ERROR:{let c=new TextDecoder().decode(a.data);throw e0(new Error("Error in fetch protocol response: "+c),t0.ERR_INVALID_PARAMETERS)}default:throw e0(new Error("Unknown response status"),t0.ERR_INVALID_MESSAGE)}}async handleMessage(e){let{stream:r}=e,n=vC(r),i=r0.decode((await rl.decode.fromReader(n.reader).next()).value.slice()),s,o=this._getLookupFunction(i.identifier);if(o){let a=await o(i.identifier);a?s=new Mr({status:Mr.StatusCode.OK,data:a}):s=new Mr({status:Mr.StatusCode.NOT_FOUND})}else{let a=new TextEncoder().encode("No lookup function registered for key: "+i.identifier);s=new Mr({status:Mr.StatusCode.ERROR,data:a})}n.write(rl.encode.single(Mr.encode(s).finish()))}_getLookupFunction(e){for(let r of this._lookupFunctions.keys())if(e.startsWith(r))return this._lookupFunctions.get(r);return null}registerLookupFunction(e,r){if(this._lookupFunctions.has(e))throw e0(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),t0.ERR_KEY_ALREADY_EXISTS);this._lookupFunctions.set(e,r)}unregisterLookupFunction(e,r){r!=null&&this._lookupFunctions.get(e)!==r||this._lookupFunctions.delete(e)}};Ma.PROTOCOL=e5;bC=EC.exports=Ma});var _C=w(()=>{});var xC=w(n0=>{"use strict";Object.defineProperty(n0,"__esModule",{value:!0}),n0.promisify=nl;var t5="__ES6-PROMISIFY--CUSTOM-ARGUMENTS__";function nl(t){if(typeof t!="function")throw new TypeError("Argument to promisify must be a function");var e=t[t5],r=nl.Promise||Promise;if(typeof r!="function")throw new Error("No Promise implementation found; do you need a polyfill?");return function(){for(var n=this,i=arguments.length,s=Array(i),o=0;o<i;o++)s[o]=arguments[o];return new r(function(a,c){s.push(function(u){if(u)return c(u);for(var l=arguments.length,f=Array(1<l?l-1:0),h=1;h<l;h++)f[h-1]=arguments[h];if(f.length===1||!e)return a(f[0]);var p={};f.forEach(function(d,g){var m=e[g];m&&(p[m]=d)}),a(p)}),t.apply(n,s)})}}nl.argumentNames="__ES6-PROMISIFY--CUSTOM-ARGUMENTS__",nl.Promise=void 0});var AC=w((DV,SC)=>{function r5(){return typeof window!="undefined"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process!="undefined"&&typeof process.versions=="object"&&!!process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0}SC.exports=r5});var IC=w((LV,CC)=>{"use strict";var n5=AC(),il=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Fa=n5(),i5=il&&!Fa,s5=Fa&&!il,o5=Fa&&il,a5=typeof h0=="function"&&typeof process!="undefined"&&typeof process.release!="undefined"&&process.release.name==="node"&&!Fa,c5=typeof importScripts=="function"&&typeof self!="undefined"&&typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope,u5=typeof process!="undefined"&&typeof process.env!="undefined"&&!1;CC.exports={isTest:u5,isElectron:Fa,isElectronMain:s5,isElectronRenderer:o5,isNode:a5,isBrowser:i5,isWebWorker:c5,isEnvWithDom:il}});var RC=w((kV,TC)=>{function Ir(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}TC.exports=Ir;Ir.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};Ir.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};Ir.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(r===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),r=this._cachedTimeouts.slice(-1);else return!1;var n=this;return this._timer=setTimeout(function(){n._attempts++,n._operationTimeoutCb&&(n._timeout=setTimeout(function(){n._operationTimeoutCb(n._attempts)},n._operationTimeout),n._options.unref&&n._timeout.unref()),n._fn(n._attempts)},r),this._options.unref&&this._timer.unref(),!0};Ir.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Ir.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};Ir.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};Ir.prototype.start=Ir.prototype.try;Ir.prototype.errors=function(){return this._errors};Ir.prototype.attempts=function(){return this._attempts};Ir.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,r=0,n=0;n<this._errors.length;n++){var i=this._errors[n],s=i.message,o=(t[s]||0)+1;t[s]=o,o>=r&&(e=i,r=o)}return e}});var BC=w(as=>{var l5=RC();as.operation=function(t){var e=as.timeouts(t);return new l5(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};as.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var r in t)e[r]=t[r];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var n=[],i=0;i<e.retries;i++)n.push(this.createTimeout(i,e));return t&&t.forever&&!n.length&&n.push(this.createTimeout(i,e)),n.sort(function(s,o){return s-o}),n};as.createTimeout=function(t,e){var r=e.randomize?Math.random()+1:1,n=Math.round(r*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return n=Math.min(n,e.maxTimeout),n};as.wrap=function(t,e,r){if(e instanceof Array&&(r=e,e=null),!r){r=[];for(var n in t)typeof t[n]=="function"&&r.push(n)}for(var i=0;i<r.length;i++){var s=r[i],o=t[s];t[s]=function(c){var u=as.operation(e),l=Array.prototype.slice.call(arguments,1),f=l.pop();l.push(function(h){u.retry(h)||(h&&(arguments[0]=u.mainError()),f.apply(this,arguments))}),u.attempt(function(){c.apply(t,l)})}.bind(t,o),t[s].options=e}}});var NC=w((UV,PC)=>{PC.exports=BC()});var DC=w((MV,sl)=>{"use strict";var f5=NC(),h5=["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"],i0=class extends Error{constructor(e){super();e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},d5=(t,e,r)=>{let n=r.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=n,t},p5=t=>h5.includes(t),OC=(t,e)=>new Promise((r,n)=>{e={onFailedAttempt:()=>{},retries:10,...e};let i=f5.operation(e);i.attempt(async s=>{try{r(await t(s))}catch(o){if(!(o instanceof Error)){n(new TypeError(`Non-error was thrown: "${o}". You should only throw errors.`));return}if(o instanceof i0)i.stop(),n(o.originalError);else if(o instanceof TypeError&&!p5(o.message))i.stop(),n(o);else{d5(o,s,e);try{await e.onFailedAttempt(o)}catch(a){n(a);return}i.retry(o)||n(i.mainError())}}})});sl.exports=OC;sl.exports.default=OC;sl.exports.AbortError=i0});var kC=w((FV,LC)=>{"use strict";function y5(t){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(t)||/^::1$/.test(t)}LC.exports=y5});var UC=w((KV,qC)=>{"use strict";var g5=kC();function m5(t){let{address:e}=t.nodeAddress();return g5(e)}qC.exports=m5});var $C=w((VV,jC)=>{"use strict";var v5=_C(),MC=Te(),{promisify:s0}=xC(),{Multiaddr:b5}=qt(),Co=Object.assign(MC("libp2p:nat"),{error:MC("libp2p:nat:err")}),{isBrowser:FC}=IC(),o0=DC(),E5=bh(),KC=mh(),w5=he(),{codes:{ERR_INVALID_PARAMETERS:_5}}=je(),x5=UC(),a0=7200;function S5(t=1024,e=65535){return Math.floor(Math.random()*(e-t+1)+t)}var VC=class{constructor({peerId:e,addressManager:r,transportManager:n,...i}){if(this._peerId=e,this._addressManager=r,this._transportManager=n,this._enabled=i.enabled,this._externalIp=i.externalIp,this._options={description:i.description||`${KC.name}@${KC.version} ${this._peerId}`,ttl:i.ttl||a0,autoUpdate:i.keepAlive||!0,gateway:i.gateway,enablePMP:Boolean(i.pmp&&i.pmp.enabled)},this._options.ttl<a0)throw w5(new Error(`NatManager ttl should be at least ${a0} seconds`),_5)}start(){FC||!this._enabled||this._start().catch(e=>{Co.error(e)})}async _start(){let e=this._transportManager.getAddrs();for(let r of e){let{family:n,host:i,port:s,transport:o}=r.toOptions();if(!r.isThinWaistAddress()||o!=="tcp"||x5(r)||n!==4)continue;let a=this._getClient(),c=this._externalIp||await a.externalIp();if(E5(c))throw new Error(`${c} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);let u=S5();Co(`opening uPnP connection from ${c}:${u} to ${i}:${s}`),await a.map({publicPort:u,privatePort:s,protocol:o.toUpperCase()}),this._addressManager.addObservedAddr(b5.fromNodeAddress({family:4,address:c,port:u},o))}}_getClient(){if(this._client)return this._client;let e=new v5(this._options),r=s0(e.map.bind(e)),n=s0(e.destroy.bind(e)),i=s0(e.externalIp.bind(e));return this._client={map:(...s)=>o0(()=>r(...s),{onFailedAttempt:Co.error,unref:!0}),destroy:(...s)=>o0(()=>n(...s),{onFailedAttempt:Co.error,unref:!0}),externalIp:(...s)=>o0(()=>i(...s),{onFailedAttempt:Co.error,unref:!0})},this._client}async stop(){if(!(FC||!this._client))try{await this._client.destroy(),this._client=null}catch(e){Co.error(e)}}};jC.exports=VC});var z5=w((jV,YC)=>{"use strict";var HC=Te(),Ft=Object.assign(HC("libp2p"),{error:HC("libp2p:err")}),{EventEmitter:A5}=Qt(),c0=he(),C5=Rt(),{Multiaddr:I5}=qt(),{MemoryDatastore:T5}=(m1(),g1),R5=W1(),B5=eb(),u0=ph(),{validate:P5}=mE(),{codes:ol,messages:N5}=je(),O5=EE(),D5=qE(),L5=VE(),zC=T2(),k5=F2(),q5=v_(),GC=mx(),U5=Dx(),M5=Th(),F5=gS(),K5=kA(),V5=UA(),j5=GA(),al=JA(),WC=fC(),l0=wC(),$5=$C(),{updateSelfPeerRecord:H5}=Ch(),Ka=class extends A5{static async create(e){if(e.peerId)return new Ka(e);let r=await C5.create();return e.peerId=r,new Ka(e)}constructor(e){super();if(this._options=P5(e),this.peerId=this._options.peerId,this.datastore=this._options.datastore,this._options.metrics.enabled){let n=new U5({...this._options.metrics});this.metrics=n}if(this.peerStore=new K5({peerId:this.peerId,datastore:this.datastore&&this._options.peerStore.persistence?this.datastore:new T5}),this.addresses=this._options.addresses,this.addressManager=new O5(this.peerId,this._options.addresses),this.addressManager.on("change:addresses",()=>{H5(this).catch(n=>{Ft.error("Error updating self peer record",n)})}),this._modules=this._options.modules,this._config=this._options.config,this._transport=[],this._discovery=new Map,this.connectionManager=new D5(this,{...this._options.connectionManager}),this._autodialler=new L5(this,{enabled:this._config.peerDiscovery.autoDial,minConnections:this._options.connectionManager.minConnections,autoDialInterval:this._options.connectionManager.autoDialInterval}),this._options.keychain&&this._options.keychain.datastore){Ft("creating keychain");let n=GC.generateOptions();this.keychain=new GC(this._options.keychain.datastore,{...n,...this._options.keychain}),Ft("keychain constructed")}if(this.upgrader=new F5({localPeer:this.peerId,metrics:this.metrics,onConnection:n=>this.connectionManager.onConnect(n),onConnectionEnd:n=>this.connectionManager.onDisconnect(n)}),this.transportManager=new M5({libp2p:this,upgrader:this.upgrader,faultTolerance:this._options.transportManager.faultTolerance}),this.natManager=new $5({peerId:this.peerId,addressManager:this.addressManager,transportManager:this.transportManager,...this._options.config.nat}),this.registrar=new j5({peerStore:this.peerStore,connectionManager:this.connectionManager}),this.handle=this.handle.bind(this),this.registrar.handle=this.handle,!this._modules.connEncryption||!this._modules.connEncryption.length)throw c0(new Error(N5.CONN_ENCRYPTION_REQUIRED),ol.CONN_ENCRYPTION_REQUIRED);if(this._modules.connEncryption.forEach(n=>{this.upgrader.cryptos.set(n.protocol,n)}),this.dialer=new q5({transportManager:this.transportManager,peerStore:this.peerStore,metrics:this.metrics,...this._options.dialer}),this._modules.transport.forEach(n=>{let i=n.prototype[Symbol.toStringTag],s=this._config.transport[i];this.transportManager.add(i,n,s)}),this._config.relay.enabled&&(this.transportManager.add(zC.prototype[Symbol.toStringTag],zC),this.relay=new k5(this)),this._modules.streamMuxer&&(this._modules.streamMuxer.forEach(i=>{this.upgrader.muxers.set(i.multicodec,i)}),this.identifyService=new WC({libp2p:this})),this._modules.connProtector)this.upgrader.protector=this._modules.connProtector;else if(globalThis.process!==void 0&&globalThis.process.env&&globalThis.process.env.LIBP2P_FORCE_PNET)throw new Error("Private network is enforced, but no protector was provided");if(this._modules.dht){let n=this._modules.dht;this._dht=n.create({libp2p:this,...this._config.dht})}if(this._modules.pubsub){let n=this._modules.pubsub;this.pubsub=V5(n,this,this._config.pubsub)}this.peerRouting=new R5(this),this.contentRouting=new B5(this),al.mount(this),this._onDiscoveryPeer=this._onDiscoveryPeer.bind(this),this.fetchService=new l0(this)}emit(e,...r){return e==="error"&&!this._events.error?(Ft.error(r),!1):super.emit(e,...r)}async start(){Ft("libp2p is starting"),this.identifyService&&await this.handle(Object.values(WC.getProtocolStr(this)),this.identifyService.handleMessage),this.fetchService&&await this.handle(l0.PROTOCOL,this.fetchService.handleMessage);try{await this._onStarting(),await this._onDidStart(),Ft("libp2p has started")}catch(e){throw this.emit("error",e),Ft.error("An error occurred starting libp2p",e),await this.stop(),e}}async stop(){Ft("libp2p is stopping");try{this._isStarted=!1,this.identifyService&&await this.identifyService.stop(),this.relay&&this.relay.stop(),this.peerRouting.stop(),await this._autodialler.stop(),await(this._dht&&this._dht.stop());for(let e of this._discovery.values())e.removeListener("peer",this._onDiscoveryPeer);await Promise.all(Array.from(this._discovery.values(),e=>e.stop())),this._discovery=new Map,await this.connectionManager.stop(),await Promise.all([this.pubsub&&this.pubsub.stop(),this.metrics&&this.metrics.stop()]),await this.natManager.stop(),await this.transportManager.close(),this.unhandle(l0.PROTOCOL),al.unmount(this),this.dialer.destroy()}catch(e){e&&(Ft.error(e),this.emit("error",e))}Ft("libp2p has stopped")}async loadKeychain(){if(!!this.keychain)try{await this.keychain.findKeyByName("self")}catch(e){await this.keychain.importPeer("self",this.peerId)}}isStarted(){return this._isStarted}get connections(){return this.connectionManager.connections}dial(e,r){return this._dial(e,r)}async dialProtocol(e,r,n){if(!r||!r.length)throw c0(new Error("no protocols were provided to open a stream"),ol.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this._dial(e,n)).newStream(r)}async _dial(e,r){let{id:n,multiaddrs:i}=u0(e);if(n.equals(this.peerId))throw c0(new Error("Cannot dial self"),ol.ERR_DIALED_SELF);let s=this.connectionManager.get(n);return s?i&&await this.peerStore.addressBook.add(n,i):s=await this.dialer.connectToPeer(e,r),s}get multiaddrs(){let e=this.addressManager.getAnnounceAddrs().map(i=>i.toString());e.length||(e=this.transportManager.getAddrs().map(i=>i.toString())),e=e.concat(this.addressManager.getObservedAddrs().map(i=>i.toString()));let r=this._options.addresses.announceFilter,n=new Set(e);return r(Array.from(n).map(i=>new I5(i)))}async hangUp(e){let{id:r}=u0(e),n=this.connectionManager.connections.get(r.toB58String());!n||await Promise.all(n.map(i=>i.close()))}fetch(e,r){return this.fetchService.fetch(e,r)}ping(e){let{id:r,multiaddrs:n}=u0(e);return n?al(this,n[0]):al(this,r)}async handle(e,r){e=Array.isArray(e)?e:[e],e.forEach(n=>{this.upgrader.protocols.set(n,r)}),await this.peerStore.protoBook.add(this.peerId,e)}async unhandle(e){e=Array.isArray(e)?e:[e],e.forEach(r=>{this.upgrader.protocols.delete(r)}),await this.peerStore.protoBook.remove(this.peerId,e)}async _onStarting(){let e=this.addressManager.getListenAddrs();await this.transportManager.listen(e),this.natManager.start(),this._config.pubsub.enabled&&this.pubsub&&await this.pubsub.start(),this._config.dht.enabled&&(this._dht&&await this._dht.start(),this._dht.on("peer",this._onDiscoveryPeer)),this.metrics&&this.metrics.start(),this.identifyService&&await this.identifyService.start()}async _onDidStart(){this._isStarted=!0,this.peerStore.on("peer",e=>{this.emit("peer:discovery",e),this._maybeConnect(e).catch(r=>{Ft.error(r)})});for await(let e of this.peerStore.getPeers())this.emit("peer:discovery",e.id);this.connectionManager.start(),await this._autodialler.start(),await this._setupPeerDiscovery(),this.relay&&this.relay.start(),this.peerRouting.start()}_onDiscoveryPeer(e){if(e.id.toB58String()===this.peerId.toB58String()){Ft.error(new Error(ol.ERR_DISCOVERED_SELF));return}e.multiaddrs&&this.peerStore.addressBook.add(e.id,e.multiaddrs).catch(r=>Ft.error(r)),e.protocols&&this.peerStore.protoBook.set(e.id,e.protocols).catch(r=>Ft.error(r))}async _maybeConnect(e){if(this._config.peerDiscovery.autoDial===!0&&!this.connectionManager.get(e)&&(this._options.connectionManager.minConnections||0)>this.connectionManager.size){Ft("connecting to discovered peer %s",e.toB58String());try{await this.dialer.connectToPeer(e)}catch(n){Ft.error(`could not connect to discovered peer ${e.toB58String()} with ${n}`)}}}async _setupPeerDiscovery(){let e=r=>{let n={enabled:!0};if(r.tag&&this._config.peerDiscovery&&this._config.peerDiscovery[r.tag]&&(n={...n,...this._config.peerDiscovery[r.tag]}),n.enabled&&!this._discovery.has(r.tag)){let i;typeof r=="function"?i=new r(Object.assign({},n,{peerId:this.peerId,libp2p:this})):i=r,i.on("peer",this._onDiscoveryPeer),this._discovery.set(r.tag,i)}};for(let r of this._modules.peerDiscovery||[])e(r);for(let r of this.transportManager.getTransports())r.discovery&&e(r.discovery);await Promise.all(Array.from(this._discovery.values(),r=>r.start()))}};YC.exports=Ka});return z5();})();
46
46
  /*!
47
47
  * The buffer module from node.js, for the browser.
48
48
  *
@@ -50,6 +50,6 @@ if (cid) {
50
50
  * @license MIT
51
51
  */
52
52
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
53
- /*! noble-ed25519 - MIT License (c) Paul Miller (paulmillr.com) */
53
+ /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
54
54
  /*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
55
55
  return Libp2p}));