dexie 4.0.8 → 4.1.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dexie.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Dexie=t()})(this,function(){"use strict";var s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};var w=function(){return(w=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}).apply(this,arguments)};function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||((r=r||Array.prototype.slice.call(t,0,i))[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,_=Object.keys,x=Array.isArray;function a(t,n){return"object"!=typeof n||_(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||f.Promise||(f.Promise=Promise);var c=Object.getPrototypeOf,n={}.hasOwnProperty;function m(e,t){return n.call(e,t)}function r(t,n){"function"==typeof n&&(n=n(c(t))),("undefined"==typeof Reflect?_:Reflect.ownKeys)(n).forEach(function(e){l(t,e,n[e])})}var u=Object.defineProperty;function l(e,t,n,r){u(e,t,a(n&&m(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function o(t){return{from:function(e){return t.prototype=Object.create(e.prototype),l(t.prototype,"constructor",t),{extend:r.bind(null,t.prototype)}}}}var h=Object.getOwnPropertyDescriptor;var d=[].slice;function b(e,t,n){return d.call(e,t,n)}function p(e,t){return t(e)}function y(e){if(!e)throw new Error("Assertion Failed")}function v(e){f.setImmediate?setImmediate(e):setTimeout(e,0)}function k(e,t){if("string"==typeof t&&m(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=k(e,t[r]);n.push(o)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return null==u?void 0:k(u,t.substr(a+1))}}function P(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){y("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)P(e,t[r],n[r])}else{var o,a,u=t.indexOf(".");-1!==u?(o=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?x(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n:P(u=!(u=e[o])||!m(e,o)?e[o]={}:u,a,n)):void 0===n?x(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function g(e){var t,n={};for(t in e)m(e,t)&&(n[t]=e[t]);return n}var t=[].concat;function O(e){return t.apply([],e)}var e="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(O([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return f[e]}),E=new Set(e.map(function(e){return f[e]}));var K=null;function S(e){K=new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=K.get(t);if(n)return n;if(x(t)){n=[],K.set(t,n);for(var r=0,i=t.length;r<i;++r)n.push(e(t[r]))}else if(E.has(t.constructor))n=t;else{var o,a=c(t);for(o in n=a===Object.prototype?{}:Object.create(a),K.set(t,n),t)m(t,o)&&(n[o]=e(t[o]))}return n}(e);return K=null,e}var j={}.toString;function A(e){return j.call(e).slice(8,-1)}var C="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",D="symbol"==typeof C?function(e){var t;return null!=e&&(t=e[C])&&t.apply(e)}:function(){return null};function T(e,t){t=e.indexOf(t);return 0<=t&&e.splice(t,1),0<=t}var q={};function I(e){var t,n,r,i;if(1===arguments.length){if(x(e))return e.slice();if(this===q&&"string"==typeof e)return[e];if(i=D(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var B="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},R=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],F=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(R),M={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function N(e,t){this.name=e,this.message=t}function L(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 U(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=L(e,t)}function V(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=L(e,this.failures)}o(N).from(Error).extend({toString:function(){return this.name+": "+this.message}}),o(U).from(N),o(V).from(N);var z=F.reduce(function(e,t){return e[t]=t+"Error",e},{}),W=N,Y=F.reduce(function(e,n){var r=n+"Error";function t(e,t){this.name=r,e?"string"==typeof e?(this.message="".concat(e).concat(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=M[n]||r,this.inner=null)}return o(t).from(W),e[n]=t,e},{});Y.Syntax=SyntaxError,Y.Type=TypeError,Y.Range=RangeError;var $=R.reduce(function(e,t){return e[t+"Error"]=Y[t],e},{});var Q=F.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Y[t]),e},{});function G(){}function X(e){return e}function H(t,n){return null==t||t===X?n:function(e){return n(t(e))}}function J(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function Z(i,o){return i===G?o:function(){var e=i.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=o.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?J(t,this.onsuccess):t),n&&(this.onerror=this.onerror?J(n,this.onerror):n),void 0!==r?r:e}}function ee(n,r){return n===G?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?J(e,this.onsuccess):e),t&&(this.onerror=this.onerror?J(t,this.onerror):t)}}function te(i,o){return i===G?o:function(e){var t=i.apply(this,arguments);a(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;e=o.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?J(n,this.onsuccess):n),r&&(this.onerror=this.onerror?J(r,this.onerror):r),void 0===t?void 0===e?void 0:e:a(t,e)}}function ne(e,t){return e===G?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function re(i,o){return i===G?o:function(){var e=i.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return o.apply(t,r)})}return o.apply(this,arguments)}}Q.ModifyError=U,Q.DexieError=N,Q.BulkError=V;var ie="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function oe(e){ie=e}var ae={},ue=100,e="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,c(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,c(t),e]}(),R=e[0],F=e[1],e=e[2],F=F&&F.then,se=R&&R.constructor,ce=!!e;var le=function(e,t){be.push([e,t]),he&&(queueMicrotask(Se),he=!1)},fe=!0,he=!0,de=[],pe=[],ye=X,ve={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:G,pgp:!1,env:{},finalize:G},me=ve,be=[],ge=0,we=[];function _e(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=me;if("function"!=typeof e){if(e!==ae)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Oe(this,this._value))}this._state=null,this._value=null,++t.ref,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&je();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof _e?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Pe(r)),e&&Ae()}},Oe.bind(null,r))}catch(e){Oe(r,e)}}(this,e)}var xe={get:function(){var u=me,t=Fe;function e(n,r){var i=this,o=!u.global&&(u!==me||t!==Fe),a=o&&!Ue(),e=new _e(function(e,t){Ee(i,new ke(Qe(n,u,o,a),Qe(r,u,o,a),e,t,u))});return this._consoleTask&&(e._consoleTask=this._consoleTask),e}return e.prototype=ae,e},set:function(e){l(this,"then",e&&e.prototype===ae?xe:{get:function(){return e},set:xe.set})}};function ke(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 Oe(e,t){var n,r;pe.push(t),null===e._state&&(n=e._lib&&je(),t=ye(t),e._state=!1,e._value=t,r=e,de.some(function(e){return e._value===r._value})||de.push(r),Pe(e),n&&Ae())}function Pe(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Ee(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===ge&&(++ge,le(function(){0==--ge&&Ce()},[]))}function Ee(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,++ge,le(Ke,[n,e,t])}else e._listeners.push(t)}function Ke(e,t,n){try{var r,i=t._value;!t._state&&pe.length&&(pe=[]),r=ie&&t._consoleTask?t._consoleTask.run(function(){return e(i)}):e(i),t._state||-1!==pe.indexOf(i)||function(e){var t=de.length;for(;t;)if(de[--t]._value===e._value)return de.splice(t,1)}(t),n.resolve(r)}catch(e){n.reject(e)}finally{0==--ge&&Ce(),--n.psd.ref||n.psd.finalize()}}function Se(){$e(ve,function(){je()&&Ae()})}function je(){var e=fe;return he=fe=!1,e}function Ae(){var e,t,n;do{for(;0<be.length;)for(e=be,be=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<be.length);he=fe=!0}function Ce(){var e=de;de=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=we.slice(0),n=t.length;n;)t[--n]()}function De(e){return new _e(ae,!1,e)}function Te(n,r){var i=me;return function(){var e=je(),t=me;try{return We(i,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{We(t,!1),e&&Ae()}}}r(_e.prototype,{then:xe,_then:function(e,t){Ee(this,new ke(null,null,e,t,me))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:De)(e)}):this.then(null,function(e){return(e&&e.name===t?n:De)(e)})},finally:function(t){return this.then(function(e){return _e.resolve(t()).then(function(){return e})},function(e){return _e.resolve(t()).then(function(){return De(e)})})},timeout:function(r,i){var o=this;return r<1/0?new _e(function(e,t){var n=setTimeout(function(){return t(new Y.Timeout(i))},r);o.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&l(_e.prototype,Symbol.toStringTag,"Dexie.Promise"),ve.env=Ye(),r(_e,{all:function(){var o=I.apply(null,arguments).map(Ve);return new _e(function(n,r){0===o.length&&n([]);var i=o.length;o.forEach(function(e,t){return _e.resolve(e).then(function(e){o[t]=e,--i||n(o)},r)})})},resolve:function(n){return n instanceof _e?n:n&&"function"==typeof n.then?new _e(function(e,t){n.then(e,t)}):new _e(ae,!0,n)},reject:De,race:function(){var e=I.apply(null,arguments).map(Ve);return new _e(function(t,n){e.map(function(e){return _e.resolve(e).then(t,n)})})},PSD:{get:function(){return me},set:function(e){return me=e}},totalEchoes:{get:function(){return Fe}},newPSD:Ne,usePSD:$e,scheduler:{get:function(){return le},set:function(e){le=e}},rejectionMapper:{get:function(){return ye},set:function(e){ye=e}},follow:function(i,n){return new _e(function(e,t){return Ne(function(n,r){var e=me;e.unhandleds=[],e.onunhandled=r,e.finalize=J(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},we.push(function e(){t(),we.splice(we.indexOf(e),1)}),++ge,le(function(){0==--ge&&Ce()},[])},e.finalize),i()},n,e,t)})}}),se&&(se.allSettled&&l(_e,"allSettled",function(){var e=I.apply(null,arguments).map(Ve);return new _e(function(n){0===e.length&&n([]);var r=e.length,i=new Array(r);e.forEach(function(e,t){return _e.resolve(e).then(function(e){return i[t]={status:"fulfilled",value:e}},function(e){return i[t]={status:"rejected",reason:e}}).then(function(){return--r||n(i)})})})}),se.any&&"undefined"!=typeof AggregateError&&l(_e,"any",function(){var e=I.apply(null,arguments).map(Ve);return new _e(function(n,r){0===e.length&&r(new AggregateError([]));var i=e.length,o=new Array(i);e.forEach(function(e,t){return _e.resolve(e).then(function(e){return n(e)},function(e){o[t]=e,--i||r(new AggregateError(o))})})})}));var qe={awaits:0,echoes:0,id:0},Ie=0,Be=[],Re=0,Fe=0,Me=0;function Ne(e,t,n,r){var i=me,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++Me,ve.env,o.env=ce?{Promise:_e,PromiseProp:{value:_e,configurable:!0,writable:!0},all:_e.all,race:_e.race,allSettled:_e.allSettled,any:_e.any,resolve:_e.resolve,reject:_e.reject}:{},t&&a(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};r=$e(o,e,n,r);return 0===o.ref&&o.finalize(),r}function Le(){return qe.id||(qe.id=++Ie),++qe.awaits,qe.echoes+=ue,qe.id}function Ue(){return!!qe.awaits&&(0==--qe.awaits&&(qe.id=0),qe.echoes=qe.awaits*ue,!0)}function Ve(e){return qe.echoes&&e&&e.constructor===se?(Le(),e.then(function(e){return Ue(),e},function(e){return Ue(),Xe(e)})):e}function ze(){var e=Be[Be.length-1];Be.pop(),We(e,!1)}function We(e,t){var n,r=me;(t?!qe.echoes||Re++&&e===me:!Re||--Re&&e===me)||queueMicrotask(t?function(e){++Fe,qe.echoes&&0!=--qe.echoes||(qe.echoes=qe.awaits=qe.id=0),Be.push(me),We(e,!0)}.bind(null,e):ze),e!==me&&(me=e,r===ve&&(ve.env=Ye()),ce&&(n=ve.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(f,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function Ye(){var e=f.Promise;return ce?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(f,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function $e(e,t,n,r,i){var o=me;try{return We(e,!0),t(n,r,i)}finally{We(o,!1)}}function Qe(t,n,r,i){return"function"!=typeof t?t:function(){var e=me;r&&Le(),We(n,!0);try{return t.apply(this,arguments)}finally{We(e,!1),i&&queueMicrotask(Ue)}}}function Ge(e){Promise===se&&0===qe.echoes?0===Re?e():enqueueNativeMicroTask(e):setTimeout(e,0)}-1===(""+F).indexOf("[native code]")&&(Le=Ue=G);var Xe=_e.reject;var He=String.fromCharCode(65535),Je="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Ze="String expected.",et=[],tt="__dbnames",nt="readonly",rt="readwrite";function it(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var ot={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function at(t){return"string"!=typeof t||/\./.test(t)?function(e){return e}:function(e){return void 0===e[t]&&t in e&&delete(e=S(e))[t],e}}function ut(){throw Y.Type()}function st(e,t){try{var n=ct(e),r=ct(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o)if(e[o]!==t[o])return e[o]<t[o]?-1:1;return n===r?0:n<r?-1:1}(lt(e),lt(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,i=n<r?n:r,o=0;o<i;++o){var a=st(e[o],t[o]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function ct(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=A(e);return"ArrayBuffer"===e?"binary":e}function lt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var ft=(ht.prototype._trans=function(e,r,t){var n=this._tx||me.trans,i=this.name,o=ie&&"undefined"!=typeof console&&console.createTask&&console.createTask("Dexie: ".concat("readonly"===e?"read":"write"," ").concat(this.name));function a(e,t,n){if(!n.schema[i])throw new Y.NotFound("Table "+i+" not part of transaction");return r(n.idbtrans,n)}var u=je();try{var s=n&&n.db._novip===this.db._novip?n===me.trans?n._promise(e,a,t):Ne(function(){return n._promise(e,a,t)},{trans:n,transless:me.transless||me}):function t(n,r,i,o){if(n.idbdb&&(n._state.openComplete||me.letThrough||n._vip)){var a=n._createTransaction(r,i,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(e){return e.name===z.InvalidState&&n.isOpen()&&0<--n._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),n.close({disableAutoOpen:!1}),n.open().then(function(){return t(n,r,i,o)})):Xe(e)}return a._promise(r,function(e,t){return Ne(function(){return me.trans=a,o(e,t,a)})}).then(function(e){if("readwrite"===r)try{a.idbtrans.commit()}catch(e){}return"readonly"===r?e:a._completion.then(function(){return e})})}if(n._state.openComplete)return Xe(new Y.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._state.autoOpen)return Xe(new Y.DatabaseClosed);n.open().catch(G)}return n._state.dbReadyPromise.then(function(){return t(n,r,i,o)})}(this.db,e,[this.name],a);return o&&(s._consoleTask=o,s=s.catch(function(e){return console.trace(e),Xe(e)})),s}finally{u&&Ae()}},ht.prototype.get=function(t,e){var n=this;return t&&t.constructor===Object?this.where(t).first(e):null==t?Xe(new Y.Type("Invalid argument to Table.get()")):this._trans("readonly",function(e){return n.core.get({trans:e,key:t}).then(function(e){return n.hook.reading.fire(e)})}).then(e)},ht.prototype.where=function(o){if("string"==typeof o)return new this.db.WhereClause(this,o);if(x(o))return new this.db.WhereClause(this,"[".concat(o.join("+"),"]"));var n=_(o);if(1===n.length)return this.where(n[0]).equals(o[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){if(t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})){for(var e=0;e<n.length;++e)if(-1===n.indexOf(t.keyPath[e]))return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(e&&this.db._maxKey!==He){var t=e.keyPath.slice(0,n.length);return this.where(t).equals(t.map(function(e){return o[e]}))}!e&&ie&&console.warn("The query ".concat(JSON.stringify(o)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(n.join("+"),"]"));var a=this.schema.idxByName,r=this.db._deps.indexedDB;function u(e,t){return 0===r.cmp(e,t)}var i=n.reduce(function(e,t){var n=e[0],r=e[1],e=a[t],i=o[t];return[n||e,n||!e?it(r,e&&e.multi?function(e){e=k(e,t);return x(e)&&e.some(function(e){return u(i,e)})}:function(e){return u(i,k(e,t))}):r]},[null,null]),t=i[0],i=i[1];return t?this.where(t.name).equals(o[t.keyPath]).filter(i):e?this.filter(i):this.where(n).equals("")},ht.prototype.filter=function(e){return this.toCollection().and(e)},ht.prototype.count=function(e){return this.toCollection().count(e)},ht.prototype.offset=function(e){return this.toCollection().offset(e)},ht.prototype.limit=function(e){return this.toCollection().limit(e)},ht.prototype.each=function(e){return this.toCollection().each(e)},ht.prototype.toArray=function(e){return this.toCollection().toArray(e)},ht.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},ht.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,x(e)?"[".concat(e.join("+"),"]"):e))},ht.prototype.reverse=function(){return this.toCollection().reverse()},ht.prototype.mapToClass=function(r){var e,t=this.db,n=this.name;function i(){return null!==e&&e.apply(this,arguments)||this}(this.schema.mappedClass=r).prototype instanceof ut&&(function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(i,e=r),Object.defineProperty(i.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),i.prototype.table=function(){return n},r=i);for(var o=new Set,a=r.prototype;a;a=c(a))Object.getOwnPropertyNames(a).forEach(function(e){return o.add(e)});function u(e){if(!e)return e;var t,n=Object.create(r.prototype);for(t in e)if(!o.has(t))try{n[t]=e[t]}catch(e){}return n}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),r},ht.prototype.defineClass=function(){return this.mapToClass(function(e){a(this,e)})},ht.prototype.add=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=at(o)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})}).then(function(e){return e.numFailures?_e.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{P(t,o,e)}catch(e){}return e})},ht.prototype.update=function(e,t){if("object"!=typeof e||x(e))return this.where(":id").equals(e).modify(t);e=k(e,this.schema.primKey.keyPath);return void 0===e?Xe(new Y.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},ht.prototype.put=function(t,n){var r=this,e=this.schema.primKey,i=e.auto,o=e.keyPath,a=t;return o&&i&&(a=at(o)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?_e.reject(e.failures[0]):e.lastResult}).then(function(e){if(o)try{P(t,o,e)}catch(e){}return e})},ht.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]})}).then(function(e){return e.numFailures?_e.reject(e.failures[0]):void 0})},ht.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:ot})}).then(function(e){return e.numFailures?_e.reject(e.failures[0]):void 0})},ht.prototype.bulkGet=function(t){var n=this;return this._trans("readonly",function(e){return n.core.getMany({keys:t,trans:e}).then(function(e){return e.map(function(e){return n.hook.reading.fire(e)})})})},ht.prototype.bulkAdd=function(r,e,t){var o=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=o.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Y.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Y.InvalidArgument("Arguments objects and keys must have the same length");var i=r.length,t=t&&n?r.map(at(t)):r;return o.core.mutate({trans:e,type:"add",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new V("".concat(o.name,".bulkAdd(): ").concat(t," of ").concat(i," operations failed"),e)})})},ht.prototype.bulkPut=function(r,e,t){var o=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=o.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new Y.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new Y.InvalidArgument("Arguments objects and keys must have the same length");var i=r.length,t=t&&n?r.map(at(t)):r;return o.core.mutate({trans:e,type:"put",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new V("".concat(o.name,".bulkPut(): ").concat(t," of ").concat(i," operations failed"),e)})})},ht.prototype.bulkUpdate=function(t){var h=this,n=this.core,r=t.map(function(e){return e.key}),i=t.map(function(e){return e.changes}),d=[];return this._trans("readwrite",function(e){return n.getMany({trans:e,keys:r,cache:"clone"}).then(function(c){var l=[],f=[];t.forEach(function(e,t){var n=e.key,r=e.changes,i=c[t];if(i){for(var o=0,a=Object.keys(r);o<a.length;o++){var u=a[o],s=r[u];if(u===h.schema.primKey.keyPath){if(0!==st(s,n))throw new Y.Constraint("Cannot update primary key in bulkUpdate()")}else P(i,u,s)}d.push(t),l.push(n),f.push(i)}});var s=l.length;return n.mutate({trans:e,type:"put",keys:l,values:f,updates:{keys:r,changeSpecs:i}}).then(function(e){var t=e.numFailures,n=e.failures;if(0===t)return s;for(var r=0,i=Object.keys(n);r<i.length;r++){var o,a=i[r],u=d[Number(a)];null!=u&&(o=n[a],delete n[a],n[u]=o)}throw new V("".concat(h.name,".bulkUpdate(): ").concat(t," of ").concat(s," operations failed"),n)})})})},ht.prototype.bulkDelete=function(t){var r=this,i=t.length;return this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"delete",keys:t})}).then(function(e){var t=e.numFailures,n=e.lastResult,e=e.failures;if(0===t)return n;throw new V("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(i," operations failed"),e)})},ht);function ht(){}function dt(i){function t(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return a[e].subscribe.apply(null,r),i}if("string"==typeof e)return a[e]}var a={};t.addEventType=u;for(var e=1,n=arguments.length;e<n;++e)u(arguments[e]);return t;function u(e,n,r){if("object"!=typeof e){var i;n=n||ne;var o={subscribers:[],fire:r=r||G,subscribe:function(e){-1===o.subscribers.indexOf(e)&&(o.subscribers.push(e),o.fire=n(o.fire,e))},unsubscribe:function(t){o.subscribers=o.subscribers.filter(function(e){return e!==t}),o.fire=o.subscribers.reduce(n,r)}};return a[e]=t[e]=o}_(i=e).forEach(function(e){var t=i[e];if(x(t))u(e,i[e][0],i[e][1]);else{if("asap"!==t)throw new Y.InvalidArgument("Invalid event config");var n=u(e,X,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){v(function(){e.apply(null,t)})})})}})}}function pt(e,t){return o(t).from({prototype:e}),t}function yt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function vt(e,t){e.filter=it(e.filter,t)}function mt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return it(r(),t())}:t,e.justLimit=n&&!r}function bt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new Y.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function gt(e,t,n){var r=bt(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 wt(e,o,t,n){var a=e.replayFilter?it(e.filter,e.replayFilter()):e.filter;if(e.or){var u={},r=function(e,t,n){var r,i;a&&!a(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(i=""+(r=t.primaryKey))&&(i=""+new Uint8Array(r)),m(u,i)||(u[i]=!0,o(e,t,n)))};return Promise.all([e.or._iterate(r,t),_t(gt(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return _t(gt(e,n,t),it(e.algorithm,a),o,!e.keysOnly&&e.valueMapper)}function _t(e,r,i,o){var a=Te(o?function(e,t,n){return i(o(e),t,n)}:i);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=G},function(e){n.fail(e),t=G})||a(n.value,n,function(e){return t=e}),t()})})}var e=Symbol(),xt=(kt.prototype.execute=function(e){if(void 0!==this.add){var t=this.add;if(x(t))return i(i([],x(e)?e:[],!0),t,!0).sort();if("number"==typeof t)return(Number(e)||0)+t;if("bigint"==typeof t)try{return BigInt(e)+t}catch(e){return BigInt(0)+t}throw new TypeError("Invalid term ".concat(t))}if(void 0!==this.remove){var n=this.remove;if(x(n))return x(e)?e.filter(function(e){return!n.includes(e)}).sort():[];if("number"==typeof n)return Number(e)-n;if("bigint"==typeof n)try{return BigInt(e)-n}catch(e){return BigInt(0)-n}throw new TypeError("Invalid subtrahend ".concat(n))}t=null===(t=this.replacePrefix)||void 0===t?void 0:t[0];return t&&"string"==typeof e&&e.startsWith(t)?this.replacePrefix[1]+e.substring(t.length):e},kt);function kt(e){Object.assign(this,e)}var Ot=(Pt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,Xe.bind(null,n.error)):n.table._trans("readonly",e).then(t)},Pt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,Xe.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},Pt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=it(t.algorithm,e)},Pt.prototype._iterate=function(e,t){return wt(this._ctx,e,t,this._ctx.table.core)},Pt.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&a(n,e),t._ctx=n,t},Pt.prototype.raw=function(){return this._ctx.valueMapper=null,this},Pt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return wt(n,t,e,n.table.core)})},Pt.prototype.count=function(e){var i=this;return this._read(function(e){var t=i._ctx,n=t.table.core;if(yt(t,!0))return n.count({trans:e,query:{index:bt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return wt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},Pt.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 a="next"===this._ctx.dir?1:-1;function u(e,t){e=o(e,i),t=o(t,i);return e<t?-a:t<e?a:0}return this.toArray(function(e){return e.sort(u)}).then(t)},Pt.prototype.toArray=function(e){var o=this;return this._read(function(e){var t=o._ctx;if("next"===t.dir&&yt(t,!0)&&0<t.limit){var n=t.valueMapper,r=bt(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){e=e.result;return n?e.map(n):e})}var i=[];return wt(t,function(e){return i.push(e)},e,t.table.core).then(function(){return i})},e)},Pt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,yt(e)?mt(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):mt(e,function(){var e=t;return function(){return--e<0}})),this},Pt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),mt(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},Pt.prototype.until=function(r,i){return vt(this._ctx,function(e,t,n){return!r(e.value)||(t(n),i)}),this},Pt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},Pt.prototype.last=function(e){return this.reverse().first(e)},Pt.prototype.filter=function(t){var e;return vt(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=it(e.isMatch,t),this},Pt.prototype.and=function(e){return this.filter(e)},Pt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},Pt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Pt.prototype.desc=function(){return this.reverse()},Pt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},Pt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},Pt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},Pt.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)},Pt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&yt(n,!0)&&0<n.limit)return this._read(function(e){var t=bt(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(function(e){return e.result}).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)},Pt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},Pt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},Pt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},Pt.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var n={};return vt(this._ctx,function(e){var t=e.primaryKey.toString(),e=m(n,t);return n[t]=!0,!e}),this},Pt.prototype.modify=function(w){var n=this,r=this._ctx;return this._write(function(d){var a,u,p;p="function"==typeof w?w:(a=_(w),u=a.length,function(e){for(var t=!1,n=0;n<u;++n){var r=a[n],i=w[r],o=k(e,r);i instanceof xt?(P(e,r,i.execute(o)),t=!0):o!==i&&(P(e,r,i),t=!0)}return t});function y(e,t){var n=t.failures,t=t.numFailures;c+=e-t;for(var r=0,i=_(n);r<i.length;r++){var o=i[r];s.push(n[o])}}var v=r.table.core,e=v.schema.primaryKey,m=e.outbound,b=e.extractKey,g=n.db._options.modifyChunkSize||200,s=[],c=0,t=[];return n.clone().primaryKeys().then(function(l){function f(s){var c=Math.min(g,l.length-s);return v.getMany({trans:d,keys:l.slice(s,s+c),cache:"immutable"}).then(function(e){for(var n=[],t=[],r=m?[]:null,i=[],o=0;o<c;++o){var a=e[o],u={value:S(a),primKey:l[s+o]};!1!==p.call(u,u.value,u)&&(null==u.value?i.push(l[s+o]):m||0===st(b(a),b(u.value))?(t.push(u.value),m&&r.push(l[s+o])):(i.push(l[s+o]),n.push(u.value)))}return Promise.resolve(0<n.length&&v.mutate({trans:d,type:"add",values:n}).then(function(e){for(var t in e.failures)i.splice(parseInt(t),1);y(n.length,e)})).then(function(){return(0<t.length||h&&"object"==typeof w)&&v.mutate({trans:d,type:"put",keys:r,values:t,criteria:h,changeSpec:"function"!=typeof w&&w,isAdditionalChunk:0<s}).then(function(e){return y(t.length,e)})}).then(function(){return(0<i.length||h&&w===Et)&&v.mutate({trans:d,type:"delete",keys:i,criteria:h,isAdditionalChunk:0<s}).then(function(e){return y(i.length,e)})}).then(function(){return l.length>s+c&&f(s+g)})})}var h=yt(r)&&r.limit===1/0&&("function"!=typeof w||w===Et)&&{index:r.index,range:r.range};return f(0).then(function(){if(0<s.length)throw new U("Error modifying one or more objects",s,c,t);return l.length})})})},Pt.prototype.delete=function(){var i=this._ctx,n=i.range;return yt(i)&&(i.isPrimKey||3===n.type)?this._write(function(e){var t=i.table.core.schema.primaryKey,r=n;return i.table.core.count({trans:e,query:{index:t,range:r}}).then(function(n){return i.table.core.mutate({trans:e,type:"deleteRange",range:r}).then(function(e){var t=e.failures;e.lastResult,e.results;e=e.numFailures;if(e)throw new U("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),n-e);return n-e})})}):this.modify(Et)},Pt);function Pt(){}var Et=function(e,t){return t.value=null};function Kt(e,t){return e<t?-1:e===t?0:1}function St(e,t){return t<e?-1:e===t?0:1}function jt(e,t,n){e=e instanceof qt?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function At(e){return new e.Collection(e,function(){return Tt("")}).limit(0)}function Ct(e,s,n,r){var i,c,l,f,h,d,p,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return jt(e,Ze);function t(e){i="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?Kt:St;var t=n.map(function(e){return{lower:c(e),upper:i(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),p="next"===(d=e)?"":r}t("next");e=new e.Collection(e,function(){return Dt(f[0],h[y-1]+r)});e._ondirectionchange=function(e){t(e)};var v=0;return e._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var i=c(r);if(s(i,h,v))return!0;for(var o=null,a=v;a<y;++a){var u=function(e,t,n,r,i,o){for(var a=Math.min(e.length,r.length),u=-1,s=0;s<a;++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):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;i(e[s],c)<0&&(u=s)}return a<r.length&&"next"===o?e+n.substr(e.length):a<e.length&&"prev"===o?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(r,i,f[a],h[a],l,d);null===u&&null===o?v=a+1:(null===o||0<l(o,u))&&(o=u)}return t(null!==o?function(){e.continue(o+p)}:n),!1}),e}function Dt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Tt(e){return{type:1,lower:e,upper:e}}var qt=(Object.defineProperty(It.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),It.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?At(this):new this.Collection(this,function(){return Dt(e,t,!n,!r)})}catch(e){return jt(this,Je)}},It.prototype.equals=function(e){return null==e?jt(this,Je):new this.Collection(this,function(){return Tt(e)})},It.prototype.above=function(e){return null==e?jt(this,Je):new this.Collection(this,function(){return Dt(e,void 0,!0)})},It.prototype.aboveOrEqual=function(e){return null==e?jt(this,Je):new this.Collection(this,function(){return Dt(e,void 0,!1)})},It.prototype.below=function(e){return null==e?jt(this,Je):new this.Collection(this,function(){return Dt(void 0,e,!1,!0)})},It.prototype.belowOrEqual=function(e){return null==e?jt(this,Je):new this.Collection(this,function(){return Dt(void 0,e)})},It.prototype.startsWith=function(e){return"string"!=typeof e?jt(this,Ze):this.between(e,e+He,!0,!0)},It.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Ct(this,function(e,t){return 0===e.indexOf(t[0])},[e],He)},It.prototype.equalsIgnoreCase=function(e){return Ct(this,function(e,t){return e===t[0]},[e],"")},It.prototype.anyOfIgnoreCase=function(){var e=I.apply(q,arguments);return 0===e.length?At(this):Ct(this,function(e,t){return-1!==t.indexOf(e)},e,"")},It.prototype.startsWithAnyOfIgnoreCase=function(){var e=I.apply(q,arguments);return 0===e.length?At(this):Ct(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,He)},It.prototype.anyOf=function(){var t=this,i=I.apply(q,arguments),o=this._cmp;try{i.sort(o)}catch(e){return jt(this,Je)}if(0===i.length)return At(this);var e=new this.Collection(this,function(){return Dt(i[0],i[i.length-1])});e._ondirectionchange=function(e){o="next"===e?t._ascending:t._descending,i.sort(o)};var a=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<o(r,i[a]);)if(++a===i.length)return t(n),!1;return 0===o(r,i[a])||(t(function(){e.continue(i[a])}),!1)}),e},It.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},It.prototype.noneOf=function(){var e=I.apply(q,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return jt(this,Je)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},It.prototype.inAnyRange=function(e,t){var o=this,a=this._cmp,u=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return At(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return jt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Y.InvalidArgument);var r=!t||!1!==t.includeLowers,i=t&&!0===t.includeUppers;var l,f=u;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var i=e[n];if(a(t[0],i[1])<0&&0<a(t[1],i[0])){i[0]=s(i[0],t[0]),i[1]=c(i[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return jt(this,Je)}var d=0,p=i?function(e){return 0<u(e,l[d][1])}:function(e){return 0<=u(e,l[d][1])},y=r?function(e){return 0<n(e,l[d][0])}:function(e){return 0<=n(e,l[d][0])};var v=p,e=new this.Collection(this,function(){return Dt(l[0][0],l[l.length-1][1],!r,!i)});return e._ondirectionchange=function(e){f="next"===e?(v=p,u):(v=y,n),l.sort(h)},e._addAlgorithm(function(e,t,n){for(var r,i=e.key;v(i);)if(++d===l.length)return t(n),!1;return!p(r=i)&&!y(r)||(0===o._cmp(i,l[d][1])||0===o._cmp(i,l[d][0])||t(function(){f===u?e.continue(l[d][0]):e.continue(l[d][1])}),!1)}),e},It.prototype.startsWithAnyOf=function(){var e=I.apply(q,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?At(this):this.inAnyRange(e.map(function(e){return[e,e+He]})):jt(this,"startsWithAnyOf() only works with strings")},It);function It(){}function Bt(t){return Te(function(e){return Rt(e),t(e.target.error),!1})}function Rt(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Ft="storagemutated",Mt="x-storagemutated-1",Nt=dt(null,Ft),Lt=(Ut.prototype._lock=function(){return y(!me.global),++this._reculock,1!==this._reculock||me.global||(me.lockOwnerFor=this),this},Ut.prototype._unlock=function(){if(y(!me.global),0==--this._reculock)for(me.global||(me.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{$e(e[1],e[0])}catch(e){}}return this},Ut.prototype._locked=function(){return this._reculock&&me.lockOwnerFor!==this},Ut.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(y(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new Y.DatabaseClosed(r);case"MissingAPIError":throw new Y.MissingAPI(r.message,r);default:throw new Y.OpenFailed(r)}if(!this.active)throw new Y.TransactionInactive;return y(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Te(function(e){Rt(e),n._reject(t.error)}),t.onabort=Te(function(e){Rt(e),n.active&&n._reject(new Y.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=Te(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&Nt.storagemutated.fire(t.mutatedParts)}),this},Ut.prototype._promise=function(n,r,i){var o=this;if("readwrite"===n&&"readwrite"!==this.mode)return Xe(new Y.ReadOnly("Transaction is readonly"));if(!this.active)return Xe(new Y.TransactionInactive);if(this._locked())return new _e(function(e,t){o._blockedFuncs.push([function(){o._promise(n,r,i).then(e,t)},me])});if(i)return Ne(function(){var e=new _e(function(e,t){o._lock();var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e.finally(function(){return o._unlock()}),e._lib=!0,e});var e=new _e(function(e,t){var n=r(e,t,o);n&&n.then&&n.then(e,t)});return e._lib=!0,e},Ut.prototype._root=function(){return this.parent?this.parent._root():this},Ut.prototype.waitFor=function(e){var t,r=this._root(),i=_e.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return i}):(r._waitingFor=i,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var o=r._waitingFor;return new _e(function(t,n){i.then(function(e){return r._waitingQueue.push(Te(t.bind(null,e)))},function(e){return r._waitingQueue.push(Te(n.bind(null,e)))}).finally(function(){r._waitingFor===o&&(r._waitingFor=null)})})},Ut.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new Y.Abort))},Ut.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(m(t,e))return t[e];var n=this.schema[e];if(!n)throw new Y.NotFound("Table "+e+" not part of transaction");n=new this.db.Table(e,n,this);return n.core=this.db.core.table(e),t[e]=n},Ut);function Ut(){}function Vt(e,t,n,r,i,o,a){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:o,src:(n&&!a?"&":"")+(r?"*":"")+(i?"++":"")+zt(t)}}function zt(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function Wt(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:(r=function(e){return[e.name,e]},n.reduce(function(e,t,n){n=r(t,n);return n&&(e[n[0]]=n[1]),e},{}))};var r}var Yt=function(e){try{return e.only([[]]),Yt=function(){return[[]]},[[]]}catch(e){return Yt=function(){return He},He}};function $t(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return k(e,n)}:function(e){return k(e,t)};var n}function Qt(e){return[].slice.call(e)}var Gt=0;function Xt(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function Ht(e,i,t){function _(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,e=e.upperOpen;return void 0===t?void 0===n?null:i.upperBound(n,!!e):void 0===n?i.lowerBound(t,!!r):i.bound(t,n,!!r,!!e)}function n(e){var h,w=e.name;return{name:w,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,b=e.values,g=e.range;return new Promise(function(t,e){t=Te(t);var n=y.objectStore(w),r=null==n.keyPath,i="put"===v||"add"===v;if(!i&&"delete"!==v&&"deleteRange"!==v)throw new Error("Invalid operation type: "+v);var o,a=(m||b||{length:1}).length;if(m&&b&&m.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(0===a)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++l,Rt(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===g.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===g.type?s.push(o=n.clear()):s.push(o=n.delete(_(g)))}else{var r=i?r?[b,m]:[b,null]:[m,null],f=r[0],h=r[1];if(i)for(var d=0;d<a;++d)s.push(o=h&&void 0!==h[d]?n[v](f[d],h[d]):n[v](f[d])),o.onerror=u;else for(d=0;d<a;++d)s.push(o=n[v](f[d])),o.onerror=u}function p(e){e=e.target.result,s.forEach(function(e,t){return null!=e.error&&(c[t]=e.error)}),t({numFailures:l,failures:c,results:"delete"===v?m:s.map(function(e){return e.result}),lastResult:e})}o.onerror=function(e){u(e),p(e)},o.onsuccess=p})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(t,e){t=Te(t);for(var n,r=f.objectStore(w),i=h.length,o=new Array(i),a=0,u=0,s=function(e){e=e.target;o[e._pos]=e.result,++u===a&&t(o)},c=Bt(e),l=0;l<i;++l)null!=h[l]&&((n=r.get(h[l]))._pos=l,n.onsuccess=s,n.onerror=c,++a);0===a&&t(o)})},get:function(e){var r=e.trans,i=e.key;return new Promise(function(t,e){t=Te(t);var n=r.objectStore(w).get(i);n.onsuccess=function(e){return t(e.target.result)},n.onerror=Bt(e)})},query:(h=s,function(f){return new Promise(function(n,e){n=Te(n);var r,i,o,t=f.trans,a=f.values,u=f.limit,s=f.query,c=u===1/0?void 0:u,l=s.index,s=s.range,t=t.objectStore(w),l=l.isPrimaryKey?t:t.index(l.name),s=_(s);if(0===u)return n({result:[]});h?((c=a?l.getAll(s,c):l.getAllKeys(s,c)).onsuccess=function(e){return n({result:e.target.result})},c.onerror=Bt(e)):(r=0,i=!a&&"openKeyCursor"in l?l.openKeyCursor(s):l.openCursor(s),o=[],i.onsuccess=function(e){var t=i.result;return t?(o.push(a?t.value:t.primaryKey),++r===u?n({result:o}):void t.continue()):n({result:o})},i.onerror=Bt(e))})}),openCursor:function(e){var c=e.trans,o=e.values,a=e.query,u=e.reverse,l=e.unique;return new Promise(function(t,n){t=Te(t);var e=a.index,r=a.range,i=c.objectStore(w),i=e.isPrimaryKey?i:i.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!o&&"openKeyCursor"in i?i.openKeyCursor(_(r),e):i.openCursor(_(r),e);s.onerror=Bt(n),s.onsuccess=Te(function(e){var r,i,o,a,u=s.result;u?(u.___id=++Gt,u.done=!1,r=u.continue.bind(u),i=(i=u.continuePrimaryKey)&&i.bind(u),o=u.advance.bind(u),a=function(){throw new Error("Cursor not stopped")},u.trans=c,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=Te(n),u.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},u.start=function(e){function t(){if(s.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise(function(t,e){t=Te(t),s.onerror=Bt(e),u.fail=e,u.stop=function(e){u.stop=u.continue=u.continuePrimaryKey=u.advance=a,t(e)}});return s.onsuccess=Te(function(e){s.onsuccess=t,t()}),u.continue=r,u.continuePrimaryKey=i,u.advance=o,t(),n},t(u)):t(null)},n)})},count:function(e){var t=e.query,i=e.trans,o=t.index,a=t.range;return new Promise(function(t,e){var n=i.objectStore(w),r=o.isPrimaryKey?n:n.index(o.name),n=_(a),r=n?r.count(n):r.count();r.onsuccess=Te(function(e){return t(e.target.result)}),r.onerror=Bt(e)})}}}var r,o,a,u=(o=t,a=Qt((r=e).objectStoreNames),{schema:{name:r.name,tables:a.map(function(e){return o.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=x(e),i={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:$t(e)},indexes:Qt(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,r={name:t,compound:x(e),keyPath:e,unique:n,multiEntry:r,extractKey:$t(e)};return i[Xt(e)]=r}),getIndexByKeyPath:function(e){return i[Xt(e)]}};return i[":id"]=n.primaryKey,null!=e&&(i[Xt(e)]=n.primaryKey),n})},hasGetAll:0<a.length&&"getAll"in o.objectStore(a[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),t=u.schema,s=u.hasGetAll,u=t.tables.map(n),c={};return u.forEach(function(e){return c[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!c[e])throw new Error("Table '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:Yt(i),schema:t}}function Jt(e,t,n,r){var i=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=Ht(t,i,r),e.dbcore.reduce(function(e,t){t=t.create;return w(w({},e),t(e))},r))}}function Zt(n,e){var t=e.db,e=Jt(n._middlewares,t,n._deps,e);n.core=e.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=e.core))})}function en(i,e,t,o){t.forEach(function(n){var r=o[n];e.forEach(function(e){var t=function e(t,n){return h(t,n)||(t=c(t))&&e(t,n)}(e,n);(!t||"value"in t&&void 0===t.value)&&(e===i.Transaction.prototype||e instanceof i.Transaction?l(e,n,{get:function(){return this.table(n)},set:function(e){u(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):e[n]=new i.Table(n,r))})})}function tn(n,e){e.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function nn(e,t){return e._cfg.version-t._cfg.version}function rn(n,r,i,e){var o=n._dbSchema;i.objectStoreNames.contains("$meta")&&!o.$meta&&(o.$meta=Wt("$meta",hn("")[0],[]),n._storeNames.push("$meta"));var a=n._createTransaction("readwrite",n._storeNames,o);a.create(i),a._completion.catch(e);var u=a._reject.bind(a),s=me.transless||me;Ne(function(){return me.trans=a,me.transless=s,0!==r?(Zt(n,i),t=r,((e=a).storeNames.includes("$meta")?e.table("$meta").get("version").then(function(e){return null!=e?e:t}):_e.resolve(t)).then(function(e){return c=e,l=a,f=i,t=[],e=(s=n)._versions,h=s._dbSchema=ln(0,s.idbdb,f),0!==(e=e.filter(function(e){return e._cfg.version>=c})).length?(e.forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;fn(s,t,f),fn(s,e,f),h=s._dbSchema=e;var n=an(t,e);n.add.forEach(function(e){un(f,e[0],e[1].primKey,e[1].indexes)}),n.change.forEach(function(e){if(e.recreate)throw new Y.Upgrade("Not yet support for changing primary key");var t=f.objectStore(e.name);e.add.forEach(function(e){return cn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),cn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>c){Zt(s,f),l._memoizedTables={};var i=g(e);n.del.forEach(function(e){i[e]=t[e]}),tn(s,[s.Transaction.prototype]),en(s,[s.Transaction.prototype],_(i),i),l.schema=i;var o,a=B(r);a&&Le();n=_e.follow(function(){var e;(o=r(l))&&a&&(e=Ue.bind(null,null),o.then(e,e))});return o&&"function"==typeof o.then?_e.resolve(o):n.then(function(){return o})}}),t.push(function(e){var t,n,r=u._cfg.dbschema;t=r,n=e,[].slice.call(n.db.objectStoreNames).forEach(function(e){return null==t[e]&&n.db.deleteObjectStore(e)}),tn(s,[s.Transaction.prototype]),en(s,[s.Transaction.prototype],s._storeNames,s._dbSchema),l.schema=s._dbSchema}),t.push(function(e){s.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(s.idbdb.version/10)===u._cfg.version?(s.idbdb.deleteObjectStore("$meta"),delete s._dbSchema.$meta,s._storeNames=s._storeNames.filter(function(e){return"$meta"!==e})):e.objectStore("$meta").put(u._cfg.version,"version"))})}),function e(){return t.length?_e.resolve(t.shift()(l.idbtrans)).then(e):_e.resolve()}().then(function(){sn(h,f)})):_e.resolve();var s,c,l,f,t,h}).catch(u)):(_(o).forEach(function(e){un(i,e,o[e].primKey,o[e].indexes)}),Zt(n,i),void _e.follow(function(){return n.on.populate.fire(a)}).catch(u));var e,t})}function on(e,r){sn(e._dbSchema,r),r.db.version%10!=0||r.objectStoreNames.contains("$meta")||r.db.createObjectStore("$meta").add(Math.ceil(r.db.version/10-1),"version");var t=ln(0,e.idbdb,r);fn(e,e._dbSchema,r);for(var n=0,i=an(t,e._dbSchema).change;n<i.length;n++){var o=function(t){if(t.change.length||t.recreate)return console.warn("Unable to patch indexes of table ".concat(t.name," because it has changes on the type of index or primary key.")),{value:void 0};var n=r.objectStore(t.name);t.add.forEach(function(e){ie&&console.debug("Dexie upgrade patch: Creating missing index ".concat(t.name,".").concat(e.src)),cn(n,e)})}(i[n]);if("object"==typeof o)return o.value}}function an(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 a={name:n,def:o,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(o.primKey.keyPath||"")||i.primKey.auto!==o.primKey.auto)a.recreate=!0,r.change.push(a);else{var u=i.idxByName,s=o.idxByName,c=void 0;for(c in u)s[c]||a.del.push(c);for(c in s){var l=u[c],f=s[c];l?l.src!==f.src&&a.change.push(f):a.add.push(f)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,o])}return r}function un(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 cn(i,e)}),i}function sn(t,n){_(t).forEach(function(e){n.db.objectStoreNames.contains(e)||(ie&&console.debug("Dexie: Creating missing table",e),un(n,e,t[e].primKey,t[e].indexes))})}function cn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function ln(e,t,u){var s={};return b(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=Vt(zt(a=t.keyPath),a||"",!0,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),r=[],i=0;i<t.indexNames.length;++i){var o=t.index(t.indexNames[i]),a=o.keyPath,o=Vt(o.name,a,!!o.unique,!!o.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(o)}s[e]=Wt(e,n,r)}),s}function fn(e,t,n){for(var r=n.db.objectStoreNames,i=0;i<r.length;++i){var o=r[i],a=n.objectStore(o);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var s=a.indexNames[u],c=a.index(s).keyPath,l="string"==typeof c?c:"["+b(c).join("+")+"]";!t[o]||(c=t[o].idxByName[l])&&(c.name=s,delete t[o].idxByName[l],t[o].idxByName[s]=c)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&f.WorkerGlobalScope&&f instanceof f.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function hn(e){return e.split(",").map(function(e,t){var n=(e=e.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return Vt(n,r||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),x(r),0===t)})}var dn=(pn.prototype._parseStoresSpec=function(r,i){_(r).forEach(function(e){if(null!==r[e]){var t=hn(r[e]),n=t.shift();if(n.unique=!0,n.multi)throw new Y.Schema("Primary key cannot be multi-valued");t.forEach(function(e){if(e.auto)throw new Y.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new Y.Schema("Index must have a name and cannot be an empty string")}),i[e]=Wt(e,n,t)}})},pn.prototype.stores=function(e){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?a(this._cfg.storesSource,e):e;var e=t._versions,n={},r={};return e.forEach(function(e){a(n,e._cfg.storesSource),r=e._cfg.dbschema={},e._parseStoresSpec(n,r)}),t._dbSchema=r,tn(t,[t._allTables,t,t.Transaction.prototype]),en(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],_(r),r),t._storeNames=_(r),this},pn.prototype.upgrade=function(e){return this._cfg.contentUpgrade=re(this._cfg.contentUpgrade||G,e),this},pn);function pn(){}function yn(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new er(tt,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function vn(e){return e&&"function"==typeof e.databases}function mn(e){return Ne(function(){return me.letThrough=!0,e()})}function bn(e){return!("from"in e)}var gn=function(e,t){if(!this){var n=new gn;return e&&"d"in e&&a(n,e),n}a(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function wn(e,t,n){var r=st(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(bn(e))return a(e,{from:t,to:n,d:1});var i=e.l,r=e.r;if(st(n,e.from)<0)return i?wn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},On(e);if(0<st(t,e.to))return r?wn(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},On(e);st(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<st(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;i&&!e.l&&_n(e,i),r&&n&&_n(e,r)}}function _n(e,t){bn(t)||function e(t,n){var r=n.from,i=n.to,o=n.l,n=n.r;wn(t,r,i),o&&e(t,o),n&&e(t,n)}(e,t)}function xn(e,t){var n=kn(t),r=n.next();if(r.done)return!1;for(var i=r.value,o=kn(e),a=o.next(i.from),u=a.value;!r.done&&!a.done;){if(st(u.from,i.to)<=0&&0<=st(u.to,i.from))return!0;st(i.from,u.from)<0?i=(r=n.next(u.from)).value:u=(a=o.next(i.from)).value}return!1}function kn(e){var n=bn(e)?null:{s:0,n:e};return{next:function(e){for(var t=0<arguments.length;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&st(e,n.n.from)<0;)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||st(e,n.n.to)<=0)return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function On(e){var t,n,r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),i=1<r?"r":r<-1?"l":"";i&&(t="r"==i?"l":"r",n=w({},e),r=e[i],e.from=r.from,e.to=r.to,e[i]=r[i],n[i]=r[t],(e[t]=n).d=Pn(n)),e.d=Pn(e)}function Pn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function En(t,n){return _(n).forEach(function(e){t[e]?_n(t[e],n[e]):t[e]=function e(t){var n,r,i={};for(n in t)m(t,n)&&(r=t[n],i[n]=!r||"object"!=typeof r||E.has(r.constructor)?r:e(r));return i}(n[e])}),t}function Kn(t,n){return t.all||n.all||Object.keys(t).some(function(e){return n[e]&&xn(n[e],t[e])})}r(gn.prototype,((F={add:function(e){return _n(this,e),this},addKey:function(e){return wn(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return wn(t,e,e)}),this},hasKey:function(e){var t=kn(this).next(e).value;return t&&st(t.from,e)<=0&&0<=st(t.to,e)}})[C]=function(){return kn(this)},F));var Sn={},jn={},An=!1;function Cn(e){En(jn,e),An||(An=!0,setTimeout(function(){An=!1,Dn(jn,!(jn={}))},0))}function Dn(e,t){void 0===t&&(t=!1);var n=new Set;if(e.all)for(var r=0,i=Object.values(Sn);r<i.length;r++)Tn(a=i[r],e,n,t);else for(var o in e){var a,u=/^idb\:\/\/(.*)\/(.*)\//.exec(o);u&&(o=u[1],u=u[2],(a=Sn["idb://".concat(o,"/").concat(u)])&&Tn(a,e,n,t))}n.forEach(function(e){return e()})}function Tn(e,t,n,r){for(var i=[],o=0,a=Object.entries(e.queries.query);o<a.length;o++){for(var u=a[o],s=u[0],c=[],l=0,f=u[1];l<f.length;l++){var h=f[l];Kn(t,h.obsSet)?h.subscribers.forEach(function(e){return n.add(e)}):r&&c.push(h)}r&&i.push([s,c])}if(r)for(var d=0,p=i;d<p.length;d++){var y=p[d],s=y[0],c=y[1];e.queries.query[s]=c}}function qn(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?Xe(h.dbOpenError):f});h.isBeingOpened=!0,h.dbOpenError=null,h.openComplete=!1;var t=h.openCanceller,d=Math.round(10*f.verno),p=!1;function e(){if(h.openCanceller!==t)throw new Y.DatabaseClosed("db.open() was cancelled")}function y(){return new _e(function(s,n){if(e(),!r)throw new Y.MissingAPI;var c=f.name,l=h.autoSchema||!d?r.open(c):r.open(c,d);if(!l)throw new Y.MissingAPI;l.onerror=Bt(n),l.onblocked=Te(f._fireOnBlocked),l.onupgradeneeded=Te(function(e){var t;v=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=Rt,v.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=Te(function(){n(new Y.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(v.onerror=Bt(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,m=e<1,f.idbdb=l.result,p&&on(f,v),rn(f,e/10,v,n))},n),l.onsuccess=Te(function(){v=null;var e,t,n,r,i,o=f.idbdb=l.result,a=b(o.objectStoreNames);if(0<a.length)try{var u=o.transaction(1===(r=a).length?r[0]:r,"readonly");if(h.autoSchema)t=o,n=u,(e=f).verno=t.version/10,n=e._dbSchema=ln(0,t,n),e._storeNames=b(t.objectStoreNames,0),en(e,[e._allTables],_(n),n);else if(fn(f,f._dbSchema,u),((i=an(ln(0,(i=f).idbdb,u),i._dbSchema)).add.length||i.change.some(function(e){return e.add.length||e.change.length}))&&!p)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),o.close(),d=o.version+1,p=!0,s(y());Zt(f,u)}catch(e){}et.push(f),o.onversionchange=Te(function(e){h.vcFired=!0,f.on("versionchange").fire(e)}),o.onclose=Te(function(e){f.on("close").fire(e)}),m&&(i=f._deps,u=c,o=i.indexedDB,i=i.IDBKeyRange,vn(o)||u===tt||yn(o,i).put({name:u}).catch(G)),s()},n)}).catch(function(e){switch(null==e?void 0:e.name){case"UnknownError":if(0<h.PR1398_maxLoop)return h.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),y();break;case"VersionError":if(0<d)return d=0,y()}return _e.reject(e)})}var n,i=h.dbReadyResolve,v=null,m=!1;return _e.race([t,("undefined"==typeof navigator?_e.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(y)]).then(function(){return e(),h.onReadyBeingFired=[],_e.resolve(mn(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(re,G);return h.onReadyBeingFired=[],_e.resolve(mn(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.openCanceller===t&&(h.onReadyBeingFired=null,h.isBeingOpened=!1)}).catch(function(e){h.dbOpenError=e;try{v&&v.abort()}catch(e){}return t===h.openCanceller&&f._close(),Xe(e)}).finally(function(){h.openComplete=!0,i()}).then(function(){var n;return m&&(n={},f.tables.forEach(function(t){t.schema.indexes.forEach(function(e){e.name&&(n["idb://".concat(f.name,"/").concat(t.name,"/").concat(e.name)]=new gn(-1/0,[[[]]]))}),n["idb://".concat(f.name,"/").concat(t.name,"/")]=n["idb://".concat(f.name,"/").concat(t.name,"/:dels")]=new gn(-1/0,[[[]]])}),Nt(Ft).fire(n),Dn(n,!0)),f})}function In(t){function e(e){return t.next(e)}var r=n(e),i=n(function(e){return t.throw(e)});function n(n){return function(e){var t=n(e),e=t.value;return t.done?e:e&&"function"==typeof e.then?e.then(r,i):x(e)?Promise.all(e).then(r,i):r(e)}}return n(e)()}function Bn(e,t,n){for(var r=x(e)?e.slice():[e],i=0;i<n;++i)r.push(t);return r}var Rn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(f){return w(w({},f),{table:function(e){var a=f.table(e),t=a.schema,u={},s=[];function c(e,t,n){var r=Xt(e),i=u[r]=u[r]||[],o=null==e?0:"string"==typeof e?1:e.length,a=0<t,a=w(w({},n),{name:a?"".concat(r,"(virtual-from:").concat(n.name,")"):n.name,lowLevelIndex:n,isVirtual:a,keyTail:t,keyLength:o,extractKey:$t(e),unique:!a&&n.unique});return i.push(a),a.isPrimaryKey||s.push(a),1<o&&c(2===o?e[0]:e.slice(0,o-1),t+1,n),i.sort(function(e,t){return e.keyTail-t.keyTail}),a}e=c(t.primaryKey.keyPath,0,t.primaryKey);u[":id"]=[e];for(var n=0,r=t.indexes;n<r.length;n++){var i=r[n];c(i.keyPath,0,i)}function l(e){var t,n=e.query.index;return n.isVirtual?w(w({},e),{query:{index:n.lowLevelIndex,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:Bn(t.lower,t.lowerOpen?f.MAX_KEY:f.MIN_KEY,n),lowerOpen:!0,upper:Bn(t.upper,t.upperOpen?f.MIN_KEY:f.MAX_KEY,n),upperOpen:!0})}}):e}return w(w({},a),{schema:w(w({},t),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[Xt(e)])&&e[0]}}),count:function(e){return a.count(l(e))},query:function(e){return a.query(l(e))},openCursor:function(t){var e=t.query.index,r=e.keyTail,n=e.isVirtual,i=e.keyLength;return n?a.openCursor(l(t)).then(function(e){return e&&o(e)}):a.openCursor(t);function o(n){return Object.create(n,{continue:{value:function(e){null!=e?n.continue(Bn(e,t.reverse?f.MAX_KEY:f.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,i).concat(t.reverse?f.MIN_KEY:f.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value:function(e,t){n.continuePrimaryKey(Bn(e,f.MAX_KEY,r),t)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===i?e[0]:e.slice(0,i)}},value:{get:function(){return n.value}}})}}})}})}};function Fn(i,o,a,u){return a=a||{},u=u||"",_(i).forEach(function(e){var t,n,r;m(o,e)?(t=i[e],n=o[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=A(t))!==A(n)?a[u+e]=o[e]:"Object"===r?Fn(t,n,a,u+e+"."):t!==n&&(a[u+e]=o[e]):t!==n&&(a[u+e]=o[e])):a[u+e]=void 0}),_(o).forEach(function(e){m(i,e)||(a[u+e]=o[e])}),a}function Mn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}var Nn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return w(w({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return w(w({},y),{mutate:function(e){var t=me.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===G)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===G&&p.fire===G)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===G)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===G)break;return t._promise("readwrite",function(){return function n(r,i,o){return y.query({trans:r,values:!1,query:{index:v,range:i},limit:o}).then(function(e){var t=e.result;return a({type:"delete",keys:t,trans:r}).then(function(e){return 0<e.numFailures?Promise.reject(e.failures[0]):t.length<o?{failures:[],numFailures:0,lastResult:void 0}:n(r,w(w({},i),{lower:t[t.length-1],lowerOpen:!0}),o)})})}(e.trans,e.range,1e4)},!0)}return y.mutate(e);function a(c){var e,t,n,l=me.trans,f=c.keys||Mn(v,c);if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?w(w({},c),{keys:f}):w({},c)).type&&(c.values=i([],c.values,!0)),c.keys&&(c.keys=i([],c.keys,!0)),e=y,n=f,("add"===(t=c).type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})).then(function(u){var s=f.map(function(e,t){var n,r,i,o=u[t],a={onerror:null,onsuccess:null};return"delete"===c.type?h.fire.call(a,e,o,l):"add"===c.type||void 0===o?(n=d.fire.call(a,e,c.values[t],l),null==e&&null!=n&&(c.keys[t]=e=n,v.outbound||P(c.values[t],v.keyPath,e))):(n=Fn(o,c.values[t]),(r=p.fire.call(a,n,e,o,l))&&(i=c.values[t],Object.keys(r).forEach(function(e){m(i,e)?i[e]=r[e]:P(i,e,r[e])}))),a});return y.mutate(c).then(function(e){for(var t=e.failures,n=e.results,r=e.numFailures,e=e.lastResult,i=0;i<f.length;++i){var o=(n||f)[i],a=s[i];null==o?a.onerror&&a.onerror(t[i]):a.onsuccess&&a.onsuccess("put"===c.type&&u[i]?c.values[i]:o)}return{failures:t,results:n,numFailures:r,lastResult:e}}).catch(function(t){return s.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function Ln(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],i=0,o=0;i<t.keys.length&&o<e.length;++i)0===st(t.keys[i],e[o])&&(r.push(n?S(t.values[i]):t.values[i]),++o);return r.length===e.length?r:null}catch(e){return null}}var Un={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return w(w({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Ln(t.keys,t.trans._cache,"clone"===t.cache);return e?_e.resolve(e):n.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?S(e):e},e})},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),n.mutate(e)}})}}}};function Vn(e,t){return"readonly"===e.trans.mode&&!!e.subscr&&!e.trans.explicit&&"disabled"!==e.trans.db._options.cache&&!t.schema.primaryKey.outbound}function zn(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var Wn={stack:"dbcore",level:0,name:"Observability",create:function(r){var b=r.schema.name,g=new gn(r.MIN_KEY,r.MAX_KEY);return w(w({},r),{transaction:function(e,t,n){if(me.subscr&&"readonly"!==t)throw new Y.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(me.querier));return r.transaction(e,t,n)},table:function(d){var p=r.table(d),y=p.schema,v=y.primaryKey,e=y.indexes,c=v.extractKey,l=v.outbound,m=v.autoIncrement&&e.filter(function(e){return e.compound&&e.keyPath.includes(v.keyPath)}),t=w(w({},p),{mutate:function(i){function o(e){return e="idb://".concat(b,"/").concat(d,"/").concat(e),n[e]||(n[e]=new gn)}var e,a,u,t=i.trans,n=i.mutatedParts||(i.mutatedParts={}),r=o(""),s=o(":dels"),c=i.type,l="deleteRange"===i.type?[i.range]:"delete"===i.type?[i.keys]:i.values.length<50?[Mn(v,i).filter(function(e){return e}),i.values]:[],f=l[0],h=l[1],l=i.trans._cache;return x(f)?(r.addKeys(f),(l="delete"===c||f.length===h.length?Ln(f,l):null)||s.addKeys(f),(l||h)&&(e=o,a=l,u=h,y.indexes.forEach(function(t){var n=e(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function i(e){return t.multiEntry&&x(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(a||u).forEach(function(e,t){var n=a&&r(a[t]),t=u&&r(u[t]);0!==st(n,t)&&(null!=n&&i(n),null!=t&&i(t))})}))):f?(h={from:f.lower,to:f.upper},s.add(h),r.add(h)):(r.add(g),s.add(g),y.indexes.forEach(function(e){return o(e.name).add(g)})),p.mutate(i).then(function(e){return!f||"add"!==i.type&&"put"!==i.type||(r.addKeys(e.results),m&&m.forEach(function(t){var n=i.values.map(function(e){return t.extractKey(e)}),r=t.keyPath.findIndex(function(e){return e===v.keyPath});e.results.forEach(function(e){return n[r]=e}),o(t.name).addKeys(n)})),t.mutatedParts=En(t.mutatedParts||{},n),e})}}),e=function(e){var t=e.query,e=t.index,t=t.range;return[e,new gn(null!==(e=t.lower)&&void 0!==e?e:r.MIN_KEY,null!==(t=t.upper)&&void 0!==t?t:r.MAX_KEY)]},f={get:function(e){return[v,new gn(e.key)]},getMany:function(e){return[v,(new gn).addKeys(e.keys)]},count:e,query:e,openCursor:e};return _(f).forEach(function(s){t[s]=function(i){var e=me.subscr,t=!!e,n=Vn(me,p)&&zn(s,i)?i.obsSet={}:e;if(t){var r=function(e){e="idb://".concat(b,"/").concat(d,"/").concat(e);return n[e]||(n[e]=new gn)},o=r(""),a=r(":dels"),e=f[s](i),t=e[0],e=e[1];if(("query"===s&&t.isPrimaryKey&&!i.values?a:r(t.name||"")).add(e),!t.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&i.values&&p.query(w(w({},i),{values:!1}));return p[s].apply(this,arguments).then(function(t){if("query"===s){if(l&&i.values)return u.then(function(e){e=e.result;return o.addKeys(e),t});var e=i.values?t.result.map(c):t.result;(i.values?o:a).addKeys(e)}else if("openCursor"===s){var n=t,r=i.values;return n&&Object.create(n,{key:{get:function(){return a.addKey(n.primaryKey),n.key}},primaryKey:{get:function(){var e=n.primaryKey;return a.addKey(e),e}},value:{get:function(){return r&&o.addKey(n.primaryKey),n.value}}})}return t})}a.add(g)}}return p[s].apply(this,arguments)}}),t}})}};function Yn(e,t,n){if(0===n.numFailures)return t;if("deleteRange"===t.type)return null;var r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;if(n.numFailures===r)return null;t=w({},t);return x(t.keys)&&(t.keys=t.keys.filter(function(e,t){return!(t in n.failures)})),"values"in t&&x(t.values)&&(t.values=t.values.filter(function(e,t){return!(t in n.failures)})),t}function $n(e,t){return n=e,(void 0===(r=t).lower||(r.lowerOpen?0<st(n,r.lower):0<=st(n,r.lower)))&&(e=e,void 0===(t=t).upper||(t.upperOpen?st(e,t.upper)<0:st(e,t.upper)<=0));var n,r}function Qn(e,h,t,n,r,i){if(!t||0===t.length)return e;var o=h.query.index,d=o.multiEntry,p=h.query.range,y=n.schema.primaryKey.extractKey,v=o.extractKey,a=(o.lowLevelIndex||o).extractKey,t=t.reduce(function(e,t){var n=e,r=[];if("add"===t.type||"put"===t.type)for(var i=new gn,o=t.values.length-1;0<=o;--o){var a,u=t.values[o],s=y(u);i.hasKey(s)||(a=v(u),(d&&x(a)?a.some(function(e){return $n(e,p)}):$n(a,p))&&(i.addKey(s),r.push(u)))}switch(t.type){case"add":n=e.concat(h.values?r:r.map(function(e){return y(e)}));break;case"put":var c=(new gn).addKeys(t.values.map(function(e){return y(e)})),n=e.filter(function(e){return!c.hasKey(h.values?y(e):e)}).concat(h.values?r:r.map(function(e){return y(e)}));break;case"delete":var l=(new gn).addKeys(t.keys);n=e.filter(function(e){return!l.hasKey(h.values?y(e):e)});break;case"deleteRange":var f=t.range;n=e.filter(function(e){return!$n(y(e),f)})}return n},e);return t===e?e:(t.sort(function(e,t){return st(a(e),a(t))||st(y(e),y(t))}),h.limit&&h.limit<1/0&&(t.length>h.limit?t.length=h.limit:e.length===h.limit&&t.length<h.limit&&(r.dirty=!0)),i?Object.freeze(t):t)}function Gn(e,t){return 0===st(e.lower,t.lower)&&0===st(e.upper,t.upper)&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function Xn(e,t){return function(e,t,n,r){if(void 0===e)return void 0!==t?-1:0;if(void 0===t)return 1;if(0===(t=st(e,t))){if(n&&r)return 0;if(n)return 1;if(r)return-1}return t}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(e,t,n,r){if(void 0===e)return void 0!==t?1:0;if(void 0===t)return-1;if(0===(t=st(e,t))){if(n&&r)return 0;if(n)return-1;if(r)return 1}return t}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function Hn(n,r,i,e){n.subscribers.add(i),e.addEventListener("abort",function(){var e,t;n.subscribers.delete(i),0===n.subscribers.size&&(e=n,t=r,setTimeout(function(){0===e.subscribers.size&&T(t,e)},3e3))})}var Jn={stack:"dbcore",level:0,name:"Cache",create:function(k){var O=k.schema.name;return w(w({},k),{transaction:function(g,w,e){var _,t,x=k.transaction(g,w,e);return"readwrite"===w&&(t=(_=new AbortController).signal,e=function(b){return function(){if(_.abort(),"readwrite"===w){for(var t=new Set,e=0,n=g;e<n.length;e++){var r=n[e],i=Sn["idb://".concat(O,"/").concat(r)];if(i){var o=k.table(r),a=i.optimisticOps.filter(function(e){return e.trans===x});if(x._explicit&&b&&x.mutatedParts)for(var u=0,s=Object.values(i.queries.query);u<s.length;u++)for(var c=0,l=(d=s[u]).slice();c<l.length;c++)Kn((p=l[c]).obsSet,x.mutatedParts)&&(T(d,p),p.subscribers.forEach(function(e){return t.add(e)}));else if(0<a.length){i.optimisticOps=i.optimisticOps.filter(function(e){return e.trans!==x});for(var f=0,h=Object.values(i.queries.query);f<h.length;f++)for(var d,p,y,v=0,m=(d=h[f]).slice();v<m.length;v++)null!=(p=m[v]).res&&x.mutatedParts&&(b&&!p.dirty?(y=Object.isFrozen(p.res),y=Qn(p.res,p.req,a,o,p,y),p.dirty?(T(d,p),p.subscribers.forEach(function(e){return t.add(e)})):y!==p.res&&(p.res=y,p.promise=_e.resolve({result:y}))):(p.dirty&&T(d,p),p.subscribers.forEach(function(e){return t.add(e)})))}}}t.forEach(function(e){return e()})}}},x.addEventListener("abort",e(!1),{signal:t}),x.addEventListener("error",e(!1),{signal:t}),x.addEventListener("complete",e(!0),{signal:t})),x},table:function(c){var l=k.table(c),i=l.schema.primaryKey;return w(w({},l),{mutate:function(t){var e=me.trans;if(i.outbound||"disabled"===e.db._options.cache||e.explicit)return l.mutate(t);var n=Sn["idb://".concat(O,"/").concat(c)];if(!n)return l.mutate(t);e=l.mutate(t);return"add"!==t.type&&"put"!==t.type||!(50<=t.values.length||Mn(i,t).some(function(e){return null==e}))?(n.optimisticOps.push(t),t.mutatedParts&&Cn(t.mutatedParts),e.then(function(e){0<e.numFailures&&(T(n.optimisticOps,t),(e=Yn(0,t,e))&&n.optimisticOps.push(e),t.mutatedParts&&Cn(t.mutatedParts))}),e.catch(function(){T(n.optimisticOps,t),t.mutatedParts&&Cn(t.mutatedParts)})):e.then(function(r){var e=Yn(0,w(w({},t),{values:t.values.map(function(e,t){var n,e=null!==(n=i.keyPath)&&void 0!==n&&n.includes(".")?S(e):w({},e);return P(e,i.keyPath,r.results[t]),e})}),r);n.optimisticOps.push(e),queueMicrotask(function(){return t.mutatedParts&&Cn(t.mutatedParts)})}),e},query:function(t){if(!Vn(me,l)||!zn("query",t))return l.query(t);var i="immutable"===(null===(o=me.trans)||void 0===o?void 0:o.db._options.cache),e=me,n=e.requery,r=e.signal,o=function(e,t,n,r){var i=Sn["idb://".concat(e,"/").concat(t)];if(!i)return[];if(!(t=i.queries[n]))return[null,!1,i,null];var o=t[(r.query?r.query.index.name:null)||""];if(!o)return[null,!1,i,null];switch(n){case"query":var a=o.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&Gn(e.req.query.range,r.query.range)});return a?[a,!0,i,o]:[o.find(function(e){return("limit"in e.req?e.req.limit:1/0)>=r.limit&&(!r.values||e.req.values)&&Xn(e.req.query.range,r.query.range)}),!1,i,o];case"count":a=o.find(function(e){return Gn(e.req.query.range,r.query.range)});return[a,!!a,i,o]}}(O,c,"query",t),a=o[0],e=o[1],u=o[2],s=o[3];return a&&e?a.obsSet=t.obsSet:(e=l.query(t).then(function(e){var t=e.result;if(a&&(a.res=t),i){for(var n=0,r=t.length;n<r;++n)Object.freeze(t[n]);Object.freeze(t)}else e.result=S(t);return e}).catch(function(e){return s&&a&&T(s,a),Promise.reject(e)}),a={obsSet:t.obsSet,promise:e,subscribers:new Set,type:"query",req:t,dirty:!1},s?s.push(a):(s=[a],(u=u||(Sn["idb://".concat(O,"/").concat(c)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[t.query.index.name||""]=s)),Hn(a,s,n,r),a.promise.then(function(e){return{result:Qn(e.result,t,null==u?void 0:u.optimisticOps,l,a,i)}})}})}})}};function Zn(e,r){return new Proxy(e,{get:function(e,t,n){return"db"===t?r:Reflect.get(e,t,n)}})}var er=(tr.prototype.version=function(t){if(isNaN(t)||t<.1)throw new Y.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new Y.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);var e=this._versions,n=e.filter(function(e){return e._cfg.version===t})[0];return n||(n=new this.Version(t),e.push(n),e.sort(nn),n.stores({}),this._state.autoSchema=!1,n)},tr.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||me.letThrough||this._vip)?e():new _e(function(e,t){if(n._state.openComplete)return t(new Y.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._state.autoOpen)return void t(new Y.DatabaseClosed);n.open().catch(G)}n._state.dbReadyPromise.then(e,t)}).then(e)},tr.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,i=e.name;i&&this.unuse({stack:t,name:i});e=this._middlewares[t]||(this._middlewares[t]=[]);return e.push({stack:t,create:n,level:null==r?10:r,name:i}),e.sort(function(e,t){return e.level-t.level}),this},tr.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},tr.prototype.open=function(){var e=this;return $e(ve,function(){return qn(e)})},tr.prototype._close=function(){var n=this._state,e=et.indexOf(this);if(0<=e&&et.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this.idbdb=null}n.isBeingOpened||(n.dbReadyPromise=new _e(function(e){n.dbReadyResolve=e}),n.openCanceller=new _e(function(e,t){n.cancelOpen=t}))},tr.prototype.close=function(e){var t=(void 0===e?{disableAutoOpen:!0}:e).disableAutoOpen,e=this._state;t?(e.isBeingOpened&&e.cancelOpen(new Y.DatabaseClosed),this._close(),e.autoOpen=!1,e.dbOpenError=new Y.DatabaseClosed):(this._close(),e.autoOpen=this._options.autoOpen||e.isBeingOpened,e.openComplete=!1,e.dbOpenError=null)},tr.prototype.delete=function(n){var i=this;void 0===n&&(n={disableAutoOpen:!0});var o=0<arguments.length&&"object"!=typeof arguments[0],a=this._state;return new _e(function(r,t){function e(){i.close(n);var e=i._deps.indexedDB.deleteDatabase(i.name);e.onsuccess=Te(function(){var e,t,n;e=i._deps,t=i.name,n=e.indexedDB,e=e.IDBKeyRange,vn(n)||t===tt||yn(n,e).delete(t).catch(G),r()}),e.onerror=Bt(t),e.onblocked=i._fireOnBlocked}if(o)throw new Y.InvalidArgument("Invalid closeOptions argument to db.delete()");a.isBeingOpened?a.dbReadyPromise.then(e):e()})},tr.prototype.backendDB=function(){return this.idbdb},tr.prototype.isOpen=function(){return null!==this.idbdb},tr.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},tr.prototype.hasFailed=function(){return null!==this._state.dbOpenError},tr.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(tr.prototype,"tables",{get:function(){var t=this;return _(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),tr.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new Y.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,O(i),n]}.apply(this,arguments);return this._transaction.apply(this,e)},tr.prototype._transaction=function(e,t,n){var r=this,i=me.trans;i&&i.db===this&&-1===e.indexOf("!")||(i=null);var o,a,u=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=t.map(function(e){e=e instanceof r.Table?e.name:e;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e}),"r"==e||e===nt)o=nt;else{if("rw"!=e&&e!=rt)throw new Y.InvalidArgument("Invalid transaction mode: "+e);o=rt}if(i){if(i.mode===nt&&o===rt){if(!u)throw new Y.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(function(e){if(i&&-1===i.storeNames.indexOf(e)){if(!u)throw new Y.SubTransaction("Table "+e+" not included in parent transaction.");i=null}}),u&&i&&!i.active&&(i=null)}}catch(n){return i?i._promise(null,function(e,t){t(n)}):Xe(n)}var s=function i(o,a,u,s,c){return _e.resolve().then(function(){var e=me.transless||me,t=o._createTransaction(a,u,o._dbSchema,s);if(t.explicit=!0,e={trans:t,transless:e},s)t.idbtrans=s.idbtrans;else try{t.create(),t.idbtrans._explicit=!0,o._state.PR1398_maxLoop=3}catch(e){return e.name===z.InvalidState&&o.isOpen()&&0<--o._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),o.close({disableAutoOpen:!1}),o.open().then(function(){return i(o,a,u,null,c)})):Xe(e)}var n,r=B(c);return r&&Le(),e=_e.follow(function(){var e;(n=c.call(t,t))&&(r?(e=Ue.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=In(n)))},e),(n&&"function"==typeof n.then?_e.resolve(n).then(function(e){return t.active?e:Xe(new Y.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):e.then(function(){return n})).then(function(e){return s&&t._resolve(),t._completion.then(function(){return e})}).catch(function(e){return t._reject(e),Xe(e)})})}.bind(null,this,o,a,i,n);return i?i._promise(o,s,"lock"):me.trans?$e(me.transless,function(){return r._whenReady(s)}):this._whenReady(s)},tr.prototype.table=function(e){if(!m(this._allTables,e))throw new Y.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},tr);function tr(e,t){var o=this;this._middlewares={},this.verno=0;var n=tr.dependencies;this._options=t=w({addons:tr.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};n=t.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var a,r,u,i,s,c={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:G,dbReadyPromise:null,cancelOpen:G,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen};c.dbReadyPromise=new _e(function(e){c.dbReadyResolve=e}),c.openCanceller=new _e(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=dt(this,"populate","blocked","versionchange","close",{ready:[re,G]}),this.on.ready.subscribe=p(this.on.ready.subscribe,function(i){return function(n,r){tr.vip(function(){var t,e=o._state;e.openComplete?(e.dbOpenError||_e.resolve().then(n),r&&i(n)):e.onReadyBeingFired?(e.onReadyBeingFired.push(n),r&&i(n)):(i(n),t=o,r||i(function e(){t.on.ready.unsubscribe(n),t.on.ready.unsubscribe(e)}))})}}),this.Collection=(a=this,pt(Ot.prototype,function(e,t){this.db=a;var n=ot,r=null;if(t)try{n=t()}catch(e){r=e}var i=e._ctx,t=i.table,e=t.hook.reading.fire;this._ctx={table:t,index:i.index,isPrimKey:!i.index||t.schema.primKey.keyPath&&i.index===t.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:e!==X?e:null}})),this.Table=(r=this,pt(ft.prototype,function(e,t,n){this.db=r,this._tx=n,this.name=e,this.schema=t,this.hook=r._allTables[e]?r._allTables[e].hook:dt(null,{creating:[Z,G],reading:[H,X],updating:[te,G],deleting:[ee,G]})})),this.Transaction=(u=this,pt(Lt.prototype,function(e,t,n,r,i){var o=this;this.db=u,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=dt(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 _e(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(),Xe(e)})})),this.Version=(i=this,pt(dn.prototype,function(e){this.db=i,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,pt(qt.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=st,this._descending=function(e,t){return st(t,e)},this._max=function(e,t){return 0<st(e,t)?e:t},this._min=function(e,t){return st(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange,!this._IDBKeyRange)throw new Y.MissingAPI})),this.on("versionchange",function(e){0<e.newVersion?console.warn("Another connection wants to upgrade database '".concat(o.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(o.name,"'. Closing db now to resume the delete request.")),o.close({disableAutoOpen:!1})}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(o.name,"') was blocked")):console.warn("Upgrade '".concat(o.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=Yt(t.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new o.Transaction(e,t,n,o._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(t){o.on("blocked").fire(t),et.filter(function(e){return e.name===o.name&&e!==o&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Un),this.use(Jn),this.use(Wn),this.use(Rn),this.use(Nn);var l=new Proxy(this,{get:function(e,t,n){if("_vip"===t)return!0;if("table"===t)return function(e){return Zn(o.table(e),l)};var r=Reflect.get(e,t,n);return r instanceof ft?Zn(r,l):"tables"===t?r.map(function(e){return Zn(e,l)}):"_createTransaction"===t?function(){return Zn(r.apply(this,arguments),l)}:r}});this.vip=l,n.forEach(function(e){return e(o)})}var nr,F="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",rr=(ir.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},ir.prototype[F]=function(){return this},ir);function ir(e){this._subscribe=e}try{nr={indexedDB:f.indexedDB||f.mozIndexedDB||f.webkitIndexedDB||f.msIndexedDB,IDBKeyRange:f.IDBKeyRange||f.webkitIDBKeyRange}}catch(e){nr={indexedDB:null,IDBKeyRange:null}}function or(h){var d,p=!1,e=new rr(function(r){var i=B(h);var o,a=!1,u={},s={},e={get closed(){return a},unsubscribe:function(){a||(a=!0,o&&o.abort(),c&&Nt.storagemutated.unsubscribe(f))}};r.start&&r.start(e);var c=!1,l=function(){return Ge(t)};var f=function(e){En(u,e),Kn(s,u)&&l()},t=function(){var t,n,e;!a&&nr.indexedDB&&(u={},t={},o&&o.abort(),o=new AbortController,e=function(e){var t=je();try{i&&Le();var n=Ne(h,e);return n=i?n.finally(Ue):n}finally{t&&Ae()}}(n={subscr:t,signal:o.signal,requery:l,querier:h,trans:null}),Promise.resolve(e).then(function(e){p=!0,d=e,a||n.signal.aborted||(u={},function(e){for(var t in e)if(m(e,t))return;return 1}(s=t)||c||(Nt(Ft,f),c=!0),Ge(function(){return!a&&r.next&&r.next(e)}))},function(e){p=!1,["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||a||Ge(function(){a||r.error&&r.error(e)})}))};return setTimeout(l,0),e});return e.hasValue=function(){return p},e.getValue=function(){return d},e}var ar=er;function ur(e){var t=cr;try{cr=!0,Nt.storagemutated.fire(e),Dn(e,!0)}finally{cr=t}}r(ar,w(w({},Q),{delete:function(e){return new ar(e,{addons:[]}).delete()},exists:function(e){return new ar(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=ar.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(vn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==tt})}):yn(n,t).toCollection().primaryKeys()).then(e)}catch(e){return Xe(new Y.MissingAPI)}var t,n},defineClass:function(){return function(e){a(this,e)}},ignoreTransaction:function(e){return me.trans?$e(me.transless,e):e()},vip:mn,async:function(t){return function(){try{var e=In(t.apply(this,arguments));return e&&"function"==typeof e.then?e:_e.resolve(e)}catch(e){return Xe(e)}}},spawn:function(e,t,n){try{var r=In(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:_e.resolve(r)}catch(e){return Xe(e)}},currentTransaction:{get:function(){return me.trans||null}},waitFor:function(e,t){t=_e.resolve("function"==typeof e?ar.ignoreTransaction(e):e).timeout(t||6e4);return me.trans?me.trans.waitFor(t):t},Promise:_e,debug:{get:function(){return ie},set:function(e){oe(e)}},derive:o,extend:a,props:r,override:p,Events:dt,on:Nt,liveQuery:or,extendObservabilitySet:En,getByKeyPath:k,setByKeyPath:P,delByKeyPath:function(t,e){"string"==typeof e?P(t,e,void 0):"length"in e&&[].map.call(e,function(e){P(t,e,void 0)})},shallowClone:g,deepClone:S,getObjectDiff:Fn,cmp:st,asap:v,minKey:-1/0,addons:[],connections:et,errnames:z,dependencies:nr,cache:Sn,semVer:"4.0.8",version:"4.0.8".split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),ar.maxKey=Yt(ar.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Nt(Ft,function(e){cr||(e=new CustomEvent(Mt,{detail:e}),cr=!0,dispatchEvent(e),cr=!1)}),addEventListener(Mt,function(e){e=e.detail;cr||ur(e)}));var sr,cr=!1,lr=function(){};return"undefined"!=typeof BroadcastChannel&&((lr=function(){(sr=new BroadcastChannel(Mt)).onmessage=function(e){return e.data&&ur(e.data)}})(),"function"==typeof sr.unref&&sr.unref(),Nt(Ft,function(e){cr||sr.postMessage(e)})),"undefined"!=typeof addEventListener&&(addEventListener("pagehide",function(e){if(!er.disableBfCache&&e.persisted){ie&&console.debug("Dexie: handling persisted pagehide"),null!=sr&&sr.close();for(var t=0,n=et;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!er.disableBfCache&&e.persisted&&(ie&&console.debug("Dexie: handling persisted pageshow"),lr(),ur({all:new gn(-1/0,[[]])}))})),_e.rejectionMapper=function(e,t){return!e||e instanceof N||e instanceof TypeError||e instanceof SyntaxError||!e.name||!$[e.name]?e:(t=new $[e.name](t||e.message,e),"stack"in e&&l(t,"stack",{get:function(){return this.inner.stack}}),t)},oe(ie),w(er,Object.freeze({__proto__:null,Dexie:er,liveQuery:or,Entity:ut,cmp:st,PropModSymbol:e,PropModification:xt,replacePrefix:function(e,t){return new xt({replacePrefix:[e,t]})},add:function(e){return new xt({add:e})},remove:function(e){return new xt({remove:e})},default:er,RangeSet:gn,mergeRanges:_n,rangesOverlap:xn}),{default:er}),er});
1
+ (function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Dexie=t()})(this,function(){"use strict";var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var w=function(){return(w=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function B(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return{value:(e=e&&r>=e.length?void 0:e)&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function k(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||0<t--)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function m(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||((r=r||Array.prototype.slice.call(t,0,o))[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,P=Object.keys,x=Array.isArray;function a(t,n){return"object"!=typeof n||P(n).forEach(function(e){t[e]=n[e]}),t}"undefined"==typeof Promise||f.Promise||(f.Promise=Promise);var d=Object.getPrototypeOf,n={}.hasOwnProperty;function b(e,t){return n.call(e,t)}function o(t,n){"function"==typeof n&&(n=n(d(t))),("undefined"==typeof Reflect?P:Reflect.ownKeys)(n).forEach(function(e){c(t,e,n[e])})}var u=Object.defineProperty;function c(e,t,n,r){u(e,t,a(n&&b(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function i(t){return{from:function(e){return t.prototype=Object.create(e.prototype),c(t.prototype,"constructor",t),{extend:o.bind(null,t.prototype)}}}}var l=Object.getOwnPropertyDescriptor;var h=[].slice;function g(e,t,n){return h.call(e,t,n)}function p(e,t){return t(e)}function y(e){if(!e)throw new Error("Assertion Failed")}function v(e){f.setImmediate?setImmediate(e):setTimeout(e,0)}function O(e,t){if("string"==typeof t&&b(e,t))return e[t];if(!t)return e;if("string"!=typeof t){for(var n=[],r=0,o=t.length;r<o;++r){var i=O(e,t[r]);n.push(i)}return n}var a=t.indexOf(".");if(-1!==a){var u=e[t.substr(0,a)];return null==u?void 0:O(u,t.substr(a+1))}}function E(e,t,n){if(e&&void 0!==t&&!("isFrozen"in Object&&Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){y("string"!=typeof n&&"length"in n);for(var r=0,o=t.length;r<o;++r)E(e,t[r],n[r])}else{var i,a,u=t.indexOf(".");-1!==u?(i=t.substr(0,u),""===(a=t.substr(u+1))?void 0===n?x(e)&&!isNaN(parseInt(i))?e.splice(i,1):delete e[i]:e[i]=n:E(u=!(u=e[i])||!b(e,i)?e[i]={}:u,a,n)):void 0===n?x(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function _(e){var t,n={};for(t in e)b(e,t)&&(n[t]=e[t]);return n}var t=[].concat;function S(e){return t.apply([],e)}var e="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(S([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(e){return f[e]}),K=new Set(e.map(function(e){return f[e]}));var C=null;function j(e){C=new WeakMap;e=function e(t){if(!t||"object"!=typeof t)return t;var n=C.get(t);if(n)return n;if(x(t)){n=[],C.set(t,n);for(var r=0,o=t.length;r<o;++r)n.push(e(t[r]))}else if(K.has(t.constructor))n=t;else{var i,a=d(t);for(i in n=a===Object.prototype?{}:Object.create(a),C.set(t,n),t)b(t,i)&&(n[i]=e(t[i]))}return n}(e);return C=null,e}var A={}.toString;function T(e){return A.call(e).slice(8,-1)}var D="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",I="symbol"==typeof D?function(e){var t;return null!=e&&(t=e[D])&&t.apply(e)}:function(){return null};function R(e,t){t=e.indexOf(t);return 0<=t&&e.splice(t,1),0<=t}var q={};function M(e){var t,n,r,o;if(1===arguments.length){if(x(e))return e.slice();if(this===q&&"string"==typeof e)return[e];if(o=I(e)){for(n=[];!(r=o.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"!=typeof(t=e.length))return[e];for(n=new Array(t);t--;)n[t]=e[t];return n}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var F="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},N=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],U=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(N),L={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Y(e,t){this.name=e,this.message=t}function V(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 z(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=V(e,t)}function W(e,t){this.name="BulkError",this.failures=Object.keys(t).map(function(e){return t[e]}),this.failuresByPos=t,this.message=V(e,this.failures)}i(Y).from(Error).extend({toString:function(){return this.name+": "+this.message}}),i(z).from(Y),i(W).from(Y);var $=U.reduce(function(e,t){return e[t]=t+"Error",e},{}),G=Y,H=U.reduce(function(e,n){var r=n+"Error";function t(e,t){this.name=r,e?"string"==typeof e?(this.message="".concat(e).concat(t?"\n "+t:""),this.inner=t||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=L[n]||r,this.inner=null)}return i(t).from(G),e[n]=t,e},{});H.Syntax=SyntaxError,H.Type=TypeError,H.Range=RangeError;var Q=N.reduce(function(e,t){return e[t+"Error"]=H[t],e},{});var X=U.reduce(function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=H[t]),e},{});function J(){}function Z(e){return e}function ee(t,n){return null==t||t===Z?n:function(e){return n(t(e))}}function te(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ne(o,i){return o===J?i:function(){var e=o.apply(this,arguments);void 0!==e&&(arguments[0]=e);var t=this.onsuccess,n=this.onerror;this.onsuccess=null,this.onerror=null;var r=i.apply(this,arguments);return t&&(this.onsuccess=this.onsuccess?te(t,this.onsuccess):t),n&&(this.onerror=this.onerror?te(n,this.onerror):n),void 0!==r?r:e}}function re(n,r){return n===J?r:function(){n.apply(this,arguments);var e=this.onsuccess,t=this.onerror;this.onsuccess=this.onerror=null,r.apply(this,arguments),e&&(this.onsuccess=this.onsuccess?te(e,this.onsuccess):e),t&&(this.onerror=this.onerror?te(t,this.onerror):t)}}function oe(o,i){return o===J?i:function(e){var t=o.apply(this,arguments);a(e,t);var n=this.onsuccess,r=this.onerror;this.onsuccess=null,this.onerror=null;e=i.apply(this,arguments);return n&&(this.onsuccess=this.onsuccess?te(n,this.onsuccess):n),r&&(this.onerror=this.onerror?te(r,this.onerror):r),void 0===t?void 0===e?void 0:e:a(t,e)}}function ie(e,t){return e===J?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function ae(o,i){return o===J?i:function(){var e=o.apply(this,arguments);if(e&&"function"==typeof e.then){for(var t=this,n=arguments.length,r=new Array(n);n--;)r[n]=arguments[n];return e.then(function(){return i.apply(t,r)})}return i.apply(this,arguments)}}X.ModifyError=z,X.DexieError=Y,X.BulkError=W;var ue="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function se(e){ue=e}var ce={},le=100,e="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,d(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,d(t),e]}(),N=e[0],U=e[1],e=e[2],U=U&&U.then,fe=N&&N.constructor,he=!!e;var de=function(e,t){_e.push([e,t]),ye&&(queueMicrotask(Ae),ye=!1)},pe=!0,ye=!0,ve=[],me=[],be=Z,ge={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:J,pgp:!1,env:{},finalize:J},we=ge,_e=[],xe=0,ke=[];function Pe(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=we;if("function"!=typeof e){if(e!==ce)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Se(this,this._value))}this._state=null,this._value=null,++t.ref,function t(r,e){try{e(function(n){if(null===r._state){if(n===r)throw new TypeError("A promise cannot be resolved with itself.");var e=r._lib&&Te();n&&"function"==typeof n.then?t(r,function(e,t){n instanceof Pe?n._then(e,t):n.then(e,t)}):(r._state=!0,r._value=n,Ke(r)),e&&De()}},Se.bind(null,r))}catch(e){Se(r,e)}}(this,e)}var Oe={get:function(){var u=we,t=Ue;function e(n,r){var o=this,i=!u.global&&(u!==we||t!==Ue),a=i&&!ze(),e=new Pe(function(e,t){Ce(o,new Ee(Xe(n,u,i,a),Xe(r,u,i,a),e,t,u))});return this._consoleTask&&(e._consoleTask=this._consoleTask),e}return e.prototype=ce,e},set:function(e){c(this,"then",e&&e.prototype===ce?Oe:{get:function(){return e},set:Oe.set})}};function Ee(e,t,n,r,o){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r,this.psd=o}function Se(e,t){var n,r;me.push(t),null===e._state&&(n=e._lib&&Te(),t=be(t),e._state=!1,e._value=t,r=e,ve.some(function(e){return e._value===r._value})||ve.push(r),Ke(e),n&&De())}function Ke(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Ce(e,t[n]);var o=e._PSD;--o.ref||o.finalize(),0===xe&&(++xe,de(function(){0==--xe&&Ie()},[]))}function Ce(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,++xe,de(je,[n,e,t])}else e._listeners.push(t)}function je(e,t,n){try{var r,o=t._value;!t._state&&me.length&&(me=[]),r=ue&&t._consoleTask?t._consoleTask.run(function(){return e(o)}):e(o),t._state||-1!==me.indexOf(o)||function(e){var t=ve.length;for(;t;)if(ve[--t]._value===e._value)return ve.splice(t,1)}(t),n.resolve(r)}catch(e){n.reject(e)}finally{0==--xe&&Ie(),--n.psd.ref||n.psd.finalize()}}function Ae(){Qe(ge,function(){Te()&&De()})}function Te(){var e=pe;return ye=pe=!1,e}function De(){var e,t,n;do{for(;0<_e.length;)for(e=_e,_e=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(0<_e.length);ye=pe=!0}function Ie(){var e=ve;ve=[],e.forEach(function(e){e._PSD.onunhandled.call(null,e._value,e)});for(var t=ke.slice(0),n=t.length;n;)t[--n]()}function qe(e){return new Pe(ce,!1,e)}function Be(n,r){var o=we;return function(){var e=Te(),t=we;try{return Ge(o,!0),n.apply(this,arguments)}catch(e){r&&r(e)}finally{Ge(t,!1),e&&De()}}}o(Pe.prototype,{then:Oe,_then:function(e,t){Ce(this,new Ee(null,null,e,t,we))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=e,n=arguments[1];return"function"==typeof t?this.then(null,function(e){return(e instanceof t?n:qe)(e)}):this.then(null,function(e){return(e&&e.name===t?n:qe)(e)})},finally:function(t){return this.then(function(e){return Pe.resolve(t()).then(function(){return e})},function(e){return Pe.resolve(t()).then(function(){return qe(e)})})},timeout:function(r,o){var i=this;return r<1/0?new Pe(function(e,t){var n=setTimeout(function(){return t(new H.Timeout(o))},r);i.then(e,t).finally(clearTimeout.bind(null,n))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&c(Pe.prototype,Symbol.toStringTag,"Dexie.Promise"),ge.env=He(),o(Pe,{all:function(){var i=M.apply(null,arguments).map(We);return new Pe(function(n,r){0===i.length&&n([]);var o=i.length;i.forEach(function(e,t){return Pe.resolve(e).then(function(e){i[t]=e,--o||n(i)},r)})})},resolve:function(n){return n instanceof Pe?n:n&&"function"==typeof n.then?new Pe(function(e,t){n.then(e,t)}):new Pe(ce,!0,n)},reject:qe,race:function(){var e=M.apply(null,arguments).map(We);return new Pe(function(t,n){e.map(function(e){return Pe.resolve(e).then(t,n)})})},PSD:{get:function(){return we},set:function(e){return we=e}},totalEchoes:{get:function(){return Ue}},newPSD:Ye,usePSD:Qe,scheduler:{get:function(){return de},set:function(e){de=e}},rejectionMapper:{get:function(){return be},set:function(e){be=e}},follow:function(o,n){return new Pe(function(e,t){return Ye(function(n,r){var e=we;e.unhandleds=[],e.onunhandled=r,e.finalize=te(function(){var t,e=this;t=function(){0===e.unhandleds.length?n():r(e.unhandleds[0])},ke.push(function e(){t(),ke.splice(ke.indexOf(e),1)}),++xe,de(function(){0==--xe&&Ie()},[])},e.finalize),o()},n,e,t)})}}),fe&&(fe.allSettled&&c(Pe,"allSettled",function(){var e=M.apply(null,arguments).map(We);return new Pe(function(n){0===e.length&&n([]);var r=e.length,o=new Array(r);e.forEach(function(e,t){return Pe.resolve(e).then(function(e){return o[t]={status:"fulfilled",value:e}},function(e){return o[t]={status:"rejected",reason:e}}).then(function(){return--r||n(o)})})})}),fe.any&&"undefined"!=typeof AggregateError&&c(Pe,"any",function(){var e=M.apply(null,arguments).map(We);return new Pe(function(n,r){0===e.length&&r(new AggregateError([]));var o=e.length,i=new Array(o);e.forEach(function(e,t){return Pe.resolve(e).then(function(e){return n(e)},function(e){i[t]=e,--o||r(new AggregateError(i))})})})}));var Re={awaits:0,echoes:0,id:0},Me=0,Fe=[],Ne=0,Ue=0,Le=0;function Ye(e,t,n,r){var o=we,i=Object.create(o);i.parent=o,i.ref=0,i.global=!1,i.id=++Le,ge.env,i.env=he?{Promise:Pe,PromiseProp:{value:Pe,configurable:!0,writable:!0},all:Pe.all,race:Pe.race,allSettled:Pe.allSettled,any:Pe.any,resolve:Pe.resolve,reject:Pe.reject}:{},t&&a(i,t),++o.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};r=Qe(i,e,n,r);return 0===i.ref&&i.finalize(),r}function Ve(){return Re.id||(Re.id=++Me),++Re.awaits,Re.echoes+=le,Re.id}function ze(){return!!Re.awaits&&(0==--Re.awaits&&(Re.id=0),Re.echoes=Re.awaits*le,!0)}function We(e){return Re.echoes&&e&&e.constructor===fe?(Ve(),e.then(function(e){return ze(),e},function(e){return ze(),Ze(e)})):e}function $e(){var e=Fe[Fe.length-1];Fe.pop(),Ge(e,!1)}function Ge(e,t){var n,r=we;(t?!Re.echoes||Ne++&&e===we:!Ne||--Ne&&e===we)||queueMicrotask(t?function(e){++Ue,Re.echoes&&0!=--Re.echoes||(Re.echoes=Re.awaits=Re.id=0),Fe.push(we),Ge(e,!0)}.bind(null,e):$e),e!==we&&(we=e,r===ge&&(ge.env=He()),he&&(n=ge.env.Promise,t=e.env,(r.global||e.global)&&(Object.defineProperty(f,"Promise",t.PromiseProp),n.all=t.all,n.race=t.race,n.resolve=t.resolve,n.reject=t.reject,t.allSettled&&(n.allSettled=t.allSettled),t.any&&(n.any=t.any))))}function He(){var e=f.Promise;return he?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(f,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function Qe(e,t,n,r,o){var i=we;try{return Ge(e,!0),t(n,r,o)}finally{Ge(i,!1)}}function Xe(t,n,r,o){return"function"!=typeof t?t:function(){var e=we;r&&Ve(),Ge(n,!0);try{return t.apply(this,arguments)}finally{Ge(e,!1),o&&queueMicrotask(ze)}}}function Je(e){Promise===fe&&0===Re.echoes?0===Ne?e():enqueueNativeMicroTask(e):setTimeout(e,0)}-1===(""+U).indexOf("[native code]")&&(Ve=ze=J);var Ze=Pe.reject;var N="4.1.0-alpha.12",et=String.fromCharCode(65535),tt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",nt="String expected.",rt=[],ot="__dbnames",it="readonly",at="readwrite";function ut(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var st={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ct(t){return"string"!=typeof t||/\./.test(t)?function(e){return e}:function(e){return void 0===e[t]&&t in e&&delete(e=j(e))[t],e}}function lt(){throw H.Type()}function ft(e,t){try{var n=ht(e),r=ht(t);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return t<e?1:e<t?-1:0;case"binary":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i)if(e[i]!==t[i])return e[i]<t[i]?-1:1;return n===r?0:n<r?-1:1}(dt(e),dt(t));case"Array":return function(e,t){for(var n=e.length,r=t.length,o=n<r?n:r,i=0;i<o;++i){var a=ft(e[i],t[i]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function ht(e){var t=typeof e;if("object"!=t)return t;if(ArrayBuffer.isView(e))return"binary";e=T(e);return"ArrayBuffer"===e?"binary":e}function dt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}function pt(e){var t;return null!==(e=(t=e._novip)._docCache)&&void 0!==e?e:t._docCache={cache:{},get size(){return Object.keys(this.cache).length},find:function(e,t,n){n=bt(e,t,n),n=this.cache[n];return n?n.deref():void 0},add:function(e){var t=e.meta,n=t.parentTable,r=t.parentId,t=t.parentProp;if(!n||!t||null==r)throw new Error("Missing Dexie-related metadata in Y.Doc");t=bt(n,r,t);this.cache[t]=new WeakRef(e),yt.register(e,{cache:this.cache,key:t})},delete:function(e){yt.unregister(e),delete this.cache[bt(e.meta.parentTable,e.meta.parentId,e.meta.parentProp)]}}}var yt=new FinalizationRegistry(function(e){delete e.cache[e.key]}),vt=new WeakSet;function mt(e){if(vt.has(e))throw new Error("Y.Doc has been destroyed")}function bt(e,t,n){return"".concat(e,"[").concat(t,"].").concat(n)}function gt(t,n,r){var e=t.schema.yProps;return e?(n&&0<r.numFailures&&(n=n.filter(function(e,t){return!r.failures[t]})),Promise.all(e.map(function(e){e=e.updatesTable;return n?t.db.table(e).where("k").anyOf(n).delete():t.db.table(e).clear()})).then(function(){return r})):r}function wt(e){e=e._options.Y;if(!e)throw new H.MissingAPI("Y library not supplied to Dexie constructor");return e}var _t=(xt.prototype._trans=function(e,r,t){var n=this._tx||we.trans,o=this.name,i=ue&&"undefined"!=typeof console&&console.createTask&&console.createTask("Dexie: ".concat("readonly"===e?"read":"write"," ").concat(this.name));function a(e,t,n){if(!n.schema[o])throw new H.NotFound("Table "+o+" not part of transaction");return r(n.idbtrans,n)}var u=Te();try{var s=n&&n.db._novip===this.db._novip?n===we.trans?n._promise(e,a,t):Ye(function(){return n._promise(e,a,t)},{trans:n,transless:we.transless||we}):function t(n,r,o,i){if(n.idbdb&&(n._state.openComplete||we.letThrough||n._vip)){var a=n._createTransaction(r,o,n._dbSchema);try{a.create(),n._state.PR1398_maxLoop=3}catch(e){return e.name===$.InvalidState&&n.isOpen()&&0<--n._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),n.close({disableAutoOpen:!1}),n.open().then(function(){return t(n,r,o,i)})):Ze(e)}return a._promise(r,function(e,t){return Ye(function(){return we.trans=a,i(e,t,a)})}).then(function(e){if("readwrite"===r)try{a.idbtrans.commit()}catch(e){}return"readonly"===r?e:a._completion.then(function(){return e})})}if(n._state.openComplete)return Ze(new H.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._state.autoOpen)return Ze(new H.DatabaseClosed);n.open().catch(J)}return n._state.dbReadyPromise.then(function(){return t(n,r,o,i)})}(this.db,e,[this.name],a);return i&&(s._consoleTask=i,s=s.catch(function(e){return console.trace(e),Ze(e)})),s}finally{u&&De()}},xt.prototype.get=function(t,e){var n=this;return t&&t.constructor===Object?this.where(t).first(e):null==t?Ze(new H.Type("Invalid argument to Table.get()")):this._trans("readonly",function(e){return n.core.get({trans:e,key:t}).then(function(e){return n.hook.reading.fire(e)})}).then(e)},xt.prototype.where=function(i){if("string"==typeof i)return new this.db.WhereClause(this,i);if(x(i))return new this.db.WhereClause(this,"[".concat(i.join("+"),"]"));var n=P(i);if(1===n.length)return this.where(n[0]).equals(i[n[0]]);var e=this.schema.indexes.concat(this.schema.primKey).filter(function(t){if(t.compound&&n.every(function(e){return 0<=t.keyPath.indexOf(e)})){for(var e=0;e<n.length;++e)if(-1===n.indexOf(t.keyPath[e]))return!1;return!0}return!1}).sort(function(e,t){return e.keyPath.length-t.keyPath.length})[0];if(e&&this.db._maxKey!==et){var t=e.keyPath.slice(0,n.length);return this.where(t).equals(t.map(function(e){return i[e]}))}!e&&ue&&console.warn("The query ".concat(JSON.stringify(i)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(n.join("+"),"]"));var a=this.schema.idxByName,r=this.db._deps.indexedDB;function u(e,t){return 0===r.cmp(e,t)}var o=k(n.reduce(function(e,t){var n=k(e,2),r=n[0],e=n[1],n=a[t],o=i[t];return[r||n,r||!n?ut(e,n&&n.multi?function(e){e=O(e,t);return x(e)&&e.some(function(e){return u(o,e)})}:function(e){return u(o,O(e,t))}):e]},[null,null]),2),t=o[0],o=o[1];return t?this.where(t.name).equals(i[t.keyPath]).filter(o):e?this.filter(o):this.where(n).equals("")},xt.prototype.filter=function(e){return this.toCollection().and(e)},xt.prototype.count=function(e){return this.toCollection().count(e)},xt.prototype.offset=function(e){return this.toCollection().offset(e)},xt.prototype.limit=function(e){return this.toCollection().limit(e)},xt.prototype.each=function(e){return this.toCollection().each(e)},xt.prototype.toArray=function(e){return this.toCollection().toArray(e)},xt.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},xt.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,x(e)?"[".concat(e.join("+"),"]"):e))},xt.prototype.reverse=function(){return this.toCollection().reverse()},xt.prototype.mapToClass=function(c){var e,l,t,f=this,h=this.db,n=this.name;function r(){return null!==e&&e.apply(this,arguments)||this}function o(){return null!==t&&t.apply(this,arguments)||this}(this.schema.mappedClass=c).prototype instanceof lt&&(s(r,e=c),Object.defineProperty(r.prototype,"db",{get:function(){return h},enumerable:!1,configurable:!0}),r.prototype.table=function(){return n},c=r),this.schema.yProps&&(l=wt(h),s(o,t=c),c=o,this.schema.yProps.forEach(function(e){var n,r,o,i,a,u,s,t=e.prop,e=e.updatesTable;Object.defineProperty(c.prototype,t,(n=h,r=l,i=t,a=e,u=(o=f).schema.primKey.keyPath,s=pt(n),{set:function(){throw new TypeError("Y.Doc properties are read-only")},get:function(){var e=O(this,u),t=s.find(o.name,e,i);return t||(t=new r.Doc({meta:{db:n,updatesTable:a,parentProp:i,parentTable:o.name,parentId:e}}),s.add(t),t.on("destroy",function(){vt.add(t),s.delete(t)}),t)}}))}));for(var i=new Set,a=c.prototype;a;a=d(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function u(e){if(!e)return e;var t,n=Object.create(c.prototype);for(t in e)if(!i.has(t))try{n[t]=e[t]}catch(e){}return n}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=u,this.hook("reading",u),c},xt.prototype.defineClass=function(){return this.mapToClass(function(e){a(this,e)})},xt.prototype.add=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=ct(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"add",keys:null!=n?[n]:null,values:[a]})}).then(function(e){return e.numFailures?Pe.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{E(t,i,e)}catch(e){}return e})},xt.prototype.update=function(e,t){if("object"!=typeof e||x(e))return this.where(":id").equals(e).modify(t);e=O(e,this.schema.primKey.keyPath);return void 0===e?Ze(new H.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(e).modify(t)},xt.prototype.put=function(t,n){var r=this,e=this.schema.primKey,o=e.auto,i=e.keyPath,a=t;return i&&o&&(a=ct(i)(t)),this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"put",values:[a],keys:null!=n?[n]:null})}).then(function(e){return e.numFailures?Pe.reject(e.failures[0]):e.lastResult}).then(function(e){if(i)try{E(t,i,e)}catch(e){}return e})},xt.prototype.delete=function(t){var n=this;return this._trans("readwrite",function(e){return n.core.mutate({trans:e,type:"delete",keys:[t]}).then(function(e){return gt(n,[t],e)}).then(function(e){return e.numFailures?Pe.reject(e.failures[0]):void 0})})},xt.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:st}).then(function(e){return gt(t,null,e)})}).then(function(e){return e.numFailures?Pe.reject(e.failures[0]):void 0})},xt.prototype.bulkGet=function(t){var n=this;return this._trans("readonly",function(e){return n.core.getMany({keys:t,trans:e}).then(function(e){return e.map(function(e){return n.hook.reading.fire(e)})})})},xt.prototype.bulkAdd=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new H.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new H.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(ct(t)):r;return i.core.mutate({trans:e,type:"add",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new W("".concat(i.name,".bulkAdd(): ").concat(t," of ").concat(o," operations failed"),e)})})},xt.prototype.bulkPut=function(r,e,t){var i=this,a=Array.isArray(e)?e:void 0,u=(t=t||(a?void 0:e))?t.allKeys:void 0;return this._trans("readwrite",function(e){var t=i.schema.primKey,n=t.auto,t=t.keyPath;if(t&&a)throw new H.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(a&&a.length!==r.length)throw new H.InvalidArgument("Arguments objects and keys must have the same length");var o=r.length,t=t&&n?r.map(ct(t)):r;return i.core.mutate({trans:e,type:"put",keys:a,values:t,wantResults:u}).then(function(e){var t=e.numFailures,n=e.results,r=e.lastResult,e=e.failures;if(0===t)return u?n:r;throw new W("".concat(i.name,".bulkPut(): ").concat(t," of ").concat(o," operations failed"),e)})})},xt.prototype.bulkUpdate=function(t){var p=this,n=this.core,r=t.map(function(e){return e.key}),o=t.map(function(e){return e.changes}),y=[];return this._trans("readwrite",function(e){return n.getMany({trans:e,keys:r,cache:"clone"}).then(function(f){var h=[],d=[];t.forEach(function(e,t){var n,r,o=e.key,i=e.changes,a=f[t];if(a){try{for(var u=B(Object.keys(i)),s=u.next();!s.done;s=u.next()){var c=s.value,l=i[c];if(c===p.schema.primKey.keyPath){if(0!==ft(l,o))throw new H.Constraint("Cannot update primary key in bulkUpdate()")}else E(a,c,l)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}y.push(t),h.push(o),d.push(a)}});var l=h.length;return n.mutate({trans:e,type:"put",keys:h,values:d,updates:{keys:r,changeSpecs:o}}).then(function(e){var t,n,r=e.numFailures,o=e.failures;if(0===r)return l;try{for(var i=B(Object.keys(o)),a=i.next();!a.done;a=i.next()){var u,s=a.value,c=y[Number(s)];null!=c&&(u=o[s],delete o[s],o[c]=u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}throw new W("".concat(p.name,".bulkUpdate(): ").concat(r," of ").concat(l," operations failed"),o)})})})},xt.prototype.bulkDelete=function(t){var r=this,o=t.length;return this._trans("readwrite",function(e){return r.core.mutate({trans:e,type:"delete",keys:t}).then(function(e){return gt(r,t,e)})}).then(function(e){var t=e.numFailures,n=e.lastResult,e=e.failures;if(0===t)return n;throw new W("".concat(r.name,".bulkDelete(): ").concat(t," of ").concat(o," operations failed"),e)})},xt);function xt(){}function kt(o){function t(e,t){if(t){for(var n=arguments.length,r=new Array(n-1);--n;)r[n-1]=arguments[n];return a[e].subscribe.apply(null,r),o}if("string"==typeof e)return a[e]}var a={};t.addEventType=u;for(var e=1,n=arguments.length;e<n;++e)u(arguments[e]);return t;function u(e,n,r){if("object"!=typeof e){var o;n=n||ie;var i={subscribers:[],fire:r=r||J,subscribe:function(e){-1===i.subscribers.indexOf(e)&&(i.subscribers.push(e),i.fire=n(i.fire,e))},unsubscribe:function(t){i.subscribers=i.subscribers.filter(function(e){return e!==t}),i.fire=i.subscribers.reduce(n,r)}};return a[e]=t[e]=i}P(o=e).forEach(function(e){var t=o[e];if(x(t))u(e,o[e][0],o[e][1]);else{if("asap"!==t)throw new H.InvalidArgument("Invalid event config");var n=u(e,Z,function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach(function(e){v(function(){e.apply(null,t)})})})}})}}function Pt(e,t){return i(t).from({prototype:e}),t}function Ot(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Et(e,t){e.filter=ut(e.filter,t)}function St(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return ut(r(),t())}:t,e.justLimit=n&&!r}function Kt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new H.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function Ct(e,t,n){var r=Kt(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 jt(e,i,t,n){var a=e.replayFilter?ut(e.filter,e.replayFilter()):e.filter;if(e.or){var u={},r=function(e,t,n){var r,o;a&&!a(t,n,function(e){return t.stop(e)},function(e){return t.fail(e)})||("[object ArrayBuffer]"===(o=""+(r=t.primaryKey))&&(o=""+new Uint8Array(r)),b(u,o)||(u[o]=!0,i(e,t,n)))};return Promise.all([e.or._iterate(r,t),At(Ct(e,n,t),e.algorithm,r,!e.keysOnly&&e.valueMapper)])}return At(Ct(e,n,t),ut(e.algorithm,a),i,!e.keysOnly&&e.valueMapper)}function At(e,r,o,i){var a=Be(i?function(e,t,n){return o(i(e),t,n)}:o);return e.then(function(n){if(n)return n.start(function(){var t=function(){return n.continue()};r&&!r(n,function(e){return t=e},function(e){n.stop(e),t=J},function(e){n.fail(e),t=J})||a(n.value,n,function(e){return t=e}),t()})})}var e=Symbol(),Tt=(Dt.prototype.execute=function(e){if(void 0!==this.add){var t=this.add;if(x(t))return m(m([],k(x(e)?e:[]),!1),k(t),!1).sort();if("number"==typeof t)return(Number(e)||0)+t;if("bigint"==typeof t)try{return BigInt(e)+t}catch(e){return BigInt(0)+t}throw new TypeError("Invalid term ".concat(t))}if(void 0!==this.remove){var n=this.remove;if(x(n))return x(e)?e.filter(function(e){return!n.includes(e)}).sort():[];if("number"==typeof n)return Number(e)-n;if("bigint"==typeof n)try{return BigInt(e)-n}catch(e){return BigInt(0)-n}throw new TypeError("Invalid subtrahend ".concat(n))}t=null===(t=this.replacePrefix)||void 0===t?void 0:t[0];return t&&"string"==typeof e&&e.startsWith(t)?this.replacePrefix[1]+e.substring(t.length):e},Dt);function Dt(e){Object.assign(this,e)}var It=(qt.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,Ze.bind(null,n.error)):n.table._trans("readonly",e).then(t)},qt.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,Ze.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},qt.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=ut(t.algorithm,e)},qt.prototype._iterate=function(e,t){return jt(this._ctx,e,t,this._ctx.table.core)},qt.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&a(n,e),t._ctx=n,t},qt.prototype.raw=function(){return this._ctx.valueMapper=null,this},qt.prototype.each=function(t){var n=this._ctx;return this._read(function(e){return jt(n,t,e,n.table.core)})},qt.prototype.count=function(e){var o=this;return this._read(function(e){var t=o._ctx,n=t.table.core;if(Ot(t,!0))return n.count({trans:e,query:{index:Kt(t,n.schema),range:t.range}}).then(function(e){return Math.min(e,t.limit)});var r=0;return jt(t,function(){return++r,!1},e,n).then(function(){return r})}).then(e)},qt.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],o=n.length-1;function i(e,t){return t?i(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function u(e,t){e=i(e,o),t=i(t,o);return e<t?-a:t<e?a:0}return this.toArray(function(e){return e.sort(u)}).then(t)},qt.prototype.toArray=function(e){var i=this;return this._read(function(e){var t=i._ctx;if("next"===t.dir&&Ot(t,!0)&&0<t.limit){var n=t.valueMapper,r=Kt(t,t.table.core.schema);return t.table.core.query({trans:e,limit:t.limit,values:!0,query:{index:r,range:t.range}}).then(function(e){e=e.result;return n?e.map(n):e})}var o=[];return jt(t,function(e){return o.push(e)},e,t.table.core).then(function(){return o})},e)},qt.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,Ot(e)?St(e,function(){var n=t;return function(e,t){return 0===n||(1===n?--n:t(function(){e.advance(n),n=0}),!1)}}):St(e,function(){var e=t;return function(){return--e<0}})),this},qt.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),St(this._ctx,function(){var r=e;return function(e,t,n){return--r<=0&&t(n),0<=r}},!0),this},qt.prototype.until=function(r,o){return Et(this._ctx,function(e,t,n){return!r(e.value)||(t(n),o)}),this},qt.prototype.first=function(e){return this.limit(1).toArray(function(e){return e[0]}).then(e)},qt.prototype.last=function(e){return this.reverse().first(e)},qt.prototype.filter=function(t){var e;return Et(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=ut(e.isMatch,t),this},qt.prototype.and=function(e){return this.filter(e)},qt.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},qt.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},qt.prototype.desc=function(){return this.reverse()},qt.prototype.eachKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.key,t)})},qt.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},qt.prototype.eachPrimaryKey=function(n){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,t){n(t.primaryKey,t)})},qt.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)},qt.prototype.primaryKeys=function(e){var n=this._ctx;if("next"===n.dir&&Ot(n,!0)&&0<n.limit)return this._read(function(e){var t=Kt(n,n.table.core.schema);return n.table.core.query({trans:e,values:!1,limit:n.limit,query:{index:t,range:n.range}})}).then(function(e){return e.result}).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(e,t){r.push(t.primaryKey)}).then(function(){return r}).then(e)},qt.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},qt.prototype.firstKey=function(e){return this.limit(1).keys(function(e){return e[0]}).then(e)},qt.prototype.lastKey=function(e){return this.reverse().firstKey(e)},qt.prototype.distinct=function(){var e=this._ctx,e=e.index&&e.table.schema.idxByName[e.index];if(!e||!e.multi)return this;var n={};return Et(this._ctx,function(e){var t=e.primaryKey.toString(),e=b(n,t);return n[t]=!0,!e}),this},qt.prototype.modify=function(x){var n=this,k=this._ctx;return this._write(function(p){var a,u,y;y="function"==typeof x?x:(a=P(x),u=a.length,function(e){for(var t=!1,n=0;n<u;++n){var r=a[n],o=x[r],i=O(e,r);o instanceof Tt?(E(e,r,o.execute(i)),t=!0):i!==o&&(E(e,r,o),t=!0)}return t});function v(e,t){var n,r,o=t.failures,t=t.numFailures;c+=e-t;try{for(var i=B(P(o)),a=i.next();!a.done;a=i.next()){var u=a.value;s.push(o[u])}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}var m=k.table.core,e=m.schema.primaryKey,b=e.outbound,g=e.extractKey,w=n.db._options.modifyChunkSize||200,s=[],c=0,t=[],_=x===Bt;return n.clone().primaryKeys().then(function(f){function h(s){var c=Math.min(w,f.length-s),l=f.slice(s,s+c);return(_?Promise.resolve([]):m.getMany({trans:p,keys:l,cache:"immutable"})).then(function(e){var n=[],t=[],r=b?[]:null,o=_?l:[];if(!_)for(var i=0;i<c;++i){var a=e[i],u={value:j(a),primKey:f[s+i]};!1!==y.call(u,u.value,u)&&(null==u.value?o.push(f[s+i]):b||0===ft(g(a),g(u.value))?(t.push(u.value),b&&r.push(f[s+i])):(o.push(f[s+i]),n.push(u.value)))}return Promise.resolve(0<n.length&&m.mutate({trans:p,type:"add",values:n}).then(function(e){for(var t in e.failures)o.splice(parseInt(t),1);v(n.length,e)})).then(function(){return(0<t.length||d&&"object"==typeof x)&&m.mutate({trans:p,type:"put",keys:r,values:t,criteria:d,changeSpec:"function"!=typeof x&&x,isAdditionalChunk:0<s}).then(function(e){return v(t.length,e)})}).then(function(){return(0<o.length||d&&_)&&m.mutate({trans:p,type:"delete",keys:o,criteria:d,isAdditionalChunk:0<s}).then(function(e){return gt(k.table,o,e)}).then(function(e){return v(o.length,e)})}).then(function(){return f.length>s+c&&h(s+w)})})}var d=Ot(k)&&k.limit===1/0&&("function"!=typeof x||_)&&{index:k.index,range:k.range};return h(0).then(function(){if(0<s.length)throw new z("Error modifying one or more objects",s,c,t);return f.length})})})},qt.prototype.delete=function(){var o=this._ctx,n=o.range;return!Ot(o)||o.table.schema.yProps||!o.isPrimKey&&3!==n.type?this.modify(Bt):this._write(function(e){var t=o.table.core.schema.primaryKey,r=n;return o.table.core.count({trans:e,query:{index:t,range:r}}).then(function(n){return o.table.core.mutate({trans:e,type:"deleteRange",range:r}).then(function(e){var t=e.failures,e=e.numFailures;if(e)throw new z("Could not delete some values",Object.keys(t).map(function(e){return t[e]}),n-e);return n-e})})})},qt);function qt(){}var Bt=function(e,t){return t.value=null};function Rt(e,t){return e<t?-1:e===t?0:1}function Mt(e,t){return t<e?-1:e===t?0:1}function Ft(e,t,n){e=e instanceof Vt?new e.Collection(e):e;return e._ctx.error=new(n||TypeError)(t),e}function Nt(e){return new e.Collection(e,function(){return Yt("")}).limit(0)}function Ut(e,s,n,r){var o,c,l,f,h,d,p,y=n.length;if(!n.every(function(e){return"string"==typeof e}))return Ft(e,nt);function t(e){o="next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()},c="next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()},l="next"===e?Rt:Mt;var t=n.map(function(e){return{lower:c(e),upper:o(e)}}).sort(function(e,t){return l(e.lower,t.lower)});f=t.map(function(e){return e.upper}),h=t.map(function(e){return e.lower}),p="next"===(d=e)?"":r}t("next");e=new e.Collection(e,function(){return Lt(f[0],h[y-1]+r)});e._ondirectionchange=function(e){t(e)};var v=0;return e._addAlgorithm(function(e,t,n){var r=e.key;if("string"!=typeof r)return!1;var o=c(r);if(s(o,h,v))return!0;for(var i=null,a=v;a<y;++a){var u=function(e,t,n,r,o,i){for(var a=Math.min(e.length,r.length),u=-1,s=0;s<a;++s){var c=t[s];if(c!==r[s])return o(e[s],n[s])<0?e.substr(0,s)+n[s]+n.substr(s+1):o(e[s],r[s])<0?e.substr(0,s)+r[s]+n.substr(s+1):0<=u?e.substr(0,u)+t[u]+n.substr(u+1):null;o(e[s],c)<0&&(u=s)}return a<r.length&&"next"===i?e+n.substr(e.length):a<e.length&&"prev"===i?e.substr(0,n.length):u<0?null:e.substr(0,u)+r[u]+n.substr(u+1)}(r,o,f[a],h[a],l,d);null===u&&null===i?v=a+1:(null===i||0<l(i,u))&&(i=u)}return t(null!==i?function(){e.continue(i+p)}:n),!1}),e}function Lt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Yt(e){return{type:1,lower:e,upper:e}}var Vt=(Object.defineProperty(zt.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),zt.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(e,t)||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Nt(this):new this.Collection(this,function(){return Lt(e,t,!n,!r)})}catch(e){return Ft(this,tt)}},zt.prototype.equals=function(e){return null==e?Ft(this,tt):new this.Collection(this,function(){return Yt(e)})},zt.prototype.above=function(e){return null==e?Ft(this,tt):new this.Collection(this,function(){return Lt(e,void 0,!0)})},zt.prototype.aboveOrEqual=function(e){return null==e?Ft(this,tt):new this.Collection(this,function(){return Lt(e,void 0,!1)})},zt.prototype.below=function(e){return null==e?Ft(this,tt):new this.Collection(this,function(){return Lt(void 0,e,!1,!0)})},zt.prototype.belowOrEqual=function(e){return null==e?Ft(this,tt):new this.Collection(this,function(){return Lt(void 0,e)})},zt.prototype.startsWith=function(e){return"string"!=typeof e?Ft(this,nt):this.between(e,e+et,!0,!0)},zt.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Ut(this,function(e,t){return 0===e.indexOf(t[0])},[e],et)},zt.prototype.equalsIgnoreCase=function(e){return Ut(this,function(e,t){return e===t[0]},[e],"")},zt.prototype.anyOfIgnoreCase=function(){var e=M.apply(q,arguments);return 0===e.length?Nt(this):Ut(this,function(e,t){return-1!==t.indexOf(e)},e,"")},zt.prototype.startsWithAnyOfIgnoreCase=function(){var e=M.apply(q,arguments);return 0===e.length?Nt(this):Ut(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},e,et)},zt.prototype.anyOf=function(){var t=this,o=M.apply(q,arguments),i=this._cmp;try{o.sort(i)}catch(e){return Ft(this,tt)}if(0===o.length)return Nt(this);var e=new this.Collection(this,function(){return Lt(o[0],o[o.length-1])});e._ondirectionchange=function(e){i="next"===e?t._ascending:t._descending,o.sort(i)};var a=0;return e._addAlgorithm(function(e,t,n){for(var r=e.key;0<i(r,o[a]);)if(++a===o.length)return t(n),!1;return 0===i(r,o[a])||(t(function(){e.continue(o[a])}),!1)}),e},zt.prototype.notEqual=function(e){return this.inAnyRange([[-1/0,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},zt.prototype.noneOf=function(){var e=M.apply(q,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return Ft(this,tt)}var t=e.reduce(function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[-1/0,t]]},null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},zt.prototype.inAnyRange=function(e,t){var i=this,a=this._cmp,u=this._ascending,n=this._descending,s=this._min,c=this._max;if(0===e.length)return Nt(this);if(!e.every(function(e){return void 0!==e[0]&&void 0!==e[1]&&u(e[0],e[1])<=0}))return Ft(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",H.InvalidArgument);var r=!t||!1!==t.includeLowers,o=t&&!0===t.includeUppers;var l,f=u;function h(e,t){return f(e[0],t[0])}try{(l=e.reduce(function(e,t){for(var n=0,r=e.length;n<r;++n){var o=e[n];if(a(t[0],o[1])<0&&0<a(t[1],o[0])){o[0]=s(o[0],t[0]),o[1]=c(o[1],t[1]);break}}return n===r&&e.push(t),e},[])).sort(h)}catch(e){return Ft(this,tt)}var d=0,p=o?function(e){return 0<u(e,l[d][1])}:function(e){return 0<=u(e,l[d][1])},y=r?function(e){return 0<n(e,l[d][0])}:function(e){return 0<=n(e,l[d][0])};var v=p,e=new this.Collection(this,function(){return Lt(l[0][0],l[l.length-1][1],!r,!o)});return e._ondirectionchange=function(e){f="next"===e?(v=p,u):(v=y,n),l.sort(h)},e._addAlgorithm(function(e,t,n){for(var r,o=e.key;v(o);)if(++d===l.length)return t(n),!1;return!p(r=o)&&!y(r)||(0===i._cmp(o,l[d][1])||0===i._cmp(o,l[d][0])||t(function(){f===u?e.continue(l[d][0]):e.continue(l[d][1])}),!1)}),e},zt.prototype.startsWithAnyOf=function(){var e=M.apply(q,arguments);return e.every(function(e){return"string"==typeof e})?0===e.length?Nt(this):this.inAnyRange(e.map(function(e){return[e,e+et]})):Ft(this,"startsWithAnyOf() only works with strings")},zt);function zt(){}function Wt(t){return Be(function(e){return $t(e),t(e.target.error),!1})}function $t(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Gt="storagemutated",Ht="x-storagemutated-1",Qt=kt(null,Gt),Xt=(Jt.prototype._lock=function(){return y(!we.global),++this._reculock,1!==this._reculock||we.global||(we.lockOwnerFor=this),this},Jt.prototype._unlock=function(){if(y(!we.global),0==--this._reculock)for(we.global||(we.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var e=this._blockedFuncs.shift();try{Qe(e[1],e[0])}catch(e){}}return this},Jt.prototype._locked=function(){return this._reculock&&we.lockOwnerFor!==this},Jt.prototype.create=function(t){var n=this;if(!this.mode)return this;var e=this.db.idbdb,r=this.db._state.dbOpenError;if(y(!this.idbtrans),!t&&!e)switch(r&&r.name){case"DatabaseClosedError":throw new H.DatabaseClosed(r);case"MissingAPIError":throw new H.MissingAPI(r.message,r);default:throw new H.OpenFailed(r)}if(!this.active)throw new H.TransactionInactive;return y(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||e).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Be(function(e){$t(e),n._reject(t.error)}),t.onabort=Be(function(e){$t(e),n.active&&n._reject(new H.Abort(t.error)),n.active=!1,n.on("abort").fire(e)}),t.oncomplete=Be(function(){n.active=!1,n._resolve(),"mutatedParts"in t&&Qt.storagemutated.fire(t.mutatedParts)}),this},Jt.prototype._promise=function(n,r,o){var i=this;if("readwrite"===n&&"readwrite"!==this.mode)return Ze(new H.ReadOnly("Transaction is readonly"));if(!this.active)return Ze(new H.TransactionInactive);if(this._locked())return new Pe(function(e,t){i._blockedFuncs.push([function(){i._promise(n,r,o).then(e,t)},we])});if(o)return Ye(function(){var e=new Pe(function(e,t){i._lock();var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e.finally(function(){return i._unlock()}),e._lib=!0,e});var e=new Pe(function(e,t){var n=r(e,t,i);n&&n.then&&n.then(e,t)});return e._lib=!0,e},Jt.prototype._root=function(){return this.parent?this.parent._root():this},Jt.prototype.waitFor=function(e){var t,r=this._root(),o=Pe.resolve(e);r._waitingFor?r._waitingFor=r._waitingFor.then(function(){return o}):(r._waitingFor=o,r._waitingQueue=[],t=r.idbtrans.objectStore(r.storeNames[0]),function e(){for(++r._spinCount;r._waitingQueue.length;)r._waitingQueue.shift()();r._waitingFor&&(t.get(-1/0).onsuccess=e)}());var i=r._waitingFor;return new Pe(function(t,n){o.then(function(e){return r._waitingQueue.push(Be(t.bind(null,e)))},function(e){return r._waitingQueue.push(Be(n.bind(null,e)))}).finally(function(){r._waitingFor===i&&(r._waitingFor=null)})})},Jt.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new H.Abort))},Jt.prototype.table=function(e){var t=this._memoizedTables||(this._memoizedTables={});if(b(t,e))return t[e];var n=this.schema[e];if(!n)throw new H.NotFound("Table "+e+" not part of transaction");n=new this.db.Table(e,n,this);return n.core=this.db.core.table(e),t[e]=n},Jt);function Jt(){}function Zt(e,t,n,r,o,i,a,u){return{name:e,keyPath:t,unique:n,multi:r,auto:o,compound:i,src:(n&&!a?"&":"")+(r?"*":"")+(o?"++":"")+en(t),type:u}}function en(e){return"string"==typeof e?e:e?"["+[].join.call(e,"+")+"]":""}function tn(t,e,n,r){return{name:t,primKey:e,indexes:n,mappedClass:null,yProps:null==r?void 0:r.map(function(e){return{prop:e,updatesTable:"$".concat(t,".").concat(e,"_updates")}}),idxByName:(o=function(e){return[e.name,e]},n.reduce(function(e,t,n){n=o(t,n);return n&&(e[n[0]]=n[1]),e},{}))};var o}var nn=function(e){try{return e.only([[]]),nn=function(){return[[]]},[[]]}catch(e){return nn=function(){return et},et}};function rn(t){return null==t?function(){}:"string"==typeof t?1===(n=t).split(".").length?function(e){return e[n]}:function(e){return O(e,n)}:function(e){return O(e,t)};var n}function on(e){return[].slice.call(e)}var an=0;function un(e){return null==e?":id":"string"==typeof e?e:"[".concat(e.join("+"),"]")}function sn(e,o,t){function _(e){if(3===e.type)return null;if(4===e.type)throw new Error("Cannot convert never type to IDBKeyRange");var t=e.lower,n=e.upper,r=e.lowerOpen,e=e.upperOpen;return void 0===t?void 0===n?null:o.upperBound(n,!!e):void 0===n?o.lowerBound(t,!!r):o.bound(t,n,!!r,!!e)}function n(e){var h,w=e.name;return{name:w,schema:e,mutate:function(e){var y=e.trans,v=e.type,m=e.keys,b=e.values,g=e.range;return new Promise(function(t,e){t=Be(t);var n=y.objectStore(w),r=null==n.keyPath,o="put"===v||"add"===v;if(!o&&"delete"!==v&&"deleteRange"!==v)throw new Error("Invalid operation type: "+v);var i,a=(m||b||{length:1}).length;if(m&&b&&m.length!==b.length)throw new Error("Given keys array must have same length as given values array.");if(0===a)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function u(e){++l,$t(e)}var s=[],c=[],l=0;if("deleteRange"===v){if(4===g.type)return t({numFailures:l,failures:c,results:[],lastResult:void 0});3===g.type?s.push(i=n.clear()):s.push(i=n.delete(_(g)))}else{var r=k(o?r?[b,m]:[b,null]:[m,null],2),f=r[0],h=r[1];if(o)for(var d=0;d<a;++d)s.push(i=h&&void 0!==h[d]?n[v](f[d],h[d]):n[v](f[d])),i.onerror=u;else for(d=0;d<a;++d)s.push(i=n[v](f[d])),i.onerror=u}function p(e){e=e.target.result,s.forEach(function(e,t){return null!=e.error&&(c[t]=e.error)}),t({numFailures:l,failures:c,results:"delete"===v?m:s.map(function(e){return e.result}),lastResult:e})}i.onerror=function(e){u(e),p(e)},i.onsuccess=p})},getMany:function(e){var f=e.trans,h=e.keys;return new Promise(function(t,e){t=Be(t);for(var n,r=f.objectStore(w),o=h.length,i=new Array(o),a=0,u=0,s=function(e){e=e.target;i[e._pos]=e.result,++u===a&&t(i)},c=Wt(e),l=0;l<o;++l)null!=h[l]&&((n=r.get(h[l]))._pos=l,n.onsuccess=s,n.onerror=c,++a);0===a&&t(i)})},get:function(e){var r=e.trans,o=e.key;return new Promise(function(t,e){t=Be(t);var n=r.objectStore(w).get(o);n.onsuccess=function(e){return t(e.target.result)},n.onerror=Wt(e)})},query:(h=s,function(f){return new Promise(function(n,e){n=Be(n);var r,o,i,t=f.trans,a=f.values,u=f.limit,s=f.query,c=u===1/0?void 0:u,l=s.index,s=s.range,t=t.objectStore(w),l=l.isPrimaryKey?t:t.index(l.name),s=_(s);if(0===u)return n({result:[]});h?((c=a?l.getAll(s,c):l.getAllKeys(s,c)).onsuccess=function(e){return n({result:e.target.result})},c.onerror=Wt(e)):(r=0,o=!a&&"openKeyCursor"in l?l.openKeyCursor(s):l.openCursor(s),i=[],o.onsuccess=function(e){var t=o.result;return t?(i.push(a?t.value:t.primaryKey),++r===u?n({result:i}):void t.continue()):n({result:i})},o.onerror=Wt(e))})}),openCursor:function(e){var c=e.trans,i=e.values,a=e.query,u=e.reverse,l=e.unique;return new Promise(function(t,n){t=Be(t);var e=a.index,r=a.range,o=c.objectStore(w),o=e.isPrimaryKey?o:o.index(e.name),e=u?l?"prevunique":"prev":l?"nextunique":"next",s=!i&&"openKeyCursor"in o?o.openKeyCursor(_(r),e):o.openCursor(_(r),e);s.onerror=Wt(n),s.onsuccess=Be(function(e){var r,o,i,a,u=s.result;u?(u.___id=++an,u.done=!1,r=u.continue.bind(u),o=(o=u.continuePrimaryKey)&&o.bind(u),i=u.advance.bind(u),a=function(){throw new Error("Cursor not stopped")},u.trans=c,u.stop=u.continue=u.continuePrimaryKey=u.advance=function(){throw new Error("Cursor not started")},u.fail=Be(n),u.next=function(){var e=this,t=1;return this.start(function(){return t--?e.continue():e.stop()}).then(function(){return e})},u.start=function(e){function t(){if(s.result)try{e()}catch(e){u.fail(e)}else u.done=!0,u.start=function(){throw new Error("Cursor behind last entry")},u.stop()}var n=new Promise(function(t,e){t=Be(t),s.onerror=Wt(e),u.fail=e,u.stop=function(e){u.stop=u.continue=u.continuePrimaryKey=u.advance=a,t(e)}});return s.onsuccess=Be(function(e){s.onsuccess=t,t()}),u.continue=r,u.continuePrimaryKey=o,u.advance=i,t(),n},t(u)):t(null)},n)})},count:function(e){var t=e.query,o=e.trans,i=t.index,a=t.range;return new Promise(function(t,e){var n=o.objectStore(w),r=i.isPrimaryKey?n:n.index(i.name),n=_(a),r=n?r.count(n):r.count();r.onsuccess=Be(function(e){return t(e.target.result)}),r.onerror=Wt(e)})}}}var r,i,a,u=(i=t,a=on((r=e).objectStoreNames),{schema:{name:r.name,tables:a.map(function(e){return i.objectStore(e)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=x(e),o={},n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:rn(e)},indexes:on(t.indexNames).map(function(e){return t.index(e)}).map(function(e){var t=e.name,n=e.unique,r=e.multiEntry,e=e.keyPath,r={name:t,compound:x(e),keyPath:e,unique:n,multiEntry:r,extractKey:rn(e)};return o[un(e)]=r}),getIndexByKeyPath:function(e){return o[un(e)]}};return o[":id"]=n.primaryKey,null!=e&&(o[un(e)]=n.primaryKey),n})},hasGetAll:0<a.length&&"getAll"in i.objectStore(a[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}),t=u.schema,s=u.hasGetAll,u=t.tables.map(n),c={};return u.forEach(function(e){return c[e.name]=e}),{stack:"dbcore",transaction:e.transaction.bind(e),table:function(e){if(!c[e])throw new Error("Table '".concat(e,"' not found"));return c[e]},MIN_KEY:-1/0,MAX_KEY:nn(o),schema:t}}function cn(e,t,n,r){var o=n.IDBKeyRange;return n.indexedDB,{dbcore:(r=sn(t,o,r),e.dbcore.reduce(function(e,t){t=t.create;return w(w({},e),t(e))},r))}}function ln(n,e){var t=e.db,e=cn(n._middlewares,t,n._deps,e);n.core=e.dbcore,n.tables.forEach(function(e){var t=e.name;n.core.schema.tables.some(function(e){return e.name===t})&&(e.core=n.core.table(t),n[t]instanceof n.Table&&(n[t].core=e.core))})}function fn(o,e,t,i){t.forEach(function(n){var r=i[n];e.forEach(function(e){var t=function e(t,n){return l(t,n)||(t=d(t))&&e(t,n)}(e,n);(!t||"value"in t&&void 0===t.value)&&(e===o.Transaction.prototype||e instanceof o.Transaction?c(e,n,{get:function(){return this.table(n)},set:function(e){u(this,n,{value:e,writable:!0,configurable:!0,enumerable:!0})}}):e[n]=new o.Table(n,r))})})}function hn(n,e){e.forEach(function(e){for(var t in e)e[t]instanceof n.Table&&delete e[t]})}function dn(e,t){return e._cfg.version-t._cfg.version}function pn(n,r,o,e){var i=n._dbSchema;o.objectStoreNames.contains("$meta")&&!i.$meta&&(i.$meta=tn("$meta",xn("")[0],[]),n._storeNames.push("$meta"));var a=n._createTransaction("readwrite",n._storeNames,i);a.create(o),a._completion.catch(e);var u=a._reject.bind(a),s=we.transless||we;Ye(function(){return we.trans=a,we.transless=s,0!==r?(ln(n,o),t=r,((e=a).storeNames.includes("$meta")?e.table("$meta").get("version").then(function(e){return null!=e?e:t}):Pe.resolve(t)).then(function(e){return c=e,l=a,f=o,t=[],e=(s=n)._versions,h=s._dbSchema=wn(0,s.idbdb,f),0!==(e=e.filter(function(e){return e._cfg.version>=c})).length?(e.forEach(function(u){t.push(function(){var t=h,e=u._cfg.dbschema;_n(s,t,f),_n(s,e,f),h=s._dbSchema=e;var n=vn(t,e);n.add.forEach(function(e){mn(f,e[0],e[1].primKey,e[1].indexes)}),n.change.forEach(function(e){if(e.recreate)throw new H.Upgrade("Not yet support for changing primary key");var t=f.objectStore(e.name);e.add.forEach(function(e){return gn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),gn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})});var r=u._cfg.contentUpgrade;if(r&&u._cfg.version>c){ln(s,f),l._memoizedTables={};var o=_(e);n.del.forEach(function(e){o[e]=t[e]}),hn(s,[s.Transaction.prototype]),fn(s,[s.Transaction.prototype],P(o),o),l.schema=o;var i,a=F(r);a&&Ve();n=Pe.follow(function(){var e;(i=r(l))&&a&&(e=ze.bind(null,null),i.then(e,e))});return i&&"function"==typeof i.then?Pe.resolve(i):n.then(function(){return i})}}),t.push(function(e){var t,n,r=u._cfg.dbschema;t=r,n=e,[].slice.call(n.db.objectStoreNames).forEach(function(e){return null==t[e]&&n.db.deleteObjectStore(e)}),hn(s,[s.Transaction.prototype]),fn(s,[s.Transaction.prototype],s._storeNames,s._dbSchema),l.schema=s._dbSchema}),t.push(function(e){s.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(s.idbdb.version/10)===u._cfg.version?(s.idbdb.deleteObjectStore("$meta"),delete s._dbSchema.$meta,s._storeNames=s._storeNames.filter(function(e){return"$meta"!==e})):e.objectStore("$meta").put(u._cfg.version,"version"))})}),function e(){return t.length?Pe.resolve(t.shift()(l.idbtrans)).then(e):Pe.resolve()}().then(function(){bn(h,f)})):Pe.resolve();var s,c,l,f,t,h}).catch(u)):(P(i).forEach(function(e){mn(o,e,i[e].primKey,i[e].indexes)}),ln(n,o),void Pe.follow(function(){return n.on.populate.fire(a)}).catch(u));var e,t})}function yn(e,r){var t,n;bn(e._dbSchema,r),r.db.version%10!=0||r.objectStoreNames.contains("$meta")||r.db.createObjectStore("$meta").add(Math.ceil(r.db.version/10-1),"version");var o=wn(0,e.idbdb,r);_n(e,e._dbSchema,r);e=vn(o,e._dbSchema);try{for(var i=B(e.change),a=i.next();!a.done;a=i.next()){var u=function(t){if(t.change.length||t.recreate)return console.warn("Unable to patch indexes of table ".concat(t.name," because it has changes on the type of index or primary key.")),{value:void 0};var n=r.objectStore(t.name);t.add.forEach(function(e){ue&&console.debug("Dexie upgrade patch: Creating missing index ".concat(t.name,".").concat(e.src)),gn(n,e)})}(a.value);if("object"==typeof u)return u.value}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}function vn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var o=e[n],i=t[n];if(o){var a={name:n,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(o.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||o.primKey.auto!==i.primKey.auto)a.recreate=!0,r.change.push(a);else{var u=o.idxByName,s=i.idxByName,c=void 0;for(c in u)s[c]||a.del.push(c);for(c in s){var l=u[c],f=s[c];l?l.src!==f.src&&a.change.push(f):a.add.push(f)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,i])}return r}function mn(e,t,n,r){var o=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(e){return gn(o,e)}),o}function bn(t,n){P(t).forEach(function(e){n.db.objectStoreNames.contains(e)||(ue&&console.debug("Dexie: Creating missing table",e),mn(n,e,t[e].primKey,t[e].indexes))})}function gn(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function wn(e,t,u){var s={};return g(t.objectStoreNames,0).forEach(function(e){for(var t=u.objectStore(e),n=Zt(en(a=t.keyPath),a||"",!0,!1,!!t.autoIncrement,a&&"string"!=typeof a,!0),r=[],o=0;o<t.indexNames.length;++o){var i=t.index(t.indexNames[o]),a=i.keyPath,i=Zt(i.name,a,!!i.unique,!!i.multiEntry,!1,a&&"string"!=typeof a,!1);r.push(i)}s[e]=tn(e,n,r)}),s}function _n(e,t,n){for(var r=n.db.objectStoreNames,o=0;o<r.length;++o){var i=r[o],a=n.objectStore(i);e._hasGetAll="getAll"in a;for(var u=0;u<a.indexNames.length;++u){var s=a.indexNames[u],c=a.index(s).keyPath,l="string"==typeof c?c:"["+g(c).join("+")+"]";!t[i]||(c=t[i].idxByName[l])&&(c.name=s,delete t[i].idxByName[l],t[i].idxByName[s]=c)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&f.WorkerGlobalScope&&f instanceof f.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}function xn(e){return e.split(",").map(function(e,t){var n=e.split(":"),r=null===(o=n[1])||void 0===o?void 0:o.trim();if(e=n[0].trim(),r&&"Y"!==r)throw new H.Schema("Unsupported type '".concat(r,"'"));var o=e.replace(/([&*]|\+\+)/g,""),n=/^\[/.test(o)?o.match(/^\[(.*)\]$/)[1].split("+"):o;return Zt(o,n||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),x(n),0===t,r)})}var kn=[];var Pn=(On.prototype._parseStoresSpec=function(l,f){var h=this;P(l).forEach(function(e){var t,n,r;if(null!==l[e]){var o=xn(l[e]),i=o.filter(function(e){return"Y"===e.type}).map(function(e){return e.name}),a=(o=o.filter(function(e){return"Y"!==e.type})).shift();if(!a)throw new H.Schema("Invalid schema for table "+e+": "+l[e]);if(a.unique=!0,a.multi)throw new H.Schema("Primary key cannot be multiEntry*");o.forEach(function(e){if(e.auto)throw new H.Schema("Only primary key can be marked as autoIncrement (++)");if(!e.keyPath)throw new H.Schema("Index must have a name and cannot be an empty string")});i=tn(e,a,o,i.length?i:void 0);f[e]=i;try{for(var u=B(i.yProps||[]),s=u.next();!s.done;s=u.next()){var c=s.value;h._parseStoresSpec(((r={})[c.updatesTable]="++i,k",r),f)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}}})},On.prototype.stores=function(e){var t=this.db;this._cfg.storesSource=this._cfg.storesSource?a(this._cfg.storesSource,e):e;var r,u,e=t._versions,n={},o={};return e.forEach(function(e){a(n,e._cfg.storesSource),o=e._cfg.dbschema={},e._parseStoresSpec(n,o)}),t._dbSchema=o,hn(t,[t._allTables,t,t.Transaction.prototype]),fn(t,[t._allTables,t,t.Transaction.prototype,this._cfg.tables],P(o),o),t._storeNames=P(o),t._storeNames.forEach(function(e){o[e].yProps&&t.table(e).mapToClass(o[e].mappedClass||Object)}),Object.values(o).some(function(e){return e.yProps})?t.use((r=o,u=wt(t),{stack:"dbcore",name:"yjsMiddleware",level:50,create:function(a){return w(w({},a),{table:function(i){var t=a.table(i),n=r[i].yProps;return n&&0!==n.length?w(w({},t),{mutate:function(r){if("add"!==r.type&&"put"!==r.type)return t.mutate(r);var o=r,e=n.map(function(n){return{p:n,entries:r.values.flatMap(function(e,t){if(!e||"object"!=typeof e)throw new TypeError("Table ".concat(i," (with Y-properties) must only contain objects"));if(!b(e,n.prop))return[];delete(o=o===r?w(w({},r),{values:r.values.map(function(e){return w({},e)})}):o).values[t][n.prop];e=e[n.prop];if(null===e)throw new TypeError("Cannot set Y property to null");if(void 0===e)return kn;if("object"!=typeof e||!("whenLoaded"in e))throw new TypeError("Y properties can only be inited with an Y.Doc instance or undefined to create an empty Y.Doc");if("put"===r.type)throw new TypeError("Setting ".concat(i,".").concat(n.prop," (declared as ").concat(n.prop,":Y) is only allowed when inserting new objects using db.").concat(i,".add(), not put() or update()."));return 1===u.encodeStateVector(e).length?kn:{iter:t,u:u.encodeStateAsUpdateV2(e)}})}}).filter(function(e){return 0<e.entries.length});return r===o?t.mutate(r):t.mutate(o).then(function(n){return 0===e.length?n:Promise.all(e.map(function(e){var t=e.p,e=e.entries,t=a.table(t.updatesTable),e=e.map(function(e){var t=e.iter,e=e.u;return{k:n.results[t],u:e,f:1}});return t.mutate({type:"add",values:e,trans:r.trans})})).then(function(){return n})})}}):t}})}})):t.unuse({stack:"dbcore",name:"yjsMiddleware"}),this},On.prototype.upgrade=function(e){return this._cfg.contentUpgrade=ae(this._cfg.contentUpgrade||J,e),this},On);function On(){}function En(e,t){var n=e._dbNamesDB;return n||(n=e._dbNamesDB=new pr(ot,{addons:[],indexedDB:e,IDBKeyRange:t})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function Sn(e){return e&&"function"==typeof e.databases}function Kn(e){return Ye(function(){return we.letThrough=!0,e()})}function Cn(e){return!("from"in e)}var jn=function(e,t){if(!this){var n=new jn;return e&&"d"in e&&a(n,e),n}a(this,arguments.length?{d:1,from:e,to:1<arguments.length?t:e}:{d:0})};function An(e,t,n){var r=ft(t,n);if(!isNaN(r)){if(0<r)throw RangeError();if(Cn(e))return a(e,{from:t,to:n,d:1});var o=e.l,r=e.r;if(ft(n,e.from)<0)return o?An(o,t,n):e.l={from:t,to:n,d:1,l:null,r:null},qn(e);if(0<ft(t,e.to))return r?An(r,t,n):e.r={from:t,to:n,d:1,l:null,r:null},qn(e);ft(t,e.from)<0&&(e.from=t,e.l=null,e.d=r?r.d+1:1),0<ft(n,e.to)&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);n=!e.r;o&&!e.l&&Tn(e,o),r&&n&&Tn(e,r)}}function Tn(e,t){Cn(t)||function e(t,n){var r=n.from,o=n.to,i=n.l,n=n.r;An(t,r,o),i&&e(t,i),n&&e(t,n)}(e,t)}function Dn(e,t){var n=In(t),r=n.next();if(r.done)return!1;for(var o=r.value,i=In(e),a=i.next(o.from),u=a.value;!r.done&&!a.done;){if(ft(u.from,o.to)<=0&&0<=ft(u.to,o.from))return!0;ft(o.from,u.from)<0?o=(r=n.next(u.from)).value:u=(a=i.next(o.from)).value}return!1}function In(e){var n=Cn(e)?null:{s:0,n:e};return{next:function(e){for(var t=0<arguments.length;n;)switch(n.s){case 0:if(n.s=1,t)for(;n.n.l&&ft(e,n.n.from)<0;)n={up:n,n:n.n.l,s:1};else for(;n.n.l;)n={up:n,n:n.n.l,s:1};case 1:if(n.s=2,!t||ft(e,n.n.to)<=0)return{value:n.n,done:!1};case 2:if(n.n.r){n.s=3,n={up:n,n:n.n.r,s:0};continue}case 3:n=n.up}return{done:!0}}}}function qn(e){var t,n,r=((null===(t=e.r)||void 0===t?void 0:t.d)||0)-((null===(n=e.l)||void 0===n?void 0:n.d)||0),o=1<r?"r":r<-1?"l":"";o&&(t="r"==o?"l":"r",n=w({},e),r=e[o],e.from=r.from,e.to=r.to,e[o]=r[o],n[o]=r[t],(e[t]=n).d=Bn(n)),e.d=Bn(e)}function Bn(e){var t=e.r,e=e.l;return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}function Rn(t,n){return P(n).forEach(function(e){t[e]?Tn(t[e],n[e]):t[e]=function e(t){var n,r,o={};for(n in t)b(t,n)&&(r=t[n],o[n]=!r||"object"!=typeof r||K.has(r.constructor)?r:e(r));return o}(n[e])}),t}function Mn(t,n){return t.all||n.all||Object.keys(t).some(function(e){return n[e]&&Dn(n[e],t[e])})}o(jn.prototype,((U={add:function(e){return Tn(this,e),this},addKey:function(e){return An(this,e,e),this},addKeys:function(e){var t=this;return e.forEach(function(e){return An(t,e,e)}),this},hasKey:function(e){var t=In(this).next(e).value;return t&&ft(t.from,e)<=0&&0<=ft(t.to,e)}})[D]=function(){return In(this)},U));var Fn={},Nn={},Un=!1;function Ln(e){Rn(Nn,e),Un||(Un=!0,setTimeout(function(){Un=!1,Yn(Nn,!(Nn={}))},0))}function Yn(e,t){var n,r;void 0===t&&(t=!1);var o=new Set;if(e.all)try{for(var i=B(Object.values(Fn)),a=i.next();!a.done;a=i.next())Vn(s=a.value,e,o,t)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}else for(var u in e){var s,c=/^idb\:\/\/(.*)\/(.*)\//.exec(u);c&&(c=(u=k(c,3))[1],u=u[2],(s=Fn["idb://".concat(c,"/").concat(u)])&&Vn(s,e,o,t))}o.forEach(function(e){return e()})}function Vn(e,t,n,r){var o,i,a,u,s,c,l=[];try{for(var f=B(Object.entries(e.queries.query)),h=f.next();!h.done;h=f.next()){var d=k(h.value,2),p=d[0],y=d[1],v=[];try{for(var m=(a=void 0,B(y)),b=m.next();!b.done;b=m.next()){var g=b.value;Mn(t,g.obsSet)?g.subscribers.forEach(function(e){return n.add(e)}):r&&v.push(g)}}catch(e){a={error:e}}finally{try{b&&!b.done&&(u=m.return)&&u.call(m)}finally{if(a)throw a.error}}r&&l.push([p,v])}}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}if(r)try{for(var w=B(l),_=w.next();!_.done;_=w.next()){var x=k(_.value,2),p=x[0],v=x[1];e.queries.query[p]=v}}catch(e){s={error:e}}finally{try{_&&!_.done&&(c=w.return)&&c.call(w)}finally{if(s)throw s.error}}}function zn(f){var h=f._state,r=f._deps.indexedDB;if(h.isBeingOpened||f.idbdb)return h.dbReadyPromise.then(function(){return h.dbOpenError?Ze(h.dbOpenError):f});h.isBeingOpened=!0,h.dbOpenError=null,h.openComplete=!1;var t=h.openCanceller,d=Math.round(10*f.verno),p=!1;function e(){if(h.openCanceller!==t)throw new H.DatabaseClosed("db.open() was cancelled")}function y(){return new Pe(function(s,n){if(e(),!r)throw new H.MissingAPI;var c=f.name,l=h.autoSchema||!d?r.open(c):r.open(c,d);if(!l)throw new H.MissingAPI;l.onerror=Wt(n),l.onblocked=Be(f._fireOnBlocked),l.onupgradeneeded=Be(function(e){var t;v=l.transaction,h.autoSchema&&!f._options.allowEmptyDB?(l.onerror=$t,v.abort(),l.result.close(),(t=r.deleteDatabase(c)).onsuccess=t.onerror=Be(function(){n(new H.NoSuchDatabase("Database ".concat(c," doesnt exist")))})):(v.onerror=Wt(n),e=e.oldVersion>Math.pow(2,62)?0:e.oldVersion,m=e<1,f.idbdb=l.result,p&&yn(f,v),pn(f,e/10,v,n))},n),l.onsuccess=Be(function(){v=null;var e,t,n,r,o,i=f.idbdb=l.result,a=g(i.objectStoreNames);if(0<a.length)try{var u=i.transaction(1===(r=a).length?r[0]:r,"readonly");if(h.autoSchema)t=i,n=u,(e=f).verno=t.version/10,n=e._dbSchema=wn(0,t,n),e._storeNames=g(t.objectStoreNames,0),fn(e,[e._allTables],P(n),n);else if(_n(f,f._dbSchema,u),((o=vn(wn(0,(o=f).idbdb,u),o._dbSchema)).add.length||o.change.some(function(e){return e.add.length||e.change.length}))&&!p)return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."),i.close(),d=i.version+1,p=!0,s(y());ln(f,u)}catch(e){}rt.push(f),i.onversionchange=Be(function(e){h.vcFired=!0,f.on("versionchange").fire(e)}),i.onclose=Be(function(e){f.on("close").fire(e)}),m&&(o=f._deps,u=c,i=o.indexedDB,o=o.IDBKeyRange,Sn(i)||u===ot||En(i,o).put({name:u}).catch(J)),s()},n)}).catch(function(e){switch(null==e?void 0:e.name){case"UnknownError":if(0<h.PR1398_maxLoop)return h.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),y();break;case"VersionError":if(0<d)return d=0,y()}return Pe.reject(e)})}var n,o=h.dbReadyResolve,v=null,m=!1;return Pe.race([t,("undefined"==typeof navigator?Pe.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}n=setInterval(t,100),t()}).finally(function(){return clearInterval(n)}):Promise.resolve()).then(y)]).then(function(){return e(),h.onReadyBeingFired=[],Pe.resolve(Kn(function(){return f.on.ready.fire(f.vip)})).then(function e(){if(0<h.onReadyBeingFired.length){var t=h.onReadyBeingFired.reduce(ae,J);return h.onReadyBeingFired=[],Pe.resolve(Kn(function(){return t(f.vip)})).then(e)}})}).finally(function(){h.openCanceller===t&&(h.onReadyBeingFired=null,h.isBeingOpened=!1)}).catch(function(e){h.dbOpenError=e;try{v&&v.abort()}catch(e){}return t===h.openCanceller&&f._close(),Ze(e)}).finally(function(){h.openComplete=!0,o()}).then(function(){var n;return m&&(n={},f.tables.forEach(function(t){t.schema.indexes.forEach(function(e){e.name&&(n["idb://".concat(f.name,"/").concat(t.name,"/").concat(e.name)]=new jn(-1/0,[[[]]]))}),n["idb://".concat(f.name,"/").concat(t.name,"/")]=n["idb://".concat(f.name,"/").concat(t.name,"/:dels")]=new jn(-1/0,[[[]]])}),Qt(Gt).fire(n),Yn(n,!0)),f})}function Wn(t){function e(e){return t.next(e)}var r=n(e),o=n(function(e){return t.throw(e)});function n(n){return function(e){var t=n(e),e=t.value;return t.done?e:e&&"function"==typeof e.then?e.then(r,o):x(e)?Promise.all(e).then(r,o):r(e)}}return n(e)()}function $n(e,t,n){for(var r=x(e)?e.slice():[e],o=0;o<n;++o)r.push(t);return r}var Gn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(h){return w(w({},h),{table:function(e){var t,n,a=h.table(e),r=a.schema,u={},s=[];function c(e,t,n){var r=un(e),o=u[r]=u[r]||[],i=null==e?0:"string"==typeof e?1:e.length,a=0<t,a=w(w({},n),{name:a?"".concat(r,"(virtual-from:").concat(n.name,")"):n.name,lowLevelIndex:n,isVirtual:a,keyTail:t,keyLength:i,extractKey:rn(e),unique:!a&&n.unique});return o.push(a),a.isPrimaryKey||s.push(a),1<i&&c(2===i?e[0]:e.slice(0,i-1),t+1,n),o.sort(function(e,t){return e.keyTail-t.keyTail}),a}e=c(r.primaryKey.keyPath,0,r.primaryKey);u[":id"]=[e];try{for(var o=B(r.indexes),i=o.next();!i.done;i=o.next()){var l=i.value;c(l.keyPath,0,l)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}function f(e){var t,n=e.query.index;return n.isVirtual?w(w({},e),{query:{index:n.lowLevelIndex,range:(t=e.query.range,n=n.keyTail,{type:1===t.type?2:t.type,lower:$n(t.lower,t.lowerOpen?h.MAX_KEY:h.MIN_KEY,n),lowerOpen:!0,upper:$n(t.upper,t.upperOpen?h.MIN_KEY:h.MAX_KEY,n),upperOpen:!0})}}):e}return w(w({},a),{schema:w(w({},r),{primaryKey:e,indexes:s,getIndexByKeyPath:function(e){return(e=u[un(e)])&&e[0]}}),count:function(e){return a.count(f(e))},query:function(e){return a.query(f(e))},openCursor:function(t){var e=t.query.index,r=e.keyTail,n=e.isVirtual,o=e.keyLength;return n?a.openCursor(f(t)).then(function(e){return e&&i(e)}):a.openCursor(t);function i(n){return Object.create(n,{continue:{value:function(e){null!=e?n.continue($n(e,t.reverse?h.MAX_KEY:h.MIN_KEY,r)):t.unique?n.continue(n.key.slice(0,o).concat(t.reverse?h.MIN_KEY:h.MAX_KEY,r)):n.continue()}},continuePrimaryKey:{value:function(e,t){n.continuePrimaryKey($n(e,h.MAX_KEY,r),t)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var e=n.key;return 1===o?e[0]:e.slice(0,o)}},value:{get:function(){return n.value}}})}}})}})}};function Hn(o,i,a,u){return a=a||{},u=u||"",P(o).forEach(function(e){var t,n,r;b(i,e)?(t=o[e],n=i[e],"object"==typeof t&&"object"==typeof n&&t&&n?(r=T(t))!==T(n)?a[u+e]=i[e]:"Object"===r?Hn(t,n,a,u+e+"."):t!==n&&(a[u+e]=i[e]):t!==n&&(a[u+e]=i[e])):a[u+e]=void 0}),P(i).forEach(function(e){b(o,e)||(a[u+e]=i[e])}),a}function Qn(e,t){return"delete"===t.type?t.keys:t.keys||t.values.map(e.extractKey)}var Xn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(e){return w(w({},e),{table:function(r){var y=e.table(r),v=y.schema.primaryKey;return w(w({},y),{mutate:function(e){var t=we.trans,n=t.table(r).hook,h=n.deleting,d=n.creating,p=n.updating;switch(e.type){case"add":if(d.fire===J)break;return t._promise("readwrite",function(){return a(e)},!0);case"put":if(d.fire===J&&p.fire===J)break;return t._promise("readwrite",function(){return a(e)},!0);case"delete":if(h.fire===J)break;return t._promise("readwrite",function(){return a(e)},!0);case"deleteRange":if(h.fire===J)break;return t._promise("readwrite",function(){return function n(r,o,i){return y.query({trans:r,values:!1,query:{index:v,range:o},limit:i}).then(function(e){var t=e.result;return a({type:"delete",keys:t,trans:r}).then(function(e){return 0<e.numFailures?Promise.reject(e.failures[0]):t.length<i?{failures:[],numFailures:0,lastResult:void 0}:n(r,w(w({},o),{lower:t[t.length-1],lowerOpen:!0}),i)})})}(e.trans,e.range,1e4)},!0)}return y.mutate(e);function a(c){var e,t,n,l=we.trans,f=c.keys||Qn(v,c);if(!f)throw new Error("Keys missing");return"delete"!==(c="add"===c.type||"put"===c.type?w(w({},c),{keys:f}):w({},c)).type&&(c.values=m([],k(c.values),!1)),c.keys&&(c.keys=m([],k(c.keys),!1)),e=y,n=f,("add"===(t=c).type?Promise.resolve([]):e.getMany({trans:t.trans,keys:n,cache:"immutable"})).then(function(u){var s=f.map(function(e,t){var n,r,o,i=u[t],a={onerror:null,onsuccess:null};return"delete"===c.type?h.fire.call(a,e,i,l):"add"===c.type||void 0===i?(n=d.fire.call(a,e,c.values[t],l),null==e&&null!=n&&(c.keys[t]=e=n,v.outbound||E(c.values[t],v.keyPath,e))):(n=Hn(i,c.values[t]),(r=p.fire.call(a,n,e,i,l))&&(o=c.values[t],Object.keys(r).forEach(function(e){b(o,e)?o[e]=r[e]:E(o,e,r[e])}))),a});return y.mutate(c).then(function(e){for(var t=e.failures,n=e.results,r=e.numFailures,e=e.lastResult,o=0;o<f.length;++o){var i=(n||f)[o],a=s[o];null==i?a.onerror&&a.onerror(t[o]):a.onsuccess&&a.onsuccess("put"===c.type&&u[o]?c.values[o]:i)}return{failures:t,results:n,numFailures:r,lastResult:e}}).catch(function(t){return s.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function Jn(e,t,n){try{if(!t)return null;if(t.keys.length<e.length)return null;for(var r=[],o=0,i=0;o<t.keys.length&&i<e.length;++o)0===ft(t.keys[o],e[i])&&(r.push(n?j(t.values[o]):t.values[o]),++i);return r.length===e.length?r:null}catch(e){return null}}var Zn={stack:"dbcore",level:-1,create:function(t){return{table:function(e){var n=t.table(e);return w(w({},n),{getMany:function(t){if(!t.cache)return n.getMany(t);var e=Jn(t.keys,t.trans._cache,"clone"===t.cache);return e?Pe.resolve(e):n.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?j(e):e},e})},mutate:function(e){return"add"!==e.type&&(e.trans._cache=null),n.mutate(e)}})}}}};function er(e,t){return"readonly"===e.trans.mode&&!!e.subscr&&!e.trans.explicit&&"disabled"!==e.trans.db._options.cache&&!t.schema.primaryKey.outbound}function tr(e,t){switch(e){case"query":return t.values&&!t.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var nr={stack:"dbcore",level:0,name:"Observability",create:function(r){var b=r.schema.name,g=new jn(r.MIN_KEY,r.MAX_KEY);return w(w({},r),{transaction:function(e,t,n){if(we.subscr&&"readonly"!==t)throw new H.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(we.querier));return r.transaction(e,t,n)},table:function(d){var p=r.table(d),y=p.schema,v=y.primaryKey,e=y.indexes,c=v.extractKey,l=v.outbound,m=v.autoIncrement&&e.filter(function(e){return e.compound&&e.keyPath.includes(v.keyPath)}),t=w(w({},p),{mutate:function(o){function i(e){return e="idb://".concat(b,"/").concat(d,"/").concat(e),n[e]||(n[e]=new jn)}var e,a,u,t=o.trans,n=o.mutatedParts||(o.mutatedParts={}),r=i(""),s=i(":dels"),c=o.type,l=k("deleteRange"===o.type?[o.range]:"delete"===o.type?[o.keys]:o.values.length<50?[Qn(v,o).filter(function(e){return e}),o.values]:[],2),f=l[0],h=l[1],l=o.trans._cache;return x(f)?(r.addKeys(f),(l="delete"===c||f.length===h.length?Jn(f,l):null)||s.addKeys(f),(l||h)&&(e=i,a=l,u=h,y.indexes.forEach(function(t){var n=e(t.name||"");function r(e){return null!=e?t.extractKey(e):null}function o(e){return t.multiEntry&&x(e)?e.forEach(function(e){return n.addKey(e)}):n.addKey(e)}(a||u).forEach(function(e,t){var n=a&&r(a[t]),t=u&&r(u[t]);0!==ft(n,t)&&(null!=n&&o(n),null!=t&&o(t))})}))):f?(h={from:f.lower,to:f.upper},s.add(h),r.add(h)):(r.add(g),s.add(g),y.indexes.forEach(function(e){return i(e.name).add(g)})),p.mutate(o).then(function(e){return!f||"add"!==o.type&&"put"!==o.type||(r.addKeys(e.results),m&&m.forEach(function(t){var n=o.values.map(function(e){return t.extractKey(e)}),r=t.keyPath.findIndex(function(e){return e===v.keyPath});e.results.forEach(function(e){return n[r]=e}),i(t.name).addKeys(n)})),t.mutatedParts=Rn(t.mutatedParts||{},n),e})}}),e=function(e){var t=e.query,e=t.index,t=t.range;return[e,new jn(null!==(e=t.lower)&&void 0!==e?e:r.MIN_KEY,null!==(t=t.upper)&&void 0!==t?t:r.MAX_KEY)]},f={get:function(e){return[v,new jn(e.key)]},getMany:function(e){return[v,(new jn).addKeys(e.keys)]},count:e,query:e,openCursor:e};return P(f).forEach(function(s){t[s]=function(o){var e=we.subscr,t=!!e,n=er(we,p)&&tr(s,o)?o.obsSet={}:e;if(t){var r=function(e){e="idb://".concat(b,"/").concat(d,"/").concat(e);return n[e]||(n[e]=new jn)},i=r(""),a=r(":dels"),e=k(f[s](o),2),t=e[0],e=e[1];if(("query"===s&&t.isPrimaryKey&&!o.values?a:r(t.name||"")).add(e),!t.isPrimaryKey){if("count"!==s){var u="query"===s&&l&&o.values&&p.query(w(w({},o),{values:!1}));return p[s].apply(this,arguments).then(function(t){if("query"===s){if(l&&o.values)return u.then(function(e){e=e.result;return i.addKeys(e),t});var e=o.values?t.result.map(c):t.result;(o.values?i:a).addKeys(e)}else if("openCursor"===s){var n=t,r=o.values;return n&&Object.create(n,{key:{get:function(){return a.addKey(n.primaryKey),n.key}},primaryKey:{get:function(){var e=n.primaryKey;return a.addKey(e),e}},value:{get:function(){return r&&i.addKey(n.primaryKey),n.value}}})}return t})}a.add(g)}}return p[s].apply(this,arguments)}}),t}})}};function rr(e,t,n){if(0===n.numFailures)return t;if("deleteRange"===t.type)return null;var r=t.keys?t.keys.length:"values"in t&&t.values?t.values.length:1;if(n.numFailures===r)return null;t=w({},t);return x(t.keys)&&(t.keys=t.keys.filter(function(e,t){return!(t in n.failures)})),"values"in t&&x(t.values)&&(t.values=t.values.filter(function(e,t){return!(t in n.failures)})),t}function or(e,t){return n=e,(void 0===(r=t).lower||(r.lowerOpen?0<ft(n,r.lower):0<=ft(n,r.lower)))&&(e=e,void 0===(t=t).upper||(t.upperOpen?ft(e,t.upper)<0:ft(e,t.upper)<=0));var n,r}function ir(e,h,t,n,r,o){if(!t||0===t.length)return e;var i=h.query.index,d=i.multiEntry,p=h.query.range,y=n.schema.primaryKey.extractKey,v=i.extractKey,a=(i.lowLevelIndex||i).extractKey,t=t.reduce(function(e,t){var n=e,r=[];if("add"===t.type||"put"===t.type)for(var o=new jn,i=t.values.length-1;0<=i;--i){var a,u=t.values[i],s=y(u);o.hasKey(s)||(a=v(u),(d&&x(a)?a.some(function(e){return or(e,p)}):or(a,p))&&(o.addKey(s),r.push(u)))}switch(t.type){case"add":n=e.concat(h.values?r:r.map(function(e){return y(e)}));break;case"put":var c=(new jn).addKeys(t.values.map(function(e){return y(e)})),n=e.filter(function(e){return!c.hasKey(h.values?y(e):e)}).concat(h.values?r:r.map(function(e){return y(e)}));break;case"delete":var l=(new jn).addKeys(t.keys);n=e.filter(function(e){return!l.hasKey(h.values?y(e):e)});break;case"deleteRange":var f=t.range;n=e.filter(function(e){return!or(y(e),f)})}return n},e);return t===e?e:(t.sort(function(e,t){return ft(a(e),a(t))||ft(y(e),y(t))}),h.limit&&h.limit<1/0&&(t.length>h.limit?t.length=h.limit:e.length===h.limit&&t.length<h.limit&&(r.dirty=!0)),o?Object.freeze(t):t)}function ar(e,t){return 0===ft(e.lower,t.lower)&&0===ft(e.upper,t.upper)&&!!e.lowerOpen==!!t.lowerOpen&&!!e.upperOpen==!!t.upperOpen}function ur(e,t){return function(e,t,n,r){if(void 0===e)return void 0!==t?-1:0;if(void 0===t)return 1;if(0===(t=ft(e,t))){if(n&&r)return 0;if(n)return 1;if(r)return-1}return t}(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=function(e,t,n,r){if(void 0===e)return void 0!==t?1:0;if(void 0===t)return-1;if(0===(t=ft(e,t))){if(n&&r)return 0;if(n)return-1;if(r)return 1}return t}(e.upper,t.upper,e.upperOpen,t.upperOpen)}function sr(n,r,o,e){n.subscribers.add(o),e.addEventListener("abort",function(){var e,t;n.subscribers.delete(o),0===n.subscribers.size&&(e=n,t=r,setTimeout(function(){0===e.subscribers.size&&R(t,e)},3e3))})}var cr={stack:"dbcore",level:0,name:"Cache",create:function(I){var q=I.schema.name;return w(w({},I),{transaction:function(j,A,e){var T,t,D=I.transaction(j,A,e);return"readwrite"===A&&(t=(T=new AbortController).signal,e=function(C){return function(){var t,e,n,r,o,i,a,u,s,c;if(T.abort(),"readwrite"===A){var l=new Set;try{for(var f=B(j),h=f.next();!h.done;h=f.next()){var d=h.value,p=Fn["idb://".concat(q,"/").concat(d)];if(p){var y=I.table(d),v=p.optimisticOps.filter(function(e){return e.trans===D});if(D._explicit&&C&&D.mutatedParts)try{for(var m=(n=void 0,B(Object.values(p.queries.query))),b=m.next();!b.done;b=m.next()){var g=b.value;try{for(var w=(o=void 0,B(g.slice())),_=w.next();!_.done;_=w.next())Mn((P=_.value).obsSet,D.mutatedParts)&&(R(g,P),P.subscribers.forEach(function(e){return l.add(e)}))}catch(e){o={error:e}}finally{try{_&&!_.done&&(i=w.return)&&i.call(w)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{b&&!b.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}else if(0<v.length){p.optimisticOps=p.optimisticOps.filter(function(e){return e.trans!==D});try{for(var x=(a=void 0,B(Object.values(p.queries.query))),k=x.next();!k.done;k=x.next()){g=k.value;try{for(var P,O,E,S=(s=void 0,B(g.slice())),K=S.next();!K.done;K=S.next())null!=(P=K.value).res&&D.mutatedParts&&(C&&!P.dirty?(O=Object.isFrozen(P.res),E=ir(P.res,P.req,v,y,P,O),P.dirty?(R(g,P),P.subscribers.forEach(function(e){return l.add(e)})):E!==P.res&&(P.res=E,P.promise=Pe.resolve({result:E}))):(P.dirty&&R(g,P),P.subscribers.forEach(function(e){return l.add(e)})))}catch(e){s={error:e}}finally{try{K&&!K.done&&(c=S.return)&&c.call(S)}finally{if(s)throw s.error}}}}catch(e){a={error:e}}finally{try{k&&!k.done&&(u=x.return)&&u.call(x)}finally{if(a)throw a.error}}}}}}catch(e){t={error:e}}finally{try{h&&!h.done&&(e=f.return)&&e.call(f)}finally{if(t)throw t.error}}l.forEach(function(e){return e()})}}},D.addEventListener("abort",e(!1),{signal:t}),D.addEventListener("error",e(!1),{signal:t}),D.addEventListener("complete",e(!0),{signal:t})),D},table:function(c){var l=I.table(c),o=l.schema.primaryKey;return w(w({},l),{mutate:function(t){var e=we.trans;if(o.outbound||"disabled"===e.db._options.cache||e.explicit)return l.mutate(t);var n=Fn["idb://".concat(q,"/").concat(c)];if(!n)return l.mutate(t);e=l.mutate(t);return"add"!==t.type&&"put"!==t.type||!(50<=t.values.length||Qn(o,t).some(function(e){return null==e}))?(n.optimisticOps.push(t),t.mutatedParts&&Ln(t.mutatedParts),e.then(function(e){0<e.numFailures&&(R(n.optimisticOps,t),(e=rr(0,t,e))&&n.optimisticOps.push(e),t.mutatedParts&&Ln(t.mutatedParts))}),e.catch(function(){R(n.optimisticOps,t),t.mutatedParts&&Ln(t.mutatedParts)})):e.then(function(r){var e=rr(0,w(w({},t),{values:t.values.map(function(e,t){var n,e=null!==(n=o.keyPath)&&void 0!==n&&n.includes(".")?j(e):w({},e);return E(e,o.keyPath,r.results[t]),e})}),r);n.optimisticOps.push(e),queueMicrotask(function(){return t.mutatedParts&&Ln(t.mutatedParts)})}),e},query:function(t){if(!er(we,l)||!tr("query",t))return l.query(t);var o="immutable"===(null===(i=we.trans)||void 0===i?void 0:i.db._options.cache),e=we,n=e.requery,r=e.signal,i=k(function(e,t,n,r){var o=Fn["idb://".concat(e,"/").concat(t)];if(!o)return[];if(!(t=o.queries[n]))return[null,!1,o,null];var i=t[(r.query?r.query.index.name:null)||""];if(!i)return[null,!1,o,null];switch(n){case"query":var a=i.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&ar(e.req.query.range,r.query.range)});return a?[a,!0,o,i]:[i.find(function(e){return("limit"in e.req?e.req.limit:1/0)>=r.limit&&(!r.values||e.req.values)&&ur(e.req.query.range,r.query.range)}),!1,o,i];case"count":a=i.find(function(e){return ar(e.req.query.range,r.query.range)});return[a,!!a,o,i]}}(q,c,"query",t),4),a=i[0],e=i[1],u=i[2],s=i[3];return a&&e?a.obsSet=t.obsSet:(e=l.query(t).then(function(e){var t=e.result;if(a&&(a.res=t),o){for(var n=0,r=t.length;n<r;++n)Object.freeze(t[n]);Object.freeze(t)}else e.result=j(t);return e}).catch(function(e){return s&&a&&R(s,a),Promise.reject(e)}),a={obsSet:t.obsSet,promise:e,subscribers:new Set,type:"query",req:t,dirty:!1},s?s.push(a):(s=[a],(u=u||(Fn["idb://".concat(q,"/").concat(c)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[t.query.index.name||""]=s)),sr(a,s,n,r),a.promise.then(function(e){return{result:ir(e.result,t,null==u?void 0:u.optimisticOps,l,a,o)}})}})}})}};function lr(e,r){return new Proxy(e,{get:function(e,t,n){return"db"===t?r:Reflect.get(e,t,n)}})}function fr(n,r){var t,e,o,i,a=Promise.resolve();try{for(var u=B(n.tables),s=u.next();!s.done;s=u.next()){var c=s.value,l=function(e){a=a.then(function(){return d=n,t=r,p=e.updatesTable,y=d.table(p),Promise.all([y.where("i").startsWith("").toArray(),d.transaction("rw",p,function(){return y.get(0).then(function(e){return e&&t&&e.lastRun.getTime()>Date.now()-t?null:(e=e||{i:0,lastCompressed:0},y.put(w(w({},e),{lastRun:new Date})).then(function(){return e}))})})]).then(function(e){var t=k(e,2),e=t[0],t=t[1];if(t){var f=t.lastCompressed,h=Math.min.apply(Math,m([],k(e.map(function(e){return Math.min(e.unsentFrom||1/0,null!=e.receivedUntil?e.receivedUntil+1:1/0)})),!1));return y.where("i").between(f,1/0,!1).toArray(function(o){var t,e;if(0!==o.length){for(var i=[],a=f,n=0;n<o.length;++n)if("break"===function(e){var t=o[e],n=t.i,e=t.f,r=t.k;if(h<=n&&1&e)return"break";e=i.find(function(e){return 0===ft(e.docId,r)});e?e.updates.push(t):i.push({docId:r,updates:[t]}),a=n}(n))break;if(a!==f){var r=Promise.resolve(),u=function(e,t){r=r.then(function(){return function(u,t,s,c){if(c.length<1)throw new Error("Invalid input");return u.transaction("rw",t,function(e){var a=e.table(t);return a.where({k:s}).first(function(t){var e=[t].concat(c.filter(function(e){return e.i!==t.i})),n=wt(u),r=new n.Doc({gc:!0});e.forEach(function(e){n.applyUpdateV2(r,e.u)});var o=n.encodeStateAsUpdateV2(r),i=e.pop();return a.put({i:i.i,k:s,u:o}).then(function(){return a.bulkDelete(e.map(function(e){return e.i}))})})})}(d,p,e,t)})};try{for(var s=B(i),c=s.next();!c.done;c=s.next()){var l=c.value;u(l.docId,l.updates)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return r.then(function(){return d.transaction("rw",y,function(){return y.get(0).then(function(e){if(!(e&&a<=e.lastCompressed))return y.put(w(w({},e),{lastCompressed:a}))})})})}}})}});var d,t,p,y})};try{for(var f=(o=void 0,B(c.schema.yProps||[])),h=f.next();!h.done;h=f.next())l(h.value)}catch(e){o={error:e}}finally{try{h&&!h.done&&(i=f.return)&&i.call(f)}finally{if(o)throw o.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(e=u.return)&&e.call(u)}finally{if(t)throw t.error}}return a}var hr=1e4,dr=3e5;var pr=(yr.prototype.version=function(t){if(isNaN(t)||t<.1)throw new H.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new H.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);var e=this._versions,n=e.filter(function(e){return e._cfg.version===t})[0];return n||(n=new this.Version(t),e.push(n),e.sort(dn),n.stores({}),this._state.autoSchema=!1,n)},yr.prototype._whenReady=function(e){var n=this;return this.idbdb&&(this._state.openComplete||we.letThrough||this._vip)?e():new Pe(function(e,t){if(n._state.openComplete)return t(new H.DatabaseClosed(n._state.dbOpenError));if(!n._state.isBeingOpened){if(!n._state.autoOpen)return void t(new H.DatabaseClosed);n.open().catch(J)}n._state.dbReadyPromise.then(e,t)}).then(e)},yr.prototype.use=function(e){var t=e.stack,n=e.create,r=e.level,o=e.name;o&&this.unuse({stack:t,name:o});e=this._middlewares[t]||(this._middlewares[t]=[]);return e.push({stack:t,create:n,level:null==r?10:r,name:o}),e.sort(function(e,t){return e.level-t.level}),this},yr.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},yr.prototype.open=function(){var e=this;return Qe(ge,function(){return zn(e)})},yr.prototype._close=function(){this.on.close.fire(new CustomEvent("close"));var n=this._state,e=rt.indexOf(this);if(0<=e&&rt.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(e){}this.idbdb=null}n.isBeingOpened||(n.dbReadyPromise=new Pe(function(e){n.dbReadyResolve=e}),n.openCanceller=new Pe(function(e,t){n.cancelOpen=t}))},yr.prototype.close=function(e){var t=(void 0===e?{disableAutoOpen:!0}:e).disableAutoOpen,e=this._state;t?(e.isBeingOpened&&e.cancelOpen(new H.DatabaseClosed),this._close(),e.autoOpen=!1,e.dbOpenError=new H.DatabaseClosed):(this._close(),e.autoOpen=this._options.autoOpen||e.isBeingOpened,e.openComplete=!1,e.dbOpenError=null)},yr.prototype.delete=function(n){var o=this;void 0===n&&(n={disableAutoOpen:!0});var i=0<arguments.length&&"object"!=typeof arguments[0],a=this._state;return new Pe(function(r,t){function e(){o.close(n);var e=o._deps.indexedDB.deleteDatabase(o.name);e.onsuccess=Be(function(){var e,t,n;e=o._deps,t=o.name,n=e.indexedDB,e=e.IDBKeyRange,Sn(n)||t===ot||En(n,e).delete(t).catch(J),r()}),e.onerror=Wt(t),e.onblocked=o._fireOnBlocked}if(i)throw new H.InvalidArgument("Invalid closeOptions argument to db.delete()");a.isBeingOpened?a.dbReadyPromise.then(e):e()})},yr.prototype.backendDB=function(){return this.idbdb},yr.prototype.isOpen=function(){return null!==this.idbdb},yr.prototype.hasBeenClosed=function(){var e=this._state.dbOpenError;return e&&"DatabaseClosed"===e.name},yr.prototype.hasFailed=function(){return null!==this._state.dbOpenError},yr.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(yr.prototype,"tables",{get:function(){var t=this;return P(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),yr.prototype.transaction=function(){var e=function(e,t,n){var r=arguments.length;if(r<2)throw new H.InvalidArgument("Too few arguments");for(var o=new Array(r-1);--r;)o[r-1]=arguments[r];return n=o.pop(),[e,S(o),n]}.apply(this,arguments);return this._transaction.apply(this,e)},yr.prototype._transaction=function(e,t,n){var r=this,o=we.trans;o&&o.db===this&&-1===e.indexOf("!")||(o=null);var i,a,u=-1!==e.indexOf("?");e=e.replace("!","").replace("?","");try{if(a=t.map(function(e){e=e instanceof r.Table?e.name:e;if("string"!=typeof e)throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return e}),"r"==e||e===it)i=it;else{if("rw"!=e&&e!=at)throw new H.InvalidArgument("Invalid transaction mode: "+e);i=at}if(o){if(o.mode===it&&i===at){if(!u)throw new H.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");o=null}o&&a.forEach(function(e){if(o&&-1===o.storeNames.indexOf(e)){if(!u)throw new H.SubTransaction("Table "+e+" not included in parent transaction.");o=null}}),u&&o&&!o.active&&(o=null)}}catch(n){return o?o._promise(null,function(e,t){t(n)}):Ze(n)}var s=function o(i,a,u,s,c){return Pe.resolve().then(function(){var e=we.transless||we,t=i._createTransaction(a,u,i._dbSchema,s);if(t.explicit=!0,e={trans:t,transless:e},s)t.idbtrans=s.idbtrans;else try{t.create(),t.idbtrans._explicit=!0,i._state.PR1398_maxLoop=3}catch(e){return e.name===$.InvalidState&&i.isOpen()&&0<--i._state.PR1398_maxLoop?(console.warn("Dexie: Need to reopen db"),i.close({disableAutoOpen:!1}),i.open().then(function(){return o(i,a,u,null,c)})):Ze(e)}var n,r=F(c);return r&&Ve(),e=Pe.follow(function(){var e;(n=c.call(t,t))&&(r?(e=ze.bind(null,null),n.then(e,e)):"function"==typeof n.next&&"function"==typeof n.throw&&(n=Wn(n)))},e),(n&&"function"==typeof n.then?Pe.resolve(n).then(function(e){return t.active?e:Ze(new H.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):e.then(function(){return n})).then(function(e){return s&&t._resolve(),t._completion.then(function(){return e})}).catch(function(e){return t._reject(e),Ze(e)})})}.bind(null,this,i,a,o,n);return o?o._promise(i,s,"lock"):we.trans?Qe(we.transless,function(){return r._whenReady(s)}):this._whenReady(s)},yr.prototype.table=function(e){if(!b(this._allTables,e))throw new H.InvalidTable("Table ".concat(e," does not exist"));return this._allTables[e]},yr.prototype.gc=function(){return fr(this)},yr);function yr(e,t){var i=this;this._middlewares={},this.verno=0;var n=yr.dependencies;this._options=t=w({addons:yr.addons,autoOpen:!0,indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange,cache:"cloned"},t),this._deps={indexedDB:t.indexedDB,IDBKeyRange:t.IDBKeyRange};n=t.addons;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var a,r,u,o,s,c={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:J,dbReadyPromise:null,cancelOpen:J,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:t.autoOpen};c.dbReadyPromise=new Pe(function(e){c.dbReadyResolve=e}),c.openCanceller=new Pe(function(e,t){c.cancelOpen=t}),this._state=c,this.name=e,this.on=kt(this,"populate","blocked","versionchange","close","y",{ready:[ae,J]}),this.once=function(n,r){var o=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i.on(n).unsubscribe(o),r.apply(i,e)};return i.on(n,o)},this.on.ready.subscribe=p(this.on.ready.subscribe,function(o){return function(n,r){yr.vip(function(){var t,e=i._state;e.openComplete?(e.dbOpenError||Pe.resolve().then(n),r&&o(n)):e.onReadyBeingFired?(e.onReadyBeingFired.push(n),r&&o(n)):(o(n),t=i,r||o(function e(){t.on.ready.unsubscribe(n),t.on.ready.unsubscribe(e)}))})}}),this.Collection=(a=this,Pt(It.prototype,function(e,t){this.db=a;var n=st,r=null;if(t)try{n=t()}catch(e){r=e}var o=e._ctx,t=o.table,e=t.hook.reading.fire;this._ctx={table:t,index:o.index,isPrimKey:!o.index||t.schema.primKey.keyPath&&o.index===t.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:o.or,valueMapper:e!==Z?e:null}})),this.Table=(r=this,Pt(_t.prototype,function(e,t,n){this.db=r,this._tx=n,this.name=e,this.schema=t,this.hook=r._allTables[e]?r._allTables[e].hook:kt(null,{creating:[ne,J],reading:[ee,Z],updating:[oe,J],deleting:[re,J]})})),this.Transaction=(u=this,Pt(Xt.prototype,function(e,t,n,r,o){var i=this;"readonly"!==e&&t.forEach(function(e){e=null===(e=n[e])||void 0===e?void 0:e.yProps;e&&(t=t.concat(e.map(function(e){return e.updatesTable})))}),this.db=u,this.mode=e,this.storeNames=t,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=kt(this,"complete","error","abort"),this.parent=o||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 Pe(function(e,t){i._resolve=e,i._reject=t}),this._completion.then(function(){i.active=!1,i.on.complete.fire()},function(e){var t=i.active;return i.active=!1,i.on.error.fire(e),i.parent?i.parent._reject(e):t&&i.idbtrans&&i.idbtrans.abort(),Ze(e)})})),this.Version=(o=this,Pt(Pn.prototype,function(e){this.db=o,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(s=this,Pt(Vt.prototype,function(e,t,n){if(this.db=s,this._ctx={table:e,index:":id"===t?null:t,or:n},this._cmp=this._ascending=ft,this._descending=function(e,t){return ft(t,e)},this._max=function(e,t){return 0<ft(e,t)?e:t},this._min=function(e,t){return ft(e,t)<0?e:t},this._IDBKeyRange=s._deps.IDBKeyRange,!this._IDBKeyRange)throw new H.MissingAPI})),this.on("versionchange",function(e){0<e.newVersion?console.warn("Another connection wants to upgrade database '".concat(i.name,"'. Closing db now to resume the upgrade.")):console.warn("Another connection wants to delete database '".concat(i.name,"'. Closing db now to resume the delete request.")),i.close({disableAutoOpen:!1})}),this.on("blocked",function(e){!e.newVersion||e.newVersion<e.oldVersion?console.warn("Dexie.delete('".concat(i.name,"') was blocked")):console.warn("Upgrade '".concat(i.name,"' blocked by other connection holding version ").concat(e.oldVersion/10))}),this._maxKey=nn(t.IDBKeyRange),this._createTransaction=function(e,t,n,r){return new i.Transaction(e,t,n,i._options.chromeTransactionDurability,r)},this._fireOnBlocked=function(t){i.on("blocked").fire(t),rt.filter(function(e){return e.name===i.name&&e!==i&&!e._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(Zn),this.use(cr),this.use(nr),this.use(Gn),this.use(Xn);var l,f=new Proxy(this,{get:function(e,t,n){if("_vip"===t)return!0;if("table"===t)return function(e){return lr(i.table(e),f)};var r=Reflect.get(e,t,n);return r instanceof _t?lr(r,f):"tables"===t?r.map(function(e){return lr(e,f)}):"_createTransaction"===t?function(){return lr(r.apply(this,arguments),f)}:r}});this.vip=f,null!=t&&t.Y&&!1!==(null==t?void 0:t.gc)&&(l=null,(t=this).on("ready",function(e){var t;e.tables.some(function(e){return e.schema.yProps})&&(t=function(){e.isOpen()&&fr(e,dr).catch(function(e){e&&"DatabaseClosedError"===e.name||console.debug("Error during periodic GC",e)}).then(function(){l=setTimeout(t,dr)})},l=setTimeout(t,hr))},!0),t.on("close",function(){l&&clearTimeout(l),l=null})),n.forEach(function(e){return e(i)})}var vr,U="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable",mr=(br.prototype.subscribe=function(e,t,n){return this._subscribe(e&&"function"!=typeof e?e:{next:e,error:t,complete:n})},br.prototype[U]=function(){return this},br);function br(e){this._subscribe=e}try{vr={indexedDB:f.indexedDB||f.mozIndexedDB||f.webkitIndexedDB||f.msIndexedDB,IDBKeyRange:f.IDBKeyRange||f.webkitIDBKeyRange}}catch(e){vr={indexedDB:null,IDBKeyRange:null}}function gr(h){var d,p=!1,e=new mr(function(r){var o=F(h);var i,a=!1,u={},s={},e={get closed(){return a},unsubscribe:function(){a||(a=!0,i&&i.abort(),c&&Qt.storagemutated.unsubscribe(f))}};r.start&&r.start(e);var c=!1,l=function(){return Je(t)};var f=function(e){Rn(u,e),Mn(s,u)&&l()},t=function(){var t,n,e;!a&&vr.indexedDB&&(u={},t={},i&&i.abort(),i=new AbortController,e=function(e){var t=Te();try{o&&Ve();var n=Ye(h,e);return n=o?n.finally(ze):n}finally{t&&De()}}(n={subscr:t,signal:i.signal,requery:l,querier:h,trans:null}),Promise.resolve(e).then(function(e){p=!0,d=e,a||n.signal.aborted||(u={},function(e){for(var t in e)if(b(e,t))return;return 1}(s=t)||c||(Qt(Gt,f),c=!0),Je(function(){return!a&&r.next&&r.next(e)}))},function(e){p=!1,["DatabaseClosedError","AbortError"].includes(null==e?void 0:e.name)||a||Je(function(){a||r.error&&r.error(e)})}))};return setTimeout(l,0),e});return e.hasValue=function(){return p},e.getValue=function(){return d},e}var wr=pr;function _r(e){var t=kr;try{kr=!0,Qt.storagemutated.fire(e),Yn(e,!0)}finally{kr=t}}o(wr,w(w({},X),{delete:function(e){return new wr(e,{addons:[]}).delete()},exists:function(e){return new wr(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(e){try{return t=wr.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Sn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==ot})}):En(n,t).toCollection().primaryKeys()).then(e)}catch(e){return Ze(new H.MissingAPI)}var t,n},defineClass:function(){return function(e){a(this,e)}},ignoreTransaction:function(e){return we.trans?Qe(we.transless,e):e()},vip:Kn,async:function(t){return function(){try{var e=Wn(t.apply(this,arguments));return e&&"function"==typeof e.then?e:Pe.resolve(e)}catch(e){return Ze(e)}}},spawn:function(e,t,n){try{var r=Wn(e.apply(n,t||[]));return r&&"function"==typeof r.then?r:Pe.resolve(r)}catch(e){return Ze(e)}},currentTransaction:{get:function(){return we.trans||null}},waitFor:function(e,t){t=Pe.resolve("function"==typeof e?wr.ignoreTransaction(e):e).timeout(t||6e4);return we.trans?we.trans.waitFor(t):t},Promise:Pe,debug:{get:function(){return ue},set:function(e){se(e)}},derive:i,extend:a,props:o,override:p,Events:kt,on:Qt,liveQuery:gr,extendObservabilitySet:Rn,getByKeyPath:O,setByKeyPath:E,delByKeyPath:function(t,e){"string"==typeof e?E(t,e,void 0):"length"in e&&[].map.call(e,function(e){E(t,e,void 0)})},shallowClone:_,deepClone:j,getObjectDiff:Hn,cmp:ft,asap:v,minKey:-1/0,addons:[],connections:rt,errnames:$,dependencies:vr,cache:Fn,semVer:N,version:N.split(".").map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/Math.pow(10,2*n)})})),wr.maxKey=nn(wr.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(Qt(Gt,function(e){kr||(e=new CustomEvent(Ht,{detail:e}),kr=!0,dispatchEvent(e),kr=!1)}),addEventListener(Ht,function(e){e=e.detail;kr||_r(e)}));var xr,kr=!1,Pr=function(){};function Or(n,r,o,t,i,a,u){function e(e,t){t!==n&&o.table(i).add({k:a,u:e,f:1}).then(function(e){e===c-1&&++c}).catch(function(e){n.on("error").fire(e)})}function s(){f.unsubscribe(),r.off("updateV2",e),r.off("destroy",s)}var c=0,l=!0,f=gr(function(){mt(r);var e=o.table(i);return Promise.all([(0<c?e.where("i").between(c,1/0,!1).toArray().then(function(e){return e.filter(function(e){return 0===ft(e.k,a)})}):e.where({k:a}).toArray()).then(function(e){return e}),o.table(t).where(":id").equals(a).toArray()])}).subscribe(function(e){var e=k(e,2),t=e[0],e=e[1];0<t.length&&(c=t[t.length-1].i),0!==e.length?(mt(r),0<t.length&&u.transact(r,function(){t.forEach(function(e){try{Kr.currentUpdateRow=e,u.applyUpdateV2(r,e.u)}finally{Kr.currentUpdateRow=null}})},n,!1),l&&(l=!1,r.emit("load",[r]))):r.destroy()},function(e){n.on("error").fire(e)});return r.on("updateV2",e),r.on("destroy",s),s}"undefined"!=typeof BroadcastChannel&&((Pr=function(){(xr=new BroadcastChannel(Ht)).onmessage=function(e){return e.data&&_r(e.data)}})(),"function"==typeof xr.unref&&xr.unref(),Qt(Gt,function(e){kr||xr.postMessage(e)})),"undefined"!=typeof addEventListener&&(addEventListener("pagehide",function(e){if(!pr.disableBfCache&&e.persisted){ue&&console.debug("Dexie: handling persisted pagehide"),null!=xr&&xr.close();for(var t=0,n=rt;t<n.length;t++)n[t].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(e){!pr.disableBfCache&&e.persisted&&(ue&&console.debug("Dexie: handling persisted pageshow"),Pr(),_r({all:new jn(-1/0,[[]])}))}));var Er=new WeakMap;function Sr(){return kt(null,"load","sync","error")}var Kr=(Cr.load=function(e){var t=Er.get(e);return t?++t.refCount:(t=new Cr(e),Er.set(e,t)),t},Cr.release=function(e,t){var n;vt.has(e)||((n=Er.get(e))?--n.refCount<=0&&(isNaN(null==t?void 0:t.gracePeriod)?e.destroy():setTimeout(function(){return n.refCount||e.destroy()},t.gracePeriod)):e.destroy())},Cr.for=function(e){return Er.get(e)},Cr.prototype.destroy=function(){var e;Er.delete(this.doc),this.doc=null,this.destroyed=!0,this.refCount=0,null!==(e=this.stopObserving)&&void 0!==e&&e.call(this),this.on=Sr(),this.cleanupHandlers.forEach(function(e){return e()})},Cr.prototype.addCleanupHandler=function(e){this.cleanupHandlers.push("function"==typeof e?e:function(){return e.unsubscribe()})},Cr.getDocCache=pt,Cr.currentUpdateRow=null,Cr);function Cr(e){var n=this;this.refCount=1,this.cleanupHandlers=[],this.destroyed=!1,this.on=Sr(),this.doc=e,this.off=function(e,t){return null===(e=n.on[e])||void 0===e?void 0:e.unsubscribe(t)},this.whenLoaded=new Promise(function(e,t){n.on("load",e),n.on("error",t)}),this.whenSynced=new Promise(function(e,t){n.on("sync",e),n.on("error",t)}),"dispose"in Symbol&&(this[Symbol.dispose]=function(){return Cr.release(e)}),e.on("load",function(){return n.on("load").fire()}),e.on("sync",function(e){return!1!==e&&n.on("sync").fire()}),e.on("destroy",this.destroy.bind(this));var t=e.meta||{},r=t.db,o=t.parentTable,i=t.parentId,a=t.updatesTable;if(r&&o&&a){if(!r.table(o)||!r.table(a))throw new Error("Table ".concat(o," or ").concat(a," not found in db"));mt(e);t=wt(r);this.stopObserving=Or(this,e,r,o,a,i,t),r.on.y.fire(this,t)}}return Pe.rejectionMapper=function(e,t){return!e||e instanceof Y||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Q[e.name]?e:(t=new Q[e.name](t||e.message,e),"stack"in e&&c(t,"stack",{get:function(){return this.inner.stack}}),t)},se(ue),w(pr,Object.freeze({__proto__:null,Dexie:pr,liveQuery:gr,Entity:lt,cmp:ft,PropModSymbol:e,PropModification:Tt,replacePrefix:function(e,t){return new Tt({replacePrefix:[e,t]})},add:function(e){return new Tt({add:e})},remove:function(e){return new Tt({remove:e})},default:pr,RangeSet:jn,mergeRanges:Tn,rangesOverlap:Dn,DexieYProvider:Kr}),{default:pr}),pr});
2
2
  //# sourceMappingURL=dexie.min.js.map