Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datastore-core

Package Overview
Dependencies
Maintainers
4
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datastore-core - npm Package Compare versions

Comparing version 9.1.0 to 9.1.1

4

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.DatastoreCore = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var DatastoreCore=(()=>{var Je=Object.create;var pt=Object.defineProperty;var Ge=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty;var mt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),v=(r,t)=>{for(var e in t)pt(r,e,{get:t[e],enumerable:!0})},ae=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!Qe.call(r,o)&&o!==e&&pt(r,o,{get:()=>t[o],enumerable:!(n=Ge(t,o))||n.enumerable});return r};var ce=(r,t,e)=>(e=r!=null?Je(He(r)):{},ae(t||!r||!r.__esModule?pt(e,"default",{value:r,enumerable:!0}):e,r)),Ze=r=>ae(pt({},"__esModule",{value:!0}),r);var le=mt((Dn,fe)=>{"use strict";function ue(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Ye(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return ue(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),ue(new o,e)}}fe.exports=Ye});var $e=mt((ys,Pe)=>{var st=1e3,it=st*60,at=it*60,X=at*24,mn=X*7,yn=X*365.25;Pe.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return bn(r);if(e==="number"&&isFinite(r))return t.long?wn(r):gn(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function bn(r){if(r=String(r),!(r.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(r);if(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*yn;case"weeks":case"week":case"w":return e*mn;case"days":case"day":case"d":return e*X;case"hours":case"hour":case"hrs":case"hr":case"h":return e*at;case"minutes":case"minute":case"mins":case"min":case"m":return e*it;case"seconds":case"second":case"secs":case"sec":case"s":return e*st;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function gn(r){var t=Math.abs(r);return t>=X?Math.round(r/X)+"d":t>=at?Math.round(r/at)+"h":t>=it?Math.round(r/it)+"m":t>=st?Math.round(r/st)+"s":r+"ms"}function wn(r){var t=Math.abs(r);return t>=X?Dt(r,t,X,"day"):t>=at?Dt(r,t,at,"hour"):t>=it?Dt(r,t,it,"minute"):t>=st?Dt(r,t,st,"second"):r+" ms"}function Dt(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var Ve=mt((bs,je)=>{function xn(r){e.debug=e,e.default=e,e.coerce=g,e.disable=s,e.enable=o,e.enabled=i,e.humanize=$e(),e.destroy=N,Object.keys(r).forEach(a=>{e[a]=r[a]}),e.names=[],e.skips=[],e.formatters={};function t(a){let f=0;for(let d=0;d<a.length;d++)f=(f<<5)-f+a.charCodeAt(d),f|=0;return e.colors[Math.abs(f)%e.colors.length]}e.selectColor=t;function e(a){let f,d=null,z,l;function c(...p){if(!c.enabled)return;let y=c,w=Number(new Date),A=w-(f||w);y.diff=A,y.prev=f,y.curr=w,f=w,p[0]=e.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let x=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(M,E)=>{if(M==="%%")return"%";x++;let k=e.formatters[E];if(typeof k=="function"){let H=p[x];M=k.call(y,H),p.splice(x,1),x--}return M}),e.formatArgs.call(y,p),(y.log||e.log).apply(y,p)}return c.namespace=a,c.useColors=e.useColors(),c.color=e.selectColor(a),c.extend=n,c.destroy=e.destroy,Object.defineProperty(c,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(z!==e.namespaces&&(z=e.namespaces,l=e.enabled(a)),l),set:p=>{d=p}}),typeof e.init=="function"&&e.init(c),c}function n(a,f){let d=e(this.namespace+(typeof f>"u"?":":f)+a);return d.log=this.log,d}function o(a){e.save(a),e.namespaces=a,e.names=[],e.skips=[];let f,d=(typeof a=="string"?a:"").split(/[\s,]+/),z=d.length;for(f=0;f<z;f++)d[f]&&(a=d[f].replace(/\*/g,".*?"),a[0]==="-"?e.skips.push(new RegExp("^"+a.slice(1)+"$")):e.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...e.names.map(u),...e.skips.map(u).map(f=>"-"+f)].join(",");return e.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let f,d;for(f=0,d=e.skips.length;f<d;f++)if(e.skips[f].test(a))return!1;for(f=0,d=e.names.length;f<d;f++)if(e.names[f].test(a))return!0;return!1}function u(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function g(a){return a instanceof Error?a.stack||a.message:a}function N(){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 e.enable(e.load()),e}je.exports=xn});var Ke=mt((F,Nt)=>{F.formatArgs=Cn;F.save=En;F.load=Sn;F.useColors=vn;F.storage=Fn();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 vn(){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 Cn(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Nt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}F.log=console.debug||console.log||(()=>{});function En(r){try{r?F.storage.setItem("debug",r):F.storage.removeItem("debug")}catch{}}function Sn(){let r;try{r=F.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Fn(){try{return localStorage}catch{}}Nt.exports=Ve()(F);var{formatters:An}=Nt.exports;An.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var kn={};v(kn,{BaseDatastore:()=>C,Errors:()=>j,KeyTransformDatastore:()=>R,MemoryDatastore:()=>At,MountDatastore:()=>Ut,NamespaceDatastore:()=>Tt,ShardingDatastore:()=>ot,TieredDatastore:()=>_t,shard:()=>oe});var j={};v(j,{abortedError:()=>tr,dbDeleteFailedError:()=>ct,dbOpenFailedError:()=>Ot,dbReadFailedError:()=>qe,dbWriteFailedError:()=>ut,notFoundError:()=>$});var P=ce(le(),1);function Ot(r){return r=r??new Error("Cannot open database"),(0,P.default)(r,"ERR_DB_OPEN_FAILED")}function ct(r){return r=r??new Error("Delete failed"),(0,P.default)(r,"ERR_DB_DELETE_FAILED")}function ut(r){return r=r??new Error("Write failed"),(0,P.default)(r,"ERR_DB_WRITE_FAILED")}function qe(r){return r=r??new Error("Read failed"),(0,P.default)(r,"ERR_DB_READ_FAILED")}function $(r){return r=r??new Error("Not Found"),(0,P.default)(r,"ERR_NOT_FOUND")}function tr(r){return r=r??new Error("Aborted"),(0,P.default)(r,"ERR_ABORTED")}var oe={};v(oe,{NextToLast:()=>Et,PREFIX:()=>xt,Prefix:()=>vt,SHARDING_FN:()=>St,ShardBase:()=>tt,Suffix:()=>Ct,parseShardFun:()=>Ie,readShardFun:()=>Ft});var he=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var Rt={};v(Rt,{identity:()=>ir});function er(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var u=r.length,g=r.charAt(0),N=Math.log(u)/Math.log(256),a=Math.log(256)/Math.log(u);function f(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var c=0,p=0,y=0,w=l.length;y!==w&&l[y]===0;)y++,c++;for(var A=(w-y)*a+1>>>0,x=new Uint8Array(A);y!==w;){for(var D=l[y],M=0,E=A-1;(D!==0||M<p)&&E!==-1;E--,M++)D+=256*x[E]>>>0,x[E]=D%u>>>0,D=D/u>>>0;if(D!==0)throw new Error("Non-zero carry");p=M,y++}for(var k=A-p;k!==A&&x[k]===0;)k++;for(var H=g.repeat(c);k<A;++k)H+=r.charAt(x[k]);return H}function d(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var c=0;if(l[c]!==" "){for(var p=0,y=0;l[c]===g;)p++,c++;for(var w=(l.length-c)*N+1>>>0,A=new Uint8Array(w);l[c];){var x=e[l.charCodeAt(c)];if(x===255)return;for(var D=0,M=w-1;(x!==0||D<y)&&M!==-1;M--,D++)x+=u*A[M]>>>0,A[M]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");y=D,c++}if(l[c]!==" "){for(var E=w-y;E!==w&&A[E]===0;)E++;for(var k=new Uint8Array(p+(w-E)),H=p;E!==w;)k[H++]=A[E++];return k}}}function z(l){var c=d(l);if(c)return c;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:d,decode:z}}var rr=er,nr=rr,de=nr;var Tn=new Uint8Array(0);var pe=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},O=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 me=r=>new TextEncoder().encode(r),ye=r=>new TextDecoder().decode(r);var Bt=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},zt=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 ge(this,t)}},Lt=class{constructor(t){this.decoders=t}or(t){return ge(this,t)}decode(t){let e=t[0],n=this.decoders[e];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`)}},ge=(r,t)=>new Lt({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),It=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Bt(t,e,n),this.decoder=new zt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Q=({name:r,prefix:t,encode:e,decode:n})=>new It(r,t,e,n),L=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=de(e,t);return Q({prefix:r,name:t,encode:n,decode:s=>O(o(s))})},or=(r,t,e,n)=>{let o={};for(let a=0;a<t.length;++a)o[t[a]]=a;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),u=0,g=0,N=0;for(let a=0;a<s;++a){let f=o[r[a]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);g=g<<e|f,u+=e,u>=8&&(u-=8,i[N++]=255&g>>u)}if(u>=e||255&g<<8-u)throw new SyntaxError("Unexpected end of data");return i},sr=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,u=0;for(let g=0;g<r.length;++g)for(u=u<<8|r[g],i+=8;i>e;)i-=e,s+=t[o&u>>i];if(i&&(s+=t[o&u<<e-i]),n)for(;s.length*e&7;)s+="=";return s},m=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Q({prefix:t,name:r,encode(o){return sr(o,n,e)},decode(o){return or(o,n,e,r)}});var ir=Q({prefix:"\0",name:"identity",encode:r=>ye(r),decode:r=>me(r)});var Pt={};v(Pt,{base2:()=>ar});var ar=m({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var $t={};v($t,{base8:()=>cr});var cr=m({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jt={};v(jt,{base10:()=>ur});var ur=L({prefix:"9",name:"base10",alphabet:"0123456789"});var Vt={};v(Vt,{base16:()=>fr,base16upper:()=>lr});var fr=m({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lr=m({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Kt={};v(Kt,{base32:()=>I,base32hex:()=>mr,base32hexpad:()=>br,base32hexpadupper:()=>gr,base32hexupper:()=>yr,base32pad:()=>dr,base32padupper:()=>pr,base32upper:()=>hr,base32z:()=>wr});var I=m({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),hr=m({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),dr=m({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),pr=m({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mr=m({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yr=m({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),br=m({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),gr=m({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wr=m({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Wt={};v(Wt,{base36:()=>xr,base36upper:()=>vr});var xr=L({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vr=L({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Jt={};v(Jt,{base58btc:()=>U,base58flickr:()=>Cr});var U=L({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cr=L({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xt={};v(Xt,{base64:()=>Gt,base64pad:()=>Er,base64url:()=>Sr,base64urlpad:()=>Fr});var Gt=m({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Er=m({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Sr=m({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fr=m({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ht={};v(Ht,{base256emoji:()=>Dr});var we=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}"),Ar=we.reduce((r,t,e)=>(r[e]=t,r),[]),Mr=we.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function kr(r){return r.reduce((t,e)=>(t+=Ar[e],t),"")}function Ur(r){let t=[];for(let e of r){let n=Mr[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Dr=Q({prefix:"\u{1F680}",name:"base256emoji",encode:kr,decode:Ur});var qt={};v(qt,{sha256:()=>Hr,sha512:()=>Qr});var Nr=Ce,xe=128,_r=127,Tr=~_r,Or=Math.pow(2,31);function Ce(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Or;)t[e++]=r&255|xe,r/=128;for(;r&Tr;)t[e++]=r&255|xe,r>>>=7;return t[e]=r|0,Ce.bytes=e-n+1,t}var Br=Qt,zr=128,ve=127;function Qt(r,n){var e=0,n=n||0,o=0,s=n,i,u=r.length;do{if(s>=u)throw Qt.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&ve)<<o:(i&ve)*Math.pow(2,o),o+=7}while(i>=zr);return Qt.bytes=s-n,e}var Lr=Math.pow(2,7),Ir=Math.pow(2,14),Rr=Math.pow(2,21),Pr=Math.pow(2,28),$r=Math.pow(2,35),jr=Math.pow(2,42),Vr=Math.pow(2,49),Kr=Math.pow(2,56),Wr=Math.pow(2,63),Jr=function(r){return r<Lr?1:r<Ir?2:r<Rr?3:r<Pr?4:r<$r?5:r<jr?6:r<Vr?7:r<Kr?8:r<Wr?9:10},Gr={encode:Nr,decode:Br,encodingLength:Jr},Xr=Gr,ft=Xr;var lt=(r,t=0)=>[ft.decode(r,t),ft.decode.bytes],Z=(r,t,e=0)=>(ft.encode(r,t,e),t),Y=r=>ft.encodingLength(r);var V=(r,t)=>{let e=t.byteLength,n=Y(r),o=n+Y(e),s=new Uint8Array(o+e);return Z(r,s,0),Z(e,s,n),s.set(t,o),new q(r,e,t,s)},Ee=r=>{let t=O(r),[e,n]=lt(t),[o,s]=lt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new q(e,o,i,t)},Se=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&pe(r.bytes,e.bytes)}},q=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var Yt=({name:r,code:t,encode:e})=>new Zt(r,t,e),Zt=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?V(this.code,e):e.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ae=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),Hr=Yt({name:"sha2-256",code:18,encode:Ae("SHA-256")}),Qr=Yt({name:"sha2-512",code:19,encode:Ae("SHA-512")});var te={};v(te,{identity:()=>qr});var Me=0,Zr="identity",ke=O,Yr=r=>V(Me,ke(r)),qr={code:Me,name:Zr,encode:ke,digest:Yr};var to=new TextEncoder,eo=new TextDecoder;var Ue=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return nn(e,ee(r),t||U.encoder);default:return on(e,ee(r),t||I.encoder)}};var De=new WeakMap,ee=r=>{let t=De.get(r);if(t==null){let e=new Map;return De.set(r,e),e}return t},b=class{constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==dt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==sn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return b.createV0(e)}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:e}=this.multihash,n=V(t,e);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(t){return b.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Se(t.multihash,n.multihash)}toString(t){return Ue(this,t)}toJSON(){return{"/":Ue(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 e=t;if(e instanceof b)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new b(n,o,s,i||Ne(n,o,s.bytes))}else if(e[an]===!0){let{version:n,multihash:o,code:s}=e,i=Ee(o);return b.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==dt)throw new Error(`Version 0 CID must use dag-pb (code: ${dt}) block encoding`);return new b(t,e,n,n.bytes)}case 1:{let o=Ne(t,e,n.bytes);return new b(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return b.create(0,dt,t)}static createV1(t,e){return b.create(1,t,e)}static decode(t){let[e,n]=b.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=b.inspectBytes(t),n=e.size-e.multihashSize,o=O(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new q(e.multihashCode,e.digestSize,s,o);return[e.version===0?b.createV0(i):b.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[f,d]=lt(t.subarray(e));return e+=d,f},o=n(),s=dt;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,u=n(),g=n(),N=e+g,a=N-i;return{version:o,codec:s,multihashCode:u,digestSize:g,multihashSize:a,size:N}}static parse(t,e){let[n,o]=rn(t,e),s=b.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ee(s).set(n,t),s}},rn=(r,t)=>{switch(r[0]){case"Q":{let e=t||U;return[U.prefix,e.decode(`${U.prefix}${r}`)]}case U.prefix:{let e=t||U;return[U.prefix,e.decode(r)]}case I.prefix:{let e=t||I;return[I.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},nn=(r,t,e)=>{let{prefix:n}=e;if(n!==U.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o},on=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o},dt=112,sn=18,Ne=(r,t,e)=>{let n=Y(r),o=n+Y(t),s=new Uint8Array(o+e.byteLength);return Z(r,s,0),Z(t,s,n),s.set(e,o),s},an=Symbol.for("@ipld/js-cid/CID");var re={...Rt,...Pt,...$t,...jt,...Vt,...Kt,...Wt,...Jt,...Xt,...Ht},lo={...qt,...te};function bt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function _e(r=0){return globalThis.Buffer?.allocUnsafe!=null?bt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Oe(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Te=Oe("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ne=Oe("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=_e(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),cn={utf8:Te,"utf-8":Te,hex:re.base16,latin1:ne,ascii:ne,binary:ne,...re},gt=cn;function Be(r,t="utf8"){let e=gt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}function ze(r,t="utf8"){let e=gt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?bt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var B="/",Le=new TextEncoder().encode(B),wt=Le[0],h=class{constructor(t,e){if(typeof t=="string")this._buf=ze(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(e==null&&(e=!0),e&&this.clean(),this._buf.byteLength===0||this._buf[0]!==wt)throw new Error("Invalid key")}toString(t="utf8"){return Be(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new h(t.join(B))}static random(){return new h(he().replace(/-/g,""))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new h(t):typeof t.uint8Array=="function"?new h(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=Le),this._buf[0]!==wt){let t=new Uint8Array(this._buf.byteLength+1);t.fill(wt,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===wt;)this._buf=this._buf.subarray(0,-1)}less(t){let e=this.list(),n=t.list();for(let o=0;o<e.length;o++){if(n.length<o+1)return!1;let s=e[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return e.length<n.length}reverse(){return h.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(B).slice(1)}type(){return un(this.baseNamespace())}name(){return fn(this.baseNamespace())}instance(t){return new h(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(B)||(t+=B),t+=this.type(),new h(t)}parent(){let t=this.list();return t.length===1?new h(B):new h(t.slice(0,-1).join(B))}child(t){return this.toString()===B?t:t.toString()===B?this:new h(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return h.withNamespaces([...this.namespaces(),...ln(t.map(e=>e.namespaces()))])}};function un(r){let t=r.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function fn(r){let t=r.split(":");return t[t.length-1]}function ln(r){return[].concat(...r)}var xt="/repo/flatfs/shard/",St="SHARDING",tt=class{constructor(t){this.param=t,this.name="base",this._padding=""}fun(t){return"implement me"}toString(){return`${xt}v1/${this.name}/${this.param}`}},vt=class extends tt{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="prefix"}fun(t){return(t+this._padding).slice(0,this.param)}},Ct=class extends tt{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="suffix"}fun(t){let e=this._padding+t;return e.slice(e.length-this.param)}},Et=class extends tt{constructor(t){super(t),this._padding="".padStart(t+1,"_"),this.name="next-to-last"}fun(t){let e=this._padding+t,n=e.length-this.param-1;return e.slice(n,n+this.param)}};function Ie(r){if(r=r.trim(),r.length===0)throw new Error("empty shard string");if(!r.startsWith(xt))throw new Error(`invalid or no path prefix: ${r}`);let t=r.slice(xt.length).split("/"),e=t[0];if(e!=="v1")throw new Error(`expect 'v1' version, got '${e}'`);let n=t[1];if(t[2]==null||t[2]==="")throw new Error("missing param");let o=parseInt(t[2],10);switch(n){case"prefix":return new vt(o);case"suffix":return new Ct(o);case"next-to-last":return new Et(o);default:throw new Error(`unkown sharding function: ${n}`)}}var Ft=async(r,t)=>{let e=new h(r).child(new h(St)),o=await(typeof t.getRaw=="function"?t.getRaw.bind(t):t.get.bind(t))(e);return Ie(new TextDecoder().decode(o??"").trim())};async function se(r){let t=[];for await(let e of r)t.push(e);return t}async function*K(r,t){yield*(await se(r)).sort(t)}async function W(r){for await(let t of r);}async function*S(r,t){for await(let e of r)await t(e)&&(yield e)}async function*J(r,t){let e=0;if(!(t<1)){for await(let n of r)if(yield n,e++,e===t)return}}var C=class{put(t,e,n){return Promise.reject(new Error(".put is not implemented"))}get(t,e){return Promise.reject(new Error(".get is not implemented"))}has(t,e){return Promise.reject(new Error(".has is not implemented"))}delete(t,e){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(t,e={}){for await(let{key:n,value:o}of t)await this.put(n,o,e),yield n}async*getMany(t,e={}){for await(let n of t)yield{key:n,value:await this.get(n,e)}}async*deleteMany(t,e={}){for await(let n of t)await this.delete(n,e),yield n}batch(){let t=[],e=[];return{put(n,o){t.push({key:n,value:o})},delete(n){e.push(n)},commit:async n=>{await W(this.putMany(t,n)),t=[],await W(this.deleteMany(e,n)),e=[]}}}async*_all(t,e){throw new Error("._all is not implemented")}async*_allKeys(t,e){throw new Error("._allKeys is not implemented")}query(t,e){let n=this._all(t,e);if(t.prefix!=null){let o=t.prefix;n=S(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,s)=>S(o,s),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,s)=>K(o,s),n)),t.offset!=null){let o=0,s=t.offset;n=S(n,()=>o++>=s)}return t.limit!=null&&(n=J(n,t.limit)),n}queryKeys(t,e){let n=this._allKeys(t,e);if(t.prefix!=null){let o=t.prefix;n=S(n,s=>s.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,s)=>S(o,s),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,s)=>K(o,s),n)),t.offset!=null){let o=t.offset,s=0;n=S(n,()=>s++>=o)}return t.limit!=null&&(n=J(n,t.limit)),n}};var At=class extends C{constructor(){super(),this.data=new Map}put(t,e){return this.data.set(t.toString(),e),t}get(t){let e=this.data.get(t.toString());if(e==null)throw $();return e}has(t){return this.data.has(t.toString())}delete(t){this.data.delete(t.toString())}*_all(){for(let[t,e]of this.data.entries())yield{key:new h(t),value:e}}*_allKeys(){for(let t of this.data.keys())yield new h(t)}};async function*_(r,t){for await(let e of r)yield t(e)}var Mt=class{constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},et=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Mt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Mt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};function G(r={}){return hn(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function hn(r,t){t=t??{};let e=t.onEnd,n=new et,o,s,i,u=async()=>n.isEmpty()?i?{done:!0}:await new Promise((c,p)=>{s=y=>{s=null,n.push(y);try{c(r(n))}catch(w){p(w)}return o}}):r(n),g=c=>s!=null?s(c):(n.push(c),o),N=c=>(n=new et,s!=null?s({error:c}):(n.push({error:c}),o)),a=c=>{if(i)return o;if(t?.objectMode!==!0&&c?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return g({done:!1,value:c})},f=c=>i?o:(i=!0,c!=null?N(c):g({done:!0})),d=()=>(n=new et,f(),{done:!0}),z=c=>(f(c),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:u,return:d,throw:z,push:a,end:f,get readableLength(){return n.size}},e==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(c){return l.throw(c),e!=null&&(e(c),e=void 0),{done:!0}},return(){return l.return(),e!=null&&(e(),e=void 0),{done:!0}},push:a,end(c){return l.end(c),e!=null&&(e(c),e=void 0),o},get readableLength(){return l.readableLength}},o}async function*rt(...r){let t=G({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async e=>{for await(let n of e)t.push(n)})),t.end()}catch(e){t.end(e)}}),yield*t}var dn=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Re=r=>r!=null&&(typeof r[Symbol.asyncIterator]=="function"||typeof r[Symbol.iterator]=="function"||typeof r.next=="function"),ie=r=>r!=null&&typeof r.sink=="function"&&Re(r.source),pn=r=>t=>{let e=r.sink(t);if(e.then!=null){let n=G({objectMode:!0});return e.then(()=>{n.end()},s=>{n.end(s)}),rt(n,async function*(){yield*r.source,n.end()}())}return r.source};function kt(r,...t){if(ie(r)){let n=r;r=()=>n.source}else if(Re(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&ie(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)ie(e[n])&&(e[n]=pn(e[n]));return dn(...e)}var R=class extends C{constructor(t,e){super(),this.child=t,this.transform=e}async put(t,e,n){return await this.child.put(this.transform.convert(t),e,n),t}async get(t,e){return await this.child.get(this.transform.convert(t),e)}async has(t,e){return await this.child.has(this.transform.convert(t),e)}async delete(t,e){await this.child.delete(this.transform.convert(t),e)}async*putMany(t,e={}){let n=this.transform,o=this.child;yield*kt(t,async function*(s){yield*_(s,({key:i,value:u})=>({key:n.convert(i),value:u}))},async function*(s){yield*o.putMany(s,e)},async function*(s){yield*_(s,i=>n.invert(i))})}async*getMany(t,e={}){let n=this.transform,o=this.child;yield*kt(t,async function*(s){yield*_(s,i=>n.convert(i))},async function*(s){yield*o.getMany(s,e)},async function*(s){yield*_(s,({key:i,value:u})=>({key:n.invert(i),value:u}))})}async*deleteMany(t,e={}){let n=this.transform,o=this.child;yield*kt(t,async function*(s){yield*_(s,i=>n.convert(i))},async function*(s){yield*o.deleteMany(s,e)},async function*(s){yield*_(s,i=>n.invert(i))})}batch(){let t=this.child.batch();return{put:(e,n)=>{t.put(this.transform.convert(e),n)},delete:e=>{t.delete(this.transform.convert(e))},commit:async e=>{await t.commit(e)}}}query(t,e){let n={...t};n.filters=(n.filters??[]).map(s=>({key:i,value:u})=>s({key:this.transform.convert(i),value:u}));let{prefix:o}=t;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(({key:s})=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,u)=>s({key:this.transform.invert(i.key),value:i.value},{key:this.transform.invert(u.key),value:u.value}))),_(this.child.query(n,e),({key:s,value:i})=>({key:this.transform.invert(s),value:i}))}queryKeys(t,e){let n={...t};n.filters=(n.filters??[]).map(s=>i=>s(this.transform.convert(i)));let{prefix:o}=t;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(s=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,u)=>s(this.transform.invert(i),this.transform.invert(u)))),_(this.child.queryKeys(n,e),s=>this.transform.invert(s))}};var nt=new h(St),ot=class extends C{constructor(t,e){super(),this.child=new R(t,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=e}async open(){this.shard=await ot.create(this.child,this.shard)}_convertKey(t){let e=t.toString();return e===nt.toString()?t:new h(this.shard.fun(e)).child(t)}_invertKey(t){return t.toString()===nt.toString()?t:h.withNamespaces(t.list().slice(1))}static async create(t,e){if(!await t.has(nt)){if(e==null)throw Ot(Error("Shard is required when datastore doesn't have a shard key already."));await t.put(nt,new TextEncoder().encode(e.toString()+`
`))}e==null&&(e=await Ft("/",t));let o=await Ft("/",t),s=o.toString(),i=e.toString();if(s!==i)throw new Error(`specified fun ${i} does not match repo shard fun ${s}`);return o}async put(t,e,n){return await this.child.put(t,e,n),t}async get(t,e){return await this.child.get(t,e)}async has(t,e){return await this.child.has(t,e)}async delete(t,e){await this.child.delete(t,e)}async*putMany(t,e={}){yield*this.child.putMany(t,e)}async*getMany(t,e={}){yield*this.child.getMany(t,e)}async*deleteMany(t,e={}){yield*this.child.deleteMany(t,e)}batch(){return this.child.batch()}query(t,e){let o={...t,filters:[({key:s})=>s.toString()!==nt.toString()].concat(t.filters??[])};return this.child.query(o,e)}queryKeys(t,e){let o={...t,filters:[s=>s.toString()!==nt.toString()].concat(t.filters??[])};return this.child.queryKeys(o,e)}};var Ut=class extends C{constructor(t){super(),this.mounts=t.slice()}_lookup(t){for(let e of this.mounts)if(e.prefix.toString()===t.toString()||e.prefix.isAncestorOf(t))return{datastore:e.datastore,mountpoint:e.prefix}}async put(t,e,n){let o=this._lookup(t);if(o==null)throw ut(new Error("No datastore mounted for this key"));return await o.datastore.put(t,e,n),t}async get(t,e={}){let n=this._lookup(t);if(n==null)throw $(new Error("No datastore mounted for this key"));return await n.datastore.get(t,e)}async has(t,e){let n=this._lookup(t);return n==null?await Promise.resolve(!1):await n.datastore.has(t,e)}async delete(t,e){let n=this._lookup(t);if(n==null)throw ct(new Error("No datastore mounted for this key"));await n.datastore.delete(t,e)}batch(){let t={},e=n=>{let o=this._lookup(n);if(o==null)throw new Error("No datastore mounted for this key");let s=o.mountpoint.toString();return t[s]==null&&(t[s]=o.datastore.batch()),{batch:t[s]}};return{put:(n,o)=>{e(n).batch.put(n,o)},delete:n=>{e(n).batch.delete(n)},commit:async n=>{await Promise.all(Object.keys(t).map(async o=>{await t[o].commit(n)}))}}}query(t,e){let n=this.mounts.map(s=>s.datastore.query({prefix:t.prefix,filters:t.filters},e)),o=rt(...n);if(t.filters!=null&&t.filters.forEach(s=>{o=S(o,s)}),t.orders!=null&&t.orders.forEach(s=>{o=K(o,s)}),t.offset!=null){let s=0,i=t.offset;o=S(o,()=>s++>=i)}return t.limit!=null&&(o=J(o,t.limit)),o}queryKeys(t,e){let n=this.mounts.map(s=>s.datastore.queryKeys({prefix:t.prefix,filters:t.filters},e)),o=rt(...n);if(t.filters!=null&&t.filters.forEach(s=>{o=S(o,s)}),t.orders!=null&&t.orders.forEach(s=>{o=K(o,s)}),t.offset!=null){let s=0,i=t.offset;o=S(o,()=>s++>=i)}return t.limit!=null&&(o=J(o,t.limit)),o}};var T=ce(Ke(),1);T.default.formatters.b=r=>r==null?"undefined":U.baseEncode(r);T.default.formatters.t=r=>r==null?"undefined":I.baseEncode(r);T.default.formatters.m=r=>r==null?"undefined":Gt.baseEncode(r);T.default.formatters.p=r=>r==null?"undefined":r.toString();T.default.formatters.c=r=>r==null?"undefined":r.toString();T.default.formatters.k=r=>r==null?"undefined":r.toString();function We(r){return Object.assign((0,T.default)(r),{error:(0,T.default)(`${r}:error`),trace:(0,T.default)(`${r}:trace`)})}var Mn=We("datastore:core:tiered"),_t=class extends C{constructor(t){super(),this.stores=t.slice()}async put(t,e,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(t,e,n)})),t}catch(o){throw ut(o)}}async get(t,e){for(let n of this.stores)try{let o=await n.get(t,e);if(o!=null)return o}catch(o){Mn.error(o)}throw $()}async has(t,e){for(let n of this.stores)if(await n.has(t,e))return!0;return!1}async delete(t,e){try{await Promise.all(this.stores.map(async n=>{await n.delete(t,e)}))}catch(n){throw ct(n)}}async*putMany(t,e={}){let n,o=this.stores.map(s=>{let i=G({objectMode:!0});return W(s.putMany(i,e)).catch(u=>{n=u}),i});try{for await(let s of t){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s.key}}finally{o.forEach(s=>s.end())}}async*deleteMany(t,e={}){let n,o=this.stores.map(s=>{let i=G({objectMode:!0});return W(s.deleteMany(i,e)).catch(u=>{n=u}),i});try{for await(let s of t){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s}}finally{o.forEach(s=>s.end())}}batch(){let t=this.stores.map(e=>e.batch());return{put:(e,n)=>{t.forEach(o=>{o.put(e,n)})},delete:e=>{t.forEach(n=>{n.delete(e)})},commit:async e=>{for(let n of t)await n.commit(e)}}}query(t,e){return this.stores[this.stores.length-1].query(t,e)}queryKeys(t,e){return this.stores[this.stores.length-1].queryKeys(t,e)}};var Tt=class extends R{constructor(t,e){super(t,{convert(n){return e.child(n)},invert(n){if(e.toString()==="/")return n;if(!e.isAncestorOf(n))throw new Error(`Expected prefix: (${e.toString()}) in key: ${n.toString()}`);return new h(n.toString().slice(e.toString().length),!1)}})}};return Ze(kn);})();
"use strict";var DatastoreCore=(()=>{var Xe=Object.create;var pt=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var Qe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty;var mt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),v=(r,t)=>{for(var e in t)pt(r,e,{get:t[e],enumerable:!0})},ce=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qe(t))!Ye.call(r,o)&&o!==e&&pt(r,o,{get:()=>t[o],enumerable:!(n=He(t,o))||n.enumerable});return r};var ue=(r,t,e)=>(e=r!=null?Xe(Ze(r)):{},ce(t||!r||!r.__esModule?pt(e,"default",{value:r,enumerable:!0}):e,r)),qe=r=>ce(pt({},"__esModule",{value:!0}),r);var he=mt((Xn,fe)=>{"use strict";function le(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function tr(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return le(r,e)}catch{e.message=r.message,e.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),le(new o,e)}}fe.exports=tr});var Ve=mt((Ls,je)=>{var ot=1e3,st=ot*60,it=st*60,W=it*24,Nn=W*7,_n=W*365.25;je.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Tn(r);if(e==="number"&&isFinite(r))return t.long?Bn(r):On(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Tn(r){if(r=String(r),!(r.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(r);if(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*_n;case"weeks":case"week":case"w":return e*Nn;case"days":case"day":case"d":return e*W;case"hours":case"hour":case"hrs":case"hr":case"h":return e*it;case"minutes":case"minute":case"mins":case"min":case"m":return e*st;case"seconds":case"second":case"secs":case"sec":case"s":return e*ot;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function On(r){var t=Math.abs(r);return t>=W?Math.round(r/W)+"d":t>=it?Math.round(r/it)+"h":t>=st?Math.round(r/st)+"m":t>=ot?Math.round(r/ot)+"s":r+"ms"}function Bn(r){var t=Math.abs(r);return t>=W?Dt(r,t,W,"day"):t>=it?Dt(r,t,it,"hour"):t>=st?Dt(r,t,st,"minute"):t>=ot?Dt(r,t,ot,"second"):r+" ms"}function Dt(r,t,e,n){var o=t>=e*1.5;return Math.round(r/e)+" "+n+(o?"s":"")}});var We=mt((zs,Ke)=>{function Ln(r){e.debug=e,e.default=e,e.coerce=g,e.disable=s,e.enable=o,e.enabled=i,e.humanize=Ve(),e.destroy=N,Object.keys(r).forEach(c=>{e[c]=r[c]}),e.names=[],e.skips=[],e.formatters={};function t(c){let l=0;for(let d=0;d<c.length;d++)l=(l<<5)-l+c.charCodeAt(d),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(c){let l,d=null,B,f;function u(...p){if(!u.enabled)return;let y=u,w=Number(new Date),A=w-(l||w);y.diff=A,y.prev=l,y.curr=w,l=w,p[0]=e.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let x=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(F,E)=>{if(F==="%%")return"%";x++;let k=e.formatters[E];if(typeof k=="function"){let J=p[x];F=k.call(y,J),p.splice(x,1),x--}return F}),e.formatArgs.call(y,p),(y.log||e.log).apply(y,p)}return u.namespace=c,u.useColors=e.useColors(),u.color=e.selectColor(c),u.extend=n,u.destroy=e.destroy,Object.defineProperty(u,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(B!==e.namespaces&&(B=e.namespaces,f=e.enabled(c)),f),set:p=>{d=p}}),typeof e.init=="function"&&e.init(u),u}function n(c,l){let d=e(this.namespace+(typeof l>"u"?":":l)+c);return d.log=this.log,d}function o(c){e.save(c),e.namespaces=c,e.names=[],e.skips=[];let l,d=(typeof c=="string"?c:"").split(/[\s,]+/),B=d.length;for(l=0;l<B;l++)d[l]&&(c=d[l].replace(/\*/g,".*?"),c[0]==="-"?e.skips.push(new RegExp("^"+c.slice(1)+"$")):e.names.push(new RegExp("^"+c+"$")))}function s(){let c=[...e.names.map(a),...e.skips.map(a).map(l=>"-"+l)].join(",");return e.enable(""),c}function i(c){if(c[c.length-1]==="*")return!0;let l,d;for(l=0,d=e.skips.length;l<d;l++)if(e.skips[l].test(c))return!1;for(l=0,d=e.names.length;l<d;l++)if(e.names[l].test(c))return!0;return!1}function a(c){return c.toString().substring(2,c.toString().length-2).replace(/\.\*\?$/,"*")}function g(c){return c instanceof Error?c.stack||c.message:c}function N(){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 e.enable(e.load()),e}Ke.exports=Ln});var Je=mt((S,Nt)=>{S.formatArgs=Rn;S.save=Pn;S.load=$n;S.useColors=zn;S.storage=jn();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 zn(){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 Rn(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Nt.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}S.log=console.debug||console.log||(()=>{});function Pn(r){try{r?S.storage.setItem("debug",r):S.storage.removeItem("debug")}catch{}}function $n(){let r;try{r=S.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function jn(){try{return localStorage}catch{}}Nt.exports=We()(S);var{formatters:Vn}=Nt.exports;Vn.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Jn={};v(Jn,{BaseDatastore:()=>C,Errors:()=>j,KeyTransformDatastore:()=>R,MemoryDatastore:()=>kt,MountDatastore:()=>It,NamespaceDatastore:()=>Tt,ShardingDatastore:()=>nt,TieredDatastore:()=>_t,shard:()=>se});var j={};v(j,{abortedError:()=>rr,dbDeleteFailedError:()=>at,dbOpenFailedError:()=>Ot,dbReadFailedError:()=>er,dbWriteFailedError:()=>ct,notFoundError:()=>$});var P=ue(he(),1);function Ot(r){return r=r??new Error("Cannot open database"),(0,P.default)(r,"ERR_DB_OPEN_FAILED")}function at(r){return r=r??new Error("Delete failed"),(0,P.default)(r,"ERR_DB_DELETE_FAILED")}function ct(r){return r=r??new Error("Write failed"),(0,P.default)(r,"ERR_DB_WRITE_FAILED")}function er(r){return r=r??new Error("Read failed"),(0,P.default)(r,"ERR_DB_READ_FAILED")}function $(r){return r=r??new Error("Not Found"),(0,P.default)(r,"ERR_NOT_FOUND")}function rr(r){return r=r??new Error("Aborted"),(0,P.default)(r,"ERR_ABORTED")}var se={};v(se,{NextToLast:()=>Et,PREFIX:()=>xt,Prefix:()=>vt,SHARDING_FN:()=>St,ShardBase:()=>Z,Suffix:()=>Ct,parseShardFun:()=>Re,readShardFun:()=>At});var de=(r=21)=>crypto.getRandomValues(new Uint8Array(r)).reduce((t,e)=>(e&=63,e<36?t+=e.toString(36):e<62?t+=(e-26).toString(36).toUpperCase():e>62?t+="-":t+="_",t),"");var Pt={};v(Pt,{identity:()=>cr});function nr(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(e[i]!==255)throw new TypeError(s+" is ambiguous");e[i]=o}var a=r.length,g=r.charAt(0),N=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function l(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 u=0,p=0,y=0,w=f.length;y!==w&&f[y]===0;)y++,u++;for(var A=(w-y)*c+1>>>0,x=new Uint8Array(A);y!==w;){for(var D=f[y],F=0,E=A-1;(D!==0||F<p)&&E!==-1;E--,F++)D+=256*x[E]>>>0,x[E]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");p=F,y++}for(var k=A-p;k!==A&&x[k]===0;)k++;for(var J=g.repeat(u);k<A;++k)J+=r.charAt(x[k]);return J}function d(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var u=0;if(f[u]!==" "){for(var p=0,y=0;f[u]===g;)p++,u++;for(var w=(f.length-u)*N+1>>>0,A=new Uint8Array(w);f[u];){var x=e[f.charCodeAt(u)];if(x===255)return;for(var D=0,F=w-1;(x!==0||D<y)&&F!==-1;F--,D++)x+=a*A[F]>>>0,A[F]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");y=D,u++}if(f[u]!==" "){for(var E=w-y;E!==w&&A[E]===0;)E++;for(var k=new Uint8Array(p+(w-E)),J=p;E!==w;)k[J++]=A[E++];return k}}}function B(f){var u=d(f);if(u)return u;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:d,decode:B}}var or=nr,sr=or,pe=sr;var Zn=new Uint8Array(0);var me=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},_=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 ye=r=>new TextEncoder().encode(r),be=r=>new TextDecoder().decode(r);var Bt=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Lt=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 we(this,t)}},zt=class{constructor(t){this.decoders=t}or(t){return we(this,t)}decode(t){let e=t[0],n=this.decoders[e];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`)}},we=(r,t)=>new zt({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Rt=class{constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Bt(t,e,n),this.decoder=new Lt(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},G=({name:r,prefix:t,encode:e,decode:n})=>new Rt(r,t,e,n),L=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:o}=pe(e,t);return G({prefix:r,name:t,encode:n,decode:s=>_(o(s))})},ir=(r,t,e,n)=>{let o={};for(let c=0;c<t.length;++c)o[t[c]]=c;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*e/8|0),a=0,g=0,N=0;for(let c=0;c<s;++c){let l=o[r[c]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);g=g<<e|l,a+=e,a>=8&&(a-=8,i[N++]=255&g>>a)}if(a>=e||255&g<<8-a)throw new SyntaxError("Unexpected end of data");return i},ar=(r,t,e)=>{let n=t[t.length-1]==="=",o=(1<<e)-1,s="",i=0,a=0;for(let g=0;g<r.length;++g)for(a=a<<8|r[g],i+=8;i>e;)i-=e,s+=t[o&a>>i];if(i&&(s+=t[o&a<<e-i]),n)for(;s.length*e&7;)s+="=";return s},m=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>G({prefix:t,name:r,encode(o){return ar(o,n,e)},decode(o){return ir(o,n,e,r)}});var cr=G({prefix:"\0",name:"identity",encode:r=>be(r),decode:r=>ye(r)});var $t={};v($t,{base2:()=>ur});var ur=m({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jt={};v(jt,{base8:()=>lr});var lr=m({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vt={};v(Vt,{base10:()=>fr});var fr=L({prefix:"9",name:"base10",alphabet:"0123456789"});var Kt={};v(Kt,{base16:()=>hr,base16upper:()=>dr});var hr=m({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dr=m({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wt={};v(Wt,{base32:()=>z,base32hex:()=>br,base32hexpad:()=>wr,base32hexpadupper:()=>xr,base32hexupper:()=>gr,base32pad:()=>mr,base32padupper:()=>yr,base32upper:()=>pr,base32z:()=>vr});var z=m({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pr=m({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=m({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yr=m({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),br=m({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),gr=m({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wr=m({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=m({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vr=m({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Jt={};v(Jt,{base36:()=>Cr,base36upper:()=>Er});var Cr=L({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Er=L({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Gt={};v(Gt,{base58btc:()=>M,base58flickr:()=>Sr});var M=L({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Sr=L({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ht={};v(Ht,{base64:()=>Xt,base64pad:()=>Ar,base64url:()=>Fr,base64urlpad:()=>kr});var Xt=m({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ar=m({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fr=m({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kr=m({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Qt={};v(Qt,{base256emoji:()=>Nr});var xe=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}"),Mr=xe.reduce((r,t,e)=>(r[e]=t,r),[]),Ur=xe.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ir(r){return r.reduce((t,e)=>(t+=Mr[e],t),"")}function Dr(r){let t=[];for(let e of r){let n=Ur[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Nr=G({prefix:"\u{1F680}",name:"base256emoji",encode:Ir,decode:Dr});var te={};v(te,{sha256:()=>Zr,sha512:()=>Yr});var _r=Ee,ve=128,Tr=127,Or=~Tr,Br=Math.pow(2,31);function Ee(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Br;)t[e++]=r&255|ve,r/=128;for(;r&Or;)t[e++]=r&255|ve,r>>>=7;return t[e]=r|0,Ee.bytes=e-n+1,t}var Lr=Zt,zr=128,Ce=127;function Zt(r,n){var e=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw Zt.bytes=0,new RangeError("Could not decode varint");i=r[s++],e+=o<28?(i&Ce)<<o:(i&Ce)*Math.pow(2,o),o+=7}while(i>=zr);return Zt.bytes=s-n,e}var Rr=Math.pow(2,7),Pr=Math.pow(2,14),$r=Math.pow(2,21),jr=Math.pow(2,28),Vr=Math.pow(2,35),Kr=Math.pow(2,42),Wr=Math.pow(2,49),Jr=Math.pow(2,56),Gr=Math.pow(2,63),Xr=function(r){return r<Rr?1:r<Pr?2:r<$r?3:r<jr?4:r<Vr?5:r<Kr?6:r<Wr?7:r<Jr?8:r<Gr?9:10},Hr={encode:_r,decode:Lr,encodingLength:Xr},Qr=Hr,ut=Qr;var lt=(r,t=0)=>[ut.decode(r,t),ut.decode.bytes],X=(r,t,e=0)=>(ut.encode(r,t,e),t),H=r=>ut.encodingLength(r);var V=(r,t)=>{let e=t.byteLength,n=H(r),o=n+H(e),s=new Uint8Array(o+e);return X(r,s,0),X(e,s,n),s.set(t,o),new Q(r,e,t,s)},Se=r=>{let t=_(r),[e,n]=lt(t),[o,s]=lt(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Q(e,o,i,t)},Ae=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&me(r.bytes,e.bytes)}},Q=class{constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};var qt=({name:r,code:t,encode:e})=>new Yt(r,t,e),Yt=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?V(this.code,e):e.then(n=>V(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ke=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),Zr=qt({name:"sha2-256",code:18,encode:ke("SHA-256")}),Yr=qt({name:"sha2-512",code:19,encode:ke("SHA-512")});var ee={};v(ee,{identity:()=>en});var Me=0,qr="identity",Ue=_,tn=r=>V(Me,Ue(r)),en={code:Me,name:qr,encode:Ue,digest:tn};var wo=new TextEncoder,xo=new TextDecoder;var Ie=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return sn(e,re(r),t||M.encoder);default:return an(e,re(r),t||z.encoder)}};var De=new WeakMap,re=r=>{let t=De.get(r);if(t==null){let e=new Map;return De.set(r,e),e}return t},b=class{constructor(t,e,n,o){this.code=e,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:e}=this;if(t!==ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==cn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return b.createV0(e)}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:e}=this.multihash,n=V(t,e);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(t){return b.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Ae(t.multihash,n.multihash)}toString(t){return Ie(this,t)}toJSON(){return{"/":Ie(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 e=t;if(e instanceof b)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:o,multihash:s,bytes:i}=e;return new b(n,o,s,i||Ne(n,o,s.bytes))}else if(e[un]===!0){let{version:n,multihash:o,code:s}=e,i=Se(o);return b.create(n,s,i)}else return null}static create(t,e,n){if(typeof e!="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(e!==ht)throw new Error(`Version 0 CID must use dag-pb (code: ${ht}) block encoding`);return new b(t,e,n,n.bytes)}case 1:{let o=Ne(t,e,n.bytes);return new b(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return b.create(0,ht,t)}static createV1(t,e){return b.create(1,t,e)}static decode(t){let[e,n]=b.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=b.inspectBytes(t),n=e.size-e.multihashSize,o=_(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let s=o.subarray(e.multihashSize-e.digestSize),i=new Q(e.multihashCode,e.digestSize,s,o);return[e.version===0?b.createV0(i):b.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,d]=lt(t.subarray(e));return e+=d,l},o=n(),s=ht;if(o===18?(o=0,e=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=e,a=n(),g=n(),N=e+g,c=N-i;return{version:o,codec:s,multihashCode:a,digestSize:g,multihashSize:c,size:N}}static parse(t,e){let[n,o]=on(t,e),s=b.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return re(s).set(n,t),s}},on=(r,t)=>{switch(r[0]){case"Q":{let e=t||M;return[M.prefix,e.decode(`${M.prefix}${r}`)]}case M.prefix:{let e=t||M;return[M.prefix,e.decode(r)]}case z.prefix:{let e=t||z;return[z.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},sn=(r,t,e)=>{let{prefix:n}=e;if(n!==M.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let s=e.encode(r).slice(1);return t.set(n,s),s}else return o},an=(r,t,e)=>{let{prefix:n}=e,o=t.get(n);if(o==null){let s=e.encode(r);return t.set(n,s),s}else return o},ht=112,cn=18,Ne=(r,t,e)=>{let n=H(r),o=n+H(t),s=new Uint8Array(o+e.byteLength);return X(r,s,0),X(t,s,n),s.set(e,o),s},un=Symbol.for("@ipld/js-cid/CID");var ne={...Pt,...$t,...jt,...Vt,...Kt,...Wt,...Jt,...Gt,...Ht,...Qt},Io={...te,...ee};function bt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function _e(r=0){return globalThis.Buffer?.allocUnsafe!=null?bt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Oe(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Te=Oe("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),oe=Oe("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=_e(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ln={utf8:Te,"utf-8":Te,hex:ne.base16,latin1:oe,ascii:oe,binary:oe,...ne},gt=ln;function Be(r,t="utf8"){let e=gt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}function Le(r,t="utf8"){let e=gt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?bt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var T="/",ze=new TextEncoder().encode(T),wt=ze[0],h=class{constructor(t,e){if(typeof t=="string")this._buf=Le(t);else if(t instanceof Uint8Array)this._buf=t;else throw new Error("Invalid key, should be String of Uint8Array");if(e==null&&(e=!0),e&&this.clean(),this._buf.byteLength===0||this._buf[0]!==wt)throw new Error("Invalid key")}toString(t="utf8"){return Be(this._buf,t)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(t){return new h(t.join(T))}static random(){return new h(de().replace(/-/g,""))}static asKey(t){return t instanceof Uint8Array||typeof t=="string"?new h(t):typeof t.uint8Array=="function"?new h(t.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=ze),this._buf[0]!==wt){let t=new Uint8Array(this._buf.byteLength+1);t.fill(wt,0,1),t.set(this._buf,1),this._buf=t}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===wt;)this._buf=this._buf.subarray(0,-1)}less(t){let e=this.list(),n=t.list();for(let o=0;o<e.length;o++){if(n.length<o+1)return!1;let s=e[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return e.length<n.length}reverse(){return h.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let t=this.namespaces();return t[t.length-1]}list(){return this.toString().split(T).slice(1)}type(){return fn(this.baseNamespace())}name(){return hn(this.baseNamespace())}instance(t){return new h(this.toString()+":"+t)}path(){let t=this.parent().toString();return t.endsWith(T)||(t+=T),t+=this.type(),new h(t)}parent(){let t=this.list();return t.length===1?new h(T):new h(t.slice(0,-1).join(T))}child(t){return this.toString()===T?t:t.toString()===T?this:new h(this.toString()+t.toString(),!1)}isAncestorOf(t){return t.toString()===this.toString()?!1:t.toString().startsWith(this.toString())}isDecendantOf(t){return t.toString()===this.toString()?!1:this.toString().startsWith(t.toString())}isTopLevel(){return this.list().length===1}concat(...t){return h.withNamespaces([...this.namespaces(),...dn(t.map(e=>e.namespaces()))])}};function fn(r){let t=r.split(":");return t.length<2?"":t.slice(0,-1).join(":")}function hn(r){let t=r.split(":");return t[t.length-1]}function dn(r){return[].concat(...r)}var xt="/repo/flatfs/shard/",St="SHARDING",Z=class{constructor(t){this.param=t,this.name="base",this._padding=""}fun(t){return"implement me"}toString(){return`${xt}v1/${this.name}/${this.param}`}},vt=class extends Z{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="prefix"}fun(t){return(t+this._padding).slice(0,this.param)}},Ct=class extends Z{constructor(t){super(t),this._padding="".padStart(t,"_"),this.name="suffix"}fun(t){let e=this._padding+t;return e.slice(e.length-this.param)}},Et=class extends Z{constructor(t){super(t),this._padding="".padStart(t+1,"_"),this.name="next-to-last"}fun(t){let e=this._padding+t,n=e.length-this.param-1;return e.slice(n,n+this.param)}};function Re(r){if(r=r.trim(),r.length===0)throw new Error("empty shard string");if(!r.startsWith(xt))throw new Error(`invalid or no path prefix: ${r}`);let t=r.slice(xt.length).split("/"),e=t[0];if(e!=="v1")throw new Error(`expect 'v1' version, got '${e}'`);let n=t[1];if(t[2]==null||t[2]==="")throw new Error("missing param");let o=parseInt(t[2],10);switch(n){case"prefix":return new vt(o);case"suffix":return new Ct(o);case"next-to-last":return new Et(o);default:throw new Error(`unkown sharding function: ${n}`)}}var At=async(r,t)=>{let e=new h(r).child(new h(St)),o=await(typeof t.getRaw=="function"?t.getRaw.bind(t):t.get.bind(t))(e);return Re(new TextDecoder().decode(o??"").trim())};function pn(r){return r[Symbol.asyncIterator]!=null}function mn(r){if(pn(r))return(async()=>{let e=[];for await(let n of r)e.push(n);return e})();let t=[];for(let e of r)t.push(e);return t}var ie=mn;function yn(r){return r[Symbol.asyncIterator]!=null}function bn(r,t){return yn(r)?async function*(){yield*(await ie(r)).sort(t)}():function*(){yield*ie(r).sort(t)}()}var Y=bn;function gn(r){return r[Symbol.asyncIterator]!=null}function wn(r){if(gn(r))return(async()=>{for await(let t of r);})();for(let t of r);}var q=wn;function xn(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[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(),[e](){return this}}}var Ft=xn;function vn(r){return r[Symbol.asyncIterator]!=null}function Cn(r,t){if(vn(r))return async function*(){for await(let a of r)await t(a)&&(yield a)}();let e=Ft(r),{value:n,done:o}=e.next();if(o===!0)return function*(){}();let s=t(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let a of e)await t(a)&&(yield a)}();let i=t;return function*(){s===!0&&(yield n);for(let a of e)i(a)&&(yield a)}()}var U=Cn;function En(r){return r[Symbol.asyncIterator]!=null}function Sn(r,t){return En(r)?async function*(){let e=0;if(!(t<1)){for await(let n of r)if(yield n,e++,e===t)return}}():function*(){let e=0;if(!(t<1)){for(let n of r)if(yield n,e++,e===t)return}}()}var tt=Sn;var C=class{put(t,e,n){return Promise.reject(new Error(".put is not implemented"))}get(t,e){return Promise.reject(new Error(".get is not implemented"))}has(t,e){return Promise.reject(new Error(".has is not implemented"))}delete(t,e){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(t,e={}){for await(let{key:n,value:o}of t)await this.put(n,o,e),yield n}async*getMany(t,e={}){for await(let n of t)yield{key:n,value:await this.get(n,e)}}async*deleteMany(t,e={}){for await(let n of t)await this.delete(n,e),yield n}batch(){let t=[],e=[];return{put(n,o){t.push({key:n,value:o})},delete(n){e.push(n)},commit:async n=>{await q(this.putMany(t,n)),t=[],await q(this.deleteMany(e,n)),e=[]}}}async*_all(t,e){throw new Error("._all is not implemented")}async*_allKeys(t,e){throw new Error("._allKeys is not implemented")}query(t,e){let n=this._all(t,e);if(t.prefix!=null){let o=t.prefix;n=U(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,s)=>U(o,s),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,s)=>Y(o,s),n)),t.offset!=null){let o=0,s=t.offset;n=U(n,()=>o++>=s)}return t.limit!=null&&(n=tt(n,t.limit)),n}queryKeys(t,e){let n=this._allKeys(t,e);if(t.prefix!=null){let o=t.prefix;n=U(n,s=>s.toString().startsWith(o))}if(Array.isArray(t.filters)&&(n=t.filters.reduce((o,s)=>U(o,s),n)),Array.isArray(t.orders)&&(n=t.orders.reduce((o,s)=>Y(o,s),n)),t.offset!=null){let o=t.offset,s=0;n=U(n,()=>s++>=o)}return t.limit!=null&&(n=tt(n,t.limit)),n}};var kt=class extends C{constructor(){super(),this.data=new Map}put(t,e){return this.data.set(t.toString(),e),t}get(t){let e=this.data.get(t.toString());if(e==null)throw $();return e}has(t){return this.data.has(t.toString())}delete(t){this.data.delete(t.toString())}*_all(){for(let[t,e]of this.data.entries())yield{key:new h(t),value:e}}*_allKeys(){for(let t of this.data.keys())yield new h(t)}};function An(r){return r[Symbol.asyncIterator]!=null}function Fn(r,t){if(An(r))return async function*(){for await(let a of r)yield t(a)}();let e=Ft(r),{value:n,done:o}=e.next();if(o===!0)return function*(){}();let s=t(n);if(typeof s.then=="function")return async function*(){yield await s;for await(let a of e)yield t(a)}();let i=t;return function*(){yield s;for(let a of e)yield i(a)}()}var O=Fn;var Mt=class{constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},et=class{constructor(t={}){this.hwm=t.splitLimit??16,this.head=new Mt(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new Mt(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};function K(r={}){return kn(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function kn(r,t){t=t??{};let e=t.onEnd,n=new et,o,s,i,a=async()=>n.isEmpty()?i?{done:!0}:await new Promise((u,p)=>{s=y=>{s=null,n.push(y);try{u(r(n))}catch(w){p(w)}return o}}):r(n),g=u=>s!=null?s(u):(n.push(u),o),N=u=>(n=new et,s!=null?s({error:u}):(n.push({error:u}),o)),c=u=>{if(i)return o;if(t?.objectMode!==!0&&u?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return g({done:!1,value:u})},l=u=>i?o:(i=!0,u!=null?N(u):g({done:!0})),d=()=>(n=new et,l(),{done:!0}),B=u=>(l(u),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:a,return:d,throw:B,push:c,end:l,get readableLength(){return n.size}},e==null)return o;let f=o;return o={[Symbol.asyncIterator](){return this},next(){return f.next()},throw(u){return f.throw(u),e!=null&&(e(u),e=void 0),{done:!0}},return(){return f.return(),e!=null&&(e(),e=void 0),{done:!0}},push:c,end(u){return f.end(u),e!=null&&(e(u),e=void 0),o},get readableLength(){return f.readableLength}},o}function Mn(r){return r[Symbol.asyncIterator]!=null}function Un(...r){let t=[];for(let e of r)Mn(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=K({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let o of n)e.push(o)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var dt=Un;var In=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},Pe=r=>r?.[Symbol.asyncIterator]!=null,$e=r=>r?.[Symbol.iterator]!=null,ae=r=>r==null?!1:r.sink!=null&&r.source!=null,Dn=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=K({objectMode:!0});e.then(()=>{n.end()},i=>{n.end(i)});let o,s=r.source;if(Pe(s))o=async function*(){yield*s,n.end()};else if($e(s))o=function*(){yield*s,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return dt(n,o())}return r.source};function Ut(r,...t){if(r==null)throw new Error("Empty pipeline");if(ae(r)){let n=r;r=()=>n.source}else if($e(r)||Pe(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&ae(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)ae(e[n])&&(e[n]=Dn(e[n]));return In(...e)}var R=class extends C{constructor(t,e){super(),this.child=t,this.transform=e}async put(t,e,n){return await this.child.put(this.transform.convert(t),e,n),t}async get(t,e){return await this.child.get(this.transform.convert(t),e)}async has(t,e){return await this.child.has(this.transform.convert(t),e)}async delete(t,e){await this.child.delete(this.transform.convert(t),e)}async*putMany(t,e={}){let n=this.transform,o=this.child;yield*Ut(t,async function*(s){yield*O(s,({key:i,value:a})=>({key:n.convert(i),value:a}))},async function*(s){yield*o.putMany(s,e)},async function*(s){yield*O(s,i=>n.invert(i))})}async*getMany(t,e={}){let n=this.transform,o=this.child;yield*Ut(t,async function*(s){yield*O(s,i=>n.convert(i))},async function*(s){yield*o.getMany(s,e)},async function*(s){yield*O(s,({key:i,value:a})=>({key:n.invert(i),value:a}))})}async*deleteMany(t,e={}){let n=this.transform,o=this.child;yield*Ut(t,async function*(s){yield*O(s,i=>n.convert(i))},async function*(s){yield*o.deleteMany(s,e)},async function*(s){yield*O(s,i=>n.invert(i))})}batch(){let t=this.child.batch();return{put:(e,n)=>{t.put(this.transform.convert(e),n)},delete:e=>{t.delete(this.transform.convert(e))},commit:async e=>{await t.commit(e)}}}query(t,e){let n={...t};n.filters=(n.filters??[]).map(s=>({key:i,value:a})=>s({key:this.transform.convert(i),value:a}));let{prefix:o}=t;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(({key:s})=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,a)=>s({key:this.transform.invert(i.key),value:i.value},{key:this.transform.invert(a.key),value:a.value}))),O(this.child.query(n,e),({key:s,value:i})=>({key:this.transform.invert(s),value:i}))}queryKeys(t,e){let n={...t};n.filters=(n.filters??[]).map(s=>i=>s(this.transform.convert(i)));let{prefix:o}=t;return o!=null&&o!=="/"&&(delete n.prefix,n.filters.push(s=>this.transform.invert(s).toString().startsWith(o))),n.orders!=null&&(n.orders=n.orders.map(s=>(i,a)=>s(this.transform.invert(i),this.transform.invert(a)))),O(this.child.queryKeys(n,e),s=>this.transform.invert(s))}};var rt=new h(St),nt=class extends C{constructor(t,e){super(),this.child=new R(t,{convert:this._convertKey.bind(this),invert:this._invertKey.bind(this)}),this.shard=e}async open(){this.shard=await nt.create(this.child,this.shard)}_convertKey(t){let e=t.toString();return e===rt.toString()?t:new h(this.shard.fun(e)).child(t)}_invertKey(t){return t.toString()===rt.toString()?t:h.withNamespaces(t.list().slice(1))}static async create(t,e){if(!await t.has(rt)){if(e==null)throw Ot(Error("Shard is required when datastore doesn't have a shard key already."));await t.put(rt,new TextEncoder().encode(e.toString()+`
`))}e==null&&(e=await At("/",t));let o=await At("/",t),s=o.toString(),i=e.toString();if(s!==i)throw new Error(`specified fun ${i} does not match repo shard fun ${s}`);return o}async put(t,e,n){return await this.child.put(t,e,n),t}async get(t,e){return await this.child.get(t,e)}async has(t,e){return await this.child.has(t,e)}async delete(t,e){await this.child.delete(t,e)}async*putMany(t,e={}){yield*this.child.putMany(t,e)}async*getMany(t,e={}){yield*this.child.getMany(t,e)}async*deleteMany(t,e={}){yield*this.child.deleteMany(t,e)}batch(){return this.child.batch()}query(t,e){let o={...t,filters:[({key:s})=>s.toString()!==rt.toString()].concat(t.filters??[])};return this.child.query(o,e)}queryKeys(t,e){let o={...t,filters:[s=>s.toString()!==rt.toString()].concat(t.filters??[])};return this.child.queryKeys(o,e)}};var It=class extends C{constructor(t){super(),this.mounts=t.slice()}_lookup(t){for(let e of this.mounts)if(e.prefix.toString()===t.toString()||e.prefix.isAncestorOf(t))return{datastore:e.datastore,mountpoint:e.prefix}}async put(t,e,n){let o=this._lookup(t);if(o==null)throw ct(new Error("No datastore mounted for this key"));return await o.datastore.put(t,e,n),t}async get(t,e={}){let n=this._lookup(t);if(n==null)throw $(new Error("No datastore mounted for this key"));return await n.datastore.get(t,e)}async has(t,e){let n=this._lookup(t);return n==null?await Promise.resolve(!1):await n.datastore.has(t,e)}async delete(t,e){let n=this._lookup(t);if(n==null)throw at(new Error("No datastore mounted for this key"));await n.datastore.delete(t,e)}batch(){let t={},e=n=>{let o=this._lookup(n);if(o==null)throw new Error("No datastore mounted for this key");let s=o.mountpoint.toString();return t[s]==null&&(t[s]=o.datastore.batch()),{batch:t[s]}};return{put:(n,o)=>{e(n).batch.put(n,o)},delete:n=>{e(n).batch.delete(n)},commit:async n=>{await Promise.all(Object.keys(t).map(async o=>{await t[o].commit(n)}))}}}query(t,e){let n=this.mounts.map(s=>s.datastore.query({prefix:t.prefix,filters:t.filters},e)),o=dt(...n);if(t.filters!=null&&t.filters.forEach(s=>{o=U(o,s)}),t.orders!=null&&t.orders.forEach(s=>{o=Y(o,s)}),t.offset!=null){let s=0,i=t.offset;o=U(o,()=>s++>=i)}return t.limit!=null&&(o=tt(o,t.limit)),o}queryKeys(t,e){let n=this.mounts.map(s=>s.datastore.queryKeys({prefix:t.prefix,filters:t.filters},e)),o=dt(...n);if(t.filters!=null&&t.filters.forEach(s=>{o=U(o,s)}),t.orders!=null&&t.orders.forEach(s=>{o=Y(o,s)}),t.offset!=null){let s=0,i=t.offset;o=U(o,()=>s++>=i)}return t.limit!=null&&(o=tt(o,t.limit)),o}};var I=ue(Je(),1);I.default.formatters.b=r=>r==null?"undefined":M.baseEncode(r);I.default.formatters.t=r=>r==null?"undefined":z.baseEncode(r);I.default.formatters.m=r=>r==null?"undefined":Xt.baseEncode(r);I.default.formatters.p=r=>r==null?"undefined":r.toString();I.default.formatters.c=r=>r==null?"undefined":r.toString();I.default.formatters.k=r=>r==null?"undefined":r.toString();function Kn(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function Ge(r){let t=Kn(`${r}:trace`);return I.default.enabled(`${r}:trace`)&&I.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,I.default)(`${r}:trace`)),Object.assign((0,I.default)(r),{error:(0,I.default)(`${r}:error`),trace:t})}var Wn=Ge("datastore:core:tiered"),_t=class extends C{constructor(t){super(),this.stores=t.slice()}async put(t,e,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(t,e,n)})),t}catch(o){throw ct(o)}}async get(t,e){for(let n of this.stores)try{let o=await n.get(t,e);if(o!=null)return o}catch(o){Wn.error(o)}throw $()}async has(t,e){for(let n of this.stores)if(await n.has(t,e))return!0;return!1}async delete(t,e){try{await Promise.all(this.stores.map(async n=>{await n.delete(t,e)}))}catch(n){throw at(n)}}async*putMany(t,e={}){let n,o=this.stores.map(s=>{let i=K({objectMode:!0});return q(s.putMany(i,e)).catch(a=>{n=a}),i});try{for await(let s of t){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s.key}}finally{o.forEach(s=>s.end())}}async*deleteMany(t,e={}){let n,o=this.stores.map(s=>{let i=K({objectMode:!0});return q(s.deleteMany(i,e)).catch(a=>{n=a}),i});try{for await(let s of t){if(n!=null)throw n;o.forEach(i=>i.push(s)),yield s}}finally{o.forEach(s=>s.end())}}batch(){let t=this.stores.map(e=>e.batch());return{put:(e,n)=>{t.forEach(o=>{o.put(e,n)})},delete:e=>{t.forEach(n=>{n.delete(e)})},commit:async e=>{for(let n of t)await n.commit(e)}}}query(t,e){return this.stores[this.stores.length-1].query(t,e)}queryKeys(t,e){return this.stores[this.stores.length-1].queryKeys(t,e)}};var Tt=class extends R{constructor(t,e){super(t,{convert(n){return e.child(n)},invert(n){if(e.toString()==="/")return n;if(!e.isAncestorOf(n))throw new Error(`Expected prefix: (${e.toString()}) in key: ${n.toString()}`);return new h(n.toString().slice(e.toString().length),!1)}})}};return qe(Jn);})();
return DatastoreCore}));
{
"name": "datastore-core",
"version": "9.1.0",
"version": "9.1.1",
"description": "Wrapper implementation for interface-datastore",

@@ -99,3 +99,3 @@ "author": "Friedel Ziegelmayer <dignifiedquire@gmail.com>",

"branches": [
"master"
"main"
],

@@ -201,11 +201,11 @@ "plugins": [

"interface-store": "^5.0.0",
"it-all": "^2.0.0",
"it-drain": "^2.0.0",
"it-filter": "^2.0.1",
"it-map": "^2.0.1",
"it-merge": "^2.0.0",
"it-pipe": "^2.0.3",
"it-all": "^3.0.1",
"it-drain": "^3.0.1",
"it-filter": "^3.0.0",
"it-map": "^3.0.1",
"it-merge": "^3.0.0",
"it-pipe": "^3.0.0",
"it-pushable": "^3.0.0",
"it-sort": "^2.0.1",
"it-take": "^2.0.0",
"it-sort": "^3.0.1",
"it-take": "^3.0.1",
"uint8arrays": "^4.0.2"

@@ -212,0 +212,0 @@ },

@@ -6,3 +6,3 @@ # datastore-core <!-- omit in toc -->

[![codecov](https://img.shields.io/codecov/c/github/ipfs/js-stores.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-stores)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-stores/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/js-stores/actions/workflows/js-test-and-release.yml?query=branch%3Amaster)
[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/js-stores/js-test-and-release.yml?branch=main\&style=flat-square)](https://github.com/ipfs/js-stores/actions/workflows/js-test-and-release.yml?query=branch%3Amain)

@@ -9,0 +9,0 @@ > Wrapper implementation for interface-datastore

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc