Comparing version 1.3.6-beta.2 to 1.3.6-beta.3
@@ -28,3 +28,3 @@ { | ||
], | ||
"version": "1.3.6-beta.2" | ||
"version": "1.3.6-beta.3" | ||
} |
@@ -1,2 +0,2 @@ | ||
// Type definitions for Dexie v1.3.6-beta.2 | ||
// Type definitions for Dexie v1.3.6-beta.3 | ||
// Project: https://github.com/dfahlander/Dexie.js | ||
@@ -18,3 +18,5 @@ // Definitions by: David Fahlander <http://github.com/dfahlander> | ||
addons?: Array<(db: Dexie) => void>, | ||
autoOpen?: boolean | ||
autoOpen?: boolean, | ||
indexedDB?: IDBDatabase, | ||
IDBKeyRange?: IDBKeyRange | ||
}); | ||
@@ -52,2 +54,4 @@ | ||
static maxKey: Array<string>; | ||
static dump(error:any):string; | ||
@@ -403,4 +407,6 @@ static dependencies: { | ||
inner: any; | ||
constructor (name?:string, message?:string); | ||
toString(): string; | ||
dump(): string; | ||
} | ||
@@ -427,2 +433,3 @@ | ||
class DatabaseClosedError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} | ||
class IncompatiblePromiseError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} | ||
class UnknownError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} | ||
@@ -429,0 +436,0 @@ class ConstraintError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} |
@@ -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){return"object"!=typeof t&&(t=t()),tn(t).forEach(function(e){n[e]=t[e]}),n}function t(t){return{from:function(e){return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,{extend:function(r){n(t.prototype,"object"!=typeof r?r(e.prototype):r)}}}}}function e(n,t,e){return on.call(n,t,e)}function r(n,t){return t(n)}function o(n){var t=setTimeout(n,1e3);clearTimeout(t)}function i(n){if(!n)throw new hn.Internal("Assertion failed")}function u(n){rn.setImmediate?setImmediate(n):setTimeout(n,0)}function a(n,t){try{n()}catch(e){t&&t(e)}}function c(n){if(n.stack)return n;try{var t=new Error(n.message||n);if(t.stack)return n.stack=t.stack,n;throw t}catch(e){n.stack=e.stack}return n}function s(n){return T.reject(c(n))}function f(n,t){if(n.hasOwnProperty(t))return n[t];if(!t)return n;if("string"!=typeof t){for(var e=[],r=0,o=t.length;o>r;++r){var i=f(n,t[r]);e.push(i)}return e}var u=t.indexOf(".");if(-1!==u){var a=n[t.substr(0,u)];return void 0===a?void 0:f(a,t.substr(u+1))}}function l(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){i("string"!=typeof e&&"length"in e);for(var r=0,o=t.length;o>r;++r)l(n,t[r],e[r])}else{var u=t.indexOf(".");if(-1!==u){var a=t.substr(0,u),c=t.substr(u+1);if(""===c)void 0===e?delete n[a]:n[a]=e;else{var s=n[a];s||(s=n[a]={}),l(s,c,e)}}else void 0===e?delete n[t]:n[t]=e}}function h(n,t){"string"==typeof t?l(n,t,void 0):"length"in t&&[].map.call(t,function(t){l(n,t,void 0)})}function d(n){var t={};for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t}function p(n){if(!n||"object"!=typeof n)return n;var t;if(en(n)){t=[];for(var e=0,r=n.length;r>e;++e)t.push(p(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 o in n)n.hasOwnProperty(o)&&(t[o]=p(n[o]))}return t}function v(n,t,e,r){e=e||{},r=r||"";for(var o in n)if(n.hasOwnProperty(o))if(t.hasOwnProperty(o)){var i=n[o],u=t[o];"object"==typeof i&&"object"==typeof u?v(i,u,e,r+o+"."):i!==u&&(e[r+o]=t[o])}else e[r+o]=void 0;for(o in t)t.hasOwnProperty(o)&&!n.hasOwnProperty(o)&&(e[r+o]=t[o]);return e}function y(n,t){this.name=n,this.message=t}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 g(n,t,e,r){this.name="ModifyError",this.failures=t,this.failedKeys=r,this.successCount=e,this.message=m(n,t)}function b(n,t){this.name="BulkError",this.failures=t,this.message=m(n,t)}function w(n,t){var e=n;return n instanceof y||!n.name||!dn[n.name]||(e=new dn[n.name](t||n.message,n),n.stack&&(e.stack=n.stack)),e}function _(){}function x(n){return n}function P(n,t){return null==n||n===x?t:function(e){return t(n(e))}}function k(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function D(n,t){return n===_?t:function(){var e=n.apply(this,arguments);void 0!==e&&(arguments[0]=e);var r=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var i=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?k(r,this.onsuccess):r),o&&(this.onerror=this.onerror?k(o,this.onerror):o),void 0!==i?i:e}}function S(n,t){return n===_?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?k(e,this.onsuccess):e),r&&(this.onerror=this.onerror?k(r,this.onerror):r)}}function O(t,e){return t===_?e:function(){var r=t.apply(this,arguments);void 0!==r&&n(arguments[0],r);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var u=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?k(o,this.onsuccess):o),i&&(this.onerror=this.onerror?k(i,this.onerror):i),void 0===r?void 0===u?void 0:u:void 0===u?r:n(r,u)}}function I(n,t){return n===_?t:function(){return n.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function E(n,t){return n===_?t:function(){return t.apply(this,arguments)===!1?!1:n.apply(this,arguments)}}function C(n,t){return n===_?t:function(){var e=n.apply(this,arguments);if(e&&"function"==typeof e.then){var r=this,o=arguments;return e.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function j(n){function t(n,t,e){if(en(n))return o(n);if("object"==typeof n)return r(n);t||(t=I),e||(e=_);var i={subscribers:[],fire:e,subscribe:function(n){i.subscribers.push(n),i.fire=t(i.fire,n)},unsubscribe:function(n){i.subscribers=i.subscribers.filter(function(t){return t!==n}),i.fire=i.subscribers.reduce(t,e)}};return a[n]=c[n]=i,i}function r(n){tn(n).forEach(function(e){var r=n[e];if(en(r))t(e,n[e][0],n[e][1]);else{if("asap"!==r)throw new hn.InvalidArgument("Invalid event config");var o=t(e,null,function(){var n=arguments;o.subscribers.forEach(function(t){u(function(){t.apply(rn,n)})})});o.subscribe=function(n){-1===o.subscribers.indexOf(n)&&o.subscribers.push(n)},o.unsubscribe=function(n){var t=o.subscribers.indexOf(n);-1!==t&&o.subscribers.splice(t,1)}}})}function o(n){function e(){return r?!1:void(r=!0)}var r=!1;n.forEach(function(n){t(n).subscribe(e)})}var i=arguments,a={},c=function(t,r){if(r){var o=e(arguments,1),i=a[t];return i.subscribe.apply(i,o),n}return"string"==typeof t?a[t]:void 0};c.addEventType=t;for(var s=1,f=i.length;f>s;++s)t(i[s]);return c}function A(){var n=gn;gn=[];for(var t=0,e=n.length;e>t;++t){var r=n[t];r[0].apply(rn,r[1])}}function T(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],this._catched=!1;var t=this,e=!0;this._PSD=T.PSD;try{U(this,n,function(n){e?yn(N,t,n):N(t,n)},function(n){return e?(yn(R,t,n),!1):R(t,n)})}finally{e=!1}}function K(n,t){if(null===n._state)return void n._deferreds.push(t);var e=n._state?t.onFulfilled:t.onRejected;if(null===e)return(n._state?t.resolve:t.reject)(n._value);var r,o=mn;mn=!1,yn=wn;try{var i=T.PSD;T.PSD=n._PSD,r=e(n._value),n._state||r&&"function"==typeof r.then&&r._state===!1||B(n),t.resolve(r)}catch(u){t.reject(u)}finally{if(T.PSD=i,o){do{for(;gn.length>0;)A();var a=bn.pop();if(a)try{a()}catch(u){}}while(bn.length>0||gn.length>0);yn=vn,mn=!0}}}function F(n){var t=mn;mn=!1,yn=wn;try{return n()}finally{if(t){do{for(;gn.length>0;)A();var e=bn.pop();if(e)try{e()}catch(r){}}while(bn.length>0||gn.length>0);yn=vn,mn=!0}}}function B(n){n._catched=!0,n._parent&&!n._parent._catched&&B(n._parent)}function N(n,t){var e=T.PSD;T.PSD=n._PSD;try{if(t===n)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)return t instanceof T&&null!==t._state?(n._state=t._state,n._value=t._value,void q.call(n)):void U(n,function(n,e){t.then(n,e)},function(t){N(n,t)},function(t){R(n,t)});n._state=!0,n._value=t,q.call(n)}catch(r){R(r)}finally{T.PSD=e}}function R(n,t){var e=T.PSD;if(T.PSD=n._PSD,n._state=!1,n._value=t,q.call(n),!n._catched)try{n.onuncatched?n.onuncatched(n._value):T.on.error.fire(n._value)}catch(r){}return T.PSD=e,n._catched}function q(){for(var n=0,t=this._deferreds.length;t>n;n++)K(this,this._deferreds[n]);this._deferreds=[]}function M(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r}function U(n,t,e,r){var o=!1;try{t(function(n){o||(o=!0,e(n))},function(t){return o?n._catched:(o=!0,r(t))})}catch(i){if(o)return;return r(i)}}function V(n){console.error("Uncaught Promise: "+(n.stack||n))}function W(o,i){function h(){Xn.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+Xn.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+Xn.name+"'. Closing db now to resume the delete request."),Xn.close()}),Xn.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+Xn.name+"') was blocked"):console.warn("Upgrade '"+Xn.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function y(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function m(n,t,o,i){if(0===n){tn(Mn).forEach(function(n){I(t,n,Mn[n].primKey,Mn[n].indexes)});var u=Xn._createTransaction(Qn,Vn,Mn);u.idbtrans=t,u.idbtrans.onerror=J(o,["populating database"]),u.on("error").subscribe(o),T.newPSD(function(){T.PSD.trans=u;try{Xn.on("populate").fire(u)}catch(n){i.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(e){}t.db.close(),o(n)}})}else{var a=[],c=Un.filter(function(t){return t._cfg.version===n})[0];if(!c)throw new hn.Upgrade("Dexie specification of currently installed DB version is missing");Mn=Xn._dbSchema=c._cfg.dbschema;var s=!1,f=Un.filter(function(t){return t._cfg.version>n});f.forEach(function(n){var i=Mn,u=n._cfg.dbschema;An(i,t),An(u,t),Mn=Xn._dbSchema=u;var c=k(i,u);c.add.forEach(function(n){a.push(function(t,e){I(t,n[0],n[1].primKey,n[1].indexes),e()})}),c.change.forEach(function(n){if(n.recreate)throw new hn.Upgrade("Not yet support for changing primary key");a.push(function(t,e){var r=t.objectStore(n.name);n.add.forEach(function(n){F(r,n)}),n.change.forEach(function(n){r.deleteIndex(n.name),F(r,n)}),n.del.forEach(function(n){r.deleteIndex(n)}),e()})}),n._cfg.contentUpgrade&&a.push(function(t,i){s=!0;var a=Xn._createTransaction(Qn,e(t.db.objectStoreNames),u);a.idbtrans=t;var c=0;a._promise=r(a._promise,function(n){return function(t,e,r){function o(n){return function(){n.apply(this,arguments),0===--c&&i()}}return++c,n.call(this,t,function(n,t){arguments[0]=o(n),arguments[1]=o(t),e.apply(this,arguments)},r)}}),t.onerror=J(o,["running upgrader function for version",n._cfg.version]),a.on("error").subscribe(o),n._cfg.contentUpgrade(a),0===c&&i()}),s&&!On||a.push(function(n,t){K(u,n),t()})});var l=function(){try{a.length?a.shift()(t,l):A(Mn,t)}catch(n){i.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(e){}t.db.close(),o(n)}};l()}}function k(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var o=n[r],i=t[r];if(o){var u={name:r,def:t[r],recreate:!1,del:[],add:[],change:[]};if(o.primKey.src!==i.primKey.src)u.recreate=!0,e.change.push(u);else{var a=o.indexes.reduce(function(n,t){return n[t.name]=t,n},{}),c=i.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,i])}return e}function I(n,t,e,r){var o=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){F(o,n)}),o}function A(n,t){tn(n).forEach(function(e){t.db.objectStoreNames.contains(e)||I(t,e,n[e].primKey,n[e].indexes)})}function K(n,t){for(var e=0;e<t.db.objectStoreNames.length;++e){var r=t.db.objectStoreNames[e];null!==n[r]&&void 0!==n[r]||t.db.deleteObjectStore(r)}}function F(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function B(){Zn.forEach(function(n){n.resume()})}function N(n,t){throw new hn.InvalidTable("Table "+t[0]+" not part of transaction. Original Scope Function Source: "+W.Promise.PSD.trans.scopeFunc.toString())}function R(n,t,e,r){this.name=n,this.schema=e,this.hook=Wn[n]?Wn[n].hook:j(null,{creating:[D,_],reading:[P,x],updating:[O,_],deleting:[S,_]}),this._tpf=t,this._collClass=r||un}function q(n,t,e,r){R.call(this,n,t,e,r||an)}function M(n,t){var e=T.PSD;return function(r){try{r.stopPropagation&&r.stopPropagation(),r.preventDefault&&r.preventDefault();var o=r.target.error;n.push(o),r.target._err&&T.usePSD(e,r.target._err.bind(null,o))}finally{t&&t()}}}function U(n){var t=T.PSD;return function(e){var r;try{r=e.target.error,e.target._err&&T.usePSD(t,e.target._err.bind(null,r))}finally{n(r)}}}function V(n,t){var e=T.PSD;return t?function(t){var r;try{r=t.target.result,t.target._suc&&T.usePSD(e,t.target._suc.bind(null,r))}finally{n&&n(r)}}:function(t){n(t.target.result)}}function z(n,t,e,r,o){return new T(function(i,u){var c=e.length,s=c-1;if(0===c)return i();if(r){var f={onsuccess:null,onerror:null},l=U(function(n){return u(w(n))}),h=V(null,!0);a(function(){for(var r=0;c>r;++r){var u=e[r];o.call(f,u[0],u[1],t);var a=n["delete"](u[0]);f.onerror&&(a._err=f.onerror),f.onsuccess&&(a._suc=f.onsuccess),a.onerror=l,r===s?a.onsuccess=V(i,!0):a.onsuccess=h,f.onsuccess=null,f.onerror=null}},function(n){throw f.onerror&&f.onerror(n),n})}else for(var d=0;c>d;++d){var p=n["delete"](e[d]);p.onerror=function(n){return u(w(n.target.error))},d===s&&(p.onsuccess=function(){return i()})}})}function rn(n,t,e,r){function o(n,t,e,r){return i._promise(n,e,r)}var i=this;this.db=Xn,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=j(this,["complete","error"],"abort"),this._reculock=0,this._blockedFuncs=[],this._psd=null,this.active=!0,this._dbschema=e,r&&(this.parent=r),this._tpf=o,this.tables=Object.create(Ln);for(var u=t.length-1;-1!==u;--u){var a=t[u],c=Xn._tableFactory(n,e[a],o);this.tables[a]=c,this[a]||(this[a]=c)}}function on(n,t,e){this._ctx={table:n,index:":id"===t?null:t,collClass:n._collClass,or:e}}function un(n,t){var e=null,r=null;if(t)try{e=t()}catch(o){r=c(w(o))}var i=n._ctx,u=i.table;this._ctx={table:u,index:i.index,isPrimKey:!i.index||u.schema.primKey.keyPath&&i.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:i.or,valueFilter:u.hook.reading.fire}}function an(){un.apply(this,arguments)}function cn(n,t){return n._cfg.version-t._cfg.version}function sn(n,t,e,r,o,i){e.forEach(function(e){var u=Xn._tableFactory(r,o[e],t);n.forEach(function(n){n[e]||(i?Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var n=T.PSD&&T.PSD.trans;return n&&n.db===Xn?n.tables[e]:u}}):n[e]=u)})})}function fn(n){n.forEach(function(n){for(var t in n)n[t]instanceof R&&delete n[t]})}function ln(n,t,e,r,o,i){i=i||x,n.onerror||(n.onerror=J(o)),t?n.onsuccess=L(function(){var u=n.result;if(u){var a=function(){u["continue"]()};t(u,function(n){a=n},r,o)&&e(i(u.value),u,function(n){a=n}),a()}else r()},o):n.onsuccess=L(function(){var t=n.result;if(t){var o=function(){t["continue"]()};e(i(t.value),t,function(n){o=n}),o()}else r()},o)}function dn(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace("&","").replace("++","").replace("*",""),r=0!==e.indexOf("[")?e:n.substring(n.indexOf("[")+1,n.indexOf("]")).split("+");t.push(new X(e,r||null,-1!==n.indexOf("&"),-1!==n.indexOf("*"),-1!==n.indexOf("++"),en(r),-1!==r.indexOf(".")))}),t}function pn(n,t){return Rn.cmp(n,t)}function vn(n,t){return pn(n,t)<0?n:t}function yn(n,t){return pn(n,t)>0?n:t}function mn(n,t){return Rn.cmp(n,t)}function gn(n,t){return Rn.cmp(t,n)}function bn(n,t){return t>n?-1:n===t?0:1}function wn(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 jn(){if(Xn.verno=zn.version/10,Xn._dbSchema=Mn={},Vn=e(zn.objectStoreNames,0),0!==Vn.length){var n=zn.transaction($(Vn),"readonly");Vn.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf("."),i=new X(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,o),u=[],a=0;a<e.indexNames.length;++a){var c=e.index(e.indexNames[a]);r=c.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf(".");var s=new X(c.name,r,!!c.unique,!!c.multiEntry,!1,r&&"string"!=typeof r,o);u.push(s)}Mn[t]=new Z(t,i,u,{})}),sn([Wn],Xn._transPromiseFactory,tn(Mn),Qn,Mn)}}function An(n,t){for(var r=t.db.objectStoreNames,o=0;o<r.length;++o)for(var i=r[o],u=t.objectStore(i),a=0;a<u.indexNames.length;++a){var c=u.indexNames[a],s=u.index(c).keyPath,f="string"==typeof s?s:"["+e(s).join("+")+"]";if(n[i]){var l=n[i].idxByName[f];l&&(l.name=c)}}}function Tn(n){Xn.on("blocked").fire(n),Dn.filter(function(n){return n.name===Xn.name&&n!==Xn&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var Kn=W.dependencies,Fn=n({addons:W.addons,autoOpen:!0,indexedDB:Kn.indexedDB,IDBKeyRange:Kn.IDBKeyRange},i||{}),Bn=Fn.addons,Nn=Fn.autoOpen,Rn=Fn.indexedDB,qn=Fn.IDBKeyRange,Mn=this._dbSchema={},Un=[],Vn=[],Wn={},Ln={},zn=null,Hn=!0,Jn=null,Gn=!1,Yn="readonly",Qn="readwrite",Xn=this,Zn=[],$n=!0,nt=!!nn(Rn);this.version=function(n){if(zn||Gn)throw new hn.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,n);var t=Un.filter(function(t){return t._cfg.version===n})[0];return t?t:(t=new y(n),Un.push(t),Un.sort(cn),t)},n(y.prototype,{stores:function(t){this._cfg.storesSource=this._cfg.storesSource?n(this._cfg.storesSource,t):t;var e={};Un.forEach(function(t){n(e,t._cfg.storesSource)});var r=this._cfg.dbschema={};return this._parseStoresSpec(e,r),Mn=Xn._dbSchema=r,fn([Wn,Xn,Ln]),sn([Ln],N,tn(r),Qn,r),sn([Wn,Xn,this._cfg.tables],Xn._transPromiseFactory,tn(r),Qn,r,!0),Vn=tn(r),this},upgrade:function(n){var t=this;return En(function(){n(Xn._createTransaction(Qn,tn(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){tn(n).forEach(function(e){if(null!==n[e]){var r={},o=dn(n[e]),i=o.shift();if(i.multi)throw new hn.Schema("Primary key cannot be multi-valued");i.keyPath&&l(r,i.keyPath,i.auto?0:i.keyPath),o.forEach(function(n){if(n.auto)throw new hn.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new hn.Schema("Index must have a name and cannot be an empty string");l(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new Z(e,i,o,r)}})}}),this._allTables=Wn,this._tableFactory=function(n,t,e){return n===Yn?new R(t.name,e,t,un):new q(t.name,e,t)},this._createTransaction=function(n,t,e,r){return new rn(n,t,e,r)},this._transPromiseFactory=function(n,t,e){if(!Hn||T.PSD&&T.PSD.letThrough){var r=Xn._createTransaction(n,t,Mn);return r._promise(n,function(n,t){r.error(function(n){Xn.on("error").fire(n)}),T.newPSD(function(){T.PSD.trans=r,e(function(t){r.complete(function(){n(t)})},t,r)})})}if(!Gn&&!Nn)return s(new hn.DatabaseClosed);var o=new T(function(r,i){Zn.push({resume:function(){var u=Xn._transPromiseFactory(n,t,e);o.onuncatched=u.onuncatched,u.then(r,i)}})});return Nn&&!Gn&&Xn.open()["catch"](_),o},this._whenReady=function(n){if(!Cn&&Hn&&(!T.PSD||!T.PSD.letThrough)){if(!Gn){if(!Nn)return s(new hn.DatabaseClosed);Xn.open()["catch"](_)}return new T(function(t,e){Zn.push({resume:function(){n(t,e)}})})}return new T(n)},this.verno=0,this.open=function(){return zn?T.resolve(Xn):Gn?new T(function(n,t){return Xn._whenReady(function(){n(Xn)},function(n){t(n)})}):(Jn=null,Gn=!0,Hn=!0,new T(function(n,t){function e(n){try{r.transaction.abort()}catch(e){}if(zn)try{zn.close()}catch(e){}zn=null,Gn=!1,Jn=w(n),Hn=!1,t(Jn),B()}Cn&&n();var r;try{if(Un.length>0&&($n=!1),!Rn)throw new hn.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using Safari, make sure to include indexedDB polyfill.");if(r=$n?Rn.open(o):Rn.open(o,Math.round(10*Xn.verno)),!r)throw new hn.MissingAPI("IndexedDB API not available");r.onerror=J(e,["opening database",o]),r.onblocked=Tn,r.onupgradeneeded=L(function(n){if($n&&!Xn._allowEmptyDB){r.onerror=function(n){n.preventDefault()},r.transaction.abort(),r.result.close();var t=Rn.deleteDatabase(o);t.onsuccess=t.onerror=function(){e(new hn.NoSuchDatabase("Database "+o+" doesnt exist"))}}else{r.transaction.onerror=J(e);var i=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;m(i/10,r.transaction,e,r)}},e),r.onsuccess=L(function(){if(Gn=!1,zn=r.result,$n)jn();else if(zn.objectStoreNames.length>0)try{An(Mn,zn.transaction($(zn.objectStoreNames),Yn))}catch(t){}zn.onversionchange=function(n){Xn._vcFired=!0,Xn.on("versionchange").fire(n)},nt||Y(function(n){return-1===n.indexOf(o)?n.push(o):void 0}),T.newPSD(function(){function t(){Hn=!1,B(),n()}T.PSD.letThrough=!0;try{var r=Xn.on.ready.fire();r&&"function"==typeof r.then?r.then(t,function(n){zn.close(),zn=null,e(n)}):u(t)}catch(o){e(o)}})},e)}catch(i){e(i)}}).then(function(){return Dn.push(Xn),Xn}))},this.close=function(){var n=Dn.indexOf(Xn);n>=0&&Dn.splice(n,1),zn?(zn.close(),zn=null,Nn=!1,Hn&&B(),Hn=!1,Jn=new hn.DatabaseClosed):Gn&&Xn.on("ready",function(){return T.reject(new hn.DatabaseClosed)})},this["delete"]=function(){var n=arguments;return new T(function(t,e){function r(){Xn.close();var n=Rn.deleteDatabase(o);n.onsuccess=function(){nt||Y(function(n){var t=n.indexOf(o);return t>=0?n.splice(t,1):void 0}),t()},n.onerror=J(e,["deleting",o]),n.onblocked=Tn}if(n.length>0)throw new hn.InvalidArgument("Arguments not allowed in db.delete()");Gn?Zn.push({resume:r}):r()})},this.backendDB=function(){return zn},this.isOpen=function(){return null!==zn},this.hasFailed=function(){return null!==Jn},this.dynamicallyOpened=function(){return $n},this.name=o,Object.defineProperty(this,"tables",{get:function(){return tn(Wn).map(function(n){return Wn[n]})}}),this.on=j(this,"error","populate",{blocked:[E,_],ready:[C,_],versionchange:[E,_]}),this.on.ready.subscribe=r(this.on.ready.subscribe,function(n){return function(t,e){function r(){return e||Xn.on.ready.unsubscribe(r),t.apply(this,arguments)}n.call(this,r),Xn.isOpen()&&(Hn?Zn.push({resume:r}):r())}}),En(function(){Xn.on("populate").fire(Xn._createTransaction(Qn,Vn,Mn)),Xn.on("error").fire(new Error)}),this.transaction=function(n,t,o){function i(t,e){var i=null,s=!0;try{if(l)throw l;i=Xn._createTransaction(n,h,Mn,a);var f=h.map(function(n){return i.tables[n]});f.push(i);var d,p=0;T.newPSD(function(){T.PSD.trans=i,i.scopeFunc=o,a&&(i.idbtrans=a.idbtrans,i._promise=r(i._promise,function(n){return function(t,e,r){function o(n){return function(t){var e;return T._rootExec(function(){e=n(t),T._tickFinalize(function(){0===--p&&i.active&&(i.active=!1,i.on.complete.fire())})}),e}}return++p,n.call(this,t,function(n,t,r){return e(o(n),o(t),r)},r)}})),i.complete(function(){t(d)}),i.error(function(n){function t(){var t=e(n);a||t||Xn.on.error.fire(n)}i.idbtrans&&(i.idbtrans.onerror=G);try{i.abort()}catch(r){}a&&(a.active=!1,a.on.error.fire(n)),s?u(t):t()}),T._rootExec(function(){d=o.apply(i,f),d&&("function"==typeof d.next&&"function"==typeof d["throw"]?d=Q(d):"function"!=typeof d.then||d.hasOwnProperty("_PSD")||e(c(new hn.IncompatiblePromise)))})}),(!i.idbtrans||a&&0===p)&&i._nop()}catch(v){i&&i.idbtrans&&(i.idbtrans.onerror=G),i&&i.abort(),a&&a.on.error.fire(v),u(function(){e(v)||Xn.on("error").fire(v)})}s=!1}t=e(arguments,1,arguments.length-1),o=arguments[arguments.length-1];var a=T.PSD&&T.PSD.trans;a&&a.db===Xn&&-1===n.indexOf("!")||(a=null);var s=-1!==n.indexOf("?");n=n.replace("!","").replace("?","");var f=en(t[0])?t.reduce(function(n,t){return n.concat(t)}):t,l=null,h=f.map(function(n){return"string"==typeof n?n:(n instanceof R||(l=l||new TypeError("Invalid type. Arguments following mode must be instances of Table or String")),n.name)});return"r"==n||n==Yn?n=Yn:"rw"==n||n==Qn?n=Qn:l=new hn.InvalidArgument("Invalid transaction mode: "+n),a&&(l||(a&&a.mode===Yn&&n===Qn&&(s?a=null:l=l||new hn.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY")),a&&h.forEach(function(n){a.tables.hasOwnProperty(n)||(s?a=null:l=l||new hn.SubTransaction("Table "+n+" not included in parent transaction. Parent Transaction function: "+a.scopeFunc.toString()))}))),a?a._promise(n,i,"lock"):Xn._whenReady(i)},this.table=function(n){if(Cn&&$n)return new q(n);if(!Wn.hasOwnProperty(n))throw new hn.InvalidTable("Table "+n+" does not exist");return Wn[n]},n(R.prototype,function(){function n(){throw new hn.ReadOnly("Current Transaction is READONLY")}return{_trans:function(n,t,e){return this._tpf(n,[this.name],t,e)},_idbstore:function(n,t,e){if(Cn)return new T(t);var r=this;return this._tpf(n,[this.name],function(n,e,o){t(n,e,o.idbtrans.objectStore(r.name),o)},e)},get:function(n,t){var e=this;return this._idbstore(Yn,function(t,r,o){Cn&&t(e.schema.instanceTemplate);var i=o.get(n);i.onerror=J(r,["getting",n,"from",e.name]),i.onsuccess=function(){t(e.hook.reading.fire(i.result))}}).then(t)},where:function(n){return new on(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 on(this,n))},toCollection:function(){return new this._collClass(new on(this))},mapToClass:function(n,t){this.schema.mappedClass=n;var e=Object.create(n.prototype);t&&H(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)t.hasOwnProperty(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(W.defineClass(n),n)},add:n,put:n,"delete":n,clear:n,update:n}}),t(q).from(R).extend(function(){return{bulkDelete:function(n){return this.hook.deleting.fire===_?this._idbstore(Qn,function(t,e,r,o){t(z(r,o,n,!1,_))}):this.where(":id").anyOf(n)["delete"]().then(function(){})},bulkPut:function(n,t){var e=this;return this._idbstore(Qn,function(r,o,i,u){if(!i.keyPath&&!e.schema.primKey.auto&&!t)throw new hn.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(i.keyPath&&t)throw new hn.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new hn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return r();var a,c,s=function(n){0===l.length?r(n):o(new b(e.name+".bulkPut(): "+l.length+" of "+h+" operations failed",l))},l=[],h=n.length,d=u.tables[e.name];if(e.hook.creating.fire===_&&e.hook.updating.fire===_){c=M(l);for(var p=0,v=n.length;v>p;++p)a=t?i.put(n[p],t[p]):i.put(n[p]),a.onerror=c;a.onerror=M(l,s),a.onsuccess=V(s)}else{var y=t||i.keyPath&&n.map(function(n){return f(n,i.keyPath)}),m=y&&y.reduce(function(t,e,r){return null!=e&&(t[e]=n[r]),t},{}),w=y?d.where(":id").anyOf(y.filter(function(n){return null!=n})).modify(function(){this.value=m[this.primKey],m[this.primKey]=null})["catch"](g,function(n){l=n.failures}).then(function(){for(var e=[],r=t&&[],o=y.length-1;o>=0;--o){var i=y[o];(null==i||m[i])&&(e.push(n[o]),t&&r.push(i),null!=i&&(m[i]=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);w.then(s)["catch"](b,function(n){l=l.concat(n.failures),s()})["catch"](o)}},"locked")},bulkAdd:function(n,t){var e=this,r=this.hook.creating.fire;return this._idbstore(Qn,function(o,i,u,c){function s(n){0===y.length?o(n):i(new b(e.name+".bulkAdd(): "+y.length+" of "+m+" operations failed",y))}if(!u.keyPath&&!e.schema.primKey.auto&&!t)throw new hn.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(u.keyPath&&t)throw new hn.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(t&&t.length!==n.length)throw new hn.InvalidArgument("Arguments objects and keys must have the same length");if(0===n.length)return o();var h,d,v,y=[],m=n.length;if(r!==_){var g=u.keyPath,w={onerror:null,onsuccess:null};d=M(y,null),v=V(null,!0),a(function(){for(var e=0,o=n.length;o>e;++e){var i=t&&t[e],a=n[e],s=t?i:g?f(a,g):void 0,y=r.call(w,s,a,c);null==s&&null!=y&&(g?(a=p(a),l(a,g,y)):i=y),h=null!=i?u.add(a,i):u.add(a),w.onerror&&(h._err=w.onerror),w.onsuccess&&(h._suc=w.onsuccess),o-1>e&&(h.onerror=d,w.onsuccess&&(h.onsuccess=v),w.onerror=null,w.onsuccess=null)}},function(n){throw w.onerror&&w.onerror(n),n}),h.onerror=M(y,s),h.onsuccess=V(s,!0)}else{d=M(y);for(var x=0,P=n.length;P>x;++x)h=t?u.add(n[x],t[x]):u.add(n[x]),h.onerror=d;h.onerror=M(y,s),h.onsuccess=V(s)}})},add:function(n,t){var e=this,r=this.hook.creating.fire;return this._idbstore(Qn,function(o,i,u,a){var c={onsuccess:null,onerror:null};if(r!==_){var s=null!=t?t:u.keyPath?f(n,u.keyPath):void 0,h=r.call(c,s,n,a);null==s&&null!=h&&(u.keyPath?l(n,u.keyPath,h):t=h)}try{var d=null!=t?u.add(n,t):u.add(n),p=T.PSD;d.onerror=J(function(n){return c.onerror&&T.usePSD(p,c.onerror.bind(c,n)),i(n)},["adding",n,"into",e.name]),d.onsuccess=function(t){var e=u.keyPath;e&&l(n,e,t.target.result),c.onsuccess&&T.usePSD(p,c.onsuccess.bind(c,t.target.result)),o(d.result)}}catch(v){throw c.onerror&&c.onerror(v),v}})},put:function(n,t){var e=this,r=this.hook.creating.fire,o=this.hook.updating.fire;return r!==_||o!==_?this._trans(Qn,function(r,o,i){var u=void 0!==t?t:e.schema.primKey.keyPath&&f(n,e.schema.primKey.keyPath);null==u?i.tables[e.name].add(n).then(r,o):(i._lock(),n=p(n),i.tables[e.name].where(":id").equals(u).modify(function(){this.value=n}).then(function(r){return 0===r?i.tables[e.name].add(n,t):u})["finally"](function(){i._unlock()}).then(r,o))}):this._idbstore(Qn,function(r,o,i){var u=void 0!==t?i.put(n,t):i.put(n);u.onerror=J(o,["putting",n,"into",e.name]),u.onsuccess=function(t){var e=i.keyPath;e&&l(n,e,t.target.result),r(u.result)}})},"delete":function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n)["delete"]():this._idbstore(Qn,function(t,e,r){var o=r["delete"](n);o.onerror=J(e,["deleting",n,"from",r.name]),o.onsuccess=function(){t(o.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection()["delete"]():this._idbstore(Qn,function(n,t,e){var r=e.clear();r.onerror=J(t,["clearing",e.name]),r.onsuccess=function(){n(r.result)}})},update:function(n,t){if("object"!=typeof t||en(t))throw new hn.InvalidArgument("db.update(keyOrObject, modifications). modifications must be an object.");if("object"!=typeof n||en(n))return this.where(":id").equals(n).modify(t);tn(t).forEach(function(e){l(n,e,t[e])});var e=f(n,this.schema.primKey.keyPath);return void 0===e&&T.reject(new hn.InvalidArgument("Given object does not contain its primary key")),this.where(":id").equals(e).modify(t)}}}),n(rn.prototype,{_lock:function(){return++this._reculock,1===this._reculock&&T.PSD&&(T.PSD.lockOwnerFor=this),this},_unlock:function(){if(0===--this._reculock)for(T.PSD&&(T.PSD.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(t){}}return this},_locked:function(){return this._reculock&&(!T.PSD||T.PSD.lockOwnerFor!==this)},_nop:function(n){this.tables[this.storeNames[0]].get(0).then(n)},_promise:function(n,t,e){var r=this;return T.newPSD(function(){var o;return r._locked()?o=new T(function(o,i){r._blockedFuncs.push(function(){r._promise(n,t,e).then(o,i)})}):(o=r.active?new T(function(o,i){if(!r.idbtrans&&n){if(!zn)throw!Jn||["DatabaseClosedError","MissingAPIError"].indexOf(Jn.name)>=0?Jn:new hn.OpenFailed(Jn);var a=r.idbtrans=zn.transaction($(r.storeNames),r.mode);a.onerror=function(n){r.on("error").fire(n&&n.target.error),n.preventDefault(),r.abort()},a.onabort=function(n){u(function(){r.on("error").fire(new hn.Abort("Transaction aborted for unknown reason"))}),r.active=!1,r.on("abort").fire(n)},a.oncomplete=function(n){r.active=!1,r.on("complete").fire(n)}}e&&r._lock();try{t(o,i,r)}catch(s){var f=c(w(s));W.ignoreTransaction(function(){r.on("error").fire(f)}),r.abort(),i(f)}}):T.reject(c(new hn.TransactionInactive("Transaction is inactive. Original Scope Function Source: "+r.scopeFunc.toString()))),r.active&&e&&o["finally"](function(){r._unlock()})), | ||
o.onuncatched=function(n){W.ignoreTransaction(function(){r.on("error").fire(n)}),r.abort()},o})},complete:function(n){return this.on("complete",n)},error:function(n){return this.on("error",n)},abort:function(){if(this.idbtrans&&this.active)try{this.active=!1,this.idbtrans.abort(),this.on.error.fire(new hn.Abort("Transaction Aborted"))}catch(n){}},table:function(n){if(!this.tables.hasOwnProperty(n))throw new hn.InvalidTable("Table "+n+" not in transaction");return this.tables[n]}}),n(on.prototype,function(){function n(n,t,e){var r=n instanceof on?new n._ctx.collClass(n):n;try{throw e?new e(t):new TypeError(t)}catch(o){r._ctx.error=o}return r}function t(n){return new n._ctx.collClass(n,function(){return qn.only("")}).limit(0)}function r(n){return e(1===n.length&&en(n[0])?n[0]:n)}function o(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function i(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function u(n,t,e,r,o,i){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 o(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):o(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;o(n[c],s)<0&&(a=c)}return u<r.length&&"next"===i?n+e.substr(n.length):u<n.length&&"prev"===i?n.substr(0,e.length):0>a?null:n.substr(0,a)+r[a]+e.substr(a+1)}function a(n,t,e,r){function a(n){c=o(n),s=i(n),f="next"===n?bn:wn;var t=e.map(function(n){return{lower:s(n),upper:c(n)}}).sort(function(n,t){return f(n.lower,t.lower)});l=t.map(function(n){return n.upper}),h=t.map(function(n){return n.lower}),d=n,p="next"===n?"":r}var c,s,f,l,h,d,p,v=e.length;a("next");var y=new n._ctx.collClass(n,function(){return qn.bound(l[0],h[v-1]+r)});y._ondirectionchange=function(n){a(n)};var m=0;return y._addAlgorithm(function(n,e,r){var o=n.key;if("string"!=typeof o)return!1;var i=s(o);if(t(i,h,m))return!0;for(var a=null,c=m;v>c;++c){var y=u(o,i,l[c],h[c],f,d);null===y&&null===a?m=c+1:(null===a||f(a,y)>0)&&(a=y)}return e(null!==a?function(){n["continue"](a+p)}:r),!1}),y}return{between:function(e,r,o,i){o=o!==!1,i=i===!0;try{return pn(e,r)>0||0===pn(e,r)&&(o||i)&&(!o||!i)?t(this):new this._ctx.collClass(this,function(){return qn.bound(e,r,!o,!i)})}catch(u){return n(this,Pn)}},equals:function(n){return new this._ctx.collClass(this,function(){return qn.only(n)})},above:function(n){return new this._ctx.collClass(this,function(){return qn.lowerBound(n,!0)})},aboveOrEqual:function(n){return new this._ctx.collClass(this,function(){return qn.lowerBound(n)})},below:function(n){return new this._ctx.collClass(this,function(){return qn.upperBound(n,!0)})},belowOrEqual:function(n){return new this._ctx.collClass(this,function(){return qn.upperBound(n)})},startsWith:function(t){return"string"!=typeof t?n(this,kn):this.between(t,t+_n,!0,!0)},startsWithIgnoreCase:function(t){return"string"!=typeof t?n(this,kn):""===t?this.startsWith(t):a(this,function(n,t){return 0===n.indexOf(t[0])},[t],_n)},equalsIgnoreCase:function(t){return"string"!=typeof t?n(this,kn):a(this,function(n,t){return n===t[0]},[t],"")},anyOfIgnoreCase:function(){var e=r(arguments);return 0===e.length?t(this):e.every(function(n){return"string"==typeof n})?a(this,function(n,t){return-1!==t.indexOf(n)},e,""):n(this,"anyOfIgnoreCase() only works with strings")},startsWithAnyOfIgnoreCase:function(){var e=r(arguments);return 0===e.length?t(this):e.every(function(n){return"string"==typeof n})?a(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},e,_n):n(this,"startsWithAnyOfIgnoreCase() only works with strings")},anyOf:function(){var e=r(arguments),o=mn;try{e.sort(o)}catch(i){return n(this,Pn)}if(0===e.length)return t(this);var u=new this._ctx.collClass(this,function(){return qn.bound(e[0],e[e.length-1])});u._ondirectionchange=function(n){o="next"===n?mn:gn,e.sort(o)};var a=0;return u._addAlgorithm(function(n,t,r){for(var i=n.key;o(i,e[a])>0;)if(++a,a===e.length)return t(r),!1;return 0===o(i,e[a])?!0:(t(function(){n["continue"](e[a])}),!1)}),u},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,xn]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=r(arguments);if(0===t.length)return new this._ctx.collClass(this);try{t.sort(mn)}catch(e){return n(this,Pn)}var o=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return o.push([t[t.length-1],xn]),this.inAnyRange(o,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function o(n,t){for(var e=0,r=n.length;r>e;++e){var o=n[e];if(pn(t[0],o[1])<0&&pn(t[1],o[0])>0){o[0]=vn(o[0],t[0]),o[1]=yn(o[1],t[1]);break}}return e===r&&n.push(t),n}function i(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]&&mn(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",hn.InvalidArgument);var c,s=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,l=mn;try{c=e.reduce(o,[]),c.sort(i)}catch(h){return n(this,Pn)}var d=0,p=f?function(n){return mn(n,c[d][1])>0}:function(n){return mn(n,c[d][1])>=0},v=s?function(n){return gn(n,c[d][0])>0}:function(n){return gn(n,c[d][0])>=0},y=p,m=new a.collClass(this,function(){return qn.bound(c[0][0],c[c.length-1][1],!s,!f)});return m._ondirectionchange=function(n){"next"===n?(y=p,l=mn):(y=v,l=gn),c.sort(i)},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===pn(r,c[d][1])||0===pn(r,c[d][0])?!1:(t(function(){l===mn?n["continue"](c[d][0]):n["continue"](c[d][1])}),!1)}),m},startsWithAnyOf:function(){var e=r(arguments);return e.every(function(n){return"string"==typeof n})?0===e.length?t(this):this.inAnyRange(e.map(function(n){return[n,n+_n]})):n(this,"startsWithAnyOf() only works with strings")}}}),n(un.prototype,function(){function t(n,t){n.filter=Sn(n.filter,t)}function e(n,t){var e=n.replayFilter;n.replayFilter=e?function(){return Sn(e(),t())}:t}function r(n,t){n.isMatch=Sn(n.isMatch,t)}function o(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new hn.Schema("KeyPath "+n.index+" on object store "+t.name+" is not indexed");return t.index(e.name)}function i(n,t){var e=o(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,o){var u=n.replayFilter?Sn(n.filter,n.replayFilter()):n.filter;n.or?!function(){function a(){2===++f&&e()}function c(n,e,o){if(!u||u(e,o,a,r)){var i=e.primaryKey.toString();s.hasOwnProperty(i)||(s[i]=!0,t(n,e,o))}}var s={},f=0;n.or._iterate(c,a,r,o),ln(i(n,o),n.algorithm,c,a,r,!n.keysOnly&&n.valueFilter)}():ln(i(n,o),Sn(n.algorithm,u),t,e,r,!n.keysOnly&&n.valueFilter)}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(Yn,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(Qn,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(t){var e=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&n(r,t),e._ctx=r,e},raw:function(){return this._ctx.valueFilter=null,this},each:function(n){var t=this._ctx;return Cn&&n(a(t)),this._read(function(e,r,o){u(t,n,e,r,o)})},count:function(n){if(Cn)return T.resolve(0).then(n);var t=this,e=this._ctx;if(e.filter||e.algorithm||e.or||e.replayFilter){var r=0;return this._read(function(n,t,o){u(e,function(){return++r,!1},function(){n(r)},t,o)},n)}return this._read(function(n,r,i){var u=o(e,i),a=e.range?u.count(e.range):u.count();a.onerror=J(r,["calling","count()","on",t.name]),a.onsuccess=function(t){n(t.target.result)}},n)},sortBy:function(n,t){function e(n,t){return t?e(n[o[t]],t-1):n[i]}function r(n,t){var r=e(n,u),o=e(t,u);return o>r?-a:r>o?a:0}var o=n.split(".").reverse(),i=o[0],u=o.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){Cn&&n([a(t)]);var o=[];u(t,function(n){o.push(n)},function(){n(o)},e,r)},n)},offset:function(n){var t=this._ctx;return 0>=n?this:(t.offset+=n,t.or||t.algorithm||t.filter||t.replayFilter?e(t,function(){var t=n;return function(){return--t<0}}):e(t,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),e(this._ctx,function(){var t=n;return function(n,e,r){return--t<=0&&e(r),t>=0}}),this},until:function(n,e){var r=this._ctx;return Cn&&n(a(r)),t(this._ctx,function(t,r,o){return n(t.value)?(r(o),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)},and:function(n){return Cn&&n(a(this._ctx)),t(this._ctx,function(t){return n(t.value)}),r(this._ctx,n),this},or:function(n){return new on(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 Cn&&n(f(a(this._ctx),this._ctx.index?this._ctx.table.schema.idxByName[this._ctx.index].keyPath:this._ctx.table.schema.primKey.keyPath)),t.keysOnly=!0,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=!0;var e=[];return Cn?new T(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 n=this._ctx,e=n.index&&n.table.schema.idxByName[n.index];if(!e||!e.multi)return this;var r={};return t(this._ctx,function(n){var t=n.primaryKey.toString(),e=r.hasOwnProperty(t);return r[t]=!0,!e}),this}}}),t(an).from(un).extend({modify:function(t){var e=this,r=this._ctx,o=r.table.hook,i=o.updating.fire,u=o.deleting.fire;return Cn&&"function"==typeof t&&t.call({value:r.table.schema.instanceTemplate},r.table.schema.instanceTemplate),this._write(function(o,c,s,h){function y(n,t){function e(n){return I.push(n),E.push(o.primKey),o.onerror&&T.newPSD(function(){T.PSD.trans=h,o.onerror(n)}),b(),!0}C=t.primaryKey;var o={primKey:t.primaryKey,value:n,onsuccess:null,onerror:null};if(w.call(o,n,o)!==!1){var i=!o.hasOwnProperty("value");++D,a(function(){var u=i?t["delete"]():t.update(o.value);u.onerror=J(e,i?["deleting",n,"from",r.table.name]:["modifying",n,"on",r.table.name]),u.onsuccess=function(){o.onsuccess&&T.newPSD(function(){T.PSD.trans=h,o.onsuccess(o.value)}),++S,b()}},e)}else o.onsuccess&&o.onsuccess(o.value)}function m(n){return n&&(I.push(n),E.push(C)),c(new g("Error modifying one or more objects",I,S,E))}function b(){O&&S+I.length===D&&(I.length>0?m():o(S))}var w;if("function"==typeof t)w=i===_&&u===_?t:function(n){var e=p(n);if(t.call(this,n,this)===!1)return!1;if(this.hasOwnProperty("value")){var r=v(e,this.value),o=i.call(this,r,this.primKey,e,h);o&&(n=this.value,tn(o).forEach(function(t){l(n,t,o[t])}))}else u.call(this,this.primKey,n,h)};else if(i===_){var x=tn(t),P=x.length;w=function(n){for(var e=!1,r=0;P>r;++r){var o=x[r],i=t[o];f(n,o)!==i&&(l(n,o,i),e=!0)}return e}}else{var k=t;t=d(k),w=function(e){var r=!1,o=i.call(this,t,this.primKey,p(e),h);return o&&n(t,o),tn(t).forEach(function(n){var o=t[n];f(e,n)!==o&&(l(e,n,o),r=!0)}),o&&(t=d(k)),r}}var D=0,S=0,O=!1,I=[],E=[],C=null;e.clone().raw()._iterate(y,function(){O=!0,b()},m,s)})},"delete":function(){var n=this,t=this._ctx,e=t.range,r=t.table.hook.deleting.fire,o=r!==_;if(!o&&!t.or&&!t.algorithm&&!t.filter&&!t.replayFilter&&(t.isPrimKey&&!In||!e))return this._write(function(n,r,o){var i=J(r,["deleting range from",t.table.name]),u=e?o.count(e):o.count();u.onerror=i,u.onsuccess=function(){var t=u.result;a(function(){var r=e?o["delete"](e):o.clear();r.onerror=i,r.onsuccess=function(){return n(t)}},function(n){return r(w(n))})}});var i=o?2e3:1e4;return this._write(function(e,u,a,c){var s=0,f=Object.create(t.table);f._tpf=c._tpf;var l=n.clone({table:f,keysOnly:!o}).distinct().limit(i).raw(),h=[],d=function(){return l.each(o?function(n,t){h.push([t.primaryKey,t.value])}:function(n,t){h.push(t.primaryKey)}).then(function(){return o?h.sort(function(n,t){return mn(n[0],t[0])}):h.sort(mn),z(a,c,h,o,r)}).then(function(){var n=h.length;return s+=n,h=[],i>n?s:d()})};e(d())})}}),n(this,{Collection:un,Table:R,Transaction:rn,Version:y,WhereClause:on,WriteableCollection:an,WriteableTable:q}),h(),Bn.forEach(function(n){n(Xn)})}function L(n,t){var e=T.PSD;return function(){var r=T.PSD;T.PSD=e;try{n.apply(this,arguments)}catch(o){t(o)}finally{T.PSD=r}}}function z(n){if("function"==typeof n)return new n;if(en(n))return[z(n[0])];if(n&&"object"==typeof n){var t={};return H(t,n),t}return n}function H(n,t){return tn(t).forEach(function(e){var r=z(t[e]);n[e]=r}),n}function J(n,t){return function(e){var r=e&&e.target.error||new Error("");if(t){var o=" occurred when "+t.map(function(n){switch(typeof n){case"function":return n();case"string":return n;default:return JSON.stringify(n)}}).join(" ");r.message&&r.message!=r.name&&(o+=". "+r.message),r.name?r=w(r,r.name+o):r+=o}return n(r),e&&(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()),!1}}function G(n){n.preventDefault()}function Y(n){var t,e=W.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 Q(n){function t(n){return function(t){var r=n(t),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(i,u):Array.isArray(o)?e(o,0):i(o)}}function e(n,t){if(t===n.length)return i(n);var r=n[t];return r.constructor&&"function"==typeof r.constructor.all?r.constructor.all(n).then(i,u):e(n,t+1)}var r=function(t){return n.next(t)},o=function(t){return n["throw"](t)},i=t(r),u=t(o);return t(r)()}function X(n,t,e,r,o,i,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=o,this.compound=i,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(o?"++":"")+a}function Z(n,t,e,r){this.name=n,this.primKey=t||new X,this.indexes=e||[new X],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=e.reduce(function(n,t){return n[t.name]=t,n},{})}function $(n){return 1===n.length?n[0]:n}function nn(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var tn=Object.keys,en=Array.isArray,rn="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,on=[].slice,un=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","IncompatiblePromise"],an=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],cn=un.concat(an),sn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",IncompatiblePromise:"Incompatible Promise used in transaction scope. See http://tinyurl.com/znyqjqc"};t(y).from(Error),t(g).from(y),t(b).from(y);var fn=cn.reduce(function(n,t){return n[t]=t+"Error",n},{}),ln=y,hn=cn.reduce(function(n,e){function r(n,t){this.name=o,"string"==typeof n?(this.message=n,this.inner=t||null):"object"==typeof n?(this.message=n.name+" "+n.message,this.inner=n):(this.message=sn[e],this.inner=null)}var o=e+"Error";return t(r).from(ln),n[e]=r,n},{});hn.Syntax=SyntaxError,hn.Type=TypeError,hn.Range=RangeError;var dn=an.reduce(function(n,t){return n[t+"Error"]=hn[t],n},{}),pn=cn.reduce(function(n,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(n[t+"Error"]=hn[t]),n},{});pn.ModifyError=g,pn.DexieError=y,pn.BulkError=b;var vn=rn.setImmediate||function(n){var t=e(arguments,1);setTimeout(function(){n.apply(rn,t)},0)};o(function(){vn=yn=wn=function(n){var t=arguments;setTimeout(function(){n.apply(rn,e(t,1))},0)}});var yn=vn,mn=!0,gn=[],bn=[],wn=function(n){gn.push([n,e(arguments,1)])};T.all=function(){var n=e(1===arguments.length&&en(arguments[0])?arguments[0]:arguments);return new T(function(t,e){function r(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var a=u.then;if("function"==typeof a)return void a.call(u,function(n){r(i,n)},e)}n[i]=u,0===--o&&t(n)}catch(c){e(c)}}if(0===n.length)return t([]);for(var o=n.length,i=0;i<n.length;i++)r(i,n[i])})},T.prototype.then=function(n,t){var e=this,r=new T(function(r,o){null===e._state?K(e,new M(n,t,r,o)):yn(K,e,new M(n,t,r,o))});return r._PSD=this._PSD,r.onuncatched=this.onuncatched,r._parent=this,r},T.prototype._then=function(n,t){K(this,new M(n,t,_,_))},T.prototype["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):T.reject(n)}):this.then(null,function(n){return n&&n.name===t?e(n):T.reject(n)})},T.prototype["finally"]=function(n){return this.then(function(t){return n(),t},function(t){return n(),T.reject(t)})},T.prototype.onuncatched=null,T.resolve=function(n){if(n&&"function"==typeof n.then)return n;var t=new T(function(){});return t._state=!0,t._value=n,t},T.reject=function(n){var t=new T(function(){});return t._state=!1,t._value=n,t},T.race=function(n){return new T(function(t,e){n.map(function(n){n.then(t,e)})})},T.PSD=null,T.newPSD=function(n){var t=T.PSD;T.PSD=t?Object.create(t):{};try{return n()}finally{T.PSD=t}},T.usePSD=function(n,t){var e=T.PSD;T.PSD=n;try{return t()}finally{T.PSD=e}},T._rootExec=F,T._tickFinalize=function(n){if(mn)throw new Error("Not in a virtual tick");bn.push(n)},T.on=j(null,{error:[function(n,t){return t},V]});var _n=String.fromCharCode(65535),xn=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return _n}}(),Pn="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",kn="String expected.",Dn=[],Sn="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),On=Sn,In=Sn,En=function(){},Cn=!1;W["delete"]=function(n){var t=new W(n),e=t["delete"]();return e.onblocked=function(n){return t.on("blocked",n),this},e},W.exists=function(n){return new W(n).open().then(function(n){return n.close(),!0})["catch"](W.NoSuchDatabaseError,function(){return!1})},W.getDatabaseNames=function(n){return new T(function(n,t){var r=nn(indexedDB);if(r){var o=r();o.onsuccess=function(t){n(e(t.target.result,0))},o.onerror=J(t)}else Y(function(t){return n(t),!1})}).then(n)},W.defineClass=function(t){function e(e){e?n(this,e):Cn&&H(this,t)}return e},W.applyStructure=H,W.ignoreTransaction=function(n){return T.newPSD(function(){return T.PSD.trans=null,n()})},W.vip=function(n){return T.newPSD(function(){return T.PSD.letThrough=!0,n()})},W.async=function(n){return function(){try{var t=Q(n.apply(this,arguments));return t&&"function"==typeof t.then?t:W.Promise.resolve(t)}catch(e){return W.Promise.reject(e)}}},W.spawn=function(n,t,e){try{var r=Q(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:W.Promise.resolve(r)}catch(o){return W.Promise.reject(o)}},Object.defineProperty(W,"currentTransaction",{get:function(){return T.PSD&&T.PSD.trans||null}}),W.Promise=T,W.derive=t,W.extend=n,W.override=r,W.Events=W.events=j,W.getByKeyPath=f,W.setByKeyPath=l,W.delByKeyPath=h,W.shallowClone=d,W.deepClone=p,W.addons=[],W.fakeAutoComplete=En,W.asap=u,W.maxKey=xn,W.connections=Dn,n(W,pn),W.MultiModifyError=W.ModifyError,W.errnames=fn,W.IndexSpec=X,W.TableSchema=Z;var jn=rn.idbModules&&rn.idbModules.shimIndexedDB?rn.idbModules:{};return W.dependencies={indexedDB:jn.shimIndexedDB||rn.indexedDB||rn.mozIndexedDB||rn.webkitIndexedDB||rn.msIndexedDB,IDBKeyRange:jn.IDBKeyRange||rn.IDBKeyRange||rn.webkitIDBKeyRange},a(function(){W.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:rn.localStorage}),W.semVer="1.3.6-beta.2",W.version=W.semVer.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),o(function(){W.fakeAutoComplete=En=o,W.fake=Cn=!0}),W["default"]=W,W}); | ||
!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(){}function t(n){return n}function e(n,e){return null==n||n===t?e:function(t){return e(n(t))}}function r(n,t){return function(){n.apply(this,arguments),t.apply(this,arguments)}}function o(t,e){return t===n?e:function(){var n=t.apply(this,arguments);void 0!==n&&(arguments[0]=n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var u=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?r(o,this.onsuccess):o),i&&(this.onerror=this.onerror?r(i,this.onerror):i),void 0!==u?u:n}}function i(t,e){return t===n?e:function(){t.apply(this,arguments);var n=this.onsuccess,o=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?r(n,this.onsuccess):n),o&&(this.onerror=this.onerror?r(o,this.onerror):o)}}function u(t,e){return t===n?e:function(){var n=t.apply(this,arguments);f(arguments[0],n);var o=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var u=e.apply(this,arguments);return o&&(this.onsuccess=this.onsuccess?r(o,this.onsuccess):o),i&&(this.onerror=this.onerror?r(i,this.onerror):i),void 0===n?void 0===u?void 0:u:f(n,u)}}function a(t,e){return t===n?e:function(){return t.apply(this,arguments)===!1?!1:e.apply(this,arguments)}}function c(t,e){return t===n?e:function(){return e.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function s(t,e){return t===n?e:function(){var n=t.apply(this,arguments);if(n&&"function"==typeof n.then){var r=this,o=arguments;return n.then(function(){return e.apply(r,o)})}return e.apply(this,arguments)}}function f(n,t){return"object"!=typeof t?n:(on(t).forEach(function(e){n[e]=t[e]}),n)}function l(n,t){"function"==typeof t&&(t=t(Object.getPrototypeOf(n))),on(t).forEach(function(e){h(n,e,t[e])})}function h(n,t,e,r){Object.defineProperty(n,t,f("function"==typeof e.get?{get:e.get,set:e.set,configurable:!0}:{value:e,configurable:!0,writable:!0},r))}function d(n){return{from:function(t){return n.prototype=Object.create(t.prototype),h(n.prototype,"constructor",n),{extend:l.bind(null,n.prototype)}}}}function p(n,t,e){return cn.call(n,t,e)}function v(n,t){return t(n)}function y(n){var t=setTimeout(n,1e3);clearTimeout(t)}function m(n){if(!n)throw new vn.Internal("Assertion failed")}function g(n){an.setImmediate?setImmediate(n):setTimeout(n,0)}function b(n,t){try{n()}catch(e){t&&t(e)}}function w(n){var t=n&&n.stack;return t?t.indexOf(n+"")>0?t:n+". "+t:n}function _(n){if(n.stack)return n;try{var t=new Error(n.message||n);if(t.stack)return n.stack=t.stack,n;throw t}catch(e){n.stack=e.stack}return n}function x(n){return B.reject(_(n))}function P(n,t){if(n.hasOwnProperty(t))return n[t];if(!t)return n;if("string"!=typeof t){for(var e=[],r=0,o=t.length;o>r;++r){var i=P(n,t[r]);e.push(i)}return e}var u=t.indexOf(".");if(-1!==u){var a=n[t.substr(0,u)];return void 0===a?void 0:P(a,t.substr(u+1))}}function k(n,t,e){if(n&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(n)))if("string"!=typeof t&&"length"in t){m("string"!=typeof e&&"length"in e);for(var r=0,o=t.length;o>r;++r)k(n,t[r],e[r])}else{var i=t.indexOf(".");if(-1!==i){var u=t.substr(0,i),a=t.substr(i+1);if(""===a)void 0===e?delete n[u]:n[u]=e;else{var c=n[u];c||(c=n[u]={}),k(c,a,e)}}else void 0===e?delete n[t]:n[t]=e}}function D(n,t){"string"==typeof t?k(n,t,void 0):"length"in t&&[].map.call(t,function(t){k(n,t,void 0)})}function S(n){var t={};for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t}function O(n){if(!n||"object"!=typeof n)return n;var t;if(un(n)){t=[];for(var e=0,r=n.length;r>e;++e)t.push(O(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 o in n)n.hasOwnProperty(o)&&(t[o]=O(n[o]))}return t}function E(n,t,e,r){e=e||{},r=r||"";for(var o in n)if(n.hasOwnProperty(o))if(t.hasOwnProperty(o)){var i=n[o],u=t[o];"object"==typeof i&&"object"==typeof u?E(i,u,e,r+o+"."):i!==u&&(e[r+o]=t[o])}else e[r+o]=void 0;for(o in t)t.hasOwnProperty(o)&&!n.hasOwnProperty(o)&&(e[r+o]=t[o]);return e}function I(n,t){this.name=n,this.message=t}function C(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 A(n,t,e,r){this.name="ModifyError",this.failures=t,this.failedKeys=r,this.successCount=e,this.message=C(n,t)}function j(n,t){this.name="BulkError",this.failures=t,this.message=C(n,t)}function T(n,t){var e=n;return n instanceof I||!n.name||!yn[n.name]||(e=new yn[n.name](t||n.message,n),n.stack&&(e.stack=n.stack)),e}function K(t){function e(t,e,i){if(un(t))return o(t);if("object"==typeof t)return r(t);e||(e=a),i||(i=n);var s={subscribers:[],fire:i,subscribe:function(n){s.subscribers.push(n),s.fire=e(s.fire,n)},unsubscribe:function(n){s.subscribers=s.subscribers.filter(function(t){return t!==n}),s.fire=s.subscribers.reduce(e,i)}};return u[t]=c[t]=s,s}function r(n){on(n).forEach(function(t){var r=n[t];if(un(r))e(t,n[t][0],n[t][1]);else{if("asap"!==r)throw new vn.InvalidArgument("Invalid event config");var o=e(t,null,function(){var n=arguments;o.subscribers.forEach(function(t){g(function(){t.apply(an,n)})})});o.subscribe=function(n){-1===o.subscribers.indexOf(n)&&o.subscribers.push(n)},o.unsubscribe=function(n){var t=o.subscribers.indexOf(n);-1!==t&&o.subscribers.splice(t,1)}}})}function o(n){function t(){return r?!1:void(r=!0)}var r=!1;n.forEach(function(n){e(n).subscribe(t)})}var i=arguments,u={},c=function(n,e){if(e){var r=p(arguments,1),o=u[n];return o.subscribe.apply(o,r),t}return"string"==typeof n?u[n]:void 0};c.addEventType=e;for(var s=1,f=i.length;f>s;++s)e(i[s]);return c}function F(){var n=_n;_n=[];for(var t=0,e=n.length;e>t;++t){var r=n[t];r[0].apply(an,r[1])}}function B(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],this._catched=!1;var t=this,e=!0;this._PSD=B.PSD;try{L(this,n,function(n){e?bn(M,t,n):M(t,n)},function(n){return e?(bn(U,t,n),!1):U(t,n)})}finally{e=!1}}function N(n,t){if(null===n._state)return void n._deferreds.push(t);var e=n._state?t.onFulfilled:t.onRejected;if(null===e)return(n._state?t.resolve:t.reject)(n._value);var r,o=wn;wn=!1,bn=Pn;try{var i=B.PSD;B.PSD=n._PSD,r=e(n._value),n._state||r&&"function"==typeof r.then&&r._state===!1||q(n),t.resolve(r)}catch(u){t.reject(u)}finally{if(B.PSD=i,o){do{for(;_n.length>0;)F();var a=xn.pop();if(a)try{a()}catch(u){}}while(xn.length>0||_n.length>0);bn=gn,wn=!0}}}function R(n){var t=wn;wn=!1,bn=Pn;try{return n()}finally{if(t){do{for(;_n.length>0;)F();var e=xn.pop();if(e)try{e()}catch(r){}}while(xn.length>0||_n.length>0);bn=gn,wn=!0}}}function q(n){n._catched=!0,n._parent&&!n._parent._catched&&q(n._parent)}function M(n,t){var e=B.PSD;B.PSD=n._PSD;try{if(t===n)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then)return t instanceof B&&null!==t._state?(n._state=t._state,n._value=t._value,void V.call(n)):void L(n,function(n,e){t.then(n,e)},function(t){M(n,t)},function(t){U(n,t)});n._state=!0,n._value=t,V.call(n)}catch(r){U(r)}finally{B.PSD=e}}function U(n,t){var e=B.PSD;if(B.PSD=n._PSD,n._state=!1,n._value=t,V.call(n),!n._catched)try{n.onuncatched?n.onuncatched(n._value):B.on.error.fire(n._value)}catch(r){}return B.PSD=e,n._catched}function V(){for(var n=0,t=this._deferreds.length;t>n;n++)N(this,this._deferreds[n]);this._deferreds=[]}function W(n,t,e,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==typeof t?t:null,this.resolve=e,this.reject=r}function L(n,t,e,r){var o=!1;try{t(function(n){o||(o=!0,e(n))},function(t){return o?n._catched:(o=!0,r(t))})}catch(i){if(o)return;return r(i)}}function z(n){console.warn("Uncaught Promise: "+w(n))}function H(r,a){function y(){$n.on("versionchange",function(n){n.newVersion>0?console.warn("Another connection wants to upgrade database '"+$n.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+$n.name+"'. Closing db now to resume the delete request."),$n.close()}),$n.on("blocked",function(n){!n.newVersion||n.newVersion<n.oldVersion?console.warn("Dexie.delete('"+$n.name+"') was blocked"):console.warn("Upgrade '"+$n.name+"' blocked by other connection holding version "+n.oldVersion/10)})}function m(n){this._cfg={version:n,storesSource:null,dbschema:{},tables:{},contentUpgrade:null},this.stores({})}function w(n,t,e,r){if(0===n){on(Vn).forEach(function(n){I(t,n,Vn[n].primKey,Vn[n].indexes)});var o=$n._createTransaction(Zn,Ln,Vn);o.idbtrans=t,o.idbtrans.onerror=Q(e,["populating database"]),o.on("error").subscribe(e),B.newPSD(function(){B.PSD.trans=o;try{$n.on("populate").fire(o)}catch(n){r.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(i){}t.db.close(),e(n)}})}else{var i=[],u=Wn.filter(function(t){return t._cfg.version===n})[0];if(!u)throw new vn.Upgrade("Dexie specification of currently installed DB version is missing");Vn=$n._dbSchema=u._cfg.dbschema;var a=!1,c=Wn.filter(function(t){return t._cfg.version>n});c.forEach(function(n){var r=Vn,o=n._cfg.dbschema;Kn(r,t),Kn(o,t),Vn=$n._dbSchema=o;var u=D(r,o);u.add.forEach(function(n){i.push(function(t,e){I(t,n[0],n[1].primKey,n[1].indexes),e()})}),u.change.forEach(function(n){if(n.recreate)throw new vn.Upgrade("Not yet support for changing primary key");i.push(function(t,e){var r=t.objectStore(n.name);n.add.forEach(function(n){N(r,n)}),n.change.forEach(function(n){r.deleteIndex(n.name),N(r,n)}),n.del.forEach(function(n){r.deleteIndex(n)}),e()})}),n._cfg.contentUpgrade&&i.push(function(t,r){a=!0;var i=$n._createTransaction(Zn,p(t.db.objectStoreNames),o);i.idbtrans=t;var u=0;i._promise=v(i._promise,function(n){return function(t,e,o){function i(n){return function(){n.apply(this,arguments),0===--u&&r()}}return++u,n.call(this,t,function(n,t){arguments[0]=i(n),arguments[1]=i(t),e.apply(this,arguments)},o)}}),t.onerror=Q(e,["running upgrader function for version",n._cfg.version]),i.on("error").subscribe(e),n._cfg.contentUpgrade(i),0===u&&r()}),a&&!Cn||i.push(function(n,t){F(o,n),t()})});var s=function(){try{i.length?i.shift()(t,s):C(Vn,t)}catch(n){r.onerror=t.onerror=function(n){n.preventDefault()};try{t.abort()}catch(o){}t.db.close(),e(n)}};s()}}function D(n,t){var e={del:[],add:[],change:[]};for(var r in n)t[r]||e.del.push(r);for(r in t){var o=n[r],i=t[r];if(o){var u={name:r,def:t[r],recreate:!1,del:[],add:[],change:[]};if(o.primKey.src!==i.primKey.src)u.recreate=!0,e.change.push(u);else{var a=o.indexes.reduce(function(n,t){return n[t.name]=t,n},{}),c=i.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,i])}return e}function I(n,t,e,r){var o=n.db.createObjectStore(t,e.keyPath?{keyPath:e.keyPath,autoIncrement:e.auto}:{autoIncrement:e.auto});return r.forEach(function(n){N(o,n)}),o}function C(n,t){on(n).forEach(function(e){t.db.objectStoreNames.contains(e)||I(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]&&void 0!==n[r]||t.db.deleteObjectStore(r)}}function N(n,t){n.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function R(){nt.forEach(function(n){n.resume()})}function q(n,t){throw new vn.InvalidTable("Table "+t[0]+" not part of transaction. Original Scope Function Source: "+H.Promise.PSD.trans.scopeFunc.toString())}function M(r,a,c,s){this.name=r,this.schema=c,this.hook=zn[r]?zn[r].hook:K(null,{creating:[o,n],reading:[e,t],updating:[u,n],deleting:[i,n]}),this._tpf=a,this._collClass=s||cn}function U(n,t,e,r){M.call(this,n,t,e,r||sn)}function V(n,t){var e=B.PSD;return function(r){try{r.stopPropagation&&r.stopPropagation(),r.preventDefault&&r.preventDefault();var o=r.target.error;n.push(o),r.target._err&&B.usePSD(e,r.target._err.bind(null,o))}finally{t&&t()}}}function W(n){var t=B.PSD;return function(e){var r;try{r=e.target.error,e.target._err&&B.usePSD(t,e.target._err.bind(null,r))}finally{n(r)}}}function L(n,t){var e=B.PSD;return t?function(t){var r;try{r=t.target.result,t.target._suc&&B.usePSD(e,t.target._suc.bind(null,r))}finally{n&&n(r)}}:function(t){n(t.target.result)}}function z(n,t,e,r,o){return new B(function(i,u){var a=e.length,c=a-1;if(0===a)return i();if(r){var s={onsuccess:null,onerror:null},f=W(function(n){return u(T(n))}),l=L(null,!0);b(function(){for(var r=0;a>r;++r){var u=e[r];o.call(s,u[0],u[1],t);var h=n["delete"](u[0]);s.onerror&&(h._err=s.onerror),s.onsuccess&&(h._suc=s.onsuccess),h.onerror=f,r===c?h.onsuccess=L(i,!0):h.onsuccess=l,s.onsuccess=null,s.onerror=null}},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=function(n){return u(T(n.target.error))},h===c&&(d.onsuccess=function(){return i()})}})}function G(n,t,e,r){function o(n,t,e,r){return i._promise(n,e,r)}var i=this;this.db=$n,this.mode=n,this.storeNames=t,this.idbtrans=null,this.on=K(this,["complete","error"],"abort"),this._reculock=0,this._blockedFuncs=[],this._psd=null,this.active=!0,this._dbschema=e,r&&(this.parent=r),this._tpf=o,this.tables=Object.create(Hn);for(var u=t.length-1;-1!==u;--u){var a=t[u],c=$n._tableFactory(n,e[a],o);this.tables[a]=c,this[a]||(this[a]=c)}}function an(n,t,e){this._ctx={table:n,index:":id"===t?null:t,collClass:n._collClass,or:e}}function cn(n,t){var e=null,r=null;if(t)try{e=t()}catch(o){r=_(T(o))}var i=n._ctx,u=i.table;this._ctx={table:u,index:i.index,isPrimKey:!i.index||u.schema.primKey.keyPath&&i.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:i.or,valueFilter:u.hook.reading.fire}}function sn(){cn.apply(this,arguments)}function fn(n,t){return n._cfg.version-t._cfg.version}function ln(n,t,e,r,o,i){e.forEach(function(e){var u=$n._tableFactory(r,o[e],t);n.forEach(function(n){n[e]||(i?h(n,e,{get:function(){var n=B.PSD&&B.PSD.trans;return n&&n.db===$n?n.tables[e]:u}},{enumerable:!0}):n[e]=u)})})}function hn(n){n.forEach(function(n){for(var t in n)n[t]instanceof M&&delete n[t]})}function dn(n,e,r,o,i,u){u=u||t,n.onerror||(n.onerror=Q(i)),e?n.onsuccess=J(function(){var t=n.result;if(t){var a=function(){t["continue"]()};e(t,function(n){a=n},o,i)&&r(u(t.value),t,function(n){a=n}),a()}else o()},i):n.onsuccess=J(function(){var t=n.result;if(t){var e=function(){t["continue"]()};r(u(t.value),t,function(n){e=n}),e()}else o()},i)}function pn(n){var t=[];return n.split(",").forEach(function(n){n=n.trim();var e=n.replace("&","").replace("++","").replace("*",""),r=0!==e.indexOf("[")?e:n.substring(n.indexOf("[")+1,n.indexOf("]")).split("+");t.push(new nn(e,r||null,-1!==n.indexOf("&"),-1!==n.indexOf("*"),-1!==n.indexOf("++"),un(r),-1!==r.indexOf(".")))}),t}function yn(n,t){return Mn.cmp(n,t)}function mn(n,t){return yn(n,t)<0?n:t}function gn(n,t){return yn(n,t)>0?n:t}function bn(n,t){return Mn.cmp(n,t)}function wn(n,t){return Mn.cmp(t,n)}function _n(n,t){return t>n?-1:n===t?0:1}function xn(n,t){return n>t?-1:n===t?0:1}function Pn(n,t){return n?t?function(){return n.apply(this,arguments)&&t.apply(this,arguments)}:n:t}function In(){if($n.verno=Jn.version/10,$n._dbSchema=Vn={},Ln=p(Jn.objectStoreNames,0),0!==Ln.length){var n=Jn.transaction(en(Ln),"readonly");Ln.forEach(function(t){for(var e=n.objectStore(t),r=e.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf("."),i=new nn(r,r||"",!1,!1,!!e.autoIncrement,r&&"string"!=typeof r,o),u=[],a=0;a<e.indexNames.length;++a){var c=e.index(e.indexNames[a]);r=c.keyPath,o=r&&"string"==typeof r&&-1!==r.indexOf(".");var s=new nn(c.name,r,!!c.unique,!!c.multiEntry,!1,r&&"string"!=typeof r,o);u.push(s)}Vn[t]=new tn(t,i,u,{})}),ln([zn],$n._transPromiseFactory,on(Vn),Zn,Vn)}}function Kn(n,t){for(var e=t.db.objectStoreNames,r=0;r<e.length;++r)for(var o=e[r],i=t.objectStore(o),u=0;u<i.indexNames.length;++u){var a=i.indexNames[u],c=i.index(a).keyPath,s="string"==typeof c?c:"["+p(c).join("+")+"]";if(n[o]){var f=n[o].idxByName[s];f&&(f.name=a)}}}function Fn(n){$n.on("blocked").fire(n),En.filter(function(n){return n.name===$n.name&&n!==$n&&!n._vcFired}).map(function(t){return t.on("versionchange").fire(n)})}var Bn=H.dependencies,Nn=f({addons:H.addons,autoOpen:!0,indexedDB:Bn.indexedDB,IDBKeyRange:Bn.IDBKeyRange},a),Rn=Nn.addons,qn=Nn.autoOpen,Mn=Nn.indexedDB,Un=Nn.IDBKeyRange,Vn=this._dbSchema={},Wn=[],Ln=[],zn={},Hn={},Jn=null,Gn=!0,Yn=null,Qn=!1,Xn="readonly",Zn="readwrite",$n=this,nt=[],tt=!0,et=!!rn(Mn);this.version=function(n){if(Jn||Qn)throw new vn.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 m(n),Wn.push(t),Wn.sort(fn),t)},f(m.prototype,{stores:function(n){this._cfg.storesSource=this._cfg.storesSource?f(this._cfg.storesSource,n):n;var t={};Wn.forEach(function(n){f(t,n._cfg.storesSource)});var e=this._cfg.dbschema={};return this._parseStoresSpec(t,e),Vn=$n._dbSchema=e,hn([zn,$n,Hn]),ln([Hn],q,on(e),Zn,e),ln([zn,$n,this._cfg.tables],$n._transPromiseFactory,on(e),Zn,e,!0),Ln=on(e),this},upgrade:function(n){var t=this;return jn(function(){n($n._createTransaction(Zn,on(t._cfg.dbschema),t._cfg.dbschema))}),this._cfg.contentUpgrade=n,this},_parseStoresSpec:function(n,t){on(n).forEach(function(e){if(null!==n[e]){var r={},o=pn(n[e]),i=o.shift();if(i.multi)throw new vn.Schema("Primary key cannot be multi-valued");i.keyPath&&k(r,i.keyPath,i.auto?0:i.keyPath),o.forEach(function(n){if(n.auto)throw new vn.Schema("Only primary key can be marked as autoIncrement (++)");if(!n.keyPath)throw new vn.Schema("Index must have a name and cannot be an empty string");k(r,n.keyPath,n.compound?n.keyPath.map(function(){return""}):"")}),t[e]=new tn(e,i,o,r)}})}}),this._allTables=zn,this._tableFactory=function(n,t,e){return n===Xn?new M(t.name,e,t,cn):new U(t.name,e,t)},this._createTransaction=function(n,t,e,r){return new G(n,t,e,r)},this._transPromiseFactory=function(t,e,r){if(!Gn||B.PSD&&B.PSD.letThrough){var o=$n._createTransaction(t,e,Vn);return o._promise(t,function(n,t){o.error(function(n){$n.on("error").fire(n)}),B.newPSD(function(){B.PSD.trans=o,r(function(t){o.complete(function(){n(t)})},t,o)})})}if(!Qn&&!qn)return x(new vn.DatabaseClosed);var i=new B(function(n,o){nt.push({resume:function(){var u=$n._transPromiseFactory(t,e,r);i.onuncatched=u.onuncatched,u.then(n,o)}})});return qn&&!Qn&&$n.open()["catch"](n),i},this._whenReady=function(t){if(!Tn&&Gn&&(!B.PSD||!B.PSD.letThrough)){if(!Qn){if(!qn)return x(new vn.DatabaseClosed);$n.open()["catch"](n)}return new B(function(n,e){nt.push({resume:function(){t(n,e)}})})}return new B(t)},this.verno=0,this.open=function(){return Jn?B.resolve($n):Qn?new B(function(n,t){return $n._whenReady(function(){n($n)},function(n){t(n)})}):(Yn=null,Qn=!0,Gn=!0,new B(function(n,t){function e(n){try{o.transaction.abort()}catch(e){}if(Jn)try{Jn.close()}catch(e){}Jn=null,Qn=!1,Yn=T(n),Gn=!1,t(Yn),R()}Tn&&n();var o;try{if(Wn.length>0&&(tt=!1),!Mn)throw new vn.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using Safari, make sure to include indexedDB polyfill.");if(o=tt?Mn.open(r):Mn.open(r,Math.round(10*$n.verno)),!o)throw new vn.MissingAPI("IndexedDB API not available");o.onerror=Q(e,["opening database",r]),o.onblocked=Fn,o.onupgradeneeded=J(function(n){if(tt&&!$n._allowEmptyDB){o.onerror=function(n){n.preventDefault()},o.transaction.abort(),o.result.close();var t=Mn.deleteDatabase(r);t.onsuccess=t.onerror=function(){e(new vn.NoSuchDatabase("Database "+r+" doesnt exist"))}}else{o.transaction.onerror=Q(e);var i=n.oldVersion>Math.pow(2,62)?0:n.oldVersion;w(i/10,o.transaction,e,o)}},e),o.onsuccess=J(function(){if(Qn=!1,Jn=o.result,tt)In();else if(Jn.objectStoreNames.length>0)try{Kn(Vn,Jn.transaction(en(Jn.objectStoreNames),Xn))}catch(t){}Jn.onversionchange=function(n){$n._vcFired=!0,$n.on("versionchange").fire(n)},et||Z(function(n){return-1===n.indexOf(r)?n.push(r):void 0}),B.newPSD(function(){function t(){Gn=!1,R(),n()}B.PSD.letThrough=!0;try{var r=$n.on.ready.fire();r&&"function"==typeof r.then?r.then(t,function(n){Jn.close(),Jn=null,e(n)}):g(t)}catch(o){e(o)}})},e)}catch(i){e(i)}}).then(function(){return En.push($n),$n}))},this.close=function(){var n=En.indexOf($n);n>=0&&En.splice(n,1),Jn?(Jn.close(),Jn=null,qn=!1,Gn&&R(),Gn=!1,Yn=new vn.DatabaseClosed):Qn&&$n.on("ready",function(){return B.reject(new vn.DatabaseClosed)})},this["delete"]=function(){var n=arguments;return new B(function(t,e){function o(){$n.close();var n=Mn.deleteDatabase(r);n.onsuccess=function(){et||Z(function(n){var t=n.indexOf(r);return t>=0?n.splice(t,1):void 0}),t()},n.onerror=Q(e,["deleting",r]),n.onblocked=Fn}if(n.length>0)throw new vn.InvalidArgument("Arguments not allowed in db.delete()");Qn?nt.push({resume:o}):o()})},this.backendDB=function(){return Jn},this.isOpen=function(){return null!==Jn},this.hasFailed=function(){return null!==Yn},this.dynamicallyOpened=function(){return tt},this.name=r,h(this,"tables",{get:function(){return on(zn).map(function(n){return zn[n]})}}),this.on=K(this,"error","populate",{blocked:[c,n],ready:[s,n],versionchange:[c,n]}),this.on.ready.subscribe=v(this.on.ready.subscribe,function(n){return function(t,e){function r(){return e||$n.on.ready.unsubscribe(r),t.apply(this,arguments)}n.call(this,r),$n.isOpen()&&(Gn?nt.push({resume:r}):r())}}),jn(function(){$n.on("populate").fire($n._createTransaction(Zn,Ln,Vn)),$n.on("error").fire(new Error)}),this.transaction=function(n,t,e){function r(t,r){var i=null,u=!0;try{if(a)throw a;i=$n._createTransaction(n,c,Vn,o);var s=c.map(function(n){return i.tables[n]});s.push(i);var f,l=0;B.newPSD(function(){B.PSD.trans=i,i.scopeFunc=e,o&&(i.idbtrans=o.idbtrans,i._promise=v(i._promise,function(n){return function(t,e,r){function o(n){return function(t){var e;return B._rootExec(function(){e=n(t),B._tickFinalize(function(){0===--l&&i.active&&(i.active=!1,i.on.complete.fire())})}),e}}return++l,n.call(this,t,function(n,t,r){return e(o(n),o(t),r)},r)}})),i.complete(function(){t(f)}),i.error(function(n){function t(){var t=r(n);o||t||$n.on.error.fire(n)}i.idbtrans&&(i.idbtrans.onerror=X);try{i.abort()}catch(e){}o&&(o.active=!1,o.on.error.fire(n)),u?g(t):t()}),B._rootExec(function(){if(f=e.apply(i,s))if("function"==typeof f.next&&"function"==typeof f["throw"])f=$(f);else if("function"==typeof f.then&&!f.hasOwnProperty("_PSD"))throw new vn.IncompatiblePromise})}),(!i.idbtrans||o&&0===l)&&i._nop()}catch(h){i&&i.idbtrans&&(i.idbtrans.onerror=X),i&&i.abort(),o&&o.on.error.fire(h),g(function(){r(h)||$n.on("error").fire(h)})}u=!1}t=p(arguments,1,arguments.length-1),e=arguments[arguments.length-1];var o=B.PSD&&B.PSD.trans;o&&o.db===$n&&-1===n.indexOf("!")||(o=null);var i=-1!==n.indexOf("?");n=n.replace("!","").replace("?","");var u=un(t[0])?t.reduce(function(n,t){return n.concat(t)}):t,a=null,c=u.map(function(n){return"string"==typeof n?n:(n instanceof M||(a=a||new TypeError("Invalid type. Arguments following mode must be instances of Table or String")),n.name)});return"r"==n||n==Xn?n=Xn:"rw"==n||n==Zn?n=Zn:a=new vn.InvalidArgument("Invalid transaction mode: "+n),o&&(a||(o&&o.mode===Xn&&n===Zn&&(i?o=null:a=a||new vn.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY")),o&&c.forEach(function(n){o.tables.hasOwnProperty(n)||(i?o=null:a=a||new vn.SubTransaction("Table "+n+" not included in parent transaction. Parent Transaction function: "+o.scopeFunc.toString()))}))),o?o._promise(n,r,"lock"):$n._whenReady(r)},this.table=function(n){if(Tn&&tt)return new U(n);if(!zn.hasOwnProperty(n))throw new vn.InvalidTable("Table "+n+" does not exist");return zn[n]},l(M.prototype,function(){function n(){throw new vn.ReadOnly("Current Transaction is READONLY")}return{_trans:function(n,t,e){return this._tpf(n,[this.name],t,e)},_idbstore:function(n,t,e){if(Tn)return new B(t);var r=this;return this._tpf(n,[this.name],function(n,e,o){t(n,e,o.idbtrans.objectStore(r.name),o)},e)},get:function(n,t){var e=this;return this._idbstore(Xn,function(t,r,o){Tn&&t(e.schema.instanceTemplate);var i=o.get(n);i.onerror=Q(r,["getting",n,"from",e.name]),i.onsuccess=function(){t(e.hook.reading.fire(i.result))}}).then(t)},where:function(n){return new an(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 an(this,n))},toCollection:function(){return new this._collClass(new an(this))},mapToClass:function(n,t){this.schema.mappedClass=n;var e=Object.create(n.prototype);t&&Y(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)t.hasOwnProperty(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(H.defineClass(n),n)},add:n,put:n,"delete":n,clear:n,update:n}}),d(U).from(M).extend(function(){return{bulkDelete:function(t){return this.hook.deleting.fire===n?this._idbstore(Zn,function(e,r,o,i){e(z(o,i,t,!1,n))}):this.where(":id").anyOf(t)["delete"]().then(function(){})},bulkPut:function(t,e){var r=this;return this._idbstore(Zn,function(o,i,u,a){if(!u.keyPath&&!r.schema.primKey.auto&&!e)throw new vn.InvalidArgument("bulkPut() with non-inbound keys requires keys array in second argument");if(u.keyPath&&e)throw new vn.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(e&&e.length!==t.length)throw new vn.InvalidArgument("Arguments objects and keys must have the same length");if(0===t.length)return o();var c,s,f=function(n){0===l.length?o(n):i(new j(r.name+".bulkPut(): "+l.length+" of "+h+" operations failed",l))},l=[],h=t.length,d=a.tables[r.name];if(r.hook.creating.fire===n&&r.hook.updating.fire===n){s=V(l);for(var p=0,v=t.length;v>p;++p)c=e?u.put(t[p],e[p]):u.put(t[p]),c.onerror=s;c.onerror=V(l,f),c.onsuccess=L(f)}else{var y=e||u.keyPath&&t.map(function(n){return P(n,u.keyPath)}),m=y&&y.reduce(function(n,e,r){return null!=e&&(n[e]=t[r]),n},{}),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"](A,function(n){l=n.failures}).then(function(){for(var n=[],r=e&&[],o=y.length-1;o>=0;--o){var i=y[o];(null==i||m[i])&&(n.push(t[o]),e&&r.push(i),null!=i&&(m[i]=null))}return n.reverse(),e&&r.reverse(),d.bulkAdd(n,r)}).then(function(n){var t=y[y.length-1];return null!=t?t:n}):d.bulkAdd(t);g.then(f)["catch"](j,function(n){l=l.concat(n.failures),f()})["catch"](i)}},"locked")},bulkAdd:function(t,e){var r=this,o=this.hook.creating.fire;return this._idbstore(Zn,function(i,u,a,c){function s(n){0===d.length?i(n):u(new j(r.name+".bulkAdd(): "+d.length+" of "+p+" operations failed",d))}if(!a.keyPath&&!r.schema.primKey.auto&&!e)throw new vn.InvalidArgument("bulkAdd() with non-inbound keys requires keys array in second argument");if(a.keyPath&&e)throw new vn.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(e&&e.length!==t.length)throw new vn.InvalidArgument("Arguments objects and keys must have the same length");if(0===t.length)return i();var f,l,h,d=[],p=t.length;if(o!==n){var v=a.keyPath,y={onerror:null,onsuccess:null};l=V(d,null),h=L(null,!0),b(function(){for(var n=0,r=t.length;r>n;++n){var i=e&&e[n],u=t[n],s=e?i:v?P(u,v):void 0,d=o.call(y,s,u,c);null==s&&null!=d&&(v?(u=O(u),k(u,v,d)):i=d),f=null!=i?a.add(u,i):a.add(u),y.onerror&&(f._err=y.onerror),y.onsuccess&&(f._suc=y.onsuccess),r-1>n&&(f.onerror=l,y.onsuccess&&(f.onsuccess=h),y.onerror=null,y.onsuccess=null)}},function(n){throw y.onerror&&y.onerror(n),n}),f.onerror=V(d,s),f.onsuccess=L(s,!0)}else{l=V(d);for(var m=0,g=t.length;g>m;++m)f=e?a.add(t[m],e[m]):a.add(t[m]),f.onerror=l;f.onerror=V(d,s),f.onsuccess=L(s)}})},add:function(t,e){var r=this,o=this.hook.creating.fire;return this._idbstore(Zn,function(i,u,a,c){var s={onsuccess:null,onerror:null};if(o!==n){var f=null!=e?e:a.keyPath?P(t,a.keyPath):void 0,l=o.call(s,f,t,c);null==f&&null!=l&&(a.keyPath?k(t,a.keyPath,l):e=l)}try{var h=null!=e?a.add(t,e):a.add(t),d=B.PSD;h.onerror=Q(function(n){return s.onerror&&B.usePSD(d,s.onerror.bind(s,n)),u(n)},["adding",t,"into",r.name]),h.onsuccess=function(n){var e=a.keyPath;e&&k(t,e,n.target.result),s.onsuccess&&B.usePSD(d,s.onsuccess.bind(s,n.target.result)),i(h.result)}}catch(p){throw s.onerror&&s.onerror(p),p}})},put:function(t,e){var r=this,o=this.hook.creating.fire,i=this.hook.updating.fire;return o!==n||i!==n?this._trans(Zn,function(n,o,i){var u=void 0!==e?e:r.schema.primKey.keyPath&&P(t,r.schema.primKey.keyPath);null==u?i.tables[r.name].add(t).then(n,o):(i._lock(),t=O(t),i.tables[r.name].where(":id").equals(u).modify(function(){this.value=t}).then(function(n){return 0===n?i.tables[r.name].add(t,e):u})["finally"](function(){i._unlock()}).then(n,o))}):this._idbstore(Zn,function(n,o,i){var u=void 0!==e?i.put(t,e):i.put(t);u.onerror=Q(o,["putting",t,"into",r.name]),u.onsuccess=function(e){var r=i.keyPath;r&&k(t,r,e.target.result),n(u.result)}})},"delete":function(n){return this.hook.deleting.subscribers.length?this.where(":id").equals(n)["delete"]():this._idbstore(Zn,function(t,e,r){var o=r["delete"](n);o.onerror=Q(e,["deleting",n,"from",r.name]),o.onsuccess=function(){t(o.result)}})},clear:function(){return this.hook.deleting.subscribers.length?this.toCollection()["delete"]():this._idbstore(Zn,function(n,t,e){var r=e.clear();r.onerror=Q(t,["clearing",e.name]),r.onsuccess=function(){n(r.result)}})},update:function(n,t){if("object"!=typeof t||un(t))throw new vn.InvalidArgument("db.update(keyOrObject, modifications). modifications must be an object.");if("object"!=typeof n||un(n))return this.where(":id").equals(n).modify(t);on(t).forEach(function(e){k(n,e,t[e])});var e=P(n,this.schema.primKey.keyPath);return void 0===e&&B.reject(new vn.InvalidArgument("Given object does not contain its primary key")),this.where(":id").equals(e).modify(t)}}}),l(G.prototype,{_lock:function(){return++this._reculock,1===this._reculock&&B.PSD&&(B.PSD.lockOwnerFor=this),this},_unlock:function(){if(0===--this._reculock)for(B.PSD&&(B.PSD.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var n=this._blockedFuncs.shift();try{n()}catch(t){}}return this},_locked:function(){return this._reculock&&(!B.PSD||B.PSD.lockOwnerFor!==this)},_nop:function(n){this.tables[this.storeNames[0]].get(0).then(n)},_promise:function(n,t,e){var r=this;return B.newPSD(function(){var o;return r._locked()?o=new B(function(o,i){r._blockedFuncs.push(function(){r._promise(n,t,e).then(o,i)})}):(o=r.active?new B(function(o,i){if(!r.idbtrans&&n){if(!Jn)throw!Yn||["DatabaseClosedError","MissingAPIError"].indexOf(Yn.name)>=0?Yn:new vn.OpenFailed(Yn);var u=r.idbtrans=Jn.transaction(en(r.storeNames),r.mode);u.onerror=function(n){r.on("error").fire(n&&n.target.error),n.preventDefault(),r.abort()},u.onabort=function(n){g(function(){r.on("error").fire(new vn.Abort("Transaction aborted for unknown reason"))}),r.active=!1,r.on("abort").fire(n)},u.oncomplete=function(n){r.active=!1,r.on("complete").fire(n)}}e&&r._lock();try{t(o,i,r)}catch(a){var c=_(T(a));H.ignoreTransaction(function(){ | ||
r.on("error").fire(c)}),r.abort(),i(c)}}):B.reject(_(new vn.TransactionInactive("Transaction is inactive. Original Scope Function Source: "+r.scopeFunc.toString()))),r.active&&e&&o["finally"](function(){r._unlock()})),o.onuncatched=function(n){H.ignoreTransaction(function(){r.on("error").fire(n)}),r.abort()},o})},complete:function(n){return this.on("complete",n)},error:function(n){return this.on("error",n)},abort:function(){if(this.idbtrans&&this.active)try{this.active=!1,this.idbtrans.abort(),this.on.error.fire(new vn.Abort("Transaction Aborted"))}catch(n){}},table:function(n){if(!this.tables.hasOwnProperty(n))throw new vn.InvalidTable("Table "+n+" not in transaction");return this.tables[n]}}),l(an.prototype,function(){function n(n,t,e){var r=n instanceof an?new n._ctx.collClass(n):n;try{throw e?new e(t):new TypeError(t)}catch(o){r._ctx.error=o}return r}function t(n){return new n._ctx.collClass(n,function(){return Un.only("")}).limit(0)}function e(n){return p(1===n.length&&un(n[0])?n[0]:n)}function r(n){return"next"===n?function(n){return n.toUpperCase()}:function(n){return n.toLowerCase()}}function o(n){return"next"===n?function(n){return n.toLowerCase()}:function(n){return n.toUpperCase()}}function i(n,t,e,r,o,i){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 o(n[c],e[c])<0?n.substr(0,c)+e[c]+e.substr(c+1):o(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;o(n[c],s)<0&&(a=c)}return u<r.length&&"next"===i?n+e.substr(n.length):u<n.length&&"prev"===i?n.substr(0,e.length):0>a?null:n.substr(0,a)+r[a]+e.substr(a+1)}function u(n,t,e,u){function a(n){c=r(n),s=o(n),f="next"===n?_n:xn;var t=e.map(function(n){return{lower:s(n),upper:c(n)}}).sort(function(n,t){return f(n.lower,t.lower)});l=t.map(function(n){return n.upper}),h=t.map(function(n){return n.lower}),d=n,p="next"===n?"":u}var c,s,f,l,h,d,p,v=e.length;a("next");var y=new n._ctx.collClass(n,function(){return Un.bound(l[0],h[v-1]+u)});y._ondirectionchange=function(n){a(n)};var m=0;return y._addAlgorithm(function(n,e,r){var o=n.key;if("string"!=typeof o)return!1;var u=s(o);if(t(u,h,m))return!0;for(var a=null,c=m;v>c;++c){var y=i(o,u,l[c],h[c],f,d);null===y&&null===a?m=c+1:(null===a||f(a,y)>0)&&(a=y)}return e(null!==a?function(){n["continue"](a+p)}:r),!1}),y}return{between:function(e,r,o,i){o=o!==!1,i=i===!0;try{return yn(e,r)>0||0===yn(e,r)&&(o||i)&&(!o||!i)?t(this):new this._ctx.collClass(this,function(){return Un.bound(e,r,!o,!i)})}catch(u){return n(this,Sn)}},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,On):this.between(t,t+kn,!0,!0)},startsWithIgnoreCase:function(t){return"string"!=typeof t?n(this,On):""===t?this.startsWith(t):u(this,function(n,t){return 0===n.indexOf(t[0])},[t],kn)},equalsIgnoreCase:function(t){return"string"!=typeof t?n(this,On):u(this,function(n,t){return n===t[0]},[t],"")},anyOfIgnoreCase:function(){var r=e(arguments);return 0===r.length?t(this):r.every(function(n){return"string"==typeof n})?u(this,function(n,t){return-1!==t.indexOf(n)},r,""):n(this,"anyOfIgnoreCase() only works with strings")},startsWithAnyOfIgnoreCase:function(){var r=e(arguments);return 0===r.length?t(this):r.every(function(n){return"string"==typeof n})?u(this,function(n,t){return t.some(function(t){return 0===n.indexOf(t)})},r,kn):n(this,"startsWithAnyOfIgnoreCase() only works with strings")},anyOf:function(){var r=e(arguments),o=bn;try{r.sort(o)}catch(i){return n(this,Sn)}if(0===r.length)return t(this);var u=new this._ctx.collClass(this,function(){return Un.bound(r[0],r[r.length-1])});u._ondirectionchange=function(n){o="next"===n?bn:wn,r.sort(o)};var a=0;return u._addAlgorithm(function(n,t,e){for(var i=n.key;o(i,r[a])>0;)if(++a,a===r.length)return t(e),!1;return 0===o(i,r[a])?!0:(t(function(){n["continue"](r[a])}),!1)}),u},notEqual:function(n){return this.inAnyRange([[-(1/0),n],[n,Dn]],{includeLowers:!1,includeUppers:!1})},noneOf:function(){var t=e(arguments);if(0===t.length)return new this._ctx.collClass(this);try{t.sort(bn)}catch(r){return n(this,Sn)}var o=t.reduce(function(n,t){return n?n.concat([[n[n.length-1][1],t]]):[[-(1/0),t]]},null);return o.push([t[t.length-1],Dn]),this.inAnyRange(o,{includeLowers:!1,includeUppers:!1})},inAnyRange:function(e,r){function o(n,t){for(var e=0,r=n.length;r>e;++e){var o=n[e];if(yn(t[0],o[1])<0&&yn(t[1],o[0])>0){o[0]=mn(o[0],t[0]),o[1]=gn(o[1],t[1]);break}}return e===r&&n.push(t),n}function i(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]&&bn(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",vn.InvalidArgument);var c,s=!r||r.includeLowers!==!1,f=r&&r.includeUppers===!0,l=bn;try{c=e.reduce(o,[]),c.sort(i)}catch(h){return n(this,Sn)}var d=0,p=f?function(n){return bn(n,c[d][1])>0}:function(n){return bn(n,c[d][1])>=0},v=s?function(n){return wn(n,c[d][0])>0}:function(n){return wn(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=bn):(y=v,l=wn),c.sort(i)},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===yn(r,c[d][1])||0===yn(r,c[d][0])?!1:(t(function(){l===bn?n["continue"](c[d][0]):n["continue"](c[d][1])}),!1)}),m},startsWithAnyOf:function(){var r=e(arguments);return r.every(function(n){return"string"==typeof n})?0===r.length?t(this):this.inAnyRange(r.map(function(n){return[n,n+kn]})):n(this,"startsWithAnyOf() only works with strings")}}}),l(cn.prototype,function(){function n(n,t){n.filter=Pn(n.filter,t)}function t(n,t){var e=n.replayFilter;n.replayFilter=e?function(){return Pn(e(),t())}:t}function e(n,t){n.isMatch=Pn(n.isMatch,t)}function r(n,t){if(n.isPrimKey)return t;var e=n.table.schema.idxByName[n.index];if(!e)throw new vn.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 i(n,t,e,r,i){var u=n.replayFilter?Pn(n.filter,n.replayFilter()):n.filter;n.or?!function(){function a(){2===++f&&e()}function c(n,e,o){if(!u||u(e,o,a,r)){var i=e.primaryKey.toString();s.hasOwnProperty(i)||(s[i]=!0,t(n,e,o))}}var s={},f=0;n.or._iterate(c,a,r,i),dn(o(n,i),n.algorithm,c,a,r,!n.keysOnly&&n.valueFilter)}():dn(o(n,i),Pn(n.algorithm,u),t,e,r,!n.keysOnly&&n.valueFilter)}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(Xn,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(Zn,n,"locked")},_addAlgorithm:function(n){var t=this._ctx;t.algorithm=Pn(t.algorithm,n)},_iterate:function(n,t,e,r){return i(this._ctx,n,t,e,r)},clone:function(n){var t=Object.create(this.constructor.prototype),e=Object.create(this._ctx);return n&&f(e,n),t._ctx=e,t},raw:function(){return this._ctx.valueFilter=null,this},each:function(n){var t=this._ctx;return Tn&&n(u(t)),this._read(function(e,r,o){i(t,n,e,r,o)})},count:function(n){if(Tn)return B.resolve(0).then(n);var t=this,e=this._ctx;if(e.filter||e.algorithm||e.or||e.replayFilter){var o=0;return this._read(function(n,t,r){i(e,function(){return++o,!1},function(){n(o)},t,r)},n)}return this._read(function(n,o,i){var u=r(e,i),a=e.range?u.count(e.range):u.count();a.onerror=Q(o,["calling","count()","on",t.name]),a.onsuccess=function(t){n(t.target.result)}},n)},sortBy:function(n,t){function e(n,t){return t?e(n[o[t]],t-1):n[i]}function r(n,t){var r=e(n,u),o=e(t,u);return o>r?-a:r>o?a:0}var o=n.split(".").reverse(),i=o[0],u=o.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){Tn&&n([u(t)]);var o=[];i(t,function(n){o.push(n)},function(){n(o)},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 Tn&&t(u(r)),n(this._ctx,function(n,r,o){return t(n.value)?(r(o),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)},and:function(t){return Tn&&t(u(this._ctx)),n(this._ctx,function(n){return t(n.value)}),e(this._ctx,t),this},or:function(n){return new an(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 Tn&&n(P(u(this._ctx),this._ctx.index?this._ctx.table.schema.idxByName[this._ctx.index].keyPath:this._ctx.table.schema.primKey.keyPath)),t.keysOnly=!0,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=!0;var e=[];return Tn?new B(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=r.hasOwnProperty(t);return r[t]=!0,!e}),this}}}),d(sn).from(cn).extend({modify:function(t){var e=this,r=this._ctx,o=r.table.hook,i=o.updating.fire,u=o.deleting.fire;return Tn&&"function"==typeof t&&t.call({value:r.table.schema.instanceTemplate},r.table.schema.instanceTemplate),this._write(function(o,a,c,s){function l(n,t){function e(n){return x.push(n),D.push(o.primKey),o.onerror&&B.newPSD(function(){B.PSD.trans=s,o.onerror(n)}),d(),!0}I=t.primaryKey;var o={primKey:t.primaryKey,value:n,onsuccess:null,onerror:null};if(p.call(o,n,o)!==!1){var i=!o.hasOwnProperty("value");++g,b(function(){var u=i?t["delete"]():t.update(o.value);u.onerror=Q(e,i?["deleting",n,"from",r.table.name]:["modifying",n,"on",r.table.name]),u.onsuccess=function(){o.onsuccess&&B.newPSD(function(){B.PSD.trans=s,o.onsuccess(o.value)}),++w,d()}},e)}else o.onsuccess&&o.onsuccess(o.value)}function h(n){return n&&(x.push(n),D.push(I)),a(new A("Error modifying one or more objects",x,w,D))}function d(){_&&w+x.length===g&&(x.length>0?h():o(w))}var p;if("function"==typeof t)p=i===n&&u===n?t:function(n){var e=O(n);if(t.call(this,n,this)===!1)return!1;if(this.hasOwnProperty("value")){var r=E(e,this.value),o=i.call(this,r,this.primKey,e,s);o&&(n=this.value,on(o).forEach(function(t){k(n,t,o[t])}))}else u.call(this,this.primKey,n,s)};else if(i===n){var v=on(t),y=v.length;p=function(n){for(var e=!1,r=0;y>r;++r){var o=v[r],i=t[o];P(n,o)!==i&&(k(n,o,i),e=!0)}return e}}else{var m=t;t=S(m),p=function(n){var e=!1,r=i.call(this,t,this.primKey,O(n),s);return r&&f(t,r),on(t).forEach(function(r){var o=t[r];P(n,r)!==o&&(k(n,r,o),e=!0)}),r&&(t=S(m)),e}}var g=0,w=0,_=!1,x=[],D=[],I=null;e.clone().raw()._iterate(l,function(){_=!0,d()},h,c)})},"delete":function(){var t=this,e=this._ctx,r=e.range,o=e.table.hook.deleting.fire,i=o!==n;if(!i&&!e.or&&!e.algorithm&&!e.filter&&!e.replayFilter&&(e.isPrimKey&&!An||!r))return this._write(function(n,t,o){var i=Q(t,["deleting range from",e.table.name]),u=r?o.count(r):o.count();u.onerror=i,u.onsuccess=function(){var e=u.result;b(function(){var t=r?o["delete"](r):o.clear();t.onerror=i,t.onsuccess=function(){return n(e)}},function(n){return t(T(n))})}});var u=i?2e3:1e4;return this._write(function(n,r,a,c){var s=0,f=Object.create(e.table);f._tpf=c._tpf;var l=t.clone({table:f,keysOnly:!i}).distinct().limit(u).raw(),h=[],d=function(){return l.each(i?function(n,t){h.push([t.primaryKey,t.value])}:function(n,t){h.push(t.primaryKey)}).then(function(){return i?h.sort(function(n,t){return bn(n[0],t[0])}):h.sort(bn),z(a,c,h,i,o)}).then(function(){var n=h.length;return s+=n,h=[],u>n?s:d()})};n(d())})}}),f(this,{Collection:cn,Table:M,Transaction:G,Version:m,WhereClause:an,WriteableCollection:sn,WriteableTable:U}),y(),Rn.forEach(function(n){n($n)})}function J(n,t){var e=B.PSD;return function(){var r=B.PSD;B.PSD=e;try{n.apply(this,arguments)}catch(o){t(o)}finally{B.PSD=r}}}function G(n){if("function"==typeof n)return new n;if(un(n))return[G(n[0])];if(n&&"object"==typeof n){var t={};return Y(t,n),t}return n}function Y(n,t){return on(t).forEach(function(e){var r=G(t[e]);n[e]=r}),n}function Q(n,t){return function(e){var r=e&&e.target.error||new Error("");if(t){var o=" occurred when "+t.map(function(n){switch(typeof n){case"function":return n();case"string":return n;default:return JSON.stringify(n)}}).join(" ");r.message&&r.message!=r.name&&(o+=". "+r.message),r.name?r=T(r,r.name+o):r+=o}return n(r),e&&(e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()),!1}}function X(n){n.preventDefault()}function Z(n){var t,e=H.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 $(n){function t(n){return function(t){var r=n(t),o=r.value;return r.done?o:o&&"function"==typeof o.then?o.then(i,u):Array.isArray(o)?e(o,0):i(o)}}function e(n,t){if(t===n.length)return i(n);var r=n[t];return r.constructor&&"function"==typeof r.constructor.all?r.constructor.all(n).then(i,u):e(n,t+1)}var r=function(t){return n.next(t)},o=function(t){return n["throw"](t)},i=t(r),u=t(o);return t(r)()}function nn(n,t,e,r,o,i,u){this.name=n,this.keyPath=t,this.unique=e,this.multi=r,this.auto=o,this.compound=i,this.dotted=u;var a="string"==typeof t?t:t&&"["+[].join.call(t,"+")+"]";this.src=(e?"&":"")+(r?"*":"")+(o?"++":"")+a}function tn(n,t,e,r){this.name=n,this.primKey=t||new nn,this.indexes=e||[new nn],this.instanceTemplate=r,this.mappedClass=null,this.idxByName=e.reduce(function(n,t){return n[t.name]=t,n},{})}function en(n){return 1===n.length?n[0]:n}function rn(n){var t=n&&(n.getDatabaseNames||n.webkitGetDatabaseNames);return t&&t.bind(n)}var on=Object.keys,un=Array.isArray,an="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,cn=[].slice,sn=["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"],ln=sn.concat(fn),hn={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",IncompatiblePromise:"Incompatible Promise used in transaction scope. See http://tinyurl.com/znyqjqc"};d(I).from(Error).extend({dump:function(){return w(this)}}),d(A).from(I),d(j).from(I);var dn=ln.reduce(function(n,t){return n[t]=t+"Error",n},{}),pn=I,vn=ln.reduce(function(n,t){function e(n,e){this.name=r,"string"==typeof n?(this.message=n,this.inner=e||null):"object"==typeof n?(this.message=n.name+" "+n.message,this.inner=n):(this.message=hn[t],this.inner=null)}var r=t+"Error";return d(e).from(pn),n[t]=e,n},{});vn.Syntax=SyntaxError,vn.Type=TypeError,vn.Range=RangeError;var yn=fn.reduce(function(n,t){return n[t+"Error"]=vn[t],n},{}),mn=ln.reduce(function(n,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(n[t+"Error"]=vn[t]),n},{});mn.ModifyError=A,mn.DexieError=I,mn.BulkError=j;var gn=an.setImmediate||function(n){var t=p(arguments,1);setTimeout(function(){n.apply(an,t)},0)};y(function(){gn=bn=Pn=function(n){var t=arguments;setTimeout(function(){n.apply(an,p(t,1))},0)}});var bn=gn,wn=!0,_n=[],xn=[],Pn=function(n){_n.push([n,p(arguments,1)])};B.all=function(){var n=p(1===arguments.length&&un(arguments[0])?arguments[0]:arguments);return new B(function(t,e){function r(i,u){try{if(u&&("object"==typeof u||"function"==typeof u)){var a=u.then;if("function"==typeof a)return void a.call(u,function(n){r(i,n)},e)}n[i]=u,0===--o&&t(n)}catch(c){e(c)}}if(0===n.length)return t([]);for(var o=n.length,i=0;i<n.length;i++)r(i,n[i])})},B.prototype.then=function(n,t){var e=this,r=new B(function(r,o){null===e._state?N(e,new W(n,t,r,o)):bn(N,e,new W(n,t,r,o))});return r._PSD=this._PSD,r.onuncatched=this.onuncatched,r._parent=this,r},B.prototype._then=function(t,e){N(this,new W(t,e,n,n))},B.prototype["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):B.reject(n)}):this.then(null,function(n){return n&&n.name===t?e(n):B.reject(n)})},B.prototype["finally"]=function(n){return this.then(function(t){return n(),t},function(t){return n(),B.reject(t)})},B.prototype.onuncatched=null,B.resolve=function(n){if(n&&"function"==typeof n.then)return n;var t=new B(function(){});return t._state=!0,t._value=n,t},B.reject=function(n){var t=new B(function(){});return t._state=!1,t._value=n,t},B.race=function(n){return new B(function(t,e){n.map(function(n){n.then(t,e)})})},B.PSD=null,B.newPSD=function(n){var t=B.PSD;B.PSD=t?Object.create(t):{};try{return n()}finally{B.PSD=t}},B.usePSD=function(n,t){var e=B.PSD;B.PSD=n;try{return t()}finally{B.PSD=e}},B._rootExec=R,B._tickFinalize=function(n){if(wn)throw new Error("Not in a virtual tick");xn.push(n)},B.on=K(null,{error:[function(n,t){return t},z]});var kn=String.fromCharCode(65535),Dn=function(){try{return IDBKeyRange.only([[]]),[[]]}catch(n){return kn}}(),Sn="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",On="String expected.",En=[],In="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Cn=In,An=In,jn=function(){},Tn=!1;H["delete"]=function(n){var t=new H(n),e=t["delete"]();return e.onblocked=function(n){return t.on("blocked",n),this},e},H.exists=function(n){return new H(n).open().then(function(n){return n.close(),!0})["catch"](H.NoSuchDatabaseError,function(){return!1})},H.getDatabaseNames=function(n){return new B(function(n,t){var e=rn(indexedDB);if(e){var r=e();r.onsuccess=function(t){n(p(t.target.result,0))},r.onerror=Q(t)}else Z(function(t){return n(t),!1})}).then(n)},H.defineClass=function(n){function t(t){t?f(this,t):Tn&&Y(this,n)}return t},H.applyStructure=Y,H.ignoreTransaction=function(n){return B.newPSD(function(){return B.PSD.trans=null,n()})},H.vip=function(n){return B.newPSD(function(){return B.PSD.letThrough=!0,n()})},H.async=function(n){return function(){try{var t=$(n.apply(this,arguments));return t&&"function"==typeof t.then?t:H.Promise.resolve(t)}catch(e){return H.Promise.reject(e)}}},H.spawn=function(n,t,e){try{var r=$(n.apply(e,t||[]));return r&&"function"==typeof r.then?r:H.Promise.resolve(r)}catch(o){return H.Promise.reject(o)}},h(H,"currentTransaction",{get:function(){return B.PSD&&B.PSD.trans||null}}),H.Promise=B,H.derive=d,H.extend=f,H.extendProto=l,H.override=v,H.Events=H.events=K,H.getByKeyPath=P,H.setByKeyPath=k,H.delByKeyPath=D,H.shallowClone=S,H.deepClone=O,H.addons=[],H.fakeAutoComplete=jn,H.asap=g,H.maxKey=Dn,H.connections=En,H.dump=w,f(H,mn),H.MultiModifyError=H.ModifyError,H.errnames=dn,H.IndexSpec=nn,H.TableSchema=tn;var Kn=an.idbModules&&an.idbModules.shimIndexedDB?an.idbModules:{};return H.dependencies={indexedDB:Kn.shimIndexedDB||an.indexedDB||an.mozIndexedDB||an.webkitIndexedDB||an.msIndexedDB,IDBKeyRange:Kn.IDBKeyRange||an.IDBKeyRange||an.webkitIDBKeyRange},b(function(){H.dependencies.localStorage=null!=("undefined"!=typeof chrome&&null!==chrome?chrome.storage:void 0)?null:an.localStorage}),H.semVer="1.3.6-beta.3",H.version=H.semVer.split(".").map(function(n){return parseInt(n)}).reduce(function(n,t,e){return n+t/Math.pow(10,2*e)}),y(function(){H.fakeAutoComplete=jn=y,H.fake=Tn=!0}),H["default"]=H,H}); | ||
//# sourceMappingURL=dist/dexie.min.js.map |
{ | ||
"name": "dexie", | ||
"version": "1.3.6-beta.2", | ||
"version": "1.3.6-beta.3", | ||
"description": "A Minimalistic Wrapper for IndexedDB", | ||
@@ -31,4 +31,5 @@ "main": "dist/dexie.js", | ||
"watch": "babel-node --presets es2015 --plugins syntax-async-functions,transform-regenerator tools/watch.js", | ||
"test": "node_modules/.bin/karma start test/karma.conf.js --single-run --browsers Chrome", | ||
"test:debug": "node_modules/.bin/karma start test/karma.conf.js --browsers Chrome" | ||
"test": "node_modules/.bin/karma start test/karma.conf.js --single-run", | ||
"test:bs": "node_modules/.bin/karma start test/karma.browserstack.conf.js --single-run", | ||
"test:debug": "node_modules/.bin/karma start test/karma.conf.js --log-level debug" | ||
}, | ||
@@ -47,3 +48,5 @@ "engines": { | ||
"es6-promisify-all": "^0.1.0", | ||
"eslint": "^2.7.0", | ||
"karma": "^0.13.19", | ||
"karma-browserstack-launcher": "^0.1.10", | ||
"karma-chrome-launcher": "^0.2.2", | ||
@@ -50,0 +53,0 @@ "karma-mocha-reporter": "^1.1.5", |
@@ -56,3 +56,3 @@ import {extend} from './utils'; | ||
var res = f1.apply(this, arguments); | ||
if (res !== undefined) extend(arguments[0], res); // If f1 returns new modifications, extend caller's modifications with the result before calling next in chain. | ||
extend(arguments[0], res); // If f1 returns new modifications, extend caller's modifications with the result before calling next in chain. | ||
var onsuccess = this.onsuccess, // In case event listener has set this.onsuccess | ||
@@ -67,3 +67,3 @@ onerror = this.onerror; // In case event listener has set this.onerror | ||
(res2 === undefined ? undefined : res2) : | ||
(res2 === undefined ? res : extend(res, res2)); | ||
(extend(res, res2)); | ||
}; | ||
@@ -70,0 +70,0 @@ } |
@@ -18,3 +18,5 @@ // Type definitions for Dexie v{version} | ||
addons?: Array<(db: Dexie) => void>, | ||
autoOpen?: boolean | ||
autoOpen?: boolean, | ||
indexedDB?: IDBDatabase, | ||
IDBKeyRange?: IDBKeyRange | ||
}); | ||
@@ -52,2 +54,4 @@ | ||
static maxKey: Array<string>; | ||
static dump(error:any):string; | ||
@@ -403,4 +407,6 @@ static dependencies: { | ||
inner: any; | ||
constructor (name?:string, message?:string); | ||
toString(): string; | ||
dump(): string; | ||
} | ||
@@ -427,2 +433,3 @@ | ||
class DatabaseClosedError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} | ||
class IncompatiblePromiseError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} | ||
class UnknownError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} | ||
@@ -429,0 +436,0 @@ class ConstraintError extends DexieError {constructor (msg?: string, inner?: Object); constructor (inner: Object);} |
@@ -1,2 +0,2 @@ | ||
import { derive } from './utils'; | ||
import { derive, messageAndStack } from './utils'; | ||
@@ -58,3 +58,7 @@ var dexieErrorNames = [ | ||
} | ||
derive(DexieError).from(Error); | ||
derive(DexieError).from(Error).extend({ | ||
dump: function () { | ||
return messageAndStack(this); | ||
} | ||
}); | ||
@@ -61,0 +65,0 @@ function getMultiErrorMessage (msg, failures) { |
@@ -1,2 +0,2 @@ | ||
import {_global, slice, isArray, doFakeAutoComplete} from './utils'; | ||
import {_global, slice, isArray, doFakeAutoComplete, messageAndStack} from './utils'; | ||
import { nop } from './chaining-functions'; | ||
@@ -375,3 +375,3 @@ import Events from './Events'; | ||
function defaultErrorHandler(e) { | ||
console.error(`Uncaught Promise: ${e.stack || e}`); | ||
console.warn(`Uncaught Promise: ${messageAndStack(e)}`); | ||
} |
@@ -22,3 +22,3 @@ /* | ||
export function extend(obj, extension) { | ||
if (typeof extension !== 'object') extension = extension(); // Allow to supply a function returning the extension. Useful for simplifying private scopes. | ||
if (typeof extension !== 'object') return obj; | ||
keys(extension).forEach(function (key) { | ||
@@ -30,2 +30,15 @@ obj[key] = extension[key]; | ||
export function extendProto (proto, extension) { | ||
if (typeof extension === 'function') extension = extension(Object.getPrototypeOf(proto)); | ||
keys(extension).forEach(key => { | ||
setProp(proto, key, extension[key]); | ||
}); | ||
} | ||
export function setProp(obj, prop, functionOrGetSet, options) { | ||
Object.defineProperty(obj, prop, extend(typeof functionOrGetSet.get === 'function' ? | ||
{get: functionOrGetSet.get, set: functionOrGetSet.set, configurable: true} : | ||
{value: functionOrGetSet, configurable: true, writable: true}, options)); | ||
} | ||
export function derive(Child) { | ||
@@ -35,7 +48,5 @@ return { | ||
Child.prototype = Object.create(Parent.prototype); | ||
Child.prototype.constructor = Child; | ||
setProp(Child.prototype, "constructor", Child); | ||
return { | ||
extend: function (extension) { | ||
extend(Child.prototype, typeof extension !== 'object' ? extension(Parent.prototype) : extension); | ||
} | ||
extend: extendProto.bind(null, Child.prototype) | ||
}; | ||
@@ -76,2 +87,11 @@ } | ||
export function messageAndStack (e) { | ||
var stack = e && e.stack; | ||
return stack ? | ||
stack.indexOf(e+'') > 0 ? | ||
stack : | ||
e + ". " + stack : | ||
e; | ||
} | ||
export function stack(error) { | ||
@@ -78,0 +98,0 @@ if (error.stack) return error; // Provided error already has a stack |
@@ -6,3 +6,3 @@ module.exports = function(config) { | ||
frameworks: [ | ||
'qunit', | ||
'qunit' | ||
], | ||
@@ -28,9 +28,13 @@ | ||
port: 9876, | ||
captureTimeout: 30 * 1000, | ||
browserNoActivityTimeout: 10 * 60 * 1000, | ||
port: 19144, | ||
//captureTimeout: 30 * 1000, | ||
//browserNoActivityTimeout: 10 * 60 * 1000, | ||
colors: true, | ||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
//logLevel: config.LOG_DEBUG, | ||
browsers: [ | ||
'Chrome' | ||
'Chrome' | ||
], | ||
@@ -41,3 +45,3 @@ | ||
'karma-mocha-reporter', | ||
'karma-chrome-launcher' | ||
'karma-chrome-launcher', | ||
] | ||
@@ -44,0 +48,0 @@ }; |
@@ -21,3 +21,3 @@ import Dexie from 'dexie'; | ||
function log(txt, noPerf) { | ||
let logstr = (tick && lastPerf ? "took " + (Date.now()-tick) + "ms\n" :"") + txt + (noPerf?"\n":"... "); | ||
let logstr = (tick && lastPerf ? "took " + (Date.now()-tick) + "ms.\n" :"") + txt + (noPerf?"\n":""); | ||
ok(true, logstr); | ||
@@ -44,5 +44,5 @@ tick = Date.now(); | ||
yield db.delete(); | ||
log("Inserting data:"); | ||
log(`Inserting data (${MAX} items):`); | ||
yield db.storage.bulkAdd(data); | ||
log("done. Deleting data with dexie"); | ||
log(`done. Deleting items using db.storage.where("id").between(100, ${MAX - 100}).delete()`); | ||
yield db.storage.where("id").between(100, MAX - 100).delete(); | ||
@@ -49,0 +49,0 @@ log("done"); |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
1595405
43
16681
19
3