1 line
70 KiB
JavaScript
1 line
70 KiB
JavaScript
System.register([],function(e,t){var n,r,i,o,u,a,s,c,l,f,h,p,d,y,v,m,g,b,_,w,k,x,P,E,O,S,j,A,K,C,I,T,B,D,R,F,q,M,N,U,V,W,z,L,Y,G,H,Q,X,J,$,Z,ee,te,ne,re,ie,oe,ue,ae,se,ce,le,fe,he,pe,de,ye,ve,me,ge,be,_e,we,ke,xe,Pe,Ee,Oe,Se,je,Ae,Ke,Ce,Ie,Te,Be,De;function Re(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var o=arguments[t],u=0,a=o.length;u<a;u++,i++)r[i]=o[u];return r}function Fe(e,t){return"object"!=typeof t||r(t).forEach(function(n){e[n]=t[n]}),e}function qe(e,t){return a.call(e,t)}function Me(e,t){"function"==typeof t&&(t=t(u(e))),r(t).forEach(function(n){Ne(e,n,t[n])})}function Ne(e,t,n,r){s(e,t,Fe(n&&qe(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Ue(e){return{from:function(t){return e.prototype=Object.create(t.prototype),Ne(e.prototype,"constructor",e),{extend:Me.bind(null,e.prototype)}}}}function Ve(e,t){var n;return c(e,t)||(n=u(e))&&Ve(n,t)}function We(e,t,n){return l.call(e,t,n)}function ze(e,t){return t(e)}function Le(e){if(!e)throw new Error("Assertion Failed")}function Ye(e){o.setImmediate?setImmediate(e):setTimeout(e,0)}function Ge(e,t){return e.reduce(function(e,n,r){var i=t(n,r);return i&&(e[i[0]]=i[1]),e},{})}function He(e,t){if(qe(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,i=t.length;r<i;++r){var o=He(e,t[r]);n.push(o)}return n}var u=t.indexOf(".");if(-1!==u){var a=e[t.substr(0,u)];return void 0===a?void 0:He(a,t.substr(u+1))}}function Qe(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){Le("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)Qe(e,t[r],n[r])}else{var u=t.indexOf(".");if(-1!==u){var a=t.substr(0,u),s=t.substr(u+1);if(""===s)void 0===n?i(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=n;else{var c=e[a];c||(c=e[a]={}),Qe(c,s,n)}}else void 0===n?i(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Xe(e,t){"string"==typeof t?Qe(e,t,void 0):"length"in t&&[].map.call(t,function(t){Qe(e,t,void 0)})}function Je(e){var t={};for(var n in e)qe(e,n)&&(t[n]=e[n]);return t}function $e(e){return f.apply([],e)}function Ze(e){if(!e||"object"!=typeof e)return e;var t;if(i(e)){t=[];for(var n=0,r=e.length;n<r;++n)t.push(Ze(e[n]))}else if(p.indexOf(e.constructor)>=0)t=e;else for(var o in t=e.constructor?Object.create(e.constructor.prototype):{},e)qe(e,o)&&(t[o]=Ze(e[o]));return t}function et(e){return y.call(e).slice(8,-1)}function tt(e,t,n,i){return n=n||{},i=i||"",r(e).forEach(function(r){if(qe(t,r)){var o=e[r],u=t[r];if("object"==typeof o&&"object"==typeof u&&o&&u){var a=et(o),s=et(u);a===s?d[a]?v(o,a)!==v(u,s)&&(n[i+r]=t[r]):tt(o,u,n,i+r+"."):n[i+r]=t[r]}else o!==u&&(n[i+r]=t[r])}else n[i+r]=void 0}),r(t).forEach(function(r){qe(e,r)||(n[i+r]=t[r])}),n}function nt(e){var t,n,r,o;if(1===arguments.length){if(i(e))return e.slice();if(this===b&&"string"==typeof e)return[e];if(o=g(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}function rt(e,t){w=e,k=t}function it(){if(x)try{throw new Error}catch(e){return e}return new Error}function ot(e,t){var n=e.stack;return n?(t=t||0,0===n.indexOf(e.name)&&(t+=(e.name+e.message).split("\n").length),n.split("\n").slice(t).filter(k).map(function(e){return"\n"+e}).join("")):""}function ut(e,t){this._e=it(),this.name=e,this.message=t}function at(e,t){return e+". Errors: "+Object.keys(t).map(function(e){return t[e].toString()}).filter(function(e,t,n){return n.indexOf(e)===t}).join("\n")}function st(e,t,n,r){this._e=it(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=at(e,t)}function ct(e,t){this._e=it(),this.name="BulkError",this.failures=t,this.message=at(e,t)}function lt(e,t){if(!e||e instanceof ut||e instanceof TypeError||e instanceof SyntaxError||!e.name||!K[e.name])return e;var n=new K[e.name](t||e.message,e);return"stack"in e&&Ne(n,"stack",{get:function(){return this.inner.stack}}),n}function ft(){}function ht(e){return e}function pt(e,t){return null==e||e===ht?t:function(n){return t(e(n))}}function dt(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function yt(e,t){return e===ft?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?dt(r,this.onsuccess):r),i&&(this.onerror=this.onerror?dt(i,this.onerror):i),void 0!==o?o:n}}function vt(e,t){return e===ft?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?dt(n,this.onsuccess):n),r&&(this.onerror=this.onerror?dt(r,this.onerror):r)}}function mt(e,t){return e===ft?t:function(n){var r=e.apply(this,arguments);Fe(n,r);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var u=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?dt(i,this.onsuccess):i),o&&(this.onerror=this.onerror?dt(o,this.onerror):o),void 0===r?void 0===u?void 0:u:Fe(r,u)}}function gt(e,t){return e===ft?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function bt(e,t){return e===ft?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return n.then(function(){return t.apply(r,o)})}return t.apply(this,arguments)}}function _t(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=ft,this._lib=!1;var t=this._PSD=$;if(w&&(this._stackHolder=it(),this._prev=null,this._numPrev=0),"function"!=typeof e){if(e!==I)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&xt(this,this._value))}this._state=null,this._value=null,++t.ref,kt(this,e)}function wt(e,t,n,r,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=i}function kt(e,t){try{t(function(t){if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Kt();t&&"function"==typeof t.then?kt(e,function(e,n){t instanceof _t?t._then(e,n):t.then(e,n)}):(e._state=!0,e._value=t,Pt(e)),n&&Ct()}},xt.bind(null,e))}catch(n){xt(e,n)}}function xt(e,t){if(H.push(t),null===e._state){var n=e._lib&&Kt();t=X(t),e._state=!1,e._value=t,w&&null!==t&&"object"==typeof t&&!t._promise&&function(e,t,n){try{e.apply(null,n)}catch(r){t&&t(r)}}(function(){var n=Ve(t,"stack");t._promise=e,Ne(t,"stack",{get:function(){return V?n&&(n.get?n.get.apply(t):n.value):e.stack}})}),function(e){G.some(function(t){return t._value===e._value})||G.push(e)}(e),Pt(e),n&&Ct()}}function Pt(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Et(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===ee&&(++ee,z(function(){0===--ee&&It()},[]))}function Et(e,t){if(null!==e._state){var n=e._state?t.onFulfilled:t.onRejected;if(null===n)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++ee,z(Ot,[n,e,t])}else e._listeners.push(t)}function Ot(e,t,n){try{Q=t;var r,i=t._value;t._state?r=e(i):(H.length&&(H=[]),r=e(i),-1===H.indexOf(i)&&function(e){for(var t=G.length;t;)if(G[--t]._value===e._value)return void G.splice(t,1)}(t)),n.resolve(r)}catch(o){n.reject(o)}finally{Q=null,0===--ee&&It(),--n.psd.ref||n.psd.finalize()}}function St(e,t,n){if(t.length===n)return t;var r="";if(!1===e._state){var i,o,u=e._value;null!=u?(i=u.name||"Error",o=u.message||u,r=ot(u,0)):(i=u,o=""),t.push(i+(o?": "+o:"")+r)}return w&&((r=ot(e._stackHolder,2))&&-1===t.indexOf(r)&&t.push(r),e._prev&&St(e._prev,t,n)),t}function jt(e,t){var n=t?t._numPrev+1:0;n<T&&(e._prev=t,e._numPrev=n)}function At(){Kt()&&Ct()}function Kt(){var e=L;return L=!1,Y=!1,e}function Ct(){var e,t,n;do{for(;Z.length>0;)for(e=Z,Z=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(Z.length>0);L=!0,Y=!0}function It(){var e=G;G=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=te.slice(0),n=t.length;n;)t[--n]()}function Tt(e){return new _t(I,!1,e)}function Bt(e,t){var n=$;return function(){var r=Kt(),i=$;try{return Ut(n,!0),e.apply(this,arguments)}catch(o){t&&t(o)}finally{Ut(i,!1),r&&Ct()}}}function Dt(e,t,n,r){var i=$,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++se;var u=J.env;o.env=U?{Promise:_t,PromiseProp:{value:_t,configurable:!0,writable:!0},all:_t.all,race:_t.race,allSettled:_t.allSettled,any:_t.any,resolve:_t.resolve,reject:_t.reject,nthen:Yt(u.nthen,o),gthen:Yt(u.gthen,o)}:{},t&&Fe(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Wt(o,e,n,r);return 0===o.ref&&o.finalize(),a}function Rt(){return re.id||(re.id=++ie),++re.awaits,re.echoes+=B,re.id}function Ft(){return!!re.awaits&&(0===--re.awaits&&(re.id=0),re.echoes=re.awaits*B,!0)}function qt(e){return re.echoes&&e&&e.constructor===N?(Rt(),e.then(function(e){return Ft(),e},function(e){return Ft(),le(e)})):e}function Mt(e){++ae,re.echoes&&0!==--re.echoes||(re.echoes=re.id=0),oe.push($),Ut(e,!0)}function Nt(){var e=oe[oe.length-1];oe.pop(),Ut(e,!1)}function Ut(e,t){var n=$;if((t?!re.echoes||ue++&&e===$:!ue||--ue&&e===$)||zt(t?Mt.bind(null,e):Nt),e!==$&&($=e,n===J&&(J.env=Vt()),U)){var r=J.env.Promise,i=e.env;F.then=i.nthen,r.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(o,"Promise",i.PromiseProp),r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject,i.allSettled&&(r.allSettled=i.allSettled),i.any&&(r.any=i.any))}}function Vt(){var e=o.Promise;return U?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(o,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:F.then,gthen:e.prototype.then}:{}}function Wt(e,t,n,r,i){var o=$;try{return Ut(e,!0),t(n,r,i)}finally{Ut(o,!1)}}function zt(e){M.call(R,e)}function Lt(e,t,n,r){return"function"!=typeof e?e:function(){var i=$;n&&Rt(),Ut(t,!0);try{return e.apply(this,arguments)}finally{Ut(i,!1),r&&zt(Ft)}}}function Yt(e,t){return function(n,r){return e.call(this,Lt(n,t),Lt(r,t))}}function Gt(e,t){var n;try{n=t.onuncatched(e)}catch(u){}if(!1!==n)try{var r,i={promise:t,reason:e};if(o.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(ce,!0,!0),Fe(r,i)):o.CustomEvent&&Fe(r=new CustomEvent(ce,{detail:i}),i),r&&o.dispatchEvent&&(dispatchEvent(r),!o.PromiseRejectionEvent&&o.onunhandledrejection))try{o.onunhandledrejection(r)}catch(a){}w&&r&&!r.defaultPrevented&&console.warn("Unhandled rejection: "+(e.stack||e))}catch(u){}}function Ht(e,t,n,r){if(e._state.openComplete||$.letThrough){var i=e._createTransaction(t,n,e._dbSchema);try{i.create()}catch(o){return le(o)}return i._promise(t,function(e,t){return Dt(function(){return $.trans=i,r(e,t,i)})}).then(function(e){return i._completion.then(function(){return e})})}if(!e._state.isBeingOpened){if(!e._options.autoOpen)return le(new A.DatabaseClosed);e.open().catch(ft)}return e._state.dbReadyPromise.then(function(){return Ht(e,t,n,r)})}function Qt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}function Xt(e){return function(t){return void 0===He(t,e)&&Xe(t=Ze(t),e),t}}function Jt(e){var t={},n=function(n,r){if(r){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return t[n].subscribe.apply(null,o),e}if("string"==typeof n)return t[n]};n.addEventType=a;for(var o=1,u=arguments.length;o<u;++o)a(arguments[o]);return n;function a(e,o,u){if("object"!=typeof e){var s;o||(o=gt),u||(u=ft);var c={subscribers:[],fire:u,subscribe:function(e){-1===c.subscribers.indexOf(e)&&(c.subscribers.push(e),c.fire=o(c.fire,e))},unsubscribe:function(e){c.subscribers=c.subscribers.filter(function(t){return t!==e}),c.fire=c.subscribers.reduce(o,u)}};return t[e]=n[e]=c,c}r(s=e).forEach(function(e){var t=s[e];if(i(t))a(e,s[e][0],s[e][1]);else{if("asap"!==t)throw new A.InvalidArgument("Invalid event config");var n=a(e,ht,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){Ye(function(){e.apply(null,t)})})})}})}}function $t(e,t){return Ue(t).from({prototype:e}),t}function Zt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function en(e,t){e.filter=Qt(e.filter,t)}function tn(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return Qt(r(),t())}:t,e.justLimit=n&&!r}function nn(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new A.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function rn(e,t,n){var r=nn(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:"prev"===e.dir,unique:!!e.unique,query:{index:r,range:e.range}})}function on(e,t,n,r){var i=e.replayFilter?Qt(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},u=function(e,n,r){if(!i||i(n,r,function(e){return n.stop(e)},function(e){return n.fail(e)})){var u=n.primaryKey,a=""+u;"[object ArrayBuffer]"===a&&(a=""+new Uint8Array(u)),qe(o,a)||(o[a]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(u,n),un(rn(e,r,n),e.algorithm,u,!e.keysOnly&&e.valueMapper)])}return un(rn(e,r,n),Qt(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function un(e,t,n,r){var i=Bt(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then(function(e){if(e)return e.start(function(){var n=function(){return e.continue()};t&&!t(e,function(e){return n=e},function(t){e.stop(t),n=ft},function(t){e.fail(t),n=ft})||i(e.value,e,function(e){return n=e}),n()})})}function an(e,t){return e<t?-1:e===t?0:1}function sn(e,t){return e>t?-1:e===t?0:1}function cn(e,t,n){var r=e instanceof Se?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function ln(e){return new e.Collection(e,function(){return dn("")}).limit(0)}function fn(e,t,n,r,i,o){for(var u=Math.min(e.length,r.length),a=-1,s=0;s<u;++s){var c=t[s];if(c!==r[s])return i(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):i(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):a>=0?e.substr(0,a)+t[a]+n.substr(a+1):null;i(e[s],c)<0&&(a=s)}return u<r.length&&"next"===o?e+n.substr(e.length):u<e.length&&"prev"===o?e.substr(0,n.length):a<0?null:e.substr(0,a)+r[a]+n.substr(a+1)}function hn(e,t,n,r){var i,o,u,a,s,c,l,f=n.length;if(!n.every(function(e){return"string"==typeof e}))return cn(e,ye);function h(e){i=function(e){return"next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()}}(e),o=function(e){return"next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()}}(e),u="next"===e?an:sn;var t=n.map(function(e){return{lower:o(e),upper:i(e)}}).sort(function(e,t){return u(e.lower,t.lower)});a=t.map(function(e){return e.upper}),s=t.map(function(e){return e.lower}),c=e,l="next"===e?"":r}h("next");var p=new e.Collection(e,function(){return pn(a[0],s[f-1]+r)});p._ondirectionchange=function(e){h(e)};var d=0;return p._addAlgorithm(function(e,n,r){var i=e.key;if("string"!=typeof i)return!1;var h=o(i);if(t(h,s,d))return!0;for(var p=null,y=d;y<f;++y){var v=fn(i,h,a[y],s[y],u,c);null===v&&null===p?d=y+1:(null===p||u(p,v)>0)&&(p=v)}return n(null!==p?function(){e.continue(p+l)}:r),!1}),p}function pn(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function dn(e){return{type:1,lower:e,upper:e}}function yn(e){return 1===e.length?e[0]:e}function vn(e){try{return e.only([[]]),[[]]}catch(t){return he}}function mn(e){return Bt(function(t){return gn(t),e(t.target.error),!1})}function gn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}function bn(e,t,n,r,i,o,u){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!u?"&":"")+(r?"*":"")+(i?"++":"")+_n(t)}}function _n(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function wn(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:Ge(n,function(e){return[e.name,e]})}}function kn(e){return null==e?function(){}:"string"==typeof e?function(e){return 1===e.split(".").length?function(t){return t[e]}:function(t){return He(t,e)}}(e):function(t){return He(t,e)}}function xn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}function Pn(e){return[].slice.call(e)}function En(e){return null==e?":id":"string"==typeof e?e:"["+e.join("+")+"]"}function On(e,t,n,r){var o=t.cmp.bind(t);function u(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,r=e.upper,i=e.lowerOpen,o=e.upperOpen;return void 0===t?void 0===r?null:n.upperBound(r,!!o):void 0===r?n.lowerBound(t,!!i):n.bound(t,r,!!i,!!o)}var a=function(e,t){var n=Pn(e.objectStoreNames);return{schema:{name:e.name,tables:n.map(function(e){return t.objectStore(e)}).map(function(e){var t=e.keyPath,n=e.autoIncrement,r=i(t),o=null==t,u={},a={name:e.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:o,compound:r,keyPath:t,autoIncrement:n,unique:!0,extractKey:kn(t)},indexes:Pn(e.indexNames).map(function(t){return e.index(t)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,o=e.keyPath,a={name:t,compound:i(o),keyPath:o,unique:n,multiEntry:r,extractKey:kn(o)};return u[En(o)]=a,a}),getIndexByKeyPath:function(e){return u[En(e)]}};return u[":id"]=a.primaryKey,null!=t&&(u[En(t)]=a.primaryKey),a})},hasGetAll:n.length>0&&"getAll"in t.objectStore(n[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,r),s=a.schema,c=a.hasGetAll,l=s.tables.map(function(e){return function(e){var t=e.name;return{name:t,schema:e,mutate:function(n){var r=n.trans,i=n.type,o=n.keys,a=n.values,s=n.range,c=n.wantResults;return new Promise(function(n,l){n=Bt(n);var f=r.objectStore(t),h=null==f.keyPath,p="put"===i||"add"===i;if(!p&&"delete"!==i&&"deleteRange"!==i)throw new Error("Invalid operation type: "+i);var d=(o||a||{length:1}).length;if(o&&a&&o.length!==a.length)throw new Error("Given keys array must have same length as given values array.");if(0===d)return n({numFailures:0,failures:{},results:[],lastResult:void 0});var y,v=c&&Re(o||xn(e.primaryKey,{type:i,keys:o,values:a})),m=[],g=0,b=function(e){++g,gn(e),v&&(v[e.target._reqno]=void 0),m[e.target._reqno]=e.target.error},_=function(e){var t=e.target;v[t._reqno]=t.result};if("deleteRange"===i){if(4===s.type)return n({numFailures:g,failures:m,results:v,lastResult:void 0});y=3===s.type?f.clear():f.delete(u(s))}else{var w=p?h?[a,o]:[a,null]:[o,null],k=w[0],x=w[1];if(p)for(var P=0;P<d;++P)(y=x&&void 0!==x[P]?f[i](k[P],x[P]):f[i](k[P]))._reqno=P,v&&void 0===v[P]&&(y.onsuccess=_),y.onerror=b;else for(P=0;P<d;++P)(y=f[i](k[P]))._reqno=P,y.onerror=b}var E=function(e){var t=e.target.result;v&&(v[d-1]=t),n({numFailures:g,failures:m,results:v,lastResult:t})};y.onerror=function(e){b(e),E(e)},y.onsuccess=E})},getMany:function(e){var n=e.trans,r=e.keys;return new Promise(function(e,i){e=Bt(e);for(var o,u=n.objectStore(t),a=r.length,s=new Array(a),c=0,l=0,f=function(t){var n=t.target;s[n._pos]=n.result,++l===c&&e(s)},h=mn(i),p=0;p<a;++p)null!=r[p]&&((o=u.get(r[p]))._pos=p,o.onsuccess=f,o.onerror=h,++c);0===c&&e(s)})},get:function(e){var n=e.trans,r=e.key;return new Promise(function(e,i){e=Bt(e);var o=n.objectStore(t).get(r);o.onsuccess=function(t){return e(t.target.result)},o.onerror=mn(i)})},query:function(e){return function(n){return new Promise(function(r,i){r=Bt(r);var o=n.trans,a=n.values,s=n.limit,c=n.query,l=s===1/0?void 0:s,f=c.index,h=c.range,p=o.objectStore(t),d=f.isPrimaryKey?p:p.index(f.name),y=u(h);if(0===s)return r({result:[]});if(e){var v=a?d.getAll(y,l):d.getAllKeys(y,l);v.onsuccess=function(e){return r({result:e.target.result})},v.onerror=mn(i)}else{var m=0,g=a||!("openKeyCursor"in d)?d.openCursor(y):d.openKeyCursor(y),b=[];g.onsuccess=function(e){var t=g.result;return t?(b.push(a?t.value:t.primaryKey),++m===s?r({result:b}):void t.continue()):r({result:b})},g.onerror=mn(i)}})}}(c),openCursor:function(e){var n=e.trans,r=e.values,i=e.query,o=e.reverse,a=e.unique;return new Promise(function(e,s){e=Bt(e);var c=i.index,l=i.range,f=n.objectStore(t),h=c.isPrimaryKey?f:f.index(c.name),p=o?a?"prevunique":"prev":a?"nextunique":"next",d=r||!("openKeyCursor"in h)?h.openCursor(u(l),p):h.openKeyCursor(u(l),p);d.onerror=mn(s),d.onsuccess=Bt(function(t){var r=d.result;if(r){r.___id=++Ae,r.done=!1;var i=r.continue.bind(r),o=r.continuePrimaryKey;o&&(o=o.bind(r));var u=r.advance.bind(r),a=function(){throw new Error("Cursor not stopped")};r.trans=n,r.stop=r.continue=r.continuePrimaryKey=r.advance=function(){throw new Error("Cursor not started")},r.fail=Bt(s),r.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},r.start=function(e){var t=new Promise(function(e,t){e=Bt(e),d.onerror=mn(t),r.fail=t,r.stop=function(t){r.stop=r.continue=r.continuePrimaryKey=r.advance=a,e(t)}}),n=function(){if(d.result)try{e()}catch(t){r.fail(t)}else r.done=!0,r.start=function(){throw new Error("Cursor behind last entry")},r.stop()};return d.onsuccess=Bt(function(e){d.onsuccess=n,n()}),r.continue=i,r.continuePrimaryKey=o,r.advance=u,n(),t},e(r)}else e(null)},s)})},count:function(e){var n=e.query,r=e.trans,i=n.index,o=n.range;return new Promise(function(e,n){var a=r.objectStore(t),s=i.isPrimaryKey?a:a.index(i.name),c=u(o),l=c?s.count(c):s.count();l.onsuccess=Bt(function(t){return e(t.target.result)}),l.onerror=mn(n)})}}}(e)}),f={};return l.forEach(function(e){return f[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!f[e])throw new Error("Table '"+e+"' not found");return f[e]},cmp:o,MIN_KEY:-1/0,MAX_KEY:vn(n),schema:s}}function Sn(e,t){return t.reduce(function(e,t){var r=t.create;return n(n({},e),r(e))},e)}function jn(e,t){var n=t.db;e.core=function(e,t,n,r){var i=n.IDBKeyRange;return{dbcore:Sn(On(t,n.indexedDB,i,r),e.dbcore)}}(e._middlewares,n,e._deps,t).dbcore,e.tables.forEach(function(t){var n=t.name;e.core.schema.tables.some(function(e){return e.name===n})&&(t.core=e.core.table(n),e[n]instanceof e.Table&&(e[n].core=t.core))})}function An(e,t,n,r){n.forEach(function(n){var i=r[n];t.forEach(function(t){var r=Ve(t,n);(!r||"value"in r&&void 0===r.value)&&(t===e.Transaction.prototype||t instanceof e.Transaction?Ne(t,n,{get:function(){return this.table(n)},set:function(e){s(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):t[n]=new e.Table(n,i))})})}function Kn(e,t){t.forEach(function(t){for(var n in t)t[n]instanceof e.Table&&delete t[n]})}function Cn(e,t){return e._cfg.version-t._cfg.version}function In(e,t,n,i){var o=e._dbSchema,u=e._createTransaction("readwrite",e._storeNames,o);u.create(n),u._completion.catch(i);var a=u._reject.bind(u),s=$.transless||$;Dt(function(){$.trans=u,$.transless=s,0===t?(r(o).forEach(function(e){Bn(n,e,o[e].primKey,o[e].indexes)}),jn(e,n),_t.follow(function(){return e.on.populate.fire(u)}).catch(a)):function(e,t,n,i){var o=[],u=e._versions,a=e._dbSchema=Rn(0,e.idbdb,i),s=!1;function c(){return o.length?_t.resolve(o.shift()(n.idbtrans)).then(c):_t.resolve()}return u.filter(function(e){return e._cfg.version>=t}).forEach(function(u){o.push(function(){var o=a,c=u._cfg.dbschema;Fn(e,o,i),Fn(e,c,i),a=e._dbSchema=c;var l=Tn(o,c);l.add.forEach(function(e){Bn(i,e[0],e[1].primKey,e[1].indexes)}),l.change.forEach(function(e){if(e.recreate)throw new A.Upgrade("Not yet support for changing primary key");var t=i.objectStore(e.name);e.add.forEach(function(e){return Dn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),Dn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var f=u._cfg.contentUpgrade;if(f&&u._cfg.version>t){jn(e,i),n._memoizedTables={},s=!0;var h=Je(c);l.del.forEach(function(e){h[e]=o[e]}),Kn(e,[e.Transaction.prototype]),An(e,[e.Transaction.prototype],r(h),h),n.schema=h;var p,d=_(f);d&&Rt();var y=_t.follow(function(){if((p=f(n))&&d){var e=Ft.bind(null,null);p.then(e,e)}});return p&&"function"==typeof p.then?_t.resolve(p):y.then(function(){return p})}}),o.push(function(t){s&&ge||function(e,t){for(var n=0;n<t.db.objectStoreNames.length;++n){var r=t.db.objectStoreNames[n];null==e[r]&&t.db.deleteObjectStore(r)}}(u._cfg.dbschema,t),Kn(e,[e.Transaction.prototype]),An(e,[e.Transaction.prototype],e._storeNames,e._dbSchema),n.schema=e._dbSchema})}),c().then(function(){var e,t;t=i,r(e=a).forEach(function(n){t.db.objectStoreNames.contains(n)||Bn(t,n,e[n].primKey,e[n].indexes)})})}(e,t,u,n).catch(a)})}function Tn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],o=t[n];if(i){var u={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto&&!me)u.recreate=!0,r.change.push(u);else{var a=i.idxByName,s=o.idxByName,c=void 0;for(c in a)s[c]||u.del.push(c);for(c in s){var l=a[c],f=s[c];l?l.src!==f.src&&u.change.push(f):u.add.push(f)}(u.del.length>0||u.add.length>0||u.change.length>0)&&r.change.push(u)}}else r.add.push([n,o])}return r}function Bn(e,t,n,r){var i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(e){return Dn(i,e)}),i}function Dn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Rn(e,t,n){var r={};return We(t.objectStoreNames,0).forEach(function(e){for(var t=n.objectStore(e),i=t.keyPath,o=bn(_n(i),i||"",!1,!1,!!t.autoIncrement,i&&"string"!=typeof i,!0),u=[],a=0;a<t.indexNames.length;++a){var s=t.index(t.indexNames[a]);i=s.keyPath;var c=bn(s.name,i,!!s.unique,!!s.multiEntry,!1,i&&"string"!=typeof i,!1);u.push(c)}r[e]=wn(e,o,u)}),r}function Fn(e,t,n){for(var r=n.db.objectStoreNames,i=0;i<r.length;++i){var u=r[i],a=n.objectStore(u);e._hasGetAll="getAll"in a;for(var s=0;s<a.indexNames.length;++s){var c=a.indexNames[s],l=a.index(c).keyPath,f="string"==typeof l?l:"["+We(l).join("+")+"]";if(t[u]){var h=t[u].idxByName[f];h&&(h.name=c,delete t[u].idxByName[f],t[u].idxByName[c]=h)}}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&o.WorkerGlobalScope&&o instanceof o.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function qn(e){try{Ce=function(e){var t,n=e&&"function"==typeof e.databases;if(!n){var r=new Be(we,{addons:[]});r.version(1).stores({dbnames:"name"}),t=r.table("dbnames")}return{getDatabaseNames:function(){return n?_t.resolve(e.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==we})}):t.toCollection().primaryKeys()},add:function(e){return!n&&e!==we&&t.put({name:e}).catch(ft)},remove:function(e){return!n&&e!==we&&t.delete(e).catch(ft)}}}(e)}catch(t){}}function Mn(e){return Dt(function(){return $.letThrough=!0,e()})}function Nn(e){var t=e._state,n=e._deps.indexedDB;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(function(){return t.dbOpenError?le(t.dbOpenError):e});w&&(t.openCanceller._stackHolder=it()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;var i=t.dbReadyResolve,o=null;return _t.race([t.openCanceller,new _t(function(i,u){if(!n)throw new A.MissingAPI("indexedDB API not found. If using IE10+, make sure to run your code on a server URL (not locally). If using old Safari versions, make sure to include indexedDB polyfill.");var a=e.name,s=t.autoSchema?n.open(a):n.open(a,Math.round(10*e.verno));if(!s)throw new A.MissingAPI("IndexedDB API not available");s.onerror=mn(u),s.onblocked=Bt(e._fireOnBlocked),s.onupgradeneeded=Bt(function(r){if(o=s.transaction,t.autoSchema&&!e._options.allowEmptyDB){s.onerror=gn,o.abort(),s.result.close();var i=n.deleteDatabase(a);i.onsuccess=i.onerror=Bt(function(){u(new A.NoSuchDatabase("Database "+a+" doesnt exist"))})}else{o.onerror=mn(u);var c=r.oldVersion>Math.pow(2,62)?0:r.oldVersion;e.idbdb=s.result,In(e,c/10,o,u)}},u),s.onsuccess=Bt(function(){o=null;var n=e.idbdb=s.result,u=We(n.objectStoreNames);if(u.length>0)try{var c=n.transaction(yn(u),"readonly");t.autoSchema?function(e,t,n){e.verno=t.version/10;var i=e._dbSchema=Rn(0,t,n);e._storeNames=We(t.objectStoreNames,0),An(e,[e._allTables],r(i),i)}(e,n,c):(Fn(e,e._dbSchema,c),function(e,t){var n=Tn(Rn(0,e.idbdb,t),e._dbSchema);return!(n.add.length||n.change.some(function(e){return e.add.length||e.change.length}))}(e,c)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),jn(e,c)}catch(l){}ve.push(e),n.onversionchange=Bt(function(n){t.vcFired=!0,e.on("versionchange").fire(n)}),Ce.add(a),i()},u)})]).then(function(){return t.onReadyBeingFired=[],_t.resolve(Mn(e.on.ready.fire)).then(function e(){if(t.onReadyBeingFired.length>0){var n=t.onReadyBeingFired.reduce(bt,ft);return t.onReadyBeingFired=[],_t.resolve(Mn(n)).then(e)}})}).finally(function(){t.onReadyBeingFired=null}).then(function(){return t.isBeingOpened=!1,e}).catch(function(n){try{o&&o.abort()}catch(r){}return t.isBeingOpened=!1,e.close(),t.dbOpenError=n,le(t.dbOpenError)}).finally(function(){t.openComplete=!0,i()})}function Un(e){var t=function(t){return e.next(t)},n=o(t),r=o(function(t){return e.throw(t)});function o(e){return function(t){var o=e(t),u=o.value;return o.done?u:u&&"function"==typeof u.then?u.then(n,r):i(u)?Promise.all(u).then(n,r):n(u)}}return o(t)()}function Vn(e,t,n){var r=arguments.length;if(r<2)throw new A.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,$e(i),n]}function Wn(e,t,n,r,i){return _t.resolve().then(function(){var o=$.transless||$,u=e._createTransaction(t,n,e._dbSchema,r),a={trans:u,transless:o};r?u.idbtrans=r.idbtrans:u.create();var s,c=_(i);c&&Rt();var l=_t.follow(function(){if(s=i.call(u,u))if(c){var e=Ft.bind(null,null);s.then(e,e)}else"function"==typeof s.next&&"function"==typeof s.throw&&(s=Un(s))},a);return(s&&"function"==typeof s.then?_t.resolve(s).then(function(e){return u.active?e:le(new A.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):l.then(function(){return s})).then(function(e){return r&&u._resolve(),u._completion.then(function(){return e})}).catch(function(e){return u._reject(e),le(e)})})}function zn(e,t,n){for(var r=i(e)?e.slice():[e],o=0;o<n;++o)r.push(t);return r}function Ln(e){return n(n({},e),{table:function(t){var r=e.table(t),i=r.schema,o={},u=[];function a(e,t,r){var i=En(e),s=o[i]=o[i]||[],c=null==e?0:"string"==typeof e?1:e.length,l=t>0,f=n(n({},r),{isVirtual:l,isPrimaryKey:!l&&r.isPrimaryKey,keyTail:t,keyLength:c,extractKey:kn(e),unique:!l&&r.unique});return s.push(f),f.isPrimaryKey||u.push(f),c>1&&a(2===c?e[0]:e.slice(0,c-1),t+1,r),s.sort(function(e,t){return e.keyTail-t.keyTail}),f}var s=a(i.primaryKey.keyPath,0,i.primaryKey);o[":id"]=[s];for(var c=0,l=i.indexes;c<l.length;c++){var f=l[c];a(f.keyPath,0,f)}function h(t){var r,i,o=t.query.index;return o.isVirtual?n(n({},t),{query:{index:o,range:(r=t.query.range,i=o.keyTail,{type:1===r.type?2:r.type,lower:zn(r.lower,r.lowerOpen?e.MAX_KEY:e.MIN_KEY,i),lowerOpen:!0,upper:zn(r.upper,r.upperOpen?e.MIN_KEY:e.MAX_KEY,i),upperOpen:!0})}}):t}return n(n({},r),{schema:n(n({},i),{primaryKey:s,indexes:u,getIndexByKeyPath:function(e){var t=o[En(e)];return t&&t[0]}}),count:function(e){return r.count(h(e))},query:function(e){return r.query(h(e))},openCursor:function(t){var n=t.query.index,i=n.keyTail,o=n.isVirtual,u=n.keyLength;return o?r.openCursor(h(t)).then(function(n){return n&&function(n){return Object.create(n,{continue:{value:function(r){null!=r?n.continue(zn(r,t.reverse?e.MAX_KEY:e.MIN_KEY,i)):t.unique?n.continue(zn(n.key,t.reverse?e.MIN_KEY:e.MAX_KEY,i)):n.continue()}},continuePrimaryKey:{value:function(t,r){n.continuePrimaryKey(zn(t,e.MAX_KEY,i),r)}},key:{get:function(){var e=n.key;return 1===u?e[0]:e.slice(0,u)}},value:{get:function(){return n.value}}})}(n)}):r.openCursor(t)}})}})}return{setters:[],execute:function(){n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},n.apply(this,arguments)},r=Object.keys,i=Array.isArray,o="undefined"!=typeof self?self:"undefined"!=typeof window?window:global,"undefined"==typeof Promise||o.Promise||(o.Promise=Promise),u=Object.getPrototypeOf,a={}.hasOwnProperty,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=[].slice,f=[].concat,h="Boolean,String,Date,RegExp,Blob,File,FileList,ArrayBuffer,DataView,Uint8ClampedArray,ImageData,Map,Set".split(",").concat($e([8,16,32,64].map(function(e){return["Int","Uint","Float"].map(function(t){return t+e+"Array"})}))).filter(function(e){return o[e]}),p=h.map(function(e){return o[e]}),d=Ge(h,function(e){return[e,!0]}),y={}.toString,v=function(e,t){return"Array"===t?""+e.map(function(e){return v(e,et(e))}):"ArrayBuffer"===t?""+new Uint8Array(e):"Date"===t?e.getTime():ArrayBuffer.isView(e)?""+new Uint8Array(e.buffer):e},m="undefined"!=typeof Symbol&&Symbol.iterator,g=m?function(e){var t;return null!=e&&(t=e[m])&&t.apply(e)}:function(){return null},b={},_="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},w="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href),k=function(){return!0},x=!new Error("").stack,E=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(P=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"]),O={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed"},Ue(ut).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+ot(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Ue(st).from(ut),Ue(ct).from(ut),S=E.reduce(function(e,t){return e[t]=t+"Error",e},{}),j=ut,A=E.reduce(function(e,t){var n=t+"Error";function r(e,r){this._e=it(),this.name=n,e?"string"==typeof e?(this.message=e+(r?"\n "+r:""),this.inner=r||null):"object"==typeof e&&(this.message=e.name+" "+e.message,this.inner=e):(this.message=O[t]||n,this.inner=null)}return Ue(r).from(j),e[t]=r,e},{}),A.Syntax=SyntaxError,A.Type=TypeError,A.Range=RangeError,K=P.reduce(function(e,t){return e[t+"Error"]=A[t],e},{}),(C=E.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=A[t]),e},{})).ModifyError=st,C.DexieError=ut,C.BulkError=ct,I={},T=100,B=100,D="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,e.__proto__,e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,t.__proto__,e]}(),R=D[0],F=D[1],q=D[2],M=F&&F.then,N=R&&R.constructor,U=!!q,V=!1,W=q?function(){q.then(At)}:o.setImmediate?setImmediate.bind(null,At):o.MutationObserver?function(){var e=document.createElement("div");new MutationObserver(function(){At(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:function(){setTimeout(At,0)},z=function(e,t){Z.push([e,t]),Y&&(W(),Y=!1)},L=!0,Y=!0,G=[],H=[],Q=null,X=ht,$=J={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Gt,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(function(e){try{Gt(e[0],e[1])}catch(t){}})}},Z=[],ee=0,te=[],ne={get:function(){var e=$,t=ae;function n(n,r){var i=this,o=!e.global&&(e!==$||t!==ae),u=o&&!Ft(),a=new _t(function(t,a){Et(i,new wt(Lt(n,e,o,u),Lt(r,e,o,u),t,a,e))});return w&&jt(a,this),a}return n.prototype=I,n},set:function(e){Ne(this,"then",e&&e.prototype===I?ne:{get:function(){return e},set:ne.set})}},Me(_t.prototype,{then:ne,_then:function(e,t){Et(this,new wt(null,null,e,t,$))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,function(e){return e instanceof t?n(e):Tt(e)}):this.then(null,function(e){return e&&e.name===t?n(e):Tt(e)})},finally:function(e){return this.then(function(t){return e(),t},function(t){return e(),Tt(t)})},stack:{get:function(){if(this._stack)return this._stack;try{V=!0;var e=St(this,[],20).join("\nFrom previous: ");return null!==this._state&&(this._stack=e),e}finally{V=!1}}},timeout:function(e,t){var n=this;return e<1/0?new _t(function(r,i){var o=setTimeout(function(){return i(new A.Timeout(t))},e);n.then(r,i).finally(clearTimeout.bind(null,o))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&Ne(_t.prototype,Symbol.toStringTag,"Dexie.Promise"),J.env=Vt(),Me(_t,{all:function(){var e=nt.apply(null,arguments).map(qt);return new _t(function(t,n){0===e.length&&t([]);var r=e.length;e.forEach(function(i,o){return _t.resolve(i).then(function(n){e[o]=n,--r||t(e)},n)})})},resolve:function(e){if(e instanceof _t)return e;if(e&&"function"==typeof e.then)return new _t(function(t,n){e.then(t,n)});var t=new _t(I,!0,e);return jt(t,Q),t},reject:Tt,race:function(){var e=nt.apply(null,arguments).map(qt);return new _t(function(t,n){e.map(function(e){return _t.resolve(e).then(t,n)})})},PSD:{get:function(){return $},set:function(e){return $=e}},totalEchoes:{get:function(){return ae}},newPSD:Dt,usePSD:Wt,scheduler:{get:function(){return z},set:function(e){z=e}},rejectionMapper:{get:function(){return X},set:function(e){X=e}},follow:function(e,t){return new _t(function(n,r){return Dt(function(t,n){var r=$;r.unhandleds=[],r.onunhandled=n,r.finalize=dt(function(){var e=this;!function(e){te.push(function t(){e(),te.splice(te.indexOf(t),1)}),++ee,z(function(){0===--ee&&It()},[])}(function(){0===e.unhandleds.length?t():n(e.unhandleds[0])})},r.finalize),e()},t,n,r)})}}),N&&(N.allSettled&&Ne(_t,"allSettled",function(){var e=nt.apply(null,arguments).map(qt);return new _t(function(t){0===e.length&&t([]);var n=e.length,r=new Array(n);e.forEach(function(e,i){return _t.resolve(e).then(function(e){return r[i]={status:"fulfilled",value:e}},function(e){return r[i]={status:"rejected",reason:e}}).then(function(){return--n||t(r)})})})}),N.any&&"undefined"!=typeof AggregateError&&Ne(_t,"any",function(){var e=nt.apply(null,arguments).map(qt);return new _t(function(t,n){0===e.length&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach(function(e,o){return _t.resolve(e).then(function(e){return t(e)},function(e){i[o]=e,--r||n(new AggregateError(i))})})})})),re={awaits:0,echoes:0,id:0},ie=0,oe=[],ue=0,ae=0,se=0,-1===(""+M).indexOf("[native code]")&&(Rt=Ft=ft),ce="unhandledrejection",le=_t.reject,fe="3.0.3",he=String.fromCharCode(65535),pe=-1/0,de="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",ye="String expected.",ve=[],me="undefined"!=typeof navigator&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),ge=me,be=me,_e=function(e){return!/(dexie\.js|dexie\.min\.js)/.test(e)},we="__dbnames",ke="readonly",xe="readwrite",Pe={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1},Ee=function(){function e(){}return e.prototype._trans=function(e,t,n){var r=this._tx||$.trans,i=this.name;function o(e,n,r){if(!r.schema[i])throw new A.NotFound("Table "+i+" not part of transaction");return t(r.idbtrans,r)}var u=Kt();try{return r&&r.db===this.db?r===$.trans?r._promise(e,o,n):Dt(function(){return r._promise(e,o,n)},{trans:r,transless:$.transless||$}):Ht(this.db,e,[this.name],o)}finally{u&&Ct()}},e.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):this._trans("readonly",function(t){return n.core.get({trans:t,key:e}).then(function(e){return n.hook.reading.fire(e)})}).then(t)},e.prototype.where=function(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(i(e))return new this.db.WhereClause(this,"["+e.join("+")+"]");var t=r(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(e){return e.compound&&t.every(function(t){return e.keyPath.indexOf(t)>=0})&&e.keyPath.every(function(e){return t.indexOf(e)>=0})})[0];if(n&&this.db._maxKey!==he)return this.where(n.name).equals(n.keyPath.map(function(t){return e[t]}));!n&&w&&console.warn("The query "+JSON.stringify(e)+" on "+this.name+" would benefit of a compound index ["+t.join("+")+"]");var o=this.schema.idxByName,u=this.db._deps.indexedDB;function a(e,t){try{return 0===u.cmp(e,t)}catch(n){return!1}}var s=t.reduce(function(t,n){var r=t[0],u=t[1],s=o[n],c=e[n];return[r||s,r||!s?Qt(u,s&&s.multi?function(e){var t=He(e,n);return i(t)&&t.some(function(e){return a(c,e)})}:function(e){return a(c,He(e,n))}):u]},[null,null]),c=s[0],l=s[1];return c?this.where(c.name).equals(e[c.keyPath]).filter(l):n?this.filter(l):this.where(t).equals("")},e.prototype.filter=function(e){return this.toCollection().and(e)},e.prototype.count=function(e){return this.toCollection().count(e)},e.prototype.offset=function(e){return this.toCollection().offset(e)},e.prototype.limit=function(e){return this.toCollection().limit(e)},e.prototype.each=function(e){return this.toCollection().each(e)},e.prototype.toArray=function(e){return this.toCollection().toArray(e)},e.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},e.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,i(e)?"["+e.join("+")+"]":e))},e.prototype.reverse=function(){return this.toCollection().reverse()},e.prototype.mapToClass=function(e){this.schema.mappedClass=e;var t=function(t){if(!t)return t;var n=Object.create(e.prototype);for(var r in t)if(qe(t,r))try{n[r]=t[r]}catch(i){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=t,this.hook("reading",t),e},e.prototype.defineClass=function(){return this.mapToClass(function(e){Fe(this,e)})},e.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,u=e;return o&&i&&(u=Xt(o)(e)),this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[u]})}).then(function(e){return e.numFailures?_t.reject(e.failures[0]):e.lastResult}).then(function(t){if(o)try{Qe(e,o,t)}catch(n){}return t})},e.prototype.update=function(e,t){if("object"!=typeof t||i(t))throw new A.InvalidArgument("Modifications must be an object.");if("object"!=typeof e||i(e))return this.where(":id").equals(e).modify(t);r(t).forEach(function(n){Qe(e,n,t[n])});var n=He(e,this.schema.primKey.keyPath);return void 0===n?le(new A.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(n).modify(t)},e.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,u=e;return o&&i&&(u=Xt(o)(e)),this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"put",values:[u],keys:null!=t?[t]:null})}).then(function(e){return e.numFailures?_t.reject(e.failures[0]):e.lastResult}).then(function(t){if(o)try{Qe(e,o,t)}catch(n){}return t})},e.prototype.delete=function(e){var t=this;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})}).then(function(e){return e.numFailures?_t.reject(e.failures[0]):void 0})},e.prototype.clear=function(){var e=this;return this._trans("readwrite",function(t){return e.core.mutate({trans:t,type:"deleteRange",range:Pe})}).then(function(e){return e.numFailures?_t.reject(e.failures[0]):void 0})},e.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",function(n){return t.core.getMany({keys:e,trans:n}).then(function(e){return e.map(function(e){return t.hook.reading.fire(e)})})})},e.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(t){var n=r.schema.primKey,u=n.auto,a=n.keyPath;if(a&&i)throw new A.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new A.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,c=a&&u?e.map(Xt(a)):e;return r.core.mutate({trans:t,type:"add",keys:i,values:c,wantResults:o}).then(function(e){var t=e.numFailures,n=e.results,i=e.lastResult,u=e.failures;if(0===t)return o?n:i;throw new ct(r.name+".bulkAdd(): "+t+" of "+s+" operations failed",Object.keys(u).map(function(e){return u[e]}))})})},e.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",function(t){var n=r.schema.primKey,u=n.auto,a=n.keyPath;if(a&&i)throw new A.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new A.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,c=a&&u?e.map(Xt(a)):e;return r.core.mutate({trans:t,type:"put",keys:i,values:c,wantResults:o}).then(function(e){var t=e.numFailures,n=e.results,i=e.lastResult,u=e.failures;if(0===t)return o?n:i;throw new ct(r.name+".bulkPut(): "+t+" of "+s+" operations failed",Object.keys(u).map(function(e){return u[e]}))})})},e.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",function(n){return t.core.mutate({trans:n,type:"delete",keys:e})}).then(function(e){var r=e.numFailures,i=e.lastResult,o=e.failures;if(0===r)return i;throw new ct(t.name+".bulkDelete(): "+r+" of "+n+" operations failed",o)})},e}(),Oe=function(){function e(){}return e.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,le.bind(null,n.error)):n.table._trans("readonly",e).then(t)},e.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,le.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},e.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=Qt(t.algorithm,e)},e.prototype._iterate=function(e,t){return on(this._ctx,e,t,this._ctx.table.core)},e.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&Fe(n,e),t._ctx=n,t},e.prototype.raw=function(){return this._ctx.valueMapper=null,this},e.prototype.each=function(e){var t=this._ctx;return this._read(function(n){return on(t,e,n,t.table.core)})},e.prototype.count=function(e){var t=this;return this._read(function(e){var n=t._ctx,r=n.table.core;if(Zt(n,!0))return r.count({trans:e,query:{index:nn(n,r.schema),range:n.range}}).then(function(e){return Math.min(e,n.limit)});var i=0;return on(n,function(){return++i,!1},e,r).then(function(){return i})}).then(e)},e.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],i=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[r]}var u="next"===this._ctx.dir?1:-1;function a(e,t){var n=o(e,i),r=o(t,i);return n<r?-u:n>r?u:0}return this.toArray(function(e){return e.sort(a)}).then(t)},e.prototype.toArray=function(e){var t=this;return this._read(function(e){var n=t._ctx;if("next"===n.dir&&Zt(n,!0)&&n.limit>0){var r=n.valueMapper,i=nn(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(function(e){var t=e.result;return r?t.map(r):t})}var o=[];return on(n,function(e){return o.push(e)},e,n.table.core).then(function(){return o})},e)},e.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,Zt(t)?tn(t,function(){var t=e;return function(e,n){return 0===t||(1===t?(--t,!1):(n(function(){e.advance(t),t=0}),!1))}}):tn(t,function(){var t=e;return function(){return--t<0}})),this},e.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),tn(this._ctx,function(){var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}},!0),this},e.prototype.until=function(e,t){return en(this._ctx,function(n,r,i){return!e(n.value)||(r(i),t)}),this},e.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},e.prototype.last=function(e){return this.reverse().first(e)},e.prototype.filter=function(e){var t,n;return en(this._ctx,function(t){return e(t.value)}),t=this._ctx,n=e,t.isMatch=Qt(t.isMatch,n),this},e.prototype.and=function(e){return this.filter(e)},e.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},e.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},e.prototype.desc=function(){return this.reverse()},e.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.key,n)})},e.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},e.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each(function(t,n){e(n.primaryKey,n)})},e.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.key)}).then(function(){return n}).then(e)},e.prototype.primaryKeys=function(e){var t=this._ctx;if("next"===t.dir&&Zt(t,!0)&&t.limit>0)return this._read(function(e){var n=nn(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})}).then(function(e){return e.result}).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each(function(e,t){n.push(t.primaryKey)}).then(function(){return n}).then(e)},e.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},e.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},e.prototype.lastKey=function(e){return this.reverse().firstKey(e)},e.prototype.distinct=function(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return en(this._ctx,function(e){var t=e.primaryKey.toString(),r=qe(n,t);return n[t]=!0,!r}),this},e.prototype.modify=function(e){var t=this,n=this._ctx;return this._write(function(i){var o;if("function"==typeof e)o=e;else{var u=r(e),a=u.length;o=function(t){for(var n=!1,r=0;r<a;++r){var i=u[r],o=e[i];He(t,i)!==o&&(Qe(t,i,o),n=!0)}return n}}var s=n.table.core,c=s.schema.primaryKey,l=c.outbound,f=c.extractKey,h="testmode"in Be?1:2e3,p=t.db.core.cmp,d=[],y=0,v=[],m=function(e,t){var n=t.failures,i=t.numFailures;y+=e-i;for(var o=0,u=r(n);o<u.length;o++){var a=u[o];d.push(n[a])}};return t.clone().primaryKeys().then(function(e){var t=function(n){var r=Math.min(h,e.length-n);return s.getMany({trans:i,keys:e.slice(n,n+r)}).then(function(u){for(var a=[],c=[],d=l?[]:null,y=[],v=0;v<r;++v){var g=u[v],b={value:Ze(g),primKey:e[n+v]};!1!==o.call(b,b.value,b)&&(null==b.value?y.push(e[n+v]):l||0===p(f(g),f(b.value))?(c.push(b.value),l&&d.push(e[n+v])):(y.push(e[n+v]),a.push(b.value)))}return Promise.resolve(a.length>0&&s.mutate({trans:i,type:"add",values:a}).then(function(e){for(var t in e.failures)y.splice(parseInt(t),1);m(a.length,e)})).then(function(e){return c.length>0&&s.mutate({trans:i,type:"put",keys:d,values:c}).then(function(e){return m(c.length,e)})}).then(function(){return y.length>0&&s.mutate({trans:i,type:"delete",keys:y}).then(function(e){return m(y.length,e)})}).then(function(){return e.length>n+r&&t(n+h)})})};return t(0).then(function(){if(d.length>0)throw new st("Error modifying one or more objects",d,y,v);return e.length})})})},e.prototype.delete=function(){var e=this._ctx,t=e.range;return Zt(e)&&(e.isPrimKey&&!be||3===t.type)?this._write(function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then(function(t){return e.table.core.mutate({trans:n,type:"deleteRange",range:i}).then(function(e){var n=e.failures;e.lastResult,e.results;var r=e.numFailures;if(r)throw new st("Could not delete some values",Object.keys(n).map(function(e){return n[e]}),t-r);return t-r})})}):this.modify(function(e,t){return t.value=null})},e}(),Se=function(){function e(){}return Object.defineProperty(e.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!0,configurable:!0}),e.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?ln(this):new this.Collection(this,function(){return pn(e,t,!n,!r)})}catch(i){return cn(this,de)}},e.prototype.equals=function(e){return null==e?cn(this,de):new this.Collection(this,function(){return dn(e)})},e.prototype.above=function(e){return null==e?cn(this,de):new this.Collection(this,function(){return pn(e,void 0,!0)})},e.prototype.aboveOrEqual=function(e){return null==e?cn(this,de):new this.Collection(this,function(){return pn(e,void 0,!1)})},e.prototype.below=function(e){return null==e?cn(this,de):new this.Collection(this,function(){return pn(void 0,e,!1,!0)})},e.prototype.belowOrEqual=function(e){return null==e?cn(this,de):new this.Collection(this,function(){return pn(void 0,e)})},e.prototype.startsWith=function(e){return"string"!=typeof e?cn(this,ye):this.between(e,e+he,!0,!0)},e.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):hn(this,function(e,t){return 0===e.indexOf(t[0])},[e],he)},e.prototype.equalsIgnoreCase=function(e){return hn(this,function(e,t){return e===t[0]},[e],"")},e.prototype.anyOfIgnoreCase=function(){var e=nt.apply(b,arguments);return 0===e.length?ln(this):hn(this,function(e,t){return-1!==t.indexOf(e)},e,"")},e.prototype.startsWithAnyOfIgnoreCase=function(){var e=nt.apply(b,arguments);return 0===e.length?ln(this):hn(this,function(e,t){return t.some(function(t){return 0===e.indexOf(t)})},e,he)},e.prototype.anyOf=function(){var e=this,t=nt.apply(b,arguments),n=this._cmp;try{t.sort(n)}catch(o){return cn(this,de)}if(0===t.length)return ln(this);var r=new this.Collection(this,function(){return pn(t[0],t[t.length-1])});r._ondirectionchange=function(r){n="next"===r?e._ascending:e._descending,t.sort(n)};var i=0;return r._addAlgorithm(function(e,r,o){for(var u=e.key;n(u,t[i])>0;)if(++i===t.length)return r(o),!1;return 0===n(u,t[i])||(r(function(){e.continue(t[i])}),!1)}),r},e.prototype.notEqual=function(e){return this.inAnyRange([[pe,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},e.prototype.noneOf=function(){var e=nt.apply(b,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(n){return cn(this,de)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[pe,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},e.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,o=this._descending,u=this._min,a=this._max;if(0===e.length)return ln(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&i(e[0],e[1])<=0}))return cn(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",A.InvalidArgument);var s,c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,f=i;function h(e,t){return f(e[0],t[0])}try{s=e.reduce(function(e,t){for(var n=0,i=e.length;n<i;++n){var o=e[n];if(r(t[0],o[1])<0&&r(t[1],o[0])>0){o[0]=u(o[0],t[0]),o[1]=a(o[1],t[1]);break}}return n===i&&e.push(t),e},[]),s.sort(h)}catch(g){return cn(this,de)}var p=0,d=l?function(e){return i(e,s[p][1])>0}:function(e){return i(e,s[p][1])>=0},y=c?function(e){return o(e,s[p][0])>0}:function(e){return o(e,s[p][0])>=0},v=d,m=new this.Collection(this,function(){return pn(s[0][0],s[s.length-1][1],!c,!l)});return m._ondirectionchange=function(e){"next"===e?(v=d,f=i):(v=y,f=o),s.sort(h)},m._addAlgorithm(function(e,t,r){for(var o=e.key;v(o);)if(++p===s.length)return t(r),!1;return!!function(e){return!d(e)&&!y(e)}(o)||(0===n._cmp(o,s[p][1])||0===n._cmp(o,s[p][0])||t(function(){f===i?e.continue(s[p][0]):e.continue(s[p][1])}),!1)}),m},e.prototype.startsWithAnyOf=function(){var e=nt.apply(b,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?ln(this):this.inAnyRange(e.map(function(e){return[e,e+he]})):cn(this,"startsWithAnyOf() only works with strings")},e}(),je=function(){function e(){}return e.prototype._lock=function(){return Le(!$.global),++this._reculock,1!==this._reculock||$.global||($.lockOwnerFor=this),this},e.prototype._unlock=function(){if(Le(!$.global),0===--this._reculock)for($.global||($.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{Wt(e[1],e[0])}catch(t){}}return this},e.prototype._locked=function(){return this._reculock&&$.lockOwnerFor!==this},e.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(Le(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new A.DatabaseClosed(r);case"MissingAPIError":throw new A.MissingAPI(r.message,r);default:throw new A.OpenFailed(r)}if(!this.active)throw new A.TransactionInactive;return Le(null===this._completion._state),(e=this.idbtrans=e||n.transaction(yn(this.storeNames),this.mode)).onerror=Bt(function(n){gn(n),t._reject(e.error)}),e.onabort=Bt(function(n){gn(n),t.active&&t._reject(new A.Abort(e.error)),t.active=!1,t.on("abort").fire(n)}),e.oncomplete=Bt(function(){t.active=!1,t._resolve()}),this},e.prototype._promise=function(e,t,n){var r=this;if("readwrite"===e&&"readwrite"!==this.mode)return le(new A.ReadOnly("Transaction is readonly"));if(!this.active)return le(new A.TransactionInactive);if(this._locked())return new _t(function(i,o){r._blockedFuncs.push([function(){r._promise(e,t,n).then(i,o)},$])});if(n)return Dt(function(){var e=new _t(function(e,n){r._lock();var i=t(e,n,r);i&&i.then&&i.then(e,n)});return e.finally(function(){return r._unlock()}),e._lib=!0,e});var i=new _t(function(e,n){var i=t(e,n,r);i&&i.then&&i.then(e,n)});return i._lib=!0,i},e.prototype._root=function(){return this.parent?this.parent._root():this},e.prototype.waitFor=function(e){var t=this._root(),n=_t.resolve(e);if(t._waitingFor)t._waitingFor=t._waitingFor.then(function(){return n});else{t._waitingFor=n,t._waitingQueue=[];var r=t.idbtrans.objectStore(t.storeNames[0]);!function e(){for(++t._spinCount;t._waitingQueue.length;)t._waitingQueue.shift()();t._waitingFor&&(r.get(-1/0).onsuccess=e)}()}var i=t._waitingFor;return new _t(function(e,r){n.then(function(n){return t._waitingQueue.push(Bt(e.bind(null,n)))},function(e){return t._waitingQueue.push(Bt(r.bind(null,e)))}).finally(function(){t._waitingFor===i&&(t._waitingFor=null)})})},e.prototype.abort=function(){this.active&&this._reject(new A.Abort),this.active=!1},e.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(qe(t,e))return t[e];var n=this.schema[e];if(!n)throw new A.NotFound("Table "+e+" not part of transaction");var r=new this.db.Table(e,n,this);return r.core=this.db.core.table(e),t[e]=r,r},e}(),Ae=0,Ke=function(){function e(){}return e.prototype._parseStoresSpec=function(e,t){r(e).forEach(function(n){if(null!==e[n]){var r=e[n].split(",").map(function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return bn(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),i(r),0===t)}),o=r.shift();if(o.multi)throw new A.Schema("Primary key cannot be multi-valued");r.forEach(function(e){if(e.auto)throw new A.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new A.Schema("Index must have a name and cannot be an empty string")}),t[n]=wn(n,o,r)}})},e.prototype.stores=function(e){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?Fe(this._cfg.storesSource,e):e;var n=t._versions,i={},o={};return n.forEach(function(e){Fe(i,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(i,o)}),t._dbSchema=o,Kn(t,[t._allTables,t,t.Transaction.prototype]),An(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],r(o),o),t._storeNames=r(o),this},e.prototype.upgrade=function(e){return this._cfg.contentUpgrade=e,this},e}(),Ie={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:Ln},Te={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return n(n({},e),{table:function(t){var r=e.table(t),i=r.schema.primaryKey;return n(n({},r),{mutate:function(e){var o=$.trans,u=o.table(t).hook,a=u.deleting,s=u.creating,c=u.updating;switch(e.type){case"add":if(s.fire===ft)break;return o._promise("readwrite",function(){return l(e)},!0);case"put":if(s.fire===ft&&c.fire===ft)break;return o._promise("readwrite",function(){return l(e)},!0);case"delete":if(a.fire===ft)break;return o._promise("readwrite",function(){return l(e)},!0);case"deleteRange":if(a.fire===ft)break;return o._promise("readwrite",function(){return function(e){return f(e.trans,e.range,1e4)}(e)},!0)}return r.mutate(e);function l(e){var t=$.trans,o=e.keys||xn(i,e);if(!o)throw new Error("Keys missing");return"delete"!==(e="add"===e.type||"put"===e.type?n(n({},e),{keys:o,wantResults:!0}):n({},e)).type&&(e.values=Re(e.values)),e.keys&&(e.keys=Re(e.keys)),function(e,t,n){return"add"===t.type?Promise.resolve(new Array(t.values.length)):e.getMany({trans:t.trans,keys:n})}(r,e,o).then(function(n){var u=o.map(function(r,o){var u=n[o],l={onerror:null,onsuccess:null};if("delete"===e.type)a.fire.call(l,r,u,t);else if("add"===e.type||void 0===u){var f=s.fire.call(l,r,e.values[o],t);null==r&&null!=f&&(r=f,e.keys[o]=r,i.outbound||Qe(e.values[o],i.keyPath,r))}else{var h=tt(u,e.values[o]),p=c.fire.call(l,h,r,u,t);if(p){var d=e.values[o];Object.keys(p).forEach(function(e){qe(d,e)?d[e]=p[e]:Qe(d,e,p[e])})}}return l});return r.mutate(e).then(function(t){for(var r=t.failures,i=t.results,a=t.numFailures,s=t.lastResult,c=0;c<o.length;++c){var l=i?i[c]:o[c],f=u[c];null==l?f.onerror&&f.onerror(r[c]):f.onsuccess&&f.onsuccess("put"===e.type&&n[c]?e.values[c]:l)}return{failures:r,results:i,numFailures:a,lastResult:s}}).catch(function(e){return u.forEach(function(t){return t.onerror&&t.onerror(e)}),Promise.reject(e)})})}function f(e,t,o){return r.query({trans:e,values:!1,query:{index:i,range:t},limit:o}).then(function(r){var i=r.result;return l({type:"delete",keys:i,trans:e}).then(function(r){return r.numFailures>0?Promise.reject(r.failures[0]):i.length<o?{failures:[],numFailures:0,lastResult:void 0}:f(e,n(n({},t),{lower:i[i.length-1],lowerOpen:!0}),o)})})}}})}})}},e("t",Be=function(){function e(t,r){var i=this;this._middlewares={},this.verno=0;var o=e.dependencies;this._options=r=n({addons:e.addons,autoOpen:!0,indexedDB:o.indexedDB,IDBKeyRange:o.IDBKeyRange},r),this._deps={indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange};var u=r.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null;var a,s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:ft,dbReadyPromise:null,cancelOpen:ft,openCanceller:null,autoSchema:!0};s.dbReadyPromise=new _t(function(e){s.dbReadyResolve=e}),s.openCanceller=new _t(function(e,t){s.cancelOpen=t}),this._state=s,this.name=t,this.on=Jt(this,"populate","blocked","versionchange",{ready:[bt,ft]}),this.on.ready.subscribe=ze(this.on.ready.subscribe,function(t){return function(n,r){e.vip(function(){var e=i._state;if(e.openComplete)e.dbOpenError||_t.resolve().then(n),r&&t(n);else if(e.onReadyBeingFired)e.onReadyBeingFired.push(n),r&&t(n);else{t(n);var o=i;r||t(function e(){o.on.ready.unsubscribe(n),o.on.ready.unsubscribe(e)})}})}}),this.Collection=(a=this,$t(Oe.prototype,function(e,t){this.db=a;var n=Pe,r=null;if(t)try{n=t()}catch(s){r=s}var i=e._ctx,o=i.table,u=o.hook.reading.fire;this._ctx={table:o,index:i.index,isPrimKey:!i.index||o.schema.primKey.keyPath&&i.index===o.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:u!==ht?u:null}})),this.Table=function(e){return $t(Ee.prototype,function(t,n,r){this.db=e,this._tx=r,this.name=t,this.schema=n,this.hook=e._allTables[t]?e._allTables[t].hook:Jt(null,{creating:[yt,ft],reading:[pt,ht],updating:[mt,ft],deleting:[vt,ft]})})}(this),this.Transaction=function(e){return $t(je.prototype,function(t,n,r,i){var o=this;this.db=e,this.mode=t,this.storeNames=n,this.schema=r,this.idbtrans=null,this.on=Jt(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new _t(function(e,t){o._resolve=e,o._reject=t}),this._completion.then(function(){o.active=!1,o.on.complete.fire()},function(e){var t=o.active;return o.active=!1,o.on.error.fire(e),o.parent?o.parent._reject(e):t&&o.idbtrans&&o.idbtrans.abort(),le(e)})})}(this),this.Version=function(e){return $t(Ke.prototype,function(t){this.db=e,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(e){return $t(Se.prototype,function(t,n,r){this.db=e,this._ctx={table:t,index:":id"===n?null:n,or:r};var i=e._deps.indexedDB;if(!i)throw new A.MissingAPI("indexedDB API missing");this._cmp=this._ascending=i.cmp.bind(i),this._descending=function(e,t){return i.cmp(t,e)},this._max=function(e,t){return i.cmp(e,t)>0?e:t},this._min=function(e,t){return i.cmp(e,t)<0?e:t},this._IDBKeyRange=e._deps.IDBKeyRange})}(this),this.on("versionchange",function(e){e.newVersion>0?console.warn("Another connection wants to upgrade database '"+i.name+"'. Closing db now to resume the upgrade."):console.warn("Another connection wants to delete database '"+i.name+"'. Closing db now to resume the delete request."),i.close()}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('"+i.name+"') was blocked"):console.warn("Upgrade '"+i.name+"' blocked by other connection holding version "+e.oldVersion/10)}),this._maxKey=vn(r.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new i.Transaction(e,t,n,r)},this._fireOnBlocked=function(e){i.on("blocked").fire(e),ve.filter(function(e){return e.name===i.name&&e!==i&&!e._state.vcFired}).map(function(t){return t.on("versionchange").fire(e)})},this.use(Ie),this.use(Te),u.forEach(function(e){return e(i)})}return e.prototype.version=function(e){if(isNaN(e)||e<.1)throw new A.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new A.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);var t=this._versions,n=t.filter(function(t){return t._cfg.version===e})[0];return n||(n=new this.Version(e),t.push(n),t.sort(Cn),n.stores({}),this._state.autoSchema=!1,n)},e.prototype._whenReady=function(e){var t=this;return this._state.openComplete||$.letThrough?e():new _t(function(e,n){if(!t._state.isBeingOpened){if(!t._options.autoOpen)return void n(new A.DatabaseClosed);t.open().catch(ft)}t._state.dbReadyPromise.then(e,n)}).then(e)},e.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,i=e.name;i&&this.unuse({stack:t,name:i});var o=this._middlewares[t]||(this._middlewares[t]=[]);return o.push({stack:t,create:n,level:null==r?10:r,name:i}),o.sort(function(e,t){return e.level-t.level}),this},e.prototype.unuse=function(e){var t=e.stack,n=e.name,r=e.create;return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(function(e){return r?e.create!==r:!!n&&e.name!==n})),this},e.prototype.open=function(){return Nn(this)},e.prototype.close=function(){var e=ve.indexOf(this),t=this._state;if(e>=0&&ve.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(n){}this.idbdb=null}this._options.autoOpen=!1,t.dbOpenError=new A.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError),t.dbReadyPromise=new _t(function(e){t.dbReadyResolve=e}),t.openCanceller=new _t(function(e,n){t.cancelOpen=n})},e.prototype.delete=function(){var e=this,t=arguments.length>0,n=this._state;return new _t(function(r,i){var o=function(){e.close();var t=e._deps.indexedDB.deleteDatabase(e.name);t.onsuccess=Bt(function(){Ce.remove(e.name),r()}),t.onerror=mn(i),t.onblocked=e._fireOnBlocked};if(t)throw new A.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(o):o()})},e.prototype.backendDB=function(){return this.idbdb},e.prototype.isOpen=function(){return null!==this.idbdb},e.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},e.prototype.hasFailed=function(){return null!==this._state.dbOpenError},e.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(e.prototype,"tables",{get:function(){var e=this;return r(this._allTables).map(function(t){return e._allTables[t]})},enumerable:!0,configurable:!0}),e.prototype.transaction=function(){var e=Vn.apply(this,arguments);return this._transaction.apply(this,e)},e.prototype._transaction=function(e,t,n){var r=this,i=$.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);var o,u,a=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(u=t.map(function(e){var t=e instanceof r.Table?e.name:e;if("string"!=typeof t)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==e||e===ke)o=ke;else{if("rw"!=e&&e!=xe)throw new A.InvalidArgument("Invalid transaction mode: "+e);o=xe}if(i){if(i.mode===ke&&o===xe){if(!a)throw new A.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&u.forEach(function(e){if(i&&-1===i.storeNames.indexOf(e)){if(!a)throw new A.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),a&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,function(e,t){t(c)}):le(c)}var s=Wn.bind(null,this,o,u,i,n);return i?i._promise(o,s,"lock"):$.trans?Wt($.transless,function(){return r._whenReady(s)}):this._whenReady(s)},e.prototype.table=function(e){if(!qe(this._allTables,e))throw new A.InvalidTable("Table "+e+" does not exist");return this._allTables[e]},e}()),Me(De=Be,n(n({},C),{delete:function(e){return new De(e).delete()},exists:function(e){return new De(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){return Ce?Ce.getDatabaseNames().then(e):_t.resolve([])},defineClass:function(){return function(e){Fe(this,e)}},ignoreTransaction:function(e){return $.trans?Wt($.transless,e):e()},vip:Mn,async:function(e){return function(){try{var t=Un(e.apply(this,arguments));return t&&"function"==typeof t.then?t:_t.resolve(t)}catch(n){return le(n)}}},spawn:function(e,t,n){try{var r=Un(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:_t.resolve(r)}catch(i){return le(i)}},currentTransaction:{get:function(){return $.trans||null}},waitFor:function(e,t){var n=_t.resolve("function"==typeof e?De.ignoreTransaction(e):e).timeout(t||6e4);return $.trans?$.trans.waitFor(n):n},Promise:_t,debug:{get:function(){return w},set:function(e){rt(e,"dexie"===e?function(){return!0}:_e)}},derive:Ue,extend:Fe,props:Me,override:ze,Events:Jt,getByKeyPath:He,setByKeyPath:Qe,delByKeyPath:Xe,shallowClone:Je,deepClone:Ze,getObjectDiff:tt,asap:Ye,minKey:pe,addons:[],connections:ve,errnames:S,dependencies:function(){try{return{indexedDB:o.indexedDB||o.mozIndexedDB||o.webkitIndexedDB||o.msIndexedDB,IDBKeyRange:o.IDBKeyRange||o.webkitIDBKeyRange}}catch(e){return{indexedDB:null,IDBKeyRange:null}}}(),semVer:fe,version:fe.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)}),default:De,Dexie:De})),De.maxKey=vn(De.dependencies.IDBKeyRange),qn(Be.dependencies.indexedDB),_t.rejectionMapper=lt,rt(w,_e)}}}); |