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