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

datastore-idb

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datastore-idb - npm Package Compare versions

Comparing version 2.1.4 to 2.1.5

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.DatastoreIdb = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var DatastoreIdb=(()=>{var $t=Object.create;var te=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),x=(t,e)=>{for(var r in e)te(t,r,{get:e[r],enumerable:!0})},Ge=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vt(e))!Jt.call(t,o)&&o!==r&&te(t,o,{get:()=>e[o],enumerable:!(n=Kt(e,o))||n.enumerable});return t};var Xe=(t,e,r)=>(r=t!=null?$t(Wt(t)):{},Ge(e||!t||!t.__esModule?te(r,"default",{value:t,enumerable:!0}):r,t)),Gt=t=>Ge(te({},"__esModule",{value:!0}),t);var Ze=re((Wn,Qe)=>{"use strict";function He(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function Xt(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return He(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),He(new o,r)}}Qe.exports=Xt});var Mt=re(($s,It)=>{var X=1e3,H=X*60,Q=H*60,z=Q*24,En=z*7,vn=z*365.25;It.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Cn(t);if(r==="number"&&isFinite(t))return e.long?An(t):Sn(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Cn(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*vn;case"weeks":case"week":case"w":return r*En;case"days":case"day":case"d":return r*z;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Q;case"minutes":case"minute":case"mins":case"min":case"m":return r*H;case"seconds":case"second":case"secs":case"sec":case"s":return r*X;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Sn(t){var e=Math.abs(t);return e>=z?Math.round(t/z)+"d":e>=Q?Math.round(t/Q)+"h":e>=H?Math.round(t/H)+"m":e>=X?Math.round(t/X)+"s":t+"ms"}function An(t){var e=Math.abs(t);return e>=z?fe(t,e,z,"day"):e>=Q?fe(t,e,Q,"hour"):e>=H?fe(t,e,H,"minute"):e>=X?fe(t,e,X,"second"):t+" ms"}function fe(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var Bt=re((Ks,kt)=>{function Fn(t){r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=o,r.enabled=i,r.humanize=Mt(),r.destroy=w,Object.keys(t).forEach(a=>{r[a]=t[a]}),r.names=[],r.skips=[],r.formatters={};function e(a){let u=0;for(let h=0;h<a.length;h++)u=(u<<5)-u+a.charCodeAt(h),u|=0;return r.colors[Math.abs(u)%r.colors.length]}r.selectColor=e;function r(a){let u,h=null,$,f;function d(...m){if(!d.enabled)return;let y=d,g=Number(new Date),A=g-(u||g);y.diff=A,y.prev=u,y.curr=g,u=g,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let b=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(F,E)=>{if(F==="%%")return"%";b++;let D=r.formatters[E];if(typeof D=="function"){let K=m[b];F=D.call(y,K),m.splice(b,1),b--}return F}),r.formatArgs.call(y,m),(y.log||r.log).apply(y,m)}return d.namespace=a,d.useColors=r.useColors(),d.color=r.selectColor(a),d.extend=n,d.destroy=r.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:($!==r.namespaces&&($=r.namespaces,f=r.enabled(a)),f),set:m=>{h=m}}),typeof r.init=="function"&&r.init(d),d}function n(a,u){let h=r(this.namespace+(typeof u>"u"?":":u)+a);return h.log=this.log,h}function o(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let u,h=(typeof a=="string"?a:"").split(/[\s,]+/),$=h.length;for(u=0;u<$;u++)h[u]&&(a=h[u].replace(/\*/g,".*?"),a[0]==="-"?r.skips.push(new RegExp("^"+a.slice(1)+"$")):r.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...r.names.map(c),...r.skips.map(c).map(u=>"-"+u)].join(",");return r.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let u,h;for(u=0,h=r.skips.length;u<h;u++)if(r.skips[u].test(a))return!1;for(u=0,h=r.names.length;u<h;u++)if(r.names[u].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function w(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}kt.exports=Fn});var Tt=re((C,de)=>{C.formatArgs=In;C.save=Mn;C.load=kn;C.useColors=Dn;C.storage=Bn();C.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();C.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 Dn(){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 In(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+de.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}C.log=console.debug||console.log||(()=>{});function Mn(t){try{t?C.storage.setItem("debug",t):C.storage.removeItem("debug")}catch{}}function kn(){let t;try{t=C.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Bn(){try{return localStorage}catch{}}de.exports=Bt()(C);var{formatters:Tn}=de.exports;Tn.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Kn={};x(Kn,{IDBDatastore:()=>Je});var v={};x(v,{abortedError:()=>Qt,dbDeleteFailedError:()=>pe,dbOpenFailedError:()=>Ye,dbReadFailedError:()=>Ht,dbWriteFailedError:()=>me,notFoundError:()=>ne});var P=Xe(Ze(),1);function Ye(t){return t=t??new Error("Cannot open database"),(0,P.default)(t,"ERR_DB_OPEN_FAILED")}function pe(t){return t=t??new Error("Delete failed"),(0,P.default)(t,"ERR_DB_DELETE_FAILED")}function me(t){return t=t??new Error("Write failed"),(0,P.default)(t,"ERR_DB_WRITE_FAILED")}function Ht(t){return t=t??new Error("Read failed"),(0,P.default)(t,"ERR_DB_READ_FAILED")}function ne(t){return t=t??new Error("Not Found"),(0,P.default)(t,"ERR_NOT_FOUND")}function Qt(t){return t=t??new Error("Aborted"),(0,P.default)(t,"ERR_ABORTED")}var qe=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");function oe(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}var xe={};x(xe,{base10:()=>rr});function Zt(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=t.length,l=t.charAt(0),w=Math.log(c)/Math.log(256),a=Math.log(256)/Math.log(c);function u(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 d=0,m=0,y=0,g=f.length;y!==g&&f[y]===0;)y++,d++;for(var A=(g-y)*a+1>>>0,b=new Uint8Array(A);y!==g;){for(var M=f[y],F=0,E=A-1;(M!==0||F<m)&&E!==-1;E--,F++)M+=256*b[E]>>>0,b[E]=M%c>>>0,M=M/c>>>0;if(M!==0)throw new Error("Non-zero carry");m=F,y++}for(var D=A-m;D!==A&&b[D]===0;)D++;for(var K=l.repeat(d);D<A;++D)K+=t.charAt(b[D]);return K}function h(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var d=0;if(f[d]!==" "){for(var m=0,y=0;f[d]===l;)m++,d++;for(var g=(f.length-d)*w+1>>>0,A=new Uint8Array(g);f[d];){var b=r[f.charCodeAt(d)];if(b===255)return;for(var M=0,F=g-1;(b!==0||M<y)&&F!==-1;F--,M++)b+=c*A[F]>>>0,A[F]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");y=M,d++}if(f[d]!==" "){for(var E=g-y;E!==g&&A[E]===0;)E++;for(var D=new Uint8Array(m+(g-E)),K=m;E!==g;)D[K++]=A[E++];return D}}}function $(f){var d=h(f);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:$}}var Yt=Zt,qt=Yt,et=qt;var Hn=new Uint8Array(0);var tt=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},N=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var rt=t=>new TextEncoder().encode(t),nt=t=>new TextDecoder().decode(t);var ye=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},be=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return st(this,e)}},we=class{constructor(e){this.decoders=e}or(e){return st(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},st=(t,e)=>new we({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),ge=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ye(e,r,n),this.decoder=new be(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},V=({name:t,prefix:e,encode:r,decode:n})=>new ge(t,e,r,n),O=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=et(r,e);return V({prefix:t,name:e,encode:n,decode:s=>N(o(s))})},er=(t,e,r,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,l=0,w=0;for(let a=0;a<s;++a){let u=o[t[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<r|u,c+=r,c>=8&&(c-=8,i[w++]=255&l>>c)}if(c>=r||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return i},tr=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],i+=8;i>r;)i-=r,s+=e[o&c>>i];if(i&&(s+=e[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s},p=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>V({prefix:e,name:t,encode(o){return tr(o,n,r)},decode(o){return er(o,n,r,t)}});var rr=O({prefix:"9",name:"base10",alphabet:"0123456789"});var Ee={};x(Ee,{base16:()=>nr,base16upper:()=>or});var nr=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),or=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ve={};x(ve,{base2:()=>sr});var sr=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ce={};x(Ce,{base256emoji:()=>lr});var it=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}"),ir=it.reduce((t,e,r)=>(t[r]=e,t),[]),ar=it.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function cr(t){return t.reduce((e,r)=>(e+=ir[r],e),"")}function ur(t){let e=[];for(let r of t){let n=ar[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var lr=V({prefix:"\u{1F680}",name:"base256emoji",encode:cr,decode:ur});var Se={};x(Se,{base32:()=>_,base32hex:()=>pr,base32hexpad:()=>yr,base32hexpadupper:()=>br,base32hexupper:()=>mr,base32pad:()=>dr,base32padupper:()=>hr,base32upper:()=>fr,base32z:()=>wr});var _=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fr=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),dr=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hr=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pr=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),mr=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yr=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),br=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wr=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ae={};x(Ae,{base36:()=>gr,base36upper:()=>xr});var gr=O({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xr=O({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fe={};x(Fe,{base58btc:()=>I,base58flickr:()=>Er});var I=O({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Er=O({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ie={};x(Ie,{base64:()=>De,base64pad:()=>vr,base64url:()=>Cr,base64urlpad:()=>Sr});var De=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),vr=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cr=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Sr=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Me={};x(Me,{base8:()=>Ar});var Ar=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ke={};x(ke,{identity:()=>Fr});var Fr=V({prefix:"\0",name:"identity",encode:t=>nt(t),decode:t=>rt(t)});var lo=new TextEncoder,fo=new TextDecoder;var Te={};x(Te,{identity:()=>Hr});var Mr=ut,at=128,kr=127,Br=~kr,Tr=Math.pow(2,31);function ut(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Tr;)e[r++]=t&255|at,t/=128;for(;t&Br;)e[r++]=t&255|at,t>>>=7;return e[r]=t|0,ut.bytes=r-n+1,e}var Ur=Be,Nr=128,ct=127;function Be(t,n){var r=0,n=n||0,o=0,s=n,i,c=t.length;do{if(s>=c)throw Be.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&ct)<<o:(i&ct)*Math.pow(2,o),o+=7}while(i>=Nr);return Be.bytes=s-n,r}var Lr=Math.pow(2,7),Or=Math.pow(2,14),_r=Math.pow(2,21),Pr=Math.pow(2,28),Rr=Math.pow(2,35),jr=Math.pow(2,42),zr=Math.pow(2,49),$r=Math.pow(2,56),Kr=Math.pow(2,63),Vr=function(t){return t<Lr?1:t<Or?2:t<_r?3:t<Pr?4:t<Rr?5:t<jr?6:t<zr?7:t<$r?8:t<Kr?9:10},Wr={encode:Mr,decode:Ur,encodingLength:Vr},Jr=Wr,Z=Jr;var Y=(t,e=0)=>[Z.decode(t,e),Z.decode.bytes],W=(t,e,r=0)=>(Z.encode(t,e,r),e),J=t=>Z.encodingLength(t);var R=(t,e)=>{let r=e.byteLength,n=J(t),o=n+J(r),s=new Uint8Array(o+r);return W(t,s,0),W(r,s,n),s.set(e,o),new G(t,r,e,s)},lt=t=>{let e=N(t),[r,n]=Y(e),[o,s]=Y(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new G(r,o,i,e)},ft=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&tt(t.bytes,r.bytes)}},G=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var dt=0,Gr="identity",ht=N,Xr=t=>R(dt,ht(t)),Hr={code:dt,name:Gr,encode:ht,digest:Xr};var Le={};x(Le,{sha256:()=>Qr,sha512:()=>Zr});var Ne=({name:t,code:e,encode:r})=>new Ue(t,e,r),Ue=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?R(this.code,r):r.then(n=>R(this.code,n))}else throw Error("Unknown type, must be binary type")}};var mt=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Qr=Ne({name:"sha2-256",code:18,encode:mt("SHA-256")}),Zr=Ne({name:"sha2-512",code:19,encode:mt("SHA-512")});var yt=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return qr(r,Oe(t),e||I.encoder);default:return en(r,Oe(t),e||_.encoder)}};var bt=new WeakMap,Oe=t=>{let e=bt.get(t);if(e==null){let r=new Map;return bt.set(t,r),r}return e},ie=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ee)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==tn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=R(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&ft(e.multihash,n.multihash)}toString(e){return yt(this,e)}toJSON(){return{"/":yt(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i||wt(n,o,s.bytes))}else if(r[rn]===!0){let{version:n,multihash:o,code:s}=r,i=lt(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==ee)throw new Error(`Version 0 CID must use dag-pb (code: ${ee}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=wt(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ee,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=N(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new G(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[u,h]=Y(e.subarray(r));return r+=h,u},o=n(),s=ee;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),l=n(),w=r+l,a=w-i;return{version:o,codec:s,multihashCode:c,digestSize:l,multihashSize:a,size:w}}static parse(e,r){let[n,o]=Yr(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oe(s).set(n,e),s}},Yr=(t,e)=>{switch(t[0]){case"Q":{let r=e||I;return[I.prefix,r.decode(`${I.prefix}${t}`)]}case I.prefix:{let r=e||I;return[I.prefix,r.decode(t)]}case _.prefix:{let r=e||_;return[_.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},qr=(t,e,r)=>{let{prefix:n}=r;if(n!==I.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},en=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},ee=112,tn=18,wt=(t,e,r)=>{let n=J(t),o=n+J(e),s=new Uint8Array(o+r.byteLength);return W(t,s,0),W(e,s,n),s.set(r,o),s},rn=Symbol.for("@ipld/js-cid/CID");var _e={...ke,...ve,...Me,...xe,...Ee,...Se,...Ae,...Fe,...Ie,...Ce},Io={...Le,...Te};function gt(t=0){return globalThis.Buffer?.allocUnsafe!=null?oe(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Et(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var xt=Et("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Pe=Et("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=gt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),nn={utf8:xt,"utf-8":xt,hex:_e.base16,latin1:Pe,ascii:Pe,binary:Pe,..._e},ae=nn;function vt(t,e="utf8"){let r=ae[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?oe(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Ct(t,e="utf8"){let r=ae[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var L="/",St=new TextEncoder().encode(L),ce=St[0],T=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=vt(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==ce)throw new Error("Invalid key")}toString(e="utf8"){return Ct(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(L))}static random(){return new t(qe().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=St),this._buf[0]!==ce){let e=new Uint8Array(this._buf.byteLength+1);e.fill(ce,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===ce;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let s=r[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(L).slice(1)}type(){return on(this.baseNamespace())}name(){return sn(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(L)||(e+=L),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(L):new t(e.slice(0,-1).join(L))}child(e){return this.toString()===L?e:e.toString()===L?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...an(e.map(r=>r.namespaces()))])}};function on(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function sn(t){let e=t.split(":");return e[e.length-1]}function an(t){return[].concat(...t)}var At="SHARDING";function un(t){return t[Symbol.asyncIterator]!=null}function ln(t){if(un(t))return(async()=>{for await(let e of t);})();for(let e of t);}var ue=ln;function fn(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[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(),[r](){return this}}}var Re=fn;function dn(t){return t[Symbol.asyncIterator]!=null}function hn(t,e){if(dn(t))return async function*(){for await(let c of t)await e(c)&&(yield c)}();let r=Re(t),{value:n,done:o}=r.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 r)await e(c)&&(yield c)}();let i=e;return function*(){s===!0&&(yield n);for(let c of r)i(c)&&(yield c)}()}var k=hn;function pn(t){return t[Symbol.asyncIterator]!=null}function mn(t){if(pn(t))return(async()=>{let r=[];for await(let n of t)r.push(n);return r})();let e=[];for(let r of t)e.push(r);return e}var je=mn;function yn(t){return t[Symbol.asyncIterator]!=null}function bn(t,e){return yn(t)?async function*(){yield*(await je(t)).sort(e)}():function*(){yield*je(t).sort(e)}()}var j=bn;function wn(t){return t[Symbol.asyncIterator]!=null}function gn(t,e){return wn(t)?async function*(){let r=0;if(!(e<1)){for await(let n of t)if(yield n,r++,r===e)return}}():function*(){let r=0;if(!(e<1)){for(let n of t)if(yield n,r++,r===e)return}}()}var le=gn;var U=class{put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}get(e,r){return Promise.reject(new Error(".get is not implemented"))}has(e,r){return Promise.reject(new Error(".has is not implemented"))}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,r={}){for await(let{key:n,value:o}of e)await this.put(n,o,r),yield n}async*getMany(e,r={}){for await(let n of e)yield{key:n,value:await this.get(n,r)}}async*deleteMany(e,r={}){for await(let n of e)await this.delete(n,r),yield n}batch(){let e=[],r=[];return{put(n,o){e.push({key:n,value:o})},delete(n){r.push(n)},commit:async n=>{await ue(this.putMany(e,n)),e=[],await ue(this.deleteMany(r,n)),r=[]}}}async*_all(e,r){throw new Error("._all is not implemented")}async*_allKeys(e,r){throw new Error("._allKeys is not implemented")}query(e,r){let n=this._all(e,r);if(e.prefix!=null){let o=e.prefix;n=k(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>k(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>j(o,s),n)),e.offset!=null){let o=0,s=e.offset;n=k(n,()=>o++>=s)}return e.limit!=null&&(n=le(n,e.limit)),n}queryKeys(e,r){let n=this._allKeys(e,r);if(e.prefix!=null){let o=e.prefix;n=k(n,s=>s.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>k(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>j(o,s),n)),e.offset!=null){let o=e.offset,s=0;n=k(n,()=>s++>=o)}return e.limit!=null&&(n=le(n,e.limit)),n}};var Ns=new T(At);var S=Xe(Tt(),1);S.default.formatters.b=t=>t==null?"undefined":I.baseEncode(t);S.default.formatters.t=t=>t==null?"undefined":_.baseEncode(t);S.default.formatters.m=t=>t==null?"undefined":De.baseEncode(t);S.default.formatters.p=t=>t==null?"undefined":t.toString();S.default.formatters.c=t=>t==null?"undefined":t.toString();S.default.formatters.k=t=>t==null?"undefined":t.toString();S.default.formatters.a=t=>t==null?"undefined":t.toString();function Un(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Ut(t){let e=Un(`${t}:trace`);return S.default.enabled(`${t}:trace`)&&S.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,S.default)(`${t}:trace`)),Object.assign((0,S.default)(t),{error:(0,S.default)(`${t}:error`),trace:e})}var Ys=Ut("datastore:core:tiered");var Nn=(t,e)=>e.some(r=>t instanceof r),Nt,Lt;function Ln(){return Nt||(Nt=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function On(){return Lt||(Lt=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ot=new WeakMap,$e=new WeakMap,_t=new WeakMap,ze=new WeakMap,Ve=new WeakMap;function _n(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",s),t.removeEventListener("error",i)},s=()=>{r(B(t.result)),o()},i=()=>{n(t.error),o()};t.addEventListener("success",s),t.addEventListener("error",i)});return e.then(r=>{r instanceof IDBCursor&&Ot.set(r,t)}).catch(()=>{}),Ve.set(e,t),e}function Pn(t){if($e.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",i),t.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",s),t.addEventListener("error",i),t.addEventListener("abort",i)});$e.set(t,e)}var Ke={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return $e.get(t);if(e==="objectStoreNames")return t.objectStoreNames||_t.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return B(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Pt(t){Ke=t(Ke)}function Rn(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(he(this),e,...r);return _t.set(n,e.sort?e.sort():[e]),B(n)}:On().includes(t)?function(...e){return t.apply(he(this),e),B(Ot.get(this))}:function(...e){return B(t.apply(he(this),e))}}function jn(t){return typeof t=="function"?Rn(t):(t instanceof IDBTransaction&&Pn(t),Nn(t,Ln())?new Proxy(t,Ke):t)}function B(t){if(t instanceof IDBRequest)return _n(t);if(ze.has(t))return ze.get(t);let e=jn(t);return e!==t&&(ze.set(t,e),Ve.set(e,t)),e}var he=t=>Ve.get(t);function jt(t,e,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(t,e),c=B(i);return n&&i.addEventListener("upgradeneeded",l=>{n(B(i.result),l.oldVersion,l.newVersion,B(i.transaction),l)}),r&&i.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),c.then(l=>{s&&l.addEventListener("close",()=>s()),o&&l.addEventListener("versionchange",w=>o(w.oldVersion,w.newVersion,w))}).catch(()=>{}),c}function zt(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),B(r).then(()=>{})}var zn=["get","getKey","getAll","getAllKeys","count"],$n=["put","add","delete","clear"],We=new Map;function Rt(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(We.get(e))return We.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=$n.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||zn.includes(r)))return;let s=async function(i,...c){let l=this.transaction(i,o?"readwrite":"readonly"),w=l.store;return n&&(w=w.index(c.shift())),(await Promise.all([w[r](...c),o&&l.done]))[0]};return We.set(e,s),s}Pt(t=>({...t,get:(e,r,n)=>Rt(e,r)||t.get(e,r,n),has:(e,r)=>!!Rt(e,r)||t.has(e,r)}));var Je=class extends U{location;version;db;constructor(e,r={}){super(),this.location=`${r.prefix??""}${e}`,this.version=r.version??1}async open(){try{let e=this.location;this.db=await jt(e,this.version,{upgrade(r){r.createObjectStore(e)}})}catch(e){throw v.dbOpenFailedError(e)}}async close(){this.db?.close()}async put(e,r){if(this.db==null)throw new Error("Datastore needs to be opened.");try{return await this.db.put(this.location,r,e.toString()),e}catch(n){throw v.dbWriteFailedError(n)}}async get(e){if(this.db==null)throw new Error("Datastore needs to be opened.");let r;try{r=await this.db.get(this.location,e.toString())}catch(n){throw v.dbReadFailedError(n)}if(r===void 0)throw v.notFoundError();return r}async has(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return!!await this.db.getKey(this.location,e.toString())}catch(r){throw v.dbReadFailedError(r)}}async delete(e){if(this.db==null)throw new Error("Datastore needs to be opened.");try{await this.db.delete(this.location,e.toString())}catch(r){throw v.dbWriteFailedError(r)}}batch(){let e=[],r=[];return{put(n,o){e.push({key:n,value:o})},delete(n){r.push(n)},commit:async()=>{if(this.db==null)throw new Error("Datastore needs to be opened.");let n=this.db.transaction(this.location,"readwrite");try{let o=e.filter(({key:s})=>r.find(i=>i.toString()===s.toString())==null).map(s=>async()=>{await n.store.put(s.value,s.key.toString())}).concat(r.map(s=>async()=>{await n.store.delete(s.toString())})).concat(async()=>{await n.done});await Promise.all(o.map(async s=>{await s()}))}catch{n.abort()}}}}async*query(e){let r=this.#e(e,(n,o)=>({key:n,value:o}));Array.isArray(e.filters)&&(r=e.filters.reduce((n,o)=>k(n,o),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((n,o)=>j(n,o),r)),yield*r}async*queryKeys(e){let r=this.#e(e,n=>n);Array.isArray(e.filters)&&(r=e.filters.reduce((n,o)=>k(n,o),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((n,o)=>j(n,o),r)),yield*r}async*#e(e,r){if(this.db==null)throw new Error("Datastore needs to be opened.");let n=0,o=-1;for(let s of await this.db.getAllKeys(this.location)){if(e.prefix!=null&&!s.toString().startsWith(e.prefix))continue;if(e.limit!=null&&n===e.limit)return;if(o++,e.offset!=null&&o<e.offset)continue;let i=new T(s.toString()),c;try{c=await this.get(i)}catch(l){if(l.code!=="ERR_NOT_FOUND")throw l;continue}c!=null&&(yield r(i,c),n++)}}async destroy(){await zt(this.location)}};return Gt(Kn);})();
"use strict";var DatastoreIdb=(()=>{var zt=Object.create;var te=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,Jt=Object.prototype.hasOwnProperty;var re=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),x=(t,e)=>{for(var r in e)te(t,r,{get:e[r],enumerable:!0})},Ge=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Vt(e))!Jt.call(t,o)&&o!==r&&te(t,o,{get:()=>e[o],enumerable:!(n=Kt(e,o))||n.enumerable});return t};var Xe=(t,e,r)=>(r=t!=null?zt(Wt(t)):{},Ge(e||!t||!t.__esModule?te(r,"default",{value:t,enumerable:!0}):r,t)),Gt=t=>Ge(te({},"__esModule",{value:!0}),t);var Ze=re((Wn,Qe)=>{"use strict";function He(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function Xt(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return He(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),He(new o,r)}}Qe.exports=Xt});var Mt=re((zs,It)=>{var X=1e3,H=X*60,Q=H*60,$=Q*24,En=$*7,Cn=$*365.25;It.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return vn(t);if(r==="number"&&isFinite(t))return e.long?An(t):Sn(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function vn(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Cn;case"weeks":case"week":case"w":return r*En;case"days":case"day":case"d":return r*$;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Q;case"minutes":case"minute":case"mins":case"min":case"m":return r*H;case"seconds":case"second":case"secs":case"sec":case"s":return r*X;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Sn(t){var e=Math.abs(t);return e>=$?Math.round(t/$)+"d":e>=Q?Math.round(t/Q)+"h":e>=H?Math.round(t/H)+"m":e>=X?Math.round(t/X)+"s":t+"ms"}function An(t){var e=Math.abs(t);return e>=$?fe(t,e,$,"day"):e>=Q?fe(t,e,Q,"hour"):e>=H?fe(t,e,H,"minute"):e>=X?fe(t,e,X,"second"):t+" ms"}function fe(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var Bt=re((Ks,kt)=>{function Fn(t){r.debug=r,r.default=r,r.coerce=l,r.disable=s,r.enable=o,r.enabled=i,r.humanize=Mt(),r.destroy=g,Object.keys(t).forEach(a=>{r[a]=t[a]}),r.names=[],r.skips=[],r.formatters={};function e(a){let u=0;for(let h=0;h<a.length;h++)u=(u<<5)-u+a.charCodeAt(h),u|=0;return r.colors[Math.abs(u)%r.colors.length]}r.selectColor=e;function r(a){let u,h=null,z,f;function d(...m){if(!d.enabled)return;let y=d,w=Number(new Date),A=w-(u||w);y.diff=A,y.prev=u,y.curr=w,u=w,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let b=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(F,E)=>{if(F==="%%")return"%";b++;let D=r.formatters[E];if(typeof D=="function"){let K=m[b];F=D.call(y,K),m.splice(b,1),b--}return F}),r.formatArgs.call(y,m),(y.log||r.log).apply(y,m)}return d.namespace=a,d.useColors=r.useColors(),d.color=r.selectColor(a),d.extend=n,d.destroy=r.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(z!==r.namespaces&&(z=r.namespaces,f=r.enabled(a)),f),set:m=>{h=m}}),typeof r.init=="function"&&r.init(d),d}function n(a,u){let h=r(this.namespace+(typeof u>"u"?":":u)+a);return h.log=this.log,h}function o(a){r.save(a),r.namespaces=a,r.names=[],r.skips=[];let u,h=(typeof a=="string"?a:"").split(/[\s,]+/),z=h.length;for(u=0;u<z;u++)h[u]&&(a=h[u].replace(/\*/g,".*?"),a[0]==="-"?r.skips.push(new RegExp("^"+a.slice(1)+"$")):r.names.push(new RegExp("^"+a+"$")))}function s(){let a=[...r.names.map(c),...r.skips.map(c).map(u=>"-"+u)].join(",");return r.enable(""),a}function i(a){if(a[a.length-1]==="*")return!0;let u,h;for(u=0,h=r.skips.length;u<h;u++)if(r.skips[u].test(a))return!1;for(u=0,h=r.names.length;u<h;u++)if(r.names[u].test(a))return!0;return!1}function c(a){return a.toString().substring(2,a.toString().length-2).replace(/\.\*\?$/,"*")}function l(a){return a instanceof Error?a.stack||a.message:a}function g(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}kt.exports=Fn});var Lt=re((v,de)=>{v.formatArgs=In;v.save=Mn;v.load=kn;v.useColors=Dn;v.storage=Bn();v.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();v.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Dn(){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 In(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+de.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}v.log=console.debug||console.log||(()=>{});function Mn(t){try{t?v.storage.setItem("debug",t):v.storage.removeItem("debug")}catch{}}function kn(){let t;try{t=v.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Bn(){try{return localStorage}catch{}}de.exports=Bt()(v);var{formatters:Ln}=de.exports;Ln.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Kn={};x(Kn,{IDBDatastore:()=>Je});var C={};x(C,{abortedError:()=>Qt,dbDeleteFailedError:()=>pe,dbOpenFailedError:()=>Ye,dbReadFailedError:()=>Ht,dbWriteFailedError:()=>me,notFoundError:()=>ne});var P=Xe(Ze(),1);function Ye(t){return t=t??new Error("Cannot open database"),(0,P.default)(t,"ERR_DB_OPEN_FAILED")}function pe(t){return t=t??new Error("Delete failed"),(0,P.default)(t,"ERR_DB_DELETE_FAILED")}function me(t){return t=t??new Error("Write failed"),(0,P.default)(t,"ERR_DB_WRITE_FAILED")}function Ht(t){return t=t??new Error("Read failed"),(0,P.default)(t,"ERR_DB_READ_FAILED")}function ne(t){return t=t??new Error("Not Found"),(0,P.default)(t,"ERR_NOT_FOUND")}function Qt(t){return t=t??new Error("Aborted"),(0,P.default)(t,"ERR_ABORTED")}var qe=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce((e,r)=>(r&=63,r<36?e+=r.toString(36):r<62?e+=(r-26).toString(36).toUpperCase():r>62?e+="-":e+="_",e),"");function oe(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}var xe={};x(xe,{base10:()=>rr});function Zt(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var c=t.length,l=t.charAt(0),g=Math.log(c)/Math.log(256),a=Math.log(256)/Math.log(c);function u(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 d=0,m=0,y=0,w=f.length;y!==w&&f[y]===0;)y++,d++;for(var A=(w-y)*a+1>>>0,b=new Uint8Array(A);y!==w;){for(var M=f[y],F=0,E=A-1;(M!==0||F<m)&&E!==-1;E--,F++)M+=256*b[E]>>>0,b[E]=M%c>>>0,M=M/c>>>0;if(M!==0)throw new Error("Non-zero carry");m=F,y++}for(var D=A-m;D!==A&&b[D]===0;)D++;for(var K=l.repeat(d);D<A;++D)K+=t.charAt(b[D]);return K}function h(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var d=0;if(f[d]!==" "){for(var m=0,y=0;f[d]===l;)m++,d++;for(var w=(f.length-d)*g+1>>>0,A=new Uint8Array(w);f[d];){var b=r[f.charCodeAt(d)];if(b===255)return;for(var M=0,F=w-1;(b!==0||M<y)&&F!==-1;F--,M++)b+=c*A[F]>>>0,A[F]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");y=M,d++}if(f[d]!==" "){for(var E=w-y;E!==w&&A[E]===0;)E++;for(var D=new Uint8Array(m+(w-E)),K=m;E!==w;)D[K++]=A[E++];return D}}}function z(f){var d=h(f);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:z}}var Yt=Zt,qt=Yt,et=qt;var Hn=new Uint8Array(0);var tt=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},U=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var rt=t=>new TextEncoder().encode(t),nt=t=>new TextDecoder().decode(t);var ye=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},be=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return st(this,e)}},ge=class{constructor(e){this.decoders=e}or(e){return st(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},st=(t,e)=>new ge({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),we=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ye(e,r,n),this.decoder=new be(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},V=({name:t,prefix:e,encode:r,decode:n})=>new we(t,e,r,n),O=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=et(r,e);return V({prefix:t,name:e,encode:n,decode:s=>U(o(s))})},er=(t,e,r,n)=>{let o={};for(let a=0;a<e.length;++a)o[e[a]]=a;let s=t.length;for(;t[s-1]==="=";)--s;let i=new Uint8Array(s*r/8|0),c=0,l=0,g=0;for(let a=0;a<s;++a){let u=o[t[a]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<r|u,c+=r,c>=8&&(c-=8,i[g++]=255&l>>c)}if(c>=r||255&l<<8-c)throw new SyntaxError("Unexpected end of data");return i},tr=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,s="",i=0,c=0;for(let l=0;l<t.length;++l)for(c=c<<8|t[l],i+=8;i>r;)i-=r,s+=e[o&c>>i];if(i&&(s+=e[o&c<<r-i]),n)for(;s.length*r&7;)s+="=";return s},p=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>V({prefix:e,name:t,encode(o){return tr(o,n,r)},decode(o){return er(o,n,r,t)}});var rr=O({prefix:"9",name:"base10",alphabet:"0123456789"});var Ee={};x(Ee,{base16:()=>nr,base16upper:()=>or});var nr=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),or=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ce={};x(Ce,{base2:()=>sr});var sr=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ve={};x(ve,{base256emoji:()=>lr});var it=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}"),ir=it.reduce((t,e,r)=>(t[r]=e,t),[]),ar=it.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function cr(t){return t.reduce((e,r)=>(e+=ir[r],e),"")}function ur(t){let e=[];for(let r of t){let n=ar[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}var lr=V({prefix:"\u{1F680}",name:"base256emoji",encode:cr,decode:ur});var Se={};x(Se,{base32:()=>_,base32hex:()=>pr,base32hexpad:()=>yr,base32hexpadupper:()=>br,base32hexupper:()=>mr,base32pad:()=>dr,base32padupper:()=>hr,base32upper:()=>fr,base32z:()=>gr});var _=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),fr=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),dr=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),hr=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),pr=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),mr=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),yr=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),br=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),gr=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ae={};x(Ae,{base36:()=>wr,base36upper:()=>xr});var wr=O({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xr=O({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fe={};x(Fe,{base58btc:()=>I,base58flickr:()=>Er});var I=O({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Er=O({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ie={};x(Ie,{base64:()=>De,base64pad:()=>Cr,base64url:()=>vr,base64urlpad:()=>Sr});var De=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cr=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vr=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Sr=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Me={};x(Me,{base8:()=>Ar});var Ar=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ke={};x(ke,{identity:()=>Fr});var Fr=V({prefix:"\0",name:"identity",encode:t=>nt(t),decode:t=>rt(t)});var lo=new TextEncoder,fo=new TextDecoder;var Le={};x(Le,{identity:()=>Hr});var Mr=ut,at=128,kr=127,Br=~kr,Lr=Math.pow(2,31);function ut(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Lr;)e[r++]=t&255|at,t/=128;for(;t&Br;)e[r++]=t&255|at,t>>>=7;return e[r]=t|0,ut.bytes=r-n+1,e}var Tr=Be,Ur=128,ct=127;function Be(t,n){var r=0,n=n||0,o=0,s=n,i,c=t.length;do{if(s>=c)throw Be.bytes=0,new RangeError("Could not decode varint");i=t[s++],r+=o<28?(i&ct)<<o:(i&ct)*Math.pow(2,o),o+=7}while(i>=Ur);return Be.bytes=s-n,r}var Nr=Math.pow(2,7),Or=Math.pow(2,14),_r=Math.pow(2,21),Pr=Math.pow(2,28),Rr=Math.pow(2,35),jr=Math.pow(2,42),$r=Math.pow(2,49),zr=Math.pow(2,56),Kr=Math.pow(2,63),Vr=function(t){return t<Nr?1:t<Or?2:t<_r?3:t<Pr?4:t<Rr?5:t<jr?6:t<$r?7:t<zr?8:t<Kr?9:10},Wr={encode:Mr,decode:Tr,encodingLength:Vr},Jr=Wr,Z=Jr;var Y=(t,e=0)=>[Z.decode(t,e),Z.decode.bytes],W=(t,e,r=0)=>(Z.encode(t,e,r),e),J=t=>Z.encodingLength(t);var R=(t,e)=>{let r=e.byteLength,n=J(t),o=n+J(r),s=new Uint8Array(o+r);return W(t,s,0),W(r,s,n),s.set(e,o),new G(t,r,e,s)},lt=t=>{let e=U(t),[r,n]=Y(e),[o,s]=Y(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new G(r,o,i,e)},ft=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&tt(t.bytes,r.bytes)}},G=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var dt=0,Gr="identity",ht=U,Xr=t=>R(dt,ht(t)),Hr={code:dt,name:Gr,encode:ht,digest:Xr};var Ne={};x(Ne,{sha256:()=>Qr,sha512:()=>Zr});var Ue=({name:t,code:e,encode:r})=>new Te(t,e,r),Te=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?R(this.code,r):r.then(n=>R(this.code,n))}else throw Error("Unknown type, must be binary type")}};var mt=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Qr=Ue({name:"sha2-256",code:18,encode:mt("SHA-256")}),Zr=Ue({name:"sha2-512",code:19,encode:mt("SHA-512")});var yt=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return qr(r,Oe(t),e||I.encoder);default:return en(r,Oe(t),e||_.encoder)}};var bt=new WeakMap,Oe=t=>{let e=bt.get(t);if(e==null){let r=new Map;return bt.set(t,r),r}return e},ie=class t{constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==ee)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==tn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=R(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&ft(e.multihash,n.multihash)}toString(e){return yt(this,e)}toJSON(){return{"/":yt(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new t(n,o,s,i||gt(n,o,s.bytes))}else if(r[rn]===!0){let{version:n,multihash:o,code:s}=r,i=lt(o);return t.create(n,s,i)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==ee)throw new Error(`Version 0 CID must use dag-pb (code: ${ee}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=gt(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ee,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=U(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new G(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(i):t.createV1(r.codec,i),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[u,h]=Y(e.subarray(r));return r+=h,u},o=n(),s=ee;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,c=n(),l=n(),g=r+l,a=g-i;return{version:o,codec:s,multihashCode:c,digestSize:l,multihashSize:a,size:g}}static parse(e,r){let[n,o]=Yr(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Oe(s).set(n,e),s}},Yr=(t,e)=>{switch(t[0]){case"Q":{let r=e||I;return[I.prefix,r.decode(`${I.prefix}${t}`)]}case I.prefix:{let r=e||I;return[I.prefix,r.decode(t)]}case _.prefix:{let r=e||_;return[_.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},qr=(t,e,r)=>{let{prefix:n}=r;if(n!==I.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o},en=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o},ee=112,tn=18,gt=(t,e,r)=>{let n=J(t),o=n+J(e),s=new Uint8Array(o+r.byteLength);return W(t,s,0),W(e,s,n),s.set(r,o),s},rn=Symbol.for("@ipld/js-cid/CID");var _e={...ke,...Ce,...Me,...xe,...Ee,...Se,...Ae,...Fe,...Ie,...ve},Io={...Ne,...Le};function wt(t=0){return globalThis.Buffer?.allocUnsafe!=null?oe(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Et(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var xt=Et("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Pe=Et("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=wt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),nn={utf8:xt,"utf-8":xt,hex:_e.base16,latin1:Pe,ascii:Pe,binary:Pe,..._e},ae=nn;function Ct(t,e="utf8"){let r=ae[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?oe(globalThis.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function vt(t,e="utf8"){let r=ae[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var N="/",St=new TextEncoder().encode(N),ce=St[0],L=class t{_buf;constructor(e,r){if(typeof e=="string")this._buf=Ct(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(r==null&&(r=!0),r&&this.clean(),this._buf.byteLength===0||this._buf[0]!==ce)throw new Error("Invalid key")}toString(e="utf8"){return vt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new t(e.join(N))}static random(){return new t(qe().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new t(e):typeof e.uint8Array=="function"?new t(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=St),this._buf[0]!==ce){let e=new Uint8Array(this._buf.byteLength+1);e.fill(ce,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===ce;)this._buf=this._buf.subarray(0,-1)}less(e){let r=this.list(),n=e.list();for(let o=0;o<r.length;o++){if(n.length<o+1)return!1;let s=r[o],i=n[o];if(s<i)return!0;if(s>i)return!1}return r.length<n.length}reverse(){return t.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(N).slice(1)}type(){return on(this.baseNamespace())}name(){return sn(this.baseNamespace())}instance(e){return new t(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(N)||(e+=N),e+=this.type(),new t(e)}parent(){let e=this.list();return e.length===1?new t(N):new t(e.slice(0,-1).join(N))}child(e){return this.toString()===N?e:e.toString()===N?this:new t(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return t.withNamespaces([...this.namespaces(),...an(e.map(r=>r.namespaces()))])}};function on(t){let e=t.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function sn(t){let e=t.split(":");return e[e.length-1]}function an(t){return[].concat(...t)}var At="SHARDING";function un(t){return t[Symbol.asyncIterator]!=null}function ln(t){if(un(t))return(async()=>{for await(let e of t);})();for(let e of t);}var ue=ln;function fn(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[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(),[r](){return this}}}var Re=fn;function dn(t){return t[Symbol.asyncIterator]!=null}function hn(t,e){if(dn(t))return async function*(){for await(let c of t)await e(c)&&(yield c)}();let r=Re(t),{value:n,done:o}=r.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 r)await e(c)&&(yield c)}();let i=e;return function*(){s===!0&&(yield n);for(let c of r)i(c)&&(yield c)}()}var k=hn;function pn(t){return t[Symbol.asyncIterator]!=null}function mn(t){if(pn(t))return(async()=>{let r=[];for await(let n of t)r.push(n);return r})();let e=[];for(let r of t)e.push(r);return e}var je=mn;function yn(t){return t[Symbol.asyncIterator]!=null}function bn(t,e){return yn(t)?async function*(){yield*(await je(t)).sort(e)}():function*(){yield*je(t).sort(e)}()}var j=bn;function gn(t){return t[Symbol.asyncIterator]!=null}function wn(t,e){return gn(t)?async function*(){let r=0;if(!(e<1)){for await(let n of t)if(yield n,r++,r===e)return}}():function*(){let r=0;if(!(e<1)){for(let n of t)if(yield n,r++,r===e)return}}()}var le=wn;var T=class{put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}get(e,r){return Promise.reject(new Error(".get is not implemented"))}has(e,r){return Promise.reject(new Error(".has is not implemented"))}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*putMany(e,r={}){for await(let{key:n,value:o}of e)await this.put(n,o,r),yield n}async*getMany(e,r={}){for await(let n of e)yield{key:n,value:await this.get(n,r)}}async*deleteMany(e,r={}){for await(let n of e)await this.delete(n,r),yield n}batch(){let e=[],r=[];return{put(n,o){e.push({key:n,value:o})},delete(n){r.push(n)},commit:async n=>{await ue(this.putMany(e,n)),e=[],await ue(this.deleteMany(r,n)),r=[]}}}async*_all(e,r){throw new Error("._all is not implemented")}async*_allKeys(e,r){throw new Error("._allKeys is not implemented")}query(e,r){let n=this._all(e,r);if(e.prefix!=null){let o=e.prefix;n=k(n,s=>s.key.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>k(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>j(o,s),n)),e.offset!=null){let o=0,s=e.offset;n=k(n,()=>o++>=s)}return e.limit!=null&&(n=le(n,e.limit)),n}queryKeys(e,r){let n=this._allKeys(e,r);if(e.prefix!=null){let o=e.prefix;n=k(n,s=>s.toString().startsWith(o))}if(Array.isArray(e.filters)&&(n=e.filters.reduce((o,s)=>k(o,s),n)),Array.isArray(e.orders)&&(n=e.orders.reduce((o,s)=>j(o,s),n)),e.offset!=null){let o=e.offset,s=0;n=k(n,()=>s++>=o)}return e.limit!=null&&(n=le(n,e.limit)),n}};var Us=new L(At);var S=Xe(Lt(),1);S.default.formatters.b=t=>t==null?"undefined":I.baseEncode(t);S.default.formatters.t=t=>t==null?"undefined":_.baseEncode(t);S.default.formatters.m=t=>t==null?"undefined":De.baseEncode(t);S.default.formatters.p=t=>t==null?"undefined":t.toString();S.default.formatters.c=t=>t==null?"undefined":t.toString();S.default.formatters.k=t=>t==null?"undefined":t.toString();S.default.formatters.a=t=>t==null?"undefined":t.toString();function Tn(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function Tt(t){let e=Tn(`${t}:trace`);return S.default.enabled(`${t}:trace`)&&S.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,S.default)(`${t}:trace`)),Object.assign((0,S.default)(t),{error:(0,S.default)(`${t}:error`),trace:e})}var ti=Tt("datastore:core:tiered");var Un=(t,e)=>e.some(r=>t instanceof r),Ut,Nt;function Nn(){return Ut||(Ut=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function On(){return Nt||(Nt=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Ot=new WeakMap,ze=new WeakMap,_t=new WeakMap,$e=new WeakMap,Ve=new WeakMap;function _n(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",s),t.removeEventListener("error",i)},s=()=>{r(B(t.result)),o()},i=()=>{n(t.error),o()};t.addEventListener("success",s),t.addEventListener("error",i)});return e.then(r=>{r instanceof IDBCursor&&Ot.set(r,t)}).catch(()=>{}),Ve.set(e,t),e}function Pn(t){if(ze.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",i),t.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",s),t.addEventListener("error",i),t.addEventListener("abort",i)});ze.set(t,e)}var Ke={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return ze.get(t);if(e==="objectStoreNames")return t.objectStoreNames||_t.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return B(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function Pt(t){Ke=t(Ke)}function Rn(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(he(this),e,...r);return _t.set(n,e.sort?e.sort():[e]),B(n)}:On().includes(t)?function(...e){return t.apply(he(this),e),B(Ot.get(this))}:function(...e){return B(t.apply(he(this),e))}}function jn(t){return typeof t=="function"?Rn(t):(t instanceof IDBTransaction&&Pn(t),Un(t,Nn())?new Proxy(t,Ke):t)}function B(t){if(t instanceof IDBRequest)return _n(t);if($e.has(t))return $e.get(t);let e=jn(t);return e!==t&&($e.set(t,e),Ve.set(e,t)),e}var he=t=>Ve.get(t);function jt(t,e,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(t,e),c=B(i);return n&&i.addEventListener("upgradeneeded",l=>{n(B(i.result),l.oldVersion,l.newVersion,B(i.transaction),l)}),r&&i.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),c.then(l=>{s&&l.addEventListener("close",()=>s()),o&&l.addEventListener("versionchange",g=>o(g.oldVersion,g.newVersion,g))}).catch(()=>{}),c}function $t(t,{blocked:e}={}){let r=indexedDB.deleteDatabase(t);return e&&r.addEventListener("blocked",n=>e(n.oldVersion,n)),B(r).then(()=>{})}var $n=["get","getKey","getAll","getAllKeys","count"],zn=["put","add","delete","clear"],We=new Map;function Rt(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(We.get(e))return We.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=zn.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||$n.includes(r)))return;let s=async function(i,...c){let l=this.transaction(i,o?"readwrite":"readonly"),g=l.store;return n&&(g=g.index(c.shift())),(await Promise.all([g[r](...c),o&&l.done]))[0]};return We.set(e,s),s}Pt(t=>({...t,get:(e,r,n)=>Rt(e,r)||t.get(e,r,n),has:(e,r)=>!!Rt(e,r)||t.has(e,r)}));var Je=class extends T{location;version;db;constructor(e,r={}){super(),this.location=`${r.prefix??""}${e}`,this.version=r.version??1}async open(){try{let e=this.location;this.db=await jt(e,this.version,{upgrade(r){r.createObjectStore(e)}})}catch(e){throw C.dbOpenFailedError(e)}}async close(){this.db?.close()}async put(e,r){if(this.db==null)throw new Error("Datastore needs to be opened.");try{return await this.db.put(this.location,r,e.toString()),e}catch(n){throw C.dbWriteFailedError(n)}}async get(e){if(this.db==null)throw new Error("Datastore needs to be opened.");let r;try{r=await this.db.get(this.location,e.toString())}catch(n){throw C.dbReadFailedError(n)}if(r===void 0)throw C.notFoundError();return r}async has(e){if(this.db==null)throw new Error("Blockstore needs to be opened.");try{return!!await this.db.getKey(this.location,e.toString())}catch(r){throw C.dbReadFailedError(r)}}async delete(e){if(this.db==null)throw new Error("Datastore needs to be opened.");try{await this.db.delete(this.location,e.toString())}catch(r){throw C.dbWriteFailedError(r)}}batch(){let e=[],r=[];return{put(n,o){e.push({key:n,value:o})},delete(n){r.push(n)},commit:async()=>{if(this.db==null)throw new Error("Datastore needs to be opened.");let n=this.db.transaction(this.location,"readwrite");try{let o=e.filter(({key:s})=>r.find(i=>i.toString()===s.toString())==null).map(s=>async()=>{await n.store.put(s.value,s.key.toString())}).concat(r.map(s=>async()=>{await n.store.delete(s.toString())})).concat(async()=>{await n.done});await Promise.all(o.map(async s=>{await s()}))}catch{n.abort()}}}}async*query(e){let r=this.#e(e,(n,o)=>({key:n,value:o}));Array.isArray(e.filters)&&(r=e.filters.reduce((n,o)=>k(n,o),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((n,o)=>j(n,o),r)),yield*r}async*queryKeys(e){let r=this.#e(e,n=>n);Array.isArray(e.filters)&&(r=e.filters.reduce((n,o)=>k(n,o),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((n,o)=>j(n,o),r)),yield*r}async*#e(e,r){if(this.db==null)throw new Error("Datastore needs to be opened.");let n=0,o=-1;for(let s of await this.db.getAllKeys(this.location)){if(e.prefix!=null&&!s.toString().startsWith(e.prefix))continue;if(e.limit!=null&&n===e.limit)return;if(o++,e.offset!=null&&o<e.offset)continue;let i=new L(s.toString()),c;try{c=await this.get(i)}catch(l){if(l.code!=="ERR_NOT_FOUND")throw l;continue}c!=null&&(yield r(i,c),n++)}}async destroy(){await $t(this.location)}};return Gt(Kn);})();
return DatastoreIdb}));

@@ -0,1 +1,14 @@

/**
* @packageDocumentation
*
* A Datastore implementation for browsers that stores data in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API).
*
* @example
*
* ```js
* import { IDBDatastore } from 'datastore-idb'
*
* const store = new IDBDatastore('path/to/store')
* ```
*/
import { BaseDatastore } from 'datastore-core';

@@ -2,0 +15,0 @@ import { type Batch, Key, type KeyQuery, type Pair, type Query } from 'interface-datastore';

@@ -0,1 +1,14 @@

/**
* @packageDocumentation
*
* A Datastore implementation for browsers that stores data in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API).
*
* @example
*
* ```js
* import { IDBDatastore } from 'datastore-idb'
*
* const store = new IDBDatastore('path/to/store')
* ```
*/
import { Errors, BaseDatastore } from 'datastore-core';

@@ -2,0 +15,0 @@ import { openDB, deleteDB } from 'idb';

{
"IDBDatastore": "https://ipfs.github.io/js-stores/classes/IDBDatastore.html",
".:IDBDatastore": "https://ipfs.github.io/js-stores/classes/IDBDatastore.html",
"IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/IDBDatastoreInit.html",
".:IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/IDBDatastoreInit.html"
"IDBDatastore": "https://ipfs.github.io/js-stores/classes/datastore_idb.IDBDatastore.html",
".:IDBDatastore": "https://ipfs.github.io/js-stores/classes/datastore_idb.IDBDatastore.html",
"IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/datastore_idb.IDBDatastoreInit.html",
".:IDBDatastoreInit": "https://ipfs.github.io/js-stores/interfaces/datastore_idb.IDBDatastoreInit.html"
}
{
"name": "datastore-idb",
"version": "2.1.4",
"version": "2.1.5",
"description": "Datastore implementation with IndexedDB backend.",

@@ -40,7 +40,7 @@ "author": "Hugo Dias <hugomrdias@gmail.com>",

"parserOptions": {
"sourceType": "module",
"project": [
"tsconfig.json",
"benchmarks/datastore-level/tsconfig.json"
]
],
"sourceType": "module"
}

@@ -140,4 +140,3 @@ },

"release": "aegir release",
"dep-check": "aegir dep-check",
"docs": "aegir docs"
"dep-check": "aegir dep-check"
},

@@ -151,3 +150,3 @@ "dependencies": {

"devDependencies": {
"aegir": "^40.0.8",
"aegir": "^41.1.9",
"datastore-core": "^9.0.0",

@@ -154,0 +153,0 @@ "interface-datastore-tests": "^5.0.0"

@@ -1,3 +0,1 @@

# datastore-idb <!-- omit in toc -->
[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)

@@ -10,12 +8,16 @@ [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)

## Table of contents <!-- omit in toc -->
# About
- [Install](#install)
- [Browser `<script>` tag](#browser-script-tag)
- [API Docs](#api-docs)
- [License](#license)
- [Contribute](#contribute)
A Datastore implementation for browsers that stores data in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API).
## Install
## Example
```js
import { IDBDatastore } from 'datastore-idb'
const store = new IDBDatastore('path/to/store')
```
# Install
```console

@@ -25,3 +27,3 @@ $ npm i datastore-idb

### Browser `<script>` tag
## Browser `<script>` tag

@@ -34,7 +36,7 @@ Loading this module through a script tag will make it's exports available as `DatastoreIdb` in the global namespace.

## API Docs
# API Docs
- <https://ipfs.github.io/js-stores/modules/datastore_idb.html>
## License
# License

@@ -46,3 +48,3 @@ Licensed under either of

## Contribute
# Contribute

@@ -49,0 +51,0 @@ Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-stores/issues).

@@ -0,1 +1,15 @@

/**
* @packageDocumentation
*
* A Datastore implementation for browsers that stores data in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API).
*
* @example
*
* ```js
* import { IDBDatastore } from 'datastore-idb'
*
* const store = new IDBDatastore('path/to/store')
* ```
*/
import { Errors, BaseDatastore } from 'datastore-core'

@@ -2,0 +16,0 @@ import { openDB, deleteDB, type IDBPDatabase } from 'idb'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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