diff --git a/demo/index.html b/demo/index.html
index dd8fd370..8c2e07f1 100644
--- a/demo/index.html
+++ b/demo/index.html
@@ -5,7 +5,7 @@
-
+
search-index browser example
diff --git a/demo/search-app.js b/demo/search-app.js
index b2bdcd1c..64d180d2 100644
--- a/demo/search-app.js
+++ b/demo/search-app.js
@@ -21,12 +21,12 @@ const search = function (q) {
results.forEach(function(result) {
console.log(result);
populateResultsDiv(result)
+ })
})
.catch(function (err) {
console.log('Error while searching:')
console.log(err)
})
- })
}
// Workaround for a possible bug when ID is generated
diff --git a/dist/search-index.1.0.6.js b/dist/search-index.1.0.6.js
new file mode 100644
index 00000000..633c508d
--- /dev/null
+++ b/dist/search-index.1.0.6.js
@@ -0,0 +1,22 @@
+!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.searchIndex=e():t.searchIndex=e()}(this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=37)}([function(t,e){var r,n,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(t){if(r===setTimeout)return setTimeout(t,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(t,0);try{return r(t,0)}catch(e){try{return r.call(null,t,0)}catch(e){return r.call(this,t,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(t){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var s,c=[],f=!1,l=-1;function h(){f&&s&&(f=!1,s.length?c=s.concat(c):l=-1,c.length&&p())}function p(){if(!f){var t=u(h);f=!0;for(var e=c.length;e;){for(s=c,c=[];++l1)for(var r=1;r
+ * @license MIT
+ */
+var n=r(44),i=r(45),o=r(46);function a(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(t,e){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function d(t,e){if(s.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return K(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return K(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function g(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=s.from(e,n)),s.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){var o,a=1,u=t.length,s=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,u/=2,s/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var f=-1;for(o=r;ou&&(r=u-s),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(f=c);break;case 2:128==(192&(o=t[i+1]))&&(s=(31&c)<<6|63&o)>127&&(f=s);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(s=(15&c)<<12|(63&o)<<6|63&a)>2047&&(s<55296||s>57343)&&(f=s);break;case 4:o=t[i+1],a=t[i+2],u=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&u)&&(s=(15&c)<<18|(63&o)<<12|(63&a)<<6|63&u)>65535&&s<1114112&&(f=s)}null===f?(f=65533,l=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=l}return function(t){var e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);var r="",n=0;for(;nthis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}.apply(this,arguments)},s.prototype.equals=function(t){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===s.compare(this,t)},s.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),""},s.prototype.compare=function(t,e,r,n,i){if(!s.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r),l=0;li)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":return w(this,t,e,r);case"latin1":case"binary":return m(this,t,e,r);case"base64":return E(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var x=4096;function A(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function P(t,e,r,n,i,o){if(!s.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 N(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i>>8*(n?i:1-i)}function I(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i>>8*(n?i:3-i)&255}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function L(t,e,r,n,o){return o||C(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return o||C(t,0,r,8),i.write(t,e,r,n,52,8),r+8}s.prototype.slice=function(t,e){var r,n=this.length;if((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),e0&&(i*=256);)n+=this[t+--e]*i;return n},s.prototype.readUInt8=function(t,e){return e||B(t,1,this.length),this[t]},s.prototype.readUInt16LE=function(t,e){return e||B(t,2,this.length),this[t]|this[t+1]<<8},s.prototype.readUInt16BE=function(t,e){return e||B(t,2,this.length),this[t]<<8|this[t+1]},s.prototype.readUInt32LE=function(t,e){return e||B(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},s.prototype.readUInt32BE=function(t,e){return e||B(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},s.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||B(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},s.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||B(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},s.prototype.readInt8=function(t,e){return e||B(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},s.prototype.readInt16LE=function(t,e){e||B(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt16BE=function(t,e){e||B(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},s.prototype.readInt32LE=function(t,e){return e||B(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},s.prototype.readInt32BE=function(t,e){return e||B(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},s.prototype.readFloatLE=function(t,e){return e||B(t,4,this.length),i.read(this,t,!0,23,4)},s.prototype.readFloatBE=function(t,e){return e||B(t,4,this.length),i.read(this,t,!1,23,4)},s.prototype.readDoubleLE=function(t,e){return e||B(t,8,this.length),i.read(this,t,!0,52,8)},s.prototype.readDoubleBE=function(t,e){return e||B(t,8,this.length),i.read(this,t,!1,52,8)},s.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||P(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o=0&&(o*=256);)this[e+i]=t/o&255;return e+r},s.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,1,255,0),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},s.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},s.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},s.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):I(this,t,e,!0),e+4},s.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},s.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);P(this,t,e,r,i-1,-i)}var o=0,a=1,u=0;for(this[e]=255&t;++o>0)-u&255;return e+r},s.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);P(this,t,e,r,i-1,-i)}var o=r-1,a=1,u=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/a>>0)-u&255;return e+r},s.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,1,127,-128),s.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},s.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},s.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},s.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):I(this,t,e,!0),e+4},s.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||P(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),s.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):I(this,t,e,!1),e+4},s.prototype.writeFloatLE=function(t,e,r){return L(this,t,e,!0,r)},s.prototype.writeFloatBE=function(t,e,r){return L(this,t,e,!1,r)},s.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},s.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},s.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e=0;--i)t[i+e]=this[i+r];else if(o<1e3||!s.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(D,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function z(t,e,r,n){for(var i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(2))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e){"function"==typeof Object.create?t.exports=function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e){t.exports=function(){for(var t={},e=0;e2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}i("ERR_INVALID_OPT_VALUE",function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'},TypeError),i("ERR_INVALID_ARG_TYPE",function(t,e,r){var n,i,a,u;if("string"==typeof e&&(i="not ",e.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",e=e.replace(/^not /,"")):n="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))u="The ".concat(t," ").concat(n," ").concat(o(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";u='The "'.concat(t,'" ').concat(s," ").concat(n," ").concat(o(e,"type"))}return u+=". Received type ".concat(typeof r)},TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=n},function(t,e){e.getCallback=function(t,e){return"function"==typeof t?t:e},e.getOptions=function(t){return"object"==typeof t&&null!==t?t:{}}},function(t,e,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,o=i&&"function"==typeof i.apply?i.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var s=10;function c(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var i,o,a,u;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=c(t))>0&&a.length>i&&!a.warned){a.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=t,s.type=e,s.count=a.length,u=s,console&&console.warn&&console.warn(u)}return t}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=function(){for(var t=[],e=0;e0&&(a=e[0]),a instanceof Error)throw a;var u=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw u.context=a,u}var s=i[t];if(void 0===s)return!1;if("function"==typeof s)o(s,this,e);else{var c=s.length,f=d(s,c);for(r=0;r=0;o--)if(r[o]===e||r[o].listener===e){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1=0;n--)this.removeListener(t,e[n]);return this},u.prototype.listeners=function(t){return h(this,t,!0)},u.prototype.rawListeners=function(t){return h(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},u.prototype.listenerCount=p,u.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,r){(function(t){var n=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n=o)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}}),s=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),d(r)?n.showHidden=r:r&&e._extend(n,r),v(n.showHidden)&&(n.showHidden=!1),v(n.depth)&&(n.depth=2),v(n.colors)&&(n.colors=!1),v(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=s),f(n,t,n.depth)}function s(t,e){var r=u.styles[e];return r?"["+u.colors[r][0]+"m"+t+"["+u.colors[r][1]+"m":t}function c(t,e){return t}function f(t,r,n){if(t.customInspect&&r&&k(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return b(i)||(i=f(t,i,n)),i}var o=function(t,e){if(v(e))return t.stylize("undefined","undefined");if(b(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}if(g(e))return t.stylize(""+e,"number");if(d(e))return t.stylize(""+e,"boolean");if(y(e))return t.stylize("null","null")}(t,r);if(o)return o;var a=Object.keys(r),u=function(t){var e={};return t.forEach(function(t,r){e[t]=!0}),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),E(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(r);if(0===a.length){if(k(r)){var s=r.name?": "+r.name:"";return t.stylize("[Function"+s+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(m(r))return t.stylize(Date.prototype.toString.call(r),"date");if(E(r))return l(r)}var c,w="",T=!1,S=["{","}"];(p(r)&&(T=!0,S=["[","]"]),k(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return _(r)&&(w=" "+RegExp.prototype.toString.call(r)),m(r)&&(w=" "+Date.prototype.toUTCString.call(r)),E(r)&&(w=" "+l(r)),0!==a.length||T&&0!=r.length?n<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=T?function(t,e,r,n,i){for(var o=[],a=0,u=e.length;a=0&&0,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1];return r[0]+e+" "+t.join(", ")+" "+r[1]}(c,w,S)):S[0]+w+S[1]}function l(t){return"["+Error.prototype.toString.call(t)+"]"}function h(t,e,r,n,i,o){var a,u,s;if((s=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?u=s.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):s.set&&(u=t.stylize("[Setter]","special")),A(n,i)||(a="["+i+"]"),u||(t.seen.indexOf(s.value)<0?(u=y(r)?f(t,s.value,null):f(t,s.value,r-1)).indexOf("\n")>-1&&(u=o?u.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+u.split("\n").map(function(t){return" "+t}).join("\n")):u=t.stylize("[Circular]","special")),v(a)){if(o&&i.match(/^\d+$/))return u;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+u}function p(t){return Array.isArray(t)}function d(t){return"boolean"==typeof t}function y(t){return null===t}function g(t){return"number"==typeof t}function b(t){return"string"==typeof t}function v(t){return void 0===t}function _(t){return w(t)&&"[object RegExp]"===T(t)}function w(t){return"object"==typeof t&&null!==t}function m(t){return w(t)&&"[object Date]"===T(t)}function E(t){return w(t)&&("[object Error]"===T(t)||t instanceof Error)}function k(t){return"function"==typeof t}function T(t){return Object.prototype.toString.call(t)}function S(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(r){if(v(o)&&(o=t.env.NODE_DEBUG||""),r=r.toUpperCase(),!a[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=t.pid;a[r]=function(){var t=e.format.apply(e,arguments);console.error("%s %d: %s",r,n,t)}}else a[r]=function(){};return a[r]},e.inspect=u,u.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},u.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.isArray=p,e.isBoolean=d,e.isNull=y,e.isNullOrUndefined=function(t){return null==t},e.isNumber=g,e.isString=b,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=v,e.isRegExp=_,e.isObject=w,e.isDate=m,e.isError=E,e.isFunction=k,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(41);var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){var t,r;console.log("%s - %s",(t=new Date,r=[S(t.getHours()),S(t.getMinutes()),S(t.getSeconds())].join(":"),[t.getDate(),x[t.getMonth()],r].join(" ")),e.format.apply(e,arguments))},e.inherits=r(3),e._extend=function(t,e){if(!e||!w(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var O="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function R(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(O&&t[O]){var e;if("function"!=typeof(e=t[O]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,O,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise(function(t,n){e=t,r=n}),i=[],o=0;o0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)a.endEmitted?t.emit("error",new w):x(t,a,e,!0);else if(a.ended)t.emit("error",new v);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(e=a.decoder.write(e),a.objectMode||0!==e.length?x(t,a,e,!1):B(t,a)):x(t,a,e,!1)}else n||(a.reading=!1,B(t,a));return!a.ended&&(a.lengthe.highWaterMark&&(e.highWaterMark=function(t){return t>=A?t=A:(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;e.needReadable=!1,e.emittedReadable||(c("emitReadable",e.flowing),e.emittedReadable=!0,n.nextTick(j,t))}function j(t){var e=t._readableState;c("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||t.emit("readable"),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,L(t)}function B(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(P,t,e))}function P(t,e){for(var r=e.length;!e.reading&&!e.ended&&e.length0,t.listenerCount("data")>0&&t.resume()}function I(t){c("readable nexttick read 0"),t.read(0)}function C(t,e){c("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),L(t),e.flowing&&!e.reading&&t.read(0)}function L(t){var e=t._readableState;for(c("flow",e.flowing);e.flowing&&null!==t.read(););}function M(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function D(t){var e=t._readableState;c("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,n.nextTick(U,e,t))}function U(t,e){c("endReadableNT",t.endEmitted,t.length),t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function K(t,e){for(var r=0,n=t.length;r=e.highWaterMark:e.length>0)||e.ended))return c("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?D(this):R(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&D(this),null;var n,i=e.needReadable;return c("need readable",i),(0===e.length||e.length-t0?M(t,e):null)?(e.needReadable=!0,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&D(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){this.emit("error",new _("_read()"))},T.prototype.pipe=function(t,e){var r=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,c("pipe count=%d opts=%j",i.pipesCount,e);var a=(!e||!1!==e.end)&&t!==n.stdout&&t!==n.stderr?s:g;function u(e,n){c("onunpipe"),e===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,c("cleanup"),t.removeListener("close",d),t.removeListener("finish",y),t.removeListener("drain",f),t.removeListener("error",p),t.removeListener("unpipe",u),r.removeListener("end",s),r.removeListener("end",g),r.removeListener("data",h),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||f())}function s(){c("onend"),t.end()}i.endEmitted?n.nextTick(a):r.once("end",a),t.on("unpipe",u);var f=function(t){return function(){var e=t._readableState;c("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&o(t,"data")&&(e.flowing=!0,L(t))}}(r);t.on("drain",f);var l=!1;function h(e){c("ondata");var n=t.write(e);c("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==K(i.pipes,t))&&!l&&(c("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function p(e){c("onerror",e),g(),t.removeListener("error",p),0===o(t,"error")&&t.emit("error",e)}function d(){t.removeListener("finish",y),g()}function y(){c("onfinish"),t.removeListener("close",d),g()}function g(){c("unpipe"),r.unpipe(t)}return r.on("data",h),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",p),t.once("close",d),t.once("finish",y),t.emit("pipe",r),i.flowing||(c("pipe resume"),r.resume()),t},T.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes?this:(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r),this);if(!t){var n=e.pipes,i=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,c("on readable",i.length,i.reading),i.length?R(this):i.reading||n.nextTick(I,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return"readable"===t&&n.nextTick(N,this),r},T.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||n.nextTick(N,this),e},T.prototype.resume=function(){var t=this._readableState;return t.flowing||(c("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(C,t,e))}(this,t)),this},T.prototype.pause=function(){return c("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(c("pause"),this._readableState.flowing=!1,this.emit("pause")),this},T.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",function(){if(c("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)}),t.on("data",function(i){(c("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!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-1))throw new m(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.prototype.end=function(t,e,r){var i=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),i.corked&&(i.corked=1,this.uncork()),i.ending||function(t,e,r){e.ending=!0,j(t,e),r&&(e.finished?n.nextTick(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,i,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}}).call(this,r(2),r(0))},function(t,e,r){"use strict";var n=r(55).Buffer,i=n.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&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=s,this.end=c,e=4;break;case"utf8":this.fillLast=u,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function u(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){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!==r?r: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 s(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}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 r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function f(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?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-r))}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 h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.StringDecoder=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(t.lastNeed=i-1),i;if(--n=0)return i>0&&(t.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:t.lastNeed=i-3),i;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},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}},function(t,e,r){"use strict";t.exports=f;var n=r(6).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,u=n.ERR_TRANSFORM_WITH_LENGTH_0,s=r(5);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.lengthnew Promise((e,r)=>t instanceof Promise?e(t):("string"==typeof t&&(t={gte:t,lte:t+"○"}),n(t).then(e))),r=(...t)=>Promise.all(t.map(t=>e(t))).then(t=>{var e=(t=[].concat.apply([],t)).reduce((t,e)=>(t[e._id]=t[e._id]||[],t[e._id].push(e.match),t),{});return Object.keys(e).map(t=>({_id:t,match:e[t]}))}),n=e=>new Promise((r,n)=>{const i={};t.createReadStream(e).on("data",t=>t.value.forEach(e=>{i[e]=i[e]||[],i[e].push(t.key)})).on("end",()=>r(Object.keys(i).map(t=>({_id:t,match:i[t]}))))});return{AGGREGATE:(...t)=>Promise.all(t).then(t=>{var e=new Set(t[1].map(t=>t._id));return t[0].map(t=>({match:t.match,_id:[...new Set([...t._id].filter(t=>e.has(t)))]})).filter(t=>t._id.length)}),BUCKET:t=>e(t).then(e=>({match:t,_id:[...e.reduce((t,e)=>t.add(e._id),new Set)].sort()})),GET:e,INTERSECTION:(...t)=>r(...t).then(e=>e.filter(e=>e.match.length===t.length)),SET_DIFFERENCE:(t,r)=>("string"==typeof t&&(t=e(t)),"string"==typeof r&&(r=e(r)),Promise.all([t,r]).then(t=>{var[e,r]=t;return r=r.map(t=>t._id),e.filter(t=>r.indexOf(t._id))})),UNION:r}}function s(t){return{OBJECT:e=>Promise.all(e.map(e=>t.get("○DOC○"+e._id+"○")))}}function c(t){return{DIST:e=>{"string"==typeof e&&(e={gte:e,lte:e+"○"});const r=[];return new Promise((n,i)=>{t.createKeyStream(e).on("data",t=>{r.push(t)}).on("end",()=>n(r))})},MAX:e=>{var r={limit:1,lte:e+"○",reverse:!0};return new Promise((e,n)=>{t.createKeyStream(r).on("data",e)})},MIN:e=>{var r={limit:1,gte:e+"!"};return new Promise((e,n)=>{t.createKeyStream(r).on("data",e)})}}}var f=0;const l=function(t){var e=[];return a()(t).forEach(function(t){var r=!0;if(this.path.forEach(t=>{"!"===t.substring(0,1)&&(r=!1),"_id"===t&&(r=!1)}),r&&this.isLeaf){var n=this.path.join(".")+":"+this.node;Array.isArray(this.parent.node)&&(n=this.path.slice(0,this.path.length-1).join(".")+":"+this.node),e.push(n)}}),{_id:t._id||++f,keys:e}},h=(t,e)=>(e.keys.forEach(r=>{t[r]=t[r]||[],t[r].push(e._id)}),t),p=t=>"string"==typeof t._id?t:"number"==typeof t._id?t:(t._id=f++,t),d=(t,e,r)=>(t=t.map(p),new Promise((n,i)=>{((t,e,r)=>{const n=Object.keys(t);return Promise.all(n.map(t=>new Promise((r,n)=>{e.get(t).then(r).catch(t=>r([]))}))).then(e=>e.map((e,i)=>{var o=new Set(e),a=new Set(t[n[i]]);if("put"===r)return{key:n[i],type:r,value:[...new Set([...o,...a])].sort()};if("del"===r){var u=[...new Set([...o].filter(t=>!a.has(t)))];return{key:n[i],type:0===u.length?"del":"put",value:u}}}))})((t=>t.map(l).reduce(h,{}))(t),e,r).then(i=>{e.batch(i.concat(((t,e)=>t.map(t=>({key:"○DOC○"+t._id+"○",type:e,value:t})))(t,r)),e=>n(t))})}));function y(t){return{DELETE:e=>s(t).OBJECT(e.map(t=>({_id:t}))).then(e=>d(e,t,"del")),PUT:e=>d(e,t,"put")}}const g=t=>({AGGREGATE:u(t).AGGREGATE,AND:u(t).INTERSECTION,BUCKET:u(t).BUCKET,BUCKETFILTER:u(t).AGGREGATE,DELETE:y(t).DELETE,DISTINCT:c(t).DIST,GET:u(t).GET,MAX:c(t).MAX,MIN:c(t).MIN,NOT:u(t).SET_DIFFERENCE,OBJECT:s(t).OBJECT,OR:u(t).UNION,PUT:y(t).PUT,STORE:t});e.default=function(t,e){return t=Object.assign({},{name:"fii"},t),e?t.store?e(new Error('When initing with a store use "lazy loading"'),null):void i()(t.name,{valueEncoding:"json"},(t,r)=>e(t,g(r))):g(t.store||i()(t.name,{valueEncoding:"json"}))}},function(t,e,r){var n=r(40),i=r(63);t.exports=function(t){function e(e,r,o){return"function"==typeof r&&(o=r),"object"==typeof r&&null!==r||(r={}),n(i(t(e),r),r,o)}return["destroy","repair"].forEach(function(r){"function"==typeof t[r]&&(e[r]=function(e,n){t[r](e,n||function(){})})}),e.errors=n.errors,e}},function(t,e,r){(function(e){var n=r(8).EventEmitter,i=r(9).inherits,o=r(4),a=r(42),u=r(48),s=r(59),c=r(25),f=r(62),l=r(26),h=r(7).getCallback,p=r(7).getOptions,d=c.WriteError,y=c.ReadError,g=c.NotFoundError,b=c.OpenError,v=c.InitializationError;function _(t,r,i){if(!(this instanceof _))return new _(t,r,i);var o;if(n.call(this),this.setMaxListeners(1/0),"function"==typeof r&&(i=r,r={}),r=r||{},!t||"object"!=typeof t){if(o=new v("First argument must be an abstract-leveldown compliant store"),"function"==typeof i)return e.nextTick(i,o);throw o}f.strictEqual(typeof t.status,"string",".status required, old abstract-leveldown"),this.options=p(r),this._db=t,this.db=new a(t),this.open(i)}function w(t,r){if(!t._isOpening()&&!t.isOpen())return e.nextTick(r,new y("Database is not open")),!0}_.prototype.emit=n.prototype.emit,_.prototype.once=n.prototype.once,i(_,n),_.prototype.open=function(t){var r,n=this;return t||(r=(t=l()).promise),this.isOpen()?(e.nextTick(t,null,n),r):this._isOpening()?(this.once("open",function(){t(null,n)}),r):(this.emit("opening"),this.db.open(this.options,function(e){if(e)return t(new b(e));n.db=n._db,t(null,n),n.emit("open"),n.emit("ready")}),r)},_.prototype.close=function(t){var r,n=this;return t||(r=(t=l()).promise),this.isOpen()?(this.db.close(function(){n.emit("closed"),t.apply(null,arguments)}),this.emit("closing"),this.db=new a(this._db)):this.isClosed()?e.nextTick(t):"closing"===this.db.status?this.once("closed",t):this._isOpening()&&this.once("open",function(){n.close(t)}),r},_.prototype.isOpen=function(){return"open"===this.db.status},_.prototype._isOpening=function(){return"opening"===this.db.status},_.prototype.isClosed=function(){return/^clos|new/.test(this.db.status)},_.prototype.get=function(t,e,r){if(null==t)throw new y("get() requires a key argument");var n;return(r=h(e,r))||(n=(r=l()).promise),w(this,r)?n:(e=p(e),this.db.get(t,e,function(e,n){if(e)return e=/notfound/i.test(e)||e.notFound?new g("Key not found in database ["+t+"]",e):new y(e),r(e);r(null,n)}),n)},_.prototype.put=function(t,e,r,n){if(null==t)throw new d("put() requires a key argument");var i,o=this;return(n=h(r,n))||(i=(n=l()).promise),w(this,n)?i:(r=p(r),this.db.put(t,e,r,function(r){if(r)return n(new d(r));o.emit("put",t,e),n()}),i)},_.prototype.del=function(t,e,r){if(null==t)throw new d("del() requires a key argument");var n,i=this;return(r=h(e,r))||(n=(r=l()).promise),w(this,r)?n:(e=p(e),this.db.del(t,e,function(e){if(e)return r(new d(e));i.emit("del",t),r()}),n)},_.prototype.batch=function(t,e,r){if(!arguments.length)return new s(this);if(!Array.isArray(t))throw new d("batch() requires an array argument");var n,i=this;return(r=h(e,r))||(n=(r=l()).promise),w(this,r)?n:(e=p(e),this.db.batch(t,e,function(e){if(e)return r(new d(e));i.emit("batch",t),r()}),n)},_.prototype.iterator=function(t){return this.db.iterator(t)},_.prototype.readStream=_.prototype.createReadStream=function(t){return"number"!=typeof(t=o({keys:!0,values:!0},t)).limit&&(t.limit=-1),new u(this.db.iterator(t),t)},_.prototype.keyStream=_.prototype.createKeyStream=function(t){return this.createReadStream(o(t,{keys:!0,values:!1}))},_.prototype.valueStream=_.prototype.createValueStream=function(t){return this.createReadStream(o(t,{keys:!1,values:!0}))},_.prototype.toString=function(){return"LevelUP"},_.errors=c,t.exports=_.default=_}).call(this,r(0))},function(t,e){t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},function(t,e,r){var n=r(15).AbstractLevelDOWN,i=r(3),o=r(47),a="put get del batch".split(" ");function u(t){n.call(this,""),this._db=t,this._operations=[],this._iterators=[],s(this)}function s(t){a.forEach(function(e){t["_"+e]=function(){this._operations.push({method:e,args:arguments})}}),"function"==typeof t._db.approximateSize&&(t.approximateSize=function(){this._operations.push({method:"approximateSize",args:arguments})}),t._iterator=function(t){var e=new o(t);return this._iterators.push(e),e}}i(u,n),u.prototype._open=function(t,e){var r=this;this._db.open(t,function(t){if(t)return e(t);r._operations.forEach(function(t){r._db[t.method].apply(r._db,t.args)}),r._operations=[],r._iterators.forEach(function(t){t.setDb(r._db)}),r._iterators=[],function(t){a.concat("iterator").forEach(function(e){t["_"+e]=function(){return this._db[e].apply(this._db,arguments)}}),t._db.approximateSize&&(t.approximateSize=function(){return this._db.approximateSize.apply(this._db,arguments)})}(r),e()})},u.prototype._close=function(t){var e=this;this._db.close(function(r){if(r)return t(r);s(e),t()})},u.prototype._serializeKey=function(t){return t},u.prototype._serializeValue=function(t){return t},t.exports=u,t.exports.DeferredIterator=o},function(t,e,r){(function(e,n){var i=r(4),o=r(16),a=r(17),u=Object.prototype.hasOwnProperty,s="start end gt gte lt lte".split(" ");function c(){this.status="new"}function f(t){return-1!==s.indexOf(t)}c.prototype.open=function(t,e){var r=this,n=this.status;if("function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("open() requires a callback argument");"object"==typeof t&&null!==t||(t={}),t.createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists,this.status="opening",this._open(t,function(t){if(t)return r.status=n,e(t);r.status="open",e()})},c.prototype._open=function(t,r){e.nextTick(r)},c.prototype.close=function(t){var e=this,r=this.status;if("function"!=typeof t)throw new Error("close() requires a callback argument");this.status="closing",this._close(function(n){if(n)return e.status=r,t(n);e.status="closed",t()})},c.prototype._close=function(t){e.nextTick(t)},c.prototype.get=function(t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("get() requires a callback argument");var i=this._checkKey(t);if(i)return e.nextTick(n,i);t=this._serializeKey(t),"object"==typeof r&&null!==r||(r={}),r.asBuffer=!1!==r.asBuffer,this._get(t,r,n)},c.prototype._get=function(t,r,n){e.nextTick(function(){n(new Error("NotFound"))})},c.prototype.put=function(t,r,n,i){if("function"==typeof n&&(i=n),"function"!=typeof i)throw new Error("put() requires a callback argument");var o=this._checkKey(t)||this._checkValue(r);if(o)return e.nextTick(i,o);t=this._serializeKey(t),r=this._serializeValue(r),"object"==typeof n&&null!==n||(n={}),this._put(t,r,n,i)},c.prototype._put=function(t,r,n,i){e.nextTick(i)},c.prototype.del=function(t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("del() requires a callback argument");var i=this._checkKey(t);if(i)return e.nextTick(n,i);t=this._serializeKey(t),"object"==typeof r&&null!==r||(r={}),this._del(t,r,n)},c.prototype._del=function(t,r,n){e.nextTick(n)},c.prototype.batch=function(t,r,n){if(!arguments.length)return this._chainedBatch();if("function"==typeof r&&(n=r),"function"==typeof t&&(n=t),"function"!=typeof n)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(t))return e.nextTick(n,new Error("batch(array) requires an array argument"));"object"==typeof r&&null!==r||(r={});for(var o=new Array(t.length),a=0;a0?n-4:n,l=0;l>16&255,u[s++]=e>>8&255,u[s++]=255&e;2===a&&(e=i[t.charCodeAt(l)]<<2|i[t.charCodeAt(l+1)]>>4,u[s++]=255&e);1===a&&(e=i[t.charCodeAt(l)]<<10|i[t.charCodeAt(l+1)]<<4|i[t.charCodeAt(l+2)]>>2,u[s++]=e>>8&255,u[s++]=255&e);return u},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,u=r-i;au?u:a+16383));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]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,s=a.length;u0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var i,o,a=[],u=e;u>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var o,a,u=8*i-n-1,s=(1<>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,u,s,c=8*o-i-1,f=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(s=Math.pow(2,-a))<1&&(a--,s*=2),(e+=a+l>=1?h/s:h*Math.pow(2,1-l))*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(e*s-1)*Math.pow(2,i),a+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&u,p+=d,u/=256,i-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){var n=r(15).AbstractIterator;function i(t){n.call(this,t),this._options=t,this._iterator=null,this._operations=[]}r(3)(i,n),i.prototype.setDb=function(t){var e=this._iterator=t.iterator(this._options);this._operations.forEach(function(t){e[t.method].apply(e,t.args)})},i.prototype._operation=function(t,e){if(this._iterator)return this._iterator[t].apply(this._iterator,e);this._operations.push({method:t,args:e})},"next end".split(" ").forEach(function(t){i.prototype["_"+t]=function(){this._operation(t,arguments)}}),t.exports=i},function(t,e,r){var n=r(3),i=r(49).Readable,o=r(4);function a(t,e){if(!(this instanceof a))return new a(t,e);e=e||{},i.call(this,o(e,{objectMode:!0})),this._iterator=t,this._options=e,this.on("end",this.destroy.bind(this,null,null))}t.exports=a,n(a,i),a.prototype._read=function(){var t=this,e=this._options;this.destroyed||this._iterator.next(function(r,n,i){if(!t.destroyed)return r?t.destroy(r):void(void 0===n&&void 0===i?t.push(null):!1!==e.keys&&!1===e.values?t.push(n):!1===e.keys&&!1!==e.values?t.push(i):t.push({key:n,value:i}))})},a.prototype._destroy=function(t,e){this._iterator.end(function(r){e(t||r)})}},function(t,e,r){(e=t.exports=r(18)).Stream=e,e.Readable=e,e.Writable=r(22),e.Duplex=r(5),e.Transform=r(24),e.PassThrough=r(58)},function(t,e){},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var i=r(1).Buffer,o=r(52).inspect,a=o&&o.custom||"inspect";t.exports=function(){function t(){this.head=null,this.tail=null,this.length=0}var e=t.prototype;return e.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},e.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},e.shift=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}},e.clear=function(){this.head=this.tail=null,this.length=0},e.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},e.concat=function(t){if(0===this.length)return i.alloc(0);for(var e,r,n,o=i.allocUnsafe(t>>>0),a=this.head,u=0;a;)e=a.data,r=o,n=u,i.prototype.copy.call(e,r,n),u+=a.data.length,a=a.next;return o},e.consume=function(t,e){var r;return ti.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n},e._getBuffer=function(t){var e=i.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var o=r.data,a=t>o.length?o.length:t;if(o.copy(e,e.length-t,0,a),0===(t-=a)){a===o.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=o.slice(a));break}++n}return this.length-=n,e},e[a]=function(t,e){return o(this,function(t){for(var e=1;e
+ * https://github.com/rvagg/prr
+ * License: MIT
+ */
+var n,i;n=this,i=function(){var t="function"==typeof Object.defineProperty?function(t,e,r){return Object.defineProperty(t,e,r),t}:function(t,e,r){return t[e]=r.value,t};return function(e,r,n,i){var o;if(i=function(t,e){var r="object"==typeof e,n=!r&&"string"==typeof e,i=function(t){return r?!!e[t]:!!n&&e.indexOf(t[0])>-1};return{enumerable:i("enumerable"),configurable:i("configurable"),writable:i("writable"),value:t}}(n,i),"object"==typeof r){for(o in r)Object.hasOwnProperty.call(r,o)&&(i.value=r[o],t(e,o,i));return e}return t(e,r,i)}},t.exports?t.exports=i():n.prr=i()},function(t,e,r){"use strict";(function(e){
+/*!
+ * The buffer module from node.js, for the browser.
+ *
+ * @author Feross Aboukhadijeh
+ * @license MIT
+ */
+function n(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i=0;c--)if(f[c]!==l[c])return!1;for(c=f.length-1;c>=0;c--)if(s=f[c],!v(t[s],e[s],r,n))return!1;return!0}(t,e,r,a))}return r?t===e:t==e}function _(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function w(t,e){if(!t||!e)return!1;if("[object RegExp]"==Object.prototype.toString.call(e))return e.test(t);try{if(t instanceof e)return!0}catch(t){}return!Error.isPrototypeOf(e)&&!0===e.call({},t)}function m(t,e,r,n){var i;if("function"!=typeof e)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(t){var e;try{t()}catch(t){e=t}return e}(e),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),t&&!i&&g(i,r,"Missing expected exception"+n);var a="string"==typeof n,u=!t&&i&&!r;if((!t&&o.isError(i)&&a&&w(i,r)||u)&&g(i,r,"Got unwanted exception"+n),t&&i&&r&&!w(i,r)||!t&&i)throw i}l.AssertionError=function(t){var e;this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=d(y((e=this).actual),128)+" "+e.operator+" "+d(y(e.expected),128),this.generatedMessage=!0);var r=t.stackStartFunction||g;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var n=new Error;if(n.stack){var i=n.stack,o=p(r),a=i.indexOf("\n"+o);if(a>=0){var u=i.indexOf("\n",a+1);i=i.substring(u+1)}this.stack=i}}},o.inherits(l.AssertionError,Error),l.fail=g,l.ok=b,l.equal=function(t,e,r){t!=e&&g(t,e,r,"==",l.equal)},l.notEqual=function(t,e,r){t==e&&g(t,e,r,"!=",l.notEqual)},l.deepEqual=function(t,e,r){v(t,e,!1)||g(t,e,r,"deepEqual",l.deepEqual)},l.deepStrictEqual=function(t,e,r){v(t,e,!0)||g(t,e,r,"deepStrictEqual",l.deepStrictEqual)},l.notDeepEqual=function(t,e,r){v(t,e,!1)&&g(t,e,r,"notDeepEqual",l.notDeepEqual)},l.notDeepStrictEqual=function t(e,r,n){v(e,r,!0)&&g(e,r,n,"notDeepStrictEqual",t)},l.strictEqual=function(t,e,r){t!==e&&g(t,e,r,"===",l.strictEqual)},l.notStrictEqual=function(t,e,r){t===e&&g(t,e,r,"!==",l.notStrictEqual)},l.throws=function(t,e,r){m(!0,t,e,r)},l.doesNotThrow=function(t,e,r){m(!1,t,e,r)},l.ifError=function(t){if(t)throw t};var E=Object.keys||function(t){var e=[];for(var r in t)a.call(t,r)&&e.push(r);return e}}).call(this,r(2))},function(t,e,r){"use strict";var n=r(11).AbstractLevelDOWN,i=r(11).AbstractChainedBatch,o=r(11).AbstractIterator,a=r(3),u=r(65),s=r(67).EncodingError;function c(t,e){if(!(this instanceof c))return new c(t,e);n.call(this,""),void 0===(e=e||{}).keyEncoding&&(e.keyEncoding="utf8"),void 0===e.valueEncoding&&(e.valueEncoding="utf8"),this.db=t,this.codec=new u(e)}function f(t,e){o.call(this,t),this.codec=t.codec,this.keys=e.keys,this.values=e.values,this.opts=this.codec.encodeLtgt(e),this.it=t.db.iterator(this.opts)}function l(t,e){i.call(this,t),this.codec=t.codec,this.batch=t.db.batch()}t.exports=c.default=c,a(c,n),c.prototype._serializeKey=c.prototype._serializeValue=function(t){return t},c.prototype._open=function(t,e){this.db.open(t,e)},c.prototype._close=function(t){this.db.close(t)},c.prototype._put=function(t,e,r,n){t=this.codec.encodeKey(t,r),e=this.codec.encodeValue(e,r),this.db.put(t,e,r,n)},c.prototype._get=function(t,e,r){var n=this;t=this.codec.encodeKey(t,e),e.asBuffer=this.codec.valueAsBuffer(e),this.db.get(t,e,function(t,i){if(t)return r(t);try{i=n.codec.decodeValue(i,e)}catch(t){return r(new s(t))}r(null,i)})},c.prototype._del=function(t,e,r){t=this.codec.encodeKey(t,e),this.db.del(t,e,r)},c.prototype._chainedBatch=function(){return new l(this)},c.prototype._batch=function(t,e,r){t=this.codec.encodeBatch(t,e),this.db.batch(t,e,r)},c.prototype._iterator=function(t){return t.keyAsBuffer=this.codec.keyAsBuffer(t),t.valueAsBuffer=this.codec.valueAsBuffer(t),new f(this,t)},c.prototype.approximateSize=function(t,e,r,n){return t=this.codec.encodeKey(t,r),e=this.codec.encodeKey(e,r),this.db.approximateSize(t,e,r,n)},a(f,o),f.prototype._next=function(t){var e=this;this.it.next(function(r,n,i){if(r)return t(r);try{n=e.keys&&void 0!==n?e.codec.decodeKey(n,e.opts):void 0,i=e.values&&void 0!==i?e.codec.decodeValue(i,e.opts):void 0}catch(r){return t(new s(r))}t(null,n,i)})},f.prototype._end=function(t){this.it.end(t)},a(l,i),l.prototype._put=function(t,e){t=this.codec.encodeKey(t),e=this.codec.encodeValue(e),this.batch.put(t,e)},l.prototype._del=function(t){t=this.codec.encodeKey(t),this.batch.del(t)},l.prototype._clear=function(){this.batch.clear()},l.prototype._write=function(t,e){this.batch.write(t,e)}},function(t,e,r){(function(e,n){var i=r(4),o=r(27),a=r(28),u=Object.prototype.hasOwnProperty,s="start end gt gte lt lte".split(" ");function c(){this.status="new"}function f(t){return-1!==s.indexOf(t)}c.prototype.open=function(t,e){var r=this,n=this.status;if("function"==typeof t&&(e=t),"function"!=typeof e)throw new Error("open() requires a callback argument");"object"==typeof t&&null!==t||(t={}),t.createIfMissing=!1!==t.createIfMissing,t.errorIfExists=!!t.errorIfExists,this.status="opening",this._open(t,function(t){if(t)return r.status=n,e(t);r.status="open",e()})},c.prototype._open=function(t,r){e.nextTick(r)},c.prototype.close=function(t){var e=this,r=this.status;if("function"!=typeof t)throw new Error("close() requires a callback argument");this.status="closing",this._close(function(n){if(n)return e.status=r,t(n);e.status="closed",t()})},c.prototype._close=function(t){e.nextTick(t)},c.prototype.get=function(t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("get() requires a callback argument");var i=this._checkKey(t);if(i)return e.nextTick(n,i);t=this._serializeKey(t),"object"==typeof r&&null!==r||(r={}),r.asBuffer=!1!==r.asBuffer,this._get(t,r,n)},c.prototype._get=function(t,r,n){e.nextTick(function(){n(new Error("NotFound"))})},c.prototype.put=function(t,r,n,i){if("function"==typeof n&&(i=n),"function"!=typeof i)throw new Error("put() requires a callback argument");var o=this._checkKey(t)||this._checkValue(r);if(o)return e.nextTick(i,o);t=this._serializeKey(t),r=this._serializeValue(r),"object"==typeof n&&null!==n||(n={}),this._put(t,r,n,i)},c.prototype._put=function(t,r,n,i){e.nextTick(i)},c.prototype.del=function(t,r,n){if("function"==typeof r&&(n=r),"function"!=typeof n)throw new Error("del() requires a callback argument");var i=this._checkKey(t);if(i)return e.nextTick(n,i);t=this._serializeKey(t),"object"==typeof r&&null!==r||(r={}),this._del(t,r,n)},c.prototype._del=function(t,r,n){e.nextTick(n)},c.prototype.batch=function(t,r,n){if(!arguments.length)return this._chainedBatch();if("function"==typeof r&&(n=r),"function"==typeof t&&(n=t),"function"!=typeof n)throw new Error("batch(array) requires a callback argument");if(!Array.isArray(t))return e.nextTick(n,new Error("batch(array) requires an array argument"));"object"==typeof r&&null!==r||(r={});for(var o=new Array(t.length),a=0;a-1?e.encodeKey(t[n],t):t[n]}),r},i.prototype.createStreamDecoder=function(t){var e=this;return t.keys&&t.values?function(r,n){return{key:e.decodeKey(r,t),value:e.decodeValue(n,t)}}:t.keys?function(r){return e.decodeKey(r,t)}:t.values?function(r,n){return e.decodeValue(n,t)}:function(){}},i.prototype.keyAsBuffer=function(t){return this._keyEncoding(t).buffer},i.prototype.valueAsBuffer=function(t){return this._valueEncoding(t).buffer}},function(t,e,r){(function(t){e.utf8=e["utf-8"]={encode:function(t){return n(t)?t:String(t)},decode:r,buffer:!1,type:"utf8"},e.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},e.binary={encode:function(e){return n(e)?e:t.from(e)},decode:r,buffer:!0,type:"binary"},e.none={encode:r,decode:r,buffer:!1,type:"id"},e.id=e.none;function r(t){return t}function n(e){return null==e||t.isBuffer(e)}["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach(function(r){e[r]={encode:function(e){return n(e)?e:t.from(e,r)},decode:function(t){return t.toString(r)},buffer:!0,type:r}})}).call(this,r(1).Buffer)},function(t,e,r){var n=r(10).create,i=n("LevelUPError"),o=n("NotFoundError",i);o.prototype.notFound=!0,o.prototype.status=404,t.exports={LevelUPError:i,InitializationError:n("InitializationError",i),OpenError:n("OpenError",i),ReadError:n("ReadError",i),WriteError:n("WriteError",i),NotFoundError:o,EncodingError:n("EncodingError",i)}},function(t,e,r){"use strict";(function(e){t.exports=f;var n=r(29).AbstractLevelDOWN,i=r(3),o=r(70),a=r(32),u=r(33),s=r(80),c="level-js-";function f(t,e){if(!(this instanceof f))return new f(t,e);if(n.call(this),e=e||{},"string"!=typeof t)throw new Error("constructor requires a location string argument");this.location=t,this.prefix=e.prefix||c,this.version=parseInt(e.version||1,10)}i(f,n),f.binaryKeys=s.binaryKeys(indexedDB),f.arrayKeys=s.arrayKeys(indexedDB),f.prototype._open=function(t,e){var r=indexedDB.open(this.prefix+this.location,this.version),n=this;r.onerror=function(){e(r.error||new Error("unknown error"))},r.onsuccess=function(){n.db=r.result,e()},r.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(n.location)||e.createObjectStore(n.location)}},f.prototype.store=function(t){return this.db.transaction([this.location],t).objectStore(this.location)},f.prototype.await=function(t,e){var r=t.transaction;r.onabort=function(){e(r.error||new Error("aborted by user"))},r.oncomplete=function(){e(null,t.result)}},f.prototype._get=function(t,e,r){var n=this.store("readonly");try{var i=n.get(t)}catch(t){return u(function(){r(t)})}this.await(i,function(t,n){return t?r(t):void 0===n?r(new Error("NotFound")):(e.asBuffer&&(n=a(n)),void r(null,n))})},f.prototype._del=function(t,e,r){var n=this.store("readwrite");try{var i=n.delete(t)}catch(t){return u(function(){r(t)})}this.await(i,r)},f.prototype._put=function(t,e,r,n){var i=this.store("readwrite");try{var o=i.put(e,t)}catch(t){return u(function(){n(t)})}this.await(o,n)},f.prototype._serializeKey=function(t){return e.isBuffer(t)?f.binaryKeys?t:t.toString():Array.isArray(t)?f.arrayKeys?t.map(this._serializeKey,this):String(t):t},f.prototype._serializeValue=function(t){return t},f.prototype._iterator=function(t){return new o(this,this.location,t)},f.prototype._batch=function(t,e,r){if(0===t.length)return u(r);var n,i=this.store("readwrite"),o=i.transaction,a=0;o.onabort=function(){r(n||o.error||new Error("aborted by user"))},o.oncomplete=function(){r()},function e(){var r=t[a++],u=r.key;try{var s="del"===r.type?i.delete(u):i.put(r.value,u)}catch(t){return n=t,void o.abort()}a0){var r=this._cache.shift(),n=this._cache.shift();this._keyAsBuffer&&(r=a(r)),this._valueAsBuffer&&(n=a(n)),u(function(){t(null,r,n)})}else this._completed?u(t):this._callback=t},c.prototype._end=function(t){if(this._aborted||this._completed){var e=this._error;u(function(){t(e)})}else this.onItem=s,this.onAbort=t,this.onComplete=t}},function(t,e,r){(function(t){function r(t){return void 0!==t&&""!==t}function n(t,e){return Object.hasOwnProperty.call(t,e)}function i(t,e){return Object.hasOwnProperty.call(t,e)&&e}e.compare=function(e,r){if(t.isBuffer(e)){for(var n=Math.min(e.length,r.length),i=0;ir?1:0};var o=e.lowerBoundKey=function(t){return i(t,"gt")||i(t,"gte")||i(t,"min")||(t.reverse?i(t,"end"):i(t,"start"))||void 0},a=e.lowerBound=function(t,e){var r=o(t);return r?t[r]:e},u=e.lowerBoundInclusive=function(t){return!n(t,"gt")},s=e.upperBoundInclusive=function(t){return!n(t,"lt")},c=e.lowerBoundExclusive=function(t){return!u(t)},f=e.upperBoundExclusive=function(t){return!s(t)},l=e.upperBoundKey=function(t){return i(t,"lt")||i(t,"lte")||i(t,"max")||(t.reverse?i(t,"start"):i(t,"end"))||void 0},h=e.upperBound=function(t,e){var r=l(t);return r?t[r]:e};function p(t){return t}e.start=function(t,e){return t.reverse?h(t,e):a(t,e)},e.end=function(t,e){return t.reverse?a(t,e):h(t,e)},e.startInclusive=function(t){return t.reverse?s(t):u(t)},e.endInclusive=function(t){return t.reverse?u(t):s(t)},e.toLtgt=function(t,r,i,o,a){r=r||{},i=i||p;var u=arguments.length>3,s=e.lowerBoundKey(t),c=e.upperBoundKey(t);return s?"gt"===s?r.gt=i(t.gt,!1):r.gte=i(t[s],!1):u&&(r.gte=i(o,!1)),c?"lt"===c?r.lt=i(t.lt,!0):r.lte=i(t[c],!0):u&&(r.lte=i(a,!0)),null!=t.reverse&&(r.reverse=!!t.reverse),n(r,"max")&&delete r.max,n(r,"min")&&delete r.min,n(r,"start")&&delete r.start,n(r,"end")&&delete r.end,r},e.contains=function(t,n,i){i=i||e.compare;var o=a(t);if(r(o)&&((u=i(n,o))<0||0===u&&c(t)))return!1;var u,s=h(t);if(r(s)&&((u=i(n,s))>0||0===u&&f(t)))return!1;return!0},e.filter=function(t,r){return function(n){return e.contains(t,n,r)}}}).call(this,r(1).Buffer)},function(t,e,r){(function(e){var n=r(73).strict;t.exports=function(t){if(n(t)){var r=e.from(t.buffer);return t.byteLength!==t.buffer.byteLength&&(r=r.slice(t.byteOffset,t.byteOffset+t.byteLength)),r}return e.from(t)}}).call(this,r(1).Buffer)},function(t,e){t.exports=i,i.strict=o,i.loose=a;var r=Object.prototype.toString,n={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(t){return o(t)||a(t)}function o(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function a(t){return n[r.call(t)]}},function(t,e,r){"use strict";var n,i,o,a=[r(75),r(76),r(77),r(78),r(79)],u=-1,s=[],c=!1;function f(){n&&i&&(n=!1,i.length?s=i.concat(s):u=-1,s.length&&l())}function l(){if(!n){c=!1,n=!0;for(var t=s.length,e=setTimeout(f);t;){for(i=s,s=[];i&&++u1)for(var r=1;r-1?e.encodeKey(t[n],t):t[n]}),r},i.prototype.createStreamDecoder=function(t){var e=this;return t.keys&&t.values?function(r,n){return{key:e.decodeKey(r,t),value:e.decodeValue(n,t)}}:t.keys?function(r){return e.decodeKey(r,t)}:t.values?function(r,n){return e.decodeValue(n,t)}:function(){}},i.prototype.keyAsBuffer=function(t){return this._keyEncoding(t).buffer},i.prototype.valueAsBuffer=function(t){return this._valueEncoding(t).buffer}},function(t,e,r){(function(t){e.utf8=e["utf-8"]={encode:function(t){return n(t)?t:String(t)},decode:r,buffer:!1,type:"utf8"},e.json={encode:JSON.stringify,decode:JSON.parse,buffer:!1,type:"json"},e.binary={encode:function(e){return n(e)?e:new t(e)},decode:r,buffer:!0,type:"binary"},e.none={encode:r,decode:r,buffer:!1,type:"id"},e.id=e.none;function r(t){return t}function n(e){return null==e||t.isBuffer(e)}["hex","ascii","base64","ucs2","ucs-2","utf16le","utf-16le"].forEach(function(r){e[r]={encode:function(e){return n(e)?e:new t(e,r)},decode:function(t){return t.toString(r)},buffer:!0,type:r}})}).call(this,r(1).Buffer)},function(t,e,r){var n=r(10).create,i=n("LevelUPError"),o=n("NotFoundError",i);o.prototype.notFound=!0,o.prototype.status=404,t.exports={LevelUPError:i,InitializationError:n("InitializationError",i),OpenError:n("OpenError",i),ReadError:n("ReadError",i),WriteError:n("WriteError",i),NotFoundError:o,EncodingError:n("EncodingError",i)}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=function(t){var e={};return(0,i.default)(t).forEach(function(t){if(void 0!==t){var r=!0;this.path.forEach(function(t){"_id"===t&&(r=!1),"!"===t.substring(0,1)&&(r=!1)}),r&&this.isLeaf&&(e[this.path.filter(function(t){return isNaN(t)}).join(".")]=(this.node+"").split(" "))}}),e},r=function(t){return Object.keys(t).reduce(function(e,r){if(1===t[r].length&&!isNaN(t[r][0])){var n=t[r][0];return e[r]={},e[r][n]=n,e}return e[r]=(0,o.default)(t[r]).reduce(function(t,e,r,n){return t[e.term]=(e.positions.length/n.length).toFixed(2),t},{}),e},{})},a=function(e){return new Promise(function(r,i){var o=new Set([].concat.apply([],e.map(Object.keys)));o.delete("_id"),o.delete("!doc"),t.STORE.batch(Array.from(o).map(function(t){return{type:"put",key:"○FIELD○"+t+"○",value:!0}}),function(e){e&&console.log(e),(0,n.default)(t).calibrate().then(r)})})};return{DELETE:function(){return t.DELETE.apply(t,arguments)},PUT:function(n){return t.PUT(n.map(e).map(r).map(function(t,e){return t._id=n[e]._id,t["!doc"]=n[e],t})).then(a)}}};var n=a(r(36)),i=a(r(13)),o=a(r(87));function a(t){return t&&t.__esModule?t:{default:t}}t.exports=e.default},function(t,e){t.exports=function(t,e){e=Object.assign({},{ngramLengths:[1]},e);const r=t.reduce((t,r,n,i)=>(e.ngramLengths.forEach(e=>{var o=i.slice(n,n+e);o.length===e&&(r=JSON.stringify(o),t[r]=t[r]||[],t[r].push(n))}),t),{});return Object.keys(r).map(t=>({term:JSON.parse(t),positions:r[t]})).sort((t,e)=>t.term[0]>e.term[0])}},function(t,e,r){"use strict";(function(n){Object.defineProperty(e,"__esModule",{value:!0});var i=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=t[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&u.return&&u.return()}finally{if(i)throw o}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();e.default=function(t){var e=function(t){return[].concat.apply([],t)},r=function(t){return t.map(function(t){return t.match=e(t.match),t.match=e(t.match),t})},u=function(e){return new Promise(function(r,n){return t.OBJECT(e).then(function(t){return r(e.map(function(e,r){return e.obj=t[r]["!doc"],e}))})})},s=function(){for(var e=arguments.length,n=Array(e),i=0;i-1?t.GET(e.replace(":",".")+":"):c.apply(void 0,a(n.searchableFields.map(function(t){return t+":"+e})))};return{AND:s,BUCKET:t.BUCKET,BUCKETFILTER:t.BUCKETFILTER,DICTIONARY:function(e){return new Promise(function(r,n){var i=new Set;(e="string"==typeof e?{gte:e,lte:e+"○"}:Object.assign({gte:"",lte:"○"},e)).lte="○"===e.lte.substr(-1)?e.lte:e.lte+"○";var o=t.STORE.createKeyStream(e);o.on("data",function(t){return i.add(t.split(":")[0].split(".").pop())}),o.on("end",function(){return r(Array.from(i).sort())})})},DISTINCT:function(e){return t.DISTINCT(e).then(function(t){return[].concat(a(t.reduce(function(t,e){return t.add(e.split(":")[0]),t},new Set)))})},DOCUMENTS:u,GET:f,OR:c,SCORENUMERIC:o.numericField,SCORETFIDF:o.TFIDF,SEARCH:function(){return s.apply(void 0,arguments).then(function(t){return(0,o.TFIDF)({resultSet:t,offset:0,limit:10})}).then(function(t){return u(t)})},SET_DIFFERENCE:function(t,e){return"string"==typeof t&&(t=f(t)),"string"==typeof e&&(e=f(e)),Promise.all([t,e]).then(function(t){var e=i(t,2),r=e[0],n=e[1];return n=n.map(function(t){return t._id}),r.filter(function(t){return n.indexOf(t._id)})})}}};var o=r(89);function a(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e