@libp2p/websockets 6.0.3-b1024c6c → 6.0.3-c999d6a7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PWebsockets = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PWebsockets=(()=>{var Ho=Object.create;var Pe=Object.defineProperty;var Xo=Object.getOwnPropertyDescriptor;var Ko=Object.getOwnPropertyNames;var Zo=Object.getPrototypeOf,Yo=Object.prototype.hasOwnProperty;var es=(t,e,r)=>e in t?Pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var R=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),P=(t,e)=>{for(var r in e)Pe(t,r,{get:e[r],enumerable:!0})},Tr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ko(e))!Yo.call(t,o)&&o!==r&&Pe(t,o,{get:()=>e[o],enumerable:!(n=Xo(e,o))||n.enumerable});return t};var ee=(t,e,r)=>(r=t!=null?Ho(Zo(t)):{},Tr(e||!t||!t.__esModule?Pe(r,"default",{value:t,enumerable:!0}):r,t)),ts=t=>Tr(Pe({},"__esModule",{value:!0}),t);var $e=(t,e,r)=>(es(t,typeof e!="symbol"?e+"":e,r),r);var Or=R((Xc,Nr)=>{var ce=1e3,ue=ce*60,pe=ue*60,re=pe*24,rs=re*7,ns=re*365.25;Nr.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return os(t);if(r==="number"&&isFinite(t))return e.long?is(t):ss(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function os(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*ns;case"weeks":case"week":case"w":return r*rs;case"days":case"day":case"d":return r*re;case"hours":case"hour":case"hrs":case"hr":case"h":return r*pe;case"minutes":case"minute":case"mins":case"min":case"m":return r*ue;case"seconds":case"second":case"secs":case"sec":case"s":return r*ce;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function ss(t){var e=Math.abs(t);return e>=re?Math.round(t/re)+"d":e>=pe?Math.round(t/pe)+"h":e>=ue?Math.round(t/ue)+"m":e>=ce?Math.round(t/ce)+"s":t+"ms"}function is(t){var e=Math.abs(t);return e>=re?qe(t,e,re,"day"):e>=pe?qe(t,e,pe,"hour"):e>=ue?qe(t,e,ue,"minute"):e>=ce?qe(t,e,ce,"second"):t+" ms"}function qe(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var kr=R((Kc,Lr)=>{function as(t){r.debug=r,r.default=r,r.coerce=d,r.disable=s,r.enable=o,r.enabled=i,r.humanize=Or(),r.destroy=g,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let p=0;for(let m=0;m<c.length;m++)p=(p<<5)-p+c.charCodeAt(m),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=e;function r(c){let p,m=null,I,u;function l(...v){if(!l.enabled)return;let b=l,x=Number(new Date),C=x-(p||x);b.diff=C,b.prev=p,b.curr=x,p=x,v[0]=r.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let w=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(U,y)=>{if(U==="%%")return"%";w++;let A=r.formatters[y];if(typeof A=="function"){let k=v[w];U=A.call(b,k),v.splice(w,1),w--}return U}),r.formatArgs.call(b,v),(b.log||r.log).apply(b,v)}return l.namespace=c,l.useColors=r.useColors(),l.color=r.selectColor(c),l.extend=n,l.destroy=r.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(I!==r.namespaces&&(I=r.namespaces,u=r.enabled(c)),u),set:v=>{m=v}}),typeof r.init=="function"&&r.init(l),l}function n(c,p){let m=r(this.namespace+(typeof p>"u"?":":p)+c);return m.log=this.log,m}function o(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let p,m=(typeof c=="string"?c:"").split(/[\s,]+/),I=m.length;for(p=0;p<I;p++)m[p]&&(c=m[p].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...r.names.map(a),...r.skips.map(a).map(p=>"-"+p)].join(",");return r.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let p,m;for(p=0,m=r.skips.length;p<m;p++)if(r.skips[p].test(c))return!1;for(p=0,m=r.names.length;p<m;p++)if(r.names[p].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function d(c){return c instanceof Error?c.stack||c.message:c}function g(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}Lr.exports=as});var Dr=R((B,je)=>{B.formatArgs=us;B.save=ps;B.load=fs;B.useColors=cs;B.storage=ds();B.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();B.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 cs(){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 us(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+je.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}B.log=console.debug||console.log||(()=>{});function ps(t){try{t?B.storage.setItem("debug",t):B.storage.removeItem("debug")}catch{}}function fs(){let t;try{t=B.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function ds(){try{return localStorage}catch{}}je.exports=kr()(B);var{formatters:ls}=je.exports;ls.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Pn=R((Lp,Un)=>{Un.exports=jt;var An=128,fa=127,da=~fa,la=Math.pow(2,31);function jt(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw jt.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=la;)e[r++]=t&255|An,t/=128;for(;t&da;)e[r++]=t&255|An,t>>>=7;return e[r]=t|0,jt.bytes=r-n+1,e}});var Fn=R((kp,In)=>{In.exports=Qt;var ha=128,Tn=127;function Qt(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a||o>49)throw Qt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Tn)<<o:(i&Tn)*Math.pow(2,o),o+=7}while(i>=ha);return Qt.bytes=s-n,r}});var On=R((Dp,Nn)=>{var ma=Math.pow(2,7),ba=Math.pow(2,14),wa=Math.pow(2,21),ga=Math.pow(2,28),xa=Math.pow(2,35),ya=Math.pow(2,42),va=Math.pow(2,49),Ca=Math.pow(2,56),Ea=Math.pow(2,63);Nn.exports=function(t){return t<ma?1:t<ba?2:t<wa?3:t<ga?4:t<xa?5:t<ya?6:t<va?7:t<Ca?8:t<Ea?9:10}});var Ze=R((Mp,Ln)=>{Ln.exports={encode:Pn(),decode:Fn(),encodingLength:On()}});var co=R(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});var br=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let r={value:e,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(r)}else this.pushQueue.push(Promise.resolve(r)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let r of this.pullQueue)r.reject(e);this.pullQueue.length=0}else{let r=Promise.reject(e);r.catch(()=>{}),this.pushQueue.push(r)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let r=this.pushQueue.shift();return r?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),r):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},st=class{constructor(e,{highWaterMark:r=100,lowWaterMark:n=1}={}){let o=new br;o.highWaterMark=r,o.lowWaterMark=n,o.removeCallback=e({push:s=>o.push(s),stop:()=>o.stop(),fail:s=>o.fail(s),on:(s,i)=>{o.eventHandlers[s]=i}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}};it.EventIterator=st;it.default=st});var uo=R(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});var wr=co();ze.EventIterator=wr.EventIterator;function vc(t,e,r){return new wr.EventIterator(({push:n})=>(this.addEventListener(t,n,e),()=>this.removeEventListener(t,n,e)),r)}ze.subscribe=vc;ze.default=wr.EventIterator});var xr=R((zd,go)=>{"use strict";var Cc=typeof navigator<"u"&&navigator.product==="ReactNative";function Ec(){return Cc?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var Re=self.URL,wo=Ec(),gr=class{constructor(e="",r=wo){this.super=new Re(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return Re.createObjectURL(e)}static revokeObjectURL(e){Re.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Sc(t){if(typeof t=="string")return new Re(t).toString();if(!(t instanceof Re)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",o=t.protocol?t.protocol+"//":"",s=t.host||"",i=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),d=t.hash||"",g=t.pathname||"",c=t.path||g+a;return`${o}${e||r}${s||i+n}${c}${d}`}}go.exports={URLWithLegacySupport:gr,URLSearchParams:self.URLSearchParams,defaultBase:wo,format:Sc}});var vo=R((Rd,yo)=>{"use strict";var{URLWithLegacySupport:xo,format:Ac}=xr();yo.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new xo(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new xo(t,Ac(i)).toString()}});var Eo=R((Bd,Co)=>{"use strict";var{URLWithLegacySupport:Uc,format:Pc,URLSearchParams:Tc,defaultBase:Ic}=xr(),Fc=vo();Co.exports={URL:Uc,URLSearchParams:Tc,format:Pc,relative:Fc,defaultBase:Ic}});var To=R((_d,Po)=>{function Lc(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}Po.exports=Lc});var Qc={};P(Qc,{webSockets:()=>jc});var We=class extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=We.code,this.type=We.type}},te=We;$e(te,"code","ABORT_ERR"),$e(te,"type","aborted");var Ve=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var Fr=Symbol.for("@libp2p/transport");var Ir;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Ir||(Ir={}));var $=ee(Dr(),1);function hs(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,d=t.charAt(0),g=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function p(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 l=0,v=0,b=0,x=u.length;b!==x&&u[b]===0;)b++,l++;for(var C=(x-b)*c+1>>>0,w=new Uint8Array(C);b!==x;){for(var S=u[b],U=0,y=C-1;(S!==0||U<v)&&y!==-1;y--,U++)S+=256*w[y]>>>0,w[y]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");v=U,b++}for(var A=C-v;A!==C&&w[A]===0;)A++;for(var k=d.repeat(l);A<C;++A)k+=t.charAt(w[A]);return k}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var l=0;if(u[l]!==" "){for(var v=0,b=0;u[l]===d;)v++,l++;for(var x=(u.length-l)*g+1>>>0,C=new Uint8Array(x);u[l];){var w=r[u.charCodeAt(l)];if(w===255)return;for(var S=0,U=x-1;(w!==0||S<b)&&U!==-1;U--,S++)w+=a*C[U]>>>0,C[U]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");b=S,l++}if(u[l]!==" "){for(var y=x-b;y!==x&&C[y]===0;)y++;for(var A=new Uint8Array(v+(x-y)),k=v;y!==x;)A[k++]=C[y++];return A}}}function I(u){var l=m(u);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:m,decode:I}}var ms=hs,bs=ms,Mr=bs;var Yc=new Uint8Array(0);var zr=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var ut=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},pt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Rr(this,e)}},ft=class{constructor(e){this.decoders=e}or(e){return Rr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Rr=(t,e)=>new ft({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),dt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ut(e,r,n),this.decoder=new pt(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Br=({name:t,prefix:e,encode:r,decode:n})=>new dt(t,e,r,n),lt=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Mr(r,e);return Br({prefix:t,name:e,encode:n,decode:s=>zr(o(s))})},ws=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,d=0,g=0;for(let c=0;c<s;++c){let p=o[t[c]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|p,a+=r,a>=8&&(a-=8,i[g++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},gs=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},D=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Br({prefix:e,name:t,encode(o){return gs(o,n,r)},decode(o){return ws(o,n,r,t)}});var $r=D({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),su=D({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),iu=D({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),au=D({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),cu=D({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),uu=D({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),pu=D({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),fu=D({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),du=D({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Vr=lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mu=lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Wr=D({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gu=D({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xu=D({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yu=D({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});$.default.formatters.b=t=>t==null?"undefined":Vr.baseEncode(t);$.default.formatters.t=t=>t==null?"undefined":$r.baseEncode(t);$.default.formatters.m=t=>t==null?"undefined":Wr.baseEncode(t);$.default.formatters.p=t=>t==null?"undefined":t.toString();$.default.formatters.c=t=>t==null?"undefined":t.toString();$.default.formatters.k=t=>t==null?"undefined":t.toString();$.default.formatters.a=t=>t==null?"undefined":t.toString();function xs(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Qe(t){let e=xs(`${t}:trace`);return $.default.enabled(`${t}:trace`)&&$.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,$.default)(`${t}:trace`)),Object.assign((0,$.default)(t),{error:(0,$.default)(`${t}:error`),trace:e})}var _e=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var gt={};P(gt,{base58btc:()=>M,base58flickr:()=>As});function ys(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,d=t.charAt(0),g=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function p(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 l=0,v=0,b=0,x=u.length;b!==x&&u[b]===0;)b++,l++;for(var C=(x-b)*c+1>>>0,w=new Uint8Array(C);b!==x;){for(var S=u[b],U=0,y=C-1;(S!==0||U<v)&&y!==-1;y--,U++)S+=256*w[y]>>>0,w[y]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");v=U,b++}for(var A=C-v;A!==C&&w[A]===0;)A++;for(var k=d.repeat(l);A<C;++A)k+=t.charAt(w[A]);return k}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var l=0;if(u[l]!==" "){for(var v=0,b=0;u[l]===d;)v++,l++;for(var x=(u.length-l)*g+1>>>0,C=new Uint8Array(x);u[l];){var w=r[u.charCodeAt(l)];if(w===255)return;for(var S=0,U=x-1;(w!==0||S<b)&&U!==-1;U--,S++)w+=a*C[U]>>>0,C[U]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");b=S,l++}if(u[l]!==" "){for(var y=x-b;y!==x&&C[y]===0;)y++;for(var A=new Uint8Array(v+(x-y)),k=v;y!==x;)A[k++]=C[y++];return A}}}function I(u){var l=m(u);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:m,decode:I}}var vs=ys,Cs=vs,qr=Cs;var Iu=new Uint8Array(0);var jr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},j=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Qr=t=>new TextEncoder().encode(t),_r=t=>new TextDecoder().decode(t);var ht=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Gr(this,e)}},bt=class{constructor(e){this.decoders=e}or(e){return Gr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Gr=(t,e)=>new bt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),wt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ht(e,r,n),this.decoder=new mt(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},fe=({name:t,prefix:e,encode:r,decode:n})=>new wt(t,e,r,n),H=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=qr(r,e);return fe({prefix:t,name:e,encode:n,decode:s=>j(o(s))})},Es=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,d=0,g=0;for(let c=0;c<s;++c){let p=o[t[c]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|p,a+=r,a>=8&&(a-=8,i[g++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},Ss=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},F=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>fe({prefix:e,name:t,encode(o){return Ss(o,n,r)},decode(o){return Es(o,n,r,t)}});var M=H({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),As=H({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Us=Kr,Hr=128,Ps=127,Ts=~Ps,Is=Math.pow(2,31);function Kr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Is;)e[r++]=t&255|Hr,t/=128;for(;t&Ts;)e[r++]=t&255|Hr,t>>>=7;return e[r]=t|0,Kr.bytes=r-n+1,e}var Fs=xt,Ns=128,Xr=127;function xt(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw xt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Xr)<<o:(i&Xr)*Math.pow(2,o),o+=7}while(i>=Ns);return xt.bytes=s-n,r}var Os=Math.pow(2,7),Ls=Math.pow(2,14),ks=Math.pow(2,21),Ds=Math.pow(2,28),Ms=Math.pow(2,35),zs=Math.pow(2,42),Rs=Math.pow(2,49),Bs=Math.pow(2,56),$s=Math.pow(2,63),Vs=function(t){return t<Os?1:t<Ls?2:t<ks?3:t<Ds?4:t<Ms?5:t<zs?6:t<Rs?7:t<Bs?8:t<$s?9:10},Ws={encode:Us,decode:Fs,encodingLength:Vs},qs=Ws,Te=qs;var Ie=(t,e=0)=>[Te.decode(t,e),Te.decode.bytes],de=(t,e,r=0)=>(Te.encode(t,e,r),e),le=t=>Te.encodingLength(t);var ne=(t,e)=>{let r=e.byteLength,n=le(t),o=n+le(r),s=new Uint8Array(o+r);return de(t,s,0),de(r,s,n),s.set(e,o),new he(t,r,e,s)},Ge=t=>{let e=j(t),[r,n]=Ie(e),[o,s]=Ie(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new he(r,o,i,e)},Zr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&jr(t.bytes,r.bytes)}},he=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var yt={};P(yt,{base32:()=>Q,base32hex:()=>Js,base32hexpad:()=>Hs,base32hexpadupper:()=>Xs,base32hexupper:()=>Gs,base32pad:()=>Qs,base32padupper:()=>_s,base32upper:()=>js,base32z:()=>Ks});var Q=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),js=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Qs=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_s=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Js=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gs=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hs=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xs=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ks=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Ys(r,vt(t),e||M.encoder);default:return ei(r,vt(t),e||Q.encoder)}};var en=new WeakMap,vt=t=>{let e=en.get(t);if(e==null){let r=new Map;return en.set(t,r),r}return e},T=class{constructor(e,r,n,o){this.code=r,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:r}=this;if(e!==Fe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ti)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return T.createV0(r)}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:r}=this.multihash,n=ne(e,r);return T.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 T.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Zr(e.multihash,n.multihash)}toString(e){return Yr(this,e)}toJSON(){return{"/":Yr(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 r=e;if(r instanceof T)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new T(n,o,s,i||tn(n,o,s.bytes))}else if(r[ri]===!0){let{version:n,multihash:o,code:s}=r,i=Ge(o);return T.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="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(r!==Fe)throw new Error(`Version 0 CID must use dag-pb (code: ${Fe}) block encoding`);return new T(e,r,n,n.bytes)}case 1:{let o=tn(e,r,n.bytes);return new T(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return T.create(0,Fe,e)}static createV1(e,r){return T.create(1,e,r)}static decode(e){let[r,n]=T.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=T.inspectBytes(e),n=r.size-r.multihashSize,o=j(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new he(r.multihashCode,r.digestSize,s,o);return[r.version===0?T.createV0(i):T.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[p,m]=Ie(e.subarray(r));return r+=m,p},o=n(),s=Fe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),d=n(),g=r+d,c=g-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:c,size:g}}static parse(e,r){let[n,o]=Zs(e,r),s=T.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return vt(s).set(n,e),s}},Zs=(t,e)=>{switch(t[0]){case"Q":{let r=e||M;return[M.prefix,r.decode(`${M.prefix}${t}`)]}case M.prefix:{let r=e||M;return[M.prefix,r.decode(t)]}case Q.prefix:{let r=e||Q;return[Q.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Ys=(t,e,r)=>{let{prefix:n}=r;if(n!==M.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},ei=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},Fe=112,ti=18,tn=(t,e,r)=>{let n=le(t),o=n+le(e),s=new Uint8Array(o+r.byteLength);return de(t,s,0),de(e,s,n),s.set(r,o),s},ri=Symbol.for("@ipld/js-cid/CID");function rn(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var Ut={};P(Ut,{identity:()=>ci});function ni(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,d=t.charAt(0),g=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function p(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 l=0,v=0,b=0,x=u.length;b!==x&&u[b]===0;)b++,l++;for(var C=(x-b)*c+1>>>0,w=new Uint8Array(C);b!==x;){for(var S=u[b],U=0,y=C-1;(S!==0||U<v)&&y!==-1;y--,U++)S+=256*w[y]>>>0,w[y]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");v=U,b++}for(var A=C-v;A!==C&&w[A]===0;)A++;for(var k=d.repeat(l);A<C;++A)k+=t.charAt(w[A]);return k}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var l=0;if(u[l]!==" "){for(var v=0,b=0;u[l]===d;)v++,l++;for(var x=(u.length-l)*g+1>>>0,C=new Uint8Array(x);u[l];){var w=r[u.charCodeAt(l)];if(w===255)return;for(var S=0,U=x-1;(w!==0||S<b)&&U!==-1;U--,S++)w+=a*C[U]>>>0,C[U]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");b=S,l++}if(u[l]!==" "){for(var y=x-b;y!==x&&C[y]===0;)y++;for(var A=new Uint8Array(v+(x-y)),k=v;y!==x;)A[k++]=C[y++];return A}}}function I(u){var l=m(u);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:m,decode:I}}var oi=ni,si=oi,nn=si;var Qu=new Uint8Array(0);var on=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},_=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var sn=t=>new TextEncoder().encode(t),an=t=>new TextDecoder().decode(t);var Ct=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Et=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 un(this,e)}},St=class{constructor(e){this.decoders=e}or(e){return un(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},un=(t,e)=>new St({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),At=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ct(e,r,n),this.decoder=new Et(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},be=({name:t,prefix:e,encode:r,decode:n})=>new At(t,e,r,n),X=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=nn(r,e);return be({prefix:t,name:e,encode:n,decode:s=>_(o(s))})},ii=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,d=0,g=0;for(let c=0;c<s;++c){let p=o[t[c]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|p,a+=r,a>=8&&(a-=8,i[g++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},ai=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},N=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>be({prefix:e,name:t,encode(o){return ai(o,n,r)},decode(o){return ii(o,n,r,t)}});var ci=be({prefix:"\0",name:"identity",encode:t=>an(t),decode:t=>sn(t)});var Pt={};P(Pt,{base2:()=>ui});var ui=N({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Tt={};P(Tt,{base8:()=>pi});var pi=N({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var It={};P(It,{base10:()=>fi});var fi=X({prefix:"9",name:"base10",alphabet:"0123456789"});var Ft={};P(Ft,{base16:()=>di,base16upper:()=>li});var di=N({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),li=N({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Nt={};P(Nt,{base32:()=>we,base32hex:()=>wi,base32hexpad:()=>xi,base32hexpadupper:()=>yi,base32hexupper:()=>gi,base32pad:()=>mi,base32padupper:()=>bi,base32upper:()=>hi,base32z:()=>vi});var we=N({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),hi=N({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mi=N({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bi=N({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wi=N({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gi=N({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xi=N({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),yi=N({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vi=N({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ot={};P(Ot,{base36:()=>Ci,base36upper:()=>Ei});var Ci=X({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ei=X({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Lt={};P(Lt,{base58btc:()=>W,base58flickr:()=>Si});var W=X({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Si=X({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var kt={};P(kt,{base64:()=>Ai,base64pad:()=>Ui,base64url:()=>Pi,base64urlpad:()=>Ti});var Ai=N({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ui=N({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pi=N({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ti=N({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Dt={};P(Dt,{base256emoji:()=>Li});var pn=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}"),Ii=pn.reduce((t,e,r)=>(t[r]=e,t),[]),Fi=pn.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Ni(t){return t.reduce((e,r)=>(e+=Ii[r],e),"")}function Oi(t){let e=[];for(let r of t){let n=Fi[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Li=be({prefix:"\u{1F680}",name:"base256emoji",encode:Ni,decode:Oi});var Bt={};P(Bt,{sha256:()=>Zi,sha512:()=>Yi});var ki=ln,fn=128,Di=127,Mi=~Di,zi=Math.pow(2,31);function ln(t,e,r){e=e||[],r=r||0;for(var n=r;t>=zi;)e[r++]=t&255|fn,t/=128;for(;t&Mi;)e[r++]=t&255|fn,t>>>=7;return e[r]=t|0,ln.bytes=r-n+1,e}var Ri=Mt,Bi=128,dn=127;function Mt(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw Mt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&dn)<<o:(i&dn)*Math.pow(2,o),o+=7}while(i>=Bi);return Mt.bytes=s-n,r}var $i=Math.pow(2,7),Vi=Math.pow(2,14),Wi=Math.pow(2,21),qi=Math.pow(2,28),ji=Math.pow(2,35),Qi=Math.pow(2,42),_i=Math.pow(2,49),Ji=Math.pow(2,56),Gi=Math.pow(2,63),Hi=function(t){return t<$i?1:t<Vi?2:t<Wi?3:t<qi?4:t<ji?5:t<Qi?6:t<_i?7:t<Ji?8:t<Gi?9:10},Xi={encode:ki,decode:Ri,encodingLength:Hi},Ki=Xi,Ne=Ki;var Oe=(t,e=0)=>[Ne.decode(t,e),Ne.decode.bytes],ge=(t,e,r=0)=>(Ne.encode(t,e,r),e),xe=t=>Ne.encodingLength(t);var oe=(t,e)=>{let r=e.byteLength,n=xe(t),o=n+xe(r),s=new Uint8Array(o+r);return ge(t,s,0),ge(r,s,n),s.set(e,o),new ye(t,r,e,s)},hn=t=>{let e=_(t),[r,n]=Oe(e),[o,s]=Oe(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ye(r,o,i,e)},mn=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&on(t.bytes,r.bytes)}},ye=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var Rt=({name:t,code:e,encode:r})=>new zt(t,e,r),zt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?oe(this.code,r):r.then(n=>oe(this.code,n))}else throw Error("Unknown type, must be binary type")}};var wn=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Zi=Rt({name:"sha2-256",code:18,encode:wn("SHA-256")}),Yi=Rt({name:"sha2-512",code:19,encode:wn("SHA-512")});var $t={};P($t,{identity:()=>ra});var gn=0,ea="identity",xn=_,ta=t=>oe(gn,xn(t)),ra={code:gn,name:ea,encode:xn,digest:ta};var dp=new TextEncoder,lp=new TextDecoder;var yn=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return ia(r,Vt(t),e||W.encoder);default:return aa(r,Vt(t),e||we.encoder)}};var vn=new WeakMap,Vt=t=>{let e=vn.get(t);if(e==null){let r=new Map;return vn.set(t,r),r}return e},L=class{constructor(e,r,n,o){this.code=r,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:r}=this;if(e!==ke)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ca)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return L.createV0(r)}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:r}=this.multihash,n=oe(e,r);return L.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 L.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&mn(e.multihash,n.multihash)}toString(e){return yn(this,e)}toJSON(){return{"/":yn(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 r=e;if(r instanceof L)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new L(n,o,s,i||Cn(n,o,s.bytes))}else if(r[ua]===!0){let{version:n,multihash:o,code:s}=r,i=hn(o);return L.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="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(r!==ke)throw new Error(`Version 0 CID must use dag-pb (code: ${ke}) block encoding`);return new L(e,r,n,n.bytes)}case 1:{let o=Cn(e,r,n.bytes);return new L(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return L.create(0,ke,e)}static createV1(e,r){return L.create(1,e,r)}static decode(e){let[r,n]=L.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=L.inspectBytes(e),n=r.size-r.multihashSize,o=_(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new ye(r.multihashCode,r.digestSize,s,o);return[r.version===0?L.createV0(i):L.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[p,m]=Oe(e.subarray(r));return r+=m,p},o=n(),s=ke;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),d=n(),g=r+d,c=g-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:c,size:g}}static parse(e,r){let[n,o]=sa(e,r),s=L.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Vt(s).set(n,e),s}},sa=(t,e)=>{switch(t[0]){case"Q":{let r=e||W;return[W.prefix,r.decode(`${W.prefix}${t}`)]}case W.prefix:{let r=e||W;return[W.prefix,r.decode(t)]}case we.prefix:{let r=e||we;return[we.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},ia=(t,e,r)=>{let{prefix:n}=r;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},aa=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},ke=112,ca=18,Cn=(t,e,r)=>{let n=xe(t),o=n+xe(e),s=new Uint8Array(o+r.byteLength);return ge(t,s,0),ge(e,s,n),s.set(r,o),s},ua=Symbol.for("@ipld/js-cid/CID");var Wt={...Ut,...Pt,...Tt,...It,...Ft,...Nt,...Ot,...Lt,...kt,...Dt},Ep={...Bt,...$t};function ve(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Xe(t=0){return globalThis.Buffer?.allocUnsafe!=null?ve(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Sn(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var En=Sn("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),qt=Sn("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Xe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),pa={utf8:En,"utf-8":En,hex:Wt.base16,latin1:qt,ascii:qt,binary:qt,...Wt},Ke=pa;function z(t,e="utf8"){let r=Ke[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var mr=ee(Ze(),1);function J(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Xe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return ve(r)}var Ee=ee(Ze(),1);var Ye=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let d=a==="0",g=2**(8*o)-1;for(;;){let c=this.readAtomically(()=>{let p=this.readChar();if(p===void 0)return;let m=Number.parseInt(p,e);if(!Number.isNaN(m))return m});if(c===void 0)break;if(s*=e,s+=c,s>g||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&d&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var kn=45,Sa=15,Ce=new Ye;function _t(t){if(!(t.length>Sa))return Ce.new(t).parseWith(()=>Ce.readIPv4Addr())}function Jt(t){if(!(t.length>kn))return Ce.new(t).parseWith(()=>Ce.readIPv6Addr())}function et(t){if(!(t.length>kn))return Ce.new(t).parseWith(()=>Ce.readIPAddr())}var Hp=parseInt("0xFFFF",16),Xp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Gt={};P(Gt,{identity:()=>Ia});var Ia=fe({prefix:"\0",name:"identity",encode:t=>_r(t),decode:t=>Qr(t)});var Ht={};P(Ht,{base2:()=>Fa});var Fa=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Xt={};P(Xt,{base8:()=>Na});var Na=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kt={};P(Kt,{base10:()=>Oa});var Oa=H({prefix:"9",name:"base10",alphabet:"0123456789"});var Zt={};P(Zt,{base16:()=>La,base16upper:()=>ka});var La=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ka=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Yt={};P(Yt,{base36:()=>Da,base36upper:()=>Ma});var Da=H({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ma=H({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var er={};P(er,{base64:()=>za,base64pad:()=>Ra,base64url:()=>Ba,base64urlpad:()=>$a});var za=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ra=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ba=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$a=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var tr={};P(tr,{base256emoji:()=>Qa});var zn=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}"),Va=zn.reduce((t,e,r)=>(t[r]=e,t),[]),Wa=zn.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function qa(t){return t.reduce((e,r)=>(e+=Va[r],e),"")}function ja(t){let e=[];for(let r of t){let n=Wa[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Qa=fe({prefix:"\u{1F680}",name:"base256emoji",encode:qa,decode:ja});var or={};P(or,{sha256:()=>_a,sha512:()=>Ja});var nr=({name:t,code:e,encode:r})=>new rr(t,e,r),rr=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?ne(this.code,r):r.then(n=>ne(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Bn=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),_a=nr({name:"sha2-256",code:18,encode:Bn("SHA-256")}),Ja=nr({name:"sha2-512",code:19,encode:Bn("SHA-512")});var sr={};P(sr,{identity:()=>Xa});var $n=0,Ga="identity",Vn=j,Ha=t=>ne($n,Vn(t)),Xa={code:$n,name:Ga,encode:Vn,digest:Ha};var Nf=new TextEncoder,Of=new TextDecoder;var Wn={...Gt,...Ht,...Xt,...Kt,...Zt,...yt,...Yt,...gt,...er,...tr},zf={...or,...sr};function De(t,e="utf8"){let r=Ke[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ve(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var q=ee(Ze(),1);function qn(t){return!!_t(t)}function jn(t){return!!Jt(t)}function tt(t){return!!et(t)}var Qn=qn,Ya=jn,ir=function(t){let e=0;if(t=t.toString().trim(),Qn(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Ya(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=Qn(r[n]),i;s&&(i=ir(r[n]),r[n]=z(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,z(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},_n=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Me={},ar={},tc=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];tc.forEach(t=>{let e=rc(...t);ar[e.code]=e,Me[e.name]=e});function rc(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function E(t){if(typeof t=="number"){if(ar[t]!=null)return ar[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Me[t]!=null)return Me[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var nd=E("ip4"),od=E("ip6"),sd=E("ipcidr");function Kn(t,e){switch(E(t).code){case 4:case 41:return oc(e);case 42:return Hn(e);case 6:case 273:case 33:case 132:return Yn(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Hn(e);case 421:return cc(e);case 444:return Xn(e);case 445:return Xn(e);case 466:return ac(e);default:return z(e,"base16")}}function Zn(t,e){switch(E(t).code){case 4:return Jn(e);case 41:return Jn(e);case 42:return Gn(e);case 6:case 273:case 33:case 132:return ur(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gn(e);case 421:return sc(e);case 444:return uc(e);case 445:return pc(e);case 466:return ic(e);default:return De(e,"base16")}}var cr=Object.values(Wn).map(t=>t.decoder),nc=function(){let t=cr[0].or(cr[1]);return cr.slice(2).forEach(e=>t=t.or(e)),t}();function Jn(t){if(!tt(t))throw new Error("invalid ip address");return ir(t)}function oc(t){let e=_n(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!tt(e))throw new Error("invalid ip address");return e}function ur(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Yn(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function Gn(t){let e=De(t),r=Uint8Array.from(q.default.encode(e.length));return J([r,e],r.length+e.length)}function Hn(t){let e=q.default.decode(t);if(t=t.slice(q.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return z(t)}function sc(t){let e;t[0]==="Q"||t[0]==="1"?e=Ge(M.decode(`z${t}`)).bytes:e=T.parse(t).multihash.bytes;let r=Uint8Array.from(q.default.encode(e.length));return J([r,e],r.length+e.length)}function ic(t){let e=nc.decode(t),r=Uint8Array.from(q.default.encode(e.length));return J([r,e],r.length+e.length)}function ac(t){let e=q.default.decode(t),r=t.slice(q.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+z(r,"base64url")}function cc(t){let e=q.default.decode(t),r=t.slice(q.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return z(r,"base58btc")}function uc(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=Q.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ur(n);return J([r,o],r.length+o.length)}function pc(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=Q.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ur(n);return J([r,o],r.length+o.length)}function Xn(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=z(e,"base32"),o=Yn(r);return`${n}:${o}`}function fc(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=E(o);if(s.size===0){e.push([o]);continue}if(n++,n>=r.length)throw to("invalid address: "+t);if(s.path===!0){e.push([o,hr(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function dc(t){let e=[];return t.map(r=>{let n=ot(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),hr(e.join("/"))}function lc(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=ot(e);return e.length>1?[r.code,Zn(r.code,e[1])]:[r.code]})}function pr(t){return t.map(e=>{let r=ot(e);return e[1]!=null?[r.code,Kn(r.code,e[1])]:[r.code]})}function fr(t){return nt(J(t.map(e=>{let r=ot(e),n=Uint8Array.from(Ee.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=J([n,e[1]])),n})))}function dr(t,e){return t.size>0?t.size/8:t.size===0?0:Ee.default.decode(e)+(Ee.default.decode.bytes??0)}function rt(t){let e=[],r=0;for(;r<t.length;){let n=Ee.default.decode(t,r),o=Ee.default.decode.bytes??0,s=E(n),i=dr(s,t.slice(r+o));if(i===0){e.push([n]),r+=o;continue}let a=t.slice(r+o,r+o+i);if(r+=i+o,r>t.length)throw to("Invalid address Uint8Array: "+z(t,"base16"));e.push([n,a])}return e}function lr(t){let e=rt(t),r=pr(e);return dc(r)}function hc(t){t=hr(t);let e=fc(t),r=lc(e);return fr(r)}function eo(t){return hc(t)}function nt(t){let e=mc(t);if(e!=null)throw e;return Uint8Array.from(t)}function mc(t){try{rt(t)}catch(e){return e}}function hr(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function to(t){return new Error("Error parsing address: "+t)}function ot(t){return E(t[0])}var wc=Symbol.for("nodejs.util.inspect.custom"),gc=[E("dns").code,E("dns4").code,E("dns6").code,E("dnsaddr").code],xc=new Map,ro=Symbol.for("@multiformats/js-multiaddr/multiaddr");function yc(t){return!!t?.[ro]}var G=class{bytes;#t;#r;#n;#e;[ro]=!0;constructor(e){if(e==null&&(e=""),e instanceof Uint8Array)this.bytes=nt(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=eo(e)}else if(yc(e))this.bytes=nt(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=lr(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=E("tcp"),a=E("udp"),d=E("ip4"),g=E("ip6"),c=E("dns6"),p=E("ip6zone");for(let[I,u]of this.stringTuples())I===p.code&&(s=`%${u??""}`),gc.includes(I)&&(r=i.name,o=443,n=`${u??""}${s}`,e=I===c.code?6:4),(I===i.code||I===a.code)&&(r=E(I).name,o=parseInt(u??"")),(I===d.code||I===g.code)&&(r=E(I).name,n=`${u??""}${s}`,e=I===g.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},E(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let o=mr.default.decode(r,n),s=mr.default.decode.bytes??0,i=E(o),a=dr(i,r.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return this.#r==null&&(this.#r=rt(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=pr(this.tuples())),this.#n}encapsulate(e){return e=new G(e),new G(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new G(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new G(fr(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Me.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?z(M.decode(`z${n}`),"base58btc"):z(T.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(e=>E(e[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(e){return rn(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=xc.get(r.name);if(n==null)throw new _e(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new G(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[wc](){return`Multiaddr(${lr(this.bytes)})`}};function Se(t){return new G(t)}function no(t){let e;try{e=E("sni").code}catch{return null}for(let[r,n]of t)if(r===e&&n!==void 0)return n;return null}function oo(t){return t.some(([e,r])=>e===E("tls").code)}function V(t,e,r){let n=so[E(t).name];if(n===void 0)throw new Error(`Can't interpret protocol ${E(t).name}`);let o=n(e,r);return t===E("ip6").code?`[${o}]`:o}var so={ip4:(t,e)=>t,ip6:(t,e)=>e.length===0?t:`[${t}]`,tcp:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${V(r[0],r[1]??"",e)}:${t}`},udp:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${V(r[0],r[1]??"",e)}:${t}`},dnsaddr:(t,e)=>t,dns4:(t,e)=>t,dns6:(t,e)=>t,dns:(t,e)=>t,ipfs:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${V(r[0],r[1]??"",e)}/ipfs/${t}`},p2p:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${V(r[0],r[1]??"",e)}/p2p/${t}`},http:(t,e)=>{let r=oo(e),n=no(e);if(r&&n!==null)return`https://${n}`;let o=r?"https://":"http://",s=e.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=V(s[0],s[1]??"",e);return i=i.replace("tcp://",""),`${o}${i}`},tls:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return V(r[0],r[1]??"",e)},sni:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return V(r[0],r[1]??"",e)},https:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=V(r[0],r[1]??"",e);return n=n.replace("tcp://",""),`https://${n}`},ws:(t,e)=>{let r=oo(e),n=no(e);if(r&&n!==null)return`wss://${n}`;let o=r?"wss://":"ws://",s=e.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=V(s[0],s[1]??"",e);return i=i.replace("tcp://",""),`${o}${i}`},wss:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=V(r[0],r[1]??"",e);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${V(r[0],r[1]??"",e)}/p2p-websocket-star`},"p2p-webrtc-star":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${V(r[0],r[1]??"",e)}/p2p-webrtc-star`},"p2p-webrtc-direct":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${V(r[0],r[1]??"",e)}/p2p-webrtc-direct`}};function io(t,e){let n=Se(t).stringTuples(),o=n.pop();if(o===void 0)throw new Error("Unexpected end of multiaddr");let s=E(o[0]),i=so[s.name];if(i==null)throw new Error(`No interpreter found for ${s.name}`);let a=i(o[1]??"",n);return e?.assumeHttp!==!1&&o[0]===E("tcp").code&&(a=a.replace("tcp://","http://"),(o[1]==="443"||o[1]==="80")&&(o[1]==="443"&&(a=a.replace("http://","https://")),a=a.substring(0,a.lastIndexOf(":")))),a}var ao=WebSocket;var fo=ee(uo(),1);function po(t){return t instanceof ArrayBuffer||t?.constructor?.name==="ArrayBuffer"&&typeof t?.byteLength=="number"}var lo=t=>{t.binaryType="arraybuffer";let e=async()=>{await new Promise((s,i)=>{if(n){s();return}if(o!=null){i(o);return}let a=c=>{t.removeEventListener("open",d),t.removeEventListener("error",g),c()},d=()=>{a(s)},g=c=>{a(()=>{i(c.error??new Error(`connect ECONNREFUSED ${t.url}`))})};t.addEventListener("open",d),t.addEventListener("error",g)})},r=async function*(){let s=new fo.EventIterator(({push:i,stop:a,fail:d})=>{let g=p=>{let m=null;typeof p.data=="string"&&(m=De(p.data)),po(p.data)&&(m=new Uint8Array(p.data)),p.data instanceof Uint8Array&&(m=p.data),m!=null&&i(m)},c=p=>{d(p.error??new Error("Socket error"))};return t.addEventListener("message",g),t.addEventListener("error",c),t.addEventListener("close",a),()=>{t.removeEventListener("message",g),t.removeEventListener("error",c),t.removeEventListener("close",a)}},{highWaterMark:1/0});await e();for await(let i of s)yield po(i)?new Uint8Array(i):i}(),n=t.readyState===1,o;return t.addEventListener("open",()=>{n=!0,o=null}),t.addEventListener("close",()=>{n=!1,o=null}),t.addEventListener("error",s=>{n||(o=s.error??new Error(`connect ECONNREFUSED ${t.url}`))}),Object.assign(r,{connected:e})};var ho=async t=>{if(t.readyState>=2)throw new Error("socket closed");t.readyState!==1&&await new Promise((e,r)=>{function n(){t.removeEventListener("open",o),t.removeEventListener("error",s)}function o(){n(),e()}function s(i){n(),r(i.error??new Error(`connect ECONNREFUSED ${t.url}`))}t.addEventListener("open",o),t.addEventListener("error",s)})};var mo=(t,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let o of n){try{await ho(t)}catch(s){if(s.message==="socket closed")break;throw s}t.send(o)}e.closeOnEnd!=null&&t.readyState<=1&&await new Promise((o,s)=>{t.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let a=Object.assign(new Error("ws error"),{event:i});s(a)}}),setTimeout(()=>{t.close()})})});var bo=(t,e)=>{e=e??{};let r=lo(t),n=e.remoteAddress,o=e.remotePort;if(t.url!=null)try{let i=new URL(t.url);n=i.hostname,o=parseInt(i.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:mo(t,e),source:r,connected:async()=>{await r.connected()},close:async()=>{(t.readyState===t.CONNECTING||t.readyState===t.OPEN)&&await new Promise(i=>{t.addEventListener("close",()=>{i()}),t.close()})},destroy:()=>{t.terminate!=null?t.terminate():t.close()},remoteAddress:n,remotePort:o,socket:t}};var So=ee(Eo(),1),Nc={http:"ws",https:"wss"},Oc="ws",Ao=(t,e)=>(0,So.relative)(t,e,Nc,Oc);function Uo(t,e){let r=typeof window>"u"?"":window.location;e=e??{};let n=Ao(t,r.toString()),o=new ao(n,e.websocket);return bo(o,e)}function yr(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Io=ee(To(),1),kc=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Fo=(0,Io.default)(),No=kc&&!Fo;var Jd=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Fo,Oo=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Gd=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",Hd=typeof navigator<"u"&&navigator.product==="ReactNative";var Dc=f("dns4"),Mc=f("dns6"),zc=f("dnsaddr"),Z=O(f("dns"),zc,Dc,Mc),at=O(f("ip4"),f("ip6")),Ae=O(h(at,f("tcp")),h(Z,f("tcp"))),ct=h(at,f("udp")),Rc=h(ct,f("utp")),Bc=h(ct,f("quic")),$c=h(ct,f("quic-v1")),vr=O(h(Ae,f("ws")),h(Z,f("ws"))),Ue=O(h(vr,f("p2p")),vr),Cr=O(h(Ae,f("wss")),h(Z,f("wss")),h(Ae,f("tls"),f("ws")),h(Z,f("tls"),f("ws"))),ie=O(h(Cr,f("p2p")),Cr),Er=O(h(Ae,f("http")),h(at,f("http")),h(Z,f("http"))),Sr=O(h(Ae,f("https")),h(at,f("https")),h(Z,f("https"))),Lo=h(ct,f("webrtc-direct"),f("certhash")),Mo=O(h(Lo,f("p2p")),Lo),ko=h($c,f("webtransport"),f("certhash"),f("certhash")),zo=O(h(ko,f("p2p")),ko),Ro=O(h(Ue,f("p2p-webrtc-star"),f("p2p")),h(ie,f("p2p-webrtc-star"),f("p2p")),h(Ue,f("p2p-webrtc-star")),h(ie,f("p2p-webrtc-star"))),Zd=O(h(Ue,f("p2p-websocket-star"),f("p2p")),h(ie,f("p2p-websocket-star"),f("p2p")),h(Ue,f("p2p-websocket-star")),h(ie,f("p2p-websocket-star"))),Bo=O(h(Er,f("p2p-webrtc-direct"),f("p2p")),h(Sr,f("p2p-webrtc-direct"),f("p2p")),h(Er,f("p2p-webrtc-direct")),h(Sr,f("p2p-webrtc-direct"))),ae=O(vr,Cr,Er,Sr,Ro,Bo,Ae,Rc,Bc,Z,Mo,zo),Yd=O(h(ae,f("p2p-stardust"),f("p2p")),h(ae,f("p2p-stardust"))),K=O(h(ae,f("p2p")),Ro,Bo,Mo,zo,f("p2p")),Do=O(h(K,f("p2p-circuit"),K),h(K,f("p2p-circuit")),h(f("p2p-circuit"),K),h(ae,f("p2p-circuit")),h(f("p2p-circuit"),ae),f("p2p-circuit")),$o=()=>O(h(Do,$o),Do),se=$o(),el=O(h(se,K,se),h(K,se),h(se,K),se,K);var tl=O(h(se,f("webrtc"),f("p2p")),h(se,f("webrtc")),h(ae,f("webrtc"),f("p2p")),h(ae,f("webrtc")),f("webrtc"));function Vo(t){function e(r){let n;try{n=Se(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function h(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Vo(e),partialMatch:e}}function O(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Vo(e),partialMatch:e}}function f(t){let e=t;function r(o){let s;try{s=Se(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}function jo(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return Ue.matches(r)||ie.matches(r)})}function Qo(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return ie.matches(r)})}function _o(){throw new Error("WebSocket Servers can not be created in the browser!")}var Be=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Jo(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function Ar(t,e,r){let n=r??{},o=Jo(t);async function*s(){let i,a=()=>{i?.()};for(e.addEventListener("abort",a);;){let d;try{if(e.aborted){let{abortMessage:c,abortCode:p}=n;throw new Be(c,p)}let g=new Promise((c,p)=>{i=()=>{let{abortMessage:m,abortCode:I}=n;p(new Be(m,I))}});d=await Promise.race([g,o.next()]),i=null}catch(g){e.removeEventListener("abort",a);let c=g.type==="aborted"&&e.aborted;if(c&&n.onAbort!=null&&n.onAbort(t),typeof o.return=="function")try{let p=o.return();p instanceof Promise&&p.catch(m=>{n.onReturnError!=null&&n.onReturnError(m)})}catch(p){n.onReturnError!=null&&n.onReturnError(p)}if(c&&n.returnOnAbort===!0)return;throw g}if(d.done===!0)break;yield d.value}e.removeEventListener("abort",a)}return s()}var Ur=Qe("libp2p:websockets:socket");function Go(t,e,r){r=r??{};let n={async sink(o){r?.signal!=null&&(o=Ar(o,r.signal));try{await t.sink(o)}catch(s){s.type!=="aborted"&&Ur.error(s)}},source:r.signal!=null?Ar(t.source,r.signal):t.source,remoteAddr:e,timeline:{open:Date.now()},async close(o={}){let s=Date.now();o.signal=o.signal??AbortSignal.timeout(500);let i=()=>{let{host:a,port:d}=n.remoteAddr.toOptions();Ur("timeout closing stream to %s:%s after %dms, destroying it manually",a,d,Date.now()-s),this.abort(new Ve("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};o.signal.addEventListener("abort",i);try{await t.close()}catch(a){this.abort(a)}finally{o.signal.removeEventListener("abort",i),n.timeline.close=Date.now()}},abort(o){let{host:s,port:i}=n.remoteAddr.toOptions();Ur("timeout closing stream to %s:%s due to error",s,i,o),t.destroy(),n.timeline.close=Date.now()}};return t.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}var Y=Qe("libp2p:websockets"),Pr=class{init;constructor(e){this.init=e}[Symbol.toStringTag]="@libp2p/websockets";[Fr]=!0;async dial(e,r){Y("dialing %s",e),r=r??{};let n=await this._connect(e,r),o=Go(n,e);Y("new outbound connection %s",o.remoteAddr);let s=await r.upgrader.upgradeOutbound(o);return Y("outbound connection %s upgraded",o.remoteAddr),s}async _connect(e,r){if(r?.signal?.aborted===!0)throw new te;let n=e.toOptions();Y("dialing %s:%s",n.host,n.port);let o=yr(),s=g=>{Y.error("connection error:",g),o.reject(g)},i=Uo(io(e),this.init);if(i.socket.on!=null?i.socket.on("error",s):i.socket.onerror=s,r.signal==null)return await Promise.race([i.connected(),o.promise]),Y("connected %s",e),i;let a,d=new Promise((g,c)=>{if(a=()=>{c(new te),i.close().catch(p=>{Y.error("error closing raw socket",p)})},r?.signal?.aborted===!0){a();return}r?.signal?.addEventListener("abort",a)});try{await Promise.race([d,o.promise,i.connected()])}finally{a!=null&&r?.signal?.removeEventListener("abort",a)}return Y("connected %s",e),i}createListener(e){return _o({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):No||Oo?Qo(e):jo(e)}};function jc(t={}){return()=>new Pr(t)}return ts(Qc);})();
2
+ "use strict";var Libp2PWebsockets=(()=>{var Jo=Object.create;var ze=Object.defineProperty;var Go=Object.getOwnPropertyDescriptor;var Ho=Object.getOwnPropertyNames;var Xo=Object.getPrototypeOf,Ko=Object.prototype.hasOwnProperty;var M=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),U=(t,e)=>{for(var r in e)ze(t,r,{get:e[r],enumerable:!0})},Ir=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ho(e))!Ko.call(t,o)&&o!==r&&ze(t,o,{get:()=>e[o],enumerable:!(n=Go(e,o))||n.enumerable});return t};var Z=(t,e,r)=>(r=t!=null?Jo(Xo(t)):{},Ir(e||!t||!t.__esModule?ze(r,"default",{value:t,enumerable:!0}):r,t)),Zo=t=>Ir(ze({},"__esModule",{value:!0}),t);var Fr=M((_c,Tr)=>{var se=1e3,ie=se*60,ae=ie*60,Y=ae*24,Yo=Y*7,es=Y*365.25;Tr.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return ts(t);if(r==="number"&&isFinite(t))return e.long?ns(t):rs(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function ts(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*es;case"weeks":case"week":case"w":return r*Yo;case"days":case"day":case"d":return r*Y;case"hours":case"hour":case"hrs":case"hr":case"h":return r*ae;case"minutes":case"minute":case"mins":case"min":case"m":return r*ie;case"seconds":case"second":case"secs":case"sec":case"s":return r*se;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function rs(t){var e=Math.abs(t);return e>=Y?Math.round(t/Y)+"d":e>=ae?Math.round(t/ae)+"h":e>=ie?Math.round(t/ie)+"m":e>=se?Math.round(t/se)+"s":t+"ms"}function ns(t){var e=Math.abs(t);return e>=Y?Be(t,e,Y,"day"):e>=ae?Be(t,e,ae,"hour"):e>=ie?Be(t,e,ie,"minute"):e>=se?Be(t,e,se,"second"):t+" ms"}function Be(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var Nr=M((Jc,Dr)=>{function os(t){r.debug=r,r.default=r,r.coerce=d,r.disable=s,r.enable=o,r.enabled=i,r.humanize=Fr(),r.destroy=g,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let p=0;for(let m=0;m<c.length;m++)p=(p<<5)-p+c.charCodeAt(m),p|=0;return r.colors[Math.abs(p)%r.colors.length]}r.selectColor=e;function r(c){let p,m=null,P,u;function l(...v){if(!l.enabled)return;let b=l,x=Number(new Date),C=x-(p||x);b.diff=C,b.prev=p,b.curr=x,p=x,v[0]=r.coerce(v[0]),typeof v[0]!="string"&&v.unshift("%O");let w=0;v[0]=v[0].replace(/%([a-zA-Z%])/g,(I,y)=>{if(I==="%%")return"%";w++;let A=r.formatters[y];if(typeof A=="function"){let N=v[w];I=A.call(b,N),v.splice(w,1),w--}return I}),r.formatArgs.call(b,v),(b.log||r.log).apply(b,v)}return l.namespace=c,l.useColors=r.useColors(),l.color=r.selectColor(c),l.extend=n,l.destroy=r.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(P!==r.namespaces&&(P=r.namespaces,u=r.enabled(c)),u),set:v=>{m=v}}),typeof r.init=="function"&&r.init(l),l}function n(c,p){let m=r(this.namespace+(typeof p>"u"?":":p)+c);return m.log=this.log,m}function o(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let p,m=(typeof c=="string"?c:"").split(/[\s,]+/),P=m.length;for(p=0;p<P;p++)m[p]&&(c=m[p].replace(/\*/g,".*?"),c[0]==="-"?r.skips.push(new RegExp("^"+c.slice(1)+"$")):r.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...r.names.map(a),...r.skips.map(a).map(p=>"-"+p)].join(",");return r.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let p,m;for(p=0,m=r.skips.length;p<m;p++)if(r.skips[p].test(c))return!1;for(p=0,m=r.names.length;p<m;p++)if(r.names[p].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function d(c){return c instanceof Error?c.stack||c.message:c}function g(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}Dr.exports=os});var Or=M((z,$e)=>{z.formatArgs=is;z.save=as;z.load=cs;z.useColors=ss;z.storage=us();z.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();z.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 ss(){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 is(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+$e.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}z.log=console.debug||console.log||(()=>{});function as(t){try{t?z.storage.setItem("debug",t):z.storage.removeItem("debug")}catch{}}function cs(){let t;try{t=z.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function us(){try{return localStorage}catch{}}$e.exports=Nr()(z);var{formatters:ps}=$e.exports;ps.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var An=M((Pp,Sn)=>{Sn.exports=Vt;var En=128,ca=127,ua=~ca,pa=Math.pow(2,31);function Vt(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw Vt.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=pa;)e[r++]=t&255|En,t/=128;for(;t&ua;)e[r++]=t&255|En,t>>>=7;return e[r]=t|0,Vt.bytes=r-n+1,e}});var Pn=M((Tp,Un)=>{Un.exports=Wt;var fa=128,In=127;function Wt(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a||o>49)throw Wt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&In)<<o:(i&In)*Math.pow(2,o),o+=7}while(i>=fa);return Wt.bytes=s-n,r}});var Fn=M((Fp,Tn)=>{var da=Math.pow(2,7),la=Math.pow(2,14),ha=Math.pow(2,21),ma=Math.pow(2,28),ba=Math.pow(2,35),wa=Math.pow(2,42),ga=Math.pow(2,49),xa=Math.pow(2,56),ya=Math.pow(2,63);Tn.exports=function(t){return t<da?1:t<la?2:t<ha?3:t<ma?4:t<ba?5:t<wa?6:t<ga?7:t<xa?8:t<ya?9:10}});var He=M((Dp,Dn)=>{Dn.exports={encode:An(),decode:Pn(),encodingLength:Fn()}});var io=M(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});var hr=class{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;let r={value:e,done:!1};if(this.pullQueue.length){let n=this.pullQueue.shift();n&&n.resolve(r)}else this.pushQueue.push(Promise.resolve(r)),this.highWaterMark!==void 0&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(let e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(let r of this.pullQueue)r.reject(e);this.pullQueue.length=0}else{let r=Promise.reject(e);r.catch(()=>{}),this.pushQueue.push(r)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:e=>{let r=this.pushQueue.shift();return r?(this.lowWaterMark!==void 0&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),r):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((n,o)=>{this.pullQueue.push({resolve:n,reject:o})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}},rt=class{constructor(e,{highWaterMark:r=100,lowWaterMark:n=1}={}){let o=new hr;o.highWaterMark=r,o.lowWaterMark=n,o.removeCallback=e({push:s=>o.push(s),stop:()=>o.stop(),fail:s=>o.fail(s),on:(s,i)=>{o.eventHandlers[s]=i}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}};nt.EventIterator=rt;nt.default=rt});var ao=M(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var mr=io();Le.EventIterator=mr.EventIterator;function gc(t,e,r){return new mr.EventIterator(({push:n})=>(this.addEventListener(t,n,e),()=>this.removeEventListener(t,n,e)),r)}Le.subscribe=gc;Le.default=mr.EventIterator});var wr=M((Nd,bo)=>{"use strict";var xc=typeof navigator<"u"&&navigator.product==="ReactNative";function yc(){return xc?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var ke=self.URL,mo=yc(),br=class{constructor(e="",r=mo){this.super=new ke(e,r),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return ke.createObjectURL(e)}static revokeObjectURL(e){ke.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function vc(t){if(typeof t=="string")return new ke(t).toString();if(!(t instanceof ke)){let e=t.username&&t.password?`${t.username}:${t.password}@`:"",r=t.auth?t.auth+"@":"",n=t.port?":"+t.port:"",o=t.protocol?t.protocol+"//":"",s=t.host||"",i=t.hostname||"",a=t.search||(t.query?"?"+t.query:""),d=t.hash||"",g=t.pathname||"",c=t.path||g+a;return`${o}${e||r}${s||i+n}${c}${d}`}}bo.exports={URLWithLegacySupport:br,URLSearchParams:self.URLSearchParams,defaultBase:mo,format:vc}});var xo=M((Od,go)=>{"use strict";var{URLWithLegacySupport:wo,format:Cc}=wr();go.exports=(t,e={},r={},n)=>{let o=e.protocol?e.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new wo(t)}catch{s={}}let i=Object.assign({},e,{protocol:o||s.protocol,host:e.host||s.host});return new wo(t,Cc(i)).toString()}});var vo=M((Ld,yo)=>{"use strict";var{URLWithLegacySupport:Ec,format:Sc,URLSearchParams:Ac,defaultBase:Ic}=wr(),Uc=xo();yo.exports={URL:Ec,URLSearchParams:Ac,format:Sc,relative:Uc,defaultBase:Ic}});var Io=M((Vd,Ao)=>{function Fc(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}Ao.exports=Fc});var Wc={};U(Wc,{webSockets:()=>Vc});var Se=class t extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=t.code,this.type=t.type}static code="ABORT_ERR";static type="aborted"},Re=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var Pr=Symbol.for("@libp2p/transport");var Ur;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(Ur||(Ur={}));var R=Z(Or(),1);function fs(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,d=t.charAt(0),g=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function p(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 l=0,v=0,b=0,x=u.length;b!==x&&u[b]===0;)b++,l++;for(var C=(x-b)*c+1>>>0,w=new Uint8Array(C);b!==x;){for(var S=u[b],I=0,y=C-1;(S!==0||I<v)&&y!==-1;y--,I++)S+=256*w[y]>>>0,w[y]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");v=I,b++}for(var A=C-v;A!==C&&w[A]===0;)A++;for(var N=d.repeat(l);A<C;++A)N+=t.charAt(w[A]);return N}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var l=0;if(u[l]!==" "){for(var v=0,b=0;u[l]===d;)v++,l++;for(var x=(u.length-l)*g+1>>>0,C=new Uint8Array(x);u[l];){var w=r[u.charCodeAt(l)];if(w===255)return;for(var S=0,I=x-1;(w!==0||S<b)&&I!==-1;I--,S++)w+=a*C[I]>>>0,C[I]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");b=S,l++}if(u[l]!==" "){for(var y=x-b;y!==x&&C[y]===0;)y++;for(var A=new Uint8Array(v+(x-y)),N=v;y!==x;)A[N++]=C[y++];return A}}}function P(u){var l=m(u);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:m,decode:P}}var ds=fs,ls=ds,Lr=ls;var Hc=new Uint8Array(0);var kr=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var it=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},at=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 Mr(this,e)}},ct=class{constructor(e){this.decoders=e}or(e){return Mr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Mr=(t,e)=>new ct({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),ut=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new it(e,r,n),this.decoder=new at(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},zr=({name:t,prefix:e,encode:r,decode:n})=>new ut(t,e,r,n),pt=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Lr(r,e);return zr({prefix:t,name:e,encode:n,decode:s=>kr(o(s))})},hs=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,d=0,g=0;for(let c=0;c<s;++c){let p=o[t[c]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|p,a+=r,a>=8&&(a-=8,i[g++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},ms=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},O=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>zr({prefix:e,name:t,encode(o){return ms(o,n,r)},decode(o){return hs(o,n,r,t)}});var Rr=O({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tu=O({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ru=O({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),nu=O({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ou=O({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),su=O({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),iu=O({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),au=O({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cu=O({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Br=pt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fu=pt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $r=O({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),hu=O({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mu=O({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bu=O({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});R.default.formatters.b=t=>t==null?"undefined":Br.baseEncode(t);R.default.formatters.t=t=>t==null?"undefined":Rr.baseEncode(t);R.default.formatters.m=t=>t==null?"undefined":$r.baseEncode(t);R.default.formatters.p=t=>t==null?"undefined":t.toString();R.default.formatters.c=t=>t==null?"undefined":t.toString();R.default.formatters.k=t=>t==null?"undefined":t.toString();R.default.formatters.a=t=>t==null?"undefined":t.toString();function bs(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ve(t){let e=bs(`${t}:trace`);return R.default.enabled(`${t}:trace`)&&R.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,R.default)(`${t}:trace`)),Object.assign((0,R.default)(t),{error:(0,R.default)(`${t}:error`),trace:e})}var We=class extends Error{code;props;constructor(e,r,n){super(e),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var mt={};U(mt,{base58btc:()=>L,base58flickr:()=>Cs});function ws(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,d=t.charAt(0),g=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function p(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 l=0,v=0,b=0,x=u.length;b!==x&&u[b]===0;)b++,l++;for(var C=(x-b)*c+1>>>0,w=new Uint8Array(C);b!==x;){for(var S=u[b],I=0,y=C-1;(S!==0||I<v)&&y!==-1;y--,I++)S+=256*w[y]>>>0,w[y]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");v=I,b++}for(var A=C-v;A!==C&&w[A]===0;)A++;for(var N=d.repeat(l);A<C;++A)N+=t.charAt(w[A]);return N}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var l=0;if(u[l]!==" "){for(var v=0,b=0;u[l]===d;)v++,l++;for(var x=(u.length-l)*g+1>>>0,C=new Uint8Array(x);u[l];){var w=r[u.charCodeAt(l)];if(w===255)return;for(var S=0,I=x-1;(w!==0||S<b)&&I!==-1;I--,S++)w+=a*C[I]>>>0,C[I]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");b=S,l++}if(u[l]!==" "){for(var y=x-b;y!==x&&C[y]===0;)y++;for(var A=new Uint8Array(v+(x-y)),N=v;y!==x;)A[N++]=C[y++];return A}}}function P(u){var l=m(u);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:m,decode:P}}var gs=ws,xs=gs,Vr=xs;var Su=new Uint8Array(0);var Wr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},W=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var qr=t=>new TextEncoder().encode(t),jr=t=>new TextDecoder().decode(t);var ft=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},dt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 _r(this,e)}},lt=class{constructor(e){this.decoders=e}or(e){return _r(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},_r=(t,e)=>new lt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),ht=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ft(e,r,n),this.decoder=new dt(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},ce=({name:t,prefix:e,encode:r,decode:n})=>new ht(t,e,r,n),_=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Vr(r,e);return ce({prefix:t,name:e,encode:n,decode:s=>W(o(s))})},ys=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,d=0,g=0;for(let c=0;c<s;++c){let p=o[t[c]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|p,a+=r,a>=8&&(a-=8,i[g++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},vs=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},T=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>ce({prefix:e,name:t,encode(o){return vs(o,n,r)},decode(o){return ys(o,n,r,t)}});var L=_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cs=_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Es=Hr,Jr=128,Ss=127,As=~Ss,Is=Math.pow(2,31);function Hr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Is;)e[r++]=t&255|Jr,t/=128;for(;t&As;)e[r++]=t&255|Jr,t>>>=7;return e[r]=t|0,Hr.bytes=r-n+1,e}var Us=bt,Ps=128,Gr=127;function bt(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw bt.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&Gr)<<o:(i&Gr)*Math.pow(2,o),o+=7}while(i>=Ps);return bt.bytes=s-n,r}var Ts=Math.pow(2,7),Fs=Math.pow(2,14),Ds=Math.pow(2,21),Ns=Math.pow(2,28),Os=Math.pow(2,35),Ls=Math.pow(2,42),ks=Math.pow(2,49),Ms=Math.pow(2,56),zs=Math.pow(2,63),Rs=function(t){return t<Ts?1:t<Fs?2:t<Ds?3:t<Ns?4:t<Os?5:t<Ls?6:t<ks?7:t<Ms?8:t<zs?9:10},Bs={encode:Es,decode:Us,encodingLength:Rs},$s=Bs,Ae=$s;var Ie=(t,e=0)=>[Ae.decode(t,e),Ae.decode.bytes],ue=(t,e,r=0)=>(Ae.encode(t,e,r),e),pe=t=>Ae.encodingLength(t);var ee=(t,e)=>{let r=e.byteLength,n=pe(t),o=n+pe(r),s=new Uint8Array(o+r);return ue(t,s,0),ue(r,s,n),s.set(e,o),new fe(t,r,e,s)},je=t=>{let e=W(t),[r,n]=Ie(e),[o,s]=Ie(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new fe(r,o,i,e)},Xr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Wr(t.bytes,r.bytes)}},fe=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var wt={};U(wt,{base32:()=>q,base32hex:()=>js,base32hexpad:()=>_s,base32hexpadupper:()=>Js,base32hexupper:()=>Qs,base32pad:()=>Ws,base32padupper:()=>qs,base32upper:()=>Vs,base32z:()=>Gs});var q=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vs=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ws=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qs=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),js=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qs=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_s=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Js=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gs=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Kr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return Xs(r,gt(t),e||L.encoder);default:return Ks(r,gt(t),e||q.encoder)}};var Zr=new WeakMap,gt=t=>{let e=Zr.get(t);if(e==null){let r=new Map;return Zr.set(t,r),r}return e},J=class t{constructor(e,r,n,o){this.code=r,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:r}=this;if(e!==Ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Zs)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=ee(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Xr(e.multihash,n.multihash)}toString(e){return Kr(this,e)}toJSON(){return{"/":Kr(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i||Yr(n,o,s.bytes))}else if(r[Ys]===!0){let{version:n,multihash:o,code:s}=r,i=je(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="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(r!==Ue)throw new Error(`Version 0 CID must use dag-pb (code: ${Ue}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Yr(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Ue,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=W(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new fe(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[p,m]=Ie(e.subarray(r));return r+=m,p},o=n(),s=Ue;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),d=n(),g=r+d,c=g-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:c,size:g}}static parse(e,r){let[n,o]=Hs(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return gt(s).set(n,e),s}},Hs=(t,e)=>{switch(t[0]){case"Q":{let r=e||L;return[L.prefix,r.decode(`${L.prefix}${t}`)]}case L.prefix:{let r=e||L;return[L.prefix,r.decode(t)]}case q.prefix:{let r=e||q;return[q.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},Xs=(t,e,r)=>{let{prefix:n}=r;if(n!==L.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},Ks=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},Ue=112,Zs=18,Yr=(t,e,r)=>{let n=pe(t),o=n+pe(e),s=new Uint8Array(o+r.byteLength);return ue(t,s,0),ue(e,s,n),s.set(r,o),s},Ys=Symbol.for("@ipld/js-cid/CID");function en(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var Et={};U(Et,{identity:()=>si});function ei(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=t.length,d=t.charAt(0),g=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function p(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 l=0,v=0,b=0,x=u.length;b!==x&&u[b]===0;)b++,l++;for(var C=(x-b)*c+1>>>0,w=new Uint8Array(C);b!==x;){for(var S=u[b],I=0,y=C-1;(S!==0||I<v)&&y!==-1;y--,I++)S+=256*w[y]>>>0,w[y]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");v=I,b++}for(var A=C-v;A!==C&&w[A]===0;)A++;for(var N=d.repeat(l);A<C;++A)N+=t.charAt(w[A]);return N}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var l=0;if(u[l]!==" "){for(var v=0,b=0;u[l]===d;)v++,l++;for(var x=(u.length-l)*g+1>>>0,C=new Uint8Array(x);u[l];){var w=r[u.charCodeAt(l)];if(w===255)return;for(var S=0,I=x-1;(w!==0||S<b)&&I!==-1;I--,S++)w+=a*C[I]>>>0,C[I]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");b=S,l++}if(u[l]!==" "){for(var y=x-b;y!==x&&C[y]===0;)y++;for(var A=new Uint8Array(v+(x-y)),N=v;y!==x;)A[N++]=C[y++];return A}}}function P(u){var l=m(u);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:m,decode:P}}var ti=ei,ri=ti,tn=ri;var $u=new Uint8Array(0);var rn=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},j=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var nn=t=>new TextEncoder().encode(t),on=t=>new TextDecoder().decode(t);var xt=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},yt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.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 an(this,e)}},vt=class{constructor(e){this.decoders=e}or(e){return an(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},an=(t,e)=>new vt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),Ct=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new xt(e,r,n),this.decoder=new yt(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},le=({name:t,prefix:e,encode:r,decode:n})=>new Ct(t,e,r,n),G=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=tn(r,e);return le({prefix:t,name:e,encode:n,decode:s=>j(o(s))})},ni=(t,e,r,n)=>{let o={};for(let c=0;c<e.length;++c)o[e[c]]=c;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,d=0,g=0;for(let c=0;c<s;++c){let p=o[t[c]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|p,a+=r,a>=8&&(a-=8,i[g++]=255&d>>a)}if(a>=r||255&d<<8-a)throw new SyntaxError("Unexpected end of data");return i},oi=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let d=0;d<t.length;++d)for(a=a<<8|t[d],i+=8;i>r;)i-=r,s+=e[o&a>>i];if(i&&(s+=e[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},F=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>le({prefix:e,name:t,encode(o){return oi(o,n,r)},decode(o){return ni(o,n,r,t)}});var si=le({prefix:"\0",name:"identity",encode:t=>on(t),decode:t=>nn(t)});var St={};U(St,{base2:()=>ii});var ii=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var At={};U(At,{base8:()=>ai});var ai=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var It={};U(It,{base10:()=>ci});var ci=G({prefix:"9",name:"base10",alphabet:"0123456789"});var Ut={};U(Ut,{base16:()=>ui,base16upper:()=>pi});var ui=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),pi=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Pt={};U(Pt,{base32:()=>he,base32hex:()=>hi,base32hexpad:()=>bi,base32hexpadupper:()=>wi,base32hexupper:()=>mi,base32pad:()=>di,base32padupper:()=>li,base32upper:()=>fi,base32z:()=>gi});var he=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fi=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),di=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),li=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),hi=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),mi=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bi=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),wi=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gi=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tt={};U(Tt,{base36:()=>xi,base36upper:()=>yi});var xi=G({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),yi=G({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ft={};U(Ft,{base58btc:()=>$,base58flickr:()=>vi});var $=G({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vi=G({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Dt={};U(Dt,{base64:()=>Ci,base64pad:()=>Ei,base64url:()=>Si,base64urlpad:()=>Ai});var Ci=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ei=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Si=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ai=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Nt={};U(Nt,{base256emoji:()=>Fi});var cn=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}"),Ii=cn.reduce((t,e,r)=>(t[r]=e,t),[]),Ui=cn.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Pi(t){return t.reduce((e,r)=>(e+=Ii[r],e),"")}function Ti(t){let e=[];for(let r of t){let n=Ui[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Fi=le({prefix:"\u{1F680}",name:"base256emoji",encode:Pi,decode:Ti});var Mt={};U(Mt,{sha256:()=>Hi,sha512:()=>Xi});var Di=fn,un=128,Ni=127,Oi=~Ni,Li=Math.pow(2,31);function fn(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Li;)e[r++]=t&255|un,t/=128;for(;t&Oi;)e[r++]=t&255|un,t>>>=7;return e[r]=t|0,fn.bytes=r-n+1,e}var ki=Ot,Mi=128,pn=127;function Ot(t,n){var r=0,n=n||0,o=0,s=n,i,a=t.length;do{if(s>=a)throw Ot.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&pn)<<o:(i&pn)*Math.pow(2,o),o+=7}while(i>=Mi);return Ot.bytes=s-n,r}var zi=Math.pow(2,7),Ri=Math.pow(2,14),Bi=Math.pow(2,21),$i=Math.pow(2,28),Vi=Math.pow(2,35),Wi=Math.pow(2,42),qi=Math.pow(2,49),ji=Math.pow(2,56),Qi=Math.pow(2,63),_i=function(t){return t<zi?1:t<Ri?2:t<Bi?3:t<$i?4:t<Vi?5:t<Wi?6:t<qi?7:t<ji?8:t<Qi?9:10},Ji={encode:Di,decode:ki,encodingLength:_i},Gi=Ji,Pe=Gi;var Te=(t,e=0)=>[Pe.decode(t,e),Pe.decode.bytes],me=(t,e,r=0)=>(Pe.encode(t,e,r),e),be=t=>Pe.encodingLength(t);var te=(t,e)=>{let r=e.byteLength,n=be(t),o=n+be(r),s=new Uint8Array(o+r);return me(t,s,0),me(r,s,n),s.set(e,o),new we(t,r,e,s)},dn=t=>{let e=j(t),[r,n]=Te(e),[o,s]=Te(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new we(r,o,i,e)},ln=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&rn(t.bytes,r.bytes)}},we=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var kt=({name:t,code:e,encode:r})=>new Lt(t,e,r),Lt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?te(this.code,r):r.then(n=>te(this.code,n))}else throw Error("Unknown type, must be binary type")}};var mn=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Hi=kt({name:"sha2-256",code:18,encode:mn("SHA-256")}),Xi=kt({name:"sha2-512",code:19,encode:mn("SHA-512")});var zt={};U(zt,{identity:()=>Yi});var bn=0,Ki="identity",wn=j,Zi=t=>te(bn,wn(t)),Yi={code:bn,name:Ki,encode:wn,digest:Zi};var ap=new TextEncoder,cp=new TextDecoder;var gn=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return na(r,Rt(t),e||$.encoder);default:return oa(r,Rt(t),e||he.encoder)}};var xn=new WeakMap,Rt=t=>{let e=xn.get(t);if(e==null){let r=new Map;return xn.set(t,r),r}return e},_e=class t{constructor(e,r,n,o){this.code=r,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:r}=this;if(e!==De)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==sa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}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:r}=this.multihash,n=te(e,r);return t.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 t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&ln(e.multihash,n.multihash)}toString(e){return gn(this,e)}toJSON(){return{"/":gn(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 r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i||yn(n,o,s.bytes))}else if(r[ia]===!0){let{version:n,multihash:o,code:s}=r,i=dn(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="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(r!==De)throw new Error(`Version 0 CID must use dag-pb (code: ${De}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=yn(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,De,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=j(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new we(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[p,m]=Te(e.subarray(r));return r+=m,p},o=n(),s=De;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),d=n(),g=r+d,c=g-i;return{version:o,codec:s,multihashCode:a,digestSize:d,multihashSize:c,size:g}}static parse(e,r){let[n,o]=ra(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Rt(s).set(n,e),s}},ra=(t,e)=>{switch(t[0]){case"Q":{let r=e||$;return[$.prefix,r.decode(`${$.prefix}${t}`)]}case $.prefix:{let r=e||$;return[$.prefix,r.decode(t)]}case he.prefix:{let r=e||he;return[he.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},na=(t,e,r)=>{let{prefix:n}=r;if(n!==$.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},oa=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},De=112,sa=18,yn=(t,e,r)=>{let n=be(t),o=n+be(e),s=new Uint8Array(o+r.byteLength);return me(t,s,0),me(e,s,n),s.set(r,o),s},ia=Symbol.for("@ipld/js-cid/CID");var Bt={...Et,...St,...At,...It,...Ut,...Pt,...Tt,...Ft,...Dt,...Nt},gp={...Mt,...zt};function ge(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Je(t=0){return globalThis.Buffer?.allocUnsafe!=null?ge(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Cn(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var vn=Cn("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),$t=Cn("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Je(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),aa={utf8:vn,"utf-8":vn,hex:Bt.base16,latin1:$t,ascii:$t,binary:$t,...Bt},Ge=aa;function k(t,e="utf8"){let r=Ge[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var dr=Z(He(),1);function Q(t,e){e==null&&(e=t.reduce((o,s)=>o+s.length,0));let r=Je(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return ge(r)}var ye=Z(He(),1);var Xe=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let r=this.index,n=e();return n===void 0&&(this.index=r),n}parseWith(e){let r=e();if(this.index===this.input.length)return r}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let r=this.readChar();if(r===e)return r})}readSeparator(e,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let d=a==="0",g=2**(8*o)-1;for(;;){let c=this.readAtomically(()=>{let p=this.readChar();if(p===void 0)return;let m=Number.parseInt(p,e);if(!Number.isNaN(m))return m});if(c===void 0)break;if(s*=e,s+=c,s>g||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&d&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let r=0;r<e.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[r]=n}return e})}readIPv6Addr(){let e=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return r[o]=i[0],r[o+1]=i[1],r[o+2]=i[2],r[o+3]=i[3],[o+4,!0]}let s=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(s===void 0)return[o,!1];r[o]=s>>8,r[o+1]=s&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=e(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let s=new Uint8Array(14),i=16-(n+2),[a]=e(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Nn=45,va=15,xe=new Xe;function qt(t){if(!(t.length>va))return xe.new(t).parseWith(()=>xe.readIPv4Addr())}function jt(t){if(!(t.length>Nn))return xe.new(t).parseWith(()=>xe.readIPv6Addr())}function Ke(t){if(!(t.length>Nn))return xe.new(t).parseWith(()=>xe.readIPAddr())}var jp=parseInt("0xFFFF",16),Qp=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Qt={};U(Qt,{identity:()=>Ia});var Ia=ce({prefix:"\0",name:"identity",encode:t=>jr(t),decode:t=>qr(t)});var _t={};U(_t,{base2:()=>Ua});var Ua=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Jt={};U(Jt,{base8:()=>Pa});var Pa=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gt={};U(Gt,{base10:()=>Ta});var Ta=_({prefix:"9",name:"base10",alphabet:"0123456789"});var Ht={};U(Ht,{base16:()=>Fa,base16upper:()=>Da});var Fa=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Da=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Xt={};U(Xt,{base36:()=>Na,base36upper:()=>Oa});var Na=_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Oa=_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Kt={};U(Kt,{base64:()=>La,base64pad:()=>ka,base64url:()=>Ma,base64urlpad:()=>za});var La=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ka=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ma=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),za=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zt={};U(Zt,{base256emoji:()=>Wa});var kn=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}"),Ra=kn.reduce((t,e,r)=>(t[r]=e,t),[]),Ba=kn.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function $a(t){return t.reduce((e,r)=>(e+=Ra[r],e),"")}function Va(t){let e=[];for(let r of t){let n=Ba[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var Wa=ce({prefix:"\u{1F680}",name:"base256emoji",encode:$a,decode:Va});var tr={};U(tr,{sha256:()=>qa,sha512:()=>ja});var er=({name:t,code:e,encode:r})=>new Yt(t,e,r),Yt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?ee(this.code,r):r.then(n=>ee(this.code,n))}else throw Error("Unknown type, must be binary type")}};var zn=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),qa=er({name:"sha2-256",code:18,encode:zn("SHA-256")}),ja=er({name:"sha2-512",code:19,encode:zn("SHA-512")});var rr={};U(rr,{identity:()=>Ja});var Rn=0,Qa="identity",Bn=W,_a=t=>ee(Rn,Bn(t)),Ja={code:Rn,name:Qa,encode:Bn,digest:_a};var If=new TextEncoder,Uf=new TextDecoder;var $n={...Qt,..._t,...Jt,...Gt,...Ht,...wt,...Xt,...mt,...Kt,...Zt},Nf={...tr,...rr};function Ne(t,e="utf8"){let r=Ge[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ge(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var V=Z(He(),1);function Vn(t){return!!qt(t)}function Wn(t){return!!jt(t)}function Ze(t){return!!Ke(t)}var qn=Vn,Xa=Wn,nr=function(t){let e=0;if(t=t.toString().trim(),qn(t)){let r=new Uint8Array(e+4);return t.split(/\./g).forEach(n=>{r[e++]=parseInt(n,10)&255}),r}if(Xa(t)){let r=t.split(":",8),n;for(n=0;n<r.length;n++){let s=qn(r[n]),i;s&&(i=nr(r[n]),r[n]=k(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,k(i.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let s=[n,1];for(n=9-r.length;n>0;n--)s.push("0");r.splice.apply(r,s)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[e++]=s>>8&255,o[e++]=s&255}return o}throw new Error("invalid ip address")},jn=function(t,e=0,r){e=~~e,r=r??t.length-e;let n=new DataView(t.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(t[e+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(e+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Oe={},or={},Za=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Za.forEach(t=>{let e=Ya(...t);or[e.code]=e,Oe[e.name]=e});function Ya(t,e,r,n,o){return{code:t,size:e,name:r,resolvable:!!n,path:!!o}}function E(t){if(typeof t=="number"){if(or[t]!=null)return or[t];throw new Error(`no protocol with code: ${t}`)}else if(typeof t=="string"){if(Oe[t]!=null)return Oe[t];throw new Error(`no protocol with name: ${t}`)}throw new Error(`invalid protocol id type: ${typeof t}`)}var Zf=E("ip4"),Yf=E("ip6"),ed=E("ipcidr");function Hn(t,e){switch(E(t).code){case 4:case 41:return tc(e);case 42:return Jn(e);case 6:case 273:case 33:case 132:return Kn(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Jn(e);case 421:return sc(e);case 444:return Gn(e);case 445:return Gn(e);case 466:return oc(e);default:return k(e,"base16")}}function Xn(t,e){switch(E(t).code){case 4:return Qn(e);case 41:return Qn(e);case 42:return _n(e);case 6:case 273:case 33:case 132:return ir(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _n(e);case 421:return rc(e);case 444:return ic(e);case 445:return ac(e);case 466:return nc(e);default:return Ne(e,"base16")}}var sr=Object.values($n).map(t=>t.decoder),ec=function(){let t=sr[0].or(sr[1]);return sr.slice(2).forEach(e=>t=t.or(e)),t}();function Qn(t){if(!Ze(t))throw new Error("invalid ip address");return nr(t)}function tc(t){let e=jn(t,0,t.length);if(e==null)throw new Error("ipBuff is required");if(!Ze(e))throw new Error("invalid ip address");return e}function ir(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,t),new Uint8Array(e)}function Kn(t){return new DataView(t.buffer).getUint16(t.byteOffset)}function _n(t){let e=Ne(t),r=Uint8Array.from(V.default.encode(e.length));return Q([r,e],r.length+e.length)}function Jn(t){let e=V.default.decode(t);if(t=t.slice(V.default.decode.bytes),t.length!==e)throw new Error("inconsistent lengths");return k(t)}function rc(t){let e;t[0]==="Q"||t[0]==="1"?e=je(L.decode(`z${t}`)).bytes:e=J.parse(t).multihash.bytes;let r=Uint8Array.from(V.default.encode(e.length));return Q([r,e],r.length+e.length)}function nc(t){let e=ec.decode(t),r=Uint8Array.from(V.default.encode(e.length));return Q([r,e],r.length+e.length)}function oc(t){let e=V.default.decode(t),r=t.slice(V.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return"u"+k(r,"base64url")}function sc(t){let e=V.default.decode(t),r=t.slice(V.default.decode.bytes);if(r.length!==e)throw new Error("inconsistent lengths");return k(r,"base58btc")}function ic(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=q.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ir(n);return Q([r,o],r.length+o.length)}function ac(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=q.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ir(n);return Q([r,o],r.length+o.length)}function Gn(t){let e=t.slice(0,t.length-2),r=t.slice(t.length-2),n=k(e,"base32"),o=Kn(r);return`${n}:${o}`}function cc(t){let e=[],r=t.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=E(o);if(s.size===0){e.push([o]);continue}if(n++,n>=r.length)throw Yn("invalid address: "+t);if(s.path===!0){e.push([o,fr(r.slice(n).join("/"))]);break}e.push([o,r[n]])}return e}function uc(t){let e=[];return t.map(r=>{let n=tt(r);return e.push(n.name),r.length>1&&r[1]!=null&&e.push(r[1]),null}),fr(e.join("/"))}function pc(t){return t.map(e=>{Array.isArray(e)||(e=[e]);let r=tt(e);return e.length>1?[r.code,Xn(r.code,e[1])]:[r.code]})}function ar(t){return t.map(e=>{let r=tt(e);return e[1]!=null?[r.code,Hn(r.code,e[1])]:[r.code]})}function cr(t){return et(Q(t.map(e=>{let r=tt(e),n=Uint8Array.from(ye.default.encode(r.code));return e.length>1&&e[1]!=null&&(n=Q([n,e[1]])),n})))}function ur(t,e){return t.size>0?t.size/8:t.size===0?0:ye.default.decode(e)+(ye.default.decode.bytes??0)}function Ye(t){let e=[],r=0;for(;r<t.length;){let n=ye.default.decode(t,r),o=ye.default.decode.bytes??0,s=E(n),i=ur(s,t.slice(r+o));if(i===0){e.push([n]),r+=o;continue}let a=t.slice(r+o,r+o+i);if(r+=i+o,r>t.length)throw Yn("Invalid address Uint8Array: "+k(t,"base16"));e.push([n,a])}return e}function pr(t){let e=Ye(t),r=ar(e);return uc(r)}function fc(t){t=fr(t);let e=cc(t),r=pc(e);return cr(r)}function Zn(t){return fc(t)}function et(t){let e=dc(t);if(e!=null)throw e;return Uint8Array.from(t)}function dc(t){try{Ye(t)}catch(e){return e}}function fr(t){return"/"+t.trim().split("/").filter(e=>e).join("/")}function Yn(t){return new Error("Error parsing address: "+t)}function tt(t){return E(t[0])}var hc=Symbol.for("nodejs.util.inspect.custom"),mc=[E("dns").code,E("dns4").code,E("dns6").code,E("dnsaddr").code],bc=new Map,eo=Symbol.for("@multiformats/js-multiaddr/multiaddr");function wc(t){return!!t?.[eo]}var lr=class t{bytes;#t;#r;#n;#e;[eo]=!0;constructor(e){if(e==null&&(e=""),e instanceof Uint8Array)this.bytes=et(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);this.bytes=Zn(e)}else if(wc(e))this.bytes=et(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=pr(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let e,r,n,o,s="",i=E("tcp"),a=E("udp"),d=E("ip4"),g=E("ip6"),c=E("dns6"),p=E("ip6zone");for(let[P,u]of this.stringTuples())P===p.code&&(s=`%${u??""}`),mc.includes(P)&&(r=i.name,o=443,n=`${u??""}${s}`,e=P===c.code?6:4),(P===i.code||P===a.code)&&(r=E(P).name,o=parseInt(u??"")),(P===d.code||P===g.code)&&(r=E(P).name,n=`${u??""}${s}`,e=P===g.code?6:4);if(e==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:r,port:o}}protos(){return this.protoCodes().map(e=>Object.assign({},E(e)))}protoCodes(){let e=[],r=this.bytes,n=0;for(;n<r.length;){let o=dr.default.decode(r,n),s=dr.default.decode.bytes??0,i=E(o),a=ur(i,r.slice(n+s));n+=a+s,e.push(o)}return e}protoNames(){return this.protos().map(e=>e.name)}tuples(){return this.#r==null&&(this.#r=Ye(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=ar(this.tuples())),this.#n}encapsulate(e){return e=new t(e),new t(this.toString()+e.toString())}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new t(n.slice(0,o))}decapsulateCode(e){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===e)return new t(cr(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===Oe.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?k(L.decode(`z${n}`),"base58btc"):k(J.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(e=>E(e[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(e){return en(this.bytes,e.bytes)}async resolve(e){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=bc.get(r.name);if(n==null)throw new We(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(s=>new t(s))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let r=(e??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[hc](){return`Multiaddr(${pr(this.bytes)})`}};function ve(t){return new lr(t)}function to(t){let e;try{e=E("sni").code}catch{return null}for(let[r,n]of t)if(r===e&&n!==void 0)return n;return null}function ro(t){return t.some(([e,r])=>e===E("tls").code)}function B(t,e,r){let n=no[E(t).name];if(n===void 0)throw new Error(`Can't interpret protocol ${E(t).name}`);let o=n(e,r);return t===E("ip6").code?`[${o}]`:o}var no={ip4:(t,e)=>t,ip6:(t,e)=>e.length===0?t:`[${t}]`,tcp:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${B(r[0],r[1]??"",e)}:${t}`},udp:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${B(r[0],r[1]??"",e)}:${t}`},dnsaddr:(t,e)=>t,dns4:(t,e)=>t,dns6:(t,e)=>t,dns:(t,e)=>t,ipfs:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${B(r[0],r[1]??"",e)}/ipfs/${t}`},p2p:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${B(r[0],r[1]??"",e)}/p2p/${t}`},http:(t,e)=>{let r=ro(e),n=to(e);if(r&&n!==null)return`https://${n}`;let o=r?"https://":"http://",s=e.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=B(s[0],s[1]??"",e);return i=i.replace("tcp://",""),`${o}${i}`},tls:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return B(r[0],r[1]??"",e)},sni:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return B(r[0],r[1]??"",e)},https:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=B(r[0],r[1]??"",e);return n=n.replace("tcp://",""),`https://${n}`},ws:(t,e)=>{let r=ro(e),n=to(e);if(r&&n!==null)return`wss://${n}`;let o=r?"wss://":"ws://",s=e.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=B(s[0],s[1]??"",e);return i=i.replace("tcp://",""),`${o}${i}`},wss:(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=B(r[0],r[1]??"",e);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${B(r[0],r[1]??"",e)}/p2p-websocket-star`},"p2p-webrtc-star":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${B(r[0],r[1]??"",e)}/p2p-webrtc-star`},"p2p-webrtc-direct":(t,e)=>{let r=e.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${B(r[0],r[1]??"",e)}/p2p-webrtc-direct`}};function oo(t,e){let n=ve(t).stringTuples(),o=n.pop();if(o===void 0)throw new Error("Unexpected end of multiaddr");let s=E(o[0]),i=no[s.name];if(i==null)throw new Error(`No interpreter found for ${s.name}`);let a=i(o[1]??"",n);return e?.assumeHttp!==!1&&o[0]===E("tcp").code&&(a=a.replace("tcp://","http://"),(o[1]==="443"||o[1]==="80")&&(o[1]==="443"&&(a=a.replace("http://","https://")),a=a.substring(0,a.lastIndexOf(":")))),a}var so=WebSocket;var uo=Z(ao(),1);function co(t){return t instanceof ArrayBuffer||t?.constructor?.name==="ArrayBuffer"&&typeof t?.byteLength=="number"}var po=t=>{t.binaryType="arraybuffer";let e=async()=>{await new Promise((s,i)=>{if(n){s();return}if(o!=null){i(o);return}let a=c=>{t.removeEventListener("open",d),t.removeEventListener("error",g),c()},d=()=>{a(s)},g=c=>{a(()=>{i(c.error??new Error(`connect ECONNREFUSED ${t.url}`))})};t.addEventListener("open",d),t.addEventListener("error",g)})},r=async function*(){let s=new uo.EventIterator(({push:i,stop:a,fail:d})=>{let g=p=>{let m=null;typeof p.data=="string"&&(m=Ne(p.data)),co(p.data)&&(m=new Uint8Array(p.data)),p.data instanceof Uint8Array&&(m=p.data),m!=null&&i(m)},c=p=>{d(p.error??new Error("Socket error"))};return t.addEventListener("message",g),t.addEventListener("error",c),t.addEventListener("close",a),()=>{t.removeEventListener("message",g),t.removeEventListener("error",c),t.removeEventListener("close",a)}},{highWaterMark:1/0});await e();for await(let i of s)yield co(i)?new Uint8Array(i):i}(),n=t.readyState===1,o;return t.addEventListener("open",()=>{n=!0,o=null}),t.addEventListener("close",()=>{n=!1,o=null}),t.addEventListener("error",s=>{n||(o=s.error??new Error(`connect ECONNREFUSED ${t.url}`))}),Object.assign(r,{connected:e})};var fo=async t=>{if(t.readyState>=2)throw new Error("socket closed");t.readyState!==1&&await new Promise((e,r)=>{function n(){t.removeEventListener("open",o),t.removeEventListener("error",s)}function o(){n(),e()}function s(i){n(),r(i.error??new Error(`connect ECONNREFUSED ${t.url}`))}t.addEventListener("open",o),t.addEventListener("error",s)})};var lo=(t,e)=>(e=e??{},e.closeOnEnd=e.closeOnEnd!==!1,async n=>{for await(let o of n){try{await fo(t)}catch(s){if(s.message==="socket closed")break;throw s}t.send(o)}e.closeOnEnd!=null&&t.readyState<=1&&await new Promise((o,s)=>{t.addEventListener("close",i=>{if(i.wasClean||i.code===1006)o();else{let a=Object.assign(new Error("ws error"),{event:i});s(a)}}),setTimeout(()=>{t.close()})})});var ho=(t,e)=>{e=e??{};let r=po(t),n=e.remoteAddress,o=e.remotePort;if(t.url!=null)try{let i=new URL(t.url);n=i.hostname,o=parseInt(i.port,10)}catch{}if(n==null||o==null)throw new Error("Remote connection did not have address and/or port");return{sink:lo(t,e),source:r,connected:async()=>{await r.connected()},close:async()=>{(t.readyState===t.CONNECTING||t.readyState===t.OPEN)&&await new Promise(i=>{t.addEventListener("close",()=>{i()}),t.close()})},destroy:()=>{t.terminate!=null?t.terminate():t.close()},remoteAddress:n,remotePort:o,socket:t}};var Co=Z(vo(),1),Pc={http:"ws",https:"wss"},Tc="ws",Eo=(t,e)=>(0,Co.relative)(t,e,Pc,Tc);function So(t,e){let r=typeof window>"u"?"":window.location;e=e??{};let n=Eo(t,r.toString()),o=new so(n,e.websocket);return ho(o,e)}function gr(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Uo=Z(Io(),1),Dc=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Po=(0,Uo.default)(),To=Dc&&!Po;var Wd=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Po,Fo=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,qd=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+(()=>"_")()+"ENV"]==="test",jd=typeof navigator<"u"&&navigator.product==="ReactNative";var Nc=f("dns4"),Oc=f("dns6"),Lc=f("dnsaddr"),X=D(f("dns"),Lc,Nc,Oc),ot=D(f("ip4"),f("ip6")),Ce=D(h(ot,f("tcp")),h(X,f("tcp"))),st=h(ot,f("udp")),kc=h(st,f("utp")),Mc=h(st,f("quic")),zc=h(st,f("quic-v1")),xr=D(h(Ce,f("ws")),h(X,f("ws"))),Ee=D(h(xr,f("p2p")),xr),yr=D(h(Ce,f("wss")),h(X,f("wss")),h(Ce,f("tls"),f("ws")),h(X,f("tls"),f("ws"))),ne=D(h(yr,f("p2p")),yr),vr=D(h(Ce,f("http")),h(ot,f("http")),h(X,f("http"))),Cr=D(h(Ce,f("https")),h(ot,f("https")),h(X,f("https"))),Do=h(st,f("webrtc-direct"),f("certhash")),Lo=D(h(Do,f("p2p")),Do),No=h(zc,f("webtransport"),f("certhash"),f("certhash")),ko=D(h(No,f("p2p")),No),Mo=D(h(Ee,f("p2p-webrtc-star"),f("p2p")),h(ne,f("p2p-webrtc-star"),f("p2p")),h(Ee,f("p2p-webrtc-star")),h(ne,f("p2p-webrtc-star"))),Jd=D(h(Ee,f("p2p-websocket-star"),f("p2p")),h(ne,f("p2p-websocket-star"),f("p2p")),h(Ee,f("p2p-websocket-star")),h(ne,f("p2p-websocket-star"))),zo=D(h(vr,f("p2p-webrtc-direct"),f("p2p")),h(Cr,f("p2p-webrtc-direct"),f("p2p")),h(vr,f("p2p-webrtc-direct")),h(Cr,f("p2p-webrtc-direct"))),oe=D(xr,yr,vr,Cr,Mo,zo,Ce,kc,Mc,X,Lo,ko),Gd=D(h(oe,f("p2p-stardust"),f("p2p")),h(oe,f("p2p-stardust"))),H=D(h(oe,f("p2p")),Mo,zo,Lo,ko,f("p2p")),Oo=D(h(H,f("p2p-circuit"),H),h(H,f("p2p-circuit")),h(f("p2p-circuit"),H),h(oe,f("p2p-circuit")),h(f("p2p-circuit"),oe),f("p2p-circuit")),Ro=()=>D(h(Oo,Ro),Oo),re=Ro(),Hd=D(h(re,H,re),h(H,re),h(re,H),re,H);var Xd=D(h(re,f("webrtc"),f("p2p")),h(re,f("webrtc")),h(oe,f("webrtc"),f("p2p")),h(oe,f("webrtc")),f("webrtc"));function Bo(t){function e(r){let n;try{n=ve(r)}catch{return!1}let o=t(n.protoNames());return o===null?!1:o===!0||o===!1?o:o.length===0}return e}function h(...t){function e(r){if(r.length<t.length)return null;let n=r;return t.some(o=>(n=typeof o=="function"?o().partialMatch(r):o.partialMatch(r),Array.isArray(n)&&(r=n),n===null)),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Bo(e),partialMatch:e}}function D(...t){function e(n){let o=null;return t.some(s=>{let i=typeof s=="function"?s().partialMatch(n):s.partialMatch(n);return i!=null?(o=i,!0):!1}),o}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Bo(e),partialMatch:e}}function f(t){let e=t;function r(o){let s;try{s=ve(o)}catch{return!1}let i=s.protoNames();return i.length===1&&i[0]===e}function n(o){return o.length===0?null:o[0]===e?o.slice(1):null}return{toString:function(){return e},matches:r,partialMatch:n}}function Wo(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return Ee.matches(r)||ne.matches(r)})}function qo(t){return t.filter(e=>{if(e.protoCodes().includes(290))return!1;let r=e.decapsulateCode(421);return ne.matches(r)})}function jo(){throw new Error("WebSocket Servers can not be created in the browser!")}var Me=class extends Error{constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Qo(t){if(t!=null){if(typeof t[Symbol.iterator]=="function")return t[Symbol.iterator]();if(typeof t[Symbol.asyncIterator]=="function")return t[Symbol.asyncIterator]();if(typeof t.next=="function")return t}throw new Error("argument is not an iterator or iterable")}function Er(t,e,r){let n=r??{},o=Qo(t);async function*s(){let i,a=()=>{i?.()};for(e.addEventListener("abort",a);;){let d;try{if(e.aborted){let{abortMessage:c,abortCode:p}=n;throw new Me(c,p)}let g=new Promise((c,p)=>{i=()=>{let{abortMessage:m,abortCode:P}=n;p(new Me(m,P))}});d=await Promise.race([g,o.next()]),i=null}catch(g){e.removeEventListener("abort",a);let c=g.type==="aborted"&&e.aborted;if(c&&n.onAbort!=null&&n.onAbort(t),typeof o.return=="function")try{let p=o.return();p instanceof Promise&&p.catch(m=>{n.onReturnError!=null&&n.onReturnError(m)})}catch(p){n.onReturnError!=null&&n.onReturnError(p)}if(c&&n.returnOnAbort===!0)return;throw g}if(d.done===!0)break;yield d.value}e.removeEventListener("abort",a)}return s()}var Sr=Ve("libp2p:websockets:socket");function _o(t,e,r){r=r??{};let n={async sink(o){r?.signal!=null&&(o=Er(o,r.signal));try{await t.sink(o)}catch(s){s.type!=="aborted"&&Sr.error(s)}},source:r.signal!=null?Er(t.source,r.signal):t.source,remoteAddr:e,timeline:{open:Date.now()},async close(o={}){let s=Date.now();o.signal=o.signal??AbortSignal.timeout(500);let i=()=>{let{host:a,port:d}=n.remoteAddr.toOptions();Sr("timeout closing stream to %s:%s after %dms, destroying it manually",a,d,Date.now()-s),this.abort(new Re("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};o.signal.addEventListener("abort",i);try{await t.close()}catch(a){this.abort(a)}finally{o.signal.removeEventListener("abort",i),n.timeline.close=Date.now()}},abort(o){let{host:s,port:i}=n.remoteAddr.toOptions();Sr("timeout closing stream to %s:%s due to error",s,i,o),t.destroy(),n.timeline.close=Date.now()}};return t.socket.addEventListener("close",()=>{n.timeline.close==null&&(n.timeline.close=Date.now())},{once:!0}),n}var K=Ve("libp2p:websockets"),Ar=class{init;constructor(e){this.init=e}[Symbol.toStringTag]="@libp2p/websockets";[Pr]=!0;async dial(e,r){K("dialing %s",e),r=r??{};let n=await this._connect(e,r),o=_o(n,e);K("new outbound connection %s",o.remoteAddr);let s=await r.upgrader.upgradeOutbound(o);return K("outbound connection %s upgraded",o.remoteAddr),s}async _connect(e,r){if(r?.signal?.aborted===!0)throw new Se;let n=e.toOptions();K("dialing %s:%s",n.host,n.port);let o=gr(),s=g=>{K.error("connection error:",g),o.reject(g)},i=So(oo(e),this.init);if(i.socket.on!=null?i.socket.on("error",s):i.socket.onerror=s,r.signal==null)return await Promise.race([i.connected(),o.promise]),K("connected %s",e),i;let a,d=new Promise((g,c)=>{if(a=()=>{c(new Se),i.close().catch(p=>{K.error("error closing raw socket",p)})},r?.signal?.aborted===!0){a();return}r?.signal?.addEventListener("abort",a)});try{await Promise.race([d,o.promise,i.connected()])}finally{a!=null&&r?.signal?.removeEventListener("abort",a)}return K("connected %s",e),i}createListener(e){return jo({...this.init,...e})}filter(e){return e=Array.isArray(e)?e:[e],this.init?.filter!=null?this.init?.filter(e):To||Fo?qo(e):Wo(e)}};function Vc(t={}){return()=>new Ar(t)}return Zo(Wc);})();
3
3
  return Libp2PWebsockets}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/websockets",
3
- "version": "6.0.3-b1024c6c",
3
+ "version": "6.0.3-c999d6a7",
4
4
  "description": "JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/transport-websockets#readme",
@@ -68,9 +68,9 @@
68
68
  "test:electron-main": "aegir test -t electron-main -f ./dist/test/node.js --cov"
69
69
  },
70
70
  "dependencies": {
71
- "@libp2p/interface": "0.0.1-b1024c6c",
72
- "@libp2p/logger": "2.1.1-b1024c6c",
73
- "@libp2p/utils": "3.0.12-b1024c6c",
71
+ "@libp2p/interface": "0.0.1-c999d6a7",
72
+ "@libp2p/logger": "2.1.1-c999d6a7",
73
+ "@libp2p/utils": "3.0.12-c999d6a7",
74
74
  "@multiformats/mafmt": "^12.1.2",
75
75
  "@multiformats/multiaddr": "^12.1.3",
76
76
  "@multiformats/multiaddr-to-uri": "^9.0.2",
@@ -82,8 +82,8 @@
82
82
  "ws": "^8.12.1"
83
83
  },
84
84
  "devDependencies": {
85
- "@libp2p/interface-compliance-tests": "3.0.7-b1024c6c",
86
- "aegir": "^39.0.13",
85
+ "@libp2p/interface-compliance-tests": "3.0.7-c999d6a7",
86
+ "aegir": "^40.0.1",
87
87
  "is-loopback-addr": "^2.0.1",
88
88
  "it-all": "^3.0.1",
89
89
  "it-drain": "^3.0.2",
@@ -96,8 +96,5 @@
96
96
  },
97
97
  "browser": {
98
98
  "./dist/src/listener.js": "./dist/src/listener.browser.js"
99
- },
100
- "typedoc": {
101
- "entryPoint": "./src/index.ts"
102
99
  }
103
100
  }