From 322da584a843badfd5c58c671d568272799bb535 Mon Sep 17 00:00:00 2001 From: Fergus McDowall Date: Tue, 27 Jun 2023 11:09:50 +0200 Subject: [PATCH] working for one test --- dist/search-index-4.0.0.js | 2 +- dist/search-index-esm-4.0.0.js | 2 +- dist/search-index.js | 2 +- package.json | 4 +- src/DocumentProcessor.js | 4 +- src/main.js | 43 +- src/read.js | 750 +++++++++++++++++---------------- src/tokenisationPipeline.js | 37 +- src/version.js | 1 + src/write.js | 4 +- test/src/514-test.js | 2 + test/src/init-test.js | 25 +- webpack.config.js | 21 +- 13 files changed, 459 insertions(+), 438 deletions(-) create mode 100644 src/version.js diff --git a/dist/search-index-4.0.0.js b/dist/search-index-4.0.0.js index 853a1db4..b0da28cb 100644 --- a/dist/search-index-4.0.0.js +++ b/dist/search-index-4.0.0.js @@ -1,2 +1,2 @@ /*! For license information please see search-index-4.0.0.js.LICENSE.txt */ -var SearchIndex;(()=>{var t={9464:(t,e,n)=>{"use strict";const{fromCallback:r}=n(6957),i=n(4473),{getCallback:s,getOptions:o}=n(2520),a=Symbol("promise"),c=Symbol("status"),h=Symbol("operations"),u=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[h]=[],this[l]=[],this[c]="open",this[u]=this[u].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[h].length}put(t,e,n){if("open"!==this[c])throw new i("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const r=this.db._checkKey(t)||this.db._checkValue(e);if(r)throw r;const s=n&&null!=n.sublevel?n.sublevel:this.db,o=n,a=s.keyEncoding(n&&n.keyEncoding),u=s.valueEncoding(n&&n.valueEncoding),l=a.format;n={...n,keyEncoding:l,valueEncoding:u.format},s!==this.db&&(n.sublevel=null);const f=s.prefixKey(a.encode(t),l),d=u.encode(e);return this._put(f,d,n),this[h].push({...o,type:"put",key:t,value:e}),this}_put(t,e,n){}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 n=this.db._checkKey(t);if(n)throw n;const r=e&&null!=e.sublevel?e.sublevel:this.db,s=e,o=r.keyEncoding(e&&e.keyEncoding),a=o.format;return e={...e,keyEncoding:a},r!==this.db&&(e.sublevel=null),this._del(r.prefixKey(o.encode(t),a),e),this[h].push({...s,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[h]=[],this}_clear(){}write(t,e){return e=s(t,e),e=r(e,a),t=o(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[h]),this._close(this[u])}))),e[a]}_write(t,e){}close(t){return t=r(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[u]))),t[a]}_close(t){this.nextTick(t)}[u](){this[c]="closed",this.db.detachResource(this);const t=this[l];this[l]=[];for(const e of t)e()}}},3961:(t,e,n)=>{"use strict";const{fromCallback:r}=n(6957),i=n(4473),{getOptions:s,getCallback:o}=n(2520),a=Symbol("promise"),c=Symbol("callback"),h=Symbol("working"),u=Symbol("handleOne"),l=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){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[b]=!1,this[E]=[],this[h]=!1,this[y]=!1,this[f]=!1,this[c]=null,this[u]=this[u].bind(this),this[l]=this[l].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,r,i)=>{t?n(t):this[_]?void 0===r&&void 0===i?e():e([r,i]):e(r)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new i("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(t,new i("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[h]=!0,this[c]=t,this[O]>=this[L]?this.nextTick(this[u],null):this._next(this[u])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=o(e,n),n=r(n,a),e=s(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new i("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(n,new i("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[h]=!0,this[c]=n,t<=0?this.nextTick(this[l],null,[]):this._nextv(t,e,this[l])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const r=[],i=(e,s,o)=>e?n(e):(this[_]?void 0===s&&void 0===o:void 0===s)?n(null,r):(r.push(this[_]?[s,o]:s),void(r.length===t?n(null,r):this._next(i)));this._next(i)}all(t,e){return e=o(t,e),e=r(e,a),t=s(t,A),this[y]?this.nextTick(e,new i("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(e,new i("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[h]=!0,this[c]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[l],null,[]):this._all(t,this[l])),e[a]}_all(t,e){let n=this[O];const r=[],i=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,r):this._nextv(t,A,s)},s=(t,s)=>{t?e(t):0===s.length?e(null,r):(r.push.apply(r,s),n+=s.length,i())};i()}[d](){const t=this[c];return this[w]&&null===t?k:(this[h]=!1,this[c]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=s(e,A),this[y]);else{if(this[h])throw new i("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),r=n.format;e.keyEncoding!==r&&(e={...e,keyEncoding:r});const i=this.db.prefixKey(n.encode(t),r);this._seek(i,e)}}}_seek(t,e){throw new i("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=r(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[h]?this[w]&&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[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[u](t,e,n){const r=this[d]();if(t)return r(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return r(new C("entry",t))}void 0===e&&void 0===n||this[O]++,r(null,e,n)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!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 C 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(I.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"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[u](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t{"use strict";const{supports:r}=n(3658),{Transcoder:i}=n(8499),{EventEmitter:s}=n(7187),{fromCallback:o}=n(6957),a=n(4473),{AbstractIterator:c}=n(3961),{DefaultKeyIterator:h,DefaultValueIterator:u}=n(5429),{DeferredIterator:l,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C extends s{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:n,valueEncoding:s,passive:o,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=r(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[k]=new i(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(s||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=o(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=o(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const r=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(r);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),c=i.format,h=s.format;return e.keyEncoding===c&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:c,valueEncoding:h})),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)),n(t);try{e=s.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const r=this.keyEncoding(e.keyEncoding),i=this.valueEncoding(e.valueEncoding),s=r.format,c=i.format;e.keyEncoding===s&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:s,valueEncoding:c}));const h=new Array(t.length);for(let e=0;e{if(t)return n(t);try{for(let t=0;tthis.put(t,e,n,r))),r[E];if(D(this,r))return r[E];const i=this._checkKey(t)||this._checkValue(e);if(i)return this.nextTick(r,i),r[E];const s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=s.format,h=a.format;n.keyEncoding===c&&n.valueEncoding===h||(n=Object.assign({},n,{keyEncoding:c,valueEncoding:h}));const u=this.prefixKey(s.encode(t),c),l=a.encode(e);return this._put(u,l,n,(n=>{if(n)return r(n);this.emit("put",t,e),r()})),r[E]}_put(t,e,n,r){this.nextTick(r)}del(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),s=i.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(i.encode(t),s),e,(e=>{if(e)return n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=o(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const r=new Array(t.length),{keyEncoding:i,valueEncoding:s,...c}=e;for(let e=0;e{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=o(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,r=this.keyEncoding(t.keyEncoding);return(t=b(t,r)).keyEncoding=r.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new l(this,t);if("open"!==this[O])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),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new h(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new u(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];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 p(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"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{"use strict";e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{"use strict";const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:s}=n(3961),o=Symbol("unfix"),a=Symbol("iterator"),c=Symbol("handleOne"),h=Symbol("handleMany"),u=Symbol("callback");class l extends r{constructor(t,e,n,r){super(t,e),this[a]=n,this[o]=r,this[c]=this[c].bind(this),this[h]=this[h].bind(this),this[u]=null}[c](t,e,n){const r=this[u];if(t)return r(t);void 0!==e&&(e=this[o](e)),r(t,e,n)}[h](t,e){const n=this[u];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[o](e))}n(t,e)}}class f extends i{constructor(t,e,n,r){super(t,e),this[a]=n,this[o]=r,this[c]=this[c].bind(this),this[h]=this[h].bind(this),this[u]=null}[c](t,e){const n=this[u];if(t)return n(t);void 0!==e&&(e=this[o](e)),n(t,e)}[h](t,e){const n=this[u];if(t)return n(t);for(let t=0;t{"use strict";const r=n(4473),{Buffer:i}=n(8764)||{},{AbstractSublevelIterator:s,AbstractSublevelKeyIterator:o,AbstractSublevelValueIterator:a}=n(2970),c=Symbol("prefix"),h=Symbol("upperBound"),u=Symbol("prefixRange"),l=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new r("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new r("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,i){const{separator:s,manifest:o,...a}=e.defaults(i);n=m(n,s);const u=s.charCodeAt(0)+1,p=t[l]||t;if(!d.encode(n).every((t=>t>u&&t<127)))throw new r(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,o),a);const g=(t.prefix||"")+s+n+s,v=g.slice(0,-1)+String.fromCharCode(u);this[l]=p,this[c]=new b(g),this[h]=new b(v),this[f]=new E,this.nextTick=p.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,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[c].buffer;return i.concat([e,t],e.byteLength+t.byteLength)}}[u](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[h][e]}get prefix(){return this[c].utf8}get db(){return this[l]}_open(t,e){this[l].open({passive:!0},e)}_put(t,e,n,r){this[l].put(t,e,n,r)}_get(t,e,n){this[l].get(t,e,n)}_getMany(t,e,n){this[l].getMany(t,e,n)}_del(t,e,n){this[l].del(t,e,n)}_batch(t,e,n){this[l].batch(t,e,n)}_clear(t,e){this[u](t,t.keyEncoding),this[l].clear(t,e)}_iterator(t){this[u](t,t.keyEncoding);const e=this[l].iterator(t),n=this[f].get(this[c].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_keys(t){this[u](t,t.keyEncoding);const e=this[l].keys(t),n=this[f].get(this[c].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_values(t){this[u](t,t.keyEncoding);const e=this[l].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=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 b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=i?i.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="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,n)),n}}const m=function(t,e){let n=0,r=t.length;for(;nn&&t[r-1]===e;)r--;return t.slice(n,r)}},2520:(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:{}}},4765:(t,e,n)=>{"use strict";const{AbstractChainedBatch:r}=n(9464),i=n(4473),s=Symbol("encoded");e.DefaultChainedBatch=class extends r{constructor(t){super(t),this[s]=[]}_put(t,e,n){this[s].push({...n,type:"put",key:t,value:e})}_del(t,e){this[s].push({...e,type:"del",key:t})}_clear(){this[s]=[]}_write(t,e){"opening"===this.db.status?this.db.defer((()=>this._write(t,e))):"open"===this.db.status?0===this[s].length?this.nextTick(e):this.db._batch(this[s],t,e):this.nextTick(e,new i("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},5429:(t,e,n)=>{"use strict";const{AbstractKeyIterator:r,AbstractValueIterator:i}=n(3961),s=Symbol("iterator"),o=Symbol("callback"),a=Symbol("handleOne"),c=Symbol("handleMany");class h extends r{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}class u extends i{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}for(const t of[h,u]){const e=t===h,n=e?t=>t[0]:t=>t[1];t.prototype._next=function(t){this[o]=t,this[s].next(this[a])},t.prototype[a]=function(t,n,r){const i=this[o];t?i(t):i(null,e?n:r)},t.prototype._nextv=function(t,e,n){this[o]=n,this[s].nextv(t,e,this[c])},t.prototype._all=function(t,e){this[o]=e,this[s].all(t,this[c])},t.prototype[c]=function(t,e){const r=this[o];t?r(t):r(null,e.map(n))},t.prototype._seek=function(t,e){this[s].seek(t,e)},t.prototype._close=function(t){this[s].close(t)}}e.DefaultKeyIterator=h,e.DefaultValueIterator=u},593:(t,e,n)=>{"use strict";const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:s}=n(3961),o=n(4473),a=Symbol("nut"),c=Symbol("undefer"),h=Symbol("factory");class u extends r{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.iterator(e),this.db.defer((()=>this[c]()))}}class l extends i{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.keys(e),this.db.defer((()=>this[c]()))}}class f extends s{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.values(e),this.db.defer((()=>this[c]()))}}for(const t of[u,l,f])t.prototype[c]=function(){"open"===this.db.status&&(this[a]=this[h]())},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 o("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(t,e,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,new o("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 o("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=u,e.DeferredKeyIterator=l,e.DeferredValueIterator=f},6909:(t,e,n)=>{"use strict";const r=n(4375);t.exports=function(t,...e){0===e.length?r(t):r((()=>t(...e)))}},56:(t,e,n)=>{"use strict";const r=n(4473),i=Object.prototype.hasOwnProperty,s=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const o in t)if(i.call(t,o)&&"keyEncoding"!==o&&"valueEncoding"!==o){if("start"===o||"end"===o)throw new r(`The legacy range option '${o}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===o)throw new r("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});s.has(o)?n[o]=e.encode(t[o]):n[o]=t[o]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{"use strict";e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,s=a(t),o=s[0],c=s[1],h=new i(function(t,e,n){return 3*(e+n)/4-n}(0,o,c)),u=0,l=c>0?o-4:o;for(n=0;n>16&255,h[u++]=e>>8&255,h[u++]=255&e;return 2===c&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,h[u++]=255&e),1===c&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,h[u++]=e>>8&255,h[u++]=255&e),h},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=16383,a=0,h=r-i;ah?h:a+o));return 1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,r){for(var i,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},1708:(t,e,n)=>{"use strict";const{AbstractLevel:r}=n(875),i=n(4473),s=n(9967),{fromCallback:o}=n(6957),{Iterator:a}=n(8212),c=n(9687),h=n(9968),u=n(1217),l="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends r{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new i("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:r,version:s,...o}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},o),"string"!=typeof t)throw new Error("constructor requires a location string argument");this[p]=t,this[d]=null==r?l:r,this[y]=parseInt(s||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const r=this[g]("readonly");let s;try{s=r.get(t)}catch(t){return this.nextTick(n,t)}this[b](s,(function(t,e){return t?n(t):void 0===e?n(new i("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,c(e))}))}_getMany(t,e,n){const r=this[g]("readonly"),i=t.map((t=>e=>{let n;try{n=r.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:c(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));s(i,16,n)}_del(t,e,n){const r=this[g]("readwrite");let i;try{i=r.delete(t)}catch(t){return this.nextTick(n,t)}this[b](i,n)}_put(t,e,n,r){const i=this[g]("readwrite");let s;try{s=i.put(e,t)}catch(t){return this.nextTick(r,t)}this[b](s,r)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const r=this[g]("readwrite"),i=r.transaction;let s,o=0;i.onabort=function(){n(s||i.error||new Error("aborted by user"))},i.oncomplete=function(){n()},function e(){const n=t[o++],a=n.key;let c;try{c="del"===n.type?r.delete(a):r.put(n.value,a)}catch(t){return s=t,void i.abort()}o=0)return h(this,this[p],n,t,e);try{const t=this[g]("readwrite");r=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](r,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=l),n=o(n,E);const r=indexedDB.deleteDatabase(e+t);return r.onsuccess=function(){n()},r.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{"use strict";const{AbstractIterator:r}=n(875),i=n(1217),s=n(9687),o=Symbol("cache"),a=Symbol("finished"),c=Symbol("options"),h=Symbol("currentOptions"),u=Symbol("position"),l=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends r{constructor(t,e,n){super(t,n),this[o]=[],this[a]=0===this.limit,this[c]=n,this[h]={...n},this[u]=void 0,this[l]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[o].length>0)return t=Math.min(t,this[o].length),this.nextTick(n,null,this[o].splice(0,t));let r;void 0!==this[u]&&(this[c].reverse?(this[h].lt=this[u],this[h].lte=void 0):(this[h].gt=this[u],this[h].gte=void 0));try{r=i(this[h])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[l]],"readonly"),y=d.objectStore(this[l]),g=[];if(this[c].reverse)y[!this[c].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](r,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:r}=n;this[u]=e,g.push([this[c].keys&&void 0!==e?s(e):void 0,this[c].values&&void 0!==r?s(r):void 0]),g.length{if(void 0===e||void 0===n)return;const r=Math.max(e.length,n.length);0===r||t===1/0?this[a]=!0:this[u]=e[r-1],g.length=r;for(let t=0;t{e=t.target.result,i()}:(e=[],this.nextTick(i)),this[c].values?y.getAll(r,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,i()}:(n=[],this.nextTick(i))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[o].length>0){const[e,n]=this[o].shift();this.nextTick(t,null,e,n)}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,n)=>{if(e)return t(e);this[o]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[o].splice(0,this[o].length),r=this.limit-this.count-n.length;if(r<=0)return this.nextTick(e,null,n);this._nextv(r,d,((t,r)=>{if(t)return e(t);n.length>0&&(r=n.concat(r)),e(null,r)}))}_seek(t,e){let n;this[f]=!0,this[o]=[],this[a]=!1,this[u]=void 0,this[h]={...this[c]};try{n=i(this[c])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[c].reverse?this[h].lte=t:this[h].gte=t:this[a]=!0}}},9968:t=>{"use strict";t.exports=function(t,e,n,r,i){if(0===r.limit)return t.nextTick(i);const s=t.db.transaction([e],"readwrite"),o=s.objectStore(e);let a=0;s.oncomplete=function(){i()},s.onabort=function(){i(s.error||new Error("aborted by user"))};const c=o.openKeyCursor?"openKeyCursor":"openCursor",h=r.reverse?"prev":"next";o[c](n,h).onsuccess=function(t){const e=t.target.result;e&&(o.delete(e.key).onsuccess=function(){(r.limit<=0||++a{"use strict";const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{"use strict";t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,r=void 0===t.gte,i=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,r,i):void 0!==e?IDBKeyRange.lowerBound(e,r):void 0!==n?IDBKeyRange.upperBound(n,i):null}},8764:(t,e,n)=>{"use strict";const r=n(9742),i=n(645),s="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 o=2147483647;function a(t){if(t>o)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,n){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 h(t,e,n)}function h(t,e,n){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 n=0|y(t,e);let r=a(n);const i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return c.from(r,e,n);const i=function(t){if(c.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(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,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(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 u(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(i)return r?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function E(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){let s,o=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){let r=-1;for(s=n;sa&&(n=a-c),s=n;s>=0;s--){let n=!0;for(let r=0;ri&&(r=i):r=i;const s=e.length;let o;for(r>s/2&&(r=s/2),o=0;o>8,i=n%256,s.push(i),s.push(r);return s}(e,t.length-n),t,n,r)}function L(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+o<=n){let n,r,a,c;switch(o){case 1:e<128&&(s=e);break;case 2:n=t[i+1],128==(192&n)&&(c=(31&e)<<6|63&n,c>127&&(s=c));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(c=(15&e)<<12|(63&n)<<6|63&r,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=o}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",r=0;for(;rr.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},c.byteLength=y,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;en&&(t+=" ... "),""},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(t,e,n,r,i){if(Y(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===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(e>>>=0);const a=Math.min(s,o),h=this.slice(r,i),u=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let s=!1;for(;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;ir)&&(n=r);let i="";for(let r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function D(t,e,n,r,i){z(e,r,i,t,n,7);let s=Number(e&BigInt(4294967295));t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,n}function U(t,e,n,r,i){z(e,r,i,t,n,7);let s=Number(e&BigInt(4294967295));t[n+7]=s,s>>=8,t[n+6]=s,s>>=8,t[n+5]=s,s>>=8,t[n+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=o,o>>=8,t[n+2]=o,o>>=8,t[n+1]=o,o>>=8,t[n]=o,n+8}function P(t,e,n,r,i,s){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,r,s){return e=+e,n>>>=0,s||P(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,s){return e=+e,n>>>=0,s||P(t,0,n,8),i.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,s=0;for(;++s>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,s=0;for(;++s=i&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=e,i=1,s=this[t+--r];for(;r>0&&(i*=256);)s+=this[t+--r]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||N(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,s=0;for(this[e]=255&t;++s>>=0,n>>>=0,r||N(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=Q((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let i=0,s=1,o=0;for(this[e]=255&t;++i>0)-o&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let i=n-1,s=1,o=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===o&&0!==this[e+i+1]&&(o=1),this[e+i]=(t/s>>0)-o&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=Q((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,s){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(s+1)}${r}`:`>= -(2${r} ** ${8*(s+1)-1}${r}) and < 2 ** ${8*(s+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(r,i,s)}function G(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=V(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=V(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const r=t.length;let i=null;const s=[];for(let o=0;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6957:(t,e,n)=>{"use strict";var r=n(886);e.fromCallback=function(t,e){if(void 0===t){var n=new Promise((function(e,n){t=function(t,r){t?n(t):e(r)}}));t[void 0!==e?e:"promise"]=n}else if("function"!=typeof t)throw new TypeError("Callback must be a function");return t},e.fromPromise=function(t,e){if(void 0===e)return t;t.then((function(t){r((()=>e(null,t)))})).catch((function(t){r((()=>e(t)))}))}},886:t=>{t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t)},8840:(t,e)=>{function n(t){for(var e="",n=0;n0?"F"+o:"D"+n(o)},e.decode=function(t){if("DaN"===t)return NaN;if("FF"===t)return 1/0;if("DD"===t)return-1/0;var e="D"===t[0],r=(e?n(t):t).slice(2).split("M");return Number((e?"-":"")+r[1]+"e"+String(Number(r[0])-500))}},2833:(t,e)=>{var n={"?":"?@","!":"??",'"':"?%"},r={"?@":"?","??":"!","?%":'"'};e.factory=function(t){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,i=e.split('"'),s=[[]],o=0,a=i.length,c=0;c{var r=n(8840),i=n(2833);e.flip=function(t){var e=t.toString(),n="";for(var r in e)n+="."==e[r]?".":9-+e[r];return n},e.number=r,e.string={encode:function(t){return/\x00|\x01/.test(t)?"J"+t.replace(/\x01/g,"").replace(/\x00/g,""):"J"+t},decode:function(t){if("J"===t[0])return t.substring(1)}},e.encode=function(t){return e[typeof t].encode(t)},e.decode=function(t){if(""===t)return t;if(!s[t[0]])throw new Error("no decoder for:"+JSON.stringify(t));return s[t[0]](t)},e.object=i.factory(e),e.boolean={encode:function(t){return t?"C":"B"},decode:function(t){return"C"===t}},e.undefined={encode:function(t){return"L"},decode:function(){}};var s={A:e.object.decode,B:e.boolean.decode,C:e.boolean.decode,D:e.number.decode,F:e.number.decode,J:e.string.decode,K:e.object.decode,L:e.undefined.decode};e.buffer=!1,e.type="charwise"},6729:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,r,s,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,s||t,o),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i{"use strict";var e,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise((function(n,r){function i(n){t.removeListener(e,s),r(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}y(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function h(t,e,n,r){var i,s,o,h;if(a(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=c(t))>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,h=u,console&&console.warn&&console.warn(h)}return t}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=u.bind(r);return i.listener=n,r.wrapFn=i,i}function f(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var h=c.length,u=p(c,h);for(n=0;n=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9203:(t,e,n)=>{const r=n(7270),{BrowserLevel:i}=n(1708);t.exports=({name:t="fii",...e})=>r({db:new i(t),...e})},7270:(t,e,n)=>{const r=n(9563),i=n(8936),s=n(1387),o=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELDe.FIELD?1:t.VALUEe.VALUE?1:t.SCOREe.SCORE?1:0)),t))),a=t=>{const e=r(t),n=i(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(o),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(o),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:s,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(o),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(o),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const r=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;r.open((i=>i?n(i):e(Object.assign(t,{_db:r}))))})))(t).then(a)},1387:(t,e,n)=>{const r=n(2483);t.exports={keyEncoding:r,valueEncoding:"json"}},6782:t=>{const e=null,n=void 0;t.exports=(t,r)=>new Promise(((i,s)=>{if(Array.isArray(t))return s(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return i({FIELD:r,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return i({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?i(Object.assign(t,{FIELD:r})):(t.FIELD=[t.FIELD].flat(),i(t))}))},9563:(t,e,n)=>{const r=n(6782),i=n(2483),{EntryStream:s}=n(6741),o=n(1387);i.LO=null,i.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>r(t,await l()),a=async(e,r=(t=>new Promise((e=>e(t)))))=>new Promise((async(i,s)=>{const o=t=>void 0===t?i(void 0):t instanceof Promise?i(t):void 0;try{o(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),o(e=await(e=>void 0===e?u(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?c(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),o(e=await r(e))}catch(t){return s(t)}return Array.isArray(e)?i(e):i(u(e))})),c=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),h=(t,e,n)=>{const r=[];return void 0===e&&"number"!=typeof e||r.push(e),n&&r.push(i.HI),["IDX",t,r]},u=e=>new Promise((n=>{if(void 0===e)return n(void 0);const r=new Map;return Promise.all(e.FIELD.map((n=>new Promise((i=>new s(t._db,{gte:h(n,e.VALUE.GTE),lte:h(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...o}).on("data",(t=>t.value.forEach((e=>r.set(e,[...r.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",i)))))).then((()=>n(Array.from(r.keys()).map((t=>({_id:t,_match:r.get(t)}))))))})),l=()=>new Promise((e=>{const n=[];new s(t._db,{gte:["FIELD",i.LO],lte:["FIELD",i.HI],...o}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,r)=>{const i=[];new s(t._db,{...e,...o}).on("data",(t=>{i.push(t)})).on("end",(()=>n(i)))})),y=(t,e)=>n(t).then((t=>u(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let r=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(r+=" "),p({gte:h(e,r),lte:h(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:h(e,t.VALUE.GTE),lte:h(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],o),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],o).catch((t=>null))))).then((t=>t.reduce(((t,n,r)=>(null!=n&&t.push(e[r]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:l,GET:a,INTERSECTION:(t,e)=>c(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],o),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],o).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:c,parseToken:n}}},8936:(t,e,n)=>{const r=n(3692),i=n(9563),s=n(1387);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const i=[];return r(e._object).forEach((function(e){const r=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==r&&!n.doNotIndexField.filter((t=>r.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([r,[this.node].flat(1/0)]);i.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:i}},o=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(r,a,c,h,u)=>new Promise((l=>{r=r.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),u=Object.assign(t,u),i(t).EXIST(...r.map((t=>t._id))).then((t=>((t,e,n)=>{const r=Object.keys(t);return Promise.all(r.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,r)=>e.get(t,s).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,i)=>{const s=new Set(e),o=new Set(t[r[i]]);if("put"===n)return{key:["IDX",...JSON.parse(r[i])],type:n,value:[...new Set([...s,...o])].sort()};if("del"===n){const t=[...new Set([...s].filter((t=>!o.has(t))))];return{key:["IDX",...JSON.parse(r[i])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(o,{}))(r,u),a,c).then((e=>a.batch(e.concat(u.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(r,c):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),s,(e=>l(r.map((e=>{let n;return"put"===c?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===c&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:h,status:n}})))))))))})),c=e=>t._db.put(["~LAST_UPDATED"],Date.now(),s).then((()=>e));return{DELETE:e=>i(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(c),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),s))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(c),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],s).then().catch((e=>t._db.put(["~CREATED"],Date.now(),s).then(c))),TIMESTAMP_LAST_UPDATED:c}}},645:(t,e)=>{e.read=function(t,e,n,r,i){var s,o,a=8*i-r-1,c=(1<>1,u=-7,l=n?i-1:0,f=n?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-u)-1,d>>=-u,u+=a;u>0;s=256*s+t[e+l],l+=f,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=256*o+t[e+l],l+=f,u-=8);if(0===s)s=1-h;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=h}return(d?-1:1)*o*Math.pow(2,s-r)},e.write=function(t,e,n,r,i,s){var o,a,c,h=8*s-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(o++,c/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*c-1)*Math.pow(2,i),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;t[n+d]=255&a,d+=p,a/=256,i-=8);for(o=o<0;t[n+d]=255&o,d+=p,o/=256,h-=8);t[n+d-p]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},6741:(t,e,n)=>{"use strict";const{Readable:r}=n(8473),i=Symbol("iterator"),s=Symbol("nextv");class o extends r{constructor(t,e,n){const{highWaterMark:r,...o}=n||{};super({objectMode:!0,highWaterMark:r||1e3}),this[i]=t[e](o),this[s]=this[s].bind(this),this.once("end",this.destroy.bind(this,null,null))}get db(){return this[i].db}_read(t){this.destroyed||this[i].nextv(t,this[s])}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const t of e)this.push(t)}}_destroy(t,e){this[i].close((function(n){e(t||n)}))}}e.EntryStream=class extends o{constructor(t,e){super(t,"iterator",{...e,keys:!0,values:!0})}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const[t,n]of e)this.push({key:t,value:n})}}},e.KeyStream=class extends o{constructor(t,e){super(t,"keys",e)}},e.ValueStream=class extends o{constructor(t,e){super(t,"values",e)}}},8499:(t,e,n)=>{"use strict";const r=n(4473),i=n(8002),{Encoding:s}=n(8266),{BufferFormat:o,ViewFormat:a,UTF8Format:c}=n(2376),h=Symbol("formats"),u=Symbol("encodings"),l=new Set(["buffer","view","utf8"]);e.Transcoder=class{constructor(t){if(!Array.isArray(t))throw new TypeError("The first argument 'formats' must be an array");if(!t.every((t=>l.has(t))))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[u]=new Map,this[h]=new Set(t);for(const t in i)try{this.encoding(t)}catch(t){if("LEVEL_ENCODING_NOT_SUPPORTED"!==t.code)throw t}}encodings(){return Array.from(new Set(this[u].values()))}encoding(t){let e=this[u].get(t);if(void 0===e){if("string"==typeof t&&""!==t){if(e=d[t],!e)throw new r(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if("object"!=typeof t||null===t)throw new TypeError("First argument 'encoding' must be a string or object");e=function(t){if(t instanceof s)return t;const e="type"in t&&"string"==typeof t.type?t.type:void 0,n=t.name||e||"anonymous-"+p++;switch(function(t){return"format"in t&&void 0!==t.format?t.format:"buffer"in t&&"boolean"==typeof t.buffer?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}(t)){case"view":return new a({...t,name:n});case"utf8":return new c({...t,name:n});case"buffer":return new o({...t,name:n});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}(t)}const{name:n,format:i}=e;if(!this[h].has(i))if(this[h].has("view"))e=e.createViewTranscoder();else if(this[h].has("buffer"))e=e.createBufferTranscoder();else{if(!this[h].has("utf8"))throw new r(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});e=e.createUTF8Transcoder()}for(const r of[t,n,e.name,e.commonName])this[u].set(r,e)}return e}};const f={binary:i.buffer,"utf-8":i.utf8},d={...i,...f};let p=0},8266:(t,e,n)=>{"use strict";const r=n(4473),i=new Set(["buffer","view","utf8"]);e.Encoding=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,"function"!=typeof this.encode)throw new TypeError("The 'encode' property must be a function");if("function"!=typeof this.decode)throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),"string"!=typeof this.name||""===this.name)throw new TypeError("The 'name' property must be a string");if("string"!=typeof this.format||!i.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}},8002:(t,e,n)=>{"use strict";const{Buffer:r}=n(8764)||{Buffer:{isBuffer:()=>!1}},{textEncoder:i,textDecoder:s}=n(4005)(),{BufferFormat:o,ViewFormat:a,UTF8Format:c}=n(2376),h=t=>t;e.utf8=new c({encode:function(t){return r.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?s.decode(t):String(t)},decode:h,name:"utf8",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.encode(t)},decode:function(t){return s.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new o({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}}),e.json=new c({encode:JSON.stringify,decode:JSON.parse,name:"json"}),e.buffer=new o({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:h,name:"buffer",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.from(String(t),"utf8")},decode:function(t){return r.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}}),e.view=new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.encode(t)},decode:h,name:"view",createBufferTranscoder(){return new o({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:h,name:`${this.name}+buffer`})}}),e.hex=new o({encode:function(t){return r.isBuffer(t)?t:r.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"}),e.base64=new o({encode:function(t){return r.isBuffer(t)?t:r.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})},2376:(t,e,n)=>{"use strict";const{Buffer:r}=n(8764)||{},{Encoding:i}=n(8266),s=n(4005);class o extends i{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:t=>this.decode(r.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class a extends i{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new o({encode:t=>{const e=this.encode(t);return r.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}e.BufferFormat=o,e.ViewFormat=a,e.UTF8Format=class extends i{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new o({encode:t=>r.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){const{textEncoder:t,textDecoder:e}=s();return new a({encode:e=>t.encode(this.encode(e)),decode:t=>this.decode(e.decode(t)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}},4005:t=>{"use strict";let e=null;t.exports=function(){return null===e&&(e={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),e}},4473:t=>{"use strict";t.exports=class extends Error{constructor(t,e){super(t||""),"object"==typeof e&&null!==e&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}},6349:function(t,e){!function(t){"use strict";const e=function(t,e){return t.slice(e-1).map(((n,r)=>t.slice(r,r+e)))};t.ngraminator=function(t,n){return n.reduce(((n,r)=>[...e(t,r),...n]),[]).sort()},Object.defineProperty(t,"__esModule",{value:!0})}(e)},4155:t=>{var e,n,r=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var a,c=[],h=!1,u=-1;function l(){h&&a&&(h=!1,a.length?c=a.concat(c):u=-1,c.length&&f())}function f(){if(!h){var t=o(l);h=!0;for(var e=c.length;e;){for(a=c,c=[];++u1)for(var n=1;n{let r;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:n.g):t=>(r||(r=Promise.resolve())).then(t).catch((t=>setTimeout((()=>{throw t}),0)))},4281:t=>{"use strict";var e={};function n(t,n,r){r||(r=Error);var i=function(t){var e,r;function i(e,r,i){return t.call(this,function(t,e,r){return"string"==typeof n?n:n(t,e,r)}(e,r,i))||this}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,i}(r);i.prototype.name=r.name,i.prototype.code=t,e[t]=i}function r(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(t){return String(t)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:2===n?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}n("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(t,e,n){var i,s,o,a,c;if("string"==typeof e&&(s="not ",e.substr(0,4)===s)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,n){return(void 0===n||n>t.length)&&(n=t.length),t.substring(n-9,n)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(r(e,"type"));else{var h=("number"!=typeof c&&(c=0),c+1>(a=t).length||-1===a.indexOf(".",c)?"argument":"property");o='The "'.concat(t,'" ').concat(h," ").concat(i," ").concat(r(e,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},6753:(t,e,n)=>{"use strict";var r=n(4155),i=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=u;var s=n(9481),o=n(4229);n(5717)(u,s);for(var a=i(o.prototype),c=0;c{"use strict";t.exports=i;var r=n(4605);function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}n(5717)(i,r),i.prototype._transform=function(t,e,n){n(null,t)}},9481:(t,e,n)=>{"use strict";var r,i=n(4155);t.exports=L,L.ReadableState=S,n(7187).EventEmitter;var s,o=function(t,e){return t.listeners(e).length},a=n(2503),c=n(8764).Buffer,h=n.g.Uint8Array||function(){},u=n(4616);s=u&&u.debuglog?u.debuglog("stream"):function(){};var l,f,d,p=n(7327),y=n(1195),g=n(2457).getHighWaterMark,b=n(4281).q,E=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(5717)(L,a);var _=y.errorOrDestroy,T=["error","close","destroy","pause","resume"];function S(t,e,i){r=r||n(6753),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=n(2553).s),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function L(t){if(r=r||n(6753),!(this instanceof L))return new L(t);var e=this instanceof r;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function O(t,e,n,r,i){s("readableAddChunk",e);var o,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(s("onEofChunk"),!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?R(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,a);else if(i||(o=function(t,e){var n,r;return r=e,c.isBuffer(r)||r instanceof h||"string"==typeof e||void 0===e||t.objectMode||(n=new E("chunk",["string","Buffer","Uint8Array"],e)),n}(a,e)),o)_(t,o);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r)a.endEmitted?_(t,new w):A(t,a,e,!0);else if(a.ended)_(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(e=a.decoder.write(e),a.objectMode||0!==e.length?A(t,a,e,!1):C(t,a)):A(t,a,e,!1)}else r||(a.reading=!1,C(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=k?t=k:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function R(t){var e=t._readableState;s("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(s("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(I,t))}function I(t){var e=t._readableState;s("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function U(t){s("readable nexttick read 0"),t.read(0)}function P(t,e){s("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(s("flow",e.flowing);e.flowing&&null!==t.read(););}function B(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function j(t){var e=t._readableState;s("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(F,e,t))}function F(t,e){if(s("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function V(t,e){for(var n=0,r=t.length;n=e.highWaterMark:e.length>0)||e.ended))return s("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?j(this):R(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&j(this),null;var r,i=e.needReadable;return s("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&j(this)),null!==r&&this.emit("data",r),r},L.prototype._read=function(t){_(this,new v("_read()"))},L.prototype.pipe=function(t,e){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=t;break;case 1:r.pipes=[r.pipes,t];break;default:r.pipes.push(t)}r.pipesCount+=1,s("pipe count=%d opts=%j",r.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:c;function c(){s("onend"),t.end()}r.endEmitted?i.nextTick(a):n.once("end",a),t.on("unpipe",(function e(i,o){s("onunpipe"),i===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,s("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",h),t.removeListener("error",f),t.removeListener("unpipe",e),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),u=!0,!r.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}));var h=function(t){return function(){var e=t._readableState;s("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var u=!1;function l(e){s("ondata");var i=t.write(e);s("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===t||r.pipesCount>1&&-1!==V(r.pipes,t))&&!u&&(s("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function f(e){s("onerror",e),y(),t.removeListener("error",f),0===o(t,"error")&&_(t,e)}function d(){t.removeListener("finish",p),y()}function p(){s("onfinish"),t.removeListener("close",d),y()}function y(){s("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),r.flowing||(s("pipe resume"),n.resume()),t},L.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==r.flowing&&this.resume()):"readable"===t&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,s("on readable",r.length,r.reading),r.length?R(this):r.reading||i.nextTick(U,this))),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(t,e){var n=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(D,this),n},L.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(D,this),e},L.prototype.resume=function(){var t=this._readableState;return t.flowing||(s("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(P,t,e))}(this,t)),t.paused=!1,this},L.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},L.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(s("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){s("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o{"use strict";t.exports=u;var r=n(4281).q,i=r.ERR_METHOD_NOT_IMPLEMENTED,s=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=n(6753);function h(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new s);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";var r,i=n(4155);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=L,L.WritableState=S;var o,a={deprecate:n(4927)},c=n(2503),h=n(8764).Buffer,u=n.g.Uint8Array||function(){},l=n(1195),f=n(2457).getHighWaterMark,d=n(4281).q,p=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,E=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function T(){}function S(t,e,o){r=r||n(6753),t=t||{},"boolean"!=typeof o&&(o=e instanceof r),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=f(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,s=n.writecb;if("function"!=typeof s)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,s){--e.pendingcb,n?(i.nextTick(s,r),i.nextTick(I,t,e),t._writableState.errorEmitted=!0,_(t,r)):(s(r),t._writableState.errorEmitted=!0,_(t,r),I(t,e))}(t,n,r,e,s);else{var o=x(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||k(t,n),r?i.nextTick(A,t,n,o,s):A(t,n,o,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function L(t){var e=this instanceof(r=r||n(6753));if(!e&&!o.call(L,this))return new L(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),c.call(this)}function O(t,e,n,r,i,s,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new E("write")):n?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function A(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),I(t,e)}function k(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,O(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;n;){var h=n.chunk,u=n.encoding,l=n.callback;if(O(t,e,!1,e.objectMode?1:h.length,h,u,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(n){e.pendingcb--,n&&_(t,n),e.prefinished=!0,t.emit("prefinish"),I(t,e)}))}function I(t,e){var n=x(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var r=t._readableState;(!r||r.autoDestroy&&r.endEmitted)&&t.destroy()}return n}n(5717)(L,c),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(t){return!!o.call(this,t)||this===L&&t&&t._writableState instanceof S}})):o=function(t){return t instanceof this},L.prototype.pipe=function(){_(this,new b)},L.prototype.write=function(t,e,n){var r,s=this._writableState,o=!1,a=!s.objectMode&&(r=t,h.isBuffer(r)||r instanceof u);return a&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=s.defaultEncoding),"function"!=typeof n&&(n=T),s.ending?function(t,e){var n=new v;_(t,n),i.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var s;return null===n?s=new m:"string"==typeof n||e.objectMode||(s=new p("chunk",["string","Buffer"],n)),!s||(_(t,s),i.nextTick(r,s),!1)}(this,s,t,n))&&(s.pendingcb++,o=function(t,e,n,r,i,s){if(!n){var o=function(t,e,n){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,n)),e}(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var a=e.objectMode?1:r.length;e.length+=a;var c=e.length-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),L.prototype._write=function(t,e,n){n(new y("_write()"))},L.prototype._writev=null,L.prototype.end=function(t,e,n){var r=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||function(t,e,n){e.ending=!0,I(t,e),n&&(e.finished?i.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,r,n),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),L.prototype.destroy=l.destroy,L.prototype._undestroy=l.undestroy,L.prototype._destroy=function(t,e){e(t)}},5850:(t,e,n)=>{"use strict";var r,i=n(4155);function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o=n(8610),a=Symbol("lastResolve"),c=Symbol("lastReject"),h=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function p(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var n=t[d].read();null!==n&&(t[l]=null,t[a]=null,t[c]=null,e(p(n,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),E=Object.setPrototypeOf((s(r={get stream(){return this[d]},next:function(){var t=this,e=this[h];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise((function(e,n){i.nextTick((function(){t[h]?n(t[h]):e(p(void 0,!0))}))}));var n,r=this[l];if(r)n=new Promise(function(t,e){return function(n,r){t.then((function(){e[u]?n(p(void 0,!0)):e[f](n,r)}),r)}}(r,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(p(s,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),s(r,"return",(function(){var t=this;return new Promise((function(e,n){t[d].destroy(null,(function(t){t?n(t):e(p(void 0,!0))}))}))})),r),b);t.exports=function(t){var e,n=Object.create(E,(s(e={},d,{value:t,writable:!0}),s(e,a,{value:null,writable:!0}),s(e,c,{value:null,writable:!0}),s(e,h,{value:null,writable:!0}),s(e,u,{value:t._readableState.endEmitted,writable:!0}),s(e,f,{value:function(t,e){var r=n[d].read();r?(n[l]=null,n[a]=null,n[c]=null,t(p(r,!1))):(n[a]=t,n[c]=e)},writable:!0}),e));return n[l]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[c];return null!==e&&(n[l]=null,n[a]=null,n[c]=null,e(t)),void(n[h]=t)}var r=n[a];null!==r&&(n[l]=null,n[a]=null,n[c]=null,r(p(void 0,!0))),n[u]=!0})),t.on("readable",g.bind(null,n)),n}},7327:(t,e,n)=>{"use strict";function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){for(var n=0;n0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n}},{key:"concat",value:function(t){if(0===this.length)return o.alloc(0);for(var e,n,r,i=o.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,n=i,r=a,o.prototype.copy.call(e,n,r),a+=s.data.length,s=s.next;return i}},{key:"consume",value:function(t,e){var n;return ti.length?i.length:t;if(s===i.length?r+=i:r+=i.slice(0,t),0==(t-=s)){s===i.length?(++n,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(s));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(t){var e=o.allocUnsafe(t),n=this.head,r=1;for(n.data.copy(e),t-=n.data.length;n=n.next;){var i=n.data,s=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,s),0==(t-=s)){s===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(s));break}++r}return this.length-=r,e}},{key:c,value:function(t,e){return a(this,function(t){for(var e=1;e{"use strict";var r=n(4155);function i(t,e){o(t,e),s(t)}function s(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function o(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(o,this,t)):r.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted?r.nextTick(s,n):(n._writableState.errorEmitted=!0,r.nextTick(i,n,t)):r.nextTick(i,n,t):e?(r.nextTick(s,n),e(t)):r.nextTick(s,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}},8610:(t,e,n)=>{"use strict";var r=n(4281).q.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,n,s){if("function"==typeof n)return t(e,null,n);n||(n={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var n=arguments.length,r=new Array(n),i=0;i{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9946:(t,e,n)=>{"use strict";var r,i=n(4281).q,s=i.ERR_MISSING_ARGS,o=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function c(t){t()}function h(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){u||(u=t),t&&f.forEach(c),s||(f.forEach(c),l(u))}))}));return e.reduce(h)}},2457:(t,e,n)=>{"use strict";var r=n(4281).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var s=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return t.objectMode?16:16384}}},2503:(t,e,n)=>{t.exports=n(7187).EventEmitter},8473:(t,e,n)=>{(e=t.exports=n(9481)).Stream=e,e.Readable=e,e.Writable=n(4229),e.Duplex=n(6753),e.Transform=n(4605),e.PassThrough=n(2725),e.finished=n(8610),e.pipeline=n(9946)},9967:(t,e,n)=>{t.exports=function(t,e,n){if("number"!=typeof e)throw new Error("second argument must be a Number");let i,s,o,a,c,h,u=!0;function l(t){function e(){n&&n(t,i),n=null}u?r(e):e()}function f(e,n,r){if(i[e]=r,n&&(c=!0),0==--o||n)l(n);else if(!c&&h{"use strict";var r=n(396).Buffer,i=r.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(r.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=c,this.end=h,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=u,this.end=l,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function u(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.s=s,s.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(i>0&&(t.lastNeed=i-1),i):--r=0?(i>0&&(t.lastNeed=i-2),i):--r=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},396:(t,e,n)=>{var r=n(8764),i=r.Buffer;function s(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return i(t,e,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(s(r,e),e.Buffer=o),o.prototype=Object.create(i.prototype),s(i,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=i(t);return void 0!==e?"string"==typeof n?r.fill(e,n):r.fill(e):r.fill(0),r},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}},971:t=>{t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const n=t.reduce(((t,n,r,i)=>(e.ngramLengths.forEach((e=>{var s=i.slice(r,r+e);s.length===e&&(n=JSON.stringify(s),t[n]=t[n]||[],t[n].push(r))})),t)),{});return Object.keys(n).map((t=>({term:JSON.parse(t),positions:n[t]}))).sort(((t,e)=>t.term[0]>e.term[0]))}},3692:t=>{"use strict";function e(t){return Object.prototype.toString.call(t)}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function r(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n{function r(t){try{if(!n.g.localStorage)return!1}catch(t){return!1}var e=n.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}},1861:t=>{t.exports=t=>{const e=t=>"string"==typeof t||t instanceof String,n=(r,i)=>new Promise((async s=>{return null===r?s([null,"1.00"]):(o=r)&&0===Object.keys(o).length&&Object.getPrototypeOf(o)===Object.prototype?s([[],"1.00"]):Number.isInteger(r)?s([r,r]):e(r)?s(t.tokenizer(r,i,t)):(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(r)?s((a=r,new Promise((async e=>{const r={};for(const e in a)r[e]=await n(a[e],e,t);return e(r)})))):(t=>Array.isArray(t))(r)?s((c=r,Promise.all(c.map(n)))):s(r);var o,a,c})),r=async r=>new Promise((async i=>{e(r)&&(r={body:r}),Object.prototype.hasOwnProperty.call(r,"_id")||(r._id=t.idGenerator.next().value);const s={};for(const t in r)s[t]="_id"!==t?await n(r[t],t):r[t];return i(s)}));return{processDocuments:t=>Promise.all(t.map(r))}}},2225:(t,e,n)=>{const r=n(9203),i=n(7155),{LRUCache:s}=n(4456),o=n(6291),a=n(6761),c=n(4147),h=t=>new Promise((async e=>{const r=new s({max:1e3}),c=new((await Promise.resolve().then(n.bind(n,5613))).default)({concurrency:1}),h=a(t,r,c),u=o(t,r);return h._INCREMENT_DOC_COUNT(0).then((()=>e({_AND:t.fii.AND,_BUCKET:t.fii.BUCKET,_GET:t.fii.GET,_NOT:t.fii.NOT,_OR:t.fii.OR,_CACHE:r,_PAGE:u.PAGE,_SCORE:u.SCORE,_SEARCH:u.SEARCH,_SORT:u.SORT,DELETE:h.DELETE,FLUSH:h.FLUSH,IMPORT:h.IMPORT,PUT:h.PUT,PUT_RAW:h.PUT_RAW,TOKENIZATION_PIPELINE_STAGES:i,ALL_DOCUMENTS:u.ALL_DOCUMENTS,BUCKETS:t.fii.BUCKETS,CREATED:t.fii.CREATED,DICTIONARY:u.DICTIONARY,DISTINCT:u.DISTINCT,DOCUMENTS:u.DOCUMENTS,DOCUMENT_COUNT:u.DOCUMENT_COUNT,DOCUMENT_VECTORS:u.DOCUMENT_VECTORS,EXPORT:t.fii.EXPORT,FACETS:u.FACETS,FIELDS:t.fii.FIELDS,INDEX:t.fii,LAST_UPDATED:t.fii.LAST_UPDATED,MAX:t.fii.MAX,MIN:t.fii.MIN,QUERY:u.QUERY,SEARCH:u.SEARCH})))}));t.exports=t=>((t={})=>new Promise(((e,n)=>(t=Object.assign({cacheLength:1e3,caseSensitive:!1,docExistsSpace:"DOC_RAW",idGenerator:function*(){let t=0;for(;;)yield Date.now()+"-"+t++}(),isLeaf:t=>Array.isArray(t)&&2===t.length&&t.every((t=>"string"==typeof t||"number"==typeof t||null===t)),skipFields:[],ngrams:{},replace:{},storeRawDocs:!0,stopwords:[],storeVectors:!0,tokenAppend:"#",tokenSplitRegex:/[\p{L}\d]+/gu,tokenizer:i.tokenizer},t),r(t).then((n=>e(Object.assign({fii:n},t))))))))(t).then(h).then((t=>(t=>new Promise(((e,n)=>{const r=["CREATED_WITH"],i="search-index@"+c.version;return t.INDEX.STORE.get(r,t.INDEX.LEVEL_OPTIONS).then((t=>i===t?e():n(new Error("This index was created with "+t+", you are running "+i)))).catch((n=>t.INDEX.STORE.put(r,i,t.INDEX.LEVEL_OPTIONS).then(e)))})))(t).then((()=>t))))},6291:(t,e,n)=>{const{EntryStream:r}=n(6741);t.exports=(t,e)=>{const n=e=>new Promise(((n,i)=>{const s=[];new r(t.fii.STORE,{gte:["DOC_RAW",null],lte:["DOC_RAW",void 0],limit:e,...t.fii.LEVEL_OPTIONS}).on("data",(t=>s.push({_id:t.value._id,_doc:t.value}))).on("end",(()=>n(s)))})),i=(...e)=>e.length?Promise.all(e.map((e=>t.fii.STORE.get(["DOC_RAW",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))):n(),s=(...e)=>t.fii.DISTINCT(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),o=(...e)=>t.fii.FACETS(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),a=(t,e)=>{const n=(e=Object.assign({NUMBER:0,SIZE:20},e||{})).NUMBER*e.SIZE,r=n+e.SIZE||void 0;return t.slice(n,r)},c=(t,e={})=>{e=Object.assign({TYPE:"TFIDF"},e);const n=t=>!e.FIELDS||e.FIELDS.includes(t.FIELD),r=t=>(t||[]).filter(n);return new Promise((i=>i("TFIDF"===e.TYPE?u().then((e=>t.map(((t,r,i)=>{const s=Math.log((e+1)/i.length);return t._score=+(t._match||[]).filter(n).reduce(((t,e)=>t+s*+e.SCORE),0).toFixed(2),t})))):"PRODUCT"===e.TYPE?t.map((t=>({...t,_score:+r(t._match).reduce(((t,e)=>t*+e.SCORE),1).toFixed(2)}))):"CONCAT"===e.TYPE?t.map((t=>({...t,_score:r(t._match).reduce(((t,e)=>t+e.SCORE),"")}))):"SUM"===e.TYPE?t.map((t=>({...t,_score:+r(t._match).reduce(((t,e)=>t+ +e.SCORE),0).toFixed(2)}))):"VALUE"===e.TYPE?t.map((t=>({...t,_score:r(t._match).reduce(((t,e)=>t+e.VALUE),"")}))):null)))},h=(t,e)=>(e=Object.assign({DIRECTION:"DESCENDING",TYPE:"NUMERIC"},e||{}),t.sort(((t,e)=>t._ide._id?1:0)).sort({NUMERIC:{DESCENDING:(t,e)=>+e._score-+t._score,ASCENDING:(t,e)=>+t._score-+e._score},ALPHABETIC:{DESCENDING:(t,e)=>t._scoree._score?-1:0,ASCENDING:(t,e)=>t._scoree._score?1:0}}[e.TYPE][e.DIRECTION])),u=()=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS),l=(e,r={})=>{const s=e=>"string"==typeof e||"number"==typeof e?t.fii.GET(e,r.PIPELINE):e.FIELD||e.VALUE?t.fii.GET(e):e.AND?t.fii.AND(e.AND.map(s),r.PIPELINE):e.GET?t.fii.GET(e.GET,r.PIPELINE):e.NOT?t.fii.NOT(s(e.NOT.INCLUDE),s(e.NOT.EXCLUDE)):e.OR?t.fii.OR(e.OR.map(s),r.PIPELINE):e.ALL_DOCUMENTS?n(e.ALL_DOCUMENTS):void 0;return s(e).then((t=>t.RESULT?Object.assign(t,{RESULT_LENGTH:t.RESULT.length}):{RESULT:t,RESULT_LENGTH:t.length})).then((e=>r.BUCKETS?t.fii.BUCKETS(...r.BUCKETS).then((n=>Object.assign(e,{BUCKETS:t.fii.AGGREGATION_FILTER(n,e.RESULT)}))):e)).then((n=>r.FACETS?n.RESULT.length?e.ALL_DOCUMENTS?o(...r.FACETS).then((t=>Object.assign(n,{FACETS:t}))):o(...r.FACETS).then((e=>Object.assign(n,{FACETS:t.fii.AGGREGATION_FILTER(e,n.RESULT)}))):Object.assign(n,{FACETS:[]}):n)).then((t=>{return r.WEIGHT?Object.assign({RESULT:(e=t.RESULT,n=r.WEIGHT,e.map((t=>(t._match=t._match.map((t=>(n.forEach((e=>{let n=!1;e.FIELD&&e.VALUE?e.FIELD===t.FIELD&&e.VALUE===t.VALUE&&(n=!0):e.FIELD?e.FIELD===t.FIELD&&(n=!0):e.VALUE&&e.VALUE===t.VALUE&&(n=!0),n&&(t.SCORE=(e.WEIGHT*+t.SCORE).toFixed(2))})),t))),t))))},t):t;var e,n})).then((t=>r.SCORE?c(t.RESULT,r.SCORE).then((e=>Object.assign(t,{RESULT:e}))):t)).then((t=>Object.assign(t,r.SORT?{RESULT:h(t.RESULT,r.SORT)}:{}))).then((t=>Object.assign(t,r.PAGE?{RESULT:a(t.RESULT,r.PAGE)}:{}))).then((t=>r.DOCUMENTS?i(...t.RESULT.map((t=>t._id))).then((e=>Object.assign(t,{RESULT:t.RESULT.map(((t,n)=>Object.assign(t,{_doc:e[n]})))}))):t))},f=(t,n)=>new Promise((r=>(n=JSON.stringify(n),e.has(n)?r(e.get(n)):t.then((t=>e.set(n,t))).then((()=>r(e.get(n)))))));return{ALL_DOCUMENTS:n,DICTIONARY:t=>f((t=>s(t).then((t=>Array.from(t.reduce(((t,e)=>t.add(e.VALUE)),new Set)).sort(((t,e)=>(t+"").localeCompare(e+"",void 0,{numeric:!0,sensitivity:"base"}))))))(t),{DICTIONARY:t||null}),DISTINCT:s,DOCUMENTS:(...t)=>f(i(...t),{DOCUMENTS:t}),DOCUMENT_COUNT:u,DOCUMENT_VECTORS:(...e)=>Promise.all(e.map((e=>t.fii.STORE.get(["DOC",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))),FACETS:o,PAGE:a,QUERY:(t,e)=>f(l(t,e),{QUERY:[t,e]}),SCORE:c,SEARCH:(t,e)=>f(((t,e)=>l({AND:[...t]},Object.assign({SCORE:{TYPE:"TFIDF"},SORT:!0},e)))(t,e),{SEARCH:[t,e]}),SORT:h}}},7155:(t,e,n)=>{const r=n(971),{ngraminator:i}=n(6349),s=([t,e,n])=>Promise.resolve([t.match(n.tokenSplitRegex)||[],e,n]),o=([t,e,n])=>[n.skipFields.includes(e)?[]:t,e,n],a=([t,e,n])=>Promise.resolve([t.map((t=>n.caseSensitive?t:t.toLowerCase())),e,n]),c=([t,e,n])=>{const{fields:r,values:i}=n.replace,s=()=>t.reduce(((t,e)=>[e,...t,...i[e]||[]]),[]);return i?r?r.includes(e)?Promise.resolve([s(),e,n]):Promise.resolve([t,e,n]):Promise.resolve([s(),e,n]):Promise.resolve([t,e,n])},h=([t,e,n])=>{let{fields:r,lengths:s,join:o=" "}=n.ngrams;return r||(r=[e]),s&&r.includes(e)?[i(t.filter((t=>null!==t)),s).map((t=>t.join(o))),e,n]:Promise.resolve([t,e,n])},u=([t,e,n])=>[t.filter((t=>!n.stopwords.includes(t.toLowerCase()))),e,n],l=([t,e,n])=>{const i=r(t),s=i.reduce(((t,e)=>Math.max(e.positions.length,t)),0);return Promise.resolve([i.map((t=>[t.term[0],(t.positions.length/s).toFixed(2)])).sort(),e,n])};e.SPY=([t,e,n])=>(console.log("----------------"),console.log("field ->"),console.log(e),console.log("tokens ->"),console.log(t),console.log("----------------"),Promise.resolve([t,e,n])),e.tokenizer=(t,e,n)=>s([t,e,n]).then(o).then(a).then(c).then(h).then(u).then(l).then((([t,e,n])=>t)),e.SPLIT=s,e.SKIP=o,e.LOWACASE=a,e.REPLACE=c,e.NGRAMS=h,e.STOPWORDS=u,e.SCORE_TERM_FREQUENCY=l},6761:(t,e,n)=>{const r=n(1861);t.exports=(t,e,n)=>{const i=e=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],+n+e,t.fii.LEVEL_OPTIONS))).catch((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],e,t.fii.LEVEL_OPTIONS))),s=(n,r,i)=>(e.clear(),Promise.all(n.map(((e,n)=>t.fii.STORE.put(["DOC_RAW",r[n]],i?{}:e,t.fii.LEVEL_OPTIONS)))).then((t=>n.map(((t,e)=>({_id:r[e],status:"OK",operation:"_PUT_RAW"}))))));return{DELETE:(...n)=>{return r=n,t.fii.DELETE(r,t.fii.LEVEL_OPTIONS).then((n=>{e.clear();const r=n.filter((t=>"DELETED"===t.status));return Promise.all([Promise.all(r.map((e=>t.fii.STORE.del(["DOC_RAW",e._id],t.fii.LEVEL_OPTIONS)))),(i=r.length,t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((e=>t.fii.STORE.put(["DOCUMENT_COUNT"],+e-i,t.fii.LEVEL_OPTIONS))))]).then((()=>n));var i}));var r},FLUSH:()=>t.fii.STORE.clear().then((()=>{e.clear();const n=Date.now();return t.fii.STORE.batch([{type:"put",key:["~CREATED"],value:n},{type:"put",key:["~LAST_UPDATED"],value:n},{type:"put",key:["DOCUMENT_COUNT"],value:0}],t.fii.LEVEL_OPTIONS)})).then((()=>!0)),IMPORT:n=>(e.clear(),Promise.resolve(t.fii.IMPORT(n))),PUT:(o,a)=>n.add((()=>((n,o)=>(e.clear(),o=Object.assign(t,o),r(t).processDocuments(n).then((e=>t.fii.PUT(e,o,t.fii.LEVEL_OPTIONS).then((e=>Promise.all([s(n,e.map((t=>t._id)),!t.storeRawDocs),i(e.filter((t=>"CREATED"===t.status)).length)]).then((()=>e))))))))(o,a))),PUT_RAW:s,_INCREMENT_DOC_COUNT:i}}},2361:()=>{},4616:()=>{},4456:(t,e,n)=>{"use strict";var r=n(4155);Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const i="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=new Set,o="object"==typeof r&&r?r:{},a=(t,e,n,r)=>{"function"==typeof o.emitWarning?o.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let c=globalThis.AbortController,h=globalThis.AbortSignal;if(void 0===c){h=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},c=class{constructor(){e()}signal=new h;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==o.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,a("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const u=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),l=t=>u(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?f:null:null;class f extends Array{constructor(t){super(t),this.fill(0)}}class d{heap;length;static#t=!1;static create(t){const e=l(t);if(!e)return[];d.#t=!0;const n=new d(t,e);return d.#t=!1,n}constructor(t,e){if(!d.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class p{#e;#n;#r;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#u;#l;#f;#d;#p;#y;#g;#b;#E;#m;#v;#w;#_;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#m,sizes:t.#b,keyMap:t.#c,keyList:t.#h,valList:t.#u,next:t.#l,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#y,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,r,i)=>t.#S(e,n,r,i),moveToTail:e=>t.#L(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#s}get dispose(){return this.#r}get disposeAfter(){return this.#i}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:i,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:h,dispose:f,disposeAfter:y,noDisposeOnSet:g,noUpdateTTL:b,maxSize:E=0,maxEntrySize:m=0,sizeCalculation:v,fetchMethod:w,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:L,ignoreFetchAbort:O}=t;if(0!==e&&!u(e))throw new TypeError("max option must be a nonnegative integer");const A=e?l(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=E,this.maxEntrySize=m||this.#n,this.sizeCalculation=v,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==w&&"function"!=typeof w)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=w,this.#w=!!w,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#l=new A(e),this.#f=new A(e),this.#d=0,this.#p=0,this.#y=d.create(e),this.#o=0,this.#a=0,"function"==typeof f&&(this.#r=f),"function"==typeof y?(this.#i=y,this.#g=[]):(this.#i=void 0,this.#g=void 0),this.#v=!!this.#r,this.#_=!!this.#i,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!L,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#n&&!u(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!u(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#x()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=u(r)||0===r?r:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!u(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!s.has(t))(t)&&(s.add(t),a("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,p))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#R(){const t=new f(this.#e),e=new f(this.#e);this.#m=t,this.#E=e,this.#I=(n,r,s=i.now())=>{if(e[n]=0!==r?s:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(n)&&this.delete(this.#h[n])}),r+1);t.unref&&t.unref()}},this.#C=n=>{e[n]=0!==t[n]?i.now():0},this.#N=(i,s)=>{if(t[s]){const o=t[s],a=e[s];i.ttl=o,i.start=a,i.now=n||r();const c=i.now-a;i.remainingTTL=o-c}};let n=0;const r=()=>{const t=i.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const s=this.#c.get(i);if(void 0===s)return 0;const o=t[s],a=e[s];return 0===o||0===a?1/0:o-((n||r())-a)},this.#k=i=>0!==t[i]&&0!==e[i]&&(n||r())-e[i]>t[i]}#C=()=>{};#N=()=>{};#I=()=>{};#k=()=>!1;#x(){const t=new f(this.#e);this.#a=0,this.#b=t,this.#D=e=>{this.#a-=t[e],t[e]=0},this.#U=(t,e,n,r)=>{if(this.#T(e))return 0;if(!u(n)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!u(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#P=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#a>n;)this.#M(!0)}this.#a+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#a)}}#D=t=>{};#P=(t,e,n)=>{};#U=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#d;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#l[e]}#B(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#u[t]||void 0===this.#h[t]||this.#T(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*rentries(){for(const t of this.#A())void 0===this.#u[t]||void 0===this.#h[t]||this.#T(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*values(){for(const t of this.#O())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}*rvalues(){for(const t of this.#A())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of this.#O()){const r=this.#u[n],i=this.#T(r)?r.__staleWhileFetching:r;if(void 0!==i&&t(i,this.#h[n],this))return this.get(this.#h[n],e)}}forEach(t,e=this){for(const n of this.#O()){const r=this.#u[n],i=this.#T(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#h[n],this)}}rforEach(t,e=this){for(const n of this.#A()){const r=this.#u[n],i=this.#T(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#h[n],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const n=this.#h[e],r=this.#u[e],s=this.#T(r)?r.__staleWhileFetching:r;if(void 0===s||void 0===n)continue;const o={value:s};if(this.#m&&this.#E){o.ttl=this.#m[e];const t=i.now()-this.#E[e];o.start=Math.floor(Date.now()-t)}this.#b&&(o.size=this.#b[e]),t.unshift([n,o])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=i.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:i,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const h=this.#U(t,e,n.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let u=0===this.#o?void 0:this.#c.get(t);if(void 0===u)u=0===this.#o?this.#p:0!==this.#y.length?this.#y.pop():this.#o===this.#e?this.#M(!1):this.#o,this.#h[u]=t,this.#u[u]=e,this.#c.set(t,u),this.#l[this.#p]=u,this.#f[u]=this.#p,this.#p=u,this.#o++,this.#P(u,h,a),a&&(a.set="add"),c=!1;else{this.#L(u);const n=this.#u[u];if(e!==n){if(this.#w&&this.#T(n)?n.__abortController.abort(new Error("replaced")):s||(this.#v&&this.#r?.(n,t,"set"),this.#_&&this.#g?.push([n,t,"set"])),this.#D(u),this.#P(u,h,a),this.#u[u]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#m||this.#R(),this.#m&&(c||this.#I(u,r,i),a&&this.#N(a,u)),!s&&this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#u[this.#d];if(this.#M(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}}}#M(t){const e=this.#d,n=this.#h[e],r=this.#u[e];return this.#w&&this.#T(r)?r.__abortController.abort(new Error("evicted")):(this.#v||this.#_)&&(this.#v&&this.#r?.(r,n,"evict"),this.#_&&this.#g?.push([r,n,"evict"])),this.#D(e),t&&(this.#h[e]=void 0,this.#u[e]=void 0,this.#y.push(e)),1===this.#o?(this.#d=this.#p=0,this.#y.length=0):this.#d=this.#l[e],this.#c.delete(n),this.#o--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,i=this.#c.get(t);if(void 0!==i){const t=this.#u[i];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(i))return n&&this.#C(i),r&&(r.has="hit",this.#N(r,i)),!0;r&&(r.has="stale",this.#N(r,i))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#c.get(t);if(void 0!==r&&(n||!this.#k(r))){const t=this.#u[r];return this.#T(t)?t.__staleWhileFetching:t}}#S(t,e,n,r){const i=void 0===e?void 0:this.#u[e];if(this.#T(i))return i;const s=new c,{signal:o}=n;o?.addEventListener("abort",(()=>s.abort(o.reason)),{signal:s.signal});const a={signal:s.signal,options:n,context:r},h=(r,i=!1)=>{const{aborted:o}=s.signal,c=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(s.signal.reason);const h=l;return this.#u[e]===l&&(void 0===r?h.__staleWhileFetching?this.#u[e]=h.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:i}=s.signal,o=i&&n.allowStaleOnFetchAbort,a=o||n.allowStaleOnFetchRejection,c=a||n.noDeleteOnFetchRejection,h=l;if(this.#u[e]===l&&(c&&void 0!==h.__staleWhileFetching?o||(this.#u[e]=h.__staleWhileFetching):this.delete(t)),a)return n.status&&void 0!==h.__staleWhileFetching&&(n.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw r};n.status&&(n.status.fetchDispatched=!0);const l=new Promise(((e,r)=>{const o=this.#s?.(t,i,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),r),s.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),u(t)))),f=Object.assign(l,{__abortController:s,__staleWhileFetching:i,__returned:void 0});return void 0===e?(this.set(t,f,{...a.options,status:void 0}),e=this.#c.get(t)):this.#u[e]=f,f}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof c}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:b}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});const E={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:s,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:g,signal:b};let m=this.#c.get(t);if(void 0===m){g&&(g.fetch="miss");const e=this.#S(t,m,E,p);return e.__returned=e}{const e=this.#u[m];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=this.#k(m);if(!y&&!i)return g&&(g.fetch="hit"),this.#L(m),r&&this.#C(m),g&&this.#N(g,m),e;const s=this.#S(t,m,E,p),o=void 0!==s.__staleWhileFetching&&n;return g&&(g.fetch=i?"stale":"refresh",o&&i&&(g.returnedStale=!0)),o?s.__staleWhileFetching:s.__returned=s}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:s}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#u[o],a=this.#T(e);return s&&this.#N(s,o),this.#k(o)?(s&&(s.get="stale"),a?(s&&n&&void 0!==e.__staleWhileFetching&&(s.returnedStale=!0),n?e.__staleWhileFetching:void 0):(i||this.delete(t),s&&n&&(s.returnedStale=!0),n?e:void 0)):(s&&(s.get="hit"),a?e.__staleWhileFetching:(this.#L(o),r&&this.#C(o),e))}s&&(s.get="miss")}#j(t,e){this.#f[e]=t,this.#l[t]=e}#L(t){t!==this.#p&&(t===this.#d?this.#d=this.#l[t]:this.#j(this.#f[t],this.#l[t]),this.#j(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#o){const n=this.#c.get(t);if(void 0!==n)if(e=!0,1===this.#o)this.clear();else{this.#D(n);const e=this.#u[n];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#v||this.#_)&&(this.#v&&this.#r?.(e,t,"delete"),this.#_&&this.#g?.push([e,t,"delete"])),this.#c.delete(t),this.#h[n]=void 0,this.#u[n]=void 0,n===this.#p?this.#p=this.#f[n]:n===this.#d?this.#d=this.#l[n]:(this.#l[this.#f[n]]=this.#l[n],this.#f[this.#l[n]]=this.#f[n]),this.#o--,this.#y.push(n)}}if(this.#_&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#u[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const n=this.#h[t];this.#v&&this.#r?.(e,n,"delete"),this.#_&&this.#g?.push([e,n,"delete"])}}if(this.#c.clear(),this.#u.fill(void 0),this.#h.fill(void 0),this.#m&&this.#E&&(this.#m.fill(0),this.#E.fill(0)),this.#b&&this.#b.fill(0),this.#d=0,this.#p=0,this.#y.length=0,this.#a=0,this.#o=0,this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}}}e.LRUCache=p},5613:(t,e,n)=>{"use strict";n.r(e),n.d(e,{AbortError:()=>j,default:()=>F});var r=n(6729);class i extends Error{constructor(t){super(t),this.name="TimeoutError"}}class s extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const o=t=>void 0===globalThis.DOMException?new s(t):new DOMException(t),a=t=>{const e=void 0===t.reason?o("This operation was aborted."):t.reason;return e instanceof Error?e:o(e)};var c,h=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class u{constructor(){c.set(this,[])}enqueue(t,e){const n={priority:(e={priority:0,...e}).priority,run:t};if(this.size&&h(this,c,"f")[this.size-1].priority>=e.priority)return void h(this,c,"f").push(n);const r=function(t,e,n){let r=0,i=t.length;for(;i>0;){const n=Math.trunc(i/2);let o=r+n;s=t[o],e.priority-s.priority<=0?(r=++o,i-=n+1):i=n}var s;return r}(h(this,c,"f"),n);h(this,c,"f").splice(r,0,n)}dequeue(){const t=h(this,c,"f").shift();return null==t?void 0:t.run}filter(t){return h(this,c,"f").filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return h(this,c,"f").length}}c=new WeakMap;var l,f,d,p,y,g,b,E,m,v,w,_,T,S,L,O,A,k,x,R,I,C,N,D,U,P,M=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},B=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class j extends Error{}class F extends r{constructor(t){var e,n,r,i;if(super(),l.add(this),f.set(this,void 0),d.set(this,void 0),p.set(this,0),y.set(this,void 0),g.set(this,void 0),b.set(this,0),E.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,void 0),_.set(this,0),T.set(this,void 0),S.set(this,void 0),L.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:u,...t}).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(r=t.interval)||void 0===r?void 0:r.toString())&&void 0!==i?i:""}\` (${typeof t.interval})`);M(this,f,t.carryoverConcurrencyCount,"f"),M(this,d,t.intervalCap===Number.POSITIVE_INFINITY||0===t.interval,"f"),M(this,y,t.intervalCap,"f"),M(this,g,t.interval,"f"),M(this,v,new t.queueClass,"f"),M(this,w,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,M(this,L,!0===t.throwOnTimeout,"f"),M(this,S,!1===t.autoStart,"f")}get concurrency(){return B(this,T,"f")}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);M(this,T,t,"f"),B(this,l,"m",D).call(this)}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:B(this,L,"f"),...e},new Promise(((n,r)=>{B(this,v,"f").enqueue((async()=>{var s,o,c;M(this,_,(o=B(this,_,"f"),++o),"f"),M(this,p,(c=B(this,p,"f"),++c),"f");try{if(null===(s=e.signal)||void 0===s?void 0:s.aborted)throw new j("The task was aborted.");let r=t({signal:e.signal});e.timeout&&(r=function(t,e,n,r){let s;const o=new Promise(((o,c)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:t}=r;t.aborted&&c(a(t)),t.addEventListener("abort",(()=>{c(a(t))}))}s=r.customTimers.setTimeout.call(void 0,(()=>{const r=n instanceof Error?n:new i(`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),c(r)}),e),(async()=>{try{o(await t)}catch(t){c(t)}finally{r.customTimers.clearTimeout.call(void 0,s)}})()}else o(t)}));return o.clear=()=>{clearTimeout(s),s=void 0},o}(Promise.resolve(r),e.timeout)),e.signal&&(r=Promise.race([r,B(this,l,"m",U).call(this,e.signal)]));const o=await r;n(o),this.emit("completed",o)}catch(t){if(t instanceof i&&!e.throwOnTimeout)return void n();r(t),this.emit("error",t)}finally{B(this,l,"m",k).call(this)}}),e),this.emit("add"),B(this,l,"m",I).call(this)}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return B(this,S,"f")?(M(this,S,!1,"f"),B(this,l,"m",D).call(this),this):this}pause(){M(this,S,!0,"f")}clear(){M(this,v,new(B(this,w,"f")),"f")}async onEmpty(){0!==B(this,v,"f").size&&await B(this,l,"m",P).call(this,"empty")}async onSizeLessThan(t){B(this,v,"f").sizeB(this,v,"f").size{B(this,l,"m",x).call(this)}),e),"f"),!0;M(this,p,B(this,f,"f")?B(this,_,"f"):0,"f")}return!1},I=function(){if(0===B(this,v,"f").size)return B(this,E,"f")&&clearInterval(B(this,E,"f")),M(this,E,void 0,"f"),this.emit("empty"),0===B(this,_,"f")&&this.emit("idle"),!1;if(!B(this,S,"f")){const t=!B(this,l,"a",R);if(B(this,l,"a",O)&&B(this,l,"a",A)){const e=B(this,v,"f").dequeue();return!!e&&(this.emit("active"),e(),t&&B(this,l,"m",C).call(this),!0)}}return!1},C=function(){B(this,d,"f")||void 0!==B(this,E,"f")||(M(this,E,setInterval((()=>{B(this,l,"m",N).call(this)}),B(this,g,"f")),"f"),M(this,b,Date.now()+B(this,g,"f"),"f"))},N=function(){0===B(this,p,"f")&&0===B(this,_,"f")&&B(this,E,"f")&&(clearInterval(B(this,E,"f")),M(this,E,void 0,"f")),M(this,p,B(this,f,"f")?B(this,_,"f"):0,"f"),B(this,l,"m",D).call(this)},D=function(){for(;B(this,l,"m",I).call(this););},U=async function(t){return new Promise(((e,n)=>{t.addEventListener("abort",(()=>{n(new j("The task was aborted."))}),{once:!0})}))},P=async function(t,e){return new Promise((n=>{const r=()=>{e&&!e()||(this.off(t,r),n())};this.on(t,r)}))}},4147:t=>{"use strict";t.exports=JSON.parse('{"name":"search-index","version":"4.0.0","description":"A network resilient, persistent full-text search library for the browser and Node.js","keywords":["search","elasticsearch","elastic","lunr.js","flexsearch","norch","solr"],"engines":{"node":">=12"},"main":"src/node.js","browser":"src/browser.js","files":["dist","src"],"directories":{"lib":"src"},"scripts":{"build":"npm run empty-sandbox && rm -rf ./dist/* && webpack && cp dist/search-index-$npm_package_version.js dist/search-index.js","demo-export":"node demo/generate-index/export.js","demo-fetch":"node demo/generate-index/fetch.js","demo-process":"node demo/generate-index/process.js","demo-rebuild":"npm run demo-fetch && npm run demo-process && npm run demo-export && npm run demo-link-lib","demo-start":"http-server -c-1 demo & open-cli http://127.0.0.1:8080","demo-link-lib":"cd demo/lib && ln -sf ../../dist/search-index.js && cd ../../","empty-sandbox":"rm -rf fii && rm -rf test/sandbox && mkdir test/sandbox","lint":"standard --fix test/src/* src/* demo/src/* demo/generate-index/*.js","test":"npm run empty-sandbox && npm run test-node && npm run test-browser && npm run lint","test-browser":"npm run build && cat test/sandbox/browser-tests.js | tape-run","test-node":"npm run empty-sandbox && tape test/src/*-test.js","toc":"doctoc docs/API.md --title \'# API Documentation for search-index\' && doctoc docs/FAQ.md --title \'# FAQ\'"},"repository":{"type":"git","url":"git+https://github.com/fergiemcdowall/search-index.git"},"author":"Fergus McDowall","license":"MIT","bugs":{"url":"https://github.com/fergiemcdowall/search-index/issues"},"homepage":"https://fergiemcdowall.github.io/search-index/","devDependencies":{"assert":"^2.0.0","classic-level":"^1.3.0","doctoc":"2.2.1","fuzzyset":"1.0.5","http-server":"14.1.1","level-out":"^1.0.1","memory-level":"^1.0.0","open-cli":"7.2.0","os-browserify":"^0.3.0","path":"^0.12.7","path-browserify":"^1.0.1","process":"^0.11.10","standard":"17.1.0","stemmer":"1.0.5","stopword":"2.0.8","stream-browserify":"^3.0.0","tape":"5.6.3","tape-run":"^10.0.0","webpack":"5.87.0","webpack-cli":"5.1.4","world-bank-dataset":"^1.0.0"},"dependencies":{"fergies-inverted-index":"12.0.0","browser-level":"^1.0.1","charwise":"^3.0.1","level-read-stream":"^1.1.0","lru-cache":"10.0.0","memory-level":"^1.0.0","ngraminator":"3.0.2","p-queue":"7.3.4","term-vector":"^1.0.0"}}')}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(2225);SearchIndex=r})(); \ No newline at end of file +var SearchIndex;(()=>{var t={9464:(t,e,n)=>{"use strict";const{fromCallback:i}=n(6957),r=n(4473),{getCallback:s,getOptions:o}=n(2520),a=Symbol("promise"),h=Symbol("status"),c=Symbol("operations"),u=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[c]=[],this[l]=[],this[h]="open",this[u]=this[u].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[c].length}put(t,e,n){if("open"!==this[h])throw new r("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;const s=n&&null!=n.sublevel?n.sublevel:this.db,o=n,a=s.keyEncoding(n&&n.keyEncoding),u=s.valueEncoding(n&&n.valueEncoding),l=a.format;n={...n,keyEncoding:l,valueEncoding:u.format},s!==this.db&&(n.sublevel=null);const f=s.prefixKey(a.encode(t),l),d=u.encode(e);return this._put(f,d,n),this[c].push({...o,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if("open"!==this[h])throw new r("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const n=this.db._checkKey(t);if(n)throw n;const i=e&&null!=e.sublevel?e.sublevel:this.db,s=e,o=i.keyEncoding(e&&e.keyEncoding),a=o.format;return e={...e,keyEncoding:a},i!==this.db&&(e.sublevel=null),this._del(i.prefixKey(o.encode(t),a),e),this[c].push({...s,type:"del",key:t}),this}_del(t,e){}clear(){if("open"!==this[h])throw new r("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[c]=[],this}_clear(){}write(t,e){return e=s(t,e),e=i(e,a),t=o(t),"open"!==this[h]?this.nextTick(e,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):0===this.length?this.close(e):(this[h]="writing",this._write(t,(t=>{this[h]="closing",this[l].push((()=>e(t))),t||this.db.emit("batch",this[c]),this._close(this[u])}))),e[a]}_write(t,e){}close(t){return t=i(t,a),"closing"===this[h]?this[l].push(t):"closed"===this[h]?this.nextTick(t):(this[l].push(t),"writing"!==this[h]&&(this[h]="closing",this._close(this[u]))),t[a]}_close(t){this.nextTick(t)}[u](){this[h]="closed",this.db.detachResource(this);const t=this[l];this[l]=[];for(const e of t)e()}}},3961:(t,e,n)=>{"use strict";const{fromCallback:i}=n(6957),r=n(4473),{getOptions:s,getCallback:o}=n(2520),a=Symbol("promise"),h=Symbol("callback"),c=Symbol("working"),u=Symbol("handleOne"),l=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){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[b]=!1,this[E]=[],this[c]=!1,this[y]=!1,this[f]=!1,this[h]=null,this[u]=this[u].bind(this),this[l]=this[l].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,i,r)=>{t?n(t):this[_]?void 0===i&&void 0===r?e():e([i,r]):e(i)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new r("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(t,new r("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=t,this[O]>=this[L]?this.nextTick(this[u],null):this._next(this[u])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=o(e,n),n=i(n,a),e=s(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new r("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(n,new r("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[c]=!0,this[h]=n,t<=0?this.nextTick(this[l],null,[]):this._nextv(t,e,this[l])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const i=[],r=(e,s,o)=>e?n(e):(this[_]?void 0===s&&void 0===o:void 0===s)?n(null,i):(i.push(this[_]?[s,o]:s),void(i.length===t?n(null,i):this._next(r)));this._next(r)}all(t,e){return e=o(t,e),e=i(e,a),t=s(t,A),this[y]?this.nextTick(e,new r("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(e,new r("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[l],null,[]):this._all(t,this[l])),e[a]}_all(t,e){let n=this[O];const i=[],r=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,i):this._nextv(t,A,s)},s=(t,s)=>{t?e(t):0===s.length?e(null,i):(i.push.apply(i,s),n+=s.length,r())};r()}[d](){const t=this[h];return this[w]&&null===t?k:(this[c]=!1,this[h]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=s(e,A),this[y]);else{if(this[c])throw new r("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),i=n.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});const r=this.db.prefixKey(n.encode(t),i);this._seek(r,e)}}}_seek(t,e){throw new r("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=i(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[c]?this[w]&&this[d]()(new r("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[g])),t[a]}_close(t){this.nextTick(t)}[g](){this[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[u](t,e,n){const i=this[d]();if(t)return i(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return i(new C("entry",t))}void 0===e&&void 0===n||this[O]++,i(null,e,n)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!0,console.warn(new r("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 C extends r{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(I.prototype,t.split(" ")[0],{get(){throw new r(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new r(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[u](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t{"use strict";const{supports:i}=n(3658),{Transcoder:r}=n(8499),{EventEmitter:s}=n(7187),{fromCallback:o}=n(6957),a=n(4473),{AbstractIterator:h}=n(3961),{DefaultKeyIterator:c,DefaultValueIterator:u}=n(5429),{DeferredIterator:l,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C extends s{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:n,valueEncoding:s,passive:o,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=i(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[k]=new r(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(s||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=o(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=o(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const i=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(i);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const i=this._checkKey(t);if(i)return this.nextTick(n,i),n[E];const r=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),h=r.format,c=s.format;return e.keyEncoding===h&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:h,valueEncoding:c})),this._get(this.prefixKey(r.encode(t),h),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)),n(t);try{e=s.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const i=this.keyEncoding(e.keyEncoding),r=this.valueEncoding(e.valueEncoding),s=i.format,h=r.format;e.keyEncoding===s&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:s,valueEncoding:h}));const c=new Array(t.length);for(let e=0;e{if(t)return n(t);try{for(let t=0;tthis.put(t,e,n,i))),i[E];if(D(this,i))return i[E];const r=this._checkKey(t)||this._checkValue(e);if(r)return this.nextTick(i,r),i[E];const s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),h=s.format,c=a.format;n.keyEncoding===h&&n.valueEncoding===c||(n=Object.assign({},n,{keyEncoding:h,valueEncoding:c}));const u=this.prefixKey(s.encode(t),h),l=a.encode(e);return this._put(u,l,n,(n=>{if(n)return i(n);this.emit("put",t,e),i()})),i[E]}_put(t,e,n,i){this.nextTick(i)}del(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const i=this._checkKey(t);if(i)return this.nextTick(n,i),n[E];const r=this.keyEncoding(e.keyEncoding),s=r.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(r.encode(t),s),e,(e=>{if(e)return n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=o(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const i=new Array(t.length),{keyEncoding:r,valueEncoding:s,...h}=e;for(let e=0;e{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=o(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,i=this.keyEncoding(t.keyEncoding);return(t=b(t,i)).keyEncoding=i.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new l(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new h(this,t)}keys(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new c(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new u(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];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 p(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"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{"use strict";e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{"use strict";const{AbstractIterator:i,AbstractKeyIterator:r,AbstractValueIterator:s}=n(3961),o=Symbol("unfix"),a=Symbol("iterator"),h=Symbol("handleOne"),c=Symbol("handleMany"),u=Symbol("callback");class l extends i{constructor(t,e,n,i){super(t,e),this[a]=n,this[o]=i,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[u]=null}[h](t,e,n){const i=this[u];if(t)return i(t);void 0!==e&&(e=this[o](e)),i(t,e,n)}[c](t,e){const n=this[u];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[o](e))}n(t,e)}}class f extends r{constructor(t,e,n,i){super(t,e),this[a]=n,this[o]=i,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[u]=null}[h](t,e){const n=this[u];if(t)return n(t);void 0!==e&&(e=this[o](e)),n(t,e)}[c](t,e){const n=this[u];if(t)return n(t);for(let t=0;t{"use strict";const i=n(4473),{Buffer:r}=n(8764)||{},{AbstractSublevelIterator:s,AbstractSublevelKeyIterator:o,AbstractSublevelValueIterator:a}=n(2970),h=Symbol("prefix"),c=Symbol("upperBound"),u=Symbol("prefixRange"),l=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new i("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new i("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,r){const{separator:s,manifest:o,...a}=e.defaults(r);n=m(n,s);const u=s.charCodeAt(0)+1,p=t[l]||t;if(!d.encode(n).every((t=>t>u&&t<127)))throw new i(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,o),a);const g=(t.prefix||"")+s+n+s,v=g.slice(0,-1)+String.fromCharCode(u);this[l]=p,this[h]=new b(g),this[c]=new b(v),this[f]=new E,this.nextTick=p.nextTick}prefixKey(t,e){if("utf8"===e)return this[h].utf8+t;if(0===t.byteLength)return this[h][e];if("view"===e){const e=this[h].view,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[h].buffer;return r.concat([e,t],e.byteLength+t.byteLength)}}[u](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[h][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[c][e]}get prefix(){return this[h].utf8}get db(){return this[l]}_open(t,e){this[l].open({passive:!0},e)}_put(t,e,n,i){this[l].put(t,e,n,i)}_get(t,e,n){this[l].get(t,e,n)}_getMany(t,e,n){this[l].getMany(t,e,n)}_del(t,e,n){this[l].del(t,e,n)}_batch(t,e,n){this[l].batch(t,e,n)}_clear(t,e){this[u](t,t.keyEncoding),this[l].clear(t,e)}_iterator(t){this[u](t,t.keyEncoding);const e=this[l].iterator(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_keys(t){this[u](t,t.keyEncoding);const e=this[l].keys(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_values(t){this[u](t,t.keyEncoding);const e=this[l].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=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 b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=r?r.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="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,n)),n}}const m=function(t,e){let n=0,i=t.length;for(;nn&&t[i-1]===e;)i--;return t.slice(n,i)}},2520:(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:{}}},4765:(t,e,n)=>{"use strict";const{AbstractChainedBatch:i}=n(9464),r=n(4473),s=Symbol("encoded");e.DefaultChainedBatch=class extends i{constructor(t){super(t),this[s]=[]}_put(t,e,n){this[s].push({...n,type:"put",key:t,value:e})}_del(t,e){this[s].push({...e,type:"del",key:t})}_clear(){this[s]=[]}_write(t,e){"opening"===this.db.status?this.db.defer((()=>this._write(t,e))):"open"===this.db.status?0===this[s].length?this.nextTick(e):this.db._batch(this[s],t,e):this.nextTick(e,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},5429:(t,e,n)=>{"use strict";const{AbstractKeyIterator:i,AbstractValueIterator:r}=n(3961),s=Symbol("iterator"),o=Symbol("callback"),a=Symbol("handleOne"),h=Symbol("handleMany");class c extends i{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}class u extends r{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}for(const t of[c,u]){const e=t===c,n=e?t=>t[0]:t=>t[1];t.prototype._next=function(t){this[o]=t,this[s].next(this[a])},t.prototype[a]=function(t,n,i){const r=this[o];t?r(t):r(null,e?n:i)},t.prototype._nextv=function(t,e,n){this[o]=n,this[s].nextv(t,e,this[h])},t.prototype._all=function(t,e){this[o]=e,this[s].all(t,this[h])},t.prototype[h]=function(t,e){const i=this[o];t?i(t):i(null,e.map(n))},t.prototype._seek=function(t,e){this[s].seek(t,e)},t.prototype._close=function(t){this[s].close(t)}}e.DefaultKeyIterator=c,e.DefaultValueIterator=u},593:(t,e,n)=>{"use strict";const{AbstractIterator:i,AbstractKeyIterator:r,AbstractValueIterator:s}=n(3961),o=n(4473),a=Symbol("nut"),h=Symbol("undefer"),c=Symbol("factory");class u extends i{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.iterator(e),this.db.defer((()=>this[h]()))}}class l extends r{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.keys(e),this.db.defer((()=>this[h]()))}}class f extends s{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.values(e),this.db.defer((()=>this[h]()))}}for(const t of[u,l,f])t.prototype[h]=function(){"open"===this.db.status&&(this[a]=this[c]())},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 o("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(t,e,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,new o("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 o("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=u,e.DeferredKeyIterator=l,e.DeferredValueIterator=f},6909:(t,e,n)=>{"use strict";const i=n(4375);t.exports=function(t,...e){0===e.length?i(t):i((()=>t(...e)))}},56:(t,e,n)=>{"use strict";const i=n(4473),r=Object.prototype.hasOwnProperty,s=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const o in t)if(r.call(t,o)&&"keyEncoding"!==o&&"valueEncoding"!==o){if("start"===o||"end"===o)throw new i(`The legacy range option '${o}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===o)throw new i("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});s.has(o)?n[o]=e.encode(t[o]):n[o]=t[o]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{"use strict";e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,s=a(t),o=s[0],h=s[1],c=new r(function(t,e,n){return 3*(e+n)/4-n}(0,o,h)),u=0,l=h>0?o-4:o;for(n=0;n>16&255,c[u++]=e>>8&255,c[u++]=255&e;return 2===h&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,c[u++]=255&e),1===h&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e),c},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=16383,a=0,c=i-r;ac?c:a+o));return 1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),s.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],i[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function h(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},1708:(t,e,n)=>{"use strict";const{AbstractLevel:i}=n(875),r=n(4473),s=n(9967),{fromCallback:o}=n(6957),{Iterator:a}=n(8212),h=n(9687),c=n(9968),u=n(1217),l="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends i{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new r("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:i,version:s,...o}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},o),"string"!=typeof t)throw new Error("constructor requires a location string argument");this[p]=t,this[d]=null==i?l:i,this[y]=parseInt(s||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const i=this[g]("readonly");let s;try{s=i.get(t)}catch(t){return this.nextTick(n,t)}this[b](s,(function(t,e){return t?n(t):void 0===e?n(new r("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,h(e))}))}_getMany(t,e,n){const i=this[g]("readonly"),r=t.map((t=>e=>{let n;try{n=i.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:h(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));s(r,16,n)}_del(t,e,n){const i=this[g]("readwrite");let r;try{r=i.delete(t)}catch(t){return this.nextTick(n,t)}this[b](r,n)}_put(t,e,n,i){const r=this[g]("readwrite");let s;try{s=r.put(e,t)}catch(t){return this.nextTick(i,t)}this[b](s,i)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const i=this[g]("readwrite"),r=i.transaction;let s,o=0;r.onabort=function(){n(s||r.error||new Error("aborted by user"))},r.oncomplete=function(){n()},function e(){const n=t[o++],a=n.key;let h;try{h="del"===n.type?i.delete(a):i.put(n.value,a)}catch(t){return s=t,void r.abort()}o=0)return c(this,this[p],n,t,e);try{const t=this[g]("readwrite");i=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](i,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=l),n=o(n,E);const i=indexedDB.deleteDatabase(e+t);return i.onsuccess=function(){n()},i.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{"use strict";const{AbstractIterator:i}=n(875),r=n(1217),s=n(9687),o=Symbol("cache"),a=Symbol("finished"),h=Symbol("options"),c=Symbol("currentOptions"),u=Symbol("position"),l=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends i{constructor(t,e,n){super(t,n),this[o]=[],this[a]=0===this.limit,this[h]=n,this[c]={...n},this[u]=void 0,this[l]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[o].length>0)return t=Math.min(t,this[o].length),this.nextTick(n,null,this[o].splice(0,t));let i;void 0!==this[u]&&(this[h].reverse?(this[c].lt=this[u],this[c].lte=void 0):(this[c].gt=this[u],this[c].gte=void 0));try{i=r(this[c])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[l]],"readonly"),y=d.objectStore(this[l]),g=[];if(this[h].reverse)y[!this[h].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](i,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:i}=n;this[u]=e,g.push([this[h].keys&&void 0!==e?s(e):void 0,this[h].values&&void 0!==i?s(i):void 0]),g.length{if(void 0===e||void 0===n)return;const i=Math.max(e.length,n.length);0===i||t===1/0?this[a]=!0:this[u]=e[i-1],g.length=i;for(let t=0;t{e=t.target.result,r()}:(e=[],this.nextTick(r)),this[h].values?y.getAll(i,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,r()}:(n=[],this.nextTick(r))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[o].length>0){const[e,n]=this[o].shift();this.nextTick(t,null,e,n)}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,n)=>{if(e)return t(e);this[o]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[o].splice(0,this[o].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(e,null,n);this._nextv(i,d,((t,i)=>{if(t)return e(t);n.length>0&&(i=n.concat(i)),e(null,i)}))}_seek(t,e){let n;this[f]=!0,this[o]=[],this[a]=!1,this[u]=void 0,this[c]={...this[h]};try{n=r(this[h])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[h].reverse?this[c].lte=t:this[c].gte=t:this[a]=!0}}},9968:t=>{"use strict";t.exports=function(t,e,n,i,r){if(0===i.limit)return t.nextTick(r);const s=t.db.transaction([e],"readwrite"),o=s.objectStore(e);let a=0;s.oncomplete=function(){r()},s.onabort=function(){r(s.error||new Error("aborted by user"))};const h=o.openKeyCursor?"openKeyCursor":"openCursor",c=i.reverse?"prev":"next";o[h](n,c).onsuccess=function(t){const e=t.target.result;e&&(o.delete(e.key).onsuccess=function(){(i.limit<=0||++a{"use strict";const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{"use strict";t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,i=void 0===t.gte,r=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,i,r):void 0!==e?IDBKeyRange.lowerBound(e,i):void 0!==n?IDBKeyRange.upperBound(n,r):null}},8764:(t,e,n)=>{"use strict";const i=n(9742),r=n(645),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,n){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 c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let i=a(n);const r=i.write(t,e);return r!==n&&(i=i.slice(0,r)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,n);const r=function(t){if(h.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(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 u(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let i=0;i=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function y(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(r)return i?-1:q(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function b(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function E(t,e,n,i,r){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:m(t,e,n,i,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,i,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,i,r){let s,o=1,a=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,n/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let i=-1;for(s=n;sa&&(n=a-h),s=n;s>=0;s--){let n=!0;for(let i=0;ir&&(i=r):i=r;const s=e.length;let o;for(i>s/2&&(i=s/2),o=0;o>8,r=n%256,s.push(r),s.push(i);return s}(e,t.length-n),t,n,i)}function L(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const i=[];let r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+o<=n){let n,i,a,h;switch(o){case 1:e<128&&(s=e);break;case 2:n=t[r+1],128==(192&n)&&(h=(31&e)<<6|63&n,h>127&&(s=h));break;case 3:n=t[r+1],i=t[r+2],128==(192&n)&&128==(192&i)&&(h=(15&e)<<12|(63&n)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:n=t[r+1],i=t[r+2],a=t[r+3],128==(192&n)&&128==(192&i)&&128==(192&a)&&(h=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&a,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),r+=o}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",i=0;for(;ii.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,r)):Uint8Array.prototype.set.call(i,e,r);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,r)}r+=e.length}return i},h.byteLength=y,h.prototype._isBuffer=!0,h.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;en&&(t+=" ... "),""},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,n,i,r){if(Y(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.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===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),e<0||n>t.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&e>=n)return 0;if(i>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(e>>>=0);const a=Math.min(s,o),c=this.slice(i,r),u=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-e;if((void 0===n||n>r)&&(n=r),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;ri)&&(n=i);let r="";for(let i=e;in)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,i,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function D(t,e,n,i,r){z(e,i,r,t,n,7);let s=Number(e&BigInt(4294967295));t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,n}function U(t,e,n,i,r){z(e,i,r,t,n,7);let s=Number(e&BigInt(4294967295));t[n+7]=s,s>>=8,t[n+6]=s,s>>=8,t[n+5]=s,s>>=8,t[n+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=o,o>>=8,t[n+2]=o,o>>=8,t[n+1]=o,o>>=8,t[n]=o,n+8}function P(t,e,n,i,r,s){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,i,s){return e=+e,n>>>=0,s||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function B(t,e,n,i,s){return e=+e,n>>>=0,s||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}h.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t],r=1,s=0;for(;++s>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t+--e],r=1;for(;e>0&&(r*=256);)i+=this[t+--e]*r;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t],r=1,s=0;for(;++s=r&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let i=e,r=1,s=this[t+--i];for(;i>0&&(r*=256);)s+=this[t+--i]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||C(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||N(this,t,e,n,Math.pow(2,8*n)-1,0);let r=1,s=0;for(this[e]=255&t;++s>>=0,n>>>=0,i||N(this,t,e,n,Math.pow(2,8*n)-1,0);let r=n-1,s=1;for(this[e+r]=255&t;--r>=0&&(s*=256);)this[e+r]=t/s&255;return e+n},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}let r=0,s=1,o=0;for(this[e]=255&t;++r>0)-o&255;return e+n},h.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}let r=n-1,s=1,o=0;for(this[e+r]=255&t;--r>=0&&(s*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/s>>0)-o&255;return e+n},h.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},h.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},h.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},h.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},h.prototype.copy=function(t,e,n,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,i,r,s){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new F.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(i,r,s)}function G(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new F.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=V(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),i+=` It must be ${e}. Received ${r}`,i}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const i=t.length;let r=null;const s=[];for(let o=0;o55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,i){let r;for(r=0;r=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)e[i+r]=t[n]+t[r]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6957:(t,e,n)=>{"use strict";var i=n(886);e.fromCallback=function(t,e){if(void 0===t){var n=new Promise((function(e,n){t=function(t,i){t?n(t):e(i)}}));t[void 0!==e?e:"promise"]=n}else if("function"!=typeof t)throw new TypeError("Callback must be a function");return t},e.fromPromise=function(t,e){if(void 0===e)return t;t.then((function(t){i((()=>e(null,t)))})).catch((function(t){i((()=>e(t)))}))}},886:t=>{t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t)},8840:(t,e)=>{function n(t){for(var e="",n=0;n0?"F"+o:"D"+n(o)},e.decode=function(t){if("DaN"===t)return NaN;if("FF"===t)return 1/0;if("DD"===t)return-1/0;var e="D"===t[0],i=(e?n(t):t).slice(2).split("M");return Number((e?"-":"")+i[1]+"e"+String(Number(i[0])-500))}},2833:(t,e)=>{var n={"?":"?@","!":"??",'"':"?%"},i={"?@":"?","??":"!","?%":'"'};e.factory=function(t){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,r=e.split('"'),s=[[]],o=0,a=r.length,h=0;h{var i=n(8840),r=n(2833);e.flip=function(t){var e=t.toString(),n="";for(var i in e)n+="."==e[i]?".":9-+e[i];return n},e.number=i,e.string={encode:function(t){return/\x00|\x01/.test(t)?"J"+t.replace(/\x01/g,"").replace(/\x00/g,""):"J"+t},decode:function(t){if("J"===t[0])return t.substring(1)}},e.encode=function(t){return e[typeof t].encode(t)},e.decode=function(t){if(""===t)return t;if(!s[t[0]])throw new Error("no decoder for:"+JSON.stringify(t));return s[t[0]](t)},e.object=r.factory(e),e.boolean={encode:function(t){return t?"C":"B"},decode:function(t){return"C"===t}},e.undefined={encode:function(t){return"L"},decode:function(){}};var s={A:e.object.decode,B:e.boolean.decode,C:e.boolean.decode,D:e.number.decode,F:e.number.decode,J:e.string.decode,K:e.object.decode,L:e.undefined.decode};e.buffer=!1,e.type="charwise"},6729:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function i(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,i,s,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new r(i,s||t,o),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,s=i.length,o=new Array(s);r{"use strict";var e,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var r=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise((function(n,i){function r(n){t.removeListener(e,s),i(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}y(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,r)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function c(t,e,n,i){var r,s,o,c;if(a(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=h(t))>0&&o.length>r&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,c=u,console&&console.warn&&console.warn(c)}return t}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=u.bind(i);return r.listener=n,i.wrapFn=r,r}function f(t,e,n){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var c=h.length,u=p(h,c);for(n=0;n=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9203:(t,e,n)=>{const i=n(7270),{BrowserLevel:r}=n(1708);t.exports=({name:t="fii",...e})=>i({db:new r(t),...e})},7270:(t,e,n)=>{const i=n(9563),r=n(8936),s=n(1387),o=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELDe.FIELD?1:t.VALUEe.VALUE?1:t.SCOREe.SCORE?1:0)),t))),a=t=>{const e=i(t),n=r(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(o),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(o),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:s,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(o),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(o),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const i=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;i.open((r=>r?n(r):e(Object.assign(t,{_db:i}))))})))(t).then(a)},1387:(t,e,n)=>{const i=n(2483);t.exports={keyEncoding:i,valueEncoding:"json"}},6782:t=>{const e=null,n=void 0;t.exports=(t,i)=>new Promise(((r,s)=>{if(Array.isArray(t))return s(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return r({FIELD:i,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return r({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?r(Object.assign(t,{FIELD:i})):(t.FIELD=[t.FIELD].flat(),r(t))}))},9563:(t,e,n)=>{const i=n(6782),r=n(2483),{EntryStream:s}=n(6741),o=n(1387);r.LO=null,r.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>i(t,await l()),a=async(e,i=(t=>new Promise((e=>e(t)))))=>new Promise((async(r,s)=>{const o=t=>void 0===t?r(void 0):t instanceof Promise?r(t):void 0;try{o(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),o(e=await(e=>void 0===e?u(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?h(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),o(e=await i(e))}catch(t){return s(t)}return Array.isArray(e)?r(e):r(u(e))})),h=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),c=(t,e,n)=>{const i=[];return void 0===e&&"number"!=typeof e||i.push(e),n&&i.push(r.HI),["IDX",t,i]},u=e=>new Promise((n=>{if(void 0===e)return n(void 0);const i=new Map;return Promise.all(e.FIELD.map((n=>new Promise((r=>new s(t._db,{gte:c(n,e.VALUE.GTE),lte:c(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...o}).on("data",(t=>t.value.forEach((e=>i.set(e,[...i.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",r)))))).then((()=>n(Array.from(i.keys()).map((t=>({_id:t,_match:i.get(t)}))))))})),l=()=>new Promise((e=>{const n=[];new s(t._db,{gte:["FIELD",r.LO],lte:["FIELD",r.HI],...o}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,i)=>{const r=[];new s(t._db,{...e,...o}).on("data",(t=>{r.push(t)})).on("end",(()=>n(r)))})),y=(t,e)=>n(t).then((t=>u(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let i=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(i+=" "),p({gte:c(e,i),lte:c(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:c(e,t.VALUE.GTE),lte:c(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],o),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],o).catch((t=>null))))).then((t=>t.reduce(((t,n,i)=>(null!=n&&t.push(e[i]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:l,GET:a,INTERSECTION:(t,e)=>h(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],o),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],o).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:h,parseToken:n}}},8936:(t,e,n)=>{const i=n(3692),r=n(9563),s=n(1387);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const r=[];return i(e._object).forEach((function(e){const i=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==i&&!n.doNotIndexField.filter((t=>i.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([i,[this.node].flat(1/0)]);r.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:r}},o=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(i,a,h,c,u)=>new Promise((l=>{i=i.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),u=Object.assign(t,u),r(t).EXIST(...i.map((t=>t._id))).then((t=>((t,e,n)=>{const i=Object.keys(t);return Promise.all(i.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,i)=>e.get(t,s).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,r)=>{const s=new Set(e),o=new Set(t[i[r]]);if("put"===n)return{key:["IDX",...JSON.parse(i[r])],type:n,value:[...new Set([...s,...o])].sort()};if("del"===n){const t=[...new Set([...s].filter((t=>!o.has(t))))];return{key:["IDX",...JSON.parse(i[r])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(o,{}))(i,u),a,h).then((e=>a.batch(e.concat(u.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(i,h):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),s,(e=>l(i.map((e=>{let n;return"put"===h?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===h&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:c,status:n}})))))))))})),h=e=>t._db.put(["~LAST_UPDATED"],Date.now(),s).then((()=>e));return{DELETE:e=>r(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(h),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),s))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(h),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],s).then().catch((e=>t._db.put(["~CREATED"],Date.now(),s).then(h))),TIMESTAMP_LAST_UPDATED:h}}},645:(t,e)=>{e.read=function(t,e,n,i,r){var s,o,a=8*r-i-1,h=(1<>1,u=-7,l=n?r-1:0,f=n?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-u)-1,d>>=-u,u+=a;u>0;s=256*s+t[e+l],l+=f,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=i;u>0;o=256*o+t[e+l],l+=f,u-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),s-=c}return(d?-1:1)*o*Math.pow(2,s-i)},e.write=function(t,e,n,i,r,s){var o,a,h,c=8*s-r-1,u=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[n+d]=255&a,d+=p,a/=256,r-=8);for(o=o<0;t[n+d]=255&o,d+=p,o/=256,c-=8);t[n+d-p]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},6741:(t,e,n)=>{"use strict";const{Readable:i}=n(8473),r=Symbol("iterator"),s=Symbol("nextv");class o extends i{constructor(t,e,n){const{highWaterMark:i,...o}=n||{};super({objectMode:!0,highWaterMark:i||1e3}),this[r]=t[e](o),this[s]=this[s].bind(this),this.once("end",this.destroy.bind(this,null,null))}get db(){return this[r].db}_read(t){this.destroyed||this[r].nextv(t,this[s])}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const t of e)this.push(t)}}_destroy(t,e){this[r].close((function(n){e(t||n)}))}}e.EntryStream=class extends o{constructor(t,e){super(t,"iterator",{...e,keys:!0,values:!0})}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const[t,n]of e)this.push({key:t,value:n})}}},e.KeyStream=class extends o{constructor(t,e){super(t,"keys",e)}},e.ValueStream=class extends o{constructor(t,e){super(t,"values",e)}}},8499:(t,e,n)=>{"use strict";const i=n(4473),r=n(8002),{Encoding:s}=n(8266),{BufferFormat:o,ViewFormat:a,UTF8Format:h}=n(2376),c=Symbol("formats"),u=Symbol("encodings"),l=new Set(["buffer","view","utf8"]);e.Transcoder=class{constructor(t){if(!Array.isArray(t))throw new TypeError("The first argument 'formats' must be an array");if(!t.every((t=>l.has(t))))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[u]=new Map,this[c]=new Set(t);for(const t in r)try{this.encoding(t)}catch(t){if("LEVEL_ENCODING_NOT_SUPPORTED"!==t.code)throw t}}encodings(){return Array.from(new Set(this[u].values()))}encoding(t){let e=this[u].get(t);if(void 0===e){if("string"==typeof t&&""!==t){if(e=d[t],!e)throw new i(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if("object"!=typeof t||null===t)throw new TypeError("First argument 'encoding' must be a string or object");e=function(t){if(t instanceof s)return t;const e="type"in t&&"string"==typeof t.type?t.type:void 0,n=t.name||e||"anonymous-"+p++;switch(function(t){return"format"in t&&void 0!==t.format?t.format:"buffer"in t&&"boolean"==typeof t.buffer?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}(t)){case"view":return new a({...t,name:n});case"utf8":return new h({...t,name:n});case"buffer":return new o({...t,name:n});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}(t)}const{name:n,format:r}=e;if(!this[c].has(r))if(this[c].has("view"))e=e.createViewTranscoder();else if(this[c].has("buffer"))e=e.createBufferTranscoder();else{if(!this[c].has("utf8"))throw new i(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});e=e.createUTF8Transcoder()}for(const i of[t,n,e.name,e.commonName])this[u].set(i,e)}return e}};const f={binary:r.buffer,"utf-8":r.utf8},d={...r,...f};let p=0},8266:(t,e,n)=>{"use strict";const i=n(4473),r=new Set(["buffer","view","utf8"]);e.Encoding=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,"function"!=typeof this.encode)throw new TypeError("The 'encode' property must be a function");if("function"!=typeof this.decode)throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),"string"!=typeof this.name||""===this.name)throw new TypeError("The 'name' property must be a string");if("string"!=typeof this.format||!r.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}},8002:(t,e,n)=>{"use strict";const{Buffer:i}=n(8764)||{Buffer:{isBuffer:()=>!1}},{textEncoder:r,textDecoder:s}=n(4005)(),{BufferFormat:o,ViewFormat:a,UTF8Format:h}=n(2376),c=t=>t;e.utf8=new h({encode:function(t){return i.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?s.decode(t):String(t)},decode:c,name:"utf8",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.encode(t)},decode:function(t){return s.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new o({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}}),e.json=new h({encode:JSON.stringify,decode:JSON.parse,name:"json"}),e.buffer=new o({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:c,name:"buffer",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.from(String(t),"utf8")},decode:function(t){return i.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}}),e.view=new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.encode(t)},decode:c,name:"view",createBufferTranscoder(){return new o({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:c,name:`${this.name}+buffer`})}}),e.hex=new o({encode:function(t){return i.isBuffer(t)?t:i.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"}),e.base64=new o({encode:function(t){return i.isBuffer(t)?t:i.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})},2376:(t,e,n)=>{"use strict";const{Buffer:i}=n(8764)||{},{Encoding:r}=n(8266),s=n(4005);class o extends r{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:t=>this.decode(i.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class a extends r{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new o({encode:t=>{const e=this.encode(t);return i.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}e.BufferFormat=o,e.ViewFormat=a,e.UTF8Format=class extends r{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new o({encode:t=>i.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){const{textEncoder:t,textDecoder:e}=s();return new a({encode:e=>t.encode(this.encode(e)),decode:t=>this.decode(e.decode(t)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}},4005:t=>{"use strict";let e=null;t.exports=function(){return null===e&&(e={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),e}},4473:t=>{"use strict";t.exports=class extends Error{constructor(t,e){super(t||""),"object"==typeof e&&null!==e&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}},6349:function(t,e){!function(t){"use strict";const e=function(t,e){return t.slice(e-1).map(((n,i)=>t.slice(i,i+e)))};t.ngraminator=function(t,n){return n.reduce(((n,i)=>[...e(t,i),...n]),[]).sort()},Object.defineProperty(t,"__esModule",{value:!0})}(e)},4155:t=>{var e,n,i=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===r||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:r}catch(t){e=r}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var a,h=[],c=!1,u=-1;function l(){c&&a&&(c=!1,a.length?h=a.concat(h):u=-1,h.length&&f())}function f(){if(!c){var t=o(l);c=!0;for(var e=h.length;e;){for(a=h,h=[];++u1)for(var n=1;n{let i;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:n.g):t=>(i||(i=Promise.resolve())).then(t).catch((t=>setTimeout((()=>{throw t}),0)))},4281:t=>{"use strict";var e={};function n(t,n,i){i||(i=Error);var r=function(t){var e,i;function r(e,i,r){return t.call(this,function(t,e,i){return"string"==typeof n?n:n(t,e,i)}(e,i,r))||this}return i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i,r}(i);r.prototype.name=i.name,r.prototype.code=t,e[t]=r}function i(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(t){return String(t)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:2===n?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}n("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(t,e,n){var r,s,o,a,h;if("string"==typeof e&&(s="not ",e.substr(0,4)===s)?(r="must not be",e=e.replace(/^not /,"")):r="must be",function(t,e,n){return(void 0===n||n>t.length)&&(n=t.length),t.substring(n-9,n)===e}(t," argument"))o="The ".concat(t," ").concat(r," ").concat(i(e,"type"));else{var c=("number"!=typeof h&&(h=0),h+1>(a=t).length||-1===a.indexOf(".",h)?"argument":"property");o='The "'.concat(t,'" ').concat(c," ").concat(r," ").concat(i(e,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},6753:(t,e,n)=>{"use strict";var i=n(4155),r=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=u;var s=n(9481),o=n(4229);n(5717)(u,s);for(var a=r(o.prototype),h=0;h{"use strict";t.exports=r;var i=n(4605);function r(t){if(!(this instanceof r))return new r(t);i.call(this,t)}n(5717)(r,i),r.prototype._transform=function(t,e,n){n(null,t)}},9481:(t,e,n)=>{"use strict";var i,r=n(4155);t.exports=L,L.ReadableState=S,n(7187).EventEmitter;var s,o=function(t,e){return t.listeners(e).length},a=n(2503),h=n(8764).Buffer,c=n.g.Uint8Array||function(){},u=n(4616);s=u&&u.debuglog?u.debuglog("stream"):function(){};var l,f,d,p=n(7327),y=n(1195),g=n(2457).getHighWaterMark,b=n(4281).q,E=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(5717)(L,a);var _=y.errorOrDestroy,T=["error","close","destroy","pause","resume"];function S(t,e,r){i=i||n(6753),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",r),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=n(2553).s),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function L(t){if(i=i||n(6753),!(this instanceof L))return new L(t);var e=this instanceof i;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function O(t,e,n,i,r){s("readableAddChunk",e);var o,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(s("onEofChunk"),!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?R(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,a);else if(r||(o=function(t,e){var n,i;return i=e,h.isBuffer(i)||i instanceof c||"string"==typeof e||void 0===e||t.objectMode||(n=new E("chunk",["string","Buffer","Uint8Array"],e)),n}(a,e)),o)_(t,o);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===h.prototype||(e=function(t){return h.from(t)}(e)),i)a.endEmitted?_(t,new w):A(t,a,e,!0);else if(a.ended)_(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(e=a.decoder.write(e),a.objectMode||0!==e.length?A(t,a,e,!1):C(t,a)):A(t,a,e,!1)}else i||(a.reading=!1,C(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=k?t=k:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function R(t){var e=t._readableState;s("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(s("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(I,t))}function I(t){var e=t._readableState;s("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function U(t){s("readable nexttick read 0"),t.read(0)}function P(t,e){s("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(s("flow",e.flowing);e.flowing&&null!==t.read(););}function B(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function F(t){var e=t._readableState;s("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(j,e,t))}function j(t,e){if(s("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function V(t,e){for(var n=0,i=t.length;n=e.highWaterMark:e.length>0)||e.ended))return s("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):R(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&F(this),null;var i,r=e.needReadable;return s("need readable",r),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&F(this)),null!==i&&this.emit("data",i),i},L.prototype._read=function(t){_(this,new v("_read()"))},L.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,s("pipe count=%d opts=%j",i.pipesCount,e);var a=e&&!1===e.end||t===r.stdout||t===r.stderr?y:h;function h(){s("onend"),t.end()}i.endEmitted?r.nextTick(a):n.once("end",a),t.on("unpipe",(function e(r,o){s("onunpipe"),r===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,s("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",c),t.removeListener("error",f),t.removeListener("unpipe",e),n.removeListener("end",h),n.removeListener("end",y),n.removeListener("data",l),u=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;s("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",c);var u=!1;function l(e){s("ondata");var r=t.write(e);s("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==V(i.pipes,t))&&!u&&(s("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function f(e){s("onerror",e),y(),t.removeListener("error",f),0===o(t,"error")&&_(t,e)}function d(){t.removeListener("finish",p),y()}function p(){s("onfinish"),t.removeListener("close",d),y()}function y(){s("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),i.flowing||(s("pipe resume"),n.resume()),t},L.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var i=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,s("on readable",i.length,i.reading),i.length?R(this):i.reading||r.nextTick(U,this))),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(t,e){var n=a.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(D,this),n},L.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(D,this),e},L.prototype.resume=function(){var t=this._readableState;return t.flowing||(s("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(P,t,e))}(this,t)),t.paused=!1,this},L.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},L.prototype.wrap=function(t){var e=this,n=this._readableState,i=!1;for(var r in t.on("end",(function(){if(s("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(r){s("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r||(n.objectMode||r&&r.length)&&(e.push(r)||(i=!0,t.pause()))})),t)void 0===this[r]&&"function"==typeof t[r]&&(this[r]=function(e){return function(){return t[e].apply(t,arguments)}}(r));for(var o=0;o{"use strict";t.exports=u;var i=n(4281).q,r=i.ERR_METHOD_NOT_IMPLEMENTED,s=i.ERR_MULTIPLE_CALLBACK,o=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,h=n(6753);function c(t,e){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(null===i)return this.emit("error",new s);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),i(t);var r=this._readableState;r.reading=!1,(r.needReadable||r.length{"use strict";var i,r=n(4155);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var i=t.entry;for(t.entry=null;i;){var r=i.callback;e.pendingcb--,r(undefined),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=L,L.WritableState=S;var o,a={deprecate:n(4927)},h=n(2503),c=n(8764).Buffer,u=n.g.Uint8Array||function(){},l=n(1195),f=n(2457).getHighWaterMark,d=n(4281).q,p=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,E=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function T(){}function S(t,e,o){i=i||n(6753),t=t||{},"boolean"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=f(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,i=n.sync,s=n.writecb;if("function"!=typeof s)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,s){--e.pendingcb,n?(r.nextTick(s,i),r.nextTick(I,t,e),t._writableState.errorEmitted=!0,_(t,i)):(s(i),t._writableState.errorEmitted=!0,_(t,i),I(t,e))}(t,n,i,e,s);else{var o=x(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||k(t,n),i?r.nextTick(A,t,n,o,s):A(t,n,o,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function L(t){var e=this instanceof(i=i||n(6753));if(!e&&!o.call(L,this))return new L(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function O(t,e,n,i,r,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new E("write")):n?t._writev(r,e.onwrite):t._write(r,s,e.onwrite),e.sync=!1}function A(t,e,n,i){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,i(),I(t,e)}function k(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var i=e.bufferedRequestCount,r=new Array(i),o=e.corkedRequestsFree;o.entry=n;for(var a=0,h=!0;n;)r[a]=n,n.isBuf||(h=!1),n=n.next,a+=1;r.allBuffers=h,O(t,e,!0,e.length,r,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,u=n.encoding,l=n.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,u,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(n){e.pendingcb--,n&&_(t,n),e.prefinished=!0,t.emit("prefinish"),I(t,e)}))}function I(t,e){var n=x(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(5717)(L,h),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(t){return!!o.call(this,t)||this===L&&t&&t._writableState instanceof S}})):o=function(t){return t instanceof this},L.prototype.pipe=function(){_(this,new b)},L.prototype.write=function(t,e,n){var i,s=this._writableState,o=!1,a=!s.objectMode&&(i=t,c.isBuffer(i)||i instanceof u);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=s.defaultEncoding),"function"!=typeof n&&(n=T),s.ending?function(t,e){var n=new v;_(t,n),r.nextTick(e,n)}(this,n):(a||function(t,e,n,i){var s;return null===n?s=new m:"string"==typeof n||e.objectMode||(s=new p("chunk",["string","Buffer"],n)),!s||(_(t,s),r.nextTick(i,s),!1)}(this,s,t,n))&&(s.pendingcb++,o=function(t,e,n,i,r,s){if(!n){var o=function(t,e,n){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,n)),e}(e,i,r);i!==o&&(n=!0,r="buffer",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var h=e.length-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),L.prototype._write=function(t,e,n){n(new y("_write()"))},L.prototype._writev=null,L.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,I(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),L.prototype.destroy=l.destroy,L.prototype._undestroy=l.undestroy,L.prototype._destroy=function(t,e){e(t)}},5850:(t,e,n)=>{"use strict";var i,r=n(4155);function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o=n(8610),a=Symbol("lastResolve"),h=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function p(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var n=t[d].read();null!==n&&(t[l]=null,t[a]=null,t[h]=null,e(p(n,!1)))}}function g(t){r.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),E=Object.setPrototypeOf((s(i={get stream(){return this[d]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise((function(e,n){r.nextTick((function(){t[c]?n(t[c]):e(p(void 0,!0))}))}));var n,i=this[l];if(i)n=new Promise(function(t,e){return function(n,i){t.then((function(){e[u]?n(p(void 0,!0)):e[f](n,i)}),i)}}(i,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(p(s,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),s(i,"return",(function(){var t=this;return new Promise((function(e,n){t[d].destroy(null,(function(t){t?n(t):e(p(void 0,!0))}))}))})),i),b);t.exports=function(t){var e,n=Object.create(E,(s(e={},d,{value:t,writable:!0}),s(e,a,{value:null,writable:!0}),s(e,h,{value:null,writable:!0}),s(e,c,{value:null,writable:!0}),s(e,u,{value:t._readableState.endEmitted,writable:!0}),s(e,f,{value:function(t,e){var i=n[d].read();i?(n[l]=null,n[a]=null,n[h]=null,t(p(i,!1))):(n[a]=t,n[h]=e)},writable:!0}),e));return n[l]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[h];return null!==e&&(n[l]=null,n[a]=null,n[h]=null,e(t)),void(n[c]=t)}var i=n[a];null!==i&&(n[l]=null,n[a]=null,n[h]=null,i(p(void 0,!0))),n[u]=!0})),t.on("readable",g.bind(null,n)),n}},7327:(t,e,n)=>{"use strict";function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){for(var n=0;n0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n}},{key:"concat",value:function(t){if(0===this.length)return o.alloc(0);for(var e,n,i,r=o.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,n=r,i=a,o.prototype.copy.call(e,n,i),a+=s.data.length,s=s.next;return r}},{key:"consume",value:function(t,e){var n;return tr.length?r.length:t;if(s===r.length?i+=r:i+=r.slice(0,t),0==(t-=s)){s===r.length?(++n,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=r.slice(s));break}++n}return this.length-=n,i}},{key:"_getBuffer",value:function(t){var e=o.allocUnsafe(t),n=this.head,i=1;for(n.data.copy(e),t-=n.data.length;n=n.next;){var r=n.data,s=t>r.length?r.length:t;if(r.copy(e,e.length-t,0,s),0==(t-=s)){s===r.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=r.slice(s));break}++i}return this.length-=i,e}},{key:h,value:function(t,e){return a(this,function(t){for(var e=1;e{"use strict";var i=n(4155);function r(t,e){o(t,e),s(t)}function s(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function o(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(o,this,t)):i.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted?i.nextTick(s,n):(n._writableState.errorEmitted=!0,i.nextTick(r,n,t)):i.nextTick(r,n,t):e?(i.nextTick(s,n),e(t)):i.nextTick(s,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,i=t._writableState;n&&n.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}}},8610:(t,e,n)=>{"use strict";var i=n(4281).q.ERR_STREAM_PREMATURE_CLOSE;function r(){}t.exports=function t(e,n,s){if("function"==typeof n)return t(e,null,n);n||(n={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var n=arguments.length,i=new Array(n),r=0;r{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9946:(t,e,n)=>{"use strict";var i,r=n(4281).q,s=r.ERR_MISSING_ARGS,o=r.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function h(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),r=0;r0,(function(t){u||(u=t),t&&f.forEach(h),s||(f.forEach(h),l(u))}))}));return e.reduce(c)}},2457:(t,e,n)=>{"use strict";var i=n(4281).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,r){var s=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,r,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new i(r?n:"highWaterMark",s);return Math.floor(s)}return t.objectMode?16:16384}}},2503:(t,e,n)=>{t.exports=n(7187).EventEmitter},8473:(t,e,n)=>{(e=t.exports=n(9481)).Stream=e,e.Readable=e,e.Writable=n(4229),e.Duplex=n(6753),e.Transform=n(4605),e.PassThrough=n(2725),e.finished=n(8610),e.pipeline=n(9946)},9967:(t,e,n)=>{t.exports=function(t,e,n){if("number"!=typeof e)throw new Error("second argument must be a Number");let r,s,o,a,h,c,u=!0;function l(t){function e(){n&&n(t,r),n=null}u?i(e):e()}function f(e,n,i){if(r[e]=i,n&&(h=!0),0==--o||n)l(n);else if(!h&&c{"use strict";var i=n(396).Buffer,r=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=u,this.end=l,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function u(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.s=s,s.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(r>0&&(t.lastNeed=r-1),r):--i=0?(r>0&&(t.lastNeed=r-2),r):--i=0?(r>0&&(2===r?r=0:t.lastNeed=r-3),r):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var i=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},396:(t,e,n)=>{var i=n(8764),r=i.Buffer;function s(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return r(t,e,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),o.prototype=Object.create(r.prototype),s(r,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return r(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=r(t);return void 0!==e?"string"==typeof n?i.fill(e,n):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},971:t=>{t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const n=t.reduce(((t,n,i,r)=>(e.ngramLengths.forEach((e=>{var s=r.slice(i,i+e);s.length===e&&(n=JSON.stringify(s),t[n]=t[n]||[],t[n].push(i))})),t)),{});return Object.keys(n).map((t=>({term:JSON.parse(t),positions:n[t]}))).sort(((t,e)=>t.term[0]>e.term[0]))}},3692:t=>{"use strict";function e(t){return Object.prototype.toString.call(t)}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n{function i(t){try{if(!n.g.localStorage)return!1}catch(t){return!1}var e=n.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(i("noDeprecation"))return t;var n=!1;return function(){if(!n){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}},2361:()=>{},4616:()=>{}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var s=e[i]={exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";n.r(i),n.d(i,{SearchIndex:()=>ft});var t=n(6729);class e extends Error{constructor(t){super(t),this.name="TimeoutError"}}class r extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const s=t=>void 0===globalThis.DOMException?new r(t):new DOMException(t),o=t=>{const e=void 0===t.reason?s("This operation was aborted."):t.reason;return e instanceof Error?e:s(e)};var a,h=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class c{constructor(){a.set(this,[])}enqueue(t,e){const n={priority:(e={priority:0,...e}).priority,run:t};if(this.size&&h(this,a,"f")[this.size-1].priority>=e.priority)return void h(this,a,"f").push(n);const i=function(t,e,n){let i=0,r=t.length;for(;r>0;){const n=Math.trunc(r/2);let o=i+n;s=t[o],e.priority-s.priority<=0?(i=++o,r-=n+1):r=n}var s;return i}(h(this,a,"f"),n);h(this,a,"f").splice(i,0,n)}dequeue(){const t=h(this,a,"f").shift();return null==t?void 0:t.run}filter(t){return h(this,a,"f").filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return h(this,a,"f").length}}a=new WeakMap;var u,l,f,d,p,y,g,b,E,m,v,w,_,T,S,L,O,A,k,x,R,I,C,N,D,U,P=function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},M=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class B extends Error{}class F extends t{constructor(t){var e,n,i,r;if(super(),u.add(this),l.set(this,void 0),f.set(this,void 0),d.set(this,0),p.set(this,void 0),y.set(this,void 0),g.set(this,0),b.set(this,void 0),E.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,0),_.set(this,void 0),T.set(this,void 0),S.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:c,...t}).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(r=null===(i=t.interval)||void 0===i?void 0:i.toString())&&void 0!==r?r:""}\` (${typeof t.interval})`);P(this,l,t.carryoverConcurrencyCount,"f"),P(this,f,t.intervalCap===Number.POSITIVE_INFINITY||0===t.interval,"f"),P(this,p,t.intervalCap,"f"),P(this,y,t.interval,"f"),P(this,m,new t.queueClass,"f"),P(this,v,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,P(this,S,!0===t.throwOnTimeout,"f"),P(this,T,!1===t.autoStart,"f")}get concurrency(){return M(this,_,"f")}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);P(this,_,t,"f"),M(this,u,"m",N).call(this)}async add(t,n={}){return n={timeout:this.timeout,throwOnTimeout:M(this,S,"f"),...n},new Promise(((i,r)=>{M(this,m,"f").enqueue((async()=>{var s,a,h;P(this,w,(a=M(this,w,"f"),++a),"f"),P(this,d,(h=M(this,d,"f"),++h),"f");try{if(null===(s=n.signal)||void 0===s?void 0:s.aborted)throw new B("The task was aborted.");let r=t({signal:n.signal});n.timeout&&(r=function(t,n,i,r){let s;const a=new Promise(((a,h)=>{if("number"!=typeof n||1!==Math.sign(n))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(n!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:t}=r;t.aborted&&h(o(t)),t.addEventListener("abort",(()=>{h(o(t))}))}s=r.customTimers.setTimeout.call(void 0,(()=>{const r=i instanceof Error?i:new e(`Promise timed out after ${n} milliseconds`);"function"==typeof t.cancel&&t.cancel(),h(r)}),n),(async()=>{try{a(await t)}catch(t){h(t)}finally{r.customTimers.clearTimeout.call(void 0,s)}})()}else a(t)}));return a.clear=()=>{clearTimeout(s),s=void 0},a}(Promise.resolve(r),n.timeout)),n.signal&&(r=Promise.race([r,M(this,u,"m",D).call(this,n.signal)]));const a=await r;i(a),this.emit("completed",a)}catch(t){if(t instanceof e&&!n.throwOnTimeout)return void i();r(t),this.emit("error",t)}finally{M(this,u,"m",A).call(this)}}),n),this.emit("add"),M(this,u,"m",R).call(this)}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return M(this,T,"f")?(P(this,T,!1,"f"),M(this,u,"m",N).call(this),this):this}pause(){P(this,T,!0,"f")}clear(){P(this,m,new(M(this,v,"f")),"f")}async onEmpty(){0!==M(this,m,"f").size&&await M(this,u,"m",U).call(this,"empty")}async onSizeLessThan(t){M(this,m,"f").sizeM(this,m,"f").size{M(this,u,"m",k).call(this)}),e),"f"),!0;P(this,d,M(this,l,"f")?M(this,w,"f"):0,"f")}return!1},R=function(){if(0===M(this,m,"f").size)return M(this,b,"f")&&clearInterval(M(this,b,"f")),P(this,b,void 0,"f"),this.emit("empty"),0===M(this,w,"f")&&this.emit("idle"),!1;if(!M(this,T,"f")){const t=!M(this,u,"a",x);if(M(this,u,"a",L)&&M(this,u,"a",O)){const e=M(this,m,"f").dequeue();return!!e&&(this.emit("active"),e(),t&&M(this,u,"m",I).call(this),!0)}}return!1},I=function(){M(this,f,"f")||void 0!==M(this,b,"f")||(P(this,b,setInterval((()=>{M(this,u,"m",C).call(this)}),M(this,y,"f")),"f"),P(this,g,Date.now()+M(this,y,"f"),"f"))},C=function(){0===M(this,d,"f")&&0===M(this,w,"f")&&M(this,b,"f")&&(clearInterval(M(this,b,"f")),P(this,b,void 0,"f")),P(this,d,M(this,l,"f")?M(this,w,"f"):0,"f"),M(this,u,"m",N).call(this)},N=function(){for(;M(this,u,"m",R).call(this););},D=async function(t){return new Promise(((e,n)=>{t.addEventListener("abort",(()=>{n(new B("The task was aborted."))}),{once:!0})}))},U=async function(t,e){return new Promise((n=>{const i=()=>{e&&!e()||(this.off(t,i),n())};this.on(t,i)}))};var j=n(6741);class V{constructor(t,e){const n=e=>new Promise(((n,i)=>{const r=[];new j.EntryStream(t.fii.STORE,{gte:["DOC_RAW",null],lte:["DOC_RAW",void 0],limit:e,...t.fii.LEVEL_OPTIONS}).on("data",(t=>r.push({_id:t.value._id,_doc:t.value}))).on("end",(()=>n(r)))})),i=(...e)=>e.length?Promise.all(e.map((e=>t.fii.STORE.get(["DOC_RAW",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))):n(),r=(...e)=>t.fii.DISTINCT(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),s=(...e)=>t.fii.FACETS(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),o=(t,e)=>{const n=(e=Object.assign({NUMBER:0,SIZE:20},e||{})).NUMBER*e.SIZE,i=n+e.SIZE||void 0;return t.slice(n,i)},a=(t,e={})=>{e=Object.assign({TYPE:"TFIDF"},e);const n=t=>!e.FIELDS||e.FIELDS.includes(t.FIELD),i=t=>(t||[]).filter(n);return new Promise((r=>r("TFIDF"===e.TYPE?c().then((e=>t.map(((t,i,r)=>{const s=Math.log((e+1)/r.length);return t._score=+(t._match||[]).filter(n).reduce(((t,e)=>t+s*+e.SCORE),0).toFixed(2),t})))):"PRODUCT"===e.TYPE?t.map((t=>({...t,_score:+i(t._match).reduce(((t,e)=>t*+e.SCORE),1).toFixed(2)}))):"CONCAT"===e.TYPE?t.map((t=>({...t,_score:i(t._match).reduce(((t,e)=>t+e.SCORE),"")}))):"SUM"===e.TYPE?t.map((t=>({...t,_score:+i(t._match).reduce(((t,e)=>t+ +e.SCORE),0).toFixed(2)}))):"VALUE"===e.TYPE?t.map((t=>({...t,_score:i(t._match).reduce(((t,e)=>t+e.VALUE),"")}))):null)))},h=(t,e)=>(e=Object.assign({DIRECTION:"DESCENDING",TYPE:"NUMERIC"},e||{}),t.sort(((t,e)=>t._ide._id?1:0)).sort({NUMERIC:{DESCENDING:(t,e)=>+e._score-+t._score,ASCENDING:(t,e)=>+t._score-+e._score},ALPHABETIC:{DESCENDING:(t,e)=>t._scoree._score?-1:0,ASCENDING:(t,e)=>t._scoree._score?1:0}}[e.TYPE][e.DIRECTION])),c=()=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS),u=(e,r={})=>{const c=e=>"string"==typeof e||"number"==typeof e?t.fii.GET(e,r.PIPELINE):e.FIELD||e.VALUE?t.fii.GET(e):e.AND?t.fii.AND(e.AND.map(c),r.PIPELINE):e.GET?t.fii.GET(e.GET,r.PIPELINE):e.NOT?t.fii.NOT(c(e.NOT.INCLUDE),c(e.NOT.EXCLUDE)):e.OR?t.fii.OR(e.OR.map(c),r.PIPELINE):e.ALL_DOCUMENTS?n(e.ALL_DOCUMENTS):void 0;return c(e).then((t=>t.RESULT?Object.assign(t,{RESULT_LENGTH:t.RESULT.length}):{RESULT:t,RESULT_LENGTH:t.length})).then((e=>r.BUCKETS?t.fii.BUCKETS(...r.BUCKETS).then((n=>Object.assign(e,{BUCKETS:t.fii.AGGREGATION_FILTER(n,e.RESULT)}))):e)).then((n=>r.FACETS?n.RESULT.length?e.ALL_DOCUMENTS?s(...r.FACETS).then((t=>Object.assign(n,{FACETS:t}))):s(...r.FACETS).then((e=>Object.assign(n,{FACETS:t.fii.AGGREGATION_FILTER(e,n.RESULT)}))):Object.assign(n,{FACETS:[]}):n)).then((t=>{return r.WEIGHT?Object.assign({RESULT:(e=t.RESULT,n=r.WEIGHT,e.map((t=>(t._match=t._match.map((t=>(n.forEach((e=>{let n=!1;e.FIELD&&e.VALUE?e.FIELD===t.FIELD&&e.VALUE===t.VALUE&&(n=!0):e.FIELD?e.FIELD===t.FIELD&&(n=!0):e.VALUE&&e.VALUE===t.VALUE&&(n=!0),n&&(t.SCORE=(e.WEIGHT*+t.SCORE).toFixed(2))})),t))),t))))},t):t;var e,n})).then((t=>r.SCORE?a(t.RESULT,r.SCORE).then((e=>Object.assign(t,{RESULT:e}))):t)).then((t=>Object.assign(t,r.SORT?{RESULT:h(t.RESULT,r.SORT)}:{}))).then((t=>Object.assign(t,r.PAGE?{RESULT:o(t.RESULT,r.PAGE)}:{}))).then((t=>r.DOCUMENTS?i(...t.RESULT.map((t=>t._id))).then((e=>Object.assign(t,{RESULT:t.RESULT.map(((t,n)=>Object.assign(t,{_doc:e[n]})))}))):t))},l=(t,n)=>new Promise((i=>(n=JSON.stringify(n),e.has(n)?i(e.get(n)):t.then((t=>e.set(n,t))).then((()=>i(e.get(n)))))));return{ALL_DOCUMENTS:n,DICTIONARY:t=>l((t=>r(t).then((t=>Array.from(t.reduce(((t,e)=>t.add(e.VALUE)),new Set)).sort(((t,e)=>(t+"").localeCompare(e+"",void 0,{numeric:!0,sensitivity:"base"}))))))(t),{DICTIONARY:t||null}),DISTINCT:r,DOCUMENTS:(...t)=>l(i(...t),{DOCUMENTS:t}),DOCUMENT_COUNT:c,DOCUMENT_VECTORS:(...e)=>Promise.all(e.map((e=>t.fii.STORE.get(["DOC",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))),FACETS:s,PAGE:o,QUERY:(t,e)=>l(u(t,e),{QUERY:[t,e]}),SCORE:a,SEARCH:(t,e)=>l(((t,e)=>u({AND:[...t]},Object.assign({SCORE:{TYPE:"TFIDF"},SORT:!0},e)))(t,e),{SEARCH:[t,e]}),SORT:h}}}var z=n(9203),G=n(4155);const W="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,K=new Set,q="object"==typeof G&&G?G:{},$=(t,e,n,i)=>{"function"==typeof q.emitWarning?q.emitWarning(t,e,n,i):console.error(`[${n}] ${e}: ${t}`)};let H=globalThis.AbortController,Y=globalThis.AbortSignal;if(void 0===H){Y=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},H=class{constructor(){e()}signal=new Y;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==q.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,$("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const J=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),X=t=>J(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Q:null:null;class Q extends Array{constructor(t){super(t),this.fill(0)}}class Z{heap;length;static#t=!1;static create(t){const e=X(t);if(!e)return[];Z.#t=!0;const n=new Z(t,e);return Z.#t=!1,n}constructor(t,e){if(!Z.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class tt{#e;#n;#i;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#h;#c;#u;#l;#f;#d;#p;#y;#g;#b;#E;#m;#v;#w;#_;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#m,sizes:t.#b,keyMap:t.#h,keyList:t.#c,valList:t.#u,next:t.#l,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#y,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,i,r)=>t.#S(e,n,i,r),moveToTail:e=>t.#L(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#r}constructor(t){const{max:e=0,ttl:n,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:s,updateAgeOnHas:o,allowStale:a,dispose:h,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:l,maxSize:f=0,maxEntrySize:d=0,sizeCalculation:p,fetchMethod:y,noDeleteOnFetchRejection:g,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:m,ignoreFetchAbort:v}=t;if(0!==e&&!J(e))throw new TypeError("max option must be a nonnegative integer");const w=e?X(e):Array;if(!w)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=f,this.maxEntrySize=d||this.#n,this.sizeCalculation=p,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==y&&"function"!=typeof y)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=y,this.#w=!!y,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#l=new w(e),this.#f=new w(e),this.#d=0,this.#p=0,this.#y=Z.create(e),this.#o=0,this.#a=0,"function"==typeof h&&(this.#i=h),"function"==typeof c?(this.#r=c,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#v=!!this.#i,this.#_=!!this.#r,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!l,this.noDeleteOnFetchRejection=!!g,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!m,this.ignoreFetchAbort=!!v,0!==this.maxEntrySize){if(0!==this.#n&&!J(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!J(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#x()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!o,this.ttlResolution=J(i)||0===i?i:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!J(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!K.has(t))(t)&&(K.add(t),$("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,tt))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#R(){const t=new Q(this.#e),e=new Q(this.#e);this.#m=t,this.#E=e,this.#I=(n,i,r=W.now())=>{if(e[n]=0!==i?r:0,t[n]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(n)&&this.delete(this.#c[n])}),i+1);t.unref&&t.unref()}},this.#C=n=>{e[n]=0!==t[n]?W.now():0},this.#N=(r,s)=>{if(t[s]){const o=t[s],a=e[s];r.ttl=o,r.start=a,r.now=n||i();const h=r.now-a;r.remainingTTL=o-h}};let n=0;const i=()=>{const t=W.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=r=>{const s=this.#h.get(r);if(void 0===s)return 0;const o=t[s],a=e[s];return 0===o||0===a?1/0:o-((n||i())-a)},this.#k=r=>0!==t[r]&&0!==e[r]&&(n||i())-e[r]>t[r]}#C=()=>{};#N=()=>{};#I=()=>{};#k=()=>!1;#x(){const t=new Q(this.#e);this.#a=0,this.#b=t,this.#D=e=>{this.#a-=t[e],t[e]=0},this.#U=(t,e,n,i)=>{if(this.#T(e))return 0;if(!J(n)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(n=i(e,t),!J(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#P=(e,n,i)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#a>n;)this.#M(!0)}this.#a+=t[e],i&&(i.entrySize=n,i.totalCalculatedSize=this.#a)}}#D=t=>{};#P=(t,e,n)=>{};#U=(t,e,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#d;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#l[e]}#B(t){return void 0!==t&&this.#h.get(this.#c[t])===t}*entries(){for(const t of this.#O())void 0===this.#u[t]||void 0===this.#c[t]||this.#T(this.#u[t])||(yield[this.#c[t],this.#u[t]])}*rentries(){for(const t of this.#A())void 0===this.#u[t]||void 0===this.#c[t]||this.#T(this.#u[t])||(yield[this.#c[t],this.#u[t]])}*keys(){for(const t of this.#O()){const e=this.#c[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#c[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*values(){for(const t of this.#O())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}*rvalues(){for(const t of this.#A())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of this.#O()){const i=this.#u[n],r=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==r&&t(r,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#O()){const i=this.#u[n],r=this.#T(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#A()){const i=this.#u[n],r=this.#T(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#c[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const n=this.#c[e],i=this.#u[e],r=this.#T(i)?i.__staleWhileFetching:i;if(void 0===r||void 0===n)continue;const s={value:r};if(this.#m&&this.#E){s.ttl=this.#m[e];const t=W.now()-this.#E[e];s.start=Math.floor(Date.now()-t)}this.#b&&(s.size=this.#b[e]),t.unshift([n,s])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=W.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:r,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=n;let{noUpdateTTL:h=this.noUpdateTTL}=n;const c=this.#U(t,e,n.size||0,o);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let u=0===this.#o?void 0:this.#h.get(t);if(void 0===u)u=0===this.#o?this.#p:0!==this.#y.length?this.#y.pop():this.#o===this.#e?this.#M(!1):this.#o,this.#c[u]=t,this.#u[u]=e,this.#h.set(t,u),this.#l[this.#p]=u,this.#f[u]=this.#p,this.#p=u,this.#o++,this.#P(u,c,a),a&&(a.set="add"),h=!1;else{this.#L(u);const n=this.#u[u];if(e!==n){if(this.#w&&this.#T(n)?n.__abortController.abort(new Error("replaced")):s||(this.#v&&this.#i?.(n,t,"set"),this.#_&&this.#g?.push([n,t,"set"])),this.#D(u),this.#P(u,c,a),this.#u[u]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#m||this.#R(),this.#m&&(h||this.#I(u,i,r),a&&this.#N(a,u)),!s&&this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#u[this.#d];if(this.#M(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}}}#M(t){const e=this.#d,n=this.#c[e],i=this.#u[e];return this.#w&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#v||this.#_)&&(this.#v&&this.#i?.(i,n,"evict"),this.#_&&this.#g?.push([i,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#u[e]=void 0,this.#y.push(e)),1===this.#o?(this.#d=this.#p=0,this.#y.length=0):this.#d=this.#l[e],this.#h.delete(n),this.#o--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=e,r=this.#h.get(t);if(void 0!==r){const t=this.#u[r];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(r))return n&&this.#C(r),i&&(i.has="hit",this.#N(i,r)),!0;i&&(i.has="stale",this.#N(i,r))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,i=this.#h.get(t);if(void 0!==i&&(n||!this.#k(i))){const t=this.#u[i];return this.#T(t)?t.__staleWhileFetching:t}}#S(t,e,n,i){const r=void 0===e?void 0:this.#u[e];if(this.#T(r))return r;const s=new H,{signal:o}=n;o?.addEventListener("abort",(()=>s.abort(o.reason)),{signal:s.signal});const a={signal:s.signal,options:n,context:i},h=(i,r=!1)=>{const{aborted:o}=s.signal,h=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(o&&!r?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,h&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!h&&!r)return c(s.signal.reason);const l=u;return this.#u[e]===u&&(void 0===i?l.__staleWhileFetching?this.#u[e]=l.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,i,a.options))),i},c=i=>{const{aborted:r}=s.signal,o=r&&n.allowStaleOnFetchAbort,a=o||n.allowStaleOnFetchRejection,h=a||n.noDeleteOnFetchRejection,c=u;if(this.#u[e]===u&&(h&&void 0!==c.__staleWhileFetching?o||(this.#u[e]=c.__staleWhileFetching):this.delete(t)),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw i};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#s?.(t,r,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),s.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),c(t)))),l=Object.assign(u,{__abortController:s,__staleWhileFetching:r,__returned:void 0});return void 0===e?(this.set(t,l,{...a.options,status:void 0}),e=this.#h.get(t)):this.#u[e]=l,l}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof H}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:b}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});const E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:s,noDisposeOnSet:o,size:a,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:g,signal:b};let m=this.#h.get(t);if(void 0===m){g&&(g.fetch="miss");const e=this.#S(t,m,E,p);return e.__returned=e}{const e=this.#u[m];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const r=this.#k(m);if(!y&&!r)return g&&(g.fetch="hit"),this.#L(m),i&&this.#C(m),g&&this.#N(g,m),e;const s=this.#S(t,m,E,p),o=void 0!==s.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",o&&r&&(g.returnedStale=!0)),o?s.__staleWhileFetching:s.__returned=s}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:s}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#u[o],a=this.#T(e);return s&&this.#N(s,o),this.#k(o)?(s&&(s.get="stale"),a?(s&&n&&void 0!==e.__staleWhileFetching&&(s.returnedStale=!0),n?e.__staleWhileFetching:void 0):(r||this.delete(t),s&&n&&(s.returnedStale=!0),n?e:void 0)):(s&&(s.get="hit"),a?e.__staleWhileFetching:(this.#L(o),i&&this.#C(o),e))}s&&(s.get="miss")}#F(t,e){this.#f[e]=t,this.#l[t]=e}#L(t){t!==this.#p&&(t===this.#d?this.#d=this.#l[t]:this.#F(this.#f[t],this.#l[t]),this.#F(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#o){const n=this.#h.get(t);if(void 0!==n)if(e=!0,1===this.#o)this.clear();else{this.#D(n);const e=this.#u[n];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#v||this.#_)&&(this.#v&&this.#i?.(e,t,"delete"),this.#_&&this.#g?.push([e,t,"delete"])),this.#h.delete(t),this.#c[n]=void 0,this.#u[n]=void 0,n===this.#p?this.#p=this.#f[n]:n===this.#d?this.#d=this.#l[n]:(this.#l[this.#f[n]]=this.#l[n],this.#f[this.#l[n]]=this.#f[n]),this.#o--,this.#y.push(n)}}if(this.#_&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#u[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const n=this.#c[t];this.#v&&this.#i?.(e,n,"delete"),this.#_&&this.#g?.push([e,n,"delete"])}}if(this.#h.clear(),this.#u.fill(void 0),this.#c.fill(void 0),this.#m&&this.#E&&(this.#m.fill(0),this.#E.fill(0)),this.#b&&this.#b.fill(0),this.#d=0,this.#p=0,this.#y.length=0,this.#a=0,this.#o=0,this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}}}const et=(t,e,n)=>{const i=e=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],+n+e,t.fii.LEVEL_OPTIONS))).catch((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],e,t.fii.LEVEL_OPTIONS))),r=(n,i,r)=>(e.clear(),Promise.all(n.map(((e,n)=>t.fii.STORE.put(["DOC_RAW",i[n]],r?{}:e,t.fii.LEVEL_OPTIONS)))).then((t=>n.map(((t,e)=>({_id:i[e],status:"OK",operation:"_PUT_RAW"}))))));return{DELETE:(...n)=>{return i=n,t.fii.DELETE(i,t.fii.LEVEL_OPTIONS).then((n=>{e.clear();const i=n.filter((t=>"DELETED"===t.status));return Promise.all([Promise.all(i.map((e=>t.fii.STORE.del(["DOC_RAW",e._id],t.fii.LEVEL_OPTIONS)))),(r=i.length,t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((e=>t.fii.STORE.put(["DOCUMENT_COUNT"],+e-r,t.fii.LEVEL_OPTIONS))))]).then((()=>n));var r}));var i},FLUSH:()=>t.fii.STORE.clear().then((()=>{e.clear();const n=Date.now();return t.fii.STORE.batch([{type:"put",key:["~CREATED"],value:n},{type:"put",key:["~LAST_UPDATED"],value:n},{type:"put",key:["DOCUMENT_COUNT"],value:0}],t.fii.LEVEL_OPTIONS)})).then((()=>!0)),IMPORT:n=>(e.clear(),Promise.resolve(t.fii.IMPORT(n))),PUT:(s,o)=>n.add((()=>((n,s)=>(e.clear(),s=Object.assign(t,s),(t=>{const e=t=>"string"==typeof t||t instanceof String,n=(i,r)=>new Promise((async s=>{return null===i?s([null,"1.00"]):(o=i)&&0===Object.keys(o).length&&Object.getPrototypeOf(o)===Object.prototype?s([[],"1.00"]):Number.isInteger(i)?s([i,i]):e(i)?s(t.tokenizer(i,r,t)):(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(i)?s((a=i,new Promise((async e=>{const i={};for(const e in a)i[e]=await n(a[e],e,t);return e(i)})))):(t=>Array.isArray(t))(i)?s((h=i,Promise.all(h.map(n)))):s(i);var o,a,h})),i=async i=>new Promise((async r=>{e(i)&&(i={body:i}),Object.prototype.hasOwnProperty.call(i,"_id")||(i._id=t.idGenerator.next().value);const s={};for(const t in i)s[t]="_id"!==t?await n(i[t],t):i[t];return r(s)}));return{processDocuments:t=>Promise.all(t.map(i))}})(t).processDocuments(n).then((e=>t.fii.PUT(e,s,t.fii.LEVEL_OPTIONS).then((e=>Promise.all([r(n,e.map((t=>t._id)),!t.storeRawDocs),i(e.filter((t=>"CREATED"===t.status)).length)]).then((()=>e))))))))(s,o))),PUT_RAW:r,_INCREMENT_DOC_COUNT:i}};var nt=n(971),it=n(6349);const rt=([t,e,n])=>[n.skipFields.includes(e)?[]:t,e,n],st=([t,e,n])=>Promise.resolve([t.map((t=>n.caseSensitive?t:t.toLowerCase())),e,n]),ot=([t,e,n])=>{const{fields:i,values:r}=n.replace,s=()=>t.reduce(((t,e)=>[e,...t,...r[e]||[]]),[]);return r?i?i.includes(e)?Promise.resolve([s(),e,n]):Promise.resolve([t,e,n]):Promise.resolve([s(),e,n]):Promise.resolve([t,e,n])},at=([t,e,n])=>{let{fields:i,lengths:r,join:s=" "}=n.ngrams;return i||(i=[e]),r&&i.includes(e)?[it(t.filter((t=>null!==t)),r).map((t=>t.join(s))),e,n]:Promise.resolve([t,e,n])},ht=([t,e,n])=>[t.filter((t=>!n.stopwords.includes(t.toLowerCase()))),e,n],ct=([t,e,n])=>{const i=nt(t),r=i.reduce(((t,e)=>Math.max(e.positions.length,t)),0);return Promise.resolve([i.map((t=>[t.term[0],(t.positions.length/r).toFixed(2)])).sort(),e,n])},ut=(t,e,n)=>(([t,e,n])=>Promise.resolve([t.match(n.tokenSplitRegex)||[],e,n]))([t,e,n]).then(rt).then(st).then(ot).then(at).then(ht).then(ct).then((([t,e,n])=>t)),lt=t=>new Promise((async e=>{const n=new tt({max:1e3}),i=new F({concurrency:1}),r=et(t,n,i),s=new V(t,n);return r._INCREMENT_DOC_COUNT(0).then((()=>e({_AND:t.fii.AND,_BUCKET:t.fii.BUCKET,_GET:t.fii.GET,_NOT:t.fii.NOT,_OR:t.fii.OR,_CACHE:n,_PAGE:s.PAGE,_SCORE:s.SCORE,_SEARCH:s.SEARCH,_SORT:s.SORT,DELETE:r.DELETE,FLUSH:r.FLUSH,IMPORT:r.IMPORT,PUT:r.PUT,PUT_RAW:r.PUT_RAW,TOKENIZATION_PIPELINE_STAGES:ut,ALL_DOCUMENTS:s.ALL_DOCUMENTS,BUCKETS:t.fii.BUCKETS,CREATED:t.fii.CREATED,DICTIONARY:s.DICTIONARY,DISTINCT:s.DISTINCT,DOCUMENTS:s.DOCUMENTS,DOCUMENT_COUNT:s.DOCUMENT_COUNT,DOCUMENT_VECTORS:s.DOCUMENT_VECTORS,EXPORT:t.fii.EXPORT,FACETS:s.FACETS,FIELDS:t.fii.FIELDS,INDEX:t.fii,LAST_UPDATED:t.fii.LAST_UPDATED,MAX:t.fii.MAX,MIN:t.fii.MIN,QUERY:s.QUERY,SEARCH:s.SEARCH})))}));class ft{constructor(t){return((t={})=>new Promise(((e,n)=>(t=Object.assign({cacheLength:1e3,caseSensitive:!1,docExistsSpace:"DOC_RAW",idGenerator:function*(){let t=0;for(;;)yield Date.now()+"-"+t++}(),isLeaf:t=>Array.isArray(t)&&2===t.length&&t.every((t=>"string"==typeof t||"number"==typeof t||null===t)),skipFields:[],ngrams:{},replace:{},storeRawDocs:!0,stopwords:[],storeVectors:!0,tokenAppend:"#",tokenSplitRegex:/[\p{L}\d]+/gu,tokenizer:ut},t),z(t).then((n=>e(Object.assign({fii:n},t))))))))(t).then(lt).then((t=>(t=>new Promise(((e,n)=>{const i=["CREATED_WITH"],r="search-index@4.0.0";return t.INDEX.STORE.get(i,t.INDEX.LEVEL_OPTIONS).then((t=>r===t?e():n(new Error("This index was created with "+t+", you are running "+r)))).catch((n=>t.INDEX.STORE.put(i,r,t.INDEX.LEVEL_OPTIONS).then(e)))})))(t).then((()=>t))))}}})(),SearchIndex=i})(); \ No newline at end of file diff --git a/dist/search-index-esm-4.0.0.js b/dist/search-index-esm-4.0.0.js index 07705578..170a75ab 100644 --- a/dist/search-index-esm-4.0.0.js +++ b/dist/search-index-esm-4.0.0.js @@ -1,2 +1,2 @@ /*! For license information please see search-index-esm-4.0.0.js.LICENSE.txt */ -var t={9464:(t,e,n)=>{const{fromCallback:r}=n(6957),i=n(4473),{getCallback:o,getOptions:s}=n(2520),a=Symbol("promise"),h=Symbol("status"),c=Symbol("operations"),l=Symbol("finishClose"),u=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[c]=[],this[u]=[],this[h]="open",this[l]=this[l].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[c].length}put(t,e,n){if("open"!==this[h])throw new i("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const r=this.db._checkKey(t)||this.db._checkValue(e);if(r)throw r;const o=n&&null!=n.sublevel?n.sublevel:this.db,s=n,a=o.keyEncoding(n&&n.keyEncoding),l=o.valueEncoding(n&&n.valueEncoding),u=a.format;n={...n,keyEncoding:u,valueEncoding:l.format},o!==this.db&&(n.sublevel=null);const f=o.prefixKey(a.encode(t),u),d=l.encode(e);return this._put(f,d,n),this[c].push({...s,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if("open"!==this[h])throw new i("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const n=this.db._checkKey(t);if(n)throw n;const r=e&&null!=e.sublevel?e.sublevel:this.db,o=e,s=r.keyEncoding(e&&e.keyEncoding),a=s.format;return e={...e,keyEncoding:a},r!==this.db&&(e.sublevel=null),this._del(r.prefixKey(s.encode(t),a),e),this[c].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if("open"!==this[h])throw new i("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[c]=[],this}_clear(){}write(t,e){return e=o(t,e),e=r(e,a),t=s(t),"open"!==this[h]?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[h]="writing",this._write(t,(t=>{this[h]="closing",this[u].push((()=>e(t))),t||this.db.emit("batch",this[c]),this._close(this[l])}))),e[a]}_write(t,e){}close(t){return t=r(t,a),"closing"===this[h]?this[u].push(t):"closed"===this[h]?this.nextTick(t):(this[u].push(t),"writing"!==this[h]&&(this[h]="closing",this._close(this[l]))),t[a]}_close(t){this.nextTick(t)}[l](){this[h]="closed",this.db.detachResource(this);const t=this[u];this[u]=[];for(const e of t)e()}}},3961:(t,e,n)=>{const{fromCallback:r}=n(6957),i=n(4473),{getOptions:o,getCallback:s}=n(2520),a=Symbol("promise"),h=Symbol("callback"),c=Symbol("working"),l=Symbol("handleOne"),u=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){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[b]=!1,this[E]=[],this[c]=!1,this[y]=!1,this[f]=!1,this[h]=null,this[l]=this[l].bind(this),this[u]=this[u].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,r,i)=>{t?n(t):this[_]?void 0===r&&void 0===i?e():e([r,i]):e(r)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new i("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(t,new i("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=t,this[O]>=this[L]?this.nextTick(this[l],null):this._next(this[l])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=s(e,n),n=r(n,a),e=o(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new i("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(n,new i("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[c]=!0,this[h]=n,t<=0?this.nextTick(this[u],null,[]):this._nextv(t,e,this[u])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const r=[],i=(e,o,s)=>e?n(e):(this[_]?void 0===o&&void 0===s:void 0===o)?n(null,r):(r.push(this[_]?[o,s]:o),void(r.length===t?n(null,r):this._next(i)));this._next(i)}all(t,e){return e=s(t,e),e=r(e,a),t=o(t,A),this[y]?this.nextTick(e,new i("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(e,new i("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[u],null,[]):this._all(t,this[u])),e[a]}_all(t,e){let n=this[O];const r=[],i=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,r):this._nextv(t,A,o)},o=(t,o)=>{t?e(t):0===o.length?e(null,r):(r.push.apply(r,o),n+=o.length,i())};i()}[d](){const t=this[h];return this[w]&&null===t?k:(this[c]=!1,this[h]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=o(e,A),this[y]);else{if(this[c])throw new i("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),r=n.format;e.keyEncoding!==r&&(e={...e,keyEncoding:r});const i=this.db.prefixKey(n.encode(t),r);this._seek(i,e)}}}_seek(t,e){throw new i("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=r(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[c]?this[w]&&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[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[l](t,e,n){const r=this[d]();if(t)return r(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return r(new C("entry",t))}void 0===e&&void 0===n||this[O]++,r(null,e,n)}[u](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!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 C 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(I.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"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[l](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[u](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t{const{supports:r}=n(3658),{Transcoder:i}=n(8499),{EventEmitter:o}=n(7187),{fromCallback:s}=n(6957),a=n(4473),{AbstractIterator:h}=n(3961),{DefaultKeyIterator:c,DefaultValueIterator:l}=n(5429),{DeferredIterator:u,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C 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:n,valueEncoding:o,passive:s,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=r(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[k]=new i(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(o||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=s(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=s(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const r=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(r);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),h=i.format,c=o.format;return e.keyEncoding===h&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:h,valueEncoding:c})),this._get(this.prefixKey(i.encode(t),h),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)),n(t);try{e=o.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const r=this.keyEncoding(e.keyEncoding),i=this.valueEncoding(e.valueEncoding),o=r.format,h=i.format;e.keyEncoding===o&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:o,valueEncoding:h}));const c=new Array(t.length);for(let e=0;e{if(t)return n(t);try{for(let t=0;tthis.put(t,e,n,r))),r[E];if(D(this,r))return r[E];const i=this._checkKey(t)||this._checkValue(e);if(i)return this.nextTick(r,i),r[E];const o=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),h=o.format,c=a.format;n.keyEncoding===h&&n.valueEncoding===c||(n=Object.assign({},n,{keyEncoding:h,valueEncoding:c}));const l=this.prefixKey(o.encode(t),h),u=a.encode(e);return this._put(l,u,n,(n=>{if(n)return r(n);this.emit("put",t,e),r()})),r[E]}_put(t,e,n,r){this.nextTick(r)}del(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];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 n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=s(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const r=new Array(t.length),{keyEncoding:i,valueEncoding:o,...h}=e;for(let e=0;e{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=s(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,r=this.keyEncoding(t.keyEncoding);return(t=b(t,r)).keyEncoding=r.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new u(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new h(this,t)}keys(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new c(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new l(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];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 p(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"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:o}=n(3961),s=Symbol("unfix"),a=Symbol("iterator"),h=Symbol("handleOne"),c=Symbol("handleMany"),l=Symbol("callback");class u extends r{constructor(t,e,n,r){super(t,e),this[a]=n,this[s]=r,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[l]=null}[h](t,e,n){const r=this[l];if(t)return r(t);void 0!==e&&(e=this[s](e)),r(t,e,n)}[c](t,e){const n=this[l];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[s](e))}n(t,e)}}class f extends i{constructor(t,e,n,r){super(t,e),this[a]=n,this[s]=r,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[l]=null}[h](t,e){const n=this[l];if(t)return n(t);void 0!==e&&(e=this[s](e)),n(t,e)}[c](t,e){const n=this[l];if(t)return n(t);for(let t=0;t{const r=n(4473),{Buffer:i}=n(8764)||{},{AbstractSublevelIterator:o,AbstractSublevelKeyIterator:s,AbstractSublevelValueIterator:a}=n(2970),h=Symbol("prefix"),c=Symbol("upperBound"),l=Symbol("prefixRange"),u=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new r("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new r("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,i){const{separator:o,manifest:s,...a}=e.defaults(i);n=m(n,o);const l=o.charCodeAt(0)+1,p=t[u]||t;if(!d.encode(n).every((t=>t>l&&t<127)))throw new r(`Prefix must use bytes > ${l} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,s),a);const g=(t.prefix||"")+o+n+o,v=g.slice(0,-1)+String.fromCharCode(l);this[u]=p,this[h]=new b(g),this[c]=new b(v),this[f]=new E,this.nextTick=p.nextTick}prefixKey(t,e){if("utf8"===e)return this[h].utf8+t;if(0===t.byteLength)return this[h][e];if("view"===e){const e=this[h].view,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[h].buffer;return i.concat([e,t],e.byteLength+t.byteLength)}}[l](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[h][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[c][e]}get prefix(){return this[h].utf8}get db(){return this[u]}_open(t,e){this[u].open({passive:!0},e)}_put(t,e,n,r){this[u].put(t,e,n,r)}_get(t,e,n){this[u].get(t,e,n)}_getMany(t,e,n){this[u].getMany(t,e,n)}_del(t,e,n){this[u].del(t,e,n)}_batch(t,e,n){this[u].batch(t,e,n)}_clear(t,e){this[l](t,t.keyEncoding),this[u].clear(t,e)}_iterator(t){this[l](t,t.keyEncoding);const e=this[u].iterator(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_keys(t){this[l](t,t.keyEncoding);const e=this[u].keys(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_values(t){this[l](t,t.keyEncoding);const e=this[u].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=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 b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=i?i.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="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,n)),n}}const m=function(t,e){let n=0,r=t.length;for(;nn&&t[r-1]===e;)r--;return t.slice(n,r)}},2520:(t,e)=>{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:{}}},4765:(t,e,n)=>{const{AbstractChainedBatch:r}=n(9464),i=n(4473),o=Symbol("encoded");e.DefaultChainedBatch=class extends r{constructor(t){super(t),this[o]=[]}_put(t,e,n){this[o].push({...n,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"}))}}},5429:(t,e,n)=>{const{AbstractKeyIterator:r,AbstractValueIterator:i}=n(3961),o=Symbol("iterator"),s=Symbol("callback"),a=Symbol("handleOne"),h=Symbol("handleMany");class c extends r{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}class l extends i{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}for(const t of[c,l]){const e=t===c,n=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,n,r){const i=this[s];t?i(t):i(null,e?n:r)},t.prototype._nextv=function(t,e,n){this[s]=n,this[o].nextv(t,e,this[h])},t.prototype._all=function(t,e){this[s]=e,this[o].all(t,this[h])},t.prototype[h]=function(t,e){const r=this[s];t?r(t):r(null,e.map(n))},t.prototype._seek=function(t,e){this[o].seek(t,e)},t.prototype._close=function(t){this[o].close(t)}}e.DefaultKeyIterator=c,e.DefaultValueIterator=l},593:(t,e,n)=>{const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:o}=n(3961),s=n(4473),a=Symbol("nut"),h=Symbol("undefer"),c=Symbol("factory");class l extends r{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.iterator(e),this.db.defer((()=>this[h]()))}}class u extends i{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.keys(e),this.db.defer((()=>this[h]()))}}class f extends o{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.values(e),this.db.defer((()=>this[h]()))}}for(const t of[l,u,f])t.prototype[h]=function(){"open"===this.db.status&&(this[a]=this[c]())},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,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,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=l,e.DeferredKeyIterator=u,e.DeferredValueIterator=f},6909:(t,e,n)=>{const r=n(4375);t.exports=function(t,...e){0===e.length?r(t):r((()=>t(...e)))}},56:(t,e,n)=>{const r=n(4473),i=Object.prototype.hasOwnProperty,o=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const s in t)if(i.call(t,s)&&"keyEncoding"!==s&&"valueEncoding"!==s){if("start"===s||"end"===s)throw new r(`The legacy range option '${s}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===s)throw new r("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});o.has(s)?n[s]=e.encode(t[s]):n[s]=t[s]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{e.byteLength=function(t){var e=a(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,o=a(t),s=o[0],h=o[1],c=new i(function(t,e,n){return 3*(e+n)/4-n}(0,s,h)),l=0,u=h>0?s-4:s;for(n=0;n>16&255,c[l++]=e>>8&255,c[l++]=255&e;return 2===h&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,c[l++]=255&e),1===h&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e),c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],s=16383,a=0,c=r-i;ac?c:a+s));return 1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],r[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 n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function h(t,e,r){for(var i,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},1708:(t,e,n)=>{const{AbstractLevel:r}=n(875),i=n(4473),o=n(9967),{fromCallback:s}=n(6957),{Iterator:a}=n(8212),h=n(9687),c=n(9968),l=n(1217),u="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends r{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new i("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:r,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[p]=t,this[d]=null==r?u:r,this[y]=parseInt(o||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const r=this[g]("readonly");let o;try{o=r.get(t)}catch(t){return this.nextTick(n,t)}this[b](o,(function(t,e){return t?n(t):void 0===e?n(new i("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,h(e))}))}_getMany(t,e,n){const r=this[g]("readonly"),i=t.map((t=>e=>{let n;try{n=r.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:h(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));o(i,16,n)}_del(t,e,n){const r=this[g]("readwrite");let i;try{i=r.delete(t)}catch(t){return this.nextTick(n,t)}this[b](i,n)}_put(t,e,n,r){const i=this[g]("readwrite");let o;try{o=i.put(e,t)}catch(t){return this.nextTick(r,t)}this[b](o,r)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const r=this[g]("readwrite"),i=r.transaction;let o,s=0;i.onabort=function(){n(o||i.error||new Error("aborted by user"))},i.oncomplete=function(){n()},function e(){const n=t[s++],a=n.key;let h;try{h="del"===n.type?r.delete(a):r.put(n.value,a)}catch(t){return o=t,void i.abort()}s=0)return c(this,this[p],n,t,e);try{const t=this[g]("readwrite");r=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](r,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=u),n=s(n,E);const r=indexedDB.deleteDatabase(e+t);return r.onsuccess=function(){n()},r.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{const{AbstractIterator:r}=n(875),i=n(1217),o=n(9687),s=Symbol("cache"),a=Symbol("finished"),h=Symbol("options"),c=Symbol("currentOptions"),l=Symbol("position"),u=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends r{constructor(t,e,n){super(t,n),this[s]=[],this[a]=0===this.limit,this[h]=n,this[c]={...n},this[l]=void 0,this[u]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[s].length>0)return t=Math.min(t,this[s].length),this.nextTick(n,null,this[s].splice(0,t));let r;void 0!==this[l]&&(this[h].reverse?(this[c].lt=this[l],this[c].lte=void 0):(this[c].gt=this[l],this[c].gte=void 0));try{r=i(this[c])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[u]],"readonly"),y=d.objectStore(this[u]),g=[];if(this[h].reverse)y[!this[h].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](r,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:r}=n;this[l]=e,g.push([this[h].keys&&void 0!==e?o(e):void 0,this[h].values&&void 0!==r?o(r):void 0]),g.length{if(void 0===e||void 0===n)return;const r=Math.max(e.length,n.length);0===r||t===1/0?this[a]=!0:this[l]=e[r-1],g.length=r;for(let t=0;t{e=t.target.result,i()}:(e=[],this.nextTick(i)),this[h].values?y.getAll(r,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,i()}:(n=[],this.nextTick(i))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[s].length>0){const[e,n]=this[s].shift();this.nextTick(t,null,e,n)}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,n)=>{if(e)return t(e);this[s]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[s].splice(0,this[s].length),r=this.limit-this.count-n.length;if(r<=0)return this.nextTick(e,null,n);this._nextv(r,d,((t,r)=>{if(t)return e(t);n.length>0&&(r=n.concat(r)),e(null,r)}))}_seek(t,e){let n;this[f]=!0,this[s]=[],this[a]=!1,this[l]=void 0,this[c]={...this[h]};try{n=i(this[h])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[h].reverse?this[c].lte=t:this[c].gte=t:this[a]=!0}}},9968:t=>{t.exports=function(t,e,n,r,i){if(0===r.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 h=s.openKeyCursor?"openKeyCursor":"openCursor",c=r.reverse?"prev":"next";s[h](n,c).onsuccess=function(t){const e=t.target.result;e&&(s.delete(e.key).onsuccess=function(){(r.limit<=0||++a{const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,r=void 0===t.gte,i=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,r,i):void 0!==e?IDBKeyRange.lowerBound(e,r):void 0!==n?IDBKeyRange.upperBound(n,i):null}},8764:(t,e,n)=>{const r=n(9742),i=n(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.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,h.prototype),e}function h(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let r=a(n);const i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return h.from(r,e,n);const i=function(t){if(h.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(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 h.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(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 u(t){return l(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(i)return r?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function E(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=h.from(e,r)),h.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){let o,s=1,a=t.length,h=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;s=2,a/=2,h/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let r=-1;for(o=n;oa&&(n=a-h),o=n;o>=0;o--){let n=!0;for(let r=0;ri&&(r=i):r=i;const o=e.length;let s;for(r>o/2&&(r=o/2),s=0;s>8,i=n%256,o.push(i),o.push(r);return o}(e,t.length-n),t,n,r)}function L(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+s<=n){let n,r,a,h;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[i+1],128==(192&n)&&(h=(31&e)<<6|63&n,h>127&&(o=h));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(h=(15&e)<<12|(63&n)<<6|63&r,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(h=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,h>65535&&h<1114112&&(o=h))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),i+=s}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",r=0;for(;rr.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},h.byteLength=y,h.prototype._isBuffer=!0,h.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;en&&(t+=" ... "),""},o&&(h.prototype[o]=h.prototype.inspect),h.prototype.compare=function(t,e,n,r,i){if(Y(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.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===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(o,s),c=this.slice(r,i),l=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let o=!1;for(;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;ir)&&(n=r);let i="";for(let r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,i,o){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function D(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function U(t,e,n,r,i){z(e,r,i,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function P(t,e,n,r,i,o){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,r,o){return e=+e,n>>>=0,o||P(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,o){return e=+e,n>>>=0,o||P(t,0,n,8),i.write(t,e,n,r,52,8),n+8}h.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,o=0;for(;++o>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,o=0;for(;++o=i&&(r-=Math.pow(2,8*e)),r},h.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=e,i=1,o=this[t+--r];for(;r>0&&(i*=256);)o+=this[t+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},h.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||N(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,o=0;for(this[e]=255&t;++o>>=0,n>>>=0,r||N(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+n},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let i=0,o=1,s=0;for(this[e]=255&t;++i>0)-s&255;return e+n},h.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let i=n-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o>>0)-s&255;return e+n},h.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},h.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},h.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},h.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},h.prototype.copy=function(t,e,n,r){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,o){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(r,i,o)}function G(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=V(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=V(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const r=t.length;let i=null;const o=[];for(let s=0;s55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(e-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function $(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6957:(t,e,n)=>{var r=n(886);e.fromCallback=function(t,e){if(void 0===t){var n=new Promise((function(e,n){t=function(t,r){t?n(t):e(r)}}));t[void 0!==e?e:"promise"]=n}else if("function"!=typeof t)throw new TypeError("Callback must be a function");return t},e.fromPromise=function(t,e){if(void 0===e)return t;t.then((function(t){r((()=>e(null,t)))})).catch((function(t){r((()=>e(t)))}))}},886:t=>{t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t)},8840:(t,e)=>{function n(t){for(var e="",n=0;n0?"F"+s:"D"+n(s)},e.decode=function(t){if("DaN"===t)return NaN;if("FF"===t)return 1/0;if("DD"===t)return-1/0;var e="D"===t[0],r=(e?n(t):t).slice(2).split("M");return Number((e?"-":"")+r[1]+"e"+String(Number(r[0])-500))}},2833:(t,e)=>{var n={"?":"?@","!":"??",'"':"?%"},r={"?@":"?","??":"!","?%":'"'};e.factory=function(t){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,i=e.split('"'),o=[[]],s=0,a=i.length,h=0;h{var r=n(8840),i=n(2833);e.flip=function(t){var e=t.toString(),n="";for(var r in e)n+="."==e[r]?".":9-+e[r];return n},e.number=r,e.string={encode:function(t){return/\x00|\x01/.test(t)?"J"+t.replace(/\x01/g,"").replace(/\x00/g,""):"J"+t},decode:function(t){if("J"===t[0])return t.substring(1)}},e.encode=function(t){return e[typeof t].encode(t)},e.decode=function(t){if(""===t)return t;if(!o[t[0]])throw new Error("no decoder for:"+JSON.stringify(t));return o[t[0]](t)},e.object=i.factory(e),e.boolean={encode:function(t){return t?"C":"B"},decode:function(t){return"C"===t}},e.undefined={encode:function(t){return"L"},decode:function(){}};var o={A:e.object.decode,B:e.boolean.decode,C:e.boolean.decode,D:e.number.decode,F:e.number.decode,J:e.string.decode,K:e.object.decode,L:e.undefined.decode};e.buffer=!1,e.type="charwise"},6729:t=>{var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||t,s),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i{var e,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(n,r){function i(n){t.removeListener(e,o),r(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,n,r){var i,o,s,c;if(a(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]),void 0===s)s=o[e]=n,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),(i=h(t))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,c=l,console&&console.warn&&console.warn(c)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=l.bind(r);return i.listener=n,r.wrapFn=i,i}function f(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var h=o[t];if(void 0===h)return!1;if("function"==typeof h)r(h,this,e);else{var c=h.length,l=p(h,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,i=o;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return f(this,t,!0)},o.prototype.rawListeners=function(t){return f(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9203:(t,e,n)=>{const r=n(7270),{BrowserLevel:i}=n(1708);t.exports=({name:t="fii",...e})=>r({db:new i(t),...e})},7270:(t,e,n)=>{const r=n(9563),i=n(8936),o=n(1387),s=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELDe.FIELD?1:t.VALUEe.VALUE?1:t.SCOREe.SCORE?1:0)),t))),a=t=>{const e=r(t),n=i(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(s),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(s),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:o,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(s),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(s),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const r=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;r.open((i=>i?n(i):e(Object.assign(t,{_db:r}))))})))(t).then(a)},1387:(t,e,n)=>{const r=n(2483);t.exports={keyEncoding:r,valueEncoding:"json"}},6782:t=>{const e=null,n=void 0;t.exports=(t,r)=>new Promise(((i,o)=>{if(Array.isArray(t))return o(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return i({FIELD:r,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return i({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?i(Object.assign(t,{FIELD:r})):(t.FIELD=[t.FIELD].flat(),i(t))}))},9563:(t,e,n)=>{const r=n(6782),i=n(2483),{EntryStream:o}=n(6741),s=n(1387);i.LO=null,i.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>r(t,await u()),a=async(e,r=(t=>new Promise((e=>e(t)))))=>new Promise((async(i,o)=>{const s=t=>void 0===t?i(void 0):t instanceof Promise?i(t):void 0;try{s(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),s(e=await(e=>void 0===e?l(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?h(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),s(e=await r(e))}catch(t){return o(t)}return Array.isArray(e)?i(e):i(l(e))})),h=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),c=(t,e,n)=>{const r=[];return void 0===e&&"number"!=typeof e||r.push(e),n&&r.push(i.HI),["IDX",t,r]},l=e=>new Promise((n=>{if(void 0===e)return n(void 0);const r=new Map;return Promise.all(e.FIELD.map((n=>new Promise((i=>new o(t._db,{gte:c(n,e.VALUE.GTE),lte:c(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...s}).on("data",(t=>t.value.forEach((e=>r.set(e,[...r.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",i)))))).then((()=>n(Array.from(r.keys()).map((t=>({_id:t,_match:r.get(t)}))))))})),u=()=>new Promise((e=>{const n=[];new o(t._db,{gte:["FIELD",i.LO],lte:["FIELD",i.HI],...s}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,r)=>{const i=[];new o(t._db,{...e,...s}).on("data",(t=>{i.push(t)})).on("end",(()=>n(i)))})),y=(t,e)=>n(t).then((t=>l(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let r=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(r+=" "),p({gte:c(e,r),lte:c(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:c(e,t.VALUE.GTE),lte:c(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],s),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],s).catch((t=>null))))).then((t=>t.reduce(((t,n,r)=>(null!=n&&t.push(e[r]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:u,GET:a,INTERSECTION:(t,e)=>h(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],s),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],s).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:h,parseToken:n}}},8936:(t,e,n)=>{const r=n(3692),i=n(9563),o=n(1387);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const i=[];return r(e._object).forEach((function(e){const r=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==r&&!n.doNotIndexField.filter((t=>r.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([r,[this.node].flat(1/0)]);i.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:i}},s=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(r,a,h,c,l)=>new Promise((u=>{r=r.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),l=Object.assign(t,l),i(t).EXIST(...r.map((t=>t._id))).then((t=>((t,e,n)=>{const r=Object.keys(t);return Promise.all(r.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,r)=>e.get(t,o).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,i)=>{const o=new Set(e),s=new Set(t[r[i]]);if("put"===n)return{key:["IDX",...JSON.parse(r[i])],type:n,value:[...new Set([...o,...s])].sort()};if("del"===n){const t=[...new Set([...o].filter((t=>!s.has(t))))];return{key:["IDX",...JSON.parse(r[i])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(s,{}))(r,l),a,h).then((e=>a.batch(e.concat(l.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(r,h):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),o,(e=>u(r.map((e=>{let n;return"put"===h?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===h&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:c,status:n}})))))))))})),h=e=>t._db.put(["~LAST_UPDATED"],Date.now(),o).then((()=>e));return{DELETE:e=>i(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(h),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),o))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(h),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],o).then().catch((e=>t._db.put(["~CREATED"],Date.now(),o).then(h))),TIMESTAMP_LAST_UPDATED:h}}},645:(t,e)=>{e.read=function(t,e,n,r,i){var o,s,a=8*i-r-1,h=(1<>1,l=-7,u=n?i-1:0,f=n?-1:1,d=t[e+u];for(u+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+u],u+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=r;l>0;s=256*s+t[e+u],u+=f,l-=8);if(0===o)o=1-c;else{if(o===h)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},e.write=function(t,e,n,r,i,o){var s,a,h,c=8*o-i-1,l=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-s))<1&&(s--,h*=2),(e+=s+u>=1?f/h:f*Math.pow(2,1-u))*h>=2&&(s++,h/=2),s+u>=l?(a=0,s=l):s+u>=1?(a=(e*h-1)*Math.pow(2,i),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;t[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<0;t[n+d]=255&s,d+=p,s/=256,c-=8);t[n+d-p]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},6741:(t,e,n)=>{const{Readable:r}=n(8473),i=Symbol("iterator"),o=Symbol("nextv");class s extends r{constructor(t,e,n){const{highWaterMark:r,...s}=n||{};super({objectMode:!0,highWaterMark:r||1e3}),this[i]=t[e](s),this[o]=this[o].bind(this),this.once("end",this.destroy.bind(this,null,null))}get db(){return this[i].db}_read(t){this.destroyed||this[i].nextv(t,this[o])}[o](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const t of e)this.push(t)}}_destroy(t,e){this[i].close((function(n){e(t||n)}))}}e.EntryStream=class extends s{constructor(t,e){super(t,"iterator",{...e,keys:!0,values:!0})}[o](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const[t,n]of e)this.push({key:t,value:n})}}},e.KeyStream=class extends s{constructor(t,e){super(t,"keys",e)}},e.ValueStream=class extends s{constructor(t,e){super(t,"values",e)}}},8499:(t,e,n)=>{const r=n(4473),i=n(8002),{Encoding:o}=n(8266),{BufferFormat:s,ViewFormat:a,UTF8Format:h}=n(2376),c=Symbol("formats"),l=Symbol("encodings"),u=new Set(["buffer","view","utf8"]);e.Transcoder=class{constructor(t){if(!Array.isArray(t))throw new TypeError("The first argument 'formats' must be an array");if(!t.every((t=>u.has(t))))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[l]=new Map,this[c]=new Set(t);for(const t in i)try{this.encoding(t)}catch(t){if("LEVEL_ENCODING_NOT_SUPPORTED"!==t.code)throw t}}encodings(){return Array.from(new Set(this[l].values()))}encoding(t){let e=this[l].get(t);if(void 0===e){if("string"==typeof t&&""!==t){if(e=d[t],!e)throw new r(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if("object"!=typeof t||null===t)throw new TypeError("First argument 'encoding' must be a string or object");e=function(t){if(t instanceof o)return t;const e="type"in t&&"string"==typeof t.type?t.type:void 0,n=t.name||e||"anonymous-"+p++;switch(function(t){return"format"in t&&void 0!==t.format?t.format:"buffer"in t&&"boolean"==typeof t.buffer?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}(t)){case"view":return new a({...t,name:n});case"utf8":return new h({...t,name:n});case"buffer":return new s({...t,name:n});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}(t)}const{name:n,format:i}=e;if(!this[c].has(i))if(this[c].has("view"))e=e.createViewTranscoder();else if(this[c].has("buffer"))e=e.createBufferTranscoder();else{if(!this[c].has("utf8"))throw new r(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});e=e.createUTF8Transcoder()}for(const r of[t,n,e.name,e.commonName])this[l].set(r,e)}return e}};const f={binary:i.buffer,"utf-8":i.utf8},d={...i,...f};let p=0},8266:(t,e,n)=>{const r=n(4473),i=new Set(["buffer","view","utf8"]);e.Encoding=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,"function"!=typeof this.encode)throw new TypeError("The 'encode' property must be a function");if("function"!=typeof this.decode)throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),"string"!=typeof this.name||""===this.name)throw new TypeError("The 'name' property must be a string");if("string"!=typeof this.format||!i.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}},8002:(t,e,n)=>{const{Buffer:r}=n(8764)||{Buffer:{isBuffer:()=>!1}},{textEncoder:i,textDecoder:o}=n(4005)(),{BufferFormat:s,ViewFormat:a,UTF8Format:h}=n(2376),c=t=>t;e.utf8=new h({encode:function(t){return r.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?o.decode(t):String(t)},decode:c,name:"utf8",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.encode(t)},decode:function(t){return o.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new s({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}}),e.json=new h({encode:JSON.stringify,decode:JSON.parse,name:"json"}),e.buffer=new s({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:c,name:"buffer",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.from(String(t),"utf8")},decode:function(t){return r.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}}),e.view=new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.encode(t)},decode:c,name:"view",createBufferTranscoder(){return new s({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:c,name:`${this.name}+buffer`})}}),e.hex=new s({encode:function(t){return r.isBuffer(t)?t:r.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"}),e.base64=new s({encode:function(t){return r.isBuffer(t)?t:r.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})},2376:(t,e,n)=>{const{Buffer:r}=n(8764)||{},{Encoding:i}=n(8266),o=n(4005);class s extends i{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:t=>this.decode(r.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class a extends i{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new s({encode:t=>{const e=this.encode(t);return r.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}e.BufferFormat=s,e.ViewFormat=a,e.UTF8Format=class extends i{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new s({encode:t=>r.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){const{textEncoder:t,textDecoder:e}=o();return new a({encode:e=>t.encode(this.encode(e)),decode:t=>this.decode(e.decode(t)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}},4005:t=>{let e=null;t.exports=function(){return null===e&&(e={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),e}},4473:t=>{t.exports=class extends Error{constructor(t,e){super(t||""),"object"==typeof e&&null!==e&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}},6349:function(t,e){!function(t){const e=function(t,e){return t.slice(e-1).map(((n,r)=>t.slice(r,r+e)))};t.ngraminator=function(t,n){return n.reduce(((n,r)=>[...e(t,r),...n]),[]).sort()},Object.defineProperty(t,"__esModule",{value:!0})}(e)},4155:t=>{var e,n,r=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var a,h=[],c=!1,l=-1;function u(){c&&a&&(c=!1,a.length?h=a.concat(h):l=-1,h.length&&f())}function f(){if(!c){var t=s(u);c=!0;for(var e=h.length;e;){for(a=h,h=[];++l1)for(var n=1;n{let r;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:n.g):t=>(r||(r=Promise.resolve())).then(t).catch((t=>setTimeout((()=>{throw t}),0)))},4281:t=>{var e={};function n(t,n,r){r||(r=Error);var i=function(t){var e,r;function i(e,r,i){return t.call(this,function(t,e,r){return"string"==typeof n?n:n(t,e,r)}(e,r,i))||this}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,i}(r);i.prototype.name=r.name,i.prototype.code=t,e[t]=i}function r(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(t){return String(t)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:2===n?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}n("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(t,e,n){var i,o,s,a,h;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,n){return(void 0===n||n>t.length)&&(n=t.length),t.substring(n-9,n)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(r(e,"type"));else{var c=("number"!=typeof h&&(h=0),h+1>(a=t).length||-1===a.indexOf(".",h)?"argument":"property");s='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(r(e,"type"))}return s+". Received type ".concat(typeof n)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},6753:(t,e,n)=>{var r=n(4155),i=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=l;var o=n(9481),s=n(4229);n(5717)(l,o);for(var a=i(s.prototype),h=0;h{t.exports=i;var r=n(4605);function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}n(5717)(i,r),i.prototype._transform=function(t,e,n){n(null,t)}},9481:(t,e,n)=>{var r,i=n(4155);t.exports=L,L.ReadableState=S,n(7187).EventEmitter;var o,s=function(t,e){return t.listeners(e).length},a=n(2503),h=n(8764).Buffer,c=n.g.Uint8Array||function(){},l=n(4616);o=l&&l.debuglog?l.debuglog("stream"):function(){};var u,f,d,p=n(7327),y=n(1195),g=n(2457).getHighWaterMark,b=n(4281).q,E=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(5717)(L,a);var _=y.errorOrDestroy,T=["error","close","destroy","pause","resume"];function S(t,e,i){r=r||n(6753),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=n(2553).s),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function L(t){if(r=r||n(6753),!(this instanceof L))return new L(t);var e=this instanceof r;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function O(t,e,n,r,i){o("readableAddChunk",e);var s,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?R(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,a);else if(i||(s=function(t,e){var n,r;return r=e,h.isBuffer(r)||r instanceof c||"string"==typeof e||void 0===e||t.objectMode||(n=new E("chunk",["string","Buffer","Uint8Array"],e)),n}(a,e)),s)_(t,s);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===h.prototype||(e=function(t){return h.from(t)}(e)),r)a.endEmitted?_(t,new w):A(t,a,e,!0);else if(a.ended)_(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(e=a.decoder.write(e),a.objectMode||0!==e.length?A(t,a,e,!1):C(t,a)):A(t,a,e,!1)}else r||(a.reading=!1,C(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=k?t=k:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function R(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(I,t))}function I(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function U(t){o("readable nexttick read 0"),t.read(0)}function P(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function B(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function j(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(F,e,t))}function F(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function V(t,e){for(var n=0,r=t.length;n=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?j(this):R(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&j(this),null;var r,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&j(this)),null!==r&&this.emit("data",r),r},L.prototype._read=function(t){_(this,new v("_read()"))},L.prototype.pipe=function(t,e){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=t;break;case 1:r.pipes=[r.pipes,t];break;default:r.pipes.push(t)}r.pipesCount+=1,o("pipe count=%d opts=%j",r.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:h;function h(){o("onend"),t.end()}r.endEmitted?i.nextTick(a):n.once("end",a),t.on("unpipe",(function e(i,s){o("onunpipe"),i===n&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,o("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",c),t.removeListener("error",f),t.removeListener("unpipe",e),n.removeListener("end",h),n.removeListener("end",y),n.removeListener("data",u),l=!0,!r.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",c);var l=!1;function u(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===t||r.pipesCount>1&&-1!==V(r.pipes,t))&&!l&&(o("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function f(e){o("onerror",e),y(),t.removeListener("error",f),0===s(t,"error")&&_(t,e)}function d(){t.removeListener("finish",p),y()}function p(){o("onfinish"),t.removeListener("close",d),y()}function y(){o("unpipe"),n.unpipe(t)}return n.on("data",u),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),r.flowing||(o("pipe resume"),n.resume()),t},L.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==r.flowing&&this.resume()):"readable"===t&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,o("on readable",r.length,r.reading),r.length?R(this):r.reading||i.nextTick(U,this))),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(t,e){var n=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(D,this),n},L.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(D,this),e},L.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(P,t,e))}(this,t)),t.paused=!1,this},L.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},L.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var s=0;s{t.exports=l;var r=n(4281).q,i=r.ERR_METHOD_NOT_IMPLEMENTED,o=r.ERR_MULTIPLE_CALLBACK,s=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,h=n(6753);function c(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new o);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{var r,i=n(4155);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=L,L.WritableState=S;var s,a={deprecate:n(4927)},h=n(2503),c=n(8764).Buffer,l=n.g.Uint8Array||function(){},u=n(1195),f=n(2457).getHighWaterMark,d=n(4281).q,p=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,E=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,_=u.errorOrDestroy;function T(){}function S(t,e,s){r=r||n(6753),t=t||{},"boolean"!=typeof s&&(s=e instanceof r),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=f(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,o=n.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,o){--e.pendingcb,n?(i.nextTick(o,r),i.nextTick(I,t,e),t._writableState.errorEmitted=!0,_(t,r)):(o(r),t._writableState.errorEmitted=!0,_(t,r),I(t,e))}(t,n,r,e,o);else{var s=x(n)||t.destroyed;s||n.corked||n.bufferProcessing||!n.bufferedRequest||k(t,n),r?i.nextTick(A,t,n,s,o):A(t,n,s,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function L(t){var e=this instanceof(r=r||n(6753));if(!e&&!s.call(L,this))return new L(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function O(t,e,n,r,i,o,s){e.writelen=r,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new E("write")):n?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function A(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),I(t,e)}function k(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),s=e.corkedRequestsFree;s.entry=n;for(var a=0,h=!0;n;)i[a]=n,n.isBuf||(h=!1),n=n.next,a+=1;i.allBuffers=h,O(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,u=n.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,l,u),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(n){e.pendingcb--,n&&_(t,n),e.prefinished=!0,t.emit("prefinish"),I(t,e)}))}function I(t,e){var n=x(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var r=t._readableState;(!r||r.autoDestroy&&r.endEmitted)&&t.destroy()}return n}n(5717)(L,h),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===L&&t&&t._writableState instanceof S}})):s=function(t){return t instanceof this},L.prototype.pipe=function(){_(this,new b)},L.prototype.write=function(t,e,n){var r,o=this._writableState,s=!1,a=!o.objectMode&&(r=t,c.isBuffer(r)||r instanceof l);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof n&&(n=T),o.ending?function(t,e){var n=new v;_(t,n),i.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var o;return null===n?o=new m:"string"==typeof n||e.objectMode||(o=new p("chunk",["string","Buffer"],n)),!o||(_(t,o),i.nextTick(r,o),!1)}(this,o,t,n))&&(o.pendingcb++,s=function(t,e,n,r,i,o){if(!n){var s=function(t,e,n){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,n)),e}(e,r,i);r!==s&&(n=!0,i="buffer",r=s)}var a=e.objectMode?1:r.length;e.length+=a;var h=e.length-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),L.prototype._write=function(t,e,n){n(new y("_write()"))},L.prototype._writev=null,L.prototype.end=function(t,e,n){var r=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||function(t,e,n){e.ending=!0,I(t,e),n&&(e.finished?i.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,r,n),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),L.prototype.destroy=u.destroy,L.prototype._undestroy=u.undestroy,L.prototype._destroy=function(t,e){e(t)}},5850:(t,e,n)=>{var r,i=n(4155);function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var s=n(8610),a=Symbol("lastResolve"),h=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function p(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var n=t[d].read();null!==n&&(t[u]=null,t[a]=null,t[h]=null,e(p(n,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),E=Object.setPrototypeOf((o(r={get stream(){return this[d]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[l])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise((function(e,n){i.nextTick((function(){t[c]?n(t[c]):e(p(void 0,!0))}))}));var n,r=this[u];if(r)n=new Promise(function(t,e){return function(n,r){t.then((function(){e[l]?n(p(void 0,!0)):e[f](n,r)}),r)}}(r,this));else{var o=this[d].read();if(null!==o)return Promise.resolve(p(o,!1));n=new Promise(this[f])}return this[u]=n,n}},Symbol.asyncIterator,(function(){return this})),o(r,"return",(function(){var t=this;return new Promise((function(e,n){t[d].destroy(null,(function(t){t?n(t):e(p(void 0,!0))}))}))})),r),b);t.exports=function(t){var e,n=Object.create(E,(o(e={},d,{value:t,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,h,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,l,{value:t._readableState.endEmitted,writable:!0}),o(e,f,{value:function(t,e){var r=n[d].read();r?(n[u]=null,n[a]=null,n[h]=null,t(p(r,!1))):(n[a]=t,n[h]=e)},writable:!0}),e));return n[u]=null,s(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[h];return null!==e&&(n[u]=null,n[a]=null,n[h]=null,e(t)),void(n[c]=t)}var r=n[a];null!==r&&(n[u]=null,n[a]=null,n[h]=null,r(p(void 0,!0))),n[l]=!0})),t.on("readable",g.bind(null,n)),n}},7327:(t,e,n)=>{function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){for(var n=0;n0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n}},{key:"concat",value:function(t){if(0===this.length)return s.alloc(0);for(var e,n,r,i=s.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,n=i,r=a,s.prototype.copy.call(e,n,r),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var n;return ti.length?i.length:t;if(o===i.length?r+=i:r+=i.slice(0,t),0==(t-=o)){o===i.length?(++n,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(t){var e=s.allocUnsafe(t),n=this.head,r=1;for(n.data.copy(e),t-=n.data.length;n=n.next;){var i=n.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(o));break}++r}return this.length-=r,e}},{key:h,value:function(t,e){return a(this,function(t){for(var e=1;e{var r=n(4155);function i(t,e){s(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(s,this,t)):r.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted?r.nextTick(o,n):(n._writableState.errorEmitted=!0,r.nextTick(i,n,t)):r.nextTick(i,n,t):e?(r.nextTick(o,n),e(t)):r.nextTick(o,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}},8610:(t,e,n)=>{var r=n(4281).q.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,n,o){if("function"==typeof n)return t(e,null,n);n||(n={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var n=arguments.length,r=new Array(n),i=0;i{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9946:(t,e,n)=>{var r,i=n(4281).q,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function h(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){l||(l=t),t&&f.forEach(h),o||(f.forEach(h),u(l))}))}));return e.reduce(c)}},2457:(t,e,n)=>{var r=n(4281).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var o=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new r(i?n:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},2503:(t,e,n)=>{t.exports=n(7187).EventEmitter},8473:(t,e,n)=>{(e=t.exports=n(9481)).Stream=e,e.Readable=e,e.Writable=n(4229),e.Duplex=n(6753),e.Transform=n(4605),e.PassThrough=n(2725),e.finished=n(8610),e.pipeline=n(9946)},9967:(t,e,n)=>{t.exports=function(t,e,n){if("number"!=typeof e)throw new Error("second argument must be a Number");let i,o,s,a,h,c,l=!0;function u(t){function e(){n&&n(t,i),n=null}l?r(e):e()}function f(e,n,r){if(i[e]=r,n&&(h=!0),0==--s||n)u(n);else if(!h&&c{var r=n(396).Buffer,i=r.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(r.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=u,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function l(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function u(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.s=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(i>0&&(t.lastNeed=i-1),i):--r=0?(i>0&&(t.lastNeed=i-2),i):--r=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},396:(t,e,n)=>{var r=n(8764),i=r.Buffer;function o(t,e){for(var n in t)e[n]=t[n]}function s(t,e,n){return i(t,e,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(o(r,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,n)},s.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=i(t);return void 0!==e?"string"==typeof n?r.fill(e,n):r.fill(e):r.fill(0),r},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}},971:t=>{t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const n=t.reduce(((t,n,r,i)=>(e.ngramLengths.forEach((e=>{var o=i.slice(r,r+e);o.length===e&&(n=JSON.stringify(o),t[n]=t[n]||[],t[n].push(r))})),t)),{});return Object.keys(n).map((t=>({term:JSON.parse(t),positions:n[t]}))).sort(((t,e)=>t.term[0]>e.term[0]))}},3692:t=>{function e(t){return Object.prototype.toString.call(t)}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function r(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n{function r(t){try{if(!n.g.localStorage)return!1}catch(t){return!1}var e=n.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}},1861:t=>{t.exports=t=>{const e=t=>"string"==typeof t||t instanceof String,n=(r,i)=>new Promise((async o=>{return null===r?o([null,"1.00"]):(s=r)&&0===Object.keys(s).length&&Object.getPrototypeOf(s)===Object.prototype?o([[],"1.00"]):Number.isInteger(r)?o([r,r]):e(r)?o(t.tokenizer(r,i,t)):(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(r)?o((a=r,new Promise((async e=>{const r={};for(const e in a)r[e]=await n(a[e],e,t);return e(r)})))):(t=>Array.isArray(t))(r)?o((h=r,Promise.all(h.map(n)))):o(r);var s,a,h})),r=async r=>new Promise((async i=>{e(r)&&(r={body:r}),Object.prototype.hasOwnProperty.call(r,"_id")||(r._id=t.idGenerator.next().value);const o={};for(const t in r)o[t]="_id"!==t?await n(r[t],t):r[t];return i(o)}));return{processDocuments:t=>Promise.all(t.map(r))}}},2225:(t,e,n)=>{const r=n(9203),i=n(7155),{LRUCache:o}=n(4456),s=n(6291),a=n(6761),h=n(4147),c=t=>new Promise((async e=>{const r=new o({max:1e3}),h=new((await Promise.resolve().then(n.bind(n,5613))).default)({concurrency:1}),c=a(t,r,h),l=s(t,r);return c._INCREMENT_DOC_COUNT(0).then((()=>e({_AND:t.fii.AND,_BUCKET:t.fii.BUCKET,_GET:t.fii.GET,_NOT:t.fii.NOT,_OR:t.fii.OR,_CACHE:r,_PAGE:l.PAGE,_SCORE:l.SCORE,_SEARCH:l.SEARCH,_SORT:l.SORT,DELETE:c.DELETE,FLUSH:c.FLUSH,IMPORT:c.IMPORT,PUT:c.PUT,PUT_RAW:c.PUT_RAW,TOKENIZATION_PIPELINE_STAGES:i,ALL_DOCUMENTS:l.ALL_DOCUMENTS,BUCKETS:t.fii.BUCKETS,CREATED:t.fii.CREATED,DICTIONARY:l.DICTIONARY,DISTINCT:l.DISTINCT,DOCUMENTS:l.DOCUMENTS,DOCUMENT_COUNT:l.DOCUMENT_COUNT,DOCUMENT_VECTORS:l.DOCUMENT_VECTORS,EXPORT:t.fii.EXPORT,FACETS:l.FACETS,FIELDS:t.fii.FIELDS,INDEX:t.fii,LAST_UPDATED:t.fii.LAST_UPDATED,MAX:t.fii.MAX,MIN:t.fii.MIN,QUERY:l.QUERY,SEARCH:l.SEARCH})))}));t.exports=t=>((t={})=>new Promise(((e,n)=>(t=Object.assign({cacheLength:1e3,caseSensitive:!1,docExistsSpace:"DOC_RAW",idGenerator:function*(){let t=0;for(;;)yield Date.now()+"-"+t++}(),isLeaf:t=>Array.isArray(t)&&2===t.length&&t.every((t=>"string"==typeof t||"number"==typeof t||null===t)),skipFields:[],ngrams:{},replace:{},storeRawDocs:!0,stopwords:[],storeVectors:!0,tokenAppend:"#",tokenSplitRegex:/[\p{L}\d]+/gu,tokenizer:i.tokenizer},t),r(t).then((n=>e(Object.assign({fii:n},t))))))))(t).then(c).then((t=>(t=>new Promise(((e,n)=>{const r=["CREATED_WITH"],i="search-index@"+h.version;return t.INDEX.STORE.get(r,t.INDEX.LEVEL_OPTIONS).then((t=>i===t?e():n(new Error("This index was created with "+t+", you are running "+i)))).catch((n=>t.INDEX.STORE.put(r,i,t.INDEX.LEVEL_OPTIONS).then(e)))})))(t).then((()=>t))))},6291:(t,e,n)=>{const{EntryStream:r}=n(6741);t.exports=(t,e)=>{const n=e=>new Promise(((n,i)=>{const o=[];new r(t.fii.STORE,{gte:["DOC_RAW",null],lte:["DOC_RAW",void 0],limit:e,...t.fii.LEVEL_OPTIONS}).on("data",(t=>o.push({_id:t.value._id,_doc:t.value}))).on("end",(()=>n(o)))})),i=(...e)=>e.length?Promise.all(e.map((e=>t.fii.STORE.get(["DOC_RAW",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))):n(),o=(...e)=>t.fii.DISTINCT(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),s=(...e)=>t.fii.FACETS(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),a=(t,e)=>{const n=(e=Object.assign({NUMBER:0,SIZE:20},e||{})).NUMBER*e.SIZE,r=n+e.SIZE||void 0;return t.slice(n,r)},h=(t,e={})=>{e=Object.assign({TYPE:"TFIDF"},e);const n=t=>!e.FIELDS||e.FIELDS.includes(t.FIELD),r=t=>(t||[]).filter(n);return new Promise((i=>i("TFIDF"===e.TYPE?l().then((e=>t.map(((t,r,i)=>{const o=Math.log((e+1)/i.length);return t._score=+(t._match||[]).filter(n).reduce(((t,e)=>t+o*+e.SCORE),0).toFixed(2),t})))):"PRODUCT"===e.TYPE?t.map((t=>({...t,_score:+r(t._match).reduce(((t,e)=>t*+e.SCORE),1).toFixed(2)}))):"CONCAT"===e.TYPE?t.map((t=>({...t,_score:r(t._match).reduce(((t,e)=>t+e.SCORE),"")}))):"SUM"===e.TYPE?t.map((t=>({...t,_score:+r(t._match).reduce(((t,e)=>t+ +e.SCORE),0).toFixed(2)}))):"VALUE"===e.TYPE?t.map((t=>({...t,_score:r(t._match).reduce(((t,e)=>t+e.VALUE),"")}))):null)))},c=(t,e)=>(e=Object.assign({DIRECTION:"DESCENDING",TYPE:"NUMERIC"},e||{}),t.sort(((t,e)=>t._ide._id?1:0)).sort({NUMERIC:{DESCENDING:(t,e)=>+e._score-+t._score,ASCENDING:(t,e)=>+t._score-+e._score},ALPHABETIC:{DESCENDING:(t,e)=>t._scoree._score?-1:0,ASCENDING:(t,e)=>t._scoree._score?1:0}}[e.TYPE][e.DIRECTION])),l=()=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS),u=(e,r={})=>{const o=e=>"string"==typeof e||"number"==typeof e?t.fii.GET(e,r.PIPELINE):e.FIELD||e.VALUE?t.fii.GET(e):e.AND?t.fii.AND(e.AND.map(o),r.PIPELINE):e.GET?t.fii.GET(e.GET,r.PIPELINE):e.NOT?t.fii.NOT(o(e.NOT.INCLUDE),o(e.NOT.EXCLUDE)):e.OR?t.fii.OR(e.OR.map(o),r.PIPELINE):e.ALL_DOCUMENTS?n(e.ALL_DOCUMENTS):void 0;return o(e).then((t=>t.RESULT?Object.assign(t,{RESULT_LENGTH:t.RESULT.length}):{RESULT:t,RESULT_LENGTH:t.length})).then((e=>r.BUCKETS?t.fii.BUCKETS(...r.BUCKETS).then((n=>Object.assign(e,{BUCKETS:t.fii.AGGREGATION_FILTER(n,e.RESULT)}))):e)).then((n=>r.FACETS?n.RESULT.length?e.ALL_DOCUMENTS?s(...r.FACETS).then((t=>Object.assign(n,{FACETS:t}))):s(...r.FACETS).then((e=>Object.assign(n,{FACETS:t.fii.AGGREGATION_FILTER(e,n.RESULT)}))):Object.assign(n,{FACETS:[]}):n)).then((t=>{return r.WEIGHT?Object.assign({RESULT:(e=t.RESULT,n=r.WEIGHT,e.map((t=>(t._match=t._match.map((t=>(n.forEach((e=>{let n=!1;e.FIELD&&e.VALUE?e.FIELD===t.FIELD&&e.VALUE===t.VALUE&&(n=!0):e.FIELD?e.FIELD===t.FIELD&&(n=!0):e.VALUE&&e.VALUE===t.VALUE&&(n=!0),n&&(t.SCORE=(e.WEIGHT*+t.SCORE).toFixed(2))})),t))),t))))},t):t;var e,n})).then((t=>r.SCORE?h(t.RESULT,r.SCORE).then((e=>Object.assign(t,{RESULT:e}))):t)).then((t=>Object.assign(t,r.SORT?{RESULT:c(t.RESULT,r.SORT)}:{}))).then((t=>Object.assign(t,r.PAGE?{RESULT:a(t.RESULT,r.PAGE)}:{}))).then((t=>r.DOCUMENTS?i(...t.RESULT.map((t=>t._id))).then((e=>Object.assign(t,{RESULT:t.RESULT.map(((t,n)=>Object.assign(t,{_doc:e[n]})))}))):t))},f=(t,n)=>new Promise((r=>(n=JSON.stringify(n),e.has(n)?r(e.get(n)):t.then((t=>e.set(n,t))).then((()=>r(e.get(n)))))));return{ALL_DOCUMENTS:n,DICTIONARY:t=>f((t=>o(t).then((t=>Array.from(t.reduce(((t,e)=>t.add(e.VALUE)),new Set)).sort(((t,e)=>(t+"").localeCompare(e+"",void 0,{numeric:!0,sensitivity:"base"}))))))(t),{DICTIONARY:t||null}),DISTINCT:o,DOCUMENTS:(...t)=>f(i(...t),{DOCUMENTS:t}),DOCUMENT_COUNT:l,DOCUMENT_VECTORS:(...e)=>Promise.all(e.map((e=>t.fii.STORE.get(["DOC",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))),FACETS:s,PAGE:a,QUERY:(t,e)=>f(u(t,e),{QUERY:[t,e]}),SCORE:h,SEARCH:(t,e)=>f(((t,e)=>u({AND:[...t]},Object.assign({SCORE:{TYPE:"TFIDF"},SORT:!0},e)))(t,e),{SEARCH:[t,e]}),SORT:c}}},7155:(t,e,n)=>{const r=n(971),{ngraminator:i}=n(6349),o=([t,e,n])=>Promise.resolve([t.match(n.tokenSplitRegex)||[],e,n]),s=([t,e,n])=>[n.skipFields.includes(e)?[]:t,e,n],a=([t,e,n])=>Promise.resolve([t.map((t=>n.caseSensitive?t:t.toLowerCase())),e,n]),h=([t,e,n])=>{const{fields:r,values:i}=n.replace,o=()=>t.reduce(((t,e)=>[e,...t,...i[e]||[]]),[]);return i?r?r.includes(e)?Promise.resolve([o(),e,n]):Promise.resolve([t,e,n]):Promise.resolve([o(),e,n]):Promise.resolve([t,e,n])},c=([t,e,n])=>{let{fields:r,lengths:o,join:s=" "}=n.ngrams;return r||(r=[e]),o&&r.includes(e)?[i(t.filter((t=>null!==t)),o).map((t=>t.join(s))),e,n]:Promise.resolve([t,e,n])},l=([t,e,n])=>[t.filter((t=>!n.stopwords.includes(t.toLowerCase()))),e,n],u=([t,e,n])=>{const i=r(t),o=i.reduce(((t,e)=>Math.max(e.positions.length,t)),0);return Promise.resolve([i.map((t=>[t.term[0],(t.positions.length/o).toFixed(2)])).sort(),e,n])};e.SPY=([t,e,n])=>(console.log("----------------"),console.log("field ->"),console.log(e),console.log("tokens ->"),console.log(t),console.log("----------------"),Promise.resolve([t,e,n])),e.tokenizer=(t,e,n)=>o([t,e,n]).then(s).then(a).then(h).then(c).then(l).then(u).then((([t,e,n])=>t)),e.SPLIT=o,e.SKIP=s,e.LOWACASE=a,e.REPLACE=h,e.NGRAMS=c,e.STOPWORDS=l,e.SCORE_TERM_FREQUENCY=u},6761:(t,e,n)=>{const r=n(1861);t.exports=(t,e,n)=>{const i=e=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],+n+e,t.fii.LEVEL_OPTIONS))).catch((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],e,t.fii.LEVEL_OPTIONS))),o=(n,r,i)=>(e.clear(),Promise.all(n.map(((e,n)=>t.fii.STORE.put(["DOC_RAW",r[n]],i?{}:e,t.fii.LEVEL_OPTIONS)))).then((t=>n.map(((t,e)=>({_id:r[e],status:"OK",operation:"_PUT_RAW"}))))));return{DELETE:(...n)=>{return r=n,t.fii.DELETE(r,t.fii.LEVEL_OPTIONS).then((n=>{e.clear();const r=n.filter((t=>"DELETED"===t.status));return Promise.all([Promise.all(r.map((e=>t.fii.STORE.del(["DOC_RAW",e._id],t.fii.LEVEL_OPTIONS)))),(i=r.length,t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((e=>t.fii.STORE.put(["DOCUMENT_COUNT"],+e-i,t.fii.LEVEL_OPTIONS))))]).then((()=>n));var i}));var r},FLUSH:()=>t.fii.STORE.clear().then((()=>{e.clear();const n=Date.now();return t.fii.STORE.batch([{type:"put",key:["~CREATED"],value:n},{type:"put",key:["~LAST_UPDATED"],value:n},{type:"put",key:["DOCUMENT_COUNT"],value:0}],t.fii.LEVEL_OPTIONS)})).then((()=>!0)),IMPORT:n=>(e.clear(),Promise.resolve(t.fii.IMPORT(n))),PUT:(s,a)=>n.add((()=>((n,s)=>(e.clear(),s=Object.assign(t,s),r(t).processDocuments(n).then((e=>t.fii.PUT(e,s,t.fii.LEVEL_OPTIONS).then((e=>Promise.all([o(n,e.map((t=>t._id)),!t.storeRawDocs),i(e.filter((t=>"CREATED"===t.status)).length)]).then((()=>e))))))))(s,a))),PUT_RAW:o,_INCREMENT_DOC_COUNT:i}}},2361:()=>{},4616:()=>{},4456:(t,e,n)=>{var r=n(4155);Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const i="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,o=new Set,s="object"==typeof r&&r?r:{},a=(t,e,n,r)=>{"function"==typeof s.emitWarning?s.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let h=globalThis.AbortController,c=globalThis.AbortSignal;if(void 0===h){c=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},h=class{constructor(){e()}signal=new c;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==s.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,a("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const l=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),u=t=>l(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?f:null:null;class f extends Array{constructor(t){super(t),this.fill(0)}}class d{heap;length;static#t=!1;static create(t){const e=u(t);if(!e)return[];d.#t=!0;const n=new d(t,e);return d.#t=!1,n}constructor(t,e){if(!d.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class p{#e;#n;#r;#i;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#a;#h;#c;#l;#u;#f;#d;#p;#y;#g;#b;#E;#m;#v;#w;#_;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#m,sizes:t.#b,keyMap:t.#h,keyList:t.#c,valList:t.#l,next:t.#u,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#y,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,r,i)=>t.#S(e,n,r,i),moveToTail:e=>t.#L(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#a}get size(){return this.#s}get fetchMethod(){return this.#o}get dispose(){return this.#r}get disposeAfter(){return this.#i}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:i,updateAgeOnGet:s,updateAgeOnHas:h,allowStale:c,dispose:f,disposeAfter:y,noDisposeOnSet:g,noUpdateTTL:b,maxSize:E=0,maxEntrySize:m=0,sizeCalculation:v,fetchMethod:w,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:L,ignoreFetchAbort:O}=t;if(0!==e&&!l(e))throw new TypeError("max option must be a nonnegative integer");const A=e?u(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=E,this.maxEntrySize=m||this.#n,this.sizeCalculation=v,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==w&&"function"!=typeof w)throw new TypeError("fetchMethod must be a function if specified");if(this.#o=w,this.#w=!!w,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new A(e),this.#f=new A(e),this.#d=0,this.#p=0,this.#y=d.create(e),this.#s=0,this.#a=0,"function"==typeof f&&(this.#r=f),"function"==typeof y?(this.#i=y,this.#g=[]):(this.#i=void 0,this.#g=void 0),this.#v=!!this.#r,this.#_=!!this.#i,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!L,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#n&&!l(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!l(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#x()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!h,this.ttlResolution=l(r)||0===r?r:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!l(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!o.has(t))(t)&&(o.add(t),a("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,p))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#R(){const t=new f(this.#e),e=new f(this.#e);this.#m=t,this.#E=e,this.#I=(n,r,o=i.now())=>{if(e[n]=0!==r?o:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(n)&&this.delete(this.#c[n])}),r+1);t.unref&&t.unref()}},this.#C=n=>{e[n]=0!==t[n]?i.now():0},this.#N=(i,o)=>{if(t[o]){const s=t[o],a=e[o];i.ttl=s,i.start=a,i.now=n||r();const h=i.now-a;i.remainingTTL=s-h}};let n=0;const r=()=>{const t=i.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const o=this.#h.get(i);if(void 0===o)return 0;const s=t[o],a=e[o];return 0===s||0===a?1/0:s-((n||r())-a)},this.#k=i=>0!==t[i]&&0!==e[i]&&(n||r())-e[i]>t[i]}#C=()=>{};#N=()=>{};#I=()=>{};#k=()=>!1;#x(){const t=new f(this.#e);this.#a=0,this.#b=t,this.#D=e=>{this.#a-=t[e],t[e]=0},this.#U=(t,e,n,r)=>{if(this.#T(e))return 0;if(!l(n)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!l(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#P=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#a>n;)this.#M(!0)}this.#a+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#a)}}#D=t=>{};#P=(t,e,n)=>{};#U=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#s)for(let e=this.#p;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#s)for(let e=this.#d;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#u[e]}#B(t){return void 0!==t&&this.#h.get(this.#c[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#c[t]||this.#T(this.#l[t])||(yield[this.#c[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#c[t]||this.#T(this.#l[t])||(yield[this.#c[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#c[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#c[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O())void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}*rvalues(){for(const t of this.#A())void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of this.#O()){const r=this.#l[n],i=this.#T(r)?r.__staleWhileFetching:r;if(void 0!==i&&t(i,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#O()){const r=this.#l[n],i=this.#T(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#A()){const r=this.#l[n],i=this.#T(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#c[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const n=this.#c[e],r=this.#l[e],o=this.#T(r)?r.__staleWhileFetching:r;if(void 0===o||void 0===n)continue;const s={value:o};if(this.#m&&this.#E){s.ttl=this.#m[e];const t=i.now()-this.#E[e];s.start=Math.floor(Date.now()-t)}this.#b&&(s.size=this.#b[e]),t.unshift([n,s])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=i.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:i,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:h=this.noUpdateTTL}=n;const c=this.#U(t,e,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#s?void 0:this.#h.get(t);if(void 0===l)l=0===this.#s?this.#p:0!==this.#y.length?this.#y.pop():this.#s===this.#e?this.#M(!1):this.#s,this.#c[l]=t,this.#l[l]=e,this.#h.set(t,l),this.#u[this.#p]=l,this.#f[l]=this.#p,this.#p=l,this.#s++,this.#P(l,c,a),a&&(a.set="add"),h=!1;else{this.#L(l);const n=this.#l[l];if(e!==n){if(this.#w&&this.#T(n)?n.__abortController.abort(new Error("replaced")):o||(this.#v&&this.#r?.(n,t,"set"),this.#_&&this.#g?.push([n,t,"set"])),this.#D(l),this.#P(l,c,a),this.#l[l]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#m||this.#R(),this.#m&&(h||this.#I(l,r,i),a&&this.#N(a,l)),!o&&this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#s;){const t=this.#l[this.#d];if(this.#M(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}}}#M(t){const e=this.#d,n=this.#c[e],r=this.#l[e];return this.#w&&this.#T(r)?r.__abortController.abort(new Error("evicted")):(this.#v||this.#_)&&(this.#v&&this.#r?.(r,n,"evict"),this.#_&&this.#g?.push([r,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#l[e]=void 0,this.#y.push(e)),1===this.#s?(this.#d=this.#p=0,this.#y.length=0):this.#d=this.#u[e],this.#h.delete(n),this.#s--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,i=this.#h.get(t);if(void 0!==i){const t=this.#l[i];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(i))return n&&this.#C(i),r&&(r.has="hit",this.#N(r,i)),!0;r&&(r.has="stale",this.#N(r,i))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#h.get(t);if(void 0!==r&&(n||!this.#k(r))){const t=this.#l[r];return this.#T(t)?t.__staleWhileFetching:t}}#S(t,e,n,r){const i=void 0===e?void 0:this.#l[e];if(this.#T(i))return i;const o=new h,{signal:s}=n;s?.addEventListener("abort",(()=>o.abort(s.reason)),{signal:o.signal});const a={signal:o.signal,options:n,context:r},c=(r,i=!1)=>{const{aborted:s}=o.signal,h=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(s&&!i?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,h&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!h&&!i)return l(o.signal.reason);const c=u;return this.#l[e]===u&&(void 0===r?c.__staleWhileFetching?this.#l[e]=c.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},l=r=>{const{aborted:i}=o.signal,s=i&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,h=a||n.noDeleteOnFetchRejection,c=u;if(this.#l[e]===u&&(h&&void 0!==c.__staleWhileFetching?s||(this.#l[e]=c.__staleWhileFetching):this.delete(t)),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw r};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((e,r)=>{const s=this.#o?.(t,i,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),r),o.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>c(t,!0)))}))})).then(c,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),l(t)))),f=Object.assign(u,{__abortController:o,__staleWhileFetching:i,__returned:void 0});return void 0===e?(this.set(t,f,{...a.options,status:void 0}),e=this.#h.get(t)):this.#l[e]=f,f}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof h}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:b}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});const E={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:g,signal:b};let m=this.#h.get(t);if(void 0===m){g&&(g.fetch="miss");const e=this.#S(t,m,E,p);return e.__returned=e}{const e=this.#l[m];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=this.#k(m);if(!y&&!i)return g&&(g.fetch="hit"),this.#L(m),r&&this.#C(m),g&&this.#N(g,m),e;const o=this.#S(t,m,E,p),s=void 0!==o.__staleWhileFetching&&n;return g&&(g.fetch=i?"stale":"refresh",s&&i&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:o}=e,s=this.#h.get(t);if(void 0!==s){const e=this.#l[s],a=this.#T(e);return o&&this.#N(o,s),this.#k(s)?(o&&(o.get="stale"),a?(o&&n&&void 0!==e.__staleWhileFetching&&(o.returnedStale=!0),n?e.__staleWhileFetching:void 0):(i||this.delete(t),o&&n&&(o.returnedStale=!0),n?e:void 0)):(o&&(o.get="hit"),a?e.__staleWhileFetching:(this.#L(s),r&&this.#C(s),e))}o&&(o.get="miss")}#j(t,e){this.#f[e]=t,this.#u[t]=e}#L(t){t!==this.#p&&(t===this.#d?this.#d=this.#u[t]:this.#j(this.#f[t],this.#u[t]),this.#j(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#s){const n=this.#h.get(t);if(void 0!==n)if(e=!0,1===this.#s)this.clear();else{this.#D(n);const e=this.#l[n];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#v||this.#_)&&(this.#v&&this.#r?.(e,t,"delete"),this.#_&&this.#g?.push([e,t,"delete"])),this.#h.delete(t),this.#c[n]=void 0,this.#l[n]=void 0,n===this.#p?this.#p=this.#f[n]:n===this.#d?this.#d=this.#u[n]:(this.#u[this.#f[n]]=this.#u[n],this.#f[this.#u[n]]=this.#f[n]),this.#s--,this.#y.push(n)}}if(this.#_&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const n=this.#c[t];this.#v&&this.#r?.(e,n,"delete"),this.#_&&this.#g?.push([e,n,"delete"])}}if(this.#h.clear(),this.#l.fill(void 0),this.#c.fill(void 0),this.#m&&this.#E&&(this.#m.fill(0),this.#E.fill(0)),this.#b&&this.#b.fill(0),this.#d=0,this.#p=0,this.#y.length=0,this.#a=0,this.#s=0,this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}}}e.LRUCache=p},5613:(t,e,n)=>{n.r(e),n.d(e,{AbortError:()=>j,default:()=>F});var r=n(6729);class i extends Error{constructor(t){super(t),this.name="TimeoutError"}}class o extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const s=t=>void 0===globalThis.DOMException?new o(t):new DOMException(t),a=t=>{const e=void 0===t.reason?s("This operation was aborted."):t.reason;return e instanceof Error?e:s(e)};var h,c=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class l{constructor(){h.set(this,[])}enqueue(t,e){const n={priority:(e={priority:0,...e}).priority,run:t};if(this.size&&c(this,h,"f")[this.size-1].priority>=e.priority)return void c(this,h,"f").push(n);const r=function(t,e,n){let r=0,i=t.length;for(;i>0;){const n=Math.trunc(i/2);let s=r+n;o=t[s],e.priority-o.priority<=0?(r=++s,i-=n+1):i=n}var o;return r}(c(this,h,"f"),n);c(this,h,"f").splice(r,0,n)}dequeue(){const t=c(this,h,"f").shift();return null==t?void 0:t.run}filter(t){return c(this,h,"f").filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return c(this,h,"f").length}}h=new WeakMap;var u,f,d,p,y,g,b,E,m,v,w,_,T,S,L,O,A,k,x,R,I,C,N,D,U,P,M=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},B=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class j extends Error{}class F extends r{constructor(t){var e,n,r,i;if(super(),u.add(this),f.set(this,void 0),d.set(this,void 0),p.set(this,0),y.set(this,void 0),g.set(this,void 0),b.set(this,0),E.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,void 0),_.set(this,0),T.set(this,void 0),S.set(this,void 0),L.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:l,...t}).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(r=t.interval)||void 0===r?void 0:r.toString())&&void 0!==i?i:""}\` (${typeof t.interval})`);M(this,f,t.carryoverConcurrencyCount,"f"),M(this,d,t.intervalCap===Number.POSITIVE_INFINITY||0===t.interval,"f"),M(this,y,t.intervalCap,"f"),M(this,g,t.interval,"f"),M(this,v,new t.queueClass,"f"),M(this,w,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,M(this,L,!0===t.throwOnTimeout,"f"),M(this,S,!1===t.autoStart,"f")}get concurrency(){return B(this,T,"f")}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);M(this,T,t,"f"),B(this,u,"m",D).call(this)}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:B(this,L,"f"),...e},new Promise(((n,r)=>{B(this,v,"f").enqueue((async()=>{var o,s,h;M(this,_,(s=B(this,_,"f"),++s),"f"),M(this,p,(h=B(this,p,"f"),++h),"f");try{if(null===(o=e.signal)||void 0===o?void 0:o.aborted)throw new j("The task was aborted.");let r=t({signal:e.signal});e.timeout&&(r=function(t,e,n,r){let o;const s=new Promise(((s,h)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:t}=r;t.aborted&&h(a(t)),t.addEventListener("abort",(()=>{h(a(t))}))}o=r.customTimers.setTimeout.call(void 0,(()=>{const r=n instanceof Error?n:new i(`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),h(r)}),e),(async()=>{try{s(await t)}catch(t){h(t)}finally{r.customTimers.clearTimeout.call(void 0,o)}})()}else s(t)}));return s.clear=()=>{clearTimeout(o),o=void 0},s}(Promise.resolve(r),e.timeout)),e.signal&&(r=Promise.race([r,B(this,u,"m",U).call(this,e.signal)]));const s=await r;n(s),this.emit("completed",s)}catch(t){if(t instanceof i&&!e.throwOnTimeout)return void n();r(t),this.emit("error",t)}finally{B(this,u,"m",k).call(this)}}),e),this.emit("add"),B(this,u,"m",I).call(this)}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return B(this,S,"f")?(M(this,S,!1,"f"),B(this,u,"m",D).call(this),this):this}pause(){M(this,S,!0,"f")}clear(){M(this,v,new(B(this,w,"f")),"f")}async onEmpty(){0!==B(this,v,"f").size&&await B(this,u,"m",P).call(this,"empty")}async onSizeLessThan(t){B(this,v,"f").sizeB(this,v,"f").size{B(this,u,"m",x).call(this)}),e),"f"),!0;M(this,p,B(this,f,"f")?B(this,_,"f"):0,"f")}return!1},I=function(){if(0===B(this,v,"f").size)return B(this,E,"f")&&clearInterval(B(this,E,"f")),M(this,E,void 0,"f"),this.emit("empty"),0===B(this,_,"f")&&this.emit("idle"),!1;if(!B(this,S,"f")){const t=!B(this,u,"a",R);if(B(this,u,"a",O)&&B(this,u,"a",A)){const e=B(this,v,"f").dequeue();return!!e&&(this.emit("active"),e(),t&&B(this,u,"m",C).call(this),!0)}}return!1},C=function(){B(this,d,"f")||void 0!==B(this,E,"f")||(M(this,E,setInterval((()=>{B(this,u,"m",N).call(this)}),B(this,g,"f")),"f"),M(this,b,Date.now()+B(this,g,"f"),"f"))},N=function(){0===B(this,p,"f")&&0===B(this,_,"f")&&B(this,E,"f")&&(clearInterval(B(this,E,"f")),M(this,E,void 0,"f")),M(this,p,B(this,f,"f")?B(this,_,"f"):0,"f"),B(this,u,"m",D).call(this)},D=function(){for(;B(this,u,"m",I).call(this););},U=async function(t){return new Promise(((e,n)=>{t.addEventListener("abort",(()=>{n(new j("The task was aborted."))}),{once:!0})}))},P=async function(t,e){return new Promise((n=>{const r=()=>{e&&!e()||(this.off(t,r),n())};this.on(t,r)}))}},4147:t=>{t.exports=JSON.parse('{"name":"search-index","version":"4.0.0","description":"A network resilient, persistent full-text search library for the browser and Node.js","keywords":["search","elasticsearch","elastic","lunr.js","flexsearch","norch","solr"],"engines":{"node":">=12"},"main":"src/node.js","browser":"src/browser.js","files":["dist","src"],"directories":{"lib":"src"},"scripts":{"build":"npm run empty-sandbox && rm -rf ./dist/* && webpack && cp dist/search-index-$npm_package_version.js dist/search-index.js","demo-export":"node demo/generate-index/export.js","demo-fetch":"node demo/generate-index/fetch.js","demo-process":"node demo/generate-index/process.js","demo-rebuild":"npm run demo-fetch && npm run demo-process && npm run demo-export && npm run demo-link-lib","demo-start":"http-server -c-1 demo & open-cli http://127.0.0.1:8080","demo-link-lib":"cd demo/lib && ln -sf ../../dist/search-index.js && cd ../../","empty-sandbox":"rm -rf fii && rm -rf test/sandbox && mkdir test/sandbox","lint":"standard --fix test/src/* src/* demo/src/* demo/generate-index/*.js","test":"npm run empty-sandbox && npm run test-node && npm run test-browser && npm run lint","test-browser":"npm run build && cat test/sandbox/browser-tests.js | tape-run","test-node":"npm run empty-sandbox && tape test/src/*-test.js","toc":"doctoc docs/API.md --title \'# API Documentation for search-index\' && doctoc docs/FAQ.md --title \'# FAQ\'"},"repository":{"type":"git","url":"git+https://github.com/fergiemcdowall/search-index.git"},"author":"Fergus McDowall","license":"MIT","bugs":{"url":"https://github.com/fergiemcdowall/search-index/issues"},"homepage":"https://fergiemcdowall.github.io/search-index/","devDependencies":{"assert":"^2.0.0","classic-level":"^1.3.0","doctoc":"2.2.1","fuzzyset":"1.0.5","http-server":"14.1.1","level-out":"^1.0.1","memory-level":"^1.0.0","open-cli":"7.2.0","os-browserify":"^0.3.0","path":"^0.12.7","path-browserify":"^1.0.1","process":"^0.11.10","standard":"17.1.0","stemmer":"1.0.5","stopword":"2.0.8","stream-browserify":"^3.0.0","tape":"5.6.3","tape-run":"^10.0.0","webpack":"5.87.0","webpack-cli":"5.1.4","world-bank-dataset":"^1.0.0"},"dependencies":{"fergies-inverted-index":"12.0.0","browser-level":"^1.0.1","charwise":"^3.0.1","level-read-stream":"^1.1.0","lru-cache":"10.0.0","memory-level":"^1.0.0","ngraminator":"3.0.2","p-queue":"7.3.4","term-vector":"^1.0.0"}}')}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n(2225); \ No newline at end of file +var t={9464:(t,e,n)=>{const{fromCallback:i}=n(6957),r=n(4473),{getCallback:o,getOptions:s}=n(2520),a=Symbol("promise"),h=Symbol("status"),c=Symbol("operations"),l=Symbol("finishClose"),u=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[c]=[],this[u]=[],this[h]="open",this[l]=this[l].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[c].length}put(t,e,n){if("open"!==this[h])throw new r("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;const o=n&&null!=n.sublevel?n.sublevel:this.db,s=n,a=o.keyEncoding(n&&n.keyEncoding),l=o.valueEncoding(n&&n.valueEncoding),u=a.format;n={...n,keyEncoding:u,valueEncoding:l.format},o!==this.db&&(n.sublevel=null);const f=o.prefixKey(a.encode(t),u),d=l.encode(e);return this._put(f,d,n),this[c].push({...s,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if("open"!==this[h])throw new r("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const n=this.db._checkKey(t);if(n)throw n;const i=e&&null!=e.sublevel?e.sublevel:this.db,o=e,s=i.keyEncoding(e&&e.keyEncoding),a=s.format;return e={...e,keyEncoding:a},i!==this.db&&(e.sublevel=null),this._del(i.prefixKey(s.encode(t),a),e),this[c].push({...o,type:"del",key:t}),this}_del(t,e){}clear(){if("open"!==this[h])throw new r("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[c]=[],this}_clear(){}write(t,e){return e=o(t,e),e=i(e,a),t=s(t),"open"!==this[h]?this.nextTick(e,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):0===this.length?this.close(e):(this[h]="writing",this._write(t,(t=>{this[h]="closing",this[u].push((()=>e(t))),t||this.db.emit("batch",this[c]),this._close(this[l])}))),e[a]}_write(t,e){}close(t){return t=i(t,a),"closing"===this[h]?this[u].push(t):"closed"===this[h]?this.nextTick(t):(this[u].push(t),"writing"!==this[h]&&(this[h]="closing",this._close(this[l]))),t[a]}_close(t){this.nextTick(t)}[l](){this[h]="closed",this.db.detachResource(this);const t=this[u];this[u]=[];for(const e of t)e()}}},3961:(t,e,n)=>{const{fromCallback:i}=n(6957),r=n(4473),{getOptions:o,getCallback:s}=n(2520),a=Symbol("promise"),h=Symbol("callback"),c=Symbol("working"),l=Symbol("handleOne"),u=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){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[b]=!1,this[E]=[],this[c]=!1,this[y]=!1,this[f]=!1,this[h]=null,this[l]=this[l].bind(this),this[u]=this[u].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,i,r)=>{t?n(t):this[_]?void 0===i&&void 0===r?e():e([i,r]):e(i)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new r("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(t,new r("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=t,this[O]>=this[L]?this.nextTick(this[l],null):this._next(this[l])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=s(e,n),n=i(n,a),e=o(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new r("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(n,new r("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[c]=!0,this[h]=n,t<=0?this.nextTick(this[u],null,[]):this._nextv(t,e,this[u])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const i=[],r=(e,o,s)=>e?n(e):(this[_]?void 0===o&&void 0===s:void 0===o)?n(null,i):(i.push(this[_]?[o,s]:o),void(i.length===t?n(null,i):this._next(r)));this._next(r)}all(t,e){return e=s(t,e),e=i(e,a),t=o(t,A),this[y]?this.nextTick(e,new r("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(e,new r("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[u],null,[]):this._all(t,this[u])),e[a]}_all(t,e){let n=this[O];const i=[],r=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,i):this._nextv(t,A,o)},o=(t,o)=>{t?e(t):0===o.length?e(null,i):(i.push.apply(i,o),n+=o.length,r())};r()}[d](){const t=this[h];return this[w]&&null===t?k:(this[c]=!1,this[h]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=o(e,A),this[y]);else{if(this[c])throw new r("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),i=n.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});const r=this.db.prefixKey(n.encode(t),i);this._seek(r,e)}}}_seek(t,e){throw new r("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=i(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[c]?this[w]&&this[d]()(new r("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[g])),t[a]}_close(t){this.nextTick(t)}[g](){this[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[l](t,e,n){const i=this[d]();if(t)return i(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return i(new C("entry",t))}void 0===e&&void 0===n||this[O]++,i(null,e,n)}[u](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!0,console.warn(new r("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 C extends r{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(I.prototype,t.split(" ")[0],{get(){throw new r(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new r(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[l](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[u](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t{const{supports:i}=n(3658),{Transcoder:r}=n(8499),{EventEmitter:o}=n(7187),{fromCallback:s}=n(6957),a=n(4473),{AbstractIterator:h}=n(3961),{DefaultKeyIterator:c,DefaultValueIterator:l}=n(5429),{DeferredIterator:u,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C 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:n,valueEncoding:o,passive:s,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=i(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[k]=new r(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(o||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=s(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=s(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const i=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(i);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const i=this._checkKey(t);if(i)return this.nextTick(n,i),n[E];const r=this.keyEncoding(e.keyEncoding),o=this.valueEncoding(e.valueEncoding),h=r.format,c=o.format;return e.keyEncoding===h&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:h,valueEncoding:c})),this._get(this.prefixKey(r.encode(t),h),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)),n(t);try{e=o.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const i=this.keyEncoding(e.keyEncoding),r=this.valueEncoding(e.valueEncoding),o=i.format,h=r.format;e.keyEncoding===o&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:o,valueEncoding:h}));const c=new Array(t.length);for(let e=0;e{if(t)return n(t);try{for(let t=0;tthis.put(t,e,n,i))),i[E];if(D(this,i))return i[E];const r=this._checkKey(t)||this._checkValue(e);if(r)return this.nextTick(i,r),i[E];const o=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),h=o.format,c=a.format;n.keyEncoding===h&&n.valueEncoding===c||(n=Object.assign({},n,{keyEncoding:h,valueEncoding:c}));const l=this.prefixKey(o.encode(t),h),u=a.encode(e);return this._put(l,u,n,(n=>{if(n)return i(n);this.emit("put",t,e),i()})),i[E]}_put(t,e,n,i){this.nextTick(i)}del(t,e,n){if(n=y(e,n),n=s(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const i=this._checkKey(t);if(i)return this.nextTick(n,i),n[E];const r=this.keyEncoding(e.keyEncoding),o=r.format;return e.keyEncoding!==o&&(e=Object.assign({},e,{keyEncoding:o})),this._del(this.prefixKey(r.encode(t),o),e,(e=>{if(e)return n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=s(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const i=new Array(t.length),{keyEncoding:r,valueEncoding:o,...h}=e;for(let e=0;e{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=s(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,i=this.keyEncoding(t.keyEncoding);return(t=b(t,i)).keyEncoding=i.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new u(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new h(this,t)}keys(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new c(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new l(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];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 p(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"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{const{AbstractIterator:i,AbstractKeyIterator:r,AbstractValueIterator:o}=n(3961),s=Symbol("unfix"),a=Symbol("iterator"),h=Symbol("handleOne"),c=Symbol("handleMany"),l=Symbol("callback");class u extends i{constructor(t,e,n,i){super(t,e),this[a]=n,this[s]=i,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[l]=null}[h](t,e,n){const i=this[l];if(t)return i(t);void 0!==e&&(e=this[s](e)),i(t,e,n)}[c](t,e){const n=this[l];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[s](e))}n(t,e)}}class f extends r{constructor(t,e,n,i){super(t,e),this[a]=n,this[s]=i,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[l]=null}[h](t,e){const n=this[l];if(t)return n(t);void 0!==e&&(e=this[s](e)),n(t,e)}[c](t,e){const n=this[l];if(t)return n(t);for(let t=0;t{const i=n(4473),{Buffer:r}=n(8764)||{},{AbstractSublevelIterator:o,AbstractSublevelKeyIterator:s,AbstractSublevelValueIterator:a}=n(2970),h=Symbol("prefix"),c=Symbol("upperBound"),l=Symbol("prefixRange"),u=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new i("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new i("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,r){const{separator:o,manifest:s,...a}=e.defaults(r);n=m(n,o);const l=o.charCodeAt(0)+1,p=t[u]||t;if(!d.encode(n).every((t=>t>l&&t<127)))throw new i(`Prefix must use bytes > ${l} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,s),a);const g=(t.prefix||"")+o+n+o,v=g.slice(0,-1)+String.fromCharCode(l);this[u]=p,this[h]=new b(g),this[c]=new b(v),this[f]=new E,this.nextTick=p.nextTick}prefixKey(t,e){if("utf8"===e)return this[h].utf8+t;if(0===t.byteLength)return this[h][e];if("view"===e){const e=this[h].view,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[h].buffer;return r.concat([e,t],e.byteLength+t.byteLength)}}[l](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[h][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[c][e]}get prefix(){return this[h].utf8}get db(){return this[u]}_open(t,e){this[u].open({passive:!0},e)}_put(t,e,n,i){this[u].put(t,e,n,i)}_get(t,e,n){this[u].get(t,e,n)}_getMany(t,e,n){this[u].getMany(t,e,n)}_del(t,e,n){this[u].del(t,e,n)}_batch(t,e,n){this[u].batch(t,e,n)}_clear(t,e){this[l](t,t.keyEncoding),this[u].clear(t,e)}_iterator(t){this[l](t,t.keyEncoding);const e=this[u].iterator(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_keys(t){this[l](t,t.keyEncoding);const e=this[u].keys(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_values(t){this[l](t,t.keyEncoding);const e=this[u].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=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 b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=r?r.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="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,n)),n}}const m=function(t,e){let n=0,i=t.length;for(;nn&&t[i-1]===e;)i--;return t.slice(n,i)}},2520:(t,e)=>{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:{}}},4765:(t,e,n)=>{const{AbstractChainedBatch:i}=n(9464),r=n(4473),o=Symbol("encoded");e.DefaultChainedBatch=class extends i{constructor(t){super(t),this[o]=[]}_put(t,e,n){this[o].push({...n,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 r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},5429:(t,e,n)=>{const{AbstractKeyIterator:i,AbstractValueIterator:r}=n(3961),o=Symbol("iterator"),s=Symbol("callback"),a=Symbol("handleOne"),h=Symbol("handleMany");class c extends i{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}class l extends r{constructor(t,e){super(t,e),this[o]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}for(const t of[c,l]){const e=t===c,n=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,n,i){const r=this[s];t?r(t):r(null,e?n:i)},t.prototype._nextv=function(t,e,n){this[s]=n,this[o].nextv(t,e,this[h])},t.prototype._all=function(t,e){this[s]=e,this[o].all(t,this[h])},t.prototype[h]=function(t,e){const i=this[s];t?i(t):i(null,e.map(n))},t.prototype._seek=function(t,e){this[o].seek(t,e)},t.prototype._close=function(t){this[o].close(t)}}e.DefaultKeyIterator=c,e.DefaultValueIterator=l},593:(t,e,n)=>{const{AbstractIterator:i,AbstractKeyIterator:r,AbstractValueIterator:o}=n(3961),s=n(4473),a=Symbol("nut"),h=Symbol("undefer"),c=Symbol("factory");class l extends i{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.iterator(e),this.db.defer((()=>this[h]()))}}class u extends r{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.keys(e),this.db.defer((()=>this[h]()))}}class f extends o{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.values(e),this.db.defer((()=>this[h]()))}}for(const t of[l,u,f])t.prototype[h]=function(){"open"===this.db.status&&(this[a]=this[c]())},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,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,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=l,e.DeferredKeyIterator=u,e.DeferredValueIterator=f},6909:(t,e,n)=>{const i=n(4375);t.exports=function(t,...e){0===e.length?i(t):i((()=>t(...e)))}},56:(t,e,n)=>{const i=n(4473),r=Object.prototype.hasOwnProperty,o=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const s in t)if(r.call(t,s)&&"keyEncoding"!==s&&"valueEncoding"!==s){if("start"===s||"end"===s)throw new i(`The legacy range option '${s}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===s)throw new i("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});o.has(s)?n[s]=e.encode(t[s]):n[s]=t[s]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{e.byteLength=function(t){var e=a(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,o=a(t),s=o[0],h=o[1],c=new r(function(t,e,n){return 3*(e+n)/4-n}(0,s,h)),l=0,u=h>0?s-4:s;for(n=0;n>16&255,c[l++]=e>>8&255,c[l++]=255&e;return 2===h&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,c[l++]=255&e),1===h&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e),c},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,o=[],s=16383,a=0,c=i-r;ac?c:a+s));return 1===r?(e=t[i-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],i[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 n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function h(t,e,i){for(var r,o,s=[],a=e;a>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},1708:(t,e,n)=>{const{AbstractLevel:i}=n(875),r=n(4473),o=n(9967),{fromCallback:s}=n(6957),{Iterator:a}=n(8212),h=n(9687),c=n(9968),l=n(1217),u="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends i{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new r("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:i,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[p]=t,this[d]=null==i?u:i,this[y]=parseInt(o||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const i=this[g]("readonly");let o;try{o=i.get(t)}catch(t){return this.nextTick(n,t)}this[b](o,(function(t,e){return t?n(t):void 0===e?n(new r("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,h(e))}))}_getMany(t,e,n){const i=this[g]("readonly"),r=t.map((t=>e=>{let n;try{n=i.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:h(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));o(r,16,n)}_del(t,e,n){const i=this[g]("readwrite");let r;try{r=i.delete(t)}catch(t){return this.nextTick(n,t)}this[b](r,n)}_put(t,e,n,i){const r=this[g]("readwrite");let o;try{o=r.put(e,t)}catch(t){return this.nextTick(i,t)}this[b](o,i)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const i=this[g]("readwrite"),r=i.transaction;let o,s=0;r.onabort=function(){n(o||r.error||new Error("aborted by user"))},r.oncomplete=function(){n()},function e(){const n=t[s++],a=n.key;let h;try{h="del"===n.type?i.delete(a):i.put(n.value,a)}catch(t){return o=t,void r.abort()}s=0)return c(this,this[p],n,t,e);try{const t=this[g]("readwrite");i=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](i,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=u),n=s(n,E);const i=indexedDB.deleteDatabase(e+t);return i.onsuccess=function(){n()},i.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{const{AbstractIterator:i}=n(875),r=n(1217),o=n(9687),s=Symbol("cache"),a=Symbol("finished"),h=Symbol("options"),c=Symbol("currentOptions"),l=Symbol("position"),u=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends i{constructor(t,e,n){super(t,n),this[s]=[],this[a]=0===this.limit,this[h]=n,this[c]={...n},this[l]=void 0,this[u]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[s].length>0)return t=Math.min(t,this[s].length),this.nextTick(n,null,this[s].splice(0,t));let i;void 0!==this[l]&&(this[h].reverse?(this[c].lt=this[l],this[c].lte=void 0):(this[c].gt=this[l],this[c].gte=void 0));try{i=r(this[c])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[u]],"readonly"),y=d.objectStore(this[u]),g=[];if(this[h].reverse)y[!this[h].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](i,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:i}=n;this[l]=e,g.push([this[h].keys&&void 0!==e?o(e):void 0,this[h].values&&void 0!==i?o(i):void 0]),g.length{if(void 0===e||void 0===n)return;const i=Math.max(e.length,n.length);0===i||t===1/0?this[a]=!0:this[l]=e[i-1],g.length=i;for(let t=0;t{e=t.target.result,r()}:(e=[],this.nextTick(r)),this[h].values?y.getAll(i,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,r()}:(n=[],this.nextTick(r))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[s].length>0){const[e,n]=this[s].shift();this.nextTick(t,null,e,n)}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,n)=>{if(e)return t(e);this[s]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[s].splice(0,this[s].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(e,null,n);this._nextv(i,d,((t,i)=>{if(t)return e(t);n.length>0&&(i=n.concat(i)),e(null,i)}))}_seek(t,e){let n;this[f]=!0,this[s]=[],this[a]=!1,this[l]=void 0,this[c]={...this[h]};try{n=r(this[h])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[h].reverse?this[c].lte=t:this[c].gte=t:this[a]=!0}}},9968:t=>{t.exports=function(t,e,n,i,r){if(0===i.limit)return t.nextTick(r);const o=t.db.transaction([e],"readwrite"),s=o.objectStore(e);let a=0;o.oncomplete=function(){r()},o.onabort=function(){r(o.error||new Error("aborted by user"))};const h=s.openKeyCursor?"openKeyCursor":"openCursor",c=i.reverse?"prev":"next";s[h](n,c).onsuccess=function(t){const e=t.target.result;e&&(s.delete(e.key).onsuccess=function(){(i.limit<=0||++a{const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,i=void 0===t.gte,r=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,i,r):void 0!==e?IDBKeyRange.lowerBound(e,i):void 0!==n?IDBKeyRange.upperBound(n,r):null}},8764:(t,e,n)=>{const i=n(9742),r=n(645),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.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,h.prototype),e}function h(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return u(t)}return c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let i=a(n);const r=i.write(t,e);return r!==n&&(i=i.slice(0,r)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,n);const r=function(t){if(h.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(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 u(t){return l(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let i=0;i=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(r)return i?-1:q(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function b(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function E(t,e,n,i,r){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:m(t,e,n,i,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,i,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,i,r){let o,s=1,a=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,h/=2,n/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(r){let i=-1;for(o=n;oa&&(n=a-h),o=n;o>=0;o--){let n=!0;for(let i=0;ir&&(i=r):i=r;const o=e.length;let s;for(i>o/2&&(i=o/2),s=0;s>8,r=n%256,o.push(r),o.push(i);return o}(e,t.length-n),t,n,i)}function L(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const i=[];let r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+s<=n){let n,i,a,h;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[r+1],128==(192&n)&&(h=(31&e)<<6|63&n,h>127&&(o=h));break;case 3:n=t[r+1],i=t[r+2],128==(192&n)&&128==(192&i)&&(h=(15&e)<<12|(63&n)<<6|63&i,h>2047&&(h<55296||h>57343)&&(o=h));break;case 4:n=t[r+1],i=t[r+2],a=t[r+3],128==(192&n)&&128==(192&i)&&128==(192&a)&&(h=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&a,h>65535&&h<1114112&&(o=h))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),r+=s}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",i=0;for(;ii.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,r)):Uint8Array.prototype.set.call(i,e,r);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,r)}r+=e.length}return i},h.byteLength=y,h.prototype._isBuffer=!0,h.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;en&&(t+=" ... "),""},o&&(h.prototype[o]=h.prototype.inspect),h.prototype.compare=function(t,e,n,i,r){if(Y(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.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===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),e<0||n>t.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&e>=n)return 0;if(i>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(r>>>=0)-(i>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(o,s),c=this.slice(i,r),l=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-e;if((void 0===n||n>r)&&(n=r),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;ri)&&(n=i);let r="";for(let i=e;in)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,i,r,o){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function D(t,e,n,i,r){z(e,i,r,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function U(t,e,n,i,r){z(e,i,r,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function P(t,e,n,i,r,o){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function B(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}h.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t],r=1,o=0;for(;++o>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t+--e],r=1;for(;e>0&&(r*=256);)i+=this[t+--e]*r;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t],r=1,o=0;for(;++o=r&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let i=e,r=1,o=this[t+--i];for(;i>0&&(r*=256);)o+=this[t+--i]*r;return r*=128,o>=r&&(o-=Math.pow(2,8*e)),o},h.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||C(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||N(this,t,e,n,Math.pow(2,8*n)-1,0);let r=1,o=0;for(this[e]=255&t;++o>>=0,n>>>=0,i||N(this,t,e,n,Math.pow(2,8*n)-1,0);let r=n-1,o=1;for(this[e+r]=255&t;--r>=0&&(o*=256);)this[e+r]=t/o&255;return e+n},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}let r=0,o=1,s=0;for(this[e]=255&t;++r>0)-s&255;return e+n},h.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}let r=n-1,o=1,s=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===s&&0!==this[e+r+1]&&(s=1),this[e+r]=(t/o>>0)-s&255;return e+n},h.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},h.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},h.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},h.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},h.prototype.copy=function(t,e,n,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,i,r,o){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new F.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(i,r,o)}function G(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new F.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=V(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),i+=` It must be ${e}. Received ${r}`,i}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const i=t.length;let r=null;const o=[];for(let s=0;s55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(e-=3)>-1&&o.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function $(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,i){let r;for(r=0;r=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)e[i+r]=t[n]+t[r]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6957:(t,e,n)=>{var i=n(886);e.fromCallback=function(t,e){if(void 0===t){var n=new Promise((function(e,n){t=function(t,i){t?n(t):e(i)}}));t[void 0!==e?e:"promise"]=n}else if("function"!=typeof t)throw new TypeError("Callback must be a function");return t},e.fromPromise=function(t,e){if(void 0===e)return t;t.then((function(t){i((()=>e(null,t)))})).catch((function(t){i((()=>e(t)))}))}},886:t=>{t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t)},8840:(t,e)=>{function n(t){for(var e="",n=0;n0?"F"+s:"D"+n(s)},e.decode=function(t){if("DaN"===t)return NaN;if("FF"===t)return 1/0;if("DD"===t)return-1/0;var e="D"===t[0],i=(e?n(t):t).slice(2).split("M");return Number((e?"-":"")+i[1]+"e"+String(Number(i[0])-500))}},2833:(t,e)=>{var n={"?":"?@","!":"??",'"':"?%"},i={"?@":"?","??":"!","?%":'"'};e.factory=function(t){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,r=e.split('"'),o=[[]],s=0,a=r.length,h=0;h{var i=n(8840),r=n(2833);e.flip=function(t){var e=t.toString(),n="";for(var i in e)n+="."==e[i]?".":9-+e[i];return n},e.number=i,e.string={encode:function(t){return/\x00|\x01/.test(t)?"J"+t.replace(/\x01/g,"").replace(/\x00/g,""):"J"+t},decode:function(t){if("J"===t[0])return t.substring(1)}},e.encode=function(t){return e[typeof t].encode(t)},e.decode=function(t){if(""===t)return t;if(!o[t[0]])throw new Error("no decoder for:"+JSON.stringify(t));return o[t[0]](t)},e.object=r.factory(e),e.boolean={encode:function(t){return t?"C":"B"},decode:function(t){return"C"===t}},e.undefined={encode:function(t){return"L"},decode:function(){}};var o={A:e.object.decode,B:e.boolean.decode,C:e.boolean.decode,D:e.number.decode,F:e.number.decode,J:e.string.decode,K:e.object.decode,L:e.undefined.decode};e.buffer=!1,e.type="charwise"},6729:t=>{var e=Object.prototype.hasOwnProperty,n="~";function i(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function o(t,e,i,o,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new r(i,o||t,s),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,o=i.length,s=new Array(o);r{var e,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var r=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(n,i){function r(n){t.removeListener(e,o),i(n)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,r)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,n,i){var r,o,s,c;if(a(n),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),o=t._events),s=o[e]),void 0===s)s=o[e]=n,++t._eventsCount;else if("function"==typeof s?s=o[e]=i?[n,s]:[s,n]:i?s.unshift(n):s.push(n),(r=h(t))>0&&s.length>r&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,c=l,console&&console.warn&&console.warn(c)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function u(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=l.bind(i);return r.listener=n,i.wrapFn=r,r}function f(t,e,n){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var h=o[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var c=h.length,l=p(h,c);for(n=0;n=0;o--)if(n[o]===e||n[o].listener===e){s=n[o].listener,r=o;break}if(r<0)return this;0===r?n.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},o.prototype.listeners=function(t){return f(this,t,!0)},o.prototype.rawListeners=function(t){return f(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},o.prototype.listenerCount=d,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9203:(t,e,n)=>{const i=n(7270),{BrowserLevel:r}=n(1708);t.exports=({name:t="fii",...e})=>i({db:new r(t),...e})},7270:(t,e,n)=>{const i=n(9563),r=n(8936),o=n(1387),s=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELDe.FIELD?1:t.VALUEe.VALUE?1:t.SCOREe.SCORE?1:0)),t))),a=t=>{const e=i(t),n=r(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(s),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(s),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:o,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(s),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(s),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const i=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;i.open((r=>r?n(r):e(Object.assign(t,{_db:i}))))})))(t).then(a)},1387:(t,e,n)=>{const i=n(2483);t.exports={keyEncoding:i,valueEncoding:"json"}},6782:t=>{const e=null,n=void 0;t.exports=(t,i)=>new Promise(((r,o)=>{if(Array.isArray(t))return o(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return r({FIELD:i,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return r({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?r(Object.assign(t,{FIELD:i})):(t.FIELD=[t.FIELD].flat(),r(t))}))},9563:(t,e,n)=>{const i=n(6782),r=n(2483),{EntryStream:o}=n(6741),s=n(1387);r.LO=null,r.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>i(t,await u()),a=async(e,i=(t=>new Promise((e=>e(t)))))=>new Promise((async(r,o)=>{const s=t=>void 0===t?r(void 0):t instanceof Promise?r(t):void 0;try{s(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),s(e=await(e=>void 0===e?l(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?h(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),s(e=await i(e))}catch(t){return o(t)}return Array.isArray(e)?r(e):r(l(e))})),h=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),c=(t,e,n)=>{const i=[];return void 0===e&&"number"!=typeof e||i.push(e),n&&i.push(r.HI),["IDX",t,i]},l=e=>new Promise((n=>{if(void 0===e)return n(void 0);const i=new Map;return Promise.all(e.FIELD.map((n=>new Promise((r=>new o(t._db,{gte:c(n,e.VALUE.GTE),lte:c(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...s}).on("data",(t=>t.value.forEach((e=>i.set(e,[...i.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",r)))))).then((()=>n(Array.from(i.keys()).map((t=>({_id:t,_match:i.get(t)}))))))})),u=()=>new Promise((e=>{const n=[];new o(t._db,{gte:["FIELD",r.LO],lte:["FIELD",r.HI],...s}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,i)=>{const r=[];new o(t._db,{...e,...s}).on("data",(t=>{r.push(t)})).on("end",(()=>n(r)))})),y=(t,e)=>n(t).then((t=>l(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let i=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(i+=" "),p({gte:c(e,i),lte:c(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:c(e,t.VALUE.GTE),lte:c(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],s),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],s).catch((t=>null))))).then((t=>t.reduce(((t,n,i)=>(null!=n&&t.push(e[i]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:u,GET:a,INTERSECTION:(t,e)=>h(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],s),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],s).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:h,parseToken:n}}},8936:(t,e,n)=>{const i=n(3692),r=n(9563),o=n(1387);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const r=[];return i(e._object).forEach((function(e){const i=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==i&&!n.doNotIndexField.filter((t=>i.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([i,[this.node].flat(1/0)]);r.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:r}},s=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(i,a,h,c,l)=>new Promise((u=>{i=i.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),l=Object.assign(t,l),r(t).EXIST(...i.map((t=>t._id))).then((t=>((t,e,n)=>{const i=Object.keys(t);return Promise.all(i.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,i)=>e.get(t,o).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,r)=>{const o=new Set(e),s=new Set(t[i[r]]);if("put"===n)return{key:["IDX",...JSON.parse(i[r])],type:n,value:[...new Set([...o,...s])].sort()};if("del"===n){const t=[...new Set([...o].filter((t=>!s.has(t))))];return{key:["IDX",...JSON.parse(i[r])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(s,{}))(i,l),a,h).then((e=>a.batch(e.concat(l.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(i,h):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),o,(e=>u(i.map((e=>{let n;return"put"===h?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===h&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:c,status:n}})))))))))})),h=e=>t._db.put(["~LAST_UPDATED"],Date.now(),o).then((()=>e));return{DELETE:e=>r(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(h),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),o))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(h),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],o).then().catch((e=>t._db.put(["~CREATED"],Date.now(),o).then(h))),TIMESTAMP_LAST_UPDATED:h}}},645:(t,e)=>{e.read=function(t,e,n,i,r){var o,s,a=8*r-i-1,h=(1<>1,l=-7,u=n?r-1:0,f=n?-1:1,d=t[e+u];for(u+=f,o=d&(1<<-l)-1,d>>=-l,l+=a;l>0;o=256*o+t[e+u],u+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=i;l>0;s=256*s+t[e+u],u+=f,l-=8);if(0===o)o=1-c;else{if(o===h)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,i),o-=c}return(d?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,n,i,r,o){var s,a,h,c=8*o-r-1,l=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:o-1,p=i?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-s))<1&&(s--,h*=2),(e+=s+u>=1?f/h:f*Math.pow(2,1-u))*h>=2&&(s++,h/=2),s+u>=l?(a=0,s=l):s+u>=1?(a=(e*h-1)*Math.pow(2,r),s+=u):(a=e*Math.pow(2,u-1)*Math.pow(2,r),s=0));r>=8;t[n+d]=255&a,d+=p,a/=256,r-=8);for(s=s<0;t[n+d]=255&s,d+=p,s/=256,c-=8);t[n+d-p]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},6741:(t,e,n)=>{const{Readable:i}=n(8473),r=Symbol("iterator"),o=Symbol("nextv");class s extends i{constructor(t,e,n){const{highWaterMark:i,...s}=n||{};super({objectMode:!0,highWaterMark:i||1e3}),this[r]=t[e](s),this[o]=this[o].bind(this),this.once("end",this.destroy.bind(this,null,null))}get db(){return this[r].db}_read(t){this.destroyed||this[r].nextv(t,this[o])}[o](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const t of e)this.push(t)}}_destroy(t,e){this[r].close((function(n){e(t||n)}))}}e.EntryStream=class extends s{constructor(t,e){super(t,"iterator",{...e,keys:!0,values:!0})}[o](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const[t,n]of e)this.push({key:t,value:n})}}},e.KeyStream=class extends s{constructor(t,e){super(t,"keys",e)}},e.ValueStream=class extends s{constructor(t,e){super(t,"values",e)}}},8499:(t,e,n)=>{const i=n(4473),r=n(8002),{Encoding:o}=n(8266),{BufferFormat:s,ViewFormat:a,UTF8Format:h}=n(2376),c=Symbol("formats"),l=Symbol("encodings"),u=new Set(["buffer","view","utf8"]);e.Transcoder=class{constructor(t){if(!Array.isArray(t))throw new TypeError("The first argument 'formats' must be an array");if(!t.every((t=>u.has(t))))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[l]=new Map,this[c]=new Set(t);for(const t in r)try{this.encoding(t)}catch(t){if("LEVEL_ENCODING_NOT_SUPPORTED"!==t.code)throw t}}encodings(){return Array.from(new Set(this[l].values()))}encoding(t){let e=this[l].get(t);if(void 0===e){if("string"==typeof t&&""!==t){if(e=d[t],!e)throw new i(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if("object"!=typeof t||null===t)throw new TypeError("First argument 'encoding' must be a string or object");e=function(t){if(t instanceof o)return t;const e="type"in t&&"string"==typeof t.type?t.type:void 0,n=t.name||e||"anonymous-"+p++;switch(function(t){return"format"in t&&void 0!==t.format?t.format:"buffer"in t&&"boolean"==typeof t.buffer?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}(t)){case"view":return new a({...t,name:n});case"utf8":return new h({...t,name:n});case"buffer":return new s({...t,name:n});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}(t)}const{name:n,format:r}=e;if(!this[c].has(r))if(this[c].has("view"))e=e.createViewTranscoder();else if(this[c].has("buffer"))e=e.createBufferTranscoder();else{if(!this[c].has("utf8"))throw new i(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});e=e.createUTF8Transcoder()}for(const i of[t,n,e.name,e.commonName])this[l].set(i,e)}return e}};const f={binary:r.buffer,"utf-8":r.utf8},d={...r,...f};let p=0},8266:(t,e,n)=>{const i=n(4473),r=new Set(["buffer","view","utf8"]);e.Encoding=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,"function"!=typeof this.encode)throw new TypeError("The 'encode' property must be a function");if("function"!=typeof this.decode)throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),"string"!=typeof this.name||""===this.name)throw new TypeError("The 'name' property must be a string");if("string"!=typeof this.format||!r.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}},8002:(t,e,n)=>{const{Buffer:i}=n(8764)||{Buffer:{isBuffer:()=>!1}},{textEncoder:r,textDecoder:o}=n(4005)(),{BufferFormat:s,ViewFormat:a,UTF8Format:h}=n(2376),c=t=>t;e.utf8=new h({encode:function(t){return i.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?o.decode(t):String(t)},decode:c,name:"utf8",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.encode(t)},decode:function(t){return o.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new s({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}}),e.json=new h({encode:JSON.stringify,decode:JSON.parse,name:"json"}),e.buffer=new s({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:c,name:"buffer",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.from(String(t),"utf8")},decode:function(t){return i.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}}),e.view=new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.encode(t)},decode:c,name:"view",createBufferTranscoder(){return new s({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:c,name:`${this.name}+buffer`})}}),e.hex=new s({encode:function(t){return i.isBuffer(t)?t:i.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"}),e.base64=new s({encode:function(t){return i.isBuffer(t)?t:i.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})},2376:(t,e,n)=>{const{Buffer:i}=n(8764)||{},{Encoding:r}=n(8266),o=n(4005);class s extends r{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:t=>this.decode(i.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class a extends r{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new s({encode:t=>{const e=this.encode(t);return i.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}e.BufferFormat=s,e.ViewFormat=a,e.UTF8Format=class extends r{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new s({encode:t=>i.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){const{textEncoder:t,textDecoder:e}=o();return new a({encode:e=>t.encode(this.encode(e)),decode:t=>this.decode(e.decode(t)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}},4005:t=>{let e=null;t.exports=function(){return null===e&&(e={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),e}},4473:t=>{t.exports=class extends Error{constructor(t,e){super(t||""),"object"==typeof e&&null!==e&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}},6349:function(t,e){!function(t){const e=function(t,e){return t.slice(e-1).map(((n,i)=>t.slice(i,i+e)))};t.ngraminator=function(t,n){return n.reduce(((n,i)=>[...e(t,i),...n]),[]).sort()},Object.defineProperty(t,"__esModule",{value:!0})}(e)},4155:t=>{var e,n,i=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===r||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:r}catch(t){e=r}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(t){n=o}}();var a,h=[],c=!1,l=-1;function u(){c&&a&&(c=!1,a.length?h=a.concat(h):l=-1,h.length&&f())}function f(){if(!c){var t=s(u);c=!0;for(var e=h.length;e;){for(a=h,h=[];++l1)for(var n=1;n{let i;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:n.g):t=>(i||(i=Promise.resolve())).then(t).catch((t=>setTimeout((()=>{throw t}),0)))},4281:t=>{var e={};function n(t,n,i){i||(i=Error);var r=function(t){var e,i;function r(e,i,r){return t.call(this,function(t,e,i){return"string"==typeof n?n:n(t,e,i)}(e,i,r))||this}return i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i,r}(i);r.prototype.name=i.name,r.prototype.code=t,e[t]=r}function i(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(t){return String(t)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:2===n?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}n("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(t,e,n){var r,o,s,a,h;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(r="must not be",e=e.replace(/^not /,"")):r="must be",function(t,e,n){return(void 0===n||n>t.length)&&(n=t.length),t.substring(n-9,n)===e}(t," argument"))s="The ".concat(t," ").concat(r," ").concat(i(e,"type"));else{var c=("number"!=typeof h&&(h=0),h+1>(a=t).length||-1===a.indexOf(".",h)?"argument":"property");s='The "'.concat(t,'" ').concat(c," ").concat(r," ").concat(i(e,"type"))}return s+". Received type ".concat(typeof n)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},6753:(t,e,n)=>{var i=n(4155),r=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=l;var o=n(9481),s=n(4229);n(5717)(l,o);for(var a=r(s.prototype),h=0;h{t.exports=r;var i=n(4605);function r(t){if(!(this instanceof r))return new r(t);i.call(this,t)}n(5717)(r,i),r.prototype._transform=function(t,e,n){n(null,t)}},9481:(t,e,n)=>{var i,r=n(4155);t.exports=L,L.ReadableState=S,n(7187).EventEmitter;var o,s=function(t,e){return t.listeners(e).length},a=n(2503),h=n(8764).Buffer,c=n.g.Uint8Array||function(){},l=n(4616);o=l&&l.debuglog?l.debuglog("stream"):function(){};var u,f,d,p=n(7327),y=n(1195),g=n(2457).getHighWaterMark,b=n(4281).q,E=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(5717)(L,a);var _=y.errorOrDestroy,T=["error","close","destroy","pause","resume"];function S(t,e,r){i=i||n(6753),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",r),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(u||(u=n(2553).s),this.decoder=new u(t.encoding),this.encoding=t.encoding)}function L(t){if(i=i||n(6753),!(this instanceof L))return new L(t);var e=this instanceof i;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function O(t,e,n,i,r){o("readableAddChunk",e);var s,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?R(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,a);else if(r||(s=function(t,e){var n,i;return i=e,h.isBuffer(i)||i instanceof c||"string"==typeof e||void 0===e||t.objectMode||(n=new E("chunk",["string","Buffer","Uint8Array"],e)),n}(a,e)),s)_(t,s);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===h.prototype||(e=function(t){return h.from(t)}(e)),i)a.endEmitted?_(t,new w):A(t,a,e,!0);else if(a.ended)_(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(e=a.decoder.write(e),a.objectMode||0!==e.length?A(t,a,e,!1):C(t,a)):A(t,a,e,!1)}else i||(a.reading=!1,C(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=k?t=k:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function R(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(I,t))}function I(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function U(t){o("readable nexttick read 0"),t.read(0)}function P(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function B(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function F(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(j,e,t))}function j(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function V(t,e){for(var n=0,i=t.length;n=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):R(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&F(this),null;var i,r=e.needReadable;return o("need readable",r),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&F(this)),null!==i&&this.emit("data",i),i},L.prototype._read=function(t){_(this,new v("_read()"))},L.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,o("pipe count=%d opts=%j",i.pipesCount,e);var a=e&&!1===e.end||t===r.stdout||t===r.stderr?y:h;function h(){o("onend"),t.end()}i.endEmitted?r.nextTick(a):n.once("end",a),t.on("unpipe",(function e(r,s){o("onunpipe"),r===n&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,o("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",c),t.removeListener("error",f),t.removeListener("unpipe",e),n.removeListener("end",h),n.removeListener("end",y),n.removeListener("data",u),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",c);var l=!1;function u(e){o("ondata");var r=t.write(e);o("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==V(i.pipes,t))&&!l&&(o("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function f(e){o("onerror",e),y(),t.removeListener("error",f),0===s(t,"error")&&_(t,e)}function d(){t.removeListener("finish",p),y()}function p(){o("onfinish"),t.removeListener("close",d),y()}function y(){o("unpipe"),n.unpipe(t)}return n.on("data",u),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),i.flowing||(o("pipe resume"),n.resume()),t},L.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var i=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,o("on readable",i.length,i.reading),i.length?R(this):i.reading||r.nextTick(U,this))),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(t,e){var n=a.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(D,this),n},L.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(D,this),e},L.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(P,t,e))}(this,t)),t.paused=!1,this},L.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},L.prototype.wrap=function(t){var e=this,n=this._readableState,i=!1;for(var r in t.on("end",(function(){if(o("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(r){o("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r||(n.objectMode||r&&r.length)&&(e.push(r)||(i=!0,t.pause()))})),t)void 0===this[r]&&"function"==typeof t[r]&&(this[r]=function(e){return function(){return t[e].apply(t,arguments)}}(r));for(var s=0;s{t.exports=l;var i=n(4281).q,r=i.ERR_METHOD_NOT_IMPLEMENTED,o=i.ERR_MULTIPLE_CALLBACK,s=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,h=n(6753);function c(t,e){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(null===i)return this.emit("error",new o);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),i(t);var r=this._readableState;r.reading=!1,(r.needReadable||r.length{var i,r=n(4155);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var i=t.entry;for(t.entry=null;i;){var r=i.callback;e.pendingcb--,r(undefined),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=L,L.WritableState=S;var s,a={deprecate:n(4927)},h=n(2503),c=n(8764).Buffer,l=n.g.Uint8Array||function(){},u=n(1195),f=n(2457).getHighWaterMark,d=n(4281).q,p=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,E=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,_=u.errorOrDestroy;function T(){}function S(t,e,s){i=i||n(6753),t=t||{},"boolean"!=typeof s&&(s=e instanceof i),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=f(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,i=n.sync,o=n.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,o){--e.pendingcb,n?(r.nextTick(o,i),r.nextTick(I,t,e),t._writableState.errorEmitted=!0,_(t,i)):(o(i),t._writableState.errorEmitted=!0,_(t,i),I(t,e))}(t,n,i,e,o);else{var s=x(n)||t.destroyed;s||n.corked||n.bufferProcessing||!n.bufferedRequest||k(t,n),i?r.nextTick(A,t,n,s,o):A(t,n,s,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function L(t){var e=this instanceof(i=i||n(6753));if(!e&&!s.call(L,this))return new L(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function O(t,e,n,i,r,o,s){e.writelen=i,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new E("write")):n?t._writev(r,e.onwrite):t._write(r,o,e.onwrite),e.sync=!1}function A(t,e,n,i){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,i(),I(t,e)}function k(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var i=e.bufferedRequestCount,r=new Array(i),s=e.corkedRequestsFree;s.entry=n;for(var a=0,h=!0;n;)r[a]=n,n.isBuf||(h=!1),n=n.next,a+=1;r.allBuffers=h,O(t,e,!0,e.length,r,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,u=n.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,l,u),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(n){e.pendingcb--,n&&_(t,n),e.prefinished=!0,t.emit("prefinish"),I(t,e)}))}function I(t,e){var n=x(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(5717)(L,h),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===L&&t&&t._writableState instanceof S}})):s=function(t){return t instanceof this},L.prototype.pipe=function(){_(this,new b)},L.prototype.write=function(t,e,n){var i,o=this._writableState,s=!1,a=!o.objectMode&&(i=t,c.isBuffer(i)||i instanceof l);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof n&&(n=T),o.ending?function(t,e){var n=new v;_(t,n),r.nextTick(e,n)}(this,n):(a||function(t,e,n,i){var o;return null===n?o=new m:"string"==typeof n||e.objectMode||(o=new p("chunk",["string","Buffer"],n)),!o||(_(t,o),r.nextTick(i,o),!1)}(this,o,t,n))&&(o.pendingcb++,s=function(t,e,n,i,r,o){if(!n){var s=function(t,e,n){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,n)),e}(e,i,r);i!==s&&(n=!0,r="buffer",i=s)}var a=e.objectMode?1:i.length;e.length+=a;var h=e.length-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),L.prototype._write=function(t,e,n){n(new y("_write()"))},L.prototype._writev=null,L.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,I(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),L.prototype.destroy=u.destroy,L.prototype._undestroy=u.undestroy,L.prototype._destroy=function(t,e){e(t)}},5850:(t,e,n)=>{var i,r=n(4155);function o(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var s=n(8610),a=Symbol("lastResolve"),h=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),u=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function p(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var n=t[d].read();null!==n&&(t[u]=null,t[a]=null,t[h]=null,e(p(n,!1)))}}function g(t){r.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),E=Object.setPrototypeOf((o(i={get stream(){return this[d]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[l])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise((function(e,n){r.nextTick((function(){t[c]?n(t[c]):e(p(void 0,!0))}))}));var n,i=this[u];if(i)n=new Promise(function(t,e){return function(n,i){t.then((function(){e[l]?n(p(void 0,!0)):e[f](n,i)}),i)}}(i,this));else{var o=this[d].read();if(null!==o)return Promise.resolve(p(o,!1));n=new Promise(this[f])}return this[u]=n,n}},Symbol.asyncIterator,(function(){return this})),o(i,"return",(function(){var t=this;return new Promise((function(e,n){t[d].destroy(null,(function(t){t?n(t):e(p(void 0,!0))}))}))})),i),b);t.exports=function(t){var e,n=Object.create(E,(o(e={},d,{value:t,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,h,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,l,{value:t._readableState.endEmitted,writable:!0}),o(e,f,{value:function(t,e){var i=n[d].read();i?(n[u]=null,n[a]=null,n[h]=null,t(p(i,!1))):(n[a]=t,n[h]=e)},writable:!0}),e));return n[u]=null,s(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[h];return null!==e&&(n[u]=null,n[a]=null,n[h]=null,e(t)),void(n[c]=t)}var i=n[a];null!==i&&(n[u]=null,n[a]=null,n[h]=null,i(p(void 0,!0))),n[l]=!0})),t.on("readable",g.bind(null,n)),n}},7327:(t,e,n)=>{function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function o(t,e){for(var n=0;n0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n}},{key:"concat",value:function(t){if(0===this.length)return s.alloc(0);for(var e,n,i,r=s.allocUnsafe(t>>>0),o=this.head,a=0;o;)e=o.data,n=r,i=a,s.prototype.copy.call(e,n,i),a+=o.data.length,o=o.next;return r}},{key:"consume",value:function(t,e){var n;return tr.length?r.length:t;if(o===r.length?i+=r:i+=r.slice(0,t),0==(t-=o)){o===r.length?(++n,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=r.slice(o));break}++n}return this.length-=n,i}},{key:"_getBuffer",value:function(t){var e=s.allocUnsafe(t),n=this.head,i=1;for(n.data.copy(e),t-=n.data.length;n=n.next;){var r=n.data,o=t>r.length?r.length:t;if(r.copy(e,e.length-t,0,o),0==(t-=o)){o===r.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=r.slice(o));break}++i}return this.length-=i,e}},{key:h,value:function(t,e){return a(this,function(t){for(var e=1;e{var i=n(4155);function r(t,e){s(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(s,this,t)):i.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted?i.nextTick(o,n):(n._writableState.errorEmitted=!0,i.nextTick(r,n,t)):i.nextTick(r,n,t):e?(i.nextTick(o,n),e(t)):i.nextTick(o,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,i=t._writableState;n&&n.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}}},8610:(t,e,n)=>{var i=n(4281).q.ERR_STREAM_PREMATURE_CLOSE;function r(){}t.exports=function t(e,n,o){if("function"==typeof n)return t(e,null,n);n||(n={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var n=arguments.length,i=new Array(n),r=0;r{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9946:(t,e,n)=>{var i,r=n(4281).q,o=r.ERR_MISSING_ARGS,s=r.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function h(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),r=0;r0,(function(t){l||(l=t),t&&f.forEach(h),o||(f.forEach(h),u(l))}))}));return e.reduce(c)}},2457:(t,e,n)=>{var i=n(4281).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,r){var o=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,r,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new i(r?n:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},2503:(t,e,n)=>{t.exports=n(7187).EventEmitter},8473:(t,e,n)=>{(e=t.exports=n(9481)).Stream=e,e.Readable=e,e.Writable=n(4229),e.Duplex=n(6753),e.Transform=n(4605),e.PassThrough=n(2725),e.finished=n(8610),e.pipeline=n(9946)},9967:(t,e,n)=>{t.exports=function(t,e,n){if("number"!=typeof e)throw new Error("second argument must be a Number");let r,o,s,a,h,c,l=!0;function u(t){function e(){n&&n(t,r),n=null}l?i(e):e()}function f(e,n,i){if(r[e]=i,n&&(h=!0),0==--s||n)u(n);else if(!h&&c{var i=n(396).Buffer,r=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=u,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function l(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function u(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.s=o,o.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(r>0&&(t.lastNeed=r-1),r):--i=0?(r>0&&(t.lastNeed=r-2),r):--i=0?(r>0&&(2===r?r=0:t.lastNeed=r-3),r):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var i=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},396:(t,e,n)=>{var i=n(8764),r=i.Buffer;function o(t,e){for(var n in t)e[n]=t[n]}function s(t,e,n){return r(t,e,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=i:(o(i,e),e.Buffer=s),s.prototype=Object.create(r.prototype),o(r,s),s.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return r(t,e,n)},s.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=r(t);return void 0!==e?"string"==typeof n?i.fill(e,n):i.fill(e):i.fill(0),i},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},971:t=>{t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const n=t.reduce(((t,n,i,r)=>(e.ngramLengths.forEach((e=>{var o=r.slice(i,i+e);o.length===e&&(n=JSON.stringify(o),t[n]=t[n]||[],t[n].push(i))})),t)),{});return Object.keys(n).map((t=>({term:JSON.parse(t),positions:n[t]}))).sort(((t,e)=>t.term[0]>e.term[0]))}},3692:t=>{function e(t){return Object.prototype.toString.call(t)}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n{function i(t){try{if(!n.g.localStorage)return!1}catch(t){return!1}var e=n.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(i("noDeprecation"))return t;var n=!1;return function(){if(!n){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}},2361:()=>{},4616:()=>{}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i={};(()=>{n.d(i,{W:()=>ft});var t=n(6729);class e extends Error{constructor(t){super(t),this.name="TimeoutError"}}class r extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const o=t=>void 0===globalThis.DOMException?new r(t):new DOMException(t),s=t=>{const e=void 0===t.reason?o("This operation was aborted."):t.reason;return e instanceof Error?e:o(e)};var a,h=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class c{constructor(){a.set(this,[])}enqueue(t,e){const n={priority:(e={priority:0,...e}).priority,run:t};if(this.size&&h(this,a,"f")[this.size-1].priority>=e.priority)return void h(this,a,"f").push(n);const i=function(t,e,n){let i=0,r=t.length;for(;r>0;){const n=Math.trunc(r/2);let s=i+n;o=t[s],e.priority-o.priority<=0?(i=++s,r-=n+1):r=n}var o;return i}(h(this,a,"f"),n);h(this,a,"f").splice(i,0,n)}dequeue(){const t=h(this,a,"f").shift();return null==t?void 0:t.run}filter(t){return h(this,a,"f").filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return h(this,a,"f").length}}a=new WeakMap;var l,u,f,d,p,y,g,b,E,m,v,w,_,T,S,L,O,A,k,x,R,I,C,N,D,U,P=function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},M=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class B extends Error{}class F extends t{constructor(t){var e,n,i,r;if(super(),l.add(this),u.set(this,void 0),f.set(this,void 0),d.set(this,0),p.set(this,void 0),y.set(this,void 0),g.set(this,0),b.set(this,void 0),E.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,0),_.set(this,void 0),T.set(this,void 0),S.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:c,...t}).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(r=null===(i=t.interval)||void 0===i?void 0:i.toString())&&void 0!==r?r:""}\` (${typeof t.interval})`);P(this,u,t.carryoverConcurrencyCount,"f"),P(this,f,t.intervalCap===Number.POSITIVE_INFINITY||0===t.interval,"f"),P(this,p,t.intervalCap,"f"),P(this,y,t.interval,"f"),P(this,m,new t.queueClass,"f"),P(this,v,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,P(this,S,!0===t.throwOnTimeout,"f"),P(this,T,!1===t.autoStart,"f")}get concurrency(){return M(this,_,"f")}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);P(this,_,t,"f"),M(this,l,"m",N).call(this)}async add(t,n={}){return n={timeout:this.timeout,throwOnTimeout:M(this,S,"f"),...n},new Promise(((i,r)=>{M(this,m,"f").enqueue((async()=>{var o,a,h;P(this,w,(a=M(this,w,"f"),++a),"f"),P(this,d,(h=M(this,d,"f"),++h),"f");try{if(null===(o=n.signal)||void 0===o?void 0:o.aborted)throw new B("The task was aborted.");let r=t({signal:n.signal});n.timeout&&(r=function(t,n,i,r){let o;const a=new Promise(((a,h)=>{if("number"!=typeof n||1!==Math.sign(n))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(n!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:t}=r;t.aborted&&h(s(t)),t.addEventListener("abort",(()=>{h(s(t))}))}o=r.customTimers.setTimeout.call(void 0,(()=>{const r=i instanceof Error?i:new e(`Promise timed out after ${n} milliseconds`);"function"==typeof t.cancel&&t.cancel(),h(r)}),n),(async()=>{try{a(await t)}catch(t){h(t)}finally{r.customTimers.clearTimeout.call(void 0,o)}})()}else a(t)}));return a.clear=()=>{clearTimeout(o),o=void 0},a}(Promise.resolve(r),n.timeout)),n.signal&&(r=Promise.race([r,M(this,l,"m",D).call(this,n.signal)]));const a=await r;i(a),this.emit("completed",a)}catch(t){if(t instanceof e&&!n.throwOnTimeout)return void i();r(t),this.emit("error",t)}finally{M(this,l,"m",A).call(this)}}),n),this.emit("add"),M(this,l,"m",R).call(this)}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return M(this,T,"f")?(P(this,T,!1,"f"),M(this,l,"m",N).call(this),this):this}pause(){P(this,T,!0,"f")}clear(){P(this,m,new(M(this,v,"f")),"f")}async onEmpty(){0!==M(this,m,"f").size&&await M(this,l,"m",U).call(this,"empty")}async onSizeLessThan(t){M(this,m,"f").sizeM(this,m,"f").size{M(this,l,"m",k).call(this)}),e),"f"),!0;P(this,d,M(this,u,"f")?M(this,w,"f"):0,"f")}return!1},R=function(){if(0===M(this,m,"f").size)return M(this,b,"f")&&clearInterval(M(this,b,"f")),P(this,b,void 0,"f"),this.emit("empty"),0===M(this,w,"f")&&this.emit("idle"),!1;if(!M(this,T,"f")){const t=!M(this,l,"a",x);if(M(this,l,"a",L)&&M(this,l,"a",O)){const e=M(this,m,"f").dequeue();return!!e&&(this.emit("active"),e(),t&&M(this,l,"m",I).call(this),!0)}}return!1},I=function(){M(this,f,"f")||void 0!==M(this,b,"f")||(P(this,b,setInterval((()=>{M(this,l,"m",C).call(this)}),M(this,y,"f")),"f"),P(this,g,Date.now()+M(this,y,"f"),"f"))},C=function(){0===M(this,d,"f")&&0===M(this,w,"f")&&M(this,b,"f")&&(clearInterval(M(this,b,"f")),P(this,b,void 0,"f")),P(this,d,M(this,u,"f")?M(this,w,"f"):0,"f"),M(this,l,"m",N).call(this)},N=function(){for(;M(this,l,"m",R).call(this););},D=async function(t){return new Promise(((e,n)=>{t.addEventListener("abort",(()=>{n(new B("The task was aborted."))}),{once:!0})}))},U=async function(t,e){return new Promise((n=>{const i=()=>{e&&!e()||(this.off(t,i),n())};this.on(t,i)}))};var j=n(6741);class V{constructor(t,e){const n=e=>new Promise(((n,i)=>{const r=[];new j.EntryStream(t.fii.STORE,{gte:["DOC_RAW",null],lte:["DOC_RAW",void 0],limit:e,...t.fii.LEVEL_OPTIONS}).on("data",(t=>r.push({_id:t.value._id,_doc:t.value}))).on("end",(()=>n(r)))})),i=(...e)=>e.length?Promise.all(e.map((e=>t.fii.STORE.get(["DOC_RAW",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))):n(),r=(...e)=>t.fii.DISTINCT(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),o=(...e)=>t.fii.FACETS(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),s=(t,e)=>{const n=(e=Object.assign({NUMBER:0,SIZE:20},e||{})).NUMBER*e.SIZE,i=n+e.SIZE||void 0;return t.slice(n,i)},a=(t,e={})=>{e=Object.assign({TYPE:"TFIDF"},e);const n=t=>!e.FIELDS||e.FIELDS.includes(t.FIELD),i=t=>(t||[]).filter(n);return new Promise((r=>r("TFIDF"===e.TYPE?c().then((e=>t.map(((t,i,r)=>{const o=Math.log((e+1)/r.length);return t._score=+(t._match||[]).filter(n).reduce(((t,e)=>t+o*+e.SCORE),0).toFixed(2),t})))):"PRODUCT"===e.TYPE?t.map((t=>({...t,_score:+i(t._match).reduce(((t,e)=>t*+e.SCORE),1).toFixed(2)}))):"CONCAT"===e.TYPE?t.map((t=>({...t,_score:i(t._match).reduce(((t,e)=>t+e.SCORE),"")}))):"SUM"===e.TYPE?t.map((t=>({...t,_score:+i(t._match).reduce(((t,e)=>t+ +e.SCORE),0).toFixed(2)}))):"VALUE"===e.TYPE?t.map((t=>({...t,_score:i(t._match).reduce(((t,e)=>t+e.VALUE),"")}))):null)))},h=(t,e)=>(e=Object.assign({DIRECTION:"DESCENDING",TYPE:"NUMERIC"},e||{}),t.sort(((t,e)=>t._ide._id?1:0)).sort({NUMERIC:{DESCENDING:(t,e)=>+e._score-+t._score,ASCENDING:(t,e)=>+t._score-+e._score},ALPHABETIC:{DESCENDING:(t,e)=>t._scoree._score?-1:0,ASCENDING:(t,e)=>t._scoree._score?1:0}}[e.TYPE][e.DIRECTION])),c=()=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS),l=(e,r={})=>{const c=e=>"string"==typeof e||"number"==typeof e?t.fii.GET(e,r.PIPELINE):e.FIELD||e.VALUE?t.fii.GET(e):e.AND?t.fii.AND(e.AND.map(c),r.PIPELINE):e.GET?t.fii.GET(e.GET,r.PIPELINE):e.NOT?t.fii.NOT(c(e.NOT.INCLUDE),c(e.NOT.EXCLUDE)):e.OR?t.fii.OR(e.OR.map(c),r.PIPELINE):e.ALL_DOCUMENTS?n(e.ALL_DOCUMENTS):void 0;return c(e).then((t=>t.RESULT?Object.assign(t,{RESULT_LENGTH:t.RESULT.length}):{RESULT:t,RESULT_LENGTH:t.length})).then((e=>r.BUCKETS?t.fii.BUCKETS(...r.BUCKETS).then((n=>Object.assign(e,{BUCKETS:t.fii.AGGREGATION_FILTER(n,e.RESULT)}))):e)).then((n=>r.FACETS?n.RESULT.length?e.ALL_DOCUMENTS?o(...r.FACETS).then((t=>Object.assign(n,{FACETS:t}))):o(...r.FACETS).then((e=>Object.assign(n,{FACETS:t.fii.AGGREGATION_FILTER(e,n.RESULT)}))):Object.assign(n,{FACETS:[]}):n)).then((t=>{return r.WEIGHT?Object.assign({RESULT:(e=t.RESULT,n=r.WEIGHT,e.map((t=>(t._match=t._match.map((t=>(n.forEach((e=>{let n=!1;e.FIELD&&e.VALUE?e.FIELD===t.FIELD&&e.VALUE===t.VALUE&&(n=!0):e.FIELD?e.FIELD===t.FIELD&&(n=!0):e.VALUE&&e.VALUE===t.VALUE&&(n=!0),n&&(t.SCORE=(e.WEIGHT*+t.SCORE).toFixed(2))})),t))),t))))},t):t;var e,n})).then((t=>r.SCORE?a(t.RESULT,r.SCORE).then((e=>Object.assign(t,{RESULT:e}))):t)).then((t=>Object.assign(t,r.SORT?{RESULT:h(t.RESULT,r.SORT)}:{}))).then((t=>Object.assign(t,r.PAGE?{RESULT:s(t.RESULT,r.PAGE)}:{}))).then((t=>r.DOCUMENTS?i(...t.RESULT.map((t=>t._id))).then((e=>Object.assign(t,{RESULT:t.RESULT.map(((t,n)=>Object.assign(t,{_doc:e[n]})))}))):t))},u=(t,n)=>new Promise((i=>(n=JSON.stringify(n),e.has(n)?i(e.get(n)):t.then((t=>e.set(n,t))).then((()=>i(e.get(n)))))));return{ALL_DOCUMENTS:n,DICTIONARY:t=>u((t=>r(t).then((t=>Array.from(t.reduce(((t,e)=>t.add(e.VALUE)),new Set)).sort(((t,e)=>(t+"").localeCompare(e+"",void 0,{numeric:!0,sensitivity:"base"}))))))(t),{DICTIONARY:t||null}),DISTINCT:r,DOCUMENTS:(...t)=>u(i(...t),{DOCUMENTS:t}),DOCUMENT_COUNT:c,DOCUMENT_VECTORS:(...e)=>Promise.all(e.map((e=>t.fii.STORE.get(["DOC",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))),FACETS:o,PAGE:s,QUERY:(t,e)=>u(l(t,e),{QUERY:[t,e]}),SCORE:a,SEARCH:(t,e)=>u(((t,e)=>l({AND:[...t]},Object.assign({SCORE:{TYPE:"TFIDF"},SORT:!0},e)))(t,e),{SEARCH:[t,e]}),SORT:h}}}var z=n(9203),G=n(4155);const W="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,K=new Set,q="object"==typeof G&&G?G:{},$=(t,e,n,i)=>{"function"==typeof q.emitWarning?q.emitWarning(t,e,n,i):console.error(`[${n}] ${e}: ${t}`)};let H=globalThis.AbortController,Y=globalThis.AbortSignal;if(void 0===H){Y=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},H=class{constructor(){e()}signal=new Y;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==q.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,$("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const J=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),X=t=>J(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Q:null:null;class Q extends Array{constructor(t){super(t),this.fill(0)}}class Z{heap;length;static#t=!1;static create(t){const e=X(t);if(!e)return[];Z.#t=!0;const n=new Z(t,e);return Z.#t=!1,n}constructor(t,e){if(!Z.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class tt{#e;#n;#i;#r;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#s;#a;#h;#c;#l;#u;#f;#d;#p;#y;#g;#b;#E;#m;#v;#w;#_;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#m,sizes:t.#b,keyMap:t.#h,keyList:t.#c,valList:t.#l,next:t.#u,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#y,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,i,r)=>t.#S(e,n,i,r),moveToTail:e=>t.#L(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#a}get size(){return this.#s}get fetchMethod(){return this.#o}get dispose(){return this.#i}get disposeAfter(){return this.#r}constructor(t){const{max:e=0,ttl:n,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:o,updateAgeOnHas:s,allowStale:a,dispose:h,disposeAfter:c,noDisposeOnSet:l,noUpdateTTL:u,maxSize:f=0,maxEntrySize:d=0,sizeCalculation:p,fetchMethod:y,noDeleteOnFetchRejection:g,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:m,ignoreFetchAbort:v}=t;if(0!==e&&!J(e))throw new TypeError("max option must be a nonnegative integer");const w=e?X(e):Array;if(!w)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=f,this.maxEntrySize=d||this.#n,this.sizeCalculation=p,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==y&&"function"!=typeof y)throw new TypeError("fetchMethod must be a function if specified");if(this.#o=y,this.#w=!!y,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#l=new Array(e).fill(void 0),this.#u=new w(e),this.#f=new w(e),this.#d=0,this.#p=0,this.#y=Z.create(e),this.#s=0,this.#a=0,"function"==typeof h&&(this.#i=h),"function"==typeof c?(this.#r=c,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#v=!!this.#i,this.#_=!!this.#r,this.noDisposeOnSet=!!l,this.noUpdateTTL=!!u,this.noDeleteOnFetchRejection=!!g,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!m,this.ignoreFetchAbort=!!v,0!==this.maxEntrySize){if(0!==this.#n&&!J(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!J(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#x()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!s,this.ttlResolution=J(i)||0===i?i:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!J(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!K.has(t))(t)&&(K.add(t),$("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,tt))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#R(){const t=new Q(this.#e),e=new Q(this.#e);this.#m=t,this.#E=e,this.#I=(n,i,r=W.now())=>{if(e[n]=0!==i?r:0,t[n]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(n)&&this.delete(this.#c[n])}),i+1);t.unref&&t.unref()}},this.#C=n=>{e[n]=0!==t[n]?W.now():0},this.#N=(r,o)=>{if(t[o]){const s=t[o],a=e[o];r.ttl=s,r.start=a,r.now=n||i();const h=r.now-a;r.remainingTTL=s-h}};let n=0;const i=()=>{const t=W.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=r=>{const o=this.#h.get(r);if(void 0===o)return 0;const s=t[o],a=e[o];return 0===s||0===a?1/0:s-((n||i())-a)},this.#k=r=>0!==t[r]&&0!==e[r]&&(n||i())-e[r]>t[r]}#C=()=>{};#N=()=>{};#I=()=>{};#k=()=>!1;#x(){const t=new Q(this.#e);this.#a=0,this.#b=t,this.#D=e=>{this.#a-=t[e],t[e]=0},this.#U=(t,e,n,i)=>{if(this.#T(e))return 0;if(!J(n)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(n=i(e,t),!J(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#P=(e,n,i)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#a>n;)this.#M(!0)}this.#a+=t[e],i&&(i.entrySize=n,i.totalCalculatedSize=this.#a)}}#D=t=>{};#P=(t,e,n)=>{};#U=(t,e,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#s)for(let e=this.#p;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#s)for(let e=this.#d;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#u[e]}#B(t){return void 0!==t&&this.#h.get(this.#c[t])===t}*entries(){for(const t of this.#O())void 0===this.#l[t]||void 0===this.#c[t]||this.#T(this.#l[t])||(yield[this.#c[t],this.#l[t]])}*rentries(){for(const t of this.#A())void 0===this.#l[t]||void 0===this.#c[t]||this.#T(this.#l[t])||(yield[this.#c[t],this.#l[t]])}*keys(){for(const t of this.#O()){const e=this.#c[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#c[t];void 0===e||this.#T(this.#l[t])||(yield e)}}*values(){for(const t of this.#O())void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}*rvalues(){for(const t of this.#A())void 0===this.#l[t]||this.#T(this.#l[t])||(yield this.#l[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of this.#O()){const i=this.#l[n],r=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==r&&t(r,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#O()){const i=this.#l[n],r=this.#T(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#A()){const i=this.#l[n],r=this.#T(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#c[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const n=this.#c[e],i=this.#l[e],r=this.#T(i)?i.__staleWhileFetching:i;if(void 0===r||void 0===n)continue;const o={value:r};if(this.#m&&this.#E){o.ttl=this.#m[e];const t=W.now()-this.#E[e];o.start=Math.floor(Date.now()-t)}this.#b&&(o.size=this.#b[e]),t.unshift([n,o])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=W.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:r,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:s=this.sizeCalculation,status:a}=n;let{noUpdateTTL:h=this.noUpdateTTL}=n;const c=this.#U(t,e,n.size||0,s);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let l=0===this.#s?void 0:this.#h.get(t);if(void 0===l)l=0===this.#s?this.#p:0!==this.#y.length?this.#y.pop():this.#s===this.#e?this.#M(!1):this.#s,this.#c[l]=t,this.#l[l]=e,this.#h.set(t,l),this.#u[this.#p]=l,this.#f[l]=this.#p,this.#p=l,this.#s++,this.#P(l,c,a),a&&(a.set="add"),h=!1;else{this.#L(l);const n=this.#l[l];if(e!==n){if(this.#w&&this.#T(n)?n.__abortController.abort(new Error("replaced")):o||(this.#v&&this.#i?.(n,t,"set"),this.#_&&this.#g?.push([n,t,"set"])),this.#D(l),this.#P(l,c,a),this.#l[l]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#m||this.#R(),this.#m&&(h||this.#I(l,i,r),a&&this.#N(a,l)),!o&&this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}return this}pop(){try{for(;this.#s;){const t=this.#l[this.#d];if(this.#M(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}}}#M(t){const e=this.#d,n=this.#c[e],i=this.#l[e];return this.#w&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#v||this.#_)&&(this.#v&&this.#i?.(i,n,"evict"),this.#_&&this.#g?.push([i,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#l[e]=void 0,this.#y.push(e)),1===this.#s?(this.#d=this.#p=0,this.#y.length=0):this.#d=this.#u[e],this.#h.delete(n),this.#s--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=e,r=this.#h.get(t);if(void 0!==r){const t=this.#l[r];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(r))return n&&this.#C(r),i&&(i.has="hit",this.#N(i,r)),!0;i&&(i.has="stale",this.#N(i,r))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,i=this.#h.get(t);if(void 0!==i&&(n||!this.#k(i))){const t=this.#l[i];return this.#T(t)?t.__staleWhileFetching:t}}#S(t,e,n,i){const r=void 0===e?void 0:this.#l[e];if(this.#T(r))return r;const o=new H,{signal:s}=n;s?.addEventListener("abort",(()=>o.abort(s.reason)),{signal:o.signal});const a={signal:o.signal,options:n,context:i},h=(i,r=!1)=>{const{aborted:s}=o.signal,h=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(s&&!r?(n.status.fetchAborted=!0,n.status.fetchError=o.signal.reason,h&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),s&&!h&&!r)return c(o.signal.reason);const u=l;return this.#l[e]===l&&(void 0===i?u.__staleWhileFetching?this.#l[e]=u.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,i,a.options))),i},c=i=>{const{aborted:r}=o.signal,s=r&&n.allowStaleOnFetchAbort,a=s||n.allowStaleOnFetchRejection,h=a||n.noDeleteOnFetchRejection,c=l;if(this.#l[e]===l&&(h&&void 0!==c.__staleWhileFetching?s||(this.#l[e]=c.__staleWhileFetching):this.delete(t)),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw i};n.status&&(n.status.fetchDispatched=!0);const l=new Promise(((e,i)=>{const s=this.#o?.(t,r,a);s&&s instanceof Promise&&s.then((t=>e(void 0===t?void 0:t)),i),o.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),c(t)))),u=Object.assign(l,{__abortController:o,__staleWhileFetching:r,__returned:void 0});return void 0===e?(this.set(t,u,{...a.options,status:void 0}),e=this.#h.get(t)):this.#l[e]=u,u}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof H}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:s=this.noDisposeOnSet,size:a=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:l=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:u=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:b}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});const E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:o,noDisposeOnSet:s,size:a,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:l,allowStaleOnFetchRejection:u,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:g,signal:b};let m=this.#h.get(t);if(void 0===m){g&&(g.fetch="miss");const e=this.#S(t,m,E,p);return e.__returned=e}{const e=this.#l[m];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const r=this.#k(m);if(!y&&!r)return g&&(g.fetch="hit"),this.#L(m),i&&this.#C(m),g&&this.#N(g,m),e;const o=this.#S(t,m,E,p),s=void 0!==o.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",s&&r&&(g.returnedStale=!0)),s?o.__staleWhileFetching:o.__returned=o}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:o}=e,s=this.#h.get(t);if(void 0!==s){const e=this.#l[s],a=this.#T(e);return o&&this.#N(o,s),this.#k(s)?(o&&(o.get="stale"),a?(o&&n&&void 0!==e.__staleWhileFetching&&(o.returnedStale=!0),n?e.__staleWhileFetching:void 0):(r||this.delete(t),o&&n&&(o.returnedStale=!0),n?e:void 0)):(o&&(o.get="hit"),a?e.__staleWhileFetching:(this.#L(s),i&&this.#C(s),e))}o&&(o.get="miss")}#F(t,e){this.#f[e]=t,this.#u[t]=e}#L(t){t!==this.#p&&(t===this.#d?this.#d=this.#u[t]:this.#F(this.#f[t],this.#u[t]),this.#F(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#s){const n=this.#h.get(t);if(void 0!==n)if(e=!0,1===this.#s)this.clear();else{this.#D(n);const e=this.#l[n];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#v||this.#_)&&(this.#v&&this.#i?.(e,t,"delete"),this.#_&&this.#g?.push([e,t,"delete"])),this.#h.delete(t),this.#c[n]=void 0,this.#l[n]=void 0,n===this.#p?this.#p=this.#f[n]:n===this.#d?this.#d=this.#u[n]:(this.#u[this.#f[n]]=this.#u[n],this.#f[this.#u[n]]=this.#f[n]),this.#s--,this.#y.push(n)}}if(this.#_&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#l[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const n=this.#c[t];this.#v&&this.#i?.(e,n,"delete"),this.#_&&this.#g?.push([e,n,"delete"])}}if(this.#h.clear(),this.#l.fill(void 0),this.#c.fill(void 0),this.#m&&this.#E&&(this.#m.fill(0),this.#E.fill(0)),this.#b&&this.#b.fill(0),this.#d=0,this.#p=0,this.#y.length=0,this.#a=0,this.#s=0,this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}}}const et=(t,e,n)=>{const i=e=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],+n+e,t.fii.LEVEL_OPTIONS))).catch((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],e,t.fii.LEVEL_OPTIONS))),r=(n,i,r)=>(e.clear(),Promise.all(n.map(((e,n)=>t.fii.STORE.put(["DOC_RAW",i[n]],r?{}:e,t.fii.LEVEL_OPTIONS)))).then((t=>n.map(((t,e)=>({_id:i[e],status:"OK",operation:"_PUT_RAW"}))))));return{DELETE:(...n)=>{return i=n,t.fii.DELETE(i,t.fii.LEVEL_OPTIONS).then((n=>{e.clear();const i=n.filter((t=>"DELETED"===t.status));return Promise.all([Promise.all(i.map((e=>t.fii.STORE.del(["DOC_RAW",e._id],t.fii.LEVEL_OPTIONS)))),(r=i.length,t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((e=>t.fii.STORE.put(["DOCUMENT_COUNT"],+e-r,t.fii.LEVEL_OPTIONS))))]).then((()=>n));var r}));var i},FLUSH:()=>t.fii.STORE.clear().then((()=>{e.clear();const n=Date.now();return t.fii.STORE.batch([{type:"put",key:["~CREATED"],value:n},{type:"put",key:["~LAST_UPDATED"],value:n},{type:"put",key:["DOCUMENT_COUNT"],value:0}],t.fii.LEVEL_OPTIONS)})).then((()=>!0)),IMPORT:n=>(e.clear(),Promise.resolve(t.fii.IMPORT(n))),PUT:(o,s)=>n.add((()=>((n,o)=>(e.clear(),o=Object.assign(t,o),(t=>{const e=t=>"string"==typeof t||t instanceof String,n=(i,r)=>new Promise((async o=>{return null===i?o([null,"1.00"]):(s=i)&&0===Object.keys(s).length&&Object.getPrototypeOf(s)===Object.prototype?o([[],"1.00"]):Number.isInteger(i)?o([i,i]):e(i)?o(t.tokenizer(i,r,t)):(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(i)?o((a=i,new Promise((async e=>{const i={};for(const e in a)i[e]=await n(a[e],e,t);return e(i)})))):(t=>Array.isArray(t))(i)?o((h=i,Promise.all(h.map(n)))):o(i);var s,a,h})),i=async i=>new Promise((async r=>{e(i)&&(i={body:i}),Object.prototype.hasOwnProperty.call(i,"_id")||(i._id=t.idGenerator.next().value);const o={};for(const t in i)o[t]="_id"!==t?await n(i[t],t):i[t];return r(o)}));return{processDocuments:t=>Promise.all(t.map(i))}})(t).processDocuments(n).then((e=>t.fii.PUT(e,o,t.fii.LEVEL_OPTIONS).then((e=>Promise.all([r(n,e.map((t=>t._id)),!t.storeRawDocs),i(e.filter((t=>"CREATED"===t.status)).length)]).then((()=>e))))))))(o,s))),PUT_RAW:r,_INCREMENT_DOC_COUNT:i}};var nt=n(971),it=n(6349);const rt=([t,e,n])=>[n.skipFields.includes(e)?[]:t,e,n],ot=([t,e,n])=>Promise.resolve([t.map((t=>n.caseSensitive?t:t.toLowerCase())),e,n]),st=([t,e,n])=>{const{fields:i,values:r}=n.replace,o=()=>t.reduce(((t,e)=>[e,...t,...r[e]||[]]),[]);return r?i?i.includes(e)?Promise.resolve([o(),e,n]):Promise.resolve([t,e,n]):Promise.resolve([o(),e,n]):Promise.resolve([t,e,n])},at=([t,e,n])=>{let{fields:i,lengths:r,join:o=" "}=n.ngrams;return i||(i=[e]),r&&i.includes(e)?[it(t.filter((t=>null!==t)),r).map((t=>t.join(o))),e,n]:Promise.resolve([t,e,n])},ht=([t,e,n])=>[t.filter((t=>!n.stopwords.includes(t.toLowerCase()))),e,n],ct=([t,e,n])=>{const i=nt(t),r=i.reduce(((t,e)=>Math.max(e.positions.length,t)),0);return Promise.resolve([i.map((t=>[t.term[0],(t.positions.length/r).toFixed(2)])).sort(),e,n])},lt=(t,e,n)=>(([t,e,n])=>Promise.resolve([t.match(n.tokenSplitRegex)||[],e,n]))([t,e,n]).then(rt).then(ot).then(st).then(at).then(ht).then(ct).then((([t,e,n])=>t)),ut=t=>new Promise((async e=>{const n=new tt({max:1e3}),i=new F({concurrency:1}),r=et(t,n,i),o=new V(t,n);return r._INCREMENT_DOC_COUNT(0).then((()=>e({_AND:t.fii.AND,_BUCKET:t.fii.BUCKET,_GET:t.fii.GET,_NOT:t.fii.NOT,_OR:t.fii.OR,_CACHE:n,_PAGE:o.PAGE,_SCORE:o.SCORE,_SEARCH:o.SEARCH,_SORT:o.SORT,DELETE:r.DELETE,FLUSH:r.FLUSH,IMPORT:r.IMPORT,PUT:r.PUT,PUT_RAW:r.PUT_RAW,TOKENIZATION_PIPELINE_STAGES:lt,ALL_DOCUMENTS:o.ALL_DOCUMENTS,BUCKETS:t.fii.BUCKETS,CREATED:t.fii.CREATED,DICTIONARY:o.DICTIONARY,DISTINCT:o.DISTINCT,DOCUMENTS:o.DOCUMENTS,DOCUMENT_COUNT:o.DOCUMENT_COUNT,DOCUMENT_VECTORS:o.DOCUMENT_VECTORS,EXPORT:t.fii.EXPORT,FACETS:o.FACETS,FIELDS:t.fii.FIELDS,INDEX:t.fii,LAST_UPDATED:t.fii.LAST_UPDATED,MAX:t.fii.MAX,MIN:t.fii.MIN,QUERY:o.QUERY,SEARCH:o.SEARCH})))}));class ft{constructor(t){return((t={})=>new Promise(((e,n)=>(t=Object.assign({cacheLength:1e3,caseSensitive:!1,docExistsSpace:"DOC_RAW",idGenerator:function*(){let t=0;for(;;)yield Date.now()+"-"+t++}(),isLeaf:t=>Array.isArray(t)&&2===t.length&&t.every((t=>"string"==typeof t||"number"==typeof t||null===t)),skipFields:[],ngrams:{},replace:{},storeRawDocs:!0,stopwords:[],storeVectors:!0,tokenAppend:"#",tokenSplitRegex:/[\p{L}\d]+/gu,tokenizer:lt},t),z(t).then((n=>e(Object.assign({fii:n},t))))))))(t).then(ut).then((t=>(t=>new Promise(((e,n)=>{const i=["CREATED_WITH"],r="search-index@4.0.0";return t.INDEX.STORE.get(i,t.INDEX.LEVEL_OPTIONS).then((t=>r===t?e():n(new Error("This index was created with "+t+", you are running "+r)))).catch((n=>t.INDEX.STORE.put(i,r,t.INDEX.LEVEL_OPTIONS).then(e)))})))(t).then((()=>t))))}}})();var r=i.W;export{r as SearchIndex}; \ No newline at end of file diff --git a/dist/search-index.js b/dist/search-index.js index 853a1db4..b0da28cb 100644 --- a/dist/search-index.js +++ b/dist/search-index.js @@ -1,2 +1,2 @@ /*! For license information please see search-index-4.0.0.js.LICENSE.txt */ -var SearchIndex;(()=>{var t={9464:(t,e,n)=>{"use strict";const{fromCallback:r}=n(6957),i=n(4473),{getCallback:s,getOptions:o}=n(2520),a=Symbol("promise"),c=Symbol("status"),h=Symbol("operations"),u=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[h]=[],this[l]=[],this[c]="open",this[u]=this[u].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[h].length}put(t,e,n){if("open"!==this[c])throw new i("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const r=this.db._checkKey(t)||this.db._checkValue(e);if(r)throw r;const s=n&&null!=n.sublevel?n.sublevel:this.db,o=n,a=s.keyEncoding(n&&n.keyEncoding),u=s.valueEncoding(n&&n.valueEncoding),l=a.format;n={...n,keyEncoding:l,valueEncoding:u.format},s!==this.db&&(n.sublevel=null);const f=s.prefixKey(a.encode(t),l),d=u.encode(e);return this._put(f,d,n),this[h].push({...o,type:"put",key:t,value:e}),this}_put(t,e,n){}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 n=this.db._checkKey(t);if(n)throw n;const r=e&&null!=e.sublevel?e.sublevel:this.db,s=e,o=r.keyEncoding(e&&e.keyEncoding),a=o.format;return e={...e,keyEncoding:a},r!==this.db&&(e.sublevel=null),this._del(r.prefixKey(o.encode(t),a),e),this[h].push({...s,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[h]=[],this}_clear(){}write(t,e){return e=s(t,e),e=r(e,a),t=o(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[h]),this._close(this[u])}))),e[a]}_write(t,e){}close(t){return t=r(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[u]))),t[a]}_close(t){this.nextTick(t)}[u](){this[c]="closed",this.db.detachResource(this);const t=this[l];this[l]=[];for(const e of t)e()}}},3961:(t,e,n)=>{"use strict";const{fromCallback:r}=n(6957),i=n(4473),{getOptions:s,getCallback:o}=n(2520),a=Symbol("promise"),c=Symbol("callback"),h=Symbol("working"),u=Symbol("handleOne"),l=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){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[b]=!1,this[E]=[],this[h]=!1,this[y]=!1,this[f]=!1,this[c]=null,this[u]=this[u].bind(this),this[l]=this[l].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,r,i)=>{t?n(t):this[_]?void 0===r&&void 0===i?e():e([r,i]):e(r)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new i("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(t,new i("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[h]=!0,this[c]=t,this[O]>=this[L]?this.nextTick(this[u],null):this._next(this[u])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=o(e,n),n=r(n,a),e=s(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new i("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(n,new i("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[h]=!0,this[c]=n,t<=0?this.nextTick(this[l],null,[]):this._nextv(t,e,this[l])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const r=[],i=(e,s,o)=>e?n(e):(this[_]?void 0===s&&void 0===o:void 0===s)?n(null,r):(r.push(this[_]?[s,o]:s),void(r.length===t?n(null,r):this._next(i)));this._next(i)}all(t,e){return e=o(t,e),e=r(e,a),t=s(t,A),this[y]?this.nextTick(e,new i("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[h]?this.nextTick(e,new i("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[h]=!0,this[c]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[l],null,[]):this._all(t,this[l])),e[a]}_all(t,e){let n=this[O];const r=[],i=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,r):this._nextv(t,A,s)},s=(t,s)=>{t?e(t):0===s.length?e(null,r):(r.push.apply(r,s),n+=s.length,i())};i()}[d](){const t=this[c];return this[w]&&null===t?k:(this[h]=!1,this[c]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=s(e,A),this[y]);else{if(this[h])throw new i("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),r=n.format;e.keyEncoding!==r&&(e={...e,keyEncoding:r});const i=this.db.prefixKey(n.encode(t),r);this._seek(i,e)}}}_seek(t,e){throw new i("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=r(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[h]?this[w]&&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[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[u](t,e,n){const r=this[d]();if(t)return r(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return r(new C("entry",t))}void 0===e&&void 0===n||this[O]++,r(null,e,n)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!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 C 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(I.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"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[u](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t{"use strict";const{supports:r}=n(3658),{Transcoder:i}=n(8499),{EventEmitter:s}=n(7187),{fromCallback:o}=n(6957),a=n(4473),{AbstractIterator:c}=n(3961),{DefaultKeyIterator:h,DefaultValueIterator:u}=n(5429),{DeferredIterator:l,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C extends s{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:n,valueEncoding:s,passive:o,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=r(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[k]=new i(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(s||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=o(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=o(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const r=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(r);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),c=i.format,h=s.format;return e.keyEncoding===c&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:c,valueEncoding:h})),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)),n(t);try{e=s.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const r=this.keyEncoding(e.keyEncoding),i=this.valueEncoding(e.valueEncoding),s=r.format,c=i.format;e.keyEncoding===s&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:s,valueEncoding:c}));const h=new Array(t.length);for(let e=0;e{if(t)return n(t);try{for(let t=0;tthis.put(t,e,n,r))),r[E];if(D(this,r))return r[E];const i=this._checkKey(t)||this._checkValue(e);if(i)return this.nextTick(r,i),r[E];const s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),c=s.format,h=a.format;n.keyEncoding===c&&n.valueEncoding===h||(n=Object.assign({},n,{keyEncoding:c,valueEncoding:h}));const u=this.prefixKey(s.encode(t),c),l=a.encode(e);return this._put(u,l,n,(n=>{if(n)return r(n);this.emit("put",t,e),r()})),r[E]}_put(t,e,n,r){this.nextTick(r)}del(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const r=this._checkKey(t);if(r)return this.nextTick(n,r),n[E];const i=this.keyEncoding(e.keyEncoding),s=i.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(i.encode(t),s),e,(e=>{if(e)return n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=o(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const r=new Array(t.length),{keyEncoding:i,valueEncoding:s,...c}=e;for(let e=0;e{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=o(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,r=this.keyEncoding(t.keyEncoding);return(t=b(t,r)).keyEncoding=r.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new l(this,t);if("open"!==this[O])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),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new h(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[c.keyEncoding]=e,t[c.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new u(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];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 p(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"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{"use strict";e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{"use strict";const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:s}=n(3961),o=Symbol("unfix"),a=Symbol("iterator"),c=Symbol("handleOne"),h=Symbol("handleMany"),u=Symbol("callback");class l extends r{constructor(t,e,n,r){super(t,e),this[a]=n,this[o]=r,this[c]=this[c].bind(this),this[h]=this[h].bind(this),this[u]=null}[c](t,e,n){const r=this[u];if(t)return r(t);void 0!==e&&(e=this[o](e)),r(t,e,n)}[h](t,e){const n=this[u];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[o](e))}n(t,e)}}class f extends i{constructor(t,e,n,r){super(t,e),this[a]=n,this[o]=r,this[c]=this[c].bind(this),this[h]=this[h].bind(this),this[u]=null}[c](t,e){const n=this[u];if(t)return n(t);void 0!==e&&(e=this[o](e)),n(t,e)}[h](t,e){const n=this[u];if(t)return n(t);for(let t=0;t{"use strict";const r=n(4473),{Buffer:i}=n(8764)||{},{AbstractSublevelIterator:s,AbstractSublevelKeyIterator:o,AbstractSublevelValueIterator:a}=n(2970),c=Symbol("prefix"),h=Symbol("upperBound"),u=Symbol("prefixRange"),l=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new r("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new r("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,i){const{separator:s,manifest:o,...a}=e.defaults(i);n=m(n,s);const u=s.charCodeAt(0)+1,p=t[l]||t;if(!d.encode(n).every((t=>t>u&&t<127)))throw new r(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,o),a);const g=(t.prefix||"")+s+n+s,v=g.slice(0,-1)+String.fromCharCode(u);this[l]=p,this[c]=new b(g),this[h]=new b(v),this[f]=new E,this.nextTick=p.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,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[c].buffer;return i.concat([e,t],e.byteLength+t.byteLength)}}[u](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[h][e]}get prefix(){return this[c].utf8}get db(){return this[l]}_open(t,e){this[l].open({passive:!0},e)}_put(t,e,n,r){this[l].put(t,e,n,r)}_get(t,e,n){this[l].get(t,e,n)}_getMany(t,e,n){this[l].getMany(t,e,n)}_del(t,e,n){this[l].del(t,e,n)}_batch(t,e,n){this[l].batch(t,e,n)}_clear(t,e){this[u](t,t.keyEncoding),this[l].clear(t,e)}_iterator(t){this[u](t,t.keyEncoding);const e=this[l].iterator(t),n=this[f].get(this[c].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_keys(t){this[u](t,t.keyEncoding);const e=this[l].keys(t),n=this[f].get(this[c].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_values(t){this[u](t,t.keyEncoding);const e=this[l].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=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 b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=i?i.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="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,n)),n}}const m=function(t,e){let n=0,r=t.length;for(;nn&&t[r-1]===e;)r--;return t.slice(n,r)}},2520:(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:{}}},4765:(t,e,n)=>{"use strict";const{AbstractChainedBatch:r}=n(9464),i=n(4473),s=Symbol("encoded");e.DefaultChainedBatch=class extends r{constructor(t){super(t),this[s]=[]}_put(t,e,n){this[s].push({...n,type:"put",key:t,value:e})}_del(t,e){this[s].push({...e,type:"del",key:t})}_clear(){this[s]=[]}_write(t,e){"opening"===this.db.status?this.db.defer((()=>this._write(t,e))):"open"===this.db.status?0===this[s].length?this.nextTick(e):this.db._batch(this[s],t,e):this.nextTick(e,new i("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},5429:(t,e,n)=>{"use strict";const{AbstractKeyIterator:r,AbstractValueIterator:i}=n(3961),s=Symbol("iterator"),o=Symbol("callback"),a=Symbol("handleOne"),c=Symbol("handleMany");class h extends r{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}class u extends i{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[c]=this[c].bind(this)}}for(const t of[h,u]){const e=t===h,n=e?t=>t[0]:t=>t[1];t.prototype._next=function(t){this[o]=t,this[s].next(this[a])},t.prototype[a]=function(t,n,r){const i=this[o];t?i(t):i(null,e?n:r)},t.prototype._nextv=function(t,e,n){this[o]=n,this[s].nextv(t,e,this[c])},t.prototype._all=function(t,e){this[o]=e,this[s].all(t,this[c])},t.prototype[c]=function(t,e){const r=this[o];t?r(t):r(null,e.map(n))},t.prototype._seek=function(t,e){this[s].seek(t,e)},t.prototype._close=function(t){this[s].close(t)}}e.DefaultKeyIterator=h,e.DefaultValueIterator=u},593:(t,e,n)=>{"use strict";const{AbstractIterator:r,AbstractKeyIterator:i,AbstractValueIterator:s}=n(3961),o=n(4473),a=Symbol("nut"),c=Symbol("undefer"),h=Symbol("factory");class u extends r{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.iterator(e),this.db.defer((()=>this[c]()))}}class l extends i{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.keys(e),this.db.defer((()=>this[c]()))}}class f extends s{constructor(t,e){super(t,e),this[a]=null,this[h]=()=>t.values(e),this.db.defer((()=>this[c]()))}}for(const t of[u,l,f])t.prototype[c]=function(){"open"===this.db.status&&(this[a]=this[h]())},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 o("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(t,e,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,new o("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 o("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=u,e.DeferredKeyIterator=l,e.DeferredValueIterator=f},6909:(t,e,n)=>{"use strict";const r=n(4375);t.exports=function(t,...e){0===e.length?r(t):r((()=>t(...e)))}},56:(t,e,n)=>{"use strict";const r=n(4473),i=Object.prototype.hasOwnProperty,s=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const o in t)if(i.call(t,o)&&"keyEncoding"!==o&&"valueEncoding"!==o){if("start"===o||"end"===o)throw new r(`The legacy range option '${o}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===o)throw new r("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});s.has(o)?n[o]=e.encode(t[o]):n[o]=t[o]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{"use strict";e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],r=e[1];return 3*(n+r)/4-r},e.toByteArray=function(t){var e,n,s=a(t),o=s[0],c=s[1],h=new i(function(t,e,n){return 3*(e+n)/4-n}(0,o,c)),u=0,l=c>0?o-4:o;for(n=0;n>16&255,h[u++]=e>>8&255,h[u++]=255&e;return 2===c&&(e=r[t.charCodeAt(n)]<<2|r[t.charCodeAt(n+1)]>>4,h[u++]=255&e),1===c&&(e=r[t.charCodeAt(n)]<<10|r[t.charCodeAt(n+1)]<<4|r[t.charCodeAt(n+2)]>>2,h[u++]=e>>8&255,h[u++]=255&e),h},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,s=[],o=16383,a=0,h=r-i;ah?h:a+o));return 1===i?(e=t[r-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function c(t,e,r){for(var i,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},1708:(t,e,n)=>{"use strict";const{AbstractLevel:r}=n(875),i=n(4473),s=n(9967),{fromCallback:o}=n(6957),{Iterator:a}=n(8212),c=n(9687),h=n(9968),u=n(1217),l="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends r{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new i("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:r,version:s,...o}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},o),"string"!=typeof t)throw new Error("constructor requires a location string argument");this[p]=t,this[d]=null==r?l:r,this[y]=parseInt(s||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const r=this[g]("readonly");let s;try{s=r.get(t)}catch(t){return this.nextTick(n,t)}this[b](s,(function(t,e){return t?n(t):void 0===e?n(new i("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,c(e))}))}_getMany(t,e,n){const r=this[g]("readonly"),i=t.map((t=>e=>{let n;try{n=r.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:c(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));s(i,16,n)}_del(t,e,n){const r=this[g]("readwrite");let i;try{i=r.delete(t)}catch(t){return this.nextTick(n,t)}this[b](i,n)}_put(t,e,n,r){const i=this[g]("readwrite");let s;try{s=i.put(e,t)}catch(t){return this.nextTick(r,t)}this[b](s,r)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const r=this[g]("readwrite"),i=r.transaction;let s,o=0;i.onabort=function(){n(s||i.error||new Error("aborted by user"))},i.oncomplete=function(){n()},function e(){const n=t[o++],a=n.key;let c;try{c="del"===n.type?r.delete(a):r.put(n.value,a)}catch(t){return s=t,void i.abort()}o=0)return h(this,this[p],n,t,e);try{const t=this[g]("readwrite");r=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](r,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=l),n=o(n,E);const r=indexedDB.deleteDatabase(e+t);return r.onsuccess=function(){n()},r.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{"use strict";const{AbstractIterator:r}=n(875),i=n(1217),s=n(9687),o=Symbol("cache"),a=Symbol("finished"),c=Symbol("options"),h=Symbol("currentOptions"),u=Symbol("position"),l=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends r{constructor(t,e,n){super(t,n),this[o]=[],this[a]=0===this.limit,this[c]=n,this[h]={...n},this[u]=void 0,this[l]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[o].length>0)return t=Math.min(t,this[o].length),this.nextTick(n,null,this[o].splice(0,t));let r;void 0!==this[u]&&(this[c].reverse?(this[h].lt=this[u],this[h].lte=void 0):(this[h].gt=this[u],this[h].gte=void 0));try{r=i(this[h])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[l]],"readonly"),y=d.objectStore(this[l]),g=[];if(this[c].reverse)y[!this[c].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](r,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:r}=n;this[u]=e,g.push([this[c].keys&&void 0!==e?s(e):void 0,this[c].values&&void 0!==r?s(r):void 0]),g.length{if(void 0===e||void 0===n)return;const r=Math.max(e.length,n.length);0===r||t===1/0?this[a]=!0:this[u]=e[r-1],g.length=r;for(let t=0;t{e=t.target.result,i()}:(e=[],this.nextTick(i)),this[c].values?y.getAll(r,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,i()}:(n=[],this.nextTick(i))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[o].length>0){const[e,n]=this[o].shift();this.nextTick(t,null,e,n)}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,n)=>{if(e)return t(e);this[o]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[o].splice(0,this[o].length),r=this.limit-this.count-n.length;if(r<=0)return this.nextTick(e,null,n);this._nextv(r,d,((t,r)=>{if(t)return e(t);n.length>0&&(r=n.concat(r)),e(null,r)}))}_seek(t,e){let n;this[f]=!0,this[o]=[],this[a]=!1,this[u]=void 0,this[h]={...this[c]};try{n=i(this[c])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[c].reverse?this[h].lte=t:this[h].gte=t:this[a]=!0}}},9968:t=>{"use strict";t.exports=function(t,e,n,r,i){if(0===r.limit)return t.nextTick(i);const s=t.db.transaction([e],"readwrite"),o=s.objectStore(e);let a=0;s.oncomplete=function(){i()},s.onabort=function(){i(s.error||new Error("aborted by user"))};const c=o.openKeyCursor?"openKeyCursor":"openCursor",h=r.reverse?"prev":"next";o[c](n,h).onsuccess=function(t){const e=t.target.result;e&&(o.delete(e.key).onsuccess=function(){(r.limit<=0||++a{"use strict";const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{"use strict";t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,r=void 0===t.gte,i=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,r,i):void 0!==e?IDBKeyRange.lowerBound(e,r):void 0!==n?IDBKeyRange.upperBound(n,i):null}},8764:(t,e,n)=>{"use strict";const r=n(9742),i=n(645),s="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 o=2147483647;function a(t){if(t>o)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,n){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 h(t,e,n)}function h(t,e,n){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 n=0|y(t,e);let r=a(n);const i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const r=t.valueOf&&t.valueOf();if(null!=r&&r!==t)return c.from(r,e,n);const i=function(t){if(c.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(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,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(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 u(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let r=0;r=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function y(t,e){if(c.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 n=t.length,r=arguments.length>2&&!0===arguments[2];if(!r&&0===n)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(i)return r?-1:q(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,n){let r=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(r)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),r=!0}}function b(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function E(t,e,n,r,i){if(0===t.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=i?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(i)return-1;n=t.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof e&&(e=c.from(e,r)),c.isBuffer(e))return 0===e.length?-1:m(t,e,n,r,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,r,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,r,i){let s,o=1,a=t.length,c=e.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(t.length<2||e.length<2)return-1;o=2,a/=2,c/=2,n/=2}function h(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){let r=-1;for(s=n;sa&&(n=a-c),s=n;s>=0;s--){let n=!0;for(let r=0;ri&&(r=i):r=i;const s=e.length;let o;for(r>s/2&&(r=s/2),o=0;o>8,i=n%256,s.push(i),s.push(r);return s}(e,t.length-n),t,n,r)}function L(t,e,n){return 0===e&&n===t.length?r.fromByteArray(t):r.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const r=[];let i=e;for(;i239?4:e>223?3:e>191?2:1;if(i+o<=n){let n,r,a,c;switch(o){case 1:e<128&&(s=e);break;case 2:n=t[i+1],128==(192&n)&&(c=(31&e)<<6|63&n,c>127&&(s=c));break;case 3:n=t[i+1],r=t[i+2],128==(192&n)&&128==(192&r)&&(c=(15&e)<<12|(63&n)<<6|63&r,c>2047&&(c<55296||c>57343)&&(s=c));break;case 4:n=t[i+1],r=t[i+2],a=t[i+3],128==(192&n)&&128==(192&r)&&128==(192&a)&&(c=(15&e)<<18|(63&n)<<12|(63&r)<<6|63&a,c>65535&&c<1114112&&(s=c))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),i+=o}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",r=0;for(;rr.length?(c.isBuffer(e)||(e=c.from(e)),e.copy(r,i)):Uint8Array.prototype.set.call(r,e,i);else{if(!c.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(r,i)}i+=e.length}return r},c.byteLength=y,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;en&&(t+=" ... "),""},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(t,e,n,r,i){if(Y(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===n&&(n=t?t.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),e<0||n>t.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&e>=n)return 0;if(r>=i)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(e>>>=0);const a=Math.min(s,o),h=this.slice(r,i),u=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}const i=this.length-e;if((void 0===n||n>i)&&(n=i),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");let s=!1;for(;;)switch(r){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,n){let r="";n=Math.min(t.length,n);for(let i=e;ir)&&(n=r);let i="";for(let r=e;rn)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,r,i,s){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function D(t,e,n,r,i){z(e,r,i,t,n,7);let s=Number(e&BigInt(4294967295));t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,n}function U(t,e,n,r,i){z(e,r,i,t,n,7);let s=Number(e&BigInt(4294967295));t[n+7]=s,s>>=8,t[n+6]=s,s>>=8,t[n+5]=s,s>>=8,t[n+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=o,o>>=8,t[n+2]=o,o>>=8,t[n+1]=o,o>>=8,t[n]=o,n+8}function P(t,e,n,r,i,s){if(n+r>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,r,s){return e=+e,n>>>=0,s||P(t,0,n,4),i.write(t,e,n,r,23,4),n+4}function B(t,e,n,r,s){return e=+e,n>>>=0,s||P(t,0,n,8),i.write(t,e,n,r,52,8),n+8}c.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,s=0;for(;++s>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t+--e],i=1;for(;e>0&&(i*=256);)r+=this[t+--e]*i;return r},c.prototype.readUint8=c.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(r)+(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(r)<>>=0,e>>>=0,n||C(t,e,this.length);let r=this[t],i=1,s=0;for(;++s=i&&(r-=Math.pow(2,8*e)),r},c.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let r=e,i=1,s=this[t+--r];for(;r>0&&(i*=256);)s+=this[t+--r]*i;return i*=128,s>=i&&(s-=Math.pow(2,8*e)),s},c.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},c.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const r=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(r)<>>=0,e||C(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,e,n,r){t=+t,e>>>=0,n>>>=0,r||N(this,t,e,n,Math.pow(2,8*n)-1,0);let i=1,s=0;for(this[e]=255&t;++s>>=0,n>>>=0,r||N(this,t,e,n,Math.pow(2,8*n)-1,0);let i=n-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+n},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigUInt64LE=Q((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeBigUInt64BE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),c.prototype.writeIntLE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let i=0,s=1,o=0;for(this[e]=255&t;++i>0)-o&255;return e+n},c.prototype.writeIntBE=function(t,e,n,r){if(t=+t,e>>>=0,!r){const r=Math.pow(2,8*n-1);N(this,t,e,n,r-1,-r)}let i=n-1,s=1,o=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===o&&0!==this[e+i+1]&&(o=1),this[e+i]=(t/s>>0)-o&255;return e+n},c.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},c.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},c.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},c.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},c.prototype.writeBigInt64LE=Q((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeBigInt64BE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),c.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},c.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},c.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},c.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},c.prototype.copy=function(t,e,n,r){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),e>=t.length&&(e=t.length),e||(e=0),r>0&&r=this.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(i=e;i=r+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,r,i,s){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(s+1)}${r}`:`>= -(2${r} ** ${8*(s+1)-1}${r}) and < 2 ** ${8*(s+1)-1}${r}`:`>= ${e}${r} and <= ${n}${r}`,new j.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(r,i,s)}function G(t,e){if("number"!=typeof t)throw new j.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new j.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new j.ERR_BUFFER_OUT_OF_BOUNDS;throw new j.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}F("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),F("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),F("ERR_OUT_OF_RANGE",(function(t,e,n){let r=`The value of "${t}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=V(String(n)):"bigint"==typeof n&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=V(i)),i+="n"),r+=` It must be ${e}. Received ${i}`,r}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const r=t.length;let i=null;const s=[];for(let o=0;o55295&&n<57344){if(!i){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(e-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(t){return r.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,r){let i;for(i=0;i=e.length||i>=t.length);++i)e[i+n]=t[i];return i}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const r=16*n;for(let i=0;i<16;++i)e[r+i]=t[n]+t[i]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6957:(t,e,n)=>{"use strict";var r=n(886);e.fromCallback=function(t,e){if(void 0===t){var n=new Promise((function(e,n){t=function(t,r){t?n(t):e(r)}}));t[void 0!==e?e:"promise"]=n}else if("function"!=typeof t)throw new TypeError("Callback must be a function");return t},e.fromPromise=function(t,e){if(void 0===e)return t;t.then((function(t){r((()=>e(null,t)))})).catch((function(t){r((()=>e(t)))}))}},886:t=>{t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t)},8840:(t,e)=>{function n(t){for(var e="",n=0;n0?"F"+o:"D"+n(o)},e.decode=function(t){if("DaN"===t)return NaN;if("FF"===t)return 1/0;if("DD"===t)return-1/0;var e="D"===t[0],r=(e?n(t):t).slice(2).split("M");return Number((e?"-":"")+r[1]+"e"+String(Number(r[0])-500))}},2833:(t,e)=>{var n={"?":"?@","!":"??",'"':"?%"},r={"?@":"?","??":"!","?%":'"'};e.factory=function(t){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,i=e.split('"'),s=[[]],o=0,a=i.length,c=0;c{var r=n(8840),i=n(2833);e.flip=function(t){var e=t.toString(),n="";for(var r in e)n+="."==e[r]?".":9-+e[r];return n},e.number=r,e.string={encode:function(t){return/\x00|\x01/.test(t)?"J"+t.replace(/\x01/g,"").replace(/\x00/g,""):"J"+t},decode:function(t){if("J"===t[0])return t.substring(1)}},e.encode=function(t){return e[typeof t].encode(t)},e.decode=function(t){if(""===t)return t;if(!s[t[0]])throw new Error("no decoder for:"+JSON.stringify(t));return s[t[0]](t)},e.object=i.factory(e),e.boolean={encode:function(t){return t?"C":"B"},decode:function(t){return"C"===t}},e.undefined={encode:function(t){return"L"},decode:function(){}};var s={A:e.object.decode,B:e.boolean.decode,C:e.boolean.decode,D:e.number.decode,F:e.number.decode,J:e.string.decode,K:e.object.decode,L:e.undefined.decode};e.buffer=!1,e.type="charwise"},6729:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function r(){}function i(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,r,s,o){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,s||t,o),c=n?n+e:e;return t._events[c]?t._events[c].fn?t._events[c]=[t._events[c],a]:t._events[c].push(a):(t._events[c]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new r:delete t._events[e]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,r,i=[];if(0===this._eventsCount)return i;for(r in t=this._events)e.call(t,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},a.prototype.listeners=function(t){var e=n?n+t:t,r=this._events[e];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,s=r.length,o=new Array(s);i{"use strict";var e,n="object"==typeof Reflect?Reflect:null,r=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise((function(n,r){function i(n){t.removeListener(e,s),r(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",i),n([].slice.call(arguments))}y(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function h(t,e,n,r){var i,s,o,h;if(a(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=r?[n,o]:[o,n]:r?o.unshift(n):o.push(n),(i=c(t))>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,h=u,console&&console.warn&&console.warn(h)}return t}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,n){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},i=u.bind(r);return i.listener=n,r.wrapFn=i,i}function f(t,e,n){var r=t._events;if(void 0===r)return[];var i=r[e];return void 0===i?[]:"function"==typeof i?n?[i.listener||i]:[i]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var h=c.length,u=p(c,h);for(n=0;n=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,i=s;break}if(i<0)return this;0===i?n.shift():function(t,e){for(;e+1=0;r--)this.removeListener(t,e[r]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9203:(t,e,n)=>{const r=n(7270),{BrowserLevel:i}=n(1708);t.exports=({name:t="fii",...e})=>r({db:new i(t),...e})},7270:(t,e,n)=>{const r=n(9563),i=n(8936),s=n(1387),o=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELDe.FIELD?1:t.VALUEe.VALUE?1:t.SCOREe.SCORE?1:0)),t))),a=t=>{const e=r(t),n=i(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(o),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(o),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:s,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(o),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(o),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const r=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;r.open((i=>i?n(i):e(Object.assign(t,{_db:r}))))})))(t).then(a)},1387:(t,e,n)=>{const r=n(2483);t.exports={keyEncoding:r,valueEncoding:"json"}},6782:t=>{const e=null,n=void 0;t.exports=(t,r)=>new Promise(((i,s)=>{if(Array.isArray(t))return s(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return i({FIELD:r,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return i({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?i(Object.assign(t,{FIELD:r})):(t.FIELD=[t.FIELD].flat(),i(t))}))},9563:(t,e,n)=>{const r=n(6782),i=n(2483),{EntryStream:s}=n(6741),o=n(1387);i.LO=null,i.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>r(t,await l()),a=async(e,r=(t=>new Promise((e=>e(t)))))=>new Promise((async(i,s)=>{const o=t=>void 0===t?i(void 0):t instanceof Promise?i(t):void 0;try{o(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),o(e=await(e=>void 0===e?u(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?c(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),o(e=await r(e))}catch(t){return s(t)}return Array.isArray(e)?i(e):i(u(e))})),c=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),h=(t,e,n)=>{const r=[];return void 0===e&&"number"!=typeof e||r.push(e),n&&r.push(i.HI),["IDX",t,r]},u=e=>new Promise((n=>{if(void 0===e)return n(void 0);const r=new Map;return Promise.all(e.FIELD.map((n=>new Promise((i=>new s(t._db,{gte:h(n,e.VALUE.GTE),lte:h(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...o}).on("data",(t=>t.value.forEach((e=>r.set(e,[...r.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",i)))))).then((()=>n(Array.from(r.keys()).map((t=>({_id:t,_match:r.get(t)}))))))})),l=()=>new Promise((e=>{const n=[];new s(t._db,{gte:["FIELD",i.LO],lte:["FIELD",i.HI],...o}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,r)=>{const i=[];new s(t._db,{...e,...o}).on("data",(t=>{i.push(t)})).on("end",(()=>n(i)))})),y=(t,e)=>n(t).then((t=>u(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let r=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(r+=" "),p({gte:h(e,r),lte:h(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:h(e,t.VALUE.GTE),lte:h(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],o),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],o).catch((t=>null))))).then((t=>t.reduce(((t,n,r)=>(null!=n&&t.push(e[r]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:l,GET:a,INTERSECTION:(t,e)=>c(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],o),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],o).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:c,parseToken:n}}},8936:(t,e,n)=>{const r=n(3692),i=n(9563),s=n(1387);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const i=[];return r(e._object).forEach((function(e){const r=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==r&&!n.doNotIndexField.filter((t=>r.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([r,[this.node].flat(1/0)]);i.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:i}},o=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(r,a,c,h,u)=>new Promise((l=>{r=r.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),u=Object.assign(t,u),i(t).EXIST(...r.map((t=>t._id))).then((t=>((t,e,n)=>{const r=Object.keys(t);return Promise.all(r.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,r)=>e.get(t,s).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,i)=>{const s=new Set(e),o=new Set(t[r[i]]);if("put"===n)return{key:["IDX",...JSON.parse(r[i])],type:n,value:[...new Set([...s,...o])].sort()};if("del"===n){const t=[...new Set([...s].filter((t=>!o.has(t))))];return{key:["IDX",...JSON.parse(r[i])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(o,{}))(r,u),a,c).then((e=>a.batch(e.concat(u.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(r,c):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),s,(e=>l(r.map((e=>{let n;return"put"===c?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===c&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:h,status:n}})))))))))})),c=e=>t._db.put(["~LAST_UPDATED"],Date.now(),s).then((()=>e));return{DELETE:e=>i(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(c),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),s))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(c),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],s).then().catch((e=>t._db.put(["~CREATED"],Date.now(),s).then(c))),TIMESTAMP_LAST_UPDATED:c}}},645:(t,e)=>{e.read=function(t,e,n,r,i){var s,o,a=8*i-r-1,c=(1<>1,u=-7,l=n?i-1:0,f=n?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-u)-1,d>>=-u,u+=a;u>0;s=256*s+t[e+l],l+=f,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=r;u>0;o=256*o+t[e+l],l+=f,u-=8);if(0===s)s=1-h;else{if(s===c)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=h}return(d?-1:1)*o*Math.pow(2,s-r)},e.write=function(t,e,n,r,i,s){var o,a,c,h=8*s-i-1,u=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-o))<1&&(o--,c*=2),(e+=o+l>=1?f/c:f*Math.pow(2,1-l))*c>=2&&(o++,c/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*c-1)*Math.pow(2,i),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;t[n+d]=255&a,d+=p,a/=256,i-=8);for(o=o<0;t[n+d]=255&o,d+=p,o/=256,h-=8);t[n+d-p]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},6741:(t,e,n)=>{"use strict";const{Readable:r}=n(8473),i=Symbol("iterator"),s=Symbol("nextv");class o extends r{constructor(t,e,n){const{highWaterMark:r,...o}=n||{};super({objectMode:!0,highWaterMark:r||1e3}),this[i]=t[e](o),this[s]=this[s].bind(this),this.once("end",this.destroy.bind(this,null,null))}get db(){return this[i].db}_read(t){this.destroyed||this[i].nextv(t,this[s])}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const t of e)this.push(t)}}_destroy(t,e){this[i].close((function(n){e(t||n)}))}}e.EntryStream=class extends o{constructor(t,e){super(t,"iterator",{...e,keys:!0,values:!0})}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const[t,n]of e)this.push({key:t,value:n})}}},e.KeyStream=class extends o{constructor(t,e){super(t,"keys",e)}},e.ValueStream=class extends o{constructor(t,e){super(t,"values",e)}}},8499:(t,e,n)=>{"use strict";const r=n(4473),i=n(8002),{Encoding:s}=n(8266),{BufferFormat:o,ViewFormat:a,UTF8Format:c}=n(2376),h=Symbol("formats"),u=Symbol("encodings"),l=new Set(["buffer","view","utf8"]);e.Transcoder=class{constructor(t){if(!Array.isArray(t))throw new TypeError("The first argument 'formats' must be an array");if(!t.every((t=>l.has(t))))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[u]=new Map,this[h]=new Set(t);for(const t in i)try{this.encoding(t)}catch(t){if("LEVEL_ENCODING_NOT_SUPPORTED"!==t.code)throw t}}encodings(){return Array.from(new Set(this[u].values()))}encoding(t){let e=this[u].get(t);if(void 0===e){if("string"==typeof t&&""!==t){if(e=d[t],!e)throw new r(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if("object"!=typeof t||null===t)throw new TypeError("First argument 'encoding' must be a string or object");e=function(t){if(t instanceof s)return t;const e="type"in t&&"string"==typeof t.type?t.type:void 0,n=t.name||e||"anonymous-"+p++;switch(function(t){return"format"in t&&void 0!==t.format?t.format:"buffer"in t&&"boolean"==typeof t.buffer?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}(t)){case"view":return new a({...t,name:n});case"utf8":return new c({...t,name:n});case"buffer":return new o({...t,name:n});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}(t)}const{name:n,format:i}=e;if(!this[h].has(i))if(this[h].has("view"))e=e.createViewTranscoder();else if(this[h].has("buffer"))e=e.createBufferTranscoder();else{if(!this[h].has("utf8"))throw new r(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});e=e.createUTF8Transcoder()}for(const r of[t,n,e.name,e.commonName])this[u].set(r,e)}return e}};const f={binary:i.buffer,"utf-8":i.utf8},d={...i,...f};let p=0},8266:(t,e,n)=>{"use strict";const r=n(4473),i=new Set(["buffer","view","utf8"]);e.Encoding=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,"function"!=typeof this.encode)throw new TypeError("The 'encode' property must be a function");if("function"!=typeof this.decode)throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),"string"!=typeof this.name||""===this.name)throw new TypeError("The 'name' property must be a string");if("string"!=typeof this.format||!i.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new r(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}},8002:(t,e,n)=>{"use strict";const{Buffer:r}=n(8764)||{Buffer:{isBuffer:()=>!1}},{textEncoder:i,textDecoder:s}=n(4005)(),{BufferFormat:o,ViewFormat:a,UTF8Format:c}=n(2376),h=t=>t;e.utf8=new c({encode:function(t){return r.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?s.decode(t):String(t)},decode:h,name:"utf8",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.encode(t)},decode:function(t){return s.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new o({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}}),e.json=new c({encode:JSON.stringify,decode:JSON.parse,name:"json"}),e.buffer=new o({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:h,name:"buffer",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.from(String(t),"utf8")},decode:function(t){return r.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}}),e.view=new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.encode(t)},decode:h,name:"view",createBufferTranscoder(){return new o({encode:function(t){return r.isBuffer(t)?t:ArrayBuffer.isView(t)?r.from(t.buffer,t.byteOffset,t.byteLength):r.from(String(t),"utf8")},decode:h,name:`${this.name}+buffer`})}}),e.hex=new o({encode:function(t){return r.isBuffer(t)?t:r.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"}),e.base64=new o({encode:function(t){return r.isBuffer(t)?t:r.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})},2376:(t,e,n)=>{"use strict";const{Buffer:r}=n(8764)||{},{Encoding:i}=n(8266),s=n(4005);class o extends i{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:t=>this.decode(r.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class a extends i{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new o({encode:t=>{const e=this.encode(t);return r.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}e.BufferFormat=o,e.ViewFormat=a,e.UTF8Format=class extends i{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new o({encode:t=>r.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){const{textEncoder:t,textDecoder:e}=s();return new a({encode:e=>t.encode(this.encode(e)),decode:t=>this.decode(e.decode(t)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}},4005:t=>{"use strict";let e=null;t.exports=function(){return null===e&&(e={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),e}},4473:t=>{"use strict";t.exports=class extends Error{constructor(t,e){super(t||""),"object"==typeof e&&null!==e&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}},6349:function(t,e){!function(t){"use strict";const e=function(t,e){return t.slice(e-1).map(((n,r)=>t.slice(r,r+e)))};t.ngraminator=function(t,n){return n.reduce(((n,r)=>[...e(t,r),...n]),[]).sort()},Object.defineProperty(t,"__esModule",{value:!0})}(e)},4155:t=>{var e,n,r=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var a,c=[],h=!1,u=-1;function l(){h&&a&&(h=!1,a.length?c=a.concat(c):u=-1,c.length&&f())}function f(){if(!h){var t=o(l);h=!0;for(var e=c.length;e;){for(a=c,c=[];++u1)for(var n=1;n{let r;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:n.g):t=>(r||(r=Promise.resolve())).then(t).catch((t=>setTimeout((()=>{throw t}),0)))},4281:t=>{"use strict";var e={};function n(t,n,r){r||(r=Error);var i=function(t){var e,r;function i(e,r,i){return t.call(this,function(t,e,r){return"string"==typeof n?n:n(t,e,r)}(e,r,i))||this}return r=t,(e=i).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,i}(r);i.prototype.name=r.name,i.prototype.code=t,e[t]=i}function r(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(t){return String(t)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:2===n?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}n("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(t,e,n){var i,s,o,a,c;if("string"==typeof e&&(s="not ",e.substr(0,4)===s)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,n){return(void 0===n||n>t.length)&&(n=t.length),t.substring(n-9,n)===e}(t," argument"))o="The ".concat(t," ").concat(i," ").concat(r(e,"type"));else{var h=("number"!=typeof c&&(c=0),c+1>(a=t).length||-1===a.indexOf(".",c)?"argument":"property");o='The "'.concat(t,'" ').concat(h," ").concat(i," ").concat(r(e,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},6753:(t,e,n)=>{"use strict";var r=n(4155),i=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=u;var s=n(9481),o=n(4229);n(5717)(u,s);for(var a=i(o.prototype),c=0;c{"use strict";t.exports=i;var r=n(4605);function i(t){if(!(this instanceof i))return new i(t);r.call(this,t)}n(5717)(i,r),i.prototype._transform=function(t,e,n){n(null,t)}},9481:(t,e,n)=>{"use strict";var r,i=n(4155);t.exports=L,L.ReadableState=S,n(7187).EventEmitter;var s,o=function(t,e){return t.listeners(e).length},a=n(2503),c=n(8764).Buffer,h=n.g.Uint8Array||function(){},u=n(4616);s=u&&u.debuglog?u.debuglog("stream"):function(){};var l,f,d,p=n(7327),y=n(1195),g=n(2457).getHighWaterMark,b=n(4281).q,E=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(5717)(L,a);var _=y.errorOrDestroy,T=["error","close","destroy","pause","resume"];function S(t,e,i){r=r||n(6753),t=t||{},"boolean"!=typeof i&&(i=e instanceof r),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=n(2553).s),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function L(t){if(r=r||n(6753),!(this instanceof L))return new L(t);var e=this instanceof r;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function O(t,e,n,r,i){s("readableAddChunk",e);var o,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(s("onEofChunk"),!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?R(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,a);else if(i||(o=function(t,e){var n,r;return r=e,c.isBuffer(r)||r instanceof h||"string"==typeof e||void 0===e||t.objectMode||(n=new E("chunk",["string","Buffer","Uint8Array"],e)),n}(a,e)),o)_(t,o);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===c.prototype||(e=function(t){return c.from(t)}(e)),r)a.endEmitted?_(t,new w):A(t,a,e,!0);else if(a.ended)_(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(e=a.decoder.write(e),a.objectMode||0!==e.length?A(t,a,e,!1):C(t,a)):A(t,a,e,!1)}else r||(a.reading=!1,C(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=k?t=k:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function R(t){var e=t._readableState;s("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(s("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(I,t))}function I(t){var e=t._readableState;s("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function U(t){s("readable nexttick read 0"),t.read(0)}function P(t,e){s("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(s("flow",e.flowing);e.flowing&&null!==t.read(););}function B(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function j(t){var e=t._readableState;s("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(F,e,t))}function F(t,e){if(s("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function V(t,e){for(var n=0,r=t.length;n=e.highWaterMark:e.length>0)||e.ended))return s("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?j(this):R(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&j(this),null;var r,i=e.needReadable;return s("need readable",i),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&j(this)),null!==r&&this.emit("data",r),r},L.prototype._read=function(t){_(this,new v("_read()"))},L.prototype.pipe=function(t,e){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=t;break;case 1:r.pipes=[r.pipes,t];break;default:r.pipes.push(t)}r.pipesCount+=1,s("pipe count=%d opts=%j",r.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:c;function c(){s("onend"),t.end()}r.endEmitted?i.nextTick(a):n.once("end",a),t.on("unpipe",(function e(i,o){s("onunpipe"),i===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,s("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",h),t.removeListener("error",f),t.removeListener("unpipe",e),n.removeListener("end",c),n.removeListener("end",y),n.removeListener("data",l),u=!0,!r.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}));var h=function(t){return function(){var e=t._readableState;s("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",h);var u=!1;function l(e){s("ondata");var i=t.write(e);s("dest.write",i),!1===i&&((1===r.pipesCount&&r.pipes===t||r.pipesCount>1&&-1!==V(r.pipes,t))&&!u&&(s("false write response, pause",r.awaitDrain),r.awaitDrain++),n.pause())}function f(e){s("onerror",e),y(),t.removeListener("error",f),0===o(t,"error")&&_(t,e)}function d(){t.removeListener("finish",p),y()}function p(){s("onfinish"),t.removeListener("close",d),y()}function y(){s("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),r.flowing||(s("pipe resume"),n.resume()),t},L.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var r=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==r.flowing&&this.resume()):"readable"===t&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,s("on readable",r.length,r.reading),r.length?R(this):r.reading||i.nextTick(U,this))),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(t,e){var n=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(D,this),n},L.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(D,this),e},L.prototype.resume=function(){var t=this._readableState;return t.flowing||(s("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(P,t,e))}(this,t)),t.paused=!1,this},L.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},L.prototype.wrap=function(t){var e=this,n=this._readableState,r=!1;for(var i in t.on("end",(function(){if(s("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){s("wrapped data"),n.decoder&&(i=n.decoder.write(i)),n.objectMode&&null==i||(n.objectMode||i&&i.length)&&(e.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var o=0;o{"use strict";t.exports=u;var r=n(4281).q,i=r.ERR_METHOD_NOT_IMPLEMENTED,s=r.ERR_MULTIPLE_CALLBACK,o=r.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=r.ERR_TRANSFORM_WITH_LENGTH_0,c=n(6753);function h(t,e){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new s);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),r(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length{"use strict";var r,i=n(4155);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=L,L.WritableState=S;var o,a={deprecate:n(4927)},c=n(2503),h=n(8764).Buffer,u=n.g.Uint8Array||function(){},l=n(1195),f=n(2457).getHighWaterMark,d=n(4281).q,p=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,E=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function T(){}function S(t,e,o){r=r||n(6753),t=t||{},"boolean"!=typeof o&&(o=e instanceof r),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=f(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,s=n.writecb;if("function"!=typeof s)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,s){--e.pendingcb,n?(i.nextTick(s,r),i.nextTick(I,t,e),t._writableState.errorEmitted=!0,_(t,r)):(s(r),t._writableState.errorEmitted=!0,_(t,r),I(t,e))}(t,n,r,e,s);else{var o=x(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||k(t,n),r?i.nextTick(A,t,n,o,s):A(t,n,o,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function L(t){var e=this instanceof(r=r||n(6753));if(!e&&!o.call(L,this))return new L(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),c.call(this)}function O(t,e,n,r,i,s,o){e.writelen=r,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new E("write")):n?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function A(t,e,n,r){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),I(t,e)}function k(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var r=e.bufferedRequestCount,i=new Array(r),o=e.corkedRequestsFree;o.entry=n;for(var a=0,c=!0;n;)i[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;i.allBuffers=c,O(t,e,!0,e.length,i,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;n;){var h=n.chunk,u=n.encoding,l=n.callback;if(O(t,e,!1,e.objectMode?1:h.length,h,u,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(n){e.pendingcb--,n&&_(t,n),e.prefinished=!0,t.emit("prefinish"),I(t,e)}))}function I(t,e){var n=x(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var r=t._readableState;(!r||r.autoDestroy&&r.endEmitted)&&t.destroy()}return n}n(5717)(L,c),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(t){return!!o.call(this,t)||this===L&&t&&t._writableState instanceof S}})):o=function(t){return t instanceof this},L.prototype.pipe=function(){_(this,new b)},L.prototype.write=function(t,e,n){var r,s=this._writableState,o=!1,a=!s.objectMode&&(r=t,h.isBuffer(r)||r instanceof u);return a&&!h.isBuffer(t)&&(t=function(t){return h.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=s.defaultEncoding),"function"!=typeof n&&(n=T),s.ending?function(t,e){var n=new v;_(t,n),i.nextTick(e,n)}(this,n):(a||function(t,e,n,r){var s;return null===n?s=new m:"string"==typeof n||e.objectMode||(s=new p("chunk",["string","Buffer"],n)),!s||(_(t,s),i.nextTick(r,s),!1)}(this,s,t,n))&&(s.pendingcb++,o=function(t,e,n,r,i,s){if(!n){var o=function(t,e,n){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=h.from(e,n)),e}(e,r,i);r!==o&&(n=!0,i="buffer",r=o)}var a=e.objectMode?1:r.length;e.length+=a;var c=e.length-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),L.prototype._write=function(t,e,n){n(new y("_write()"))},L.prototype._writev=null,L.prototype.end=function(t,e,n){var r=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),r.corked&&(r.corked=1,this.uncork()),r.ending||function(t,e,n){e.ending=!0,I(t,e),n&&(e.finished?i.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,r,n),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),L.prototype.destroy=l.destroy,L.prototype._undestroy=l.undestroy,L.prototype._destroy=function(t,e){e(t)}},5850:(t,e,n)=>{"use strict";var r,i=n(4155);function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o=n(8610),a=Symbol("lastResolve"),c=Symbol("lastReject"),h=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function p(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var n=t[d].read();null!==n&&(t[l]=null,t[a]=null,t[c]=null,e(p(n,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),E=Object.setPrototypeOf((s(r={get stream(){return this[d]},next:function(){var t=this,e=this[h];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise((function(e,n){i.nextTick((function(){t[h]?n(t[h]):e(p(void 0,!0))}))}));var n,r=this[l];if(r)n=new Promise(function(t,e){return function(n,r){t.then((function(){e[u]?n(p(void 0,!0)):e[f](n,r)}),r)}}(r,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(p(s,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),s(r,"return",(function(){var t=this;return new Promise((function(e,n){t[d].destroy(null,(function(t){t?n(t):e(p(void 0,!0))}))}))})),r),b);t.exports=function(t){var e,n=Object.create(E,(s(e={},d,{value:t,writable:!0}),s(e,a,{value:null,writable:!0}),s(e,c,{value:null,writable:!0}),s(e,h,{value:null,writable:!0}),s(e,u,{value:t._readableState.endEmitted,writable:!0}),s(e,f,{value:function(t,e){var r=n[d].read();r?(n[l]=null,n[a]=null,n[c]=null,t(p(r,!1))):(n[a]=t,n[c]=e)},writable:!0}),e));return n[l]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[c];return null!==e&&(n[l]=null,n[a]=null,n[c]=null,e(t)),void(n[h]=t)}var r=n[a];null!==r&&(n[l]=null,n[a]=null,n[c]=null,r(p(void 0,!0))),n[u]=!0})),t.on("readable",g.bind(null,n)),n}},7327:(t,e,n)=>{"use strict";function r(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){for(var n=0;n0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n}},{key:"concat",value:function(t){if(0===this.length)return o.alloc(0);for(var e,n,r,i=o.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,n=i,r=a,o.prototype.copy.call(e,n,r),a+=s.data.length,s=s.next;return i}},{key:"consume",value:function(t,e){var n;return ti.length?i.length:t;if(s===i.length?r+=i:r+=i.slice(0,t),0==(t-=s)){s===i.length?(++n,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(s));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(t){var e=o.allocUnsafe(t),n=this.head,r=1;for(n.data.copy(e),t-=n.data.length;n=n.next;){var i=n.data,s=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,s),0==(t-=s)){s===i.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=i.slice(s));break}++r}return this.length-=r,e}},{key:c,value:function(t,e){return a(this,function(t){for(var e=1;e{"use strict";var r=n(4155);function i(t,e){o(t,e),s(t)}function s(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function o(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,c=this._writableState&&this._writableState.destroyed;return a||c?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,r.nextTick(o,this,t)):r.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted?r.nextTick(s,n):(n._writableState.errorEmitted=!0,r.nextTick(i,n,t)):r.nextTick(i,n,t):e?(r.nextTick(s,n),e(t)):r.nextTick(s,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,r=t._writableState;n&&n.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}}},8610:(t,e,n)=>{"use strict";var r=n(4281).q.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,n,s){if("function"==typeof n)return t(e,null,n);n||(n={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var n=arguments.length,r=new Array(n),i=0;i{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9946:(t,e,n)=>{"use strict";var r,i=n(4281).q,s=i.ERR_MISSING_ARGS,o=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function c(t){t()}function h(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i0,(function(t){u||(u=t),t&&f.forEach(c),s||(f.forEach(c),l(u))}))}));return e.reduce(h)}},2457:(t,e,n)=>{"use strict";var r=n(4281).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,i){var s=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,i,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new r(i?n:"highWaterMark",s);return Math.floor(s)}return t.objectMode?16:16384}}},2503:(t,e,n)=>{t.exports=n(7187).EventEmitter},8473:(t,e,n)=>{(e=t.exports=n(9481)).Stream=e,e.Readable=e,e.Writable=n(4229),e.Duplex=n(6753),e.Transform=n(4605),e.PassThrough=n(2725),e.finished=n(8610),e.pipeline=n(9946)},9967:(t,e,n)=>{t.exports=function(t,e,n){if("number"!=typeof e)throw new Error("second argument must be a Number");let i,s,o,a,c,h,u=!0;function l(t){function e(){n&&n(t,i),n=null}u?r(e):e()}function f(e,n,r){if(i[e]=r,n&&(c=!0),0==--o||n)l(n);else if(!c&&h{"use strict";var r=n(396).Buffer,i=r.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(r.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=c,this.end=h,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=u,this.end=l,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function c(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function h(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function u(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.s=s,s.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(i>0&&(t.lastNeed=i-1),i):--r=0?(i>0&&(t.lastNeed=i-2),i):--r=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var r=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,r),t.toString("utf8",e,r)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},396:(t,e,n)=>{var r=n(8764),i=r.Buffer;function s(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return i(t,e,n)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=r:(s(r,e),e.Buffer=o),o.prototype=Object.create(i.prototype),s(i,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var r=i(t);return void 0!==e?"string"==typeof n?r.fill(e,n):r.fill(e):r.fill(0),r},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r.SlowBuffer(t)}},971:t=>{t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const n=t.reduce(((t,n,r,i)=>(e.ngramLengths.forEach((e=>{var s=i.slice(r,r+e);s.length===e&&(n=JSON.stringify(s),t[n]=t[n]||[],t[n].push(r))})),t)),{});return Object.keys(n).map((t=>({term:JSON.parse(t),positions:n[t]}))).sort(((t,e)=>t.term[0]>e.term[0]))}},3692:t=>{"use strict";function e(t){return Object.prototype.toString.call(t)}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function r(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n{function r(t){try{if(!n.g.localStorage)return!1}catch(t){return!1}var e=n.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(r("noDeprecation"))return t;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(e);r("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}},1861:t=>{t.exports=t=>{const e=t=>"string"==typeof t||t instanceof String,n=(r,i)=>new Promise((async s=>{return null===r?s([null,"1.00"]):(o=r)&&0===Object.keys(o).length&&Object.getPrototypeOf(o)===Object.prototype?s([[],"1.00"]):Number.isInteger(r)?s([r,r]):e(r)?s(t.tokenizer(r,i,t)):(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(r)?s((a=r,new Promise((async e=>{const r={};for(const e in a)r[e]=await n(a[e],e,t);return e(r)})))):(t=>Array.isArray(t))(r)?s((c=r,Promise.all(c.map(n)))):s(r);var o,a,c})),r=async r=>new Promise((async i=>{e(r)&&(r={body:r}),Object.prototype.hasOwnProperty.call(r,"_id")||(r._id=t.idGenerator.next().value);const s={};for(const t in r)s[t]="_id"!==t?await n(r[t],t):r[t];return i(s)}));return{processDocuments:t=>Promise.all(t.map(r))}}},2225:(t,e,n)=>{const r=n(9203),i=n(7155),{LRUCache:s}=n(4456),o=n(6291),a=n(6761),c=n(4147),h=t=>new Promise((async e=>{const r=new s({max:1e3}),c=new((await Promise.resolve().then(n.bind(n,5613))).default)({concurrency:1}),h=a(t,r,c),u=o(t,r);return h._INCREMENT_DOC_COUNT(0).then((()=>e({_AND:t.fii.AND,_BUCKET:t.fii.BUCKET,_GET:t.fii.GET,_NOT:t.fii.NOT,_OR:t.fii.OR,_CACHE:r,_PAGE:u.PAGE,_SCORE:u.SCORE,_SEARCH:u.SEARCH,_SORT:u.SORT,DELETE:h.DELETE,FLUSH:h.FLUSH,IMPORT:h.IMPORT,PUT:h.PUT,PUT_RAW:h.PUT_RAW,TOKENIZATION_PIPELINE_STAGES:i,ALL_DOCUMENTS:u.ALL_DOCUMENTS,BUCKETS:t.fii.BUCKETS,CREATED:t.fii.CREATED,DICTIONARY:u.DICTIONARY,DISTINCT:u.DISTINCT,DOCUMENTS:u.DOCUMENTS,DOCUMENT_COUNT:u.DOCUMENT_COUNT,DOCUMENT_VECTORS:u.DOCUMENT_VECTORS,EXPORT:t.fii.EXPORT,FACETS:u.FACETS,FIELDS:t.fii.FIELDS,INDEX:t.fii,LAST_UPDATED:t.fii.LAST_UPDATED,MAX:t.fii.MAX,MIN:t.fii.MIN,QUERY:u.QUERY,SEARCH:u.SEARCH})))}));t.exports=t=>((t={})=>new Promise(((e,n)=>(t=Object.assign({cacheLength:1e3,caseSensitive:!1,docExistsSpace:"DOC_RAW",idGenerator:function*(){let t=0;for(;;)yield Date.now()+"-"+t++}(),isLeaf:t=>Array.isArray(t)&&2===t.length&&t.every((t=>"string"==typeof t||"number"==typeof t||null===t)),skipFields:[],ngrams:{},replace:{},storeRawDocs:!0,stopwords:[],storeVectors:!0,tokenAppend:"#",tokenSplitRegex:/[\p{L}\d]+/gu,tokenizer:i.tokenizer},t),r(t).then((n=>e(Object.assign({fii:n},t))))))))(t).then(h).then((t=>(t=>new Promise(((e,n)=>{const r=["CREATED_WITH"],i="search-index@"+c.version;return t.INDEX.STORE.get(r,t.INDEX.LEVEL_OPTIONS).then((t=>i===t?e():n(new Error("This index was created with "+t+", you are running "+i)))).catch((n=>t.INDEX.STORE.put(r,i,t.INDEX.LEVEL_OPTIONS).then(e)))})))(t).then((()=>t))))},6291:(t,e,n)=>{const{EntryStream:r}=n(6741);t.exports=(t,e)=>{const n=e=>new Promise(((n,i)=>{const s=[];new r(t.fii.STORE,{gte:["DOC_RAW",null],lte:["DOC_RAW",void 0],limit:e,...t.fii.LEVEL_OPTIONS}).on("data",(t=>s.push({_id:t.value._id,_doc:t.value}))).on("end",(()=>n(s)))})),i=(...e)=>e.length?Promise.all(e.map((e=>t.fii.STORE.get(["DOC_RAW",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))):n(),s=(...e)=>t.fii.DISTINCT(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),o=(...e)=>t.fii.FACETS(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),a=(t,e)=>{const n=(e=Object.assign({NUMBER:0,SIZE:20},e||{})).NUMBER*e.SIZE,r=n+e.SIZE||void 0;return t.slice(n,r)},c=(t,e={})=>{e=Object.assign({TYPE:"TFIDF"},e);const n=t=>!e.FIELDS||e.FIELDS.includes(t.FIELD),r=t=>(t||[]).filter(n);return new Promise((i=>i("TFIDF"===e.TYPE?u().then((e=>t.map(((t,r,i)=>{const s=Math.log((e+1)/i.length);return t._score=+(t._match||[]).filter(n).reduce(((t,e)=>t+s*+e.SCORE),0).toFixed(2),t})))):"PRODUCT"===e.TYPE?t.map((t=>({...t,_score:+r(t._match).reduce(((t,e)=>t*+e.SCORE),1).toFixed(2)}))):"CONCAT"===e.TYPE?t.map((t=>({...t,_score:r(t._match).reduce(((t,e)=>t+e.SCORE),"")}))):"SUM"===e.TYPE?t.map((t=>({...t,_score:+r(t._match).reduce(((t,e)=>t+ +e.SCORE),0).toFixed(2)}))):"VALUE"===e.TYPE?t.map((t=>({...t,_score:r(t._match).reduce(((t,e)=>t+e.VALUE),"")}))):null)))},h=(t,e)=>(e=Object.assign({DIRECTION:"DESCENDING",TYPE:"NUMERIC"},e||{}),t.sort(((t,e)=>t._ide._id?1:0)).sort({NUMERIC:{DESCENDING:(t,e)=>+e._score-+t._score,ASCENDING:(t,e)=>+t._score-+e._score},ALPHABETIC:{DESCENDING:(t,e)=>t._scoree._score?-1:0,ASCENDING:(t,e)=>t._scoree._score?1:0}}[e.TYPE][e.DIRECTION])),u=()=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS),l=(e,r={})=>{const s=e=>"string"==typeof e||"number"==typeof e?t.fii.GET(e,r.PIPELINE):e.FIELD||e.VALUE?t.fii.GET(e):e.AND?t.fii.AND(e.AND.map(s),r.PIPELINE):e.GET?t.fii.GET(e.GET,r.PIPELINE):e.NOT?t.fii.NOT(s(e.NOT.INCLUDE),s(e.NOT.EXCLUDE)):e.OR?t.fii.OR(e.OR.map(s),r.PIPELINE):e.ALL_DOCUMENTS?n(e.ALL_DOCUMENTS):void 0;return s(e).then((t=>t.RESULT?Object.assign(t,{RESULT_LENGTH:t.RESULT.length}):{RESULT:t,RESULT_LENGTH:t.length})).then((e=>r.BUCKETS?t.fii.BUCKETS(...r.BUCKETS).then((n=>Object.assign(e,{BUCKETS:t.fii.AGGREGATION_FILTER(n,e.RESULT)}))):e)).then((n=>r.FACETS?n.RESULT.length?e.ALL_DOCUMENTS?o(...r.FACETS).then((t=>Object.assign(n,{FACETS:t}))):o(...r.FACETS).then((e=>Object.assign(n,{FACETS:t.fii.AGGREGATION_FILTER(e,n.RESULT)}))):Object.assign(n,{FACETS:[]}):n)).then((t=>{return r.WEIGHT?Object.assign({RESULT:(e=t.RESULT,n=r.WEIGHT,e.map((t=>(t._match=t._match.map((t=>(n.forEach((e=>{let n=!1;e.FIELD&&e.VALUE?e.FIELD===t.FIELD&&e.VALUE===t.VALUE&&(n=!0):e.FIELD?e.FIELD===t.FIELD&&(n=!0):e.VALUE&&e.VALUE===t.VALUE&&(n=!0),n&&(t.SCORE=(e.WEIGHT*+t.SCORE).toFixed(2))})),t))),t))))},t):t;var e,n})).then((t=>r.SCORE?c(t.RESULT,r.SCORE).then((e=>Object.assign(t,{RESULT:e}))):t)).then((t=>Object.assign(t,r.SORT?{RESULT:h(t.RESULT,r.SORT)}:{}))).then((t=>Object.assign(t,r.PAGE?{RESULT:a(t.RESULT,r.PAGE)}:{}))).then((t=>r.DOCUMENTS?i(...t.RESULT.map((t=>t._id))).then((e=>Object.assign(t,{RESULT:t.RESULT.map(((t,n)=>Object.assign(t,{_doc:e[n]})))}))):t))},f=(t,n)=>new Promise((r=>(n=JSON.stringify(n),e.has(n)?r(e.get(n)):t.then((t=>e.set(n,t))).then((()=>r(e.get(n)))))));return{ALL_DOCUMENTS:n,DICTIONARY:t=>f((t=>s(t).then((t=>Array.from(t.reduce(((t,e)=>t.add(e.VALUE)),new Set)).sort(((t,e)=>(t+"").localeCompare(e+"",void 0,{numeric:!0,sensitivity:"base"}))))))(t),{DICTIONARY:t||null}),DISTINCT:s,DOCUMENTS:(...t)=>f(i(...t),{DOCUMENTS:t}),DOCUMENT_COUNT:u,DOCUMENT_VECTORS:(...e)=>Promise.all(e.map((e=>t.fii.STORE.get(["DOC",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))),FACETS:o,PAGE:a,QUERY:(t,e)=>f(l(t,e),{QUERY:[t,e]}),SCORE:c,SEARCH:(t,e)=>f(((t,e)=>l({AND:[...t]},Object.assign({SCORE:{TYPE:"TFIDF"},SORT:!0},e)))(t,e),{SEARCH:[t,e]}),SORT:h}}},7155:(t,e,n)=>{const r=n(971),{ngraminator:i}=n(6349),s=([t,e,n])=>Promise.resolve([t.match(n.tokenSplitRegex)||[],e,n]),o=([t,e,n])=>[n.skipFields.includes(e)?[]:t,e,n],a=([t,e,n])=>Promise.resolve([t.map((t=>n.caseSensitive?t:t.toLowerCase())),e,n]),c=([t,e,n])=>{const{fields:r,values:i}=n.replace,s=()=>t.reduce(((t,e)=>[e,...t,...i[e]||[]]),[]);return i?r?r.includes(e)?Promise.resolve([s(),e,n]):Promise.resolve([t,e,n]):Promise.resolve([s(),e,n]):Promise.resolve([t,e,n])},h=([t,e,n])=>{let{fields:r,lengths:s,join:o=" "}=n.ngrams;return r||(r=[e]),s&&r.includes(e)?[i(t.filter((t=>null!==t)),s).map((t=>t.join(o))),e,n]:Promise.resolve([t,e,n])},u=([t,e,n])=>[t.filter((t=>!n.stopwords.includes(t.toLowerCase()))),e,n],l=([t,e,n])=>{const i=r(t),s=i.reduce(((t,e)=>Math.max(e.positions.length,t)),0);return Promise.resolve([i.map((t=>[t.term[0],(t.positions.length/s).toFixed(2)])).sort(),e,n])};e.SPY=([t,e,n])=>(console.log("----------------"),console.log("field ->"),console.log(e),console.log("tokens ->"),console.log(t),console.log("----------------"),Promise.resolve([t,e,n])),e.tokenizer=(t,e,n)=>s([t,e,n]).then(o).then(a).then(c).then(h).then(u).then(l).then((([t,e,n])=>t)),e.SPLIT=s,e.SKIP=o,e.LOWACASE=a,e.REPLACE=c,e.NGRAMS=h,e.STOPWORDS=u,e.SCORE_TERM_FREQUENCY=l},6761:(t,e,n)=>{const r=n(1861);t.exports=(t,e,n)=>{const i=e=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],+n+e,t.fii.LEVEL_OPTIONS))).catch((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],e,t.fii.LEVEL_OPTIONS))),s=(n,r,i)=>(e.clear(),Promise.all(n.map(((e,n)=>t.fii.STORE.put(["DOC_RAW",r[n]],i?{}:e,t.fii.LEVEL_OPTIONS)))).then((t=>n.map(((t,e)=>({_id:r[e],status:"OK",operation:"_PUT_RAW"}))))));return{DELETE:(...n)=>{return r=n,t.fii.DELETE(r,t.fii.LEVEL_OPTIONS).then((n=>{e.clear();const r=n.filter((t=>"DELETED"===t.status));return Promise.all([Promise.all(r.map((e=>t.fii.STORE.del(["DOC_RAW",e._id],t.fii.LEVEL_OPTIONS)))),(i=r.length,t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((e=>t.fii.STORE.put(["DOCUMENT_COUNT"],+e-i,t.fii.LEVEL_OPTIONS))))]).then((()=>n));var i}));var r},FLUSH:()=>t.fii.STORE.clear().then((()=>{e.clear();const n=Date.now();return t.fii.STORE.batch([{type:"put",key:["~CREATED"],value:n},{type:"put",key:["~LAST_UPDATED"],value:n},{type:"put",key:["DOCUMENT_COUNT"],value:0}],t.fii.LEVEL_OPTIONS)})).then((()=>!0)),IMPORT:n=>(e.clear(),Promise.resolve(t.fii.IMPORT(n))),PUT:(o,a)=>n.add((()=>((n,o)=>(e.clear(),o=Object.assign(t,o),r(t).processDocuments(n).then((e=>t.fii.PUT(e,o,t.fii.LEVEL_OPTIONS).then((e=>Promise.all([s(n,e.map((t=>t._id)),!t.storeRawDocs),i(e.filter((t=>"CREATED"===t.status)).length)]).then((()=>e))))))))(o,a))),PUT_RAW:s,_INCREMENT_DOC_COUNT:i}}},2361:()=>{},4616:()=>{},4456:(t,e,n)=>{"use strict";var r=n(4155);Object.defineProperty(e,"__esModule",{value:!0}),e.LRUCache=void 0;const i="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,s=new Set,o="object"==typeof r&&r?r:{},a=(t,e,n,r)=>{"function"==typeof o.emitWarning?o.emitWarning(t,e,n,r):console.error(`[${n}] ${e}: ${t}`)};let c=globalThis.AbortController,h=globalThis.AbortSignal;if(void 0===c){h=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},c=class{constructor(){e()}signal=new h;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==o.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,a("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const u=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),l=t=>u(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?f:null:null;class f extends Array{constructor(t){super(t),this.fill(0)}}class d{heap;length;static#t=!1;static create(t){const e=l(t);if(!e)return[];d.#t=!0;const n=new d(t,e);return d.#t=!1,n}constructor(t,e){if(!d.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class p{#e;#n;#r;#i;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#c;#h;#u;#l;#f;#d;#p;#y;#g;#b;#E;#m;#v;#w;#_;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#m,sizes:t.#b,keyMap:t.#c,keyList:t.#h,valList:t.#u,next:t.#l,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#y,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,r,i)=>t.#S(e,n,r,i),moveToTail:e=>t.#L(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#s}get dispose(){return this.#r}get disposeAfter(){return this.#i}constructor(t){const{max:e=0,ttl:n,ttlResolution:r=1,ttlAutopurge:i,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:h,dispose:f,disposeAfter:y,noDisposeOnSet:g,noUpdateTTL:b,maxSize:E=0,maxEntrySize:m=0,sizeCalculation:v,fetchMethod:w,noDeleteOnFetchRejection:_,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:S,allowStaleOnFetchAbort:L,ignoreFetchAbort:O}=t;if(0!==e&&!u(e))throw new TypeError("max option must be a nonnegative integer");const A=e?l(e):Array;if(!A)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=E,this.maxEntrySize=m||this.#n,this.sizeCalculation=v,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==w&&"function"!=typeof w)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=w,this.#w=!!w,this.#c=new Map,this.#h=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#l=new A(e),this.#f=new A(e),this.#d=0,this.#p=0,this.#y=d.create(e),this.#o=0,this.#a=0,"function"==typeof f&&(this.#r=f),"function"==typeof y?(this.#i=y,this.#g=[]):(this.#i=void 0,this.#g=void 0),this.#v=!!this.#r,this.#_=!!this.#i,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!b,this.noDeleteOnFetchRejection=!!_,this.allowStaleOnFetchRejection=!!S,this.allowStaleOnFetchAbort=!!L,this.ignoreFetchAbort=!!O,0!==this.maxEntrySize){if(0!==this.#n&&!u(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!u(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#x()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=u(r)||0===r?r:1,this.ttlAutopurge=!!i,this.ttl=n||0,this.ttl){if(!u(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!s.has(t))(t)&&(s.add(t),a("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,p))}}getRemainingTTL(t){return this.#c.has(t)?1/0:0}#R(){const t=new f(this.#e),e=new f(this.#e);this.#m=t,this.#E=e,this.#I=(n,r,s=i.now())=>{if(e[n]=0!==r?s:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(n)&&this.delete(this.#h[n])}),r+1);t.unref&&t.unref()}},this.#C=n=>{e[n]=0!==t[n]?i.now():0},this.#N=(i,s)=>{if(t[s]){const o=t[s],a=e[s];i.ttl=o,i.start=a,i.now=n||r();const c=i.now-a;i.remainingTTL=o-c}};let n=0;const r=()=>{const t=i.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const s=this.#c.get(i);if(void 0===s)return 0;const o=t[s],a=e[s];return 0===o||0===a?1/0:o-((n||r())-a)},this.#k=i=>0!==t[i]&&0!==e[i]&&(n||r())-e[i]>t[i]}#C=()=>{};#N=()=>{};#I=()=>{};#k=()=>!1;#x(){const t=new f(this.#e);this.#a=0,this.#b=t,this.#D=e=>{this.#a-=t[e],t[e]=0},this.#U=(t,e,n,r)=>{if(this.#T(e))return 0;if(!u(n)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!u(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#P=(e,n,r)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#a>n;)this.#M(!0)}this.#a+=t[e],r&&(r.entrySize=n,r.totalCalculatedSize=this.#a)}}#D=t=>{};#P=(t,e,n)=>{};#U=(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#d;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#l[e]}#B(t){return void 0!==t&&this.#c.get(this.#h[t])===t}*entries(){for(const t of this.#O())void 0===this.#u[t]||void 0===this.#h[t]||this.#T(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*rentries(){for(const t of this.#A())void 0===this.#u[t]||void 0===this.#h[t]||this.#T(this.#u[t])||(yield[this.#h[t],this.#u[t]])}*keys(){for(const t of this.#O()){const e=this.#h[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#h[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*values(){for(const t of this.#O())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}*rvalues(){for(const t of this.#A())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of this.#O()){const r=this.#u[n],i=this.#T(r)?r.__staleWhileFetching:r;if(void 0!==i&&t(i,this.#h[n],this))return this.get(this.#h[n],e)}}forEach(t,e=this){for(const n of this.#O()){const r=this.#u[n],i=this.#T(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#h[n],this)}}rforEach(t,e=this){for(const n of this.#A()){const r=this.#u[n],i=this.#T(r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,this.#h[n],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#h[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const n=this.#h[e],r=this.#u[e],s=this.#T(r)?r.__staleWhileFetching:r;if(void 0===s||void 0===n)continue;const o={value:s};if(this.#m&&this.#E){o.ttl=this.#m[e];const t=i.now()-this.#E[e];o.start=Math.floor(Date.now()-t)}this.#b&&(o.size=this.#b[e]),t.unshift([n,o])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=i.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:r=this.ttl,start:i,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=n;let{noUpdateTTL:c=this.noUpdateTTL}=n;const h=this.#U(t,e,n.size||0,o);if(this.maxEntrySize&&h>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let u=0===this.#o?void 0:this.#c.get(t);if(void 0===u)u=0===this.#o?this.#p:0!==this.#y.length?this.#y.pop():this.#o===this.#e?this.#M(!1):this.#o,this.#h[u]=t,this.#u[u]=e,this.#c.set(t,u),this.#l[this.#p]=u,this.#f[u]=this.#p,this.#p=u,this.#o++,this.#P(u,h,a),a&&(a.set="add"),c=!1;else{this.#L(u);const n=this.#u[u];if(e!==n){if(this.#w&&this.#T(n)?n.__abortController.abort(new Error("replaced")):s||(this.#v&&this.#r?.(n,t,"set"),this.#_&&this.#g?.push([n,t,"set"])),this.#D(u),this.#P(u,h,a),this.#u[u]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===r||this.#m||this.#R(),this.#m&&(c||this.#I(u,r,i),a&&this.#N(a,u)),!s&&this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#u[this.#d];if(this.#M(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}}}#M(t){const e=this.#d,n=this.#h[e],r=this.#u[e];return this.#w&&this.#T(r)?r.__abortController.abort(new Error("evicted")):(this.#v||this.#_)&&(this.#v&&this.#r?.(r,n,"evict"),this.#_&&this.#g?.push([r,n,"evict"])),this.#D(e),t&&(this.#h[e]=void 0,this.#u[e]=void 0,this.#y.push(e)),1===this.#o?(this.#d=this.#p=0,this.#y.length=0):this.#d=this.#l[e],this.#c.delete(n),this.#o--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,i=this.#c.get(t);if(void 0!==i){const t=this.#u[i];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(i))return n&&this.#C(i),r&&(r.has="hit",this.#N(r,i)),!0;r&&(r.has="stale",this.#N(r,i))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=this.#c.get(t);if(void 0!==r&&(n||!this.#k(r))){const t=this.#u[r];return this.#T(t)?t.__staleWhileFetching:t}}#S(t,e,n,r){const i=void 0===e?void 0:this.#u[e];if(this.#T(i))return i;const s=new c,{signal:o}=n;o?.addEventListener("abort",(()=>s.abort(o.reason)),{signal:s.signal});const a={signal:s.signal,options:n,context:r},h=(r,i=!1)=>{const{aborted:o}=s.signal,c=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(o&&!i?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,c&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!c&&!i)return u(s.signal.reason);const h=l;return this.#u[e]===l&&(void 0===r?h.__staleWhileFetching?this.#u[e]=h.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,a.options))),r},u=r=>{const{aborted:i}=s.signal,o=i&&n.allowStaleOnFetchAbort,a=o||n.allowStaleOnFetchRejection,c=a||n.noDeleteOnFetchRejection,h=l;if(this.#u[e]===l&&(c&&void 0!==h.__staleWhileFetching?o||(this.#u[e]=h.__staleWhileFetching):this.delete(t)),a)return n.status&&void 0!==h.__staleWhileFetching&&(n.status.returnedStale=!0),h.__staleWhileFetching;if(h.__returned===h)throw r};n.status&&(n.status.fetchDispatched=!0);const l=new Promise(((e,r)=>{const o=this.#s?.(t,i,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),r),s.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),u(t)))),f=Object.assign(l,{__abortController:s,__staleWhileFetching:i,__returned:void 0});return void 0===e?(this.set(t,f,{...a.options,status:void 0}),e=this.#c.get(t)):this.#u[e]=f,f}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof c}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:c=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:b}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:g});const E={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:s,noDisposeOnSet:o,size:a,sizeCalculation:c,noUpdateTTL:h,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:g,signal:b};let m=this.#c.get(t);if(void 0===m){g&&(g.fetch="miss");const e=this.#S(t,m,E,p);return e.__returned=e}{const e=this.#u[m];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=this.#k(m);if(!y&&!i)return g&&(g.fetch="hit"),this.#L(m),r&&this.#C(m),g&&this.#N(g,m),e;const s=this.#S(t,m,E,p),o=void 0!==s.__staleWhileFetching&&n;return g&&(g.fetch=i?"stale":"refresh",o&&i&&(g.returnedStale=!0)),o?s.__staleWhileFetching:s.__returned=s}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:s}=e,o=this.#c.get(t);if(void 0!==o){const e=this.#u[o],a=this.#T(e);return s&&this.#N(s,o),this.#k(o)?(s&&(s.get="stale"),a?(s&&n&&void 0!==e.__staleWhileFetching&&(s.returnedStale=!0),n?e.__staleWhileFetching:void 0):(i||this.delete(t),s&&n&&(s.returnedStale=!0),n?e:void 0)):(s&&(s.get="hit"),a?e.__staleWhileFetching:(this.#L(o),r&&this.#C(o),e))}s&&(s.get="miss")}#j(t,e){this.#f[e]=t,this.#l[t]=e}#L(t){t!==this.#p&&(t===this.#d?this.#d=this.#l[t]:this.#j(this.#f[t],this.#l[t]),this.#j(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#o){const n=this.#c.get(t);if(void 0!==n)if(e=!0,1===this.#o)this.clear();else{this.#D(n);const e=this.#u[n];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#v||this.#_)&&(this.#v&&this.#r?.(e,t,"delete"),this.#_&&this.#g?.push([e,t,"delete"])),this.#c.delete(t),this.#h[n]=void 0,this.#u[n]=void 0,n===this.#p?this.#p=this.#f[n]:n===this.#d?this.#d=this.#l[n]:(this.#l[this.#f[n]]=this.#l[n],this.#f[this.#l[n]]=this.#f[n]),this.#o--,this.#y.push(n)}}if(this.#_&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#u[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const n=this.#h[t];this.#v&&this.#r?.(e,n,"delete"),this.#_&&this.#g?.push([e,n,"delete"])}}if(this.#c.clear(),this.#u.fill(void 0),this.#h.fill(void 0),this.#m&&this.#E&&(this.#m.fill(0),this.#E.fill(0)),this.#b&&this.#b.fill(0),this.#d=0,this.#p=0,this.#y.length=0,this.#a=0,this.#o=0,this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#i?.(...e)}}}e.LRUCache=p},5613:(t,e,n)=>{"use strict";n.r(e),n.d(e,{AbortError:()=>j,default:()=>F});var r=n(6729);class i extends Error{constructor(t){super(t),this.name="TimeoutError"}}class s extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const o=t=>void 0===globalThis.DOMException?new s(t):new DOMException(t),a=t=>{const e=void 0===t.reason?o("This operation was aborted."):t.reason;return e instanceof Error?e:o(e)};var c,h=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class u{constructor(){c.set(this,[])}enqueue(t,e){const n={priority:(e={priority:0,...e}).priority,run:t};if(this.size&&h(this,c,"f")[this.size-1].priority>=e.priority)return void h(this,c,"f").push(n);const r=function(t,e,n){let r=0,i=t.length;for(;i>0;){const n=Math.trunc(i/2);let o=r+n;s=t[o],e.priority-s.priority<=0?(r=++o,i-=n+1):i=n}var s;return r}(h(this,c,"f"),n);h(this,c,"f").splice(r,0,n)}dequeue(){const t=h(this,c,"f").shift();return null==t?void 0:t.run}filter(t){return h(this,c,"f").filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return h(this,c,"f").length}}c=new WeakMap;var l,f,d,p,y,g,b,E,m,v,w,_,T,S,L,O,A,k,x,R,I,C,N,D,U,P,M=function(t,e,n,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(t,n):i?i.value=n:e.set(t,n),n},B=function(t,e,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(t):r?r.value:e.get(t)};class j extends Error{}class F extends r{constructor(t){var e,n,r,i;if(super(),l.add(this),f.set(this,void 0),d.set(this,void 0),p.set(this,0),y.set(this,void 0),g.set(this,void 0),b.set(this,0),E.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,void 0),_.set(this,0),T.set(this,void 0),S.set(this,void 0),L.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:u,...t}).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(r=t.interval)||void 0===r?void 0:r.toString())&&void 0!==i?i:""}\` (${typeof t.interval})`);M(this,f,t.carryoverConcurrencyCount,"f"),M(this,d,t.intervalCap===Number.POSITIVE_INFINITY||0===t.interval,"f"),M(this,y,t.intervalCap,"f"),M(this,g,t.interval,"f"),M(this,v,new t.queueClass,"f"),M(this,w,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,M(this,L,!0===t.throwOnTimeout,"f"),M(this,S,!1===t.autoStart,"f")}get concurrency(){return B(this,T,"f")}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);M(this,T,t,"f"),B(this,l,"m",D).call(this)}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:B(this,L,"f"),...e},new Promise(((n,r)=>{B(this,v,"f").enqueue((async()=>{var s,o,c;M(this,_,(o=B(this,_,"f"),++o),"f"),M(this,p,(c=B(this,p,"f"),++c),"f");try{if(null===(s=e.signal)||void 0===s?void 0:s.aborted)throw new j("The task was aborted.");let r=t({signal:e.signal});e.timeout&&(r=function(t,e,n,r){let s;const o=new Promise(((o,c)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:t}=r;t.aborted&&c(a(t)),t.addEventListener("abort",(()=>{c(a(t))}))}s=r.customTimers.setTimeout.call(void 0,(()=>{const r=n instanceof Error?n:new i(`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),c(r)}),e),(async()=>{try{o(await t)}catch(t){c(t)}finally{r.customTimers.clearTimeout.call(void 0,s)}})()}else o(t)}));return o.clear=()=>{clearTimeout(s),s=void 0},o}(Promise.resolve(r),e.timeout)),e.signal&&(r=Promise.race([r,B(this,l,"m",U).call(this,e.signal)]));const o=await r;n(o),this.emit("completed",o)}catch(t){if(t instanceof i&&!e.throwOnTimeout)return void n();r(t),this.emit("error",t)}finally{B(this,l,"m",k).call(this)}}),e),this.emit("add"),B(this,l,"m",I).call(this)}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return B(this,S,"f")?(M(this,S,!1,"f"),B(this,l,"m",D).call(this),this):this}pause(){M(this,S,!0,"f")}clear(){M(this,v,new(B(this,w,"f")),"f")}async onEmpty(){0!==B(this,v,"f").size&&await B(this,l,"m",P).call(this,"empty")}async onSizeLessThan(t){B(this,v,"f").sizeB(this,v,"f").size{B(this,l,"m",x).call(this)}),e),"f"),!0;M(this,p,B(this,f,"f")?B(this,_,"f"):0,"f")}return!1},I=function(){if(0===B(this,v,"f").size)return B(this,E,"f")&&clearInterval(B(this,E,"f")),M(this,E,void 0,"f"),this.emit("empty"),0===B(this,_,"f")&&this.emit("idle"),!1;if(!B(this,S,"f")){const t=!B(this,l,"a",R);if(B(this,l,"a",O)&&B(this,l,"a",A)){const e=B(this,v,"f").dequeue();return!!e&&(this.emit("active"),e(),t&&B(this,l,"m",C).call(this),!0)}}return!1},C=function(){B(this,d,"f")||void 0!==B(this,E,"f")||(M(this,E,setInterval((()=>{B(this,l,"m",N).call(this)}),B(this,g,"f")),"f"),M(this,b,Date.now()+B(this,g,"f"),"f"))},N=function(){0===B(this,p,"f")&&0===B(this,_,"f")&&B(this,E,"f")&&(clearInterval(B(this,E,"f")),M(this,E,void 0,"f")),M(this,p,B(this,f,"f")?B(this,_,"f"):0,"f"),B(this,l,"m",D).call(this)},D=function(){for(;B(this,l,"m",I).call(this););},U=async function(t){return new Promise(((e,n)=>{t.addEventListener("abort",(()=>{n(new j("The task was aborted."))}),{once:!0})}))},P=async function(t,e){return new Promise((n=>{const r=()=>{e&&!e()||(this.off(t,r),n())};this.on(t,r)}))}},4147:t=>{"use strict";t.exports=JSON.parse('{"name":"search-index","version":"4.0.0","description":"A network resilient, persistent full-text search library for the browser and Node.js","keywords":["search","elasticsearch","elastic","lunr.js","flexsearch","norch","solr"],"engines":{"node":">=12"},"main":"src/node.js","browser":"src/browser.js","files":["dist","src"],"directories":{"lib":"src"},"scripts":{"build":"npm run empty-sandbox && rm -rf ./dist/* && webpack && cp dist/search-index-$npm_package_version.js dist/search-index.js","demo-export":"node demo/generate-index/export.js","demo-fetch":"node demo/generate-index/fetch.js","demo-process":"node demo/generate-index/process.js","demo-rebuild":"npm run demo-fetch && npm run demo-process && npm run demo-export && npm run demo-link-lib","demo-start":"http-server -c-1 demo & open-cli http://127.0.0.1:8080","demo-link-lib":"cd demo/lib && ln -sf ../../dist/search-index.js && cd ../../","empty-sandbox":"rm -rf fii && rm -rf test/sandbox && mkdir test/sandbox","lint":"standard --fix test/src/* src/* demo/src/* demo/generate-index/*.js","test":"npm run empty-sandbox && npm run test-node && npm run test-browser && npm run lint","test-browser":"npm run build && cat test/sandbox/browser-tests.js | tape-run","test-node":"npm run empty-sandbox && tape test/src/*-test.js","toc":"doctoc docs/API.md --title \'# API Documentation for search-index\' && doctoc docs/FAQ.md --title \'# FAQ\'"},"repository":{"type":"git","url":"git+https://github.com/fergiemcdowall/search-index.git"},"author":"Fergus McDowall","license":"MIT","bugs":{"url":"https://github.com/fergiemcdowall/search-index/issues"},"homepage":"https://fergiemcdowall.github.io/search-index/","devDependencies":{"assert":"^2.0.0","classic-level":"^1.3.0","doctoc":"2.2.1","fuzzyset":"1.0.5","http-server":"14.1.1","level-out":"^1.0.1","memory-level":"^1.0.0","open-cli":"7.2.0","os-browserify":"^0.3.0","path":"^0.12.7","path-browserify":"^1.0.1","process":"^0.11.10","standard":"17.1.0","stemmer":"1.0.5","stopword":"2.0.8","stream-browserify":"^3.0.0","tape":"5.6.3","tape-run":"^10.0.0","webpack":"5.87.0","webpack-cli":"5.1.4","world-bank-dataset":"^1.0.0"},"dependencies":{"fergies-inverted-index":"12.0.0","browser-level":"^1.0.1","charwise":"^3.0.1","level-read-stream":"^1.1.0","lru-cache":"10.0.0","memory-level":"^1.0.0","ngraminator":"3.0.2","p-queue":"7.3.4","term-vector":"^1.0.0"}}')}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var s=e[r]={exports:{}};return t[r].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r=n(2225);SearchIndex=r})(); \ No newline at end of file +var SearchIndex;(()=>{var t={9464:(t,e,n)=>{"use strict";const{fromCallback:i}=n(6957),r=n(4473),{getCallback:s,getOptions:o}=n(2520),a=Symbol("promise"),h=Symbol("status"),c=Symbol("operations"),u=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[c]=[],this[l]=[],this[h]="open",this[u]=this[u].bind(this),this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get length(){return this[c].length}put(t,e,n){if("open"!==this[h])throw new r("Batch is not open: cannot call put() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const i=this.db._checkKey(t)||this.db._checkValue(e);if(i)throw i;const s=n&&null!=n.sublevel?n.sublevel:this.db,o=n,a=s.keyEncoding(n&&n.keyEncoding),u=s.valueEncoding(n&&n.valueEncoding),l=a.format;n={...n,keyEncoding:l,valueEncoding:u.format},s!==this.db&&(n.sublevel=null);const f=s.prefixKey(a.encode(t),l),d=u.encode(e);return this._put(f,d,n),this[c].push({...o,type:"put",key:t,value:e}),this}_put(t,e,n){}del(t,e){if("open"!==this[h])throw new r("Batch is not open: cannot call del() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});const n=this.db._checkKey(t);if(n)throw n;const i=e&&null!=e.sublevel?e.sublevel:this.db,s=e,o=i.keyEncoding(e&&e.keyEncoding),a=o.format;return e={...e,keyEncoding:a},i!==this.db&&(e.sublevel=null),this._del(i.prefixKey(o.encode(t),a),e),this[c].push({...s,type:"del",key:t}),this}_del(t,e){}clear(){if("open"!==this[h])throw new r("Batch is not open: cannot call clear() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"});return this._clear(),this[c]=[],this}_clear(){}write(t,e){return e=s(t,e),e=i(e,a),t=o(t),"open"!==this[h]?this.nextTick(e,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"})):0===this.length?this.close(e):(this[h]="writing",this._write(t,(t=>{this[h]="closing",this[l].push((()=>e(t))),t||this.db.emit("batch",this[c]),this._close(this[u])}))),e[a]}_write(t,e){}close(t){return t=i(t,a),"closing"===this[h]?this[l].push(t):"closed"===this[h]?this.nextTick(t):(this[l].push(t),"writing"!==this[h]&&(this[h]="closing",this._close(this[u]))),t[a]}_close(t){this.nextTick(t)}[u](){this[h]="closed",this.db.detachResource(this);const t=this[l];this[l]=[];for(const e of t)e()}}},3961:(t,e,n)=>{"use strict";const{fromCallback:i}=n(6957),r=n(4473),{getOptions:s,getCallback:o}=n(2520),a=Symbol("promise"),h=Symbol("callback"),c=Symbol("working"),u=Symbol("handleOne"),l=Symbol("handleMany"),f=Symbol("autoClose"),d=Symbol("finishWork"),p=Symbol("returnMany"),y=Symbol("closing"),g=Symbol("handleClose"),b=Symbol("closed"),E=Symbol("closeCallbacks"),m=Symbol("keyEncoding"),v=Symbol("valueEncoding"),w=Symbol("abortOnClose"),_=Symbol("legacy"),T=Symbol("keys"),S=Symbol("values"),L=Symbol("limit"),O=Symbol("count"),A=Object.freeze({}),k=()=>{};let x=!1;class R{constructor(t,e,n){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[b]=!1,this[E]=[],this[c]=!1,this[y]=!1,this[f]=!1,this[h]=null,this[u]=this[u].bind(this),this[l]=this[l].bind(this),this[g]=this[g].bind(this),this[m]=e[m],this[v]=e[v],this[_]=n,this[L]=Number.isInteger(e.limit)&&e.limit>=0?e.limit:1/0,this[O]=0,this[w]=!!e.abortOnClose,this.db=t,this.db.attachResource(this),this.nextTick=t.nextTick}get count(){return this[O]}get limit(){return this[L]}next(t){let e;if(void 0===t)e=new Promise(((e,n)=>{t=(t,i,r)=>{t?n(t):this[_]?void 0===i&&void 0===r?e():e([i,r]):e(i)}}));else if("function"!=typeof t)throw new TypeError("Callback must be a function");return this[y]?this.nextTick(t,new r("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(t,new r("Iterator is busy: cannot call next() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=t,this[O]>=this[L]?this.nextTick(this[u],null):this._next(this[u])),e}_next(t){this.nextTick(t)}nextv(t,e,n){return n=o(e,n),n=i(n,a),e=s(e,A),Number.isInteger(t)?(this[y]?this.nextTick(n,new r("Iterator is not open: cannot call nextv() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(n,new r("Iterator is busy: cannot call nextv() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(t<1&&(t=1),this[L]<1/0&&(t=Math.min(t,this[L]-this[O])),this[c]=!0,this[h]=n,t<=0?this.nextTick(this[l],null,[]):this._nextv(t,e,this[l])),n[a]):(this.nextTick(n,new TypeError("The first argument 'size' must be an integer")),n[a])}_nextv(t,e,n){const i=[],r=(e,s,o)=>e?n(e):(this[_]?void 0===s&&void 0===o:void 0===s)?n(null,i):(i.push(this[_]?[s,o]:s),void(i.length===t?n(null,i):this._next(r)));this._next(r)}all(t,e){return e=o(t,e),e=i(e,a),t=s(t,A),this[y]?this.nextTick(e,new r("Iterator is not open: cannot call all() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this[c]?this.nextTick(e,new r("Iterator is busy: cannot call all() until previous call has completed",{code:"LEVEL_ITERATOR_BUSY"})):(this[c]=!0,this[h]=e,this[f]=!0,this[O]>=this[L]?this.nextTick(this[l],null,[]):this._all(t,this[l])),e[a]}_all(t,e){let n=this[O];const i=[],r=()=>{const t=this[L]<1/0?Math.min(1e3,this[L]-n):1e3;t<=0?this.nextTick(e,null,i):this._nextv(t,A,s)},s=(t,s)=>{t?e(t):0===s.length?e(null,i):(i.push.apply(i,s),n+=s.length,r())};r()}[d](){const t=this[h];return this[w]&&null===t?k:(this[c]=!1,this[h]=null,this[y]&&this._close(this[g]),t)}[p](t,e,n){this[f]?this.close(t.bind(null,e,n)):t(e,n)}seek(t,e){if(e=s(e,A),this[y]);else{if(this[c])throw new r("Iterator is busy: cannot call seek() until next() has completed",{code:"LEVEL_ITERATOR_BUSY"});{const n=this.db.keyEncoding(e.keyEncoding||this[m]),i=n.format;e.keyEncoding!==i&&(e={...e,keyEncoding:i});const r=this.db.prefixKey(n.encode(t),i);this._seek(r,e)}}}_seek(t,e){throw new r("Iterator does not support seek()",{code:"LEVEL_NOT_SUPPORTED"})}close(t){return t=i(t,a),this[b]?this.nextTick(t):this[y]?this[E].push(t):(this[y]=!0,this[E].push(t),this[c]?this[w]&&this[d]()(new r("Aborted on iterator close()",{code:"LEVEL_ITERATOR_NOT_OPEN"})):this._close(this[g])),t[a]}_close(t){this.nextTick(t)}[g](){this[b]=!0,this.db.detachResource(this);const t=this[E];this[E]=[];for(const e of t)e()}async*[Symbol.asyncIterator](){try{let t;for(;void 0!==(t=await this.next());)yield t}finally{this[b]||await this.close()}}}class I extends R{constructor(t,e){super(t,e,!0),this[T]=!1!==e.keys,this[S]=!1!==e.values}[u](t,e,n){const i=this[d]();if(t)return i(t);try{e=this[T]&&void 0!==e?this[m].decode(e):void 0,n=this[S]&&void 0!==n?this[v].decode(n):void 0}catch(t){return i(new C("entry",t))}void 0===e&&void 0===n||this[O]++,i(null,e,n)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(const t of e){const e=t[0],n=t[1];t[0]=this[T]&&void 0!==e?this[m].decode(e):void 0,t[1]=this[S]&&void 0!==n?this[v].decode(n):void 0}}catch(t){return this[p](n,new C("entries",t))}this[O]+=e.length,this[p](n,null,e)}end(t){return x||"undefined"==typeof console||(x=!0,console.warn(new r("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 C extends r{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(I.prototype,t.split(" ")[0],{get(){throw new r(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})},set(){throw new r(`The ${t} has been removed`,{code:"LEVEL_LEGACY"})}});I.keyEncoding=m,I.valueEncoding=v,e.AbstractIterator=I,e.AbstractKeyIterator=class extends R{constructor(t,e){super(t,e,!1)}[u](t,e){const n=this[d]();if(t)return n(t);try{e=void 0!==e?this[m].decode(e):void 0}catch(t){return n(new C("key",t))}void 0!==e&&this[O]++,n(null,e)}[l](t,e){const n=this[d]();if(t)return this[p](n,t);try{for(let t=0;t{"use strict";const{supports:i}=n(3658),{Transcoder:r}=n(8499),{EventEmitter:s}=n(7187),{fromCallback:o}=n(6957),a=n(4473),{AbstractIterator:h}=n(3961),{DefaultKeyIterator:c,DefaultValueIterator:u}=n(5429),{DeferredIterator:l,DeferredKeyIterator:f,DeferredValueIterator:d}=n(593),{DefaultChainedBatch:p}=n(4765),{getCallback:y,getOptions:g}=n(2520),b=n(56),E=Symbol("promise"),m=Symbol("landed"),v=Symbol("resources"),w=Symbol("closeResources"),_=Symbol("operations"),T=Symbol("undefer"),S=Symbol("deferOpen"),L=Symbol("options"),O=Symbol("status"),A=Symbol("defaultOptions"),k=Symbol("transcoder"),x=Symbol("keyEncoding"),R=Symbol("valueEncoding"),I=()=>{};class C extends s{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:n,valueEncoding:s,passive:o,...a}=e;this[v]=new Set,this[_]=[],this[S]=!0,this[L]=a,this[O]="opening",this.supports=i(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[k]=new r(U(this)),this[x]=this[k].encoding(n||"utf8"),this[R]=this[k].encoding(s||"utf8");for(const t of this[k].encodings())this.supports.encodings[t.commonName]||(this.supports.encodings[t.commonName]=!0);this[A]={empty:Object.freeze({}),entry:Object.freeze({keyEncoding:this[x].commonName,valueEncoding:this[R].commonName}),key:Object.freeze({keyEncoding:this[x].commonName})},this.nextTick((()=>{this[S]&&this.open({passive:!1},I)}))}get status(){return this[O]}keyEncoding(t){return this[k].encoding(null!=t?t:this[x])}valueEncoding(t){return this[k].encoding(null!=t?t:this[R])}open(t,e){e=y(t,e),e=o(e,E),(t={...this[L],...g(t)}).createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists;const n=t=>{"closing"===this[O]||"opening"===this[O]?this.once(m,t?()=>n(t):n):"open"!==this[O]?e(new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN",cause:t})):e()};return t.passive?"opening"===this[O]?this.once(m,n):this.nextTick(n):"closed"===this[O]||this[S]?(this[S]=!1,this[O]="opening",this.emit("opening"),this._open(t,(t=>{if(t)return this[O]="closed",this[w]((()=>{this.emit(m),n(t)})),void this[T]();this[O]="open",this[T](),this.emit(m),"open"===this[O]&&this.emit("open"),"open"===this[O]&&this.emit("ready"),n()}))):"open"===this[O]?this.nextTick(n):this.once(m,(()=>this.open(t,e))),e[E]}_open(t,e){this.nextTick(e)}close(t){t=o(t,E);const e=n=>{"opening"===this[O]||"closing"===this[O]?this.once(m,n?e(n):e):"closed"!==this[O]?t(new a("Database is not closed",{code:"LEVEL_DATABASE_NOT_CLOSED",cause:n})):t()};if("open"===this[O]){this[O]="closing",this.emit("closing");const t=t=>{this[O]="open",this[T](),this.emit(m),e(t)};this[w]((()=>{this._close((n=>{if(n)return t(n);this[O]="closed",this[T](),this.emit(m),"closed"===this[O]&&this.emit("closed"),e()}))}))}else"closed"===this[O]?this.nextTick(e):this.once(m,(()=>this.close(t)));return t[E]}[w](t){if(0===this[v].size)return this.nextTick(t);let e=this[v].size,n=!0;const i=()=>{0==--e&&(n?this.nextTick(t):t())};for(const t of this[v])t.close(i);n=!1,this[v].clear()}_close(t){this.nextTick(t)}get(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.get(t,e,n))),n[E];if(D(this,n))return n[E];const i=this._checkKey(t);if(i)return this.nextTick(n,i),n[E];const r=this.keyEncoding(e.keyEncoding),s=this.valueEncoding(e.valueEncoding),h=r.format,c=s.format;return e.keyEncoding===h&&e.valueEncoding===c||(e=Object.assign({},e,{keyEncoding:h,valueEncoding:c})),this._get(this.prefixKey(r.encode(t),h),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)),n(t);try{e=s.decode(e)}catch(t){return n(new a("Could not decode value",{code:"LEVEL_DECODE_ERROR",cause:t}))}n(null,e)})),n[E]}_get(t,e,n){this.nextTick(n,new Error("NotFound"))}getMany(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].entry),"opening"===this[O])return this.defer((()=>this.getMany(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'keys' must be an array")),n[E];if(0===t.length)return this.nextTick(n,null,[]),n[E];const i=this.keyEncoding(e.keyEncoding),r=this.valueEncoding(e.valueEncoding),s=i.format,h=r.format;e.keyEncoding===s&&e.valueEncoding===h||(e=Object.assign({},e,{keyEncoding:s,valueEncoding:h}));const c=new Array(t.length);for(let e=0;e{if(t)return n(t);try{for(let t=0;tthis.put(t,e,n,i))),i[E];if(D(this,i))return i[E];const r=this._checkKey(t)||this._checkValue(e);if(r)return this.nextTick(i,r),i[E];const s=this.keyEncoding(n.keyEncoding),a=this.valueEncoding(n.valueEncoding),h=s.format,c=a.format;n.keyEncoding===h&&n.valueEncoding===c||(n=Object.assign({},n,{keyEncoding:h,valueEncoding:c}));const u=this.prefixKey(s.encode(t),h),l=a.encode(e);return this._put(u,l,n,(n=>{if(n)return i(n);this.emit("put",t,e),i()})),i[E]}_put(t,e,n,i){this.nextTick(i)}del(t,e,n){if(n=y(e,n),n=o(n,E),e=g(e,this[A].key),"opening"===this[O])return this.defer((()=>this.del(t,e,n))),n[E];if(D(this,n))return n[E];const i=this._checkKey(t);if(i)return this.nextTick(n,i),n[E];const r=this.keyEncoding(e.keyEncoding),s=r.format;return e.keyEncoding!==s&&(e=Object.assign({},e,{keyEncoding:s})),this._del(this.prefixKey(r.encode(t),s),e,(e=>{if(e)return n(e);this.emit("del",t),n()})),n[E]}_del(t,e,n){this.nextTick(n)}batch(t,e,n){if(!arguments.length){if("opening"===this[O])return new p(this);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._chainedBatch()}if(n="function"==typeof t?t:y(e,n),n=o(n,E),e=g(e,this[A].empty),"opening"===this[O])return this.defer((()=>this.batch(t,e,n))),n[E];if(D(this,n))return n[E];if(!Array.isArray(t))return this.nextTick(n,new TypeError("The first argument 'operations' must be an array")),n[E];if(0===t.length)return this.nextTick(n),n[E];const i=new Array(t.length),{keyEncoding:r,valueEncoding:s,...h}=e;for(let e=0;e{if(e)return n(e);this.emit("batch",t),n()})),n[E]}_batch(t,e,n){this.nextTick(n)}sublevel(t,e){return this._sublevel(t,N.defaults(e))}_sublevel(t,e){return new N(this,t,e)}prefixKey(t,e){return t}clear(t,e){if(e=y(t,e),e=o(e,E),t=g(t,this[A].empty),"opening"===this[O])return this.defer((()=>this.clear(t,e))),e[E];if(D(this,e))return e[E];const n=t,i=this.keyEncoding(t.keyEncoding);return(t=b(t,i)).keyEncoding=i.format,0===t.limit?this.nextTick(e):this._clear(t,(t=>{if(t)return e(t);this.emit("clear",n),e()})),e[E]}_clear(t,e){this.nextTick(e)}iterator(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e)).keys=!1!==t.keys,t.values=!1!==t.values,t[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new l(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._iterator(t)}_iterator(t){return new h(this,t)}keys(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new f(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._keys(t)}_keys(t){return new c(this,t)}values(t){const e=this.keyEncoding(t&&t.keyEncoding),n=this.valueEncoding(t&&t.valueEncoding);if((t=b(t,e))[h.keyEncoding]=e,t[h.valueEncoding]=n,t.keyEncoding=e.format,t.valueEncoding=n.format,"opening"===this[O])return new d(this,t);if("open"!==this[O])throw new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"});return this._values(t)}_values(t){return new u(this,t)}defer(t){if("function"!=typeof t)throw new TypeError("The first argument must be a function");this[_].push(t)}[T](){if(0===this[_].length)return;const t=this[_];this[_]=[];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 p(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"})}}C.prototype.nextTick=n(6909);const{AbstractSublevel:N}=n(9650)({AbstractLevel:C});e.AbstractLevel=C,e.AbstractSublevel=N;const D=function(t,e){return"open"!==t[O]&&(t.nextTick(e,new a("Database is not open",{code:"LEVEL_DATABASE_NOT_OPEN"})),!0)},U=function(t){return Object.keys(t.supports.encodings).filter((e=>!!t.supports.encodings[e]))}},875:(t,e,n)=>{"use strict";e.AbstractLevel=n(9071).AbstractLevel,e.AbstractSublevel=n(9071).AbstractSublevel,e.AbstractIterator=n(3961).AbstractIterator,e.AbstractKeyIterator=n(3961).AbstractKeyIterator,e.AbstractValueIterator=n(3961).AbstractValueIterator,e.AbstractChainedBatch=n(9464).AbstractChainedBatch},2970:(t,e,n)=>{"use strict";const{AbstractIterator:i,AbstractKeyIterator:r,AbstractValueIterator:s}=n(3961),o=Symbol("unfix"),a=Symbol("iterator"),h=Symbol("handleOne"),c=Symbol("handleMany"),u=Symbol("callback");class l extends i{constructor(t,e,n,i){super(t,e),this[a]=n,this[o]=i,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[u]=null}[h](t,e,n){const i=this[u];if(t)return i(t);void 0!==e&&(e=this[o](e)),i(t,e,n)}[c](t,e){const n=this[u];if(t)return n(t);for(const t of e){const e=t[0];void 0!==e&&(t[0]=this[o](e))}n(t,e)}}class f extends r{constructor(t,e,n,i){super(t,e),this[a]=n,this[o]=i,this[h]=this[h].bind(this),this[c]=this[c].bind(this),this[u]=null}[h](t,e){const n=this[u];if(t)return n(t);void 0!==e&&(e=this[o](e)),n(t,e)}[c](t,e){const n=this[u];if(t)return n(t);for(let t=0;t{"use strict";const i=n(4473),{Buffer:r}=n(8764)||{},{AbstractSublevelIterator:s,AbstractSublevelKeyIterator:o,AbstractSublevelValueIterator:a}=n(2970),h=Symbol("prefix"),c=Symbol("upperBound"),u=Symbol("prefixRange"),l=Symbol("parent"),f=Symbol("unfix"),d=new TextEncoder,p={separator:"!"};t.exports=function({AbstractLevel:t}){class e extends t{static defaults(t){if("string"==typeof t)throw new i("The subleveldown string shorthand for { separator } has been removed",{code:"LEVEL_LEGACY"});if(t&&t.open)throw new i("The subleveldown open option has been removed",{code:"LEVEL_LEGACY"});return null==t?p:t.separator?t:{...t,separator:"!"}}constructor(t,n,r){const{separator:s,manifest:o,...a}=e.defaults(r);n=m(n,s);const u=s.charCodeAt(0)+1,p=t[l]||t;if(!d.encode(n).every((t=>t>u&&t<127)))throw new i(`Prefix must use bytes > ${u} < 127`,{code:"LEVEL_INVALID_PREFIX"});super(y(p,o),a);const g=(t.prefix||"")+s+n+s,v=g.slice(0,-1)+String.fromCharCode(u);this[l]=p,this[h]=new b(g),this[c]=new b(v),this[f]=new E,this.nextTick=p.nextTick}prefixKey(t,e){if("utf8"===e)return this[h].utf8+t;if(0===t.byteLength)return this[h][e];if("view"===e){const e=this[h].view,n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n}{const e=this[h].buffer;return r.concat([e,t],e.byteLength+t.byteLength)}}[u](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[h][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[c][e]}get prefix(){return this[h].utf8}get db(){return this[l]}_open(t,e){this[l].open({passive:!0},e)}_put(t,e,n,i){this[l].put(t,e,n,i)}_get(t,e,n){this[l].get(t,e,n)}_getMany(t,e,n){this[l].getMany(t,e,n)}_del(t,e,n){this[l].del(t,e,n)}_batch(t,e,n){this[l].batch(t,e,n)}_clear(t,e){this[u](t,t.keyEncoding),this[l].clear(t,e)}_iterator(t){this[u](t,t.keyEncoding);const e=this[l].iterator(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new s(this,t,e,n)}_keys(t){this[u](t,t.keyEncoding);const e=this[l].keys(t),n=this[f].get(this[h].utf8.length,t.keyEncoding);return new o(this,t,e,n)}_values(t){this[u](t,t.keyEncoding);const e=this[l].values(t);return new a(this,t,e)}}return{AbstractSublevel:e}};const y=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 b{constructor(t){this.utf8=t,this.view=d.encode(t),this.buffer=r?r.from(this.view.buffer,0,this.view.byteLength):{}}}class E{constructor(){this.cache=new Map}get(t,e){let n=this.cache.get(e);return void 0===n&&(n="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,n)),n}}const m=function(t,e){let n=0,i=t.length;for(;nn&&t[i-1]===e;)i--;return t.slice(n,i)}},2520:(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:{}}},4765:(t,e,n)=>{"use strict";const{AbstractChainedBatch:i}=n(9464),r=n(4473),s=Symbol("encoded");e.DefaultChainedBatch=class extends i{constructor(t){super(t),this[s]=[]}_put(t,e,n){this[s].push({...n,type:"put",key:t,value:e})}_del(t,e){this[s].push({...e,type:"del",key:t})}_clear(){this[s]=[]}_write(t,e){"opening"===this.db.status?this.db.defer((()=>this._write(t,e))):"open"===this.db.status?0===this[s].length?this.nextTick(e):this.db._batch(this[s],t,e):this.nextTick(e,new r("Batch is not open: cannot call write() after write() or close()",{code:"LEVEL_BATCH_NOT_OPEN"}))}}},5429:(t,e,n)=>{"use strict";const{AbstractKeyIterator:i,AbstractValueIterator:r}=n(3961),s=Symbol("iterator"),o=Symbol("callback"),a=Symbol("handleOne"),h=Symbol("handleMany");class c extends i{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!0,values:!1}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}class u extends r{constructor(t,e){super(t,e),this[s]=t.iterator({...e,keys:!1,values:!0}),this[a]=this[a].bind(this),this[h]=this[h].bind(this)}}for(const t of[c,u]){const e=t===c,n=e?t=>t[0]:t=>t[1];t.prototype._next=function(t){this[o]=t,this[s].next(this[a])},t.prototype[a]=function(t,n,i){const r=this[o];t?r(t):r(null,e?n:i)},t.prototype._nextv=function(t,e,n){this[o]=n,this[s].nextv(t,e,this[h])},t.prototype._all=function(t,e){this[o]=e,this[s].all(t,this[h])},t.prototype[h]=function(t,e){const i=this[o];t?i(t):i(null,e.map(n))},t.prototype._seek=function(t,e){this[s].seek(t,e)},t.prototype._close=function(t){this[s].close(t)}}e.DefaultKeyIterator=c,e.DefaultValueIterator=u},593:(t,e,n)=>{"use strict";const{AbstractIterator:i,AbstractKeyIterator:r,AbstractValueIterator:s}=n(3961),o=n(4473),a=Symbol("nut"),h=Symbol("undefer"),c=Symbol("factory");class u extends i{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.iterator(e),this.db.defer((()=>this[h]()))}}class l extends r{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.keys(e),this.db.defer((()=>this[h]()))}}class f extends s{constructor(t,e){super(t,e),this[a]=null,this[c]=()=>t.values(e),this.db.defer((()=>this[h]()))}}for(const t of[u,l,f])t.prototype[h]=function(){"open"===this.db.status&&(this[a]=this[c]())},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 o("Iterator is not open: cannot call next() after close()",{code:"LEVEL_ITERATOR_NOT_OPEN"}))},t.prototype._nextv=function(t,e,n){null!==this[a]?this[a].nextv(t,e,n):"opening"===this.db.status?this.db.defer((()=>this._nextv(t,e,n))):this.nextTick(n,new o("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 o("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=u,e.DeferredKeyIterator=l,e.DeferredValueIterator=f},6909:(t,e,n)=>{"use strict";const i=n(4375);t.exports=function(t,...e){0===e.length?i(t):i((()=>t(...e)))}},56:(t,e,n)=>{"use strict";const i=n(4473),r=Object.prototype.hasOwnProperty,s=new Set(["lt","lte","gt","gte"]);t.exports=function(t,e){const n={};for(const o in t)if(r.call(t,o)&&"keyEncoding"!==o&&"valueEncoding"!==o){if("start"===o||"end"===o)throw new i(`The legacy range option '${o}' has been removed`,{code:"LEVEL_LEGACY"});if("encoding"===o)throw new i("The levelup-style 'encoding' alias has been removed, use 'valueEncoding' instead",{code:"LEVEL_LEGACY"});s.has(o)?n[o]=e.encode(t[o]):n[o]=t[o]}return n.reverse=!!n.reverse,n.limit=Number.isInteger(n.limit)&&n.limit>=0?n.limit:-1,n}},3658:(t,e)=>{"use strict";e.supports=function(...t){const e=t.reduce(((t,e)=>Object.assign(t,e)),{});return Object.assign(e,{snapshots:e.snapshots||!1,permanence:e.permanence||!1,seek:e.seek||!1,clear:e.clear||!1,getMany:e.getMany||!1,keyIterator:e.keyIterator||!1,valueIterator:e.valueIterator||!1,iteratorNextv:e.iteratorNextv||!1,iteratorAll:e.iteratorAll||!1,status:e.status||!1,createIfMissing:e.createIfMissing||!1,errorIfExists:e.errorIfExists||!1,deferredOpen:e.deferredOpen||!1,promises:e.promises||!1,streams:e.streams||!1,encodings:Object.assign({},e.encodings),events:Object.assign({},e.events),additionalMethods:Object.assign({},e.additionalMethods)})}},9742:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,s=a(t),o=s[0],h=s[1],c=new r(function(t,e,n){return 3*(e+n)/4-n}(0,o,h)),u=0,l=h>0?o-4:o;for(n=0;n>16&255,c[u++]=e>>8&255,c[u++]=255&e;return 2===h&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,c[u++]=255&e),1===h&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e),c},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,s=[],o=16383,a=0,c=i-r;ac?c:a+o));return 1===r?(e=t[i-1],s.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],s.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),s.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],i[s.charCodeAt(o)]=o;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function h(t,e,i){for(var r,s,o=[],a=e;a>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},1708:(t,e,n)=>{"use strict";const{AbstractLevel:i}=n(875),r=n(4473),s=n(9967),{fromCallback:o}=n(6957),{Iterator:a}=n(8212),h=n(9687),c=n(9968),u=n(1217),l="level-js-",f=Symbol("idb"),d=Symbol("namePrefix"),p=Symbol("location"),y=Symbol("version"),g=Symbol("store"),b=Symbol("onComplete"),E=Symbol("promise");class m extends i{constructor(t,e,n){if("function"==typeof e||"function"==typeof n)throw new r("The levelup-style callback argument has been removed",{code:"LEVEL_LEGACY"});const{prefix:i,version:s,...o}=e||{};if(super({encodings:{view:!0},snapshots:!1,createIfMissing:!1,errorIfExists:!1,seek:!0},o),"string"!=typeof t)throw new Error("constructor requires a location string argument");this[p]=t,this[d]=null==i?l:i,this[y]=parseInt(s||1,10),this[f]=null}get location(){return this[p]}get namePrefix(){return this[d]}get version(){return this[y]}get db(){return this[f]}get type(){return"browser-level"}_open(t,e){const n=indexedDB.open(this[d]+this[p],this[y]);n.onerror=function(){e(n.error||new Error("unknown error"))},n.onsuccess=()=>{this[f]=n.result,e()},n.onupgradeneeded=t=>{const e=t.target.result;e.objectStoreNames.contains(this[p])||e.createObjectStore(this[p])}}[g](t){return this[f].transaction([this[p]],t).objectStore(this[p])}[b](t,e){const n=t.transaction;n.onabort=function(){e(n.error||new Error("aborted by user"))},n.oncomplete=function(){e(null,t.result)}}_get(t,e,n){const i=this[g]("readonly");let s;try{s=i.get(t)}catch(t){return this.nextTick(n,t)}this[b](s,(function(t,e){return t?n(t):void 0===e?n(new r("Entry not found",{code:"LEVEL_NOT_FOUND"})):void n(null,h(e))}))}_getMany(t,e,n){const i=this[g]("readonly"),r=t.map((t=>e=>{let n;try{n=i.get(t)}catch(t){return e(t)}n.onsuccess=()=>{const t=n.result;e(null,void 0===t?t:h(t))},n.onerror=t=>{t.stopPropagation(),e(n.error)}}));s(r,16,n)}_del(t,e,n){const i=this[g]("readwrite");let r;try{r=i.delete(t)}catch(t){return this.nextTick(n,t)}this[b](r,n)}_put(t,e,n,i){const r=this[g]("readwrite");let s;try{s=r.put(e,t)}catch(t){return this.nextTick(i,t)}this[b](s,i)}_iterator(t){return new a(this,this[p],t)}_batch(t,e,n){const i=this[g]("readwrite"),r=i.transaction;let s,o=0;r.onabort=function(){n(s||r.error||new Error("aborted by user"))},r.oncomplete=function(){n()},function e(){const n=t[o++],a=n.key;let h;try{h="del"===n.type?i.delete(a):i.put(n.value,a)}catch(t){return s=t,void r.abort()}o=0)return c(this,this[p],n,t,e);try{const t=this[g]("readwrite");i=n?t.delete(n):t.clear()}catch(t){return this.nextTick(e,t)}this[b](i,e)}_close(t){this[f].close(),this.nextTick(t)}}m.destroy=function(t,e,n){"function"==typeof e&&(n=e,e=l),n=o(n,E);const i=indexedDB.deleteDatabase(e+t);return i.onsuccess=function(){n()},i.onerror=function(t){n(t)},n[E]},e.BrowserLevel=m},8212:(t,e,n)=>{"use strict";const{AbstractIterator:i}=n(875),r=n(1217),s=n(9687),o=Symbol("cache"),a=Symbol("finished"),h=Symbol("options"),c=Symbol("currentOptions"),u=Symbol("position"),l=Symbol("location"),f=Symbol("first"),d={};function p(t){"function"==typeof t.commit&&t.commit()}e.Iterator=class extends i{constructor(t,e,n){super(t,n),this[o]=[],this[a]=0===this.limit,this[h]=n,this[c]={...n},this[u]=void 0,this[l]=e,this[f]=!0}_nextv(t,e,n){if(this[f]=!1,this[a])return this.nextTick(n,null,[]);if(this[o].length>0)return t=Math.min(t,this[o].length),this.nextTick(n,null,this[o].splice(0,t));let i;void 0!==this[u]&&(this[h].reverse?(this[c].lt=this[u],this[c].lte=void 0):(this[c].gt=this[u],this[c].gte=void 0));try{i=r(this[c])}catch(t){return this[a]=!0,this.nextTick(n,null,[])}const d=this.db.db.transaction([this[l]],"readonly"),y=d.objectStore(this[l]),g=[];if(this[h].reverse)y[!this[h].values&&y.openKeyCursor?"openKeyCursor":"openCursor"](i,"prev").onsuccess=e=>{const n=e.target.result;if(n){const{key:e,value:i}=n;this[u]=e,g.push([this[h].keys&&void 0!==e?s(e):void 0,this[h].values&&void 0!==i?s(i):void 0]),g.length{if(void 0===e||void 0===n)return;const i=Math.max(e.length,n.length);0===i||t===1/0?this[a]=!0:this[u]=e[i-1],g.length=i;for(let t=0;t{e=t.target.result,r()}:(e=[],this.nextTick(r)),this[h].values?y.getAll(i,t<1/0?t:void 0).onsuccess=t=>{n=t.target.result,r()}:(n=[],this.nextTick(r))}d.onabort=()=>{n(d.error||new Error("aborted by user")),n=null},d.oncomplete=()=>{n(null,g),n=null}}_next(t){if(this[o].length>0){const[e,n]=this[o].shift();this.nextTick(t,null,e,n)}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,n)=>{if(e)return t(e);this[o]=n,this._next(t)}))}}_all(t,e){this[f]=!1;const n=this[o].splice(0,this[o].length),i=this.limit-this.count-n.length;if(i<=0)return this.nextTick(e,null,n);this._nextv(i,d,((t,i)=>{if(t)return e(t);n.length>0&&(i=n.concat(i)),e(null,i)}))}_seek(t,e){let n;this[f]=!0,this[o]=[],this[a]=!1,this[u]=void 0,this[c]={...this[h]};try{n=r(this[h])}catch(t){return void(this[a]=!0)}null===n||n.includes(t)?this[h].reverse?this[c].lte=t:this[c].gte=t:this[a]=!0}}},9968:t=>{"use strict";t.exports=function(t,e,n,i,r){if(0===i.limit)return t.nextTick(r);const s=t.db.transaction([e],"readwrite"),o=s.objectStore(e);let a=0;s.oncomplete=function(){r()},s.onabort=function(){r(s.error||new Error("aborted by user"))};const h=o.openKeyCursor?"openKeyCursor":"openCursor",c=i.reverse?"prev":"next";o[h](n,c).onsuccess=function(t){const e=t.target.result;e&&(o.delete(e.key).onsuccess=function(){(i.limit<=0||++a{"use strict";const e=new TextEncoder;t.exports=function(t){return t instanceof Uint8Array?t:t instanceof ArrayBuffer?new Uint8Array(t):e.encode(t)}},1217:t=>{"use strict";t.exports=function(t){const e=void 0!==t.gte?t.gte:void 0!==t.gt?t.gt:void 0,n=void 0!==t.lte?t.lte:void 0!==t.lt?t.lt:void 0,i=void 0===t.gte,r=void 0===t.lte;return void 0!==e&&void 0!==n?IDBKeyRange.bound(e,n,i,r):void 0!==e?IDBKeyRange.lowerBound(e,i):void 0!==n?IDBKeyRange.upperBound(n,r):null}},8764:(t,e,n)=>{"use strict";const i=n(9742),r=n(645),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=h,e.SlowBuffer=function(t){return+t!=t&&(t=0),h.alloc(+t)},e.INSPECT_MAX_BYTES=50;const o=2147483647;function a(t){if(t>o)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,h.prototype),e}function h(t,e,n){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 c(t,e,n)}function c(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!h.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|y(t,e);let i=a(n);const r=i.write(t,e);return r!==n&&(i=i.slice(0,r)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(Y(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(Y(t,ArrayBuffer)||t&&Y(t.buffer,ArrayBuffer))return d(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(Y(t,SharedArrayBuffer)||t&&Y(t.buffer,SharedArrayBuffer)))return d(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return h.from(i,e,n);const r=function(t){if(h.isBuffer(t)){const e=0|p(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||J(t.length)?a(0):f(t):"Buffer"===t.type&&Array.isArray(t.data)?f(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return h.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(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 u(t),a(t<0?0:0|p(t))}function f(t){const e=t.length<0?0:0|p(t.length),n=a(e);for(let i=0;i=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return 0|t}function y(t,e){if(h.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||Y(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 n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(t).length;default:if(r)return i?-1:q(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return k(this,e,n);case"latin1":case"binary":return x(this,e,n);case"base64":return L(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function b(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function E(t,e,n,i,r){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),J(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=h.from(e,i)),h.isBuffer(e))return 0===e.length?-1:m(t,e,n,i,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,i,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,i,r){let s,o=1,a=t.length,h=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;o=2,a/=2,h/=2,n/=2}function c(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(r){let i=-1;for(s=n;sa&&(n=a-h),s=n;s>=0;s--){let n=!0;for(let i=0;ir&&(i=r):i=r;const s=e.length;let o;for(i>s/2&&(i=s/2),o=0;o>8,r=n%256,s.push(r),s.push(i);return s}(e,t.length-n),t,n,i)}function L(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const i=[];let r=e;for(;r239?4:e>223?3:e>191?2:1;if(r+o<=n){let n,i,a,h;switch(o){case 1:e<128&&(s=e);break;case 2:n=t[r+1],128==(192&n)&&(h=(31&e)<<6|63&n,h>127&&(s=h));break;case 3:n=t[r+1],i=t[r+2],128==(192&n)&&128==(192&i)&&(h=(15&e)<<12|(63&n)<<6|63&i,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:n=t[r+1],i=t[r+2],a=t[r+3],128==(192&n)&&128==(192&i)&&128==(192&a)&&(h=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&a,h>65535&&h<1114112&&(s=h))}}null===s?(s=65533,o=1):s>65535&&(s-=65536,i.push(s>>>10&1023|55296),s=56320|1023&s),i.push(s),r+=o}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let n="",i=0;for(;ii.length?(h.isBuffer(e)||(e=h.from(e)),e.copy(i,r)):Uint8Array.prototype.set.call(i,e,r);else{if(!h.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,r)}r+=e.length}return i},h.byteLength=y,h.prototype._isBuffer=!0,h.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;en&&(t+=" ... "),""},s&&(h.prototype[s]=h.prototype.inspect),h.prototype.compare=function(t,e,n,i,r){if(Y(t,Uint8Array)&&(t=h.from(t,t.offset,t.byteLength)),!h.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===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),e<0||n>t.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&e>=n)return 0;if(i>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let s=(r>>>=0)-(i>>>=0),o=(n>>>=0)-(e>>>=0);const a=Math.min(s,o),c=this.slice(i,r),u=t.slice(e,n);for(let t=0;t>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-e;if((void 0===n||n>r)&&(n=r),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return w(this,t,e,n);case"ascii":case"latin1":case"binary":return _(this,t,e,n);case"base64":return T(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}},h.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const A=4096;function k(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;ri)&&(n=i);let r="";for(let i=e;in)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,n,i,r,s){if(!h.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||et.length)throw new RangeError("Index out of range")}function D(t,e,n,i,r){z(e,i,r,t,n,7);let s=Number(e&BigInt(4294967295));t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,n}function U(t,e,n,i,r){z(e,i,r,t,n,7);let s=Number(e&BigInt(4294967295));t[n+7]=s,s>>=8,t[n+6]=s,s>>=8,t[n+5]=s,s>>=8,t[n+4]=s;let o=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=o,o>>=8,t[n+2]=o,o>>=8,t[n+1]=o,o>>=8,t[n]=o,n+8}function P(t,e,n,i,r,s){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function M(t,e,n,i,s){return e=+e,n>>>=0,s||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function B(t,e,n,i,s){return e=+e,n>>>=0,s||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}h.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t],r=1,s=0;for(;++s>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t+--e],r=1;for(;e>0&&(r*=256);)i+=this[t+--e]*r;return i},h.prototype.readUint8=h.prototype.readUInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),this[t]},h.prototype.readUint16LE=h.prototype.readUInt16LE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]|this[t+1]<<8},h.prototype.readUint16BE=h.prototype.readUInt16BE=function(t,e){return t>>>=0,e||C(t,2,this.length),this[t]<<8|this[t+1]},h.prototype.readUint32LE=h.prototype.readUInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},h.prototype.readUint32BE=h.prototype.readUInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},h.prototype.readBigUInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(r)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<>>=0,e>>>=0,n||C(t,e,this.length);let i=this[t],r=1,s=0;for(;++s=r&&(i-=Math.pow(2,8*e)),i},h.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||C(t,e,this.length);let i=e,r=1,s=this[t+--i];for(;i>0&&(r*=256);)s+=this[t+--i]*r;return r*=128,s>=r&&(s-=Math.pow(2,8*e)),s},h.prototype.readInt8=function(t,e){return t>>>=0,e||C(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},h.prototype.readInt16LE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt16BE=function(t,e){t>>>=0,e||C(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},h.prototype.readInt32LE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},h.prototype.readInt32BE=function(t,e){return t>>>=0,e||C(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},h.prototype.readBigInt64LE=Q((function(t){G(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||W(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<>>=0,e||C(t,4,this.length),r.read(this,t,!0,23,4)},h.prototype.readFloatBE=function(t,e){return t>>>=0,e||C(t,4,this.length),r.read(this,t,!1,23,4)},h.prototype.readDoubleLE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!0,52,8)},h.prototype.readDoubleBE=function(t,e){return t>>>=0,e||C(t,8,this.length),r.read(this,t,!1,52,8)},h.prototype.writeUintLE=h.prototype.writeUIntLE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||N(this,t,e,n,Math.pow(2,8*n)-1,0);let r=1,s=0;for(this[e]=255&t;++s>>=0,n>>>=0,i||N(this,t,e,n,Math.pow(2,8*n)-1,0);let r=n-1,s=1;for(this[e+r]=255&t;--r>=0&&(s*=256);)this[e+r]=t/s&255;return e+n},h.prototype.writeUint8=h.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,255,0),this[e]=255&t,e+1},h.prototype.writeUint16LE=h.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeUint16BE=h.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeUint32LE=h.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},h.prototype.writeUint32BE=h.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigUInt64LE=Q((function(t,e=0){return D(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeBigUInt64BE=Q((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),h.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}let r=0,s=1,o=0;for(this[e]=255&t;++r>0)-o&255;return e+n},h.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);N(this,t,e,n,i-1,-i)}let r=n-1,s=1,o=0;for(this[e+r]=255&t;--r>=0&&(s*=256);)t<0&&0===o&&0!==this[e+r+1]&&(o=1),this[e+r]=(t/s>>0)-o&255;return e+n},h.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},h.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},h.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},h.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},h.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},h.prototype.writeBigInt64LE=Q((function(t,e=0){return D(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeBigInt64BE=Q((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),h.prototype.writeFloatLE=function(t,e,n){return M(this,t,e,!0,n)},h.prototype.writeFloatBE=function(t,e,n){return M(this,t,e,!1,n)},h.prototype.writeDoubleLE=function(t,e,n){return B(this,t,e,!0,n)},h.prototype.writeDoubleBE=function(t,e,n){return B(this,t,e,!1,n)},h.prototype.copy=function(t,e,n,i){if(!h.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function z(t,e,n,i,r,s){if(t>n||t3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(s+1)}${i}`:`>= -(2${i} ** ${8*(s+1)-1}${i}) and < 2 ** ${8*(s+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new F.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,n){G(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||W(e,t.length-(n+1))}(i,r,s)}function G(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function W(t,e,n){if(Math.floor(t)!==t)throw G(t,n),new F.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}j("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),j("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),j("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=V(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),i+=` It must be ${e}. Received ${r}`,i}),RangeError);const K=/[^+/0-9A-Za-z-_]/g;function q(t,e){let n;e=e||1/0;const i=t.length;let r=null;const s=[];for(let o=0;o55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===i){(e-=3)>-1&&s.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&s.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(e-=3)>-1&&s.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;s.push(n)}else if(n<2048){if((e-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(K,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function H(t,e,n,i){let r;for(r=0;r=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function Y(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function J(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)e[i+r]=t[n]+t[r]}return e}();function Q(t){return"undefined"==typeof BigInt?Z:t}function Z(){throw new Error("BigInt not supported")}},6957:(t,e,n)=>{"use strict";var i=n(886);e.fromCallback=function(t,e){if(void 0===t){var n=new Promise((function(e,n){t=function(t,i){t?n(t):e(i)}}));t[void 0!==e?e:"promise"]=n}else if("function"!=typeof t)throw new TypeError("Callback must be a function");return t},e.fromPromise=function(t,e){if(void 0===e)return t;t.then((function(t){i((()=>e(null,t)))})).catch((function(t){i((()=>e(t)))}))}},886:t=>{t.exports="function"==typeof queueMicrotask?queueMicrotask:t=>Promise.resolve().then(t)},8840:(t,e)=>{function n(t){for(var e="",n=0;n0?"F"+o:"D"+n(o)},e.decode=function(t){if("DaN"===t)return NaN;if("FF"===t)return 1/0;if("DD"===t)return-1/0;var e="D"===t[0],i=(e?n(t):t).slice(2).split("M");return Number((e?"-":"")+i[1]+"e"+String(Number(i[0])-500))}},2833:(t,e)=>{var n={"?":"?@","!":"??",'"':"?%"},i={"?@":"?","??":"!","?%":'"'};e.factory=function(t){return{encode:e,decode:function(e){if("A"===e)return null;if("K!"===e)return[];for(var n,r=e.split('"'),s=[[]],o=0,a=r.length,h=0;h{var i=n(8840),r=n(2833);e.flip=function(t){var e=t.toString(),n="";for(var i in e)n+="."==e[i]?".":9-+e[i];return n},e.number=i,e.string={encode:function(t){return/\x00|\x01/.test(t)?"J"+t.replace(/\x01/g,"").replace(/\x00/g,""):"J"+t},decode:function(t){if("J"===t[0])return t.substring(1)}},e.encode=function(t){return e[typeof t].encode(t)},e.decode=function(t){if(""===t)return t;if(!s[t[0]])throw new Error("no decoder for:"+JSON.stringify(t));return s[t[0]](t)},e.object=r.factory(e),e.boolean={encode:function(t){return t?"C":"B"},decode:function(t){return"C"===t}},e.undefined={encode:function(t){return"L"},decode:function(){}};var s={A:e.object.decode,B:e.boolean.decode,C:e.boolean.decode,D:e.number.decode,F:e.number.decode,J:e.string.decode,K:e.object.decode,L:e.undefined.decode};e.buffer=!1,e.type="charwise"},6729:t=>{"use strict";var e=Object.prototype.hasOwnProperty,n="~";function i(){}function r(t,e,n){this.fn=t,this.context=e,this.once=n||!1}function s(t,e,i,s,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new r(i,s||t,o),h=n?n+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],a]:t._events[h].push(a):(t._events[h]=a,t._eventsCount++),t}function o(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),a.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},a.prototype.listeners=function(t){var e=n?n+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,s=i.length,o=new Array(s);r{"use strict";var e,n="object"==typeof Reflect?Reflect:null,i=n&&"function"==typeof n.apply?n.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)};e=n&&"function"==typeof n.ownKeys?n.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var r=Number.isNaN||function(t){return t!=t};function s(){s.init.call(this)}t.exports=s,t.exports.once=function(t,e){return new Promise((function(n,i){function r(n){t.removeListener(e,s),i(n)}function s(){"function"==typeof t.removeListener&&t.removeListener("error",r),n([].slice.call(arguments))}y(t,e,s,{once:!0}),"error"!==e&&function(t,e,n){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,r)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function h(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function c(t,e,n,i){var r,s,o,c;if(a(n),void 0===(s=t._events)?(s=t._events=Object.create(null),t._eventsCount=0):(void 0!==s.newListener&&(t.emit("newListener",e,n.listener?n.listener:n),s=t._events),o=s[e]),void 0===o)o=s[e]=n,++t._eventsCount;else if("function"==typeof o?o=s[e]=i?[n,o]:[o,n]:i?o.unshift(n):o.push(n),(r=h(t))>0&&o.length>r&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=o.length,c=u,console&&console.warn&&console.warn(c)}return t}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,n){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:n},r=u.bind(i);return r.listener=n,i.wrapFn=r,r}function f(t,e,n){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?n?[r.listener||r]:[r]:n?function(t){for(var e=new Array(t.length),n=0;n0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var h=s[t];if(void 0===h)return!1;if("function"==typeof h)i(h,this,e);else{var c=h.length,u=p(h,c);for(n=0;n=0;s--)if(n[s]===e||n[s].listener===e){o=n[s].listener,r=s;break}if(r<0)return this;0===r?n.shift():function(t,e){for(;e+1=0;i--)this.removeListener(t,e[i]);return this},s.prototype.listeners=function(t){return f(this,t,!0)},s.prototype.rawListeners=function(t){return f(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},s.prototype.listenerCount=d,s.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},9203:(t,e,n)=>{const i=n(7270),{BrowserLevel:r}=n(1708);t.exports=({name:t="fii",...e})=>i({db:new r(t),...e})},7270:(t,e,n)=>{const i=n(9563),r=n(8936),s=n(1387),o=t=>void 0===t?void 0:t.map((t=>(t._match=t._match.flat(1/0).map((t=>"string"==typeof t?JSON.parse(t):t)).sort(((t,e)=>t.FIELDe.FIELD?1:t.VALUEe.VALUE?1:t.SCOREe.SCORE?1:0)),t))),a=t=>{const e=i(t),n=r(t);return n.TIMESTAMP_CREATED().then((()=>({AGGREGATION_FILTER:e.AGGREGATION_FILTER,AND:(t,n)=>e.INTERSECTION(t,n).then(o),BUCKET:e.BUCKET,BUCKETS:e.BUCKETS,CREATED:e.CREATED,DELETE:n.DELETE,DISTINCT:e.DISTINCT,EXIST:e.EXIST,EXPORT:e.EXPORT,FACETS:e.FACETS,FIELDS:e.FIELDS,GET:(t,n)=>e.GET(t,n).then(o),IMPORT:n.IMPORT,LAST_UPDATED:e.LAST_UPDATED,LEVEL_OPTIONS:s,MAX:e.MAX,MIN:e.MIN,NOT:(...t)=>e.SET_SUBTRACTION(...t).then(o),OBJECT:e.OBJECT,OR:(t,n)=>e.UNION(t,n).then((t=>t.union)).then(o),PUT:n.PUT,SORT:e.SORT,STORE:t._db,TIMESTAMP_LAST_UPDATED:n.TIMESTAMP_LAST_UPDATED,parseToken:e.parseToken})))};t.exports=t=>((t={})=>new Promise(((e,n)=>{const i=(t=Object.assign({caseSensitive:!0,isLeaf:t=>"string"==typeof t||"number"==typeof t,stopwords:[],doNotIndexField:[],storeVectors:!0,docExistsSpace:"DOC"},t)).db;i.open((r=>r?n(r):e(Object.assign(t,{_db:i}))))})))(t).then(a)},1387:(t,e,n)=>{const i=n(2483);t.exports={keyEncoding:i,valueEncoding:"json"}},6782:t=>{const e=null,n=void 0;t.exports=(t,i)=>new Promise(((r,s)=>{if(Array.isArray(t))return s(new Error("token cannot be Array"));if(void 0===t&&(t={}),"string"==typeof t){if(-1===t.indexOf(":"))return r({FIELD:i,VALUE:{GTE:t,LTE:t}});const[e,...n]=t.split(":");return r({FIELD:[e],VALUE:{GTE:n.join(":"),LTE:n.join(":")}})}return"number"==typeof t&&(t={VALUE:{GTE:t,LTE:t}}),null===t.VALUE&&(t.VALUE={GTE:null,LTE:null}),"string"!=typeof t.VALUE&&"number"!=typeof t.VALUE||(t.VALUE={GTE:t.VALUE,LTE:t.VALUE}),void 0!==t.VALUE&&Object.keys(t.VALUE).length||(t.VALUE={GTE:e,LTE:n}),void 0===t.VALUE.GTE&&(t.VALUE.GTE=e),void 0===t.VALUE.LTE&&(t.VALUE.LTE=n),t.VALUE=Object.assign(t.VALUE,{GTE:t.VALUE.GTE,LTE:t.VALUE.LTE}),void 0===t.FIELD?r(Object.assign(t,{FIELD:i})):(t.FIELD=[t.FIELD].flat(),r(t))}))},9563:(t,e,n)=>{const i=n(6782),r=n(2483),{EntryStream:s}=n(6741),o=n(1387);r.LO=null,r.HI=void 0,t.exports=t=>{const e=t=>"string"==typeof t,n=async t=>i(t,await l()),a=async(e,i=(t=>new Promise((e=>e(t)))))=>new Promise((async(r,s)=>{const o=t=>void 0===t?r(void 0):t instanceof Promise?r(t):void 0;try{o(e),e=await n(e),e=await(e=>{const n=e=>t.caseSensitive||"string"!=typeof e?e:e.toLowerCase();return{FIELD:e.FIELD.map(n),VALUE:{GTE:n(e.VALUE.GTE),LTE:n(e.VALUE.LTE)}}})(e),e=await(e=>e.VALUE.GTE===e.VALUE.LTE&&t.stopwords.includes(e.VALUE.GTE)?void 0:e)(e),o(e=await(e=>void 0===e?u(void 0):e.VALUE.GTE===e.VALUE.LTE&&t.queryReplace&&t.queryReplace[e.VALUE.GTE]?h(t.queryReplace[e.VALUE.GTE].map((t=>({FIELD:e.FIELD,VALUE:{GTE:t,LTE:t}})))).then((t=>t.union)):e)(e)),o(e=await i(e))}catch(t){return s(t)}return Array.isArray(e)?r(e):r(u(e))})),h=async(t,e)=>Promise.all(t.map((t=>a(t,e)))).then((t=>{const e=t.flat(1/0).reduce(((t,e)=>(e&&t.set(e._id,[...t.get(e._id)||[],e._match]),t)),new Map);return{sumTokensMinusStopwords:t.filter((t=>t)).length,union:Array.from(e.keys()).map((t=>({_id:t,_match:e.get(t)})))}})),c=(t,e,n)=>{const i=[];return void 0===e&&"number"!=typeof e||i.push(e),n&&i.push(r.HI),["IDX",t,i]},u=e=>new Promise((n=>{if(void 0===e)return n(void 0);const i=new Map;return Promise.all(e.FIELD.map((n=>new Promise((r=>new s(t._db,{gte:c(n,e.VALUE.GTE),lte:c(n,e.VALUE.LTE,!0),limit:e.LIMIT,reverse:e.REVERSE,...o}).on("data",(t=>t.value.forEach((e=>i.set(e,[...i.get(e)||[],JSON.stringify({FIELD:t.key[1],VALUE:t.key[2][0],SCORE:t.key[2][1]})]))))).on("end",r)))))).then((()=>n(Array.from(i.keys()).map((t=>({_id:t,_match:i.get(t)}))))))})),l=()=>new Promise((e=>{const n=[];new s(t._db,{gte:["FIELD",r.LO],lte:["FIELD",r.HI],...o}).on("data",(t=>n.push(t.value))).on("end",(()=>e(n)))})),f=(t,e)=>e&&0!==e.length?(e=new Set(e.map((t=>t._id))),t.map((t=>Object.assign(t,{_id:[...new Set([...t._id].filter((t=>e.has(t))))]})))):t,d=async t=>n(t).then((t=>a(t).then((e=>Object.assign(t,{_id:[...e.reduce(((t,e)=>t.add(e._id)),new Set)].sort(),VALUE:t.VALUE}))))),p=e=>new Promise(((n,i)=>{const r=[];new s(t._db,{...e,...o}).on("data",(t=>{r.push(t)})).on("end",(()=>n(r)))})),y=(t,e)=>n(t).then((t=>u(Object.assign(t,{LIMIT:1,REVERSE:e})))).then((t=>t.length?JSON.parse(t.pop()._match.pop()).VALUE:null)),g=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>{let n=t.VALUE.LTE;void 0!==t.VALUE.LTE&&"number"!=typeof t.VALUE.LTE&&(n+="○");let i=t.VALUE.GTE;return t.VALUE.GTE&&"number"!=typeof t.VALUE.GTE&&(i+=" "),p({gte:c(e,i),lte:c(e,n,!0),keys:!0,values:!1}).then((t=>t.map((({key:t})=>({FIELD:t[1],VALUE:t[2][0]})))))}))))).then((t=>t.flat())),b=t=>n(t).then((t=>Promise.all(t.FIELD.map((e=>p({gte:c(e,t.VALUE.GTE),lte:c(e,t.VALUE.LTE,!0)}).then((t=>t.map((t=>({FIELD:t.key[1],VALUE:t.key[2][0],_id:t.value})))))))))).then((t=>t.flat())),E=new Intl.Collator("en",{numeric:!0,sensitivity:"base"});return{AGGREGATE:({BUCKETS:t,FACETS:e,QUERY:n})=>Promise.all([t,e,n]).then((([t=[],e=[],n=[]])=>({BUCKETS:f(t.flat(),n),FACETS:f(e.flat(),n),RESULT:n}))),AGGREGATION_FILTER:f,BUCKET:d,BUCKETS:(...t)=>Promise.all(t.map(d)),CREATED:()=>t._db.get(["~CREATED"],o),DISTINCT:(...t)=>Promise.all(t.length?t.map(g):[g({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),EXIST:(...e)=>Promise.all(e.map((e=>t._db.get([t.docExistsSpace,e],o).catch((t=>null))))).then((t=>t.reduce(((t,n,i)=>(null!=n&&t.push(e[i]),t)),[]))),EXPORT:p,FACETS:(...t)=>Promise.all(t.length?t.map(b):[b({})]).then((t=>[...t.flat().reduce(((t,e)=>t.add(JSON.stringify(e))),new Set)].map(JSON.parse))),FIELDS:l,GET:a,INTERSECTION:(t,e)=>h(t,e).then((t=>t.union.filter((e=>e._match.length===t.sumTokensMinusStopwords)))),LAST_UPDATED:()=>t._db.get(["~LAST_UPDATED"],o),MAX:t=>y(t,!0),MIN:y,OBJECT:e=>Promise.all(e.map((e=>t._db.get(["DOC",e._id],o).catch((t=>null))))).then((t=>e.map(((e,n)=>(e._object=t[n],e))))),SET_SUBTRACTION:(t,n)=>Promise.all([e(t)?a(t):t,e(n)?a(n):n]).then((([t,e])=>t.filter((t=>-1===e.map((t=>t._id)).indexOf(t._id))))),SORT:t=>new Promise((e=>e(t.sort(((t,e)=>E.compare(t._id,e._id)))))),UNION:h,parseToken:n}}},8936:(t,e,n)=>{const i=n(3692),r=n(9563),s=n(1387);t.exports=t=>{let e=0;const n=(e,n)=>{if(null==e._object)return{_id:e._id,keys:[]};const r=[];return i(e._object).forEach((function(e){const i=this.path.filter((t=>!Number.isInteger(+t))).join(".");if("_id"!==i&&!n.doNotIndexField.filter((t=>i.startsWith(t))).length&&t.isLeaf(this.node)){if(!t.stopwords.includes(this.node)){const e=JSON.stringify([i,[this.node].flat(1/0)]);r.push(t.caseSensitive?e:e.toLowerCase())}this.update(this.node,!0)}})),{_id:e._id,keys:r}},o=(t,e)=>(e.keys.forEach((n=>{t[n]=t[n]||[],t[n].push(e._id)})),t),a=(i,a,h,c,u)=>new Promise((l=>{i=i.map((t=>{var n;return t._id=void 0===(n=t._id)?++e:"string"==typeof n||"number"==typeof n?n:void 0,t._object&&(t._object._id=t._id),t})),u=Object.assign(t,u),r(t).EXIST(...i.map((t=>t._id))).then((t=>((t,e,n)=>{const i=Object.keys(t);return Promise.all(i.map((t=>["IDX",...JSON.parse(t)])).map((t=>new Promise(((n,i)=>e.get(t,s).then(n).catch((t=>n([])))))))).then((e=>e.map(((e,r)=>{const s=new Set(e),o=new Set(t[i[r]]);if("put"===n)return{key:["IDX",...JSON.parse(i[r])],type:n,value:[...new Set([...s,...o])].sort()};if("del"===n){const t=[...new Set([...s].filter((t=>!o.has(t))))];return{key:["IDX",...JSON.parse(i[r])],type:0===t.length?"del":"put",value:t}}return e}))))})(((t,e)=>t.map((t=>n(t,e))).reduce(o,{}))(i,u),a,h).then((e=>a.batch(e.concat(u.storeVectors?((t,e)=>t.map((t=>({key:["DOC",t._id],type:e,value:t._object}))))(i,h):[]).concat((t=>[...new Set(t.map((t=>t.key[1].split(":")[0])))].map((t=>({type:"put",key:["FIELD",t],value:t}))))(e)),s,(e=>l(i.map((e=>{let n;return"put"===h?n=t.includes(e._id)?"UPDATED":"CREATED":"del"===h&&(n=null===e._object?"FAILED":"DELETED"),{_id:e._id,operation:c,status:n}})))))))))})),h=e=>t._db.put(["~LAST_UPDATED"],Date.now(),s).then((()=>e));return{DELETE:e=>r(t).OBJECT(e.map((t=>({_id:t})))).then((e=>a(e,t._db,"del","DELETE",{}))).then(h),IMPORT:e=>t._db.clear().then((()=>t._db.batch(e.map((t=>Object.assign(t,{type:"put"}))),s))),PUT:(e,n={})=>a(e.map((t=>({_id:t._id,_object:t}))),t._db,"put","PUT",n).then(h),TIMESTAMP_CREATED:()=>t._db.get(["~CREATED"],s).then().catch((e=>t._db.put(["~CREATED"],Date.now(),s).then(h))),TIMESTAMP_LAST_UPDATED:h}}},645:(t,e)=>{e.read=function(t,e,n,i,r){var s,o,a=8*r-i-1,h=(1<>1,u=-7,l=n?r-1:0,f=n?-1:1,d=t[e+l];for(l+=f,s=d&(1<<-u)-1,d>>=-u,u+=a;u>0;s=256*s+t[e+l],l+=f,u-=8);for(o=s&(1<<-u)-1,s>>=-u,u+=i;u>0;o=256*o+t[e+l],l+=f,u-=8);if(0===s)s=1-c;else{if(s===h)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,i),s-=c}return(d?-1:1)*o*Math.pow(2,s-i)},e.write=function(t,e,n,i,r,s){var o,a,h,c=8*s-r-1,u=(1<>1,f=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:s-1,p=i?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-o))<1&&(o--,h*=2),(e+=o+l>=1?f/h:f*Math.pow(2,1-l))*h>=2&&(o++,h/=2),o+l>=u?(a=0,o=u):o+l>=1?(a=(e*h-1)*Math.pow(2,r),o+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,r),o=0));r>=8;t[n+d]=255&a,d+=p,a/=256,r-=8);for(o=o<0;t[n+d]=255&o,d+=p,o/=256,c-=8);t[n+d-p]|=128*y}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}}},6741:(t,e,n)=>{"use strict";const{Readable:i}=n(8473),r=Symbol("iterator"),s=Symbol("nextv");class o extends i{constructor(t,e,n){const{highWaterMark:i,...o}=n||{};super({objectMode:!0,highWaterMark:i||1e3}),this[r]=t[e](o),this[s]=this[s].bind(this),this.once("end",this.destroy.bind(this,null,null))}get db(){return this[r].db}_read(t){this.destroyed||this[r].nextv(t,this[s])}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const t of e)this.push(t)}}_destroy(t,e){this[r].close((function(n){e(t||n)}))}}e.EntryStream=class extends o{constructor(t,e){super(t,"iterator",{...e,keys:!0,values:!0})}[s](t,e){if(!this.destroyed){if(t)return this.destroy(t);if(0===e.length)this.push(null);else for(const[t,n]of e)this.push({key:t,value:n})}}},e.KeyStream=class extends o{constructor(t,e){super(t,"keys",e)}},e.ValueStream=class extends o{constructor(t,e){super(t,"values",e)}}},8499:(t,e,n)=>{"use strict";const i=n(4473),r=n(8002),{Encoding:s}=n(8266),{BufferFormat:o,ViewFormat:a,UTF8Format:h}=n(2376),c=Symbol("formats"),u=Symbol("encodings"),l=new Set(["buffer","view","utf8"]);e.Transcoder=class{constructor(t){if(!Array.isArray(t))throw new TypeError("The first argument 'formats' must be an array");if(!t.every((t=>l.has(t))))throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'");this[u]=new Map,this[c]=new Set(t);for(const t in r)try{this.encoding(t)}catch(t){if("LEVEL_ENCODING_NOT_SUPPORTED"!==t.code)throw t}}encodings(){return Array.from(new Set(this[u].values()))}encoding(t){let e=this[u].get(t);if(void 0===e){if("string"==typeof t&&""!==t){if(e=d[t],!e)throw new i(`Encoding '${t}' is not found`,{code:"LEVEL_ENCODING_NOT_FOUND"})}else{if("object"!=typeof t||null===t)throw new TypeError("First argument 'encoding' must be a string or object");e=function(t){if(t instanceof s)return t;const e="type"in t&&"string"==typeof t.type?t.type:void 0,n=t.name||e||"anonymous-"+p++;switch(function(t){return"format"in t&&void 0!==t.format?t.format:"buffer"in t&&"boolean"==typeof t.buffer?t.buffer?"buffer":"utf8":"code"in t&&Number.isInteger(t.code)?"view":"buffer"}(t)){case"view":return new a({...t,name:n});case"utf8":return new h({...t,name:n});case"buffer":return new o({...t,name:n});default:throw new TypeError("Format must be one of 'buffer', 'view', 'utf8'")}}(t)}const{name:n,format:r}=e;if(!this[c].has(r))if(this[c].has("view"))e=e.createViewTranscoder();else if(this[c].has("buffer"))e=e.createBufferTranscoder();else{if(!this[c].has("utf8"))throw new i(`Encoding '${n}' cannot be transcoded`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"});e=e.createUTF8Transcoder()}for(const i of[t,n,e.name,e.commonName])this[u].set(i,e)}return e}};const f={binary:r.buffer,"utf-8":r.utf8},d={...r,...f};let p=0},8266:(t,e,n)=>{"use strict";const i=n(4473),r=new Set(["buffer","view","utf8"]);e.Encoding=class{constructor(t){if(this.encode=t.encode||this.encode,this.decode=t.decode||this.decode,this.name=t.name||this.name,this.format=t.format||this.format,"function"!=typeof this.encode)throw new TypeError("The 'encode' property must be a function");if("function"!=typeof this.decode)throw new TypeError("The 'decode' property must be a function");if(this.encode=this.encode.bind(this),this.decode=this.decode.bind(this),"string"!=typeof this.name||""===this.name)throw new TypeError("The 'name' property must be a string");if("string"!=typeof this.format||!r.has(this.format))throw new TypeError("The 'format' property must be one of 'buffer', 'view', 'utf8'");t.createViewTranscoder&&(this.createViewTranscoder=t.createViewTranscoder),t.createBufferTranscoder&&(this.createBufferTranscoder=t.createBufferTranscoder),t.createUTF8Transcoder&&(this.createUTF8Transcoder=t.createUTF8Transcoder)}get commonName(){return this.name.split("+")[0]}createBufferTranscoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'buffer'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createViewTranscoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'view'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}createUTF8Transcoder(){throw new i(`Encoding '${this.name}' cannot be transcoded to 'utf8'`,{code:"LEVEL_ENCODING_NOT_SUPPORTED"})}}},8002:(t,e,n)=>{"use strict";const{Buffer:i}=n(8764)||{Buffer:{isBuffer:()=>!1}},{textEncoder:r,textDecoder:s}=n(4005)(),{BufferFormat:o,ViewFormat:a,UTF8Format:h}=n(2376),c=t=>t;e.utf8=new h({encode:function(t){return i.isBuffer(t)?t.toString("utf8"):ArrayBuffer.isView(t)?s.decode(t):String(t)},decode:c,name:"utf8",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.encode(t)},decode:function(t){return s.decode(t)},name:`${this.name}+view`})},createBufferTranscoder(){return new o({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:function(t){return t.toString("utf8")},name:`${this.name}+buffer`})}}),e.json=new h({encode:JSON.stringify,decode:JSON.parse,name:"json"}),e.buffer=new o({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:c,name:"buffer",createViewTranscoder(){return new a({encode:function(t){return ArrayBuffer.isView(t)?t:i.from(String(t),"utf8")},decode:function(t){return i.from(t.buffer,t.byteOffset,t.byteLength)},name:`${this.name}+view`})}}),e.view=new a({encode:function(t){return ArrayBuffer.isView(t)?t:r.encode(t)},decode:c,name:"view",createBufferTranscoder(){return new o({encode:function(t){return i.isBuffer(t)?t:ArrayBuffer.isView(t)?i.from(t.buffer,t.byteOffset,t.byteLength):i.from(String(t),"utf8")},decode:c,name:`${this.name}+buffer`})}}),e.hex=new o({encode:function(t){return i.isBuffer(t)?t:i.from(String(t),"hex")},decode:function(t){return t.toString("hex")},name:"hex"}),e.base64=new o({encode:function(t){return i.isBuffer(t)?t:i.from(String(t),"base64")},decode:function(t){return t.toString("base64")},name:"base64"})},2376:(t,e,n)=>{"use strict";const{Buffer:i}=n(8764)||{},{Encoding:r}=n(8266),s=n(4005);class o extends r{constructor(t){super({...t,format:"buffer"})}createViewTranscoder(){return new a({encode:this.encode,decode:t=>this.decode(i.from(t.buffer,t.byteOffset,t.byteLength)),name:`${this.name}+view`})}createBufferTranscoder(){return this}}class a extends r{constructor(t){super({...t,format:"view"})}createBufferTranscoder(){return new o({encode:t=>{const e=this.encode(t);return i.from(e.buffer,e.byteOffset,e.byteLength)},decode:this.decode,name:`${this.name}+buffer`})}createViewTranscoder(){return this}}e.BufferFormat=o,e.ViewFormat=a,e.UTF8Format=class extends r{constructor(t){super({...t,format:"utf8"})}createBufferTranscoder(){return new o({encode:t=>i.from(this.encode(t),"utf8"),decode:t=>this.decode(t.toString("utf8")),name:`${this.name}+buffer`})}createViewTranscoder(){const{textEncoder:t,textDecoder:e}=s();return new a({encode:e=>t.encode(this.encode(e)),decode:t=>this.decode(e.decode(t)),name:`${this.name}+view`})}createUTF8Transcoder(){return this}}},4005:t=>{"use strict";let e=null;t.exports=function(){return null===e&&(e={textEncoder:new TextEncoder,textDecoder:new TextDecoder}),e}},4473:t=>{"use strict";t.exports=class extends Error{constructor(t,e){super(t||""),"object"==typeof e&&null!==e&&(e.code&&(this.code=String(e.code)),e.expected&&(this.expected=!0),e.transient&&(this.transient=!0),e.cause&&(this.cause=e.cause)),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}}},6349:function(t,e){!function(t){"use strict";const e=function(t,e){return t.slice(e-1).map(((n,i)=>t.slice(i,i+e)))};t.ngraminator=function(t,n){return n.reduce(((n,i)=>[...e(t,i),...n]),[]).sort()},Object.defineProperty(t,"__esModule",{value:!0})}(e)},4155:t=>{var e,n,i=t.exports={};function r(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===r||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(n){try{return e.call(null,t,0)}catch(n){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:r}catch(t){e=r}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(t){n=s}}();var a,h=[],c=!1,u=-1;function l(){c&&a&&(c=!1,a.length?h=a.concat(h):u=-1,h.length&&f())}function f(){if(!c){var t=o(l);c=!0;for(var e=h.length;e;){for(a=h,h=[];++u1)for(var n=1;n{let i;t.exports="function"==typeof queueMicrotask?queueMicrotask.bind("undefined"!=typeof window?window:n.g):t=>(i||(i=Promise.resolve())).then(t).catch((t=>setTimeout((()=>{throw t}),0)))},4281:t=>{"use strict";var e={};function n(t,n,i){i||(i=Error);var r=function(t){var e,i;function r(e,i,r){return t.call(this,function(t,e,i){return"string"==typeof n?n:n(t,e,i)}(e,i,r))||this}return i=t,(e=r).prototype=Object.create(i.prototype),e.prototype.constructor=e,e.__proto__=i,r}(i);r.prototype.name=i.name,r.prototype.code=t,e[t]=r}function i(t,e){if(Array.isArray(t)){var n=t.length;return t=t.map((function(t){return String(t)})),n>2?"one of ".concat(e," ").concat(t.slice(0,n-1).join(", "),", or ")+t[n-1]:2===n?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}n("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),n("ERR_INVALID_ARG_TYPE",(function(t,e,n){var r,s,o,a,h;if("string"==typeof e&&(s="not ",e.substr(0,4)===s)?(r="must not be",e=e.replace(/^not /,"")):r="must be",function(t,e,n){return(void 0===n||n>t.length)&&(n=t.length),t.substring(n-9,n)===e}(t," argument"))o="The ".concat(t," ").concat(r," ").concat(i(e,"type"));else{var c=("number"!=typeof h&&(h=0),h+1>(a=t).length||-1===a.indexOf(".",h)?"argument":"property");o='The "'.concat(t,'" ').concat(c," ").concat(r," ").concat(i(e,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),n("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),n("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),n("ERR_STREAM_PREMATURE_CLOSE","Premature close"),n("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),n("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),n("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),n("ERR_STREAM_WRITE_AFTER_END","write after end"),n("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),n("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),n("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.q=e},6753:(t,e,n)=>{"use strict";var i=n(4155),r=Object.keys||function(t){var e=[];for(var n in t)e.push(n);return e};t.exports=u;var s=n(9481),o=n(4229);n(5717)(u,s);for(var a=r(o.prototype),h=0;h{"use strict";t.exports=r;var i=n(4605);function r(t){if(!(this instanceof r))return new r(t);i.call(this,t)}n(5717)(r,i),r.prototype._transform=function(t,e,n){n(null,t)}},9481:(t,e,n)=>{"use strict";var i,r=n(4155);t.exports=L,L.ReadableState=S,n(7187).EventEmitter;var s,o=function(t,e){return t.listeners(e).length},a=n(2503),h=n(8764).Buffer,c=n.g.Uint8Array||function(){},u=n(4616);s=u&&u.debuglog?u.debuglog("stream"):function(){};var l,f,d,p=n(7327),y=n(1195),g=n(2457).getHighWaterMark,b=n(4281).q,E=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,w=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;n(5717)(L,a);var _=y.errorOrDestroy,T=["error","close","destroy","pause","resume"];function S(t,e,r){i=i||n(6753),t=t||{},"boolean"!=typeof r&&(r=e instanceof i),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",r),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(l||(l=n(2553).s),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function L(t){if(i=i||n(6753),!(this instanceof L))return new L(t);var e=this instanceof i;this._readableState=new S(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function O(t,e,n,i,r){s("readableAddChunk",e);var o,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(s("onEofChunk"),!e.ended){if(e.decoder){var n=e.decoder.end();n&&n.length&&(e.buffer.push(n),e.length+=e.objectMode?1:n.length)}e.ended=!0,e.sync?R(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}}(t,a);else if(r||(o=function(t,e){var n,i;return i=e,h.isBuffer(i)||i instanceof c||"string"==typeof e||void 0===e||t.objectMode||(n=new E("chunk",["string","Buffer","Uint8Array"],e)),n}(a,e)),o)_(t,o);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===h.prototype||(e=function(t){return h.from(t)}(e)),i)a.endEmitted?_(t,new w):A(t,a,e,!0);else if(a.ended)_(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(e=a.decoder.write(e),a.objectMode||0!==e.length?A(t,a,e,!1):C(t,a)):A(t,a,e,!1)}else i||(a.reading=!1,C(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=k?t=k:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function R(t){var e=t._readableState;s("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(s("emitReadable",e.flowing),e.emittedReadable=!0,r.nextTick(I,t))}function I(t){var e=t._readableState;s("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,M(t)}function C(t,e){e.readingMore||(e.readingMore=!0,r.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function U(t){s("readable nexttick read 0"),t.read(0)}function P(t,e){s("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),M(t),e.flowing&&!e.reading&&t.read(0)}function M(t){var e=t._readableState;for(s("flow",e.flowing);e.flowing&&null!==t.read(););}function B(t,e){return 0===e.length?null:(e.objectMode?n=e.buffer.shift():!t||t>=e.length?(n=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):n=e.buffer.consume(t,e.decoder),n);var n}function F(t){var e=t._readableState;s("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,r.nextTick(j,e,t))}function j(t,e){if(s("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var n=e._writableState;(!n||n.autoDestroy&&n.finished)&&e.destroy()}}function V(t,e){for(var n=0,i=t.length;n=e.highWaterMark:e.length>0)||e.ended))return s("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):R(this),null;if(0===(t=x(t,e))&&e.ended)return 0===e.length&&F(this),null;var i,r=e.needReadable;return s("need readable",r),(0===e.length||e.length-t0?B(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),n!==t&&e.ended&&F(this)),null!==i&&this.emit("data",i),i},L.prototype._read=function(t){_(this,new v("_read()"))},L.prototype.pipe=function(t,e){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,s("pipe count=%d opts=%j",i.pipesCount,e);var a=e&&!1===e.end||t===r.stdout||t===r.stderr?y:h;function h(){s("onend"),t.end()}i.endEmitted?r.nextTick(a):n.once("end",a),t.on("unpipe",(function e(r,o){s("onunpipe"),r===n&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,s("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",c),t.removeListener("error",f),t.removeListener("unpipe",e),n.removeListener("end",h),n.removeListener("end",y),n.removeListener("data",l),u=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;s("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,M(t))}}(n);t.on("drain",c);var u=!1;function l(e){s("ondata");var r=t.write(e);s("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==V(i.pipes,t))&&!u&&(s("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function f(e){s("onerror",e),y(),t.removeListener("error",f),0===o(t,"error")&&_(t,e)}function d(){t.removeListener("finish",p),y()}function p(){s("onfinish"),t.removeListener("close",d),y()}function y(){s("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,n){if("function"==typeof t.prependListener)return t.prependListener(e,n);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(n):t._events[e]=[n,t._events[e]]:t.on(e,n)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),i.flowing||(s("pipe resume"),n.resume()),t},L.prototype.unpipe=function(t){var e=this._readableState,n={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,n)),this;if(!t){var i=e.pipes,r=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var s=0;s0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,s("on readable",i.length,i.reading),i.length?R(this):i.reading||r.nextTick(U,this))),n},L.prototype.addListener=L.prototype.on,L.prototype.removeListener=function(t,e){var n=a.prototype.removeListener.call(this,t,e);return"readable"===t&&r.nextTick(D,this),n},L.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||r.nextTick(D,this),e},L.prototype.resume=function(){var t=this._readableState;return t.flowing||(s("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,r.nextTick(P,t,e))}(this,t)),t.paused=!1,this},L.prototype.pause=function(){return s("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(s("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},L.prototype.wrap=function(t){var e=this,n=this._readableState,i=!1;for(var r in t.on("end",(function(){if(s("wrapped end"),n.decoder&&!n.ended){var t=n.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(r){s("wrapped data"),n.decoder&&(r=n.decoder.write(r)),n.objectMode&&null==r||(n.objectMode||r&&r.length)&&(e.push(r)||(i=!0,t.pause()))})),t)void 0===this[r]&&"function"==typeof t[r]&&(this[r]=function(e){return function(){return t[e].apply(t,arguments)}}(r));for(var o=0;o{"use strict";t.exports=u;var i=n(4281).q,r=i.ERR_METHOD_NOT_IMPLEMENTED,s=i.ERR_MULTIPLE_CALLBACK,o=i.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=i.ERR_TRANSFORM_WITH_LENGTH_0,h=n(6753);function c(t,e){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(null===i)return this.emit("error",new s);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),i(t);var r=this._readableState;r.reading=!1,(r.needReadable||r.length{"use strict";var i,r=n(4155);function s(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,n){var i=t.entry;for(t.entry=null;i;){var r=i.callback;e.pendingcb--,r(undefined),i=i.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=L,L.WritableState=S;var o,a={deprecate:n(4927)},h=n(2503),c=n(8764).Buffer,u=n.g.Uint8Array||function(){},l=n(1195),f=n(2457).getHighWaterMark,d=n(4281).q,p=d.ERR_INVALID_ARG_TYPE,y=d.ERR_METHOD_NOT_IMPLEMENTED,g=d.ERR_MULTIPLE_CALLBACK,b=d.ERR_STREAM_CANNOT_PIPE,E=d.ERR_STREAM_DESTROYED,m=d.ERR_STREAM_NULL_VALUES,v=d.ERR_STREAM_WRITE_AFTER_END,w=d.ERR_UNKNOWN_ENCODING,_=l.errorOrDestroy;function T(){}function S(t,e,o){i=i||n(6753),t=t||{},"boolean"!=typeof o&&(o=e instanceof i),this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=f(this,t,"writableHighWaterMark",o),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,i=n.sync,s=n.writecb;if("function"!=typeof s)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,i,s){--e.pendingcb,n?(r.nextTick(s,i),r.nextTick(I,t,e),t._writableState.errorEmitted=!0,_(t,i)):(s(i),t._writableState.errorEmitted=!0,_(t,i),I(t,e))}(t,n,i,e,s);else{var o=x(n)||t.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||k(t,n),i?r.nextTick(A,t,n,o,s):A(t,n,o,s)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function L(t){var e=this instanceof(i=i||n(6753));if(!e&&!o.call(L,this))return new L(t);this._writableState=new S(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),h.call(this)}function O(t,e,n,i,r,s,o){e.writelen=i,e.writecb=o,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new E("write")):n?t._writev(r,e.onwrite):t._write(r,s,e.onwrite),e.sync=!1}function A(t,e,n,i){n||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,i(),I(t,e)}function k(t,e){e.bufferProcessing=!0;var n=e.bufferedRequest;if(t._writev&&n&&n.next){var i=e.bufferedRequestCount,r=new Array(i),o=e.corkedRequestsFree;o.entry=n;for(var a=0,h=!0;n;)r[a]=n,n.isBuf||(h=!1),n=n.next,a+=1;r.allBuffers=h,O(t,e,!0,e.length,r,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new s(e),e.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,u=n.encoding,l=n.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,u,l),n=n.next,e.bufferedRequestCount--,e.writing)break}null===n&&(e.lastBufferedRequest=null)}e.bufferedRequest=n,e.bufferProcessing=!1}function x(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function R(t,e){t._final((function(n){e.pendingcb--,n&&_(t,n),e.prefinished=!0,t.emit("prefinish"),I(t,e)}))}function I(t,e){var n=x(e);if(n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,r.nextTick(R,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var i=t._readableState;(!i||i.autoDestroy&&i.endEmitted)&&t.destroy()}return n}n(5717)(L,h),S.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(S.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(o=Function.prototype[Symbol.hasInstance],Object.defineProperty(L,Symbol.hasInstance,{value:function(t){return!!o.call(this,t)||this===L&&t&&t._writableState instanceof S}})):o=function(t){return t instanceof this},L.prototype.pipe=function(){_(this,new b)},L.prototype.write=function(t,e,n){var i,s=this._writableState,o=!1,a=!s.objectMode&&(i=t,c.isBuffer(i)||i instanceof u);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(n=e,e=null),a?e="buffer":e||(e=s.defaultEncoding),"function"!=typeof n&&(n=T),s.ending?function(t,e){var n=new v;_(t,n),r.nextTick(e,n)}(this,n):(a||function(t,e,n,i){var s;return null===n?s=new m:"string"==typeof n||e.objectMode||(s=new p("chunk",["string","Buffer"],n)),!s||(_(t,s),r.nextTick(i,s),!1)}(this,s,t,n))&&(s.pendingcb++,o=function(t,e,n,i,r,s){if(!n){var o=function(t,e,n){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,n)),e}(e,i,r);i!==o&&(n=!0,r="buffer",i=o)}var a=e.objectMode?1:i.length;e.length+=a;var h=e.length-1))throw new w(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(L.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(L.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),L.prototype._write=function(t,e,n){n(new y("_write()"))},L.prototype._writev=null,L.prototype.end=function(t,e,n){var i=this._writableState;return"function"==typeof t?(n=t,t=null,e=null):"function"==typeof e&&(n=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,n){e.ending=!0,I(t,e),n&&(e.finished?r.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,i,n),this},Object.defineProperty(L.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(L.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),L.prototype.destroy=l.destroy,L.prototype._undestroy=l.undestroy,L.prototype._destroy=function(t,e){e(t)}},5850:(t,e,n)=>{"use strict";var i,r=n(4155);function s(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var o=n(8610),a=Symbol("lastResolve"),h=Symbol("lastReject"),c=Symbol("error"),u=Symbol("ended"),l=Symbol("lastPromise"),f=Symbol("handlePromise"),d=Symbol("stream");function p(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var n=t[d].read();null!==n&&(t[l]=null,t[a]=null,t[h]=null,e(p(n,!1)))}}function g(t){r.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),E=Object.setPrototypeOf((s(i={get stream(){return this[d]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[u])return Promise.resolve(p(void 0,!0));if(this[d].destroyed)return new Promise((function(e,n){r.nextTick((function(){t[c]?n(t[c]):e(p(void 0,!0))}))}));var n,i=this[l];if(i)n=new Promise(function(t,e){return function(n,i){t.then((function(){e[u]?n(p(void 0,!0)):e[f](n,i)}),i)}}(i,this));else{var s=this[d].read();if(null!==s)return Promise.resolve(p(s,!1));n=new Promise(this[f])}return this[l]=n,n}},Symbol.asyncIterator,(function(){return this})),s(i,"return",(function(){var t=this;return new Promise((function(e,n){t[d].destroy(null,(function(t){t?n(t):e(p(void 0,!0))}))}))})),i),b);t.exports=function(t){var e,n=Object.create(E,(s(e={},d,{value:t,writable:!0}),s(e,a,{value:null,writable:!0}),s(e,h,{value:null,writable:!0}),s(e,c,{value:null,writable:!0}),s(e,u,{value:t._readableState.endEmitted,writable:!0}),s(e,f,{value:function(t,e){var i=n[d].read();i?(n[l]=null,n[a]=null,n[h]=null,t(p(i,!1))):(n[a]=t,n[h]=e)},writable:!0}),e));return n[l]=null,o(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=n[h];return null!==e&&(n[l]=null,n[a]=null,n[h]=null,e(t)),void(n[c]=t)}var i=n[a];null!==i&&(n[l]=null,n[a]=null,n[h]=null,i(p(void 0,!0))),n[u]=!0})),t.on("readable",g.bind(null,n)),n}},7327:(t,e,n)=>{"use strict";function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s(t,e){for(var n=0;n0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,n=""+e.data;e=e.next;)n+=t+e.data;return n}},{key:"concat",value:function(t){if(0===this.length)return o.alloc(0);for(var e,n,i,r=o.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,n=r,i=a,o.prototype.copy.call(e,n,i),a+=s.data.length,s=s.next;return r}},{key:"consume",value:function(t,e){var n;return tr.length?r.length:t;if(s===r.length?i+=r:i+=r.slice(0,t),0==(t-=s)){s===r.length?(++n,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=r.slice(s));break}++n}return this.length-=n,i}},{key:"_getBuffer",value:function(t){var e=o.allocUnsafe(t),n=this.head,i=1;for(n.data.copy(e),t-=n.data.length;n=n.next;){var r=n.data,s=t>r.length?r.length:t;if(r.copy(e,e.length-t,0,s),0==(t-=s)){s===r.length?(++i,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=r.slice(s));break}++i}return this.length-=i,e}},{key:h,value:function(t,e){return a(this,function(t){for(var e=1;e{"use strict";var i=n(4155);function r(t,e){o(t,e),s(t)}function s(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function o(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var n=this,a=this._readableState&&this._readableState.destroyed,h=this._writableState&&this._writableState.destroyed;return a||h?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(o,this,t)):i.nextTick(o,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?n._writableState?n._writableState.errorEmitted?i.nextTick(s,n):(n._writableState.errorEmitted=!0,i.nextTick(r,n,t)):i.nextTick(r,n,t):e?(i.nextTick(s,n),e(t)):i.nextTick(s,n)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var n=t._readableState,i=t._writableState;n&&n.autoDestroy||i&&i.autoDestroy?t.destroy(e):t.emit("error",e)}}},8610:(t,e,n)=>{"use strict";var i=n(4281).q.ERR_STREAM_PREMATURE_CLOSE;function r(){}t.exports=function t(e,n,s){if("function"==typeof n)return t(e,null,n);n||(n={}),s=function(t){var e=!1;return function(){if(!e){e=!0;for(var n=arguments.length,i=new Array(n),r=0;r{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9946:(t,e,n)=>{"use strict";var i,r=n(4281).q,s=r.ERR_MISSING_ARGS,o=r.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function h(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),r=0;r0,(function(t){u||(u=t),t&&f.forEach(h),s||(f.forEach(h),l(u))}))}));return e.reduce(c)}},2457:(t,e,n)=>{"use strict";var i=n(4281).q.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,n,r){var s=function(t,e,n){return null!=t.highWaterMark?t.highWaterMark:e?t[n]:null}(e,r,n);if(null!=s){if(!isFinite(s)||Math.floor(s)!==s||s<0)throw new i(r?n:"highWaterMark",s);return Math.floor(s)}return t.objectMode?16:16384}}},2503:(t,e,n)=>{t.exports=n(7187).EventEmitter},8473:(t,e,n)=>{(e=t.exports=n(9481)).Stream=e,e.Readable=e,e.Writable=n(4229),e.Duplex=n(6753),e.Transform=n(4605),e.PassThrough=n(2725),e.finished=n(8610),e.pipeline=n(9946)},9967:(t,e,n)=>{t.exports=function(t,e,n){if("number"!=typeof e)throw new Error("second argument must be a Number");let r,s,o,a,h,c,u=!0;function l(t){function e(){n&&n(t,r),n=null}u?i(e):e()}function f(e,n,i){if(r[e]=i,n&&(h=!0),0==--o||n)l(n);else if(!h&&c{"use strict";var i=n(396).Buffer,r=i.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function s(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(i.isEncoding===r||!r(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=h,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=u,this.end=l,e=3;break;default:return this.write=f,void(this.end=d)}this.lastNeed=0,this.lastTotal=0,this.lastChar=i.allocUnsafe(e)}function o(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,n=function(t,e,n){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==n?n:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function h(t,e){if((t.length-e)%2==0){var n=t.toString("utf16le",e);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,n)}return e}function u(t,e){var n=(t.length-e)%3;return 0===n?t.toString("base64",e):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-n))}function l(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}e.s=s,s.prototype.write=function(t){if(0===t.length)return"";var e,n;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0?(r>0&&(t.lastNeed=r-1),r):--i=0?(r>0&&(t.lastNeed=r-2),r):--i=0?(r>0&&(2===r?r=0:t.lastNeed=r-3),r):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=n;var i=t.length-(n-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},s.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},396:(t,e,n)=>{var i=n(8764),r=i.Buffer;function s(t,e){for(var n in t)e[n]=t[n]}function o(t,e,n){return r(t,e,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=i:(s(i,e),e.Buffer=o),o.prototype=Object.create(r.prototype),s(r,o),o.from=function(t,e,n){if("number"==typeof t)throw new TypeError("Argument must not be a number");return r(t,e,n)},o.alloc=function(t,e,n){if("number"!=typeof t)throw new TypeError("Argument must be a number");var i=r(t);return void 0!==e?"string"==typeof n?i.fill(e,n):i.fill(e):i.fill(0),i},o.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return r(t)},o.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i.SlowBuffer(t)}},971:t=>{t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const n=t.reduce(((t,n,i,r)=>(e.ngramLengths.forEach((e=>{var s=r.slice(i,i+e);s.length===e&&(n=JSON.stringify(s),t[n]=t[n]||[],t[n].push(i))})),t)),{});return Object.keys(n).map((t=>({term:JSON.parse(t),positions:n[t]}))).sort(((t,e)=>t.term[0]>e.term[0]))}},3692:t=>{"use strict";function e(t){return Object.prototype.toString.call(t)}var n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.forEach)return t.forEach(e);for(var n=0;n{function i(t){try{if(!n.g.localStorage)return!1}catch(t){return!1}var e=n.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(i("noDeprecation"))return t;var n=!1;return function(){if(!n){if(i("throwDeprecation"))throw new Error(e);i("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}},2361:()=>{},4616:()=>{}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var s=e[i]={exports:{}};return t[i].call(s.exports,s,s.exports,n),s.exports}n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";n.r(i),n.d(i,{SearchIndex:()=>ft});var t=n(6729);class e extends Error{constructor(t){super(t),this.name="TimeoutError"}}class r extends Error{constructor(t){super(),this.name="AbortError",this.message=t}}const s=t=>void 0===globalThis.DOMException?new r(t):new DOMException(t),o=t=>{const e=void 0===t.reason?s("This operation was aborted."):t.reason;return e instanceof Error?e:s(e)};var a,h=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class c{constructor(){a.set(this,[])}enqueue(t,e){const n={priority:(e={priority:0,...e}).priority,run:t};if(this.size&&h(this,a,"f")[this.size-1].priority>=e.priority)return void h(this,a,"f").push(n);const i=function(t,e,n){let i=0,r=t.length;for(;r>0;){const n=Math.trunc(r/2);let o=i+n;s=t[o],e.priority-s.priority<=0?(i=++o,r-=n+1):r=n}var s;return i}(h(this,a,"f"),n);h(this,a,"f").splice(i,0,n)}dequeue(){const t=h(this,a,"f").shift();return null==t?void 0:t.run}filter(t){return h(this,a,"f").filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return h(this,a,"f").length}}a=new WeakMap;var u,l,f,d,p,y,g,b,E,m,v,w,_,T,S,L,O,A,k,x,R,I,C,N,D,U,P=function(t,e,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(t,n):r?r.value=n:e.set(t,n),n},M=function(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)};class B extends Error{}class F extends t{constructor(t){var e,n,i,r;if(super(),u.add(this),l.set(this,void 0),f.set(this,void 0),d.set(this,0),p.set(this,void 0),y.set(this,void 0),g.set(this,0),b.set(this,void 0),E.set(this,void 0),m.set(this,void 0),v.set(this,void 0),w.set(this,0),_.set(this,void 0),T.set(this,void 0),S.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:c,...t}).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(r=null===(i=t.interval)||void 0===i?void 0:i.toString())&&void 0!==r?r:""}\` (${typeof t.interval})`);P(this,l,t.carryoverConcurrencyCount,"f"),P(this,f,t.intervalCap===Number.POSITIVE_INFINITY||0===t.interval,"f"),P(this,p,t.intervalCap,"f"),P(this,y,t.interval,"f"),P(this,m,new t.queueClass,"f"),P(this,v,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,P(this,S,!0===t.throwOnTimeout,"f"),P(this,T,!1===t.autoStart,"f")}get concurrency(){return M(this,_,"f")}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);P(this,_,t,"f"),M(this,u,"m",N).call(this)}async add(t,n={}){return n={timeout:this.timeout,throwOnTimeout:M(this,S,"f"),...n},new Promise(((i,r)=>{M(this,m,"f").enqueue((async()=>{var s,a,h;P(this,w,(a=M(this,w,"f"),++a),"f"),P(this,d,(h=M(this,d,"f"),++h),"f");try{if(null===(s=n.signal)||void 0===s?void 0:s.aborted)throw new B("The task was aborted.");let r=t({signal:n.signal});n.timeout&&(r=function(t,n,i,r){let s;const a=new Promise(((a,h)=>{if("number"!=typeof n||1!==Math.sign(n))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(n!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:t}=r;t.aborted&&h(o(t)),t.addEventListener("abort",(()=>{h(o(t))}))}s=r.customTimers.setTimeout.call(void 0,(()=>{const r=i instanceof Error?i:new e(`Promise timed out after ${n} milliseconds`);"function"==typeof t.cancel&&t.cancel(),h(r)}),n),(async()=>{try{a(await t)}catch(t){h(t)}finally{r.customTimers.clearTimeout.call(void 0,s)}})()}else a(t)}));return a.clear=()=>{clearTimeout(s),s=void 0},a}(Promise.resolve(r),n.timeout)),n.signal&&(r=Promise.race([r,M(this,u,"m",D).call(this,n.signal)]));const a=await r;i(a),this.emit("completed",a)}catch(t){if(t instanceof e&&!n.throwOnTimeout)return void i();r(t),this.emit("error",t)}finally{M(this,u,"m",A).call(this)}}),n),this.emit("add"),M(this,u,"m",R).call(this)}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return M(this,T,"f")?(P(this,T,!1,"f"),M(this,u,"m",N).call(this),this):this}pause(){P(this,T,!0,"f")}clear(){P(this,m,new(M(this,v,"f")),"f")}async onEmpty(){0!==M(this,m,"f").size&&await M(this,u,"m",U).call(this,"empty")}async onSizeLessThan(t){M(this,m,"f").sizeM(this,m,"f").size{M(this,u,"m",k).call(this)}),e),"f"),!0;P(this,d,M(this,l,"f")?M(this,w,"f"):0,"f")}return!1},R=function(){if(0===M(this,m,"f").size)return M(this,b,"f")&&clearInterval(M(this,b,"f")),P(this,b,void 0,"f"),this.emit("empty"),0===M(this,w,"f")&&this.emit("idle"),!1;if(!M(this,T,"f")){const t=!M(this,u,"a",x);if(M(this,u,"a",L)&&M(this,u,"a",O)){const e=M(this,m,"f").dequeue();return!!e&&(this.emit("active"),e(),t&&M(this,u,"m",I).call(this),!0)}}return!1},I=function(){M(this,f,"f")||void 0!==M(this,b,"f")||(P(this,b,setInterval((()=>{M(this,u,"m",C).call(this)}),M(this,y,"f")),"f"),P(this,g,Date.now()+M(this,y,"f"),"f"))},C=function(){0===M(this,d,"f")&&0===M(this,w,"f")&&M(this,b,"f")&&(clearInterval(M(this,b,"f")),P(this,b,void 0,"f")),P(this,d,M(this,l,"f")?M(this,w,"f"):0,"f"),M(this,u,"m",N).call(this)},N=function(){for(;M(this,u,"m",R).call(this););},D=async function(t){return new Promise(((e,n)=>{t.addEventListener("abort",(()=>{n(new B("The task was aborted."))}),{once:!0})}))},U=async function(t,e){return new Promise((n=>{const i=()=>{e&&!e()||(this.off(t,i),n())};this.on(t,i)}))};var j=n(6741);class V{constructor(t,e){const n=e=>new Promise(((n,i)=>{const r=[];new j.EntryStream(t.fii.STORE,{gte:["DOC_RAW",null],lte:["DOC_RAW",void 0],limit:e,...t.fii.LEVEL_OPTIONS}).on("data",(t=>r.push({_id:t.value._id,_doc:t.value}))).on("end",(()=>n(r)))})),i=(...e)=>e.length?Promise.all(e.map((e=>t.fii.STORE.get(["DOC_RAW",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))):n(),r=(...e)=>t.fii.DISTINCT(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),s=(...e)=>t.fii.FACETS(...e).then((t=>[...t.reduce(((t,e)=>t.add(JSON.stringify(Object.assign(e,{VALUE:e.VALUE})))),new Set)].map(JSON.parse))),o=(t,e)=>{const n=(e=Object.assign({NUMBER:0,SIZE:20},e||{})).NUMBER*e.SIZE,i=n+e.SIZE||void 0;return t.slice(n,i)},a=(t,e={})=>{e=Object.assign({TYPE:"TFIDF"},e);const n=t=>!e.FIELDS||e.FIELDS.includes(t.FIELD),i=t=>(t||[]).filter(n);return new Promise((r=>r("TFIDF"===e.TYPE?c().then((e=>t.map(((t,i,r)=>{const s=Math.log((e+1)/r.length);return t._score=+(t._match||[]).filter(n).reduce(((t,e)=>t+s*+e.SCORE),0).toFixed(2),t})))):"PRODUCT"===e.TYPE?t.map((t=>({...t,_score:+i(t._match).reduce(((t,e)=>t*+e.SCORE),1).toFixed(2)}))):"CONCAT"===e.TYPE?t.map((t=>({...t,_score:i(t._match).reduce(((t,e)=>t+e.SCORE),"")}))):"SUM"===e.TYPE?t.map((t=>({...t,_score:+i(t._match).reduce(((t,e)=>t+ +e.SCORE),0).toFixed(2)}))):"VALUE"===e.TYPE?t.map((t=>({...t,_score:i(t._match).reduce(((t,e)=>t+e.VALUE),"")}))):null)))},h=(t,e)=>(e=Object.assign({DIRECTION:"DESCENDING",TYPE:"NUMERIC"},e||{}),t.sort(((t,e)=>t._ide._id?1:0)).sort({NUMERIC:{DESCENDING:(t,e)=>+e._score-+t._score,ASCENDING:(t,e)=>+t._score-+e._score},ALPHABETIC:{DESCENDING:(t,e)=>t._scoree._score?-1:0,ASCENDING:(t,e)=>t._scoree._score?1:0}}[e.TYPE][e.DIRECTION])),c=()=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS),u=(e,r={})=>{const c=e=>"string"==typeof e||"number"==typeof e?t.fii.GET(e,r.PIPELINE):e.FIELD||e.VALUE?t.fii.GET(e):e.AND?t.fii.AND(e.AND.map(c),r.PIPELINE):e.GET?t.fii.GET(e.GET,r.PIPELINE):e.NOT?t.fii.NOT(c(e.NOT.INCLUDE),c(e.NOT.EXCLUDE)):e.OR?t.fii.OR(e.OR.map(c),r.PIPELINE):e.ALL_DOCUMENTS?n(e.ALL_DOCUMENTS):void 0;return c(e).then((t=>t.RESULT?Object.assign(t,{RESULT_LENGTH:t.RESULT.length}):{RESULT:t,RESULT_LENGTH:t.length})).then((e=>r.BUCKETS?t.fii.BUCKETS(...r.BUCKETS).then((n=>Object.assign(e,{BUCKETS:t.fii.AGGREGATION_FILTER(n,e.RESULT)}))):e)).then((n=>r.FACETS?n.RESULT.length?e.ALL_DOCUMENTS?s(...r.FACETS).then((t=>Object.assign(n,{FACETS:t}))):s(...r.FACETS).then((e=>Object.assign(n,{FACETS:t.fii.AGGREGATION_FILTER(e,n.RESULT)}))):Object.assign(n,{FACETS:[]}):n)).then((t=>{return r.WEIGHT?Object.assign({RESULT:(e=t.RESULT,n=r.WEIGHT,e.map((t=>(t._match=t._match.map((t=>(n.forEach((e=>{let n=!1;e.FIELD&&e.VALUE?e.FIELD===t.FIELD&&e.VALUE===t.VALUE&&(n=!0):e.FIELD?e.FIELD===t.FIELD&&(n=!0):e.VALUE&&e.VALUE===t.VALUE&&(n=!0),n&&(t.SCORE=(e.WEIGHT*+t.SCORE).toFixed(2))})),t))),t))))},t):t;var e,n})).then((t=>r.SCORE?a(t.RESULT,r.SCORE).then((e=>Object.assign(t,{RESULT:e}))):t)).then((t=>Object.assign(t,r.SORT?{RESULT:h(t.RESULT,r.SORT)}:{}))).then((t=>Object.assign(t,r.PAGE?{RESULT:o(t.RESULT,r.PAGE)}:{}))).then((t=>r.DOCUMENTS?i(...t.RESULT.map((t=>t._id))).then((e=>Object.assign(t,{RESULT:t.RESULT.map(((t,n)=>Object.assign(t,{_doc:e[n]})))}))):t))},l=(t,n)=>new Promise((i=>(n=JSON.stringify(n),e.has(n)?i(e.get(n)):t.then((t=>e.set(n,t))).then((()=>i(e.get(n)))))));return{ALL_DOCUMENTS:n,DICTIONARY:t=>l((t=>r(t).then((t=>Array.from(t.reduce(((t,e)=>t.add(e.VALUE)),new Set)).sort(((t,e)=>(t+"").localeCompare(e+"",void 0,{numeric:!0,sensitivity:"base"}))))))(t),{DICTIONARY:t||null}),DISTINCT:r,DOCUMENTS:(...t)=>l(i(...t),{DOCUMENTS:t}),DOCUMENT_COUNT:c,DOCUMENT_VECTORS:(...e)=>Promise.all(e.map((e=>t.fii.STORE.get(["DOC",e],t.fii.LEVEL_OPTIONS).catch((t=>null))))),FACETS:s,PAGE:o,QUERY:(t,e)=>l(u(t,e),{QUERY:[t,e]}),SCORE:a,SEARCH:(t,e)=>l(((t,e)=>u({AND:[...t]},Object.assign({SCORE:{TYPE:"TFIDF"},SORT:!0},e)))(t,e),{SEARCH:[t,e]}),SORT:h}}}var z=n(9203),G=n(4155);const W="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,K=new Set,q="object"==typeof G&&G?G:{},$=(t,e,n,i)=>{"function"==typeof q.emitWarning?q.emitWarning(t,e,n,i):console.error(`[${n}] ${e}: ${t}`)};let H=globalThis.AbortController,Y=globalThis.AbortSignal;if(void 0===H){Y=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(t,e){this._onabort.push(e)}},H=class{constructor(){e()}signal=new Y;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);this.signal.onabort?.(t)}}};let t="1"!==q.env?.LRU_CACHE_IGNORE_AC_WARNING;const e=()=>{t&&(t=!1,$("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e))}}Symbol("type");const J=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),X=t=>J(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Q:null:null;class Q extends Array{constructor(t){super(t),this.fill(0)}}class Z{heap;length;static#t=!1;static create(t){const e=X(t);if(!e)return[];Z.#t=!0;const n=new Z(t,e);return Z.#t=!1,n}constructor(t,e){if(!Z.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new e(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}}class tt{#e;#n;#i;#r;#s;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#o;#a;#h;#c;#u;#l;#f;#d;#p;#y;#g;#b;#E;#m;#v;#w;#_;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#m,sizes:t.#b,keyMap:t.#h,keyList:t.#c,valList:t.#u,next:t.#l,prev:t.#f,get head(){return t.#d},get tail(){return t.#p},free:t.#y,isBackgroundFetch:e=>t.#T(e),backgroundFetch:(e,n,i,r)=>t.#S(e,n,i,r),moveToTail:e=>t.#L(e),indexes:e=>t.#O(e),rindexes:e=>t.#A(e),isStale:e=>t.#k(e)}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#a}get size(){return this.#o}get fetchMethod(){return this.#s}get dispose(){return this.#i}get disposeAfter(){return this.#r}constructor(t){const{max:e=0,ttl:n,ttlResolution:i=1,ttlAutopurge:r,updateAgeOnGet:s,updateAgeOnHas:o,allowStale:a,dispose:h,disposeAfter:c,noDisposeOnSet:u,noUpdateTTL:l,maxSize:f=0,maxEntrySize:d=0,sizeCalculation:p,fetchMethod:y,noDeleteOnFetchRejection:g,noDeleteOnStaleGet:b,allowStaleOnFetchRejection:E,allowStaleOnFetchAbort:m,ignoreFetchAbort:v}=t;if(0!==e&&!J(e))throw new TypeError("max option must be a nonnegative integer");const w=e?X(e):Array;if(!w)throw new Error("invalid max value: "+e);if(this.#e=e,this.#n=f,this.maxEntrySize=d||this.#n,this.sizeCalculation=p,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==y&&"function"!=typeof y)throw new TypeError("fetchMethod must be a function if specified");if(this.#s=y,this.#w=!!y,this.#h=new Map,this.#c=new Array(e).fill(void 0),this.#u=new Array(e).fill(void 0),this.#l=new w(e),this.#f=new w(e),this.#d=0,this.#p=0,this.#y=Z.create(e),this.#o=0,this.#a=0,"function"==typeof h&&(this.#i=h),"function"==typeof c?(this.#r=c,this.#g=[]):(this.#r=void 0,this.#g=void 0),this.#v=!!this.#i,this.#_=!!this.#r,this.noDisposeOnSet=!!u,this.noUpdateTTL=!!l,this.noDeleteOnFetchRejection=!!g,this.allowStaleOnFetchRejection=!!E,this.allowStaleOnFetchAbort=!!m,this.ignoreFetchAbort=!!v,0!==this.maxEntrySize){if(0!==this.#n&&!J(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!J(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#x()}if(this.allowStale=!!a,this.noDeleteOnStaleGet=!!b,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!o,this.ttlResolution=J(i)||0===i?i:1,this.ttlAutopurge=!!r,this.ttl=n||0,this.ttl){if(!J(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#R()}if(0===this.#e&&0===this.ttl&&0===this.#n)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){const t="LRU_CACHE_UNBOUNDED";(t=>!K.has(t))(t)&&(K.add(t),$("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,tt))}}getRemainingTTL(t){return this.#h.has(t)?1/0:0}#R(){const t=new Q(this.#e),e=new Q(this.#e);this.#m=t,this.#E=e,this.#I=(n,i,r=W.now())=>{if(e[n]=0!==i?r:0,t[n]=i,0!==i&&this.ttlAutopurge){const t=setTimeout((()=>{this.#k(n)&&this.delete(this.#c[n])}),i+1);t.unref&&t.unref()}},this.#C=n=>{e[n]=0!==t[n]?W.now():0},this.#N=(r,s)=>{if(t[s]){const o=t[s],a=e[s];r.ttl=o,r.start=a,r.now=n||i();const h=r.now-a;r.remainingTTL=o-h}};let n=0;const i=()=>{const t=W.now();if(this.ttlResolution>0){n=t;const e=setTimeout((()=>n=0),this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=r=>{const s=this.#h.get(r);if(void 0===s)return 0;const o=t[s],a=e[s];return 0===o||0===a?1/0:o-((n||i())-a)},this.#k=r=>0!==t[r]&&0!==e[r]&&(n||i())-e[r]>t[r]}#C=()=>{};#N=()=>{};#I=()=>{};#k=()=>!1;#x(){const t=new Q(this.#e);this.#a=0,this.#b=t,this.#D=e=>{this.#a-=t[e],t[e]=0},this.#U=(t,e,n,i)=>{if(this.#T(e))return 0;if(!J(n)){if(!i)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof i)throw new TypeError("sizeCalculation must be a function");if(n=i(e,t),!J(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n},this.#P=(e,n,i)=>{if(t[e]=n,this.#n){const n=this.#n-t[e];for(;this.#a>n;)this.#M(!0)}this.#a+=t[e],i&&(i.entrySize=n,i.totalCalculatedSize=this.#a)}}#D=t=>{};#P=(t,e,n)=>{};#U=(t,e,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#O({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#p;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#d);)e=this.#f[e]}*#A({allowStale:t=this.allowStale}={}){if(this.#o)for(let e=this.#d;this.#B(e)&&(!t&&this.#k(e)||(yield e),e!==this.#p);)e=this.#l[e]}#B(t){return void 0!==t&&this.#h.get(this.#c[t])===t}*entries(){for(const t of this.#O())void 0===this.#u[t]||void 0===this.#c[t]||this.#T(this.#u[t])||(yield[this.#c[t],this.#u[t]])}*rentries(){for(const t of this.#A())void 0===this.#u[t]||void 0===this.#c[t]||this.#T(this.#u[t])||(yield[this.#c[t],this.#u[t]])}*keys(){for(const t of this.#O()){const e=this.#c[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*rkeys(){for(const t of this.#A()){const e=this.#c[t];void 0===e||this.#T(this.#u[t])||(yield e)}}*values(){for(const t of this.#O())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}*rvalues(){for(const t of this.#A())void 0===this.#u[t]||this.#T(this.#u[t])||(yield this.#u[t])}[Symbol.iterator](){return this.entries()}find(t,e={}){for(const n of this.#O()){const i=this.#u[n],r=this.#T(i)?i.__staleWhileFetching:i;if(void 0!==r&&t(r,this.#c[n],this))return this.get(this.#c[n],e)}}forEach(t,e=this){for(const n of this.#O()){const i=this.#u[n],r=this.#T(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#c[n],this)}}rforEach(t,e=this){for(const n of this.#A()){const i=this.#u[n],r=this.#T(i)?i.__staleWhileFetching:i;void 0!==r&&t.call(e,r,this.#c[n],this)}}purgeStale(){let t=!1;for(const e of this.#A({allowStale:!0}))this.#k(e)&&(this.delete(this.#c[e]),t=!0);return t}dump(){const t=[];for(const e of this.#O({allowStale:!0})){const n=this.#c[e],i=this.#u[e],r=this.#T(i)?i.__staleWhileFetching:i;if(void 0===r||void 0===n)continue;const s={value:r};if(this.#m&&this.#E){s.ttl=this.#m[e];const t=W.now()-this.#E[e];s.start=Math.floor(Date.now()-t)}this.#b&&(s.size=this.#b[e]),t.unshift([n,s])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=W.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){if(void 0===e)return this.delete(t),this;const{ttl:i=this.ttl,start:r,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:o=this.sizeCalculation,status:a}=n;let{noUpdateTTL:h=this.noUpdateTTL}=n;const c=this.#U(t,e,n.size||0,o);if(this.maxEntrySize&&c>this.maxEntrySize)return a&&(a.set="miss",a.maxEntrySizeExceeded=!0),this.delete(t),this;let u=0===this.#o?void 0:this.#h.get(t);if(void 0===u)u=0===this.#o?this.#p:0!==this.#y.length?this.#y.pop():this.#o===this.#e?this.#M(!1):this.#o,this.#c[u]=t,this.#u[u]=e,this.#h.set(t,u),this.#l[this.#p]=u,this.#f[u]=this.#p,this.#p=u,this.#o++,this.#P(u,c,a),a&&(a.set="add"),h=!1;else{this.#L(u);const n=this.#u[u];if(e!==n){if(this.#w&&this.#T(n)?n.__abortController.abort(new Error("replaced")):s||(this.#v&&this.#i?.(n,t,"set"),this.#_&&this.#g?.push([n,t,"set"])),this.#D(u),this.#P(u,c,a),this.#u[u]=e,a){a.set="replace";const t=n&&this.#T(n)?n.__staleWhileFetching:n;void 0!==t&&(a.oldValue=t)}}else a&&(a.set="update")}if(0===i||this.#m||this.#R(),this.#m&&(h||this.#I(u,i,r),a&&this.#N(a,u)),!s&&this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}return this}pop(){try{for(;this.#o;){const t=this.#u[this.#d];if(this.#M(!0),this.#T(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}}}#M(t){const e=this.#d,n=this.#c[e],i=this.#u[e];return this.#w&&this.#T(i)?i.__abortController.abort(new Error("evicted")):(this.#v||this.#_)&&(this.#v&&this.#i?.(i,n,"evict"),this.#_&&this.#g?.push([i,n,"evict"])),this.#D(e),t&&(this.#c[e]=void 0,this.#u[e]=void 0,this.#y.push(e)),1===this.#o?(this.#d=this.#p=0,this.#y.length=0):this.#d=this.#l[e],this.#h.delete(n),this.#o--,e}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=e,r=this.#h.get(t);if(void 0!==r){const t=this.#u[r];if(this.#T(t)&&void 0===t.__staleWhileFetching)return!1;if(!this.#k(r))return n&&this.#C(r),i&&(i.has="hit",this.#N(i,r)),!0;i&&(i.has="stale",this.#N(i,r))}else i&&(i.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,i=this.#h.get(t);if(void 0!==i&&(n||!this.#k(i))){const t=this.#u[i];return this.#T(t)?t.__staleWhileFetching:t}}#S(t,e,n,i){const r=void 0===e?void 0:this.#u[e];if(this.#T(r))return r;const s=new H,{signal:o}=n;o?.addEventListener("abort",(()=>s.abort(o.reason)),{signal:s.signal});const a={signal:s.signal,options:n,context:i},h=(i,r=!1)=>{const{aborted:o}=s.signal,h=n.ignoreFetchAbort&&void 0!==i;if(n.status&&(o&&!r?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,h&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),o&&!h&&!r)return c(s.signal.reason);const l=u;return this.#u[e]===u&&(void 0===i?l.__staleWhileFetching?this.#u[e]=l.__staleWhileFetching:this.delete(t):(n.status&&(n.status.fetchUpdated=!0),this.set(t,i,a.options))),i},c=i=>{const{aborted:r}=s.signal,o=r&&n.allowStaleOnFetchAbort,a=o||n.allowStaleOnFetchRejection,h=a||n.noDeleteOnFetchRejection,c=u;if(this.#u[e]===u&&(h&&void 0!==c.__staleWhileFetching?o||(this.#u[e]=c.__staleWhileFetching):this.delete(t)),a)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw i};n.status&&(n.status.fetchDispatched=!0);const u=new Promise(((e,i)=>{const o=this.#s?.(t,r,a);o&&o instanceof Promise&&o.then((t=>e(void 0===t?void 0:t)),i),s.signal.addEventListener("abort",(()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>h(t,!0)))}))})).then(h,(t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),c(t)))),l=Object.assign(u,{__abortController:s,__staleWhileFetching:r,__returned:void 0});return void 0===e?(this.set(t,l,{...a.options,status:void 0}),e=this.#h.get(t)):this.#u[e]=l,l}#T(t){if(!this.#w)return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof H}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:o=this.noDisposeOnSet,size:a=0,sizeCalculation:h=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:l=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:y=!1,status:g,signal:b}=e;if(!this.#w)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,status:g});const E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:r,ttl:s,noDisposeOnSet:o,size:a,sizeCalculation:h,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:l,allowStaleOnFetchAbort:d,ignoreFetchAbort:f,status:g,signal:b};let m=this.#h.get(t);if(void 0===m){g&&(g.fetch="miss");const e=this.#S(t,m,E,p);return e.__returned=e}{const e=this.#u[m];if(this.#T(e)){const t=n&&void 0!==e.__staleWhileFetching;return g&&(g.fetch="inflight",t&&(g.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const r=this.#k(m);if(!y&&!r)return g&&(g.fetch="hit"),this.#L(m),i&&this.#C(m),g&&this.#N(g,m),e;const s=this.#S(t,m,E,p),o=void 0!==s.__staleWhileFetching&&n;return g&&(g.fetch=r?"stale":"refresh",o&&r&&(g.returnedStale=!0)),o?s.__staleWhileFetching:s.__returned=s}}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:r=this.noDeleteOnStaleGet,status:s}=e,o=this.#h.get(t);if(void 0!==o){const e=this.#u[o],a=this.#T(e);return s&&this.#N(s,o),this.#k(o)?(s&&(s.get="stale"),a?(s&&n&&void 0!==e.__staleWhileFetching&&(s.returnedStale=!0),n?e.__staleWhileFetching:void 0):(r||this.delete(t),s&&n&&(s.returnedStale=!0),n?e:void 0)):(s&&(s.get="hit"),a?e.__staleWhileFetching:(this.#L(o),i&&this.#C(o),e))}s&&(s.get="miss")}#F(t,e){this.#f[e]=t,this.#l[t]=e}#L(t){t!==this.#p&&(t===this.#d?this.#d=this.#l[t]:this.#F(this.#f[t],this.#l[t]),this.#F(this.#p,t),this.#p=t)}delete(t){let e=!1;if(0!==this.#o){const n=this.#h.get(t);if(void 0!==n)if(e=!0,1===this.#o)this.clear();else{this.#D(n);const e=this.#u[n];this.#T(e)?e.__abortController.abort(new Error("deleted")):(this.#v||this.#_)&&(this.#v&&this.#i?.(e,t,"delete"),this.#_&&this.#g?.push([e,t,"delete"])),this.#h.delete(t),this.#c[n]=void 0,this.#u[n]=void 0,n===this.#p?this.#p=this.#f[n]:n===this.#d?this.#d=this.#l[n]:(this.#l[this.#f[n]]=this.#l[n],this.#f[this.#l[n]]=this.#f[n]),this.#o--,this.#y.push(n)}}if(this.#_&&this.#g?.length){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}return e}clear(){for(const t of this.#A({allowStale:!0})){const e=this.#u[t];if(this.#T(e))e.__abortController.abort(new Error("deleted"));else{const n=this.#c[t];this.#v&&this.#i?.(e,n,"delete"),this.#_&&this.#g?.push([e,n,"delete"])}}if(this.#h.clear(),this.#u.fill(void 0),this.#c.fill(void 0),this.#m&&this.#E&&(this.#m.fill(0),this.#E.fill(0)),this.#b&&this.#b.fill(0),this.#d=0,this.#p=0,this.#y.length=0,this.#a=0,this.#o=0,this.#_&&this.#g){const t=this.#g;let e;for(;e=t?.shift();)this.#r?.(...e)}}}const et=(t,e,n)=>{const i=e=>t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],+n+e,t.fii.LEVEL_OPTIONS))).catch((n=>t.fii.STORE.put(["DOCUMENT_COUNT"],e,t.fii.LEVEL_OPTIONS))),r=(n,i,r)=>(e.clear(),Promise.all(n.map(((e,n)=>t.fii.STORE.put(["DOC_RAW",i[n]],r?{}:e,t.fii.LEVEL_OPTIONS)))).then((t=>n.map(((t,e)=>({_id:i[e],status:"OK",operation:"_PUT_RAW"}))))));return{DELETE:(...n)=>{return i=n,t.fii.DELETE(i,t.fii.LEVEL_OPTIONS).then((n=>{e.clear();const i=n.filter((t=>"DELETED"===t.status));return Promise.all([Promise.all(i.map((e=>t.fii.STORE.del(["DOC_RAW",e._id],t.fii.LEVEL_OPTIONS)))),(r=i.length,t.fii.STORE.get(["DOCUMENT_COUNT"],t.fii.LEVEL_OPTIONS).then((e=>t.fii.STORE.put(["DOCUMENT_COUNT"],+e-r,t.fii.LEVEL_OPTIONS))))]).then((()=>n));var r}));var i},FLUSH:()=>t.fii.STORE.clear().then((()=>{e.clear();const n=Date.now();return t.fii.STORE.batch([{type:"put",key:["~CREATED"],value:n},{type:"put",key:["~LAST_UPDATED"],value:n},{type:"put",key:["DOCUMENT_COUNT"],value:0}],t.fii.LEVEL_OPTIONS)})).then((()=>!0)),IMPORT:n=>(e.clear(),Promise.resolve(t.fii.IMPORT(n))),PUT:(s,o)=>n.add((()=>((n,s)=>(e.clear(),s=Object.assign(t,s),(t=>{const e=t=>"string"==typeof t||t instanceof String,n=(i,r)=>new Promise((async s=>{return null===i?s([null,"1.00"]):(o=i)&&0===Object.keys(o).length&&Object.getPrototypeOf(o)===Object.prototype?s([[],"1.00"]):Number.isInteger(i)?s([i,i]):e(i)?s(t.tokenizer(i,r,t)):(t=>"object"==typeof t&&null!==t&&!Array.isArray(t))(i)?s((a=i,new Promise((async e=>{const i={};for(const e in a)i[e]=await n(a[e],e,t);return e(i)})))):(t=>Array.isArray(t))(i)?s((h=i,Promise.all(h.map(n)))):s(i);var o,a,h})),i=async i=>new Promise((async r=>{e(i)&&(i={body:i}),Object.prototype.hasOwnProperty.call(i,"_id")||(i._id=t.idGenerator.next().value);const s={};for(const t in i)s[t]="_id"!==t?await n(i[t],t):i[t];return r(s)}));return{processDocuments:t=>Promise.all(t.map(i))}})(t).processDocuments(n).then((e=>t.fii.PUT(e,s,t.fii.LEVEL_OPTIONS).then((e=>Promise.all([r(n,e.map((t=>t._id)),!t.storeRawDocs),i(e.filter((t=>"CREATED"===t.status)).length)]).then((()=>e))))))))(s,o))),PUT_RAW:r,_INCREMENT_DOC_COUNT:i}};var nt=n(971),it=n(6349);const rt=([t,e,n])=>[n.skipFields.includes(e)?[]:t,e,n],st=([t,e,n])=>Promise.resolve([t.map((t=>n.caseSensitive?t:t.toLowerCase())),e,n]),ot=([t,e,n])=>{const{fields:i,values:r}=n.replace,s=()=>t.reduce(((t,e)=>[e,...t,...r[e]||[]]),[]);return r?i?i.includes(e)?Promise.resolve([s(),e,n]):Promise.resolve([t,e,n]):Promise.resolve([s(),e,n]):Promise.resolve([t,e,n])},at=([t,e,n])=>{let{fields:i,lengths:r,join:s=" "}=n.ngrams;return i||(i=[e]),r&&i.includes(e)?[it(t.filter((t=>null!==t)),r).map((t=>t.join(s))),e,n]:Promise.resolve([t,e,n])},ht=([t,e,n])=>[t.filter((t=>!n.stopwords.includes(t.toLowerCase()))),e,n],ct=([t,e,n])=>{const i=nt(t),r=i.reduce(((t,e)=>Math.max(e.positions.length,t)),0);return Promise.resolve([i.map((t=>[t.term[0],(t.positions.length/r).toFixed(2)])).sort(),e,n])},ut=(t,e,n)=>(([t,e,n])=>Promise.resolve([t.match(n.tokenSplitRegex)||[],e,n]))([t,e,n]).then(rt).then(st).then(ot).then(at).then(ht).then(ct).then((([t,e,n])=>t)),lt=t=>new Promise((async e=>{const n=new tt({max:1e3}),i=new F({concurrency:1}),r=et(t,n,i),s=new V(t,n);return r._INCREMENT_DOC_COUNT(0).then((()=>e({_AND:t.fii.AND,_BUCKET:t.fii.BUCKET,_GET:t.fii.GET,_NOT:t.fii.NOT,_OR:t.fii.OR,_CACHE:n,_PAGE:s.PAGE,_SCORE:s.SCORE,_SEARCH:s.SEARCH,_SORT:s.SORT,DELETE:r.DELETE,FLUSH:r.FLUSH,IMPORT:r.IMPORT,PUT:r.PUT,PUT_RAW:r.PUT_RAW,TOKENIZATION_PIPELINE_STAGES:ut,ALL_DOCUMENTS:s.ALL_DOCUMENTS,BUCKETS:t.fii.BUCKETS,CREATED:t.fii.CREATED,DICTIONARY:s.DICTIONARY,DISTINCT:s.DISTINCT,DOCUMENTS:s.DOCUMENTS,DOCUMENT_COUNT:s.DOCUMENT_COUNT,DOCUMENT_VECTORS:s.DOCUMENT_VECTORS,EXPORT:t.fii.EXPORT,FACETS:s.FACETS,FIELDS:t.fii.FIELDS,INDEX:t.fii,LAST_UPDATED:t.fii.LAST_UPDATED,MAX:t.fii.MAX,MIN:t.fii.MIN,QUERY:s.QUERY,SEARCH:s.SEARCH})))}));class ft{constructor(t){return((t={})=>new Promise(((e,n)=>(t=Object.assign({cacheLength:1e3,caseSensitive:!1,docExistsSpace:"DOC_RAW",idGenerator:function*(){let t=0;for(;;)yield Date.now()+"-"+t++}(),isLeaf:t=>Array.isArray(t)&&2===t.length&&t.every((t=>"string"==typeof t||"number"==typeof t||null===t)),skipFields:[],ngrams:{},replace:{},storeRawDocs:!0,stopwords:[],storeVectors:!0,tokenAppend:"#",tokenSplitRegex:/[\p{L}\d]+/gu,tokenizer:ut},t),z(t).then((n=>e(Object.assign({fii:n},t))))))))(t).then(lt).then((t=>(t=>new Promise(((e,n)=>{const i=["CREATED_WITH"],r="search-index@4.0.0";return t.INDEX.STORE.get(i,t.INDEX.LEVEL_OPTIONS).then((t=>r===t?e():n(new Error("This index was created with "+t+", you are running "+r)))).catch((n=>t.INDEX.STORE.put(i,r,t.INDEX.LEVEL_OPTIONS).then(e)))})))(t).then((()=>t))))}}})(),SearchIndex=i})(); \ No newline at end of file diff --git a/package.json b/package.json index d591c770..6f3454ae 100755 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "directories": { "lib": "src" }, + "type": "module", "scripts": { "build": "npm run empty-sandbox && rm -rf ./dist/* && webpack && cp dist/search-index-$npm_package_version.js dist/search-index.js", "demo-export": "node demo/generate-index/export.js", @@ -32,10 +33,11 @@ "demo-start": "http-server -c-1 demo & open-cli http://127.0.0.1:8080", "demo-link-lib": "cd demo/lib && ln -sf ../../dist/search-index.js && cd ../../", "empty-sandbox": "rm -rf fii && rm -rf test/sandbox && mkdir test/sandbox", + "generateVersionModule": "echo export const packageVersion = \\\"${npm_package_version}\\\" > src/version.js", "lint": "standard --fix test/src/* src/* demo/src/* demo/generate-index/*.js", "test": "npm run empty-sandbox && npm run test-node && npm run test-browser && npm run lint", "test-browser": "npm run build && cat test/sandbox/browser-tests.js | tape-run", - "test-node": "npm run empty-sandbox && tape test/src/*-test.js", + "test-node": "npm run empty-sandbox && tape test/src/init-test.js", "toc": "doctoc docs/API.md --title '# API Documentation for search-index' && doctoc docs/FAQ.md --title '# FAQ'" }, "repository": { diff --git a/src/DocumentProcessor.js b/src/DocumentProcessor.js index 245fc4db..382e03da 100644 --- a/src/DocumentProcessor.js +++ b/src/DocumentProcessor.js @@ -1,4 +1,4 @@ -module.exports = ops => { +export const DocumentProcessor = ops => { const isObject = item => typeof item === 'object' && item !== null && !Array.isArray(item) @@ -25,7 +25,7 @@ module.exports = ops => { const processValueUnknownType = (unknown, key) => // eslint-disable-next-line - new Promise(async resolve => { + new Promise(async resolve => { if (unknown === null) return resolve([null, '1.00']) if (isEmptyObject(unknown)) return resolve([[], '1.00']) if (Number.isInteger(unknown)) return resolve([unknown, unknown]) diff --git a/src/main.js b/src/main.js index c1b6d36b..5b4250e8 100755 --- a/src/main.js +++ b/src/main.js @@ -1,10 +1,14 @@ -const fii = require('fergies-inverted-index') -const tp = require('./tokenisationPipeline') - -const { LRUCache } = require('lru-cache') -const reader = require('./read.js') -const writer = require('./write.js') -const packageJSON = require('../package.json') +import PQueue from 'p-queue' +import Reader from './read.js' +import fii from 'fergies-inverted-index' +// the following makes standard.js/ESLint throw a wobbly that can't be +// resolved by setting an ignore rule +// import packageJSON from '../package.json' assert { type: 'json' } +// So do this instead: +import { packageVersion } from './version.js' +import { LRUCache } from 'lru-cache' +import { Writer } from './write.js' +import { tokenizationPipeline } from './tokenisationPipeline.js' // eslint-disable-next-line const makeASearchIndex = ops => @@ -16,11 +20,13 @@ const makeASearchIndex = ops => }) // eslint-disable-next-line - const queue = new (await import('p-queue')).default({ concurrency: 1 }) + // const queue = new (await import('p-queue')).default({ concurrency: 1 }) + + const queue = new PQueue({ concurrency: 1 }) // TODO: should be just ops? - const w = writer(ops, cache, queue) - const r = reader(ops, cache) + const w = Writer(ops, cache, queue) + const r = new Reader(ops, cache) // TODO: more caching return w._INCREMENT_DOC_COUNT(0).then(() => @@ -45,7 +51,7 @@ const makeASearchIndex = ops => IMPORT: w.IMPORT, PUT: w.PUT, PUT_RAW: w.PUT_RAW, - TOKENIZATION_PIPELINE_STAGES: tp, + TOKENIZATION_PIPELINE_STAGES: tokenizationPipeline, // public API (read) ALL_DOCUMENTS: r.ALL_DOCUMENTS, @@ -99,7 +105,7 @@ const initIndex = (ops = {}) => storeVectors: true, // TODO: make a test for this being false tokenAppend: '#', tokenSplitRegex: /[\p{L}\d]+/gu, - tokenizer: tp.tokenizer + tokenizer: tokenizationPipeline }, ops ) @@ -119,7 +125,7 @@ const initIndex = (ops = {}) => const validateVersion = si => new Promise((resolve, reject) => { const key = ['CREATED_WITH'] - const version = 'search-index@' + packageJSON.version + const version = 'search-index@' + packageVersion return si.INDEX.STORE.get(key, si.INDEX.LEVEL_OPTIONS) .then(v => // throw a rejection if versions do not match @@ -137,7 +143,10 @@ const validateVersion = si => .catch(e => si.INDEX.STORE.put(key, version, si.INDEX.LEVEL_OPTIONS).then(resolve)) }) -module.exports = ops => - initIndex(ops) - .then(makeASearchIndex) - .then(si => validateVersion(si).then(() => si)) +export class SearchIndex { + constructor (ops) { + return initIndex(ops) + .then(makeASearchIndex) + .then(si => validateVersion(si).then(() => si)) + } +} diff --git a/src/read.js b/src/read.js index 3fb245b6..0b46b6ab 100755 --- a/src/read.js +++ b/src/read.js @@ -1,428 +1,430 @@ // TODO: remove all '○' and '#' - -const { EntryStream } = require('level-read-stream') - -module.exports = (ops, cache) => { - // TODO add aggregation to ALL_DOCUMENTS - const ALL_DOCUMENTS = limit => - new Promise((resolve, reject) => { - const result = [] - new EntryStream(ops.fii.STORE, { - // gte: null, - // lte: undefined, - gte: ['DOC_RAW', null], - lte: ['DOC_RAW', undefined], - limit, - ...ops.fii.LEVEL_OPTIONS +import { EntryStream } from 'level-read-stream' + +export default class Reader { + // exports.reader = (ops, cache) => { + constructor (ops, cache) { + // TODO add aggregation to ALL_DOCUMENTS + const ALL_DOCUMENTS = limit => + new Promise((resolve, reject) => { + const result = [] + new EntryStream(ops.fii.STORE, { + // gte: null, + // lte: undefined, + gte: ['DOC_RAW', null], + lte: ['DOC_RAW', undefined], + limit, + ...ops.fii.LEVEL_OPTIONS + }) + .on('data', d => + result.push({ + _id: d.value._id, + _doc: d.value + }) + ) + .on('end', () => resolve(result)) }) - .on('data', d => - result.push({ - _id: d.value._id, - _doc: d.value - }) - ) - .on('end', () => resolve(result)) - }) - - const DOCUMENTS = (...requestedDocs) => - requestedDocs.length - ? Promise.all( - requestedDocs.map(_id => - ops.fii.STORE.get(['DOC_RAW', _id], ops.fii.LEVEL_OPTIONS).catch(e => null) + + const DOCUMENTS = (...requestedDocs) => + requestedDocs.length + ? Promise.all( + requestedDocs.map(_id => + ops.fii.STORE.get(['DOC_RAW', _id], ops.fii.LEVEL_OPTIONS).catch(e => null) + ) ) + : ALL_DOCUMENTS() + + const DOCUMENT_VECTORS = (...requestedDocs) => + Promise.all( + requestedDocs.map(_id => ops.fii.STORE.get(['DOC', _id], ops.fii.LEVEL_OPTIONS).catch(e => null)) ) - : ALL_DOCUMENTS() - - const DOCUMENT_VECTORS = (...requestedDocs) => - Promise.all( - requestedDocs.map(_id => ops.fii.STORE.get(['DOC', _id], ops.fii.LEVEL_OPTIONS).catch(e => null)) - ) - - const DICTIONARY = token => - DISTINCT(token).then(results => - Array.from( - results.reduce((acc, cur) => acc.add(cur.VALUE), new Set()) - ).sort((a, b) => + + const DICTIONARY = token => + DISTINCT(token).then(results => + Array.from( + results.reduce((acc, cur) => acc.add(cur.VALUE), new Set()) + ).sort((a, b) => // This should sort an array of strings and // numbers in an intuitive way (numbers numerically, strings // alphabetically) - (a + '').localeCompare(b + '', undefined, { - numeric: true, - sensitivity: 'base' - }) - ) - ) - - const DISTINCT = (...tokens) => - ops.fii.DISTINCT(...tokens).then(result => { - return [ - // Stringify Set entries so that Set can determine duplicates - ...result.reduce( - (acc, cur) => - acc.add( - JSON.stringify( - Object.assign(cur, { - VALUE: cur.VALUE - }) - ) - ), - new Set() - ) - ].map(JSON.parse) - }) // un-stringify - - const FACETS = (...tokens) => - ops.fii.FACETS(...tokens).then(result => - [ - // Stringify Set entries so that Set can determine duplicates - ...result.reduce( - (acc, cur) => - acc.add( - JSON.stringify( - Object.assign(cur, { - // VALUE: cur.VALUE.split('#')[0] // TODO: this is wrong - VALUE: cur.VALUE - }) - ) - ), - new Set() + (a + '').localeCompare(b + '', undefined, { + numeric: true, + sensitivity: 'base' + }) ) - ].map(JSON.parse) - ) // un-stringify - - const PAGE = (results, options) => { - options = Object.assign( - { - NUMBER: 0, - SIZE: 20 - }, - options || {} - ) - const start = options.NUMBER * options.SIZE - // handle end index correctly when (start + size) == 0 - // (when paging from the end with a negative page number) - const end = start + options.SIZE || undefined - return results.slice(start, end) - } + ) + + const DISTINCT = (...tokens) => + ops.fii.DISTINCT(...tokens).then(result => { + return [ + // Stringify Set entries so that Set can determine duplicates + ...result.reduce( + (acc, cur) => + acc.add( + JSON.stringify( + Object.assign(cur, { + VALUE: cur.VALUE + }) + ) + ), + new Set() + ) + ].map(JSON.parse) + }) // un-stringify + + const FACETS = (...tokens) => + ops.fii.FACETS(...tokens).then(result => + [ + // Stringify Set entries so that Set can determine duplicates + ...result.reduce( + (acc, cur) => + acc.add( + JSON.stringify( + Object.assign(cur, { + // VALUE: cur.VALUE.split('#')[0] // TODO: this is wrong + VALUE: cur.VALUE + }) + ) + ), + new Set() + ) + ].map(JSON.parse) + ) // un-stringify - // score by tfidf by default - // TODO: Total hits (length of _match) - // TODO: better error handling: what if TYPE is 'XXXXX' - // TODO: scoring precision (decimal places) should be an option - const SCORE = (results, scoreOps = {}) => { - // TODO: test for defaulting to TFIDF - scoreOps = Object.assign( - { - TYPE: 'TFIDF' - }, - scoreOps - ) - - const filterFields = item => { - if (!scoreOps.FIELDS) return true - return scoreOps.FIELDS.includes(item.FIELD) + const PAGE = (results, options) => { + options = Object.assign( + { + NUMBER: 0, + SIZE: 20 + }, + options || {} + ) + const start = options.NUMBER * options.SIZE + // handle end index correctly when (start + size) == 0 + // (when paging from the end with a negative page number) + const end = start + options.SIZE || undefined + return results.slice(start, end) } - const filterMatch = _match => (_match || []).filter(filterFields) - - return new Promise(resolve => - resolve( - scoreOps.TYPE === 'TFIDF' - ? DOCUMENT_COUNT().then(docCount => - results.map((result, _, resultSet) => { - const idf = Math.log((docCount + 1) / resultSet.length) - result._score = +(result._match || []) - .filter(filterFields) - .reduce((acc, cur) => acc + idf * +cur.SCORE, 0) - // TODO: make precision an option - .toFixed(2) - return result - }) - ) - : scoreOps.TYPE === 'PRODUCT' - ? results.map(r => ({ - ...r, - _score: +filterMatch(r._match) - .reduce((acc, cur) => acc * +cur.SCORE, 1) - .toFixed(2) - })) - : scoreOps.TYPE === 'CONCAT' + // score by tfidf by default + // TODO: Total hits (length of _match) + // TODO: better error handling: what if TYPE is 'XXXXX' + // TODO: scoring precision (decimal places) should be an option + const SCORE = (results, scoreOps = {}) => { + // TODO: test for defaulting to TFIDF + scoreOps = Object.assign( + { + TYPE: 'TFIDF' + }, + scoreOps + ) + + const filterFields = item => { + if (!scoreOps.FIELDS) return true + return scoreOps.FIELDS.includes(item.FIELD) + } + + const filterMatch = _match => (_match || []).filter(filterFields) + + return new Promise(resolve => + resolve( + scoreOps.TYPE === 'TFIDF' + ? DOCUMENT_COUNT().then(docCount => + results.map((result, _, resultSet) => { + const idf = Math.log((docCount + 1) / resultSet.length) + result._score = +(result._match || []) + .filter(filterFields) + .reduce((acc, cur) => acc + idf * +cur.SCORE, 0) + // TODO: make precision an option + .toFixed(2) + return result + }) + ) + : scoreOps.TYPE === 'PRODUCT' ? results.map(r => ({ ...r, - _score: filterMatch(r._match).reduce( - (acc, cur) => acc + cur.SCORE, - '' - ) + _score: +filterMatch(r._match) + .reduce((acc, cur) => acc * +cur.SCORE, 1) + .toFixed(2) })) - : scoreOps.TYPE === 'SUM' + : scoreOps.TYPE === 'CONCAT' ? results.map(r => ({ ...r, - _score: +filterMatch(r._match) - .reduce((acc, cur) => acc + +cur.SCORE, 0) - .toFixed(2) // TODO: make precision an option + _score: filterMatch(r._match).reduce( + (acc, cur) => acc + cur.SCORE, + '' + ) })) - : scoreOps.TYPE === 'VALUE' + : scoreOps.TYPE === 'SUM' ? results.map(r => ({ ...r, - _score: filterMatch(r._match).reduce( - (acc, cur) => acc + cur.VALUE, - '' - ) + _score: +filterMatch(r._match) + .reduce((acc, cur) => acc + +cur.SCORE, 0) + .toFixed(2) // TODO: make precision an option })) - : null + : scoreOps.TYPE === 'VALUE' + ? results.map(r => ({ + ...r, + _score: filterMatch(r._match).reduce( + (acc, cur) => acc + cur.VALUE, + '' + ) + })) + : null + ) ) - ) - } + } - // TODO: maybe add a default page size? - const SEARCH = (q, qops) => { - return parseJsonQuery( - { - AND: [...q] - }, - Object.assign( + // TODO: maybe add a default page size? + const SEARCH = (q, qops) => { + return parseJsonQuery( { - SCORE: { - TYPE: 'TFIDF' - }, - SORT: true + AND: [...q] }, - qops + Object.assign( + { + SCORE: { + TYPE: 'TFIDF' + }, + SORT: true + }, + qops + ) ) - ) - } + } - const SORT = (results, options) => { - options = Object.assign( - { - DIRECTION: 'DESCENDING', - TYPE: 'NUMERIC' - }, - options || {} - ) - const sortFunction = { - NUMERIC: { - DESCENDING: (a, b) => +b._score - +a._score, - ASCENDING: (a, b) => +a._score - +b._score - }, - ALPHABETIC: { - DESCENDING: (a, b) => { - if (a._score < b._score) return 1 - if (a._score > b._score) return -1 - return 0 + const SORT = (results, options) => { + options = Object.assign( + { + DIRECTION: 'DESCENDING', + TYPE: 'NUMERIC' }, - ASCENDING: (a, b) => { - if (a._score < b._score) return -1 - if (a._score > b._score) return 1 - return 0 + options || {} + ) + const sortFunction = { + NUMERIC: { + DESCENDING: (a, b) => +b._score - +a._score, + ASCENDING: (a, b) => +a._score - +b._score + }, + ALPHABETIC: { + DESCENDING: (a, b) => { + if (a._score < b._score) return 1 + if (a._score > b._score) return -1 + return 0 + }, + ASCENDING: (a, b) => { + if (a._score < b._score) return -1 + if (a._score > b._score) return 1 + return 0 + } } } + return results + .sort((a, b) => { + if (a._id < b._id) return -1 + if (a._id > b._id) return 1 + return 0 + }) + .sort(sortFunction[options.TYPE][options.DIRECTION]) } - return results - .sort((a, b) => { - if (a._id < b._id) return -1 - if (a._id > b._id) return 1 - return 0 - }) - .sort(sortFunction[options.TYPE][options.DIRECTION]) - } - const DOCUMENT_COUNT = () => ops.fii.STORE.get(['DOCUMENT_COUNT'], ops.fii.LEVEL_OPTIONS) - - const WEIGHT = (results, weights) => - results.map(r => { - r._match = r._match.map(m => { - weights.forEach(w => { - let doWeighting = false - // TODO: possible bug / edge case- does this work when weighting a field with value 0? - if (w.FIELD && w.VALUE) { - if (w.FIELD === m.FIELD && w.VALUE === m.VALUE) { - doWeighting = true - } - } else if (w.FIELD) { - if (w.FIELD === m.FIELD) { - doWeighting = true + const DOCUMENT_COUNT = () => ops.fii.STORE.get(['DOCUMENT_COUNT'], ops.fii.LEVEL_OPTIONS) + + const WEIGHT = (results, weights) => + results.map(r => { + r._match = r._match.map(m => { + weights.forEach(w => { + let doWeighting = false + // TODO: possible bug / edge case- does this work when weighting a field with value 0? + if (w.FIELD && w.VALUE) { + if (w.FIELD === m.FIELD && w.VALUE === m.VALUE) { + doWeighting = true + } + } else if (w.FIELD) { + if (w.FIELD === m.FIELD) { + doWeighting = true + } + } else if (w.VALUE) { + if (w.VALUE === m.VALUE) { + doWeighting = true + } } - } else if (w.VALUE) { - if (w.VALUE === m.VALUE) { - doWeighting = true - } - } - if (doWeighting) m.SCORE = (w.WEIGHT * +m.SCORE).toFixed(2) + if (doWeighting) m.SCORE = (w.WEIGHT * +m.SCORE).toFixed(2) + }) + return m }) - return m - }) - return r - }) - - // This function reads queries in a JSON format and then translates them to - // Promises - const parseJsonQuery = (q, options = {}) => { - const runQuery = cmd => { - // if string or object with only FIELD or VALUE, assume - // that this is a GET - if (typeof cmd === 'string' || typeof cmd === 'number') { - return ops.fii.GET(cmd, options.PIPELINE) - } - if (cmd.FIELD) return ops.fii.GET(cmd) - if (cmd.VALUE) return ops.fii.GET(cmd) - - // else: - if (cmd.AND) return ops.fii.AND(cmd.AND.map(runQuery), options.PIPELINE) - if (cmd.GET) return ops.fii.GET(cmd.GET, options.PIPELINE) - if (cmd.NOT) { - return ops.fii.NOT(runQuery(cmd.NOT.INCLUDE), runQuery(cmd.NOT.EXCLUDE)) - } - if (cmd.OR) return ops.fii.OR(cmd.OR.map(runQuery), options.PIPELINE) + return r + }) - // TODO this should be ALL_DOCUMENTS, such that - // ALL_DOCUMENTS=true returns everything (needs test) - // It should be possible to combine ALL_DOCUMENTS with FACETS - // and other aggregations - if (cmd.ALL_DOCUMENTS) return ALL_DOCUMENTS(cmd.ALL_DOCUMENTS) - } + // This function reads queries in a JSON format and then translates them to + // Promises + const parseJsonQuery = (q, options = {}) => { + const runQuery = cmd => { + // if string or object with only FIELD or VALUE, assume + // that this is a GET + if (typeof cmd === 'string' || typeof cmd === 'number') { + return ops.fii.GET(cmd, options.PIPELINE) + } + if (cmd.FIELD) return ops.fii.GET(cmd) + if (cmd.VALUE) return ops.fii.GET(cmd) + + // else: + if (cmd.AND) return ops.fii.AND(cmd.AND.map(runQuery), options.PIPELINE) + if (cmd.GET) return ops.fii.GET(cmd.GET, options.PIPELINE) + if (cmd.NOT) { + return ops.fii.NOT(runQuery(cmd.NOT.INCLUDE), runQuery(cmd.NOT.EXCLUDE)) + } + if (cmd.OR) return ops.fii.OR(cmd.OR.map(runQuery), options.PIPELINE) - const formatResults = result => - result.RESULT - ? Object.assign(result, { - RESULT_LENGTH: result.RESULT.length - }) - : { - RESULT: result, - RESULT_LENGTH: result.length - } + // TODO this should be ALL_DOCUMENTS, such that + // ALL_DOCUMENTS=true returns everything (needs test) + // It should be possible to combine ALL_DOCUMENTS with FACETS + // and other aggregations + if (cmd.ALL_DOCUMENTS) return ALL_DOCUMENTS(cmd.ALL_DOCUMENTS) + } - // APPEND DOCUMENTS IF SPECIFIED - const appendDocuments = result => - options.DOCUMENTS - ? DOCUMENTS(...result.RESULT.map(doc => doc._id)).then(documents => - Object.assign(result, { - RESULT: result.RESULT.map((doc, i) => - Object.assign(doc, { - _doc: documents[i] - }) - ) + const formatResults = result => + result.RESULT + ? Object.assign(result, { + RESULT_LENGTH: result.RESULT.length }) - ) - : result + : { + RESULT: result, + RESULT_LENGTH: result.length + } - // SCORE IF SPECIFIED - const score = result => - options.SCORE - ? SCORE(result.RESULT, options.SCORE).then(scoredResult => - Object.assign(result, { - RESULT: scoredResult - }) + // APPEND DOCUMENTS IF SPECIFIED + const appendDocuments = result => + options.DOCUMENTS + ? DOCUMENTS(...result.RESULT.map(doc => doc._id)).then(documents => + Object.assign(result, { + RESULT: result.RESULT.map((doc, i) => + Object.assign(doc, { + _doc: documents[i] + }) + ) + }) + ) + : result + + // SCORE IF SPECIFIED + const score = result => + options.SCORE + ? SCORE(result.RESULT, options.SCORE).then(scoredResult => + Object.assign(result, { + RESULT: scoredResult + }) + ) + : result + + // SORT IF SPECIFIED + const sort = result => + Object.assign( + result, + options.SORT + ? { + RESULT: SORT(result.RESULT, options.SORT) + } + : {} ) - : result - - // SORT IF SPECIFIED - const sort = result => - Object.assign( - result, - options.SORT - ? { - RESULT: SORT(result.RESULT, options.SORT) - } - : {} - ) - // BUCKETS IF SPECIFIED - const buckets = result => - options.BUCKETS - ? ops.fii.BUCKETS(...options.BUCKETS).then(bkts => - Object.assign(result, { - BUCKETS: ops.fii.AGGREGATION_FILTER(bkts, result.RESULT) + // BUCKETS IF SPECIFIED + const buckets = result => + options.BUCKETS + ? ops.fii.BUCKETS(...options.BUCKETS).then(bkts => + Object.assign(result, { + BUCKETS: ops.fii.AGGREGATION_FILTER(bkts, result.RESULT) + }) + ) + : result + + // FACETS IF SPECIFIED + // TODO: FAST OPTION FOR WHEN ALL_DOCUMENTS IS SPECIFIED + // TODO: This should be 3 cases: 1. needs filter, 2. no results, + // 3. no need for filter + const facets = result => { + // no FACETS are specified + if (!options.FACETS) return result + + // QUERY returned no results, and facets will therefore be empty + if (!result.RESULT.length) { + return Object.assign(result, { + FACETS: [] // if empty result set then just return empty facets }) - ) - : result - - // FACETS IF SPECIFIED - // TODO: FAST OPTION FOR WHEN ALL_DOCUMENTS IS SPECIFIED - // TODO: This should be 3 cases: 1. needs filter, 2. no results, - // 3. no need for filter - const facets = result => { - // no FACETS are specified - if (!options.FACETS) return result - - // QUERY returned no results, and facets will therefore be empty - if (!result.RESULT.length) { - return Object.assign(result, { - FACETS: [] // if empty result set then just return empty facets - }) - } + } - // ALL_DOCUMENTS so no need to filter the facets - if (q.ALL_DOCUMENTS) { + // ALL_DOCUMENTS so no need to filter the facets + if (q.ALL_DOCUMENTS) { + return FACETS(...options.FACETS).then(fcts => + Object.assign(result, { + FACETS: fcts + }) + ) + } + + // else return FACETS(...options.FACETS).then(fcts => Object.assign(result, { - FACETS: fcts + FACETS: ops.fii.AGGREGATION_FILTER(fcts, result.RESULT) }) ) } - // else - return FACETS(...options.FACETS).then(fcts => - Object.assign(result, { - FACETS: ops.fii.AGGREGATION_FILTER(fcts, result.RESULT) - }) - ) - } + // PAGE IF SPECIFIED + const page = result => + Object.assign( + result, + options.PAGE ? { RESULT: PAGE(result.RESULT, options.PAGE) } : {} + ) - // PAGE IF SPECIFIED - const page = result => - Object.assign( - result, - options.PAGE ? { RESULT: PAGE(result.RESULT, options.PAGE) } : {} - ) + // WEIGHT IF SPECIFIED + const weight = result => + options.WEIGHT + ? Object.assign( + { RESULT: WEIGHT(result.RESULT, options.WEIGHT) }, + result + ) + : result + + return runQuery(q) + .then(formatResults) + .then(buckets) + .then(facets) + .then(weight) + .then(score) + .then(sort) + .then(page) + .then(appendDocuments) + } - // WEIGHT IF SPECIFIED - const weight = result => - options.WEIGHT - ? Object.assign( - { RESULT: WEIGHT(result.RESULT, options.WEIGHT) }, - result - ) - : result - - return runQuery(q) - .then(formatResults) - .then(buckets) - .then(facets) - .then(weight) - .then(score) - .then(sort) - .then(page) - .then(appendDocuments) - } + const tryCache = (q, cacheKey) => + new Promise(resolve => { + cacheKey = JSON.stringify(cacheKey) + return cache.has(cacheKey) + ? resolve(cache.get(cacheKey)) + : q + .then(res => cache.set(cacheKey, res)) + .then(() => resolve(cache.get(cacheKey))) + }) - const tryCache = (q, cacheKey) => - new Promise(resolve => { - cacheKey = JSON.stringify(cacheKey) - return cache.has(cacheKey) - ? resolve(cache.get(cacheKey)) - : q - .then(res => cache.set(cacheKey, res)) - .then(() => resolve(cache.get(cacheKey))) - }) - - return { - ALL_DOCUMENTS, - DICTIONARY: token => - tryCache(DICTIONARY(token), { DICTIONARY: token || null }), - DISTINCT, - DOCUMENTS: (...docs) => - tryCache(DOCUMENTS(...docs), { - DOCUMENTS: docs - }), - DOCUMENT_COUNT, - DOCUMENT_VECTORS, - FACETS, - PAGE, - QUERY: (q, qops) => tryCache(parseJsonQuery(q, qops), { QUERY: [q, qops] }), - SCORE, - SEARCH: (q, qops) => tryCache(SEARCH(q, qops), { SEARCH: [q, qops] }), - SORT + return { + ALL_DOCUMENTS, + DICTIONARY: token => + tryCache(DICTIONARY(token), { DICTIONARY: token || null }), + DISTINCT, + DOCUMENTS: (...docs) => + tryCache(DOCUMENTS(...docs), { + DOCUMENTS: docs + }), + DOCUMENT_COUNT, + DOCUMENT_VECTORS, + FACETS, + PAGE, + QUERY: (q, qops) => tryCache(parseJsonQuery(q, qops), { QUERY: [q, qops] }), + SCORE, + SEARCH: (q, qops) => tryCache(SEARCH(q, qops), { SEARCH: [q, qops] }), + SORT + } } } diff --git a/src/tokenisationPipeline.js b/src/tokenisationPipeline.js index d9e7698c..bf79fce5 100644 --- a/src/tokenisationPipeline.js +++ b/src/tokenisationPipeline.js @@ -1,5 +1,5 @@ -const tv = require('term-vector') -const { ngraminator } = require('ngraminator') +import tv from 'term-vector' +import ngraminator from 'ngraminator' const SPLIT = ([tokens, field, ops]) => Promise.resolve([tokens.match(ops.tokenSplitRegex) || [], field, ops]) @@ -80,7 +80,7 @@ const SCORE_TERM_FREQUENCY = ([tokens, field, ops]) => { ]) } -exports.SPY = ([tokens, field, ops]) => { +export const SPY = ([tokens, field, ops]) => { console.log('----------------') console.log('field ->') console.log(field) @@ -90,20 +90,19 @@ exports.SPY = ([tokens, field, ops]) => { return Promise.resolve([tokens, field, ops]) } -exports.tokenizer = (tokens, field, ops) => - SPLIT([tokens, field, ops]) - .then(SKIP) - .then(LOWCASE) - .then(REPLACE) - .then(NGRAMS) - .then(STOPWORDS) - .then(SCORE_TERM_FREQUENCY) - .then(([tokens, field, ops]) => tokens) +export const tokenizationPipeline = (tokens, field, ops) => SPLIT([tokens, field, ops]) + .then(SKIP) + .then(LOWCASE) + .then(REPLACE) + .then(NGRAMS) + .then(STOPWORDS) + .then(SCORE_TERM_FREQUENCY) + .then(([tokens, field, ops]) => tokens) -exports.SPLIT = SPLIT -exports.SKIP = SKIP -exports.LOWACASE = LOWCASE -exports.REPLACE = REPLACE -exports.NGRAMS = NGRAMS -exports.STOPWORDS = STOPWORDS -exports.SCORE_TERM_FREQUENCY = SCORE_TERM_FREQUENCY +// exports.SPLIT = SPLIT +// exports.SKIP = SKIP +// exports.LOWACASE = LOWCASE +// exports.REPLACE = REPLACE +// exports.NGRAMS = NGRAMS +// exports.STOPWORDS = STOPWORDS +// exports.SCORE_TERM_FREQUENCY = SCORE_TERM_FREQUENCY diff --git a/src/version.js b/src/version.js new file mode 100644 index 00000000..c0d2ffa2 --- /dev/null +++ b/src/version.js @@ -0,0 +1 @@ +export const packageVersion = '4.0.0' diff --git a/src/write.js b/src/write.js index 679bfaa4..d8243a77 100755 --- a/src/write.js +++ b/src/write.js @@ -1,6 +1,6 @@ -const DocumentProcessor = require('./DocumentProcessor') +import { DocumentProcessor } from './DocumentProcessor.js' -module.exports = (ops, cache, queue) => { +export const Writer = (ops, cache, queue) => { const incrementDocCount = increment => ops.fii.STORE.get(['DOCUMENT_COUNT'], ops.fii.LEVEL_OPTIONS) .then(count => ops.fii.STORE.put(['DOCUMENT_COUNT'], +count + increment, ops.fii.LEVEL_OPTIONS)) diff --git a/test/src/514-test.js b/test/src/514-test.js index 413f937e..e841af51 100644 --- a/test/src/514-test.js +++ b/test/src/514-test.js @@ -4,6 +4,8 @@ const test = require('tape') const sandbox = 'test/sandbox/' const indexName = sandbox + '514' +let global = {} + test('create a search index', t => { t.plan(1) si({ name: indexName, storeVectors: true }).then(db => { diff --git a/test/src/init-test.js b/test/src/init-test.js index 4324c414..28dabbdc 100644 --- a/test/src/init-test.js +++ b/test/src/init-test.js @@ -1,5 +1,8 @@ -const si = require('../../') -const test = require('tape') +import { SearchIndex } from '../../src/main.js' + +import tape from 'tape' + +let db const data = [ { @@ -31,17 +34,17 @@ const data = [ } ] -test('can create a search index WITHOUT an options object', t => { +tape('can create a search index WITHOUT an options object', async t => { t.plan(1) - si().then(db => { - global.db = db - t.pass('ok') - }) + try { + db = await new SearchIndex() + t.ok(db) + } catch (e) { + t.error(e) + } }) -test('can add some data', t => { +tape('can add some data', t => { t.plan(1) - global.db.PUT(data).then(() => { - t.pass('ok') - }) + db.PUT(data).then(t.pass) }) diff --git a/webpack.config.js b/webpack.config.js index 1a7e7904..dc99ffdb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,7 +1,10 @@ -const path = require('path') -const webpack = require('webpack') -const glob = require('glob') -const pkg = require('./package.json') +import glob from 'glob' +import path from 'path' +import pkg from './package.json' assert { type: "json" } +import webpack from 'webpack' +import { createRequire } from 'node:module' + +const require = createRequire(import.meta.url) const config = { plugins: [ @@ -11,14 +14,14 @@ const config = { }), // Webpack 5 no longer polyfills 'process' new webpack.ProvidePlugin({ - process: 'process/browser' + process: 'process/browser.js' }), // as per https://github.com/webpack/changelog-v5/issues/10 new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'] }) ], - target: ['web'], + target: [ 'web' ], resolve: { fallback: { // BREAKING CHANGE: webpack < 5 used to include polyfills for @@ -35,8 +38,8 @@ const config = { } } -module.exports = [ - { +// module.exports = [ +export default [{ ...config, mode: 'production', entry: './src/main.js', @@ -67,7 +70,7 @@ module.exports = [ // possibly it would be good to have some kind of code splitting // instead mode: 'production', - entry: glob.sync('./test/src/*-test.js'), + entry: glob.sync('./test/src/init-test.js'), output: { path: path.resolve('test/sandbox'), filename: 'browser-tests.js'