!function(t){if("function"==typeofbootstrap)bootstrap("nedb",t);elseif("object"==typeofexports)module.exports=t();elseif("function"==typeofdefine&&define.amd)define(t);elseif("undefined"!=typeofses){if(!ses.ok())return;ses.makeNedb=t}else"undefined"!=typeofwindow?window.Nedb=t():global.Nedb=t()}(function(){vart;returnfunction(t,e,n){functionr(n,o){if(!e[n]){if(!t[n]){vara="function"==typeofrequire&&require;if(!o&&a)returna(n,!0);if(i)returni(n,!0);thrownewError("Cannot find module '"+n+"'")}varu=e[n]={exports:{}};t[n][0].call(u.exports,function(e){vari=t[n][1][e];returnr(i?i:e)},u,u.exports)}returne[n].exports}for(vari="function"==typeofrequire&&require,o=0;o<n.length;o++)r(n[o]);returnr}({1:[function(t,e,n){functionr(t,e){if(t.indexOf)returnt.indexOf(e);for(varn=0;n<t.length;n++)if(e===t[n])returnn;return-1}vari=t("__browserify_process");i.EventEmitter||(i.EventEmitter=function(){});varo=n.EventEmitter=i.EventEmitter,a="function"==typeofArray.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)},u=10;o.prototype.setMaxListeners=function(t){this._events||(this._events={}),this._events.maxListeners=t},o.prototype.emit=function(t){if("error"===t&&(!this._events||!this._events.error||a(this._events.error)&&!this._events.error.length))throwarguments[1]instanceofError?arguments[1]:newError("Uncaught, unspecified 'error' event.");if(!this._events)return!1;vare=this._events[t];if(!e)return!1;if("function"==typeofe){switch(arguments.length){case1:e.call(this);break;case2:e.call(this,arguments[1]);break;case3:e.call(this,arguments[1],arguments[2]);break;default:varn=Array.prototype.slice.call(arguments,1);e.apply(this,n)}return!0}if(a(e)){for(varn=Array.prototype.slice.call(arguments,1),r=e.slice(),i=0,o=r.length;o>i;i++)r[i].apply(this,n);return!0}return!1},o.prototype.addListener=function(t,e){if("function"!=typeofe)thrownewError("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",t,e),this._events[t])if(a(this._events[t])){if(!this._events[t].warned){varn;n=void0!==this._events.maxListeners?this._events.maxListeners:u,n&&n>0&&this._events[t].length>n&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),console.trace())}this._events[t].push(e)}elsethis._events[t]=[this._events[t],e];elsethis._events[t]=e;returnthis},o.prototype.on=o.prototype.addListener,o.prototype.once=function(t,e){varn=this;returnn.on(t,functionr(){n.removeListener(t,r),e.apply(this,arguments)}),this},o.prototype.removeListener=function(t,e){if("function"!=typeofe)thrownewError("removeListener only takes instances of Function");if(!this._events||!this._events[t])returnthis;varn=this._events[t];if(a(n)){vari=r(n,e);if(0>i)returnthis;n.splice(i,1),0==n.length&&deletethis._events[t]}elsethis._events[t]===e&&deletethis._events[t];returnthis},o.prototype.removeAllListeners=function(t){return0===arguments.length?(this._events={},this):(t&&this._events&&this._events[t]&&(this._events[t]=null),this)},o.prototype.listeners=function(t){returnthis._events||(this._events={}),this._events[t]||(this._events[t]=[]),a(this._events[t])||(this._events[t]=[this._events[t]]),this._events[t]},o.listenerCount=function(t,e){varn;returnn=t._events&&t._events[e]?"function"==typeoft._events[e]?1:t._events[e].length:0}},{__browserify_process:4}],2:[function(t,e,n){functionr(t,e){for(varn=[],r=0;r<t.length;r++)e(t[r],r,t)&&n.push(t[r]);returnn}functioni(t,e){for(varn=0,r=t.length;r>=0;r--){vari=t[r];"."==i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");returnt}varo=t("__browserify_process"),a=/^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;n.resolve=function(){for(vart="",e=!1,n=arguments.length;n>=-1&&!e;n--){vara=n>=0?arguments[n]:o.cwd();"string"==typeofa&&a&&(t=a+"/"+t,e="/"===a.charAt(0))}returnt=i(r(t.split("/"),function(t
}varr=t("__browserify_process"),i=t("./storage"),o=t("path"),a=t("./model"),u=t("async"),s=t("./customUtils"),c=t("./indexes");n.ensureDirectoryExists=function(t,e){varn=e||function(){};i.mkdirp(t,function(t){returnn(t)})},n.getNWAppFilename=function(t,e){varn;switch(r.platform){case"win32":case"win64":if(n=r.env.LOCALAPPDATA||r.env.APPDATA,!n)throw"Couldn't find the base application data folder";n=o.join(n,t);break;case"darwin":if(n=r.env.HOME,!n)throw"Couldn't find the base application data directory";n=o.join(n,"Library","Application Support",t);break;case"linux":if(n=r.env.HOME,!n)throw"Couldn't find the base application data directory";n=o.join(n,".config",t);break;default:throw"Can't use the Node Webkit relative path for platform "+r.platform}returno.join(n,"nedb-data",e)},n.prototype.persistCachedDatabase=function(t){vare=t||function(){},n="",r=this;returnthis.inMemoryOnly?e(null):(this.db.getAllData().forEach(function(t){n+=r.afterSerialization(a.serialize(t))+"\n"}),Object.keys(this.db.indexes).forEach(function(t){"_id"!=t&&(n+=r.afterSerialization(a.serialize({$$indexCreated:{fieldName:t,unique:r.db.indexes[t].unique,sparse:r.db.indexes[t].sparse}}))+"\n")}),i.crashSafeWriteFile(this.filename,n,e),void0)},n.prototype.compactDatafile=function(){this.db.executor.push({"this":this,fn:this.persistCachedDatabase,arguments:[]})},n.prototype.setAutocompactionInterval=function(t){vare=this,n=5e3,r=Math.max(t||0,n);this.stopAutocompaction(),this.autocompactionIntervalId=setInterval(function(){e.compactDatafile()},r)},n.prototype.stopAutocompaction=function(){this.autocompactionIntervalId&&clearInterval(this.autocompactionIntervalId)},n.prototype.persistNewState=function(t,e){varn=this,r="",o=e||function(){};returnn.inMemoryOnly?o(null):(t.forEach(function(t){r+=n.afterSerialization(a.serialize(t))+"\n"}),0===r.length?o(null):(i.appendFile(n.filename,r,"utf8",function(t){returno(t)}),void0))},n.prototype.treatRawData=function(t){vare,n=t.split("\n"),r={},i=[],o={},u=-1;for(e=0;e<n.length;e+=1){vars;try{s=a.deserialize(this.beforeDeserialization(n[e])),s._id?s.$$deleted===!0?deleter[s._id]:r[s._id]=s:s.$$indexCreated&&void0!=s.$$indexCreated.fieldName?o[s.$$indexCreated.fieldName]=s.$$indexCreated:"string"==typeofs.$$indexRemoved&&deleteo[s.$$indexRemoved]}catch(c){u+=1}}if(n.length>0&&u/n.length>this.corruptAlertThreshold)throw"More than 10% of the data file is corrupt, the wrong beforeDeserialization hook may be used. Cautiously refusing to start NeDB to prevent dataloss";returnObject.keys(r).forEach(function(t){i.push(r[t])}),{data:i,indexes:o}},n.prototype.loadDatabase=function(t){vare=t||function(){},r=this;returnr.db.resetIndexes(),r.inMemoryOnly?e(null):(u.waterfall([function(t){n.ensureDirectoryExists(o.dirname(r.filename),function(){i.ensureDatafileIntegrity(r.filename,function(){i.readFile(r.filename,"utf8",function(e,n){if(e)returnt(e);try{vari=r.treatRawData(n)}catch(o){returnt(o)}Object.keys(i.indexes).forEach(function(t){r.db.indexes[t]=newc(i.indexes[t])});try{r.db.resetIndexes(i.data)}catch(o){returnr.db.resetIndexes(),t(o)}r.db.persistence.persistCachedDatabase(t)})})})}],function(t){returnt?e(t):(r.db.executor.processBuffer(),e(null))}),void0)},e.exports=n},{"./customUtils":6,"./indexes":9,"./model":10,"./storage":12,__browserify_process:4,async:13,path:2}],12:[function(t,e){functionn(t,e){f.getItem(t,function(t,n){returnnull!==n?e(!0):e(!1)})}functionr(t,e,n){f.getItem(t,function(r,i){null===i?f.removeItem(e,function(){returnn()}):f.setItem(e,i,function(){f.removeItem(t,function(){returnn()})})})}functioni(t,e,n,r){"function"==typeofn&&(r=n),f.setItem(t,e,function(){returnr()})}functiono(t,e,n,r){"function"==typeofn&&(r=n),f.getItem(t,function(n,i){i=i||"",i+=e,f.setItem(t,i,function(){returnr()})})}functiona(t,e,n){"function"==typeofe&&(n=e),f.getItem(t,function(t,e){returnn(null,e||"")})}functionu(t,e){f.removeItem(t,function(){returne()})}functions(t,e){returne()}functionc(t,e){returne(null)}varf=t("localforage");f.config({name:"NeDB",storeName:"nedb
if(e)for(varnine)e.hasOwnProperty(n)&&(arguments[0][n]=h(e[n])?e[n].slice():e[n])}returnarguments[0]}functiono(t){for(vareinu)if(u.hasOwnProperty(e)&&u[e]===t)return!0;return!1}vara={},u={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage"},s=[u.INDEXEDDB,u.WEBSQL,u.LOCALSTORAGE],c=["clear","getItem","iterate","key","keys","length","removeItem","setItem"],f={description:"",driver:s.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},l=function(t){vare=e||t.indexedDB||t.webkitIndexedDB||t.mozIndexedDB||t.OIndexedDB||t.msIndexedDB,n={};returnn[u.WEBSQL]=!!t.openDatabase,n[u.INDEXEDDB]=!!function(){if("undefined"!=typeoft.openDatabase&&t.navigator&&t.navigator.userAgent&&/Safari/.test(t.navigator.userAgent)&&!/Chrome/.test(t.navigator.userAgent))return!1;try{returne&&"function"==typeofe.open&&"undefined"!=typeoft.IDBKeyRange}catch(n){return!1}}(),n[u.LOCALSTORAGE]=!!function(){try{returnt.localStorage&&"setItem"int.localStorage&&t.localStorage.setItem}catch(e){return!1}}(),n}(this),h=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},p=function(){functione(t){r(this,e),this.INDEXEDDB=u.INDEXEDDB,this.LOCALSTORAGE=u.LOCALSTORAGE,this.WEBSQL=u.WEBSQL,this._defaultConfig=i({},f),this._config=i({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver)}returne.prototype.config=function(t){if("object"==typeoft){if(this._ready)returnnewError("Can't call config() after localforage has been used.");for(vareint)"storeName"===e&&(t[e]=t[e].replace(/\W/g,"_")),this._config[e]=t[e];return"driver"int&&t.driver&&this.setDriver(this._config.driver),!0}return"string"==typeoft?this._config[t]:this._config},e.prototype.defineDriver=function(t,e,n){varr=newPromise(function(e,n){try{varr=t._driver,i=newError("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver"),u=newError("Custom driver name already in use: "+t._driver);if(!t._driver)returnn(i),void0;if(o(t._driver))returnn(u),void0;for(vars=c.concat("_initStorage"),f=0;f<s.length;f++){varh=s[f];if(!h||!t[h]||"function"!=typeoft[h])returnn(i),void0}varp=Promise.resolve(!0);"_support"int&&(p=t._support&&"function"==typeoft._support?t._support():Promise.resolve(!!t._support)),p.then(function(n){l[r]=n,a[r]=t,e()},n)}catch(d){n(d)}});returnr.then(e,n),r},e.prototype.driver=function(){returnthis._driver||null},e.prototype.getDriver=function(t,e,r){vari=this,u=function(){if(o(t))switch(t){casei.INDEXEDDB:returnnewPromise(function(t){t(n(1))});casei.LOCALSTORAGE:returnnewPromise(function(t){t(n(2))});casei.WEBSQL:returnnewPromise(function(t){t(n(4))})}elseif(a[t])returnPromise.resolve(a[t]);returnPromise.reject(newError("Driver not found."))}();returnu.then(e,r),u},e.prototype.getSerializer=function(t){vare=newPromise(function(t){t(n(3))});returnt&&"function"==typeoft&&e.then(function(e){t(e)}),e},e.prototype.ready=function(t){vare=this,n=e._driverSet.then(function(){returnnull===e._ready&&(e._ready=e._initDriver()),e._ready});returnn.then(t,t),n},e.prototype.setDriver=function(t,e,n){functionr(){o._config.driver=o.driver()}functioni(t){returnfunction(){functione(){for(;n<t.length;){vari=t[n];returnn++,o._dbInfo=null,o._ready=null,o.getDriver(i).then(function(t){returno._extend(t),r(),o._ready=o._initStorage(o._config),o._ready})["catch"](e)}r();vara=newError("No available storage method found.");returno._driverSet=Promise.reject(a),o._driverSet}varn=0;returne()}}varo=this;h(t)||(t=[t]);vara=this._getSupportedDrivers(t),u=null!==this._driverSet?this._driverSet["catch"](function(){returnPromise.resolve()}):Promise.resolve();returnthis._driverSet=u.then(function(){vart=a[0];returno._dbInfo=null,o._ready=null,o.getDriver(t).then(function(t){o._driver=t._driver,r(),o._wrapLibraryMethodsWithReady(),o._initDriver=i(a)})})["catch"](function(){r();vart=newError("Noavailablestorage