@libp2p/multistream-select
Advanced tools
Comparing version 3.1.9-ea8a0637 to 3.1.9-eabf6f36
(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 Wt=Object.create;var me=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var Yt=Object.getOwnPropertyNames;var er=Object.getPrototypeOf,tr=Object.prototype.hasOwnProperty;var be=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),L=(r,e)=>{for(var t in e)me(r,t,{get:e[t],enumerable:!0})},nt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Yt(e))!tr.call(r,o)&&o!==t&&me(r,o,{get:()=>e[o],enumerable:!(n=Zt(e,o))||n.enumerable});return r};var ot=(r,e,t)=>(t=r!=null?Wt(er(r)):{},nt(e||!r||!r.__esModule?me(t,"default",{value:r,enumerable:!0}):t,r)),rr=r=>nt(me({},"__esModule",{value:!0}),r);var it=be((Yn,st)=>{var W=1e3,Z=W*60,Y=Z*60,G=Y*24,nr=G*7,or=G*365.25;st.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return sr(r);if(t==="number"&&isFinite(r))return e.long?ar(r):ir(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function sr(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*or;case"weeks":case"week":case"w":return t*nr;case"days":case"day":case"d":return t*G;case"hours":case"hour":case"hrs":case"hr":case"h":return t*Y;case"minutes":case"minute":case"mins":case"min":case"m":return t*Z;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 ir(r){var e=Math.abs(r);return e>=G?Math.round(r/G)+"d":e>=Y?Math.round(r/Y)+"h":e>=Z?Math.round(r/Z)+"m":e>=W?Math.round(r/W)+"s":r+"ms"}function ar(r){var e=Math.abs(r);return e>=G?ge(r,e,G,"day"):e>=Y?ge(r,e,Y,"hour"):e>=Z?ge(r,e,Z,"minute"):e>=W?ge(r,e,W,"second"):r+" ms"}function ge(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ct=be((eo,at)=>{function cr(r){t.debug=t,t.default=t,t.coerce=l,t.disable=s,t.enable=o,t.enabled=i,t.humanize=it(),t.destroy=d,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let c=0;for(let h=0;h<u.length;h++)c=(c<<5)-c+u.charCodeAt(h),c|=0;return t.colors[Math.abs(c)%t.colors.length]}t.selectColor=e;function t(u){let c,h=null,E,p;function f(...m){if(!f.enabled)return;let g=f,x=Number(new Date),O=x-(c||x);g.diff=O,g.prev=c,g.curr=x,c=x,m[0]=t.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let C=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(T,A)=>{if(T==="%%")return"%";C++;let N=t.formatters[A];if(typeof N=="function"){let Q=m[C];T=N.call(g,Q),m.splice(C,1),C--}return T}),t.formatArgs.call(g,m),(g.log||t.log).apply(g,m)}return f.namespace=u,f.useColors=t.useColors(),f.color=t.selectColor(u),f.extend=n,f.destroy=t.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(E!==t.namespaces&&(E=t.namespaces,p=t.enabled(u)),p),set:m=>{h=m}}),typeof t.init=="function"&&t.init(f),f}function n(u,c){let h=t(this.namespace+(typeof c>"u"?":":c)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let c,h=(typeof u=="string"?u:"").split(/[\s,]+/),E=h.length;for(c=0;c<E;c++)h[c]&&(u=h[c].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.slice(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function s(){let u=[...t.names.map(a),...t.skips.map(a).map(c=>"-"+c)].join(",");return t.enable(""),u}function i(u){if(u[u.length-1]==="*")return!0;let c,h;for(c=0,h=t.skips.length;c<h;c++)if(t.skips[c].test(u))return!1;for(c=0,h=t.names.length;c<h;c++)if(t.names[c].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function d(){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}at.exports=cr});var ut=be((v,we)=>{v.formatArgs=fr;v.save=lr;v.load=hr;v.useColors=ur;v.storage=dr();v.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`."))}})();v.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function ur(){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 fr(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+we.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)}v.log=console.debug||console.log||(()=>{});function lr(r){try{r?v.storage.setItem("debug",r):v.storage.removeItem("debug")}catch{}}function hr(){let r;try{r=v.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function dr(){try{return localStorage}catch{}}we.exports=ct()(v);var{formatters:pr}=we.exports;pr.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Vt=be((Rs,zt)=>{"use strict";function Pt(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Pn(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 Pt(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Pt(new o,t)}}zt.exports=Pn});var Xn={};L(Xn,{PROTOCOL_ID:()=>D,handle:()=>Qt,lazySelect:()=>Kt,select:()=>Jt});var D="/multistream/1.0.0";var P=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var S=ot(ut(),1);var Re={};L(Re,{base32:()=>V,base32hex:()=>Ar,base32hexpad:()=>vr,base32hexpadupper:()=>Sr,base32hexupper:()=>Lr,base32pad:()=>Cr,base32padupper:()=>Er,base32upper:()=>xr,base32z:()=>Fr});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),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,l=r.charAt(0),d=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function c(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var f=0,m=0,g=0,x=p.length;g!==x&&p[g]===0;)g++,f++;for(var O=(x-g)*u+1>>>0,C=new Uint8Array(O);g!==x;){for(var R=p[g],T=0,A=O-1;(R!==0||T<m)&&A!==-1;A--,T++)R+=256*C[A]>>>0,C[A]=R%a>>>0,R=R/a>>>0;if(R!==0)throw new Error("Non-zero carry");m=T,g++}for(var N=O-m;N!==O&&C[N]===0;)N++;for(var Q=l.repeat(f);N<O;++N)Q+=r.charAt(C[N]);return Q}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var f=0;if(p[f]!==" "){for(var m=0,g=0;p[f]===l;)m++,f++;for(var x=(p.length-f)*d+1>>>0,O=new Uint8Array(x);p[f];){var C=t[p.charCodeAt(f)];if(C===255)return;for(var R=0,T=x-1;(C!==0||R<g)&&T!==-1;T--,R++)C+=a*O[T]>>>0,O[T]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");g=R,f++}if(p[f]!==" "){for(var A=x-g;A!==x&&O[A]===0;)A++;for(var N=new Uint8Array(m+(x-A)),Q=m;A!==x;)N[Q++]=O[A++];return N}}}function E(p){var f=h(p);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:c,decodeUnsafe:h,decode:E}}var br=mr,gr=br,ft=gr;var ro=new Uint8Array(0);var lt=(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},M=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 ht=r=>new TextEncoder().encode(r),dt=r=>new TextDecoder().decode(r);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")}},Ne=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 mt(this,e)}},De=class{constructor(e){this.decoders=e}or(e){return mt(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`)}},mt=(r,e)=>new De({...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 Ne(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ee=({name:r,prefix:e,encode:t,decode:n})=>new Ie(r,e,t,n),z=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ft(t,e);return ee({prefix:r,name:e,encode:n,decode:s=>M(o(s))})},wr=(r,e,t,n)=>{let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,l=0,d=0;for(let u=0;u<s;++u){let c=o[r[u]];if(c===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<t|c,a+=t,a>=8&&(a-=8,i[d++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return i},yr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let l=0;l<r.length;++l)for(a=a<<8|r[l],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s},b=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>ee({prefix:e,name:r,encode(o){return yr(o,n,t)},decode(o){return wr(o,n,t,r)}});var V=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xr=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cr=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Er=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ar=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Lr=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vr=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Sr=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Fr=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ke={};L(ke,{base58btc:()=>I,base58flickr:()=>Ur});var I=z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ur=z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Be={};L(Be,{base64:()=>Me,base64pad:()=>Or,base64url:()=>Tr,base64urlpad:()=>Nr});var Me=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Or=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Tr=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Nr=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});S.default.formatters.b=r=>r==null?"undefined":I.baseEncode(r);S.default.formatters.t=r=>r==null?"undefined":V.baseEncode(r);S.default.formatters.m=r=>r==null?"undefined":Me.baseEncode(r);S.default.formatters.p=r=>r==null?"undefined":r.toString();S.default.formatters.c=r=>r==null?"undefined":r.toString();S.default.formatters.k=r=>r==null?"undefined":r.toString();S.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 te(r){let e=Dr(`${r}:trace`);return S.default.enabled(`${r}:trace`)&&S.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,S.default)(`${r}:trace`)),Object.assign((0,S.default)(r),{error:(0,S.default)(`${r}:error`),trace:e})}function j(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function B(r=0){return globalThis.Buffer?.alloc!=null?j(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function k(r=0){return globalThis.Buffer?.allocUnsafe!=null?j(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Pe(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=k(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return j(t)}function bt(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 wt=Symbol.for("@achingbrain/uint8arraylist");function gt(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 ye(r){return!!r?.[wt]}var w=class{constructor(...e){Object.defineProperty(this,wt,{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(ye(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(ye(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=gt(this.bufs,e);return t.buf[t.index]}set(e,t){let n=gt(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(ye(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 Pe(n,o)}subarray(e,t){let{bufs:n,length:o}=this._subList(e,t);return n.length===1?n[0]:Pe(n,o)}sublist(e,t){let{bufs:n,length:o}=this._subList(e,t),s=new w;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 i=this.bufs[s],a=o,l=a+i.byteLength;if(o=l,e>=l)continue;let d=e>=a&&e<l,u=t>a&&t<=l;if(d&&u){if(e===a&&t===l){n.push(i);break}let c=e-a;n.push(i.subarray(c,c+(t-e)));break}if(d){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(u){if(t===l){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!ye(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,i=new Int32Array(s);for(let c=0;c<s;c++)i[c]=-1;for(let c=0;c<o;c++)i[n[c]]=c;let a=i,l=this.byteLength-n.byteLength,d=n.byteLength-1,u;for(let c=t;c<=l;c+=u){u=0;for(let h=d;h>=0;h--){let E=this.get(c+h);if(n[h]!==E){u=Math.max(1,h-a[E]);break}}if(u===0)return c}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=k(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=B(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=B(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=B(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=k(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=B(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=B(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=B(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=B(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=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof w)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!bt(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new w;return n.bufs=e,t==null&&(t=e.reduce((o,s)=>o+s.byteLength,0)),n.length=t,n}};function xe(r){let e=async function*(){let t=yield,n=new w;for await(let o of r){if(t==null){n.append(o),t=yield n,n=new w;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 w);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 Ce=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}},re=class{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Ce(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 Ce(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 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,i,a=async()=>n.isEmpty()?i?{done:!0}:await new Promise((f,m)=>{s=g=>{s=null,n.push(g);try{f(r(n))}catch(x){m(x)}return o}}):r(n),l=f=>s!=null?s(f):(n.push(f),o),d=f=>(n=new re,s!=null?s({error:f}):(n.push({error:f}),o)),u=f=>{if(i)return o;if(e?.objectMode!==!0&&f?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:f})},c=f=>i?o:(i=!0,f!=null?d(f):l({done:!0})),h=()=>(n=new re,c(),{done:!0}),E=f=>(c(f),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:h,throw:E,push:u,end:c,get readableLength(){return n.size}},t==null)return o;let p=o;return o={[Symbol.asyncIterator](){return this},next(){return p.next()},throw(f){return p.throw(f),t!=null&&(t(f),t=void 0),{done:!0}},return(){return p.return(),t!=null&&(t(),t=void 0),{done:!0}},push:u,end(f){return p.end(f),t!=null&&(t(f),t=void 0),o},get readableLength(){return p.readableLength}},o}function ze(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}function Ee(r){let e=_(),t=xe(r.source),n=ze(),o,s=r.sink(async function*(){yield*e,yield*await n.promise}());return s.catch(a=>{o=a}),{reader:t,writer:e,stream:{sink:async a=>{if(o!=null){await Promise.reject(o);return}n.resolve(a),await s},source:t},rest:()=>e.end(),write:e.push,read:async()=>{let a=await t.next();if(a.value!=null)return a.value}}}function Rr(r){return r[Symbol.asyncIterator]!=null}function kr(...r){let e=[];for(let t of r)Rr(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 Ae=kr;var Ve={};L(Ve,{identity:()=>Mr});var Mr=ee({prefix:"\0",name:"identity",encode:r=>dt(r),decode:r=>ht(r)});var _e={};L(_e,{base2:()=>Br});var Br=b({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $e={};L($e,{base8:()=>Pr});var Pr=b({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ge={};L(Ge,{base10:()=>zr});var zr=z({prefix:"9",name:"base10",alphabet:"0123456789"});var je={};L(je,{base16:()=>Vr,base16upper:()=>_r});var Vr=b({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_r=b({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var qe={};L(qe,{base36:()=>$r,base36upper:()=>Gr});var $r=z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gr=z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var He={};L(He,{base256emoji:()=>Jr});var yt=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}"),jr=yt.reduce((r,e,t)=>(r[t]=e,r),[]),qr=yt.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Hr(r){return r.reduce((e,t)=>(e+=jr[t],e),"")}function Xr(r){let e=[];for(let t of r){let n=qr[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var Jr=ee({prefix:"\u{1F680}",name:"base256emoji",encode:Hr,decode:Xr});var Qe={};L(Qe,{sha256:()=>pn,sha512:()=>mn});var Kr=Et,xt=128,Qr=127,Wr=~Qr,Zr=Math.pow(2,31);function Et(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Zr;)e[t++]=r&255|xt,r/=128;for(;r&Wr;)e[t++]=r&255|xt,r>>>=7;return e[t]=r|0,Et.bytes=t-n+1,e}var Yr=Xe,en=128,Ct=127;function Xe(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Xe.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Ct)<<o:(i&Ct)*Math.pow(2,o),o+=7}while(i>=en);return Xe.bytes=s-n,t}var tn=Math.pow(2,7),rn=Math.pow(2,14),nn=Math.pow(2,21),on=Math.pow(2,28),sn=Math.pow(2,35),an=Math.pow(2,42),cn=Math.pow(2,49),un=Math.pow(2,56),fn=Math.pow(2,63),ln=function(r){return r<tn?1:r<rn?2:r<nn?3:r<on?4:r<sn?5:r<an?6:r<cn?7:r<un?8:r<fn?9:10},hn={encode:Kr,decode:Yr,encodingLength:ln},dn=hn,ae=dn;var ce=(r,e=0)=>[ae.decode(r,e),ae.decode.bytes],ne=(r,e,t=0)=>(ae.encode(r,e,t),e),oe=r=>ae.encodingLength(r);var q=(r,e)=>{let t=e.byteLength,n=oe(r),o=n+oe(t),s=new Uint8Array(o+t);return ne(r,s,0),ne(t,s,n),s.set(e,o),new se(r,t,e,s)},At=r=>{let e=M(r),[t,n]=ce(e),[o,s]=ce(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new se(t,o,i,e)},Lt=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&<(r.bytes,t.bytes)}},se=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var Ke=({name:r,code:e,encode:t})=>new Je(r,e,t),Je=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?q(this.code,t):t.then(n=>q(this.code,n))}else throw Error("Unknown type, must be binary type")}};var St=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),pn=Ke({name:"sha2-256",code:18,encode:St("SHA-256")}),mn=Ke({name:"sha2-512",code:19,encode:St("SHA-512")});var We={};L(We,{identity:()=>wn});var Ft=0,bn="identity",Ut=M,gn=r=>q(Ft,Ut(r)),wn={code:Ft,name:bn,encode:Ut,digest:gn};var Wo=new TextEncoder,Zo=new TextDecoder;var Ot=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return En(t,Ze(r),e||I.encoder);default:return An(t,Ze(r),e||V.encoder)}};var Tt=new WeakMap,Ze=r=>{let e=Tt.get(r);if(e==null){let t=new Map;return Tt.set(r,t),t}return e},y=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!==fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Ln)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return y.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=q(e,t);return y.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 y.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Lt(e.multihash,n.multihash)}toString(e){return Ot(this,e)}toJSON(){return{"/":Ot(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 y)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new y(n,o,s,i||Nt(n,o,s.bytes))}else if(t[vn]===!0){let{version:n,multihash:o,code:s}=t,i=At(o);return y.create(n,s,i)}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!==fe)throw new Error(`Version 0 CID must use dag-pb (code: ${fe}) block encoding`);return new y(e,t,n,n.bytes)}case 1:{let o=Nt(e,t,n.bytes);return new y(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return y.create(0,fe,e)}static createV1(e,t){return y.create(1,e,t)}static decode(e){let[t,n]=y.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=y.inspectBytes(e),n=t.size-t.multihashSize,o=M(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new se(t.multihashCode,t.digestSize,s,o);return[t.version===0?y.createV0(i):y.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[c,h]=ce(e.subarray(t));return t+=h,c},o=n(),s=fe;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),l=n(),d=t+l,u=d-i;return{version:o,codec:s,multihashCode:a,digestSize:l,multihashSize:u,size:d}}static parse(e,t){let[n,o]=Cn(e,t),s=y.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ze(s).set(n,e),s}},Cn=(r,e)=>{switch(r[0]){case"Q":{let t=e||I;return[I.prefix,t.decode(`${I.prefix}${r}`)]}case I.prefix:{let t=e||I;return[I.prefix,t.decode(r)]}case V.prefix:{let t=e||V;return[V.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)]}}},En=(r,e,t)=>{let{prefix:n}=t;if(n!==I.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},An=(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},fe=112,Ln=18,Nt=(r,e,t)=>{let n=oe(r),o=n+oe(e),s=new Uint8Array(o+t.byteLength);return ne(r,s,0),ne(e,s,n),s.set(t,o),s},vn=Symbol.for("@ipld/js-cid/CID");var Ye={...Ve,..._e,...$e,...Ge,...je,...Re,...qe,...ke,...Be,...He},cs={...Qe,...We};function It(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Dt=It("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),et=It("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=k(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Sn={utf8:Dt,"utf-8":Dt,hex:Ye.base16,latin1:et,ascii:et,binary:et,...Ye},ve=Sn;function F(r,e="utf8"){let t=ve[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?j(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var le=class extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Rt(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 kt(r,e,t){let n=t??{},o=Rt(r);async function*s(){let i,a=()=>{i?.()};for(e.addEventListener("abort",a);;){let l;try{if(e.aborted){let{abortMessage:u,abortCode:c}=n;throw new le(u,c)}let d=new Promise((u,c)=>{i=()=>{let{abortMessage:h,abortCode:E}=n;c(new le(h,E))}});l=await Promise.race([d,o.next()]),i=null}catch(d){e.removeEventListener("abort",a);let u=d.type==="aborted"&&e.aborted;if(u&&n.onAbort!=null&&n.onAbort(r),typeof o.return=="function")try{let c=o.return();c instanceof Promise&&c.catch(h=>{n.onReturnError!=null&&n.onReturnError(h)})}catch(c){n.onReturnError!=null&&n.onReturnError(c)}if(u&&n.returnOnAbort===!0)return;throw d}if(l.done===!0)break;yield l.value}e.removeEventListener("abort",a)}return s()}function Fn(r){return r[Symbol.asyncIterator]!=null}function Un(r){if(Fn(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Mt=Un;function Se(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 Bt=4294967296,U=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 U(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 U(t,n)}toBytes(e,t=0){let n=Se(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 U;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>Bt&&(o=0,++n>Bt&&(n=0))),new U(n,o)}static fromNumber(e){if(e===0)return new U;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 U(o,n)}static fromBytes(e,t=0){let n=Se(e),o=new U,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 On=Math.pow(2,7),Tn=Math.pow(2,14),Nn=Math.pow(2,21),Dn=Math.pow(2,28),In=Math.pow(2,35),Rn=Math.pow(2,42),kn=Math.pow(2,49),Mn=Math.pow(2,56),Bn=Math.pow(2,63),H={encodingLength(r){return r<On?1:r<Tn?2:r<Nn?3:r<Dn?4:r<In?5:r<Rn?6:r<kn?7:r<Mn?8:r<Bn?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=k(H.encodingLength(r))),U.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return U.fromBytes(r,e).toNumber(!0)}};function Fe(r){return r[Symbol.asyncIterator]!=null}var Ue=r=>{let e=H.encodingLength(r),t=k(e);return H.encode(r,t),Ue.bytes=e,t};Ue.bytes=0;function Oe(r,e){e=e??{};let t=e.lengthEncoder??Ue;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??Ue;return new w(t(r.byteLength),r)};var ie=ot(Vt(),1);var zn=8,Vn=1024*1024*4,X;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(X||(X={}));var tt=r=>{let e=H.decode(r);return tt.bytes=H.encodingLength(e),e};tt.bytes=0;function he(r,e){let t=new w,n=X.LENGTH,o=-1,s=e?.lengthDecoder??tt,i=e?.maxLengthLength??zn,a=e?.maxDataLength??Vn;function*l(){for(;t.byteLength>0;){if(n===X.LENGTH)try{if(o=s(t),o<0)throw(0,ie.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>a)throw(0,ie.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let d=s.bytes;t.consume(d),e?.onLength!=null&&e.onLength(o),n=X.DATA}catch(d){if(d instanceof RangeError){if(t.byteLength>i)throw(0,ie.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw d}if(n===X.DATA){if(t.byteLength<o)break;let d=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(d),yield d,n=X.LENGTH}}}return Fe(r)?async function*(){for await(let d of r)t.append(d),yield*l();if(t.byteLength>0)throw(0,ie.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let d of r)t.append(d),yield*l();if(t.byteLength>0)throw(0,ie.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}he.fromReader=(r,e)=>{let t=1,n=async function*(){for(;;)try{let{done:s,value:i}=await r.next(t);if(s===!0)return;i!=null&&(yield i)}catch(s){if(s.code==="ERR_UNDER_READ")return{done:!0,value:null};throw s}finally{t=1}}();return he(n,{...e??{},onLength:s=>{t=s}})};function _t(r,...e){if(r==null)throw new Error("Empty pipeline");if(rt(r)){let n=r;r=()=>n.source}else if(Gt(r)||$t(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&rt(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++)rt(t[n])&&(t[n]=Gn(t[n]));return $n(...t)}var $n=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},$t=r=>r?.[Symbol.asyncIterator]!=null,Gt=r=>r?.[Symbol.iterator]!=null,rt=r=>r==null?!1:r.sink!=null&&r.source!=null,Gn=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=_({objectMode:!0});t.then(()=>{n.end()},i=>{n.end(i)});let o,s=r.source;if($t(s))o=async function*(){yield*s,n.end()};else if(Gt(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Ae(n,o())}return r.source};function jt(r,e="utf8"){let t=ve[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 qn=te("libp2p:mss"),qt=F(` | ||
`);function J(r){let e=new w(r,qt);return Oe.single(e)}function K(r,e,t={}){let n=J(e);t.writeBytes===!0?r.push(n.subarray()):r.push(n)}function Ht(r,e,t={}){let n=new w;for(let o of e)n.append(J(o));t.writeBytes===!0?r.push(n.subarray()):r.push(n)}async function Hn(r,e){let t=1,n={[Symbol.asyncIterator]:()=>n,next:async()=>r.next(t)},o=n;e?.signal!=null&&(o=kt(n,e.signal));let s=a=>{t=a},i=await _t(o,a=>he(a,{onLength:s,maxDataLength:1024}),async a=>Mt(a));if(i==null||i.length===0)throw new P("no buffer returned","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(i.get(i.byteLength-1)!==qt[0])throw qn.error("Invalid mss message - missing newline - %s",i.subarray()),new P("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return i.sublist(0,-1)}async function $(r,e){let t=await Hn(r,e);return jt(t.subarray())}var de=te("libp2p:mss:select");async function Jt(r,e,t={}){e=Array.isArray(e)?[...e]:[e];let{reader:n,writer:o,rest:s,stream:i}=Ee(r),a=e.shift();if(a==null)throw new Error("At least one protocol must be specified");de.trace('select: write ["%s", "%s"]',D,a);let l=F(D),d=F(a);Ht(o,[l,d],t);let u=await $(n,t);if(de.trace('select: read "%s"',u),u===D&&(u=await $(n,t),de.trace('select: read "%s"',u)),u===a)return s(),{stream:i,protocol:a};for(let c of e){de.trace('select: write "%s"',c),K(o,F(c),t);let h=await $(n,t);if(de.trace('select: read "%s" for "%s"',h,c),h===c)return s(),{stream:i,protocol:c}}throw s(),new P("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}function Kt(r,e){let t=_(),n=!1;return{stream:{sink:async o=>{await r.sink(async function*(){let s=!0;for await(let i of Ae(o,t))if(s){s=!1,n=!0,t.end();let a=F(D),l=F(e),d=new w(J(a),J(l));i.length>0&&d.append(i),yield*d}else yield i}())},source:async function*(){n||t.push(new Uint8Array);let o=xe(r.source),s=await $(o);if(s===D&&(s=await $(o)),s!==e)throw new P("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL");for await(let i of o)yield*i}()},protocol:e}}var pe=te("libp2p:mss:handle");async function Qt(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:o,rest:s,stream:i}=Ee(r);for(;;){let a=await $(o,t);if(pe.trace('read "%s"',a),a===D){pe.trace('respond with "%s" for "%s"',D,a),K(n,F(D),t);continue}if(e.includes(a))return K(n,F(a),t),pe.trace('respond with "%s" for "%s"',a,a),s(),{stream:i,protocol:a};if(a==="ls"){K(n,new w(...e.map(l=>J(F(l)))),t),pe.trace('respond with "%s" for %s',e,a);continue}K(n,F("na"),t),pe('respond with "na" for "%s"',a)}}return rr(Xn);})(); | ||
"use strict";var Libp2PMultistreamSelect=(()=>{var ur=Object.create;var me=Object.defineProperty;var lr=Object.getOwnPropertyDescriptor;var hr=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,pr=Object.prototype.hasOwnProperty;var ge=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),F=(r,e)=>{for(var t in e)me(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&&me(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?me(t,"default",{value:r,enumerable:!0}):t,r)),br=r=>ft(me({},"__esModule",{value:!0}),r);var ht=ge((go,lt)=>{var K=1e3,Q=K*60,W=Q*60,$=W*24,mr=$*7,gr=$*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*$;case"hours":case"hour":case"hrs":case"hr":case"h":return t*W;case"minutes":case"minute":case"mins":case"min":case"m":return t*Q;case"seconds":case"second":case"secs":case"sec":case"s":return t*K;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function yr(r){var e=Math.abs(r);return e>=$?Math.round(r/$)+"d":e>=W?Math.round(r/W)+"h":e>=Q?Math.round(r/Q)+"m":e>=K?Math.round(r/K)+"s":r+"ms"}function xr(r){var e=Math.abs(r);return e>=$?we(r,e,$,"day"):e>=W?we(r,e,W,"hour"):e>=Q?we(r,e,Q,"minute"):e>=K?we(r,e,K,"second"):r+" ms"}function we(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var pt=ge((wo,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,S,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 I=h[w];v=A.call(m,I),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:(S!==t.namespaces&&(S=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,]+/),S=p.length;for(f=0;f<S;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=ge((D,ye)=>{D.formatArgs=Er;D.save=vr;D.load=Lr;D.useColors=Ar;D.storage=Sr();D.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`."))}})();D.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 ":" ")+"+"+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)}D.log=console.debug||console.log||(()=>{});function vr(r){try{r?D.storage.setItem("debug",r):D.storage.removeItem("debug")}catch{}}function Lr(){let r;try{r=D.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Sr(){try{return localStorage}catch{}}ye.exports=pt()(D);var{formatters:Ur}=ye.exports;Ur.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Zt=ge((Ai,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={};F(ho,{PROTOCOL_ID:()=>T,handle:()=>fr,lazySelect:()=>cr,select:()=>ar});var T="/multistream/1.0.0";var P=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var N=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 I=l.repeat(d);A<y;++A)I+=r.charAt(w[A]);return I}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)),I=h;x!==g;)A[I++]=y[x++];return A}}}function S(u){var d=p(u);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:p,decode:S}}var Dr=Fr,Nr=Dr,mt=Nr;var xo=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 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")}},Ie=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)}},Re=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 Re({...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 Te(e,t,n),this.decoder=new Ie(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),Be=({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))})},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,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},Tr=(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},U=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>yt({prefix:e,name:r,encode(o){return Tr(o,n,t)},decode(o){return Or(o,n,t,r)}});var xt=U({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),So=U({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Uo=U({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fo=U({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Do=U({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),No=U({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Oo=U({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),To=U({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Io=U({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ct=Be({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bo=Be({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var At=U({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zo=U({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Vo=U({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_o=U({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});N.default.formatters.b=r=>r==null?"undefined":Ct.baseEncode(r);N.default.formatters.t=r=>r==null?"undefined":xt.baseEncode(r);N.default.formatters.m=r=>r==null?"undefined":At.baseEncode(r);N.default.formatters.p=r=>r==null?"undefined":r.toString();N.default.formatters.c=r=>r==null?"undefined":r.toString();N.default.formatters.k=r=>r==null?"undefined":r.toString();N.default.formatters.a=r=>r==null?"undefined":r.toString();function Ir(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 Y(r){let e=Ir(`${r}:trace`);return N.default.enabled(`${r}:trace`)&&N.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,N.default)(`${r}:trace`)),Object.assign((0,N.default)(r),{error:(0,N.default)(`${r}:error`),trace:e})}function G(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function B(r=0){return globalThis.Buffer?.alloc!=null?G(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function R(r=0){return globalThis.Buffer?.allocUnsafe!=null?G(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Me(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=R(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return G(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 xe(r){return!!r?.[Lt]}var L=class r{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(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=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(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 r;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(!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,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 S=this.get(f+p);if(n[p]!==S){c=Math.max(1,p-i[S]);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=R(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=B(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=B(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=B(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=R(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=B(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=B(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=B(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=B(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=B(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,t,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof r)||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 r;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}function Z(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ae=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}},ee=class{size;hwm;head;tail;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()}};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 z(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 ee,o,s,a,i=Z(),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=Z()})}},b=h=>s!=null?s(h):(n.push(h),o),c=h=>(n=new ee,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})),S=()=>(n=new ee,p(),{done:!0}),u=h=>(p(h),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:l,return:S,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 Ee(r){let e=z(),t=Ce(r.source),n=Z(),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 Br(...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=z({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=Br;var Ge={};F(Ge,{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,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 I=l.repeat(d);A<y;++A)I+=r.charAt(w[A]);return I}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)),I=h;x!==g;)A[I++]=y[x++];return A}}}function S(u){var d=p(u);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:p,decode:S}}var Pr=Mr,zr=Pr,St=zr;var ws=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},M=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),Dt=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 Ot(this,e)}},_e=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 _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)}},te=({name:r,prefix:e,encode:t,decode:n})=>new $e(r,e,t,n),V=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=St(t,e);return te({prefix:r,name:e,encode:n,decode:s=>M(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})=>te({prefix:e,name:r,encode(o){return _r(o,n,t)},decode(o){return Vr(o,n,t,r)}});var $r=te({prefix:"\0",name:"identity",encode:r=>Dt(r),decode:r=>Ft(r)});var je={};F(je,{base2:()=>Gr});var Gr=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qe={};F(qe,{base8:()=>jr});var jr=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xe={};F(Xe,{base10:()=>qr});var qr=V({prefix:"9",name:"base10",alphabet:"0123456789"});var Je={};F(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={};F(He,{base32:()=>re,base32hex:()=>Wr,base32hexpad:()=>Zr,base32hexpadupper:()=>en,base32hexupper:()=>Yr,base32pad:()=>Kr,base32padupper:()=>Qr,base32upper:()=>Hr,base32z:()=>tn});var re=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={};F(Ke,{base36:()=>rn,base36upper:()=>nn});var rn=V({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nn=V({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Qe={};F(Qe,{base58btc:()=>k,base58flickr:()=>on});var k=V({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),on=V({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var We={};F(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={};F(Ye,{base256emoji:()=>pn});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}"),un=Tt.reduce((r,e,t)=>(r[t]=e,r),[]),ln=Tt.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=te({prefix:"\u{1F680}",name:"base256emoji",encode:hn,decode:dn});var rt={};F(rt,{sha256:()=>In,sha512:()=>Rn});var bn=kt,It=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|It,r/=128;for(;r&gn;)e[t++]=r&255|It,r>>>=7;return e[t]=r|0,kt.bytes=t-n+1,e}var yn=Ze,xn=128,Rt=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&Rt)<<o:(a&Rt)*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),Dn=Math.pow(2,63),Nn=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<Dn?9:10},On={encode:bn,decode:yn,encodingLength:Nn},Tn=On,ae=Tn;var ce=(r,e=0)=>[ae.decode(r,e),ae.decode.bytes],ne=(r,e,t=0)=>(ae.encode(r,e,t),e),oe=r=>ae.encodingLength(r);var j=(r,e)=>{let t=e.byteLength,n=oe(r),o=n+oe(t),s=new Uint8Array(o+t);return ne(r,s,0),ne(t,s,n),s.set(e,o),new se(r,t,e,s)},Bt=r=>{let e=M(r),[t,n]=ce(e),[o,s]=ce(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new se(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&&Ut(r.bytes,t.bytes)}},se=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?j(this.code,t):t.then(n=>j(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)),In=tt({name:"sha2-256",code:18,encode:zt("SHA-256")}),Rn=tt({name:"sha2-512",code:19,encode:zt("SHA-512")});var nt={};F(nt,{identity:()=>Mn});var Vt=0,kn="identity",_t=M,Bn=r=>j(Vt,_t(r)),Mn={code:Vt,name:kn,encode:_t,digest:Bn};var zs=new TextEncoder,Vs=new TextDecoder;var $t=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return _n(t,ot(r),e||k.encoder);default:return $n(t,ot(r),e||re.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},Se=class r{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!==ue)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 r.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=j(e,t);return r.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 r.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 r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new r(n,o,s,a||jt(n,o,s.bytes))}else if(t[jn]===!0){let{version:n,multihash:o,code:s}=t,a=Bt(o);return r.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!==ue)throw new Error(`Version 0 CID must use dag-pb (code: ${ue}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=jt(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ue,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=M(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 se(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(a):r.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,p]=ce(e.subarray(t));return t+=p,f},o=n(),s=ue;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=r.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||k;return[k.prefix,t.decode(`${k.prefix}${r}`)]}case k.prefix:{let t=e||k;return[k.prefix,t.decode(r)]}case re.prefix:{let t=e||re;return[re.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!==k.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},ue=112,Gn=18,jt=(r,e,t)=>{let n=oe(r),o=n+oe(e),s=new Uint8Array(o+t.byteLength);return ne(r,s,0),ne(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},Qs={...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=R(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 O(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?G(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var le=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 le(c,f)}let b=new Promise((c,f)=>{a=()=>{let{abortMessage:p,abortCode:S}=n;f(new le(p,S))}});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,he=class r{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),q={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=R(q.encodingLength(r))),he.fromNumber(r).toBytes(e,t),e},decode(r,e=0){return he.fromBytes(r,e).toNumber(!0)}};function De(r){return r[Symbol.asyncIterator]!=null}var Ne=r=>{let e=q.encodingLength(r),t=R(e);return q.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 De(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 ie=ut(Zt(),1);var oo=8,so=1024*1024*4,X;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(X||(X={}));var at=r=>{let e=q.decode(r);return at.bytes=q.encodingLength(e),e};at.bytes=0;function de(r,e){let t=new L,n=X.LENGTH,o=-1,s=e?.lengthDecoder??at,a=e?.maxLengthLength??oo,i=e?.maxDataLength??so;function*l(){for(;t.byteLength>0;){if(n===X.LENGTH)try{if(o=s(t),o<0)throw(0,ie.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>i)throw(0,ie.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=X.DATA}catch(b){if(b instanceof RangeError){if(t.byteLength>a)throw(0,ie.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw b}if(n===X.DATA){if(t.byteLength<o)break;let b=t.sublist(0,o);t.consume(o),e?.onData!=null&&e.onData(b),yield b,n=X.LENGTH}}}return De(r)?async function*(){for await(let b of r)t.append(b),yield*l();if(t.byteLength>0)throw(0,ie.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,ie.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 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=z({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 ve(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=Y("libp2p:mss"),or=O(` | ||
`);function J(r){let e=new L(r,or);return Oe.single(e)}function H(r,e,t={}){let n=J(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(J(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=>de(i,{onLength:s,maxDataLength:1024}),async i=>Kt(i));if(a==null||a.length===0)throw new P("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 P("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return a.sublist(0,-1)}async function _(r,e){let t=await lo(r,e);return nr(t.subarray())}var pe=Y("libp2p:mss:select");async function ar(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"]',T,i);let l=O(T),b=O(i);sr(o,[l,b],t);let c=await _(n,t);if(pe.trace('select: read "%s"',c),c===T&&(c=await _(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),H(o,O(f),t);let p=await _(n,t);if(pe.trace('select: read "%s" for "%s"',p,f),p===f)return s(),{stream:a,protocol:f}}throw s(),new P("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}function cr(r,e){let t=z(),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=O(T),l=O(e),b=new L(J(i),J(l));a.length>0&&b.append(a),yield*b}else yield a}())},source:async function*(){n||t.push(new Uint8Array);let o=Ce(r.source),s=await _(o);if(s===T&&(s=await _(o)),s!==e)throw new P("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL");for await(let a of o)yield*a}()},protocol:e}}var be=Y("libp2p:mss:handle");async function fr(r,e,t){e=Array.isArray(e)?e:[e];let{writer:n,reader:o,rest:s,stream:a}=Ee(r);for(;;){let i=await _(o,t);if(be.trace('read "%s"',i),i===T){be.trace('respond with "%s" for "%s"',T,i),H(n,O(T),t);continue}if(e.includes(i))return H(n,O(i),t),be.trace('respond with "%s" for "%s"',i,i),s(),{stream:a,protocol:i};if(i==="ls"){H(n,new L(...e.map(l=>J(O(l)))),t),be.trace('respond with "%s" for %s',e,i);continue}H(n,O("na"),t),be('respond with "na" for "%s"',i)}}return br(ho);})(); | ||
return Libp2PMultistreamSelect})); |
import { PROTOCOL_ID } from './constants.js'; | ||
import type { AbortOptions } from '@libp2p/interfaces'; | ||
import type { AbortOptions } from '@libp2p/interface'; | ||
import type { Duplex, Source } from 'it-stream-types'; | ||
@@ -4,0 +4,0 @@ export { PROTOCOL_ID }; |
import { Uint8ArrayList } from 'uint8arraylist'; | ||
import type { MultistreamSelectInit } from '.'; | ||
import type { AbortOptions } from '@libp2p/interfaces'; | ||
import type { AbortOptions } from '@libp2p/interface'; | ||
import type { Pushable } from 'it-pushable'; | ||
@@ -5,0 +5,0 @@ import type { Reader } from 'it-reader'; |
@@ -1,2 +0,2 @@ | ||
import { CodeError } from '@libp2p/interfaces/errors'; | ||
import { CodeError } from '@libp2p/interface/errors'; | ||
import { logger } from '@libp2p/logger'; | ||
@@ -3,0 +3,0 @@ import { abortableSource } from 'abortable-iterator'; |
@@ -1,2 +0,2 @@ | ||
import { CodeError } from '@libp2p/interfaces/errors'; | ||
import { CodeError } from '@libp2p/interface/errors'; | ||
import { logger } from '@libp2p/logger'; | ||
@@ -3,0 +3,0 @@ import { handshake } from 'it-handshake'; |
{ | ||
"name": "@libp2p/multistream-select", | ||
"version": "3.1.9-ea8a0637", | ||
"version": "3.1.9-eabf6f36", | ||
"description": "JavaScript implementation of multistream-select", | ||
@@ -55,4 +55,4 @@ "license": "Apache-2.0 OR MIT", | ||
"dependencies": { | ||
"@libp2p/interfaces": "3.3.2-ea8a0637", | ||
"@libp2p/logger": "2.1.1-ea8a0637", | ||
"@libp2p/interface": "0.0.1-eabf6f36", | ||
"@libp2p/logger": "2.1.1-eabf6f36", | ||
"abortable-iterator": "^5.0.1", | ||
@@ -64,11 +64,11 @@ "it-first": "^3.0.1", | ||
"it-pipe": "^3.0.1", | ||
"it-pushable": "^3.1.3", | ||
"it-pushable": "^3.2.0", | ||
"it-reader": "^6.0.1", | ||
"it-stream-types": "^2.0.1", | ||
"uint8arraylist": "^2.4.3", | ||
"uint8arrays": "^4.0.3" | ||
"uint8arrays": "^4.0.4" | ||
}, | ||
"devDependencies": { | ||
"@types/varint": "^6.0.0", | ||
"aegir": "^39.0.10", | ||
"aegir": "^40.0.1", | ||
"iso-random-stream": "^2.0.2", | ||
@@ -80,6 +80,3 @@ "it-all": "^3.0.1", | ||
"varint": "^6.0.0" | ||
}, | ||
"typedoc": { | ||
"entryPoint": "./src/index.ts" | ||
} | ||
} |
@@ -45,11 +45,13 @@ # @libp2p/multistream-select <!-- omit in toc --> | ||
< /multistream-select/0.3.0 # i speak multistream-select/0.3.0 | ||
> /multistream-select/0.3.0 # ok, let's speak multistream-select/0.3.0 | ||
> /ipfs-dht/0.2.3 # i want to speak ipfs-dht/0.2.3 | ||
< na # ipfs-dht/0.2.3 is not available | ||
> /ipfs-dht/0.1.9 # What about ipfs-dht/0.1.9 ? | ||
< /ipfs-dht/0.1.9 # ok let's speak ipfs-dht/0.1.9 -- in a sense acts as an ACK | ||
> <dht-message> | ||
> <dht-message> | ||
> <dht-message> | ||
``` | ||
< /multistream-select/0.3.0 # i speak multistream-select/0.3.0 | ||
> /multistream-select/0.3.0 # ok, let's speak multistream-select/0.3.0 | ||
> /ipfs-dht/0.2.3 # i want to speak ipfs-dht/0.2.3 | ||
< na # ipfs-dht/0.2.3 is not available | ||
> /ipfs-dht/0.1.9 # What about ipfs-dht/0.1.9 ? | ||
< /ipfs-dht/0.1.9 # ok let's speak ipfs-dht/0.1.9 -- in a sense acts as an ACK | ||
> <dht-message> | ||
> <dht-message> | ||
> <dht-message> | ||
``` | ||
@@ -56,0 +58,0 @@ ## API Docs |
@@ -1,2 +0,1 @@ | ||
export const PROTOCOL_ID = '/multistream/1.0.0' | ||
@@ -3,0 +2,0 @@ |
import { PROTOCOL_ID } from './constants.js' | ||
import type { AbortOptions } from '@libp2p/interfaces' | ||
import type { AbortOptions } from '@libp2p/interface' | ||
import type { Duplex, Source } from 'it-stream-types' | ||
@@ -4,0 +4,0 @@ |
@@ -1,3 +0,2 @@ | ||
import { CodeError } from '@libp2p/interfaces/errors' | ||
import { CodeError } from '@libp2p/interface/errors' | ||
import { logger } from '@libp2p/logger' | ||
@@ -13,3 +12,3 @@ import { abortableSource } from 'abortable-iterator' | ||
import type { MultistreamSelectInit } from '.' | ||
import type { AbortOptions } from '@libp2p/interfaces' | ||
import type { AbortOptions } from '@libp2p/interface' | ||
import type { Pushable } from 'it-pushable' | ||
@@ -16,0 +15,0 @@ import type { Reader } from 'it-reader' |
@@ -1,2 +0,2 @@ | ||
import { CodeError } from '@libp2p/interfaces/errors' | ||
import { CodeError } from '@libp2p/interface/errors' | ||
import { logger } from '@libp2p/logger' | ||
@@ -3,0 +3,0 @@ import { handshake } from 'it-handshake' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
98629
887
71
+ Added@libp2p/interface@0.0.1-eabf6f36(transitive)
+ Added@libp2p/logger@2.1.1-eabf6f36(transitive)
- Removed@libp2p/interfaces@3.3.2-ea8a0637
- Removed@libp2p/interface-peer-id@2.0.2-ea8a0637(transitive)
- Removed@libp2p/interfaces@3.3.2-ea8a0637(transitive)
- Removed@libp2p/logger@2.1.1-ea8a0637(transitive)
- Removedmultiformats@11.0.2(transitive)
Updatedit-pushable@^3.2.0
Updateduint8arrays@^4.0.4