!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.pouchdbFind=e()}}(function(){var e;return function t(e,n,r){function o(u,a){if(!n[u]){if(!e[u]){var c="function"==typeof require&&require;if(!a&&c)return c(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var f=n[u]={exports:{}};e[u][0].call(f.exports,function(t){var n=e[u][1][t];return o(n?n:t)},f,f.exports,t,e,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u0?e.slice(n):e}function s(e){var t=e.value,n=t&&"object"==typeof t&&t._id||e.id;return n}function f(e,t){try{e.emit("error",t)}catch(n){console.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."),console.error(t)}}function l(e,t,n){try{return{output:t.apply(null,n)}}catch(r){return f(e,r),{error:r}}}function d(e,t){var n=e.descending?"endkey":"startkey",o=e.descending?"startkey":"endkey";if("undefined"!=typeof e[n]&&"undefined"!=typeof e[o]&&m(e[n],e[o])>0)throw new r("No rows can match your key range, reverse your start_key and end_key or set {descending : true}");if(t.reduce&&e.reduce!==!1){if(e.include_docs)throw new r("{include_docs:true} is invalid for reduce");if(e.keys&&e.keys.length>1&&!e.group&&!e.group_level)throw new r("Multi-key fetches for reduce views must use {group: true}")}if(e.group_level){if("number"!=typeof e.group_level)throw new r('Invalid value for integer: "'+e.group_level+'"');if(e.group_level<0)throw new r('Invalid value for positive integer: "'+e.group_level+'"')}}function h(e){return function(t){if(404===t.status)return e;throw t}}function p(e){function t(e,t,n){function r(){return u(l)?x.resolve(c):t.db.get(a)["catch"](h(c))}function o(e){return e.keys.length?t.db.allDocs({keys:e.keys,include_docs:!0}):x.resolve({rows:[]})}function i(e,t){for(var n=[],r={},o=0,i=t.rows.length;i>o;o++){var u=t.rows[o],a=u.doc;if(a&&(n.push(a),r[a._id]=!0,a._deleted=!f[a._id],!a._deleted)){var c=f[a._id];"value"in c&&(a.value=c.value)}}var s=Object.keys(f);return s.forEach(function(e){if(!r[e]){var t={_id:e},o=f[e];"value"in o&&(t.value=o.value),n.push(t)}}),e.keys=_.uniq(s.concat(e.keys)),n.push(e),n}var a="_local/doc_"+e,c={_id:a,keys:[]},s=n[e],f=s.indexableKeysToKeyValues,l=s.changes;return r().then(function(e){return o(e).then(function(t){return i(e,t)})})}function r(e,n,r){var o="_local/lastSeq";return e.db.get(o)["catch"](h({_id:o,seq:0})).then(function(o){var i=Object.keys(n);return x.all(i.map(function(r){return t(r,e,n)})).then(function(t){var n=_.flatten(t);return o.seq=r,n.push(o),e.db.bulkDocs({docs:n})})})}function f(e){var t="string"==typeof e?e:e.name,n=$[t];return n||(n=$[t]=new g),n}function p(e){return _.sequentialize(f(e),function(){return y(e)})()}function y(e){function t(e,t){var n={id:i._id,key:w(e)};"undefined"!=typeof t&&null!==t&&(n.value=w(t)),o.push(n)}function n(t,n){return function(){return r(e,t,n)}}var o,i,u=D(e.mapFun,t),c=e.seq||0,s=new g;return new x(function(t,r){function f(){s.finish().then(function(){e.seq=c,t()})}function d(){function t(e){r(e)}e.sourceDB.changes({conflicts:!0,include_docs:!0,style:"all_docs",since:c,limit:O}).on("complete",function(t){var r=t.results;if(!r.length)return f();for(var h={},p=0,y=r.length;y>p;p++){var v=r[p];if("_"!==v.doc._id[0]){o=[],i=v.doc,i._deleted||l(e.sourceDB,u,[i]),o.sort(a);for(var g,w={},k=0,_=o.length;_>k;k++){var x=o[k],$=[x.key,x.id];0===m(x.key,g)&&$.push(k);var j=b($);w[j]=x,g=x.key}h[v.doc._id]={indexableKeysToKeyValues:w,changes:v.changes}}c=v.seq}return s.add(n(h,c)),r.lengthu?n.slice(0,u):n),t&&0===m(t.key[0][0],n)?(t.key.push([n,e.id]),void t.value.push(e.value)):void i.push({key:[[n,e.id]],value:[e.value]})});for(var a=0,s=i.length;s>a;a++){var f=i[a],d=l(e.sourceDB,o,[f.key,f.value,!1]);if(d.error&&/BuiltInError/.test(d.error.constructor))throw d.error;f.value=d.error?null:d.output,f.key=f.key[0][0]}return{rows:c(i,n.limit,n.skip)}}function E(e,t){return _.sequentialize(f(e),function(){return q(e,t)})()}function q(e,t){function n(t){return t.include_docs=!0,e.db.allDocs(t).then(function(e){return o=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(!(n>t||t>n))return e.doc.value}var r=v.parseIndexableString(e.doc._id);return{key:r[0],id:r[1],value:"value"in e.doc?e.doc.value:null}})})}function r(n){var r;if(r=i?A(e,n,t):{total_rows:o,offset:u,rows:n},t.include_docs){var a=_.uniq(n.map(s));return e.sourceDB.allDocs({keys:a,include_docs:!0,conflicts:t.conflicts,attachments:t.attachments,binary:t.binary}).then(function(e){var t={};return e.rows.forEach(function(e){e.doc&&(t["$"+e.id]=e.doc)}),n.forEach(function(e){var n=s(e),r=t["$"+n];r&&(e.doc=r)}),r})}return r}var o,i=e.reduceFun&&t.reduce!==!1,u=t.skip||0;"undefined"==typeof t.keys||t.keys.length||(t.limit=0,delete t.keys);var a=function(e){return e.reduce(function(e,t){return e.concat(t)})};if("undefined"!=typeof t.keys){var c=t.keys,f=c.map(function(e){var t={startkey:b([e]),endkey:b([e,{}])};return n(t)});return x.all(f).then(a).then(r)}var l={descending:t.descending};if("undefined"!=typeof t.startkey&&(l.startkey=b(t.descending?[t.startkey,{}]:[t.startkey])),"undefined"!=typeof t.endkey){var d=t.inclusive_end!==!1;t.descending&&(d=!d),l.endkey=b(d?[t.endkey,{}]:[t.endkey])}if("undefined"!=typeof t.key){var h=b([t.key]),p=b([t.key,{}]);l.descending?(l.endkey=h,l.startkey=p):(l.startkey=h,l.endkey=p)}return i||("number"==typeof t.limit&&(l.limit=t.limit),l.skip=u),n(l).then(r)}function F(e){return e.get("_local/"+S).then(function(t){var n={};Object.keys(t.views).forEach(function(e){var t=i(e),r="_design/"+t[0],o=t[1];n[r]=n[r]||{},n[r][o]=!0});var r={keys:Object.keys(n),include_docs:!0};return e.allDocs(r).then(function(r){var o={};r.rows.forEach(function(e){var r=e.key.substring(8);Object.keys(n[e.key]).forEach(function(n){var i=r+"/"+n;t.views[i]||(i=n);var u=Object.keys(t.views[i]),a=e.doc&&e.doc.views&&e.doc.views[n];u.forEach(function(e){o[e]=o[e]||a})})});var i=Object.keys(o).filter(function(e){return!o[e]}),u=i.map(function(t){return _.sequentialize(f(t),function(){return new e.constructor(t,e.__opts).destroy()})()});return x.all(u).then(function(){return{ok:!0}})})},h({ok:!0}))}function I(e,t,r){if("string"!=typeof t){d(r,t);var u={db:e,viewName:"temp_view/temp_view",map:t.map,reduce:t.reduce,temporary:!0,pluginName:S};return j.add(function(){return k(u).then(function(e){function t(){return e.db.destroy()}return _.fin(p(e).then(function(){return E(e,r)}),t)})}),j.finish()}var a=t,c=i(a),s=c[0],f=c[1];return e.get("_design/"+s).then(function(t){var i=t.views&&t.views[f];if(!i)throw new o("ddoc "+t._id+" has no view named "+f);C(t,f),d(r,i);var u={db:e,viewName:a,map:i.map,reduce:i.reduce,pluginName:S};return k(u).then(function(e){return"ok"===r.stale||"update_after"===r.stale?("update_after"===r.stale&&n.nextTick(function(){p(e)}),E(e,r)):p(e).then(function(){return E(e,r)})})})}var S=e.name,D=e.mapper,M=e.reducer,C=e.ddocValidator,T=function(e,t,n){var r=this;"function"==typeof t&&(n=t,t={}),t=_.extend(!0,{},t),"function"==typeof e&&(e={map:e});var o=x.resolve().then(function(){return I(r,e,t)});return _.promisedCallback(o,n),o},B=_.callbackify(function(){var e=this;return F(e)});return{query:T,viewCleanup:B}}var y,v=e(26),g=e(3),m=v.collate,b=v.toIndexableString,w=v.normalizeKey,k=e(1);y="undefined"!=typeof console&&"function"==typeof console.log?Function.prototype.bind.call(console.log,console):function(){};var _=e(5),x=_.Promise,$={},j=new g,O=50;_.inherits(r,Error),_.inherits(o,Error),t.exports=p}).call(this,e(34))},{1:1,26:26,3:3,34:34,5:5}],3:[function(e,t,n){"use strict";function r(){this.promise=new o(function(e){e()})}var o=e(5).Promise;r.prototype.add=function(e){return this.promise=this.promise["catch"](function(){}).then(function(){return e()}),this.promise},r.prototype.finish=function(){return this.promise},t.exports=r},{5:5}],4:[function(e,t,n){"use strict";var r=e(31).upsert;t.exports=function(e,t,n){return r.apply(e,[t,n])}},{31:31}],5:[function(e,t,n){(function(t){"use strict";n.Promise=e(29),n.inherits=e(23),n.extend=e(28);var r=e(18);n.promisedCallback=function(e,n){return n&&e.then(function(e){t.nextTick(function(){n(null,e)})},function(e){t.nextTick(function(){n(e)})}),e},n.callbackify=function(e){return r(function(t){var r=t.pop(),o=e.apply(this,t);return"function"==typeof r&&n.promisedCallback(o,r),o})},n.fin=function(e,t){return e.then(function(e){var n=t();return"function"==typeof n.then?n.then(function(){return e}):e},function(e){var n=t();if("function"==typeof n.then)return n.then(function(){throw e});throw e})},n.sequentialize=function(e,t){return function(){var n=arguments,r=this;return e.add(function(){return t.apply(r,n)})}},n.flatten=function(e){for(var t=[],n=0,r=e.length;r>n;n++)t=t.concat(e[n]);return t},n.uniq=function(e){for(var t={},n=0,r=e.length;r>n;n++)t["$"+e[n]]=!0;var o=Object.keys(t),i=new Array(o.length);for(n=0,r=o.length;r>n;n++)i[n]=o[n].substring(1);return i};var o=e(19),i=e(35);n.MD5=function(e){return t.browser?i.hash(e):o.createHash("md5").update(e).digest("hex")}}).call(this,e(34))},{18:18,19:19,23:23,28:28,29:29,34:34,35:35}],6:[function(e,t,n){"use strict";function r(e,t,n){t=a(t),e.request({method:"POST",url:"_index",body:t},n)}function o(e,t,n){e.request({method:"POST",url:"_find",body:t},n)}function i(e,t){e.request({method:"GET",url:"_index"},t)}function u(e,t,n){var r=t.ddoc,o=t.type||"json",i=t.name;if(!r)return n(new Error("you must provide an index's ddoc"));if(!i)return n(new Error("you must provide an index's name"));var u="_index/"+[r,o,i].map(encodeURIComponent).join("/");e.request({method:"DELETE",url:u},n)}var a=e(16);n.createIndex=r,n.find=o,n.getIndexes=i,n.deleteIndex=u},{16:16}],7:[function(e,t,n){"use strict";function r(e,t){return function(n){for(var r=[],o=0,i=e.length;i>o;o++){for(var u=p(e[o]),a=n,c=0,s=u.length;s>c;c++){var f=u[c];if(a=a[f],!a)break}r.push(a)}t(r)}}function o(e,t){var n=p(e);return function(e){for(var r=e,o=0,i=n.length;i>o;o++){var u=n[o];if(r=r[u],!r)return}t(r)}}function i(e,t){return function(n){t(n[e])}}function u(e,t){return function(n){for(var r=[],o=0,i=e.length;i>o;o++)r.push(n[e[o]]);t(r)}}function a(e){for(var t=0,n=e.length;n>t;t++){var r=e[t];if(-1!==r.indexOf("."))return!1}return!0}function c(e,t){var n=a(e),c=1===e.length;return n?c?i(e[0],t):u(e,t):c?o(e[0],t):r(e,t)}function s(e,t){var n=Object.keys(e.fields);return c(n,t)}function f(){throw new Error("reduce not supported")}function l(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?")}var d=e(15),h=e(2),p=d.parseField,y=h({name:"indexes",mapper:s,reducer:f,ddocValidator:l});t.exports=y},{15:15,2:2}],8:[function(e,t,n){"use strict";function r(e,t,n){return a.upsert.call(e,t,n)}function o(e,t){function n(e){return e._rev&&"query"!==e.language&&(y=!0),e.language="query",e.views=e.views||{},(v=!!e.views[s])?!1:(e.views[s]={map:{fields:i.mergeObjects(t.index.fields)},reduce:"_count",options:{def:o}},e)}t=d(t);var o=i.clone(t.index);t.index=l(t.index),f(t.index);var a=i.MD5(JSON.stringify(t)),s=t.name||"idx-"+a,h=t.ddoc||"idx-"+a,p="_design/"+h,y=!1,v=!1;return u("creating index",p),r(e,p,n).then(function(){if(y)throw new Error('invalid language for ddoc with id "'+p+'" (should be "query")')}).then(function(){var t=h+"/"+s;return c.query.call(e,t,{limit:0,reduce:!1}).then(function(){return{id:p,name:s,result:v?"exists":"created"}})})}var i=e(17),u=i.log,a=e(31),c=e(7),s=e(15),f=s.validateIndex,l=s.massageIndexDef,d=e(16);t.exports=o},{15:15,16:16,17:17,31:31,7:7}],9:[function(e,t,n){"use strict";function r(e,t){function n(e){return 1===Object.keys(e.views).length&&e.views[u]?{_id:r,_deleted:!0}:(delete e.views[u],e)}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 r=t.ddoc,u=t.name;return i(e,r,n).then(function(){return o.viewCleanup.apply(e)}).then(function(){return{ok:!0}})}var o=e(7),i=e(4);t.exports=r},{4:4,7:7}],10:[function(e,t,n){"use strict";function r(e){function t(t){return e.map(function(e){var n=k(e),r=x(n),o=j(t,r);return o})}return function(e,n){var r=t(e.doc),o=t(n.doc),i=m(r,o);return 0!==i?i:$.compare(e.doc._id,n.doc._id)}}function o(e,t,n){if(e=e.filter(function(e){return i(e.doc,t.selector,n)}),t.sort){var o=r(t.sort);e=e.sort(o),"string"!=typeof t.sort[0]&&"desc"===_(t.sort[0])&&(e=e.reverse())}if("limit"in t||"skip"in t){var u=t.skip||0,a=("limit"in t?t.limit:e.length)+u;e=e.slice(u,a)}return e}function i(e,t,n){return n.every(function(n){var r=t[n],o=x(n),i=j(e,o);return w(n)?a(n,r,e):u(r,e,o,i)})}function u(e,t,n,r){return e?Object.keys(e).every(function(o){var i=e[o];return c(o,t,i,n,r)}):!0}function a(e,t,n){return"$or"===e?t.some(function(e){return i(n,e,Object.keys(e))}):"$not"===e?!i(n,t,Object.keys(t)):!t.find(function(e){return i(n,e,Object.keys(e))})}function c(e,t,n,r,o){if(!O[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 or $all');return O[e](t,n,r,o)}function s(e){return"undefined"!=typeof e&&null!==e}function f(e){return"undefined"!=typeof e}function l(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?!1:e%n===r}function d(e,t){return t.some(function(t){return e instanceof Array?e.indexOf(t)>-1:e===t})}function h(e,t){return t.every(function(t){return e.indexOf(t)>-1})}function p(e,t){return e.length===t}function y(e,t){var n=new RegExp(t);return n.test(e)}function v(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.")}var g=e(24),m=e(26).collate,b=e(15),w=b.isCombinationalField,k=b.getKey,_=b.getValue,x=b.parseField,$=e(17),j=$.getFieldFromDoc,O={$elemMatch:function(e,t,n,r){return g(r)?0===r.length?!1:"object"==typeof r[0]?r.some(function(e){return i(e,t,Object.keys(t))}):r.some(function(r){return u(t,e,n,r)}):!1},$eq:function(e,t,n,r){return f(r)&&0===m(r,t)},$gte:function(e,t,n,r){return f(r)&&m(r,t)>=0},$gt:function(e,t,n,r){return f(r)&&m(r,t)>0},$lte:function(e,t,n,r){return f(r)&&m(r,t)<=0},$lt:function(e,t,n,r){return f(r)&&m(r,t)<0},$exists:function(e,t,n,r){return t?f(r):!f(r)},$mod:function(e,t,n,r){return s(r)&&l(r,t)},$ne:function(e,t,n,r){return t.every(function(e){return 0!==m(r,e)})},$in:function(e,t,n,r){return s(r)&&d(r,t)},$nin:function(e,t,n,r){return s(r)&&!d(r,t)},$size:function(e,t,n,r){return s(r)&&p(r,t)},$all:function(e,t,n,r){return g(r)&&h(r,t)},$regex:function(e,t,n,r){return s(r)&&y(r,t)},$type:function(e,t,n,r){return v(r,t)}};t.exports=o},{15:15,17:17,24:24,26:26}],11:[function(e,t,n){"use strict";function r(e){return e.ddoc.substring(8)+"/"+e.name}function o(e,t){var n=a(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)}function i(e,t){return t.selector&&(t.selector=p(t.selector)),t.sort&&(t.sort=y(t.sort)),g(t),c(e).then(function(n){var i=l(t,n.indexes),a=i.index;m(t,a);var c=u.extend(!0,{include_docs:!0,reduce:!1},i.queryOpts);if("startkey"in c&&"endkey"in c&&s(c.startkey,c.endkey)>0)return{docs:[]};var d=t.sort&&"string"!=typeof t.sort[0]&&"desc"===v(t.sort[0]);return d&&(c.descending=!0,c=b(c)),i.inMemoryFields.length||("limit"in t&&(c.limit=t.limit),"skip"in t&&(c.skip=t.skip)),k.resolve().then(function(){if("_all_docs"===a.name)return o(e,c);var t=r(a);return f.query.call(e,t,c)}).then(function(e){c.inclusive_start===!1&&(e.rows=w(e.rows,c.startkey,a)),i.inMemoryFields.length&&(e.rows=h(e.rows,t,i.inMemoryFields));var n={docs:e.rows.map(function(e){var n=e.doc;return t.fields?u.pick(n,t.fields):n})};return a.defaultUsed&&(n.warning="no matching index found, create an index to optimize query time"),n})})}var u=e(17),a=u.clone,c=e(13),s=e(26).collate,f=e(7),l=e(12),d=e(15),h=e(10),p=d.massageSelector,y=d.massageSort,v=d.getValue,g=d.validateFindRequest,m=d.validateSort,b=d.reverseOptions,w=d.filterInclusiveStart,k=u.Promise;t.exports=i},{10:10,12:12,13:13,15:15,17:17,26:26,7:7}],12:[function(e,t,n){"use strict";function r(e,t){for(var n=e.def.fields.map(j),r=0,o=n.length;o>r;r++){var i=n[r];if(t===i)return!0}return!1}function o(e,t){var n=e[t],r=j(n);return"$eq"!==r}function i(e,t){var n=t.def.fields.map(j);return e.slice().sort(function(e,t){var r=n.indexOf(e),o=n.indexOf(t);return-1===r&&(r=Number.MAX_VALUE),-1===o&&(o=Number.MAX_VALUE),_.compare(r,o)})}function u(e,t,n){n=i(n,e);for(var u=!1,a=0,c=n.length;c>a;a++){var s=n[a];if(u||!r(e,s))return n.slice(a);c-1>a&&o(t,s)&&(u=!0)}return[]}function a(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}function c(e,t,n,r){var o=_.flatten(e,u(t,n,r),a(n));return i(_.uniq(o),t)}function s(e,t,n){if(t){var r=_.oneArrayIsStrictSubArrayOfOther(t,e),o=_.oneArrayIsSubArrayOfOther(n,e);return r&&o}return _.oneSetIsSubArrayOfOther(n,e)}function f(e){return-1===q.indexOf(e)}function l(e,t){var n=e[0],r=t[n],o=Object.keys(r).some(function(e){return!f(e)});if(!o)return!1;var i=1===Object.keys(r).length&&"$ne"===j(r);return!i}function d(e,t,n,r){var o=e.def.fields.map(j),i=s(o,t,n);return i?l(o,r):!1}function h(e,t,n,r){return r.reduce(function(r,o){var i=d(o,n,t,e);return i&&r.push(o),r},[])}function p(e,t,n,r){function o(e){for(var t=e.def.fields.map(j),n=0,r=0,o=t.length;o>r;r++){var i=t[r];a[i]&&n++}return n}var i=h(e,t,n,r);if(0===i.length){var u=r[0];return u.defaultUsed=!0,u}if(1===i.length)return i[0];var a=_.arrayToObject(t);return _.max(i,o)}function y(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}}}function v(e,t){var n,r=j(t.def.fields[0]),o=e[r],i=[],u=Object.keys(o);return u.forEach(function(e){if(f(e))return void i.push(r);var t=o[e],u=y(e,t);n=n?_.mergeObjects([n,u]):u}),{queryOpts:n,inMemoryFields:i}}function g(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 m(e,t){function n(e){r!==!1&&a.push(A),o!==!1&&c.push(E),u=i.slice(e)}for(var r,o,i=t.def.fields.map(j),u=[],a=[],c=[],s=0,f=i.length;f>s;s++){var l=i[s],d=e[l];if(!d){n(s);break}if(s>0){if("$ne"in d){n(s);break}var h="$gt"in d||"$gte"in d||"$lt"in d||"$lte"in d,p=Object.keys(e[i[s-1]]),y=_.arrayEquals(p,["$eq"]),v=_.arrayEquals(p,Object.keys(d)),m=h&&!y&&!v;if(m){n(s);break}}for(var b=Object.keys(d),w=null,k=0;k-1}function a(e,t,n){"undefined"==typeof n.$eq&&("undefined"!=typeof n.$gte?"$gte"===e?t>n.$gte&&(n.$gte=t):t>=n.$gte&&(delete n.$gte,n.$gt=t):"undefined"!=typeof n.$gt?"$gte"===e?t>n.$gt&&(delete n.$gt,n.$gte=t):t>n.$gt&&(n.$gt=t):n[e]=t)}function c(e,t,n){"undefined"==typeof n.$eq&&("undefined"!=typeof n.$lte?"$lte"===e?to;o++){var u=e[o],a=p(u.doc,n);if(1===r.length)a=a[0];else for(;a.length>t.length;)a.pop();if(Math.abs(_.collate(a,t))>0)break}return o>0?e.slice(o):e}function v(e){var t=k.clone(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}function g(e){var t=e.fields.filter(function(e){return"asc"===o(e)});if(0!==t.length&&t.length!==e.fields.length)throw new Error("unsupported mixed sorting")}function m(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}function b(e){if("object"!=typeof e.selector)throw new Error("you must provide a selector when you find()")}function w(e,t){var n,o=Object.keys(e),i=t?t.map(r):[];return n=o.length>=i.length?o: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),r>n?-1:n>r?1:0}),{fields:n,sortOrder:t.map(r)})}var k=e(17),_=e(26),x=["$or","$nor","$not"];t.exports={getKey:r,getValue:o,massageSort:i,massageSelector:d,validateIndex:g,validateFindRequest:b,validateSort:m,reverseOptions:v,filterInclusiveStart:y,massageIndexDef:h,parseField:k.parseField,getUserFields:w,isCombinationalField:u}},{17:17,26:26}],16:[function(e,t,n){"use strict";var r=e(17),o=r.clone;t.exports=function(e){return e=o(e),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}},{17:17}],17:[function(e,t,n){(function(t){"use strict";var r=e(29);n.once=function(e){var t=!1;return n.getArguments(function(n){if(t)throw console.trace(),new Error("once called more than once");t=!0,e.apply(this,n)})},n.getArguments=function(e){return function(){for(var t=arguments.length,n=new Array(t),r=-1;++rr;r++){var i=e[r];Array.isArray(i)?t=t.concat(n.flatten.apply(null,i)):t.push(i)}return t}),n.mergeObjects=function(e){for(var t={},r=0,o=e.length;o>r;r++)t=n.extend(!0,t,e[r]);return t},n.getFieldFromDoc=function(e,t){for(var n=e,r=0,o=t.length;o>r;r++){var i=t[r];if(n=n[i],!n)break}return n},n.setFieldInDoc=function(e,t,n){for(var r=0,o=t.length;o-1>r;r++){var i=t[r];e=e[i]={}}e[t[o-1]]=n},n.parseField=function(e){for(var t=[],n="",r=0,o=e.length;o>r;r++){var i=e[r];"."===i?r>0&&"\\"===e[r-1]?n=n.substring(0,n.length-1)+".":(t.push(n),n=""):n+=i}return t.push(n),t},n.pick=function(e,t){for(var r={},o=0,i=t.length;i>o;o++){var u=n.parseField(t[o]),a=n.getFieldFromDoc(e,u);"undefined"!=typeof a&&n.setFieldInDoc(r,u,a)}return r},n.oneArrayIsSubArrayOfOther=function(e,t){for(var n=0,r=Math.min(e.length,t.length);r>n;n++)if(e[n]!==t[n])return!1;return!0},n.oneArrayIsStrictSubArrayOfOther=function(e,t){return e.length>t.length?!1:n.oneArrayIsSubArrayOfOther(e,t)},n.oneSetIsSubArrayOfOther=function(e,t){e=e.slice();for(var n=0,r=t.length;r>n;n++){var o=t[n];if(!e.length)break;var i=e.indexOf(o);if(-1===i)return!1;e.splice(i,1)}return!0},n.compare=function(e,t){return t>e?-1:e>t?1:0},n.arrayToObject=function(e){for(var t={},n=0,r=e.length;r>n;n++)t[e[n]]=!0;return t},n.max=function(e,t){for(var n=null,r=-1,o=0,i=e.length;i>o;o++){var u=e[o],a=t(u);a>r&&(r=a,n=u)}return n},n.arrayEquals=function(e,t){if(e.length!==t.length)return!1;for(var n=0,r=e.length;r>n;n++)if(e[n]!==t[n])return!1;return!0},n.uniq=function(e){for(var t={},n=0;n=31}function o(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var o=0,i=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,r),e}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function u(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(t){}}function a(){var e;try{e=n.storage.debug}catch(t){}return e}function c(){try{return window.localStorage}catch(e){}}n=t.exports=e(21),n.log=i,n.formatArgs=o,n.save=u,n.load=a,n.useColors=r,n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:c(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{21:21}],21:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function o(e){function t(){}function o(){var e=o,t=+new Date,i=t-(s||t);e.diff=i,e.prev=s,e.curr=t,s=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var u=Array.prototype.slice.call(arguments); u[0]=n.coerce(u[0]),"string"!=typeof u[0]&&(u=["%o"].concat(u));var a=0;u[0]=u[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;a++;var o=n.formatters[r];if("function"==typeof o){var i=u[a];t=o.call(e,i),u.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(u=n.formatArgs.apply(e,u));var c=o.log||n.log||console.log.bind(console);c.apply(e,u)}t.enabled=!1,o.enabled=!0;var i=n.enabled(e)?o:t;return i.namespace=e,i}function i(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,o=0;r>o;o++)t[o]&&(e=t[o].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function u(){n.enable("")}function a(e){var t,r;for(t=0,r=n.skips.length;r>t;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;r>t;t++)if(n.names[t].test(e))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=o,n.coerce=c,n.disable=u,n.enable=i,n.enabled=a,n.humanize=e(25),n.names=[],n.skips=[],n.formatters={};var s,f=0},{25:25}],22:[function(e,t,n){(function(e){"use strict";function n(){f=!0;for(var e,t,n=l.length;n;){for(t=l,l=[],e=-1;++e1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*l;case"days":case"day":case"d":return n*f;case"hours":case"hour":case"hrs":case"hr":case"h":return n*s;case"minutes":case"minute":case"mins":case"min":case"m":return n*c;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}}}function o(e){return e>=f?Math.round(e/f)+"d":e>=s?Math.round(e/s)+"h":e>=c?Math.round(e/c)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return u(e,f,"day")||u(e,s,"hour")||u(e,c,"minute")||u(e,a,"second")||e+" ms"}function u(e,t,n){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var a=1e3,c=60*a,s=60*c,f=24*s,l=365.25*f;t.exports=function(e,t){return t=t||{},"string"==typeof e?r(e):t["long"]?i(e):o(e)}},{}],26:[function(e,t,n){"use strict";function r(e){if(null!==e)switch(typeof e){case"boolean":return e?1:0;case"number":return f(e);case"string":return e.replace(/\u0002/g,"").replace(/\u0001/g,"").replace(/\u0000/g,"");case"object":var t=Array.isArray(e),r=t?e:Object.keys(e),o=-1,i=r.length,u="";if(t)for(;++oo;o++){var i=n.collate(e[o],t[o]);if(0!==i)return i}return e.length===t.length?0:e.length>t.length?1:-1}function a(e,t){return e===t?0:e>t?1:-1}function c(e,t){for(var r=Object.keys(e),o=Object.keys(t),i=Math.min(r.length,o.length),u=0;i>u;u++){var a=n.collate(r[u],o[u]);if(0!==a)return a;if(a=n.collate(e[r[u]],t[o[u]]),0!==a)return a}return r.length===o.length?0:r.length>o.length?1:-1}function s(e){var t=["boolean","number","string","object"],n=t.indexOf(typeof e);return~n?null===e?1:Array.isArray(e)?5:3>n?n+2:n+3:Array.isArray(e)?5:void 0}function f(e){if(0===e)return"1";var t=e.toExponential().split(/e\+?/),n=parseInt(t[1],10),r=0>e,o=r?"0":"2",i=(r?-n:n)-l,u=p.padLeft(i.toString(),"0",d);o+=h+u;var a=Math.abs(parseFloat(t[0]));r&&(a=10-a);var c=a.toFixed(20);return c=c.replace(/\.?0+$/,""),o+=h+c}var l=-324,d=3,h="",p=e(27);n.collate=function(e,t){if(e===t)return 0;e=n.normalizeKey(e),t=n.normalizeKey(t);var r=s(e),o=s(t);if(r-o!==0)return r-o;if(null===e)return 0;switch(typeof e){case"number":return e-t;case"boolean":return e===t?0:t>e?-1:1;case"string":return a(e,t)}return Array.isArray(e)?u(e,t):c(e,t)},n.normalizeKey=function(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 r=e.length;e=new Array(r);for(var o=0;r>o;o++)e[o]=n.normalizeKey(t[o])}else{if(e instanceof Date)return e.toJSON();if(null!==e){e={};for(var i in t)if(t.hasOwnProperty(i)){var u=t[i];"undefined"!=typeof u&&(e[i]=n.normalizeKey(u))}}}}return e},n.toIndexableString=function(e){var t="\x00";return e=n.normalizeKey(e),s(e)+h+r(e)+t},n.parseIndexableString=function(e){for(var t=[],n=[],r=0;;){var u=e[r++];if("\x00"!==u)switch(u){case"1":t.push(null);break;case"2":t.push("1"===e[r]),r++;break;case"3":var a=o(e,r);t.push(a.num),r+=a.length;break;case"4":for(var c="";;){var s=e[r];if("\x00"===s)break;c+=s,r++}c=c.replace(/\u0001\u0001/g,"\x00").replace(/\u0001\u0002/g,"").replace(/\u0002\u0002/g,""),t.push(c);break;case"5":var f={element:[],index:t.length};t.push(f.element),n.push(f);break;case"6":var l={element:{},index:t.length};t.push(l.element),n.push(l);break;default:throw new Error("bad collationIndex or unexpectedly reached end of input: "+u)}else{if(1===t.length)return t.pop();i(t,n)}}}},{27:27}],27:[function(e,t,n){"use strict";function r(e,t,n){for(var r="",o=n-e.length;r.lengthn;n++){if(n===o)return 1;var i=e.charAt(n),u=t.charAt(n);if(i!==u)return u>i?-1:1}return o>r?-1:0},n.intToDecimalForm=function(e){var t=0>e,n="";do{var r=t?-Math.ceil(e%10):Math.floor(e%10);n=r+n,e=t?Math.ceil(e/10):Math.floor(e/10)}while(e);return t&&"0"!==n&&(n="-"+n),n}},{}],28:[function(e,t,n){"use strict";function r(e){return null===e?String(e):"object"==typeof e||"function"==typeof e?s[h.call(e)]||"object":typeof e}function o(e){return null!==e&&e===e.window}function i(e){if(!e||"object"!==r(e)||e.nodeType||o(e))return!1;try{if(e.constructor&&!p.call(e,"constructor")&&!p.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}var n;for(n in e);return void 0===n||p.call(e,n)}function u(e){return"function"===r(e)}function a(){for(var e=[],t=-1,n=arguments.length,r=new Array(n);++th;h++)if(null!=(r=t[h])){l=y(r);for(o in r)if(!(o in Object.prototype)){if(l&&!g.test(o))continue;if(a=d[o],c=r[o],d===c)continue;v&&c&&(i(c)||(s=y(c)))?(s?(s=!1,f=a&&y(a)?a:[]):f=a&&i(a)?a:{},e.push({args:[v,f,c],result:{container:d,key:o}})):void 0!==c&&(y(r)&&u(c)||(d[o]=c))}}n.container[n.key]=d}for(var s={},f=["Boolean","Number","String","Function","Array","Date","RegExp","Object","Error"],l=0;l1)for(var n=1;n>>32-i,r)},r=function(e,t,r,o,i,u,a){return n(t&r|~t&o,e,t,i,u,a)},o=function(e,t,r,o,i,u,a){return n(t&o|r&~o,e,t,i,u,a)},i=function(e,t,r,o,i,u,a){return n(t^r^o,e,t,i,u,a)},u=function(e,t,r,o,i,u,a){return n(r^(t|~o),e,t,i,u,a)},a=function(e,n){var a=e[0],c=e[1],s=e[2],f=e[3];a=r(a,c,s,f,n[0],7,-680876936),f=r(f,a,c,s,n[1],12,-389564586),s=r(s,f,a,c,n[2],17,606105819),c=r(c,s,f,a,n[3],22,-1044525330),a=r(a,c,s,f,n[4],7,-176418897),f=r(f,a,c,s,n[5],12,1200080426),s=r(s,f,a,c,n[6],17,-1473231341),c=r(c,s,f,a,n[7],22,-45705983),a=r(a,c,s,f,n[8],7,1770035416),f=r(f,a,c,s,n[9],12,-1958414417),s=r(s,f,a,c,n[10],17,-42063),c=r(c,s,f,a,n[11],22,-1990404162),a=r(a,c,s,f,n[12],7,1804603682),f=r(f,a,c,s,n[13],12,-40341101),s=r(s,f,a,c,n[14],17,-1502002290),c=r(c,s,f,a,n[15],22,1236535329),a=o(a,c,s,f,n[1],5,-165796510),f=o(f,a,c,s,n[6],9,-1069501632),s=o(s,f,a,c,n[11],14,643717713),c=o(c,s,f,a,n[0],20,-373897302),a=o(a,c,s,f,n[5],5,-701558691),f=o(f,a,c,s,n[10],9,38016083),s=o(s,f,a,c,n[15],14,-660478335),c=o(c,s,f,a,n[4],20,-405537848),a=o(a,c,s,f,n[9],5,568446438),f=o(f,a,c,s,n[14],9,-1019803690),s=o(s,f,a,c,n[3],14,-187363961),c=o(c,s,f,a,n[8],20,1163531501),a=o(a,c,s,f,n[13],5,-1444681467),f=o(f,a,c,s,n[2],9,-51403784),s=o(s,f,a,c,n[7],14,1735328473),c=o(c,s,f,a,n[12],20,-1926607734),a=i(a,c,s,f,n[5],4,-378558),f=i(f,a,c,s,n[8],11,-2022574463),s=i(s,f,a,c,n[11],16,1839030562),c=i(c,s,f,a,n[14],23,-35309556),a=i(a,c,s,f,n[1],4,-1530992060),f=i(f,a,c,s,n[4],11,1272893353),s=i(s,f,a,c,n[7],16,-155497632),c=i(c,s,f,a,n[10],23,-1094730640),a=i(a,c,s,f,n[13],4,681279174),f=i(f,a,c,s,n[0],11,-358537222),s=i(s,f,a,c,n[3],16,-722521979),c=i(c,s,f,a,n[6],23,76029189),a=i(a,c,s,f,n[9],4,-640364487),f=i(f,a,c,s,n[12],11,-421815835),s=i(s,f,a,c,n[15],16,530742520),c=i(c,s,f,a,n[2],23,-995338651),a=u(a,c,s,f,n[0],6,-198630844),f=u(f,a,c,s,n[7],10,1126891415),s=u(s,f,a,c,n[14],15,-1416354905),c=u(c,s,f,a,n[5],21,-57434055),a=u(a,c,s,f,n[12],6,1700485571),f=u(f,a,c,s,n[3],10,-1894986606),s=u(s,f,a,c,n[10],15,-1051523),c=u(c,s,f,a,n[1],21,-2054922799),a=u(a,c,s,f,n[8],6,1873313359),f=u(f,a,c,s,n[15],10,-30611744),s=u(s,f,a,c,n[6],15,-1560198380),c=u(c,s,f,a,n[13],21,1309151649),a=u(a,c,s,f,n[4],6,-145523070),f=u(f,a,c,s,n[11],10,-1120210379),s=u(s,f,a,c,n[2],15,718787259),c=u(c,s,f,a,n[9],21,-343485551),e[0]=t(a,e[0]),e[1]=t(c,e[1]),e[2]=t(s,e[2]),e[3]=t(f,e[3])},c=function(e){var t,n=[];for(t=0;64>t;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},s=function(e){var t,n=[];for(t=0;64>t;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n},f=function(e){var t,n,r,o,i,u,s=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;s>=t;t+=64)a(f,c(e.substring(t-64,t)));for(e=e.substring(t-64),n=e.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;n>t;t+=1)r[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(a(f,r),t=0;16>t;t+=1)r[t]=0;return o=8*s,o=o.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),u=parseInt(o[1],16)||0,r[14]=i,r[15]=u,a(f,r),f},l=function(e){var t,n,r,o,i,u,c=e.length,f=[1732584193,-271733879,-1732584194,271733878];for(t=64;c>=t;t+=64)a(f,s(e.subarray(t-64,t)));for(e=c>t-64?e.subarray(t-64):new Uint8Array(0),n=e.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;n>t;t+=1)r[t>>2]|=e[t]<<(t%4<<3);if(r[t>>2]|=128<<(t%4<<3),t>55)for(a(f,r),t=0;16>t;t+=1)r[t]=0;return o=8*c,o=o.toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(o[2],16),u=parseInt(o[1],16)||0,r[14]=i,r[15]=u,a(f,r),f},d=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"],h=function(e){var t,n="";for(t=0;4>t;t+=1)n+=d[e>>8*t+4&15]+d[e>>8*t&15];return n},p=function(e){var t;for(t=0;t>16)+(t>>16)+(n>>16);return r<<16|65535&n}),v.prototype.append=function(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),this.appendBinary(e),this},v.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,n=this._buff.length;for(t=64;n>=t;t+=64)a(this._state,c(this._buff.substring(t-64,t)));return this._buff=this._buff.substr(t-64),this},v.prototype.end=function(e){var t,n,r=this._buff,o=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;o>t;t+=1)i[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(i,o),n=e?this._state:p(this._state),this.reset(),n},v.prototype._finish=function(e,t){var n,r,o,i=t;if(e[i>>2]|=128<<(i%4<<3),i>55)for(a(this._state,e),i=0;16>i;i+=1)e[i]=0;n=8*this._length,n=n.toString(16).match(/(.*?)(.{0,8})$/),r=parseInt(n[2],16),o=parseInt(n[1],16)||0,e[14]=r,e[15]=o,a(this._state,e)},v.prototype.reset=function(){return this._buff="",this._length=0,this._state=[1732584193,-271733879,-1732584194,271733878],this},v.prototype.destroy=function(){delete this._state,delete this._buff,delete this._length},v.hash=function(e,t){/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e)));var n=f(e);return t?n:p(n)},v.hashBinary=function(e,t){var n=f(e);return t?n:p(n)},v.ArrayBuffer=function(){this.reset()},v.ArrayBuffer.prototype.append=function(e){var t,n=this._concatArrayBuffer(this._buff,e),r=n.length;for(this._length+=e.byteLength,t=64;r>=t;t+=64)a(this._state,s(n.subarray(t-64,t)));return this._buff=r>t-64?n.subarray(t-64):new Uint8Array(0),this},v.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,o=r.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;o>t;t+=1)i[t>>2]|=r[t]<<(t%4<<3);return this._finish(i,o),n=e?this._state:p(this._state),this.reset(),n},v.ArrayBuffer.prototype._finish=v.prototype._finish,v.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._state=[1732584193,-271733879,-1732584194,271733878],this},v.ArrayBuffer.prototype.destroy=v.prototype.destroy,v.ArrayBuffer.prototype._concatArrayBuffer=function(e,t){var n=e.length,r=new Uint8Array(n+t.byteLength);return r.set(e),r.set(new Uint8Array(t),n),r},v.ArrayBuffer.hash=function(e,t){var n=l(new Uint8Array(e));return t?n:p(n)},v})},{}],36:[function(e,t,n){"use strict";var r=e(17),o=e(6),i=e(14),u={};u.createIndex=r.toPromise(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to create"));var n="http"===this.type()?o:i;n.createIndex(this,e,t)}),u.find=r.toPromise(function(e,t){if("undefined"==typeof t&&(t=e,e=void 0),"object"!=typeof e)return t(new Error("you must provide search parameters to find()"));var n="http"===this.type()?o:i;n.find(this,e,t)}),u.getIndexes=r.toPromise(function(e){var t="http"===this.type()?o:i;t.getIndexes(this,e)}),u.deleteIndex=r.toPromise(function(e,t){if("object"!=typeof e)return t(new Error("you must provide an index to delete"));var n="http"===this.type()?o:i;n.deleteIndex(this,e,t)}),t.exports=u,"undefined"!=typeof window&&window.PouchDB&&window.PouchDB.plugin(u)},{14:14,17:17,6:6}]},{},[36])(36)});