blockstore-core
Advanced tools
Comparing version 4.3.0 to 4.3.1
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.BlockstoreCore = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var BlockstoreCore=(()=>{var Qe=Object.create;var Z=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var H=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),be=(r,e)=>{for(var t in e)Z(r,t,{get:e[t],enumerable:!0})},ye=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ze(e))!Ke.call(r,o)&&o!==t&&Z(r,o,{get:()=>e[o],enumerable:!(n=Xe(e,o))||n.enumerable});return r};var we=(r,e,t)=>(t=r!=null?Qe(He(r)):{},ye(e||!r||!r.__esModule?Z(t,"default",{value:r,enumerable:!0}):t,r)),We=r=>ye(Z({},"__esModule",{value:!0}),r);var Ce=H((sr,xe)=>{"use strict";function ge(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Ye(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return ge(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),ge(new o,t)}}xe.exports=Ye});var Te=H((Vr,Pe)=>{var V=1e3,$=V*60,_=$*60,D=_*24,Nt=D*7,Dt=D*365.25;Pe.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Rt(r);if(t==="number"&&isFinite(r))return e.long?Tt(r):Pt(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Rt(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Dt;case"weeks":case"week":case"w":return t*Nt;case"days":case"day":case"d":return t*D;case"hours":case"hour":case"hrs":case"hr":case"h":return t*_;case"minutes":case"minute":case"mins":case"min":case"m":return t*$;case"seconds":case"second":case"secs":case"sec":case"s":return t*V;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Pt(r){var e=Math.abs(r);return e>=D?Math.round(r/D)+"d":e>=_?Math.round(r/_)+"h":e>=$?Math.round(r/$)+"m":e>=V?Math.round(r/V)+"s":r+"ms"}function Tt(r){var e=Math.abs(r);return e>=D?ee(r,e,D,"day"):e>=_?ee(r,e,_,"hour"):e>=$?ee(r,e,$,"minute"):e>=V?ee(r,e,V,"second"):r+" ms"}function ee(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var Be=H(($r,je)=>{function jt(r){t.debug=t,t.default=t,t.coerce=w,t.disable=s,t.enable=o,t.enabled=a,t.humanize=Te(),t.destroy=M,Object.keys(r).forEach(i=>{t[i]=r[i]}),t.names=[],t.skips=[],t.formatters={};function e(i){let l=0;for(let h=0;h<i.length;h++)l=(l<<5)-l+i.charCodeAt(h),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(i){let l,h=null,O,d;function f(...c){if(!f.enabled)return;let p=f,m=Number(new Date),y=m-(l||m);p.diff=y,p.prev=l,p.curr=m,l=m,c[0]=t.coerce(c[0]),typeof c[0]!="string"&&c.unshift("%O");let g=0;c[0]=c[0].replace(/%([a-zA-Z%])/g,(S,v)=>{if(S==="%%")return"%";g++;let k=t.formatters[v];if(typeof k=="function"){let R=c[g];S=k.call(p,R),c.splice(g,1),g--}return S}),t.formatArgs.call(p,c),(p.log||t.log).apply(p,c)}return f.namespace=i,f.useColors=t.useColors(),f.color=t.selectColor(i),f.extend=n,f.destroy=t.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(O!==t.namespaces&&(O=t.namespaces,d=t.enabled(i)),d),set:c=>{h=c}}),typeof t.init=="function"&&t.init(f),f}function n(i,l){let h=t(this.namespace+(typeof l>"u"?":":l)+i);return h.log=this.log,h}function o(i){t.save(i),t.namespaces=i,t.names=[],t.skips=[];let l,h=(typeof i=="string"?i:"").split(/[\s,]+/),O=h.length;for(l=0;l<O;l++)h[l]&&(i=h[l].replace(/\*/g,".*?"),i[0]==="-"?t.skips.push(new RegExp("^"+i.slice(1)+"$")):t.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...t.names.map(u),...t.skips.map(u).map(l=>"-"+l)].join(",");return t.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l<h;l++)if(t.skips[l].test(i))return!1;for(l=0,h=t.names.length;l<h;l++)if(t.names[l].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function w(i){return i instanceof Error?i.stack||i.message:i}function M(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}je.exports=jt});var Ve=H((F,te)=>{F.formatArgs=Vt;F.save=$t;F.load=_t;F.useColors=Bt;F.storage=qt();F.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();F.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 Bt(){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 Vt(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+te.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}F.log=console.debug||console.log||(()=>{});function $t(r){try{r?F.storage.setItem("debug",r):F.storage.removeItem("debug")}catch{}}function _t(){let r;try{r=F.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function qt(){try{return localStorage}catch{}}te.exports=Be()(F);var{formatters:Jt}=te.exports;Jt.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var nr={};be(nr,{BaseBlockstore:()=>I,BlackHoleBlockstore:()=>Y,Errors:()=>rr,MemoryBlockstore:()=>W,TieredBlockstore:()=>oe});var P={};be(P,{abortedError:()=>ot,closeFailedError:()=>tt,deleteFailedError:()=>ie,getFailedError:()=>rt,hasFailedError:()=>nt,notFoundError:()=>U,openFailedError:()=>et,putFailedError:()=>se});var L=we(Ce(),1);function et(r){return r=r??new Error("Open failed"),(0,L.default)(r,"ERR_OPEN_FAILED")}function tt(r){return r=r??new Error("Close failed"),(0,L.default)(r,"ERR_CLOSE_FAILED")}function se(r){return r=r??new Error("Put failed"),(0,L.default)(r,"ERR_PUT_FAILED")}function rt(r){return r=r??new Error("Get failed"),(0,L.default)(r,"ERR_GET_FAILED")}function ie(r){return r=r??new Error("Delete failed"),(0,L.default)(r,"ERR_DELETE_FAILED")}function nt(r){return r=r??new Error("Has failed"),(0,L.default)(r,"ERR_HAS_FAILED")}function U(r){return r=r??new Error("Not Found"),(0,L.default)(r,"ERR_NOT_FOUND")}function ot(r){return r=r??new Error("Aborted"),(0,L.default)(r,"ERR_ABORTED")}var I=class{has(e,t){return Promise.reject(new Error(".has is not implemented"))}put(e,t,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,t){for await(let{cid:n,block:o}of e)await this.put(n,o,t),yield n}get(e,t){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,t){for await(let n of e)yield{cid:n,block:await this.get(n,t)}}async delete(e,t){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,t){for await(let n of e)await this.delete(n,t),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};function st(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),a=s.charCodeAt(0);if(t[a]!==255)throw new TypeError(s+" is ambiguous");t[a]=o}var u=r.length,w=r.charAt(0),M=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var f=0,c=0,p=0,m=d.length;p!==m&&d[p]===0;)p++,f++;for(var y=(m-p)*i+1>>>0,g=new Uint8Array(y);p!==m;){for(var C=d[p],S=0,v=y-1;(C!==0||S<c)&&v!==-1;v--,S++)C+=256*g[v]>>>0,g[v]=C%u>>>0,C=C/u>>>0;if(C!==0)throw new Error("Non-zero carry");c=S,p++}for(var k=y-c;k!==y&&g[k]===0;)k++;for(var R=w.repeat(f);k<y;++k)R+=r.charAt(g[k]);return R}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var f=0;if(d[f]!==" "){for(var c=0,p=0;d[f]===w;)c++,f++;for(var m=(d.length-f)*M+1>>>0,y=new Uint8Array(m);d[f];){var g=t[d.charCodeAt(f)];if(g===255)return;for(var C=0,S=m-1;(g!==0||C<p)&&S!==-1;S--,C++)g+=u*y[S]>>>0,y[S]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");p=C,f++}if(d[f]!==" "){for(var v=m-p;v!==m&&y[v]===0;)v++;for(var k=new Uint8Array(c+(m-v)),R=c;v!==m;)k[R++]=y[v++];return k}}}function O(d){var f=h(d);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:O}}var it=st,at=it,ve=at;var cr=new Uint8Array(0);var Ee=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},N=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var ae=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ce=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Fe(this,e)}},ue=class{constructor(e){this.decoders=e}or(e){return Fe(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Fe=(r,e)=>new ue({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),le=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ae(e,t,n),this.decoder=new ce(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ae=({name:r,prefix:e,encode:t,decode:n})=>new le(r,e,t,n),fe=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ve(t,e);return Ae({prefix:r,name:e,encode:n,decode:s=>N(o(s))})},ct=(r,e,t,n)=>{let o={};for(let i=0;i<e.length;++i)o[e[i]]=i;let s=r.length;for(;r[s-1]==="=";)--s;let a=new Uint8Array(s*t/8|0),u=0,w=0,M=0;for(let i=0;i<s;++i){let l=o[r[i]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);w=w<<t|l,u+=t,u>=8&&(u-=8,a[M++]=255&w>>u)}if(u>=t||255&w<<8-u)throw new SyntaxError("Unexpected end of data");return a},ut=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",a=0,u=0;for(let w=0;w<r.length;++w)for(u=u<<8|r[w],a+=8;a>t;)a-=t,s+=e[o&u>>a];if(a&&(s+=e[o&u<<t-a]),n)for(;s.length*t&7;)s+="=";return s},x=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Ae({prefix:e,name:r,encode(o){return ut(o,n,t)},decode(o){return ct(o,n,t,r)}});var E=x({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pr=x({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=x({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),br=x({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yr=x({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wr=x({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gr=x({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=x({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cr=x({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var lt=Me,Se=128,ft=127,dt=~ft,ht=Math.pow(2,31);function Me(r,e,t){e=e||[],t=t||0;for(var n=t;r>=ht;)e[t++]=r&255|Se,r/=128;for(;r&dt;)e[t++]=r&255|Se,r>>>=7;return e[t]=r|0,Me.bytes=t-n+1,e}var pt=de,mt=128,ke=127;function de(r,n){var t=0,n=n||0,o=0,s=n,a,u=r.length;do{if(s>=u)throw de.bytes=0,new RangeError("Could not decode varint");a=r[s++],t+=o<28?(a&ke)<<o:(a&ke)*Math.pow(2,o),o+=7}while(a>=mt);return de.bytes=s-n,t}var bt=Math.pow(2,7),yt=Math.pow(2,14),wt=Math.pow(2,21),gt=Math.pow(2,28),xt=Math.pow(2,35),Ct=Math.pow(2,42),vt=Math.pow(2,49),Et=Math.pow(2,56),Ft=Math.pow(2,63),At=function(r){return r<bt?1:r<yt?2:r<wt?3:r<gt?4:r<xt?5:r<Ct?6:r<vt?7:r<Et?8:r<Ft?9:10},St={encode:lt,decode:pt,encodingLength:At},kt=St,J=kt;var G=(r,e=0)=>[J.decode(r,e),J.decode.bytes],T=(r,e,t=0)=>(J.encode(r,e,t),e),j=r=>J.encodingLength(r);var Ie=(r,e)=>{let t=e.byteLength,n=j(r),o=n+j(t),s=new Uint8Array(o+t);return T(r,s,0),T(t,s,n),s.set(e,o),new B(r,t,e,s)},K=r=>{let e=N(r),[t,n]=G(e),[o,s]=G(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new B(t,o,a,e)},Le=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Ee(r.bytes,t.bytes)}},B=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var z=fe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kr=fe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ue=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return zt(t,he(r),e||z.encoder);default:return It(t,he(r),e||E.encoder)}};var Ne=new WeakMap,he=r=>{let e=Ne.get(r);if(e==null){let t=new Map;return Ne.set(r,t),t}return e},b=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Q)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Lt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return b.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ie(e,t);return b.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return b.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Le(e.multihash,n.multihash)}toString(e){return Ue(this,e)}toJSON(){return{"/":Ue(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof b)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:a}=t;return new b(n,o,s,a||De(n,o,s.bytes))}else if(t[Ot]===!0){let{version:n,multihash:o,code:s}=t,a=K(o);return b.create(n,s,a)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Q)throw new Error(`Version 0 CID must use dag-pb (code: ${Q}) block encoding`);return new b(e,t,n,n.bytes)}case 1:{let o=De(e,t,n.bytes);return new b(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return b.create(0,Q,e)}static createV1(e,t){return b.create(1,e,t)}static decode(e){let[t,n]=b.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=b.inspectBytes(e),n=t.size-t.multihashSize,o=N(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),a=new B(t.multihashCode,t.digestSize,s,o);return[t.version===0?b.createV0(a):b.createV1(t.codec,a),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,h]=G(e.subarray(t));return t+=h,l},o=n(),s=Q;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=t,u=n(),w=n(),M=t+w,i=M-a;return{version:o,codec:s,multihashCode:u,digestSize:w,multihashSize:i,size:M}}static parse(e,t){let[n,o]=Mt(e,t),s=b.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return he(s).set(n,e),s}},Mt=(r,e)=>{switch(r[0]){case"Q":{let t=e||z;return[z.prefix,t.decode(`${z.prefix}${r}`)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}case E.prefix:{let t=e||E;return[E.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},zt=(r,e,t)=>{let{prefix:n}=t;if(n!==z.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},It=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},Q=112,Lt=18,De=(r,e,t)=>{let n=j(r),o=n+j(e),s=new Uint8Array(o+t.byteLength);return T(r,s,0),T(e,s,n),s.set(t,o),s},Ot=Symbol.for("@ipld/js-cid/CID");var Re=85;var W=class extends I{data;constructor(){super(),this.data=new Map}put(e,t){return this.data.set(E.encode(e.multihash.bytes),t),e}get(e){let t=this.data.get(E.encode(e.multihash.bytes));if(t==null)throw U();return t}has(e){return this.data.has(E.encode(e.multihash.bytes))}async delete(e){this.data.delete(E.encode(e.multihash.bytes))}async*getAll(){for(let[e,t]of this.data.entries())yield{cid:b.createV1(Re,K(E.decode(e))),block:t}}};var Y=class extends I{put(e){return e}get(){throw U()}has(){return!1}async delete(){}async*getAll(){}};var A=we(Ve(),1);var $e=x({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qr=x({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jr=x({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gr=x({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});A.default.formatters.b=r=>r==null?"undefined":z.baseEncode(r);A.default.formatters.t=r=>r==null?"undefined":E.baseEncode(r);A.default.formatters.m=r=>r==null?"undefined":$e.baseEncode(r);A.default.formatters.p=r=>r==null?"undefined":r.toString();A.default.formatters.c=r=>r==null?"undefined":r.toString();A.default.formatters.k=r=>r==null?"undefined":r.toString();A.default.formatters.a=r=>r==null?"undefined":r.toString();function Gt(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function _e(r){let e=Gt(`${r}:trace`);return A.default.enabled(`${r}:trace`)&&A.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,A.default)(`${r}:trace`)),Object.assign((0,A.default)(r),{error:(0,A.default)(`${r}:error`),trace:e})}function Qt(r){return r[Symbol.asyncIterator]!=null}function Xt(r){if(Qt(r))return(async()=>{for await(let e of r);})();for(let e of r);}var pe=Xt;function Zt(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var qe=Zt;function Ht(r){return r[Symbol.asyncIterator]!=null}function Kt(r,e){if(Ht(r))return async function*(){for await(let u of r)await e(u)&&(yield u)}();let t=qe(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let u of t)await e(u)&&(yield u)}();let a=e;return function*(){s===!0&&(yield n);for(let u of t)a(u)&&(yield u)}()}var Je=Kt;function re(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var ne=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},q=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new ne(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new ne(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var me=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function X(r={}){return Wt(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Wt(r,e){e=e??{};let t=e.onEnd,n=new q,o,s,a,u=re(),w=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((c,p)=>{s=m=>{s=null,n.push(m);try{c(r(n))}catch(y){p(y)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=re()})}},M=c=>s!=null?s(c):(n.push(c),o),i=c=>(n=new q,s!=null?s({error:c}):(n.push({error:c}),o)),l=c=>{if(a)return o;if(e?.objectMode!==!0&&c?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return M({done:!1,value:c})},h=c=>a?o:(a=!0,c!=null?i(c):M({done:!0})),O=()=>(n=new q,h(),{done:!0}),d=c=>(h(c),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:w,return:O,throw:d,push:l,end:h,get readableLength(){return n.size},onEmpty:async c=>{let p=c?.signal;if(p?.throwIfAborted(),n.isEmpty())return;let m,y;p!=null&&(m=new Promise((g,C)=>{y=()=>{C(new me)},p.addEventListener("abort",y)}));try{await Promise.race([u.promise,m])}finally{y!=null&&p!=null&&p?.removeEventListener("abort",y)}}},t==null)return o;let f=o;return o={[Symbol.asyncIterator](){return this},next(){return f.next()},throw(c){return f.throw(c),t!=null&&(t(c),t=void 0),{done:!0}},return(){return f.return(),t!=null&&(t(),t=void 0),{done:!0}},push:l,end(c){return f.end(c),t!=null&&(t(c),t=void 0),o},get readableLength(){return f.readableLength}},o}function Yt(r){return r[Symbol.asyncIterator]!=null}function er(...r){let e=[];for(let t of r)Yt(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=X({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var Ge=er;var tr=_e("blockstore:core:tiered"),oe=class extends I{stores;constructor(e){super(),this.stores=e.slice()}async put(e,t,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(e,t,n)})),e}catch(o){throw se(o)}}async get(e,t){for(let n of this.stores)try{let o=await n.get(e,t);if(o!=null)return o}catch(o){tr.error(o)}throw U()}async has(e,t){for(let n of this.stores)if(await n.has(e,t))return!0;return!1}async delete(e,t){try{await Promise.all(this.stores.map(async n=>{await n.delete(e,t)}))}catch(n){throw ie(n)}}async*putMany(e,t={}){let n,o=this.stores.map(s=>{let a=X({objectMode:!0});return pe(s.putMany(a,t)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s.cid}}finally{o.forEach(s=>s.end())}}async*deleteMany(e,t={}){let n,o=this.stores.map(s=>{let a=X({objectMode:!0});return pe(s.deleteMany(a,t)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s}}finally{o.forEach(s=>s.end())}}async*getAll(e){let t=new Set;yield*Je(Ge(...this.stores.map(n=>n.getAll(e))),n=>{let o=n.cid.toString();return t.has(o)?!1:(t.add(o),!0)})}};var rr={...P};return We(nr);})(); | ||
"use strict";var BlockstoreCore=(()=>{var st=Object.create;var Z=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var at=Object.getOwnPropertyNames;var ct=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var W=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ce=(r,e)=>{for(var t in e)Z(r,t,{get:e[t],enumerable:!0})},Ee=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of at(e))!ft.call(r,o)&&o!==t&&Z(r,o,{get:()=>e[o],enumerable:!(n=it(e,o))||n.enumerable});return r};var Fe=(r,e,t)=>(t=r!=null?st(ct(r)):{},Ee(e||!r||!r.__esModule?Z(t,"default",{value:r,enumerable:!0}):t,r)),ut=r=>Ee(Z({},"__esModule",{value:!0}),r);var Ue=W((Cr,Se)=>{"use strict";function Ae(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function lt(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return Ae(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),Ae(new o,t)}}Se.exports=lt});var _e=W((on,qe)=>{var $=1e3,q=$*60,_=q*60,P=_*24,Gt=P*7,Qt=P*365.25;qe.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return Xt(r);if(t==="number"&&isFinite(r))return e.long?Zt(r):Kt(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Xt(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*Qt;case"weeks":case"week":case"w":return t*Gt;case"days":case"day":case"d":return t*P;case"hours":case"hour":case"hrs":case"hr":case"h":return t*_;case"minutes":case"minute":case"mins":case"min":case"m":return t*q;case"seconds":case"second":case"secs":case"sec":case"s":return t*$;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function Kt(r){var e=Math.abs(r);return e>=P?Math.round(r/P)+"d":e>=_?Math.round(r/_)+"h":e>=q?Math.round(r/q)+"m":e>=$?Math.round(r/$)+"s":r+"ms"}function Zt(r){var e=Math.abs(r);return e>=P?te(r,e,P,"day"):e>=_?te(r,e,_,"hour"):e>=q?te(r,e,q,"minute"):e>=$?te(r,e,$,"second"):r+" ms"}function te(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var Ge=W((sn,Je)=>{function Wt(r){t.debug=t,t.default=t,t.coerce=y,t.disable=s,t.enable=o,t.enabled=i,t.humanize=_e(),t.destroy=F,Object.keys(r).forEach(a=>{t[a]=r[a]}),t.names=[],t.skips=[],t.formatters={};function e(a){let d=0;for(let p=0;p<a.length;p++)d=(d<<5)-d+a.charCodeAt(p),d|=0;return t.colors[Math.abs(d)%t.colors.length]}t.selectColor=e;function t(a){let d,p=null,M,f;function l(...u){if(!l.enabled)return;let h=l,b=Number(new Date),w=b-(d||b);h.diff=w,h.prev=d,h.curr=b,d=b,u[0]=t.coerce(u[0]),typeof u[0]!="string"&&u.unshift("%O");let m=0;u[0]=u[0].replace(/%([a-zA-Z%])/g,(C,g)=>{if(C==="%%")return"%";m++;let v=t.formatters[g];if(typeof v=="function"){let k=u[m];C=v.call(h,k),u.splice(m,1),m--}return C}),t.formatArgs.call(h,u),(h.log||t.log).apply(h,u)}return l.namespace=a,l.useColors=t.useColors(),l.color=t.selectColor(a),l.extend=n,l.destroy=t.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(M!==t.namespaces&&(M=t.namespaces,f=t.enabled(a)),f),set:u=>{p=u}}),typeof t.init=="function"&&t.init(l),l}function n(a,d){let p=t(this.namespace+(typeof d>"u"?":":d)+a);return p.log=this.log,p}function o(a){t.save(a),t.namespaces=a,t.names=[],t.skips=[];let d,p=(typeof a=="string"?a:"").split(/[\s,]+/),M=p.length;for(d=0;d<M;d++)p[d]&&(a=p[d].replace(/\*/g,".*?"),a[0]==="-"?t.skips.push(new RegExp("^"+a.slice(1)+"$")):t.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...t.names.map(c),...t.skips.map(c).map(d=>"-"+d)].join(",");return t.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let d,p;for(d=0,p=t.skips.length;d<p;d++)if(t.skips[d].test(a))return!1;for(d=0,p=t.names.length;d<p;d++)if(t.names[d].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function y(a){return a instanceof Error?a.stack||a.message:a}function F(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}Je.exports=Wt});var Qe=W((S,re)=>{S.formatArgs=Yt;S.save=er;S.load=tr;S.useColors=Ht;S.storage=rr();S.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();S.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 Ht(){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 Yt(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+re.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}S.log=console.debug||console.log||(()=>{});function er(r){try{r?S.storage.setItem("debug",r):S.storage.removeItem("debug")}catch{}}function tr(){let r;try{r=S.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function rr(){try{return localStorage}catch{}}re.exports=Ge()(S);var{formatters:nr}=re.exports;nr.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var xr={};Ce(xr,{BaseBlockstore:()=>O,BlackHoleBlockstore:()=>ee,Errors:()=>gr,MemoryBlockstore:()=>Y,TieredBlockstore:()=>se});var T={};Ce(T,{abortedError:()=>mt,closeFailedError:()=>ht,deleteFailedError:()=>ae,getFailedError:()=>pt,hasFailedError:()=>bt,notFoundError:()=>R,openFailedError:()=>dt,putFailedError:()=>ie});var L=Fe(Ue(),1);function dt(r){return r=r??new Error("Open failed"),(0,L.default)(r,"ERR_OPEN_FAILED")}function ht(r){return r=r??new Error("Close failed"),(0,L.default)(r,"ERR_CLOSE_FAILED")}function ie(r){return r=r??new Error("Put failed"),(0,L.default)(r,"ERR_PUT_FAILED")}function pt(r){return r=r??new Error("Get failed"),(0,L.default)(r,"ERR_GET_FAILED")}function ae(r){return r=r??new Error("Delete failed"),(0,L.default)(r,"ERR_DELETE_FAILED")}function bt(r){return r=r??new Error("Has failed"),(0,L.default)(r,"ERR_HAS_FAILED")}function R(r){return r=r??new Error("Not Found"),(0,L.default)(r,"ERR_NOT_FOUND")}function mt(r){return r=r??new Error("Aborted"),(0,L.default)(r,"ERR_ABORTED")}var O=class{has(e,t){return Promise.reject(new Error(".has is not implemented"))}put(e,t,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,t){for await(let{cid:n,block:o}of e)await this.put(n,o,t),yield n}get(e,t){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,t){for await(let n of e)yield{cid:n,block:await this.get(n,t)}}async delete(e,t){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,t){for await(let n of e)await this.delete(n,t),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};function yt(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,y=r.charAt(0),F=Math.log(c)/Math.log(256),a=Math.log(256)/Math.log(c);function d(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,u=0,h=0,b=f.length;h!==b&&f[h]===0;)h++,l++;for(var w=(b-h)*a+1>>>0,m=new Uint8Array(w);h!==b;){for(var x=f[h],C=0,g=w-1;(x!==0||C<u)&&g!==-1;g--,C++)x+=256*m[g]>>>0,m[g]=x%c>>>0,x=x/c>>>0;if(x!==0)throw new Error("Non-zero carry");u=C,h++}for(var v=w-u;v!==w&&m[v]===0;)v++;for(var k=y.repeat(l);v<w;++v)k+=r.charAt(m[v]);return k}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var u=0,h=0;f[l]===y;)u++,l++;for(var b=(f.length-l)*F+1>>>0,w=new Uint8Array(b);f[l];){var m=t[f.charCodeAt(l)];if(m===255)return;for(var x=0,C=b-1;(m!==0||x<h)&&C!==-1;C--,x++)m+=c*w[C]>>>0,w[C]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");h=x,l++}if(f[l]!==" "){for(var g=b-h;g!==b&&w[g]===0;)g++;for(var v=new Uint8Array(u+(b-g)),k=u;g!==b;)v[k++]=w[g++];return v}}}function M(f){var l=p(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:p,decode:M}}var wt=yt,gt=wt,ke=gt;var Ar=new Uint8Array(0);var ze=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0},D=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var ce=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},fe=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Me(this,e)}},ue=class{constructor(e){this.decoders=e}or(e){return Me(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Me=(r,e)=>new ue({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),le=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new ce(e,t,n),this.decoder=new fe(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Oe=({name:r,prefix:e,encode:t,decode:n})=>new le(r,e,t,n),de=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=ke(t,e);return Oe({prefix:r,name:e,encode:n,decode:s=>D(o(s))})},xt=(r,e,t,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,y=0,F=0;for(let a=0;a<s;++a){let d=o[r[a]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);y=y<<t|d,c+=t,c>=8&&(c-=8,i[F++]=255&y>>c)}if(c>=t||255&y<<8-c)throw new SyntaxError("Unexpected end of data");return i},vt=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let y=0;y<r.length;++y)for(c=c<<8|r[y],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},I=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>Oe({prefix:e,name:r,encode(o){return vt(o,n,t)},decode(o){return xt(o,n,t,r)}});var z=I({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Or=I({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ir=I({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Lr=I({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Nr=I({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rr=I({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Dr=I({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pr=I({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tr=I({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ct=Ne,Ie=128,Et=127,Ft=~Et,At=Math.pow(2,31);function Ne(r,e,t){e=e||[],t=t||0;for(var n=t;r>=At;)e[t++]=r&255|Ie,r/=128;for(;r&Ft;)e[t++]=r&255|Ie,r>>>=7;return e[t]=r|0,Ne.bytes=t-n+1,e}var St=he,Ut=128,Le=127;function he(r,n){var t=0,n=n||0,o=0,s=n,i,c=r.length;do{if(s>=c)throw he.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&Le)<<o:(i&Le)*Math.pow(2,o),o+=7}while(i>=Ut);return he.bytes=s-n,t}var kt=Math.pow(2,7),zt=Math.pow(2,14),Mt=Math.pow(2,21),Ot=Math.pow(2,28),It=Math.pow(2,35),Lt=Math.pow(2,42),Nt=Math.pow(2,49),Rt=Math.pow(2,56),Dt=Math.pow(2,63),Pt=function(r){return r<kt?1:r<zt?2:r<Mt?3:r<Ot?4:r<It?5:r<Lt?6:r<Nt?7:r<Rt?8:r<Dt?9:10},Tt={encode:Ct,decode:St,encodingLength:Pt},Bt=Tt,G=Bt;var Q=(r,e=0)=>[G.decode(r,e),G.decode.bytes],B=(r,e,t=0)=>(G.encode(r,e,t),e),j=r=>G.encodingLength(r);var De=(r,e)=>{let t=e.byteLength,n=j(r),o=n+j(t),s=new Uint8Array(o+t);return B(r,s,0),B(t,s,n),s.set(e,o),new V(r,t,e,s)},H=r=>{let e=D(r),[t,n]=Q(e),[o,s]=Q(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new V(t,o,i,e)},Pe=(r,e)=>{if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ze(r.bytes,t.bytes)}},V=class{constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var N=de({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_r=de({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Be=(r,e)=>{let{bytes:t,version:n}=r;switch(n){case 0:return Vt(t,pe(r),e||N.encoder);default:return $t(t,pe(r),e||z.encoder)}};var je=new WeakMap,pe=r=>{let e=je.get(r);if(e==null){let t=new Map;return je.set(r,t),t}return e},E=class{constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==X)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==qt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return E.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=De(e,t);return E.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return E.equals(this,e)}static equals(e,t){let n=t;return n&&e.code===n.code&&e.version===n.version&&Pe(e.multihash,n.multihash)}toString(e){return Be(this,e)}toJSON(){return{"/":Be(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof E)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:s,bytes:i}=t;return new E(n,o,s,i||Ve(n,o,s.bytes))}else if(t[_t]===!0){let{version:n,multihash:o,code:s}=t,i=H(o);return E.create(n,s,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==X)throw new Error(`Version 0 CID must use dag-pb (code: ${X}) block encoding`);return new E(e,t,n,n.bytes)}case 1:{let o=Ve(e,t,n.bytes);return new E(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return E.create(0,X,e)}static createV1(e,t){return E.create(1,e,t)}static decode(e){let[t,n]=E.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=E.inspectBytes(e),n=t.size-t.multihashSize,o=D(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new V(t.multihashCode,t.digestSize,s,o);return[t.version===0?E.createV0(i):E.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[d,p]=Q(e.subarray(t));return t+=p,d},o=n(),s=X;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,c=n(),y=n(),F=t+y,a=F-i;return{version:o,codec:s,multihashCode:c,digestSize:y,multihashSize:a,size:F}}static parse(e,t){let[n,o]=jt(e,t),s=E.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pe(s).set(n,e),s}},jt=(r,e)=>{switch(r[0]){case"Q":{let t=e||N;return[N.prefix,t.decode(`${N.prefix}${r}`)]}case N.prefix:{let t=e||N;return[N.prefix,t.decode(r)]}case z.prefix:{let t=e||z;return[z.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},Vt=(r,e,t)=>{let{prefix:n}=t;if(n!==N.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o},$t=(r,e,t)=>{let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o},X=112,qt=18,Ve=(r,e,t)=>{let n=j(r),o=n+j(e),s=new Uint8Array(o+t.byteLength);return B(r,s,0),B(e,s,n),s.set(t,o),s},_t=Symbol.for("@ipld/js-cid/CID");var $e=85;var Y=class extends O{data;constructor(){super(),this.data=new Map}put(e,t){return this.data.set(z.encode(e.multihash.bytes),t),e}get(e){let t=this.data.get(z.encode(e.multihash.bytes));if(t==null)throw R();return t}has(e){return this.data.has(z.encode(e.multihash.bytes))}async delete(e){this.data.delete(z.encode(e.multihash.bytes))}async*getAll(){for(let[e,t]of this.data.entries())yield{cid:E.createV1($e,H(z.decode(e))),block:t}}};var ee=class extends O{put(e){return e}get(){throw R()}has(){return!1}async delete(){}async*getAll(){}};var U=Fe(Qe(),1);function or(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var c=r.length,y=r.charAt(0),F=Math.log(c)/Math.log(256),a=Math.log(256)/Math.log(c);function d(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var l=0,u=0,h=0,b=f.length;h!==b&&f[h]===0;)h++,l++;for(var w=(b-h)*a+1>>>0,m=new Uint8Array(w);h!==b;){for(var x=f[h],C=0,g=w-1;(x!==0||C<u)&&g!==-1;g--,C++)x+=256*m[g]>>>0,m[g]=x%c>>>0,x=x/c>>>0;if(x!==0)throw new Error("Non-zero carry");u=C,h++}for(var v=w-u;v!==w&&m[v]===0;)v++;for(var k=y.repeat(l);v<w;++v)k+=r.charAt(m[v]);return k}function p(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var l=0;if(f[l]!==" "){for(var u=0,h=0;f[l]===y;)u++,l++;for(var b=(f.length-l)*F+1>>>0,w=new Uint8Array(b);f[l];){var m=t[f.charCodeAt(l)];if(m===255)return;for(var x=0,C=b-1;(m!==0||x<h)&&C!==-1;C--,x++)m+=c*w[C]>>>0,w[C]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");h=x,l++}if(f[l]!==" "){for(var g=b-h;g!==b&&w[g]===0;)g++;for(var v=new Uint8Array(u+(b-g)),k=u;g!==b;)v[k++]=w[g++];return v}}}function M(f){var l=p(f);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:p,decode:M}}var sr=or,ir=sr,Xe=ir;var cn=new Uint8Array(0);var Ke=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var be=class{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},me=class{constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ze(this,e)}},ye=class{constructor(e){this.decoders=e}or(e){return Ze(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Ze=(r,e)=>new ye({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),we=class{constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new be(e,t,n),this.decoder=new me(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},We=({name:r,prefix:e,encode:t,decode:n})=>new we(r,e,t,n),ge=({prefix:r,name:e,alphabet:t})=>{let{encode:n,decode:o}=Xe(t,e);return We({prefix:r,name:e,encode:n,decode:s=>Ke(o(s))})},ar=(r,e,t,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),c=0,y=0,F=0;for(let a=0;a<s;++a){let d=o[r[a]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);y=y<<t|d,c+=t,c>=8&&(c-=8,i[F++]=255&y>>c)}if(c>=t||255&y<<8-c)throw new SyntaxError("Unexpected end of data");return i},cr=(r,e,t)=>{let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,c=0;for(let y=0;y<r.length;++y)for(c=c<<8|r[y],i+=8;i>t;)i-=t,s+=e[o&c>>i];if(i&&(s+=e[o&c<<t-i]),n)for(;s.length*t&7;)s+="=";return s},A=({name:r,prefix:e,bitsPerChar:t,alphabet:n})=>We({prefix:e,name:r,encode(o){return cr(o,n,t)},decode(o){return ar(o,n,t,r)}});var He=A({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pn=A({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bn=A({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),mn=A({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yn=A({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wn=A({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gn=A({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xn=A({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vn=A({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ye=ge({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fn=ge({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var et=A({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Un=A({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),kn=A({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),zn=A({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});U.default.formatters.b=r=>r==null?"undefined":Ye.baseEncode(r);U.default.formatters.t=r=>r==null?"undefined":He.baseEncode(r);U.default.formatters.m=r=>r==null?"undefined":et.baseEncode(r);U.default.formatters.p=r=>r==null?"undefined":r.toString();U.default.formatters.c=r=>r==null?"undefined":r.toString();U.default.formatters.k=r=>r==null?"undefined":r.toString();U.default.formatters.a=r=>r==null?"undefined":r.toString();function fr(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function tt(r){let e=fr(`${r}:trace`);return U.default.enabled(`${r}:trace`)&&U.default.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=(0,U.default)(`${r}:trace`)),Object.assign((0,U.default)(r),{error:(0,U.default)(`${r}:error`),trace:e})}function ur(r){return r[Symbol.asyncIterator]!=null}function lr(r){if(ur(r))return(async()=>{for await(let e of r);})();for(let e of r);}var xe=lr;function dr(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var rt=dr;function hr(r){return r[Symbol.asyncIterator]!=null}function pr(r,e){if(hr(r))return async function*(){for await(let c of r)await e(c)&&(yield c)}();let t=rt(r),{value:n,done:o}=t.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let c of t)await e(c)&&(yield c)}();let i=e;return function*(){s===!0&&(yield n);for(let c of t)i(c)&&(yield c)}()}var nt=pr;function ne(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var oe=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},J=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new oe(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new oe(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var ve=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function K(r={}){return br(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function br(r,e){e=e??{};let t=e.onEnd,n=new J,o,s,i,c=ne(),y=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((u,h)=>{s=b=>{s=null,n.push(b);try{u(r(n))}catch(w){h(w)}return o}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{c.resolve(),c=ne()})}},F=u=>s!=null?s(u):(n.push(u),o),a=u=>(n=new J,s!=null?s({error:u}):(n.push({error:u}),o)),d=u=>{if(i)return o;if(e?.objectMode!==!0&&u?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return F({done:!1,value:u})},p=u=>i?o:(i=!0,u!=null?a(u):F({done:!0})),M=()=>(n=new J,p(),{done:!0}),f=u=>(p(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:y,return:M,throw:f,push:d,end:p,get readableLength(){return n.size},onEmpty:async u=>{let h=u?.signal;if(h?.throwIfAborted(),n.isEmpty())return;let b,w;h!=null&&(b=new Promise((m,x)=>{w=()=>{x(new ve)},h.addEventListener("abort",w)}));try{await Promise.race([c.promise,b])}finally{w!=null&&h!=null&&h?.removeEventListener("abort",w)}}},t==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(u){return l.throw(u),t!=null&&(t(u),t=void 0),{done:!0}},return(){return l.return(),t!=null&&(t(),t=void 0),{done:!0}},push:d,end(u){return l.end(u),t!=null&&(t(u),t=void 0),o},get readableLength(){return l.readableLength}},o}function mr(r){return r[Symbol.asyncIterator]!=null}function yr(...r){let e=[];for(let t of r)mr(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=K({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)t.push(o)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var ot=yr;var wr=tt("blockstore:core:tiered"),se=class extends O{stores;constructor(e){super(),this.stores=e.slice()}async put(e,t,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(e,t,n)})),e}catch(o){throw ie(o)}}async get(e,t){for(let n of this.stores)try{let o=await n.get(e,t);if(o!=null)return o}catch(o){wr.error(o)}throw R()}async has(e,t){for(let n of this.stores)if(await n.has(e,t))return!0;return!1}async delete(e,t){try{await Promise.all(this.stores.map(async n=>{await n.delete(e,t)}))}catch(n){throw ae(n)}}async*putMany(e,t={}){let n,o=this.stores.map(s=>{let i=K({objectMode:!0});return xe(s.putMany(i,t)).catch(c=>{n=c}),i});try{for await(let s of e){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s.cid}}finally{o.forEach(s=>s.end())}}async*deleteMany(e,t={}){let n,o=this.stores.map(s=>{let i=K({objectMode:!0});return xe(s.deleteMany(i,t)).catch(c=>{n=c}),i});try{for await(let s of e){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s}}finally{o.forEach(s=>s.end())}}async*getAll(e){let t=new Set;yield*nt(ot(...this.stores.map(n=>n.getAll(e))),n=>{let o=n.cid.toString();return t.has(o)?!1:(t.add(o),!0)})}};var gr={...T};return ut(xr);})(); | ||
return BlockstoreCore})); |
{ | ||
"name": "blockstore-core", | ||
"version": "4.3.0", | ||
"version": "4.3.1", | ||
"description": "Contains various implementations of the API contract described in interface-blockstore", | ||
@@ -182,3 +182,3 @@ "author": "Alex Potsides <alex.potsides@protocol.ai>", | ||
"dependencies": { | ||
"@libp2p/logger": "^2.0.0", | ||
"@libp2p/logger": "^3.0.0", | ||
"err-code": "^3.0.1", | ||
@@ -185,0 +185,0 @@ "interface-blockstore": "^5.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75403
742
+ Added@libp2p/interface@0.1.6(transitive)
+ Added@libp2p/logger@3.1.0(transitive)
+ Addedabortable-iterator@5.1.0(transitive)
+ Addedget-iterator@2.0.1(transitive)
+ Addedit-stream-types@2.0.2(transitive)
+ Addedrace-signal@1.1.0(transitive)
- Removed@libp2p/interface-peer-id@2.0.2(transitive)
- Removed@libp2p/logger@2.1.1(transitive)
Updated@libp2p/logger@^3.0.0