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