UNPKG

@orbitdb/core

Version:

Distributed p2p database on IPFS

2 lines 303 kB
/*! For license information please see orbitdb.min.js.LICENSE.txt */ var OrbitDB;(()=>{var t={464:(t,e,r)=>{"use strict";const{fromCallback:n}=r(957),i=r(473),{getCallback:o,getOptions:s}=r(520),a=Symbol("promise"),c=Symbol("status"),u=Symbol("operations"),h=Symbol("finishClose"),l=Symbol("closeCallbacks");e.AbstractChainedBatch=class{constructor(t){if("object"!=typeof t||null===t)throw new TypeError("The first argument must be an abstract-level database, received "+(null===t?"null":typeof t));this[u]=[],this[l]=[],this[c]="open",this[h]=this[h].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[u].length}put(t,e,r){if("open"!==this[c])throw new i("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const n=this.db._checkKey(t)||this.db._checkValue(e);if(n)throw n;const o=r&&null!=r.sublevel?r.sublevel:this.db,s=r,a=o.keyEncoding(r&&r.keyEncoding),h=o.valueEncoding(r&&r.valueEncoding),l=a.format;r={...r,keyEncoding:l,valueEncoding:h.format},o!==this.db&&(r.sublevel=null);const f=o.prefixKey(a.encode(t),l),d=h.encode(e);return this._put(f,d,r),this[u].push({...s,type:"put",key:t,value:e}),this}_put(t,e,r){}del(t,e){if("open"!==this[c])throw new i("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const r=this.db._checkKey(t);if(r)throw r;const n=e&&null!=e.sublevel?e.sublevel:this.db,o=e,s=n.keyEncoding(e&&e.keyEncoding),a=s.format;return e={...e,keyEncoding:a},n!==this.db&&(e.sublevel=null),this._del(n.prefixKey(s.encode(t),a),e),this[u].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if("open"!==this[c])throw new i("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[u]=[],this}_clear(){}write(t,e){return e=o(t,e),e=n(e,a),t=s(t),"open"!==this[c]?this.nextTick(e,new i("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):0===this.length?this.close(e):(this[c]="writing",this._write(t,(t=>{this[c]="closing",this[l].push((()=>e(t))),t||this.db.emit("batch",this[u]),this._close(this[h])}))),e[a]}_write(t,e){}close(t){return t=n(t,a),"closing"===this[c]?this[l].push(t):"closed"===this[c]?this.nextTick(t):(this[l].push(t),"writing"!==this[c]&&(this[c]="closing",this._close(this[h]))),t[a]}_close(t){this.nextTick(t)}[h](){this[c]="closed",this.db.detachResource(this);const t=this[l];this[l]=[];for(const e of t)e()}}},961:(t,e,r)=>{"use strict";const{fromCallback:n}=r(957),i=r(473),{getOptions:o,getCallback:s}=r(520),a=Symbol("promise"),c=Symbol("callback"),u=Symbol("working"),h=Symbol("handleOne"),l=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),y=Symbol("returnMany"),p=Symbol("closing"),g=Symbol("handleClose"),w=Symbol("closed"),b=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),E=Symbol("abortOnClose"),x=Symbol("legacy"),B=Symbol("keys"),A=Symbol("values"),k=Symbol("limit"),S=Symbol("count"),I=Object.freeze({}),T=()=>{};let C=!1;class U{constructor(t,e,r){if("object"!=typeof t||null===t)throw new TypeError("The first argument must be an abstract-level database, received "+(null===t?"null":typeof t));if("object"!=typeof e||null===e)throw new TypeError("The second argument must be an options object");this[w]=!1,this[b]=[],this[u]=!1,this[p]=!1,this[f]=!1,this[c]=null,this[h]=this[h].bind(this),this[l]=this[l].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[x]=r,this[k]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[S]=0,this[E]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[S]}get limit(){return this[k]}next(t){let e;if(void 0===t)e=new Promise(((e,r)=>{t=(t,n,i)=>{t?r(t):this[x]?void 0===n&&void 0===i?e():e([n,i]):e(n)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[p]?this.nextTick(t,new i("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[u]?this.nextTick(t,new i("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[u]=!0,this[c]=t,this[S]>=this[k]?this.nextTick(this[h],null):this._next(this[h])),e}_next(t){this.nextTick(t)}nextv(t,e,r){return r=s(e,r),r=n(r,a),e=o(e,I),Number.isInteger(t)?(this[p]?this.nextTick(r,new i("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[u]?this.nextTick(r,new i("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[k]<1/0&&(t=Math.min(t,this[k]-this[S])),this[u]=!0,this[c]=r,t<=0?this.nextTick(this[l],null,[]):this._nextv(t,e,this[l])),r[a]):(this.nextTick(r,new TypeError("The first argument 'size' must be an integer")),r[a])}_nextv(t,e,r){const n=[],i=(e,o,s)=>e?r(e):(this[x]?void 0===o&&void 0===s:void 0===o)?r(null,n):(n.push(this[x]?[o,s]:o),void(n.length===t?r(null,n):this._next(i)));this._next(i)}all(t,e){return e=s(t,e),e=n(e,a),t=o(t,I),this[p]?this.nextTick(e,new i("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[u]?this.nextTick(e,new i("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[u]=!0,this[c]=e,this[f]=!0,this[S]>=this[k]?this.nextTick(this[l],null,[]):this._all(t,this[l])),e[a]}_all(t,e){let r=this[S];const n=[],i=()=>{const t=this[k]<1/0?Math.min(1e3,this[k]-r):1e3;t<=0?this.nextTick(e,null,n):this._nextv(t,I,o)},o=(t,o)=>{t?e(t):0===o.length?e(null,n):(n.push.apply(n,o),r+=o.length,i())};i()}[d](){const t=this[c];return this[E]&&null===t?T:(this[u]=!1,this[c]=null,this[p]&&this._close(this[g]),t)}[y](t,e,r){this[f]?this.close(t.bind(null,e,r)):t(e,r)}seek(t,e){if(e=o(e,I),this[p]);else{if(this[u])throw new i("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const r=this.db.keyEncoding(e.keyEncoding||this[m]),n=r.format;e.keyEncoding!==n&&(e={...e,keyEncoding:n});const i=this.db.prefixKey(r.encode(t),n);this._seek(i,e)}}}_seek(t,e){throw new i("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=n(t,a),this[w]?this.nextTick(t):this[p]?this[b].push(t):(this[p]=!0,this[b].push(t),this[u]?this[E]&&this[d]()(new i("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[g])),t[a]}_close(t){this.nextTick(t)}[g](){this[w]=!0,this.db.detachResource(this);const t=this[b];this[b]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[w]||await this.close()}}}class L extends U{constructor(t,e){super(t,e,!0),this[B]=!1!==e.keys,this[A]=!1!==e.values}[h](t,e,r){const n=this[d]();if(t)return n(t);try{e=this[B]&&void 0!==e?this[m].decode(e):void 0,r=this[A]&&void 0!==r?this[v].decode(r):void 0}catch(t){return n(new N("entry",t))}void 0===e&&void 0===r||this[S]++,n(null,e,r)}[l](t,e){const r=this[d]();if(t)return this[y](r,t);try{for(const t of e){const e=t[0],r=t[1];t[0]=this[B]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[A]&&void 0!==r?this[v].decode(r):void 0}}catch(t){return this[y](r,new N("entries",t))}this[S]+=e.length,this[y](r,null,e)}end(t){return C||"undefined"==typeof console||(C=!0,console.warn(new i("The iterator.end() method was renamed to close() and end() is an alias that will be removed in a future version",{code:"LEVEL_LEGACY"}))),this.close(t)}}class N extends i{constructor(t,e){super(`Iterator could not decode ${t}`,{code:"LEVEL_DECODE_ERROR",cause:e})}}for(const t of["_ended property","_nexting property","_end method"])Object.defineProperty(L.prototype,t.split(" ")[0],{get(){throw new i(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new i(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});L.keyEncoding=m,L.valueEncoding=v,e.AbstractIterator=L,e.AbstractKeyIterator=class extends U{constructor(t,e){super(t,e,!1)}[h](t,e){const r=this[d]();if(t)return r(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return r(new N("key",t))}void 0!==e&&this[S]++,r(null,e)}[l](t,e){const r=this[d]();if(t)return this[y](r,t);try{for(let t=0;t<e.length;t++){const r=e[t];e[t]=void 0!==r?this[m].decode(r):void 0}}catch(t){return this[y](r,new N("keys",t))}this[S]+=e.length,this[y](r,null,e)}},e.AbstractValueIterator=class extends U{constructor(t,e){super(t,e,!1)}[h](t,e){const r=this[d]();if(t)return r(t);try{e=void 0!==e?this[v].decode(e):void 0}catch(t){return r(new N("value",t))}void 0!==e&&this[S]++,r(null,e)}[l](t,e){const r=this[d]();if(t)return this[y](r,t);try{for(let t=0;t<e.length;t++){const r=e[t];e[t]=void 0!==r?this[v].decode(r):void 0}}catch(t){return this[y](r,new N("values",t))}this[S]+=e.length,this[y](r,null,e)}}},71:(t,e,r)=>{"use strict";const{supports:n}=r(675),{Transcoder:i}=r(499),{EventEmitter:o}=r(187),{fromCallback:s}=r(957),a=r(473),{AbstractIterator:c}=r(961),{DefaultKeyIterator:u,DefaultValueIterator:h}=r(429),{DeferredIterator:l,DeferredKeyIterator:f,DeferredValueIterator:d}=r(593),{DefaultChainedBatch:y}=r(765),{getCallback:p,getOptions:g}=r(520),w=r(56),b=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),E=Symbol("closeResources"),x=Symbol("operations"),B=Symbol("undefer"),A=Symbol("deferOpen"),k=Symbol("options"),S=Symbol("status"),I=Symbol("defaultOptions"),T=Symbol("transcoder"),C=Symbol("keyEncoding"),U=Symbol("valueEncoding"),L=()=>{};class N extends o{constructor(t,e){if(super(),"object"!=typeof t||null===t)throw new TypeError("The first argument 'manifest' must be an object");e=g(e);const{keyEncoding:r,valueEncoding:o,passive:s,...a}=e;this[v]=new Set,this[x]=[],this[A]=!0,this[k]=a,this[S]="opening",this.supports=n(t,{status:!0,promises:!0,clear:!0,getMany:!0,deferredOpen:!0,snapshots:!1!==t.snapshots,permanence:!1!==t.permanence,keyIterator:!0,valueIterator:!0,iteratorNextv:!0,iteratorAll:!0,encodings:t.encodings||{},events:Object.assign({},t.events,{opening:!0,open:!0,closing:!0,closed:!0,put:!0,del:!0,batch:!0,clear:!0})}),this[T]=new i(R(this)),this[C]=this[T].encoding(r||"utf8"),this[U]=this[T].encoding(o||"utf8");for(const t of this[T].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[I]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[C].commonName,valueEncoding:this[U].commonName}),key:Object.freeze({keyEncoding:this[C].commonName})},this.nextTick((()=>{this[A]&&this.open({passive:!1},L)}))}get status(){return this[S]}keyEncoding(t){return this[T].encoding(null!=t?t:this[C])}valueEncoding(t){return this[T].encoding(null!=t?t:this[U])}open(t,e){e=p(t,e),e=s(e,b),(t={...this[k],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const r=t=>{"closing"===this[S]||"opening"===this[S]?this.once(m,t?()=>r(t):r):"open"!==this[S]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[S]?this.once(m,r):this.nextTick(r):"closed"===this[S]||this[A]?(this[A]=!1,this[S]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[S]="closed",this[E]((()=>{this.emit(m),r(t)})),void this[B]();this[S]="open",this[B](),this.emit(m),"open"===this[S]&&this.emit("open"),"open"===this[S]&&this.emit("ready"),r()}))):"open"===this[S]?this.nextTick(r):this.once(m,(()=>this.open(t,e))),e[b]}_open(t,e){this.nextTick(e)}close(t){t=s(t,b);const e=r=>{"opening"===this[S]||"closing"===this[S]?this.once(m,r?e(r):e):"closed"!==this[S]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:r})):t()};if("open"===this[S]){this[S]="closing",this.emit("closing");const t=t=>{this[S]="open",this[B](),this.emit(m),e(t)};this[E]((()=>{this._close((r=>{if(r)return t(r);this[S]="closed",this[B](),this.emit(m),"closed"===this[S]&&this.emit("closed"),e()}))}))}else"closed"===this[S]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[b]}[E](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,r=!0;const n=()=>{0==--e&&(r?this.nextTick(t):t())};for(const t of this[v])t.close(n);r=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,r){if(r=p(e,r),r=s(r,b),e=g(e,this[I].entry),"opening"===this[S])return this.defer((()=>this.get(t,e,r))),r[b];if(_(this,r))return r[b];const n=this._checkKey(t);if(n)return this.nextTick(r,n),r[b];const i=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),c=i.format,u=o.format;return e.keyEncoding===c&&e.valueEncoding===u||(e=Object.assign({},e,{keyEncoding:c,valueEncoding:u})),this._get(this.prefixKey(i.encode(t),c),e,((t,e)=>{if(t)return("LEVEL_NOT_FOUND"===t.code||t.notFound||/NotFound/i.test(t))&&(t.code||(t.code="LEVEL_NOT_FOUND"),t.notFound||(t.notFound=!0),t.status||(t.status=404)),r(t);try{e=o.decode(e)}catch(t){return r(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}r(null,e)})),r[b]}_get(t,e,r){this.nextTick(r,new Error("NotFound"))}getMany(t,e,r){if(r=p(e,r),r=s(r,b),e=g(e,this[I].entry),"opening"===this[S])return this.defer((()=>this.getMany(t,e,r))),r[b];if(_(this,r))return r[b];if(!Array.isArray(t))return this.nextTick(r,new TypeError("The first argument 'keys' must be an array")),r[b];if(0===t.length)return this.nextTick(r,null,[]),r[b];const n=this.keyEncoding(e.keyEncoding),i=this.valueEncoding(e.valueEncoding),o=n.format,c=i.format;e.keyEncoding===o&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:o,valueEncoding:c}));const u=new Array(t.length);for(let e=0;e<t.length;e++){const i=t[e],s=this._checkKey(i);if(s)return this.nextTick(r,s),r[b];u[e]=this.prefixKey(n.encode(i),o)}return this._getMany(u,e,((t,e)=>{if(t)return r(t);try{for(let t=0;t<e.length;t++)void 0!==e[t]&&(e[t]=i.decode(e[t]))}catch(t){return r(new a(`Could not decode one or more of ${e.length} value(s)`,{code:"LEVEL_DECODE_ERROR",cause:t}))}r(null,e)})),r[b]}_getMany(t,e,r){this.nextTick(r,null,new Array(t.length).fill(void 0))}put(t,e,r,n){if(n=p(r,n),n=s(n,b),r=g(r,this[I].entry),"opening"===this[S])return this.defer((()=>this.put(t,e,r,n))),n[b];if(_(this,n))return n[b];const i=this._checkKey(t)||this._checkValue(e);if(i)return this.nextTick(n,i),n[b];const o=this.keyEncoding(r.keyEncoding),a=this.valueEncoding(r.valueEncoding),c=o.format,u=a.format;r.keyEncoding===c&&r.valueEncoding===u||(r=Object.assign({},r,{keyEncoding:c,valueEncoding:u}));const h=this.prefixKey(o.encode(t),c),l=a.encode(e);return this._put(h,l,r,(r=>{if(r)return n(r);this.emit("put",t,e),n()})),n[b]}_put(t,e,r,n){this.nextTick(n)}del(t,e,r){if(r=p(e,r),r=s(r,b),e=g(e,this[I].key),"opening"===this[S])return this.defer((()=>this.del(t,e,r))),r[b];if(_(this,r))return r[b];const n=this._checkKey(t);if(n)return this.nextTick(r,n),r[b];const i=this.keyEncoding(e.keyEncoding),o=i.format;return e.keyEncoding!==o&&(e=Object.assign({},e,{keyEncoding:o})),this._del(this.prefixKey(i.encode(t),o),e,(e=>{if(e)return r(e);this.emit("del",t),r()})),r[b]}_del(t,e,r){this.nextTick(r)}batch(t,e,r){if(!arguments.length){if("opening"===this[S])return new y(this);if("open"!==this[S])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(r="function"==typeof t?t:p(e,r),r=s(r,b),e=g(e,this[I].empty),"opening"===this[S])return this.defer((()=>this.batch(t,e,r))),r[b];if(_(this,r))return r[b];if(!Array.isArray(t))return this.nextTick(r,new TypeError("The first argument 'operations' must be an array")),r[b];if(0===t.length)return this.nextTick(r),r[b];const n=new Array(t.length),{keyEncoding:i,valueEncoding:o,...c}=e;for(let e=0;e<t.length;e++){if("object"!=typeof t[e]||null===t[e])return this.nextTick(r,new TypeError("A batch operation must be an object")),r[b];const s=Object.assign({},t[e]);if("put"!==s.type&&"del"!==s.type)return this.nextTick(r,new TypeError("A batch operation must have a type property that is 'put' or 'del'")),r[b];const a=this._checkKey(s.key);if(a)return this.nextTick(r,a),r[b];const c=null!=s.sublevel?s.sublevel:this,u=c.keyEncoding(s.keyEncoding||i),h=u.format;if(s.key=c.prefixKey(u.encode(s.key),h),s.keyEncoding=h,"put"===s.type){const t=this._checkValue(s.value);if(t)return this.nextTick(r,t),r[b];const e=c.valueEncoding(s.valueEncoding||o);s.value=e.encode(s.value),s.valueEncoding=e.format}c!==this&&(s.sublevel=null),n[e]=s}return this._batch(n,c,(e=>{if(e)return r(e);this.emit("batch",t),r()})),r[b]}_batch(t,e,r){this.nextTick(r)}sublevel(t,e){return this._sublevel(t,O.defaults(e))}_sublevel(t,e){return new O(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=p(t,e),e=s(e,b),t=g(t,this[I].empty),"opening"===this[S])return this.defer((()=>this.clear(t,e))),e[b];if(_(this,e))return e[b];const r=t,n=this.keyEncoding(t.keyEncoding);return(t=w(t,n)).keyEncoding=n.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",r),e()})),e[b]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if((t=w(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[c.keyEncoding]=e,t[c.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,"opening"===this[S])return new l(this,t);if("open"!==this[S])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new c(this,t)}keys(t){const e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if((t=w(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,"opening"===this[S])return new f(this,t);if("open"!==this[S])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new u(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),r=this.valueEncoding(t&&t.valueEncoding);if((t=w(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=r,t.keyEncoding=e.format,t.valueEncoding=r.format,"opening"===this[S])return new d(this,t);if("open"!==this[S])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new h(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[x].push(t)}[B](){if(0===this[x].length)return;const t=this[x];this[x]=[];for(const e of t)e()}attachResource(t){if("object"!=typeof t||null===t||"function"!=typeof t.close)throw new TypeError("The first argument must be a resource object");this[v].add(t)}detachResource(t){this[v].delete(t)}_chainedBatch(){return new y(this)}_checkKey(t){if(null==t)return new a("Key cannot be null or undefined",{code:"LEVEL_INVALID_KEY"})}_checkValue(t){if(null==t)return new a("Value cannot be null or undefined",{code:"LEVEL_INVALID_VALUE"})}}N.prototype.nextTick=r(909);const{AbstractSublevel:O}=r(650)({AbstractLevel:N});e.AbstractLevel=N,e.AbstractSublevel=O;const _=function(t,e){return"open"!==t[S]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},R=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,r)=>{"use strict";e.AbstractLevel=r(71).AbstractLevel,e.AbstractSublevel=r(71).AbstractSublevel,e.AbstractIterator=r(961).AbstractIterator,e.AbstractKeyIterator=r(961).AbstractKeyIterator,e.AbstractValueIterator=r(961).AbstractValueIterator,e.AbstractChainedBatch=r(464).AbstractChainedBatch},970:(t,e,r)=>{"use strict";const{AbstractIterator:n,AbstractKeyIterator:i,AbstractValueIterator:o}=r(961),s=Symbol("unfix"),a=Symbol("iterator"),c=Symbol("handleOne"),u=Symbol("handleMany"),h=Symbol("callback");class l extends n{constructor(t,e,r,n){super(t,e),this[a]=r,this[s]=n,this[c]=this[c].bind(this),this[u]=this[u].bind(this),this[h]=null}[c](t,e,r){const n=this[h];if(t)return n(t);void 0!==e&&(e=this[s](e)),n(t,e,r)}[u](t,e){const r=this[h];if(t)return r(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[s](e))}r(t,e)}}class f extends i{constructor(t,e,r,n){super(t,e),this[a]=r,this[s]=n,this[c]=this[c].bind(this),this[u]=this[u].bind(this),this[h]=null}[c](t,e){const r=this[h];if(t)return r(t);void 0!==e&&(e=this[s](e)),r(t,e)}[u](t,e){const r=this[h];if(t)return r(t);for(let t=0;t<e.length;t++){const r=e[t];void 0!==r&&(e[t]=this[s](r))}r(t,e)}}class d extends o{constructor(t,e,r){super(t,e),this[a]=r}}for(const t of[l,f])t.prototype._next=function(t){this[h]=t,this[a].next(this[c])},t.prototype._nextv=function(t,e,r){this[h]=r,this[a].nextv(t,e,this[u])},t.prototype._all=function(t,e){this[h]=e,this[a].all(t,this[u])};for(const t of[d])t.prototype._next=function(t){this[a].next(t)},t.prototype._nextv=function(t,e,r){this[a].nextv(t,e,r)},t.prototype._all=function(t,e){this[a].all(t,e)};for(const t of[l,f,d])t.prototype._seek=function(t,e){this[a].seek(t,e)},t.prototype._close=function(t){this[a].close(t)};e.AbstractSublevelIterator=l,e.AbstractSublevelKeyIterator=f,e.AbstractSublevelValueIterator=d},650:(t,e,r)=>{"use strict";const n=r(473),{Buffer:i}=r(764)||{},{AbstractSublevelIterator:o,AbstractSublevelKeyIterator:s,AbstractSublevelValueIterator:a}=r(970),c=Symbol("prefix"),u=Symbol("upperBound"),h=Symbol("prefixRange"),l=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,y={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new n("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new n("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?y:t.separator?t:{...t,separator:"!"}}constructor(t,r,i){const{separator:o,manifest:s,...a}=e.defaults(i);r=m(r,o);const h=o.charCodeAt(0)+1,y=t[l]||t;if(!d.encode(r).every((t=>t>h&&t<127)))throw new n(`Prefix must use bytes > ${h} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(p(y,s),a);const g=(t.prefix||"")+o+r+o,v=g.slice(0,-1)+String.fromCharCode(h);this[l]=y,this[c]=new w(g),this[u]=new w(v),this[f]=new b,this.nextTick=y.nextTick}prefixKey(t,e){if("utf8"===e)return this[c].utf8+t;if(0===t.byteLength)return this[c][e];if("view"===e){const e=this[c].view,r=new Uint8Array(e.byteLength+t.byteLength);return r.set(e,0),r.set(t,e.byteLength),r}{const e=this[c].buffer;return i.concat([e,t],e.byteLength+t.byteLength)}}[h](t,e){void 0!==t.gte?t.gte=this.prefixKey(t.gte,e):void 0!==t.gt?t.gt=this.prefixKey(t.gt,e):t.gte=this[c][e],void 0!==t.lte?t.lte=this.prefixKey(t.lte,e):void 0!==t.lt?t.lt=this.prefixKey(t.lt,e):t.lte=this[u][e]}get prefix(){return this[c].utf8}get db(){return this[l]}_open(t,e){this[l].open({passive:!0},e)}_put(t,e,r,n){this[l].put(t,e,r,n)}_get(t,e,r){this[l].get(t,e,r)}_getMany(t,e,r){this[l].getMany(t,e,r)}_del(t,e,r){this[l].del(t,e,r)}_batch(t,e,r){this[l].batch(t,e,r)}_clear(t,e){this[h](t,t.keyEncoding),this[l].clear(t,e)}_iterator(t){this[h](t,t.keyEncoding);const e=this[l].iterator(t),r=this[f].get(this[c].utf8.length,t.keyEncoding);return new o(this,t,e,r)}_keys(t){this[h](t,t.keyEncoding);const e=this[l].keys(t),r=this[f].get(this[c].utf8.length,t.keyEncoding);return new s(this,t,e,r)}_values(t){this[h](t,t.keyEncoding);const e=this[l].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const p=function(t,e){return{...t.supports,createIfMissing:!1,errorIfExists:!1,events:{},additionalMethods:{},...e,encodings:{utf8:g(t,"utf8"),buffer:g(t,"buffer"),view:g(t,"view")}}},g=function(t,e){return!!t.supports.encodings[e]&&t.keyEncoding(e).name===e};class w{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=i?i.from(this.view.buffer,0,this.view.byteLength):{}}}class b{constructor(){this.cache=new Map}get(t,e){let r=this.cache.get(e);return void 0===r&&(r="view"===e?function(t,e){return e.subarray(t)}.bind(null,t):function(t,e){return e.slice(t)}.bind(null,t),this.cache.set(e,r)),r}}const m=function(t,e){let r=0,n=t.length;for(;r<n&&t[r]===e;)r++;for(;n>r&&t[n-1]===e;)n--;return t.slice(r,n)}},520:(t,e)=>{"use strict";e.getCallback=function(t,e){return"function"==typeof t?t:e},e.getOptions=function(t,e){return"object"==typeof t&&null!==t?t:void 0!==e?e:{}}},765:(t,e,r)=>{"use strict";const{AbstractChainedBatch:n}=r(464),i=r(473),o=Symbol("encoded");e.DefaultChainedBatch=class extends n{constructor(t){super(t),this[o]=[]}_put(t,e,r){this[o].push({...r,type:"put",key:t,value:e})}_del(t,e){this[o].push({...e,type:"del",key:t})}_clear(){this[o]=[]}_write(t,e){"opening"===this.db.status?this.db.defer((()=>this._write(t,e))):"open"===this.db.status?0===this[o].length?this.nextTick(e):this.db._batch(this[o],t,e):this.nextTick(e,new i("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},429:(t,e,r)=>{"use strict";const{AbstractKeyIterator:n,AbstractValueIterator:i}=r(961),o=Symbol("iterator"),s=Symbol("callback"),a=Symbol("handleOne"),c=Symbol("handleMany");class u extends n{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}class h extends i{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}for(const t of[u,h]){const e=t===u,r=e?t=>t[0]:t=>t[1];t.prototype._next=function(t){this[s]=t,this[o].next(this[a])},t.prototype[a]=function(t,r,n){const i=this[s];t?i(t):i(null,e?r:n)},t.prototype._nextv=function(t,e,r){this[s]=r,this[o].nextv(t,e,this[c])},t.prototype._all=function(t,e){this[s]=e,this[o].all(t,this[c])},t.prototype[c]=function(t,e){const n=this[s];t?n(t):n(null,e.map(r))},t.prototype._seek=function(t,e){this[o].seek(t,e)},t.prototype._close=function(t){this[o].close(t)}}e.DefaultKeyIterator=u,e.DefaultValueIterator=h},593:(t,e,r)=>{"use strict";const{AbstractIterator:n,AbstractKeyIterator:i,AbstractValueIterator:o}=r(961),s=r(473),a=Symbol("nut"),c=Symbol("undefer"),u=Symbol("factory");class h extends n{constructor(t,e){super(t,e),this[a]=null,this[u]=()=>t.iterator(e),this.db.defer((()=>this[c]()))}}class l extends i{constructor(t,e){super(t,e),this[a]=null,this[u]=()=>t.keys(e),this.db.defer((()=>this[c]()))}}class f extends o{constructor(t,e){super(t,e),this[a]=null,this[u]=()=>t.values(e),this.db.defer((()=>this[c]()))}}for(const t of[h,l,f])t.prototype[c]=function(){"open"===this.db.status&&(this[a]=this[u]())},t.prototype._next=function(t){null!==this[a]?this[a].next(t):"opening"===this.db.status?this.db.defer((()=>this._next(t))):this.nextTick(t,new s("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(t,e,r){null!==this[a]?this[a].nextv(t,e,r):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,r))):this.nextTick(r,new s("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._all=function(t,e){null!==this[a]?this[a].all(e):"opening"===this.db.status?this.db.defer((()=>this._all(t,e))):this.nextTick(e,new s("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._seek=function(t,e){null!==this[a]?this[a]._seek(t,e):"opening"===this.db.status&&this.db.defer((()=>this._seek(t,e)))},t.prototype._close=function(t){null!==this[a]?this[a].close(t):"opening"===this.db.status?this.db.defer((()=>this._close(t))):this.nextTick(t)};e.DeferredIterator=h,e.DeferredKeyIterator=l,e.DeferredValueIterator=f},909:(t,e,r)=>{"use strict";const n=r(375);t.exports=function(t,...e){0===e.length?n(t):n((()=>t(...e)))}},56:(t,e,r)=>{"use strict";const n=r(473),i=Object.prototype.hasOwnProperty,o=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const r={};for(const s in t)if(i.call(t,s)&&"keyEncoding"!==s&&"valueEncoding"!==s){if("start"===s||"end"===s)throw new n(`The legacy range option '${s}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===s)throw new n("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});o.has(s)?r[s]=e.encode(t[s]):r[s]=t[s]}return r.reverse=!!r.reverse,r.limit=Number.isInteger(r.limit)&&r.limit>=0?r.limit:-1,r}},742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],c=o[1],u=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,c)),h=0,l=c>0?s-4:s;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],u[h++]=e>>16&255,u[h++]=e>>8&255,u[h++]=255&e;return 2===c&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,u[h++]=255&e),1===c&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,u[h++]=e>>8&255,u[h++]=255&e),u},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,u=n-i;a<u;a+=s)o.push(c(t,a,a+s>u?u:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,s=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},708:(t,e,r)=>{"use strict";const{AbstractLevel:n}=r(875),i=r(473),o=r(967),{fromCallback:s}=r(957),{Iterator:a}=r(212),c=r(687),u=r(968),h=r(217),l="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),y=Symbol("location"),p=Symbol("version"),g=Symbol("store"),w=Symbol("onComplete"),b=Symbol("promise");class m extends n{constructor(t,e,r){if("function"==typeof e||"function"==typeof r)throw new i("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:n,version:o,...s}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},s),"string"!=typeof t)throw new Error("constructor requires a location string argument");this[y]=t,this[d]=null==n?l:n,this[p]=parseInt(o||1,10),this[f]=null}get location(){return this[y]}get namePrefix(){return this[d]}get version(){return this[p]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const r=indexedDB.open(this[d]+this[y],this[p]);r.onerror=function(){e(r.error||new Error("unknown error"))},r.onsuccess=()=>{this[f]=r.result,e()},r.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[y])||e.createObjectStore(this[y])}}[g](t){return this[f].transaction([this[y]],t).objectStore(this[y])}[w](t,e){const r=t.transaction;r.onabort=function(){e(r.error||new Error("aborted by user"))},r.oncomplete=function(){e(null,t.result)}}_get(t,e,r){const n=this[g]("readonly");let o;try{o=n.get(t)}catch(t){return this.nextTick(r,t)}this[w](o,(function(t,e){return t?r(t):void 0===e?r(new i("Entry not found",{code:"LEVEL_NOT_FOUND"})):void r(null,c(e))}))}_getMany(t,e,r){const n=this[g]("readonly"),i=t.map((t=>e=>{let r;try{r=n.get(t)}catch(t){return e(t)}r.onsuccess=()=>{const t=r.result;e(null,void 0===t?t:c(t))},r.onerror=t=>{t.stopPropagation(),e(r.error)}}));o(i,16,r)}_del(t,e,r){const n=this[g]("readwrite");let i;try{i=n.delete(t)}catch(t){return this.nextTick(r,t)}this[w](i,r)}_put(t,e,r,n){const i=this[g]("readwrite");let o;try{o=i.put(e,t)}catch(t){return this.nextTick(n,t)}this[w](o,n)}_iterator(t){return new a(this,this[y],t)}_batch(t,e,r){const n=this[g]("readwrite"),i=n.transaction;let o,s=0;i.onabort=function(){r(o||i.error||new Error("aborted by user"))},i.oncomplete=function(){r()},function e(){const r=t[s++],a=r.key;let c;try{c="del"===r.type?n.delete(a):n.put(r.value,a)}catch(t){return o=t,void i.abort()}s<t.length?c.onsuccess=e:"function"==typeof i.commit&&i.commit()}()}_clear(t,e){let r,n;try{r=h(t)}catch(t){return this.nextTick(e)}if(t.limit>=0)return u(this,this[y],r,t,e);try{const t=this[g]("readwrite");n=r?t.delete(r):t.clear()}catch(t){return this.nextTick(e,t)}this[w](n,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,r){"function"==typeof e&&(r=e,e=l),r=s(r,b);const n=indexedDB.deleteDatabase(e+t);return n.onsuccess=function(){r()},n.onerror=function(t){r(t)},r[b]},e.BrowserLevel=m},212:(t,e,r)=>{"use strict";const{AbstractIterator:n}=r(875),i=r(217),o=r(687),s=Symbol("cache"),a=Symbol("finished"),c=Symbol("options"),u=Symbol("currentOptions"),h=Symbol("position"),l=Symbol("location"),f=Symbol("first"),d={};function y(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends n{constructor(t,e,r){super(t,r),this[s]=[],this[a]=0===this.limit,this[c]=r,this[u]={...r},this[h]=void 0,this[l]=e,this[f]=!0}_nextv(t,e,r){if(this[f]=!1,this[a])return this.nextTick(r,null,[]);if(this[s].length>0)return t=Math.min(t,this[s].length),this.nextTick(r,null,this[s].splice(0,t));let n;void 0!==this[h]&&(this[c].reverse?(this[u].lt=this[h],this[u].lte=void 0):(this[u].gt=this[h],this[u].gte=void 0));try{n=i(this[u])}catch(t){return this[a]=!0,this.nextTick(r,null,[])}const d=this.db.db.transaction([this[l]],"readonly"),p=d.objectStore(this[l]),g=[];if(this[c].reverse)p[!this[c].values&&p.openKeyCursor?"openKeyCursor":"openCursor"](n,"prev").onsuccess=e=>{const r=e.target.result;if(r){const{key:e,value:n}=r;this[h]=e,g.push([this[c].keys&&void 0!==e?o(e):void 0,this[c].values&&void 0!==n?o(n):void 0]),g.length<t?r.continue():y(d)}else this[a]=!0};else{let e,r;const i=()=>{if(void 0===e||void 0===r)return;const n=Math.max(e.length,r.length);0===n||t===1/0?this[a]=!0:this[h]=e[n-1],g.length=n;for(let t=0;t<n;t++){const n=e[t],i=r[t];g[t]=[this[c].keys&&void 0!==n?o(n):void 0,this[c].values&&void 0!==i?o(i):void 0]}y(d)};this[c].keys||t<1/0?p.getAllKeys(n,t<1/0?t:void 0).onsuccess=t=>{e=t.target.result,i()}:(e=[],this.nextTick(i)),this[c].values?p.getAll(n,t<1/0?t:void 0).onsuccess=t=>{r=t.target.result,i()}:(r=[],this.nextTick(i))}d.onabort=()=>{r(d.error||new Error("aborted by user")),r=null},d.oncomplete=()=>{r(null,g),r=null}}_next(t){if(this[s].length>0){const[e,r]=this[s].shift();this.nextTick(t,null,e,r)}else if(this[a])this.nextTick(t);else{let e=Math.min(100,this.limit-this.count);this[f]&&(this[f]=!1,e=1),this._nextv(e,d,((e,r)=>{if(e)return t(e);this[s]=r,this._next(t)}))}}_all(t,e){this[f]=!1;const r=this[s].splice(0,this[s].length),n=this.limit-this.count-r.length;if(n<=0)return this.nextTick(e,null,r);this._nextv(n,d,((t,n)=>{if(t)return e(t);r.length>0&&(n=r.concat(n)),e(null,n)}))}_seek(t,e){let r;this[f]=!0,this[s]=[],this[a]=!1,this[h]=void 0,this[u]={...this[c]};try{r=i(this[c])}catch(t){return void(this[a]=!0)}null===r||r.includes(t)?this[c].reverse?this[u].lte=t:this[u].gte=t:this[a]=!0}}},968:t=>{"use strict";t.exports=function(t,e,r,n,i){if(0===n.limit)return t.nextTick(i);const o=t.db.transaction([e],"readwrite"),s=o.objectStore(e);let a=0;o.oncomplete=function(){i()},o.onabort=function(){i(o.error||new Error("aborted by user"))};const c=s.openKeyCursor?"openKeyCursor":"openCursor",u=n.reverse?"prev":"next";s[c](r,u).onsuccess=function(t){const e=t.target.result;e&&(s.delete(e.key).onsuccess=function(){(n.limit<=0||++a<n.limit)&&e.continue()})}}},687:t=>{"use strict";const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},217:t=>{"use strict";t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,r=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,n=void 0===t.gte,i=void 0===t.lte;return void 0!==e&&void 0!==r?IDBKeyRange.bound(e,r,n,i):void 0!==e?IDBKeyRange.lowerBound(e,n):void 0!==r?IDBKeyRange.upperBound(r,i):null}},764:(t,e,r)=>{"use strict";const n=r(742),i=r(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=c,e.SlowBuffer=function(t){return+t!=t&&(t=0),c.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,c.prototype),e}function c(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return l(t)}return u(t,e,r)}function u(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!c.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|p(t,e);let n=a(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(W(t,Uint8Array)){const e=new Uint8Array(t);return d(e.buffer,e.byteOffset,e.byteLength)}return f(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(W(t,ArrayBuffer)||t&&W(t.buffer,ArrayBuffer))return d(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(W(t,SharedArrayBuffer)||t&&W(t.buffer,SharedArrayBuffer)))return d(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return c.from(n,e,r);const i=function(t){if(c.isBuffer(t)){const e=0|y(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Z(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return c.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function l(t){return h(t),a(t<0?0:0|y(t))}function f(t){const e=t.length<0?0:0|y(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function d(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,c.prototype),n}function y(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function p(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||W(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return K(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(t).length;default:if(i)return n?-1:K(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return U(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return C(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function w(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function b(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),Z(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function u(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(u(t,o)===u(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===c)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){let r=!0;for(let n=0;n<c;n++)if(u(t,o+n)!==u(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(Z(n))return s;t[r+s]=n}return s}function E(t,e,r,n){return J(K(e,t.length-r),t,r,n)}function x(t,e,r,n){return J(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function B(t,e,r,n){return J(G(e),t,r,n)}function A(t,e,r,n){return J(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,c;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(c=(31&e)<<6|63&r,c>127&&(o=c));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(c=(15&e)<<12|(63&r)<<6|63&n,c>2047&&(c<55296||c>57343)&&(o=c));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(c=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,c>65535&&c<1114112&&(o=c))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}e.kMaxLength=s,c.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),c.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(t,e,r){return u(t,e,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(t,e,r){return function(t,e,r){return h(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},c.allocUnsafe=function(t){return l(t)},c.allocUnsafeSlow=function(t){return l(t)},c.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==c.prototype},c.compare=function(t,e){if(W(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),W(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=c.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(W(e,Uint8Array))i+e.length>n.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},c.byteLength=p,c.prototype._isBuffer=!0,c.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)w(this,e,e+1);return this},c.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)w(this,e,e+3),w(this,e+1,e+2);return this},c.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)w(this,e,e+7),w(this,e+1,e+6),w(this,e+2,e+5),w(this,e+3,e+4);return this},c.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?S(this,0,t):g.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(t,e,r,n,i){if(W(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),u=this.slice(n,i),h=t.slice(e,r);for(let t=0;t<a;++t)if(u[t]!==h[t]){o=u[t],s=h[t];break}return o<s?-1:s<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return b(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return b(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return x(this,t,e,r);case"base64":return B(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function T(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function C(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function U(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Y[t[n]];return i}function L(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function N(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function _(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function R(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function D(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function V(t,e,r,n,o){return e=+e,r>>>=0,o||D(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||D(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,c.prototype),n},c.prototype.readUintLE=c.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},c.prototype.readUintBE=c.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,th