New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/multistream-select

Package Overview
Dependencies
Maintainers
6
Versions
591
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/multistream-select - npm Package Compare versions

Comparing version 3.1.9-42c1c097 to 3.1.9-5315f7bc

4

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMultistreamSelect = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var Libp2PMultistreamSelect=(()=>{var fr=Object.create;var me=Object.defineProperty;var ur=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var hr=Object.getPrototypeOf,dr=Object.prototype.hasOwnProperty;var ge=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),N=(r,e)=>{for(var t in e)me(r,t,{get:e[t],enumerable:!0})},ct=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of lr(e))!dr.call(r,o)&&o!==t&&me(r,o,{get:()=>e[o],enumerable:!(n=ur(e,o))||n.enumerable});return r};var ft=(r,e,t)=>(t=r!=null?fr(hr(r)):{},ct(e||!r||!r.__esModule?me(t,"default",{value:r,enumerable:!0}):t,r)),pr=r=>ct(me({},"__esModule",{value:!0}),r);var lt=ge((wo,ut)=>{var W=1e3,Y=W*60,Z=Y*60,j=Z*24,br=j*7,mr=j*365.25;ut.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return gr(r);if(t==="number"&&isFinite(r))return e.long?yr(r):wr(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function gr(r){if(r=String(r),!(r.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(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*mr;case"weeks":case"week":case"w":return t*br;case"days":case"day":case"d":return t*j;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Z;case"minutes":case"minute":case"mins":case"min":case"m":return t*Y;case"seconds":case"second":case"secs":case"sec":case"s":return t*W;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function wr(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+"d":e>=Z?Math.round(r/Z)+"h":e>=Y?Math.round(r/Y)+"m":e>=W?Math.round(r/W)+"s":r+"ms"}function yr(r){var e=Math.abs(r);return e>=j?we(r,e,j,"day"):e>=Z?we(r,e,Z,"hour"):e>=Y?we(r,e,Y,"minute"):e>=W?we(r,e,W,"second"):r+" ms"}function we(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var dt=ge((yo,ht)=>{function xr(r){t.debug=t,t.default=t,t.coerce=h,t.disable=s,t.enable=o,t.enabled=a,t.humanize=lt(),t.destroy=p,Object.keys(r).forEach(c=>{t[c]=r[c]}),t.names=[],t.skips=[],t.formatters={};function e(c){let f=0;for(let d=0;d<c.length;d++)f=(f<<5)-f+c.charCodeAt(d),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(c){let f,d=null,U,l;function u(...m){if(!u.enabled)return;let b=u,w=Number(new Date),x=w-(f||w);b.diff=x,b.prev=f,b.curr=w,f=w,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let g=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(v,y)=>{if(v==="%%")return"%";g++;let A=t.formatters[y];if(typeof A=="function"){let k=m[g];v=A.call(b,k),m.splice(g,1),g--}return v}),t.formatArgs.call(b,m),(b.log||t.log).apply(b,m)}return u.namespace=c,u.useColors=t.useColors(),u.color=t.selectColor(c),u.extend=n,u.destroy=t.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(U!==t.namespaces&&(U=t.namespaces,l=t.enabled(c)),l),set:m=>{d=m}}),typeof t.init=="function"&&t.init(u),u}function n(c,f){let d=t(this.namespace+(typeof f>"u"?":":f)+c);return d.log=this.log,d}function o(c){t.save(c),t.namespaces=c,t.names=[],t.skips=[];let f,d=(typeof c=="string"?c:"").split(/[\s,]+/),U=d.length;for(f=0;f<U;f++)d[f]&&(c=d[f].replace(/\*/g,".*?"),c[0]==="-"?t.skips.push(new RegExp("^"+c.slice(1)+"$")):t.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...t.names.map(i),...t.skips.map(i).map(f=>"-"+f)].join(",");return t.enable(""),c}function a(c){if(c[c.length-1]==="*")return!0;let f,d;for(f=0,d=t.skips.length;f<d;f++)if(t.skips[f].test(c))return!1;for(f=0,d=t.names.length;f<d;f++)if(t.names[f].test(c))return!0;return!1}function i(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function h(c){return c instanceof Error?c.stack||c.message:c}function p(){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 t.enable(t.load()),t}ht.exports=xr});var pt=ge((O,ye)=>{O.formatArgs=Ar;O.save=Er;O.load=vr;O.useColors=Cr;O.storage=Lr();O.destroy=(()=>{let r=!1;return()=>{r||(r=!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`."))}})();O.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 Cr(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ar(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+ye.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}O.log=console.debug||console.log||(()=>{});function Er(r){try{r?O.storage.setItem("debug",r):O.storage.removeItem("debug")}catch{}}function vr(){let r;try{r=O.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Lr(){try{return localStorage}catch{}}ye.exports=dt()(O);var{formatters:Sr}=ye.exports;Sr.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Yt=ge((Ai,Wt)=>{"use strict";function Qt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function ro(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Qt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Qt(new o,t)}}Wt.exports=ro});var lo={};N(lo,{PROTOCOL_ID:()=>I,handle:()=>cr,lazySelect:()=>ar,select:()=>ir});var I="/multistream/1.0.0";var V=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var T=ft(pt(),1);function Ur(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var i=r.length,h=r.charAt(0),p=Math.log(i)/Math.log(256),c=Math.log(256)/Math.log(i);function f(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var u=0,m=0,b=0,w=l.length;b!==w&&l[b]===0;)b++,u++;for(var x=(w-b)*c+1>>>0,g=new Uint8Array(x);b!==w;){for(var C=l[b],v=0,y=x-1;(C!==0||v<m)&&y!==-1;y--,v++)C+=256*g[y]>>>0,g[y]=C%i>>>0,C=C/i>>>0;if(C!==0)throw new Error("Non-zero carry");m=v,b++}for(var A=x-m;A!==x&&g[A]===0;)A++;for(var k=h.repeat(u);A<x;++A)k+=r.charAt(g[A]);return k}function d(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var u=0;if(l[u]!==" "){for(var m=0,b=0;l[u]===h;)m++,u++;for(var w=(l.length-u)*p+1>>>0,x=new Uint8Array(w);l[u];){var g=t[l.charCodeAt(u)];if(g===255)return;for(var C=0,v=w-1;(g!==0||C<b)&&v!==-1;v--,C++)g+=i*x[v]>>>0,x[v]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");b=C,u++}if(l[u]!==" "){for(var y=w-b;y!==w&&x[y]===0;)y++;for(var A=new Uint8Array(m+(w-y)),k=m;y!==w;)A[k++]=x[y++];return A}}}function U(l){var u=d(l);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:U}}var Fr=Ur,Nr=Fr,bt=Nr;var Co=new Uint8Array(0);var mt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Te=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},De=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return gt(this,e)}},Re=class{constructor(e){this.decoders=e}or(e){return gt(this,e)}decode(e){let t=e[0],n=this.decoders[t];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`)}},gt=(r,e)=>new Re({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Ie=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Te(e,t,n),this.decoder=new De(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},wt=({name:r,prefix:e,encode:t,decode:n})=>new Ie(r,e,t,n),ke=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=bt(t,e);return wt({prefix:r,name:e,encode:n,decode:s=>mt(o(s))})},Or=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),i=0,h=0,p=0;for(let c=0;c<s;++c){let f=o[r[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|f,i+=t,i>=8&&(i-=8,a[p++]=255&h>>i)}if(i>=t||255&h<<8-i)throw new SyntaxError("Unexpected end of data");return a},Tr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,i=0;for(let h=0;h<r.length;++h)for(i=i<<8|r[h],a+=8;a>t;)a-=t,s+=e[o&i>>a];if(a&&(s+=e[o&i<<t-a]),n)for(;s.length*t&7;)s+="=";return s},F=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>wt({prefix:e,name:r,encode(o){return Tr(o,n,t)},decode(o){return Or(o,n,t,r)}});var yt=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Uo=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fo=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),No=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Oo=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),To=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Do=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ro=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Io=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xt=ke({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bo=ke({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ct=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vo=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),_o=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$o=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});T.default.formatters.b=r=>r==null?"undefined":xt.baseEncode(r);T.default.formatters.t=r=>r==null?"undefined":yt.baseEncode(r);T.default.formatters.m=r=>r==null?"undefined":Ct.baseEncode(r);T.default.formatters.p=r=>r==null?"undefined":r.toString();T.default.formatters.c=r=>r==null?"undefined":r.toString();T.default.formatters.k=r=>r==null?"undefined":r.toString();T.default.formatters.a=r=>r==null?"undefined":r.toString();function Dr(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function ee(r){let e=Dr(`${r}:trace`);return T.default.enabled(`${r}:trace`)&&T.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,T.default)(`${r}:trace`)),Object.assign((0,T.default)(r),{error:(0,T.default)(`${r}:error`),trace:e})}function q(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function P(r=0){return globalThis.Buffer?.alloc!=null?q(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function M(r=0){return globalThis.Buffer?.allocUnsafe!=null?q(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Me(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=M(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return q(t)}function At(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var vt=Symbol.for("@achingbrain/uint8arraylist");function Et(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function xe(r){return!!r?.[vt]}var L=class{constructor(...e){Object.defineProperty(this,vt,{value:!0}),this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(xe(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(xe(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=Et(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Et(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(xe(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Me(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Me(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new L;return s.length=o,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let a=this.bufs[s],i=o,h=i+a.byteLength;if(o=h,e>=h)continue;let p=e>=i&&e<h,c=t>i&&t<=h;if(p&&c){if(e===i&&t===h){n.push(a);break}let f=e-i;n.push(a.subarray(f,f+(t-e)));break}if(p){if(e===0){n.push(a);continue}n.push(a.subarray(e-i));continue}if(c){if(t===h){n.push(a);break}n.push(a.subarray(0,t-i));break}n.push(a)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!xe(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,a=new Int32Array(s);for(let f=0;f<s;f++)a[f]=-1;for(let f=0;f<o;f++)a[n[f]]=f;let i=a,h=this.byteLength-n.byteLength,p=n.byteLength-1,c;for(let f=t;f<=h;f+=c){c=0;for(let d=p;d>=0;d--){let U=this.get(f+d);if(n[d]!==U){c=Math.max(1,d-i[U]);break}}if(c===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=M(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=P(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=M(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=P(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof L)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!At(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new L;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function Ce(r){let e=async function*(){let t=yield,n=new L;for await(let o of r){if(t==null){n.append(o),t=yield n,n=new L;continue}for(n.append(o);n.length>=t;){let s=n.sublist(0,t);if(n.consume(t),t=yield s,t==null){n.length>0&&(t=yield n,n=new L);break}}}if(t!=null)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}var Ae=class{constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return 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}},te=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ae(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ae(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};function _(r={}){return Rr(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Rr(r,e){e=e??{};let t=e.onEnd,n=new te,o,s,a,i=async()=>n.isEmpty()?a?{done:!0}:await new Promise((u,m)=>{s=b=>{s=null,n.push(b);try{u(r(n))}catch(w){m(w)}return o}}):r(n),h=u=>s!=null?s(u):(n.push(u),o),p=u=>(n=new te,s!=null?s({error:u}):(n.push({error:u}),o)),c=u=>{if(a)return o;if(e?.objectMode!==!0&&u?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return h({done:!1,value:u})},f=u=>a?o:(a=!0,u!=null?p(u):h({done:!0})),d=()=>(n=new te,f(),{done:!0}),U=u=>(f(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:i,return:d,throw:U,push:c,end:f,get readableLength(){return n.size}},t==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(u){return l.throw(u),t!=null&&(t(u),t=void 0),{done:!0}},return(){return l.return(),t!=null&&(t(),t=void 0),{done:!0}},push:c,end(u){return l.end(u),t!=null&&(t(u),t=void 0),o},get readableLength(){return l.readableLength}},o}function Be(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}function Ee(r){let e=_(),t=Ce(r.source),n=Be(),o,s=r.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(i=>{o=i}),{reader:t,writer:e,stream:{sink:async i=>{if(o!=null){await Promise.reject(o);return}n.resolve(i),await s},source:t},rest:()=>e.end(),write:e.push,read:async()=>{let i=await t.next();if(i.value!=null)return i.value}}}function Ir(r){return r[Symbol.asyncIterator]!=null}function kr(...r){let e=[];for(let t of r)Ir(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=_({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var ve=kr;var $e={};N($e,{identity:()=>_r});function Mr(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var i=r.length,h=r.charAt(0),p=Math.log(i)/Math.log(256),c=Math.log(256)/Math.log(i);function f(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var u=0,m=0,b=0,w=l.length;b!==w&&l[b]===0;)b++,u++;for(var x=(w-b)*c+1>>>0,g=new Uint8Array(x);b!==w;){for(var C=l[b],v=0,y=x-1;(C!==0||v<m)&&y!==-1;y--,v++)C+=256*g[y]>>>0,g[y]=C%i>>>0,C=C/i>>>0;if(C!==0)throw new Error("Non-zero carry");m=v,b++}for(var A=x-m;A!==x&&g[A]===0;)A++;for(var k=h.repeat(u);A<x;++A)k+=r.charAt(g[A]);return k}function d(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var u=0;if(l[u]!==" "){for(var m=0,b=0;l[u]===h;)m++,u++;for(var w=(l.length-u)*p+1>>>0,x=new Uint8Array(w);l[u];){var g=t[l.charCodeAt(u)];if(g===255)return;for(var C=0,v=w-1;(g!==0||C<b)&&v!==-1;v--,C++)g+=i*x[v]>>>0,x[v]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");b=C,u++}if(l[u]!==" "){for(var y=w-b;y!==w&&x[y]===0;)y++;for(var A=new Uint8Array(m+(w-y)),k=m;y!==w;)A[k++]=x[y++];return A}}}function U(l){var u=d(l);if(u)return u;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:d,decode:U}}var Br=Mr,Pr=Br,Lt=Pr;var ws=new Uint8Array(0);var St=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},z=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Ut=r=>new TextEncoder().encode(r),Ft=r=>new TextDecoder().decode(r);var Pe=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ze=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ot(this,e)}},Ve=class{constructor(e){this.decoders=e}or(e){return Ot(this,e)}decode(e){let t=e[0],n=this.decoders[t];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`)}},Ot=(r,e)=>new Ve({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),_e=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pe(e,t,n),this.decoder=new ze(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},re=({name:r,prefix:e,encode:t,decode:n})=>new _e(r,e,t,n),$=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Lt(t,e);return re({prefix:r,name:e,encode:n,decode:s=>z(o(s))})},zr=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),i=0,h=0,p=0;for(let c=0;c<s;++c){let f=o[r[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<t|f,i+=t,i>=8&&(i-=8,a[p++]=255&h>>i)}if(i>=t||255&h<<8-i)throw new SyntaxError("Unexpected end of data");return a},Vr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,i=0;for(let h=0;h<r.length;++h)for(i=i<<8|r[h],a+=8;a>t;)a-=t,s+=e[o&i>>a];if(a&&(s+=e[o&i<<t-a]),n)for(;s.length*t&7;)s+="=";return s},E=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>re({prefix:e,name:r,encode(o){return Vr(o,n,t)},decode(o){return zr(o,n,t,r)}});var _r=re({prefix:"\0",name:"identity",encode:r=>Ft(r),decode:r=>Ut(r)});var Ge={};N(Ge,{base2:()=>$r});var $r=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var je={};N(je,{base8:()=>Gr});var Gr=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qe={};N(qe,{base10:()=>jr});var jr=$({prefix:"9",name:"base10",alphabet:"0123456789"});var Xe={};N(Xe,{base16:()=>qr,base16upper:()=>Xr});var qr=E({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Xr=E({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Je={};N(Je,{base32:()=>ne,base32hex:()=>Qr,base32hexpad:()=>Yr,base32hexpadupper:()=>Zr,base32hexupper:()=>Wr,base32pad:()=>Hr,base32padupper:()=>Kr,base32upper:()=>Jr,base32z:()=>en});var ne=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Jr=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hr=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kr=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Qr=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wr=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yr=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zr=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),en=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var He={};N(He,{base36:()=>tn,base36upper:()=>rn});var tn=$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),rn=$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ke={};N(Ke,{base58btc:()=>B,base58flickr:()=>nn});var B=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nn=$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qe={};N(Qe,{base64:()=>on,base64pad:()=>sn,base64url:()=>an,base64urlpad:()=>cn});var on=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sn=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),an=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),cn=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var We={};N(We,{base256emoji:()=>dn});var Tt=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),fn=Tt.reduce((r,e,t)=>(r[t]=e,r),[]),un=Tt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function ln(r){return r.reduce((e,t)=>(e+=fn[t],e),"")}function hn(r){let e=[];for(let t of r){let n=un[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var dn=re({prefix:"\u{1F680}",name:"base256emoji",encode:ln,decode:hn});var tt={};N(tt,{sha256:()=>Dn,sha512:()=>Rn});var pn=It,Dt=128,bn=127,mn=~bn,gn=Math.pow(2,31);function It(r,e,t){e=e||[],t=t||0;for(var n=t;r>=gn;)e[t++]=r&255|Dt,r/=128;for(;r&mn;)e[t++]=r&255|Dt,r>>>=7;return e[t]=r|0,It.bytes=t-n+1,e}var wn=Ye,yn=128,Rt=127;function Ye(r,n){var t=0,n=n||0,o=0,s=n,a,i=r.length;do{if(s>=i)throw Ye.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=o<28?(a&Rt)<<o:(a&Rt)*Math.pow(2,o),o+=7}while(a>=yn);return Ye.bytes=s-n,t}var xn=Math.pow(2,7),Cn=Math.pow(2,14),An=Math.pow(2,21),En=Math.pow(2,28),vn=Math.pow(2,35),Ln=Math.pow(2,42),Sn=Math.pow(2,49),Un=Math.pow(2,56),Fn=Math.pow(2,63),Nn=function(r){return r<xn?1:r<Cn?2:r<An?3:r<En?4:r<vn?5:r<Ln?6:r<Sn?7:r<Un?8:r<Fn?9:10},On={encode:pn,decode:wn,encodingLength:Nn},Tn=On,ce=Tn;var fe=(r,e=0)=>[ce.decode(r,e),ce.decode.bytes],oe=(r,e,t=0)=>(ce.encode(r,e,t),e),se=r=>ce.encodingLength(r);var X=(r,e)=>{let t=e.byteLength,n=se(r),o=n+se(t),s=new Uint8Array(o+t);return oe(r,s,0),oe(t,s,n),s.set(e,o),new ie(r,t,e,s)},kt=r=>{let e=z(r),[t,n]=fe(e),[o,s]=fe(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new ie(t,o,a,e)},Mt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&St(r.bytes,t.bytes)}},ie=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var et=({name:r,code:e,encode:t})=>new Ze(r,e,t),Ze=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Pt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Dn=et({name:"sha2-256",code:18,encode:Pt("SHA-256")}),Rn=et({name:"sha2-512",code:19,encode:Pt("SHA-512")});var rt={};N(rt,{identity:()=>Mn});var zt=0,In="identity",Vt=z,kn=r=>X(zt,Vt(r)),Mn={code:zt,name:In,encode:Vt,digest:kn};var zs=new TextEncoder,Vs=new TextDecoder;var _t=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Vn(t,nt(r),e||B.encoder);default:return _n(t,nt(r),e||ne.encoder)}};var $t=new WeakMap,nt=r=>{let e=$t.get(r);if(e==null){let t=new Map;return $t.set(r,t),t}return e},S=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$n)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return S.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=X(e,t);return S.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return S.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Mt(e.multihash,n.multihash)}toString(e){return _t(this,e)}toJSON(){return{"/":_t(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof S)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new S(n,o,s,a||Gt(n,o,s.bytes))}else if(t[Gn]===!0){let{version:n,multihash:o,code:s}=t,a=kt(o);return S.create(n,s,a)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new S(e,t,n,n.bytes)}case 1:{let o=Gt(e,t,n.bytes);return new S(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return S.create(0,le,e)}static createV1(e,t){return S.create(1,e,t)}static decode(e){let[t,n]=S.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=S.inspectBytes(e),n=t.size-t.multihashSize,o=z(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new ie(t.multihashCode,t.digestSize,s,o);return[t.version===0?S.createV0(a):S.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,d]=fe(e.subarray(t));return t+=d,f},o=n(),s=le;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,i=n(),h=n(),p=t+h,c=p-a;return{version:o,codec:s,multihashCode:i,digestSize:h,multihashSize:c,size:p}}static parse(e,t){let[n,o]=zn(e,t),s=S.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return nt(s).set(n,e),s}},zn=(r,e)=>{switch(r[0]){case"Q":{let t=e||B;return[B.prefix,t.decode(`${B.prefix}${r}`)]}case B.prefix:{let t=e||B;return[B.prefix,t.decode(r)]}case ne.prefix:{let t=e||ne;return[ne.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Vn=(r,e,t)=>{let{prefix:n}=t;if(n!==B.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},_n=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},le=112,$n=18,Gt=(r,e,t)=>{let n=se(r),o=n+se(e),s=new Uint8Array(o+t.byteLength);return oe(r,s,0),oe(e,s,n),s.set(t,o),s},Gn=Symbol.for("@ipld/js-cid/CID");var ot={...$e,...Ge,...je,...qe,...Xe,...Je,...He,...Ke,...Qe,...We},Qs={...tt,...rt};function qt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var jt=qt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),st=qt("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=M(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),jn={utf8:jt,"utf-8":jt,hex:ot.base16,latin1:st,ascii:st,binary:st,...ot},Se=jn;function D(r,e="utf8"){let t=Se[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?q(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var he=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Xt(r){if(r!=null){if(typeof r[Symbol.iterator]=="function")return r[Symbol.iterator]();if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r.next=="function")return r}throw new Error("argument is not an iterator or iterable")}function Jt(r,e,t){let n=t??{},o=Xt(r);async function*s(){let a,i=()=>{a?.()};for(e.addEventListener("abort",i);;){let h;try{if(e.aborted){let{abortMessage:c,abortCode:f}=n;throw new he(c,f)}let p=new Promise((c,f)=>{a=()=>{let{abortMessage:d,abortCode:U}=n;f(new he(d,U))}});h=await Promise.race([p,o.next()]),a=null}catch(p){e.removeEventListener("abort",i);let c=p.type==="aborted"&&e.aborted;if(c&&n.onAbort!=null&&n.onAbort(r),typeof o.return=="function")try{let f=o.return();f instanceof Promise&&f.catch(d=>{n.onReturnError!=null&&n.onReturnError(d)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(c&&n.returnOnAbort===!0)return;throw p}if(h.done===!0)break;yield h.value}e.removeEventListener("abort",i)}return s()}function qn(r){return r[Symbol.asyncIterator]!=null}function Xn(r){if(qn(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ht=Xn;function Ue(r){return r instanceof Uint8Array?{get(e){return r[e]},set(e,t){r[e]=t}}:{get(e){return r.get(e)},set(e,t){r.set(e,t)}}}var Kt=4294967296,R=class{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(e===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),t=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new R(n,t)}zzEncode(){let e=this.hi>>31,t=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new R(t,n)}toBytes(e,t=0){let n=Ue(e);for(;this.hi>0;)n.set(t++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(t++,this.lo&127|128),this.lo=this.lo>>>7;n.set(t++,this.lo)}static fromBigInt(e){if(e===0n)return new R;let t=e<0;t&&(e=-e);let n=Number(e>>32n)|0,o=Number(e-(BigInt(n)<<32n))|0;return t&&(n=~n>>>0,o=~o>>>0,++o>Kt&&(o=0,++n>Kt&&(n=0))),new R(n,o)}static fromNumber(e){if(e===0)return new R;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new R(o,n)}static fromBytes(e,t=0){let n=Ue(e),o=new R,s=0;if(e.length-t>4){for(;s<4;++s)if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o;if(o.lo=(o.lo|(n.get(t)&127)<<28)>>>0,o.hi=(o.hi|(n.get(t)&127)>>4)>>>0,n.get(t++)<128)return o;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o}if(e.length-t>4){for(;s<5;++s)if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}else if(t<e.byteLength)for(;s<5;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}throw RangeError("invalid varint encoding")}};var Jn=Math.pow(2,7),Hn=Math.pow(2,14),Kn=Math.pow(2,21),Qn=Math.pow(2,28),Wn=Math.pow(2,35),Yn=Math.pow(2,42),Zn=Math.pow(2,49),eo=Math.pow(2,56),to=Math.pow(2,63),J={encodingLength(r){return r<Jn?1:r<Hn?2:r<Kn?3:r<Qn?4:r<Wn?5:r<Yn?6:r<Zn?7:r<eo?8:r<to?9:10},encode(r,e,t=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=M(J.encodingLength(r))),R.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return R.fromBytes(r,e).toNumber(!0)}};function Fe(r){return r[Symbol.asyncIterator]!=null}var Ne=r=>{let e=J.encodingLength(r),t=M(e);return J.encode(r,t),Ne.bytes=e,t};Ne.bytes=0;function Oe(r,e){e=e??{};let t=e.lengthEncoder??Ne;function*n(o){let s=t(o.byteLength);s instanceof Uint8Array?yield s:yield*s,o instanceof Uint8Array?yield o:yield*o}return Fe(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Oe.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Ne;return new L(t(r.byteLength),r)};var ae=ft(Yt(),1);var no=8,oo=1024*1024*4,H;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(H||(H={}));var it=r=>{let e=J.decode(r);return it.bytes=J.encodingLength(e),e};it.bytes=0;function de(r,e){let t=new L,n=H.LENGTH,o=-1,s=e?.lengthDecoder??it,a=e?.maxLengthLength??no,i=e?.maxDataLength??oo;function*h(){for(;t.byteLength>0;){if(n===H.LENGTH)try{if(o=s(t),o<0)throw(0,ae.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>i)throw(0,ae.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let p=s.bytes;t.consume(p),e?.onLength!=null&&e.onLength(o),n=H.DATA}catch(p){if(p instanceof RangeError){if(t.byteLength>a)throw(0,ae.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw p}if(n===H.DATA){if(t.byteLength<o)break;let p=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(p),yield p,n=H.LENGTH}}}return Fe(r)?async function*(){for await(let p of r)t.append(p),yield*h();if(t.byteLength>0)throw(0,ae.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let p of r)t.append(p),yield*h();if(t.byteLength>0)throw(0,ae.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}de.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:s,value:a}=await r.next(t);if(s===!0)return;a!=null&&(yield a)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{t=1}}();return de(n,{...e??{},onLength:s=>{t=s}})};function Zt(r,...e){if(r==null)throw new Error("Empty pipeline");if(at(r)){let n=r;r=()=>n.source}else if(tr(r)||er(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&at(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)at(t[n])&&(t[n]=ao(t[n]));return io(...t)}var io=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},er=r=>r?.[Symbol.asyncIterator]!=null,tr=r=>r?.[Symbol.iterator]!=null,at=r=>r==null?!1:r.sink!=null&&r.source!=null,ao=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=_({objectMode:!0});t.then(()=>{n.end()},a=>{n.end(a)});let o,s=r.source;if(er(s))o=async function*(){yield*s,n.end()};else if(tr(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ve(n,o())}return r.source};function rr(r,e="utf8"){let t=Se[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var fo=ee("libp2p:mss"),nr=D(`
`);function K(r){let e=new L(r,nr);return Oe.single(e)}function Q(r,e,t={}){let n=K(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function or(r,e,t={}){let n=new L;for(let o of e)n.append(K(o));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function uo(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>r.next(t)},o=n;e?.signal!=null&&(o=Jt(n,e.signal));let s=i=>{t=i},a=await Zt(o,i=>de(i,{onLength:s,maxDataLength:1024}),async i=>Ht(i));if(a==null||a.length===0)throw new V("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(a.get(a.byteLength-1)!==nr[0])throw fo.error("Invalid mss message - missing newline - %s",a.subarray()),new V("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return a.sublist(0,-1)}async function G(r,e){let t=await uo(r,e);return rr(t.subarray())}var pe=ee("libp2p:mss:select");async function ir(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:o,rest:s,stream:a}=Ee(r),i=e.shift();if(i==null)throw new Error("At least one protocol must be specified");pe.trace('select: write ["%s", "%s"]',I,i);let h=D(I),p=D(i);or(o,[h,p],t);let c=await G(n,t);if(pe.trace('select: read "%s"',c),c===I&&(c=await G(n,t),pe.trace('select: read "%s"',c)),c===i)return s(),{stream:a,protocol:i};for(let f of e){pe.trace('select: write "%s"',f),Q(o,D(f),t);let d=await G(n,t);if(pe.trace('select: read "%s" for "%s"',d,f),d===f)return s(),{stream:a,protocol:f}}throw s(),new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}function ar(r,e){let t=_(),n=!1;return{stream:{sink:async o=>{await r.sink(async function*(){let s=!0;for await(let a of ve(o,t))if(s){s=!1,n=!0,t.end();let i=D(I),h=D(e),p=new L(K(i),K(h));a.length>0&&p.append(a),yield*p}else yield a}())},source:async function*(){n||t.push(new Uint8Array);let o=Ce(r.source),s=await G(o);if(s===I&&(s=await G(o)),s!==e)throw new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL");for await(let a of o)yield*a}()},protocol:e}}var be=ee("libp2p:mss:handle");async function cr(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:o,rest:s,stream:a}=Ee(r);for(;;){let i=await G(o,t);if(be.trace('read "%s"',i),i===I){be.trace('respond with "%s" for "%s"',I,i),Q(n,D(I),t);continue}if(e.includes(i))return Q(n,D(i),t),be.trace('respond with "%s" for "%s"',i,i),s(),{stream:a,protocol:i};if(i==="ls"){Q(n,new L(...e.map(h=>K(D(h)))),t),be.trace('respond with "%s" for %s',e,i);continue}Q(n,D("na"),t),be('respond with "na" for "%s"',i)}}return pr(lo);})();
"use strict";var Libp2PMultistreamSelect=(()=>{var ur=Object.create;var ge=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty;var we=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),N=(r,e)=>{for(var t in e)ge(r,t,{get:e[t],enumerable:!0})},ft=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of hr(e))!pr.call(r,o)&&o!==t&&ge(r,o,{get:()=>e[o],enumerable:!(n=lr(e,o))||n.enumerable});return r};var ut=(r,e,t)=>(t=r!=null?ur(dr(r)):{},ft(e||!r||!r.__esModule?ge(t,"default",{value:r,enumerable:!0}):t,r)),br=r=>ft(ge({},"__esModule",{value:!0}),r);var ht=we((yo,lt)=>{var W=1e3,Y=W*60,Z=Y*60,j=Z*24,mr=j*7,gr=j*365.25;lt.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return wr(r);if(t==="number"&&isFinite(r))return e.long?xr(r):yr(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function wr(r){if(r=String(r),!(r.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(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*gr;case"weeks":case"week":case"w":return t*mr;case"days":case"day":case"d":return t*j;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Z;case"minutes":case"minute":case"mins":case"min":case"m":return t*Y;case"seconds":case"second":case"secs":case"sec":case"s":return t*W;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function yr(r){var e=Math.abs(r);return e>=j?Math.round(r/j)+"d":e>=Z?Math.round(r/Z)+"h":e>=Y?Math.round(r/Y)+"m":e>=W?Math.round(r/W)+"s":r+"ms"}function xr(r){var e=Math.abs(r);return e>=j?ye(r,e,j,"day"):e>=Z?ye(r,e,Z,"hour"):e>=Y?ye(r,e,Y,"minute"):e>=W?ye(r,e,W,"second"):r+" ms"}function ye(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var pt=we((xo,dt)=>{function Cr(r){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=o,t.enabled=a,t.humanize=ht(),t.destroy=b,Object.keys(r).forEach(c=>{t[c]=r[c]}),t.names=[],t.skips=[],t.formatters={};function e(c){let f=0;for(let p=0;p<c.length;p++)f=(f<<5)-f+c.charCodeAt(p),f|=0;return t.colors[Math.abs(f)%t.colors.length]}t.selectColor=e;function t(c){let f,p=null,U,u;function d(...h){if(!d.enabled)return;let m=d,g=Number(new Date),y=g-(f||g);m.diff=y,m.prev=f,m.curr=g,f=g,h[0]=t.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let w=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(v,x)=>{if(v==="%%")return"%";w++;let A=t.formatters[x];if(typeof A=="function"){let k=h[w];v=A.call(m,k),h.splice(w,1),w--}return v}),t.formatArgs.call(m,h),(m.log||t.log).apply(m,h)}return d.namespace=c,d.useColors=t.useColors(),d.color=t.selectColor(c),d.extend=n,d.destroy=t.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(U!==t.namespaces&&(U=t.namespaces,u=t.enabled(c)),u),set:h=>{p=h}}),typeof t.init=="function"&&t.init(d),d}function n(c,f){let p=t(this.namespace+(typeof f>"u"?":":f)+c);return p.log=this.log,p}function o(c){t.save(c),t.namespaces=c,t.names=[],t.skips=[];let f,p=(typeof c=="string"?c:"").split(/[\s,]+/),U=p.length;for(f=0;f<U;f++)p[f]&&(c=p[f].replace(/\*/g,".*?"),c[0]==="-"?t.skips.push(new RegExp("^"+c.slice(1)+"$")):t.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...t.names.map(i),...t.skips.map(i).map(f=>"-"+f)].join(",");return t.enable(""),c}function a(c){if(c[c.length-1]==="*")return!0;let f,p;for(f=0,p=t.skips.length;f<p;f++)if(t.skips[f].test(c))return!1;for(f=0,p=t.names.length;f<p;f++)if(t.names[f].test(c))return!0;return!1}function i(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function l(c){return c instanceof Error?c.stack||c.message:c}function b(){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 t.enable(t.load()),t}dt.exports=Cr});var bt=we((O,xe)=>{O.formatArgs=Er;O.save=vr;O.load=Lr;O.useColors=Ar;O.storage=Sr();O.destroy=(()=>{let r=!1;return()=>{r||(r=!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`."))}})();O.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 Ar(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Er(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+xe.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}O.log=console.debug||console.log||(()=>{});function vr(r){try{r?O.storage.setItem("debug",r):O.storage.removeItem("debug")}catch{}}function Lr(){let r;try{r=O.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Sr(){try{return localStorage}catch{}}xe.exports=pt()(O);var{formatters:Ur}=xe.exports;Ur.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Zt=we((vi,Yt)=>{"use strict";function Wt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function no(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Wt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Wt(new o,t)}}Yt.exports=no});var ho={};N(ho,{PROTOCOL_ID:()=>I,handle:()=>fr,lazySelect:()=>cr,select:()=>ar});var I="/multistream/1.0.0";var V=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var T=ut(bt(),1);function Fr(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var i=r.length,l=r.charAt(0),b=Math.log(i)/Math.log(256),c=Math.log(256)/Math.log(i);function f(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var d=0,h=0,m=0,g=u.length;m!==g&&u[m]===0;)m++,d++;for(var y=(g-m)*c+1>>>0,w=new Uint8Array(y);m!==g;){for(var C=u[m],v=0,x=y-1;(C!==0||v<h)&&x!==-1;x--,v++)C+=256*w[x]>>>0,w[x]=C%i>>>0,C=C/i>>>0;if(C!==0)throw new Error("Non-zero carry");h=v,m++}for(var A=y-h;A!==y&&w[A]===0;)A++;for(var k=l.repeat(d);A<y;++A)k+=r.charAt(w[A]);return k}function p(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var d=0;if(u[d]!==" "){for(var h=0,m=0;u[d]===l;)h++,d++;for(var g=(u.length-d)*b+1>>>0,y=new Uint8Array(g);u[d];){var w=t[u.charCodeAt(d)];if(w===255)return;for(var C=0,v=g-1;(w!==0||C<m)&&v!==-1;v--,C++)w+=i*y[v]>>>0,y[v]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");m=C,d++}if(u[d]!==" "){for(var x=g-m;x!==g&&y[x]===0;)x++;for(var A=new Uint8Array(h+(g-x)),k=h;x!==g;)A[k++]=y[x++];return A}}}function U(u){var d=p(u);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:p,decode:U}}var Nr=Fr,Or=Nr,mt=Or;var Ao=new Uint8Array(0);var gt=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var De=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Re=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return wt(this,e)}},Ie=class{constructor(e){this.decoders=e}or(e){return wt(this,e)}decode(e){let t=e[0],n=this.decoders[t];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`)}},wt=(r,e)=>new Ie({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ke=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new De(e,t,n),this.decoder=new Re(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},yt=({name:r,prefix:e,encode:t,decode:n})=>new ke(r,e,t,n),Me=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=mt(t,e);return yt({prefix:r,name:e,encode:n,decode:s=>gt(o(s))})},Tr=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),i=0,l=0,b=0;for(let c=0;c<s;++c){let f=o[r[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|f,i+=t,i>=8&&(i-=8,a[b++]=255&l>>i)}if(i>=t||255&l<<8-i)throw new SyntaxError("Unexpected end of data");return a},Dr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,i=0;for(let l=0;l<r.length;++l)for(i=i<<8|r[l],a+=8;a>t;)a-=t,s+=e[o&i>>a];if(a&&(s+=e[o&i<<t-a]),n)for(;s.length*t&7;)s+="=";return s},F=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>yt({prefix:e,name:r,encode(o){return Dr(o,n,t)},decode(o){return Tr(o,n,t,r)}});var xt=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Fo=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),No=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oo=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),To=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Do=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ro=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Io=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ko=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ct=Me({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Po=Me({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var At=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),_o=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$o=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Go=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});T.default.formatters.b=r=>r==null?"undefined":Ct.baseEncode(r);T.default.formatters.t=r=>r==null?"undefined":xt.baseEncode(r);T.default.formatters.m=r=>r==null?"undefined":At.baseEncode(r);T.default.formatters.p=r=>r==null?"undefined":r.toString();T.default.formatters.c=r=>r==null?"undefined":r.toString();T.default.formatters.k=r=>r==null?"undefined":r.toString();T.default.formatters.a=r=>r==null?"undefined":r.toString();function Rr(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function ee(r){let e=Rr(`${r}:trace`);return T.default.enabled(`${r}:trace`)&&T.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,T.default)(`${r}:trace`)),Object.assign((0,T.default)(r),{error:(0,T.default)(`${r}:error`),trace:e})}function q(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function P(r=0){return globalThis.Buffer?.alloc!=null?q(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function M(r=0){return globalThis.Buffer?.allocUnsafe!=null?q(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Be(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=M(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return q(t)}function Et(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var Lt=Symbol.for("@achingbrain/uint8arraylist");function vt(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let o=t+n.byteLength;if(e<o)return{buf:n,index:e-t};t=o}throw new RangeError("index is out of bounds")}function Ce(r){return!!r?.[Lt]}var L=class{constructor(...e){Object.defineProperty(this,Lt,{value:!0}),this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(Ce(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(Ce(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=vt(this.bufs,e);return t.buf[t.index]}set(e,t){let n=vt(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(Ce(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:o}=this._subList(e,t);return Be(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Be(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new L;return s.length=o,s.bufs=n,s}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let a=this.bufs[s],i=o,l=i+a.byteLength;if(o=l,e>=l)continue;let b=e>=i&&e<l,c=t>i&&t<=l;if(b&&c){if(e===i&&t===l){n.push(a);break}let f=e-i;n.push(a.subarray(f,f+(t-e)));break}if(b){if(e===0){n.push(a);continue}n.push(a.subarray(e-i));continue}if(c){if(t===l){n.push(a);break}n.push(a.subarray(0,t-i));break}n.push(a)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!Ce(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,a=new Int32Array(s);for(let f=0;f<s;f++)a[f]=-1;for(let f=0;f<o;f++)a[n[f]]=f;let i=a,l=this.byteLength-n.byteLength,b=n.byteLength-1,c;for(let f=t;f<=l;f+=c){c=0;for(let p=b;p>=0;p--){let U=this.get(f+p);if(n[p]!==U){c=Math.max(1,p-i[U]);break}}if(c===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=M(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let o=P(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,t,n),this.write(o,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,t,n),this.write(o,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,t,n),this.write(o,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=M(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let o=P(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,t,n),this.write(o,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,t,n),this.write(o,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,t,n),this.write(o,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let o=P(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,t,n),this.write(o,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let o=P(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof L)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Et(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new L;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function Ae(r){let e=async function*(){let t=yield,n=new L;for await(let o of r){if(t==null){n.append(o),t=yield n,n=new L;continue}for(n.append(o);n.length>=t;){let s=n.sublist(0,t);if(n.consume(t),t=yield s,t==null){n.length>0&&(t=yield n,n=new L);break}}}if(t!=null)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:n})}();return e.next(),e}function te(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ee=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return 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}},re=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ee(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new Ee(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Pe=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function _(r={}){return Ir(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Ir(r,e){e=e??{};let t=e.onEnd,n=new re,o,s,a,i=te(),l=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((h,m)=>{s=g=>{s=null,n.push(g);try{h(r(n))}catch(y){m(y)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{i.resolve(),i=te()})}},b=h=>s!=null?s(h):(n.push(h),o),c=h=>(n=new re,s!=null?s({error:h}):(n.push({error:h}),o)),f=h=>{if(a)return o;if(e?.objectMode!==!0&&h?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return b({done:!1,value:h})},p=h=>a?o:(a=!0,h!=null?c(h):b({done:!0})),U=()=>(n=new re,p(),{done:!0}),u=h=>(p(h),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:l,return:U,throw:u,push:f,end:p,get readableLength(){return n.size},onEmpty:async h=>{let m=h?.signal;if(m?.throwIfAborted(),n.isEmpty())return;let g,y;m!=null&&(g=new Promise((w,C)=>{y=()=>{C(new Pe)},m.addEventListener("abort",y)}));try{await Promise.race([i.promise,g])}finally{y!=null&&m!=null&&m?.removeEventListener("abort",y)}}},t==null)return o;let d=o;return o={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(h){return d.throw(h),t!=null&&(t(h),t=void 0),{done:!0}},return(){return d.return(),t!=null&&(t(),t=void 0),{done:!0}},push:f,end(h){return d.end(h),t!=null&&(t(h),t=void 0),o},get readableLength(){return d.readableLength}},o}function ve(r){let e=_(),t=Ae(r.source),n=te(),o,s=r.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(i=>{o=i}),{reader:t,writer:e,stream:{sink:async i=>{if(o!=null){await Promise.reject(o);return}n.resolve(i),await s},source:t},rest:()=>e.end(),write:e.push,read:async()=>{let i=await t.next();if(i.value!=null)return i.value}}}function kr(r){return r[Symbol.asyncIterator]!=null}function Mr(...r){let e=[];for(let t of r)kr(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=_({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var Le=Mr;var Ge={};N(Ge,{identity:()=>$r});function Br(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var i=r.length,l=r.charAt(0),b=Math.log(i)/Math.log(256),c=Math.log(256)/Math.log(i);function f(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return"";for(var d=0,h=0,m=0,g=u.length;m!==g&&u[m]===0;)m++,d++;for(var y=(g-m)*c+1>>>0,w=new Uint8Array(y);m!==g;){for(var C=u[m],v=0,x=y-1;(C!==0||v<h)&&x!==-1;x--,v++)C+=256*w[x]>>>0,w[x]=C%i>>>0,C=C/i>>>0;if(C!==0)throw new Error("Non-zero carry");h=v,m++}for(var A=y-h;A!==y&&w[A]===0;)A++;for(var k=l.repeat(d);A<y;++A)k+=r.charAt(w[A]);return k}function p(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var d=0;if(u[d]!==" "){for(var h=0,m=0;u[d]===l;)h++,d++;for(var g=(u.length-d)*b+1>>>0,y=new Uint8Array(g);u[d];){var w=t[u.charCodeAt(d)];if(w===255)return;for(var C=0,v=g-1;(w!==0||C<m)&&v!==-1;v--,C++)w+=i*y[v]>>>0,y[v]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");m=C,d++}if(u[d]!==" "){for(var x=g-m;x!==g&&y[x]===0;)x++;for(var A=new Uint8Array(h+(g-x)),k=h;x!==g;)A[k++]=y[x++];return A}}}function U(u){var d=p(u);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:p,decode:U}}var Pr=Br,zr=Pr,St=zr;var xs=new Uint8Array(0);var Ut=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},z=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Ft=r=>new TextEncoder().encode(r),Nt=r=>new TextDecoder().decode(r);var ze=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Ve=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Tt(this,e)}},_e=class{constructor(e){this.decoders=e}or(e){return Tt(this,e)}decode(e){let t=e[0],n=this.decoders[t];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`)}},Tt=(r,e)=>new _e({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),$e=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ze(e,t,n),this.decoder=new Ve(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ne=({name:r,prefix:e,encode:t,decode:n})=>new $e(r,e,t,n),$=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=St(t,e);return ne({prefix:r,name:e,encode:n,decode:s=>z(o(s))})},Vr=(r,e,t,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),i=0,l=0,b=0;for(let c=0;c<s;++c){let f=o[r[c]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|f,i+=t,i>=8&&(i-=8,a[b++]=255&l>>i)}if(i>=t||255&l<<8-i)throw new SyntaxError("Unexpected end of data");return a},_r=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,i=0;for(let l=0;l<r.length;++l)for(i=i<<8|r[l],a+=8;a>t;)a-=t,s+=e[o&i>>a];if(a&&(s+=e[o&i<<t-a]),n)for(;s.length*t&7;)s+="=";return s},E=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>ne({prefix:e,name:r,encode(o){return _r(o,n,t)},decode(o){return Vr(o,n,t,r)}});var $r=ne({prefix:"\0",name:"identity",encode:r=>Nt(r),decode:r=>Ft(r)});var je={};N(je,{base2:()=>Gr});var Gr=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qe={};N(qe,{base8:()=>jr});var jr=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xe={};N(Xe,{base10:()=>qr});var qr=$({prefix:"9",name:"base10",alphabet:"0123456789"});var Je={};N(Je,{base16:()=>Xr,base16upper:()=>Jr});var Xr=E({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Jr=E({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var He={};N(He,{base32:()=>oe,base32hex:()=>Wr,base32hexpad:()=>Zr,base32hexpadupper:()=>en,base32hexupper:()=>Yr,base32pad:()=>Kr,base32padupper:()=>Qr,base32upper:()=>Hr,base32z:()=>tn});var oe=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hr=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kr=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qr=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wr=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Yr=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zr=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),en=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),tn=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ke={};N(Ke,{base36:()=>rn,base36upper:()=>nn});var rn=$({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nn=$({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qe={};N(Qe,{base58btc:()=>B,base58flickr:()=>on});var B=$({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),on=$({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var We={};N(We,{base64:()=>sn,base64pad:()=>an,base64url:()=>cn,base64urlpad:()=>fn});var sn=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),an=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),cn=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fn=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ye={};N(Ye,{base256emoji:()=>pn});var Dt=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),un=Dt.reduce((r,e,t)=>(r[t]=e,r),[]),ln=Dt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function hn(r){return r.reduce((e,t)=>(e+=un[t],e),"")}function dn(r){let e=[];for(let t of r){let n=ln[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var pn=ne({prefix:"\u{1F680}",name:"base256emoji",encode:hn,decode:dn});var rt={};N(rt,{sha256:()=>Rn,sha512:()=>In});var bn=kt,Rt=128,mn=127,gn=~mn,wn=Math.pow(2,31);function kt(r,e,t){e=e||[],t=t||0;for(var n=t;r>=wn;)e[t++]=r&255|Rt,r/=128;for(;r&gn;)e[t++]=r&255|Rt,r>>>=7;return e[t]=r|0,kt.bytes=t-n+1,e}var yn=Ze,xn=128,It=127;function Ze(r,n){var t=0,n=n||0,o=0,s=n,a,i=r.length;do{if(s>=i)throw Ze.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=o<28?(a&It)<<o:(a&It)*Math.pow(2,o),o+=7}while(a>=xn);return Ze.bytes=s-n,t}var Cn=Math.pow(2,7),An=Math.pow(2,14),En=Math.pow(2,21),vn=Math.pow(2,28),Ln=Math.pow(2,35),Sn=Math.pow(2,42),Un=Math.pow(2,49),Fn=Math.pow(2,56),Nn=Math.pow(2,63),On=function(r){return r<Cn?1:r<An?2:r<En?3:r<vn?4:r<Ln?5:r<Sn?6:r<Un?7:r<Fn?8:r<Nn?9:10},Tn={encode:bn,decode:yn,encodingLength:On},Dn=Tn,fe=Dn;var ue=(r,e=0)=>[fe.decode(r,e),fe.decode.bytes],se=(r,e,t=0)=>(fe.encode(r,e,t),e),ie=r=>fe.encodingLength(r);var X=(r,e)=>{let t=e.byteLength,n=ie(r),o=n+ie(t),s=new Uint8Array(o+t);return se(r,s,0),se(t,s,n),s.set(e,o),new ae(r,t,e,s)},Mt=r=>{let e=z(r),[t,n]=ue(e),[o,s]=ue(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new ae(t,o,a,e)},Bt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ut(r.bytes,t.bytes)}},ae=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var tt=({name:r,code:e,encode:t})=>new et(r,e,t),et=class{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?X(this.code,t):t.then(n=>X(this.code,n))}else throw Error("Unknown type, must be binary type")}};var zt=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),Rn=tt({name:"sha2-256",code:18,encode:zt("SHA-256")}),In=tt({name:"sha2-512",code:19,encode:zt("SHA-512")});var nt={};N(nt,{identity:()=>Bn});var Vt=0,kn="identity",_t=z,Mn=r=>X(Vt,_t(r)),Bn={code:Vt,name:kn,encode:_t,digest:Mn};var _s=new TextEncoder,$s=new TextDecoder;var $t=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return _n(t,ot(r),e||B.encoder);default:return $n(t,ot(r),e||oe.encoder)}};var Gt=new WeakMap,ot=r=>{let e=Gt.get(r);if(e==null){let t=new Map;return Gt.set(r,t),t}return e},S=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Gn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return S.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=X(e,t);return S.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return S.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Bt(e.multihash,n.multihash)}toString(e){return $t(this,e)}toJSON(){return{"/":$t(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof S)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new S(n,o,s,a||jt(n,o,s.bytes))}else if(t[jn]===!0){let{version:n,multihash:o,code:s}=t,a=Mt(o);return S.create(n,s,a)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new S(e,t,n,n.bytes)}case 1:{let o=jt(e,t,n.bytes);return new S(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return S.create(0,he,e)}static createV1(e,t){return S.create(1,e,t)}static decode(e){let[t,n]=S.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=S.inspectBytes(e),n=t.size-t.multihashSize,o=z(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new ae(t.multihashCode,t.digestSize,s,o);return[t.version===0?S.createV0(a):S.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,p]=ue(e.subarray(t));return t+=p,f},o=n(),s=he;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,i=n(),l=n(),b=t+l,c=b-a;return{version:o,codec:s,multihashCode:i,digestSize:l,multihashSize:c,size:b}}static parse(e,t){let[n,o]=Vn(e,t),s=S.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ot(s).set(n,e),s}},Vn=(r,e)=>{switch(r[0]){case"Q":{let t=e||B;return[B.prefix,t.decode(`${B.prefix}${r}`)]}case B.prefix:{let t=e||B;return[B.prefix,t.decode(r)]}case oe.prefix:{let t=e||oe;return[oe.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},_n=(r,e,t)=>{let{prefix:n}=t;if(n!==B.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},$n=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},he=112,Gn=18,jt=(r,e,t)=>{let n=ie(r),o=n+ie(e),s=new Uint8Array(o+t.byteLength);return se(r,s,0),se(e,s,n),s.set(t,o),s},jn=Symbol.for("@ipld/js-cid/CID");var st={...Ge,...je,...qe,...Xe,...Je,...He,...Ke,...Qe,...We,...Ye},Ys={...rt,...nt};function Xt(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var qt=Xt("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),it=Xt("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=M(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),qn={utf8:qt,"utf-8":qt,hex:st.base16,latin1:it,ascii:it,binary:it,...st},Ue=qn;function D(r,e="utf8"){let t=Ue[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?q(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var de=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Jt(r){if(r!=null){if(typeof r[Symbol.iterator]=="function")return r[Symbol.iterator]();if(typeof r[Symbol.asyncIterator]=="function")return r[Symbol.asyncIterator]();if(typeof r.next=="function")return r}throw new Error("argument is not an iterator or iterable")}function Ht(r,e,t){let n=t??{},o=Jt(r);async function*s(){let a,i=()=>{a?.()};for(e.addEventListener("abort",i);;){let l;try{if(e.aborted){let{abortMessage:c,abortCode:f}=n;throw new de(c,f)}let b=new Promise((c,f)=>{a=()=>{let{abortMessage:p,abortCode:U}=n;f(new de(p,U))}});l=await Promise.race([b,o.next()]),a=null}catch(b){e.removeEventListener("abort",i);let c=b.type==="aborted"&&e.aborted;if(c&&n.onAbort!=null&&n.onAbort(r),typeof o.return=="function")try{let f=o.return();f instanceof Promise&&f.catch(p=>{n.onReturnError!=null&&n.onReturnError(p)})}catch(f){n.onReturnError!=null&&n.onReturnError(f)}if(c&&n.returnOnAbort===!0)return;throw b}if(l.done===!0)break;yield l.value}e.removeEventListener("abort",i)}return s()}function Xn(r){return r[Symbol.asyncIterator]!=null}function Jn(r){if(Xn(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Kt=Jn;function Fe(r){return r instanceof Uint8Array?{get(e){return r[e]},set(e,t){r[e]=t}}:{get(e){return r.get(e)},set(e,t){r.set(e,t)}}}var Qt=4294967296,R=class{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(e===!0)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){let e=-(this.lo&1),t=((this.lo>>>1|this.hi<<31)^e)>>>0,n=(this.hi>>>1^e)>>>0;return new R(n,t)}zzEncode(){let e=this.hi>>31,t=((this.hi<<1|this.lo>>>31)^e)>>>0,n=(this.lo<<1^e)>>>0;return new R(t,n)}toBytes(e,t=0){let n=Fe(e);for(;this.hi>0;)n.set(t++,this.lo&127|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)n.set(t++,this.lo&127|128),this.lo=this.lo>>>7;n.set(t++,this.lo)}static fromBigInt(e){if(e===0n)return new R;let t=e<0;t&&(e=-e);let n=Number(e>>32n)|0,o=Number(e-(BigInt(n)<<32n))|0;return t&&(n=~n>>>0,o=~o>>>0,++o>Qt&&(o=0,++n>Qt&&(n=0))),new R(n,o)}static fromNumber(e){if(e===0)return new R;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new R(o,n)}static fromBytes(e,t=0){let n=Fe(e),o=new R,s=0;if(e.length-t>4){for(;s<4;++s)if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o;if(o.lo=(o.lo|(n.get(t)&127)<<28)>>>0,o.hi=(o.hi|(n.get(t)&127)>>4)>>>0,n.get(t++)<128)return o;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.lo=(o.lo|(n.get(t)&127)<<s*7)>>>0,n.get(t++)<128)return o}if(e.length-t>4){for(;s<5;++s)if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}else if(t<e.byteLength)for(;s<5;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(o.hi=(o.hi|(n.get(t)&127)<<s*7+3)>>>0,n.get(t++)<128)return o}throw RangeError("invalid varint encoding")}};var Hn=Math.pow(2,7),Kn=Math.pow(2,14),Qn=Math.pow(2,21),Wn=Math.pow(2,28),Yn=Math.pow(2,35),Zn=Math.pow(2,42),eo=Math.pow(2,49),to=Math.pow(2,56),ro=Math.pow(2,63),J={encodingLength(r){return r<Hn?1:r<Kn?2:r<Qn?3:r<Wn?4:r<Yn?5:r<Zn?6:r<eo?7:r<to?8:r<ro?9:10},encode(r,e,t=0){if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return e==null&&(e=M(J.encodingLength(r))),R.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return R.fromBytes(r,e).toNumber(!0)}};function Ne(r){return r[Symbol.asyncIterator]!=null}var Oe=r=>{let e=J.encodingLength(r),t=M(e);return J.encode(r,t),Oe.bytes=e,t};Oe.bytes=0;function Te(r,e){e=e??{};let t=e.lengthEncoder??Oe;function*n(o){let s=t(o.byteLength);s instanceof Uint8Array?yield s:yield*s,o instanceof Uint8Array?yield o:yield*o}return Ne(r)?async function*(){for await(let o of r)yield*n(o)}():function*(){for(let o of r)yield*n(o)}()}Te.single=(r,e)=>{e=e??{};let t=e.lengthEncoder??Oe;return new L(t(r.byteLength),r)};var ce=ut(Zt(),1);var oo=8,so=1024*1024*4,H;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(H||(H={}));var at=r=>{let e=J.decode(r);return at.bytes=J.encodingLength(e),e};at.bytes=0;function pe(r,e){let t=new L,n=H.LENGTH,o=-1,s=e?.lengthDecoder??at,a=e?.maxLengthLength??oo,i=e?.maxDataLength??so;function*l(){for(;t.byteLength>0;){if(n===H.LENGTH)try{if(o=s(t),o<0)throw(0,ce.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>i)throw(0,ce.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let b=s.bytes;t.consume(b),e?.onLength!=null&&e.onLength(o),n=H.DATA}catch(b){if(b instanceof RangeError){if(t.byteLength>a)throw(0,ce.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw b}if(n===H.DATA){if(t.byteLength<o)break;let b=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(b),yield b,n=H.LENGTH}}}return Ne(r)?async function*(){for await(let b of r)t.append(b),yield*l();if(t.byteLength>0)throw(0,ce.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let b of r)t.append(b),yield*l();if(t.byteLength>0)throw(0,ce.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}pe.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:s,value:a}=await r.next(t);if(s===!0)return;a!=null&&(yield a)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{t=1}}();return pe(n,{...e??{},onLength:s=>{t=s}})};function er(r,...e){if(r==null)throw new Error("Empty pipeline");if(ct(r)){let n=r;r=()=>n.source}else if(rr(r)||tr(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&ct(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)ct(t[n])&&(t[n]=co(t[n]));return ao(...t)}var ao=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},tr=r=>r?.[Symbol.asyncIterator]!=null,rr=r=>r?.[Symbol.iterator]!=null,ct=r=>r==null?!1:r.sink!=null&&r.source!=null,co=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=_({objectMode:!0});t.then(()=>{n.end()},a=>{n.end(a)});let o,s=r.source;if(tr(s))o=async function*(){yield*s,n.end()};else if(rr(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Le(n,o())}return r.source};function nr(r,e="utf8"){let t=Ue[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var uo=ee("libp2p:mss"),or=D(`
`);function K(r){let e=new L(r,or);return Te.single(e)}function Q(r,e,t={}){let n=K(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function sr(r,e,t={}){let n=new L;for(let o of e)n.append(K(o));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function lo(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>r.next(t)},o=n;e?.signal!=null&&(o=Ht(n,e.signal));let s=i=>{t=i},a=await er(o,i=>pe(i,{onLength:s,maxDataLength:1024}),async i=>Kt(i));if(a==null||a.length===0)throw new V("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(a.get(a.byteLength-1)!==or[0])throw uo.error("Invalid mss message - missing newline - %s",a.subarray()),new V("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return a.sublist(0,-1)}async function G(r,e){let t=await lo(r,e);return nr(t.subarray())}var be=ee("libp2p:mss:select");async function ar(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:o,rest:s,stream:a}=ve(r),i=e.shift();if(i==null)throw new Error("At least one protocol must be specified");be.trace('select: write ["%s", "%s"]',I,i);let l=D(I),b=D(i);sr(o,[l,b],t);let c=await G(n,t);if(be.trace('select: read "%s"',c),c===I&&(c=await G(n,t),be.trace('select: read "%s"',c)),c===i)return s(),{stream:a,protocol:i};for(let f of e){be.trace('select: write "%s"',f),Q(o,D(f),t);let p=await G(n,t);if(be.trace('select: read "%s" for "%s"',p,f),p===f)return s(),{stream:a,protocol:f}}throw s(),new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}function cr(r,e){let t=_(),n=!1;return{stream:{sink:async o=>{await r.sink(async function*(){let s=!0;for await(let a of Le(o,t))if(s){s=!1,n=!0,t.end();let i=D(I),l=D(e),b=new L(K(i),K(l));a.length>0&&b.append(a),yield*b}else yield a}())},source:async function*(){n||t.push(new Uint8Array);let o=Ae(r.source),s=await G(o);if(s===I&&(s=await G(o)),s!==e)throw new V("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL");for await(let a of o)yield*a}()},protocol:e}}var me=ee("libp2p:mss:handle");async function fr(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:o,rest:s,stream:a}=ve(r);for(;;){let i=await G(o,t);if(me.trace('read "%s"',i),i===I){me.trace('respond with "%s" for "%s"',I,i),Q(n,D(I),t);continue}if(e.includes(i))return Q(n,D(i),t),me.trace('respond with "%s" for "%s"',i,i),s(),{stream:a,protocol:i};if(i==="ls"){Q(n,new L(...e.map(l=>K(D(l)))),t),me.trace('respond with "%s" for %s',e,i);continue}Q(n,D("na"),t),me('respond with "na" for "%s"',i)}}return br(ho);})();
return Libp2PMultistreamSelect}));
{
"name": "@libp2p/multistream-select",
"version": "3.1.9-42c1c097",
"version": "3.1.9-5315f7bc",
"description": "JavaScript implementation of multistream-select",

@@ -55,4 +55,4 @@ "license": "Apache-2.0 OR MIT",

"dependencies": {
"@libp2p/interface": "0.0.1-42c1c097",
"@libp2p/logger": "2.1.1-42c1c097",
"@libp2p/interface": "0.0.1-5315f7bc",
"@libp2p/logger": "2.1.1-5315f7bc",
"abortable-iterator": "^5.0.1",

@@ -59,0 +59,0 @@ "it-first": "^3.0.1",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc