//<script src="https://unpkg.com/ipfs-http-client/dist/index.min.js"></script> (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsHttpClient = factory()}(typeof self !== 'undefined' ? self : this, function () { "use strict";var IpfsHttpClient=(()=>{var hd=Object.create;var xr=Object.defineProperty;var md=Object.getOwnPropertyDescriptor;var gd=Object.getOwnPropertyNames;var yd=Object.getPrototypeOf,wd=Object.prototype.hasOwnProperty;var _s=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var E=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),q=(e,t)=>{for(var r in t)xr(e,r,{get:t[r],enumerable:!0})},Ds=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gd(t))!wd.call(e,o)&&o!==r&&xr(e,o,{get:()=>t[o],enumerable:!(n=md(t,o))||n.enumerable});return e};var N=(e,t,r)=>(r=e!=null?hd(yd(e)):{},Ds(t||!e||!e.__esModule?xr(r,"default",{value:e,enumerable:!0}):r,e)),bd=e=>Ds(xr({},"__esModule",{value:!0}),e);var Da=E((F1,_a)=>{_a.exports=ko;var Na=128,ag=127,cg=~ag,ug=Math.pow(2,31);function ko(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw ko.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=ug;)t[r++]=e&255|Na,e/=128;for(;e&cg;)t[r++]=e&255|Na,e>>>=7;return t[r]=e|0,ko.bytes=r-n+1,t}});var Oa=E((z1,La)=>{La.exports=Uo;var fg=128,Ra=127;function Uo(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a||o>49)throw Uo.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Ra)<<o:(i&Ra)*Math.pow(2,o),o+=7}while(i>=fg);return Uo.bytes=s-n,r}});var Fa=E((j1,$a)=>{var lg=Math.pow(2,7),pg=Math.pow(2,14),dg=Math.pow(2,21),hg=Math.pow(2,28),mg=Math.pow(2,35),gg=Math.pow(2,42),yg=Math.pow(2,49),wg=Math.pow(2,56),bg=Math.pow(2,63);$a.exports=function(e){return e<lg?1:e<pg?2:e<dg?3:e<hg?4:e<mg?5:e<gg?6:e<yg?7:e<wg?8:e<bg?9:10}});var st=E((M1,za)=>{za.exports={encode:Da(),decode:Oa(),encodingLength:Fa()}});var te=E((cx,Qa)=>{"use strict";function Xa(e,t){for(let r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}function Dg(e,t,r){if(!e||typeof e=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof t=="object"&&(r=t,t=""),t&&(r.code=t);try{return Xa(e,r)}catch{r.message=e.message,r.stack=e.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(e)),Xa(new o,r)}}Qa.exports=Dg});var rc=E((gx,tc)=>{function $g(){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)}tc.exports=$g});var zo=E((yx,nc)=>{"use strict";var Fg=rc(),Xr=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,or=Fg(),zg=Xr&&!or,jg=or&&!Xr,Mg=or&&Xr,qg=typeof _s=="function"&&typeof process<"u"&&typeof process.release<"u"&&process.release.name==="node"&&!or,Vg=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Hg=typeof process<"u"&&typeof process.env<"u"&&!1,Gg=typeof navigator<"u"&&navigator.product==="ReactNative";nc.exports={isTest:Hg,isElectron:or,isElectronMain:jg,isElectronRenderer:Mg,isNode:qg,isBrowser:zg,isWebWorker:Vg,isEnvWithDom:Xr,isReactNative:Gg}});var ac=E((xx,ic)=>{var kt=1e3,Ut=kt*60,Bt=Ut*60,at=Bt*24,Jg=at*7,Kg=at*365.25;ic.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Xg(e);if(r==="number"&&isFinite(e))return t.long?Zg(e):Qg(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Xg(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Kg;case"weeks":case"week":case"w":return r*Jg;case"days":case"day":case"d":return r*at;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Bt;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ut;case"seconds":case"second":case"secs":case"sec":case"s":return r*kt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Qg(e){var t=Math.abs(e);return t>=at?Math.round(e/at)+"d":t>=Bt?Math.round(e/Bt)+"h":t>=Ut?Math.round(e/Ut)+"m":t>=kt?Math.round(e/kt)+"s":e+"ms"}function Zg(e){var t=Math.abs(e);return t>=at?Qr(e,t,at,"day"):t>=Bt?Qr(e,t,Bt,"hour"):t>=Ut?Qr(e,t,Ut,"minute"):t>=kt?Qr(e,t,kt,"second"):e+" ms"}function Qr(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var uc=E((Sx,cc)=>{function Yg(e){r.debug=r,r.default=r,r.coerce=c,r.disable=s,r.enable=o,r.enabled=i,r.humanize=ac(),r.destroy=l,Object.keys(e).forEach(d=>{r[d]=e[d]}),r.names=[],r.skips=[],r.formatters={};function t(d){let m=0;for(let x=0;x<d.length;x++)m=(m<<5)-m+d.charCodeAt(x),m|=0;return r.colors[Math.abs(m)%r.colors.length]}r.selectColor=t;function r(d){let m,x=null,P,T;function B(...D){if(!B.enabled)return;let M=B,Z=Number(new Date),fe=Z-(m||Z);M.diff=fe,M.prev=m,M.curr=Z,m=Z,D[0]=r.coerce(D[0]),typeof D[0]!="string"&&D.unshift("%O");let W=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(le,ne)=>{if(le==="%%")return"%";W++;let pe=r.formatters[ne];if(typeof pe=="function"){let lt=D[W];le=pe.call(M,lt),D.splice(W,1),W--}return le}),r.formatArgs.call(M,D),(M.log||r.log).apply(M,D)}return B.namespace=d,B.useColors=r.useColors(),B.color=r.selectColor(d),B.extend=n,B.destroy=r.destroy,Object.defineProperty(B,"enabled",{enumerable:!0,configurable:!1,get:()=>x!==null?x:(P!==r.namespaces&&(P=r.namespaces,T=r.enabled(d)),T),set:D=>{x=D}}),typeof r.init=="function"&&r.init(B),B}function n(d,m){let x=r(this.namespace+(typeof m>"u"?":":m)+d);return x.log=this.log,x}function o(d){r.save(d),r.namespaces=d,r.names=[],r.skips=[];let m,x=(typeof d=="string"?d:"").split(/[\s,]+/),P=x.length;for(m=0;m<P;m++)x[m]&&(d=x[m].replace(/\*/g,".*?"),d[0]==="-"?r.skips.push(new RegExp("^"+d.slice(1)+"$")):r.names.push(new RegExp("^"+d+"$")))}function s(){let d=[...r.names.map(a),...r.skips.map(a).map(m=>"-"+m)].join(",");return r.enable(""),d}function i(d){if(d[d.length-1]==="*")return!0;let m,x;for(m=0,x=r.skips.length;m<x;m++)if(r.skips[m].test(d))return!1;for(m=0,x=r.names.length;m<x;m++)if(r.names[m].test(d))return!0;return!1}function a(d){return d.toString().substring(2,d.toString().length-2).replace(/\.\*\?$/,"*")}function c(d){return d instanceof Error?d.stack||d.message:d}function l(){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}cc.exports=Yg});var fc=E((ce,Zr)=>{ce.formatArgs=ty;ce.save=ry;ce.load=ny;ce.useColors=ey;ce.storage=oy();ce.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})();ce.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 ey(){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 ty(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Zr.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}ce.log=console.debug||console.log||(()=>{});function ry(e){try{e?ce.storage.setItem("debug",e):ce.storage.removeItem("debug")}catch{}}function ny(){let e;try{e=ce.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function oy(){try{return localStorage}catch{}}Zr.exports=uc()(ce);var{formatters:sy}=Zr.exports;sy.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Vo=E(en=>{"use strict";var jo=class extends Error{constructor(t="Request timed out"){super(t),this.name="TimeoutError"}};en.TimeoutError=jo;var Mo=class extends Error{constructor(t="The operation was aborted."){super(t),this.name="AbortError"}};en.AbortError=Mo;var qo=class extends Error{constructor(t){super(t.statusText),this.name="HTTPError",this.response=t}};en.HTTPError=qo});var sr=E(()=>{});var lc=E((kx,Ho)=>{"use strict";globalThis.fetch&&globalThis.Headers&&globalThis.Request&&globalThis.Response?Ho.exports={default:globalThis.fetch,Headers:globalThis.Headers,Request:globalThis.Request,Response:globalThis.Response}:Ho.exports={default:sr().default,Headers:sr().Headers,Request:sr().Request,Response:sr().Response}});var dc=E((Ux,pc)=>{"use strict";pc.exports=lc()});var gc=E((Bx,mc)=>{"use strict";var{TimeoutError:ay,AbortError:cy}=Vo(),{Response:hc,Request:uy,Headers:Wo,default:fy}=dc(),ly=(e,t={})=>{let r=new XMLHttpRequest;r.open(t.method||"GET",e.toString(),!0);let{timeout:n,headers:o}=t;if(n&&n>0&&n<1/0&&(r.timeout=n),t.overrideMimeType!=null&&r.overrideMimeType(t.overrideMimeType),o)for(let[s,i]of new Wo(o))r.setRequestHeader(s,i);return t.signal&&(t.signal.onabort=()=>r.abort()),t.onUploadProgress&&(r.upload.onprogress=t.onUploadProgress),r.responseType="arraybuffer",new Promise((s,i)=>{let a=c=>{switch(c.type){case"error":{s(hc.error());break}case"load":{s(new Go(r.responseURL,r.response,{status:r.status,statusText:r.statusText,headers:hy(r.getAllResponseHeaders())}));break}case"timeout":{i(new ay);break}case"abort":{i(new cy);break}default:break}};r.onerror=a,r.onload=a,r.ontimeout=a,r.onabort=a,r.send(t.body)})},py=fy,dy=(e,t={})=>t.onUploadProgress!=null?ly(e,t):py(e,t),hy=e=>{let t=new Wo;for(let r of e.trim().split(/[\r\n]+/)){let n=r.indexOf(": ");n>0&&t.set(r.slice(0,n),r.slice(n+1))}return t},Go=class extends hc{constructor(t,r,n){super(r,n),Object.defineProperty(this,"url",{value:t})}};mc.exports={fetch:dy,Request:uy,Headers:Wo}});var wc=E((Nx,yc)=>{"use strict";yc.exports=e=>{if(Object.prototype.toString.call(e)!=="[object Object]")return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}});var Ko=E((Ec,Pc)=>{"use strict";var tn=wc(),{hasOwnProperty:xc}=Object.prototype,{propertyIsEnumerable:my}=Object,Nt=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),gy=Ec,bc={concatArrays:!1,ignoreUndefined:!1},rn=e=>{let t=[];for(let r in e)xc.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){let r=Object.getOwnPropertySymbols(e);for(let n of r)my.call(e,n)&&t.push(n)}return t};function _t(e){return Array.isArray(e)?yy(e):tn(e)?wy(e):e}function yy(e){let t=e.slice(0,0);return rn(e).forEach(r=>{Nt(t,r,_t(e[r]))}),t}function wy(e){let t=Object.getPrototypeOf(e)===null?Object.create(null):{};return rn(e).forEach(r=>{Nt(t,r,_t(e[r]))}),t}var Sc=(e,t,r,n)=>(r.forEach(o=>{typeof t[o]>"u"&&n.ignoreUndefined||(o in e&&e[o]!==Object.getPrototypeOf(e)?Nt(e,o,Jo(e[o],t[o],n)):Nt(e,o,_t(t[o])))}),e),by=(e,t,r)=>{let n=e.slice(0,0),o=0;return[e,t].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)xc.call(s,a)&&(i.push(String(a)),s===e?Nt(n,o++,s[a]):Nt(n,o++,_t(s[a])));n=Sc(n,s,rn(s).filter(a=>!i.includes(a)),r)}),n};function Jo(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?by(e,t,r):!tn(t)||!tn(e)?_t(t):Sc(e,t,rn(t),r)}Pc.exports=function(...e){let t=Jo(_t(bc),this!==gy&&this||{},bc),r={_:{}};for(let n of e)if(n!==void 0){if(!tn(n))throw new TypeError("`"+n+"` is not an Option Object");r=Jo(r,{_:n},t)}return r._}});var Qo=E((_x,vc)=>{"use strict";var xy=typeof navigator<"u"&&navigator.product==="ReactNative";function Sy(){return xy?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}var ir=self.URL,Tc=Sy(),Xo=class{constructor(t="",r=Tc){this.super=new ir(t,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(t){this.super.hash=t}set host(t){this.super.host=t}set hostname(t){this.super.hostname=t}set href(t){this.super.href=t}set password(t){this.super.password=t}set pathname(t){this.super.pathname=t}set port(t){this.super.port=t}set protocol(t){this.super.protocol=t}set search(t){this.super.search=t}set username(t){this.super.username=t}static createObjectURL(t){return ir.createObjectURL(t)}static revokeObjectURL(t){ir.revokeObjectURL(t)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}};function Ey(e){if(typeof e=="string")return new ir(e).toString();if(!(e instanceof ir)){let t=e.username&&e.password?`${e.username}:${e.password}@`:"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",o=e.protocol?e.protocol+"//":"",s=e.host||"",i=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",l=e.pathname||"",d=e.path||l+a;return`${o}${t||r}${s||i+n}${d}${c}`}}vc.exports={URLWithLegacySupport:Xo,URLSearchParams:self.URLSearchParams,defaultBase:Tc,format:Ey}});var Ic=E((Dx,Cc)=>{"use strict";var{URLWithLegacySupport:Ac,format:Py}=Qo();Cc.exports=(e,t={},r={},n)=>{let o=t.protocol?t.protocol.replace(":",""):"http";o=(r[o]||n||o)+":";let s;try{s=new Ac(e)}catch{s={}}let i=Object.assign({},t,{protocol:o||s.protocol,host:t.host||s.host});return new Ac(e,Py(i)).toString()}});var Uc=E((Rx,kc)=>{"use strict";var{URLWithLegacySupport:Ty,format:vy,URLSearchParams:Ay,defaultBase:Cy}=Qo(),Iy=Ic();kc.exports={URL:Ty,URLSearchParams:Ay,format:vy,relative:Iy,defaultBase:Cy}});var Yo=E((Lx,Zo)=>{function Bc(e){let t=new globalThis.AbortController;function r(){t.abort();for(let n of e)!n||!n.removeEventListener||n.removeEventListener("abort",r)}for(let n of e)if(!(!n||!n.addEventListener)){if(n.aborted){r();break}n.addEventListener("abort",r)}return t.signal}Zo.exports=Bc;Zo.exports.anySignal=Bc});var _c=E((Ox,Nc)=>{"use strict";async function*ky(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&r.cancel(),r.releaseLock()}}Nc.exports=ky});var Rc=E(($x,Dc)=>{"use strict";var Uy=async e=>{let t=[];for await(let r of e)t.push(r);return t};Dc.exports=Uy});var nn=E((Fx,jc)=>{"use strict";var{fetch:By,Request:Ny,Headers:_y}=gc(),{TimeoutError:es,HTTPError:Fc}=Vo(),Lc=Ko().bind({ignoreUndefined:!0}),{URL:Oc,URLSearchParams:$c}=Uc(),Dy=Yo(),Ry=_c(),{isBrowser:Ly,isWebWorker:Oy}=zo(),$y=Rc(),Fy=(e,t,r)=>{if(t===void 0)return e;let n=Date.now(),o=()=>Date.now()-n>=t;return new Promise((s,i)=>{let a=setTimeout(()=>{o()&&(i(new es),r.abort())},t),c=l=>m=>{if(clearTimeout(a),o()){i(new es);return}l(m)};e.then(c(s),c(i))})},zy={throwHttpErrors:!0,credentials:"same-origin"},Q=class{constructor(t={}){this.opts=Lc(zy,t)}async fetch(t,r={}){let n=Lc(this.opts,r),o=new _y(n.headers);if(typeof t!="string"&&!(t instanceof Oc||t instanceof Ny))throw new TypeError("`resource` must be a string, URL, or Request");let s=new Oc(t.toString(),n.base),{searchParams:i,transformSearchParams:a,json:c}=n;i&&(typeof a=="function"?s.search=a(new $c(n.searchParams)):s.search=new $c(n.searchParams)),c&&(n.body=JSON.stringify(n.json),o.set("content-type","application/json"));let l=new AbortController,d=Dy([l.signal,n.signal]);globalThis.ReadableStream!=null&&n.body instanceof globalThis.ReadableStream&&(Ly||Oy)&&(n.body=new Blob(await $y(Ry(n.body))));let m=await Fy(By(s.toString(),{...n,signal:d,timeout:void 0,headers:o,duplex:"half"}),n.timeout,l);if(!m.ok&&n.throwHttpErrors)throw n.handleError&&await n.handleError(m),new Fc(m);return m.iterator=async function*(){yield*zc(m.body)},m.ndjson=async function*(){for await(let x of jy(m.iterator()))r.transform?yield r.transform(x):yield x},m}post(t,r={}){return this.fetch(t,{...r,method:"POST"})}get(t,r={}){return this.fetch(t,{...r,method:"GET"})}put(t,r={}){return this.fetch(t,{...r,method:"PUT"})}delete(t,r={}){return this.fetch(t,{...r,method:"DELETE"})}options(t,r={}){return this.fetch(t,{...r,method:"OPTIONS"})}},jy=async function*(e){let t=new TextDecoder,r="";for await(let n of e){r+=t.decode(n,{stream:!0});let o=r.split(/\r?\n/);for(let s=0;s<o.length-1;s++){let i=o[s].trim();i.length>0&&(yield JSON.parse(i))}r=o[o.length-1]}r+=t.decode(),r=r.trim(),r.length!==0&&(yield JSON.parse(r))},zc=e=>{if(My(e))return e;if(Vy(e)){let t=e[Symbol.asyncIterator]();return{[Symbol.asyncIterator](){return{next:t.next.bind(t),return(r){return e.destroy(),typeof t.return=="function"?t.return():Promise.resolve({done:!0,value:r})}}}}}if(qy(e)){let t=e.getReader();return async function*(){try{for(;;){let{done:r,value:n}=await t.read();if(r)return;n&&(yield n)}}finally{t.releaseLock()}}()}throw new TypeError("Body can't be converted to AsyncIterable")},My=e=>typeof e=="object"&&e!==null&&typeof e[Symbol.asyncIterator]=="function",qy=e=>e&&typeof e.getReader=="function",Vy=e=>Object.prototype.hasOwnProperty.call(e,"readable")&&Object.prototype.hasOwnProperty.call(e,"writable");Q.HTTPError=Fc;Q.TimeoutError=es;Q.streamToAsyncIterator=zc;Q.post=(e,t)=>new Q(t).post(e,t);Q.get=(e,t)=>new Q(t).get(e,t);Q.put=(e,t)=>new Q(t).put(e,t);Q.delete=(e,t)=>new Q(t).delete(e,t);Q.options=(e,t)=>new Q(t).options(e,t);jc.exports=Q});var vu=E((fE,Tu)=>{"use strict";Tu.exports=kw;function kw(e,t){for(var r=new Array(arguments.length-1),n=0,o=2,s=!0;o<arguments.length;)r[n++]=arguments[o++];return new Promise(function(a,c){r[n]=function(d){if(s)if(s=!1,d)c(d);else{for(var m=new Array(arguments.length-1),x=0;x<m.length;)m[x++]=arguments[x];a.apply(null,m)}};try{e.apply(t||null,r)}catch(l){s&&(s=!1,c(l))}})}});var ku=E(Iu=>{"use strict";var pn=Iu;pn.length=function(t){var r=t.length;if(!r)return 0;for(var n=0;--r%4>1&&t.charAt(r)==="=";)++n;return Math.ceil(t.length*3)/4-n};var Lt=new Array(64),Cu=new Array(123);for(Ie=0;Ie<64;)Cu[Lt[Ie]=Ie<26?Ie+65:Ie<52?Ie+71:Ie<62?Ie-4:Ie-59|43]=Ie++;var Ie;pn.encode=function(t,r,n){for(var o=null,s=[],i=0,a=0,c;r<n;){var l=t[r++];switch(a){case 0:s[i++]=Lt[l>>2],c=(l&3)<<4,a=1;break;case 1:s[i++]=Lt[c|l>>4],c=(l&15)<<2,a=2;break;case 2:s[i++]=Lt[c|l>>6],s[i++]=Lt[l&63],a=0;break}i>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,s)),i=0)}return a&&(s[i++]=Lt[c],s[i++]=61,a===1&&(s[i++]=61)),o?(i&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))};var Au="invalid encoding";pn.decode=function(t,r,n){for(var o=n,s=0,i,a=0;a<t.length;){var c=t.charCodeAt(a++);if(c===61&&s>1)break;if((c=Cu[c])===void 0)throw Error(Au);switch(s){case 0:i=c,s=1;break;case 1:r[n++]=i<<2|(c&48)>>4,i=c,s=2;break;case 2:r[n++]=(i&15)<<4|(c&60)>>2,i=c,s=3;break;case 3:r[n++]=(i&3)<<6|c,s=0;break}}if(s===1)throw Error(Au);return n-o};pn.test=function(t){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}});var Bu=E((pE,Uu)=>{"use strict";Uu.exports=dn;function dn(){this._listeners={}}dn.prototype.on=function(t,r,n){return(this._listeners[t]||(this._listeners[t]=[])).push({fn:r,ctx:n||this}),this};dn.prototype.off=function(t,r){if(t===void 0)this._listeners={};else if(r===void 0)this._listeners[t]=[];else for(var n=this._listeners[t],o=0;o<n.length;)n[o].fn===r?n.splice(o,1):++o;return this};dn.prototype.emit=function(t){var r=this._listeners[t];if(r){for(var n=[],o=1;o<arguments.length;)n.push(arguments[o++]);for(o=0;o<r.length;)r[o].fn.apply(r[o++].ctx,n)}return this}});var $u=E((dE,Ou)=>{"use strict";Ou.exports=Nu(Nu);function Nu(e){return typeof Float32Array<"u"?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=r[3]===128;function o(c,l,d){t[0]=c,l[d]=r[0],l[d+1]=r[1],l[d+2]=r[2],l[d+3]=r[3]}function s(c,l,d){t[0]=c,l[d]=r[3],l[d+1]=r[2],l[d+2]=r[1],l[d+3]=r[0]}e.writeFloatLE=n?o:s,e.writeFloatBE=n?s:o;function i(c,l){return r[0]=c[l],r[1]=c[l+1],r[2]=c[l+2],r[3]=c[l+3],t[0]}function a(c,l){return r[3]=c[l],r[2]=c[l+1],r[1]=c[l+2],r[0]=c[l+3],t[0]}e.readFloatLE=n?i:a,e.readFloatBE=n?a:i}():function(){function t(n,o,s,i){var a=o<0?1:0;if(a&&(o=-o),o===0)n(1/o>0?0:2147483648,s,i);else if(isNaN(o))n(2143289344,s,i);else if(o>34028234663852886e22)n((a<<31|2139095040)>>>0,s,i);else if(o<11754943508222875e-54)n((a<<31|Math.round(o/1401298464324817e-60))>>>0,s,i);else{var c=Math.floor(Math.log(o)/Math.LN2),l=Math.round(o*Math.pow(2,-c)*8388608)&8388607;n((a<<31|c+127<<23|l)>>>0,s,i)}}e.writeFloatLE=t.bind(null,_u),e.writeFloatBE=t.bind(null,Du);function r(n,o,s){var i=n(o,s),a=(i>>31)*2+1,c=i>>>23&255,l=i&8388607;return c===255?l?NaN:a*(1/0):c===0?a*1401298464324817e-60*l:a*Math.pow(2,c-150)*(l+8388608)}e.readFloatLE=r.bind(null,Ru),e.readFloatBE=r.bind(null,Lu)}(),typeof Float64Array<"u"?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=r[7]===128;function o(c,l,d){t[0]=c,l[d]=r[0],l[d+1]=r[1],l[d+2]=r[2],l[d+3]=r[3],l[d+4]=r[4],l[d+5]=r[5],l[d+6]=r[6],l[d+7]=r[7]}function s(c,l,d){t[0]=c,l[d]=r[7],l[d+1]=r[6],l[d+2]=r[5],l[d+3]=r[4],l[d+4]=r[3],l[d+5]=r[2],l[d+6]=r[1],l[d+7]=r[0]}e.writeDoubleLE=n?o:s,e.writeDoubleBE=n?s:o;function i(c,l){return r[0]=c[l],r[1]=c[l+1],r[2]=c[l+2],r[3]=c[l+3],r[4]=c[l+4],r[5]=c[l+5],r[6]=c[l+6],r[7]=c[l+7],t[0]}function a(c,l){return r[7]=c[l],r[6]=c[l+1],r[5]=c[l+2],r[4]=c[l+3],r[3]=c[l+4],r[2]=c[l+5],r[1]=c[l+6],r[0]=c[l+7],t[0]}e.readDoubleLE=n?i:a,e.readDoubleBE=n?a:i}():function(){function t(n,o,s,i,a,c){var l=i<0?1:0;if(l&&(i=-i),i===0)n(0,a,c+o),n(1/i>0?0:2147483648,a,c+s);else if(isNaN(i))n(0,a,c+o),n(2146959360,a,c+s);else if(i>17976931348623157e292)n(0,a,c+o),n((l<<31|2146435072)>>>0,a,c+s);else{var d;if(i<22250738585072014e-324)d=i/5e-324,n(d>>>0,a,c+o),n((l<<31|d/4294967296)>>>0,a,c+s);else{var m=Math.floor(Math.log(i)/Math.LN2);m===1024&&(m=1023),d=i*Math.pow(2,-m),n(d*4503599627370496>>>0,a,c+o),n((l<<31|m+1023<<20|d*1048576&1048575)>>>0,a,c+s)}}}e.writeDoubleLE=t.bind(null,_u,0,4),e.writeDoubleBE=t.bind(null,Du,4,0);function r(n,o,s,i,a){var c=n(i,a+o),l=n(i,a+s),d=(l>>31)*2+1,m=l>>>20&2047,x=4294967296*(l&1048575)+c;return m===2047?x?NaN:d*(1/0):m===0?d*5e-324*x:d*Math.pow(2,m-1075)*(x+4503599627370496)}e.readDoubleLE=r.bind(null,Ru,0,4),e.readDoubleBE=r.bind(null,Lu,4,0)}(),e}function _u(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function Du(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=e&255}function Ru(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function Lu(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}});var Fu=E((exports,module)=>{"use strict";module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}});var ju=E(zu=>{"use strict";var ds=zu;ds.length=function(t){for(var r=0,n=0,o=0;o<t.length;++o)n=t.charCodeAt(o),n<128?r+=1:n<2048?r+=2:(n&64512)===55296&&(t.charCodeAt(o+1)&64512)===56320?(++o,r+=4):r+=3;return r};ds.read=function(t,r,n){var o=n-r;if(o<1)return"";for(var s=null,i=[],a=0,c;r<n;)c=t[r++],c<128?i[a++]=c:c>191&&c<224?i[a++]=(c&31)<<6|t[r++]&63:c>239&&c<365?(c=((c&7)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,i[a++]=55296+(c>>10),i[a++]=56320+(c&1023)):i[a++]=(c&15)<<12|(t[r++]&63)<<6|t[r++]&63,a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,i)),a=0);return s?(a&&s.push(String.fromCharCode.apply(String,i.slice(0,a))),s.join("")):String.fromCharCode.apply(String,i.slice(0,a))};ds.write=function(t,r,n){for(var o=n,s,i,a=0;a<t.length;++a)s=t.charCodeAt(a),s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=s&63|128):(s&64512)===55296&&((i=t.charCodeAt(a+1))&64512)===56320?(s=65536+((s&1023)<<10)+(i&1023),++a,r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=s&63|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=s&63|128);return n-o}});var qu=E((mE,Mu)=>{"use strict";Mu.exports=Uw;function Uw(e,t,r){var n=r||8192,o=n>>>1,s=null,i=n;return function(c){if(c<1||c>o)return e(c);i+c>n&&(s=e(n),i=0);var l=t.call(s,i,i+=c);return i&7&&(i=(i|7)+1),l}}});var Hu=E((gE,Vu)=>{"use strict";Vu.exports=G;var mr=tt();function G(e,t){this.lo=e>>>0,this.hi=t>>>0}var ut=G.zero=new G(0,0);ut.toNumber=function(){return 0};ut.zzEncode=ut.zzDecode=function(){return this};ut.length=function(){return 1};var Bw=G.zeroHash="\0\0\0\0\0\0\0\0";G.fromNumber=function(t){if(t===0)return ut;var r=t<0;r&&(t=-t);var n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new G(n,o)};G.from=function(t){if(typeof t=="number")return G.fromNumber(t);if(mr.isString(t))if(mr.Long)t=mr.Long.fromString(t);else return G.fromNumber(parseInt(t,10));return t.low||t.high?new G(t.low>>>0,t.high>>>0):ut};G.prototype.toNumber=function(t){if(!t&&this.hi>>>31){var r=~this.lo+1>>>0,n=~this.hi>>>0;return r||(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296};G.prototype.toLong=function(t){return mr.Long?new mr.Long(this.lo|0,this.hi|0,Boolean(t)):{low:this.lo|0,high:this.hi|0,unsigned:Boolean(t)}};var et=String.prototype.charCodeAt;G.fromHash=function(t){return t===Bw?ut:new G((et.call(t,0)|et.call(t,1)<<8|et.call(t,2)<<16|et.call(t,3)<<24)>>>0,(et.call(t,4)|et.call(t,5)<<8|et.call(t,6)<<16|et.call(t,7)<<24)>>>0)};G.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)};G.prototype.zzEncode=function(){var t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this};G.prototype.zzDecode=function(){var t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this};G.prototype.length=function(){var t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}});var tt=E(hs=>{"use strict";var b=hs;b.asPromise=vu();b.base64=ku();b.EventEmitter=Bu();b.float=$u();b.inquire=Fu();b.utf8=ju();b.pool=qu();b.LongBits=Hu();b.isNode=Boolean(typeof globalThis<"u"&&globalThis&&globalThis.process&&globalThis.process.versions&&globalThis.process.versions.node);b.global=b.isNode&&globalThis||typeof window<"u"&&window||typeof self<"u"&&self||hs;b.emptyArray=Object.freeze?Object.freeze([]):[];b.emptyObject=Object.freeze?Object.freeze({}):{};b.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t};b.isString=function(t){return typeof t=="string"||t instanceof String};b.isObject=function(t){return t&&typeof t=="object"};b.isset=b.isSet=function(t,r){var n=t[r];return n!=null&&t.hasOwnProperty(r)?typeof n!="object"||(Array.isArray(n)?n.length:Object.keys(n).length)>0:!1};b.Buffer=function(){try{var e=b.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch{return null}}();b._Buffer_from=null;b._Buffer_allocUnsafe=null;b.newBuffer=function(t){return typeof t=="number"?b.Buffer?b._Buffer_allocUnsafe(t):new b.Array(t):b.Buffer?b._Buffer_from(t):typeof Uint8Array>"u"?t:new Uint8Array(t)};b.Array=typeof Uint8Array<"u"?Uint8Array:Array;b.Long=b.global.dcodeIO&&b.global.dcodeIO.Long||b.global.Long||b.inquire("long");b.key2Re=/^true|false|0|1$/;b.key32Re=/^-?(?:0|[1-9][0-9]*)$/;b.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/;b.longToHash=function(t){return t?b.LongBits.from(t).toHash():b.LongBits.zeroHash};b.longFromHash=function(t,r){var n=b.LongBits.fromHash(t);return b.Long?b.Long.fromBits(n.lo,n.hi,r):n.toNumber(Boolean(r))};function Gu(e,t,r){for(var n=Object.keys(t),o=0;o<n.length;++o)(e[n[o]]===void 0||!r)&&(e[n[o]]=t[n[o]]);return e}b.merge=Gu;b.lcFirst=function(t){return t.charAt(0).toLowerCase()+t.substring(1)};function Wu(e){function t(r,n){if(!(this instanceof t))return new t(r,n);Object.defineProperty(this,"message",{get:function(){return r}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:new Error().stack||""}),n&&Gu(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}b.newError=Wu;b.ProtocolError=Wu("ProtocolError");b.oneOfGetter=function(t){for(var r={},n=0;n<t.length;++n)r[t[n]]=1;return function(){for(var o=Object.keys(this),s=o.length-1;s>-1;--s)if(r[o[s]]===1&&this[o[s]]!==void 0&&this[o[s]]!==null)return o[s]}};b.oneOfSetter=function(t){return function(r){for(var n=0;n<t.length;++n)t[n]!==r&&delete this[t[n]]}};b.toJSONOptions={longs:String,enums:String,bytes:String,json:!0};b._configure=function(){var e=b.Buffer;if(!e){b._Buffer_from=b._Buffer_allocUnsafe=null;return}b._Buffer_from=e.from!==Uint8Array.from&&e.from||function(r,n){return new e(r,n)},b._Buffer_allocUnsafe=e.allocUnsafe||function(r){return new e(r)}}});var Ss=E((wE,Qu)=>{"use strict";Qu.exports=k;var xe=tt(),ms,hn=xe.LongBits,Ju=xe.base64,Ku=xe.utf8;function gr(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function ys(){}function Nw(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function k(){this.len=0,this.head=new gr(ys,0,0),this.tail=this.head,this.states=null}var Xu=function(){return xe.Buffer?function(){return(k.create=function(){return new ms})()}:function(){return new k}};k.create=Xu();k.alloc=function(t){return new xe.Array(t)};xe.Array!==Array&&(k.alloc=xe.pool(k.alloc,xe.Array.prototype.subarray));k.prototype._push=function(t,r,n){return this.tail=this.tail.next=new gr(t,r,n),this.len+=r,this};function ws(e,t,r){t[r]=e&255}function _w(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}function bs(e,t){this.len=e,this.next=void 0,this.val=t}bs.prototype=Object.create(gr.prototype);bs.prototype.fn=_w;k.prototype.uint32=function(t){return this.len+=(this.tail=this.tail.next=new bs((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this};k.prototype.int32=function(t){return t<0?this._push(xs,10,hn.fromNumber(t)):this.uint32(t)};k.prototype.sint32=function(t){return this.uint32((t<<1^t>>31)>>>0)};function xs(e,t,r){for(;e.hi;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}k.prototype.uint64=function(t){var r=hn.from(t);return this._push(xs,r.length(),r)};k.prototype.int64=k.prototype.uint64;k.prototype.sint64=function(t){var r=hn.from(t).zzEncode();return this._push(xs,r.length(),r)};k.prototype.bool=function(t){return this._push(ws,1,t?1:0)};function gs(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}k.prototype.fixed32=function(t){return this._push(gs,4,t>>>0)};k.prototype.sfixed32=k.prototype.fixed32;k.prototype.fixed64=function(t){var r=hn.from(t);return this._push(gs,4,r.lo)._push(gs,4,r.hi)};k.prototype.sfixed64=k.prototype.fixed64;k.prototype.float=function(t){return this._push(xe.float.writeFloatLE,4,t)};k.prototype.double=function(t){return this._push(xe.float.writeDoubleLE,8,t)};var Dw=xe.Array.prototype.set?function(t,r,n){r.set(t,n)}:function(t,r,n){for(var o=0;o<t.length;++o)r[n+o]=t[o]};k.prototype.bytes=function(t){var r=t.length>>>0;if(!r)return this._push(ws,1,0);if(xe.isString(t)){var n=k.alloc(r=Ju.length(t));Ju.decode(t,n,0),t=n}return this.uint32(r)._push(Dw,r,t)};k.prototype.string=function(t){var r=Ku.length(t);return r?this.uint32(r)._push(Ku.write,r,t):this._push(ws,1,0)};k.prototype.fork=function(){return this.states=new Nw(this),this.head=this.tail=new gr(ys,0,0),this.len=0,this};k.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new gr(ys,0,0),this.len=0),this};k.prototype.ldelim=function(){var t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=t.next,this.tail=r,this.len+=n),this};k.prototype.finish=function(){for(var t=this.head.next,r=this.constructor.alloc(this.len),n=0;t;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r};k._configure=function(e){ms=e,k.create=Xu(),ms._configure()}});var ef=E((bE,Yu)=>{"use strict";Yu.exports=De;var Zu=Ss();(De.prototype=Object.create(Zu.prototype)).constructor=De;var rt=tt();function De(){Zu.call(this)}De._configure=function(){De.alloc=rt._Buffer_allocUnsafe,De.writeBytesBuffer=rt.Buffer&&rt.Buffer.prototype instanceof Uint8Array&&rt.Buffer.prototype.set.name==="set"?function(t,r,n){r.set(t,n)}:function(t,r,n){if(t.copy)t.copy(r,n,0,t.length);else for(var o=0;o<t.length;)r[n++]=t[o++]}};De.prototype.bytes=function(t){rt.isString(t)&&(t=rt._Buffer_from(t,"base64"));var r=t.length>>>0;return this.uint32(r),r&&this._push(De.writeBytesBuffer,r,t),this};function Rw(e,t,r){e.length<40?rt.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}De.prototype.string=function(t){var r=rt.Buffer.byteLength(t);return this.uint32(r),r&&this._push(Rw,r,t),this};De._configure()});var Ts=E((xE,sf)=>{"use strict";sf.exports=$;var Re=tt(),Ps,nf=Re.LongBits,Lw=Re.utf8;function ke(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function $(e){this.buf=e,this.pos=0,this.len=e.length}var tf=typeof Uint8Array<"u"?function(t){if(t instanceof Uint8Array||Array.isArray(t))return new $(t);throw Error("illegal buffer")}:function(t){if(Array.isArray(t))return new $(t);throw Error("illegal buffer")},of=function(){return Re.Buffer?function(r){return($.create=function(o){return Re.Buffer.isBuffer(o)?new Ps(o):tf(o)})(r)}:tf};$.create=of();$.prototype._slice=Re.Array.prototype.subarray||Re.Array.prototype.slice;$.prototype.uint32=function(){var t=4294967295;return function(){if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,ke(this,10);return t}}();$.prototype.int32=function(){return this.uint32()|0};$.prototype.sint32=function(){var t=this.uint32();return t>>>1^-(t&1)|0};function Es(){var e=new nf(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw ke(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw ke(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}$.prototype.bool=function(){return this.uint32()!==0};function mn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}$.prototype.fixed32=function(){if(this.pos+4>this.len)throw ke(this,4);return mn(this.buf,this.pos+=4)};$.prototype.sfixed32=function(){if(this.pos+4>this.len)throw ke(this,4);return mn(this.buf,this.pos+=4)|0};function rf(){if(this.pos+8>this.len)throw ke(this,8);return new nf(mn(this.buf,this.pos+=4),mn(this.buf,this.pos+=4))}$.prototype.float=function(){if(this.pos+4>this.len)throw ke(this,4);var t=Re.float.readFloatLE(this.buf,this.pos);return this.pos+=4,t};$.prototype.double=function(){if(this.pos+8>this.len)throw ke(this,4);var t=Re.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,t};$.prototype.bytes=function(){var t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw ke(this,t);return this.pos+=t,Array.isArray(this.buf)?this.buf.slice(r,n):r===n?new this.buf.constructor(0):this._slice.call(this.buf,r,n)};$.prototype.string=function(){var t=this.bytes();return Lw.read(t,0,t.length)};$.prototype.skip=function(t){if(typeof t=="number"){if(this.pos+t>this.len)throw ke(this,t);this.pos+=t}else do if(this.pos>=this.len)throw ke(this);while(this.buf[this.pos++]&128);return this};$.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this};$._configure=function(e){Ps=e,$.create=of(),Ps._configure();var t=Re.Long?"toLong":"toNumber";Re.merge($.prototype,{int64:function(){return Es.call(this)[t](!1)},uint64:function(){return Es.call(this)[t](!0)},sint64:function(){return Es.call(this).zzDecode()[t](!1)},fixed64:function(){return rf.call(this)[t](!0)},sfixed64:function(){return rf.call(this)[t](!1)}})}});var ff=E((SE,uf)=>{"use strict";uf.exports=ft;var cf=Ts();(ft.prototype=Object.create(cf.prototype)).constructor=ft;var af=tt();function ft(e){cf.call(this,e)}ft._configure=function(){af.Buffer&&(ft.prototype._slice=af.Buffer.prototype.slice)};ft.prototype.string=function(){var t=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+t,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+t,this.len))};ft._configure()});var pf=E((EE,lf)=>{"use strict";lf.exports=yr;var vs=tt();(yr.prototype=Object.create(vs.EventEmitter.prototype)).constructor=yr;function yr(e,t,r){if(typeof e!="function")throw TypeError("rpcImpl must be a function");vs.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}yr.prototype.rpcCall=function e(t,r,n,o,s){if(!o)throw TypeError("request must be specified");var i=this;if(!s)return vs.asPromise(e,i,t,r,n,o);if(!i.rpcImpl){setTimeout(function(){s(Error("already ended"))},0);return}try{return i.rpcImpl(t,r[i.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(c,l){if(c)return i.emit("error",c,t),s(c);if(l===null){i.end(!0);return}if(!(l instanceof n))try{l=n[i.responseDelimited?"decodeDelimited":"decode"](l)}catch(d){return i.emit("error",d,t),s(d)}return i.emit("data",l,t),s(null,l)})}catch(a){i.emit("error",a,t),setTimeout(function(){s(a)},0);return}};yr.prototype.end=function(t){return this.rpcImpl&&(t||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}});var hf=E(df=>{"use strict";var Ow=df;Ow.Service=pf()});var gf=E((TE,mf)=>{"use strict";mf.exports={}});var bf=E(wf=>{"use strict";var re=wf;re.build="minimal";re.Writer=Ss();re.BufferWriter=ef();re.Reader=Ts();re.BufferReader=ff();re.util=tt();re.rpc=hf();re.roots=gf();re.configure=yf;function yf(){re.util._configure(),re.Writer._configure(re.BufferWriter),re.Reader._configure(re.BufferReader)}yf()});var Sf=E((AE,xf)=>{"use strict";xf.exports=bf()});var gl=E((xP,ml)=>{ml.exports=e=>{if(e[Symbol.asyncIterator])return e;if(e.getReader)return async function*(){let t=e.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r)return;yield n}}finally{t.releaseLock()}}();throw new Error("unknown stream")}});var ud=E(()=>{});var ld=E(($5,fd)=>{"use strict";var cb=nn(),ub=(e,t)=>({path:decodeURIComponent(new URL(e).pathname.split("/").pop()||""),content:fb(e,t)});async function*fb(e,t){yield*(await new cb().get(e,t)).iterator()}fd.exports=ub});var db={};q(db,{CID:()=>h,create:()=>lb,globSource:()=>pb,multiaddr:()=>_,urlSource:()=>dd.default});var xd=e=>Promise.reject(new Error(`No base found for "${e}"`)),Sr=class{constructor(t){this._basesByName={},this._basesByPrefix={},this._loadBase=t.loadBase||xd;for(let r of t.bases)this.addBase(r)}addBase(t){if(this._basesByName[t.name]||this._basesByPrefix[t.prefix])throw new Error(`Codec already exists for codec "${t.name}"`);this._basesByName[t.name]=t,this._basesByPrefix[t.prefix]=t}removeBase(t){delete this._basesByName[t.name],delete this._basesByPrefix[t.prefix]}async getBase(t){if(this._basesByName[t])return this._basesByName[t];if(this._basesByPrefix[t])return this._basesByPrefix[t];let r=await this._loadBase(t);return this._basesByName[r.name]==null&&this._basesByPrefix[r.prefix]==null&&this.addBase(r),r}listBases(){return Object.values(this._basesByName)}};var Sd=e=>Promise.reject(new Error(`No codec found for "${e}"`)),Er=class{constructor(t){this._codecsByName={},this._codecsByCode={},this._loadCodec=t.loadCodec||Sd;for(let r of t.codecs)this.addCodec(r)}addCodec(t){if(this._codecsByName[t.name]||this._codecsByCode[t.code])throw new Error(`Resolver already exists for codec "${t.name}"`);this._codecsByName[t.name]=t,this._codecsByCode[t.code]=t}removeCodec(t){delete this._codecsByName[t.name],delete this._codecsByCode[t.code]}async getCodec(t){let r=typeof t=="string"?this._codecsByName:this._codecsByCode;if(r[t])return r[t];let n=await this._loadCodec(t);return r[t]==null&&this.addCodec(n),n}listCodecs(){return Object.values(this._codecsByName)}};var Ed=e=>Promise.reject(new Error(`No hasher found for "${e}"`)),Pr=class{constructor(t){this._hashersByName={},this._hashersByCode={},this._loadHasher=t.loadHasher||Ed;for(let r of t.hashers)this.addHasher(r)}addHasher(t){if(this._hashersByName[t.name]||this._hashersByCode[t.code])throw new Error(`Resolver already exists for codec "${t.name}"`);this._hashersByName[t.name]=t,this._hashersByCode[t.code]=t}removeHasher(t){delete this._hashersByName[t.name],delete this._hashersByCode[t.code]}async getHasher(t){let r=typeof t=="string"?this._hashersByName:this._hashersByCode;if(r[t])return r[t];let n=await this._loadHasher(t);return r[t]==null&&this.addHasher(n),n}listHashers(){return Object.values(this._hashersByName)}};var Vn={};q(Vn,{code:()=>yh,createLink:()=>ni,createNode:()=>ri,decode:()=>bh,encode:()=>wh,name:()=>gh,prepare:()=>Mn,validate:()=>qn});var Pd=Os,Rs=128,Td=127,vd=~Td,Ad=Math.pow(2,31);function Os(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Ad;)t[r++]=e&255|Rs,e/=128;for(;e&vd;)t[r++]=e&255|Rs,e>>>=7;return t[r]=e|0,Os.bytes=r-n+1,t}var Cd=Nn,Id=128,Ls=127;function Nn(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw Nn.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Ls)<<o:(i&Ls)*Math.pow(2,o),o+=7}while(i>=Id);return Nn.bytes=s-n,r}var kd=Math.pow(2,7),Ud=Math.pow(2,14),Bd=Math.pow(2,21),Nd=Math.pow(2,28),_d=Math.pow(2,35),Dd=Math.pow(2,42),Rd=Math.pow(2,49),Ld=Math.pow(2,56),Od=Math.pow(2,63),$d=function(e){return e<kd?1:e<Ud?2:e<Bd?3:e<Nd?4:e<_d?5:e<Dd?6:e<Rd?7:e<Ld?8:e<Od?9:10},Fd={encode:Pd,decode:Cd,encodingLength:$d},zd=Fd,Mt=zd;var qt=(e,t=0)=>[Mt.decode(e,t),Mt.decode.bytes],pt=(e,t,r=0)=>(Mt.encode(e,t,r),t),dt=e=>Mt.encodingLength(e);var xb=new Uint8Array(0);var $s=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0},Pe=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Fs=e=>new TextEncoder().encode(e),zs=e=>new TextDecoder().decode(e);var Ge=(e,t)=>{let r=t.byteLength,n=dt(e),o=n+dt(r),s=new Uint8Array(o+r);return pt(e,s,0),pt(r,s,n),s.set(t,o),new ht(e,r,t,s)},Le=e=>{let t=Pe(e),[r,n]=qt(t),[o,s]=qt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new ht(r,o,i,t)},Ms=(e,t)=>{if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&$s(e.bytes,r.bytes)}},ht=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var On={};q(On,{base58btc:()=>R,base58flickr:()=>Gd});function jd(e,t){if(e.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<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function m(T){if(T instanceof Uint8Array||(ArrayBuffer.isView(T)?T=new Uint8Array(T.buffer,T.byteOffset,T.byteLength):Array.isArray(T)&&(T=Uint8Array.from(T))),!(T instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(T.length===0)return"";for(var B=0,D=0,M=0,Z=T.length;M!==Z&&T[M]===0;)M++,B++;for(var fe=(Z-M)*d+1>>>0,W=new Uint8Array(fe);M!==Z;){for(var Ee=T[M],le=0,ne=fe-1;(Ee!==0||le<D)&&ne!==-1;ne--,le++)Ee+=256*W[ne]>>>0,W[ne]=Ee%a>>>0,Ee=Ee/a>>>0;if(Ee!==0)throw new Error("Non-zero carry");D=le,M++}for(var pe=fe-D;pe!==fe&&W[pe]===0;)pe++;for(var lt=c.repeat(B);pe<fe;++pe)lt+=e.charAt(W[pe]);return lt}function x(T){if(typeof T!="string")throw new TypeError("Expected String");if(T.length===0)return new Uint8Array;var B=0;if(T[B]!==" "){for(var D=0,M=0;T[B]===c;)D++,B++;for(var Z=(T.length-B)*l+1>>>0,fe=new Uint8Array(Z);T[B];){var W=r[T.charCodeAt(B)];if(W===255)return;for(var Ee=0,le=Z-1;(W!==0||Ee<M)&&le!==-1;le--,Ee++)W+=a*fe[le]>>>0,fe[le]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");M=Ee,B++}if(T[B]!==" "){for(var ne=Z-M;ne!==Z&&fe[ne]===0;)ne++;for(var pe=new Uint8Array(D+(Z-ne)),lt=D;ne!==Z;)pe[lt++]=fe[ne++];return pe}}}function P(T){var B=x(T);if(B)return B;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:x,decode:P}}var Md=jd,qd=Md,qs=qd;var _n=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Dn=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Vs(this,t)}},Rn=class{constructor(t){this.decoders=t}or(t){return Vs(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Vs=(e,t)=>new Rn({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ln=class{constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new _n(t,r,n),this.decoder=new Dn(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},mt=({name:e,prefix:t,encode:r,decode:n})=>new Ln(e,t,r,n),Je=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=qs(r,t);return mt({prefix:e,name:t,encode:n,decode:s=>Pe(o(s))})},Vd=(e,t,r,n)=>{let o={};for(let d=0;d<t.length;++d)o[t[d]]=d;let s=e.length;for(;e[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),a=0,c=0,l=0;for(let d=0;d<s;++d){let m=o[e[d]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,a+=r,a>=8&&(a-=8,i[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i},Hd=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i&&(s+=t[o&a<<r-i]),n)for(;s.length*r&7;)s+="=";return s},O=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>mt({prefix:t,name:e,encode(o){return Hd(o,n,r)},decode(o){return Vd(o,n,r,e)}});var R=Je({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Gd=Je({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $n={};q($n,{base32:()=>ee,base32hex:()=>Xd,base32hexpad:()=>Zd,base32hexpadupper:()=>Yd,base32hexupper:()=>Qd,base32pad:()=>Jd,base32padupper:()=>Kd,base32upper:()=>Wd,base32z:()=>eh});var ee=O({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wd=O({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jd=O({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Kd=O({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xd=O({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qd=O({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Zd=O({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yd=O({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),eh=O({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hs=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return rh(r,Fn(e),t||R.encoder);default:return nh(r,Fn(e),t||ee.encoder)}};var Gs=new WeakMap,Fn=e=>{let t=Gs.get(e);if(t==null){let r=new Map;return Gs.set(e,r),r}return t},h=class{constructor(t,r,n,o){this.code=r,this.version=t,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:t,multihash:r}=this;if(t!==Vt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==oh)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return h.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:t,digest:r}=this.multihash,n=Ge(t,r);return h.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(t){return h.equals(this,t)}static equals(t,r){let n=r;return n&&t.code===n.code&&t.version===n.version&&Ms(t.multihash,n.multihash)}toString(t){return Hs(this,t)}toJSON(){return{"/":Hs(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof h)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new h(n,o,s,i||Ws(n,o,s.bytes))}else if(r[sh]===!0){let{version:n,multihash:o,code:s}=r,i=Le(o);return h.create(n,s,i)}else return null}static create(t,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(t){case 0:{if(r!==Vt)throw new Error(`Version 0 CID must use dag-pb (code: ${Vt}) block encoding`);return new h(t,r,n,n.bytes)}case 1:{let o=Ws(t,r,n.bytes);return new h(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return h.create(0,Vt,t)}static createV1(t,r){return h.create(1,t,r)}static decode(t){let[r,n]=h.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=h.inspectBytes(t),n=r.size-r.multihashSize,o=Pe(t.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 ht(r.multihashCode,r.digestSize,s,o);return[r.version===0?h.createV0(i):h.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,x]=qt(t.subarray(r));return r+=x,m},o=n(),s=Vt;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(),c=n(),l=r+c,d=l-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:d,size:l}}static parse(t,r){let[n,o]=th(t,r),s=h.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Fn(s).set(n,t),s}},th=(e,t)=>{switch(e[0]){case"Q":{let r=t||R;return[R.prefix,r.decode(`${R.prefix}${e}`)]}case R.prefix:{let r=t||R;return[R.prefix,r.decode(e)]}case ee.prefix:{let r=t||ee;return[ee.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},rh=(e,t,r)=>{let{prefix:n}=r;if(n!==R.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o},nh=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o},Vt=112,oh=18,Ws=(e,t,r)=>{let n=dt(e),o=n+dt(t),s=new Uint8Array(o+r.byteLength);return pt(e,s,0),pt(t,s,n),s.set(r,o),s},sh=Symbol.for("@ipld/js-cid/CID");var ih=new TextDecoder;function zn(e,t){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=e.length)throw new Error("protobuf: unexpected end of data");let o=e[t++];if(r+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[r,t]}function vr(e,t){let r;[r,t]=zn(e,t);let n=t+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>e.length)throw new Error("protobuf: unexpected end of data");return[e.subarray(t,n),n]}function Js(e,t){let r;return[r,t]=zn(e,t),[r&7,r>>3,t]}function ah(e){let t={},r=e.length,n=0;for(;n<r;){let o,s;if([o,s,n]=Js(e,n),s===1){if(t.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(t.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[t.Hash,n]=vr(e,n)}else if(s===2){if(t.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let i;[i,n]=vr(e,n),t.Name=ih.decode(i)}else if(s===3){if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[t.Tsize,n]=zn(e,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${s}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return t}function Ks(e){let t=e.length,r=0,n,o=!1,s;for(;r<t;){let a,c;if([a,c,r]=Js(e,r),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(c===1){if(s)throw new Error("protobuf: (PBNode) duplicate Data section");[s,r]=vr(e,r),n&&(o=!0)}else if(c===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let l;[l,r]=vr(e,r),n.push(ah(l))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(r>t)throw new Error("protobuf: (PBNode) unexpected end of data");let i={};return s&&(i.Data=s),i.Links=n||[],i}var Qs=new TextEncoder,Xs=2**32,ch=2**31;function uh(e,t){let r=t.length;if(typeof e.Tsize=="number"){if(e.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(e.Tsize))throw new Error("Tsize too large for encoding");r=Ht(t,r,e.Tsize)-1,t[r]=24}if(typeof e.Name=="string"){let n=Qs.encode(e.Name);r-=n.length,t.set(n,r),r=Ht(t,r,n.length)-1,t[r]=18}return e.Hash&&(r-=e.Hash.length,t.set(e.Hash,r),r=Ht(t,r,e.Hash.length)-1,t[r]=10),t.length-r}function Zs(e){let t=lh(e),r=new Uint8Array(t),n=t;if(e.Data&&(n-=e.Data.length,r.set(e.Data,n),n=Ht(r,n,e.Data.length)-1,r[n]=10),e.Links)for(let o=e.Links.length-1;o>=0;o--){let s=uh(e.Links[o],r.subarray(0,n));n-=s,n=Ht(r,n,s)-1,r[n]=18}return r}function fh(e){let t=0;if(e.Hash){let r=e.Hash.length;t+=1+r+gt(r)}if(typeof e.Name=="string"){let r=Qs.encode(e.Name).length;t+=1+r+gt(r)}return typeof e.Tsize=="number"&&(t+=1+gt(e.Tsize)),t}function lh(e){let t=0;if(e.Data){let r=e.Data.length;t+=1+r+gt(r)}if(e.Links)for(let r of e.Links){let n=fh(r);t+=1+n+gt(n)}return t}function Ht(e,t,r){t-=gt(r);let n=t;for(;r>=ch;)e[t++]=r&127|128,r/=128;for(;r>=128;)e[t++]=r&127|128,r>>>=7;return e[t]=r,n}function gt(e){return e%2===0&&e++,Math.floor((ph(e)+6)/7)}function ph(e){let t=0;return e>=Xs&&(e=Math.floor(e/Xs),t=32),e>=1<<16&&(e>>>=16,t+=16),e>=1<<8&&(e>>>=8,t+=8),t+dh[e]}var dh=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var hh=["Data","Links"],mh=["Hash","Name","Tsize"],jn=new TextEncoder;function ei(e,t){if(e===t)return 0;let r=e.Name?jn.encode(e.Name):[],n=t.Name?jn.encode(t.Name):[],o=r.length,s=n.length;for(let i=0,a=Math.min(o,s);i<a;++i)if(r[i]!==n[i]){o=r[i],s=n[i];break}return o<s?-1:s<o?1:0}function Ys(e,t){return!Object.keys(e).some(r=>!t.includes(r))}function ti(e){if(typeof e.asCID=="object"){let r=h.asCID(e);if(!r)throw new TypeError("Invalid DAG-PB form");return{Hash:r}}if(typeof e!="object"||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");let t={};if(e.Hash){let r=h.asCID(e.Hash);try{r||(typeof e.Hash=="string"?r=h.parse(e.Hash):e.Hash instanceof Uint8Array&&(r=h.decode(e.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}r&&(t.Hash=r)}if(!t.Hash)throw new TypeError("Invalid DAG-PB form");return typeof e.Name=="string"&&(t.Name=e.Name),typeof e.Tsize=="number"&&(t.Tsize=e.Tsize),t}function Mn(e){if((e instanceof Uint8Array||typeof e=="string")&&(e={Data:e}),typeof e!="object"||Array.isArray(e))throw new TypeError("Invalid DAG-PB form");let t={};if(e.Data!==void 0)if(typeof e.Data=="string")t.Data=jn.encode(e.Data);else if(e.Data instanceof Uint8Array)t.Data=e.Data;else throw new TypeError("Invalid DAG-PB form");if(e.Links!==void 0)if(Array.isArray(e.Links))t.Links=e.Links.map(ti),t.Links.sort(ei);else throw new TypeError("Invalid DAG-PB form");else t.Links=[];return t}function qn(e){if(!e||typeof e!="object"||Array.isArray(e)||e instanceof Uint8Array||e["/"]&&e["/"]===e.bytes)throw new TypeError("Invalid DAG-PB form");if(!Ys(e,hh))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(e.Data!==void 0&&!(e.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(e.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let t=0;t<e.Links.length;t++){let r=e.Links[t];if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!Ys(r,mh))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(r.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(r.Hash==null||!r.Hash["/"]||r.Hash["/"]!==r.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(r.Name!==void 0&&typeof r.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(r.Tsize!==void 0){if(typeof r.Tsize!="number"||r.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(r.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(t>0&&ei(r,e.Links[t-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function ri(e,t=[]){return Mn({Data:e,Links:t})}function ni(e,t,r){return ti({Hash:r,Name:e,Tsize:t})}var gh="dag-pb",yh=112;function wh(e){qn(e);let t={};return e.Links&&(t.Links=e.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),e.Data&&(t.Data=e.Data),Zs(t)}function bh(e){let t=Ks(e),r={};return t.Data&&(r.Data=t.Data),t.Links&&(r.Links=t.Links.map(n=>{let o={};try{o.Hash=h.decode(n.Hash)}catch{}if(!o.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(o.Name=n.Name),n.Tsize!==void 0&&(o.Tsize=n.Tsize),o})),r}var Or={};q(Or,{code:()=>em,decode:()=>to,encode:()=>eo,name:()=>Yh});var xh=["string","number","bigint","symbol"],Sh=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function oi(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(xh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Eh(e))return"Buffer";let r=Ph(e);return r||"Object"}function Eh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Ph(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Sh.includes(t))return t}var p=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};p.uint=new p(0,"uint",!0);p.negint=new p(1,"negint",!0);p.bytes=new p(2,"bytes",!0);p.string=new p(3,"string",!0);p.array=new p(4,"array",!1);p.map=new p(5,"map",!1);p.tag=new p(6,"tag",!1);p.float=new p(7,"float",!0);p.false=new p(7,"false",!0);p.true=new p(7,"true",!0);p.null=new p(7,"null",!0);p.undefined=new p(7,"undefined",!0);p.break=new p(7,"break",!0);var g=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var yt=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Th=new TextDecoder,vh=new TextEncoder;function Ar(e){return yt&&globalThis.Buffer.isBuffer(e)}function Gt(e){return e instanceof Uint8Array?Ar(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var ci=yt?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):ii(e,t,r):(e,t,r)=>r-t>64?Th.decode(e.subarray(t,r)):ii(e,t,r),Cr=yt?e=>e.length>64?globalThis.Buffer.from(e):si(e):e=>e.length>64?vh.encode(e):si(e),Ue=e=>Uint8Array.from(e),wt=yt?(e,t,r)=>Ar(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),ui=yt?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Gt(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},fi=yt?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function li(e,t){if(Ar(e)&&Ar(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function si(e,t=1/0){let r,n=e.length,o=null,s=[];for(let i=0;i<n;++i){if(r=e.charCodeAt(i),r>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}else if(i+1===n){(t-=3)>-1&&s.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(t-=3)>-1&&s.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return s}function ii(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,i=o>239?4:o>223?3:o>191?2:1;if(t+i<=r){let a,c,l,d;switch(i){case 1:o<128&&(s=o);break;case 2:a=e[t+1],(a&192)===128&&(d=(o&31)<<6|a&63,d>127&&(s=d));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(d=(o&15)<<12|(a&63)<<6|c&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:a=e[t+1],c=e[t+2],l=e[t+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(d=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,i=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=i}return Hn(n)}var ai=4096;function Hn(e){let t=e.length;if(t<=ai)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ai));return r}var Ah=256,Wt=class{constructor(t=Ah){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=fi(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=wt(n,0,this.cursor)}else r=ui(this.chunks,this.cursor);return t&&this.reset(),r}};var w="CBOR decode error:",Oe="CBOR encode error:",Jt=[];Jt[23]=1;Jt[24]=2;Jt[25]=3;Jt[26]=5;Jt[27]=9;function $e(e,t,r){if(e.length-t<r)throw new Error(`${w} not enough data for type`)}var V=[24,256,65536,4294967296,BigInt("18446744073709551616")];function oe(e,t,r){$e(e,t,1);let n=e[t];if(r.strict===!0&&n<V[0])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function se(e,t,r){$e(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<V[1])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function ie(e,t,r){$e(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<V[2])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);return n}function ae(e,t,r){$e(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<V[3])throw new Error(`${w} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${w} integers outside of the safe integer range are not supported`)}function pi(e,t,r,n){return new g(p.uint,oe(e,t+1,n),2)}function di(e,t,r,n){return new g(p.uint,se(e,t+1,n),3)}function hi(e,t,r,n){return new g(p.uint,ie(e,t+1,n),5)}function mi(e,t,r,n){return new g(p.uint,ae(e,t+1,n),9)}function de(e,t){return J(e,0,t.value)}function J(e,t,r){if(r<V[0]){let n=Number(r);e.push([t|n])}else if(r<V[1]){let n=Number(r);e.push([t|24,n])}else if(r<V[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<V[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<V[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),i=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=i&255,i=i>>8,o[3]=i&255,i=i>>8,o[2]=i&255,i=i>>8,o[1]=i&255,e.push(o)}else throw new Error(`${w} encountered BigInt larger than allowable range`)}}de.encodedSize=function(t){return J.encodedSize(t.value)};J.encodedSize=function(t){return t<V[0]?1:t<V[1]?2:t<V[2]?3:t<V[3]?5:9};de.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function gi(e,t,r,n){return new g(p.negint,-1-oe(e,t+1,n),2)}function yi(e,t,r,n){return new g(p.negint,-1-se(e,t+1,n),3)}function wi(e,t,r,n){return new g(p.negint,-1-ie(e,t+1,n),5)}var Gn=BigInt(-1),bi=BigInt(1);function xi(e,t,r,n){let o=ae(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new g(p.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${w} integers outside of the safe integer range are not supported`);return new g(p.negint,Gn-BigInt(o),9)}function Ir(e,t){let r=t.value,n=typeof r=="bigint"?r*Gn-bi:r*-1-1;J(e,t.type.majorEncoded,n)}Ir.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Gn-bi:r*-1-1;return n<V[0]?1:n<V[1]?2:n<V[2]?3:n<V[3]?5:9};Ir.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Kt(e,t,r,n){$e(e,t,r+n);let o=wt(e,t+r,t+r+n);return new g(p.bytes,o,r+n)}function Si(e,t,r,n){return Kt(e,t,1,r)}function Ei(e,t,r,n){return Kt(e,t,2,oe(e,t+1,n))}function Pi(e,t,r,n){return Kt(e,t,3,se(e,t+1,n))}function Ti(e,t,r,n){return Kt(e,t,5,ie(e,t+1,n))}function vi(e,t,r,n){let o=ae(e,t+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer bytes lengths not supported`);return Kt(e,t,9,o)}function kr(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===p.string?Cr(e.value):e.value),e.encodedBytes}function bt(e,t){let r=kr(t);J(e,t.type.majorEncoded,r.length),e.push(r)}bt.encodedSize=function(t){let r=kr(t);return J.encodedSize(r.length)+r.length};bt.compareTokens=function(t,r){return Ih(kr(t),kr(r))};function Ih(e,t){return e.length<t.length?-1:e.length>t.length?1:li(e,t)}function Xt(e,t,r,n,o){let s=r+n;$e(e,t,s);let i=new g(p.string,ci(e,t+r,t+s),s);return o.retainStringBytes===!0&&(i.byteValue=wt(e,t+r,t+s)),i}function Ai(e,t,r,n){return Xt(e,t,1,r,n)}function Ci(e,t,r,n){return Xt(e,t,2,oe(e,t+1,n),n)}function Ii(e,t,r,n){return Xt(e,t,3,se(e,t+1,n),n)}function ki(e,t,r,n){return Xt(e,t,5,ie(e,t+1,n),n)}function Ui(e,t,r,n){let o=ae(e,t+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer string lengths not supported`);return Xt(e,t,9,o,n)}var Bi=bt;function xt(e,t,r,n){return new g(p.array,n,r)}function Ni(e,t,r,n){return xt(e,t,1,r)}function _i(e,t,r,n){return xt(e,t,2,oe(e,t+1,n))}function Di(e,t,r,n){return xt(e,t,3,se(e,t+1,n))}function Ri(e,t,r,n){return xt(e,t,5,ie(e,t+1,n))}function Li(e,t,r,n){let o=ae(e,t+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer array lengths not supported`);return xt(e,t,9,o)}function Oi(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return xt(e,t,1,1/0)}function Ur(e,t){J(e,p.array.majorEncoded,t.value)}Ur.compareTokens=de.compareTokens;Ur.encodedSize=function(t){return J.encodedSize(t.value)};function St(e,t,r,n){return new g(p.map,n,r)}function $i(e,t,r,n){return St(e,t,1,r)}function Fi(e,t,r,n){return St(e,t,2,oe(e,t+1,n))}function zi(e,t,r,n){return St(e,t,3,se(e,t+1,n))}function ji(e,t,r,n){return St(e,t,5,ie(e,t+1,n))}function Mi(e,t,r,n){let o=ae(e,t+1,n);if(typeof o=="bigint")throw new Error(`${w} 64-bit integer map lengths not supported`);return St(e,t,9,o)}function qi(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return St(e,t,1,1/0)}function Br(e,t){J(e,p.map.majorEncoded,t.value)}Br.compareTokens=de.compareTokens;Br.encodedSize=function(t){return J.encodedSize(t.value)};function Vi(e,t,r,n){return new g(p.tag,r,1)}function Hi(e,t,r,n){return new g(p.tag,oe(e,t+1,n),2)}function Gi(e,t,r,n){return new g(p.tag,se(e,t+1,n),3)}function Wi(e,t,r,n){return new g(p.tag,ie(e,t+1,n),5)}function Ji(e,t,r,n){return new g(p.tag,ae(e,t+1,n),9)}function Nr(e,t){J(e,p.tag.majorEncoded,t.value)}Nr.compareTokens=de.compareTokens;Nr.encodedSize=function(t){return J.encodedSize(t.value)};var Dh=20,Rh=21,Lh=22,Oh=23;function Ki(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${w} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new g(p.null,null,1):new g(p.undefined,void 0,1)}function Xi(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${w} indefinite length items not allowed`);return new g(p.break,void 0,1)}function Wn(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${w} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${w} Infinity values are not supported`)}return new g(p.float,e,t)}function Qi(e,t,r,n){return Wn(Jn(e,t+1),3,n)}function Zi(e,t,r,n){return Wn(Kn(e,t+1),5,n)}function Yi(e,t,r,n){return Wn(na(e,t+1),9,n)}function _r(e,t,r){let n=t.value;if(n===!1)e.push([p.float.majorEncoded|Dh]);else if(n===!0)e.push([p.float.majorEncoded|Rh]);else if(n===null)e.push([p.float.majorEncoded|Lh]);else if(n===void 0)e.push([p.float.majorEncoded|Oh]);else{let o,s=!1;(!r||r.float64!==!0)&&(ta(n),o=Jn(Te,1),n===o||Number.isNaN(n)?(Te[0]=249,e.push(Te.slice(0,3)),s=!0):(ra(n),o=Kn(Te,1),n===o&&(Te[0]=250,e.push(Te.slice(0,5)),s=!0))),s||($h(n),o=na(Te,1),Te[0]=251,e.push(Te.slice(0,9)))}}_r.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){ta(n);let o=Jn(Te,1);if(n===o||Number.isNaN(n))return 3;if(ra(n),o=Kn(Te,1),n===o)return 5}return 9};var ea=new ArrayBuffer(9),he=new DataView(ea,1),Te=new Uint8Array(ea,0);function ta(e){if(e===1/0)he.setUint16(0,31744,!1);else if(e===-1/0)he.setUint16(0,64512,!1);else if(Number.isNaN(e))he.setUint16(0,32256,!1);else{he.setFloat32(0,e);let t=he.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)he.setUint16(0,31744,!1);else if(r===0)he.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?he.setUint16(0,0):o<-14?he.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):he.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Jn(e,t){if(e.length-t<2)throw new Error(`${w} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function ra(e){he.setFloat32(0,e,!1)}function Kn(e,t){if(e.length-t<4)throw new Error(`${w} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function $h(e){he.setFloat64(0,e,!1)}function na(e,t){if(e.length-t<8)throw new Error(`${w} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}_r.compareTokens=de.compareTokens;function U(e,t,r){throw new Error(`${w} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Dr(e){return()=>{throw new Error(`${w} ${e}`)}}var y=[];for(let e=0;e<=23;e++)y[e]=U;y[24]=pi;y[25]=di;y[26]=hi;y[27]=mi;y[28]=U;y[29]=U;y[30]=U;y[31]=U;for(let e=32;e<=55;e++)y[e]=U;y[56]=gi;y[57]=yi;y[58]=wi;y[59]=xi;y[60]=U;y[61]=U;y[62]=U;y[63]=U;for(let e=64;e<=87;e++)y[e]=Si;y[88]=Ei;y[89]=Pi;y[90]=Ti;y[91]=vi;y[92]=U;y[93]=U;y[94]=U;y[95]=Dr("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)y[e]=Ai;y[120]=Ci;y[121]=Ii;y[122]=ki;y[123]=Ui;y[124]=U;y[125]=U;y[126]=U;y[127]=Dr("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)y[e]=Ni;y[152]=_i;y[153]=Di;y[154]=Ri;y[155]=Li;y[156]=U;y[157]=U;y[158]=U;y[159]=Oi;for(let e=160;e<=183;e++)y[e]=$i;y[184]=Fi;y[185]=zi;y[186]=ji;y[187]=Mi;y[188]=U;y[189]=U;y[190]=U;y[191]=qi;for(let e=192;e<=215;e++)y[e]=Vi;y[216]=Hi;y[217]=Gi;y[218]=Wi;y[219]=Ji;y[220]=U;y[221]=U;y[222]=U;y[223]=U;for(let e=224;e<=243;e++)y[e]=Dr("simple values are not supported");y[244]=U;y[245]=U;y[246]=U;y[247]=Ki;y[248]=Dr("simple values are not supported");y[249]=Qi;y[250]=Zi;y[251]=Yi;y[252]=U;y[253]=U;y[254]=U;y[255]=Xi;var ve=[];for(let e=0;e<24;e++)ve[e]=new g(p.uint,e,1);for(let e=-1;e>=-24;e--)ve[31-e]=new g(p.negint,e,1);ve[64]=new g(p.bytes,new Uint8Array(0),1);ve[96]=new g(p.string,"",1);ve[128]=new g(p.array,0,1);ve[160]=new g(p.map,0,1);ve[244]=new g(p.false,!1,1);ve[245]=new g(p.true,!0,1);ve[246]=new g(p.null,null,1);function oa(e){switch(e.type){case p.false:return Ue([244]);case p.true:return Ue([245]);case p.null:return Ue([246]);case p.bytes:return e.value.length?void 0:Ue([64]);case p.string:return e.value===""?Ue([96]):void 0;case p.array:return e.value===0?Ue([128]):void 0;case p.map:return e.value===0?Ue([160]):void 0;case p.uint:return e.value<24?Ue([Number(e.value)]):void 0;case p.negint:if(e.value>=-24)return Ue([31-Number(e.value)])}}var zh={float64:!1,mapSorter:qh,quickEncodeToken:oa};function jh(){let e=[];return e[p.uint.major]=de,e[p.negint.major]=Ir,e[p.bytes.major]=bt,e[p.string.major]=Bi,e[p.array.major]=Ur,e[p.map.major]=Br,e[p.tag.major]=Nr,e[p.float.major]=_r,e}var sa=jh(),Xn=new Wt,Et=class{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Oe} object contains circular references`);return new Et(r,t)}},Ke={null:new g(p.null,null),undefined:new g(p.undefined,void 0),true:new g(p.true,!0),false:new g(p.false,!1),emptyArray:new g(p.array,0),emptyMap:new g(p.map,0)},Xe={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new g(p.float,e):e>=0?new g(p.uint,e):new g(p.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new g(p.uint,e):new g(p.negint,e)},Uint8Array(e,t,r,n){return new g(p.bytes,e)},string(e,t,r,n){return new g(p.string,e)},boolean(e,t,r,n){return e?Ke.true:Ke.false},null(e,t,r,n){return Ke.null},undefined(e,t,r,n){return Ke.undefined},ArrayBuffer(e,t,r,n){return new g(p.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new g(p.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ke.emptyArray,new g(p.break)]:Ke.emptyArray;n=Et.createCheck(n,e);let o=[],s=0;for(let i of e)o[s++]=Rr(i,r,n);return r.addBreakTokens?[new g(p.array,e.length),o,new g(p.break)]:[new g(p.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),i=o?e.size:s.length;if(!i)return r.addBreakTokens===!0?[Ke.emptyMap,new g(p.break)]:Ke.emptyMap;n=Et.createCheck(n,e);let a=[],c=0;for(let l of s)a[c++]=[Rr(l,r,n),Rr(o?e.get(l):e[l],r,n)];return Mh(a,r),r.addBreakTokens?[new g(p.map,i),a,new g(p.break)]:[new g(p.map,i),a]}};Xe.Map=Xe.Object;Xe.Buffer=Xe.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Xe[`${e}Array`]=Xe.DataView;function Rr(e,t={},r){let n=oi(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||Xe[n];if(typeof o=="function"){let i=o(e,n,t,r);if(i!=null)return i}let s=Xe[n];if(!s)throw new Error(`${Oe} unsupported type: ${n}`);return s(e,n,t,r)}function Mh(e,t){t.mapSorter&&e.sort(t.mapSorter)}function qh(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,s=sa[o].compareTokens(r,n);return s===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),s}function ia(e,t,r,n){if(Array.isArray(t))for(let o of t)ia(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=Rr(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=t[n.type.major];if(s.encodedSize){let i=s.encodedSize(n,r),a=new Wt(i);if(s(a,n,r),a.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Gt(a.chunks[0])}}return Xn.reset(),ia(Xn,n,t,r),Xn.toBytes(!0)}function Zn(e,t){return t=Object.assign({},zh,t),Qn(e,sa,t)}var Vh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Yn=class{constructor(t,r={}){this.pos=0,this.data=t,this.options=r}done(){return this.pos>=this.data.length}next(){let t=this.data[this.pos],r=ve[t];if(r===void 0){let n=y[t];if(!n)throw new Error(`${w} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},Qt=Symbol.for("DONE"),Lr=Symbol.for("BREAK");function Hh(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=Zt(t,r);if(s===Lr){if(e.value===1/0)break;throw new Error(`${w} got unexpected break to lengthed array`)}if(s===Qt)throw new Error(`${w} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function Gh(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let i=0;i<e.value;i++){let a=Zt(t,r);if(a===Lr){if(e.value===1/0)break;throw new Error(`${w} got unexpected break to lengthed map`)}if(a===Qt)throw new Error(`${w} found map but not enough entries (got ${i} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${w} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(a)||!n&&a in o))throw new Error(`${w} found repeat map key "${a}"`);let c=Zt(t,r);if(c===Qt)throw new Error(`${w} found map but not enough entries (got ${i} [no value], expected ${e.value})`);n?s.set(a,c):o[a]=c}return n?s:o}function Zt(e,t){if(e.done())return Qt;let r=e.next();if(r.type===p.break)return Lr;if(r.type.terminal)return r.value;if(r.type===p.array)return Hh(r,e,t);if(r.type===p.map)return Gh(r,e,t);if(r.type===p.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Zt(e,t);return t.tags[r.value](n)}throw new Error(`${w} tag not supported (${r.value})`)}throw new Error("unsupported")}function Yt(e,t){if(!(e instanceof Uint8Array))throw new Error(`${w} data to decode must be a Uint8Array`);t=Object.assign({},Vh,t);let r=t.tokenizer||new Yn(e,t),n=Zt(r,t);if(n===Qt)throw new Error(`${w} did not find any content to decode`);if(n===Lr)throw new Error(`${w} got unexpected break`);if(!r.done())throw new Error(`${w} too many terminals, data makes no sense`);return n}var aa=42;function Jh(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=h.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new g(p.tag,aa),new g(p.bytes,r)]}function Kh(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Xh(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var Qh={float64:!0,typeEncoders:{Object:Jh,undefined:Kh,number:Xh}};function Zh(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return h.decode(e.subarray(1))}var ca={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};ca.tags[aa]=Zh;var Yh="dag-cbor",em=113,eo=e=>Zn(e,Qh),to=e=>Yt(e,ca);var fo={};q(fo,{code:()=>pm,decode:()=>la,encode:()=>fa,format:()=>dm,name:()=>lm,parse:()=>mm,stringify:()=>dm});var ro=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(t){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===p.array&&(r.elements++,r.elements!==1&&t.push([44])),r.type===p.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?t.push([44]):t.push([58]))))}[p.uint.major](t,r){this.prefix(t);let n=String(r.value),o=[];for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s);t.push(o)}[p.negint.major](t,r){this[p.uint.major](t,r)}[p.bytes.major](t,r){throw new Error(`${Oe} unsupported type: Uint8Array`)}[p.string.major](t,r){this.prefix(t);let n=Cr(JSON.stringify(r.value));t.push(n.length>32?Gt(n):n)}[p.array.major](t,r){this.prefix(t),this.inRecursive.push({type:p.array,elements:0}),t.push([91])}[p.map.major](t,r){this.prefix(t),this.inRecursive.push({type:p.map,elements:0}),t.push([123])}[p.tag.major](t,r){}[p.float.major](t,r){if(r.type.name==="break"){let i=this.inRecursive.pop();if(i){if(i.type===p.array)t.push([93]);else if(i.type===p.map)t.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${Oe} unsupported type: undefined`);if(this.prefix(t),r.type.name==="true"){t.push([116,114,117,101]);return}else if(r.type.name==="false"){t.push([102,97,108,115,101]);return}else if(r.type.name==="null"){t.push([110,117,108,108]);return}let n=String(r.value),o=[],s=!1;for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i),!s&&(o[i]===46||o[i]===101||o[i]===69)&&(s=!0);s||(o.push(46),o.push(48)),t.push(o)}};function tm(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${Oe} complex map keys are not supported`);let r=e[0],n=t[0];if(r.type!==p.string||n.type!==p.string)throw new Error(`${Oe} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${Oe} unexpected duplicate map keys, this is not supported`)}var rm={addBreakTokens:!0,mapSorter:tm};function no(e,t){return t=Object.assign({},rm,t),Qn(e,new ro,t)}var Pt=class{constructor(t,r={}){this.pos=0,this.data=t,this.options=r,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let t=this.ch();for(;t===32||t===9||t===13||t===10;)t=this.data[++this.pos]}expect(t){if(this.data.length-this.pos<t.length)throw new Error(`${w} unexpected end of input at position ${this.pos}`);for(let r=0;r<t.length;r++)if(this.data[this.pos++]!==t[r])throw new Error(`${w} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...t)}'`)}parseNumber(){let t=this.pos,r=!1,n=!1,o=a=>{for(;!this.done();){let c=this.ch();if(a.includes(c))this.pos++;else break}};if(this.ch()===45&&(r=!0,this.pos++),this.ch()===48)if(this.pos++,this.ch()===46)this.pos++,n=!0;else return new g(p.uint,0,this.pos-t);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this.pos===t+1)throw new Error(`${w} unexpected token at position ${this.pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${w} unexpected token at position ${this.pos}`);n=!0,this.pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this.pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this.pos++,o([48,49,50,51,52,53,54,55,56,57]));let s=String.fromCharCode.apply(null,this.data.subarray(t,this.pos)),i=parseFloat(s);return n?new g(p.float,i,this.pos-t):this.options.allowBigInt!==!0||Number.isSafeInteger(i)?new g(i>=0?p.uint:p.negint,i,this.pos-t):new g(i>=0?p.uint:p.negint,BigInt(s),this.pos-t)}parseString(){if(this.ch()!==34)throw new Error(`${w} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let s=this.pos,i=0;s<this.data.length&&i<65536;s++,i++){let a=this.data[s];if(a===92||a<32||a>=128)break;if(a===34){let c=String.fromCharCode.apply(null,this.data.subarray(this.pos,s));return this.pos=s+1,new g(p.string,c,i)}}let t=this.pos,r=[],n=()=>{if(this.pos+4>=this.data.length)throw new Error(`${w} unexpected end of unicode escape sequence at position ${this.pos}`);let s=0;for(let i=0;i<4;i++){let a=this.ch();if(a>=48&&a<=57)a-=48;else if(a>=97&&a<=102)a=a-97+10;else if(a>=65&&a<=70)a=a-65+10;else throw new Error(`${w} unexpected unicode escape character at position ${this.pos}`);s=s*16+a,this.pos++}return s},o=()=>{let s=this.ch(),i=null,a=s>239?4:s>223?3:s>191?2:1;if(this.pos+a>this.data.length)throw new Error(`${w} unexpected unicode sequence at position ${this.pos}`);let c,l,d,m;switch(a){case 1:s<128&&(i=s);break;case 2:c=this.data[this.pos+1],(c&192)===128&&(m=(s&31)<<6|c&63,m>127&&(i=m));break;case 3:c=this.data[this.pos+1],l=this.data[this.pos+2],(c&192)===128&&(l&192)===128&&(m=(s&15)<<12|(c&63)<<6|l&63,m>2047&&(m<55296||m>57343)&&(i=m));break;case 4:c=this.data[this.pos+1],l=this.data[this.pos+2],d=this.data[this.pos+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(m=(s&15)<<18|(c&63)<<12|(l&63)<<6|d&63,m>65535&&m<1114112&&(i=m))}i===null?(i=65533,a=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|i&1023),r.push(i),this.pos+=a};for(;!this.done();){let s=this.ch(),i;switch(s){case 92:if(this.pos++,this.done())throw new Error(`${w} unexpected string termination at position ${this.pos}`);switch(i=this.ch(),this.pos++,i){case 34:case 39:case 92:case 47:r.push(i);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${w} unexpected string escape character at position ${this.pos}`)}break;case 34:return this.pos++,new g(p.string,Hn(r),this.pos-t);default:if(s<32)throw new Error(`${w} invalid control character at position ${this.pos}`);s<128?(r.push(s),this.pos++):o()}}throw new Error(`${w} unexpected end of string at position ${this.pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this.pos++,new g(p.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new g(p.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new g(p.null,null,4);case 102:return this.expect([102,97,108,115,101]),new g(p.false,!1,5);case 116:return this.expect([116,114,117,101]),new g(p.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${w} unexpected character at position ${this.pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this.pos++,this.skipWhitespace(),new g(p.break,void 0,1);if(this.ch()!==44)throw new Error(`${w} unexpected character at position ${this.pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this.pos++,this.skipWhitespace(),new g(p.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this.pos++,this.skipWhitespace(),new g(p.break,void 0,1);if(this.ch()!==44)throw new Error(`${w} unexpected character at position ${this.pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this.pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this.pos++,this.skipWhitespace(),new g(p.break,void 0,1);let t=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${w} unexpected character at position ${this.pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this.pos++,this.modeStack.push("obj-value"),t}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${w} unexpected parse state at position ${this.pos}; this shouldn't happen`)}}};function oo(e,t){return t=Object.assign({tokenizer:new Pt(e,t)},t),Yt(e,t)}var io=({name:e,code:t,encode:r})=>new so(e,t,r),so=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ge(this.code,r):r.then(n=>Ge(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ao={};q(ao,{base64:()=>Tt,base64pad:()=>om,base64url:()=>Qe,base64urlpad:()=>sm});var Tt=O({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),om=O({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Qe=O({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sm=O({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function im(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=h.asCID(e);if(!t)return null;let r=t.toString();return[new g(p.map,1/0,1),new g(p.string,"/",1),new g(p.string,r,r.length),new g(p.break,void 0,1)]}function $r(e){let t=Tt.encode(e).slice(1);return[new g(p.map,1/0,1),new g(p.string,"/",1),new g(p.map,1/0,1),new g(p.string,"bytes",5),new g(p.string,t,t.length),new g(p.break,void 0,1),new g(p.break,void 0,1)]}function Ae(e){return $r(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function am(e){return $r(new Uint8Array(e))}function cm(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function um(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var fm={typeEncoders:{Object:im,Buffer:$r,Uint8Array:$r,Int8Array:Ae,Uint16Array:Ae,Int16Array:Ae,Uint32Array:Ae,Int32Array:Ae,Float32Array:Ae,Float64Array:Ae,Uint8ClampedArray:Ae,BigInt64Array:Ae,BigUint64Array:Ae,DataView:Ae,ArrayBuffer:am,undefined:cm,number:um}},co=class extends Pt{constructor(t,r){super(t,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let t=this._next();if(t.type===p.map){let r=this._next();if(r.type===p.string&&r.value==="/"){let n=this._next();if(n.type===p.string){if(this._next().type!==p.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new g(p.tag,42,0)}if(n.type===p.map){let o=this._next();if(o.type===p.string&&o.value==="bytes"){let s=this._next();if(s.type===p.string){for(let a=0;a<2;a++)if(this._next().type!==p.break)throw new Error("Invalid encoded Bytes form");let i=Tt.decode(`m${s.value}`);return new g(p.bytes,i,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return t}},uo={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};uo.tags[42]=h.parse;var lm="dag-json",pm=297,fa=e=>no(e,fm),la=e=>{let t=Object.assign(uo,{tokenizer:new co(e,uo)});return oo(e,t)},dm=e=>hm.decode(fa(e));var hm=new TextDecoder,mm=e=>la(gm.encode(e)),gm=new TextEncoder;var lo={};q(lo,{code:()=>Tm,decode:()=>Im,encode:()=>Cm,name:()=>Pm,toGeneral:()=>xa});function Ce(e){return Qe.encode(e).slice(1)}function me(e){return Qe.decode(`u${e}`)}function pa(e){let[t,r,n]=e;return{payload:r,signatures:[{protected:t,signature:n}],link:h.decode(me(r))}}function ym(e){let t={signature:me(e.signature)};return e.header&&(t.header=e.header),e.protected&&(t.protected=me(e.protected)),t}function da(e){let t=me(e.payload);try{h.decode(t)}catch{throw new Error("Not a valid DagJWS")}return{payload:t,signatures:e.signatures.map(ym)}}function wm(e){let t={signature:Ce(e.signature)};return e.header&&(t.header=e.header),e.protected&&(t.protected=Ce(e.protected)),t}function ha(e){let t={payload:Ce(e.payload),signatures:e.signatures.map(wm)};return t.link=h.decode(new Uint8Array(e.payload)),t}function ma(e){let[t,r,n,o,s]=e,i={ciphertext:o,iv:n,protected:t,tag:s};return r&&(i.recipients=[{encrypted_key:r}]),i}function xm(e){let t={};return e.encrypted_key&&(t.encrypted_key=me(e.encrypted_key)),e.header&&(t.header=e.header),t}function ga(e){let t={ciphertext:me(e.ciphertext),protected:me(e.protected),iv:me(e.iv),tag:me(e.tag)};return e.aad&&(t.aad=me(e.aad)),e.recipients&&(t.recipients=e.recipients.map(xm)),e.unprotected&&(t.unprotected=e.unprotected),t}function Sm(e){let t={};return e.encrypted_key&&(t.encrypted_key=Ce(e.encrypted_key)),e.header&&(t.header=e.header),t}function ya(e){let t={ciphertext:Ce(e.ciphertext),protected:Ce(e.protected),iv:Ce(e.iv),tag:Ce(e.tag)};return e.aad&&(t.aad=Ce(e.aad)),e.recipients&&(t.recipients=e.recipients.map(Sm)),e.unprotected&&(t.unprotected=e.unprotected),t}var Pm="dag-jose",Tm=133;function wa(e){return"payload"in e&&typeof e.payload=="string"&&"signatures"in e&&Array.isArray(e.signatures)}function vm(e){return"payload"in e&&e.payload instanceof Uint8Array&&"signatures"in e&&Array.isArray(e.signatures)}function Am(e){return"ciphertext"in e&&e.ciphertext instanceof Uint8Array&&"iv"in e&&e.iv instanceof Uint8Array&&"protected"in e&&e.protected instanceof Uint8Array&&"tag"in e&&e.tag instanceof Uint8Array}function ba(e){return"ciphertext"in e&&typeof e.ciphertext=="string"&&"iv"in e&&typeof e.iv=="string"&&"protected"in e&&typeof e.protected=="string"&&"tag"in e&&typeof e.tag=="string"}function xa(e){if(typeof e=="string"){let t=e.split(".");if(t.length===3)return pa(t);if(t.length===5)return ma(t);throw new Error("Not a valid JOSE string")}if(wa(e)||ba(e))return e;throw new Error("Not a valid unencoded JOSE object")}function Cm(e){typeof e=="string"&&(e=xa(e));let t;if(wa(e))t=da(e);else if(ba(e))t=ga(e);else throw new Error("Not a valid JOSE object");return new Uint8Array(eo(t))}function Im(e){let t;try{t=to(e)}catch{throw new Error("Not a valid DAG-JOSE object")}if(vm(t))return ha(t);if(Am(t))return ya(t);throw new Error("Not a valid DAG-JOSE object")}var po={};q(po,{identity:()=>ot});var Sa=0,km="identity",Ea=Pe,Um=e=>Ge(Sa,Ea(e)),ot={code:Sa,name:km,encode:Ea,digest:Um};var ho={};q(ho,{identity:()=>Bm});var Bm=mt({prefix:"\0",name:"identity",encode:e=>zs(e),decode:e=>Fs(e)});var mo={};q(mo,{base2:()=>Nm});var Nm=O({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var go={};q(go,{base8:()=>_m});var _m=O({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var yo={};q(yo,{base10:()=>Dm});var Dm=Je({prefix:"9",name:"base10",alphabet:"0123456789"});var wo={};q(wo,{base16:()=>Rm,base16upper:()=>Lm});var Rm=O({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lm=O({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bo={};q(bo,{base36:()=>Om,base36upper:()=>$m});var Om=Je({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$m=Je({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xo={};q(xo,{base256emoji:()=>qm});var Pa=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}"),Fm=Pa.reduce((e,t,r)=>(e[r]=t,e),[]),zm=Pa.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function jm(e){return e.reduce((t,r)=>(t+=Fm[r],t),"")}function Mm(e){let t=[];for(let r of e){let n=zm[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}var qm=mt({prefix:"\u{1F680}",name:"base256emoji",encode:jm,decode:Mm});var So={};q(So,{sha256:()=>Fr,sha512:()=>Vm});var Ta=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Fr=io({name:"sha2-256",code:18,encode:Ta("SHA-256")}),Vm=io({name:"sha2-512",code:19,encode:Ta("SHA-512")});var Eo={};q(Eo,{code:()=>Gm,decode:()=>Jm,encode:()=>Wm,name:()=>Hm});var Hm="raw",Gm=85,Wm=e=>Pe(e),Jm=e=>Pe(e);var Po={};q(Po,{code:()=>Zm,decode:()=>eg,encode:()=>Ym,name:()=>Qm});var Km=new TextEncoder,Xm=new TextDecoder,Qm="json",Zm=512,Ym=e=>Km.encode(JSON.stringify(e)),eg=e=>JSON.parse(Xm.decode(e));var ge={...ho,...mo,...go,...yo,...wo,...$n,...bo,...On,...ao,...xo},va={...So,...po},Aa={raw:Eo,json:Po};var zr=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();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(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let s=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let d=this.readAtomically(()=>{let m=this.readChar();if(m===void 0)return;let x=Number.parseInt(m,t);if(!Number.isNaN(x))return x});if(d===void 0)break;if(s*=t,s+=d,s>l||(i+=1,r!==void 0&&i>r))return}if(i!==0)return!n&&c&&i>1?void 0:s})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=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]=t(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]=t(s.subarray(0,i));return r.set(s.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ca=45,tg=15,vt=new zr;function To(e){if(!(e.length>tg))return vt.new(e).parseWith(()=>vt.readIPv4Addr())}function vo(e){if(!(e.length>Ca))return vt.new(e).parseWith(()=>vt.readIPv6Addr())}function jr(e){if(!(e.length>Ca))return vt.new(e).parseWith(()=>vt.readIPAddr())}function Mr(e){return Boolean(To(e))}function qr(e){return Boolean(vo(e))}function Ze(e){return Boolean(jr(e))}function At(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Vr(e=0){return globalThis.Buffer?.allocUnsafe!=null?At(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function ka(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ia=ka("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Ao=ka("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Vr(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),rg={utf8:Ia,"utf-8":Ia,hex:ge.base16,latin1:Ao,ascii:Ao,binary:Ao,...ge},Hr=rg;function C(e,t="utf8"){let r=Hr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}var Ua=Mr,ng=qr,Co=function(e){let t=0;if(e=e.toString().trim(),Ua(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(ng(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=Ua(r[n]),i;s&&(i=Co(r[n]),r[n]=C(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,C(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(t+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Ba=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(e[t+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var er={},Io={},sg=[[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"],[281,0,"webrtc-w3c"],[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"]];sg.forEach(e=>{let t=ig(...e);Io[t.code]=t,er[t.name]=t});function ig(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(o)}}function L(e){if(typeof e=="number"){if(Io[e]!=null)return Io[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(er[e]!=null)return er[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var Be=N(st(),1);function X(e,t="utf8"){let r=Hr[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?At(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function H(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=Vr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return At(r)}function Ha(e,t){switch(L(e).code){case 4:case 41:return Sg(t);case 42:return qa(t);case 6:case 273:case 33:case 132:return Wa(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return qa(t);case 421:return vg(t);case 444:return Va(t);case 445:return Va(t);case 466:return Tg(t);default:return C(t,"base16")}}function Ga(e,t){switch(L(e).code){case 4:return ja(t);case 41:return ja(t);case 42:return Ma(t);case 6:case 273:case 33:case 132:return No(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ma(t);case 421:return Eg(t);case 444:return Ag(t);case 445:return Cg(t);case 466:return Pg(t);default:return X(t,"base16")}}var Bo=Object.values(ge).map(e=>e.decoder),xg=function(){let e=Bo[0].or(Bo[1]);return Bo.slice(2).forEach(t=>e=e.or(t)),e}();function ja(e){if(!Ze(e))throw new Error("invalid ip address");return Co(e)}function Sg(e){let t=Ba(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Ze(t))throw new Error("invalid ip address");return t}function No(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Wa(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Ma(e){let t=X(e),r=Uint8Array.from(Be.default.encode(t.length));return H([r,t],r.length+t.length)}function qa(e){let t=Be.default.decode(e);if(e=e.slice(Be.default.decode.bytes),e.length!==t)throw new Error("inconsistent lengths");return C(e)}function Eg(e){let t;e[0]==="Q"||e[0]==="1"?t=Le(R.decode(`z${e}`)).bytes:t=h.parse(e).multihash.bytes;let r=Uint8Array.from(Be.default.encode(t.length));return H([r,t],r.length+t.length)}function Pg(e){let t=xg.decode(e),r=Uint8Array.from(Be.default.encode(t.length));return H([r,t],r.length+t.length)}function Tg(e){let t=Be.default.decode(e),r=e.slice(Be.default.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return"u"+C(r,"base64url")}function vg(e){let t=Be.default.decode(e),r=e.slice(Be.default.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return C(r,"base58btc")}function Ag(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=ee.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=No(n);return H([r,o],r.length+o.length)}function Cg(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=ee.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=No(n);return H([r,o],r.length+o.length)}function Va(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=C(t,"base32"),o=Wa(r);return`${n}:${o}`}var Ct=N(st(),1);function Ig(e){let t=[],r=e.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=L(o);if(s.size===0){t.push([o]);continue}if(n++,n>=r.length)throw Ka("invalid address: "+e);if(s.path===!0){t.push([o,Oo(r.slice(n).join("/"))]);break}t.push([o,r[n]])}return t}function kg(e){let t=[];return e.map(r=>{let n=Jr(r);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),Oo(t.join("/"))}function Ug(e){return e.map(t=>{Array.isArray(t)||(t=[t]);let r=Jr(t);return t.length>1?[r.code,Ga(r.code,t[1])]:[r.code]})}function _o(e){return e.map(t=>{let r=Jr(t);return t[1]!=null?[r.code,Ha(r.code,t[1])]:[r.code]})}function Do(e){return Wr(H(e.map(t=>{let r=Jr(t),n=Uint8Array.from(Ct.default.encode(r.code));return t.length>1&&t[1]!=null&&(n=H([n,t[1]])),n})))}function Ro(e,t){return e.size>0?e.size/8:e.size===0?0:Ct.default.decode(t)+(Ct.default.decode.bytes??0)}function Gr(e){let t=[],r=0;for(;r<e.length;){let n=Ct.default.decode(e,r),o=Ct.default.decode.bytes??0,s=L(n),i=Ro(s,e.slice(r+o));if(i===0){t.push([n]),r+=o;continue}let a=e.slice(r+o,r+o+i);if(r+=i+o,r>e.length)throw Ka("Invalid address Uint8Array: "+C(e,"base16"));t.push([n,a])}return t}function Lo(e){let t=Gr(e),r=_o(t);return kg(r)}function Bg(e){e=Oo(e);let t=Ig(e),r=Ug(t);return Do(r)}function Ja(e){return Bg(e)}function Wr(e){let t=Ng(e);if(t!=null)throw t;return Uint8Array.from(e)}function Ng(e){try{Gr(e)}catch(t){return t}}function Oo(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function Ka(e){return new Error("Error parsing address: "+e)}function Jr(e){return L(e[0])}var Fo=N(st(),1);var Ya=N(te(),1);function it(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}var It=function(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)},$o=function(e,t,r,n,o){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r},tr,rr,nr,Za,Rg=Symbol.for("nodejs.util.inspect.custom"),Lg=[L("dns").code,L("dns4").code,L("dns6").code,L("dnsaddr").code],Og=new Map,ec=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Kr(e){return Boolean(e?.[ec])}var Fe=class{constructor(t){if(tr.set(this,void 0),rr.set(this,void 0),nr.set(this,void 0),this[Za]=!0,t==null&&(t=""),t instanceof Uint8Array)this.bytes=Wr(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=Ja(t)}else if(Kr(t))this.bytes=Wr(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return It(this,tr,"f")==null&&$o(this,tr,Lo(this.bytes),"f"),It(this,tr,"f")}toJSON(){return this.toString()}toOptions(){let t,r,n,o,s="",i=L("tcp"),a=L("udp"),c=L("ip4"),l=L("ip6"),d=L("dns6"),m=L("ip6zone");for(let[P,T]of this.stringTuples())P===m.code&&(s=`%${T??""}`),Lg.includes(P)&&(r=i.name,o=443,n=`${T??""}${s}`,t=P===d.code?6:4),(P===i.code||P===a.code)&&(r=L(P).name,o=parseInt(T??"")),(P===c.code||P===l.code)&&(r=L(P).name,n=`${T??""}${s}`,t=P===l.code?6:4);if(t==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:t,host:n,transport:r,port:o}}protos(){return this.protoCodes().map(t=>Object.assign({},L(t)))}protoCodes(){let t=[],r=this.bytes,n=0;for(;n<r.length;){let o=Fo.default.decode(r,n),s=Fo.default.decode.bytes??0,i=L(o),a=Ro(i,r.slice(n+s));n+=a+s,t.push(o)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return It(this,rr,"f")==null&&$o(this,rr,Gr(this.bytes),"f"),It(this,rr,"f")}stringTuples(){return It(this,nr,"f")==null&&$o(this,nr,_o(this.tuples()),"f"),It(this,nr,"f")}encapsulate(t){return t=new Fe(t),new Fe(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new Fe(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new Fe(Do(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===er.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?C(R.decode(`z${n}`),"base58btc"):C(h.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>L(r[0]).path===!0)[0][1],t==null&&(t=null)}catch{t=null}return t}equals(t){return it(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=Og.get(r.name);if(n==null)throw(0,Ya.default)(new Error(`no available resolver for ${r.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new Fe(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[(tr=new WeakMap,rr=new WeakMap,nr=new WeakMap,Za=ec,Rg)](){return`Multiaddr(${Lo(this.bytes)})`}};function _(e){return new Fe(e)}var _e=N(zo(),1);var Wg=/(-?(?:\d+\.?\d*|\d*\.?\d+)(?:e[-+]?\d+)?)\s*([\p{L}]*)/uig;v.nanosecond=v.ns=1/1e6;v.\u00B5s=v.\u03BCs=v.us=v.microsecond=1/1e3;v.millisecond=v.ms=v[""]=1;v.second=v.sec=v.s=v.ms*1e3;v.minute=v.min=v.m=v.s*60;v.hour=v.hr=v.h=v.m*60;v.day=v.d=v.h*24;v.week=v.wk=v.w=v.d*7;v.month=v.b=v.d*(365.25/12);v.year=v.yr=v.y=v.d*365.25;function v(e="",t="ms"){var r=null;return e=(e+"").replace(/(\d)[,_](\d)/g,"$1$2"),e.replace(Wg,function(n,o,s){s=oc(s),s&&(r=(r||0)+parseFloat(o,10)*s)}),r&&r/(oc(t)||1)}function oc(e){return v[e]||v[e.toLowerCase().replace(/s$/,"")]}var sc=v;var ye=N(fc(),1);ye.default.formatters.b=e=>e==null?"undefined":R.baseEncode(e);ye.default.formatters.t=e=>e==null?"undefined":ee.baseEncode(e);ye.default.formatters.m=e=>e==null?"undefined":Tt.baseEncode(e);ye.default.formatters.p=e=>e==null?"undefined":e.toString();ye.default.formatters.c=e=>e==null?"undefined":e.toString();ye.default.formatters.k=e=>e==null?"undefined":e.toString();function iy(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function Yr(e){let t=iy(`${e}:trace`);return ye.default.enabled(`${e}:trace`)&&ye.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=(0,ye.default)(`${e}:trace`)),Object.assign((0,ye.default)(e),{error:(0,ye.default)(`${e}:error`),trace:t})}var ct=N(nn(),1);var Mc=N(Ko(),1),qc=Mc.default;var ar=class extends Error{code;props;constructor(t,r,n){super(t),this.code=r,this.name=n?.name??"CodeError",this.props=n??{}}};var ls=N(st(),1);var Dt=N(st(),1);var Xx=parseInt("0xFFFF",16),Qx=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Ne=N(st(),1);var Gc=Mr,Ky=qr,ts=function(e){let t=0;if(e=e.toString().trim(),Gc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(Ky(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let s=Gc(r[n]),i;s&&(i=ts(r[n]),r[n]=C(i.slice(0,2),"base16")),i!=null&&++n<8&&r.splice(n,0,C(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(t+16);for(n=0;n<r.length;n++){let s=parseInt(r[n],16);o[t++]=s>>8&255,o[t++]=s&255}return o}throw new Error("invalid ip address")},Wc=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let s=0;s<r;s++)o.push(e[t+s]);return o.join(".")}if(r===16){let o=[];for(let s=0;s<r;s+=2)o.push(n.getUint16(t+s).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var cr={},rs={},Qy=[[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"]];Qy.forEach(e=>{let t=Zy(...e);rs[t.code]=t,cr[t.name]=t});function Zy(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(o)}}function I(e){if(typeof e=="number"){if(rs[e]!=null)return rs[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(cr[e]!=null)return cr[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var N2=I("ip4"),_2=I("ip6"),D2=I("ipcidr");function Zc(e,t){switch(I(e).code){case 4:case 41:return ew(t);case 42:return Xc(t);case 6:case 273:case 33:case 132:return eu(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Xc(t);case 421:return ow(t);case 444:return Qc(t);case 445:return Qc(t);case 466:return nw(t);default:return C(t,"base16")}}function Yc(e,t){switch(I(e).code){case 4:return Jc(t);case 41:return Jc(t);case 42:return Kc(t);case 6:case 273:case 33:case 132:return os(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Kc(t);case 421:return tw(t);case 444:return sw(t);case 445:return iw(t);case 466:return rw(t);default:return X(t,"base16")}}var ns=Object.values(ge).map(e=>e.decoder),Yy=function(){let e=ns[0].or(ns[1]);return ns.slice(2).forEach(t=>e=e.or(t)),e}();function Jc(e){if(!Ze(e))throw new Error("invalid ip address");return ts(e)}function ew(e){let t=Wc(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Ze(t))throw new Error("invalid ip address");return t}function os(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function eu(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Kc(e){let t=X(e),r=Uint8Array.from(Ne.default.encode(t.length));return H([r,t],r.length+t.length)}function Xc(e){let t=Ne.default.decode(e);if(e=e.slice(Ne.default.decode.bytes),e.length!==t)throw new Error("inconsistent lengths");return C(e)}function tw(e){let t;e[0]==="Q"||e[0]==="1"?t=Le(R.decode(`z${e}`)).bytes:t=h.parse(e).multihash.bytes;let r=Uint8Array.from(Ne.default.encode(t.length));return H([r,t],r.length+t.length)}function rw(e){let t=Yy.decode(e),r=Uint8Array.from(Ne.default.encode(t.length));return H([r,t],r.length+t.length)}function nw(e){let t=Ne.default.decode(e),r=e.slice(Ne.default.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return"u"+C(r,"base64url")}function ow(e){let t=Ne.default.decode(e),r=e.slice(Ne.default.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return C(r,"base58btc")}function sw(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=ee.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=os(n);return H([r,o],r.length+o.length)}function iw(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=ee.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=os(n);return H([r,o],r.length+o.length)}function Qc(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=C(t,"base32"),o=eu(r);return`${n}:${o}`}function aw(e){let t=[],r=e.split("/").slice(1);if(r.length===1&&r[0]==="")return[];for(let n=0;n<r.length;n++){let o=r[n],s=I(o);if(s.size===0){t.push([o]);continue}if(n++,n>=r.length)throw ru("invalid address: "+e);if(s.path===!0){t.push([o,us(r.slice(n).join("/"))]);break}t.push([o,r[n]])}return t}function cw(e){let t=[];return e.map(r=>{let n=an(r);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),us(t.join("/"))}function uw(e){return e.map(t=>{Array.isArray(t)||(t=[t]);let r=an(t);return t.length>1?[r.code,Yc(r.code,t[1])]:[r.code]})}function ss(e){return e.map(t=>{let r=an(t);return t[1]!=null?[r.code,Zc(r.code,t[1])]:[r.code]})}function is(e){return sn(H(e.map(t=>{let r=an(t),n=Uint8Array.from(Dt.default.encode(r.code));return t.length>1&&t[1]!=null&&(n=H([n,t[1]])),n})))}function as(e,t){return e.size>0?e.size/8:e.size===0?0:Dt.default.decode(t)+(Dt.default.decode.bytes??0)}function on(e){let t=[],r=0;for(;r<e.length;){let n=Dt.default.decode(e,r),o=Dt.default.decode.bytes??0,s=I(n),i=as(s,e.slice(r+o));if(i===0){t.push([n]),r+=o;continue}let a=e.slice(r+o,r+o+i);if(r+=i+o,r>e.length)throw ru("Invalid address Uint8Array: "+C(e,"base16"));t.push([n,a])}return t}function cs(e){let t=on(e),r=ss(t);return cw(r)}function fw(e){e=us(e);let t=aw(e),r=uw(t);return is(r)}function tu(e){return fw(e)}function sn(e){let t=lw(e);if(t!=null)throw t;return Uint8Array.from(e)}function lw(e){try{on(e)}catch(t){return t}}function us(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}function ru(e){return new Error("Error parsing address: "+e)}function an(e){return I(e[0])}var dw=Symbol.for("nodejs.util.inspect.custom"),hw=[I("dns").code,I("dns4").code,I("dns6").code,I("dnsaddr").code],mw=new Map,nu=Symbol.for("@multiformats/js-multiaddr/multiaddr");function gw(e){return Boolean(e?.[nu])}var ze=class{bytes;#t;#r;#n;#e;[nu]=!0;constructor(t){if(t==null&&(t=""),t instanceof Uint8Array)this.bytes=sn(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=tu(t)}else if(gw(t))this.bytes=sn(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr")}toString(){return this.#t==null&&(this.#t=cs(this.bytes)),this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,s="",i=I("tcp"),a=I("udp"),c=I("ip4"),l=I("ip6"),d=I("dns6"),m=I("ip6zone");for(let[P,T]of this.stringTuples())P===m.code&&(s=`%${T??""}`),hw.includes(P)&&(r=i.name,o=443,n=`${T??""}${s}`,t=P===d.code?6:4),(P===i.code||P===a.code)&&(r=I(P).name,o=parseInt(T??"")),(P===c.code||P===l.code)&&(r=I(P).name,n=`${T??""}${s}`,t=P===l.code?6:4);if(t==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:t,host:n,transport:r,port:o}}protos(){return this.protoCodes().map(t=>Object.assign({},I(t)))}protoCodes(){let t=[],r=this.bytes,n=0;for(;n<r.length;){let o=ls.default.decode(r,n),s=ls.default.decode.bytes??0,i=I(o),a=as(i,r.slice(n+s));n+=a+s,t.push(o)}return t}protoNames(){return this.protos().map(t=>t.name)}tuples(){return this.#r==null&&(this.#r=on(this.bytes)),this.#r}stringTuples(){return this.#n==null&&(this.#n=ss(this.tuples())),this.#n}encapsulate(t){return t=new ze(t),new ze(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new ze(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new ze(is(r.slice(0,n)));return this}getPeerId(){try{let r=this.stringTuples().filter(n=>n[0]===cr.ipfs.code).pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?C(R.decode(`z${n}`),"base58btc"):C(h.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){if(this.#e===void 0)try{this.#e=this.stringTuples().filter(t=>I(t[0]).path===!0)[0][1],this.#e==null&&(this.#e=null)}catch{this.#e=null}return this.#e}equals(t){return it(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(s=>s.resolvable);if(r==null)return[this];let n=mw.get(r.name);if(n==null)throw new ar(`no available resolver for ${r.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(s=>new ze(s))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[dw](){return`Multiaddr(${cs(this.bytes)})`}};function fs(e){return new ze(e)}function ou(e){let t;try{t=I("sni").code}catch{return null}for(let[r,n]of e)if(r===t&&n!==void 0)return n;return null}function su(e){return e.some(([t,r])=>t===I("tls").code)}function ue(e,t,r){let n=iu[I(e).name];if(n===void 0)throw new Error(`Can't interpret protocol ${I(e).name}`);let o=n(t,r);return e===I("ip6").code?`[${o}]`:o}var iu={ip4:(e,t)=>e,ip6:(e,t)=>t.length===0?e:`[${e}]`,tcp:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`tcp://${ue(r[0],r[1]??"",t)}:${e}`},udp:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`udp://${ue(r[0],r[1]??"",t)}:${e}`},dnsaddr:(e,t)=>e,dns4:(e,t)=>e,dns6:(e,t)=>e,dns:(e,t)=>e,ipfs:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${ue(r[0],r[1]??"",t)}/ipfs/${e}`},p2p:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${ue(r[0],r[1]??"",t)}/p2p/${e}`},http:(e,t)=>{let r=su(t),n=ou(t);if(r&&n!==null)return`https://${n}`;let o=r?"https://":"http://",s=t.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=ue(s[0],s[1]??"",t);return i=i.replace("tcp://",""),`${o}${i}`},tls:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return ue(r[0],r[1]??"",t)},sni:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return ue(r[0],r[1]??"",t)},https:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=ue(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`https://${n}`},ws:(e,t)=>{let r=su(t),n=ou(t);if(r&&n!==null)return`wss://${n}`;let o=r?"wss://":"ws://",s=t.pop();if(s===void 0)throw new Error("Unexpected end of multiaddr");let i=ue(s[0],s[1]??"",t);return i=i.replace("tcp://",""),`${o}${i}`},wss:(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");let n=ue(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${ue(r[0],r[1]??"",t)}/p2p-websocket-star`},"p2p-webrtc-star":(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${ue(r[0],r[1]??"",t)}/p2p-webrtc-star`},"p2p-webrtc-direct":(e,t)=>{let r=t.pop();if(r===void 0)throw new Error("Unexpected end of multiaddr");return`${ue(r[0],r[1]??"",t)}/p2p-webrtc-direct`}};function au(e,t){let n=fs(e).stringTuples(),o=n.pop();if(o===void 0)throw new Error("Unexpected end of multiaddr");let s=I(o[0]),i=iu[s.name];if(i==null)throw new Error(`No interpreter found for ${s.name}`);let a=i(o[1]??"",n);return t?.assumeHttp!==!1&&o[0]===I("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}function ps(e){try{e=au(_(e))}catch{}return e=e.toString(),e}var cu=()=>{};var uu=Yr("ipfs-http-client:lib:error-handler"),yw=qc.bind({ignoreUndefined:!0}),ww=_e.isBrowser||_e.isWebWorker?location.protocol:"http",bw=_e.isBrowser||_e.isWebWorker?location.hostname:"localhost",xw=_e.isBrowser||_e.isWebWorker?location.port:"5001",Sw=(e={})=>{let t,r={},n;if(typeof e=="string"||Kr(e))t=new URL(ps(e));else if(e instanceof URL)t=e;else if(typeof e.url=="string"||Kr(e.url))t=new URL(ps(e.url)),r=e;else if(e.url instanceof URL)t=e.url,r=e;else{r=e||{};let o=(r.protocol||ww).replace(":",""),s=(r.host||bw).split(":")[0],i=r.port||xw;t=new URL(`${o}://${s}:${i}`)}if(r.apiPath?t.pathname=r.apiPath:(t.pathname==="/"||t.pathname===void 0)&&(t.pathname="api/v0"),_e.isNode){let o=cu(t);n=r.agent||new o({keepAlive:!0,maxSockets:6})}return{...r,host:t.host,protocol:t.protocol.replace(":",""),port:Number(t.port),apiPath:t.pathname,url:t,agent:n}},Ew=async e=>{let t;try{if((e.headers.get("Content-Type")||"").startsWith("application/json")){let n=await e.json();uu(n),t=n.Message||n.message}else t=await e.text()}catch(n){uu("Failed to parse error response",n),t=n.message}let r=new ct.default.HTTPError(e);throw t&&(t.includes("deadline has elapsed")&&(r=new ct.default.TimeoutError),t&&t.includes("context deadline exceeded")&&(r=new ct.default.TimeoutError)),t&&t.includes("request timed out")&&(r=new ct.default.TimeoutError),t&&(r.message=t),r},Pw=/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,fu=e=>e.replace(Pw,function(t){return"-"+t.toLowerCase()}),Tw=e=>typeof e=="string"?sc(e):e,Ye=class extends ct.default{constructor(t={}){let r=Sw(t);super({timeout:Tw(r.timeout||0)||void 0,headers:r.headers,base:`${r.url}`,handleError:Ew,transformSearchParams:o=>{let s=new URLSearchParams;for(let[i,a]of o)a!=="undefined"&&a!=="null"&&i!=="signal"&&s.append(fu(i),a),i==="timeout"&&!isNaN(a)&&s.append(fu(i),a);return s},agent:r.agent}),delete this.get,delete this.put,delete this.delete,delete this.options;let n=this.fetch;this.fetch=(o,s={})=>(typeof o=="string"&&!o.startsWith("/")&&(o=`${r.url}/${o}`),n.call(this,o,yw(s,{method:"POST"})))}},lS=ct.default.HTTPError;var u=e=>t=>e(new Ye(t),t);function cn(e){if(e!=null)return typeof e=="string"?e:e.toString(8).padStart(4,"0")}var lu=N(te(),1);function un(e){if(e==null)return;let t;if(e.secs!=null&&(t={secs:e.secs,nsecs:e.nsecs}),e.Seconds!=null&&(t={secs:e.Seconds,nsecs:e.FractionalNanoseconds}),Array.isArray(e)&&(t={secs:e[0],nsecs:e[1]}),e instanceof Date){let r=e.getTime(),n=Math.floor(r/1e3);t={secs:n,nsecs:(r-n*1e3)*1e3}}if(Object.prototype.hasOwnProperty.call(t,"secs")){if(t!=null&&t.nsecs!=null&&(t.nsecs<0||t.nsecs>999999999))throw(0,lu.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return t}}function f({arg:e,searchParams:t,hashAlg:r,mtime:n,mode:o,...s}={}){t&&(s={...s,...t}),r&&(s.hash=r),n!=null&&(n=un(n),s.mtime=n.secs,s.mtimeNsecs=n.nsecs),o!=null&&(s.mode=cn(o)),s.timeout&&!isNaN(s.timeout)&&(s.timeout=`${s.timeout}ms`),e==null?e=[]:Array.isArray(e)||(e=[e]);let i=new URLSearchParams(s);return e.forEach(a=>i.append("arg",a)),i}var pu=u(e=>{async function t(r={}){return((await(await e.post("bitswap/wantlist",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()).Keys||[]).map(o=>h.parse(o["/"]))}return t});var du=u(e=>{async function t(r,n={}){return((await(await e.post("bitswap/wantlist",{signal:n.signal,searchParams:f({...n,peer:r.toString()}),headers:n.headers})).json()).Keys||[]).map(s=>h.parse(s["/"]))}return t});var hu=Symbol.for("@libp2p/peer-id");var vw=Symbol.for("nodejs.util.inspect.custom"),mu=Object.values(ge).map(e=>e.decoder).reduce((e,t)=>e.or(t),ge.identity.decoder),gu=114,yu=36,wu=37,ur=class{constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[hu](){return!0}toString(){return this.string==null&&(this.string=R.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return h.createV1(gu,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t instanceof Uint8Array)return it(this.multihash.bytes,t);if(typeof t=="string")return F(t).equals(this);if(t?.multihash?.bytes!=null)return it(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[vw](){return`PeerId(${this.toString()})`}},fr=class extends ur{constructor(t){super({...t,type:"RSA"}),this.type="RSA",this.publicKey=t.publicKey}},lr=class extends ur{constructor(t){super({...t,type:"Ed25519"}),this.type="Ed25519",this.publicKey=t.multihash.digest}},pr=class extends ur{constructor(t){super({...t,type:"secp256k1"}),this.type="secp256k1",this.publicKey=t.multihash.digest}};function F(e,t){if(t=t??mu,e.charAt(0)==="1"||e.charAt(0)==="Q"){let r=Le(R.decode(`z${e}`));return e.startsWith("12D")?new lr({multihash:r}):e.startsWith("16U")?new pr({multihash:r}):new fr({multihash:r})}return Aw(mu.decode(e))}function Aw(e){try{let t=Le(e);if(t.code===ot.code){if(t.digest.length===yu)return new lr({multihash:t});if(t.digest.length===wu)return new pr({multihash:t})}if(t.code===Fr.code)return new fr({multihash:t})}catch{return Cw(h.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function Cw(e){if(e==null||e.multihash==null||e.version==null||e.version===1&&e.code!==gu)throw new Error("Supplied PeerID CID is invalid");let t=e.multihash;if(t.code===Fr.code)return new fr({multihash:e.multihash});if(t.code===ot.code){if(t.digest.length===yu)return new lr({multihash:e.multihash});if(t.digest.length===wu)return new pr({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}var fn=u(e=>{async function t(r={}){let n=await e.post("bitswap/stat",{searchParams:f(r),signal:r.signal,headers:r.headers});return Iw(await n.json())}return t});function Iw(e){return{provideBufLen:e.ProvideBufLen,wantlist:(e.Wantlist||[]).map(t=>h.parse(t["/"])),peers:(e.Peers||[]).map(t=>F(t)),blocksReceived:BigInt(e.BlocksReceived),dataReceived:BigInt(e.DataReceived),blocksSent:BigInt(e.BlocksSent),dataSent:BigInt(e.DataSent),dupBlksReceived:BigInt(e.DupBlksReceived),dupDataReceived:BigInt(e.DupDataReceived)}}var bu=u(e=>{async function t(r,n={}){return(await e.post("bitswap/unwant",{signal:n.signal,searchParams:f({arg:r.toString(),...n}),headers:n.headers})).json()}return t});function xu(e){return{wantlist:pu(e),wantlistForPeer:du(e),unwant:bu(e),stat:fn(e)}}var ln=u(e=>{async function t(r,n={}){let o=await e.post("block/get",{signal:n.signal,searchParams:f({arg:r.toString(),...n}),headers:n.headers});return new Uint8Array(await o.arrayBuffer())}return t});var Eu=N(te(),1);function je(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}async function*we(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}async function dr(e){let t=[];for await(let r of e)t.push(r);return t}function be(e){return ArrayBuffer.isView(e)||e instanceof ArrayBuffer}function Me(e){return e.constructor&&(e.constructor.name==="Blob"||e.constructor.name==="File")&&typeof e.stream=="function"}function hr(e){return typeof e=="object"&&(e.path||e.content)}var qe=e=>e&&typeof e.getReader=="function";async function Pu(e){if(be(e))return new Blob([e]);if(typeof e=="string"||e instanceof String)return new Blob([e.toString()]);if(Me(e))return e;if(qe(e)&&(e=we(e)),Symbol.iterator in e||Symbol.asyncIterator in e){let t=je(e),{value:r,done:n}=await t.peek();if(n)return Su(t);if(t.push(r),Number.isInteger(r))return new Blob([Uint8Array.from(await dr(t))]);if(be(r)||typeof r=="string"||r instanceof String)return Su(t)}throw(0,Eu.default)(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT")}async function Su(e){let t=[];for await(let r of e)t.push(r);return new Blob(t)}var wr=N(te(),1);async function*Rt(e,t){for await(let r of e)yield t(r)}var Ef=N(te(),1);var Ve=N(Sf(),1),Ot=Ve.default.Reader,As=Ve.default.Writer,S=Ve.default.util,K=Ve.default.roots["ipfs-unixfs"]||(Ve.default.roots["ipfs-unixfs"]={}),$w=K.Data=(()=>{function e(t){if(this.blocksizes=[],t)for(var r=Object.keys(t),n=0;n<r.length;++n)t[r[n]]!=null&&(this[r[n]]=t[r[n]])}return e.prototype.Type=0,e.prototype.Data=S.newBuffer([]),e.prototype.filesize=S.Long?S.Long.fromBits(0,0,!0):0,e.prototype.blocksizes=S.emptyArray,e.prototype.hashType=S.Long?S.Long.fromBits(0,0,!0):0,e.prototype.fanout=S.Long?S.Long.fromBits(0,0,!0):0,e.prototype.mode=0,e.prototype.mtime=null,e.encode=function(r,n){if(n||(n=As.create()),n.uint32(8).int32(r.Type),r.Data!=null&&Object.hasOwnProperty.call(r,"Data")&&n.uint32(18).bytes(r.Data),r.filesize!=null&&Object.hasOwnProperty.call(r,"filesize")&&n.uint32(24).uint64(r.filesize),r.blocksizes!=null&&r.blocksizes.length)for(var o=0;o<r.blocksizes.length;++o)n.uint32(32).uint64(r.blocksizes[o]);return r.hashType!=null&&Object.hasOwnProperty.call(r,"hashType")&&n.uint32(40).uint64(r.hashType),r.fanout!=null&&Object.hasOwnProperty.call(r,"fanout")&&n.uint32(48).uint64(r.fanout),r.mode!=null&&Object.hasOwnProperty.call(r,"mode")&&n.uint32(56).uint32(r.mode),r.mtime!=null&&Object.hasOwnProperty.call(r,"mtime")&&K.UnixTime.encode(r.mtime,n.uint32(66).fork()).ldelim(),n},e.decode=function(r,n){r instanceof Ot||(r=Ot.create(r));for(var o=n===void 0?r.len:r.pos+n,s=new K.Data;r.pos<o;){var i=r.uint32();switch(i>>>3){case 1:s.Type=r.int32();break;case 2:s.Data=r.bytes();break;case 3:s.filesize=r.uint64();break;case 4:if(s.blocksizes&&s.blocksizes.length||(s.blocksizes=[]),(i&7)===2)for(var a=r.uint32()+r.pos;r.pos<a;)s.blocksizes.push(r.uint64());else s.blocksizes.push(r.uint64());break;case 5:s.hashType=r.uint64();break;case 6:s.fanout=r.uint64();break;case 7:s.mode=r.uint32();break;case 8:s.mtime=K.UnixTime.decode(r,r.uint32());break;default:r.skipType(i&7);break}}if(!s.hasOwnProperty("Type"))throw S.ProtocolError("missing required 'Type'",{instance:s});return s},e.fromObject=function(r){if(r instanceof K.Data)return r;var n=new K.Data;switch(r.Type){case"Raw":case 0:n.Type=0;break;case"Directory":case 1:n.Type=1;break;case"File":case 2:n.Type=2;break;case"Metadata":case 3:n.Type=3;break;case"Symlink":case 4:n.Type=4;break;case"HAMTShard":case 5:n.Type=5;break}if(r.Data!=null&&(typeof r.Data=="string"?S.base64.decode(r.Data,n.Data=S.newBuffer(S.base64.length(r.Data)),0):r.Data.length&&(n.Data=r.Data)),r.filesize!=null&&(S.Long?(n.filesize=S.Long.fromValue(r.filesize)).unsigned=!0:typeof r.filesize=="string"?n.filesize=parseInt(r.filesize,10):typeof r.filesize=="number"?n.filesize=r.filesize:typeof r.filesize=="object"&&(n.filesize=new S.LongBits(r.filesize.low>>>0,r.filesize.high>>>0).toNumber(!0))),r.blocksizes){if(!Array.isArray(r.blocksizes))throw TypeError(".Data.blocksizes: array expected");n.blocksizes=[];for(var o=0;o<r.blocksizes.length;++o)S.Long?(n.blocksizes[o]=S.Long.fromValue(r.blocksizes[o])).unsigned=!0:typeof r.blocksizes[o]=="string"?n.blocksizes[o]=parseInt(r.blocksizes[o],10):typeof r.blocksizes[o]=="number"?n.blocksizes[o]=r.blocksizes[o]:typeof r.blocksizes[o]=="object"&&(n.blocksizes[o]=new S.LongBits(r.blocksizes[o].low>>>0,r.blocksizes[o].high>>>0).toNumber(!0))}if(r.hashType!=null&&(S.Long?(n.hashType=S.Long.fromValue(r.hashType)).unsigned=!0:typeof r.hashType=="string"?n.hashType=parseInt(r.hashType,10):typeof r.hashType=="number"?n.hashType=r.hashType:typeof r.hashType=="object"&&(n.hashType=new S.LongBits(r.hashType.low>>>0,r.hashType.high>>>0).toNumber(!0))),r.fanout!=null&&(S.Long?(n.fanout=S.Long.fromValue(r.fanout)).unsigned=!0:typeof r.fanout=="string"?n.fanout=parseInt(r.fanout,10):typeof r.fanout=="number"?n.fanout=r.fanout:typeof r.fanout=="object"&&(n.fanout=new S.LongBits(r.fanout.low>>>0,r.fanout.high>>>0).toNumber(!0))),r.mode!=null&&(n.mode=r.mode>>>0),r.mtime!=null){if(typeof r.mtime!="object")throw TypeError(".Data.mtime: object expected");n.mtime=K.UnixTime.fromObject(r.mtime)}return n},e.toObject=function(r,n){n||(n={});var o={};if((n.arrays||n.defaults)&&(o.blocksizes=[]),n.defaults){if(o.Type=n.enums===String?"Raw":0,n.bytes===String?o.Data="":(o.Data=[],n.bytes!==Array&&(o.Data=S.newBuffer(o.Data))),S.Long){var s=new S.Long(0,0,!0);o.filesize=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else o.filesize=n.longs===String?"0":0;if(S.Long){var s=new S.Long(0,0,!0);o.hashType=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else o.hashType=n.longs===String?"0":0;if(S.Long){var s=new S.Long(0,0,!0);o.fanout=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else o.fanout=n.longs===String?"0":0;o.mode=0,o.mtime=null}if(r.Type!=null&&r.hasOwnProperty("Type")&&(o.Type=n.enums===String?K.Data.DataType[r.Type]:r.Type),r.Data!=null&&r.hasOwnProperty("Data")&&(o.Data=n.bytes===String?S.base64.encode(r.Data,0,r.Data.length):n.bytes===Array?Array.prototype.slice.call(r.Data):r.Data),r.filesize!=null&&r.hasOwnProperty("filesize")&&(typeof r.filesize=="number"?o.filesize=n.longs===String?String(r.filesize):r.filesize:o.filesize=n.longs===String?S.Long.prototype.toString.call(r.filesize):n.longs===Number?new S.LongBits(r.filesize.low>>>0,r.filesize.high>>>0).toNumber(!0):r.filesize),r.blocksizes&&r.blocksizes.length){o.blocksizes=[];for(var i=0;i<r.blocksizes.length;++i)typeof r.blocksizes[i]=="number"?o.blocksizes[i]=n.longs===String?String(r.blocksizes[i]):r.blocksizes[i]:o.blocksizes[i]=n.longs===String?S.Long.prototype.toString.call(r.blocksizes[i]):n.longs===Number?new S.LongBits(r.blocksizes[i].low>>>0,r.blocksizes[i].high>>>0).toNumber(!0):r.blocksizes[i]}return r.hashType!=null&&r.hasOwnProperty("hashType")&&(typeof r.hashType=="number"?o.hashType=n.longs===String?String(r.hashType):r.hashType:o.hashType=n.longs===String?S.Long.prototype.toString.call(r.hashType):n.longs===Number?new S.LongBits(r.hashType.low>>>0,r.hashType.high>>>0).toNumber(!0):r.hashType),r.fanout!=null&&r.hasOwnProperty("fanout")&&(typeof r.fanout=="number"?o.fanout=n.longs===String?String(r.fanout):r.fanout:o.fanout=n.longs===String?S.Long.prototype.toString.call(r.fanout):n.longs===Number?new S.LongBits(r.fanout.low>>>0,r.fanout.high>>>0).toNumber(!0):r.fanout),r.mode!=null&&r.hasOwnProperty("mode")&&(o.mode=r.mode),r.mtime!=null&&r.hasOwnProperty("mtime")&&(o.mtime=K.UnixTime.toObject(r.mtime,n)),o},e.prototype.toJSON=function(){return this.constructor.toObject(this,Ve.default.util.toJSONOptions)},e.DataType=function(){let t={},r=Object.create(t);return r[t[0]="Raw"]=0,r[t[1]="Directory"]=1,r[t[2]="File"]=2,r[t[3]="Metadata"]=3,r[t[4]="Symlink"]=4,r[t[5]="HAMTShard"]=5,r}(),e})(),CE=K.UnixTime=(()=>{function e(t){if(t)for(var r=Object.keys(t),n=0;n<r.length;++n)t[r[n]]!=null&&(this[r[n]]=t[r[n]])}return e.prototype.Seconds=S.Long?S.Long.fromBits(0,0,!1):0,e.prototype.FractionalNanoseconds=0,e.encode=function(r,n){return n||(n=As.create()),n.uint32(8).int64(r.Seconds),r.FractionalNanoseconds!=null&&Object.hasOwnProperty.call(r,"FractionalNanoseconds")&&n.uint32(21).fixed32(r.FractionalNanoseconds),n},e.decode=function(r,n){r instanceof Ot||(r=Ot.create(r));for(var o=n===void 0?r.len:r.pos+n,s=new K.UnixTime;r.pos<o;){var i=r.uint32();switch(i>>>3){case 1:s.Seconds=r.int64();break;case 2:s.FractionalNanoseconds=r.fixed32();break;default:r.skipType(i&7);break}}if(!s.hasOwnProperty("Seconds"))throw S.ProtocolError("missing required 'Seconds'",{instance:s});return s},e.fromObject=function(r){if(r instanceof K.UnixTime)return r;var n=new K.UnixTime;return r.Seconds!=null&&(S.Long?(n.Seconds=S.Long.fromValue(r.Seconds)).unsigned=!1:typeof r.Seconds=="string"?n.Seconds=parseInt(r.Seconds,10):typeof r.Seconds=="number"?n.Seconds=r.Seconds:typeof r.Seconds=="object"&&(n.Seconds=new S.LongBits(r.Seconds.low>>>0,r.Seconds.high>>>0).toNumber())),r.FractionalNanoseconds!=null&&(n.FractionalNanoseconds=r.FractionalNanoseconds>>>0),n},e.toObject=function(r,n){n||(n={});var o={};if(n.defaults){if(S.Long){var s=new S.Long(0,0,!1);o.Seconds=n.longs===String?s.toString():n.longs===Number?s.toNumber():s}else o.Seconds=n.longs===String?"0":0;o.FractionalNanoseconds=0}return r.Seconds!=null&&r.hasOwnProperty("Seconds")&&(typeof r.Seconds=="number"?o.Seconds=n.longs===String?String(r.Seconds):r.Seconds:o.Seconds=n.longs===String?S.Long.prototype.toString.call(r.Seconds):n.longs===Number?new S.LongBits(r.Seconds.low>>>0,r.Seconds.high>>>0).toNumber():r.Seconds),r.FractionalNanoseconds!=null&&r.hasOwnProperty("FractionalNanoseconds")&&(o.FractionalNanoseconds=r.FractionalNanoseconds),o},e.prototype.toJSON=function(){return this.constructor.toObject(this,Ve.default.util.toJSONOptions)},e})(),IE=K.Metadata=(()=>{function e(t){if(t)for(var r=Object.keys(t),n=0;n<r.length;++n)t[r[n]]!=null&&(this[r[n]]=t[r[n]])}return e.prototype.MimeType="",e.encode=function(r,n){return n||(n=As.create()),r.MimeType!=null&&Object.hasOwnProperty.call(r,"MimeType")&&n.uint32(10).string(r.MimeType),n},e.decode=function(r,n){r instanceof Ot||(r=Ot.create(r));for(var o=n===void 0?r.len:r.pos+n,s=new K.Metadata;r.pos<o;){var i=r.uint32();switch(i>>>3){case 1:s.MimeType=r.string();break;default:r.skipType(i&7);break}}return s},e.fromObject=function(r){if(r instanceof K.Metadata)return r;var n=new K.Metadata;return r.MimeType!=null&&(n.MimeType=String(r.MimeType)),n},e.toObject=function(r,n){n||(n={});var o={};return n.defaults&&(o.MimeType=""),r.MimeType!=null&&r.hasOwnProperty("MimeType")&&(o.MimeType=r.MimeType),o},e.prototype.toJSON=function(){return this.constructor.toObject(this,Ve.default.util.toJSONOptions)},e})();var kE=parseInt("0644",8),UE=parseInt("0755",8);function gn(e){if(e!=null)return typeof e=="number"?e&4095:(e=e.toString(),e.substring(0,1)==="0"?parseInt(e,8)&4095:parseInt(e,10)&4095)}function yn(e){if(e==null)return;let t;if(e.secs!=null&&(t={secs:e.secs,nsecs:e.nsecs}),e.Seconds!=null&&(t={secs:e.Seconds,nsecs:e.FractionalNanoseconds}),Array.isArray(e)&&(t={secs:e[0],nsecs:e[1]}),e instanceof Date){let r=e.getTime(),n=Math.floor(r/1e3);t={secs:n,nsecs:(r-n*1e3)*1e3}}if(Object.prototype.hasOwnProperty.call(t,"secs")){if(t!=null&&t.nsecs!=null&&(t.nsecs<0||t.nsecs>999999999))throw(0,Ef.default)(new Error("mtime-nsecs must be within the range [0,999999999]"),"ERR_INVALID_MTIME_NSECS");return t}}async function*Pf(e,t){if(typeof e=="string"||e instanceof String||be(e)||Me(e)||e._readableState)throw(0,wr.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(qe(e)&&(e=we(e)),Symbol.iterator in e||Symbol.asyncIterator in e){let r=je(e),{value:n,done:o}=await r.peek();if(o){yield*[];return}if(r.push(n),Number.isInteger(n))throw(0,wr.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT");if(n._readableState){yield*Rt(r,s=>Cs({content:s},t));return}if(be(n)){yield Cs({content:r},t);return}if(hr(n)||n[Symbol.iterator]||n[Symbol.asyncIterator]||qe(n)||Me(n)){yield*Rt(r,s=>Cs(s,t));return}}throw hr(e)?(0,wr.default)(new Error("Unexpected input: single item passed - if you are using ipfs.addAll, please use ipfs.add instead"),"ERR_UNEXPECTED_INPUT"):(0,wr.default)(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}async function Cs(e,t){let{path:r,mode:n,mtime:o,content:s}=e,i={path:r||"",mode:gn(n),mtime:yn(o)};return s?i.content=await t(s):r||(i.content=await t(e)),i}function Tf(e){return Pf(e,Pu,!0)}function vf(e){if(e!=null)return typeof e=="string"?e:e.toString(8).padStart(4,"0")}async function z(e,t,r={}){let n=[],o=new FormData,s=0,i=0;for await(let{content:a,path:c,mode:l,mtime:d}of Tf(e)){let m="",x=a?"file":"dir";s>0&&(m=`-${s}`);let P=x+m,T=[];if(l!=null&&T.push(`mode=${vf(l)}`),d!=null){let{secs:B,nsecs:D}=d;T.push(`mtime=${B}`),D!=null&&T.push(`mtime-nsecs=${D}`)}if(T.length&&(P=`${P}?${T.join("&")}`),a){o.set(P,a,c!=null?encodeURIComponent(c):void 0);let B=i+a.size;n.push({name:c,start:i,end:B}),i=B}else if(c!=null)o.set(P,new File([""],encodeURIComponent(c),{type:"application/x-directory"}));else throw new Error("path or content or both must be set");s++}return{total:i,parts:n,headers:r,body:o}}var Af=N(Yo(),1);function zw(e){return e.filter(Boolean)}function j(...e){return(0,Af.anySignal)(zw(e))}var Cf=u(e=>{async function t(r,n={}){let o=new AbortController,s=j(o.signal,n.signal),i;try{i=await(await e.post("block/put",{signal:s,searchParams:f(n),...await z([r],o,n.headers)})).json()}catch(a){if(n.format==="dag-pb")return t(r,{...n,format:"protobuf"});if(n.format==="dag-cbor")return t(r,{...n,format:"cbor"});throw a}return h.parse(i.Key)}return t});var If=u(e=>{async function*t(r,n={}){Array.isArray(r)||(r=[r]);let o=await e.post("block/rm",{signal:n.signal,searchParams:f({arg:r.map(s=>s.toString()),"stream-channels":!0,...n}),headers:n.headers});for await(let s of o.ndjson())yield jw(s)}return t});function jw(e){let t={cid:h.parse(e.Hash)};return e.Error&&(t.error=new Error(e.Error)),t}var kf=u(e=>{async function t(r,n={}){let s=await(await e.post("block/stat",{signal:n.signal,searchParams:f({arg:r.toString(),...n}),headers:n.headers})).json();return{cid:h.parse(s.Key),size:s.Size}}return t});function Uf(e){return{get:ln(e),put:Cf(e),rm:If(e),stat:kf(e)}}var Bf=u(e=>{async function t(r,n={}){let o=await e.post("bootstrap/add",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers}),{Peers:s}=await o.json();return{Peers:s.map(i=>_(i))}}return t});var Nf=u(e=>{async function t(r={}){let n=await e.post("bootstrap/rm",{signal:r.signal,searchParams:f({...r,all:!0}),headers:r.headers}),{Peers:o}=await n.json();return{Peers:o.map(s=>_(s))}}return t});var _f=u(e=>{async function t(r={}){let n=await e.post("bootstrap/list",{signal:r.signal,searchParams:f(r),headers:r.headers}),{Peers:o}=await n.json();return{Peers:o.map(s=>_(s))}}return t});var Df=u(e=>{async function t(r={}){let n=await e.post("bootstrap/add",{signal:r.signal,searchParams:f({...r,default:!0}),headers:r.headers}),{Peers:o}=await n.json();return{Peers:o.map(s=>_(s))}}return t});var Rf=u(e=>{async function t(r,n={}){let o=await e.post("bootstrap/rm",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers}),{Peers:s}=await o.json();return{Peers:s.map(i=>_(i))}}return t});function Lf(e){return{add:Bf(e),clear:Nf(e),list:_f(e),reset:Df(e),rm:Rf(e)}}var Of=u(e=>{async function t(r,n={}){let s=await(await e.post("config/profile/apply",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).json();return{original:s.OldCfg,updated:s.NewCfg}}return t});function A(e){if(e==null)return e;let t=/^[A-Z]+$/,r={};return Object.keys(e).reduce((n,o)=>(t.test(o)?n[o.toLowerCase()]=e[o]:t.test(o[0])?n[o[0].toLowerCase()+o.slice(1)]=e[o]:n[o]=e[o],n),r)}var $f=u(e=>{async function t(r={}){return(await(await e.post("config/profile/list",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()).map(s=>A(s))}return t});function Ff(e){return{apply:Of(e),list:$f(e)}}var zf=u(e=>async(r,n={})=>{if(!r)throw new Error("key argument is required");return(await(await e.post("config",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).json()).Value});var jf=u(e=>async(r={})=>await(await e.post("config/show",{signal:r.signal,searchParams:f({...r}),headers:r.headers})).json());var Mf=u(e=>async(r,n={})=>{let o=new AbortController,s=j(o.signal,n.signal);await(await e.post("config/replace",{signal:s,searchParams:f(n),...await z([X(JSON.stringify(r))],o,n.headers)})).text()});var qf=u(e=>async(r,n,o={})=>{if(typeof r!="string")throw new Error("Invalid key type");let s={...o,...Mw(r,n)};await(await e.post("config",{signal:o.signal,searchParams:f(s),headers:o.headers})).text()}),Mw=(e,t)=>{switch(typeof t){case"boolean":return{arg:[e,t.toString()],bool:!0};case"string":return{arg:[e,t]};default:return{arg:[e,JSON.stringify(t)],json:!0}}};function Vf(e){return{getAll:jf(e),get:zf(e),set:qf(e),replace:Mf(e),profiles:Ff(e)}}var Hf=u(e=>{async function*t(r,n={}){yield*(await e.post("dag/export",{signal:n.signal,searchParams:f({arg:r.toString()}),headers:n.headers})).iterator()}return t});var Is=N(te(),1);async function*ks(e,t,r,n,o){let s=async l=>{let d=await r.getCodec(l.code),m=await n(l,o);return d.decode(m)},i=t.split("/").filter(Boolean),a=await s(e),c=e;for(;i.length;){let l=i.shift();if(!l)throw(0,Is.default)(new Error(`Could not resolve path "${t}"`),"ERR_INVALID_PATH");if(Object.prototype.hasOwnProperty.call(a,l))a=a[l],yield{value:a,remainderPath:i.join("/")};else throw(0,Is.default)(new Error(`no link named "${l}" under ${c}`),"ERR_NO_LINK");let d=h.asCID(a);d&&(c=d,a=await s(a))}yield{value:a,remainderPath:""}}async function Us(e){for await(let t of e)return t}async function He(e){let t;for await(let r of e)t=r;return t}var Gf=N(te(),1);var Wf=(e,t)=>u((n,o)=>{let s=ln(o);return async(a,c={})=>{if(c.path){let P=c.localResolve?await Us(ks(a,c.path,e,s,c)):await He(ks(a,c.path,e,s,c));if(!P)throw(0,Gf.default)(new Error("Not found"),"ERR_NOT_FOUND");return P}let l=await e.getCodec(a.code),d=await s(a,c);return{value:l.decode(d),remainderPath:""}}})(t);var Jf=u(e=>{async function*t(r,n={}){let o=new AbortController,s=j(o.signal,n.signal),{headers:i,body:a}=await z(r,o,n.headers),c=await e.post("dag/import",{signal:s,headers:i,body:a,searchParams:f({"pin-roots":n.pinRoots})});for await(let{Root:l}of c.ndjson())if(l!==void 0){let{Cid:{"/":d},PinErrorMsg:m}=l;yield{root:{cid:h.parse(d),pinErrorMsg:m}}}}return t});var wn=(e,t)=>u(n=>async(s,i={})=>{let a={storeCodec:"dag-cbor",hashAlg:"sha2-256",...i},c;if(a.inputCodec){if(!(s instanceof Uint8Array))throw new Error("Can only inputCodec on raw bytes that can be decoded");c=s}else c=(await e.getCodec(a.storeCodec)).encode(s),a.inputCodec=a.storeCodec;let l=new AbortController,d=j(l.signal,a.signal),x=await(await n.post("dag/put",{timeout:a.timeout,signal:d,searchParams:f(a),...await z([c],l,a.headers)})).json();return h.parse(x.Cid["/"])})(t);var Kf=u(e=>async(r,n={})=>{let s=await(await e.post("dag/resolve",{signal:n.signal,searchParams:f({arg:`${r}${n.path?`/${n.path}`.replace(/\/[/]+/g,"/"):""}`,...n}),headers:n.headers})).json();return{cid:h.parse(s.Cid["/"]),remainderPath:s.RemPath}});function Xf(e,t){return{export:Hf(t),get:Wf(e,t),import:Jf(t),put:wn(e,t),resolve:Kf(t)}}var Se=e=>{if(e.Type===0)return{name:"SENDING_QUERY",type:e.Type};if(e.Type===1)return{from:F(e.ID),name:"PEER_RESPONSE",type:e.Type,messageType:0,messageName:"PUT_VALUE",closer:(e.Responses||[]).map(({ID:t,Addrs:r})=>({id:F(t),multiaddrs:r.map(n=>_(n)),protocols:[]})),providers:(e.Responses||[]).map(({ID:t,Addrs:r})=>({id:F(t),multiaddrs:r.map(n=>_(n)),protocols:[]}))};if(e.Type===2){let t={id:e.ID??F(e.ID),multiaddrs:[],protocols:[]};return e.Responses&&e.Responses.length&&(t={id:F(e.Responses[0].ID),multiaddrs:e.Responses[0].Addrs.map(r=>_(r)),protocols:[]}),{name:"FINAL_PEER",type:e.Type,peer:t}}if(e.Type===3)return{name:"QUERY_ERROR",type:e.Type,error:new Error(e.Extra)};if(e.Type===4)return{name:"PROVIDER",type:e.Type,providers:e.Responses.map(({ID:t,Addrs:r})=>({id:F(t),multiaddrs:r.map(n=>_(n)),protocols:[]}))};if(e.Type===5)return{name:"VALUE",type:e.Type,value:X(e.Extra,"base64pad")};if(e.Type===6){let t=e.Responses.map(({ID:r})=>F(r));if(!t.length)throw new Error("No peer found");return{name:"ADDING_PEER",type:e.Type,peer:t[0]}}if(e.Type===7)return{name:"DIALING_PEER",type:e.Type,peer:F(e.ID)};throw new Error("Unknown DHT event type")};var Qf=u(e=>{async function*t(r,n={}){let o=await e.post("dht/findpeer",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers});for await(let s of o.ndjson())yield Se(s)}return t});var Zf=u(e=>{async function*t(r,n={}){let o=await e.post("dht/findprovs",{signal:n.signal,searchParams:f({arg:r.toString(),...n}),headers:n.headers});for await(let s of o.ndjson())yield Se(s)}return t});var Yf=u(e=>{async function*t(r,n={}){let o=await e.post("dht/get",{signal:n.signal,searchParams:f({arg:r instanceof Uint8Array?C(r):r.toString(),...n}),headers:n.headers});for await(let s of o.ndjson())yield Se(s)}return t});var el=u(e=>{async function*t(r,n={recursive:!1}){let o=Array.isArray(r)?r:[r],s=await e.post("dht/provide",{signal:n.signal,searchParams:f({arg:o.map(i=>i.toString()),...n}),headers:n.headers});for await(let i of s.ndjson())yield Se(i)}return t});var tl=u(e=>{async function*t(r,n,o={}){let s=new AbortController,i=j(s.signal,o.signal),a=await e.post("dht/put",{signal:i,searchParams:f({arg:r instanceof Uint8Array?C(r):r.toString(),...o}),...await z([n],s,o.headers)});for await(let c of a.ndjson())yield Se(c)}return t});var rl=u(e=>{async function*t(r,n={}){let o=await e.post("dht/query",{signal:n.signal,searchParams:f({arg:r.toString(),...n}),headers:n.headers});for await(let s of o.ndjson())yield Se(s)}return t});function nl(e){return{findPeer:Qf(e),findProvs:Zf(e),get:Yf(e),provide:el(e),put:tl(e),query:rl(e)}}var ol=u(e=>{async function t(r={}){return(await e.post("diag/cmds",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()}return t});var sl=u(e=>{async function t(r={}){return(await e.post("diag/net",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()}return t});var il=u(e=>{async function t(r={}){return(await e.post("diag/sys",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()}return t});function al(e){return{cmds:ol(e),net:sl(e),sys:il(e)}}var cl=u(e=>{async function t(r,n,o={}){await(await e.post("files/chmod",{signal:o.signal,searchParams:f({arg:r,mode:n,...o}),headers:o.headers})).text()}return t});var ul=u(e=>{async function t(r,n,o={}){let s=Array.isArray(r)?r:[r];await(await e.post("files/cp",{signal:o.signal,searchParams:f({arg:s.concat(n).map(a=>h.asCID(a)?`/ipfs/${a}`:a),...o}),headers:o.headers})).text()}return t});var fl=u(e=>{async function t(r,n={}){if(!r||typeof r!="string")throw new Error("ipfs.files.flush requires a path");let s=await(await e.post("files/flush",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).json();return h.parse(s.Cid)}return t});function br(e){let t=A(e);return Object.prototype.hasOwnProperty.call(t,"mode")&&(t.mode=parseInt(t.mode,8)),Object.prototype.hasOwnProperty.call(t,"mtime")&&(t.mtime={secs:t.mtime,nsecs:t.mtimeNsecs||0},delete t.mtimeNsecs),t}var pl=u(e=>{async function*t(r,n={}){if(!r)throw new Error("ipfs.files.ls requires a path");let o=await e.post("files/ls",{signal:n.signal,searchParams:f({arg:h.asCID(r)?`/ipfs/${r}`:r,long:!0,...n,stream:!0}),headers:n.headers});for await(let s of o.ndjson())if("Entries"in s)for(let i of s.Entries||[])yield ll(br(i));else yield ll(br(s))}return t});function ll(e){return e.hash&&(e.cid=h.parse(e.hash)),delete e.hash,e.type=e.type===1?"directory":"file",e}var dl=u(e=>{async function t(r,n={}){await(await e.post("files/mkdir",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).text()}return t});var hl=u(e=>{async function t(r,n,o={}){Array.isArray(r)||(r=[r]),await(await e.post("files/mv",{signal:o.signal,searchParams:f({arg:r.concat(n),...o}),headers:o.headers})).text()}return t});var yl=N(gl(),1),wl=u(e=>{async function*t(r,n={}){let o=await e.post("files/read",{signal:n.signal,searchParams:f({arg:r,count:n.length,...n}),headers:n.headers});yield*(0,yl.default)(o.body)}return t});var bl=N(nn(),1),xl=u(e=>{async function t(r,n={}){let o=await e.post("files/rm",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers}),s=await o.text();if(s!==""){let i=new bl.default.HTTPError(o);throw i.message=s,i}}return t});var bn=u(e=>{async function t(r,n={}){let s=await(await e.post("files/stat",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).json();return s.WithLocality=s.WithLocality||!1,Qw(br(s))}return t});function Qw(e){return e.cid=h.parse(e.hash),delete e.hash,e}var Sl=u(e=>{async function t(r,n={}){await(await e.post("files/touch",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).text()}return t});var El=u(e=>{async function t(r,n,o={}){let s=new AbortController,i=j(s.signal,o.signal);await(await e.post("files/write",{signal:i,searchParams:f({arg:r,streamChannels:!0,count:o.length,...o}),...await z([{content:n,path:"arg",mode:cn(o.mode),mtime:un(o.mtime)}],s,o.headers)})).text()}return t});function Pl(e){return{chmod:cl(e),cp:ul(e),flush:fl(e),ls:pl(e),mkdir:dl(e),mv:hl(e),read:wl(e),rm:xl(e),stat:bn(e),touch:Sl(e),write:El(e)}}var Tl=N(te(),1),vl=u(e=>async(r,n,o={})=>{throw(0,Tl.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});var Al=u(e=>{async function t(r,n){let o=n??{type:"Ed25519"},i=await(await e.post("key/gen",{signal:o.signal,searchParams:f({arg:r,...o}),headers:o.headers})).json();return A(i)}return t});var Cl=u(e=>{async function t(r,n,o,s={}){let a=await(await e.post("key/import",{signal:s.signal,searchParams:f({arg:r,pem:n,password:o,...s}),headers:s.headers})).json();return A(a)}return t});var Il=N(te(),1),kl=u(e=>async(r,n={})=>{throw(0,Il.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});var Ul=u(e=>{async function t(r={}){return((await(await e.post("key/list",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()).Keys||[]).map(s=>A(s))}return t});var Bl=u(e=>{async function t(r,n,o={}){let s=await e.post("key/rename",{signal:o.signal,searchParams:f({arg:[r,n],...o}),headers:o.headers});return A(await s.json())}return t});var Nl=u(e=>{async function t(r,n={}){let s=await(await e.post("key/rm",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).json();return A(s.Keys[0])}return t});function _l(e){return{export:vl(e),gen:Al(e),import:Cl(e),info:kl(e),list:Ul(e),rename:Bl(e),rm:Nl(e)}}var Dl=u(e=>{async function t(r,n,o={}){let s=await e.post("log/level",{signal:o.signal,searchParams:f({arg:[r,n],...o}),headers:o.headers});return A(await s.json())}return t});var Rl=u(e=>{async function t(r={}){return(await(await e.post("log/ls",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()).Strings}return t});var Ll=u(e=>{async function*t(r={}){yield*(await e.post("log/tail",{signal:r.signal,searchParams:f(r),headers:r.headers})).ndjson()}return t});function Ol(e){return{level:Dl(e),ls:Rl(e),tail:Ll(e)}}var $l=u(e=>{async function t(r,n={}){let o=await e.post("name/publish",{signal:n.signal,searchParams:f({arg:`${r}`,...n}),headers:n.headers});return A(await o.json())}return t});var Fl=u(e=>{async function*t(r,n={}){let o=await e.post("name/resolve",{signal:n.signal,searchParams:f({arg:r,stream:!0,...n}),headers:n.headers});for await(let s of o.ndjson())yield s.Path}return t});var zl=u(e=>{async function t(r,n={}){let o=await e.post("name/pubsub/cancel",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers});return A(await o.json())}return t});var jl=u(e=>{async function t(r={}){let n=await e.post("name/pubsub/state",{signal:r.signal,searchParams:f(r),headers:r.headers});return A(await n.json())}return t});var Ml=u(e=>{async function t(r={}){return(await(await e.post("name/pubsub/subs",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()).Strings||[]}return t});function ql(e){return{cancel:zl(e),state:jl(e),subs:Ml(e)}}function Vl(e){return{publish:$l(e),resolve:Fl(e),pubsub:ql(e)}}var Hl=u(e=>{async function t(r,n={}){let s=await(await e.post("object/data",{signal:n.signal,searchParams:f({arg:`${r instanceof Uint8Array?h.decode(r):r}`,...n}),headers:n.headers})).arrayBuffer();return new Uint8Array(s,0,s.byteLength)}return t});var Gl=u(e=>{async function t(r,n={}){let s=await(await e.post("object/get",{signal:n.signal,searchParams:f({arg:`${r instanceof Uint8Array?h.decode(r):r}`,dataEncoding:"base64",...n}),headers:n.headers})).json();return{Data:X(s.Data,"base64pad"),Links:(s.Links||[]).map(i=>({Name:i.Name,Hash:h.parse(i.Hash),Tsize:i.Size}))}}return t});var Wl=u(e=>{async function t(r,n={}){return((await(await e.post("object/links",{signal:n.signal,searchParams:f({arg:`${r instanceof Uint8Array?h.decode(r):r}`,...n}),headers:n.headers})).json()).Links||[]).map(i=>({Name:i.Name,Tsize:i.Size,Hash:h.parse(i.Hash)}))}return t});var Jl=u(e=>{async function t(r={}){let n=await e.post("object/new",{signal:r.signal,searchParams:f({arg:r.template,...r}),headers:r.headers}),{Hash:o}=await n.json();return h.parse(o)}return t});var Kl=(e,t)=>u(n=>{let o=wn(e,t);async function s(i,a={}){return o(i,{...a,storeCodec:"dag-pb",hashAlg:"sha2-256",version:1})}return s})(t);var Xl=u(e=>{async function t(r,n={}){let s=await(await e.post("object/stat",{signal:n.signal,searchParams:f({arg:`${r}`,...n}),headers:n.headers})).json();return{...s,Hash:h.parse(s.Hash)}}return t});var Ql=u(e=>{async function t(r,n,o={}){let s=await e.post("object/patch/add-link",{signal:o.signal,searchParams:f({arg:[`${r}`,n.Name||n.name||"",(n.Hash||n.cid||"").toString()||null],...o}),headers:o.headers}),{Hash:i}=await s.json();return h.parse(i)}return t});var Zl=u(e=>{async function t(r,n,o={}){let s=new AbortController,i=j(s.signal,o.signal),a=await e.post("object/patch/append-data",{signal:i,searchParams:f({arg:`${r}`,...o}),...await z([n],s,o.headers)}),{Hash:c}=await a.json();return h.parse(c)}return t});var Yl=u(e=>{async function t(r,n,o={}){let s=await e.post("object/patch/rm-link",{signal:o.signal,searchParams:f({arg:[`${r}`,n.Name||n.name||null],...o}),headers:o.headers}),{Hash:i}=await s.json();return h.parse(i)}return t});var ep=u(e=>{async function t(r,n,o={}){let s=new AbortController,i=j(s.signal,o.signal),a=await e.post("object/patch/set-data",{signal:i,searchParams:f({arg:[`${r}`],...o}),...await z([n],s,o.headers)}),{Hash:c}=await a.json();return h.parse(c)}return t});function tp(e){return{addLink:Ql(e),appendData:Zl(e),rmLink:Yl(e),setData:ep(e)}}function rp(e,t){return{data:Hl(t),get:Gl(t),links:Wl(t),new:Jl(t),put:Kl(e,t),stat:Xl(t),patch:tp(t)}}var $t=N(te(),1);function Zw(e){return Symbol.iterator in e}function Yw(e){return Symbol.asyncIterator in e}function np(e){return h.asCID(e)!=null}async function*xn(e){if(e==null)throw(0,$t.default)(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT");let t=h.asCID(e);if(t){yield Y({cid:t});return}if(e instanceof String||typeof e=="string"){yield Y({path:e});return}if(e.cid!=null||e.path!=null)return yield Y(e);if(Zw(e)){let r=e[Symbol.iterator](),n=r.next();if(n.done)return r;if(np(n.value)){yield Y({cid:n.value});for(let o of r)yield Y({cid:o});return}if(n.value instanceof String||typeof n.value=="string"){yield Y({path:n.value});for(let o of r)yield Y({path:o});return}if(n.value.cid!=null||n.value.path!=null){yield Y(n.value);for(let o of r)yield Y(o);return}throw(0,$t.default)(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}if(Yw(e)){let r=e[Symbol.asyncIterator](),n=await r.next();if(n.done)return r;if(np(n.value)){yield Y({cid:n.value});for await(let o of r)yield Y({cid:o});return}if(n.value instanceof String||typeof n.value=="string"){yield Y({path:n.value});for await(let o of r)yield Y({path:o});return}if(n.value.cid!=null||n.value.path!=null){yield Y(n.value);for await(let o of r)yield Y(o);return}throw(0,$t.default)(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}throw(0,$t.default)(new Error("Unexpected input: "+typeof e),"ERR_UNEXPECTED_INPUT")}function Y(e){let t=e.cid||`${e.path}`;if(!t)throw(0,$t.default)(new Error("Unexpected input: Please path either a CID or an IPFS path"),"ERR_UNEXPECTED_INPUT");let r={path:t,recursive:e.recursive!==!1};return e.metadata!=null&&(r.metadata=e.metadata),r}var Sn=u(e=>{async function*t(r,n={}){for await(let{path:o,recursive:s,metadata:i}of xn(r)){let a=await e.post("pin/add",{signal:n.signal,searchParams:f({...n,arg:o,recursive:s,metadata:i?JSON.stringify(i):void 0,stream:!0}),headers:n.headers});for await(let c of a.ndjson()){if(c.Pins){for(let l of c.Pins)yield h.parse(l);continue}yield h.parse(c)}}}return t});function op(e){let t=Sn(e);return u(()=>{async function r(n,o={}){return He(t([{path:n,...o}],o))}return r})(e)}function sp(e,t,r){let n={type:e,cid:h.parse(t)};return r&&(n.metadata=r),n}var ip=u(e=>{async function*t(r={}){let n=[];r.paths&&(n=Array.isArray(r.paths)?r.paths:[r.paths]);let o=await e.post("pin/ls",{signal:r.signal,searchParams:f({...r,arg:n.map(s=>`${s}`),stream:!0}),headers:r.headers});for await(let s of o.ndjson()){if(s.Keys){for(let i of Object.keys(s.Keys))yield sp(s.Keys[i].Type,i,s.Keys[i].Metadata);return}yield sp(s.Type,s.Cid,s.Metadata)}}return t});var En=u(e=>{async function*t(r,n={}){for await(let{path:o,recursive:s}of xn(r)){let i=new URLSearchParams(n.searchParams);i.append("arg",`${o}`),s!=null&&i.set("recursive",String(s));let a=await e.post("pin/rm",{signal:n.signal,headers:n.headers,searchParams:f({...n,arg:`${o}`,recursive:s})});for await(let c of a.ndjson()){if(c.Pins){yield*c.Pins.map(l=>h.parse(l));continue}yield h.parse(c)}}}return t});var ap=e=>{let t=En(e);return u(()=>{async function r(n,o={}){return He(t([{path:n,...o}],o))}return r})(e)};var Pn=({Name:e,Status:t,Cid:r})=>({cid:h.parse(r),name:e,status:t}),cp=e=>{if(typeof e=="string"&&e!=="")return e;throw new TypeError("service name must be passed")},up=e=>{if(h.asCID(e))return e.toString();throw new TypeError(`CID instance expected instead of ${typeof e}`)},Ft=({service:e,cid:t,name:r,status:n,all:o})=>{let s=f({service:cp(e),name:r,force:o?!0:void 0});if(t)for(let i of t)s.append("cid",up(i));if(n)for(let i of n)s.append("status",i);return s},fp=({cid:e,service:t,background:r,name:n,origins:o})=>{let s=f({arg:up(e),service:cp(t),name:n,background:r?!0:void 0});if(o)for(let i of o)s.append("origin",i.toString());return s};function lp(e){async function t(r,{timeout:n,signal:o,headers:s,...i}){let a=await e.post("pin/remote/add",{timeout:n,signal:o,headers:s,searchParams:fp({cid:r,...i})});return Pn(await a.json())}return t}function pp(e){async function*t({timeout:r,signal:n,headers:o,...s}){let i=await e.post("pin/remote/ls",{timeout:r,signal:n,headers:o,searchParams:Ft(s)});for await(let a of i.ndjson())yield Pn(a)}return t}function dp(e){async function t({timeout:r,signal:n,headers:o,...s}){await e.post("pin/remote/rm",{timeout:r,signal:n,headers:o,searchParams:Ft({...s,all:!1})})}return t}function hp(e){async function t({timeout:r,signal:n,headers:o,...s}){await e.post("pin/remote/rm",{timeout:r,signal:n,headers:o,searchParams:Ft({...s,all:!0})})}return t}function mp(e){let t=String(e);if(t==="undefined")throw Error("endpoint is required");return t[t.length-1]==="/"?t.slice(0,-1):t}function gp(e){return{service:e.Service,endpoint:new URL(e.ApiEndpoint),...e.Stat&&{stat:eb(e.Stat)}}}function eb(e){switch(e.Status){case"valid":{let{Pinning:t,Pinned:r,Queued:n,Failed:o}=e.PinCount;return{status:"valid",pinCount:{queued:n,pinning:t,pinned:r,failed:o}}}case"invalid":return{status:"invalid"};default:return{status:e.Status}}}function yp(e){async function t(r,n){let{endpoint:o,key:s,headers:i,timeout:a,signal:c}=n;await e.post("pin/remote/service/add",{timeout:a,signal:c,searchParams:f({arg:[r,mp(o),s]}),headers:i})}return t}function wp(e){async function t(r={}){let{stat:n,headers:o,timeout:s,signal:i}=r,a=await e.post("pin/remote/service/ls",{timeout:s,signal:i,headers:o,searchParams:n===!0?f({stat:n}):void 0}),{RemoteServices:c}=await a.json();return c.map(gp)}return t}function bp(e){async function t(r,n={}){await e.post("pin/remote/service/rm",{signal:n.signal,headers:n.headers,searchParams:f({arg:r})})}return t}function xp(e){let t=new Ye(e);return{add:yp(t),ls:wp(t),rm:bp(t)}}function Sp(e){let t=new Ye(e);return{add:lp(t),ls:pp(t),rm:dp(t),rmAll:hp(t),service:xp(e)}}function Ep(e){return{addAll:Sn(e),add:op(e),ls:ip(e),rmAll:En(e),rm:ap(e),remote:Sp(e)}}var Pp=e=>Array.isArray(e)?e.map(Tn):e,Tn=e=>C(zt(e)),zt=e=>Qe.decode(e),Tp=e=>BigInt(`0x${C(Qe.decode(e),"base16")}`),jt=e=>Qe.encode(X(e));var vp=u(e=>{async function t(r={}){let{Strings:n}=await(await e.post("pubsub/ls",{signal:r.signal,searchParams:f(r),headers:r.headers})).json();return Pp(n)||[]}return t});var Ap=u(e=>{async function t(r,n={}){let o=await e.post("pubsub/peers",{signal:n.signal,searchParams:f({arg:jt(r),...n}),headers:n.headers}),{Strings:s}=await o.json();return s||[]}return t});var Cp=u(e=>{async function t(r,n,o={}){let s=f({arg:jt(r),...o}),i=new AbortController,a=j(i.signal,o.signal);await(await e.post("pubsub/pub",{signal:a,searchParams:s,...await z([n],i,o.headers)})).text()}return t});var tb=Yr("ipfs-http-client:pubsub:subscribe"),Ip=(e,t)=>u(r=>{async function n(o,s,i={}){i.signal=t.subscribe(o,s,i.signal);let a,c,l=new Promise((m,x)=>{a=m,c=x}),d=setTimeout(()=>a(),1e3);return r.post("pubsub/sub",{signal:i.signal,searchParams:f({arg:jt(o),...i}),headers:i.headers}).catch(m=>{t.unsubscribe(o,s),c(m)}).then(m=>{clearTimeout(d),m&&(rb(m,{onMessage:x=>{if(s){if(typeof s=="function"){s(x);return}typeof s.handleEvent=="function"&&s.handleEvent(x)}},onEnd:()=>t.unsubscribe(o,s),onError:i.onError}),a())}),l}return n})(e);async function rb(e,{onMessage:t,onEnd:r,onError:n}){n=n||tb;try{for await(let o of e.ndjson())try{if(!o.from)continue;o.from!=null&&o.seqno!=null?t({type:"signed",from:F(o.from),data:zt(o.data),sequenceNumber:Tp(o.seqno),topic:Tn(o.topicIDs[0]),key:zt(o.key??"u"),signature:zt(o.signature??"u")}):t({type:"unsigned",data:zt(o.data),topic:Tn(o.topicIDs[0])})}catch(s){s.message=`Failed to parse pubsub message: ${s.message}`,n(s,!1,o)}}catch(o){nb(o)||n(o,!0)}finally{r()}}var nb=e=>{switch(e.type){case"aborted":return!0;case"abort":return!0;default:return e.name==="AbortError"}};var kp=(e,t)=>{async function r(n,o){t.unsubscribe(n,o)}return r};var vn=class{constructor(){this._subs=new Map}subscribe(t,r,n){let o=this._subs.get(t)||[];if(o.find(i=>i.handler===r))throw new Error(`Already subscribed to ${t} with this handler`);let s=new AbortController;return this._subs.set(t,[{handler:r,controller:s}].concat(o)),n&&n.addEventListener("abort",()=>this.unsubscribe(t,r)),s.signal}unsubscribe(t,r){let n=this._subs.get(t)||[],o;r?(this._subs.set(t,n.filter(s=>s.handler!==r)),o=n.filter(s=>s.handler===r)):(this._subs.set(t,[]),o=n),(this._subs.get(t)||[]).length||this._subs.delete(t),o.forEach(s=>s.controller.abort())}};function Up(e){let t=new vn;return{ls:vp(e),peers:Ap(e),publish:Cp(e),subscribe:Ip(e,t),unsubscribe:kp(e,t)}}var Bp=u(e=>{async function*t(r={}){yield*(await e.post("refs/local",{signal:r.signal,transform:A,searchParams:f(r),headers:r.headers})).ndjson()}return t});var Np=u((e,t)=>Object.assign(async function*(n,o={}){let s=Array.isArray(n)?n:[n];yield*(await e.post("refs",{signal:o.signal,searchParams:f({arg:s.map(a=>`${a instanceof Uint8Array?h.decode(a):a}`),...o}),headers:o.headers,transform:A})).ndjson()},{local:Bp(t)}));var _p=u(e=>{async function*t(r={}){yield*(await e.post("repo/gc",{signal:r.signal,searchParams:f(r),headers:r.headers,transform:o=>({err:o.Error?new Error(o.Error):null,cid:(o.Key||{})["/"]?h.parse(o.Key["/"]):null})})).ndjson()}return t});var An=u(e=>{async function t(r={}){let o=await(await e.post("repo/stat",{signal:r.signal,searchParams:f(r),headers:r.headers})).json();return{numObjects:BigInt(o.NumObjects),repoSize:BigInt(o.RepoSize),repoPath:o.RepoPath,version:o.Version,storageMax:BigInt(o.StorageMax)}}return t});var Dp=u(e=>{async function t(r={}){return(await(await e.post("repo/version",{signal:r.signal,searchParams:f(r),headers:r.headers})).json()).Version}return t});function Rp(e){return{gc:_p(e),stat:An(e),version:Dp(e)}}var Lp=u(e=>{async function*t(r={}){yield*(await e.post("stats/bw",{signal:r.signal,searchParams:f(r),headers:r.headers,transform:o=>({totalIn:BigInt(o.TotalIn),totalOut:BigInt(o.TotalOut),rateIn:parseFloat(o.RateIn),rateOut:parseFloat(o.RateOut)})})).ndjson()}return t});function Op(e){return{bitswap:fn(e),repo:An(e),bw:Lp(e)}}var $p=u(e=>{async function t(r={}){let n=await e.post("swarm/addrs",{signal:r.signal,searchParams:f(r),headers:r.headers}),{Addrs:o}=await n.json();return Object.keys(o).map(s=>({id:F(s),addrs:(o[s]||[]).map(i=>_(i))}))}return t});var Fp=u(e=>{async function t(r,n={}){let o=await e.post("swarm/connect",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers}),{Strings:s}=await o.json();return s||[]}return t});var zp=u(e=>{async function t(r,n={}){let o=await e.post("swarm/disconnect",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers}),{Strings:s}=await o.json();return s||[]}return t});var jp=u(e=>{async function t(r={}){let n=await e.post("swarm/addrs/local",{signal:r.signal,searchParams:f(r),headers:r.headers}),{Strings:o}=await n.json();return(o||[]).map(s=>_(s))}return t});var Mp=u(e=>{async function t(r={}){let n=await e.post("swarm/peers",{signal:r.signal,searchParams:f(r),headers:r.headers}),{Peers:o}=await n.json();return(o||[]).map(s=>({addr:_(s.Addr),peer:F(s.Peer),muxer:s.Muxer,latency:s.Latency,streams:s.Streams,direction:s.Direction==null?void 0:s.Direction===0?"inbound":"outbound"}))}return t});function qp(e){return{addrs:$p(e),connect:Fp(e),disconnect:zp(e),localAddrs:jp(e),peers:Mp(e)}}var Cn=u(e=>{async function*t(r,n={}){let o=new AbortController,s=j(o.signal,n.signal),{headers:i,body:a,total:c,parts:l}=await z(r,o,n.headers),[d,m]=typeof n.progress=="function"?ob(c,l,n.progress):[void 0,void 0],x=await e.post("add",{searchParams:f({"stream-channels":!0,...n,progress:Boolean(d)}),onUploadProgress:m,signal:s,headers:i,body:a});for await(let P of x.ndjson())P=A(P),P.hash!==void 0?yield ib(P):d&&d(P.bytes||0,P.name)}return t}),ob=(e,t,r)=>t?[void 0,sb(e,t,r)]:[r,void 0],sb=(e,t,r)=>{let n=0,o=t.length;return({loaded:s,total:i})=>{let a=Math.floor(s/i*e);for(;n<o;){let{start:c,end:l,name:d}=t[n];if(a<l){r(a-c,d);break}else r(l-c,d),n+=1}}};function ib({name:e,hash:t,size:r,mode:n,mtime:o,mtimeNsecs:s}){let i={path:e,cid:h.parse(t),size:parseInt(r)};return n!=null&&(i.mode=parseInt(n,8)),o!=null&&(i.mtime={secs:o,nsecs:s||0}),i}var Vp=N(te(),1);function Bs(e){return typeof e.stream=="function"?we(e.stream()):we(new Response(e).body)}async function*In(e){yield e}async function Hp(e){if(be(e))return In(Ns(e));if(typeof e=="string"||e instanceof String)return In(Ns(e.toString()));if(Me(e))return Bs(e);if(qe(e)&&(e=we(e)),Symbol.iterator in e||Symbol.asyncIterator in e){let t=je(e),{value:r,done:n}=await t.peek();if(n)return In(new Uint8Array(0));if(t.push(r),Number.isInteger(r))return In(Uint8Array.from(await dr(t)));if(be(r)||typeof r=="string"||r instanceof String)return Rt(t,Ns)}throw(0,Vp.default)(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT")}function Ns(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Array.isArray(e)?Uint8Array.from(e):X(e.toString())}var Un=N(te(),1);async function*Gp(e,t){if(e==null)throw(0,Un.default)(new Error(`Unexpected input: ${e}`),"ERR_UNEXPECTED_INPUT");if(typeof e=="string"||e instanceof String){yield kn(e.toString(),t);return}if(be(e)||Me(e)){yield kn(e,t);return}if(qe(e)&&(e=we(e)),Symbol.iterator in e||Symbol.asyncIterator in e){let r=je(e),{value:n,done:o}=await r.peek();if(o){yield{content:[]};return}if(r.push(n),Number.isInteger(n)||be(n)||typeof n=="string"||n instanceof String){yield kn(r,t);return}throw(0,Un.default)(new Error("Unexpected input: multiple items passed - if you are using ipfs.add, please use ipfs.addAll instead"),"ERR_UNEXPECTED_INPUT")}if(hr(e)){yield kn(e,t);return}throw(0,Un.default)(new Error('Unexpected input: cannot convert "'+typeof e+'" into ImportCandidate'),"ERR_UNEXPECTED_INPUT")}async function kn(e,t){let{path:r,mode:n,mtime:o,content:s}=e,i={path:r||"",mode:gn(n),mtime:yn(o)};return s?i.content=await t(s):r||(i.content=await t(e)),i}function Wp(e){return Gp(e,Hp)}function Jp(e){let t=Cn(e);return u(()=>{async function r(n,o={}){return await He(t(Wp(n),o))}return r})(e)}var Kp=u(e=>{async function*t(r,n={}){yield*(await e.post("cat",{signal:n.signal,searchParams:f({arg:r.toString(),...n}),headers:n.headers})).iterator()}return t});var Xp=u(e=>async(r={})=>(await e.post("commands",{signal:r.signal,searchParams:f(r),headers:r.headers})).json());var Qp=u(e=>async(r,n={})=>(await(await e.post("dns",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers})).json()).Path);var Zp=u(e=>()=>{let t=new URL(e.opts.base||"");return{host:t.hostname,port:t.port,protocol:t.protocol,pathname:t.pathname,"api-path":t.pathname}});var Yp=u(e=>{async function*t(r,n={}){let o={arg:`${r instanceof Uint8Array?h.decode(r):r}`,...n};o.compressionLevel&&(o["compression-level"]=o.compressionLevel,delete o.compressionLevel),yield*(await e.post("get",{signal:n.signal,searchParams:f(o),headers:n.headers})).iterator()}return t});var Bn=u(e=>{async function t(r={}){let o=await(await e.post("id",{signal:r.signal,searchParams:f({arg:r.peerId?r.peerId.toString():void 0,...r}),headers:r.headers})).json(),s={...A(o)};return s.id=F(s.id),s.addresses&&(s.addresses=s.addresses.map(i=>_(i))),s}return t});var ed=e=>{let t=Bn(e);async function r(n={}){let o=await t(n);return Boolean(o&&o.addresses&&o.addresses.length)}return r};var td=u((e,t)=>{async function*r(n,o={}){let s=`${n instanceof Uint8Array?h.decode(n):n}`;async function i(c){let l=c.Hash;if(l.includes("/")){let m=l.startsWith("/ipfs/")?l:`/ipfs/${l}`;l=(await bn(t)(m)).cid}else l=h.parse(l);let d={name:c.Name,path:s+(c.Name?`/${c.Name}`:""),size:c.Size,cid:l,type:ab(c)};return c.Mode&&(d.mode=parseInt(c.Mode,8)),c.Mtime!==void 0&&c.Mtime!==null&&(d.mtime={secs:c.Mtime},c.MtimeNsecs!==void 0&&c.MtimeNsecs!==null&&(d.mtime.nsecs=c.MtimeNsecs)),d}let a=await e.post("ls",{signal:o.signal,searchParams:f({arg:s,...o}),headers:o.headers});for await(let c of a.ndjson()){if(c=c.Objects,!c)throw new Error("expected .Objects in results");if(c=c[0],!c)throw new Error("expected one array in results.Objects");let l=c.Links;if(!Array.isArray(l))throw new Error("expected one array in results.Objects[0].Links");if(!l.length){yield i(c);return}yield*l.map(i)}}return r});function ab(e){switch(e.Type){case 1:case 5:return"dir";case 2:return"file";default:return"file"}}var rd=u(e=>{async function t(r={}){let n=await e.post("dns",{signal:r.signal,searchParams:f(r),headers:r.headers});return A(await n.json())}return t});var nd=u(e=>{async function*t(r,n={}){yield*(await e.post("ping",{signal:n.signal,searchParams:f({arg:`${r}`,...n}),headers:n.headers,transform:A})).ndjson()}return t});var od=u(e=>{async function t(r,n={}){let o=await e.post("resolve",{signal:n.signal,searchParams:f({arg:r,...n}),headers:n.headers}),{Path:s}=await o.json();return s}return t});var sd=N(te(),1),id=u(e=>async(r={})=>{throw(0,sd.default)(new Error("Not implemented"),"ERR_NOT_IMPLEMENTED")});var ad=u(e=>{async function t(r={}){await(await e.post("shutdown",{signal:r.signal,searchParams:f(r),headers:r.headers})).text()}return t});var cd=u(e=>{async function t(r={}){let n=await e.post("version",{signal:r.signal,searchParams:f(r),headers:r.headers});return{...A(await n.json()),"ipfs-http-client":"1.0.0"}}return t});var pd=N(ud(),1),dd=N(ld(),1);function lb(e={}){let t={name:ot.name,code:ot.code,encode:l=>l,decode:l=>l},r=Object.values(ge);(e.ipld&&e.ipld.bases?e.ipld.bases:[]).forEach(l=>r.push(l));let n=new Sr({bases:r,loadBase:e.ipld&&e.ipld.loadBase}),o=Object.values(Aa);[Vn,Or,fo,lo,t].concat(e.ipld&&e.ipld.codecs||[]).forEach(l=>o.push(l));let s=new Er({codecs:o,loadCodec:e.ipld&&e.ipld.loadCodec}),i=Object.values(va);(e.ipld&&e.ipld.hashers?e.ipld.hashers:[]).forEach(l=>i.push(l));let a=new Pr({hashers:i,loadHasher:e.ipld&&e.ipld.loadHasher});return{add:Jp(e),addAll:Cn(e),bitswap:xu(e),block:Uf(e),bootstrap:Lf(e),cat:Kp(e),commands:Xp(e),config:Vf(e),dag:Xf(s,e),dht:nl(e),diag:al(e),dns:Qp(e),files:Pl(e),get:Yp(e),getEndpointConfig:Zp(e),id:Bn(e),isOnline:ed(e),key:_l(e),log:Ol(e),ls:td(e),mount:rd(e),name:Vl(e),object:rp(s,e),pin:Ep(e),ping:nd(e),pubsub:Up(e),refs:Np(e),repo:Rp(e),resolve:od(e),start:id(e),stats:Op(e),stop:ad(e),swarm:qp(e),version:cd(e),bases:n,codecs:s,hashers:a}}var pb=pd.default;return bd(db);})(); return IpfsHttpClient})); const ipfs = IpfsHttpClient.create({ host: "localhost", port: 5001, protocol: "http", }); async function addFile(content) { const { path } = await ipfs.add(content); await ipfs.pin.add(path); return path; } async function getFile(cid) { const stream = ipfs.cat(cid); let data = ""; for await (const chunk of stream) { data += new TextDecoder().decode(chunk); } return data; } function queryGPT3() { const xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.openai.com/v1/chat/completions"); xhr.setRequestHeader("Content-Type", "application/json"); xhr.setRequestHeader("Authorization", "Bearer " + state.apiKey); const data = JSON.stringify({ model: "gpt-3.5-turbo", messages: [{ role: "user", content: state.question }], temperature: 0.0, }); xhr.send(data); xhr.onload = function () { console.log("xhr", xhr); if (xhr.status === 200) { const response = JSON.parse(xhr.responseText); console.log("response", response); const a = response.choices[0].message.content; State.update({answer: a}); attestationRequest = {question: state.question, answer: a }; addFile(JSON.stringify(attestationRequest)) .then((cid) => { console.log("CID: ", cid); State.update({cid: cid}); getFile(cid) .then((r) => console.log("Verification: ", JSON.parse(r))) .catch(console.error); }) .catch(console.error); } else { console.log("Error: " + xhr.status); } }; } return (<> <input placeholder="LLM API KEY" onChange={(e) => State.update({apiKey: e.target.value})} /> <textarea onChange={(e) => State.update({question: e.target.value})} placeholder="Enter your query" rows="10" cols="50"></textarea> <button onclick="queryGPT3()">Query GPT-3.5</button> <div>{state.answer}</div> <div>{state.attestationRequestCID}</div> </>)