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

pouchdb

Package Overview
Dependencies
Maintainers
8
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pouchdb - npm Package Compare versions

Comparing version 6.4.1 to 6.4.2

6

dist/pouchdb.find.min.js

@@ -1,8 +0,8 @@

// pouchdb-find plugin 6.4.1
// pouchdb-find plugin 6.4.2
// Based on Mango: https://github.com/cloudant/mango
//
// (c) 2012-2017 Dale Harvey and the PouchDB team
// (c) 2012-2018 Dale Harvey and the PouchDB team
// PouchDB may be freely distributed under the Apache license, version 2.0.
// For all details and documentation:
// http://pouchdb.com
!function e(t,n,r){function i(u,s){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(o)return o(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}},{}],2:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function u(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!function(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,s,a,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(n=this._events[e],u(n))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(o(n))for(s=Array.prototype.slice.call(arguments,1),r=(c=n.slice()).length,a=0;a<r;a++)c[a].apply(this,s);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(n=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,u,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],u=n.length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(s=u;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],i(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],3:[function(e,t,n){(function(e){"use strict";function n(){c=!0;for(var e,t,n=f.length;n;){for(t=f,f=[],e=-1;++e<n;)t[e]();n=f.length}c=!1}var r,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var o=0,u=new i(n),s=e.document.createTextNode("");u.observe(s,{characterData:!0}),r=function(){s.data=o=++o%2}}else if(e.setImmediate||void 0===e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var a=new e.MessageChannel;a.port1.onmessage=n,r=function(){a.port2.postMessage(0)}}var c,f=[];t.exports=function(e){1!==f.push(e)||c||r()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],5:[function(e,t,n){"use strict";function r(){}function i(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=p,this.queue=[],this.outcome=void 0,e!==r&&a(this,e)}function o(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function u(e,t,n){f(function(){var r;try{r=t(n)}catch(t){return l.reject(e,t)}r===e?l.reject(e,new TypeError("Cannot resolve promise with itself")):l.resolve(e,r)})}function s(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function a(e,t){function n(t){i||(i=!0,l.reject(e,t))}function r(t){i||(i=!0,l.resolve(e,t))}var i=!1,o=c(function(){t(r,n)});"error"===o.status&&n(o.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}var f=e(3),l={},d=["REJECTED"],h=["FULFILLED"],p=["PENDING"];t.exports=i,i.prototype.catch=function(e){return this.then(null,e)},i.prototype.then=function(e,t){if("function"!=typeof e&&this.state===h||"function"!=typeof t&&this.state===d)return this;var n=new this.constructor(r);if(this.state!==p){u(n,this.state===h?e:t,this.outcome)}else this.queue.push(new o(n,e,t));return n},o.prototype.callFulfilled=function(e){l.resolve(this.promise,e)},o.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},o.prototype.callRejected=function(e){l.reject(this.promise,e)},o.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},l.resolve=function(e,t){var n=c(s,t);if("error"===n.status)return l.reject(e,n.value);var r=n.value;if(r)a(e,r);else{e.state=h,e.outcome=t;for(var i=-1,o=e.queue.length;++i<o;)e.queue[i].callFulfilled(t)}return e},l.reject=function(e,t){e.state=d,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},i.resolve=function(e){return e instanceof this?e:l.resolve(new this(r),e)},i.reject=function(e){var t=new this(r);return l.reject(t,e)},i.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var o=new Array(n),u=0,s=-1,a=new this(r);++s<n;)!function(e,r){t.resolve(e).then(function(e){o[r]=e,++u!==n||i||(i=!0,l.resolve(a,o))},function(e){i||(i=!0,l.reject(a,e))})}(e[s],s);return a},i.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var o=-1,u=new this(r);++o<n;)!function(e){t.resolve(e).then(function(e){i||(i=!0,l.resolve(u,e))},function(e){i||(i=!0,l.reject(u,e))})}(e[o]);return u}},{3:3}],6:[function(e,t,n){function r(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===r||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function u(){v&&h&&(v=!1,h.length?p=h.concat(p):y=-1,p.length&&s())}function s(){if(!v){var e=o(u);v=!0;for(var t=p.length;t;){for(h=p,p=[];++y<t;)h&&h[y].run();y=-1,t=p.length}h=null,v=!1,function(e){if(l===clearTimeout)return clearTimeout(e);if((l===i||!l)&&clearTimeout)return l=clearTimeout,clearTimeout(e);try{l(e)}catch(t){try{return l.call(null,e)}catch(t){return l.call(this,e)}}}(e)}}function a(e,t){this.fun=e,this.array=t}function c(){}var f,l,d=t.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:r}catch(e){f=r}try{l="function"==typeof clearTimeout?clearTimeout:i}catch(e){l=i}}();var h,p=[],v=!1,y=-1;d.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new a(e,t)),1!==p.length||v||o(s)},a.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.prependListener=c,d.prependOnceListener=c,d.listeners=function(e){return[]},d.binding=function(e){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw new Error("process.chdir is not supported")},d.umask=function(){return 0}},{}],7:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var r;try{r=window}catch(e){r=self}r.SparkMD5=e()}}(function(e){"use strict";function t(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function n(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function i(e){var r,i,o,u,s,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(r=64;r<=c;r+=64)t(f,n(e.substring(r-64,r)));for(i=(e=e.substring(r-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<i;r+=1)o[r>>2]|=e.charCodeAt(r)<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(t(f,o),r=0;r<16;r+=1)o[r]=0;return u=8*c,u=u.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(u[2],16),a=parseInt(u[1],16)||0,o[14]=s,o[15]=a,t(f,o),f}function o(e){var t,n="";for(t=0;t<4;t+=1)n+=f[e>>8*t+4&15]+f[e>>8*t&15];return n}function u(e){var t;for(t=0;t<e.length;t+=1)e[t]=o(e[t]);return e.join("")}function s(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function a(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function c(){this.reset()}var f=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];return"5d41402abc4b2a76b9719d911017c592"!==u(i("hello"))&&function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,u,s,a=this.byteLength,c=t(n,a),f=a;return r!==e&&(f=t(r,a)),c>f?new ArrayBuffer(0):(i=f-c,o=new ArrayBuffer(i),u=new Uint8Array(o),s=new Uint8Array(this,c,i),u.set(s),o)}}(),c.prototype.append=function(e){return this.appendBinary(s(e)),this},c.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var r,i=this._buff.length;for(r=64;r<=i;r+=64)t(this._hash,n(this._buff.substring(r-64,r)));return this._buff=this._buff.substring(r-64),this},c.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=u(this._hash),e&&(n=a(n)),this.reset(),n},c.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},c.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},c.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},c.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},c.prototype._finish=function(e,n){var r,i,o,u=n;if(e[u>>2]|=128<<(u%4<<3),u>55)for(t(this._hash,e),u=0;u<16;u+=1)e[u]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,t(this._hash,e)},c.hash=function(e,t){return c.hashBinary(s(e),t)},c.hashBinary=function(e,t){var n=u(i(e));return t?a(n):n},c.ArrayBuffer=function(){this.reset()},c.ArrayBuffer.prototype.append=function(e){var n,i=function(e,t,n){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),n?r:r.buffer}(this._buff.buffer,e,!0),o=i.length;for(this._length+=e.byteLength,n=64;n<=o;n+=64)t(this._hash,r(i.subarray(n-64,n)));return this._buff=n-64<o?new Uint8Array(i.buffer.slice(n-64)):new Uint8Array(0),this},c.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=u(this._hash),e&&(n=a(n)),this.reset(),n},c.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},c.ArrayBuffer.prototype.getState=function(){var e=c.prototype.getState.call(this);return e.buff=function(e){return String.fromCharCode.apply(null,new Uint8Array(e))}(e.buff),e},c.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}(e.buff,!0),c.prototype.setState.call(this,e)},c.ArrayBuffer.prototype.destroy=c.prototype.destroy,c.ArrayBuffer.prototype._finish=c.prototype._finish,c.ArrayBuffer.hash=function(e,n){var i=u(function(e){var n,i,o,u,s,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(n=64;n<=c;n+=64)t(f,r(e.subarray(n-64,n)));for(i=(e=n-64<c?e.subarray(n-64):new Uint8Array(0)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<i;n+=1)o[n>>2]|=e[n]<<(n%4<<3);if(o[n>>2]|=128<<(n%4<<3),n>55)for(t(f,o),n=0;n<16;n+=1)o[n]=0;return u=8*c,u=u.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(u[2],16),a=parseInt(u[1],16)||0,o[14]=s,o[15]=a,t(f,o),f}(new Uint8Array(e)));return n?a(i):i},c})},{}],8:[function(e,t,n){var r=e(11),i=e(12),o=i;o.v1=r,o.v4=i,t.exports=o},{11:11,12:12}],9:[function(e,t,n){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,i=r;return i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]}},{}],10:[function(e,t,n){(function(e){var n,r=e.crypto||e.msCrypto;if(r&&r.getRandomValues){var i=new Uint8Array(16);n=function(){return r.getRandomValues(i),i}}if(!n){var o=new Array(16);n=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(e,t,n){var r=e(10),i=e(9),o=r(),u=[1|o[0],o[1],o[2],o[3],o[4],o[5]],s=16383&(o[6]<<8|o[7]),a=0,c=0;t.exports=function(e,t,n){var r=t&&n||0,o=t||[],f=void 0!==(e=e||{}).clockseq?e.clockseq:s,l=void 0!==e.msecs?e.msecs:(new Date).getTime(),d=void 0!==e.nsecs?e.nsecs:c+1,h=l-a+(d-c)/1e4;if(h<0&&void 0===e.clockseq&&(f=f+1&16383),(h<0||l>a)&&void 0===e.nsecs&&(d=0),d>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=l,c=d,s=f;var p=(1e4*(268435455&(l+=122192928e5))+d)%4294967296;o[r++]=p>>>24&255,o[r++]=p>>>16&255,o[r++]=p>>>8&255,o[r++]=255&p;var v=l/4294967296*1e4&268435455;o[r++]=v>>>8&255,o[r++]=255&v,o[r++]=v>>>24&15|16,o[r++]=v>>>16&255,o[r++]=f>>>8|128,o[r++]=255&f;for(var y=e.node||u,g=0;g<6;++g)o[r+g]=y[g];return t||i(o)}},{10:10,9:9}],12:[function(e,t,n){var r=e(10),i=e(9);t.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var u=(e=e||{}).random||(e.rng||r)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,t)for(var s=0;s<16;++s)t[o+s]=u[s];return t||i(u)}},{10:10,9:9}],13:[function(e,t,n){(function(t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function i(e){if(e instanceof ArrayBuffer)return function(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}function o(e){var t,n,r;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;n<r;n++)t[n]=o(e[n]);return t}if(e instanceof Date)return e.toISOString();if(function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer||"undefined"!=typeof Blob&&e instanceof Blob}(e))return i(e);if(!function(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&Ce.call(n)==De}(e))return e;t={};for(n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var u=o(e[n]);void 0!==u&&(t[n]=u)}return t}function u(e){return qe(function(t){var n=this,r="function"==typeof(t=o(t))[t.length-1]&&t.pop(),i=new Me(function(r,i){var o;try{var u=function(e){var t=!1;return qe(function(n){if(t)throw new Error("once called more than once");t=!0,e.apply(this,n)})}(function(e,t){e?i(e):r(t)});t.push(u),(o=e.apply(n,t))&&"function"==typeof o.then&&r(o)}catch(e){i(e)}});return r&&i.then(function(e){r(null,e)},r),i})}function s(e){return"$"+e}function a(e){return e.substring(1)}function c(){this._store={}}function f(e){if(this._store=new c,e&&Array.isArray(e))for(var t=0,n=e.length;t<n;t++)this.add(e[t])}function l(){return"undefined"!=typeof chrome&&void 0!==chrome.storage&&void 0!==chrome.storage.local}function d(){return Fe}function h(){Se.EventEmitter.call(this),this._listeners={},function(e){l()?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):d()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}(this)}function p(e){if("undefined"!=typeof console&&"function"==typeof console[e]){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}function v(e,t,n){Error.call(this,n),this.status=e,this.name=t,this.message=n,this.error=!0}function y(e){for(var t=[],n=0,r=e.length;n<r;n++)t=t.concat(e[n]);return t}function g(e){return"boolean"==typeof e._remote?e._remote:"function"==typeof e.type&&(p("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),"http"===e.type())}function m(e,t,n){return new Me(function(r,i){e.get(t,function(o,u){if(o){if(404!==o.status)return i(o);u={}}var s=u._rev,a=n(u);if(!a)return r({updated:!1,rev:s});a._id=t,a._rev=s,r(function(e,t,n){return e.put(t).then(function(e){return{updated:!0,rev:e.rev}},function(r){if(409!==r.status)throw r;return m(e,t._id,n)})}(e,a,n))})})}function _(e){return(e=o(e)).index||(e.index={}),["type","name","ddoc"].forEach(function(t){e.index[t]&&(e[t]=e.index[t],delete e.index[t])}),e.fields&&(e.index.fields=e.fields,delete e.fields),e.type||(e.type="json"),e}function w(e,t,n){t=_(t),e.request({method:"POST",url:"_index",body:t},n)}function b(e,t,n){e.request({method:"POST",url:"_find",body:t},n)}function k(e,t,n){e.request({method:"POST",url:"_explain",body:t},n)}function $(e,t){e.request({method:"GET",url:"_index"},t)}function x(e,t,n){var r=t.ddoc,i=t.type||"json",o=t.name;if(!r)return n(new Error("you must provide an index's ddoc"));if(!o)return n(new Error("you must provide an index's name"));var u="_index/"+[r,i,o].map(encodeURIComponent).join("/");e.request({method:"DELETE",url:u},n)}function j(e,t){for(var n=e,r=0,i=t.length;r<i;r++){if(!(n=n[t[r]]))break}return n}function E(e,t,n){for(var r=0,i=t.length;r<i-1;r++){e=e[t[r]]={}}e[t[i-1]]=n}function O(e,t){return e<t?-1:e>t?1:0}function A(e){for(var t=[],n="",r=0,i=e.length;r<i;r++){var o=e[r];"."===o?r>0&&"\\"===e[r-1]?n=n.substring(0,n.length-1)+".":(t.push(n),n=""):n+=o}return t.push(n),t}function q(e){return Pe.indexOf(e)>-1}function S(e){return Object.keys(e)[0]}function L(e){return e[S(e)]}function B(e){var t={};return e.forEach(function(e){Object.keys(e).forEach(function(n){var r=e[n];if("object"!=typeof r&&(r={$eq:r}),q(n))r instanceof Array?t[n]=r.map(function(e){return B([e])}):t[n]=B([r]);else{var i=t[n]=t[n]||{};Object.keys(r).forEach(function(e){var t=r[e];return"$gt"===e||"$gte"===e?function(e,t,n){if(void 0!==n.$eq)return;void 0!==n.$gte?"$gte"===e?t>n.$gte&&(n.$gte=t):t>=n.$gte&&(delete n.$gte,n.$gt=t):void 0!==n.$gt?"$gte"===e?t>n.$gt&&(delete n.$gt,n.$gte=t):t>n.$gt&&(n.$gt=t):n[e]=t}(e,t,i):"$lt"===e||"$lte"===e?function(e,t,n){if(void 0!==n.$eq)return;void 0!==n.$lte?"$lte"===e?t<n.$lte&&(n.$lte=t):t<=n.$lte&&(delete n.$lte,n.$lt=t):void 0!==n.$lt?"$lte"===e?t<n.$lt&&(delete n.$lt,n.$lte=t):t<n.$lt&&(n.$lt=t):n[e]=t}(e,t,i):"$ne"===e?function(e,t){"$ne"in t?t.$ne.push(e):t.$ne=[e]}(t,i):"$eq"===e?function(e,t){delete t.$gt,delete t.$gte,delete t.$lt,delete t.$lte,delete t.$ne,t.$eq=e}(t,i):void(i[e]=t)})}})}),t}function T(e,t){if(e===t)return 0;e=M(e),t=M(t);var n=F(e),r=F(t);if(n-r!=0)return n-r;switch(typeof e){case"number":return e-t;case"boolean":return e<t?-1:1;case"string":return function(e,t){return e===t?0:e>t?1:-1}(e,t)}return Array.isArray(e)?function(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){var i=T(e[r],t[r]);if(0!==i)return i}return e.length===t.length?0:e.length>t.length?1:-1}(e,t):function(e,t){for(var n=Object.keys(e),r=Object.keys(t),i=Math.min(n.length,r.length),o=0;o<i;o++){var u=T(n[o],r[o]);if(0!==u)return u;if(0!==(u=T(e[n[o]],t[r[o]])))return u}return n.length===r.length?0:n.length>r.length?1:-1}(e,t)}function M(e){switch(typeof e){case"undefined":return null;case"number":return e===1/0||e===-1/0||isNaN(e)?null:e;case"object":var t=e;if(Array.isArray(e)){var n=e.length;e=new Array(n);for(var r=0;r<n;r++)e[r]=M(t[r])}else{if(e instanceof Date)return e.toJSON();if(null!==e){e={};for(var i in t)if(t.hasOwnProperty(i)){var o=t[i];void 0!==o&&(e[i]=M(o))}}}}return e}function C(e){if(null!==e)switch(typeof e){case"boolean":return e?1:0;case"number":return function(e){if(0===e)return"1";var t=e.toExponential().split(/e\+?/),n=parseInt(t[1],10),r=e<0,i=r?"0":"2",o=function(e,t,n){return function(e,t,n){for(var r="",i=n-e.length;r.length<i;)r+=t;return r}(e,t,n)+e}(((r?-n:n)-Re).toString(),"0",ze);i+=Ve+o;var u=Math.abs(parseFloat(t[0]));r&&(u=10-u);var s=u.toFixed(20);return s=s.replace(/\.?0+$/,""),i+=Ve+s}(e);case"string":return e.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var t=Array.isArray(e),n=t?e:Object.keys(e),r=-1,i=n.length,o="";if(t)for(;++r<i;)o+=D(n[r]);else for(;++r<i;){var u=n[r];o+=D(u)+D(e[u])}return o}return""}function D(e){return e=M(e),F(e)+Ve+C(e)+"\0"}function I(e,t){var n,r=t;if("1"===e[t])n=0,t++;else{var i="0"===e[t];t++;var o="",u=e.substring(t,t+ze),s=parseInt(u,10)+Re;for(i&&(s=-s),t+=ze;;){var a=e[t];if("\0"===a)break;o+=a,t++}n=1===(o=o.split(".")).length?parseInt(o,10):parseFloat(o[0]+"."+o[1]),i&&(n-=10),0!==s&&(n=parseFloat(n+"e"+s))}return{num:n,length:t-r}}function U(e,t){var n=e.pop();if(t.length){var r=t[t.length-1];n===r.element&&(t.pop(),r=t[t.length-1]);var i=r.element,o=r.index;if(Array.isArray(i))i.push(n);else if(o===e.length-2){i[e.pop()]=n}else e.push(n)}}function F(e){var t=["boolean","number","string","object"].indexOf(typeof e);return~t?null===e?1:Array.isArray(e)?5:t<3?t+2:t+3:Array.isArray(e)?5:void 0}function N(e,t,n){if(e=e.filter(function(e){return P(e.doc,t.selector,n)}),t.sort){var r=function(e){function t(t){return e.map(function(e){var n=A(S(e));return j(t,n)})}return function(e,n){var r=T(t(e.doc),t(n.doc));return 0!==r?r:O(e.doc._id,n.doc._id)}}(t.sort);e=e.sort(r),"string"!=typeof t.sort[0]&&"desc"===L(t.sort[0])&&(e=e.reverse())}if("limit"in t||"skip"in t){var i=t.skip||0,o=("limit"in t?t.limit:e.length)+i;e=e.slice(i,o)}return e}function P(e,t,n){return n.every(function(n){var r=t[n],i=A(n),o=j(e,i);return q(n)?function(e,t,n){if("$or"===e)return t.some(function(e){return P(n,e,Object.keys(e))});if("$not"===e)return!P(n,t,Object.keys(t));return!t.find(function(e){return P(n,e,Object.keys(e))})}(n,r,e):R(r,e,i,o)})}function R(e,t,n,r){return!e||Object.keys(e).every(function(i){var o=e[i];return function(e,t,n,r,i){if(!Je[e])throw new Error('unknown operator "'+e+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return Je[e](t,n,r,i)}(i,t,o,n,r)})}function z(e){return void 0!==e&&null!==e}function V(e){return void 0!==e}function J(e,t){return t.some(function(t){return e instanceof Array?e.indexOf(t)>-1:e===t})}function K(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}}function W(e){return K(function(n){var r=n.pop(),i=e.apply(this,n);return function(e,n){e.then(function(e){t.nextTick(function(){n(null,e)})},function(e){t.nextTick(function(){n(e)})})}(i,r),i})}function X(e){for(var t={},n=0,r=e.length;n<r;n++)t=Ne(t,e[n]);return t}function G(e,t){for(var n=0,r=Math.min(e.length,t.length);n<r;n++)if(e[n]!==t[n])return!1;return!0}function Y(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}function H(e,t){return function(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}([function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),i=0;i<t;i++)r[i]=e.charCodeAt(i);return n}(e)],{type:t})}function Q(){this.promise=new Me(function(e){e()})}function Z(e){return Te.hash(e)}function ee(e){if(!e)return"undefined";switch(typeof e){case"function":case"string":return e.toString();default:return JSON.stringify(e)}}function te(e,t,n,r,i,o){var u,s=function(e,t){return ee(e)+ee(t)+"undefined"}(n,r);if(!i&&(u=e._cachedViews=e._cachedViews||{})[s])return u[s];var a=e.info().then(function(a){var c=a.db_name+"-mrview-"+(i?"temp":Z(s));return m(e,"_local/"+o,function(e){e.views=e.views||{};var n=t;-1===n.indexOf("/")&&(n=t+"/"+t);var r=e.views[n]=e.views[n]||{};if(!r[c])return r[c]=!0,e}).then(function(){return e.registerDependentDatabase(c).then(function(t){var i=t.db;i.auto_compaction=!0;var o={name:c,db:i,sourceDB:e,adapter:e.adapter,mapFun:n,reduceFun:r};return o.db.get("_local/lastSeq").catch(function(e){if(404!==e.status)throw e}).then(function(e){return o.seq=e?e.seq:0,u&&o.db.once("destroyed",function(){delete u[s]}),o})})})});return u&&(u[s]=a),a}function ne(e){this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,ne)}catch(e){}}function re(e){this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,re)}catch(e){}}function ie(e){this.status=500,this.name="invalid_value",this.message=e,this.error=!0;try{Error.captureStackTrace(this,ie)}catch(e){}}function oe(e,t){return t&&e.then(function(e){Be(function(){t(null,e)})},function(e){Be(function(){t(e)})}),e}function ue(e,t){return function(){var n=arguments,r=this;return e.add(function(){return t.apply(r,n)})}}function se(e){var t=new Ie(e),n=new Array(t.size),r=-1;return t.forEach(function(e){n[++r]=e}),n}function ae(e){var t=new Array(e.size),n=-1;return e.forEach(function(e,r){t[++n]=r}),t}function ce(e){return-1===e.indexOf("/")?[e,e]:e.split("/")}function fe(e,t){try{e.emit("error",t)}catch(e){p("error","The user's map/reduce function threw an uncaught error.\nYou can debug this error by doing:\nmyDatabase.on('error', function (err) { debugger; });\nPlease double-check your map/reduce function."),p("error",t)}}function le(e,t){var n=function(e){for(var t=0,n=e.length;t<n;t++)if(-1!==e[t].indexOf("."))return!1;return!0}(e),r=1===e.length;return n?r?function(e,t){return function(n){t(n[e])}}(e[0],t):function(e,t){return function(n){for(var r=[],i=0,o=e.length;i<o;i++)r.push(n[e[i]]);t(r)}}(e,t):r?function(e,t){var n=A(e);return function(e){for(var r=e,i=0,o=n.length;i<o;i++)if(!(r=r[n[i]]))return;t(r)}}(e[0],t):function(e,t){return function(n){for(var r=[],i=0,o=e.length;i<o;i++){for(var u=A(e[i]),s=n,a=0,c=u.length;a<c;a++)if(!(s=s[u[a]]))return;r.push(s)}t(r)}}(e,t)}function de(e){return e.fields=e.fields.map(function(e){if("string"==typeof e){var t={};return t[e]="asc",t}return e}),e}function he(e,t){for(var n=[],r=0;r<t.def.fields.length;r++){var i=S(t.def.fields[r]);n.push(e[i])}return n}function pe(e){return e.allDocs({startkey:"_design/",endkey:"_design/￿",include_docs:!0}).then(function(e){var t={indexes:[{ddoc:null,name:"_all_docs",type:"special",def:{fields:[{_id:"asc"}]}}]};return t.indexes=Ke(t.indexes,e.rows.filter(function(e){return"query"===e.doc.language}).map(function(e){return(void 0!==e.doc.views?Object.keys(e.doc.views):[]).map(function(t){var n=e.doc.views[t];return{ddoc:e.id,name:t,type:"json",def:de(n.options.def)}})})),t.indexes.sort(function(e,t){return O(e.name,t.name)}),t.total_rows=t.indexes.length,t})}function ve(e,t){for(var n=e.def.fields.map(S),r=0,i=n.length;r<i;r++){if(t===n[r])return!0}return!1}function ye(e,t){return"$eq"!==S(e[t])}function ge(e,t){var n=t.def.fields.map(S);return e.slice().sort(function(e,t){var r=n.indexOf(e),i=n.indexOf(t);return-1===r&&(r=Number.MAX_VALUE),-1===i&&(i=Number.MAX_VALUE),O(r,i)})}function me(e,t,n,r){return ge(function(e){for(var t={},n=0;n<e.length;n++)t["$"+e[n]]=!0;return Object.keys(t).map(function(e){return e.substring(1)})}(Ke(e,function(e,t,n){for(var r=!1,i=0,o=(n=ge(n,e)).length;i<o;i++){var u=n[i];if(r||!ve(e,u))return n.slice(i);i<o-1&&ye(t,u)&&(r=!0)}return[]}(t,n,r),function(e){var t=[];return Object.keys(e).forEach(function(n){var r=e[n];Object.keys(r).forEach(function(e){"$ne"===e&&t.push(n)})}),t}(n))),t)}function _e(e,t,n){if(t){var r=function(e,t){return!(e.length>t.length)&&G(e,t)}(t,e),i=G(n,e);return r&&i}return function(e,t){e=e.slice();for(var n=0,r=t.length;n<r;n++){var i=t[n];if(!e.length)break;var o=e.indexOf(i);if(-1===o)return!1;e.splice(o,1)}return!0}(n,e)}function we(e){return-1===et.indexOf(e)}function be(e,t,n,r){var i=e.def.fields.map(S);return!!_e(i,t,n)&&function(e,t){var n=t[e[0]];return void 0===n||!!Object.keys(n).some(function(e){return!we(e)})&&!(1===Object.keys(n).length&&"$ne"===S(n))}(i,r)}function ke(e,t,n,r,i){var o=function(e,t,n,r){return r.reduce(function(r,i){return be(i,n,t,e)&&r.push(i),r},[])}(e,t,n,r);if(0===o.length){if(i)throw{error:"no_usable_index",message:"There is no index available for this selector."};var u=r[0];return u.defaultUsed=!0,u}if(1===o.length&&!i)return o[0];var s=function(e){for(var t={},n=0,r=e.length;n<r;n++)t[e[n]]=!0;return t}(t);if(i){var a="_design/"+i[0],c=2===i.length&&i[1],f=o.find(function(e){return!(!c||e.ddoc!==a||c!==e.name)||e.ddoc===a});if(!f)throw{error:"unknown_error",message:"Could not find that index or could not use that index for the query"};return f}return function(e,t){for(var n=null,r=-1,i=0,o=e.length;i<o;i++){var u=e[i],s=t(u);s>r&&(r=s,n=u)}return n}(o,function(e){for(var t=e.def.fields.map(S),n=0,r=0,i=t.length;r<i;r++){var o=t[r];s[o]&&n++}return n})}function $e(e,t){switch(e){case"$eq":return{startkey:t,endkey:t};case"$lte":return{endkey:t};case"$gte":return{startkey:t};case"$lt":return{endkey:t,inclusive_end:!1};case"$gt":return{startkey:t,inclusive_start:!1}}}function xe(e,t){return t.defaultUsed?function(e){return{queryOpts:{startkey:null},inMemoryFields:[Object.keys(e)]}}(e):1===t.def.fields.length?function(e,t){var n,r=S(t.def.fields[0]),i=e[r]||{},o=[];return Object.keys(i).forEach(function(e){if(we(e))o.push(r);else{var t=function(e,t){switch(e){case"$eq":return{key:t};case"$lte":return{endkey:t};case"$gte":return{startkey:t};case"$lt":return{endkey:t,inclusive_end:!1};case"$gt":return{startkey:t,inclusive_start:!1}}}(e,i[e]);n=n?X([n,t]):t}}),{queryOpts:n,inMemoryFields:o}}(e,t):function(e,t){function n(e){!1!==r&&s.push(Qe),!1!==i&&a.push(Ze),u=o.slice(e)}for(var r,i,o=t.def.fields.map(S),u=[],s=[],a=[],c=0,f=o.length;c<f;c++){var l=e[o[c]];if(!l||!Object.keys(l).length){n(c);break}if(c>0){if(Object.keys(l).some(we)){n(c);break}var d="$gt"in l||"$gte"in l||"$lt"in l||"$lte"in l,h=Object.keys(e[o[c-1]]),p=Y(h,["$eq"]),v=Y(h,Object.keys(l));if(d&&!p&&!v){n(c);break}}for(var y=Object.keys(l),g=null,m=0;m<y.length;m++){var _=y[m],w=$e(_,l[_]);g=g?X([g,w]):w}s.push("startkey"in g?g.startkey:Qe),a.push("endkey"in g?g.endkey:Ze),"inclusive_start"in g&&(r=g.inclusive_start),"inclusive_end"in g&&(i=g.inclusive_end)}var b={startkey:s,endkey:a};return void 0!==r&&(b.inclusive_start=r),void 0!==i&&(b.inclusive_end=i),{queryOpts:b,inMemoryFields:u}}(e,t)}function je(e,t){var n=e.selector,r=function(e,t){var n,r=Object.keys(e),i=t?t.map(S):[];return n=r.length>=i.length?r:i,0===i.length?{fields:n}:(n=n.sort(function(e,t){var n=i.indexOf(e);-1===n&&(n=Number.MAX_VALUE);var r=i.indexOf(t);return-1===r&&(r=Number.MAX_VALUE),n<r?-1:n>r?1:0}),{fields:n,sortOrder:t.map(S)})}(n,e.sort),i=r.fields,o=ke(n,i,r.sortOrder,t,e.use_index),u=xe(n,o);return{queryOpts:u.queryOpts,index:o,inMemoryFields:me(u.inMemoryFields,o,n,i)}}function Ee(e,t,n){return t.selector&&(t.selector=function(e){var t=o(e),n=!1;"$and"in t&&(t=B(t.$and),n=!0),["$or","$nor"].forEach(function(e){e in t&&t[e].forEach(function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var r=t[n],i=e[r];"object"==typeof i&&null!==i||(e[r]={$eq:i})}})}),"$not"in t&&(t.$not=B([t.$not]));for(var r=Object.keys(t),i=0;i<r.length;i++){var u=r[i],s=t[u];"object"!=typeof s||null===s?s={$eq:s}:"$ne"in s&&!n&&(s.$ne=[s.$ne]),t[u]=s}return t}(t.selector)),t.sort&&(t.sort=function(e){if(!Array.isArray(e))throw new Error("invalid sort json - should be an array");return e.map(function(e){if("string"==typeof e){var t={};return t[e]="asc",t}return e})}(t.sort)),t.use_index&&(t.use_index=function(e){var t=[];return"string"==typeof e?t.push(e):t=e,t.map(function(e){return e.replace("_design/","")})}(t.use_index)),function(e){if("object"!=typeof e.selector)throw new Error("you must provide a selector when you find()")}(t),pe(e).then(function(r){e.constructor.emit("debug",["find","planning query",t]);var i=je(t,r.indexes);e.constructor.emit("debug",["find","query plan",i]);var u=i.index;!function(e,t){if(t.defaultUsed&&e.sort){var n=e.sort.filter(function(e){return"_id"!==Object.keys(e)[0]}).map(function(e){return Object.keys(e)[0]});if(n.length>0)throw new Error('Cannot sort on field(s) "'+n.join(",")+'" when using the default index')}t.defaultUsed}(t,u);var s=Ne({include_docs:!0,reduce:!1},i.queryOpts);if("startkey"in s&&"endkey"in s&&T(s.startkey,s.endkey)>0)return{docs:[]};return t.sort&&"string"!=typeof t.sort[0]&&"desc"===L(t.sort[0])&&(s.descending=!0,s=function(e){var t=o(e);return delete t.startkey,delete t.endkey,delete t.inclusive_start,delete t.inclusive_end,"endkey"in e&&(t.startkey=e.endkey),"startkey"in e&&(t.endkey=e.startkey),"inclusive_start"in e&&(t.inclusive_end=e.inclusive_start),"inclusive_end"in e&&(t.inclusive_start=e.inclusive_end),t}(s)),i.inMemoryFields.length||("limit"in t&&(s.limit=t.limit),"skip"in t&&(s.skip=t.skip)),n?Me.resolve(i,s):Me.resolve().then(function(){if("_all_docs"===u.name)return function(e,t){var n=o(t);return n.descending?("endkey"in n&&"string"!=typeof n.endkey&&(n.endkey=""),"startkey"in n&&"string"!=typeof n.startkey&&(n.limit=0)):("startkey"in n&&"string"!=typeof n.startkey&&(n.startkey=""),"endkey"in n&&"string"!=typeof n.endkey&&(n.limit=0)),"key"in n&&"string"!=typeof n.key&&(n.limit=0),e.allDocs(n).then(function(e){return e.rows=e.rows.filter(function(e){return!/^_design\//.test(e.id)}),e})}(e,s);var t=function(e){return e.ddoc.substring(8)+"/"+e.name}(u);return He.query.call(e,t,s)}).then(function(e){!1===s.inclusive_start&&(e.rows=function(e,t,n){for(var r=n.def.fields,i=0,o=e.length;i<o;i++){var u=he(e[i].doc,n);if(1===r.length)u=u[0];else for(;u.length>t.length;)u.pop();if(Math.abs(T(u,t))>0)break}return i>0?e.slice(i):e}(e.rows,s.startkey,u)),i.inMemoryFields.length&&(e.rows=N(e.rows,t,i.inMemoryFields));var n={docs:e.rows.map(function(e){var n=e.doc;return t.fields?function(e,t){for(var n={},r=0,i=t.length;r<i;r++){var o=A(t[r]),u=j(e,o);void 0!==u&&E(n,o,u)}return n}(n,t.fields):n})};return u.defaultUsed&&(n.warning="no matching index found, create an index to optimize query time"),n})})}var Oe=r(e(8)),Ae=r(e(5)),qe=r(e(1)),Se=e(2),Le=r(e(4)),Be=r(e(3)),Te=r(e(7)),Me="function"==typeof Promise?Promise:Ae,Ce=Function.prototype.toString,De=Ce.call(Object);c.prototype.get=function(e){var t=s(e);return this._store[t]},c.prototype.set=function(e,t){var n=s(e);return this._store[n]=t,!0},c.prototype.has=function(e){return s(e)in this._store},c.prototype.delete=function(e){var t=s(e),n=t in this._store;return delete this._store[t],n},c.prototype.forEach=function(e){for(var t=Object.keys(this._store),n=0,r=t.length;n<r;n++){var i=t[n];e(this._store[i],i=a(i))}},Object.defineProperty(c.prototype,"size",{get:function(){return Object.keys(this._store).length}}),f.prototype.add=function(e){return this._store.set(e,!0)},f.prototype.has=function(e){return this._store.has(e)},f.prototype.forEach=function(e){this._store.forEach(function(t,n){e(n)})},Object.defineProperty(f.prototype,"size",{get:function(){return this._store.size}});var Ie,Ue;!function(){if("undefined"==typeof Symbol||"undefined"==typeof Map||"undefined"==typeof Set)return!1;var e=Object.getOwnPropertyDescriptor(Map,Symbol.species);return e&&"get"in e&&Map[Symbol.species]===Map}()?(Ie=f,Ue=c):(Ie=Set,Ue=Map);var Fe;if(l())Fe=!1;else try{localStorage.setItem("_pouch_check_localstorage",1),Fe=!!localStorage.getItem("_pouch_check_localstorage")}catch(e){Fe=!1}Le(h,Se.EventEmitter),h.prototype.addListener=function(e,t,n,r){function i(){if(o._listeners[t])if(u)u="waiting";else{u=!0;var e=function(e,t){for(var n={},r=0,i=t.length;r<i;r++){var o=t[r];o in e&&(n[o]=e[o])}return n}(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary"]);n.changes(e).on("change",function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))}).on("complete",function(){"waiting"===u&&Be(i),u=!1}).on("error",function(){u=!1})}}if(!this._listeners[t]){var o=this,u=!1;this._listeners[t]=i,this.on(e,i)}},h.prototype.removeListener=function(e,t){t in this._listeners&&(Se.EventEmitter.prototype.removeListener.call(this,e,this._listeners[t]),delete this._listeners[t])},h.prototype.notifyLocalWindows=function(e){l()?chrome.storage.local.set({dbName:e}):d()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},h.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var Ne="function"==typeof Object.assign?Object.assign:function(e){for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};Le(v,Error),v.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};new v(401,"unauthorized","Name or password is incorrect."),new v(400,"bad_request","Missing JSON list of 'docs'"),new v(404,"not_found","missing"),new v(409,"conflict","Document update conflict"),new v(400,"bad_request","_id field must contain a string"),new v(412,"missing_id","_id is required for puts"),new v(400,"bad_request","Only reserved document ids may start with underscore."),new v(412,"precondition_failed","Database not open"),new v(500,"unknown_error","Database encountered an unknown error"),new v(500,"badarg","Some query argument is invalid"),new v(400,"invalid_request","Request was invalid"),new v(400,"query_parse_error","Some query parameter is invalid"),new v(500,"doc_validation","Bad special document member"),new v(400,"bad_request","Something wrong with the request"),new v(400,"bad_request","Document must be a JSON object"),new v(404,"not_found","Database not found"),new v(500,"indexed_db_went_bad","unknown"),new v(500,"web_sql_went_bad","unknown"),new v(500,"levelDB_went_went_bad","unknown"),new v(403,"forbidden","Forbidden by design doc validate_doc_update function"),new v(400,"bad_request","Invalid rev format"),new v(412,"file_exists","The database could not be created, the file already exists."),new v(412,"missing_stub","A pre-existing attachment stub wasn't found"),new v(413,"invalid_url","Provided URL is invalid"),Oe.v4;var Pe=["$or","$nor","$not"],Re=-324,ze=3,Ve="",Je={$elemMatch:function(e,t,n,r){return!!Array.isArray(r)&&(0!==r.length&&("object"==typeof r[0]?r.some(function(e){return P(e,t,Object.keys(t))}):r.some(function(r){return R(t,e,n,r)})))},$allMatch:function(e,t,n,r){return!!Array.isArray(r)&&(0!==r.length&&("object"==typeof r[0]?r.every(function(e){return P(e,t,Object.keys(t))}):r.every(function(r){return R(t,e,n,r)})))},$eq:function(e,t,n,r){return V(r)&&0===T(r,t)},$gte:function(e,t,n,r){return V(r)&&T(r,t)>=0},$gt:function(e,t,n,r){return V(r)&&T(r,t)>0},$lte:function(e,t,n,r){return V(r)&&T(r,t)<=0},$lt:function(e,t,n,r){return V(r)&&T(r,t)<0},$exists:function(e,t,n,r){return t?V(r):!V(r)},$mod:function(e,t,n,r){return z(r)&&function(e,t){var n=t[0],r=t[1];if(0===n)throw new Error("Bad divisor, cannot divide by zero");if(parseInt(n,10)!==n)throw new Error("Divisor is not an integer");if(parseInt(r,10)!==r)throw new Error("Modulus is not an integer");return parseInt(e,10)===e&&e%n===r}(r,t)},$ne:function(e,t,n,r){return t.every(function(e){return 0!==T(r,e)})},$in:function(e,t,n,r){return z(r)&&J(r,t)},$nin:function(e,t,n,r){return z(r)&&!J(r,t)},$size:function(e,t,n,r){return z(r)&&function(e,t){return e.length===t}(r,t)},$all:function(e,t,n,r){return Array.isArray(r)&&function(e,t){return t.every(function(t){return e.indexOf(t)>-1})}(r,t)},$regex:function(e,t,n,r){return z(r)&&function(e,t){return new RegExp(t).test(e)}(r,t)},$type:function(e,t,n,r){return function(e,t){switch(t){case"null":return null===e;case"boolean":return"boolean"==typeof e;case"number":return"number"==typeof e;case"string":return"string"==typeof e;case"array":return e instanceof Array;case"object":return"[object Object]"==={}.toString.call(e)}throw new Error(t+" not supported as a type.Please use one of object, string, array, number, boolean or null.")}(r,t)}},Ke=K(function(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e[n];Array.isArray(i)?t=t.concat(Ke.apply(null,i)):t.push(i)}return t}),We=function(e){return atob(e)};Q.prototype.add=function(e){return this.promise=this.promise.catch(function(){}).then(function(){return e()}),this.promise},Q.prototype.finish=function(){return this.promise};n.setImmediate||n.setTimeout;Le(ne,Error),Le(re,Error),Le(ie,Error);var Xe={},Ge=new Q,Ye=50,He=function(e,t,n,r){function i(e,t,n){try{t(n)}catch(t){fe(e,t)}}function o(e,t,n,r,i){try{return{output:t(n,r,i)}}catch(t){return fe(e,t),{error:t}}}function u(e,t){var n=T(e.key,t.key);return 0!==n?n:T(e.value,t.value)}function s(e){var t=e.value;return t&&"object"==typeof t&&t._id||e.id}function a(e){e.rows.forEach(function(e){var t=e.doc&&e.doc._attachments;t&&Object.keys(t).forEach(function(e){var n=t[e];t[e].data=function(e,t){return H(We(e),t)}(n.data,n.content_type)})})}function c(e){return function(t){return e.include_docs&&e.attachments&&e.binary&&a(t),t}}function f(e,t,n,r){var i=t[e];void 0!==i&&(r&&(i=encodeURIComponent(JSON.stringify(i))),n.push(e+"="+i))}function l(e){if(void 0!==e){var t=Number(e);return isNaN(t)||t!==parseInt(e,10)?e:t}}function d(e,t){var n=e.descending?"endkey":"startkey",r=e.descending?"startkey":"endkey";if(void 0!==e[n]&&void 0!==e[r]&&T(e[n],e[r])>0)throw new ne("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(t.reduce&&!1!==e.reduce){if(e.include_docs)throw new ne("{include_docs:true} is invalid for reduce");if(e.keys&&e.keys.length>1&&!e.group&&!e.group_level)throw new ne("Multi-key fetches for reduce views must use {group: true}")}["group_level","limit","skip"].forEach(function(t){var n=function(e){if(e){if("number"!=typeof e)return new ne('Invalid value for integer: "'+e+'"');if(e<0)return new ne('Invalid value for positive integer: "'+e+'"')}}(e[t]);if(n)throw n})}function h(e){return function(t){if(404===t.status)return e;throw t}}function p(e,t,n){var r="_local/doc_"+e,i={_id:r,keys:[]},o=n.get(e),u=o[0];return(function(e){return 1===e.length&&/^1-/.test(e[0].rev)}(o[1])?Me.resolve(i):t.db.get(r).catch(h(i))).then(function(e){return function(e){return e.keys.length?t.db.allDocs({keys:e.keys,include_docs:!0}):Me.resolve({rows:[]})}(e).then(function(t){return function(e,t){for(var n=[],r=new Ie,i=0,o=t.rows.length;i<o;i++){var s=t.rows[i].doc;if(s&&(n.push(s),r.add(s._id),s._deleted=!u.has(s._id),!s._deleted)){var a=u.get(s._id);"value"in a&&(s.value=a.value)}}var c=ae(u);return c.forEach(function(e){if(!r.has(e)){var t={_id:e},i=u.get(e);"value"in i&&(t.value=i.value),n.push(t)}}),e.keys=se(c.concat(e.keys)),n.push(e),n}(e,t)})})}function v(e){var t="string"==typeof e?e:e.name,n=Xe[t];return n||(n=Xe[t]=new Q),n}function m(e){return ue(v(e),function(){return function(e){function n(t,n){return function(){return function(e,t,n){return e.db.get("_local/lastSeq").catch(h({_id:"_local/lastSeq",seq:0})).then(function(r){var i=ae(t);return Me.all(i.map(function(n){return p(n,e,t)})).then(function(t){var i=y(t);return r.seq=n,i.push(r),e.db.bulkDocs({docs:i})})})}(e,t,n)}}function r(){return e.sourceDB.changes({conflicts:!0,include_docs:!0,style:"all_docs",since:f,limit:Ye}).then(o)}function o(t){var o=t.results;if(o.length){var d=function(t){for(var n=new Ue,r=0,o=t.length;r<o;r++){var l=t[r];if("_"!==l.doc._id[0]){s=[],(a=l.doc)._deleted||i(e.sourceDB,c,a),s.sort(u);var d=function(e){for(var t,n=new Ue,r=0,i=e.length;r<i;r++){var o=e[r],u=[o.key,o.id];r>0&&0===T(o.key,t)&&u.push(r),n.set(D(u),o),t=o.key}return n}(s);n.set(l.doc._id,[d,l.changes])}f=l.seq}return n}(o);if(l.add(n(d,f)),!(o.length<Ye))return r()}}var s,a,c=t(e.mapFun,function(e,t){var n={id:a._id,key:M(e)};void 0!==t&&null!==t&&(n.value=M(t)),s.push(n)}),f=e.seq||0,l=new Q;return r().then(function(){return l.finish()}).then(function(){e.seq=f})}(e)})()}function _(e,t){return ue(v(e),function(){return function(e,t){function r(t){return t.include_docs=!0,e.db.allDocs(t).then(function(e){return u=e.total_rows,e.rows.map(function(e){if("value"in e.doc&&"object"==typeof e.doc.value&&null!==e.doc.value){var t=Object.keys(e.doc.value).sort(),n=["id","key","value"];if(!(t<n||t>n))return e.doc.value}var r=function(e){for(var t=[],n=[],r=0;;){var i=e[r++];if("\0"!==i)switch(i){case"1":t.push(null);break;case"2":t.push("1"===e[r]),r++;break;case"3":var o=I(e,r);t.push(o.num),r+=o.length;break;case"4":for(var u="";;){var s=e[r];if("\0"===s)break;u+=s,r++}u=u.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),t.push(u);break;case"5":var a={element:[],index:t.length};t.push(a.element),n.push(a);break;case"6":var c={element:{},index:t.length};t.push(c.element),n.push(c);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+i)}else{if(1===t.length)return t.pop();U(t,n)}}}(e.doc._id);return{key:r[0],id:r[1],value:"value"in e.doc?e.doc.value:null}})})}function i(r){var i;if(i=a?function(e,t,r){0===r.group_level&&delete r.group_level;var i=r.group||r.group_level,u=n(e.reduceFun),s=[],a=isNaN(r.group_level)?Number.POSITIVE_INFINITY:r.group_level;t.forEach(function(e){var t=s[s.length-1],n=i?e.key:null;if(i&&Array.isArray(n)&&(n=n.slice(0,a)),t&&0===T(t.groupKey,n))return t.keys.push([e.key,e.id]),void t.values.push(e.value);s.push({keys:[[e.key,e.id]],values:[e.value],groupKey:n})}),t=[];for(var c=0,f=s.length;c<f;c++){var l=s[c],d=o(e.sourceDB,u,l.keys,l.values,!1);if(d.error&&d.error instanceof ie)throw d.error;t.push({value:d.error?null:d.output,key:l.groupKey})}return{rows:function(e,t,n){return n=n||0,"number"==typeof t?e.slice(n,t+n):n>0?e.slice(n):e}(t,r.limit,r.skip)}}(e,r,t):{total_rows:u,offset:c,rows:r},t.update_seq&&(i.update_seq=e.seq),t.include_docs){var f=se(r.map(s));return e.sourceDB.allDocs({keys:f,include_docs:!0,conflicts:t.conflicts,attachments:t.attachments,binary:t.binary}).then(function(e){var t=new Ue;return e.rows.forEach(function(e){t.set(e.id,e.doc)}),r.forEach(function(e){var n=s(e),r=t.get(n);r&&(e.doc=r)}),i})}return i}var u,a=e.reduceFun&&!1!==t.reduce,c=t.skip||0;if(void 0===t.keys||t.keys.length||(t.limit=0,delete t.keys),void 0!==t.keys){var f=t.keys,l=f.map(function(e){var n={startkey:D([e]),endkey:D([e,{}])};return t.update_seq&&(n.update_seq=!0),r(n)});return Me.all(l).then(y).then(i)}var d={descending:t.descending};t.update_seq&&(d.update_seq=!0);var h,p;if("start_key"in t&&(h=t.start_key),"startkey"in t&&(h=t.startkey),"end_key"in t&&(p=t.end_key),"endkey"in t&&(p=t.endkey),void 0!==h&&(d.startkey=t.descending?D([h,{}]):D([h])),void 0!==p){var v=!1!==t.inclusive_end;t.descending&&(v=!v),d.endkey=D(v?[p,{}]:[p])}if(void 0!==t.key){var g=D([t.key]),m=D([t.key,{}]);d.descending?(d.endkey=g,d.startkey=m):(d.startkey=g,d.endkey=m)}return a||("number"==typeof t.limit&&(d.limit=t.limit),d.skip=c),r(d).then(i)}(e,t)})()}function w(t,n,i){if("function"==typeof t._query)return function(e,t,n){return new Me(function(r,i){e._query(t,n,function(e,t){if(e)return i(e);r(t)})})}(t,n,i);if(g(t))return function(e,t,n){var r,i=[],o="GET";if(f("reduce",n,i),f("include_docs",n,i),f("attachments",n,i),f("limit",n,i),f("descending",n,i),f("group",n,i),f("group_level",n,i),f("skip",n,i),f("stale",n,i),f("conflicts",n,i),f("startkey",n,i,!0),f("start_key",n,i,!0),f("endkey",n,i,!0),f("end_key",n,i,!0),f("inclusive_end",n,i),f("key",n,i,!0),f("update_seq",n,i),i=i.join("&"),i=""===i?"":"?"+i,void 0!==n.keys){var u="keys="+encodeURIComponent(JSON.stringify(n.keys));u.length+i.length+1<=2e3?i+=("?"===i[0]?"&":"?")+u:(o="POST","string"==typeof t?r={keys:n.keys}:t.keys=n.keys)}if("string"==typeof t){var s=ce(t);return e.request({method:o,url:"_design/"+s[0]+"/_view/"+s[1]+i,body:r}).then(function(e){return e.rows.forEach(function(e){if(e.value&&e.value.error&&"builtin_reduce_error"===e.value.error)throw new Error(e.reason)}),e}).then(c(n))}return r=r||{},Object.keys(t).forEach(function(e){Array.isArray(t[e])?r[e]=t[e]:r[e]=t[e].toString()}),e.request({method:"POST",url:"_temp_view"+i,body:r}).then(c(n))}(t,n,i);if("string"!=typeof n)return d(i,n),Ge.add(function(){return te(t,"temp_view/temp_view",n.map,n.reduce,!0,e).then(function(e){return function(e,t){return e.then(function(e){return t().then(function(){return e})},function(e){return t().then(function(){throw e})})}(m(e).then(function(){return _(e,i)}),function(){return e.db.destroy()})})}),Ge.finish();var o=n,u=ce(o),s=u[0],a=u[1];return t.get("_design/"+s).then(function(n){var u=n.views&&n.views[a];if(!u)throw new re("ddoc "+n._id+" has no view named "+a);return r(n,a),d(i,u),te(t,o,u.map,u.reduce,!1,e).then(function(e){return"ok"===i.stale||"update_after"===i.stale?("update_after"===i.stale&&Be(function(){m(e)}),_(e,i)):m(e).then(function(){return _(e,i)})})})}return{query:function(e,t,n){var r=this;"function"==typeof t&&(n=t,t={}),t=t?function(e){return e.group_level=l(e.group_level),e.limit=l(e.limit),e.skip=l(e.skip),e}(t):{},"function"==typeof e&&(e={map:e});var i=Me.resolve().then(function(){return w(r,e,t)});return oe(i,n),i},viewCleanup:function(e){return qe(function(t){var n=t.pop(),r=e.apply(this,t);return"function"==typeof n&&oe(r,n),r})}(function(){return"function"==typeof this._viewCleanup?function(e){return new Me(function(t,n){e._viewCleanup(function(e,r){if(e)return n(e);t(r)})})}(this):g(this)?function(e){return e.request({method:"POST",url:"_view_cleanup"})}(this):function(t){return t.get("_local/"+e).then(function(e){var n=new Ue;Object.keys(e.views).forEach(function(e){var t=ce(e),r="_design/"+t[0],i=t[1],o=n.get(r);o||(o=new Ie,n.set(r,o)),o.add(i)});var r={keys:ae(n),include_docs:!0};return t.allDocs(r).then(function(r){var i={};r.rows.forEach(function(t){var r=t.key.substring(8);n.get(t.key).forEach(function(n){var o=r+"/"+n;e.views[o]||(o=n);var u=Object.keys(e.views[o]),s=t.doc&&t.doc.views&&t.doc.views[n];u.forEach(function(e){i[e]=i[e]||s})})});var o=Object.keys(i).filter(function(e){return!i[e]}).map(function(e){return ue(v(e),function(){return new t.constructor(e,t.__opts).destroy()})()});return Me.all(o).then(function(){return{ok:!0}})})},h({ok:!0}))}(this)})}}("indexes",function(e,t){return le(Object.keys(e.fields),t)},function(){throw new Error("reduce not supported")},function(e,t){var n=e.views[t];if(!n.map||!n.map.fields)throw new Error("ddoc "+e._id+" with view "+t+" doesn't have map.fields defined. maybe it wasn't created by this plugin?")}),Qe=null,Ze={"￿":{}},et=["$eq","$gt","$gte","$lt","$lte"],tt=W(function(e,t){function n(){return i||(i=Z(JSON.stringify(t)))}var r=o((t=_(t)).index);t.index=de(t.index),function(e){var t=e.fields.filter(function(e){return"asc"===L(e)});if(0!==t.length&&t.length!==e.fields.length)throw new Error("unsupported mixed sorting")}(t.index);var i,u=t.name||"idx-"+n(),s=t.ddoc||"idx-"+n(),a="_design/"+s,c=!1,f=!1;return e.constructor.emit("debug",["find","creating index",a]),m(e,a,function(e){return e._rev&&"query"!==e.language&&(c=!0),e.language="query",e.views=e.views||{},!(f=!!e.views[u])&&(e.views[u]={map:{fields:X(t.index.fields)},reduce:"_count",options:{def:r}},e)}).then(function(){if(c)throw new Error('invalid language for ddoc with id "'+a+'" (should be "query")')}).then(function(){var t=s+"/"+u;return He.query.call(e,t,{limit:0,reduce:!1}).then(function(){return{id:a,name:u,result:f?"exists":"created"}})})}),nt=W(Ee),rt=W(function(e,t){return Ee(e,t,!0).then(function(n){return{dbname:e.name,index:n.index,selector:t.selector,range:{start_key:n.queryOpts.startkey,end_key:n.queryOpts.endkey},opts:{use_index:t.use_index||[],bookmark:"nil",limit:t.limit,skip:t.skip,sort:t.sort||{},fields:t.fields,conflicts:!1,r:[49]},limit:t.limit,skip:t.skip||0,fields:t.fields}})}),it=W(pe),ot=W(function(e,t){if(!t.ddoc)throw new Error("you must supply an index.ddoc when deleting");if(!t.name)throw new Error("you must supply an index.name when deleting");var n=t.ddoc,r=t.name;return m(e,n,function(e){return 1===Object.keys(e.views).length&&e.views[r]?{_id:n,_deleted:!0}:(delete e.views[r],e)}).then(function(){return He.viewCleanup.apply(e)}).then(function(){return{ok:!0}})}),ut={};ut.createIndex=u(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to create"));(g(this)?w:tt)(this,e,t)}),ut.find=u(function(e,t){if(void 0===t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to find()"));(g(this)?b:nt)(this,e,t)}),ut.explain=u(function(e,t){if(void 0===t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to explain()"));(g(this)?k:rt)(this,e,t)}),ut.getIndexes=u(function(e){(g(this)?$:it)(this,e)}),ut.deleteIndex=u(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to delete"));(g(this)?x:ot)(this,e,t)}),"undefined"==typeof PouchDB?p("error",'pouchdb-find plugin error: Cannot find global "PouchDB" object! Did you remember to include pouchdb.js?'):PouchDB.plugin(ut)}).call(this,e(6),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}]},{},[13]);
!function e(t,n,r){function i(u,s){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!s&&a)return a(u,!0);if(o)return o(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return i(n||e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)i(r[u]);return i}({1:[function(e,t,n){"use strict";t.exports=function(e){return function(){var t=arguments.length;if(t){for(var n=[],r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}return e.call(this,[])}}},{}],2:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function u(e){return void 0===e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,s,a,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(u(n=this._events[e]))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(o(n))for(s=Array.prototype.slice.call(arguments,1),r=(c=n.slice()).length,a=0;a<r;a++)c[a].apply(this,s);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(n=u(this._maxListeners)?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var n=!1;function r(){this.removeListener(e,r),n||(n=!0,t.apply(this,arguments))}return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var n,r,u,s;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(u=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(s=u;s-- >0;)if(n[s]===t||n[s].listener&&n[s].listener===t){r=s;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],3:[function(e,t,n){(function(e){"use strict";var n,r,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var o=0,u=new i(f),s=e.document.createTextNode("");u.observe(s,{characterData:!0}),n=function(){s.data=o=++o%2}}else if(e.setImmediate||void 0===e.MessageChannel)n="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){f(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(f,0)};else{var a=new e.MessageChannel;a.port1.onmessage=f,n=function(){a.port2.postMessage(0)}}var c=[];function f(){var e,t;r=!0;for(var n=c.length;n;){for(t=c,c=[],e=-1;++e<n;)t[e]();n=c.length}r=!1}t.exports=function(e){1!==c.push(e)||r||n()}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],5:[function(e,t,n){"use strict";var r=e(3);function i(){}var o={},u=["REJECTED"],s=["FULFILLED"],a=["PENDING"];function c(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=a,this.queue=[],this.outcome=void 0,e!==i&&h(this,e)}function f(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function l(e,t,n){r(function(){var r;try{r=t(n)}catch(t){return o.reject(e,t)}r===e?o.reject(e,new TypeError("Cannot resolve promise with itself")):o.resolve(e,r)})}function d(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function h(e,t){var n=!1;function r(t){n||(n=!0,o.reject(e,t))}function i(t){n||(n=!0,o.resolve(e,t))}var u=v(function(){t(i,r)});"error"===u.status&&r(u.value)}function v(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}t.exports=c,c.prototype.catch=function(e){return this.then(null,e)},c.prototype.then=function(e,t){if("function"!=typeof e&&this.state===s||"function"!=typeof t&&this.state===u)return this;var n=new this.constructor(i);this.state!==a?l(n,this.state===s?e:t,this.outcome):this.queue.push(new f(n,e,t));return n},f.prototype.callFulfilled=function(e){o.resolve(this.promise,e)},f.prototype.otherCallFulfilled=function(e){l(this.promise,this.onFulfilled,e)},f.prototype.callRejected=function(e){o.reject(this.promise,e)},f.prototype.otherCallRejected=function(e){l(this.promise,this.onRejected,e)},o.resolve=function(e,t){var n=v(d,t);if("error"===n.status)return o.reject(e,n.value);var r=n.value;if(r)h(e,r);else{e.state=s,e.outcome=t;for(var i=-1,u=e.queue.length;++i<u;)e.queue[i].callFulfilled(t)}return e},o.reject=function(e,t){e.state=u,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},c.resolve=function(e){if(e instanceof this)return e;return o.resolve(new this(i),e)},c.reject=function(e){var t=new this(i);return o.reject(t,e)},c.all=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);var u=new Array(n),s=0,a=-1,c=new this(i);for(;++a<n;)f(e[a],a);return c;function f(e,i){t.resolve(e).then(function(e){u[i]=e,++s!==n||r||(r=!0,o.resolve(c,u))},function(e){r||(r=!0,o.reject(c,e))})}},c.race=function(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,r=!1;if(!n)return this.resolve([]);var u=-1,s=new this(i);for(;++u<n;)a=e[u],t.resolve(a).then(function(e){r||(r=!0,o.resolve(s,e))},function(e){r||(r=!0,o.reject(s,e))});var a;return s}},{3:3}],6:[function(e,t,n){var r,i,o=t.exports={};function u(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function a(e){if(r===setTimeout)return setTimeout(e,0);if((r===u||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:u}catch(e){r=u}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(e){i=s}}();var c,f=[],l=!1,d=-1;function h(){l&&c&&(l=!1,c.length?f=c.concat(f):d=-1,f.length&&v())}function v(){if(!l){var e=a(h);l=!0;for(var t=f.length;t;){for(c=f,f=[];++d<t;)c&&c[d].run();d=-1,t=f.length}c=null,l=!1,function(e){if(i===clearTimeout)return clearTimeout(e);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(e);try{i(e)}catch(t){try{return i.call(null,e)}catch(t){return i.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new p(e,t)),1!==f.length||l||a(v)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],7:[function(e,t,n){!function(e){if("object"==typeof n)t.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var r;try{r=window}catch(e){r=self}r.SparkMD5=e()}}(function(e){"use strict";var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function o(e){var t,i,o,u,s,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(f,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(f,o),t=0;t<16;t+=1)o[t]=0;return u=(u=8*c).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(u[2],16),a=parseInt(u[1],16)||0,o[14]=s,o[15]=a,n(f,o),f}function u(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function s(e){var t;for(t=0;t<e.length;t+=1)e[t]=u(e[t]);return e.join("")}function a(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function c(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function f(){this.reset()}return"5d41402abc4b2a76b9719d911017c592"!==s(o("hello"))&&function(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n},"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,u,s,a=this.byteLength,c=t(n,a),f=a;return r!==e&&(f=t(r,a)),c>f?new ArrayBuffer(0):(i=f-c,o=new ArrayBuffer(i),u=new Uint8Array(o),s=new Uint8Array(this,c,i),u.set(s),o)}}(),f.prototype.append=function(e){return this.appendBinary(a(e)),this},f.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},f.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=s(this._hash),e&&(n=c(n)),this.reset(),n},f.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}},f.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},f.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},f.prototype._finish=function(e,t){var r,i,o,u=t;if(e[u>>2]|=128<<(u%4<<3),u>55)for(n(this._hash,e),u=0;u<16;u+=1)e[u]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,n(this._hash,e)},f.hash=function(e,t){return f.hashBinary(a(e),t)},f.hashBinary=function(e,t){var n=s(o(e));return t?c(n):n},f.ArrayBuffer=function(){this.reset()},f.ArrayBuffer.prototype.append=function(e){var t,r,o,u,s,a=(r=this._buff.buffer,o=e,u=!0,(s=new Uint8Array(r.byteLength+o.byteLength)).set(new Uint8Array(r)),s.set(new Uint8Array(o),r.byteLength),u?s:s.buffer),c=a.length;for(this._length+=e.byteLength,t=64;t<=c;t+=64)n(this._hash,i(a.subarray(t-64,t)));return this._buff=t-64<c?new Uint8Array(a.buffer.slice(t-64)):new Uint8Array(0),this},f.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=s(this._hash),e&&(n=c(n)),this.reset(),n},f.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.ArrayBuffer.prototype.getState=function(){var e,t=f.prototype.getState.call(this);return t.buff=(e=t.buff,String.fromCharCode.apply(null,new Uint8Array(e))),t},f.ArrayBuffer.prototype.setState=function(e){return e.buff=function(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}(e.buff,!0),f.prototype.setState.call(this,e)},f.ArrayBuffer.prototype.destroy=f.prototype.destroy,f.ArrayBuffer.prototype._finish=f.prototype._finish,f.ArrayBuffer.hash=function(e,t){var r=s(function(e){var t,r,o,u,s,a,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(f,i(e.subarray(t-64,t)));for(r=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)o[t>>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(f,o),t=0;t<16;t+=1)o[t]=0;return u=(u=8*c).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(u[2],16),a=parseInt(u[1],16)||0,o[14]=s,o[15]=a,n(f,o),f}(new Uint8Array(e)));return t?c(r):r},f})},{}],8:[function(e,t,n){var r=e(11),i=e(12),o=i;o.v1=r,o.v4=i,t.exports=o},{11:11,12:12}],9:[function(e,t,n){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);t.exports=function(e,t){var n=t||0,i=r;return i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+"-"+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]+i[e[n++]]}},{}],10:[function(e,t,n){var r="undefined"!=typeof crypto&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&msCrypto.getRandomValues.bind(msCrypto);if(r){var i=new Uint8Array(16);t.exports=function(){return r(i),i}}else{var o=new Array(16);t.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}},{}],11:[function(e,t,n){var r,i,o=e(10),u=e(9),s=0,a=0;t.exports=function(e,t,n){var c=t&&n||0,f=t||[],l=(e=e||{}).node||r,d=void 0!==e.clockseq?e.clockseq:i;if(null==l||null==d){var h=o();null==l&&(l=r=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==d&&(d=i=16383&(h[6]<<8|h[7]))}var v=void 0!==e.msecs?e.msecs:(new Date).getTime(),p=void 0!==e.nsecs?e.nsecs:a+1,y=v-s+(p-a)/1e4;if(y<0&&void 0===e.clockseq&&(d=d+1&16383),(y<0||v>s)&&void 0===e.nsecs&&(p=0),p>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=v,a=p,i=d;var g=(1e4*(268435455&(v+=122192928e5))+p)%4294967296;f[c++]=g>>>24&255,f[c++]=g>>>16&255,f[c++]=g>>>8&255,f[c++]=255&g;var m=v/4294967296*1e4&268435455;f[c++]=m>>>8&255,f[c++]=255&m,f[c++]=m>>>24&15|16,f[c++]=m>>>16&255,f[c++]=d>>>8|128,f[c++]=255&d;for(var _=0;_<6;++_)f[c+_]=l[_];return t||u(f)}},{10:10,9:9}],12:[function(e,t,n){var r=e(10),i=e(9);t.exports=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var u=(e=e||{}).random||(e.rng||r)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,t)for(var s=0;s<16;++s)t[o+s]=u[s];return t||i(u)}},{10:10,9:9}],13:[function(e,t,n){(function(t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var i=r(e(5)),o=r(e(1)),u=r(e(3)),s=e(2),a=r(e(4)),c=r(e(8)),f=r(e(7)),l="function"==typeof Promise?Promise:i;function d(e){if(e instanceof ArrayBuffer)return function(e){if("function"==typeof e.slice)return e.slice(0);var t=new ArrayBuffer(e.byteLength),n=new Uint8Array(t),r=new Uint8Array(e);return n.set(r),t}(e);var t=e.size,n=e.type;return"function"==typeof e.slice?e.slice(0,t,n):e.webkitSlice(0,t,n)}var h,v,p,y=Function.prototype.toString,g=y.call(Object);function m(e){var t,n,r,i;if(!e||"object"!=typeof e)return e;if(Array.isArray(e)){for(t=[],n=0,r=e.length;n<r;n++)t[n]=m(e[n]);return t}if(e instanceof Date)return e.toISOString();if(i=e,"undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer||"undefined"!=typeof Blob&&i instanceof Blob)return d(e);if(!function(e){var t=Object.getPrototypeOf(e);if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&y.call(n)==g}(e))return e;for(n in t={},e)if(Object.prototype.hasOwnProperty.call(e,n)){var o=m(e[n]);void 0!==o&&(t[n]=o)}return t}function _(e){return o(function(t){var n=this,r="function"==typeof(t=m(t))[t.length-1]&&t.pop(),i=new l(function(r,i){var u,s,a;try{var c=(s=function(e,t){e?i(e):r(t)},a=!1,o(function(e){if(a)throw new Error("once called more than once");a=!0,s.apply(this,e)}));t.push(c),(u=e.apply(n,t))&&"function"==typeof u.then&&r(u)}catch(e){i(e)}});return r&&i.then(function(e){r(null,e)},r),i})}function w(e){return"$"+e}function b(){this._store={}}function k(e){if(this._store=new b,e&&Array.isArray(e))for(var t=0,n=e.length;t<n;t++)this.add(e[t])}function $(){return"undefined"!=typeof chrome&&void 0!==chrome.storage&&void 0!==chrome.storage.local}if(b.prototype.get=function(e){var t=w(e);return this._store[t]},b.prototype.set=function(e,t){var n=w(e);return this._store[n]=t,!0},b.prototype.has=function(e){return w(e)in this._store},b.prototype.delete=function(e){var t=w(e),n=t in this._store;return delete this._store[t],n},b.prototype.forEach=function(e){for(var t=Object.keys(this._store),n=0,r=t.length;n<r;n++){var i=t[n];e(this._store[i],i=i.substring(1))}},Object.defineProperty(b.prototype,"size",{get:function(){return Object.keys(this._store).length}}),k.prototype.add=function(e){return this._store.set(e,!0)},k.prototype.has=function(e){return this._store.has(e)},k.prototype.forEach=function(e){this._store.forEach(function(t,n){e(n)})},Object.defineProperty(k.prototype,"size",{get:function(){return this._store.size}}),!function(){if("undefined"==typeof Symbol||"undefined"==typeof Map||"undefined"==typeof Set)return!1;var e=Object.getOwnPropertyDescriptor(Map,Symbol.species);return e&&"get"in e&&Map[Symbol.species]===Map}()?(h=k,v=b):(h=Set,v=Map),$())p=!1;else try{localStorage.setItem("_pouch_check_localstorage",1),p=!!localStorage.getItem("_pouch_check_localstorage")}catch(e){p=!1}function x(){return p}function j(){var e;s.EventEmitter.call(this),this._listeners={},e=this,$()?chrome.storage.onChanged.addListener(function(t){null!=t.db_name&&e.emit(t.dbName.newValue)}):x()&&("undefined"!=typeof addEventListener?addEventListener("storage",function(t){e.emit(t.key)}):window.attachEvent("storage",function(t){e.emit(t.key)}))}function E(e){if("undefined"!=typeof console&&"function"==typeof console[e]){var t=Array.prototype.slice.call(arguments,1);console[e].apply(console,t)}}a(j,s.EventEmitter),j.prototype.addListener=function(e,t,n,r){if(!this._listeners[t]){var i=this,o=!1;this._listeners[t]=s,this.on(e,s)}function s(){if(i._listeners[t])if(o)o="waiting";else{o=!0;var e=function(e,t){for(var n={},r=0,i=t.length;r<i;r++){var o=t[r];o in e&&(n[o]=e[o])}return n}(r,["style","include_docs","attachments","conflicts","filter","doc_ids","view","since","query_params","binary"]);n.changes(e).on("change",function(e){e.seq>r.since&&!r.cancelled&&(r.since=e.seq,r.onChange(e))}).on("complete",function(){"waiting"===o&&u(s),o=!1}).on("error",function(){o=!1})}}},j.prototype.removeListener=function(e,t){t in this._listeners&&(s.EventEmitter.prototype.removeListener.call(this,e,this._listeners[t]),delete this._listeners[t])},j.prototype.notifyLocalWindows=function(e){$()?chrome.storage.local.set({dbName:e}):x()&&(localStorage[e]="a"===localStorage[e]?"b":"a")},j.prototype.notify=function(e){this.emit(e),this.notifyLocalWindows(e)};var O="function"==typeof Object.assign?Object.assign:function(e){for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t};function A(e,t,n){Error.call(this,n),this.status=e,this.name=t,this.message=n,this.error=!0}a(A,Error),A.prototype.toString=function(){return JSON.stringify({status:this.status,name:this.name,message:this.message,reason:this.reason})};new A(401,"unauthorized","Name or password is incorrect."),new A(400,"bad_request","Missing JSON list of 'docs'"),new A(404,"not_found","missing"),new A(409,"conflict","Document update conflict"),new A(400,"bad_request","_id field must contain a string"),new A(412,"missing_id","_id is required for puts"),new A(400,"bad_request","Only reserved document ids may start with underscore."),new A(412,"precondition_failed","Database not open"),new A(500,"unknown_error","Database encountered an unknown error"),new A(500,"badarg","Some query argument is invalid"),new A(400,"invalid_request","Request was invalid"),new A(400,"query_parse_error","Some query parameter is invalid"),new A(500,"doc_validation","Bad special document member"),new A(400,"bad_request","Something wrong with the request"),new A(400,"bad_request","Document must be a JSON object"),new A(404,"not_found","Database not found"),new A(500,"indexed_db_went_bad","unknown"),new A(500,"web_sql_went_bad","unknown"),new A(500,"levelDB_went_went_bad","unknown"),new A(403,"forbidden","Forbidden by design doc validate_doc_update function"),new A(400,"bad_request","Invalid rev format"),new A(412,"file_exists","The database could not be created, the file already exists."),new A(412,"missing_stub","A pre-existing attachment stub wasn't found"),new A(413,"invalid_url","Provided URL is invalid");function q(e){for(var t=[],n=0,r=e.length;n<r;n++)t=t.concat(e[n]);return t}function S(e){return"boolean"==typeof e._remote?e._remote:"function"==typeof e.type&&(E("warn","db.type() is deprecated and will be removed in a future version of PouchDB"),"http"===e.type())}function L(e,t,n){return new l(function(r,i){e.get(t,function(o,u){if(o){if(404!==o.status)return i(o);u={}}var s,a,c,f=u._rev,l=n(u);if(!l)return r({updated:!1,rev:f});l._id=t,l._rev=f,r((a=l,c=n,(s=e).put(a).then(function(e){return{updated:!0,rev:e.rev}},function(e){if(409!==e.status)throw e;return L(s,a._id,c)})))})})}c.v4;function B(e){return(e=m(e)).index||(e.index={}),["type","name","ddoc"].forEach(function(t){e.index[t]&&(e[t]=e.index[t],delete e.index[t])}),e.fields&&(e.index.fields=e.fields,delete e.fields),e.type||(e.type="json"),e}function T(e,t,n){t=B(t),e.request({method:"POST",url:"_index",body:t},n)}function M(e,t,n){e.request({method:"POST",url:"_find",body:t},n)}function C(e,t,n){e.request({method:"POST",url:"_explain",body:t},n)}function D(e,t){e.request({method:"GET",url:"_index"},t)}function I(e,t,n){var r=t.ddoc,i=t.type||"json",o=t.name;if(!r)return n(new Error("you must provide an index's ddoc"));if(!o)return n(new Error("you must provide an index's name"));var u="_index/"+[r,i,o].map(encodeURIComponent).join("/");e.request({method:"DELETE",url:u},n)}function U(e,t){for(var n=e,r=0,i=t.length;r<i;r++){if(!(n=n[t[r]]))break}return n}function F(e,t,n){for(var r=0,i=t.length;r<i-1;r++){e=e[t[r]]={}}e[t[i-1]]=n}function N(e,t){return e<t?-1:e>t?1:0}function P(e){for(var t=[],n="",r=0,i=e.length;r<i;r++){var o=e[r];"."===o?r>0&&"\\"===e[r-1]?n=n.substring(0,n.length-1)+".":(t.push(n),n=""):n+=o}return t.push(n),t}var R=["$or","$nor","$not"];function z(e){return R.indexOf(e)>-1}function V(e){return Object.keys(e)[0]}function J(e){return e[V(e)]}function K(e){var t={};return e.forEach(function(e){Object.keys(e).forEach(function(n){var r=e[n];if("object"!=typeof r&&(r={$eq:r}),z(n))r instanceof Array?t[n]=r.map(function(e){return K([e])}):t[n]=K([r]);else{var i=t[n]=t[n]||{};Object.keys(r).forEach(function(e){var t,n,o,u,s=r[e];return"$gt"===e||"$gte"===e?function(e,t,n){if(void 0!==n.$eq)return;void 0!==n.$gte?"$gte"===e?t>n.$gte&&(n.$gte=t):t>=n.$gte&&(delete n.$gte,n.$gt=t):void 0!==n.$gt?"$gte"===e?t>n.$gt&&(delete n.$gt,n.$gte=t):t>n.$gt&&(n.$gt=t):n[e]=t}(e,s,i):"$lt"===e||"$lte"===e?function(e,t,n){if(void 0!==n.$eq)return;void 0!==n.$lte?"$lte"===e?t<n.$lte&&(n.$lte=t):t<=n.$lte&&(delete n.$lte,n.$lt=t):void 0!==n.$lt?"$lte"===e?t<n.$lt&&(delete n.$lt,n.$lte=t):t<n.$lt&&(n.$lt=t):n[e]=t}(e,s,i):"$ne"===e?(o=s,void("$ne"in(u=i)?u.$ne.push(o):u.$ne=[o])):"$eq"===e?(t=s,delete(n=i).$gt,delete n.$gte,delete n.$lt,delete n.$lte,delete n.$ne,void(n.$eq=t)):void(i[e]=s)})}})}),t}var W=-324,X=3,G="";function Y(e,t){if(e===t)return 0;e=H(e),t=H(t);var n,r,i=ne(e),o=ne(t);if(i-o!=0)return i-o;switch(typeof e){case"number":return e-t;case"boolean":return e<t?-1:1;case"string":return(n=e)===(r=t)?0:n>r?1:-1}return Array.isArray(e)?function(e,t){for(var n=Math.min(e.length,t.length),r=0;r<n;r++){var i=Y(e[r],t[r]);if(0!==i)return i}return e.length===t.length?0:e.length>t.length?1:-1}(e,t):function(e,t){for(var n=Object.keys(e),r=Object.keys(t),i=Math.min(n.length,r.length),o=0;o<i;o++){var u=Y(n[o],r[o]);if(0!==u)return u;if(0!==(u=Y(e[n[o]],t[r[o]])))return u}return n.length===r.length?0:n.length>r.length?1:-1}(e,t)}function H(e){switch(typeof e){case"undefined":return null;case"number":return e===1/0||e===-1/0||isNaN(e)?null:e;case"object":var t=e;if(Array.isArray(e)){var n=e.length;e=new Array(n);for(var r=0;r<n;r++)e[r]=H(t[r])}else{if(e instanceof Date)return e.toJSON();if(null!==e)for(var i in e={},t)if(t.hasOwnProperty(i)){var o=t[i];void 0!==o&&(e[i]=H(o))}}}return e}function Q(e){if(null!==e)switch(typeof e){case"boolean":return e?1:0;case"number":return function(e){if(0===e)return"1";var t=e.toExponential().split(/e\+?/),n=parseInt(t[1],10),r=e<0,i=r?"0":"2",o=(u=((r?-n:n)-W).toString(),s="0",a=X,function(e,t,n){for(var r="",i=n-e.length;r.length<i;)r+=t;return r}(u,s,a)+u);var u,s,a;i+=G+o;var c=Math.abs(parseFloat(t[0]));r&&(c=10-c);var f=c.toFixed(20);return f=f.replace(/\.?0+$/,""),i+=G+f}(e);case"string":return e.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var t=Array.isArray(e),n=t?e:Object.keys(e),r=-1,i=n.length,o="";if(t)for(;++r<i;)o+=Z(n[r]);else for(;++r<i;){var u=n[r];o+=Z(u)+Z(e[u])}return o}return""}function Z(e){return ne(e=H(e))+G+Q(e)+"\0"}function ee(e,t){var n,r=t;if("1"===e[t])n=0,t++;else{var i="0"===e[t];t++;var o="",u=e.substring(t,t+X),s=parseInt(u,10)+W;for(i&&(s=-s),t+=X;;){var a=e[t];if("\0"===a)break;o+=a,t++}n=1===(o=o.split(".")).length?parseInt(o,10):parseFloat(o[0]+"."+o[1]),i&&(n-=10),0!==s&&(n=parseFloat(n+"e"+s))}return{num:n,length:t-r}}function te(e,t){var n=e.pop();if(t.length){var r=t[t.length-1];n===r.element&&(t.pop(),r=t[t.length-1]);var i=r.element,o=r.index;if(Array.isArray(i))i.push(n);else if(o===e.length-2){i[e.pop()]=n}else e.push(n)}}function ne(e){var t=["boolean","number","string","object"].indexOf(typeof e);return~t?null===e?1:Array.isArray(e)?5:t<3?t+2:t+3:Array.isArray(e)?5:void 0}function re(e,t,n){if(e=e.filter(function(e){return ie(e.doc,t.selector,n)}),t.sort){var r=function(e){function t(t){return e.map(function(e){var n=P(V(e));return U(t,n)})}return function(e,n){var r=Y(t(e.doc),t(n.doc));return 0!==r?r:N(e.doc._id,n.doc._id)}}(t.sort);e=e.sort(r),"string"!=typeof t.sort[0]&&"desc"===J(t.sort[0])&&(e=e.reverse())}if("limit"in t||"skip"in t){var i=t.skip||0,o=("limit"in t?t.limit:e.length)+i;e=e.slice(i,o)}return e}function ie(e,t,n){return n.every(function(n){var r=t[n],i=P(n),o=U(e,i);return z(n)?function(e,t,n){if("$or"===e)return t.some(function(e){return ie(n,e,Object.keys(e))});if("$not"===e)return!ie(n,t,Object.keys(t));return!t.find(function(e){return ie(n,e,Object.keys(e))})}(n,r,e):oe(r,e,i,o)})}function oe(e,t,n,r){return!e||Object.keys(e).every(function(i){var o=e[i];return function(e,t,n,r,i){if(!ce[e])throw new Error('unknown operator "'+e+'" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all');return ce[e](t,n,r,i)}(i,t,o,n,r)})}function ue(e){return void 0!==e&&null!==e}function se(e){return void 0!==e}function ae(e,t){return t.some(function(t){return e instanceof Array?e.indexOf(t)>-1:e===t})}var ce={$elemMatch:function(e,t,n,r){return!!Array.isArray(r)&&(0!==r.length&&("object"==typeof r[0]?r.some(function(e){return ie(e,t,Object.keys(t))}):r.some(function(r){return oe(t,e,n,r)})))},$allMatch:function(e,t,n,r){return!!Array.isArray(r)&&(0!==r.length&&("object"==typeof r[0]?r.every(function(e){return ie(e,t,Object.keys(t))}):r.every(function(r){return oe(t,e,n,r)})))},$eq:function(e,t,n,r){return se(r)&&0===Y(r,t)},$gte:function(e,t,n,r){return se(r)&&Y(r,t)>=0},$gt:function(e,t,n,r){return se(r)&&Y(r,t)>0},$lte:function(e,t,n,r){return se(r)&&Y(r,t)<=0},$lt:function(e,t,n,r){return se(r)&&Y(r,t)<0},$exists:function(e,t,n,r){return t?se(r):!se(r)},$mod:function(e,t,n,r){return ue(r)&&function(e,t){var n=t[0],r=t[1];if(0===n)throw new Error("Bad divisor, cannot divide by zero");if(parseInt(n,10)!==n)throw new Error("Divisor is not an integer");if(parseInt(r,10)!==r)throw new Error("Modulus is not an integer");return parseInt(e,10)===e&&e%n===r}(r,t)},$ne:function(e,t,n,r){return t.every(function(e){return 0!==Y(r,e)})},$in:function(e,t,n,r){return ue(r)&&ae(r,t)},$nin:function(e,t,n,r){return ue(r)&&!ae(r,t)},$size:function(e,t,n,r){return ue(r)&&(i=t,r.length===i);var i},$all:function(e,t,n,r){return Array.isArray(r)&&(i=r,t.every(function(e){return i.indexOf(e)>-1}));var i},$regex:function(e,t,n,r){return ue(r)&&(i=r,new RegExp(t).test(i));var i},$type:function(e,t,n,r){return function(e,t){switch(t){case"null":return null===e;case"boolean":return"boolean"==typeof e;case"number":return"number"==typeof e;case"string":return"string"==typeof e;case"array":return e instanceof Array;case"object":return"[object Object]"==={}.toString.call(e)}throw new Error(t+" not supported as a type.Please use one of object, string, array, number, boolean or null.")}(r,t)}};function fe(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++r<t;)n[r]=arguments[r];return e.call(this,n)}}function le(e){return fe(function(n){var r,i=n.pop(),o=e.apply(this,n);return r=i,o.then(function(e){t.nextTick(function(){r(null,e)})},function(e){t.nextTick(function(){r(e)})}),o})}var de=fe(function(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e[n];Array.isArray(i)?t=t.concat(de.apply(null,i)):t.push(i)}return t});function he(e){for(var t={},n=0,r=e.length;n<r;n++)t=O(t,e[n]);return t}function ve(e,t){for(var n=0,r=Math.min(e.length,t.length);n<r;n++)if(e[n]!==t[n])return!1;return!0}function pe(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}var ye=function(e){return atob(e)};function ge(e,t){return function(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if("TypeError"!==i.name)throw i;for(var n=new("undefined"!=typeof BlobBuilder?BlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder?MozBlobBuilder:WebKitBlobBuilder),r=0;r<e.length;r+=1)n.append(e[r]);return n.getBlob(t.type)}}([function(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),i=0;i<t;i++)r[i]=e.charCodeAt(i);return n}(e)],{type:t})}function me(){this.promise=new l(function(e){e()})}me.prototype.add=function(e){return this.promise=this.promise.catch(function(){}).then(function(){return e()}),this.promise},me.prototype.finish=function(){return this.promise};n.setImmediate||n.setTimeout;function _e(e){return f.hash(e)}function we(e){if(!e)return"undefined";switch(typeof e){case"function":case"string":return e.toString();default:return JSON.stringify(e)}}function be(e,t,n,r,i,o){var u,s,a=(u=r,we(n)+we(u)+"undefined");if(!i&&(s=e._cachedViews=e._cachedViews||{})[a])return s[a];var c=e.info().then(function(u){var c=u.db_name+"-mrview-"+(i?"temp":_e(a));return L(e,"_local/"+o,function(e){e.views=e.views||{};var n=t;-1===n.indexOf("/")&&(n=t+"/"+t);var r=e.views[n]=e.views[n]||{};if(!r[c])return r[c]=!0,e}).then(function(){return e.registerDependentDatabase(c).then(function(t){var i=t.db;i.auto_compaction=!0;var o={name:c,db:i,sourceDB:e,adapter:e.adapter,mapFun:n,reduceFun:r};return o.db.get("_local/lastSeq").catch(function(e){if(404!==e.status)throw e}).then(function(e){return o.seq=e?e.seq:0,s&&o.db.once("destroyed",function(){delete s[a]}),o})})})});return s&&(s[a]=c),c}function ke(e){this.status=400,this.name="query_parse_error",this.message=e,this.error=!0;try{Error.captureStackTrace(this,ke)}catch(e){}}function $e(e){this.status=404,this.name="not_found",this.message=e,this.error=!0;try{Error.captureStackTrace(this,$e)}catch(e){}}function xe(e){this.status=500,this.name="invalid_value",this.message=e,this.error=!0;try{Error.captureStackTrace(this,xe)}catch(e){}}function je(e,t){return t&&e.then(function(e){u(function(){t(null,e)})},function(e){u(function(){t(e)})}),e}function Ee(e,t){return function(){var n=arguments,r=this;return e.add(function(){return t.apply(r,n)})}}function Oe(e){var t=new h(e),n=new Array(t.size),r=-1;return t.forEach(function(e){n[++r]=e}),n}function Ae(e){var t=new Array(e.size),n=-1;return e.forEach(function(e,r){t[++n]=r}),t}a(ke,Error),a($e,Error),a(xe,Error);var qe={},Se=new me,Le=50;function Be(e){return-1===e.indexOf("/")?[e,e]:e.split("/")}function Te(e,t){try{e.emit("error",t)}catch(e){E("error","The user's map/reduce function threw an uncaught error.\nYou can debug this error by doing:\nmyDatabase.on('error', function (err) { debugger; });\nPlease double-check your map/reduce function."),E("error",t)}}function Me(e,t){var n,r,i,o,u,s,a,c,f,l=function(e){for(var t=0,n=e.length;t<n;t++)if(-1!==e[t].indexOf("."))return!1;return!0}(e),d=1===e.length;return l?d?(c=e[0],f=t,function(e){f(e[c])}):(s=e,a=t,function(e){for(var t=[],n=0,r=s.length;n<r;n++)t.push(e[s[n]]);a(t)}):d?(i=e[0],o=t,u=P(i),function(e){for(var t=e,n=0,r=u.length;n<r;n++)if(void 0===(t=t[u[n]]))return;o(t)}):(n=e,r=t,function(e){for(var t=[],i=0,o=n.length;i<o;i++){for(var u=P(n[i]),s=e,a=0,c=u.length;a<c;a++)if(void 0===(s=s[u[a]]))return;t.push(s)}r(t)})}var Ce=function(e,t,n,r){function i(e,t,n){try{t(n)}catch(t){Te(e,t)}}function s(e,t,n,r,i){try{return{output:t(n,r,i)}}catch(t){return Te(e,t),{error:t}}}function a(e,t){var n=Y(e.key,t.key);return 0!==n?n:Y(e.value,t.value)}function c(e){var t=e.value;return t&&"object"==typeof t&&t._id||e.id}function f(e){e.rows.forEach(function(e){var t=e.doc&&e.doc._attachments;t&&Object.keys(t).forEach(function(e){var n,r,i=t[e];t[e].data=(n=i.data,r=i.content_type,ge(ye(n),r))})})}function d(e){return function(t){return e.include_docs&&e.attachments&&e.binary&&f(t),t}}function p(e,t,n,r){var i=t[e];void 0!==i&&(r&&(i=encodeURIComponent(JSON.stringify(i))),n.push(e+"="+i))}function y(e){if(void 0!==e){var t=Number(e);return isNaN(t)||t!==parseInt(e,10)?e:t}}function g(e,t){var n=e.descending?"endkey":"startkey",r=e.descending?"startkey":"endkey";if(void 0!==e[n]&&void 0!==e[r]&&Y(e[n],e[r])>0)throw new ke("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(t.reduce&&!1!==e.reduce){if(e.include_docs)throw new ke("{include_docs:true} is invalid for reduce");if(e.keys&&e.keys.length>1&&!e.group&&!e.group_level)throw new ke("Multi-key fetches for reduce views must use {group: true}")}["group_level","limit","skip"].forEach(function(t){var n=function(e){if(e){if("number"!=typeof e)return new ke('Invalid value for integer: "'+e+'"');if(e<0)return new ke('Invalid value for positive integer: "'+e+'"')}}(e[t]);if(n)throw n})}function m(e){return function(t){if(404===t.status)return e;throw t}}function _(e,t,n){var r,i="_local/doc_"+e,o={_id:i,keys:[]},u=n.get(e),s=u[0],a=u[1];return(1===(r=a).length&&/^1-/.test(r[0].rev)?l.resolve(o):t.db.get(i).catch(m(o))).then(function(e){return(n=e,n.keys.length?t.db.allDocs({keys:n.keys,include_docs:!0}):l.resolve({rows:[]})).then(function(t){return function(e,t){for(var n=[],r=new h,i=0,o=t.rows.length;i<o;i++){var u=t.rows[i].doc;if(u&&(n.push(u),r.add(u._id),u._deleted=!s.has(u._id),!u._deleted)){var a=s.get(u._id);"value"in a&&(u.value=a.value)}}var c=Ae(s);return c.forEach(function(e){if(!r.has(e)){var t={_id:e},i=s.get(e);"value"in i&&(t.value=i.value),n.push(t)}}),e.keys=Oe(c.concat(e.keys)),n.push(e),n}(e,t)});var n})}function w(e){var t="string"==typeof e?e:e.name,n=qe[t];return n||(n=qe[t]=new me),n}function b(e){return Ee(w(e),function(){return function(e){var n,r,o=t(e.mapFun,function(e,t){var i={id:r._id,key:H(e)};void 0!==t&&null!==t&&(i.value=H(t)),n.push(i)}),u=e.seq||0;function s(t,n){return function(){return i=t,o=n,u="_local/lastSeq",(r=e).db.get(u).catch(m({_id:u,seq:0})).then(function(e){var t=Ae(i);return l.all(t.map(function(e){return _(e,r,i)})).then(function(t){var n=q(t);return e.seq=o,n.push(e),r.db.bulkDocs({docs:n})})});var r,i,o,u}}var c=new me;function f(){return e.sourceDB.changes({conflicts:!0,include_docs:!0,style:"all_docs",since:u,limit:Le}).then(d)}function d(t){var l=t.results;if(l.length){var d=function(t){for(var s=new v,c=0,f=t.length;c<f;c++){var l=t[c];if("_"!==l.doc._id[0]){n=[],(r=l.doc)._deleted||i(e.sourceDB,o,r),n.sort(a);var d=h(n);s.set(l.doc._id,[d,l.changes])}u=l.seq}return s}(l);if(c.add(s(d,u)),!(l.length<Le))return f()}}function h(e){for(var t,n=new v,r=0,i=e.length;r<i;r++){var o=e[r],u=[o.key,o.id];r>0&&0===Y(o.key,t)&&u.push(r),n.set(Z(u),o),t=o.key}return n}return f().then(function(){return c.finish()}).then(function(){e.seq=u})}(e)})()}function k(e,t){return Ee(w(e),function(){return function(e,t){var r,i=e.reduceFun&&!1!==t.reduce,o=t.skip||0;function u(t){return t.include_docs=!0,e.db.allDocs(t).then(function(e){return r=e.total_rows,e.rows.map(function(e){if("value"in e.doc&&"object"==typeof e.doc.value&&null!==e.doc.value){var t=Object.keys(e.doc.value).sort(),n=["id","key","value"];if(!(t<n||t>n))return e.doc.value}var r=function(e){for(var t=[],n=[],r=0;;){var i=e[r++];if("\0"!==i)switch(i){case"1":t.push(null);break;case"2":t.push("1"===e[r]),r++;break;case"3":var o=ee(e,r);t.push(o.num),r+=o.length;break;case"4":for(var u="";;){var s=e[r];if("\0"===s)break;u+=s,r++}u=u.replace(/\u0001\u0001/g,"\0").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),t.push(u);break;case"5":var a={element:[],index:t.length};t.push(a.element),n.push(a);break;case"6":var c={element:{},index:t.length};t.push(c.element),n.push(c);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+i)}else{if(1===t.length)return t.pop();te(t,n)}}}(e.doc._id);return{key:r[0],id:r[1],value:"value"in e.doc?e.doc.value:null}})})}function a(u){var a;if(a=i?function(e,t,r){0===r.group_level&&delete r.group_level;var i,o,u,a=r.group||r.group_level,c=n(e.reduceFun),f=[],l=isNaN(r.group_level)?Number.POSITIVE_INFINITY:r.group_level;t.forEach(function(e){var t=f[f.length-1],n=a?e.key:null;if(a&&Array.isArray(n)&&(n=n.slice(0,l)),t&&0===Y(t.groupKey,n))return t.keys.push([e.key,e.id]),void t.values.push(e.value);f.push({keys:[[e.key,e.id]],values:[e.value],groupKey:n})}),t=[];for(var d=0,h=f.length;d<h;d++){var v=f[d],p=s(e.sourceDB,c,v.keys,v.values,!1);if(p.error&&p.error instanceof xe)throw p.error;t.push({value:p.error?null:p.output,key:v.groupKey})}return{rows:(i=t,o=r.limit,u=r.skip,u=u||0,"number"==typeof o?i.slice(u,o+u):u>0?i.slice(u):i)}}(e,u,t):{total_rows:r,offset:o,rows:u},t.update_seq&&(a.update_seq=e.seq),t.include_docs){var f=Oe(u.map(c));return e.sourceDB.allDocs({keys:f,include_docs:!0,conflicts:t.conflicts,attachments:t.attachments,binary:t.binary}).then(function(e){var t=new v;return e.rows.forEach(function(e){t.set(e.id,e.doc)}),u.forEach(function(e){var n=c(e),r=t.get(n);r&&(e.doc=r)}),a})}return a}if(void 0===t.keys||t.keys.length||(t.limit=0,delete t.keys),void 0!==t.keys){var f=t.keys,d=f.map(function(e){var n={startkey:Z([e]),endkey:Z([e,{}])};return t.update_seq&&(n.update_seq=!0),u(n)});return l.all(d).then(q).then(a)}var h,p,y={descending:t.descending};if(t.update_seq&&(y.update_seq=!0),"start_key"in t&&(h=t.start_key),"startkey"in t&&(h=t.startkey),"end_key"in t&&(p=t.end_key),"endkey"in t&&(p=t.endkey),void 0!==h&&(y.startkey=t.descending?Z([h,{}]):Z([h])),void 0!==p){var g=!1!==t.inclusive_end;t.descending&&(g=!g),y.endkey=Z(g?[p,{}]:[p])}if(void 0!==t.key){var m=Z([t.key]),_=Z([t.key,{}]);y.descending?(y.endkey=m,y.startkey=_):(y.startkey=m,y.endkey=_)}return i||("number"==typeof t.limit&&(y.limit=t.limit),y.skip=o),u(y).then(a)}(e,t)})()}function $(t,n,i){if("function"==typeof t._query)return o=t,s=n,a=i,new l(function(e,t){o._query(s,a,function(n,r){if(n)return t(n);e(r)})});var o,s,a;if(S(t))return function(e,t,n){var r,i=[],o="GET";if(p("reduce",n,i),p("include_docs",n,i),p("attachments",n,i),p("limit",n,i),p("descending",n,i),p("group",n,i),p("group_level",n,i),p("skip",n,i),p("stale",n,i),p("conflicts",n,i),p("startkey",n,i,!0),p("start_key",n,i,!0),p("endkey",n,i,!0),p("end_key",n,i,!0),p("inclusive_end",n,i),p("key",n,i,!0),p("update_seq",n,i),i=""===(i=i.join("&"))?"":"?"+i,void 0!==n.keys){var u="keys="+encodeURIComponent(JSON.stringify(n.keys));u.length+i.length+1<=2e3?i+=("?"===i[0]?"&":"?")+u:(o="POST","string"==typeof t?r={keys:n.keys}:t.keys=n.keys)}if("string"==typeof t){var s=Be(t);return e.request({method:o,url:"_design/"+s[0]+"/_view/"+s[1]+i,body:r}).then(function(e){return e.rows.forEach(function(e){if(e.value&&e.value.error&&"builtin_reduce_error"===e.value.error)throw new Error(e.reason)}),e}).then(d(n))}return r=r||{},Object.keys(t).forEach(function(e){Array.isArray(t[e])?r[e]=t[e]:r[e]=t[e].toString()}),e.request({method:"POST",url:"_temp_view"+i,body:r}).then(d(n))}(t,n,i);if("string"!=typeof n)return g(i,n),Se.add(function(){return be(t,"temp_view/temp_view",n.map,n.reduce,!0,e).then(function(e){return t=b(e).then(function(){return k(e,i)}),n=function(){return e.db.destroy()},t.then(function(e){return n().then(function(){return e})},function(e){return n().then(function(){throw e})});var t,n})}),Se.finish();var c=n,f=Be(c),h=f[0],v=f[1];return t.get("_design/"+h).then(function(n){var o=n.views&&n.views[v];if(!o)throw new $e("ddoc "+n._id+" has no view named "+v);return r(n,v),g(i,o),be(t,c,o.map,o.reduce,!1,e).then(function(e){return"ok"===i.stale||"update_after"===i.stale?("update_after"===i.stale&&u(function(){b(e)}),k(e,i)):b(e).then(function(){return k(e,i)})})})}var x;return{query:function(e,t,n){var r,i=this;"function"==typeof t&&(n=t,t={}),t=t?((r=t).group_level=y(r.group_level),r.limit=y(r.limit),r.skip=y(r.skip),r):{},"function"==typeof e&&(e={map:e});var o=l.resolve().then(function(){return $(i,e,t)});return je(o,n),o},viewCleanup:(x=function(){var t,n,r=this;return"function"==typeof r._viewCleanup?(t=r,new l(function(e,n){t._viewCleanup(function(t,r){if(t)return n(t);e(r)})})):S(r)?r.request({method:"POST",url:"_view_cleanup"}):(n=r).get("_local/"+e).then(function(e){var t=new v;Object.keys(e.views).forEach(function(e){var n=Be(e),r="_design/"+n[0],i=n[1],o=t.get(r);o||(o=new h,t.set(r,o)),o.add(i)});var r={keys:Ae(t),include_docs:!0};return n.allDocs(r).then(function(r){var i={};r.rows.forEach(function(n){var r=n.key.substring(8);t.get(n.key).forEach(function(t){var o=r+"/"+t;e.views[o]||(o=t);var u=Object.keys(e.views[o]),s=n.doc&&n.doc.views&&n.doc.views[t];u.forEach(function(e){i[e]=i[e]||s})})});var o=Object.keys(i).filter(function(e){return!i[e]}).map(function(e){return Ee(w(e),function(){return new n.constructor(e,n.__opts).destroy()})()});return l.all(o).then(function(){return{ok:!0}})})},m({ok:!0}))},o(function(e){var t=e.pop(),n=x.apply(this,e);return"function"==typeof t&&je(n,t),n}))}}("indexes",function(e,t){return Me(Object.keys(e.fields),t)},function(){throw new Error("reduce not supported")},function(e,t){var n=e.views[t];if(!n.map||!n.map.fields)throw new Error("ddoc "+e._id+" with view "+t+" doesn't have map.fields defined. maybe it wasn't created by this plugin?")});function De(e){return e.fields=e.fields.map(function(e){if("string"==typeof e){var t={};return t[e]="asc",t}return e}),e}function Ie(e,t){for(var n=[],r=0;r<t.def.fields.length;r++){var i=V(t.def.fields[r]);n.push(e[i])}return n}function Ue(e){return e.allDocs({startkey:"_design/",endkey:"_design/￿",include_docs:!0}).then(function(e){var t={indexes:[{ddoc:null,name:"_all_docs",type:"special",def:{fields:[{_id:"asc"}]}}]};return t.indexes=de(t.indexes,e.rows.filter(function(e){return"query"===e.doc.language}).map(function(e){return(void 0!==e.doc.views?Object.keys(e.doc.views):[]).map(function(t){var n=e.doc.views[t];return{ddoc:e.id,name:t,type:"json",def:De(n.options.def)}})})),t.indexes.sort(function(e,t){return N(e.name,t.name)}),t.total_rows=t.indexes.length,t})}var Fe=null,Ne={"￿":{}};function Pe(e,t){for(var n=e.def.fields.map(V),r=0,i=n.length;r<i;r++){if(t===n[r])return!0}return!1}function Re(e,t){var n=t.def.fields.map(V);return e.slice().sort(function(e,t){var r=n.indexOf(e),i=n.indexOf(t);return-1===r&&(r=Number.MAX_VALUE),-1===i&&(i=Number.MAX_VALUE),N(r,i)})}function ze(e,t,n,r){var i,o;return Re(function(e){for(var t={},n=0;n<e.length;n++)t["$"+e[n]]=!0;return Object.keys(t).map(function(e){return e.substring(1)})}(de(e,function(e,t,n){for(var r=!1,i=0,o=(n=Re(n,e)).length;i<o;i++){var u=n[i];if(r||!Pe(e,u))return n.slice(i);i<o-1&&"$eq"!==V(t[u])&&(r=!0)}return[]}(t,n,r),(i=n,o=[],Object.keys(i).forEach(function(e){var t=i[e];Object.keys(t).forEach(function(t){"$ne"===t&&o.push(e)})}),o))),t)}function Ve(e,t,n){if(t){var r=(u=e,!((o=t).length>u.length)&&ve(o,u)),i=ve(n,e);return r&&i}var o,u;return function(e,t){e=e.slice();for(var n=0,r=t.length;n<r;n++){var i=t[n];if(!e.length)break;var o=e.indexOf(i);if(-1===o)return!1;e.splice(o,1)}return!0}(n,e)}var Je=["$eq","$gt","$gte","$lt","$lte"];function Ke(e){return-1===Je.indexOf(e)}function We(e,t,n,r){var i,o=e.def.fields.map(V);return!!Ve(o,t,n)&&(void 0===(i=r[o[0]])||!!Object.keys(i).some(function(e){return!Ke(e)})&&!(1===Object.keys(i).length&&"$ne"===V(i)))}function Xe(e,t,n,r,i){var o,u,s,a=(o=e,u=t,s=n,r.reduce(function(e,t){return We(t,s,u,o)&&e.push(t),e},[]));if(0===a.length){if(i)throw{error:"no_usable_index",message:"There is no index available for this selector."};var c=r[0];return c.defaultUsed=!0,c}if(1===a.length&&!i)return a[0];var f=function(e){for(var t={},n=0,r=e.length;n<r;n++)t[e[n]]=!0;return t}(t);if(i){var l="_design/"+i[0],d=2===i.length&&i[1],h=a.find(function(e){return!(!d||e.ddoc!==l||d!==e.name)||e.ddoc===l});if(!h)throw{error:"unknown_error",message:"Could not find that index or could not use that index for the query"};return h}return function(e,t){for(var n=null,r=-1,i=0,o=e.length;i<o;i++){var u=e[i],s=t(u);s>r&&(r=s,n=u)}return n}(a,function(e){for(var t=e.def.fields.map(V),n=0,r=0,i=t.length;r<i;r++){var o=t[r];f[o]&&n++}return n})}function Ge(e,t){switch(e){case"$eq":return{startkey:t,endkey:t};case"$lte":return{endkey:t};case"$gte":return{startkey:t};case"$lt":return{endkey:t,inclusive_end:!1};case"$gt":return{startkey:t,inclusive_start:!1}}}function Ye(e,t){return t.defaultUsed?(n=e,{queryOpts:{startkey:null},inMemoryFields:[Object.keys(n)]}):1===t.def.fields.length?(r=e,o=V(t.def.fields[0]),u=r[o]||{},s=[],Object.keys(u).forEach(function(e){if(Ke(e))s.push(o);else{var t=function(e,t){switch(e){case"$eq":return{key:t};case"$lte":return{endkey:t};case"$gte":return{startkey:t};case"$lt":return{endkey:t,inclusive_end:!1};case"$gt":return{startkey:t,inclusive_start:!1}}}(e,u[e]);i=i?he([i,t]):t}}),{queryOpts:i,inMemoryFields:s}):function(e,t){var n,r,i=t.def.fields.map(V),o=[],u=[],s=[];function a(e){!1!==n&&u.push(Fe),!1!==r&&s.push(Ne),o=i.slice(e)}for(var c=0,f=i.length;c<f;c++){var l=e[i[c]];if(!l||!Object.keys(l).length){a(c);break}if(c>0){if(Object.keys(l).some(Ke)){a(c);break}var d="$gt"in l||"$gte"in l||"$lt"in l||"$lte"in l,h=Object.keys(e[i[c-1]]),v=pe(h,["$eq"]),p=pe(h,Object.keys(l));if(d&&!v&&!p){a(c);break}}for(var y=Object.keys(l),g=null,m=0;m<y.length;m++){var _=y[m],w=Ge(_,l[_]);g=g?he([g,w]):w}u.push("startkey"in g?g.startkey:Fe),s.push("endkey"in g?g.endkey:Ne),"inclusive_start"in g&&(n=g.inclusive_start),"inclusive_end"in g&&(r=g.inclusive_end)}var b={startkey:u,endkey:s};return void 0!==n&&(b.inclusive_start=n),void 0!==r&&(b.inclusive_end=r),{queryOpts:b,inMemoryFields:o}}(e,t);var n,r,i,o,u,s}function He(e,t){var n,r,i,o,u,s=e.selector,a=e.sort,c=(n=s,r=a,o=Object.keys(n),u=r?r.map(V):[],i=o.length>=u.length?o:u,0===u.length?{fields:i}:{fields:i=i.sort(function(e,t){var n=u.indexOf(e);-1===n&&(n=Number.MAX_VALUE);var r=u.indexOf(t);return-1===r&&(r=Number.MAX_VALUE),n<r?-1:n>r?1:0}),sortOrder:r.map(V)}),f=c.fields,l=Xe(s,f,c.sortOrder,t,e.use_index),d=Ye(s,l);return{queryOpts:d.queryOpts,index:l,inMemoryFields:ze(d.inMemoryFields,l,s,f)}}function Qe(e,t,n){var r,i;return t.selector&&(t.selector=function(e){var t=m(e),n=!1;"$and"in t&&(t=K(t.$and),n=!0),["$or","$nor"].forEach(function(e){e in t&&t[e].forEach(function(e){for(var t=Object.keys(e),n=0;n<t.length;n++){var r=t[n],i=e[r];"object"==typeof i&&null!==i||(e[r]={$eq:i})}})}),"$not"in t&&(t.$not=K([t.$not]));for(var r=Object.keys(t),i=0;i<r.length;i++){var o=r[i],u=t[o];"object"!=typeof u||null===u?u={$eq:u}:"$ne"in u&&!n&&(u.$ne=[u.$ne]),t[o]=u}return t}(t.selector)),t.sort&&(t.sort=function(e){if(!Array.isArray(e))throw new Error("invalid sort json - should be an array");return e.map(function(e){if("string"==typeof e){var t={};return t[e]="asc",t}return e})}(t.sort)),t.use_index&&(t.use_index=(r=t.use_index,i=[],"string"==typeof r?i.push(r):i=r,i.map(function(e){return e.replace("_design/","")}))),function(e){if("object"!=typeof e.selector)throw new Error("you must provide a selector when you find()")}(t),Ue(e).then(function(r){e.constructor.emit("debug",["find","planning query",t]);var i=He(t,r.indexes);e.constructor.emit("debug",["find","query plan",i]);var o=i.index;!function(e,t){if(t.defaultUsed&&e.sort){var n=e.sort.filter(function(e){return"_id"!==Object.keys(e)[0]}).map(function(e){return Object.keys(e)[0]});if(n.length>0)throw new Error('Cannot sort on field(s) "'+n.join(",")+'" when using the default index')}t.defaultUsed}(t,o);var u,s,a=O({include_docs:!0,reduce:!1},i.queryOpts);return"startkey"in a&&"endkey"in a&&Y(a.startkey,a.endkey)>0?{docs:[]}:(t.sort&&"string"!=typeof t.sort[0]&&"desc"===J(t.sort[0])&&(a.descending=!0,delete(s=m(u=a)).startkey,delete s.endkey,delete s.inclusive_start,delete s.inclusive_end,"endkey"in u&&(s.startkey=u.endkey),"startkey"in u&&(s.endkey=u.startkey),"inclusive_start"in u&&(s.inclusive_end=u.inclusive_start),"inclusive_end"in u&&(s.inclusive_start=u.inclusive_end),a=s),i.inMemoryFields.length||("limit"in t&&(a.limit=t.limit),"skip"in t&&(a.skip=t.skip)),n?l.resolve(i,a):l.resolve().then(function(){if("_all_docs"===o.name)return n=e,(r=m(a)).descending?("endkey"in r&&"string"!=typeof r.endkey&&(r.endkey=""),"startkey"in r&&"string"!=typeof r.startkey&&(r.limit=0)):("startkey"in r&&"string"!=typeof r.startkey&&(r.startkey=""),"endkey"in r&&"string"!=typeof r.endkey&&(r.limit=0)),"key"in r&&"string"!=typeof r.key&&(r.limit=0),n.allDocs(r).then(function(e){return e.rows=e.rows.filter(function(e){return!/^_design\//.test(e.id)}),e});var t,n,r,i=(t=o).ddoc.substring(8)+"/"+t.name;return Ce.query.call(e,i,a)}).then(function(e){!1===a.inclusive_start&&(e.rows=function(e,t,n){for(var r=n.def.fields,i=0,o=e.length;i<o;i++){var u=Ie(e[i].doc,n);if(1===r.length)u=u[0];else for(;u.length>t.length;)u.pop();if(Math.abs(Y(u,t))>0)break}return i>0?e.slice(i):e}(e.rows,a.startkey,o)),i.inMemoryFields.length&&(e.rows=re(e.rows,t,i.inMemoryFields));var n={docs:e.rows.map(function(e){var n=e.doc;return t.fields?function(e,t){for(var n={},r=0,i=t.length;r<i;r++){var o=P(t[r]),u=U(e,o);void 0!==u&&F(n,o,u)}return n}(n,t.fields):n})};return o.defaultUsed&&(n.warning="no matching index found, create an index to optimize query time"),n}))})}var Ze=le(function(e,t){var n,r=m((t=B(t)).index);function i(){return n||(n=_e(JSON.stringify(t)))}t.index=De(t.index),function(e){var t=e.fields.filter(function(e){return"asc"===J(e)});if(0!==t.length&&t.length!==e.fields.length)throw new Error("unsupported mixed sorting")}(t.index);var o=t.name||"idx-"+i(),u=t.ddoc||"idx-"+i(),s="_design/"+u,a=!1,c=!1;return e.constructor.emit("debug",["find","creating index",s]),L(e,s,function(e){return e._rev&&"query"!==e.language&&(a=!0),e.language="query",e.views=e.views||{},!(c=!!e.views[o])&&(e.views[o]={map:{fields:he(t.index.fields)},reduce:"_count",options:{def:r}},e)}).then(function(){if(a)throw new Error('invalid language for ddoc with id "'+s+'" (should be "query")')}).then(function(){var t=u+"/"+o;return Ce.query.call(e,t,{limit:0,reduce:!1}).then(function(){return{id:s,name:o,result:c?"exists":"created"}})})}),et=le(Qe),tt=le(function(e,t){return Qe(e,t,!0).then(function(n){return{dbname:e.name,index:n.index,selector:t.selector,range:{start_key:n.queryOpts.startkey,end_key:n.queryOpts.endkey},opts:{use_index:t.use_index||[],bookmark:"nil",limit:t.limit,skip:t.skip,sort:t.sort||{},fields:t.fields,conflicts:!1,r:[49]},limit:t.limit,skip:t.skip||0,fields:t.fields}})}),nt=le(Ue),rt=le(function(e,t){if(!t.ddoc)throw new Error("you must supply an index.ddoc when deleting");if(!t.name)throw new Error("you must supply an index.name when deleting");var n=t.ddoc,r=t.name;return L(e,n,function(e){return 1===Object.keys(e.views).length&&e.views[r]?{_id:n,_deleted:!0}:(delete e.views[r],e)}).then(function(){return Ce.viewCleanup.apply(e)}).then(function(){return{ok:!0}})}),it={};it.createIndex=_(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to create"));(S(this)?T:Ze)(this,e,t)}),it.find=_(function(e,t){if(void 0===t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to find()"));(S(this)?M:et)(this,e,t)}),it.explain=_(function(e,t){if(void 0===t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to explain()"));(S(this)?C:tt)(this,e,t)}),it.getIndexes=_(function(e){(S(this)?D:nt)(this,e)}),it.deleteIndex=_(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to delete"));(S(this)?I:rt)(this,e,t)}),"undefined"==typeof PouchDB?E("error",'pouchdb-find plugin error: Cannot find global "PouchDB" object! Did you remember to include pouchdb.js?'):PouchDB.plugin(it)}).call(this,e(6),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8}]},{},[13]);
{
"name": "pouchdb",
"version": "6.4.1",
"version": "6.4.2",
"description": "PouchDB is a pocket-sized database",

@@ -32,3 +32,3 @@ "main": "./lib/index.js",

"clone-buffer": "1.0.0",
"debug": "3.0.1",
"debug": "3.1.0",
"double-ended-queue": "2.1.0-0",

@@ -45,6 +45,6 @@ "immediate": "3.0.6",

"readable-stream": "1.0.33",
"request": "2.80.0",
"request": "2.83.0",
"spark-md5": "3.0.0",
"through2": "2.0.3",
"uuid": "^3.1.0",
"uuid": "3.2.1",
"vuvuzela": "1.0.3"

@@ -51,0 +51,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc