Comparing version 1.4.0-beta to 1.4.0-beta2
@@ -28,3 +28,3 @@ { | ||
], | ||
"version": "1.4.0-beta" | ||
"version": "1.4.0-beta2" | ||
} |
@@ -1,2 +0,2 @@ | ||
// Type definitions for Dexie v1.4.0-beta | ||
// Type definitions for Dexie v1.4.0-beta2 | ||
// Project: https://github.com/dfahlander/Dexie.js | ||
@@ -259,3 +259,3 @@ // Definitions by: David Fahlander <http://github.com/dfahlander> | ||
each(callback: (obj: T, cursor: IDBCursor) => any): Promise<void>; | ||
each(callback: (obj: T, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
@@ -310,5 +310,6 @@ toArray(): Promise<Array<T>>; | ||
distinct(): Collection<T, Key>; | ||
each(callback: (obj: T, cursor: IDBCursor) => any): Promise<void>; | ||
eachKey(callback: (key: Key, cursor: IDBCursor) => any): Promise<void>; | ||
eachUniqueKey(callback: (key: Key, cursor: IDBCursor) => any): Promise<void>; | ||
each(callback: (obj: T, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
eachKey(callback: (key: IndexableType, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
eachPrimaryKey(callback: (key: Key, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
eachUniqueKey(callback: (key: IndexableType, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
filter(filter: (x: T) => boolean): Collection<T, Key>; | ||
@@ -318,5 +319,8 @@ first(): Promise<T>; | ||
first<U>(onFulfilled: (value: T) => U): Promise<U>; | ||
keys(): Promise<Key[]>; | ||
keys<U>(onFulfilled: (value: Key[]) => Thenable<U>): Promise<U>; | ||
keys<U>(onFulfilled: (value: Key[]) => U): Promise<U>; | ||
keys(): Promise<IndexableType[]>; | ||
keys<U>(onFulfilled: (value: IndexableType[]) => Thenable<U>): Promise<U>; | ||
keys<U>(onFulfilled: (value: IndexableType[]) => U): Promise<U>; | ||
primaryKeys(): Promise<Key[]>; | ||
primaryKeys<U>(onFulfilled: (value: Key[]) => Thenable<U>): Promise<U>; | ||
primaryKeys<U>(onFulfilled: (value: Key[]) => U): Promise<U>; | ||
last(): Promise<T>; | ||
@@ -336,5 +340,5 @@ last<U>(onFulfilled: (value: T) => Thenable<U>): Promise<U>; | ||
toArray<U>(onFulfilled: (value: Array<T>) => U): Promise<U>; | ||
uniqueKeys(): Promise<Key[]>; | ||
uniqueKeys<U>(onFulfilled: (value: Key[]) => Thenable<U>): Promise<U>; | ||
uniqueKeys<U>(onFulfilled: (value: Key[]) => U): Promise<U>; | ||
uniqueKeys(): Promise<IndexableType[]>; | ||
uniqueKeys<U>(onFulfilled: (value: IndexableType[]) => Thenable<U>): Promise<U>; | ||
uniqueKeys<U>(onFulfilled: (value: IndexableType[]) => U): Promise<U>; | ||
until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection<T, Key>; | ||
@@ -341,0 +345,0 @@ // WriteableCollection: |
@@ -1,3 +0,3 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Dexie=t()}(this,function(){"use strict";function n(n,t){kn=n,In=t}function t(){if(Cn)try{t.arguments}catch(n){return n}return new Error}function e(n,t){var e=n.stack;return e?(t=t||0,0===e.indexOf(n.name)&&(t+=(n.name+n.message).split("\n").length),e.split("\n").slice(t).filter(In).map(function(n){return"\n"+n}).join("")):""}function r(){}function i(n){return n}function o(n,t){return null==n||n===i?t:function(e){return t(n(e))}}function u(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function a(n,t){return n===r?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?u(r,this.onsuccess):r),i&&(this.onerror=this.onerror?u(i,this.onerror):i),void 0!==o?o:e}}function c(n,t){return n===r?t:function(){n.apply(this,arguments);var e=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?u(e,this.onsuccess):e),r&&(this.onerror=this.onerror?u(r,this.onerror):r)}}function s(n,t){return n===r?t:function(e){var r=n.apply(this,arguments);h(e,r);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?u(i,this.onsuccess):i),o&&(this.onerror=this.onerror?u(o,this.onerror):o),void 0===r?void 0===a?void 0:a:h(r,a)}}function f(n,t){return n===r?t:function(){return t.apply(this,arguments)===!1?!1:n.apply(this,arguments)}}function l(n,t){return n===r?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function h(n,t){return"object"!=typeof t?n:(En(t).forEach(function(e){n[e]=t[e]}),n)}function d(n,t){return Dn.call(n,t)}function p(n,t){"function"==typeof t&&(t=t(Sn(n))),En(t).forEach(function(e){v(n,e,t[e])})}function v(n,t,e,r){Object.defineProperty(n,t,h(e&&d(e,"get")&&"function"==typeof e.get?{get:e.get,set:e.set,configurable:!0}:{value:e,configurable:!0,writable:!0},r))}function y(n){return{from:function(t){return n.prototype=Object.create(t.prototype),v(n.prototype,"constructor",n),{extend:p.bind(null,n.prototype)}}}}function m(n,t){var e,r=On(n,t);return r||(e=Sn(n))&&m(e,t)}function g(n,t,e){return jn.call(n,t,e)}function b(n,t){return t(n)}function _(n){var t=setTimeout(n,1e3);clearTimeout(t)}function w(n){if(!n)throw new zn.Internal("Assertion failed")}function x(n){An.setImmediate?setImmediate(n):setTimeout(n,0)}function k(n,t){return function(){try{n.apply(this,arguments)}catch(e){t(e)}}}function I(n,t,e){try{n.apply(null,e)}catch(r){t&&t(r)}}function C(n,t){var e=R.reject(n);return t?e.uncaught(t):e}function E(n,t){if(d(n,t))return n[t];if(!t)return n;if("string"!=typeof t){for(var e=[],r=0,i=t.length;i>r;++r){var o=E(n,t[r]);e.push(o)}return e}var u=t.indexOf(".");if(-1!==u){var a=n[t.substr(0,u)];return void 0===a?void 0:E(a,t.substr(u+1))}}function P(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){w("string"!=typeof e&&"length"in e);for(var r=0,i=t.length;i>r;++r)P(n,t[r],e[r])}else{var o=t.indexOf(".");if(-1!==o){var u=t.substr(0,o),a=t.substr(o+1);if(""===a)void 0===e?delete n[u]:n[u]=e;else{var c=n[u];c||(c=n[u]={}),P(c,a,e)}}else void 0===e?delete n[t]:n[t]=e}}function A(n,t){"string"==typeof t?P(n,t,void 0):"length"in t&&[].map.call(t,function(t){P(n,t,void 0)})}function S(n){var t={};for(var e in n)d(n,e)&&(t[e]=n[e]);return t}function D(n){if(!n||"object"!=typeof n)return n;var t;if(Pn(n)){t=[];for(var e=0,r=n.length;r>e;++e)t.push(D(n[e]))}else if(n instanceof Date)t=new Date,t.setTime(n.getTime());else{t=n.constructor?Object.create(n.constructor.prototype):{};for(var i in n)d(n,i)&&(t[i]=D(n[i]))}return t}function O(n,t,e,r){e=e||{},r=r||"";for(var i in n)if(d(n,i))if(d(t,i)){var o=n[i],u=t[i];"object"==typeof o&&"object"==typeof u?O(o,u,e,r+i+"."):o!==u&&(e[r+i]=t[i])}else e[r+i]=void 0;for(i in t)d(t,i)&&!d(n,i)&&(e[r+i]=t[i]);return e}function j(n){var t,e,r,i;if(1===arguments.length){if(Pn(n))return n.slice();if(this===Bn&&"string"==typeof n)return[n];if(i=Kn(n)){for(e=[];r=i.next(),!r.done;)e.push(r.value);return e}if(null==n)return[n];if(t=n.length,"number"==typeof t){for(e=new Array(t);t--;)e[t]=n[t];return e}return[n]}for(t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return e}function T(n){return Mn.apply([],n)}function K(n,e){this._e=t(),this.name=n,this.message=e}function B(n,t){return n+". Errors: "+t.map(function(n){return n.toString()}).filter(function(n,t,e){return e.indexOf(n)===t}).join("\n")}function M(n,e,r,i){this._e=t(),this.failures=e,this.failedKeys=i,this.successCount=r}function N(n,e){this._e=t(),this.name="BulkError",this.failures=e,this.message=B(n,e)}function F(n,t){if(!n||n instanceof K||n instanceof TypeError||n instanceof SyntaxError||!n.name||!Wn[n.name])return n;var e=new Wn[n.name](t||n.message,n);return"stack"in n&&v(e,"stack",{get:function(){return this.inner.stack}}),e}function q(n){function t(n,t,i){if("object"==typeof n)return e(n);t||(t=f),i||(i=r);var a={subscribers:[],fire:i,subscribe:function(n){-1===a.subscribers.indexOf(n)&&(a.subscribers.push(n),a.fire=t(a.fire,n))},unsubscribe:function(n){a.subscribers=a.subscribers.filter(function(t){return t!==n}),a.fire=a.subscribers.reduce(t,i)}};return o[n]=u[n]=a,a}function e(n){En(n).forEach(function(e){var r=n[e];if(Pn(r))t(e,n[e][0],n[e][1]);else{if("asap"!==r)throw new zn.InvalidArgument("Invalid event config");var o=t(e,i,function(){for(var n=arguments.length,t=new Array(n);n--;)t[n]=arguments[n];o.subscribers.forEach(function(n){x(function(){n.apply(null,t)})})})}})}var o={},u=function(t,e){if(e){for(var r=arguments.length,i=new Array(r-1);--r;)i[r-1]=arguments[r];return o[t].subscribe.apply(null,i),n}return"string"==typeof t?o[t]:void 0};u.addEventType=t;for(var a=1,c=arguments.length;c>a;++a)t(arguments[a]);return u}function R(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=r,this._lib=!1;var e=this._PSD=ot;if(kn&&(this._stackHolder=t(),this._prev=null,this._numPrev=0,J(this,et)),"function"!=typeof n){if(n!==Hn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&z(this,this._value))}this._state=null,this._value=null,++e.ref,V(this,n)}function U(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r,this.psd=ot}function V(n,t){try{t(function(t){if(null===n._state){if(t===n)throw new TypeError("A promise cannot be resolved with itself.");var e=n._lib&&Y();t&&"function"==typeof t.then?V(n,function(n,e){t instanceof R?t._then(n,e):t.then(n,e)}):(n._state=!0,n._value=t,W(n)),e&&$()}},z.bind(null,n))}catch(e){z(n,e)}}function z(n,t){if(tt.push(t),null===n._state){var e=n._lib&&Y();t=rt(t),n._state=!1,n._value=t,kn&&null!==t&&!t._promise&&"object"==typeof t&&I(function(){var e=m(t,"stack");t._promise=n,v(t,"stack",{get:function(){return Qn?e&&(e.get?e.get.apply(t):e.value):n.stack}})}),nn(n),W(n),e&&$()}}function W(n){var t=n._listeners;n._listeners=[];for(var e=0,r=t.length;r>e;++e)L(n,t[e]);var i=n._PSD;--i.ref||i.finalize(),0===at&&(++at,$n(function(){0===--at&&X()},[]))}function L(n,t){if(null===n._state)return void n._listeners.push(t);var e=n._state?t.onFulfilled:t.onRejected;if(null===e)return(n._state?t.resolve:t.reject)(n._value);var r=t.psd;++r.ref,++at,$n(H,[e,n,t])}function H(n,t,e){var r=ot,i=e.psd;try{i!==r&&(ot=i),et=t;var o,u=t._value;t._state?o=n(u):(tt.length&&(tt=[]),o=n(u),-1===tt.indexOf(u)&&tn(t)),e.resolve(o)}catch(a){e.reject(a)}finally{i!==r&&(ot=r),et=null,0===--at&&X(),--i.ref||i.finalize()}}function G(n,t,r){if(t.length===r)return t;var i="";if(n._state===!1){var o,u,a=n._value;null!=a?(o=a.name||"Error",u=a.message||a,i=e(a,0)):(o=a,u=""),t.push(o+(u?": "+u:"")+i)}return kn&&(i=e(n._stackHolder,2),i&&-1===t.indexOf(i)&&t.push(i),n._prev&&G(n._prev,t,r)),t}function J(n,t){var e=t?t._numPrev+1:0;Gn>e&&(n._prev=t,n._numPrev=e)}function Q(){Y()&&$()}function Y(){var n=Xn;return Xn=!1,Zn=!1,n}function $(){var n,t,e;do for(;ut.length>0;)for(n=ut,ut=[],e=n.length,t=0;e>t;++t){var r=n[t];r[0].apply(null,r[1])}while(ut.length>0);Xn=!0,Zn=!0}function X(){var n=nt;nt=[],n.forEach(function(n){n._PSD.onunhandled.call(null,n._value,n)});for(var t=ct.slice(0),e=t.length;e;)t[--e]()}function Z(n){function t(){n(),ct.splice(ct.indexOf(t),1)}ct.push(t),++at,$n(function(){0===--at&&X()},[])}function nn(n){nt.some(function(t){return t._value===n._value})||nt.push(n)}function tn(n){for(var t=nt.length;t;)if(nt[--t]._value===n._value)return void nt.splice(t,1)}function en(n){console.warn("Unhandled rejection: "+(n.stack||n))}function rn(n){return new R(Hn,!1,n)}function on(n,t){var e=ot;return function(){var r=Y(),i=ot;try{return i!==e&&(ot=e),n.apply(this,arguments)}catch(o){t&&t(o)}finally{i!==e&&(ot=i),r&&$()}}}function un(n,t,e,r){var i=ot,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=an(o,n,t,e,r);return 0===o.ref&&o.finalize(),u}function an(n,t,e,r,i){var o=ot;try{return n!==o&&(ot=n),t(e,r,i)}finally{n!==o&&(ot=o)}}function cn(n,t){var e;try{e=t.onuncatched(n)}catch(r){}if(e!==!1)try{R.on.error.fire(n,t)}catch(r){}}function sn(n,e){function u(){Zn.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+Zn.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+Zn.name+"'. Closing db now to resume the delete request."),Zn.close()}),Zn.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+Zn.name+"') was blocked"):console.warn("Upgrade '"+Zn.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function f(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function m(n,t,e){var r=Zn._createTransaction(Xn,Ln,Vn);r.create(t),r._completion["catch"](e);var i=r._reject.bind(r);un(function(){ot.trans=r,0===n?(En(Vn).forEach(function(n){K(t,n,Vn[n].primKey,Vn[n].indexes)}),R.follow(function(){return Zn.on.populate.fire(r)})["catch"](i)):x(n,r,t)["catch"](i)})}function x(n,t,e){function r(){return i.length?R.resolve(i.shift()(t.idbtrans)).then(r):R.resolve()}var i=[],o=Wn.filter(function(t){return t._cfg.version===n})[0];if(!o)throw new zn.Upgrade("Dexie specification of currently installed DB version is missing");Vn=Zn._dbSchema=o._cfg.dbschema;var u=!1,a=Wn.filter(function(t){return t._cfg.version>n});return a.forEach(function(n){i.push(function(){var r=Vn,i=n._cfg.dbschema;On(r,e),On(i,e),Vn=Zn._dbSchema=i;var o=A(r,i);return o.add.forEach(function(n){K(e,n[0],n[1].primKey,n[1].indexes)}),o.change.forEach(function(n){if(n.recreate)throw new zn.Upgrade("Not yet support for changing primary key");var t=e.objectStore(n.name);n.add.forEach(function(n){U(t,n)}),n.change.forEach(function(n){t.deleteIndex(n.name),U(t,n)}),n.del.forEach(function(n){t.deleteIndex(n)})}),n._cfg.contentUpgrade?(u=!0,R.follow(function(){n._cfg.contentUpgrade(t)})):void 0}),i.push(function(t){if(u&&!vt){var e=n._cfg.dbschema;F(e,t)}})}),r().then(function(){B(Vn,e)})}function A(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var i=n[r],o=t[r];if(i){var u={name:r,def:t[r],recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)u.recreate=!0,e.change.push(u);else{var a=i.indexes.reduce(function(n,t){return n[t.name]=t,n},{}),c=o.indexes.reduce(function(n,t){return n[t.name]=t,n},{});for(var s in a)c[s]||u.del.push(s);for(s in c){var f=a[s],l=c[s];f?f.src!==l.src&&u.change.push(l):u.add.push(l)}(u.recreate||u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,o])}return e}function K(n,t,e,r){var i=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){U(i,n)}),i}function B(n,t){En(n).forEach(function(e){t.db.objectStoreNames.contains(e)||K(t,e,n[e].primKey,n[e].indexes)})}function F(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null==n[r]&&t.db.deleteObjectStore(r)}}function U(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function V(n){return Zn.on.error.fire(n)}function z(n,t,e){if(Yn||ot.letThrough){var i=Zn._createTransaction(n,t,Vn);return i._promise(n,function(n,t){un(function(){ot.trans=i,e(n,t,i)})}).then(function(n){return i._completion.then(function(){return n})})}if(!Qn){if(!qn)return C(new zn.DatabaseClosed,V);Zn.open()["catch"](r)}return nt.then(function(){return z(n,t,e)})}function W(n,t,e){this.name=n,this.schema=t,this.hook=Hn[n]?Hn[n].hook:q(null,{creating:[a,r],reading:[o,i],updating:[s,r],deleting:[c,r]}),this._collClass=e||Y}function L(n,t,e){W.call(this,n,t,e||$)}function H(n,t,e){return(e?vn:pn)(function(e){n.push(e),t&&t()})}function G(n,t,e,r,i){return new R(function(o,u){var a=e.length,c=a-1;if(0===a)return o();if(r){var s,f=vn(u),l=dn(null);I(function(){for(var r=0;a>r;++r){s={onsuccess:null,onerror:null};var u=e[r];i.call(s,u[0],u[1],t);var h=n["delete"](u[0]);h._hookCtx=s,h.onerror=f,r===c?h.onsuccess=dn(o):h.onsuccess=l}},function(n){throw s.onerror&&s.onerror(n),n})}else for(var h=0;a>h;++h){var d=n["delete"](e[h]);d.onerror=on(pn(u)),h===c&&(d.onsuccess=on(function(){return o()}))}}).uncaught(V)}function J(n,t,e,r){var i=this;this.db=Zn,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=q(this,"complete","error","abort"),this.parent=r||null,this.active=!0,this._tables=null,this._reculock=0,this._blockedFuncs=[],this._psd=null,this._dbschema=e,this._resolve=null,this._reject=null,this._completion=new R(function(n,t){i._resolve=n,i._reject=t}).uncaught(V),this._completion.then(function(){i.on.complete.fire()},function(n){return i.on.error.fire(n),i.parent?i.parent._reject(n):i.active&&i.idbtrans&&i.idbtrans.abort(),i.active=!1,C(n)})}function Q(n,t,e){this._ctx={table:n,index:":id"===t?null:t,collClass:n._collClass,or:e}}function Y(n,t){var e=null,r=null;if(t)try{e=t()}catch(i){r=i}var o=n._ctx,u=o.table;this._ctx={table:u,index:o.index,isPrimKey:!o.index||u.schema.primKey.keyPath&&o.index===u.schema.primKey.name,range:e,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:u.hook.reading.fire}}function $(){Y.apply(this,arguments)}function X(n,t){return n._cfg.version-t._cfg.version}function Z(n,t,e,r){t.forEach(function(t){var i=Zn._tableFactory(e,r[t]);n.forEach(function(n){t in n||(n[t]=i)})})}function nn(n){n.forEach(function(n){for(var t in n)n[t]instanceof W&&delete n[t]})}function tn(n,t,e,r,i,o){var u=o?function(n,t,r){return e(o(n),t,r)}:e,a=on(u,i);n.onerror||(n.onerror=pn(i)),t?n.onsuccess=k(function(){var e=n.result;if(e){var o=function(){e["continue"]()};t(e,function(n){o=n},r,i)&&a(e.value,e,function(n){o=n}),o()}else r()},i):n.onsuccess=k(function(){var t=n.result;if(t){var e=function(){t["continue"]()};a(t.value,t,function(n){e=n}),e()}else r()},i)}function en(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace(/([&*]|\+\+)/g,""),r=/^\[/.test(e)?e.match(/^\[(.*)\]$/)[1].split("+"):e;t.push(new bn(e,r||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),Pn(r),/\./.test(n)))}),t}function rn(n,t){return Rn.cmp(n,t)}function an(n,t){return rn(n,t)<0?n:t}function cn(n,t){return rn(n,t)>0?n:t}function fn(n,t){return Rn.cmp(n,t)}function In(n,t){return Rn.cmp(t,n)}function Cn(n,t){return t>n?-1:n===t?0:1}function An(n,t){return n>t?-1:n===t?0:1}function Sn(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function Dn(){if(Zn.verno=Gn.version/10,Zn._dbSchema=Vn={},Ln=g(Gn.objectStoreNames,0),0!==Ln.length){var n=Gn.transaction(wn(Ln),"readonly");Ln.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,i=r&&"string"==typeof r&&-1!==r.indexOf("."),o=new bn(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),u=[],a=0;a<e.indexNames.length;++a){var c=e.index(e.indexNames[a]);r=c.keyPath,i=r&&"string"==typeof r&&-1!==r.indexOf(".");var s=new bn(c.name,r,!!c.unique,!!c.multiEntry,!1,r&&"string"!=typeof r,i);u.push(s)}Vn[t]=new _n(t,o,u,{})}),Z([Hn,J.prototype],En(Vn),Xn,Vn)}}function On(n,t){for(var e=t.db.objectStoreNames,r=0;r<e.length;++r)for(var i=e[r],o=t.objectStore(i),u=0;u<o.indexNames.length;++u){var a=o.indexNames[u],c=o.index(a).keyPath,s="string"==typeof c?c:"["+g(c).join("+")+"]";if(n[i]){var f=n[i].idxByName[s];f&&(f.name=a)}}}function jn(n){Zn.on("blocked").fire(n),dt.filter(function(n){return n.name===Zn.name&&n!==Zn&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var Tn,Kn,Mn=sn.dependencies,Nn=h({addons:sn.addons,autoOpen:!0,indexedDB:Mn.indexedDB,IDBKeyRange:Mn.IDBKeyRange},e),Fn=Nn.addons,qn=Nn.autoOpen,Rn=Nn.indexedDB,Un=Nn.IDBKeyRange,Vn=this._dbSchema={},Wn=[],Ln=[],Hn={},Gn=null,Jn=null,Qn=!1,Yn=!1,$n="readonly",Xn="readwrite",Zn=this,nt=new R(function(n){Tn=n}),tt=new R(function(n,t){Kn=t}),et=!0,rt=!!xn(Rn);this.version=function(n){if(Gn||Qn)throw new zn.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=Wn.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new f(n),Wn.push(t),Wn.sort(X),t)},h(f.prototype,{stores:function(n){this._cfg.storesSource=this._cfg.storesSource?h(this._cfg.storesSource,n):n;var t={};Wn.forEach(function(n){h(t,n._cfg.storesSource)});var e=this._cfg.dbschema={};return this._parseStoresSpec(t,e),Vn=Zn._dbSchema=e,nn([Hn,Zn,J.prototype]),Z([Hn,Zn,J.prototype,this._cfg.tables],En(e),Xn,e),Ln=En(e),this},upgrade:function(n){var t=this;return gt(function(){n(Zn._createTransaction(Xn,En(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){En(n).forEach(function(e){if(null!==n[e]){var r={},i=en(n[e]),o=i.shift();if(o.multi)throw new zn.Schema("Primary key cannot be multi-valued");o.keyPath&&P(r,o.keyPath,o.auto?0:o.keyPath),i.forEach(function(n){if(n.auto)throw new zn.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new zn.Schema("Index must have a name and cannot be an empty string");P(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new _n(e,o,i,r)}})}}),this._allTables=Hn,this._tableFactory=function(n,t){return n===$n?new W(t.name,t,Y):new L(t.name,t)},this._createTransaction=function(n,t,e,r){return new J(n,t,e,r)},this._whenReady=function(n){return new R(bt||Yn||ot.letThrough?n:function(t,e){if(!Qn){if(!qn)return void e(new zn.DatabaseClosed);Zn.open()["catch"](r)}nt.then(function(){n(t,e)})}).uncaught(V)},this.verno=0,this.open=function(){if(Qn||Gn)return nt.then(function(){return Jn?C(Jn,V):Zn});kn&&(tt._stackHolder=t()),Qn=!0,Jn=null,Yn=!1;var e=Tn,r=null;return R.race([tt,new R(function(t,e){if(_(function(){return t()}),Wn.length>0&&(et=!1),!Rn)throw new zn.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 i=et?Rn.open(n):Rn.open(n,Math.round(10*Zn.verno));if(!i)throw new zn.MissingAPI("IndexedDB API not available");i.onerror=on(pn(e)),i.onblocked=on(jn),i.onupgradeneeded=on(function(t){if(r=i.transaction,et&&!Zn._allowEmptyDB){i.onerror=yn,r.abort(),i.result.close();var o=Rn.deleteDatabase(n);o.onsuccess=o.onerror=on(function(){e(new zn.NoSuchDatabase("Database "+n+" doesnt exist"))})}else{r.onerror=on(pn(e));var u=t.oldVersion>Math.pow(2,62)?0:t.oldVersion;m(u/10,r,e,i)}},e),i.onsuccess=on(function(){if(r=null,Gn=i.result,dt.push(Zn),et)Dn();else if(Gn.objectStoreNames.length>0)try{On(Vn,Gn.transaction(wn(Gn.objectStoreNames),$n))}catch(e){}Gn.onversionchange=on(function(n){Zn._vcFired=!0,Zn.on("versionchange").fire(n)}),rt||mn(function(t){return-1===t.indexOf(n)?t.push(n):void 0}),t()},e)})]).then(function(){return sn.vip(Zn.on.ready.fire)}).then(function(){return Qn=!1,Zn})["catch"](function(n){try{r&&r.abort()}catch(t){}return Qn=!1,Zn.close(),Jn=n,C(Jn,V)})["finally"](function(){Yn=!0,e()})},this.close=function(){var n=dt.indexOf(Zn);if(n>=0&&dt.splice(n,1),Gn){try{Gn.close()}catch(t){}Gn=null}qn=!1,Jn=new zn.DatabaseClosed,Qn&&Kn(Jn),nt=new R(function(n){Tn=n}),tt=new R(function(n,t){Kn=t})},this["delete"]=function(){var t=arguments.length>0;return new R(function(e,r){function i(){Zn.close();var t=Rn.deleteDatabase(n);t.onsuccess=on(function(){rt||mn(function(t){var e=t.indexOf(n);return e>=0?t.splice(e,1):void 0}),e()}),t.onerror=on(pn(r)),t.onblocked=jn}if(t)throw new zn.InvalidArgument("Arguments not allowed in db.delete()");Qn?nt.then(i):i()}).uncaught(V)},this.backendDB=function(){return Gn},this.isOpen=function(){return null!==Gn},this.hasFailed=function(){return null!==Jn},this.dynamicallyOpened=function(){return et},this.name=n,v(this,"tables",{get:function(){return En(Hn).map(function(n){return Hn[n]})}}),this.on=q(this,"error","populate","blocked","versionchange",{ready:[l,r]}),this.on.ready.subscribe=b(this.on.ready.subscribe,function(n){return function(t,e){sn.vip(function(){n(t),e||n(function r(){Zn.on.ready.unsubscribe(t),Zn.on.ready.unsubscribe(r)})})}}),gt(function(){Zn.on("populate").fire(Zn._createTransaction(Xn,Ln,Vn)),Zn.on("error").fire(new Error)}),this.transaction=function(n,t,e){function r(t){var r=ot;t(R.resolve().then(function(){return un(function(){ot.transless=ot.transless||r;var t=Zn._createTransaction(n,s,Vn,a);ot.trans=t,a?t.idbtrans=a.idbtrans:t.create();var i=s.map(function(n){return t.tables[n]});i.push(t);var o;return R.follow(function(){if(o=e.apply(t,i))if("function"==typeof o.next&&"function"==typeof o["throw"])o=gn(o);else if("function"==typeof o.then&&!d(o,"_PSD"))throw new zn.IncompatiblePromise("Incompatible Promise returned from transaction scope (read more at http://tinyurl.com/znyqjqc). Transaction scope: "+e.toString())}).uncaught(V).then(function(){return a&&t._resolve(),t._completion}).then(function(){return o})["catch"](function(n){return t._reject(n),C(n)})})}))}var i=arguments.length;if(2>i)throw new zn.InvalidArgument("Too few arguments");for(var o=new Array(i-1);--i;)o[i-1]=arguments[i];e=o.pop();var u=T(o),a=ot.trans;a&&a.db===Zn&&-1===n.indexOf("!")||(a=null);var c=-1!==n.indexOf("?");n=n.replace("!","").replace("?","");try{var s=u.map(function(n){var t=n instanceof W?n.name:n;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t});if("r"==n||n==$n)n=$n;else{if("rw"!=n&&n!=Xn)throw new zn.InvalidArgument("Invalid transaction mode: "+n);n=Xn}if(a){if(a.mode===$n&&n===Xn){if(!c)throw new zn.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");a=null}a&&s.forEach(function(n){if(!d(a.tables,n)){if(!c)throw new zn.SubTransaction("Table "+n+" not included in parent transaction.");a=null}})}}catch(f){return a?a._promise(null,function(n,t){t(f)}):C(f,V)}return a?a._promise(n,r,"lock"):Zn._whenReady(r)},this.table=function(n){if(bt&&et)return new L(n);if(!d(Hn,n))throw new zn.InvalidTable("Table "+n+" does not exist");return Hn[n]},p(W.prototype,{_trans:function(n,t,e){var r=ot.trans;return r&&r.db===Zn?r._promise(n,t,e):z(n,[this.name],t)},_idbstore:function(n,t,e){function r(n,e,r){t(n,e,r.idbtrans.objectStore(o),r)}if(bt)return new R(t);var i=ot.trans,o=this.name;return i&&i.db===Zn?i._promise(n,r,e):z(n,[this.name],r)},get:function(n,t){var e=this;return this._idbstore($n,function(t,r,i){bt&&t(e.schema.instanceTemplate);var o=i.get(n);o.onerror=pn(r),o.onsuccess=function(){t(e.hook.reading.fire(o.result))}}).then(t)},where:function(n){return new Q(this,n)},count:function(n){return this.toCollection().count(n)},offset:function(n){return this.toCollection().offset(n)},limit:function(n){return this.toCollection().limit(n)},reverse:function(){return this.toCollection().reverse()},filter:function(n){return this.toCollection().and(n)},each:function(n){return this.toCollection().each(n)},toArray:function(n){return this.toCollection().toArray(n)},orderBy:function(n){return new this._collClass(new Q(this,n))},toCollection:function(){return new this._collClass(new Q(this))},mapToClass:function(n,t){this.schema.mappedClass=n;var e=Object.create(n.prototype);t&&ln(e,t),this.schema.instanceTemplate=e;var r=function(t){if(!t)return t;var e=Object.create(n.prototype);for(var r in t)d(t,r)&&(e[r]=t[r]);return e};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),n},defineClass:function(n){return this.mapToClass(sn.defineClass(n),n)}}),y(L).from(W).extend({bulkDelete:function(n){return this.hook.deleting.fire===r?this._idbstore(Xn,function(t,e,i,o){t(G(i,o,n,!1,r))}):this.where(":id").anyOf(n)["delete"]().then(function(){})},bulkPut:function(n,t){var e=this;return this._idbstore(Xn,function(i,o,u,a){if(!u.keyPath&&!e.schema.primKey.auto&&!t)throw new zn.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(u.keyPath&&t)throw new zn.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new zn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return i();var c,s,f=function(n){0===l.length?i(n):o(new N(e.name+".bulkPut(): "+l.length+" of "+h+" operations failed",l))},l=[],h=n.length,d=e;if(e.hook.creating.fire===r&&e.hook.updating.fire===r){s=H(l);for(var p=0,v=n.length;v>p;++p)c=t?u.put(n[p],t[p]):u.put(n[p]),c.onerror=s;c.onerror=H(l,f),c.onsuccess=hn(f)}else{var y=t||u.keyPath&&n.map(function(n){return E(n,u.keyPath)}),m=y&&y.reduce(function(t,e,r){return null!=e&&(t[e]=n[r]),t},{}),g=y?d.where(":id").anyOf(y.filter(function(n){return null!=n})).modify(function(){this.value=m[this.primKey],m[this.primKey]=null})["catch"](M,function(n){l=n.failures}).then(function(){for(var e=[],r=t&&[],i=y.length-1;i>=0;--i){var o=y[i];(null==o||m[o])&&(e.push(n[i]),t&&r.push(o),null!=o&&(m[o]=null))}return e.reverse(),t&&r.reverse(),d.bulkAdd(e,r)}).then(function(n){var t=y[y.length-1];return null!=t?t:n}):d.bulkAdd(n);g.then(f)["catch"](N,function(n){l=l.concat(n.failures),f()})["catch"](o)}},"locked")},bulkAdd:function(n,t){var e=this,i=this.hook.creating.fire;return this._idbstore(Xn,function(o,u,a,c){function s(n){0===d.length?o(n):u(new N(e.name+".bulkAdd(): "+d.length+" of "+p+" operations failed",d))}if(!a.keyPath&&!e.schema.primKey.auto&&!t)throw new zn.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(a.keyPath&&t)throw new zn.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new zn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return o();var f,l,h,d=[],p=n.length;if(i!==r){var v,y=a.keyPath;l=H(d,null,!0),h=dn(null),I(function(){for(var e=0,r=n.length;r>e;++e){v={onerror:null,onsuccess:null};var o=t&&t[e],u=n[e],s=t?o:y?E(u,y):void 0,d=i.call(v,s,u,c);null==s&&null!=d&&(y?(u=D(u),P(u,y,d)):o=d),f=null!=o?a.add(u,o):a.add(u),f._hookCtx=v,r-1>e&&(f.onerror=l,v.onsuccess&&(f.onsuccess=h))}},function(n){throw v.onerror&&v.onerror(n),n}),f.onerror=H(d,s,!0),f.onsuccess=dn(s)}else{l=H(d);for(var m=0,g=n.length;g>m;++m)f=t?a.add(n[m],t[m]):a.add(n[m]),f.onerror=l;f.onerror=H(d,s),f.onsuccess=hn(s)}})},add:function(n,t){var e=this.hook.creating.fire;return this._idbstore(Xn,function(i,o,u,a){var c={onsuccess:null,onerror:null};if(e!==r){var s=null!=t?t:u.keyPath?E(n,u.keyPath):void 0,f=e.call(c,s,n,a);null==s&&null!=f&&(u.keyPath?P(n,u.keyPath,f):t=f)}try{var l=null!=t?u.add(n,t):u.add(n);l._hookCtx=c,l.onerror=vn(o),l.onsuccess=dn(function(t){var e=u.keyPath;e&&P(n,e,t),i(t)})}catch(h){throw c.onerror&&c.onerror(h),h}})},put:function(n,t){var e=this,i=this.hook.creating.fire,o=this.hook.updating.fire;return i!==r||o!==r?this._trans(Xn,function(r,i,o){var u=void 0!==t?t:e.schema.primKey.keyPath&&E(n,e.schema.primKey.keyPath);null==u?o.tables[e.name].add(n).then(r,i):(o._lock(),n=D(n),o.tables[e.name].where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?o.tables[e.name].add(n,t):u})["finally"](function(){o._unlock()}).then(r,i))}):this._idbstore(Xn,function(e,r,i){var o=void 0!==t?i.put(n,t):i.put(n);o.onerror=pn(r),o.onsuccess=function(t){var r=i.keyPath;r&&P(n,r,t.target.result),e(o.result)}})},"delete":function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n)["delete"]():this._idbstore(Xn,function(t,e,r){var i=r["delete"](n);i.onerror=pn(e),i.onsuccess=function(){t(i.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection()["delete"]():this._idbstore(Xn,function(n,t,e){var r=e.clear();r.onerror=pn(t),r.onsuccess=function(){n(r.result)}})},update:function(n,t){if("object"!=typeof t||Pn(t))throw new zn.InvalidArgument("Modifications must be an object.");if("object"!=typeof n||Pn(n))return this.where(":id").equals(n).modify(t);En(t).forEach(function(e){P(n,e,t[e])});var e=E(n,this.schema.primKey.keyPath);return void 0===e?C(new zn.InvalidArgument("Given object does not contain its primary key"),V):this.where(":id").equals(e).modify(t)}}),p(J.prototype,{tables:{get:function(){return this._tables?this._tables:this._tables=this.storeNames.reduce(function(n,t){return n[t]=Hn[t],n},{})}},_lock:function(){return w(!ot.global),++this._reculock,1!==this._reculock||ot.global||(ot.lockOwnerFor=this),this},_unlock:function(){if(w(!ot.global),0===--this._reculock)for(ot.global||(ot.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(t){}}return this},_locked:function(){return this._reculock&&ot.lockOwnerFor!==this},create:function(n){var t=this;if(w(!this.idbtrans),!n&&!Gn)switch(Jn&&Jn.name){case"DatabaseClosedError":throw new zn.DatabaseClosed(Jn);case"MissingAPIError":throw new zn.MissingAPI(Jn.message,Jn);default:throw new zn.OpenFailed(Jn)}if(!this.active)throw new zn.TransactionInactive;return w(null===this._completion._state),n=this.idbtrans=n||Gn.transaction(wn(this.storeNames),this.mode),n.onerror=on(function(e){yn(e),t._reject(n.error)}),n.onabort=on(function(n){yn(n),t.active&&t._reject(new zn.Abort),t.active=!1,t.on("abort").fire(n)}),n.oncomplete=on(function(){t.active=!1,t._resolve()}),this},_promise:function(n,t,e){var r=this;return un(function(){var i;return r._locked()?i=new R(function(i,o){r._blockedFuncs.push(function(){r._promise(n,t,e).then(i,o)})}):(i=r.active?new R(function(i,o){if(n===Xn&&r.mode!==Xn)throw new zn.ReadOnly("Transaction is readonly");!r.idbtrans&&n&&r.create(),e&&r._lock(),t(i,o,r)}):C(new zn.TransactionInactive),r.active&&e&&i["finally"](function(){r._unlock()})),i._lib=!0,i.uncaught(V)})},complete:function(n){return this.on("complete",n)},error:function(n){return this.on("error",n)},abort:function(){this.active&&this._reject(new zn.Abort),this.active=!1},table:function(n){if(!d(this.tables,n))throw new zn.InvalidTable("Table "+n+" not in transaction");return this.tables[n]}}),p(Q.prototype,function(){function n(n,t,e){var r=n instanceof Q?new n._ctx.collClass(n):n;return r._ctx.error=e?new e(t):new TypeError(t),r}function t(n){return new n._ctx.collClass(n,function(){return Un.only("")}).limit(0)}function e(n){return"next"===n?function(n){return n.toUpperCase(); | ||
}:function(n){return n.toLowerCase()}}function r(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function i(n,t,e,r,i,o){for(var u=Math.min(n.length,r.length),a=-1,c=0;u>c;++c){var s=t[c];if(s!==r[c])return i(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):i(n[c],r[c])<0?n.substr(0,c)+r[c]+e.substr(c+1):a>=0?n.substr(0,a)+t[a]+e.substr(a+1):null;i(n[c],s)<0&&(a=c)}return u<r.length&&"next"===o?n+e.substr(n.length):u<n.length&&"prev"===o?n.substr(0,e.length):0>a?null:n.substr(0,a)+r[a]+e.substr(a+1)}function o(t,o,u,a){function c(n){s=e(n),f=r(n),l="next"===n?Cn:An;var t=u.map(function(n){return{lower:f(n),upper:s(n)}}).sort(function(n,t){return l(n.lower,t.lower)});h=t.map(function(n){return n.upper}),d=t.map(function(n){return n.lower}),p=n,v="next"===n?"":a}var s,f,l,h,d,p,v,y=u.length;if(!u.every(function(n){return"string"==typeof n}))return n(t,ht);c("next");var m=new t._ctx.collClass(t,function(){return Un.bound(h[0],d[y-1]+a)});m._ondirectionchange=function(n){c(n)};var g=0;return m._addAlgorithm(function(n,t,e){var r=n.key;if("string"!=typeof r)return!1;var u=f(r);if(o(u,d,g))return!0;for(var a=null,c=g;y>c;++c){var s=i(r,u,h[c],d[c],l,p);null===s&&null===a?g=c+1:(null===a||l(a,s)>0)&&(a=s)}return t(null!==a?function(){n["continue"](a+v)}:e),!1}),m}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return rn(e,r)>0||0===rn(e,r)&&(i||o)&&(!i||!o)?t(this):new this._ctx.collClass(this,function(){return Un.bound(e,r,!i,!o)})}catch(u){return n(this,lt)}},equals:function(n){return new this._ctx.collClass(this,function(){return Un.only(n)})},above:function(n){return new this._ctx.collClass(this,function(){return Un.lowerBound(n,!0)})},aboveOrEqual:function(n){return new this._ctx.collClass(this,function(){return Un.lowerBound(n)})},below:function(n){return new this._ctx.collClass(this,function(){return Un.upperBound(n,!0)})},belowOrEqual:function(n){return new this._ctx.collClass(this,function(){return Un.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,ht):this.between(t,t+st,!0,!0)},startsWithIgnoreCase:function(n){return""===n?this.startsWith(n):o(this,function(n,t){return 0===n.indexOf(t[0])},[n],st)},equalsIgnoreCase:function(n){return o(this,function(n,t){return n===t[0]},[n],"")},anyOfIgnoreCase:function(){var n=j.apply(Bn,arguments);return 0===n.length?t(this):o(this,function(n,t){return-1!==t.indexOf(n)},n,"")},startsWithAnyOfIgnoreCase:function(){var n=j.apply(Bn,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},n,st)},anyOf:function(){var e=j.apply(Bn,arguments),r=fn;try{e.sort(r)}catch(i){return n(this,lt)}if(0===e.length)return t(this);var o=new this._ctx.collClass(this,function(){return Un.bound(e[0],e[e.length-1])});o._ondirectionchange=function(n){r="next"===n?fn:In,e.sort(r)};var u=0;return o._addAlgorithm(function(n,t,i){for(var o=n.key;r(o,e[u])>0;)if(++u,u===e.length)return t(i),!1;return 0===r(o,e[u])?!0:(t(function(){n["continue"](e[u])}),!1)}),o},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,ft]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=j.apply(Bn,arguments);if(0===t.length)return new this._ctx.collClass(this);try{t.sort(fn)}catch(e){return n(this,lt)}var r=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return r.push([t[t.length-1],ft]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(n,t){for(var e=0,r=n.length;r>e;++e){var i=n[e];if(rn(t[0],i[1])<0&&rn(t[1],i[0])>0){i[0]=an(i[0],t[0]),i[1]=cn(i[1],t[1]);break}}return e===r&&n.push(t),n}function o(n,t){return l(n[0],t[0])}function u(n){return!p(n)&&!v(n)}var a=this._ctx;if(0===e.length)return t(this);if(!e.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&fn(n[0],n[1])<=0}))return n(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",zn.InvalidArgument);var c,s=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,l=fn;try{c=e.reduce(i,[]),c.sort(o)}catch(h){return n(this,lt)}var d=0,p=f?function(n){return fn(n,c[d][1])>0}:function(n){return fn(n,c[d][1])>=0},v=s?function(n){return In(n,c[d][0])>0}:function(n){return In(n,c[d][0])>=0},y=p,m=new a.collClass(this,function(){return Un.bound(c[0][0],c[c.length-1][1],!s,!f)});return m._ondirectionchange=function(n){"next"===n?(y=p,l=fn):(y=v,l=In),c.sort(o)},m._addAlgorithm(function(n,t,e){for(var r=n.key;y(r);)if(++d,d===c.length)return t(e),!1;return u(r)?!0:0===rn(r,c[d][1])||0===rn(r,c[d][0])?!1:(t(function(){l===fn?n["continue"](c[d][0]):n["continue"](c[d][1])}),!1)}),m},startsWithAnyOf:function(){var e=j.apply(Bn,arguments);return e.every(function(n){return"string"==typeof n})?0===e.length?t(this):this.inAnyRange(e.map(function(n){return[n,n+st]})):n(this,"startsWithAnyOf() only works with strings")}}}),p(Y.prototype,function(){function n(n,t){n.filter=Sn(n.filter,t)}function t(n,t){var e=n.replayFilter;n.replayFilter=e?function(){return Sn(e(),t())}:t}function e(n,t){n.isMatch=Sn(n.isMatch,t)}function r(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new zn.Schema("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return t.index(e.name)}function i(n,t){var e=r(n,t);return n.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(n.range||null,n.dir+n.unique):e.openCursor(n.range||null,n.dir+n.unique)}function o(n,t,e,r,o){var u=n.replayFilter?Sn(n.filter,n.replayFilter()):n.filter;n.or?!function(){function a(){2===++f&&e()}function c(n,e,i){if(!u||u(e,i,a,r)){var o=e.primaryKey.toString();d(s,o)||(s[o]=!0,t(n,e,i))}}var s={},f=0;n.or._iterate(c,a,r,o),tn(i(n,o),n.algorithm,c,a,r,!n.keysOnly&&n.valueMapper)}():tn(i(n,o),Sn(n.algorithm,u),t,e,r,!n.keysOnly&&n.valueMapper)}function u(n){return n.table.schema.instanceTemplate}return{_read:function(n,t){var e=this._ctx;return e.error?e.table._trans(null,function(n,t){t(e.error)}):e.table._idbstore($n,n).then(t)},_write:function(n){var t=this._ctx;return t.error?t.table._trans(null,function(n,e){e(t.error)}):t.table._idbstore(Xn,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=Sn(t.algorithm,n)},_iterate:function(n,t,e,r){return o(this._ctx,n,t,e,r)},clone:function(n){var t=Object.create(this.constructor.prototype),e=Object.create(this._ctx);return n&&h(e,n),t._ctx=e,t},raw:function(){return this._ctx.valueMapper=null,this},each:function(n){var t=this._ctx;return bt&&n(u(t)),this._read(function(e,r,i){o(t,n,e,r,i)})},count:function(n){if(bt)return R.resolve(0).then(n);var t=this._ctx;if(t.filter||t.algorithm||t.or||t.replayFilter){var e=0;return this._read(function(n,r,i){o(t,function(){return++e,!1},function(){n(e)},r,i)},n)}return this._read(function(n,e,i){var o=r(t,i),u=t.range?o.count(t.range):o.count();u.onerror=pn(e),u.onsuccess=function(t){n(t.target.result)}},n)},sortBy:function(n,t){function e(n,t){return t?e(n[i[t]],t-1):n[o]}function r(n,t){var r=e(n,u),i=e(t,u);return i>r?-a:r>i?a:0}var i=n.split(".").reverse(),o=i[0],u=i.length-1,a="next"===this._ctx.dir?1:-1;return this.toArray(function(n){return n.sort(r)}).then(t)},toArray:function(n){var t=this._ctx;return this._read(function(n,e,r){bt&&n([u(t)]);var i=[];o(t,function(n){i.push(n)},function(){n(i)},e,r)},n)},offset:function(n){var e=this._ctx;return 0>=n?this:(e.offset+=n,e.or||e.algorithm||e.filter||e.replayFilter?t(e,function(){var t=n;return function(){return--t<0}}):t(e,function(){var t=n;return function(n,e){return 0===t?!0:1===t?(--t,!1):(e(function(){n.advance(t),t=0}),!1)}}),this)},limit:function(n){return this._ctx.limit=Math.min(this._ctx.limit,n),t(this._ctx,function(){var t=n;return function(n,e,r){return--t<=0&&e(r),t>=0}}),this},until:function(t,e){var r=this._ctx;return bt&&t(u(r)),n(this._ctx,function(n,r,i){return t(n.value)?(r(i),e):!0}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},filter:function(t){return bt&&t(u(this._ctx)),n(this._ctx,function(n){return t(n.value)}),e(this._ctx,t),this},and:function(n){return this.filter(n)},or:function(n){return new Q(this._ctx.table,n,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(n){var t=this._ctx;return bt&&n(E(u(this._ctx),this._ctx.index?this._ctx.table.schema.idxByName[this._ctx.index].keyPath:this._ctx.table.schema.primKey.keyPath)),t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.key,e)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},keys:function(n){var t=this._ctx;t.keysOnly=!t.isMatch;var e=[];return bt?new R(this.eachKey.bind(this)).then(function(n){return[n]}).then(n):this.each(function(n,t){e.push(t.key)}).then(function(){return e}).then(n)},uniqueKeys:function(n){return this._ctx.unique="unique",this.keys(n)},firstKey:function(n){return this.limit(1).keys(function(n){return n[0]}).then(n)},lastKey:function(n){return this.reverse().firstKey(n)},distinct:function(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var r={};return n(this._ctx,function(n){var t=n.primaryKey.toString(),e=d(r,t);return r[t]=!0,!e}),this}}}),y($).from(Y).extend({modify:function(n){var t=this,e=this._ctx,i=e.table.hook,o=i.updating.fire,u=i.deleting.fire;return bt&&"function"==typeof n&&n.call({value:e.table.schema.instanceTemplate},e.table.schema.instanceTemplate),this._write(function(e,i,a,c){function s(n,t){function e(n){return w.push(n),x.push(r.primKey),l(),!0}k=t.primaryKey;var r={primKey:t.primaryKey,value:n,onsuccess:null,onerror:null};if(p.call(r,n,r)!==!1){var i=!d(r,"value");++g,I(function(){var n=i?t["delete"]():t.update(r.value);n._hookCtx=r,n.onerror=vn(e),n.onsuccess=dn(function(){++b,l()})},e)}else r.onsuccess&&r.onsuccess(r.value)}function f(n){return n&&(w.push(n),x.push(k)),i(new M("Error modifying one or more objects",w,b,x))}function l(){_&&b+w.length===g&&(w.length>0?f():e(b))}var p;if("function"==typeof n)p=o===r&&u===r?n:function(t){var e=D(t);if(n.call(this,t,this)===!1)return!1;if(d(this,"value")){var r=O(e,this.value),i=o.call(this,r,this.primKey,e,c);i&&(t=this.value,En(i).forEach(function(n){P(t,n,i[n])}))}else u.call(this,this.primKey,t,c)};else if(o===r){var v=En(n),y=v.length;p=function(t){for(var e=!1,r=0;y>r;++r){var i=v[r],o=n[i];E(t,i)!==o&&(P(t,i,o),e=!0)}return e}}else{var m=n;n=S(m),p=function(t){var e=!1,r=o.call(this,n,this.primKey,D(t),c);return r&&h(n,r),En(n).forEach(function(r){var i=n[r];E(t,r)!==i&&(P(t,r,i),e=!0)}),r&&(n=S(m)),e}}var g=0,b=0,_=!1,w=[],x=[],k=null;t.clone().raw()._iterate(s,function(){_=!0,l()},f,a)})},"delete":function(){var n=this,t=this._ctx,e=t.range,i=t.table.hook.deleting.fire,o=i!==r;if(!o&&!t.or&&!t.algorithm&&!t.filter&&!t.replayFilter&&(t.isPrimKey&&!yt||!e))return this._write(function(n,t,r){var i=pn(t),o=e?r.count(e):r.count();o.onerror=i,o.onsuccess=function(){var u=o.result;I(function(){var t=e?r["delete"](e):r.clear();t.onerror=i,t.onsuccess=function(){return n(u)}},function(n){return t(n)})}});var u=o?2e3:1e4;return this._write(function(e,r,a,c){var s=0,f=n.clone({keysOnly:!t.isMatch&&!o}).distinct().limit(u).raw(),l=[],h=function(){return f.each(o?function(n,t){l.push([t.primaryKey,t.value])}:function(n,t){l.push(t.primaryKey)}).then(function(){return o?l.sort(function(n,t){return fn(n[0],t[0])}):l.sort(fn),G(a,c,l,o,i)}).then(function(){var n=l.length;return s+=n,l=[],u>n?s:h()})};e(h())})}}),h(this,{Collection:Y,Table:W,Transaction:J,Version:f,WhereClause:Q,WriteableCollection:$,WriteableTable:L}),u(),Fn.forEach(function(n){n(Zn)})}function fn(n){if("function"==typeof n)return new n;if(Pn(n))return[fn(n[0])];if(n&&"object"==typeof n){var t={};return ln(t,n),t}return n}function ln(n,t){return En(t).forEach(function(e){var r=fn(t[e]);n[e]=r}),n}function hn(n){return function(t){n(t.target.result)}}function dn(n){return on(function(t){var e=t.target,r=e.result,i=e._hookCtx,o=i&&i.onsuccess;o&&o(r),n&&n(r)},n)}function pn(n){return function(t){return yn(t),n(t.target.error),!1}}function vn(n){return on(function(t){var e=t.target,r=e.error,i=e._hookCtx,o=i&&i.onerror;return o&&o(r),yn(t),n(r),!1})}function yn(n){n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault()}function mn(n){var t,e=sn.dependencies.localStorage;if(!e)return n([]);try{t=JSON.parse(e.getItem("Dexie.DatabaseNames")||"[]")}catch(r){t=[]}n(t)&&e.setItem("Dexie.DatabaseNames",JSON.stringify(t))}function gn(n){function t(n){return function(t){var e=n(t),r=e.value;return e.done?r:r&&"function"==typeof r.then?r.then(i,o):Pn(r)?R.all(r).then(i,o):i(r)}}var e=function(t){return n.next(t)},r=function(t){return n["throw"](t)},i=t(e),o=t(r);return t(e)()}function bn(n,t,e,r,i,o,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=i,this.compound=o,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(i?"++":"")+a}function _n(n,t,e,r){this.name=n,this.primKey=t||new bn,this.indexes=e||[new bn],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=e.reduce(function(n,t){return n[t.name]=t,n},{})}function wn(n){return 1===n.length?n[0]:n}function xn(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var kn="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),In=function(){return!0},Cn=!new Error("").stack,En=Object.keys,Pn=Array.isArray,An="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,Sn=Object.getPrototypeOf,Dn={}.hasOwnProperty,On=Object.getOwnPropertyDescriptor,jn=[].slice,Tn="undefined"!=typeof Symbol&&Symbol.iterator,Kn=Tn?function(n){var t;return null!=n&&(t=n[Tn])&&t.apply(n)}:function(){return null},Bn={},Mn=[].concat,Nn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","IncompatiblePromise"],Fn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],qn=Nn.concat(Fn),Rn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};y(K).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+e(this._e,2))}},toString:function(){return this.name+": "+this.message}}),y(M).from(K),y(N).from(K);var Un=qn.reduce(function(n,t){return n[t]=t+"Error",n},{}),Vn=K,zn=qn.reduce(function(n,e){function r(n,r){this._e=t(),this.name=i,n?"string"==typeof n?(this.message=n,this.inner=r||null):"object"==typeof n&&(this.message=n.name+" "+n.message,this.inner=n):(this.message=Rn[e]||i,this.inner=null)}var i=e+"Error";return y(r).from(Vn),n[e]=r,n},{});zn.Syntax=SyntaxError,zn.Type=TypeError,zn.Range=RangeError;var Wn=Fn.reduce(function(n,t){return n[t+"Error"]=zn[t],n},{}),Ln=qn.reduce(function(n,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(n[t+"Error"]=zn[t]),n},{});Ln.ModifyError=M,Ln.DexieError=K,Ln.BulkError=N;var Hn={},Gn=100,Jn=20,Qn=!1,Yn="undefined"==typeof setImmediate?function(){setTimeout(Q,0)}:setImmediate.bind(null,Q),$n=function(n,t){ut.push([n,t]),Zn&&(Yn(),Zn=!1)},Xn=!0,Zn=!0,nt=[],tt=[],et=null,rt=i,it={global:!0,ref:0,unhandleds:[],onunhandled:cn,finalize:function(){this.unhandleds.forEach(function(n){try{cn(n[0],n[1])}catch(t){}})}},ot=it,ut=[],at=0,ct=[];p(R.prototype,{then:function(n,t){var e=this,r=new R(function(r,i){L(e,new U(n,t,r,i))});return kn&&(!this._prev||null===this._state)&&J(r,this),r},_then:function(n,t){L(this,new U(null,null,n,t))},"catch":function(n){if(1===arguments.length)return this.then(null,n);var t=arguments[0],e=arguments[1];return"function"==typeof t?this.then(null,function(n){return n instanceof t?e(n):rn(n)}):this.then(null,function(n){return n&&n.name===t?e(n):rn(n)})},"finally":function(n){return this.then(function(t){return n(),t},function(t){return n(),rn(t)})},uncaught:function(n){var t=this;return this.onuncatched=f(this.onuncatched,n),this._state===!1&&-1===nt.indexOf(this)&&nt.some(function(n,e,r){return n._value===t._value&&(r[e]=t)}),this},stack:{get:function(){if(this._stack)return this._stack;try{Qn=!0;var n=G(this,[],Jn),t=n.join("\nFrom previous: ");return null!==this._state&&(this._stack=t),t}finally{Qn=!1}}}}),p(R,{all:function(){var n=j.apply(null,arguments);return new R(function(t,e){0===n.length&&t([]);var r=n.length;n.forEach(function(i,o){return R.resolve(i).then(function(e){n[o]=e,--r||t(n)},e)})})},resolve:function(n){return n&&"function"==typeof n.then?n:new R(Hn,!0,n)},reject:rn,race:function(){var n=j.apply(null,arguments);return new R(function(t,e){n.map(function(n){return R.resolve(n).then(t,e)})})},PSD:{get:function(){return ot},set:function(n){return ot=n}},newPSD:un,usePSD:an,scheduler:{get:function(){return $n},set:function(n){$n=n}},rejectionMapper:{get:function(){return rt},set:function(n){rt=n}},follow:function(n){return new R(function(t,e){return un(function(t,e){var r=ot;r.unhandleds=[],r.onunhandled=e,r.finalize=u(function(){var n=this;Z(function(){0===n.unhandleds.length?t():e(n.unhandleds[0])})},r.finalize),n()},t,e)})},on:q(null,{error:[f,en]})}),_(function(){$n=function(n,t){setTimeout(function(){n.apply(null,t)},0)}});var st=String.fromCharCode(65535),ft=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return st}}(),lt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",ht="String expected.",dt=[],pt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),vt=pt,yt=pt,mt=function(n){return!/(dexie\.js|dexie\.min\.js)/.test(n)};n(kn,mt);var gt=function(){},bt=!1;sn["delete"]=function(n){var t=new sn(n),e=t["delete"]();return e.onblocked=function(n){return t.on("blocked",n),this},e},sn.exists=function(n){return new sn(n).open().then(function(n){return n.close(),!0})["catch"](sn.NoSuchDatabaseError,function(){return!1})},sn.getDatabaseNames=function(n){return new R(function(n,t){var e=xn(indexedDB);if(e){var r=e();r.onsuccess=function(t){n(g(t.target.result,0))},r.onerror=pn(t)}else mn(function(t){return n(t),!1})}).then(n)},sn.defineClass=function(n){function t(t){t?h(this,t):bt&&ln(this,n)}return t},sn.applyStructure=ln,sn.ignoreTransaction=function(n){return ot.trans?an(ot.transless,n):n()},sn.vip=function(n){return un(function(){return ot.letThrough=!0,n()})},sn.async=function(n){return function(){try{var t=gn(n.apply(this,arguments));return t&&"function"==typeof t.then?t:R.resolve(t)}catch(e){return C(e)}}},sn.spawn=function(n,t,e){try{var r=gn(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:R.resolve(r)}catch(i){return C(i)}},v(sn,"currentTransaction",{get:function(){return ot.trans||null}}),sn.Promise=R,v(sn,"debug",{get:function(){return kn},set:function(t){n(t,"dexie"===t?function(){return!0}:mt)}}),R.rejectionMapper=F,sn.derive=y,sn.extend=h,sn.props=p,sn.override=b,sn.Events=sn.events=q,sn.getByKeyPath=E,sn.setByKeyPath=P,sn.delByKeyPath=A,sn.shallowClone=S,sn.deepClone=D,sn.addons=[],sn.fakeAutoComplete=gt,sn.asap=x,sn.maxKey=ft,sn.connections=dt,h(sn,Ln),sn.MultiModifyError=sn.ModifyError,sn.errnames=Un,sn.IndexSpec=bn,sn.TableSchema=_n;var _t=An.idbModules&&An.idbModules.shimIndexedDB?An.idbModules:{};return sn.dependencies={indexedDB:_t.shimIndexedDB||An.indexedDB||An.mozIndexedDB||An.webkitIndexedDB||An.msIndexedDB,IDBKeyRange:_t.IDBKeyRange||An.IDBKeyRange||An.webkitIDBKeyRange},I(function(){sn.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:An.localStorage}),sn.semVer="1.4.0-beta",sn.version=sn.semVer.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),_(function(){sn.fakeAutoComplete=gt=_,sn.fake=bt=!0}),sn["default"]=sn,sn}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):n.Dexie=t()}(this,function(){"use strict";function n(n,t){In=n,An=t}function t(){if(En)try{throw t.arguments,new Error}catch(n){return n}return new Error}function e(n,t){var e=n.stack;return e?(t=t||0,0===e.indexOf(n.name)&&(t+=(n.name+n.message).split("\n").length),e.split("\n").slice(t).filter(An).map(function(n){return"\n"+n}).join("")):""}function r(){}function i(n){return n}function o(n,t){return null==n||n===i?t:function(e){return t(n(e))}}function u(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function a(n,t){return n===r?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?u(r,this.onsuccess):r),i&&(this.onerror=this.onerror?u(i,this.onerror):i),void 0!==o?o:e}}function s(n,t){return n===r?t:function(){n.apply(this,arguments);var e=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?u(e,this.onsuccess):e),r&&(this.onerror=this.onerror?u(r,this.onerror):r)}}function c(n,t){return n===r?t:function(e){var r=n.apply(this,arguments);h(e,r);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?u(i,this.onsuccess):i),o&&(this.onerror=this.onerror?u(o,this.onerror):o),void 0===r?void 0===a?void 0:a:h(r,a)}}function f(n,t){return n===r?t:function(){return t.apply(this,arguments)===!1?!1:n.apply(this,arguments)}}function l(n,t){return n===r?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function h(n,t){return"object"!=typeof t?n:(Cn(t).forEach(function(e){n[e]=t[e]}),n)}function d(n,t){return Sn.call(n,t)}function v(n,t){"function"==typeof t&&(t=t(jn(n))),Cn(t).forEach(function(e){p(n,e,t[e])})}function p(n,t,e,r){Object.defineProperty(n,t,h(e&&d(e,"get")&&"function"==typeof e.get?{get:e.get,set:e.set,configurable:!0}:{value:e,configurable:!0,writable:!0},r))}function y(n){return{from:function(t){return n.prototype=Object.create(t.prototype),p(n.prototype,"constructor",n),{extend:v.bind(null,n.prototype)}}}}function m(n,t){var e,r=Dn(n,t);return r||(e=jn(n))&&m(e,t)}function g(n,t,e){return Tn.call(n,t,e)}function b(n,t){return t(n)}function _(n){var t=setTimeout(n,1e3);clearTimeout(t)}function w(n){if(!n)throw new Ln.Internal("Assertion failed")}function k(n){Pn.setImmediate?setImmediate(n):setTimeout(n,0)}function x(n,t){return n.reduce(function(n,e,r){var i=t(e,r);return i&&(n[i[0]]=i[1]),n},{})}function I(n,t){return function(){try{n.apply(this,arguments)}catch(e){t(e)}}}function A(n,t,e){try{n.apply(null,e)}catch(r){t&&t(r)}}function E(n,t){var e=U.reject(n);return t?e.uncaught(t):e}function C(n,t){if(d(n,t))return n[t];if(!t)return n;if("string"!=typeof t){for(var e=[],r=0,i=t.length;i>r;++r){var o=C(n,t[r]);e.push(o)}return e}var u=t.indexOf(".");if(-1!==u){var a=n[t.substr(0,u)];return void 0===a?void 0:C(a,t.substr(u+1))}}function O(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){w("string"!=typeof e&&"length"in e);for(var r=0,i=t.length;i>r;++r)O(n,t[r],e[r])}else{var o=t.indexOf(".");if(-1!==o){var u=t.substr(0,o),a=t.substr(o+1);if(""===a)void 0===e?delete n[u]:n[u]=e;else{var s=n[u];s||(s=n[u]={}),O(s,a,e)}}else void 0===e?delete n[t]:n[t]=e}}function P(n,t){"string"==typeof t?O(n,t,void 0):"length"in t&&[].map.call(t,function(t){O(n,t,void 0)})}function j(n){var t={};for(var e in n)d(n,e)&&(t[e]=n[e]);return t}function S(n){if(!n||"object"!=typeof n)return n;var t;if(On(n)){t=[];for(var e=0,r=n.length;r>e;++e)t.push(S(n[e]))}else if(n instanceof Date)t=new Date,t.setTime(n.getTime());else{t=n.constructor?Object.create(n.constructor.prototype):{};for(var i in n)d(n,i)&&(t[i]=S(n[i]))}return t}function D(n,t,e,r){e=e||{},r=r||"";for(var i in n)if(d(n,i))if(d(t,i)){var o=n[i],u=t[i];"object"==typeof o&&"object"==typeof u?D(o,u,e,r+i+"."):o!==u&&(e[r+i]=t[i])}else e[r+i]=void 0;for(i in t)d(t,i)&&!d(n,i)&&(e[r+i]=t[i]);return e}function T(n){var t,e,r,i;if(1===arguments.length){if(On(n))return n.slice();if(this===Mn&&"string"==typeof n)return[n];if(i=Bn(n)){for(e=[];r=i.next(),!r.done;)e.push(r.value);return e}if(null==n)return[n];if(t=n.length,"number"==typeof t){for(e=new Array(t);t--;)e[t]=n[t];return e}return[n]}for(t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];return e}function K(n){return Nn.apply([],n)}function B(n,e){this._e=t(),this.name=n,this.message=e}function M(n,t){return n+". Errors: "+t.map(function(n){return n.toString()}).filter(function(n,t,e){return e.indexOf(n)===t}).join("\n")}function N(n,e,r,i){this._e=t(),this.failures=e,this.failedKeys=i,this.successCount=r}function q(n,e){this._e=t(),this.name="BulkError",this.failures=e,this.message=M(n,e)}function F(n,t){if(!n||n instanceof B||n instanceof TypeError||n instanceof SyntaxError||!n.name||!Wn[n.name])return n;var e=new Wn[n.name](t||n.message,n);return"stack"in n&&p(e,"stack",{get:function(){return this.inner.stack}}),e}function R(n){function t(n,t,i){if("object"==typeof n)return e(n);t||(t=f),i||(i=r);var a={subscribers:[],fire:i,subscribe:function(n){-1===a.subscribers.indexOf(n)&&(a.subscribers.push(n),a.fire=t(a.fire,n))},unsubscribe:function(n){a.subscribers=a.subscribers.filter(function(t){return t!==n}),a.fire=a.subscribers.reduce(t,i)}};return o[n]=u[n]=a,a}function e(n){Cn(n).forEach(function(e){var r=n[e];if(On(r))t(e,n[e][0],n[e][1]);else{if("asap"!==r)throw new Ln.InvalidArgument("Invalid event config");var o=t(e,i,function(){for(var n=arguments.length,t=new Array(n);n--;)t[n]=arguments[n];o.subscribers.forEach(function(n){k(function(){n.apply(null,t)})})})}})}var o={},u=function(t,e){if(e){for(var r=arguments.length,i=new Array(r-1);--r;)i[r-1]=arguments[r];return o[t].subscribe.apply(null,i),n}return"string"==typeof t?o[t]:void 0};u.addEventType=t;for(var a=1,s=arguments.length;s>a;++a)t(arguments[a]);return u}function U(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=r,this._lib=!1;var e=this._PSD=ut;if(In&&(this._stackHolder=t(),this._prev=null,this._numPrev=0,Q(this,rt)),"function"!=typeof n){if(n!==Gn)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&L(this,this._value))}this._state=null,this._value=null,++e.ref,z(this,n)}function V(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r,this.psd=ut}function z(n,t){try{t(function(t){if(null===n._state){if(t===n)throw new TypeError("A promise cannot be resolved with itself.");var e=n._lib&&$();t&&"function"==typeof t.then?z(n,function(n,e){t instanceof U?t._then(n,e):t.then(n,e)}):(n._state=!0,n._value=t,W(n)),e&&X()}},L.bind(null,n))}catch(e){L(n,e)}}function L(n,t){if(et.push(t),null===n._state){var e=n._lib&&$();t=it(t),n._state=!1,n._value=t,In&&null!==t&&!t._promise&&"object"==typeof t&&A(function(){var e=m(t,"stack");t._promise=n,p(t,"stack",{get:function(){return Yn?e&&(e.get?e.get.apply(t):e.value):n.stack}})}),tn(n),W(n),e&&X()}}function W(n){var t=n._listeners;n._listeners=[];for(var e=0,r=t.length;r>e;++e)H(n,t[e]);var i=n._PSD;--i.ref||i.finalize(),0===st&&(++st,Xn(function(){0===--st&&Z()},[]))}function H(n,t){if(null===n._state)return void n._listeners.push(t);var e=n._state?t.onFulfilled:t.onRejected;if(null===e)return(n._state?t.resolve:t.reject)(n._value);var r=t.psd;++r.ref,++st,Xn(G,[e,n,t])}function G(n,t,e){var r=ut,i=e.psd;try{i!==r&&(ut=i),rt=t;var o,u=t._value;t._state?o=n(u):(et.length&&(et=[]),o=n(u),-1===et.indexOf(u)&&en(t)),e.resolve(o)}catch(a){e.reject(a)}finally{i!==r&&(ut=r),rt=null,0===--st&&Z(),--i.ref||i.finalize()}}function J(n,t,r){if(t.length===r)return t;var i="";if(n._state===!1){var o,u,a=n._value;null!=a?(o=a.name||"Error",u=a.message||a,i=e(a,0)):(o=a,u=""),t.push(o+(u?": "+u:"")+i)}return In&&(i=e(n._stackHolder,2),i&&-1===t.indexOf(i)&&t.push(i),n._prev&&J(n._prev,t,r)),t}function Q(n,t){var e=t?t._numPrev+1:0;Jn>e&&(n._prev=t,n._numPrev=e)}function Y(){$()&&X()}function $(){var n=Zn;return Zn=!1,nt=!1,n}function X(){var n,t,e;do for(;at.length>0;)for(n=at,at=[],e=n.length,t=0;e>t;++t){var r=n[t];r[0].apply(null,r[1])}while(at.length>0);Zn=!0,nt=!0}function Z(){var n=tt;tt=[],n.forEach(function(n){n._PSD.onunhandled.call(null,n._value,n)});for(var t=ct.slice(0),e=t.length;e;)t[--e]()}function nn(n){function t(){n(),ct.splice(ct.indexOf(t),1)}ct.push(t),++st,Xn(function(){0===--st&&Z()},[])}function tn(n){tt.some(function(t){return t._value===n._value})||tt.push(n)}function en(n){for(var t=tt.length;t;)if(tt[--t]._value===n._value)return void tt.splice(t,1)}function rn(n){console.warn("Unhandled rejection: "+(n.stack||n))}function on(n){return new U(Gn,!1,n)}function un(n,t){var e=ut;return function(){var r=$(),i=ut;try{return i!==e&&(ut=e),n.apply(this,arguments)}catch(o){t&&t(o)}finally{i!==e&&(ut=i),r&&X()}}}function an(n,t,e,r){var i=ut,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var u=sn(o,n,t,e,r);return 0===o.ref&&o.finalize(),u}function sn(n,t,e,r,i){var o=ut;try{return n!==o&&(ut=n),t(e,r,i)}finally{n!==o&&(ut=o)}}function cn(n,t){var e;try{e=t.onuncatched(n)}catch(r){}if(e!==!1)try{U.on.error.fire(n,t)}catch(r){}}function fn(n,e){function u(){et.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+et.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+et.name+"'. Closing db now to resume the delete request."),et.close()}),et.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+et.name+"') was blocked"):console.warn("Upgrade '"+et.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function f(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function m(n,t,e){var r=et._createTransaction(tt,Jn,Hn);r.create(t),r._completion["catch"](e);var i=r._reject.bind(r);an(function(){ut.trans=r,0===n?(Cn(Hn).forEach(function(n){B(t,n,Hn[n].primKey,Hn[n].indexes)}),U.follow(function(){return et.on.populate.fire(r)})["catch"](i)):k(n,r,t)["catch"](i)})}function k(n,t,e){function r(){return i.length?U.resolve(i.shift()(t.idbtrans)).then(r):U.resolve()}var i=[],o=Gn.filter(function(t){return t._cfg.version===n})[0];if(!o)throw new Ln.Upgrade("Dexie specification of currently installed DB version is missing");Hn=et._dbSchema=o._cfg.dbschema;var u=!1,a=Gn.filter(function(t){return t._cfg.version>n});return a.forEach(function(n){i.push(function(){var r=Hn,i=n._cfg.dbschema;Tn(r,e),Tn(i,e),Hn=et._dbSchema=i;var o=P(r,i);return o.add.forEach(function(n){B(e,n[0],n[1].primKey,n[1].indexes)}),o.change.forEach(function(n){if(n.recreate)throw new Ln.Upgrade("Not yet support for changing primary key");var t=e.objectStore(n.name);n.add.forEach(function(n){V(t,n)}),n.change.forEach(function(n){t.deleteIndex(n.name),V(t,n)}),n.del.forEach(function(n){t.deleteIndex(n)})}),n._cfg.contentUpgrade?(u=!0,U.follow(function(){n._cfg.contentUpgrade(t)})):void 0}),i.push(function(t){if(u&&!yt){var e=n._cfg.dbschema;F(e,t)}})}),r().then(function(){M(Hn,e)})}function P(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var i=n[r],o=t[r];if(i){var u={name:r,def:o,recreate:!1,del:[],add:[],change:[]};if(i.primKey.src!==o.primKey.src)u.recreate=!0,e.change.push(u);else{var a=i.idxByName,s=o.idxByName;for(var c in a)s[c]||u.del.push(c);for(c in s){var f=a[c],l=s[c];f?f.src!==l.src&&u.change.push(l):u.add.push(l)}(u.del.length>0||u.add.length>0||u.change.length>0)&&e.change.push(u)}}else e.add.push([r,o])}return e}function B(n,t,e,r){var i=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){V(i,n)}),i}function M(n,t){Cn(n).forEach(function(e){t.db.objectStoreNames.contains(e)||B(t,e,n[e].primKey,n[e].indexes)})}function F(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null==n[r]&&t.db.deleteObjectStore(r)}}function V(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function z(n){return et.on.error.fire(n)}function L(n,t,e){if(Zn||ut.letThrough){var i=et._createTransaction(n,t,Hn);return i._promise(n,function(n,t){an(function(){ut.trans=i,e(n,t,i)})}).then(function(n){return i._completion.then(function(){return n})})}if(!Xn){if(!Vn)return E(new Ln.DatabaseClosed,z);et.open()["catch"](r)}return rt.then(function(){return L(n,t,e)})}function W(n,t,e){this.name=n,this.schema=t,this.hook=Qn[n]?Qn[n].hook:R(null,{creating:[a,r],reading:[o,i],updating:[c,r],deleting:[s,r]}),this._collClass=e||$}function H(n,t,e){W.call(this,n,t,e||Z)}function G(n,t,e){return(e?yn:pn)(function(e){n.push(e),t&&t()})}function J(n,t,e,r,i){return new U(function(o,u){var a=e.length,s=a-1;if(0===a)return o();if(r){var c,f=yn(u),l=vn(null);A(function(){for(var r=0;a>r;++r){c={onsuccess:null,onerror:null};var u=e[r];i.call(c,u[0],u[1],t);var h=n["delete"](u[0]);h._hookCtx=c,h.onerror=f,r===s?h.onsuccess=vn(o):h.onsuccess=l}},function(n){throw c.onerror&&c.onerror(n),n})}else for(var h=0;a>h;++h){var d=n["delete"](e[h]);d.onerror=un(pn(u)),h===s&&(d.onsuccess=un(function(){return o()}))}}).uncaught(z)}function Q(n,t,e,r){var i=this;this.db=et,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=R(this,"complete","error","abort"),this.parent=r||null,this.active=!0,this._tables=null,this._reculock=0,this._blockedFuncs=[],this._psd=null,this._dbschema=e,this._resolve=null,this._reject=null,this._completion=new U(function(n,t){i._resolve=n,i._reject=t}).uncaught(z),this._completion.then(function(){i.on.complete.fire()},function(n){return i.on.error.fire(n),i.parent?i.parent._reject(n):i.active&&i.idbtrans&&i.idbtrans.abort(),i.active=!1,E(n)})}function Y(n,t,e){this._ctx={table:n,index:":id"===t?null:t,collClass:n._collClass,or:e}}function $(n,t){var e=null,r=null;if(t)try{e=t()}catch(i){r=i}var o=n._ctx,u=o.table;this._ctx={table:u,index:o.index,isPrimKey:!o.index||u.schema.primKey.keyPath&&o.index===u.schema.primKey.name,range:e,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:o.or,valueMapper:u.hook.reading.fire}}function X(n,t){return!(n.filter||n.algorithm||n.or)&&(t?n.justLimit:!n.replayFilter)}function Z(){$.apply(this,arguments)}function nn(n,t){return n._cfg.version-t._cfg.version}function tn(n,t,e,r){t.forEach(function(t){var i=et._tableFactory(e,r[t]);n.forEach(function(n){t in n||(n[t]=i)})})}function en(n){n.forEach(function(n){for(var t in n)n[t]instanceof W&&delete n[t]})}function rn(n,t,e,r,i,o){var u=o?function(n,t,r){return e(o(n),t,r)}:e,a=un(u,i);n.onerror||(n.onerror=pn(i)),t?n.onsuccess=I(function(){var e=n.result;if(e){var o=function(){e["continue"]()};t(e,function(n){o=n},r,i)&&a(e.value,e,function(n){o=n}),o()}else r()},i):n.onsuccess=I(function(){var t=n.result;if(t){var e=function(){t["continue"]()};a(t.value,t,function(n){e=n}),e()}else r()},i)}function on(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace(/([&*]|\+\+)/g,""),r=/^\[/.test(e)?e.match(/^\[(.*)\]$/)[1].split("+"):e;t.push(new _n(e,r||null,/\&/.test(n),/\*/.test(n),/\+\+/.test(n),On(r),/\./.test(n)))}),t}function sn(n,t){return zn.cmp(n,t)}function cn(n,t){return sn(n,t)<0?n:t}function ln(n,t){return sn(n,t)>0?n:t}function An(n,t){return zn.cmp(n,t)}function En(n,t){return zn.cmp(t,n)}function Pn(n,t){return t>n?-1:n===t?0:1}function jn(n,t){return n>t?-1:n===t?0:1}function Sn(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function Dn(){if(et.verno=Yn.version/10,et._dbSchema=Hn={},Jn=g(Yn.objectStoreNames,0),0!==Jn.length){var n=Yn.transaction(kn(Jn),"readonly");Jn.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,i=r&&"string"==typeof r&&-1!==r.indexOf("."),o=new _n(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,i),u=[],a=0;a<e.indexNames.length;++a){var s=e.index(e.indexNames[a]);r=s.keyPath,i=r&&"string"==typeof r&&-1!==r.indexOf(".");var c=new _n(s.name,r,!!s.unique,!!s.multiEntry,!1,r&&"string"!=typeof r,i);u.push(c)}Hn[t]=new wn(t,o,u,{})}),tn([Qn,Q.prototype],Cn(Hn),tt,Hn)}}function Tn(n,t){for(var e=t.db.objectStoreNames,r=0;r<e.length;++r){var i=e[r],o=t.objectStore(i);qn="getAll"in o;for(var u=0;u<o.indexNames.length;++u){var a=o.indexNames[u],s=o.index(a).keyPath,c="string"==typeof s?s:"["+g(s).join("+")+"]";if(n[i]){var f=n[i].idxByName[c];f&&(f.name=a)}}}}function Kn(n){et.on("blocked").fire(n),vt.filter(function(n){return n.name===et.name&&n!==et&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var Bn,Nn,qn,Fn=fn.dependencies,Rn=h({addons:fn.addons,autoOpen:!0,indexedDB:Fn.indexedDB,IDBKeyRange:Fn.IDBKeyRange},e),Un=Rn.addons,Vn=Rn.autoOpen,zn=Rn.indexedDB,Wn=Rn.IDBKeyRange,Hn=this._dbSchema={},Gn=[],Jn=[],Qn={},Yn=null,$n=null,Xn=!1,Zn=!1,nt="readonly",tt="readwrite",et=this,rt=new U(function(n){Bn=n}),it=new U(function(n,t){Nn=t}),ot=!0,at=!!xn(zn);this.version=function(n){if(Yn||Xn)throw new Ln.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=Gn.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new f(n),Gn.push(t),Gn.sort(nn),t)},h(f.prototype,{stores:function(n){this._cfg.storesSource=this._cfg.storesSource?h(this._cfg.storesSource,n):n;var t={};Gn.forEach(function(n){h(t,n._cfg.storesSource)});var e=this._cfg.dbschema={};return this._parseStoresSpec(t,e),Hn=et._dbSchema=e,en([Qn,et,Q.prototype]),tn([Qn,et,Q.prototype,this._cfg.tables],Cn(e),tt,e),Jn=Cn(e),this},upgrade:function(n){var t=this;return bt(function(){n(et._createTransaction(tt,Cn(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){Cn(n).forEach(function(e){if(null!==n[e]){var r={},i=on(n[e]),o=i.shift();if(o.multi)throw new Ln.Schema("Primary key cannot be multi-valued");o.keyPath&&O(r,o.keyPath,o.auto?0:o.keyPath),i.forEach(function(n){if(n.auto)throw new Ln.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new Ln.Schema("Index must have a name and cannot be an empty string");O(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new wn(e,o,i,r)}})}}),this._allTables=Qn,this._tableFactory=function(n,t){return n===nt?new W(t.name,t,$):new H(t.name,t)},this._createTransaction=function(n,t,e,r){return new Q(n,t,e,r)},this._whenReady=function(n){return new U(_t||Zn||ut.letThrough?n:function(t,e){if(!Xn){if(!Vn)return void e(new Ln.DatabaseClosed);et.open()["catch"](r)}rt.then(function(){n(t,e)})}).uncaught(z)},this.verno=0,this.open=function(){if(Xn||Yn)return rt.then(function(){return $n?E($n,z):et});In&&(it._stackHolder=t()),Xn=!0,$n=null,Zn=!1;var e=Bn,r=null;return U.race([it,new U(function(t,e){if(_(function(){return t()}),Gn.length>0&&(ot=!1),!zn)throw new Ln.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 i=ot?zn.open(n):zn.open(n,Math.round(10*et.verno));if(!i)throw new Ln.MissingAPI("IndexedDB API not available");i.onerror=un(pn(e)),i.onblocked=un(Kn),i.onupgradeneeded=un(function(t){if(r=i.transaction,ot&&!et._allowEmptyDB){i.onerror=mn,r.abort(),i.result.close();var o=zn.deleteDatabase(n);o.onsuccess=o.onerror=un(function(){e(new Ln.NoSuchDatabase("Database "+n+" doesnt exist"))})}else{r.onerror=un(pn(e));var u=t.oldVersion>Math.pow(2,62)?0:t.oldVersion;m(u/10,r,e,i)}},e),i.onsuccess=un(function(){if(r=null,Yn=i.result,vt.push(et),ot)Dn();else if(Yn.objectStoreNames.length>0)try{Tn(Hn,Yn.transaction(kn(Yn.objectStoreNames),nt))}catch(e){}Yn.onversionchange=un(function(n){et._vcFired=!0,et.on("versionchange").fire(n)}),at||gn(function(t){return-1===t.indexOf(n)?t.push(n):void 0}),t()},e)})]).then(function(){return fn.vip(et.on.ready.fire)}).then(function(){return Xn=!1,et})["catch"](function(n){try{r&&r.abort()}catch(t){}return Xn=!1,et.close(),$n=n,E($n,z)})["finally"](function(){Zn=!0,e()})},this.close=function(){var n=vt.indexOf(et);if(n>=0&&vt.splice(n,1),Yn){try{Yn.close()}catch(t){}Yn=null}Vn=!1,$n=new Ln.DatabaseClosed,Xn&&Nn($n),rt=new U(function(n){Bn=n}),it=new U(function(n,t){Nn=t})},this["delete"]=function(){var t=arguments.length>0;return new U(function(e,r){function i(){et.close();var t=zn.deleteDatabase(n);t.onsuccess=un(function(){at||gn(function(t){var e=t.indexOf(n);return e>=0?t.splice(e,1):void 0}),e()}),t.onerror=un(pn(r)),t.onblocked=Kn}if(t)throw new Ln.InvalidArgument("Arguments not allowed in db.delete()");Xn?rt.then(i):i()}).uncaught(z)},this.backendDB=function(){return Yn},this.isOpen=function(){return null!==Yn},this.hasFailed=function(){return null!==$n},this.dynamicallyOpened=function(){return ot},this.name=n,p(this,"tables",{get:function(){return Cn(Qn).map(function(n){return Qn[n]})}}),this.on=R(this,"error","populate","blocked","versionchange",{ready:[l,r]}),this.on.ready.subscribe=b(this.on.ready.subscribe,function(n){return function(t,e){fn.vip(function(){n(t),e||n(function r(){et.on.ready.unsubscribe(t),et.on.ready.unsubscribe(r)})})}}),bt(function(){et.on("populate").fire(et._createTransaction(tt,Jn,Hn)),et.on("error").fire(new Error)}),this.transaction=function(n,t,e){function r(t){var r=ut;t(U.resolve().then(function(){return an(function(){ut.transless=ut.transless||r;var t=et._createTransaction(n,c,Hn,a);ut.trans=t,a?t.idbtrans=a.idbtrans:t.create();var i=c.map(function(n){return t.tables[n]});i.push(t);var o;return U.follow(function(){if(o=e.apply(t,i))if("function"==typeof o.next&&"function"==typeof o["throw"])o=bn(o);else if("function"==typeof o.then&&!d(o,"_PSD"))throw new Ln.IncompatiblePromise("Incompatible Promise returned from transaction scope (read more at http://tinyurl.com/znyqjqc). Transaction scope: "+e.toString())}).uncaught(z).then(function(){return a&&t._resolve(),t._completion}).then(function(){return o})["catch"](function(n){return t._reject(n),E(n)})})}))}var i=arguments.length;if(2>i)throw new Ln.InvalidArgument("Too few arguments");for(var o=new Array(i-1);--i;)o[i-1]=arguments[i];e=o.pop();var u=K(o),a=ut.trans;a&&a.db===et&&-1===n.indexOf("!")||(a=null);var s=-1!==n.indexOf("?");n=n.replace("!","").replace("?","");try{var c=u.map(function(n){var t=n instanceof W?n.name:n;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t});if("r"==n||n==nt)n=nt;else{if("rw"!=n&&n!=tt)throw new Ln.InvalidArgument("Invalid transaction mode: "+n);n=tt}if(a){if(a.mode===nt&&n===tt){if(!s)throw new Ln.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");a=null}a&&c.forEach(function(n){if(!d(a.tables,n)){if(!s)throw new Ln.SubTransaction("Table "+n+" not included in parent transaction.");a=null}})}}catch(f){return a?a._promise(null,function(n,t){t(f)}):E(f,z)}return a?a._promise(n,r,"lock"):et._whenReady(r)},this.table=function(n){if(_t&&ot)return new H(n);if(!d(Qn,n))throw new Ln.InvalidTable("Table "+n+" does not exist");return Qn[n]},v(W.prototype,{_trans:function(n,t,e){var r=ut.trans;return r&&r.db===et?r._promise(n,t,e):L(n,[this.name],t)},_idbstore:function(n,t,e){function r(n,e,r){t(n,e,r.idbtrans.objectStore(o),r)}if(_t)return new U(t);var i=ut.trans,o=this.name;return i&&i.db===et?i._promise(n,r,e):L(n,[this.name],r)},get:function(n,t){var e=this;return this._idbstore(nt,function(t,r,i){_t&&t(e.schema.instanceTemplate);var o=i.get(n);o.onerror=pn(r),o.onsuccess=function(){t(e.hook.reading.fire(o.result))}}).then(t)},where:function(n){return new Y(this,n)},count:function(n){return this.toCollection().count(n)},offset:function(n){return this.toCollection().offset(n)},limit:function(n){return this.toCollection().limit(n)},reverse:function(){return this.toCollection().reverse()},filter:function(n){return this.toCollection().and(n)},each:function(n){return this.toCollection().each(n)},toArray:function(n){return this.toCollection().toArray(n)},orderBy:function(n){return new this._collClass(new Y(this,n))},toCollection:function(){return new this._collClass(new Y(this))},mapToClass:function(n,t){this.schema.mappedClass=n;var e=Object.create(n.prototype);t&&hn(e,t),this.schema.instanceTemplate=e;var r=function(t){if(!t)return t;var e=Object.create(n.prototype);for(var r in t)d(t,r)&&(e[r]=t[r]);return e};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=r,this.hook("reading",r),n},defineClass:function(n){return this.mapToClass(fn.defineClass(n),n)}}),y(H).from(W).extend({bulkDelete:function(n){return this.hook.deleting.fire===r?this._idbstore(tt,function(t,e,i,o){t(J(i,o,n,!1,r))}):this.where(":id").anyOf(n)["delete"]().then(function(){})},bulkPut:function(n,t){var e=this;return this._idbstore(tt,function(i,o,u){if(!u.keyPath&&!e.schema.primKey.auto&&!t)throw new Ln.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(u.keyPath&&t)throw new Ln.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new Ln.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return i();var a,s,c=function(n){0===f.length?i(n):o(new q(e.name+".bulkPut(): "+f.length+" of "+l+" operations failed",f))},f=[],l=n.length,h=e;if(e.hook.creating.fire===r&&e.hook.updating.fire===r){s=G(f);for(var d=0,v=n.length;v>d;++d)a=t?u.put(n[d],t[d]):u.put(n[d]),a.onerror=s;a.onerror=G(f,c),a.onsuccess=dn(c)}else{var p=t||u.keyPath&&n.map(function(n){return C(n,u.keyPath)}),y=p&&x(p,function(t,e){return null!=t&&[t,n[e]]}),m=p?h.where(":id").anyOf(p.filter(function(n){return null!=n})).modify(function(){this.value=y[this.primKey],y[this.primKey]=null})["catch"](N,function(n){f=n.failures}).then(function(){for(var e=[],r=t&&[],i=p.length-1;i>=0;--i){var o=p[i];(null==o||y[o])&&(e.push(n[i]),t&&r.push(o),null!=o&&(y[o]=null))}return e.reverse(),t&&r.reverse(),h.bulkAdd(e,r)}).then(function(n){var t=p[p.length-1];return null!=t?t:n}):h.bulkAdd(n);m.then(c)["catch"](q,function(n){f=f.concat(n.failures),c()})["catch"](o)}},"locked")},bulkAdd:function(n,t){var e=this,i=this.hook.creating.fire;return this._idbstore(tt,function(o,u,a,s){function c(n){0===d.length?o(n):u(new q(e.name+".bulkAdd(): "+d.length+" of "+v+" operations failed",d))}if(!a.keyPath&&!e.schema.primKey.auto&&!t)throw new Ln.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(a.keyPath&&t)throw new Ln.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new Ln.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return o();var f,l,h,d=[],v=n.length;if(i!==r){var p,y=a.keyPath;l=G(d,null,!0),h=vn(null),A(function(){for(var e=0,r=n.length;r>e;++e){p={onerror:null,onsuccess:null};var o=t&&t[e],u=n[e],c=t?o:y?C(u,y):void 0,d=i.call(p,c,u,s);null==c&&null!=d&&(y?(u=S(u),O(u,y,d)):o=d),f=null!=o?a.add(u,o):a.add(u),f._hookCtx=p,r-1>e&&(f.onerror=l,p.onsuccess&&(f.onsuccess=h))}},function(n){throw p.onerror&&p.onerror(n),n}),f.onerror=G(d,c,!0),f.onsuccess=vn(c)}else{l=G(d);for(var m=0,g=n.length;g>m;++m)f=t?a.add(n[m],t[m]):a.add(n[m]),f.onerror=l;f.onerror=G(d,c),f.onsuccess=dn(c)}})},add:function(n,t){var e=this.hook.creating.fire;return this._idbstore(tt,function(i,o,u,a){var s={onsuccess:null,onerror:null};if(e!==r){var c=null!=t?t:u.keyPath?C(n,u.keyPath):void 0,f=e.call(s,c,n,a);null==c&&null!=f&&(u.keyPath?O(n,u.keyPath,f):t=f)}try{var l=null!=t?u.add(n,t):u.add(n);l._hookCtx=s,l.onerror=yn(o),l.onsuccess=vn(function(t){var e=u.keyPath;e&&O(n,e,t),i(t)})}catch(h){throw s.onerror&&s.onerror(h),h}})},put:function(n,t){var e=this,i=this.hook.creating.fire,o=this.hook.updating.fire;return i!==r||o!==r?this._trans(tt,function(r,i,o){var u=void 0!==t?t:e.schema.primKey.keyPath&&C(n,e.schema.primKey.keyPath);null==u?o.tables[e.name].add(n).then(r,i):(o._lock(),n=S(n),o.tables[e.name].where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?o.tables[e.name].add(n,t):u})["finally"](function(){o._unlock()}).then(r,i))}):this._idbstore(tt,function(e,r,i){var o=void 0!==t?i.put(n,t):i.put(n);o.onerror=pn(r),o.onsuccess=function(t){var r=i.keyPath;r&&O(n,r,t.target.result),e(o.result)}})},"delete":function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n)["delete"]():this._idbstore(tt,function(t,e,r){var i=r["delete"](n);i.onerror=pn(e),i.onsuccess=function(){t(i.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection()["delete"]():this._idbstore(tt,function(n,t,e){var r=e.clear();r.onerror=pn(t),r.onsuccess=function(){n(r.result)}})},update:function(n,t){if("object"!=typeof t||On(t))throw new Ln.InvalidArgument("Modifications must be an object.");if("object"!=typeof n||On(n))return this.where(":id").equals(n).modify(t);Cn(t).forEach(function(e){O(n,e,t[e])});var e=C(n,this.schema.primKey.keyPath);return void 0===e?E(new Ln.InvalidArgument("Given object does not contain its primary key"),z):this.where(":id").equals(e).modify(t)}}),v(Q.prototype,{_lock:function(){return w(!ut.global),++this._reculock,1!==this._reculock||ut.global||(ut.lockOwnerFor=this),this},_unlock:function(){if(w(!ut.global),0===--this._reculock)for(ut.global||(ut.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(t){}}return this},_locked:function(){return this._reculock&&ut.lockOwnerFor!==this},create:function(n){var t=this;if(w(!this.idbtrans),!n&&!Yn)switch($n&&$n.name){case"DatabaseClosedError":throw new Ln.DatabaseClosed($n);case"MissingAPIError":throw new Ln.MissingAPI($n.message,$n);default:throw new Ln.OpenFailed($n)}if(!this.active)throw new Ln.TransactionInactive;return w(null===this._completion._state),n=this.idbtrans=n||Yn.transaction(kn(this.storeNames),this.mode),n.onerror=un(function(e){mn(e),t._reject(n.error)}),n.onabort=un(function(n){mn(n),t.active&&t._reject(new Ln.Abort),t.active=!1,t.on("abort").fire(n)}),n.oncomplete=un(function(){t.active=!1,t._resolve()}),this},_promise:function(n,t,e){var r=this;return an(function(){var i;return r._locked()?i=new U(function(i,o){r._blockedFuncs.push(function(){r._promise(n,t,e).then(i,o)})}):(i=r.active?new U(function(i,o){if(n===tt&&r.mode!==tt)throw new Ln.ReadOnly("Transaction is readonly");!r.idbtrans&&n&&r.create(),e&&r._lock(),t(i,o,r)}):E(new Ln.TransactionInactive),r.active&&e&&i["finally"](function(){r._unlock()})),i._lib=!0,i.uncaught(z)})},abort:function(){this.active&&this._reject(new Ln.Abort),this.active=!1},tables:{get:function(){return this._tables?this._tables:this._tables=x(this.storeNames,function(n){return[n,Qn[n]]})}},complete:function(n){return this.on("complete",n)},error:function(n){return this.on("error",n)},table:function(n){if(-1===this.storeNames.indexOf(n))throw new Ln.InvalidTable("Table "+n+" not in transaction");return Qn[n]}}),v(Y.prototype,function(){function n(n,t,e){var r=n instanceof Y?new n._ctx.collClass(n):n;return r._ctx.error=e?new e(t):new TypeError(t),r}function t(n){return new n._ctx.collClass(n,function(){ | ||
return Wn.only("")}).limit(0)}function e(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function r(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function i(n,t,e,r,i,o){for(var u=Math.min(n.length,r.length),a=-1,s=0;u>s;++s){var c=t[s];if(c!==r[s])return i(n[s],e[s])<0?n.substr(0,s)+e[s]+e.substr(s+1):i(n[s],r[s])<0?n.substr(0,s)+r[s]+e.substr(s+1):a>=0?n.substr(0,a)+t[a]+e.substr(a+1):null;i(n[s],c)<0&&(a=s)}return u<r.length&&"next"===o?n+e.substr(n.length):u<n.length&&"prev"===o?n.substr(0,e.length):0>a?null:n.substr(0,a)+r[a]+e.substr(a+1)}function o(t,o,u,a){function s(n){c=e(n),f=r(n),l="next"===n?Pn:jn;var t=u.map(function(n){return{lower:f(n),upper:c(n)}}).sort(function(n,t){return l(n.lower,t.lower)});h=t.map(function(n){return n.upper}),d=t.map(function(n){return n.lower}),v=n,p="next"===n?"":a}var c,f,l,h,d,v,p,y=u.length;if(!u.every(function(n){return"string"==typeof n}))return n(t,dt);s("next");var m=new t._ctx.collClass(t,function(){return Wn.bound(h[0],d[y-1]+a)});m._ondirectionchange=function(n){s(n)};var g=0;return m._addAlgorithm(function(n,t,e){var r=n.key;if("string"!=typeof r)return!1;var u=f(r);if(o(u,d,g))return!0;for(var a=null,s=g;y>s;++s){var c=i(r,u,h[s],d[s],l,v);null===c&&null===a?g=s+1:(null===a||l(a,c)>0)&&(a=c)}return t(null!==a?function(){n["continue"](a+p)}:e),!1}),m}return{between:function(e,r,i,o){i=i!==!1,o=o===!0;try{return sn(e,r)>0||0===sn(e,r)&&(i||o)&&(!i||!o)?t(this):new this._ctx.collClass(this,function(){return Wn.bound(e,r,!i,!o)})}catch(u){return n(this,ht)}},equals:function(n){return new this._ctx.collClass(this,function(){return Wn.only(n)})},above:function(n){return new this._ctx.collClass(this,function(){return Wn.lowerBound(n,!0)})},aboveOrEqual:function(n){return new this._ctx.collClass(this,function(){return Wn.lowerBound(n)})},below:function(n){return new this._ctx.collClass(this,function(){return Wn.upperBound(n,!0)})},belowOrEqual:function(n){return new this._ctx.collClass(this,function(){return Wn.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,dt):this.between(t,t+ft,!0,!0)},startsWithIgnoreCase:function(n){return""===n?this.startsWith(n):o(this,function(n,t){return 0===n.indexOf(t[0])},[n],ft)},equalsIgnoreCase:function(n){return o(this,function(n,t){return n===t[0]},[n],"")},anyOfIgnoreCase:function(){var n=T.apply(Mn,arguments);return 0===n.length?t(this):o(this,function(n,t){return-1!==t.indexOf(n)},n,"")},startsWithAnyOfIgnoreCase:function(){var n=T.apply(Mn,arguments);return 0===n.length?t(this):o(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},n,ft)},anyOf:function(){var e=T.apply(Mn,arguments),r=An;try{e.sort(r)}catch(i){return n(this,ht)}if(0===e.length)return t(this);var o=new this._ctx.collClass(this,function(){return Wn.bound(e[0],e[e.length-1])});o._ondirectionchange=function(n){r="next"===n?An:En,e.sort(r)};var u=0;return o._addAlgorithm(function(n,t,i){for(var o=n.key;r(o,e[u])>0;)if(++u,u===e.length)return t(i),!1;return 0===r(o,e[u])?!0:(t(function(){n["continue"](e[u])}),!1)}),o},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,lt]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=T.apply(Mn,arguments);if(0===t.length)return new this._ctx.collClass(this);try{t.sort(An)}catch(e){return n(this,ht)}var r=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return r.push([t[t.length-1],lt]),this.inAnyRange(r,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function i(n,t){for(var e=0,r=n.length;r>e;++e){var i=n[e];if(sn(t[0],i[1])<0&&sn(t[1],i[0])>0){i[0]=cn(i[0],t[0]),i[1]=ln(i[1],t[1]);break}}return e===r&&n.push(t),n}function o(n,t){return l(n[0],t[0])}function u(n){return!v(n)&&!p(n)}var a=this._ctx;if(0===e.length)return t(this);if(!e.every(function(n){return void 0!==n[0]&&void 0!==n[1]&&An(n[0],n[1])<=0}))return n(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Ln.InvalidArgument);var s,c=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,l=An;try{s=e.reduce(i,[]),s.sort(o)}catch(h){return n(this,ht)}var d=0,v=f?function(n){return An(n,s[d][1])>0}:function(n){return An(n,s[d][1])>=0},p=c?function(n){return En(n,s[d][0])>0}:function(n){return En(n,s[d][0])>=0},y=v,m=new a.collClass(this,function(){return Wn.bound(s[0][0],s[s.length-1][1],!c,!f)});return m._ondirectionchange=function(n){"next"===n?(y=v,l=An):(y=p,l=En),s.sort(o)},m._addAlgorithm(function(n,t,e){for(var r=n.key;y(r);)if(++d,d===s.length)return t(e),!1;return u(r)?!0:0===sn(r,s[d][1])||0===sn(r,s[d][0])?!1:(t(function(){l===An?n["continue"](s[d][0]):n["continue"](s[d][1])}),!1)}),m},startsWithAnyOf:function(){var e=T.apply(Mn,arguments);return e.every(function(n){return"string"==typeof n})?0===e.length?t(this):this.inAnyRange(e.map(function(n){return[n,n+ft]})):n(this,"startsWithAnyOf() only works with strings")}}}),v($.prototype,function(){function n(n,t){n.filter=Sn(n.filter,t)}function t(n,t,e){var r=n.replayFilter;n.replayFilter=r?function(){return Sn(r(),t())}:t,n.justLimit=e&&!r}function e(n,t){n.isMatch=Sn(n.isMatch,t)}function r(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new Ln.Schema("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return t.index(e.name)}function o(n,t){var e=r(n,t);return n.keysOnly&&"openKeyCursor"in e?e.openKeyCursor(n.range||null,n.dir+n.unique):e.openCursor(n.range||null,n.dir+n.unique)}function u(n,t,e,r,i){var u=n.replayFilter?Sn(n.filter,n.replayFilter()):n.filter;n.or?function(){function a(){2===++f&&e()}function s(n,e,i){if(!u||u(e,i,a,r)){var o=e.primaryKey.toString();d(c,o)||(c[o]=!0,t(n,e,i))}}var c={},f=0;n.or._iterate(s,a,r,i),rn(o(n,i),n.algorithm,s,a,r,!n.keysOnly&&n.valueMapper)}():rn(o(n,i),Sn(n.algorithm,u),t,e,r,!n.keysOnly&&n.valueMapper)}function a(n){return n.table.schema.instanceTemplate}return{_read:function(n,t){var e=this._ctx;return e.error?e.table._trans(null,function(n,t){t(e.error)}):e.table._idbstore(nt,n).then(t)},_write:function(n){var t=this._ctx;return t.error?t.table._trans(null,function(n,e){e(t.error)}):t.table._idbstore(tt,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=Sn(t.algorithm,n)},_iterate:function(n,t,e,r){return u(this._ctx,n,t,e,r)},clone:function(n){var t=Object.create(this.constructor.prototype),e=Object.create(this._ctx);return n&&h(e,n),t._ctx=e,t},raw:function(){return this._ctx.valueMapper=null,this},each:function(n){var t=this._ctx;if(_t){var e=a(t),r=t.table.schema.primKey.keyPath,i=C(e,t.index?t.table.schema.idxByName[t.index].keyPath:r),o=C(e,r);n(e,{key:i,primaryKey:o})}return this._read(function(e,r,i){u(t,n,e,r,i)})},count:function(n){if(_t)return U.resolve(0).then(n);var t=this._ctx;if(X(t,!0))return this._read(function(n,e,i){var o=r(t,i),u=t.range?o.count(t.range):o.count();u.onerror=pn(e),u.onsuccess=function(e){n(Math.min(e.target.result,t.limit))}},n);var e=0;return this._read(function(n,r,i){u(t,function(){return++e,!1},function(){n(e)},r,i)},n)},sortBy:function(n,t){function e(n,t){return t?e(n[i[t]],t-1):n[o]}function r(n,t){var r=e(n,u),i=e(t,u);return i>r?-a:r>i?a:0}var i=n.split(".").reverse(),o=i[0],u=i.length-1,a="next"===this._ctx.dir?1:-1;return this.toArray(function(n){return n.sort(r)}).then(t)},toArray:function(n){var t=this._ctx;return this._read(function(n,e,o){if(_t&&n([a(t)]),qn&&"next"===t.dir&&X(t,!0)&&t.limit>0){var s=t.table.hook.reading.fire,c=r(t,o),f=t.limit<1/0?c.getAll(t.range,t.limit):c.getAll(t.range);f.onerror=pn(e),f.onsuccess=s===i?dn(n):un(dn(function(t){n(t.map(s))}))}else{var l=[];u(t,function(n){l.push(n)},function(){n(l)},e,o)}},n)},offset:function(n){var e=this._ctx;return 0>=n?this:(e.offset+=n,X(e)?t(e,function(){var t=n;return function(n,e){return 0===t?!0:1===t?(--t,!1):(e(function(){n.advance(t),t=0}),!1)}}):t(e,function(){var t=n;return function(){return--t<0}}),this)},limit:function(n){return this._ctx.limit=Math.min(this._ctx.limit,n),t(this._ctx,function(){var t=n;return function(n,e,r){return--t<=0&&e(r),t>=0}},!0),this},until:function(t,e){var r=this._ctx;return _t&&t(a(r)),n(this._ctx,function(n,r,i){return t(n.value)?(r(i),e):!0}),this},first:function(n){return this.limit(1).toArray(function(n){return n[0]}).then(n)},last:function(n){return this.reverse().first(n)},filter:function(t){return _t&&t(a(this._ctx)),n(this._ctx,function(n){return t(n.value)}),e(this._ctx,t),this},and:function(n){return this.filter(n)},or:function(n){return new Y(this._ctx.table,n,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(n){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.key,e)})},eachUniqueKey:function(n){return this._ctx.unique="unique",this.eachKey(n)},eachPrimaryKey:function(n){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,e){n(e.primaryKey,e)})},keys:function(n){var t=this._ctx;t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.key)}).then(function(){return e}).then(n)},primaryKeys:function(n){var t=this._ctx;if(qn&&"next"===t.dir&&X(t,!0)&&t.limit>0)return this._read(function(n,e,i){var o=r(t,i),u=t.limit<1/0?o.getAllKeys(t.range,t.limit):o.getAllKeys(t.range);u.onerror=pn(e),u.onsuccess=dn(n)}).then(n);t.keysOnly=!t.isMatch;var e=[];return this.each(function(n,t){e.push(t.primaryKey)}).then(function(){return e}).then(n)},uniqueKeys:function(n){return this._ctx.unique="unique",this.keys(n)},firstKey:function(n){return this.limit(1).keys(function(n){return n[0]}).then(n)},lastKey:function(n){return this.reverse().firstKey(n)},distinct:function(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var r={};return n(this._ctx,function(n){var t=n.primaryKey.toString(),e=d(r,t);return r[t]=!0,!e}),this}}}),y(Z).from($).extend({modify:function(n){var t=this,e=this._ctx,i=e.table.hook,o=i.updating.fire,u=i.deleting.fire;return _t&&"function"==typeof n&&n.call({value:e.table.schema.instanceTemplate},e.table.schema.instanceTemplate),this._write(function(e,i,a,s){function c(n,t){function e(n){return w.push(n),k.push(r.primKey),l(),!0}x=t.primaryKey;var r={primKey:t.primaryKey,value:n,onsuccess:null,onerror:null};if(v.call(r,n,r)!==!1){var i=!d(r,"value");++g,A(function(){var n=i?t["delete"]():t.update(r.value);n._hookCtx=r,n.onerror=yn(e),n.onsuccess=vn(function(){++b,l()})},e)}else r.onsuccess&&r.onsuccess(r.value)}function f(n){return n&&(w.push(n),k.push(x)),i(new N("Error modifying one or more objects",w,b,k))}function l(){_&&b+w.length===g&&(w.length>0?f():e(b))}var v;if("function"==typeof n)v=o===r&&u===r?n:function(t){var e=S(t);if(n.call(this,t,this)===!1)return!1;if(d(this,"value")){var r=D(e,this.value),i=o.call(this,r,this.primKey,e,s);i&&(t=this.value,Cn(i).forEach(function(n){O(t,n,i[n])}))}else u.call(this,this.primKey,t,s)};else if(o===r){var p=Cn(n),y=p.length;v=function(t){for(var e=!1,r=0;y>r;++r){var i=p[r],o=n[i];C(t,i)!==o&&(O(t,i,o),e=!0)}return e}}else{var m=n;n=j(m),v=function(t){var e=!1,r=o.call(this,n,this.primKey,S(t),s);return r&&h(n,r),Cn(n).forEach(function(r){var i=n[r];C(t,r)!==i&&(O(t,r,i),e=!0)}),r&&(n=j(m)),e}}var g=0,b=0,_=!1,w=[],k=[],x=null;t.clone().raw()._iterate(c,function(){_=!0,l()},f,a)})},"delete":function(){var n=this,t=this._ctx,e=t.range,i=t.table.hook.deleting.fire,o=i!==r;if(!o&&X(t)&&(t.isPrimKey&&!mt||!e))return this._write(function(n,t,r){var i=pn(t),o=e?r.count(e):r.count();o.onerror=i,o.onsuccess=function(){var u=o.result;A(function(){var t=e?r["delete"](e):r.clear();t.onerror=i,t.onsuccess=function(){return n(u)}},function(n){return t(n)})}});var u=o?2e3:1e4;return this._write(function(e,r,a,s){var c=0,f=n.clone({keysOnly:!t.isMatch&&!o}).distinct().limit(u).raw(),l=[],h=function(){return f.each(o?function(n,t){l.push([t.primaryKey,t.value])}:function(n,t){l.push(t.primaryKey)}).then(function(){return o?l.sort(function(n,t){return An(n[0],t[0])}):l.sort(An),J(a,s,l,o,i)}).then(function(){var n=l.length;return c+=n,l=[],u>n?c:h()})};e(h())})}}),h(this,{Collection:$,Table:W,Transaction:Q,Version:f,WhereClause:Y,WriteableCollection:Z,WriteableTable:H}),u(),Un.forEach(function(n){n(et)})}function ln(n){if("function"==typeof n)return new n;if(On(n))return[ln(n[0])];if(n&&"object"==typeof n){var t={};return hn(t,n),t}return n}function hn(n,t){return Cn(t).forEach(function(e){var r=ln(t[e]);n[e]=r}),n}function dn(n){return function(t){n(t.target.result)}}function vn(n){return un(function(t){var e=t.target,r=e.result,i=e._hookCtx,o=i&&i.onsuccess;o&&o(r),n&&n(r)},n)}function pn(n){return function(t){return mn(t),n(t.target.error),!1}}function yn(n){return un(function(t){var e=t.target,r=e.error,i=e._hookCtx,o=i&&i.onerror;return o&&o(r),mn(t),n(r),!1})}function mn(n){n.stopPropagation&&n.stopPropagation(),n.preventDefault&&n.preventDefault()}function gn(n){var t,e=fn.dependencies.localStorage;if(!e)return n([]);try{t=JSON.parse(e.getItem("Dexie.DatabaseNames")||"[]")}catch(r){t=[]}n(t)&&e.setItem("Dexie.DatabaseNames",JSON.stringify(t))}function bn(n){function t(n){return function(t){var e=n(t),r=e.value;return e.done?r:r&&"function"==typeof r.then?r.then(i,o):On(r)?U.all(r).then(i,o):i(r)}}var e=function(t){return n.next(t)},r=function(t){return n["throw"](t)},i=t(e),o=t(r);return t(e)()}function _n(n,t,e,r,i,o,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=i,this.compound=o,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(i?"++":"")+a}function wn(n,t,e,r){this.name=n,this.primKey=t||new _n,this.indexes=e||[new _n],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=x(e,function(n){return[n.name,n]})}function kn(n){return 1===n.length?n[0]:n}function xn(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var In="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),An=function(){return!0},En=!new Error("").stack,Cn=Object.keys,On=Array.isArray,Pn="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,jn=Object.getPrototypeOf,Sn={}.hasOwnProperty,Dn=Object.getOwnPropertyDescriptor,Tn=[].slice,Kn="undefined"!=typeof Symbol&&Symbol.iterator,Bn=Kn?function(n){var t;return null!=n&&(t=n[Kn])&&t.apply(n)}:function(){return null},Mn={},Nn=[].concat,qn=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","IncompatiblePromise"],Fn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Rn=qn.concat(Fn),Un={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"};y(B).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+e(this._e,2))}},toString:function(){return this.name+": "+this.message}}),y(N).from(B),y(q).from(B);var Vn=Rn.reduce(function(n,t){return n[t]=t+"Error",n},{}),zn=B,Ln=Rn.reduce(function(n,e){function r(n,r){this._e=t(),this.name=i,n?"string"==typeof n?(this.message=n,this.inner=r||null):"object"==typeof n&&(this.message=n.name+" "+n.message,this.inner=n):(this.message=Un[e]||i,this.inner=null)}var i=e+"Error";return y(r).from(zn),n[e]=r,n},{});Ln.Syntax=SyntaxError,Ln.Type=TypeError,Ln.Range=RangeError;var Wn=Fn.reduce(function(n,t){return n[t+"Error"]=Ln[t],n},{}),Hn=Rn.reduce(function(n,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(n[t+"Error"]=Ln[t]),n},{});Hn.ModifyError=N,Hn.DexieError=B,Hn.BulkError=q;var Gn={},Jn=100,Qn=20,Yn=!1,$n="undefined"==typeof setImmediate?function(){setTimeout(Y,0)}:setImmediate.bind(null,Y),Xn=function(n,t){at.push([n,t]),nt&&($n(),nt=!1)},Zn=!0,nt=!0,tt=[],et=[],rt=null,it=i,ot={global:!0,ref:0,unhandleds:[],onunhandled:cn,finalize:function(){this.unhandleds.forEach(function(n){try{cn(n[0],n[1])}catch(t){}})}},ut=ot,at=[],st=0,ct=[];v(U.prototype,{then:function(n,t){var e=this,r=new U(function(r,i){H(e,new V(n,t,r,i))});return In&&(!this._prev||null===this._state)&&Q(r,this),r},_then:function(n,t){H(this,new V(null,null,n,t))},"catch":function(n){if(1===arguments.length)return this.then(null,n);var t=arguments[0],e=arguments[1];return"function"==typeof t?this.then(null,function(n){return n instanceof t?e(n):on(n)}):this.then(null,function(n){return n&&n.name===t?e(n):on(n)})},"finally":function(n){return this.then(function(t){return n(),t},function(t){return n(),on(t)})},uncaught:function(n){var t=this;return this.onuncatched=f(this.onuncatched,n),this._state===!1&&-1===tt.indexOf(this)&&tt.some(function(n,e,r){return n._value===t._value&&(r[e]=t)}),this},stack:{get:function(){if(this._stack)return this._stack;try{Yn=!0;var n=J(this,[],Qn),t=n.join("\nFrom previous: ");return null!==this._state&&(this._stack=t),t}finally{Yn=!1}}}}),v(U,{all:function(){var n=T.apply(null,arguments);return new U(function(t,e){0===n.length&&t([]);var r=n.length;n.forEach(function(i,o){return U.resolve(i).then(function(e){n[o]=e,--r||t(n)},e)})})},resolve:function(n){return n&&"function"==typeof n.then?n:new U(Gn,!0,n)},reject:on,race:function(){var n=T.apply(null,arguments);return new U(function(t,e){n.map(function(n){return U.resolve(n).then(t,e)})})},PSD:{get:function(){return ut},set:function(n){return ut=n}},newPSD:an,usePSD:sn,scheduler:{get:function(){return Xn},set:function(n){Xn=n}},rejectionMapper:{get:function(){return it},set:function(n){it=n}},follow:function(n){return new U(function(t,e){return an(function(t,e){var r=ut;r.unhandleds=[],r.onunhandled=e,r.finalize=u(function(){var n=this;nn(function(){0===n.unhandleds.length?t():e(n.unhandleds[0])})},r.finalize),n()},t,e)})},on:R(null,{error:[f,rn]})}),_(function(){Xn=function(n,t){setTimeout(function(){n.apply(null,t)},0)}});var ft=String.fromCharCode(65535),lt=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return ft}}(),ht="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",dt="String expected.",vt=[],pt="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),yt=pt,mt=pt,gt=function(n){return!/(dexie\.js|dexie\.min\.js)/.test(n)};n(In,gt);var bt=function(){},_t=!1;fn["delete"]=function(n){var t=new fn(n),e=t["delete"]();return e.onblocked=function(n){return t.on("blocked",n),this},e},fn.exists=function(n){return new fn(n).open().then(function(n){return n.close(),!0})["catch"](fn.NoSuchDatabaseError,function(){return!1})},fn.getDatabaseNames=function(n){return new U(function(n,t){var e=xn(indexedDB);if(e){var r=e();r.onsuccess=function(t){n(g(t.target.result,0))},r.onerror=pn(t)}else gn(function(t){return n(t),!1})}).then(n)},fn.defineClass=function(n){function t(t){t?h(this,t):_t&&hn(this,n)}return t},fn.applyStructure=hn,fn.ignoreTransaction=function(n){return ut.trans?sn(ut.transless,n):n()},fn.vip=function(n){return an(function(){return ut.letThrough=!0,n()})},fn.async=function(n){return function(){try{var t=bn(n.apply(this,arguments));return t&&"function"==typeof t.then?t:U.resolve(t)}catch(e){return E(e)}}},fn.spawn=function(n,t,e){try{var r=bn(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:U.resolve(r)}catch(i){return E(i)}},p(fn,"currentTransaction",{get:function(){return ut.trans||null}}),fn.Promise=U,p(fn,"debug",{get:function(){return In},set:function(t){n(t,"dexie"===t?function(){return!0}:gt)}}),U.rejectionMapper=F,fn.derive=y,fn.extend=h,fn.props=v,fn.override=b,fn.Events=fn.events=R,fn.getByKeyPath=C,fn.setByKeyPath=O,fn.delByKeyPath=P,fn.shallowClone=j,fn.deepClone=S,fn.addons=[],fn.fakeAutoComplete=bt,fn.asap=k,fn.maxKey=lt,fn.connections=vt,h(fn,Hn),fn.MultiModifyError=fn.ModifyError,fn.errnames=Vn,fn.IndexSpec=_n,fn.TableSchema=wn;var wt=Pn.idbModules&&Pn.idbModules.shimIndexedDB?Pn.idbModules:{};return fn.dependencies={indexedDB:wt.shimIndexedDB||Pn.indexedDB||Pn.mozIndexedDB||Pn.webkitIndexedDB||Pn.msIndexedDB,IDBKeyRange:wt.IDBKeyRange||Pn.IDBKeyRange||Pn.webkitIDBKeyRange},A(function(){fn.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:Pn.localStorage}),fn.semVer="1.4.0-beta2",fn.version=fn.semVer.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),_(function(){fn.fakeAutoComplete=bt=_,fn.fake=_t=!0}),fn["default"]=fn,fn}); | ||
//# sourceMappingURL=dist/dexie.min.js.map |
{ | ||
"name": "dexie", | ||
"version": "1.4.0-beta", | ||
"version": "1.4.0-beta2", | ||
"description": "A Minimalistic Wrapper for IndexedDB", | ||
@@ -5,0 +5,0 @@ "main": "dist/dexie.js", |
@@ -68,2 +68,3 @@ Dexie.js | ||
eachKey(callback: (key) => any): Promise; | ||
eachPrimaryKey(callback: (key) => any): Promise; | ||
eachUniqueKey(callback: (key) => any): Promise; | ||
@@ -86,2 +87,3 @@ equals(key): Collection; | ||
orderBy(index: string): Collection; | ||
primaryKeys(): Promise; | ||
put(item: T, key?: Key): Promise; | ||
@@ -88,0 +90,0 @@ reverse(): Collection; |
@@ -25,2 +25,3 @@ // By default, debug will be true only if platform is a web platform and its page is served from localhost. | ||
getErrorWithStack.arguments; | ||
throw new Error(); // Fallback if above line don't throw. | ||
} catch(e) { | ||
@@ -27,0 +28,0 @@ return e; |
@@ -259,3 +259,3 @@ // Type definitions for Dexie v{version} | ||
each(callback: (obj: T, cursor: IDBCursor) => any): Promise<void>; | ||
each(callback: (obj: T, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
@@ -310,5 +310,6 @@ toArray(): Promise<Array<T>>; | ||
distinct(): Collection<T, Key>; | ||
each(callback: (obj: T, cursor: IDBCursor) => any): Promise<void>; | ||
eachKey(callback: (key: Key, cursor: IDBCursor) => any): Promise<void>; | ||
eachUniqueKey(callback: (key: Key, cursor: IDBCursor) => any): Promise<void>; | ||
each(callback: (obj: T, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
eachKey(callback: (key: IndexableType, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
eachPrimaryKey(callback: (key: Key, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
eachUniqueKey(callback: (key: IndexableType, cursor: {key: IndexableType, primaryKey: Key}) => any): Promise<void>; | ||
filter(filter: (x: T) => boolean): Collection<T, Key>; | ||
@@ -318,5 +319,8 @@ first(): Promise<T>; | ||
first<U>(onFulfilled: (value: T) => U): Promise<U>; | ||
keys(): Promise<Key[]>; | ||
keys<U>(onFulfilled: (value: Key[]) => Thenable<U>): Promise<U>; | ||
keys<U>(onFulfilled: (value: Key[]) => U): Promise<U>; | ||
keys(): Promise<IndexableType[]>; | ||
keys<U>(onFulfilled: (value: IndexableType[]) => Thenable<U>): Promise<U>; | ||
keys<U>(onFulfilled: (value: IndexableType[]) => U): Promise<U>; | ||
primaryKeys(): Promise<Key[]>; | ||
primaryKeys<U>(onFulfilled: (value: Key[]) => Thenable<U>): Promise<U>; | ||
primaryKeys<U>(onFulfilled: (value: Key[]) => U): Promise<U>; | ||
last(): Promise<T>; | ||
@@ -336,5 +340,5 @@ last<U>(onFulfilled: (value: T) => Thenable<U>): Promise<U>; | ||
toArray<U>(onFulfilled: (value: Array<T>) => U): Promise<U>; | ||
uniqueKeys(): Promise<Key[]>; | ||
uniqueKeys<U>(onFulfilled: (value: Key[]) => Thenable<U>): Promise<U>; | ||
uniqueKeys<U>(onFulfilled: (value: Key[]) => U): Promise<U>; | ||
uniqueKeys(): Promise<IndexableType[]>; | ||
uniqueKeys<U>(onFulfilled: (value: IndexableType[]) => Thenable<U>): Promise<U>; | ||
uniqueKeys<U>(onFulfilled: (value: IndexableType[]) => U): Promise<U>; | ||
until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection<T, Key>; | ||
@@ -341,0 +345,0 @@ // WriteableCollection: |
@@ -94,2 +94,15 @@ /* | ||
/** Generate an object (hash map) based on given array. | ||
* @param extractor Function taking an array item and its index and returning an array of 2 items ([key, value]) to | ||
* instert on the resulting object for each item in the array. If this function returns a falsy value, the | ||
* current item wont affect the resulting object. | ||
*/ | ||
export function arrayToObject (array, extractor) { | ||
return array.reduce((result, item, i) => { | ||
var nameAndValue = extractor(item, i); | ||
if (nameAndValue) result[nameAndValue[0]] = nameAndValue[1]; | ||
return result; | ||
}, {}); | ||
} | ||
export function trycatcher(fn, reject) { | ||
@@ -96,0 +109,0 @@ return function () { |
@@ -384,2 +384,22 @@ import Dexie from 'dexie'; | ||
asyncTest("primaryKeys", function () { | ||
db.users.orderBy("last").primaryKeys(function(a) { | ||
ok(a.length, 2); | ||
equal(a[0], 2, "Second is Karl"); | ||
equal(a[1], 1, "First is David"); | ||
}).catch(function (e) { | ||
ok(false, e); | ||
}).finally(start); | ||
}); | ||
asyncTest("primaryKeys2", function () { | ||
db.users.orderBy("first").primaryKeys(function(a) { | ||
ok(a.length, 2); | ||
equal(a[0], 1, "First is David"); | ||
equal(a[1], 2, "Second is Karl"); | ||
}).catch(function (e) { | ||
ok(false, e); | ||
}).finally(start); | ||
}); | ||
asyncTest("eachKey and eachUniqueKey", function () { | ||
@@ -386,0 +406,0 @@ db.transaction("rw", db.users, function () { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1273625
17543
303