summaryrefslogtreecommitdiff
path: root/ext/lib/dexie.min.js
blob: 62b12442685c9c3ea0505112240902194e9c8755 (plain)
1
2
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Dexie=b()}(this,function(){"use strict";function d(b,c){return"object"!=typeof c?b:(a(c).forEach(function(a){b[a]=c[a]}),b)}function g(a,b){return f.call(a,b)}function h(b,c){"function"==typeof c&&(c=c(e(b))),a(c).forEach(function(a){j(b,a,c[a])})}function j(a,b,c,e){i(a,b,d(c&&g(c,"get")&&"function"==typeof c.get?{get:c.get,set:c.set,configurable:!0}:{value:c,configurable:!0,writable:!0},e))}function k(a){return{from:function(b){return a.prototype=Object.create(b.prototype),j(a.prototype,"constructor",a),{extend:h.bind(null,a.prototype)}}}}function m(a,b){var d,c=l(a,b);return c||(d=e(a))&&m(d,b)}function o(a,b,c){return n.call(a,b,c)}function p(a,b){return b(a)}function q(a){var b=setTimeout(a,1e3);clearTimeout(b)}function r(a){if(!a)throw new Error("Assertion Failed")}function s(a){c.setImmediate?setImmediate(a):setTimeout(a,0)}function t(a,b){return a.reduce(function(a,c,d){var e=b(c,d);return e&&(a[e[0]]=e[1]),a},{})}function u(a,b){return function(){try{a.apply(this,arguments)}catch(a){b(a)}}}function v(a,b,c){try{a.apply(null,c)}catch(a){b&&b(a)}}function w(a,b){if(g(a,b))return a[b];if(!b)return a;if("string"!=typeof b){for(var c=[],d=0,e=b.length;d<e;++d){var f=w(a,b[d]);c.push(f)}return c}var h=b.indexOf(".");if(h!==-1){var i=a[b.substr(0,h)];return void 0===i?void 0:w(i,b.substr(h+1))}}function x(a,b,c){if(a&&void 0!==b&&!("isFrozen"in Object&&Object.isFrozen(a)))if("string"!=typeof b&&"length"in b){r("string"!=typeof c&&"length"in c);for(var d=0,e=b.length;d<e;++d)x(a,b[d],c[d])}else{var f=b.indexOf(".");if(f!==-1){var g=b.substr(0,f),h=b.substr(f+1);if(""===h)void 0===c?delete a[g]:a[g]=c;else{var i=a[g];i||(i=a[g]={}),x(i,h,c)}}else void 0===c?delete a[b]:a[b]=c}}function y(a,b){"string"==typeof b?x(a,b,void 0):"length"in b&&[].map.call(b,function(b){x(a,b,void 0)})}function z(a){var b={};for(var c in a)g(a,c)&&(b[c]=a[c]);return b}function A(a){if(!a||"object"!=typeof a)return a;var c;if(b(a)){c=[];for(var d=0,e=a.length;d<e;++d)c.push(A(a[d]))}else if(a instanceof Date)c=new Date,c.setTime(a.getTime());else{c=a.constructor?Object.create(a.constructor.prototype):{};for(var f in a)g(a,f)&&(c[f]=A(a[f]))}return c}function B(b,c,d,e){return d=d||{},e=e||"",a(b).forEach(function(a){if(g(c,a)){var f=b[a],h=c[a];"object"==typeof f&&"object"==typeof h&&f&&h&&f.constructor===h.constructor?B(f,h,d,e+a+"."):f!==h&&(d[e+a]=c[a])}else d[e+a]=void 0}),a(c).forEach(function(a){g(b,a)||(d[e+a]=c[a])}),d}function F(a){var c,d,e,f;if(1===arguments.length){if(b(a))return a.slice();if(this===E&&"string"==typeof a)return[a];if(f=D(a)){for(d=[];e=f.next(),!e.done;)d.push(e.value);return d}if(null==a)return[a];if(c=a.length,"number"==typeof c){for(d=new Array(c);c--;)d[c]=a[c];return d}return[a]}for(c=arguments.length,d=new Array(c);c--;)d[c]=arguments[c];return d}function H(a){return G.apply([],a)}function J(a,b){I=a,K=b}function M(){if(L)try{throw M.arguments,new Error}catch(a){return a}return new Error}function N(a,b){var c=a.stack;return c?(b=b||0,0===c.indexOf(a.name)&&(b+=(a.name+a.message).split("\n").length),c.split("\n").slice(b).filter(K).map(function(a){return"\n"+a}).join("")):""}function O(a,b){return function(){return console.warn(a+" is deprecated. See https://github.com/dfahlander/Dexie.js/wiki/Deprecations. "+N(M(),1)),b.apply(this,arguments)}}function T(a,b){this._e=M(),this.name=a,this.message=b}function U(a,b){return a+". Errors: "+b.map(function(a){return a.toString()}).filter(function(a,b,c){return c.indexOf(a)===b}).join("\n")}function V(a,b,c,d){this._e=M(),this.failures=b,this.failedKeys=d,this.successCount=c}function W(a,b){this._e=M(),this.name="BulkError",this.failures=b,this.message=U(a,b)}function _(a,b){if(!a||a instanceof T||a instanceof TypeError||a instanceof SyntaxError||!a.name||!$[a.name])return a;var c=new $[a.name](b||a.message,a);return"stack"in a&&j(c,"stack",{get:function(){return this.inner.stack}}),c}function ba(){}function ca(a){return a}function da(a,b){return null==a||a===ca?b:function(c){return b(a(c))}}function ea(a,b){return function(){a.apply(this,arguments),b.apply(this,arguments)}}function fa(a,b){return a===ba?b:function(){var c=a.apply(this,arguments);void 0!==c&&(arguments[0]=c);var d=this.onsuccess,e=this.onerror;this.onsuccess=null,this.onerror=null;var f=b.apply(this,arguments);return d&&(this.onsuccess=this.onsuccess?ea(d,this.onsuccess):d),e&&(this.onerror=this.onerror?ea(e,this.onerror):e),void 0!==f?f:c}}function ga(a,b){return a===ba?b:function(){a.apply(this,arguments);var c=this.onsuccess,d=this.onerror;this.onsuccess=this.onerror=null,b.apply(this,arguments),c&&(this.onsuccess=this.onsuccess?ea(c,this.onsuccess):c),d&&(this.onerror=this.onerror?ea(d,this.onerror):d)}}function ha(a,b){return a===ba?b:function(c){var e=a.apply(this,arguments);d(c,e);var f=this.onsuccess,g=this.onerror;this.onsuccess=null,this.onerror=null;var h=b.apply(this,arguments);return f&&(this.onsuccess=this.onsuccess?ea(f,this.onsuccess):f),g&&(this.onerror=this.onerror?ea(g,this.onerror):g),void 0===e?void 0===h?void 0:h:d(e,h)}}function ia(a,b){return a===ba?b:function(){return b.apply(this,arguments)!==!1&&a.apply(this,arguments)}}function ja(a,b){return a===ba?b:function(){var c=a.apply(this,arguments);if(c&&"function"==typeof c.then){for(var d=this,e=arguments.length,f=new Array(e);e--;)f[e]=arguments[e];return c.then(function(){return b.apply(d,f)})}return b.apply(this,arguments)}}function Ja(a){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ba,this._lib=!1;var b=this._PSD=Fa;if(I&&(this._stackHolder=M(),this._prev=null,this._numPrev=0,Sa(this,Ca)),"function"!=typeof a){if(a!==ka)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Na(this,this._value))}this._state=null,this._value=null,++b.ref,Ma(this,a)}function La(a,b,c,d,e){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.resolve=c,this.reject=d,this.psd=e}function Ma(a,b){try{b(function(b){if(null===a._state){if(b===a)throw new TypeError("A promise cannot be resolved with itself.");var c=a._lib&&Ua();b&&"function"==typeof b.then?Ma(a,function(a,c){b instanceof Ja?b._then(a,c):b.then(a,c)}):(a._state=!0,a._value=b,Oa(a)),c&&Va()}},Na.bind(null,a))}catch(b){Na(a,b)}}function Na(a,b){if(Ba.push(b),null===a._state){var c=a._lib&&Ua();b=Da(b),a._state=!1,a._value=b,I&&null!==b&&"object"==typeof b&&!b._promise&&v(function(){var c=m(b,"stack");b._promise=a,j(b,"stack",{get:function(){return va?c&&(c.get?c.get.apply(b):c.value):a.stack}})}),Ya(a),Oa(a),c&&Va()}}function Oa(a){var b=a._listeners;a._listeners=[];for(var c=0,d=b.length;c<d;++c)Pa(a,b[c]);var e=a._PSD;--e.ref||e.finalize(),0===Ha&&(++Ha,xa(function(){0===--Ha&&Wa()},[]))}function Pa(a,b){if(null===a._state)return void a._listeners.push(b);var c=a._state?b.onFulfilled:b.onRejected;return null===c?(a._state?b.resolve:b.reject)(a._value):(++b.psd.ref,++Ha,void xa(Qa,[c,a,b]))}function Qa(a,b,c){try{Ca=b;var d,e=b._value;b._state?d=a(e):(Ba.length&&(Ba=[]),d=a(e),Ba.indexOf(e)===-1&&Za(b)),c.resolve(d)}catch(a){c.reject(a)}finally{Ca=null,0===--Ha&&Wa(),--c.psd.ref||c.psd.finalize()}}function Ra(a,b,c){if(b.length===c)return b;var d="";if(a._state===!1){var f,g,e=a._value;null!=e?(f=e.name||"Error",g=e.message||e,d=N(e,0)):(f=e,g=""),b.push(f+(g?": "+g:"")+d)}return I&&(d=N(a._stackHolder,2),d&&b.indexOf(d)===-1&&b.push(d),a._prev&&Ra(a._prev,b,c)),b}function Sa(a,b){var c=b?b._numPrev+1:0;c<la&&(a._prev=b,a._numPrev=c)}function Ta(){Ua()&&Va()}function Ua(){var a=ya;return ya=!1,za=!1,a}function Va(){var a,b,c;do for(;Ga.length>0;)for(a=Ga,Ga=[],c=a.length,b=0;b<c;++b){var d=a[b];d[0].apply(null,d[1])}while(Ga.length>0);ya=!0,za=!0}function Wa(){var a=Aa;Aa=[],a.forEach(function(a){a._PSD.onunhandled.call(null,a._value,a)});for(var b=Ia.slice(0),c=b.length;c;)b[--c]()}function Xa(a){function b(){a(),Ia.splice(Ia.indexOf(b),1)}Ia.push(b),++Ha,xa(function(){0===--Ha&&Wa()},[])}function Ya(a){Aa.some(function(b){return b._value===a._value})||Aa.push(a)}function Za(a){for(var b=Aa.length;b;)if(Aa[--b]._value===a._value)return void Aa.splice(b,1)}function $a(a){return new Ja(ka,!1,a)}function _a(a,b){var c=Fa;return function(){var d=Ua(),e=Fa;try{return mb(c,!0),a.apply(this,arguments)}catch(a){b&&b(a)}finally{mb(e,!1),d&&Va()}}}function gb(a,b,c,e){var f=Fa,g=Object.create(f);g.parent=f,g.ref=0,g.global=!1,g.id=++fb;var h=Ea.env;g.env=sa?{Promise:Ja,all:Ja.all,race:Ja.race,resolve:Ja.resolve,reject:Ja.reject,nthen:rb(h.nthen,g),gthen:rb(h.gthen,g)}:{},b&&d(g,b),++f.ref,g.finalize=function(){--this.parent.ref||this.parent.finalize()};var i=ob(g,a,c,e);return 0===g.ref&&g.finalize(),i}function hb(){return ab.id||(ab.id=++bb),++ab.awaits,ab.echoes+=na,ab.id}function ib(a){!ab.awaits||a&&a!==ab.id||(0===--ab.awaits&&(ab.id=0),ab.echoes=ab.awaits*na)}function jb(a){return ab.echoes&&a&&a.constructor===ta?(hb(),a.then(function(a){return ib(),a},function(a){return ib(),ub(a)})):a}function kb(a){++eb,ab.echoes&&0!==--ab.echoes||(ab.echoes=ab.id=0),cb.push(Fa),mb(a,!0)}function lb(){var a=cb[cb.length-1];cb.pop(),mb(a,!1)}function mb(a,b){var d=Fa;if((b?!ab.echoes||db++&&a===Fa:!db||--db&&a===Fa)||pb(b?kb.bind(null,a):lb),a!==Fa){Fa=a,d===Ea&&(Ea.env=nb());var e=Ea.env.Promise;if(e){var f=a.env;qa.then=f.nthen,e.prototype.then=f.gthen,(d.global||a.global)&&(c.Promise=f.Promise,e.all=f.all,e.race=f.race,e.resolve=f.resolve,e.reject=f.reject)}}}function nb(){var a=c.Promise;return a?{Promise:a,all:a.all,race:a.race,resolve:a.resolve,reject:a.reject,nthen:qa.then,gthen:a.prototype.then}:{}}function ob(a,b,c,d,e){var f=Fa;try{return mb(a,!0),b(c,d,e)}finally{mb(f,!1)}}function pb(a){sa.call(pa,a)}function qb(a,b,c){return"function"!=typeof a?a:function(){var d=Fa;c&&hb(),mb(b,!0);try{return a.apply(this,arguments)}finally{mb(d,!1)}}}function rb(a,b){return function(c,d){return a.call(this,qb(c,b,!1),qb(d,b,!1))}}function tb(a,b){var e;try{e=b.onuncatched(a)}catch(a){}if(e!==!1)try{var f,g={promise:b,reason:a};if(c.document&&document.createEvent?(f=document.createEvent("Event"),f.initEvent(sb,!0,!0),d(f,g)):c.CustomEvent&&(f=new CustomEvent(sb,{detail:g}),d(f,g)),f&&c.dispatchEvent&&(dispatchEvent(f),!c.PromiseRejectionEvent&&c.onunhandledrejection))try{c.onunhandledrejection(f)}catch(a){}f.defaultPrevented||console.warn("Unhandled rejection: "+(a.stack||a))}catch(a){}}function vb(c){function h(a,b,c){if("object"==typeof a)return i(a);b||(b=ia),c||(c=ba);var f={subscribers:[],fire:c,subscribe:function(a){f.subscribers.indexOf(a)===-1&&(f.subscribers.push(a),f.fire=b(f.fire,a))},unsubscribe:function(a){f.subscribers=f.subscribers.filter(function(b){return b!==a}),f.fire=f.subscribers.reduce(b,c)}};return d[a]=e[a]=f,f}function i(c){a(c).forEach(function(a){var d=c[a];if(b(d))h(a,c[a][0],c[a][1]);else{if("asap"!==d)throw new Z.InvalidArgument("Invalid event config");var e=h(a,ca,function(){for(var b=arguments.length,c=new Array(b);b--;)c[b]=arguments[b];e.subscribers.forEach(function(a){s(function(){a.apply(null,c)})})})}})}var d={},e=function(a,b){if(b){for(var e=arguments.length,f=new Array(e-1);--e;)f[e-1]=arguments[e];return d[a].subscribe.apply(null,f),c}if("string"==typeof a)return d[a]};e.addEventType=h;for(var f=1,g=arguments.length;f<g;++f)h(arguments[f]);return e}function Gb(c,e){function _(){Q.on("versionchange",function(a){a.newVersion>0?console.warn("Another connection wants to upgrade database '"+Q.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+Q.name+"'. Closing db now to resume the delete request."),Q.close()}),Q.on("blocked",function(a){!a.newVersion||a.newVersion<a.oldVersion?console.warn("Dexie.delete('"+Q.name+"') was blocked"):console.warn("Upgrade '"+Q.name+"' blocked by other connection holding version "+a.oldVersion/10)})}function aa(a){this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function ea(b,c,d){var e=Q._createTransaction(P,C,s);e.create(c),e._completion.catch(d);var f=e._reject.bind(e);gb(function(){Fa.trans=e,0===b?(a(s).forEach(function(a){la(c,a,s[a].primKey,s[a].indexes)}),Ja.follow(function(){return Q.on.populate.fire(e)}).catch(f)):ia(b,e,c).catch(f)})}function ia(a,b,c){function h(){return d.length?Ja.resolve(d.shift()(b.idbtrans)).then(h):Ja.resolve()}var d=[],e=y.filter(function(b){return b._cfg.version===a})[0];if(!e)throw new Z.Upgrade("Dexie specification of currently installed DB version is missing");s=Q._dbSchema=e._cfg.dbschema;var f=!1,g=y.filter(function(b){return b._cfg.version>a});return g.forEach(function(a){d.push(function(){var d=s,e=a._cfg.dbschema;Qa(d,c),Qa(e,c),s=Q._dbSchema=e;var g=ka(d,e);if(g.add.forEach(function(a){la(c,a[0],a[1].primKey,a[1].indexes)}),g.change.forEach(function(a){if(a.recreate)throw new Z.Upgrade("Not yet support for changing primary key");var b=c.objectStore(a.name);a.add.forEach(function(a){oa(b,a)}),a.change.forEach(function(a){b.deleteIndex(a.name),oa(b,a)}),a.del.forEach(function(a){b.deleteIndex(a)})}),a._cfg.contentUpgrade)return f=!0,Ja.follow(function(){a._cfg.contentUpgrade(b)})}),d.push(function(b){if(!f||!Db){var c=a._cfg.dbschema;na(c,b)}})}),h().then(function(){ma(s,c)})}function ka(a,b){var c={del:[],add:[],change:[]};for(var d in a)b[d]||c.del.push(d);for(d in b){var e=a[d],f=b[d];if(e){var g={name:d,def:f,recreate:!1,del:[],add:[],change:[]};if(e.primKey.src!==f.primKey.src)g.recreate=!0,c.change.push(g);else{var h=e.idxByName,i=f.idxByName;for(var j in h)i[j]||g.del.push(j);for(j in i){var k=h[j],l=i[j];k?k.src!==l.src&&g.change.push(l):g.add.push(l)}(g.del.length>0||g.add.length>0||g.change.length>0)&&c.change.push(g)}}else c.add.push([d,f])}return c}function la(a,b,c,d){var e=a.db.createObjectStore(b,c.keyPath?{keyPath:c.keyPath,autoIncrement:c.auto}:{autoIncrement:c.auto});return d.forEach(function(a){oa(e,a)}),e}function ma(b,c){a(b).forEach(function(a){c.db.objectStoreNames.contains(a)||la(c,a,b[a].primKey,b[a].indexes)})}function na(a,b){for(var c=0;c<b.db.objectStoreNames.length;++c){var d=b.db.objectStoreNames[c];null==a[d]&&b.db.deleteObjectStore(d)}}function oa(a,b){a.createIndex(b.name,b.keyPath,{unique:b.unique,multiEntry:b.multi})}function pa(a,b,c){if(L||Fa.letThrough){var d=Q._createTransaction(a,b,s).create();return d._promise(a,function(a,b){return gb(function(){return Fa.trans=d,c(a,b,d)})}).then(function(a){return d._completion.then(function(){return a})})}if(!K){if(!l)return ub(new Z.DatabaseClosed);Q.open().catch(ba)}return S.then(function(){return pa(a,b,c)})}function qa(a,b,c){var d=arguments.length;if(d<2)throw new Z.InvalidArgument("Too few arguments");for(var e=new Array(d-1);--d;)e[d-1]=arguments[d];c=e.pop();var f=H(e);return[a,f,c]}function ra(a,b){this.name=a,this.schema=b,this.hook=D[a]?D[a].hook:vb(null,{creating:[fa,ba],reading:[da,ca],updating:[ha,ba],deleting:[ga,ba]})}function sa(a,b,c){return(c?Ob:Mb)(function(c){a.push(c),b&&b()})}function va(a,b,c,d,e){return new Ja(function(f,g){var h=c.length,i=h-1;if(0===h)return f();if(d){var l,m=Ob(g),n=Lb(null);v(function(){for(var d=0;d<h;++d){l={onsuccess:null,onerror:null};var g=c[d];e.call(l,g[0],g[1],b);var j=a.delete(g[0]);j._hookCtx=l,j.onerror=m,d===i?j.onsuccess=Lb(f):j.onsuccess=n}},function(a){throw l.onerror&&l.onerror(a),a})}else for(var j=0;j<h;++j){var k=a.delete(c[j]);k.onerror=Mb(g),j===i&&(k.onsuccess=_a(function(){return f()}))}})}function wa(a,b,c,d){var e=this;this.db=Q,this.mode=a,this.storeNames=b,this.idbtrans=null,this.on=vb(this,"complete","error","abort"),this.parent=d||null,this.active=!0,this._tables=null,this._reculock=0,this._blockedFuncs=[],this._psd=null,this._dbschema=c,this._resolve=null,this._reject=null,this._completion=new Ja(function(a,b){e._resolve=a,e._reject=b}),this._completion.then(function(){e.on.complete.fire()},function(a){return e.on.error.fire(a),e.parent?e.parent._reject(a):e.active&&e.idbtrans&&e.idbtrans.abort(),e.active=!1,ub(a)})}function xa(a,b,c){this._ctx={table:a,index:":id"===b?null:b,or:c}}function ya(a,b){var c=null,d=null;if(b)try{c=b()}catch(a){d=a}var e=a._ctx,f=e.table;this._ctx={table:f,index:e.index,isPrimKey:!e.index||f.schema.primKey.keyPath&&e.index===f.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:d,or:e.or,valueMapper:f.hook.reading.fire}}function za(a,b){return!(a.filter||a.algorithm||a.or)&&(b?a.justLimit:!a.replayFilter)}function Aa(a,b){return a._cfg.version-b._cfg.version}function Ba(a,b,c){b.forEach(function(b){var d=Q._tableFactory(P,c[b]);a.forEach(function(a){b in a||(a[b]=d)})})}function Ca(a){a.forEach(function(a){for(var b in a)a[b]instanceof ra&&delete a[b]})}function Da(a,b,c,d,e,f){var g=f?function(a,b,d){return c(f(a),b,d)}:c,h=_a(g,e);a.onerror||(a.onerror=Mb(e)),b?a.onsuccess=u(function(){var f=a.result;if(f){var g=function(){f.continue()};b(f,function(a){g=a},d,e)&&h(f.value,f,function(a){g=a}),g()}else d()},e):a.onsuccess=u(function(){var c=a.result;if(c){var e=function(){c.continue()};h(c.value,c,function(a){e=a}),e()}else d()},e)}function Ea(a){var c=[];return a.split(",").forEach(function(a){a=a.trim();var d=a.replace(/([&*]|\+\+)/g,""),e=/^\[/.test(d)?d.match(/^\[(.*)\]$/)[1].split("+"):d;c.push(new Sb(d,e||null,/\&/.test(a),/\*/.test(a),/\+\+/.test(a),b(e),/\./.test(a)))}),c}function Ga(a,b){return m.cmp(a,b)}function Ha(a,b){return Ga(a,b)<0?a:b}function Ia(a,b){return Ga(a,b)>0?a:b}function Ka(a,b){return m.cmp(a,b)}function La(a,b){return m.cmp(b,a)}function Ma(a,b){return a<b?-1:a===b?0:1}function Na(a,b){return a>b?-1:a===b?0:1}function Oa(a,b){return a?b?function(){return a.apply(this,arguments)&&b.apply(this,arguments)}:a:b}function Pa(){if(Q.verno=G.version/10,Q._dbSchema=s={},C=o(G.objectStoreNames,0),0!==C.length){var b=G.transaction(Vb(C),"readonly");C.forEach(function(a){for(var c=b.objectStore(a),d=c.keyPath,e=d&&"string"==typeof d&&d.indexOf(".")!==-1,f=new Sb(d,d||"",!1,!1,!!c.autoIncrement,d&&"string"!=typeof d,e),g=[],h=0;h<c.indexNames.length;++h){var i=c.index(c.indexNames[h]);d=i.keyPath,e=d&&"string"==typeof d&&d.indexOf(".")!==-1;var j=new Sb(i.name,d,!!i.unique,!!i.multiEntry,!1,d&&"string"!=typeof d,e);g.push(j)}s[a]=new Tb(a,f,g,{})}),Ba([D],a(s),s)}}function Qa(a,b){for(var c=b.db.objectStoreNames,d=0;d<c.length;++d){var e=c[d],f=b.objectStore(e);$="getAll"in f;for(var g=0;g<f.indexNames.length;++g){var h=f.indexNames[g],i=f.index(h).keyPath,j="string"==typeof i?i:"["+o(i).join("+")+"]";if(a[e]){var k=a[e].idxByName[j];k&&(k.name=h)}}}}function Ra(a){Q.on("blocked").fire(a),Bb.filter(function(a){return a.name===Q.name&&a!==Q&&!a._vcFired}).map(function(b){return b.on("versionchange").fire(a)})}var R,T,$,f=Gb.dependencies,i=d({addons:Gb.addons,autoOpen:!0,indexedDB:f.indexedDB,IDBKeyRange:f.IDBKeyRange},e),k=i.addons,l=i.autoOpen,m=i.indexedDB,n=i.IDBKeyRange,s=this._dbSchema={},y=[],C=[],D={},G=null,J=null,K=!1,L=!1,N="readonly",P="readwrite",Q=this,S=new Ja(function(a){R=a}),U=new Ja(function(a,b){T=b}),X=!0,Y=!!Wb(m);this.version=function(a){if(G||K)throw new Z.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,a);var b=y.filter(function(b){return b._cfg.version===a})[0];return b?b:(b=new aa(a),y.push(b),y.sort(Aa),b)},d(aa.prototype,{stores:function(b){this._cfg.storesSource=this._cfg.storesSource?d(this._cfg.storesSource,b):b;var c={};y.forEach(function(a){d(c,a._cfg.storesSource)});var e=this._cfg.dbschema={};return this._parseStoresSpec(c,e),s=Q._dbSchema=e,Ca([D,Q,wa.prototype]),Ba([D,Q,wa.prototype,this._cfg.tables],a(e),e),C=a(e),this},upgrade:function(b){var c=this;return Hb(function(){b(Q._createTransaction(P,a(c._cfg.dbschema),c._cfg.dbschema))}),this._cfg.contentUpgrade=b,this},_parseStoresSpec:function(b,c){a(b).forEach(function(a){if(null!==b[a]){var d={},e=Ea(b[a]),f=e.shift();if(f.multi)throw new Z.Schema("Primary key cannot be multi-valued");f.keyPath&&x(d,f.keyPath,f.auto?0:f.keyPath),e.forEach(function(a){if(a.auto)throw new Z.Schema("Only primary key can be marked as autoIncrement (++)");if(!a.keyPath)throw new Z.Schema("Index must have a name and cannot be an empty string");x(d,a.keyPath,a.compound?a.keyPath.map(function(){return""}):"")}),c[a]=new Tb(a,f,e,d)}})}}),this._allTables=D,this._tableFactory=function(b,c){return new ra(c.name,c)},this._createTransaction=function(a,b,c,d){return new wa(a,b,c,d)},this._whenReady=function(a){return new Ja(Ib||L||Fa.letThrough?a:function(b,c){if(!K){if(!l)return void c(new Z.DatabaseClosed);Q.open().catch(ba)}S.then(function(){a(b,c)})})},this.verno=0,this.open=function(){if(K||G)return S.then(function(){return J?ub(J):Q});I&&(U._stackHolder=M()),K=!0,J=null,L=!1;var a=R,b=null;return Ja.race([U,new Ja(function(a,d){if(q(function(){return a()}),y.length>0&&(X=!1),!m)throw new Z.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var e=X?m.open(c):m.open(c,Math.round(10*Q.verno));if(!e)throw new Z.MissingAPI("IndexedDB API not available");e.onerror=Mb(d),e.onblocked=_a(Ra),e.onupgradeneeded=_a(function(a){if(b=e.transaction,X&&!Q._allowEmptyDB){e.onerror=Pb,b.abort(),e.result.close();var f=m.deleteDatabase(c);f.onsuccess=f.onerror=_a(function(){d(new Z.NoSuchDatabase("Database "+c+" doesnt exist"))})}else{b.onerror=Mb(d);var g=a.oldVersion>Math.pow(2,62)?0:a.oldVersion;ea(g/10,b,d,e)}},d),e.onsuccess=_a(function(){if(b=null,G=e.result,Bb.push(Q),X)Pa();else if(G.objectStoreNames.length>0)try{Qa(s,G.transaction(Vb(G.objectStoreNames),N))}catch(a){}G.onversionchange=_a(function(a){Q._vcFired=!0,Q.on("versionchange").fire(a)}),Y||Qb(function(a){if(a.indexOf(c)===-1)return a.push(c)}),a()},d)})]).then(function(){return Gb.vip(Q.on.ready.fire)}).then(function(){return K=!1,Q}).catch(function(a){try{b&&b.abort()}catch(a){}return K=!1,Q.close(),J=a,ub(J)}).finally(function(){L=!0,a()})},this.close=function(){var a=Bb.indexOf(Q);if(a>=0&&Bb.splice(a,1),G){try{G.close()}catch(a){}G=null}l=!1,J=new Z.DatabaseClosed,K&&T(J),S=new Ja(function(a){R=a}),U=new Ja(function(a,b){T=b})},this.delete=function(){var a=arguments.length>0;return new Ja(function(b,d){function e(){Q.close();var a=m.deleteDatabase(c);a.onsuccess=_a(function(){Y||Qb(function(a){var b=a.indexOf(c);if(b>=0)return a.splice(b,1)}),b()}),a.onerror=Mb(d),a.onblocked=Ra}if(a)throw new Z.InvalidArgument("Arguments not allowed in db.delete()");K?S.then(e):e()})},this.backendDB=function(){return G},this.isOpen=function(){return null!==G},this.hasFailed=function(){return null!==J},this.dynamicallyOpened=function(){return X},this.name=c,j(this,"tables",{get:function(){return a(D).map(function(a){return D[a]})}}),this.on=vb(this,"populate","blocked","versionchange",{ready:[ja,ba]}),this.on.ready.subscribe=p(this.on.ready.subscribe,function(a){return function(b,c){Gb.vip(function(){L?(J||Ja.resolve().then(b),c&&a(b)):(a(b),c||a(function a(){Q.on.ready.unsubscribe(b),Q.on.ready.unsubscribe(a)}))})}}),Hb(function(){Q.on("populate").fire(Q._createTransaction(P,C,s))}),this.transaction=function(){var a=qa.apply(this,arguments);return this._transaction.apply(this,a)},this._transaction=function(a,b,c){function g(b){var e=Fa;b(Ja.resolve().then(function(){var b=Fa.transless||e,g=Q._createTransaction(a,f,s,d),h={trans:g,transless:b};d?g.idbtrans=d.idbtrans:g.create(),c.constructor===ua&&hb();var i,j=Ja.follow(function(){if(i=c.call(g,g))if(i.constructor===ta){var a=ib.bind(null,null);i.then(a,a)}else"function"==typeof i.next&&"function"==typeof i.throw&&(i=Rb(i))},h);return Ja.resolve(i).finally(function(){if(!g.active)throw new Z.PrematureCommit("Transaction committed too early. See http://bit.ly/2eVASrf")}).then(function(a){return j.then(function(){d&&g._resolve()}).then(function(){return g._completion}).then(function(){return a})}).catch(function(a){return g._reject(a),ub(a)})}))}var d=Fa.trans;d&&d.db===Q&&a.indexOf("!")===-1||(d=null);var e=a.indexOf("?")!==-1;a=a.replace("!","").replace("?","");try{var f=b.map(function(a){var b=a instanceof ra?a.name:a;if("string"!=typeof b)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return b});if("r"==a||a==N)a=N;else{if("rw"!=a&&a!=P)throw new Z.InvalidArgument("Invalid transaction mode: "+a);a=P}if(d){if(d.mode===N&&a===P){if(!e)throw new Z.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");d=null}d&&f.forEach(function(a){if(d&&d.storeNames.indexOf(a)===-1){if(!e)throw new Z.SubTransaction("Table "+a+" not included in parent transaction.");d=null}})}}catch(a){return d?d._promise(null,function(b,c){c(a)}):ub(a)}return d?d._promise(a,g,"lock"):Q._whenReady(g)},this.table=function(a){if(Ib&&X)return new ra(a);if(!g(D,a))throw new Z.InvalidTable("Table "+a+" does not exist");return D[a]},h(ra.prototype,{_trans:function(b,c,d){var e=Fa.trans;return e&&e.db===Q?e._promise(b,c,d):pa(b,[this.name],c)},_idbstore:function(b,c,d){function g(a,b,d){c(a,b,d.idbtrans.objectStore(f),d)}if(Ib)return new Ja(c);var e=Fa.trans,f=this.name;return e&&e.db===Q?e._promise(b,g,d):pa(b,[this.name],g)},get:function(a,b){var c=this;return this._idbstore(N,function(b,d,e){Ib&&b(c.schema.instanceTemplate);var f=e.get(a);f.onerror=Mb(d),f.onsuccess=_a(function(){b(c.hook.reading.fire(f.result))},d)}).then(b)},where:function(a){return new xa(this,a)},count:function(a){return this.toCollection().count(a)},offset:function(a){return this.toCollection().offset(a)},limit:function(a){return this.toCollection().limit(a)},reverse:function(){return this.toCollection().reverse()},filter:function(a){return this.toCollection().and(a)},each:function(a){return this.toCollection().each(a)},toArray:function(a){return this.toCollection().toArray(a)},orderBy:function(a){return new ya(new xa(this,a))},toCollection:function(){return new ya(new xa(this))},mapToClass:function(a,b){this.schema.mappedClass=a;var c=Object.create(a.prototype);b&&Kb(c,b),this.schema.instanceTemplate=c;var d=function(b){if(!b)return b;var c=Object.create(a.prototype);for(var d in b)if(g(b,d))try{c[d]=b[d]}catch(a){}return c};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=d,this.hook("reading",d),a},defineClass:function(a){return this.mapToClass(Gb.defineClass(a),a)},bulkDelete:function(a){return this.hook.deleting.fire===ba?this._idbstore(P,function(b,c,d,e){b(va(d,e,a,!1,ba))}):this.where(":id").anyOf(a).delete().then(function(){})},bulkPut:function(a,b){var c=this;return this._idbstore(P,function(d,e,f){if(!f.keyPath&&!c.schema.primKey.auto&&!b)throw new Z.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(f.keyPath&&b)throw new Z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(b&&b.length!==a.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");if(0===a.length)return d();var h,j,g=function(a){0===i.length?d(a):e(new W(c.name+".bulkPut(): "+i.length+" of "+k+" operations failed",i))},i=[],k=a.length,l=c;if(c.hook.creating.fire===ba&&c.hook.updating.fire===ba){j=sa(i);for(var m=0,n=a.length;m<n;++m)h=b?f.put(a[m],b[m]):f.put(a[m]),h.onerror=j;h.onerror=sa(i,g),h.onsuccess=Nb(g)}else{var o=b||f.keyPath&&a.map(function(a){return w(a,f.keyPath)}),p=o&&t(o,function(b,c){return null!=b&&[b,a[c]]}),q=o?l.where(":id").anyOf(o.filter(function(a){return null!=a})).modify(function(){this.value=p[this.primKey],p[this.primKey]=null}).catch(V,function(a){i=a.failures}).then(function(){for(var c=[],d=b&&[],e=o.length-1;e>=0;--e){var f=o[e];(null==f||p[f])&&(c.push(a[e]),b&&d.push(f),null!=f&&(p[f]=null))}return c.reverse(),b&&d.reverse(),l.bulkAdd(c,d)}).then(function(a){var b=o[o.length-1];return null!=b?b:a}):l.bulkAdd(a);q.then(g).catch(W,function(a){i=i.concat(a.failures),g()}).catch(e)}},"locked")},bulkAdd:function(a,b){var c=this,d=this.hook.creating.fire;return this._idbstore(P,function(e,f,g,h){function i(a){0===k.length?e(a):f(new W(c.name+".bulkAdd(): "+k.length+" of "+n+" operations failed",k))}if(!g.keyPath&&!c.schema.primKey.auto&&!b)throw new Z.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(g.keyPath&&b)throw new Z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(b&&b.length!==a.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");if(0===a.length)return e();var j,l,m,k=[],n=a.length;if(d!==ba){var p,o=g.keyPath;l=sa(k,null,!0),m=Lb(null),v(function(){for(var c=0,e=a.length;c<e;++c){p={onerror:null,onsuccess:null};var f=b&&b[c],i=a[c],k=b?f:o?w(i,o):void 0,n=d.call(p,k,i,h);null==k&&null!=n&&(o?(i=A(i),x(i,o,n)):f=n),j=null!=f?g.add(i,f):g.add(i),j._hookCtx=p,c<e-1&&(j.onerror=l,p.onsuccess&&(j.onsuccess=m))}},function(a){throw p.onerror&&p.onerror(a),a}),j.onerror=sa(k,i,!0),j.onsuccess=Lb(i)}else{l=sa(k);for(var q=0,r=a.length;q<r;++q)j=b?g.add(a[q],b[q]):g.add(a[q]),j.onerror=l;j.onerror=sa(k,i),j.onsuccess=Nb(i)}})},add:function(a,b){var c=this.hook.creating.fire;return this._idbstore(P,function(d,e,f,g){var h={onsuccess:null,onerror:null};if(c!==ba){var i=null!=b?b:f.keyPath?w(a,f.keyPath):void 0,j=c.call(h,i,a,g);null==i&&null!=j&&(f.keyPath?x(a,f.keyPath,j):b=j)}try{var k=null!=b?f.add(a,b):f.add(a);k._hookCtx=h,k.onerror=Ob(e),k.onsuccess=Lb(function(b){var c=f.keyPath;c&&x(a,c,b),d(b)})}catch(a){throw h.onerror&&h.onerror(a),a}})},put:function(a,b){var c=this,d=this.hook.creating.fire,e=this.hook.updating.fire;if(d!==ba||e!==ba){var f=this.schema.primKey.keyPath,g=void 0!==b?b:f&&w(a,f);return null==g?this.add(a):(a=A(a),this._trans(P,function(){return c.where(":id").equals(g).modify(function(){this.value=a}).then(function(d){return 0===d?c.add(a,b):g})},"locked"))}return this._idbstore(P,function(c,d,e){var f=void 0!==b?e.put(a,b):e.put(a);f.onerror=Mb(d),f.onsuccess=_a(function(b){var d=e.keyPath;d&&x(a,d,b.target.result),c(f.result)})})},delete:function(a){return this.hook.deleting.subscribers.length?this.where(":id").equals(a).delete():this._idbstore(P,function(b,c,d){var e=d.delete(a);e.onerror=Mb(c),e.onsuccess=_a(function(){b(e.result)})})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection().delete():this._idbstore(P,function(a,b,c){var d=c.clear();d.onerror=Mb(b),d.onsuccess=_a(function(){a(d.result)})})},update:function(c,d){if("object"!=typeof d||b(d))throw new Z.InvalidArgument("Modifications must be an object.");if("object"!=typeof c||b(c))return this.where(":id").equals(c).modify(d);a(d).forEach(function(a){x(c,a,d[a])});var e=w(c,this.schema.primKey.keyPath);return void 0===e?ub(new Z.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(d)}}),h(wa.prototype,{_lock:function(){return r(!Fa.global),++this._reculock,1!==this._reculock||Fa.global||(Fa.lockOwnerFor=this),this},_unlock:function(){if(r(!Fa.global),0===--this._reculock)for(Fa.global||(Fa.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var a=this._blockedFuncs.shift();try{ob(a[1],a[0])}catch(a){}}return this},_locked:function(){return this._reculock&&Fa.lockOwnerFor!==this},create:function(a){var b=this;if(!this.mode)return this;if(r(!this.idbtrans),!a&&!G)switch(J&&J.name){case"DatabaseClosedError":throw new Z.DatabaseClosed(J);case"MissingAPIError":throw new Z.MissingAPI(J.message,J);default:throw new Z.OpenFailed(J)}if(!this.active)throw new Z.TransactionInactive;return r(null===this._completion._state),a=this.idbtrans=a||G.transaction(Vb(this.storeNames),this.mode),
a.onerror=_a(function(c){Pb(c),b._reject(a.error)}),a.onabort=_a(function(a){Pb(a),b.active&&b._reject(new Z.Abort),b.active=!1,b.on("abort").fire(a)}),a.oncomplete=_a(function(){b.active=!1,b._resolve()}),this},_promise:function(a,b,c){var d=this;if(a===P&&this.mode!==P)return ub(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return ub(new Z.TransactionInactive);if(this._locked())return new Ja(function(e,f){d._blockedFuncs.push([function(){d._promise(a,b,c).then(e,f)},Fa])});if(c)return gb(function(){var a=new Ja(function(a,c){d._lock();var e=b(a,c,d);e&&e.then&&e.then(a,c)});return a.finally(function(){return d._unlock()}),a._lib=!0,a});var e=new Ja(function(a,c){var e=b(a,c,d);e&&e.then&&e.then(a,c)});return e._lib=!0,e},abort:function(){this.active&&this._reject(new Z.Abort),this.active=!1},tables:{get:O("Transaction.tables",function(){return D})},table:O("Transaction.table()",function(a){return D[a]})}),h(xa.prototype,function(){function a(a,b,c){var d=a instanceof xa?new ya(a):a;return d._ctx.error=c?new c(b):new TypeError(b),d}function b(a){return new ya(a,function(){return n.only("")}).limit(0)}function c(a){return"next"===a?function(a){return a.toUpperCase()}:function(a){return a.toLowerCase()}}function d(a){return"next"===a?function(a){return a.toLowerCase()}:function(a){return a.toUpperCase()}}function e(a,b,c,d,e,f){for(var g=Math.min(a.length,d.length),h=-1,i=0;i<g;++i){var j=b[i];if(j!==d[i])return e(a[i],c[i])<0?a.substr(0,i)+c[i]+c.substr(i+1):e(a[i],d[i])<0?a.substr(0,i)+d[i]+c.substr(i+1):h>=0?a.substr(0,h)+b[h]+c.substr(h+1):null;e(a[i],j)<0&&(h=i)}return g<d.length&&"next"===f?a+c.substr(a.length):g<a.length&&"prev"===f?a.substr(0,c.length):h<0?null:a.substr(0,h)+d[h]+c.substr(h+1)}function f(b,f,g,h){function r(a){i=c(a),j=d(a),k="next"===a?Ma:Na;var b=g.map(function(a){return{lower:j(a),upper:i(a)}}).sort(function(a,b){return k(a.lower,b.lower)});l=b.map(function(a){return a.upper}),m=b.map(function(a){return a.lower}),o=a,p="next"===a?"":h}var i,j,k,l,m,o,p,q=g.length;if(!g.every(function(a){return"string"==typeof a}))return a(b,Ab);r("next");var s=new ya(b,function(){return n.bound(l[0],m[q-1]+h)});s._ondirectionchange=function(a){r(a)};var t=0;return s._addAlgorithm(function(a,b,c){var d=a.key;if("string"!=typeof d)return!1;var g=j(d);if(f(g,m,t))return!0;for(var h=null,i=t;i<q;++i){var n=e(d,g,l[i],m[i],k,o);null===n&&null===h?t=i+1:(null===h||k(h,n)>0)&&(h=n)}return b(null!==h?function(){a.continue(h+p)}:c),!1}),s}return{between:function(c,d,e,f){e=e!==!1,f=f===!0;try{return Ga(c,d)>0||0===Ga(c,d)&&(e||f)&&(!e||!f)?b(this):new ya(this,function(){return n.bound(c,d,!e,!f)})}catch(b){return a(this,zb)}},equals:function(a){return new ya(this,function(){return n.only(a)})},above:function(a){return new ya(this,function(){return n.lowerBound(a,!0)})},aboveOrEqual:function(a){return new ya(this,function(){return n.lowerBound(a)})},below:function(a){return new ya(this,function(){return n.upperBound(a,!0)})},belowOrEqual:function(a){return new ya(this,function(){return n.upperBound(a)})},startsWith:function(b){return"string"!=typeof b?a(this,Ab):this.between(b,b+xb,!0,!0)},startsWithIgnoreCase:function(a){return""===a?this.startsWith(a):f(this,function(a,b){return 0===a.indexOf(b[0])},[a],xb)},equalsIgnoreCase:function(a){return f(this,function(a,b){return a===b[0]},[a],"")},anyOfIgnoreCase:function(){var a=F.apply(E,arguments);return 0===a.length?b(this):f(this,function(a,b){return b.indexOf(a)!==-1},a,"")},startsWithAnyOfIgnoreCase:function(){var a=F.apply(E,arguments);return 0===a.length?b(this):f(this,function(a,b){return b.some(function(b){return 0===a.indexOf(b)})},a,xb)},anyOf:function(){var c=F.apply(E,arguments),d=Ka;try{c.sort(d)}catch(b){return a(this,zb)}if(0===c.length)return b(this);var e=new ya(this,function(){return n.bound(c[0],c[c.length-1])});e._ondirectionchange=function(a){d="next"===a?Ka:La,c.sort(d)};var f=0;return e._addAlgorithm(function(a,b,e){for(var g=a.key;d(g,c[f])>0;)if(++f,f===c.length)return b(e),!1;return 0===d(g,c[f])||(b(function(){a.continue(c[f])}),!1)}),e},notEqual:function(a){return this.inAnyRange([[-(1/0),a],[a,yb]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var b=F.apply(E,arguments);if(0===b.length)return new ya(this);try{b.sort(Ka)}catch(b){return a(this,zb)}var c=b.reduce(function(a,b){return a?a.concat([[a[a.length-1][1],b]]):[[-(1/0),b]]},null);return c.push([b[b.length-1],yb]),this.inAnyRange(c,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(c,d){function g(a,b){for(var c=0,d=a.length;c<d;++c){var e=a[c];if(Ga(b[0],e[1])<0&&Ga(b[1],e[0])>0){e[0]=Ha(e[0],b[0]),e[1]=Ia(e[1],b[1]);break}}return c===d&&a.push(b),a}function i(a,b){return h(a[0],b[0])}function o(a){return!l(a)&&!m(a)}if(0===c.length)return b(this);if(!c.every(function(a){return void 0!==a[0]&&void 0!==a[1]&&Ka(a[0],a[1])<=0}))return a(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Z.InvalidArgument);var j,e=!d||d.includeLowers!==!1,f=d&&d.includeUppers===!0,h=Ka;try{j=c.reduce(g,[]),j.sort(i)}catch(b){return a(this,zb)}var k=0,l=f?function(a){return Ka(a,j[k][1])>0}:function(a){return Ka(a,j[k][1])>=0},m=e?function(a){return La(a,j[k][0])>0}:function(a){return La(a,j[k][0])>=0},p=l,q=new ya(this,function(){return n.bound(j[0][0],j[j.length-1][1],!e,!f)});return q._ondirectionchange=function(a){"next"===a?(p=l,h=Ka):(p=m,h=La),j.sort(i)},q._addAlgorithm(function(a,b,c){for(var d=a.key;p(d);)if(++k,k===j.length)return b(c),!1;return!!o(d)||0!==Ga(d,j[k][1])&&0!==Ga(d,j[k][0])&&(b(function(){h===Ka?a.continue(j[k][0]):a.continue(j[k][1])}),!1)}),q},startsWithAnyOf:function(){var c=F.apply(E,arguments);return c.every(function(a){return"string"==typeof a})?0===c.length?b(this):this.inAnyRange(c.map(function(a){return[a,a+xb]})):a(this,"startsWithAnyOf() only works with strings")}}}),h(ya.prototype,function(){function b(a,b){a.filter=Oa(a.filter,b)}function c(a,b,c){var d=a.replayFilter;a.replayFilter=d?function(){return Oa(d(),b())}:b,a.justLimit=c&&!d}function e(a,b){a.isMatch=Oa(a.isMatch,b)}function f(a,b){if(a.isPrimKey)return b;var c=a.table.schema.idxByName[a.index];if(!c)throw new Z.Schema("KeyPath "+a.index+" on object store "+b.name+" is not indexed");return b.index(c.name)}function h(a,b){var c=f(a,b);return a.keysOnly&&"openKeyCursor"in c?c.openKeyCursor(a.range||null,a.dir+a.unique):c.openCursor(a.range||null,a.dir+a.unique)}function i(a,b,c,d,e){var f=a.replayFilter?Oa(a.filter,a.replayFilter()):a.filter;a.or?function(){function k(){2===++j&&c()}function l(a,c,e){if(!f||f(c,e,k,d)){var h=c.primaryKey.toString();g(i,h)||(i[h]=!0,b(a,c,e))}}var i={},j=0;a.or._iterate(l,k,d,e),Da(h(a,e),a.algorithm,l,k,d,!a.keysOnly&&a.valueMapper)}():Da(h(a,e),Oa(a.algorithm,f),b,c,d,!a.keysOnly&&a.valueMapper)}function j(a){return a.table.schema.instanceTemplate}return{_read:function(a,b){var c=this._ctx;return c.error?c.table._trans(null,function(b,d){d(c.error)}):c.table._idbstore(N,a).then(b)},_write:function(a){var b=this._ctx;return b.error?b.table._trans(null,function(c,d){d(b.error)}):b.table._idbstore(P,a,"locked")},_addAlgorithm:function(a){var b=this._ctx;b.algorithm=Oa(b.algorithm,a)},_iterate:function(a,b,c,d){return i(this._ctx,a,b,c,d)},clone:function(a){var b=Object.create(this.constructor.prototype),c=Object.create(this._ctx);return a&&d(c,a),b._ctx=c,b},raw:function(){return this._ctx.valueMapper=null,this},each:function(a){var b=this._ctx;if(Ib){var c=j(b),d=b.table.schema.primKey.keyPath,e=w(c,b.index?b.table.schema.idxByName[b.index].keyPath:d),f=w(c,d);a(c,{key:e,primaryKey:f})}return this._read(function(c,d,e){i(b,a,c,d,e)})},count:function(a){if(Ib)return Ja.resolve(0).then(a);var b=this._ctx;if(za(b,!0))return this._read(function(a,c,d){var e=f(b,d),g=b.range?e.count(b.range):e.count();g.onerror=Mb(c),g.onsuccess=function(c){a(Math.min(c.target.result,b.limit))}},a);var c=0;return this._read(function(a,d,e){i(b,function(){return++c,!1},function(){a(c)},d,e)},a)},sortBy:function(a,b){function f(a,b){return b?f(a[c[b]],b-1):a[d]}function h(a,b){var c=f(a,e),d=f(b,e);return c<d?-g:c>d?g:0}var c=a.split(".").reverse(),d=c[0],e=c.length-1,g="next"===this._ctx.dir?1:-1;return this.toArray(function(a){return a.sort(h)}).then(b)},toArray:function(a){var b=this._ctx;return this._read(function(a,c,d){if(Ib&&a([j(b)]),$&&"next"===b.dir&&za(b,!0)&&b.limit>0){var e=b.table.hook.reading.fire,g=f(b,d),h=b.limit<1/0?g.getAll(b.range,b.limit):g.getAll(b.range);h.onerror=Mb(c),h.onsuccess=Nb(e===ca?a:function(b){try{a(b.map(e))}catch(a){c(a)}})}else{var k=[];i(b,function(a){k.push(a)},function(){a(k)},c,d)}},a)},offset:function(a){var b=this._ctx;return a<=0?this:(b.offset+=a,za(b)?c(b,function(){var b=a;return function(a,c){return 0===b||(1===b?(--b,!1):(c(function(){a.advance(b),b=0}),!1))}}):c(b,function(){var b=a;return function(){return--b<0}}),this)},limit:function(a){return this._ctx.limit=Math.min(this._ctx.limit,a),c(this._ctx,function(){var b=a;return function(a,c,d){return--b<=0&&c(d),b>=0}},!0),this},until:function(a,c){var d=this._ctx;return Ib&&a(j(d)),b(this._ctx,function(b,d,e){return!a(b.value)||(d(e),c)}),this},first:function(a){return this.limit(1).toArray(function(a){return a[0]}).then(a)},last:function(a){return this.reverse().first(a)},filter:function(a){return Ib&&a(j(this._ctx)),b(this._ctx,function(b){return a(b.value)}),e(this._ctx,a),this},and:function(a){return this.filter(a)},or:function(a){return new xa(this._ctx.table,a,this)},reverse:function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},desc:function(){return this.reverse()},eachKey:function(a){var b=this._ctx;return b.keysOnly=!b.isMatch,this.each(function(b,c){a(c.key,c)})},eachUniqueKey:function(a){return this._ctx.unique="unique",this.eachKey(a)},eachPrimaryKey:function(a){var b=this._ctx;return b.keysOnly=!b.isMatch,this.each(function(b,c){a(c.primaryKey,c)})},keys:function(a){var b=this._ctx;b.keysOnly=!b.isMatch;var c=[];return this.each(function(a,b){c.push(b.key)}).then(function(){return c}).then(a)},primaryKeys:function(a){var b=this._ctx;if($&&"next"===b.dir&&za(b,!0)&&b.limit>0)return this._read(function(a,c,d){var e=f(b,d),g=b.limit<1/0?e.getAllKeys(b.range,b.limit):e.getAllKeys(b.range);g.onerror=Mb(c),g.onsuccess=Nb(a)}).then(a);b.keysOnly=!b.isMatch;var c=[];return this.each(function(a,b){c.push(b.primaryKey)}).then(function(){return c}).then(a)},uniqueKeys:function(a){return this._ctx.unique="unique",this.keys(a)},firstKey:function(a){return this.limit(1).keys(function(a){return a[0]}).then(a)},lastKey:function(a){return this.reverse().firstKey(a)},distinct:function(){var a=this._ctx,c=a.index&&a.table.schema.idxByName[a.index];if(!c||!c.multi)return this;var d={};return b(this._ctx,function(a){var b=a.primaryKey.toString(),c=g(d,b);return d[b]=!0,!c}),this},modify:function(b){var c=this,e=this._ctx,f=e.table.hook,h=f.updating.fire,i=f.deleting.fire;return Ib&&"function"==typeof b&&b.call({value:e.table.schema.instanceTemplate},e.table.schema.instanceTemplate),this._write(function(e,f,j,k){function y(a,b){function d(a){return s.push(a),t.push(c.primKey),D(),!0}u=b.primaryKey;var c={primKey:b.primaryKey,value:a,onsuccess:null,onerror:null};if(l.call(c,a,c)!==!1){var e=!g(c,"value");++p,v(function(){var a=e?b.delete():b.update(c.value);a._hookCtx=c,a.onerror=Ob(d),a.onsuccess=Lb(function(){++q,D()})},d)}else c.onsuccess&&c.onsuccess(c.value)}function C(a){return a&&(s.push(a),t.push(u)),f(new V("Error modifying one or more objects",s,q,t))}function D(){r&&q+s.length===p&&(s.length>0?C():e(q))}var l;if("function"==typeof b)l=h===ba&&i===ba?b:function(c){var d=A(c);if(b.call(this,c,this)===!1)return!1;if(g(this,"value")){var e=B(d,this.value),f=h.call(this,e,this.primKey,d,k);f&&(c=this.value,a(f).forEach(function(a){x(c,a,f[a])}))}else i.call(this,this.primKey,c,k)};else if(h===ba){var m=a(b),n=m.length;l=function(a){for(var c=!1,d=0;d<n;++d){var e=m[d],f=b[e];w(a,e)!==f&&(x(a,e,f),c=!0)}return c}}else{var o=b;b=z(o),l=function(c){var e=!1,f=h.call(this,b,this.primKey,A(c),k);return f&&d(b,f),a(b).forEach(function(a){var d=b[a];w(c,a)!==d&&(x(c,a,d),e=!0)}),f&&(b=z(o)),e}}var p=0,q=0,r=!1,s=[],t=[],u=null;c.clone().raw()._iterate(y,function(){r=!0,D()},C,j)})},delete:function(){var a=this,b=this._ctx,c=b.range,d=b.table.hook.deleting.fire,e=d!==ba;if(!e&&za(b)&&(b.isPrimKey&&!Eb||!c))return this._write(function(a,b,d){var e=Mb(b),f=c?d.count(c):d.count();f.onerror=e,f.onsuccess=function(){var g=f.result;v(function(){var b=c?d.delete(c):d.clear();b.onerror=e,b.onsuccess=function(){return a(g)}},function(a){return b(a)})}});var f=e?2e3:1e4;return this._write(function(c,g,h,i){var j=0,k=a.clone({keysOnly:!b.isMatch&&!e}).distinct().limit(f).raw(),l=[],m=function(){return k.each(e?function(a,b){l.push([b.primaryKey,b.value])}:function(a,b){l.push(b.primaryKey)}).then(function(){return e?l.sort(function(a,b){return Ka(a[0],b[0])}):l.sort(Ka),va(h,i,l,e,d)}).then(function(){var a=l.length;return j+=a,l=[],a<f?j:m()})};c(m())})}}}),d(this,{Collection:ya,Table:ra,Transaction:wa,Version:aa,WhereClause:xa}),_(),k.forEach(function(a){a(Q)})}function Jb(a){if("function"==typeof a)return new a;if(b(a))return[Jb(a[0])];if(a&&"object"==typeof a){var c={};return Kb(c,a),c}return a}function Kb(b,c){return a(c).forEach(function(a){var d=Jb(c[a]);b[a]=d}),b}function Lb(a){return _a(function(b){var c=b.target,d=c.result,e=c._hookCtx,f=e&&e.onsuccess;f&&f(d),a&&a(d)},a)}function Mb(a){return _a(function(b){return Pb(b),a(b.target.error),!1})}function Nb(a){return _a(function(b){a(b.target.result)})}function Ob(a){return _a(function(b){var c=b.target,d=c.error,e=c._hookCtx,f=e&&e.onerror;return f&&f(d),Pb(b),a(d),!1})}function Pb(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault()}function Qb(a){var b,c=Gb.dependencies.localStorage;if(!c)return a([]);try{b=JSON.parse(c.getItem("Dexie.DatabaseNames")||"[]")}catch(a){b=[]}a(b)&&c.setItem("Dexie.DatabaseNames",JSON.stringify(b))}function Rb(a){function g(a){return function(c){var d=a(c),g=d.value;return d.done?g:g&&"function"==typeof g.then?g.then(e,f):b(g)?Ja.all(g).then(e,f):e(g)}}var c=function(b){return a.next(b)},d=function(b){return a.throw(b)},e=g(c),f=g(d);return g(c)()}function Sb(a,b,c,d,e,f,g){this.name=a,this.keyPath=b,this.unique=c,this.multi=d,this.auto=e,this.compound=f,this.dotted=g;var h="string"==typeof b?b:b&&"["+[].join.call(b,"+")+"]";this.src=(c?"&":"")+(d?"*":"")+(e?"++":"")+h}function Tb(a,b,c,d){this.name=a,this.primKey=b||new Sb,this.indexes=c||[new Sb],this.instanceTemplate=d,this.mappedClass=null,this.idxByName=t(c,function(a){return[a.name,a]})}function Vb(a){return 1===a.length?a[0]:a}function Wb(a){var b=a&&(a.getDatabaseNames||a.webkitGetDatabaseNames);return b&&b.bind(a)}var a=Object.keys,b=Array.isArray,c="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,e=Object.getPrototypeOf,f={}.hasOwnProperty,i=Object.defineProperty,l=Object.getOwnPropertyDescriptor,n=[].slice,C="undefined"!=typeof Symbol&&Symbol.iterator,D=C?function(a){var b;return null!=a&&(b=a[C])&&b.apply(a)}:function(){return null},E={},G=[].concat,I="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),K=function(){return!0},L=!new Error("").stack,P=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],Q=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],R=P.concat(Q),S={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};k(T).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+N(this._e,2))}},toString:function(){return this.name+": "+this.message}}),k(V).from(T),k(W).from(T);var X=R.reduce(function(a,b){return a[b]=b+"Error",a},{}),Y=T,Z=R.reduce(function(a,b){function d(a,d){this._e=M(),this.name=c,a?"string"==typeof a?(this.message=a,this.inner=d||null):"object"==typeof a&&(this.message=a.name+" "+a.message,this.inner=a):(this.message=S[b]||c,this.inner=null)}var c=b+"Error";return k(d).from(Y),a[b]=d,a},{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var $=Q.reduce(function(a,b){return a[b+"Error"]=Z[b],a},{}),aa=R.reduce(function(a,b){return["Syntax","Type","Range"].indexOf(b)===-1&&(a[b+"Error"]=Z[b]),a},{});aa.ModifyError=V,aa.DexieError=T,aa.BulkError=W;var ka={},la=100,ma=20,na=7,oa=function(){try{return new Function("let F=async ()=>{},p=F();return [p,Object.getPrototypeOf(p),Promise.resolve(),F.constructor];")()}catch(b){var a=c.Promise;return a?[a.resolve(),a.prototype,a.resolve()]:[]}}(),pa=oa[0],qa=oa[1],ra=oa[2],sa=qa&&qa.then,ta=pa&&pa.constructor,ua=oa[3],va=!1,wa=ra?function(){ra.then(Ta)}:c.setImmediate?setImmediate.bind(null,Ta):c.MutationObserver?function(){var a=document.createElement("div");new MutationObserver(function(){Ta(),a=null}).observe(a,{attributes:!0}),a.setAttribute("i","1")}:function(){setTimeout(Ta,0)},xa=function(a,b){Ga.push([a,b]),za&&(wa(),za=!1)},ya=!0,za=!0,Aa=[],Ba=[],Ca=null,Da=ca,Ea={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:tb,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(a){try{tb(a[0],a[1])}catch(a){}})}},Fa=Ea,Ga=[],Ha=0,Ia=[],Ka={get:function(){function c(c,d){var e=this,f=!a.global&&(a!==Fa||b!==eb);f&&ib();var g=new Ja(function(b,g){Pa(e,new La(qb(c,a,f),qb(d,a,f),b,g,a))});return I&&(!this._prev||null===this._state)&&Sa(g,this),g}var a=Fa,b=eb;return c._tQzo=!0,c},set:function(a){j(this,"then",a&&a._tQzo?Ka:{get:function(){return a},set:Ka.set})}};h(Ja.prototype,{then:Ka,_then:function(a,b){Pa(this,new La(null,null,a,b,Fa))},catch:function(a){if(1===arguments.length)return this.then(null,a);var b=arguments[0],c=arguments[1];return"function"==typeof b?this.then(null,function(a){return a instanceof b?c(a):$a(a)}):this.then(null,function(a){return a&&a.name===b?c(a):$a(a)})},finally:function(a){return this.then(function(b){return a(),b},function(b){return a(),$a(b)})},stack:{get:function(){if(this._stack)return this._stack;try{va=!0;var a=Ra(this,[],ma),b=a.join("\nFrom previous: ");return null!==this._state&&(this._stack=b),b}finally{va=!1}}}}),Ea.env=nb(),h(Ja,{all:function(){var a=F.apply(null,arguments).map(jb);return new Ja(function(b,c){0===a.length&&b([]);var d=a.length;a.forEach(function(e,f){return Ja.resolve(e).then(function(c){a[f]=c,--d||b(a)},c)})})},resolve:function(a){return a instanceof Ja?a:a&&"function"==typeof a.then?new Ja(function(b,c){a.then(b,c)}):new Ja(ka,!0,a)},reject:$a,race:function(){var a=F.apply(null,arguments).map(jb);return new Ja(function(b,c){a.map(function(a){return Ja.resolve(a).then(b,c)})})},PSD:{get:function(){return Fa},set:function(a){return Fa=a}},newPSD:gb,usePSD:ob,scheduler:{get:function(){return xa},set:function(a){xa=a}},rejectionMapper:{get:function(){return Da},set:function(a){Da=a}},follow:function(a,b){return new Ja(function(c,d){return gb(function(b,c){var d=Fa;d.unhandleds=[],d.onunhandled=c,d.finalize=ea(function(){var a=this;Xa(function(){0===a.unhandleds.length?b():c(a.unhandleds[0])})},d.finalize),a()},b,c,d)})}});var ab={awaits:0,echoes:0,id:0},bb=0,cb=[],db=0,eb=0,fb=0,sb="unhandledrejection";q(function(){xa=function(a,b){setTimeout(function(){a.apply(null,b)},0)}});var ub=Ja.reject,wb="2.0.0-beta.4",xb=String.fromCharCode(65535),yb=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(a){return xb}}(),zb="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ab="String expected.",Bb=[],Cb="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Db=Cb,Eb=Cb,Fb=function(a){return!/(dexie\.js|dexie\.min\.js)/.test(a)};J(I,Fb);var Hb=function(){},Ib=!1,Ub=c.idbModules&&c.idbModules.shimIndexedDB?c.idbModules:{};return h(Gb,aa),h(Gb,{delete:function(a){var b=new Gb(a),c=b.delete();return c.onblocked=function(a){return b.on("blocked",a),this},c},exists:function(a){return new Gb(a).open().then(function(a){return a.close(),!0}).catch(Gb.NoSuchDatabaseError,function(){return!1})},getDatabaseNames:function(a){return new Ja(function(a,b){var c=Wb(indexedDB);if(c){var d=c();d.onsuccess=function(b){a(o(b.target.result,0))},d.onerror=Mb(b)}else Qb(function(b){return a(b),!1})}).then(a)},defineClass:function(a){function b(b){b?d(this,b):Ib&&Kb(this,a)}return b},applyStructure:Kb,ignoreTransaction:function(a){return Fa.trans?ob(Fa.transless,a):a()},vip:function(a){return gb(function(){return Fa.letThrough=!0,a()})},async:function(a){return function(){try{var b=Rb(a.apply(this,arguments));return b&&"function"==typeof b.then?b:Ja.resolve(b)}catch(a){return ub(a)}}},spawn:function(a,b,c){try{var d=Rb(a.apply(c,b||[]));return d&&"function"==typeof d.then?d:Ja.resolve(d)}catch(a){return ub(a)}},currentTransaction:{get:function(){return Fa.trans||null}},Promise:Ja,debug:{get:function(){return I},set:function(a){J(a,"dexie"===a?function(){return!0}:Fb)}},derive:k,extend:d,props:h,override:p,Events:vb,getByKeyPath:w,setByKeyPath:x,delByKeyPath:y,shallowClone:z,deepClone:A,getObjectDiff:B,asap:s,maxKey:yb,addons:[],connections:Bb,MultiModifyError:Z.Modify,errnames:X,IndexSpec:Sb,TableSchema:Tb,dependencies:{indexedDB:Ub.shimIndexedDB||c.indexedDB||c.mozIndexedDB||c.webkitIndexedDB||c.msIndexedDB,IDBKeyRange:Ub.IDBKeyRange||c.IDBKeyRange||c.webkitIDBKeyRange},semVer:wb,version:wb.split(".").map(function(a){return parseInt(a)}).reduce(function(a,b,c){return a+b/Math.pow(10,2*c)}),fakeAutoComplete:Hb,default:Gb}),v(function(){Gb.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:c.localStorage}),Ja.rejectionMapper=_,q(function(){Gb.fakeAutoComplete=Hb=q,Gb.fake=Ib=!0}),Gb});