@liascript/exporter
Version:
A generic exporter for LiaScript
14 lines • 103 kB
JavaScript
function e(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},n=t.parcelRequire55a5;n.register("bH3SQ",(function(t,r){e(t.exports,"Connector",(function(){return u}));var i=n("4ekS1"),o=n("6Ndrt"),a=n("jXXgq");class u extends a.Connector{hasIndex(){return!0}async open(e,t,n){return await this.database.open(e,t,{table:"code",id:n})}load(e){return this.database.load(e)}store(e){return this.database.store(e)}update(e,t){this.database.transaction(e,t)}slide(e){this.database.slide(e)}async getIndex(){return await this.database.listIndex()}deleteFromIndex(e){this.database.deleteIndex(e)}async storeToIndex(e){return this.database.storeIndex(e)}restoreFromIndex(e,t){return this.database.restore(e,t)}async reset(e,t){e&&t&&(await this.database.reset(e,t),i.default.info("DB: reset => ",e,t))}getFromIndex(e){return this.database.getIndex(e)}async addMisc(e,t,n,r){this.database.addMisc(e,t,n,r)}async getMisc(e,t,n){return this.database.getMisc(e,t,n)}constructor(){super(),this.database=new o.LiaDB}}})),n.register("6Ndrt",(function(t,r){e(t.exports,"LiaDB",(function(){return a}));var i=n("kxHmC"),o=n("4ekS1");class a{open_(e){let t=new(0,i.default)(e);return t.version(1).stores({code:"[id+version], version",quiz:"[id+version], version",survey:"[id+version], version",task:"[id+version], version",offline:"[id+version], version"}),t}async open(e,t,n){this.version=t,this.db=this.open_(e);try{await this.db.open()}catch(e){o.default.warn("DB: open -> ",e.message),this.db=null}if(n&&this.db)return await this.db[n.table].get({id:n.id,version:t})}async store(e,t){this.db&&0!==this.version&&(o.default.warn(`liaDB: event(store), table(${e.table}), id(${e.id}), data(${e.data})`),await this.db[e.table].put({id:e.id,version:null!=t?t:this.version,data:e.data,created:(new Date).getTime()}))}async load(e,t){if(!this.db)return;o.default.info("loading => ",e.table,e.id);const n=await this.db[e.table].get({id:e.id,version:null!=t?t:this.version});return n?(o.default.info("restore table",e.table),n.data):null}async slide(e){try{let t=await this.db.offline.get({id:0,version:this.version});t.data.section_active=e,await this.db.offline.put(t)}catch(t){o.default.warn("DB: could not update slide => ",e)}}async transaction(e,t){if(!this.db||0===this.version)return;let n=this.db;await n.transaction("rw",n[e.table],(async()=>{const r=await n[e.table].get({id:e.id,version:this.version});r.data&&(r.data=t(r.data),await n[e.table].put(r))}))}async restore(e,t){if(await this.dbIndex.courses.get(e)){let n=this.open_(e);const r=await n.offline.get({id:0,version:null!=t?t:this.version});return void 0===r?null:r.data}}async getIndex(e){try{return await this.dbIndex.courses.get(e)}catch(e){o.default.warn("DB: getIndex -> ",e.message)}return null}async listIndex(e="updated",t=!1){const n=await this.dbIndex.courses.orderBy(e).toArray();return t||n.reverse(),n}async storeIndex(e){if(!this.dbIndex.isOpen())return void o.default.warn("DB: storeIndex ... db is closed");const t=new Date;let n=await this.dbIndex.courses.get(e.readme);if(n||(n={id:e.readme,title:e.definition.str_title,author:e.definition.author,created:t.getTime(),updated:null,updated_str:null,data:{}}),n.updated=t.getTime(),n.updated_str=t.toLocaleDateString(),n.data[e.version]){if(n.data[e.version].version!==e.definition.version){n.data[e.version]=e.definition,n.data[e.version].title=e.title,o.default.info("storing new version to index",n);let r=this.open_(e.readme);await r.open(),await r.offline.put({id:0,version:e.version,data:e,created:t.getTime(),misc:{}})}}else n.data[e.version]=e.definition,n.data[e.version].title=e.title,o.default.info("storing new version to index",n),await this.db.offline.put({id:0,version:e.version,data:e,created:t.getTime(),misc:{}});this.dbIndex.courses.put(n).then((function(e){o.default.info("DB: storeIndex",e)}))}async addMisc(e,t,n,r){const i=this.open_(e);await i.open(),await i.transaction("rw",i.offline,(async()=>{let e=await i.offline.get({id:0,version:t||this.version});e&&(e.misc[n]=r,await i.offline.put(e))}))}async getMisc(e,t,n){const r=this.open_(e);await r.open();const i=await r.offline.get({id:0,version:t||this.version});return n?null==i?void 0:i.misc[n]:null==i?void 0:i.misc}async deleteIndex(e){await Promise.all([this.dbIndex.courses.delete(e),i.default.delete(e)])}async reset(e,t){const n=this.open_(e);await n.open(),await Promise.all([n.code.where("version").equals(t).delete(),n.quiz.where("version").equals(t).delete(),n.survey.where("version").equals(t).delete(),n.task.where("version").equals(t).delete()])}constructor(){this.dbIndex=new(0,i.default)("Index"),this.dbIndex.version(1).stores({courses:"&id,updated,author,created,title"}),this.version=0}}})),n.register("kxHmC",(function(n,r){e(n.exports,"default",(function(){return lr}));
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var i=function(e,t){return i=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])},i(e,t)},o=function(){return o=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},o.apply(this,arguments)};function a(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)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:t,s=Object.keys,c=Array.isArray;function l(e,t){return"object"!=typeof t||s(t).forEach((function(n){e[n]=t[n]})),e}"undefined"==typeof Promise||u.Promise||(u.Promise=Promise);var f=Object.getPrototypeOf,d={}.hasOwnProperty;function h(e,t){return d.call(e,t)}function p(e,t){"function"==typeof t&&(t=t(f(e))),("undefined"==typeof Reflect?s:Reflect.ownKeys)(t).forEach((function(n){v(e,n,t[n])}))}var y=Object.defineProperty;function v(e,t,n,r){y(e,t,l(n&&h(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function m(e){return{from:function(t){return e.prototype=Object.create(t.prototype),v(e.prototype,"constructor",e),{extend:p.bind(null,e.prototype)}}}}var b=Object.getOwnPropertyDescriptor;function g(e,t){var n;return b(e,t)||(n=f(e))&&g(n,t)}var w=[].slice;function _(e,t,n){return w.call(e,t,n)}function x(e,t){return t(e)}function k(e){if(!e)throw new Error("Assertion Failed")}function O(e){u.setImmediate?setImmediate(e):setTimeout(e,0)}function P(e,t){if("string"==typeof t&&h(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=P(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:P(u,t.substr(a+1))}}function S(e,t,n){if(e&&void 0!==t&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if("string"!=typeof t&&"length"in t){k("string"!=typeof n&&"length"in n);for(var r=0,i=t.length;r<i;++r)S(e,t[r],n[r])}else{var o=t.indexOf(".");if(-1!==o){var a=t.substr(0,o),u=t.substr(o+1);if(""===u)void 0===n?c(e)&&!isNaN(parseInt(a))?e.splice(a,1):delete e[a]:e[a]=n;else{var s=e[a];s&&h(e,a)||(s=e[a]={}),S(s,u,n)}}else void 0===n?c(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function K(e){var t={};for(var n in e)h(e,n)&&(t[n]=e[n]);return t}var E=[].concat;function I(e){return E.apply([],e)}var j="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(I([8,16,32,64].map((function(e){return["Int","Uint","Float"].map((function(t){return t+e+"Array"}))})))).filter((function(e){return u[e]})),C=new Set(j.map((function(e){return u[e]})));function A(e){var t={};for(var n in e)if(h(e,n)){var r=e[n];t[n]=!r||"object"!=typeof r||C.has(r.constructor)?r:A(r)}return t}var D=null;function T(e){D=new WeakMap;var t=q(e);return D=null,t}function q(e){if(!e||"object"!=typeof e)return e;var t=D.get(e);if(t)return t;if(c(e)){t=[],D.set(e,t);for(var n=0,r=e.length;n<r;++n)t.push(q(e[n]))}else if(C.has(e.constructor))t=e;else{var i=f(e);for(var o in t=i===Object.prototype?{}:Object.create(i),D.set(e,t),e)h(e,o)&&(t[o]=q(e[o]))}return t}var B={}.toString;function R(e){return B.call(e).slice(8,-1)}var M="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",F="symbol"==typeof M?function(e){var t;return null!=e&&(t=e[M])&&t.apply(e)}:function(){return null};function N(e,t){var n=e.indexOf(t);return n>=0&&e.splice(n,1),n>=0}var L={};function U(e){var t,n,r,i;if(1===arguments.length){if(c(e))return e.slice();if(this===L&&"string"==typeof e)return[e];if(i=F(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==e)return[e];if("number"==typeof(t=e.length)){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}var z="undefined"!=typeof Symbol?function(e){return"AsyncFunction"===e[Symbol.toStringTag]}:function(){return!1},V=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],W=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(V),Y={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 $(e,t){this.name=e,this.message=t}function X(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 Q(e,t,n,r){this.failures=t,this.failedKeys=r,this.successCount=n,this.message=X(e,t)}function G(e,t){this.name="BulkError",this.failures=Object.keys(t).map((function(e){return t[e]})),this.failuresByPos=t,this.message=X(e,this.failures)}m($).from(Error).extend({toString:function(){return this.name+": "+this.message}}),m(Q).from($),m(G).from($);var H=W.reduce((function(e,t){return e[t]=t+"Error",e}),{}),J=$,Z=W.reduce((function(e,t){var n=t+"Error";function r(e,r){this.name=n,e?"string"==typeof e?(this.message="".concat(e).concat(r?"\n "+r:""),this.inner=r||null):"object"==typeof e&&(this.message="".concat(e.name," ").concat(e.message),this.inner=e):(this.message=Y[t]||n,this.inner=null)}return m(r).from(J),e[t]=r,e}),{});Z.Syntax=SyntaxError,Z.Type=TypeError,Z.Range=RangeError;var ee=V.reduce((function(e,t){return e[t+"Error"]=Z[t],e}),{}),te=W.reduce((function(e,t){return-1===["Syntax","Type","Range"].indexOf(t)&&(e[t+"Error"]=Z[t]),e}),{});function ne(){}function re(e){return e}function ie(e,t){return null==e||e===re?t:function(n){return t(e(n))}}function oe(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function ae(e,t){return e===ne?t:function(){var n=e.apply(this,arguments);void 0!==n&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?oe(r,this.onsuccess):r),i&&(this.onerror=this.onerror?oe(i,this.onerror):i),void 0!==o?o:n}}function ue(e,t){return e===ne?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?oe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?oe(r,this.onerror):r)}}function se(e,t){return e===ne?t:function(n){var r=e.apply(this,arguments);l(n,r);var i=this.onsuccess,o=this.onerror;this.onsuccess=null,this.onerror=null;var a=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?oe(i,this.onsuccess):i),o&&(this.onerror=this.onerror?oe(o,this.onerror):o),void 0===r?void 0===a?void 0:a:l(r,a)}}function ce(e,t){return e===ne?t:function(){return!1!==t.apply(this,arguments)&&e.apply(this,arguments)}}function le(e,t){return e===ne?t:function(){var n=e.apply(this,arguments);if(n&&"function"==typeof n.then){for(var r=this,i=arguments.length,o=new Array(i);i--;)o[i]=arguments[i];return n.then((function(){return t.apply(r,o)}))}return t.apply(this,arguments)}}te.ModifyError=Q,te.DexieError=$,te.BulkError=G;var fe="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function de(e,t){fe=e}var he={},pe=100,ye="undefined"==typeof Promise?[]:function(){var e=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[e,f(e),e];var t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,f(t),e]}(),ve=ye[0],me=ye[1],be=ye[2],ge=me&&me.then,we=ve&&ve.constructor,_e=!!be,xe=function(e,t){je.push([e,t]),Oe&&(queueMicrotask(Le),Oe=!1)},ke=!0,Oe=!0,Pe=[],Se=[],Ke=re,Ee={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ne,pgp:!1,env:{},finalize:ne},Ie=Ee,je=[],Ce=0,Ae=[];function De(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var t=this._PSD=Ie;if("function"!=typeof e){if(e!==he)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Re(this,this._value))}this._state=null,this._value=null,++t.ref,Be(this,e)}var Te={get:function(){var e=Ie,t=He;function n(n,r){var i=this,o=!e.global&&(e!==Ie||t!==He),a=o&&!tt(),u=new De((function(t,u){Fe(i,new qe(st(n,e,o,a),st(r,e,o,a),t,u,e))}));return this._consoleTask&&(u._consoleTask=this._consoleTask),u}return n.prototype=he,n},set:function(e){v(this,"then",e&&e.prototype===he?Te:{get:function(){return e},set:Te.set})}};function qe(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 Be(e,t){try{t((function(t){if(null===e._state){if(t===e)throw new TypeError("A promise cannot be resolved with itself.");var n=e._lib&&Ue();t&&"function"==typeof t.then?Be(e,(function(e,n){t instanceof De?t._then(e,n):t.then(e,n)})):(e._state=!0,e._value=t,Me(e)),n&&ze()}}),Re.bind(null,e))}catch(t){Re(e,t)}}function Re(e,t){if(Se.push(t),null===e._state){var n=e._lib&&Ue();t=Ke(t),e._state=!1,e._value=t,function(e){Pe.some((function(t){return t._value===e._value}))||Pe.push(e)}(e),Me(e),n&&ze()}}function Me(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)Fe(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),0===Ce&&(++Ce,xe((function(){0==--Ce&&Ve()}),[]))}function Fe(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,++Ce,xe(Ne,[n,e,t])}else e._listeners.push(t)}function Ne(e,t,n){try{var r,i=t._value;!t._state&&Se.length&&(Se=[]),r=fe&&t._consoleTask?t._consoleTask.run((function(){return e(i)})):e(i),t._state||-1!==Se.indexOf(i)||function(e){for(var t=Pe.length;t;)if(Pe[--t]._value===e._value)return void Pe.splice(t,1)}(t),n.resolve(r)}catch(e){n.reject(e)}finally{0==--Ce&&Ve(),--n.psd.ref||n.psd.finalize()}}function Le(){ut(Ee,(function(){Ue()&&ze()}))}function Ue(){var e=ke;return ke=!1,Oe=!1,e}function ze(){var e,t,n;do{for(;je.length>0;)for(e=je,je=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}}while(je.length>0);ke=!0,Oe=!0}function Ve(){var e=Pe;Pe=[],e.forEach((function(e){e._PSD.onunhandled.call(null,e._value,e)}));for(var t=Ae.slice(0),n=t.length;n;)t[--n]()}function We(e){return new De(he,!1,e)}function Ye(e,t){var n=Ie;return function(){var r=Ue(),i=Ie;try{return ot(n,!0),e.apply(this,arguments)}catch(e){t&&t(e)}finally{ot(i,!1),r&&ze()}}}p(De.prototype,{then:Te,_then:function(e,t){Fe(this,new qe(null,null,e,t,Ie))},catch:function(e){if(1===arguments.length)return this.then(null,e);var t=arguments[0],n=arguments[1];return"function"==typeof t?this.then(null,(function(e){return e instanceof t?n(e):We(e)})):this.then(null,(function(e){return e&&e.name===t?n(e):We(e)}))},finally:function(e){return this.then((function(t){return De.resolve(e()).then((function(){return t}))}),(function(t){return De.resolve(e()).then((function(){return We(t)}))}))},timeout:function(e,t){var n=this;return e<1/0?new De((function(r,i){var o=setTimeout((function(){return i(new Z.Timeout(t))}),e);n.then(r,i).finally(clearTimeout.bind(null,o))})):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&v(De.prototype,Symbol.toStringTag,"Dexie.Promise"),Ee.env=at(),p(De,{all:function(){var e=U.apply(null,arguments).map(nt);return new De((function(t,n){0===e.length&&t([]);var r=e.length;e.forEach((function(i,o){return De.resolve(i).then((function(n){e[o]=n,--r||t(e)}),n)}))}))},resolve:function(e){return e instanceof De?e:e&&"function"==typeof e.then?new De((function(t,n){e.then(t,n)})):new De(he,!0,e)},reject:We,race:function(){var e=U.apply(null,arguments).map(nt);return new De((function(t,n){e.map((function(e){return De.resolve(e).then(t,n)}))}))},PSD:{get:function(){return Ie},set:function(e){return Ie=e}},totalEchoes:{get:function(){return He}},newPSD:Ze,usePSD:ut,scheduler:{get:function(){return xe},set:function(e){xe=e}},rejectionMapper:{get:function(){return Ke},set:function(e){Ke=e}},follow:function(e,t){return new De((function(n,r){return Ze((function(t,n){var r=Ie;r.unhandleds=[],r.onunhandled=n,r.finalize=oe((function(){var e=this;!function(e){Ae.push((function t(){e(),Ae.splice(Ae.indexOf(t),1)})),++Ce,xe((function(){0==--Ce&&Ve()}),[])}((function(){0===e.unhandleds.length?t():n(e.unhandleds[0])}))}),r.finalize),e()}),t,n,r)}))}}),we&&(we.allSettled&&v(De,"allSettled",(function(){var e=U.apply(null,arguments).map(nt);return new De((function(t){0===e.length&&t([]);var n=e.length,r=new Array(n);e.forEach((function(e,i){return De.resolve(e).then((function(e){return r[i]={status:"fulfilled",value:e}}),(function(e){return r[i]={status:"rejected",reason:e}})).then((function(){return--n||t(r)}))}))}))})),we.any&&"undefined"!=typeof AggregateError&&v(De,"any",(function(){var e=U.apply(null,arguments).map(nt);return new De((function(t,n){0===e.length&&n(new AggregateError([]));var r=e.length,i=new Array(r);e.forEach((function(e,o){return De.resolve(e).then((function(e){return t(e)}),(function(e){i[o]=e,--r||n(new AggregateError(i))}))}))}))})),we.withResolvers&&(De.withResolvers=we.withResolvers));var $e={awaits:0,echoes:0,id:0},Xe=0,Qe=[],Ge=0,He=0,Je=0;function Ze(e,t,n,r){var i=Ie,o=Object.create(i);o.parent=i,o.ref=0,o.global=!1,o.id=++Je,Ee.env,o.env=_e?{Promise:De,PromiseProp:{value:De,configurable:!0,writable:!0},all:De.all,race:De.race,allSettled:De.allSettled,any:De.any,resolve:De.resolve,reject:De.reject}:{},t&&l(o,t),++i.ref,o.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=ut(o,e,n,r);return 0===o.ref&&o.finalize(),a}function et(){return $e.id||($e.id=++Xe),++$e.awaits,$e.echoes+=pe,$e.id}function tt(){return!!$e.awaits&&(0==--$e.awaits&&($e.id=0),$e.echoes=$e.awaits*pe,!0)}function nt(e){return $e.echoes&&e&&e.constructor===we?(et(),e.then((function(e){return tt(),e}),(function(e){return tt(),lt(e)}))):e}function rt(e){++He,$e.echoes&&0!=--$e.echoes||($e.echoes=$e.awaits=$e.id=0),Qe.push(Ie),ot(e,!0)}function it(){var e=Qe[Qe.length-1];Qe.pop(),ot(e,!1)}function ot(e,t){var n=Ie;if((t?!$e.echoes||Ge++&&e===Ie:!Ge||--Ge&&e===Ie)||queueMicrotask(t?rt.bind(null,e):it),e!==Ie&&(Ie=e,n===Ee&&(Ee.env=at()),_e)){var r=Ee.env.Promise,i=e.env;(n.global||e.global)&&(Object.defineProperty(u,"Promise",i.PromiseProp),r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject,i.allSettled&&(r.allSettled=i.allSettled),i.any&&(r.any=i.any))}}function at(){var e=u.Promise;return _e?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(u,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject}:{}}function ut(e,t,n,r,i){var o=Ie;try{return ot(e,!0),t(n,r,i)}finally{ot(o,!1)}}function st(e,t,n,r){return"function"!=typeof e?e:function(){var i=Ie;n&&et(),ot(t,!0);try{return e.apply(this,arguments)}finally{ot(i,!1),r&&queueMicrotask(tt)}}}function ct(e){Promise===we&&0===$e.echoes?0===Ge?e():enqueueNativeMicroTask(e):setTimeout(e,0)}-1===(""+ge).indexOf("[native code]")&&(et=tt=ne);var lt=De.reject;function ft(e,t,n,r){if(e.idbdb&&(e._state.openComplete||Ie.letThrough||e._vip)){var i=e._createTransaction(t,n,e._dbSchema);try{i.create(),e._state.PR1398_maxLoop=3}catch(i){return i.name===H.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e.close({disableAutoOpen:!1}),e.open().then((function(){return ft(e,t,n,r)}))):lt(i)}return i._promise(t,(function(e,t){return Ze((function(){return Ie.trans=i,r(e,t,i)}))})).then((function(e){if("readwrite"===t)try{i.idbtrans.commit()}catch(e){}return"readonly"===t?e:i._completion.then((function(){return e}))}))}if(e._state.openComplete)return lt(new Z.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._state.autoOpen)return lt(new Z.DatabaseClosed);e.open().catch(ne)}return e._state.dbReadyPromise.then((function(){return ft(e,t,n,r)}))}var dt="4.0.11",ht=String.fromCharCode(65535),pt=-1/0,yt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",vt="String expected.",mt=[],bt="__dbnames",gt="readonly",wt="readwrite";function _t(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var xt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function kt(e){return"string"!=typeof e||/\./.test(e)?function(e){return e}:function(t){return void 0===t[e]&&e in t&&delete(t=T(t))[e],t}}function Ot(){throw Z.Type()}function Pt(e,t){try{var n=St(e),r=St(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 e>t?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}(Kt(e),Kt(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=Pt(e[o],t[o]);if(0!==a)return a}return n===r?0:n<r?-1:1}(e,t)}}catch(e){}return NaN}function St(e){var t=typeof e;if("object"!==t)return t;if(ArrayBuffer.isView(e))return"binary";var n=R(e);return"ArrayBuffer"===n?"binary":n}function Kt(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}var Et=function(){function e(){}return e.prototype._trans=function(e,t,n){var r=this._tx||Ie.trans,i=this.name,o=fe&&"undefined"!=typeof console&&console.createTask&&console.createTask("Dexie: ".concat("readonly"===e?"read":"write"," ").concat(this.name));function a(e,n,r){if(!r.schema[i])throw new Z.NotFound("Table "+i+" not part of transaction");return t(r.idbtrans,r)}var u=Ue();try{var s=r&&r.db._novip===this.db._novip?r===Ie.trans?r._promise(e,a,n):Ze((function(){return r._promise(e,a,n)}),{trans:r,transless:Ie.transless||Ie}):ft(this.db,e,[this.name],a);return o&&(s._consoleTask=o,s=s.catch((function(e){return console.trace(e),lt(e)}))),s}finally{u&&ze()}},e.prototype.get=function(e,t){var n=this;return e&&e.constructor===Object?this.where(e).first(t):null==e?lt(new Z.Type("Invalid argument to Table.get()")):this._trans("readonly",(function(t){return n.core.get({trans:t,key:e}).then((function(e){return n.hook.reading.fire(e)}))})).then(t)},e.prototype.where=function(e){if("string"==typeof e)return new this.db.WhereClause(this,e);if(c(e))return new this.db.WhereClause(this,"[".concat(e.join("+"),"]"));var t=s(e);if(1===t.length)return this.where(t[0]).equals(e[t[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter((function(e){if(e.compound&&t.every((function(t){return e.keyPath.indexOf(t)>=0}))){for(var n=0;n<t.length;++n)if(-1===t.indexOf(e.keyPath[n]))return!1;return!0}return!1})).sort((function(e,t){return e.keyPath.length-t.keyPath.length}))[0];if(n&&this.db._maxKey!==ht){var r=n.keyPath.slice(0,t.length);return this.where(r).equals(r.map((function(t){return e[t]})))}!n&&fe&&console.warn("The query ".concat(JSON.stringify(e)," on ").concat(this.name," would benefit from a ")+"compound index [".concat(t.join("+"),"]"));var i=this.schema.idxByName;function o(e,t){return 0===Pt(e,t)}var a=t.reduce((function(t,n){var r=t[0],a=t[1],u=i[n],s=e[n];return[r||u,r||!u?_t(a,u&&u.multi?function(e){var t=P(e,n);return c(t)&&t.some((function(e){return o(s,e)}))}:function(e){return o(s,P(e,n))}):a]}),[null,null]),u=a[0],l=a[1];return u?this.where(u.name).equals(e[u.keyPath]).filter(l):n?this.filter(l):this.where(t).equals("")},e.prototype.filter=function(e){return this.toCollection().and(e)},e.prototype.count=function(e){return this.toCollection().count(e)},e.prototype.offset=function(e){return this.toCollection().offset(e)},e.prototype.limit=function(e){return this.toCollection().limit(e)},e.prototype.each=function(e){return this.toCollection().each(e)},e.prototype.toArray=function(e){return this.toCollection().toArray(e)},e.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},e.prototype.orderBy=function(e){return new this.db.Collection(new this.db.WhereClause(this,c(e)?"[".concat(e.join("+"),"]"):e))},e.prototype.reverse=function(){return this.toCollection().reverse()},e.prototype.mapToClass=function(e){var t=this.db,n=this.name;this.schema.mappedClass=e,e.prototype instanceof Ot&&(e=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return 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}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(r,e),Object.defineProperty(r.prototype,"db",{get:function(){return t},enumerable:!1,configurable:!0}),r.prototype.table=function(){return n},r}(e));for(var r=new Set,o=e.prototype;o;o=f(o))Object.getOwnPropertyNames(o).forEach((function(e){return r.add(e)}));var a=function(t){if(!t)return t;var n=Object.create(e.prototype);for(var i in t)if(!r.has(i))try{n[i]=t[i]}catch(e){}return n};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=a,this.hook("reading",a),e},e.prototype.defineClass=function(){return this.mapToClass((function(e){l(this,e)}))},e.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=kt(o)(e)),this._trans("readwrite",(function(e){return n.core.mutate({trans:e,type:"add",keys:null!=t?[t]:null,values:[a]})})).then((function(e){return e.numFailures?De.reject(e.failures[0]):e.lastResult})).then((function(t){if(o)try{S(e,o,t)}catch(e){}return t}))},e.prototype.update=function(e,t){if("object"!=typeof e||c(e))return this.where(":id").equals(e).modify(t);var n=P(e,this.schema.primKey.keyPath);return void 0===n?lt(new Z.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(n).modify(t)},e.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,o=r.keyPath,a=e;return o&&i&&(a=kt(o)(e)),this._trans("readwrite",(function(e){return n.core.mutate({trans:e,type:"put",values:[a],keys:null!=t?[t]:null})})).then((function(e){return e.numFailures?De.reject(e.failures[0]):e.lastResult})).then((function(t){if(o)try{S(e,o,t)}catch(e){}return t}))},e.prototype.delete=function(e){var t=this;return this._trans("readwrite",(function(n){return t.core.mutate({trans:n,type:"delete",keys:[e]})})).then((function(e){return e.numFailures?De.reject(e.failures[0]):void 0}))},e.prototype.clear=function(){var e=this;return this._trans("readwrite",(function(t){return e.core.mutate({trans:t,type:"deleteRange",range:xt})})).then((function(e){return e.numFailures?De.reject(e.failures[0]):void 0}))},e.prototype.bulkGet=function(e){var t=this;return this._trans("readonly",(function(n){return t.core.getMany({keys:e,trans:n}).then((function(e){return e.map((function(e){return t.hook.reading.fire(e)}))}))}))},e.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(function(t){var n=r.schema.primKey,a=n.auto,u=n.keyPath;if(u&&i)throw new Z.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,c=u&&a?e.map(kt(u)):e;return r.core.mutate({trans:t,type:"add",keys:i,values:c,wantResults:o}).then((function(e){var t=e.numFailures,n=e.results,i=e.lastResult,a=e.failures;if(0===t)return o?n:i;throw new G("".concat(r.name,".bulkAdd(): ").concat(t," of ").concat(s," operations failed"),a)}))}))},e.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,o=(n=n||(i?void 0:t))?n.allKeys:void 0;return this._trans("readwrite",(function(t){var n=r.schema.primKey,a=n.auto,u=n.keyPath;if(u&&i)throw new Z.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==e.length)throw new Z.InvalidArgument("Arguments objects and keys must have the same length");var s=e.length,c=u&&a?e.map(kt(u)):e;return r.core.mutate({trans:t,type:"put",keys:i,values:c,wantResults:o}).then((function(e){var t=e.numFailures,n=e.results,i=e.lastResult,a=e.failures;if(0===t)return o?n:i;throw new G("".concat(r.name,".bulkPut(): ").concat(t," of ").concat(s," operations failed"),a)}))}))},e.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map((function(e){return e.key})),i=e.map((function(e){return e.changes})),o=[];return this._trans("readwrite",(function(a){return n.getMany({trans:a,keys:r,cache:"clone"}).then((function(u){var s=[],c=[];e.forEach((function(e,n){var r=e.key,i=e.changes,a=u[n];if(a){for(var l=0,f=Object.keys(i);l<f.length;l++){var d=f[l],h=i[d];if(d===t.schema.primKey.keyPath){if(0!==Pt(h,r))throw new Z.Constraint("Cannot update primary key in bulkUpdate()")}else S(a,d,h)}o.push(n),s.push(r),c.push(a)}}));var l=s.length;return n.mutate({trans:a,type:"put",keys:s,values:c,updates:{keys:r,changeSpecs:i}}).then((function(e){var n=e.numFailures,r=e.failures;if(0===n)return l;for(var i=0,a=Object.keys(r);i<a.length;i++){var u=a[i],s=o[Number(u)];if(null!=s){var c=r[u];delete r[u],r[s]=c}}throw new G("".concat(t.name,".bulkUpdate(): ").concat(n," of ").concat(l," operations failed"),r)}))}))}))},e.prototype.bulkDelete=function(e){var t=this,n=e.length;return this._trans("readwrite",(function(n){return t.core.mutate({trans:n,type:"delete",keys:e})})).then((function(e){var r=e.numFailures,i=e.lastResult,o=e.failures;if(0===r)return i;throw new G("".concat(t.name,".bulkDelete(): ").concat(r," of ").concat(n," operations failed"),o)}))},e}();function It(e){var t={},n=function(n,r){if(r){for(var i=arguments.length,o=new Array(i-1);--i;)o[i-1]=arguments[i];return t[n].subscribe.apply(null,o),e}if("string"==typeof n)return t[n]};n.addEventType=o;for(var r=1,i=arguments.length;r<i;++r)o(arguments[r]);return n;function o(e,r,i){if("object"!=typeof e){var a;r||(r=ce),i||(i=ne);var u={subscribers:[],fire:i,subscribe:function(e){-1===u.subscribers.indexOf(e)&&(u.subscribers.push(e),u.fire=r(u.fire,e))},unsubscribe:function(e){u.subscribers=u.subscribers.filter((function(t){return t!==e})),u.fire=u.subscribers.reduce(r,i)}};return t[e]=n[e]=u,u}s(a=e).forEach((function(e){var t=a[e];if(c(t))o(e,a[e][0],a[e][1]);else{if("asap"!==t)throw new Z.InvalidArgument("Invalid event config");var n=o(e,re,(function(){for(var e=arguments.length,t=new Array(e);e--;)t[e]=arguments[e];n.subscribers.forEach((function(e){O((function(){e.apply(null,t)}))}))}))}}))}}function jt(e,t){return m(t).from({prototype:e}),t}function Ct(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function At(e,t){e.filter=_t(e.filter,t)}function Dt(e,t,n){var r=e.replayFilter;e.replayFilter=r?function(){return _t(r(),t())}:t,e.justLimit=n&&!r}function Tt(e,t){if(e.isPrimKey)return t.primaryKey;var n=t.getIndexByKeyPath(e.index);if(!n)throw new Z.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function qt(e,t,n){var r=Tt(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 Bt(e,t,n,r){var i=e.replayFilter?_t(e.filter,e.replayFilter()):e.filter;if(e.or){var o={},a=function(e,n,r){if(!i||i(n,r,(function(e){return n.stop(e)}),(function(e){return n.fail(e)}))){var a=n.primaryKey,u=""+a;"[object ArrayBuffer]"===u&&(u=""+new Uint8Array(a)),h(o,u)||(o[u]=!0,t(e,n,r))}};return Promise.all([e.or._iterate(a,n),Rt(qt(e,r,n),e.algorithm,a,!e.keysOnly&&e.valueMapper)])}return Rt(qt(e,r,n),_t(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function Rt(e,t,n,r){var i=Ye(r?function(e,t,i){return n(r(e),t,i)}:n);return e.then((function(e){if(e)return e.start((function(){var n=function(){return e.continue()};t&&!t(e,(function(e){return n=e}),(function(t){e.stop(t),n=ne}),(function(t){e.fail(t),n=ne}))||i(e.value,e,(function(e){return n=e})),n()}))}))}var Mt=function(){function e(e){this["@@propmod"]=e}return e.prototype.execute=function(e){var t,n=this["@@propmod"];if(void 0!==n.add){var r=n.add;if(c(r))return a(a([],c(e)?e:[],!0),r,!0).sort();if("number"==typeof r)return(Number(e)||0)+r;if("bigint"==typeof r)try{return BigInt(e)+r}catch(e){return BigInt(0)+r}throw new TypeError("Invalid term ".concat(r))}if(void 0!==n.remove){var i=n.remove;if(c(i))return c(e)?e.filter((function(e){return!i.includes(e)})).sort():[];if("number"==typeof i)return Number(e)-i;if("bigint"==typeof i)try{return BigInt(e)-i}catch(e){return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}var o=null===(t=n.replacePrefix)||void 0===t?void 0:t[0];return o&&"string"==typeof e&&e.startsWith(o)?n.replacePrefix[1]+e.substring(o.length):e},e}(),Ft=function(){function e(){}return e.prototype._read=function(e,t){var n=this._ctx;return n.error?n.table._trans(null,lt.bind(null,n.error)):n.table._trans("readonly",e).then(t)},e.prototype._write=function(e){var t=this._ctx;return t.error?t.table._trans(null,lt.bind(null,t.error)):t.table._trans("readwrite",e,"locked")},e.prototype._addAlgorithm=function(e){var t=this._ctx;t.algorithm=_t(t.algorithm,e)},e.prototype._iterate=function(e,t){return Bt(this._ctx,e,t,this._ctx.table.core)},e.prototype.clone=function(e){var t=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return e&&l(n,e),t._ctx=n,t},e.prototype.raw=function(){return this._ctx.valueMapper=null,this},e.prototype.each=function(e){var t=this._ctx;return this._read((function(n){return Bt(t,e,n,t.table.core)}))},e.prototype.count=function(e){var t=this;return this._read((function(e){var n=t._ctx,r=n.table.core;if(Ct(n,!0))return r.count({trans:e,query:{index:Tt(n,r.schema),range:n.range}}).then((function(e){return Math.min(e,n.limit)}));var i=0;return Bt(n,(function(){return++i,!1}),e,r).then((function(){return i}))})).then(e)},e.prototype.sortBy=function(e,t){var n=e.split(".").reverse(),r=n[0],i=n.length-1;function o(e,t){return t?o(e[n[t]],t-1):e[r]}var a="next"===this._ctx.dir?1:-1;function u(e,t){return Pt(o(e,i),o(t,i))*a}return this.toArray((function(e){return e.sort(u)})).then(t)},e.prototype.toArray=function(e){var t=this;return this._read((function(e){var n=t._ctx;if("next"===n.dir&&Ct(n,!0)&&n.limit>0){var r=n.valueMapper,i=Tt(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then((function(e){var t=e.result;return r?t.map(r):t}))}var o=[];return Bt(n,(function(e){return o.push(e)}),e,n.table.core).then((function(){return o}))}),e)},e.prototype.offset=function(e){var t=this._ctx;return e<=0||(t.offset+=e,Ct(t)?Dt(t,(function(){var t=e;return function(e,n){return 0===t||(1===t?(--t,!1):(n((function(){e.advance(t),t=0})),!1))}})):Dt(t,(function(){var t=e;return function(){return--t<0}}))),this},e.prototype.limit=function(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Dt(this._ctx,(function(){var t=e;return function(e,n,r){return--t<=0&&n(r),t>=0}}),!0),this},e.prototype.until=function(e,t){return At(this._ctx,(function(n,r,i){return!e(n.value)||(r(i),t)})),this},e.prototype.first=function(e){return this.limit(1).toArray((function(e){return e[0]})).then(e)},e.prototype.last=function(e){return this.reverse().first(e)},e.prototype.filter=function(e){var t,n;return At(this._ctx,(function(t){return e(t.value)})),t=this._ctx,n=e,t.isMatch=_t(t.isMatch,n),this},e.prototype.and=function(e){return this.filter(e)},e.prototype.or=function(e){return new this.db.WhereClause(this._ctx.table,e,this)},e.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},e.prototype.desc=function(){return this.reverse()},e.prototype.eachKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.key,n)}))},e.prototype.eachUniqueKey=function(e){return this._ctx.unique="unique",this.eachKey(e)},e.prototype.eachPrimaryKey=function(e){var t=this._ctx;return t.keysOnly=!t.isMatch,this.each((function(t,n){e(n.primaryKey,n)}))},e.prototype.keys=function(e){var t=this._ctx;t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.key)})).then((function(){return n})).then(e)},e.prototype.primaryKeys=function(e){var t=this._ctx;if("next"===t.dir&&Ct(t,!0)&&t.limit>0)return this._read((function(e){var n=Tt(t,t.table.core.schema);return t.table.core.query({trans:e,values:!1,limit:t.limit,query:{index:n,range:t.range}})})).then((function(e){return e.result})).then(e);t.keysOnly=!t.isMatch;var n=[];return this.each((function(e,t){n.push(t.primaryKey)})).then((function(){return n})).then(e)},e.prototype.uniqueKeys=function(e){return this._ctx.unique="unique",this.keys(e)},e.prototype.firstKey=function(e){return this.limit(1).keys((function(e){return e[0]})).then(e)},e.prototype.lastKey=function(e){return this.reverse().firstKey(e)},e.prototype.distinct=function(){var e=this._ctx,t=e.index&&e.table.schema.idxByName[e.index];if(!t||!t.multi)return this;var n={};return At(this._ctx,(function(e){var t=e.primaryKey.toString(),r=h(n,t);return n[t]=!0,!r})),this},e.prototype.modify=function(e){var t=this,n=this._ctx;return this._write((function(r){var i;if("function"==typeof e)i=e;else{var o=s(e),a=o.length;i=function(t){for(var n=!1,r=0;r<a;++r){var i=o[r],u=e[i],s=P(t,i);u instanceof Mt?(S(t,i,u.execute(s)),n=!0):s!==u&&(S(t,i,u),n=!0)}return n}}var u=n.table.core,c=u.schema.primaryKey,l=c.outbound,f=c.extractKey,d=200,h=t.db._options.modifyChunkSize;h&&(d="object"==typeof h?h[u.name]||h["*"]||200:h);var p=[],y=0,v=[],m=function(e,t){var n=t.failures,r=t.numFailures;y+=e-r;for(var i=0,o=s(n);i<o.length;i++){var a=o[i];p.push(n[a])}};return t.clone().primaryKeys().then((function(t){var o=Ct(n)&&n.limit===1/0&&("function"!=typeof e||e===Nt)&&{index:n.index,range:n.range},a=function(n){var s=Math.min(d,t.length-n);return u.getMany({trans:r,keys:t.slice(n,n+s),cache:"immutable"}).then((function(c){for(var h=[],p=[],y=l?[]:null,v=[],b=0;b<s;++b){var g=c[b],w={value:T(g),primKey:t[n+b]};!1!==i.call(w,w.value,w)&&(null==w.value?v.push(t[n+b]):l||0===Pt(f(g),f(w.value))?(p.push(w.value),l&&y.push(t[n+b])):(v.push(t[n+b]),h.push(w.value)))}return Promise.resolve(h.length>0&&u.mutate({trans:r,type:"add",values:h}).then((function(e){for(var t in e.failures)v.splice(parseInt(t),1);m(h.length,e)}))).then((function(){return(p.length>0||o&&"object"==typeof e)&&u.mutate({trans:r,type:"put",keys:y,values:p,criteria:o,changeSpec:"function"!=typeof e&&e,isAdditionalChunk:n>0}).then((function(e){return m(p.length,e)}))})).then((function(){return(v.length>0||o&&e===Nt)&&u.mutate({trans:r,type:"delete",keys:v,criteria:o,isAdditionalChunk:n>0}).then((function(e){return m(v.length,e)}))})).then((function(){return t.length>n+s&&a(n+d)}))}))};return a(0).then((function(){if(p.length>0)throw new Q("Error modifying one or more objects",p,y,v);return t.length}))}))}))},e.prototype.delete=function(){var e=this._ctx,t=e.range;return Ct(e)&&(e.isPrimKey||3===t.type)?this._write((function(n){var r=e.table.core.schema.primaryKey,i=t;return e.table.core.count({trans:n,query:{index:r,range:i}}).then((function(t){return e.table.core.mutate({trans:n,type:"deleteRange",range:i}).then((function(e){var n=e.failures;e.lastResult,e.results;var r=e.numFailures;if(r)throw new Q("Could not delete some values",Object.keys(n).map((function(e){return n[e]})),t-r);return t-r}))}))})):this.modify(Nt)},e}(),Nt=function(e,t){return t.value=null};function Lt(e,t){return e<t?-1:e===t?0:1}function Ut(e,t){return e>t?-1:e===t?0:1}function zt(e,t,n){var r=e instanceof Qt?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function Vt(e){return new e.Collection(e,(function(){return Xt("")})).limit(0)}function Wt(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):u>=0?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)}function Yt(e,t,n,r){var i,o,a,u,s,c,l,f=n.length;if(!n.every((function(e){return"string"==typeof e})))return zt(e,vt);function d(e){i=function(e){return"next"===e?function(e){return e.toUpperCase()}:function(e){return e.toLowerCase()}}(e),o=function(e){return"next"===e?function(e){return e.toLowerCase()}:function(e){return e.toUpperCase()}}(e),a="next"===e?Lt:Ut;var t=n.map((function(e){return{lower:o(e),upper:i(e)}})).sort((function(e,t){return a(e.lower,t.lower)}));u=t.map((function(e){return e.upper})),s=t.map((function(e){return e.lower})),c=e,l="next"===e?"":r}d("next");var h=new e.Collection(e,(function(){return $t(u[0],s[f-1]+r)}));h._ondirectionchange=function(e){d(e)};var p=0;return h._addAlgorithm((function(e,n,r){var i=e.key;if("string"!=typeof i)return!1;var d=o(i);if(t(d,s,p))return!0;for(var h=null,y=p;y<f;++y){var v=Wt(i,d,u[y],s[y],a,c);null===v&&null===h?p=y+1:(null===h||a(h,v)>0)&&(h=v)}return n(null!==h?function(){e.continue(h+l)}:r),!1})),h}function $t(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function Xt(e){return{type:1,lower:e,upper:e}}var Qt=function(){function e(){}return Object.defineProperty(e.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),e.prototype.between=function(e,t,n,r){n=!1!==n,r=!0===r;try{return this._cmp(e,t)>0||0===this._cmp(e,t)&&(n||r)&&(!n||!r)?Vt(this):new this.Collection(this,(function(){return $t(e,t,!n,!r)}))}catch(e){return zt(this,yt)}},e.prototype.equals=function(e){return null==e?zt(this,yt):new this.Collection(this,(function(){return Xt(e)}))},e.prototype.above=function(e){return null==e?zt(this,yt):new this.Collection(this,(function(){return $t(e,void 0,!0)}))},e.prototype.aboveOrEqual=function(e){return null==e?zt(this,yt):new this.Collection(this,(function(){return $t(e,void 0,!1)}))},e.prototype.below=function(e){return null==e?zt(this,yt):new this.Collection(this,(function(){return $t(void 0,e,!1,!0)}))},e.prototype.belowOrEqual=function(e){return null==e?zt(this,yt):new this.Collection(this,(function(){return $t(void 0,e)}))},e.prototype.startsWith=function(e){return"string"!=typeof e?zt(this,vt):this.between(e,e+ht,!0,!0)},e.prototype.startsWithIgnoreCase=function(e){return""===e?this.startsWith(e):Yt(this,(function(e,t){return 0===e.indexOf(t[0])}),[e],ht)},e.prototype.equalsIgnoreCase=function(e){return Yt(this,(function(e,t){return e===t[0]}),[e],"")},e.prototype.anyOfIgnoreCase=function(){var e=U.apply(L,arguments);return 0===e.length?Vt(this):Yt(this,(function(e,t){return-1!==t.indexOf(e)}),e,"")},e.prototype.startsWithAnyOfIgnoreCase=function(){var e=U.apply(L,arguments);return 0===e.length?Vt(this):Yt(this,(function(e,t){return t.some((function(t){return 0===e.indexOf(t)}))}),e,ht)},e.prototype.anyOf=function(){var e=this,t=U.apply(L,arguments),n=this._cmp;try{t.sort(n)}catch(e){return zt(this,yt)}if(0===t.length)return Vt(this);var r=new this.Collection(this,(function(){return $t(t[0],t[t.length-1])}));r._ondirectionchange=function(r){n="next"===r?e._ascending:e._descending,t.sort(n)};var i=0;return r._addAlgorithm((function(e,r,o){for(var a=e.key;n(a,t[i])>0;)if(++i===t.length)return r(o),!1;return 0===n(a,t[i])||(r((function(){e.continue(t[i])})),!1)})),r},e.prototype.notEqual=function(e){return this.inAnyRange([[pt,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},e.prototype.noneOf=function(){var e=U.apply(L,arguments);if(0===e.length)return new this.Collection(this);try{e.sort(this._ascending)}catch(e){return zt(this,yt)}var t=e.reduce((function(e,t){return e?e.concat([[e[e.length-1][1],t]]):[[pt,t]]}),null);return t.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(t,{includeLowers:!1,includeUppers:!1})},e.prototype.inAnyRange=function(e,t){var n=this,r=this._cmp,i=this._ascending,o=this._descending,a=this._min,u=this._max;if(0===e.length)return Vt(this);if(!e.every((function(e){return void 0!==e[0]&&void 0!==e[1]&&i(e[0],e[1])<=0})))return zt(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",Z.InvalidArgument);var s,c=!t||!1!==t.includeLowers,l=t&&!0===t.includeUppers,f=i;function d(e,t){return f(e[0],t[0])}try{s=e.reduce((function(e,t){for(var n=0,i=e.length;n<i;++n){var o=e[n];if(r(t[0],o[1])<0&&r(t[1],o[0])>0){o[0]=a(o[0],t[0]),o[1]=u(o[1],t[1]);break}}return n===i&&e.push(t),e}),[]),s.sort(d)}catch(e){return zt(this,yt)}var h=0,p=l?function(e){return i(e,s[h][1])>0}:function(e){return i(e,s[h][1])>=0},y=c?function(e){return o(e,s[h][0])>0}:function(e){return o(e,s[h][0])>=0},v=p,m=new this.Collection(this,(function(){return $t(s[0][0],s[s.length-1][1],!c,!l)}));return m._ondirectionchange=function(e){"next"===e?(v=p,f=i):(v=y,f=o),s.sort(d)},m._addAlgorithm((function(e,t,r){for(var o=e.key;v(o);)if(++h===s.length)return t(r),!1;return!!function(e){return!p(e)&&!y(e)}(o)||(0===n._cmp(o,s[h][1])||0===n._cmp(o,s[h][0])||t((function(){f===i?e.continue(s[h][0]):e.continue(s[h][1])})),!1)})),m},e.prototype.startsWithAnyOf=function(){var e=U.apply(L,arguments);return e.every((function(e){return"string"==typeof e}))?0===e.length?Vt(this):this.inAnyRange(e.map((function(e){return[e,e+ht]}))):zt(this,"startsWithAnyOf() only works with strings")},e}();function Gt(e){return Ye((function(t){return Ht(t),e(t.target.error),!1}))}function Ht(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}var Jt="storagemutated",Zt="x-storagemutated-1",en=It(null,Jt),tn=function(){function e(){}return e.prototype._lock=function(){return k(!Ie.global),++this._reculock,1!==this._reculock||Ie.global||(Ie.lockOwnerFor=this),this},e.prototype._unlock=function(){if(k(!Ie.global),0==--this._reculock)for(Ie.global||(Ie.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{ut(e[1],e[0])}catch(e){}}return this},e.prototype._locked=function(){return this._reculock&&Ie.lockOwnerFor!==this},e.prototype.create=function(e){var t=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(k(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new Z.DatabaseClosed(r);case"MissingAPIError":throw new Z.MissingAPI(r.message,r);default:throw new Z.OpenFailed(r)}if(!this.active)throw new Z.TransactionInactive;return k(null===this._completion._state),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Ye((function(n){Ht(n),t._reject(e.error)})),e.onabort=Ye((function(n){Ht(n),t.active&&t._reject(new Z.Abort(e.error)),t.active=!1,t.on("abort").fire(n)})),e.oncomplete=Ye((function(){t.active=!1,t._resolve(),"mutatedParts"in e&&en.storagemutated.fire(e.mutatedParts)})),this},e.prototype._promise=function(e,t,n){var r=this;if("readwrite"===e&&"readwrite"!==this.mode)return lt(new Z.ReadOnly("Transaction is readonly"));if(!this.active)return lt(new Z.TransactionInactive);if(this._locked())return new De((function(i,o){r._blockedFuncs.push([function(){r._promise(e,t,n).then(i,o)},Ie])}));if(n)return Ze((function(){var e=new De((function(e,n){r._lock();var i=t(e,n,r);i&&i.then&&i.then(e,n)}));return e.finally((function(){return r._unlock()})),e._lib=!0,e}));var i=new De((function(e,n){var i=t(e,n,r);i&&i.then&&i.then(e,n)}));ret