From 578768b19e9f03a6e5bae3f39a8bed66225660ba Mon Sep 17 00:00:00 2001 From: Roj Date: Wed, 20 Mar 2024 02:35:27 +0300 Subject: [PATCH] [Update Explorer] Rebuild worker --- static/update-explorer/worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/update-explorer/worker.js b/static/update-explorer/worker.js index bda6e9c..d6560a5 100644 --- a/static/update-explorer/worker.js +++ b/static/update-explorer/worker.js @@ -22,4 +22,4 @@ On the other hand, if you actually know what you're doing and you do need to ins `+r).join("")):""}var Xo=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"],ki=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],cr=Xo.concat(ki),Zo={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 Je(t,e){this._e=Le(),this.name=t,this.message=e}Ye(Je).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Nn(this._e,2))}},toString:function(){return this.name+": "+this.message}});function Ti(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,i)=>i.indexOf(n)===r).join(` `)}function Zt(t,e,n,r){this._e=Le(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Ti(t,e)}Ye(Zt).from(Je);function pt(t,e){this._e=Le(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Ti(t,e)}Ye(pt).from(Je);var hr=cr.reduce((t,e)=>(t[e]=e+"Error",t),{}),ea=Je,k=cr.reduce((t,e)=>{var n=e+"Error";function r(i,s){this._e=Le(),this.name=n,i?typeof i=="string"?(this.message=`${i}${s?` `+s:""}`,this.inner=s||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=Zo[e]||n,this.inner=null)}return Ye(r).from(ea),t[e]=r,t},{});k.Syntax=SyntaxError;k.Type=TypeError;k.Range=RangeError;var oi=ki.reduce((t,e)=>(t[e+"Error"]=k[e],t),{});function ta(t,e){if(!t||t instanceof Je||t instanceof TypeError||t instanceof SyntaxError||!t.name||!oi[t.name])return t;var n=new oi[t.name](e||t.message,t);return"stack"in t&&he(n,"stack",{get:function(){return this.inner.stack}}),n}var dn=cr.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=k[e]),t),{});dn.ModifyError=Zt;dn.DexieError=Je;dn.BulkError=pt;function F(){}function At(t){return t}function na(t,e){return t==null||t===At?e:function(n){return e(t(n))}}function Pe(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function ra(t,e){return t===F?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var s=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?Pe(r,this.onsuccess):r),i&&(this.onerror=this.onerror?Pe(i,this.onerror):i),s!==void 0?s:n}}function ia(t,e){return t===F?e:function(){t.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,e.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?Pe(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Pe(r,this.onerror):r)}}function sa(t,e){return t===F?e:function(n){var r=t.apply(this,arguments);H(n,r);var i=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?Pe(i,this.onsuccess):i),s&&(this.onerror=this.onerror?Pe(s,this.onerror):s),r===void 0?o===void 0?void 0:o:H(r,o)}}function oa(t,e){return t===F?e:function(){return e.apply(this,arguments)===!1?!1:t.apply(this,arguments)}}function pr(t,e){return t===F?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,i=arguments.length,s=new Array(i);i--;)s[i]=arguments[i];return n.then(function(){return e.apply(r,s)})}return e.apply(this,arguments)}}var ft={},aa=100,ua=20,Ii=100,[$n,en,Hn]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,yt(t),t];let e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,yt(e),t]})(),Ei=en&&en.then,Gt=$n&&$n.constructor,mr=!!Hn,Gn=!1,la=Hn?()=>{Hn.then(Bt)}:P.setImmediate?bi.bind(null,Bt):P.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{Bt(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(Bt,0)},bt=function(t,e){ht.push([t,e]),tn&&(la(),tn=!1)},Wn=!0,tn=!0,Ee=[],Wt=[],Vn=null,zn=At,Ve={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:li,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{li(t[0],t[1])}catch{}})}},R=Ve,ht=[],Fe=0,Vt=[];function x(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=F,this._lib=!1;var e=this._PSD=R;if(ne&&(this._stackHolder=Le(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==ft)throw new TypeError("Not a function");this._state=arguments[1],this._value=arguments[2],this._state===!1&&Jn(this,this._value);return}this._state=null,this._value=null,++e.ref,Pi(this,t)}var Yn={get:function(){var t=R,e=nn;function n(r,i){var s=!t.global&&(t!==R||e!==nn);let o=s&&!pe();var a=new x((u,d)=>{gr(this,new Fi(sn(r,t,s,o),sn(i,t,s,o),u,d,t))});return ne&&ji(a,this),a}return n.prototype=ft,n},set:function(t){he(this,"then",t&&t.prototype===ft?Yn:{get:function(){return t},set:Yn.set})}};ze(x.prototype,{then:Yn,_then:function(t,e){gr(this,new Fi(null,null,t,e,R))},catch:function(t){if(arguments.length===1)return this.then(null,t);var e=arguments[0],n=arguments[1];return typeof e=="function"?this.then(null,r=>r instanceof e?n(r):zt(r)):this.then(null,r=>r&&r.name===e?n(r):zt(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),zt(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Gn=!0;var t=Li(this,[],ua),e=t.join(` -From previous: `);return this._state!==null&&(this._stack=e),e}finally{Gn=!1}}},timeout:function(t,e){return t<1/0?new x((n,r)=>{var i=setTimeout(()=>r(new k.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,i))}):this}});typeof Symbol<"u"&&Symbol.toStringTag&&he(x.prototype,Symbol.toStringTag,"Dexie.Promise");Ve.env=Qi();function Fi(t,e,n,r,i){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=i}ze(x,{all:function(){var t=le.apply(null,arguments).map(rn);return new x(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((i,s)=>x.resolve(i).then(o=>{t[s]=o,--r||e(t)},n))})},resolve:t=>{if(t instanceof x)return t;if(t&&typeof t.then=="function")return new x((n,r)=>{t.then(n,r)});var e=new x(ft,!0,t);return ji(e,Vn),e},reject:zt,race:function(){var t=le.apply(null,arguments).map(rn);return new x((e,n)=>{t.map(r=>x.resolve(r).then(e,n))})},PSD:{get:()=>R,set:t=>R=t},totalEchoes:{get:()=>nn},newPSD:we,usePSD:Ze,scheduler:{get:()=>bt,set:t=>{bt=t}},rejectionMapper:{get:()=>zn,set:t=>{zn=t}},follow:(t,e)=>new x((n,r)=>we((i,s)=>{var o=R;o.unhandleds=[],o.onunhandled=s,o.finalize=Pe(function(){ca(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),t()},e,n,r))});Gt&&(Gt.allSettled&&he(x,"allSettled",function(){let t=le.apply(null,arguments).map(rn);return new x(e=>{t.length===0&&e([]);let n=t.length,r=new Array(n);t.forEach((i,s)=>x.resolve(i).then(o=>r[s]={status:"fulfilled",value:o},o=>r[s]={status:"rejected",reason:o}).then(()=>--n||e(r)))})}),Gt.any&&typeof AggregateError<"u"&&he(x,"any",function(){let t=le.apply(null,arguments).map(rn);return new x((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length,i=new Array(r);t.forEach((s,o)=>x.resolve(s).then(a=>e(a),a=>{i[o]=a,--r||n(new AggregateError(i))}))})}));function Pi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&St();n&&typeof n.then=="function"?Pi(t,(i,s)=>{n instanceof x?n._then(i,s):n.then(i,s)}):(t._state=!0,t._value=n,Oi(t)),r&&Rt()}},Jn.bind(null,t))}catch(n){Jn(t,n)}}function Jn(t,e){if(Wt.push(e),t._state===null){var n=t._lib&&St();e=zn(e),t._state=!1,t._value=e,ne&&e!==null&&typeof e=="object"&&!e._promise&&Ho(()=>{var r=lr(e,"stack");e._promise=t,he(e,"stack",{get:()=>Gn?r&&(r.get?r.get.apply(e):r.value):t.stack})}),ha(t),Oi(t),n&&Rt()}}function Oi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Fe===0&&yr()},[]))}function gr(t,e){if(t._state===null){t._listeners.push(e);return}var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Fe,bt(da,[n,t,e])}function da(t,e,n){try{Vn=e;var r,i=e._value;e._state?r=t(i):(Wt.length&&(Wt=[]),r=t(i),Wt.indexOf(i)===-1&&pa(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Vn=null,--Fe===0&&yr(),--n.psd.ref||n.psd.finalize()}}function Li(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var i=t._value,s,o;i!=null?(s=i.name||"Error",o=i.message||i,r=Nn(i,0)):(s=i,o=""),e.push(s+(o?": "+o:"")+r)}return ne&&(r=Nn(t._stackHolder,2),r&&e.indexOf(r)===-1&&e.push(r),t._prev&&Li(t._prev,e,n)),e}function ji(t,e){var n=e?e._numPrev+1:0;n0;)for(t=ht,ht=[],n=t.length,e=0;e0);Wn=!0,tn=!0}function yr(){var t=Ee;Ee=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=Vt.slice(0),n=e.length;n;)e[--n]()}function ca(t){function e(){t(),Vt.splice(Vt.indexOf(e),1)}Vt.push(e),++Fe,bt(()=>{--Fe===0&&yr()},[])}function ha(t){Ee.some(e=>e._value===t._value)||Ee.push(t)}function pa(t){for(var e=Ee.length;e;)if(Ee[--e]._value===t._value){Ee.splice(e,1);return}}function zt(t){return new x(ft,!1,t)}function O(t,e){var n=R;return function(){var r=St(),i=R;try{return ve(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{ve(i,!1),r&&Rt()}}}var D={awaits:0,echoes:0,id:0},ma=0,Yt=[],On=0,nn=0,ga=0;function we(t,e,n,r){var i=R,s=Object.create(i);s.parent=i,s.ref=0,s.global=!1,s.id=++ga;var o=Ve.env;s.env=mr?{Promise:x,PromiseProp:{value:x,configurable:!0,writable:!0},all:x.all,race:x.race,allSettled:x.allSettled,any:x.any,resolve:x.resolve,reject:x.reject,nthen:ai(o.nthen,s),gthen:ai(o.gthen,s)}:{},e&&H(s,e),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Ze(s,t,n,r);return s.ref===0&&s.finalize(),a}function Xe(){return D.id||(D.id=++ma),++D.awaits,D.echoes+=Ii,D.id}function pe(){return D.awaits?(--D.awaits===0&&(D.id=0),D.echoes=D.awaits*Ii,!0):!1}(""+Ei).indexOf("[native code]")===-1&&(Xe=pe=F);function rn(t){return D.echoes&&t&&t.constructor===Gt?(Xe(),t.then(e=>(pe(),e),e=>(pe(),Q(e)))):t}function ya(t){++nn,(!D.echoes||--D.echoes===0)&&(D.echoes=D.id=0),Yt.push(R),ve(t,!0)}function fa(){var t=Yt[Yt.length-1];Yt.pop(),ve(t,!1)}function ve(t,e){var n=R;if((e?D.echoes&&(!On++||t!==R):On&&(!--On||t!==R))&&Ui(e?ya.bind(null,t):fa),t!==R&&(R=t,n===Ve&&(Ve.env=Qi()),mr)){var r=Ve.env.Promise,i=t.env;en.then=i.nthen,r.prototype.then=i.gthen,(n.global||t.global)&&(Object.defineProperty(P,"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 Qi(){var t=P.Promise;return mr?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(P,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:en.then,gthen:t.prototype.then}:{}}function Ze(t,e,n,r,i){var s=R;try{return ve(t,!0),e(n,r,i)}finally{ve(s,!1)}}function Ui(t){Ei.call($n,t)}function sn(t,e,n,r){return typeof t!="function"?t:function(){var i=R;n&&Xe(),ve(e,!0);try{return t.apply(this,arguments)}finally{ve(i,!1),r&&Ui(pe)}}}function ai(t,e){return function(n,r){return t.call(this,sn(n,e),sn(r,e))}}var ui="unhandledrejection";function li(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,i={promise:e,reason:t};if(P.document&&document.createEvent?(r=document.createEvent("Event"),r.initEvent(ui,!0,!0),H(r,i)):P.CustomEvent&&(r=new CustomEvent(ui,{detail:i}),H(r,i)),r&&P.dispatchEvent&&(dispatchEvent(r),!P.PromiseRejectionEvent&&P.onunhandledrejection))try{P.onunhandledrejection(r)}catch{}ne&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Q=x.reject;function Xn(t,e,n,r){if(!t.idbdb||!t._state.openComplete&&!R.letThrough&&!t._vip){if(t._state.openComplete)return Q(new k.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Q(new k.DatabaseClosed);t.open().catch(F)}return t._state.dbReadyPromise.then(()=>Xn(t,e,n,r))}else{var i=t._createTransaction(e,n,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===hr.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Xn(t,e,n,r))):Q(s)}return i._promise(e,(s,o)=>we(()=>(R.trans=i,r(s,o,i)))).then(s=>i._completion.then(()=>s))}}var di="3.2.6",Ie="\uFFFF",Zn=-1/0,ae="Invalid key provided. Keys must be of type string, number, Date or Array.",Ki="String expected.",mt=[],cn=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),ba=cn,Ca=cn,Di=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),hn="__dbnames",Ln="readonly",jn="readwrite";function Oe(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}var Bi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function qt(t){return typeof t=="string"&&!/\./.test(t)?e=>(e[t]===void 0&&t in e&&(e=xt(e),delete e[t]),e):e=>e}var _a=class{_trans(t,e,n){let r=this._tx||R.trans,i=this.name;function s(a,u,d){if(!d.schema[i])throw new k.NotFound("Table "+i+" not part of transaction");return e(d.idbtrans,d)}let o=St();try{return r&&r.db===this.db?r===R.trans?r._promise(t,s,n):we(()=>r._promise(t,s,n),{trans:r,transless:R.transless||R}):Xn(this.db,t,[this.name],s)}finally{o&&Rt()}}get(t,e){return t&&t.constructor===Object?this.where(t).first(e):this._trans("readonly",n=>this.core.get({trans:n,key:t}).then(r=>this.hook.reading.fire(r))).then(e)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(B(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);let e=j(t);if(e.length===1)return this.where(e[0]).equals(t[e[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(u=>{if(u.compound&&e.every(d=>u.keyPath.indexOf(d)>=0)){for(let d=0;du.keyPath.length-d.keyPath.length)[0];if(n&&this.db._maxKey!==Ie){let u=n.keyPath.slice(0,e.length);return this.where(u).equals(u.map(d=>t[d]))}!n&&ne&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${e.join("+")}]`);let{idxByName:r}=this.schema,i=this.db._deps.indexedDB;function s(u,d){try{return i.cmp(u,d)===0}catch{return!1}}let[o,a]=e.reduce(([u,d],h)=>{let c=r[h],l=t[h];return[u||c,u||!c?Oe(d,c&&c.multi?f=>{let y=ce(f,h);return B(y)&&y.some(m=>s(l,m))}:f=>s(l,ce(f,h))):d]},[null,null]);return o?this.where(o.name).equals(t[o.keyPath]).filter(a):n?this.filter(a):this.where(e).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,B(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;let e=n=>{if(!n)return n;let r=Object.create(t.prototype);for(var i in n)if(V(n,i))try{r[i]=n[i]}catch{}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=e,this.hook("reading",e),t}defineClass(){function t(e){H(this,e)}return this.mapToClass(t)}add(t,e){let{auto:n,keyPath:r}=this.schema.primKey,i=t;return r&&n&&(i=qt(r)(t)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"add",keys:e!=null?[e]:null,values:[i]})).then(s=>s.numFailures?x.reject(s.failures[0]):s.lastResult).then(s=>{if(r)try{Z(t,r,s)}catch{}return s})}update(t,e){if(typeof t=="object"&&!B(t)){let n=ce(t,this.schema.primKey.keyPath);if(n===void 0)return Q(new k.InvalidArgument("Given object does not contain its primary key"));try{typeof e!="function"?j(e).forEach(r=>{Z(t,r,e[r])}):e(t,{value:t,primKey:n})}catch{}return this.where(":id").equals(n).modify(e)}else return this.where(":id").equals(t).modify(e)}put(t,e){let{auto:n,keyPath:r}=this.schema.primKey,i=t;return r&&n&&(i=qt(r)(t)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"put",values:[i],keys:e!=null?[e]:null})).then(s=>s.numFailures?x.reject(s.failures[0]):s.lastResult).then(s=>{if(r)try{Z(t,r,s)}catch{}return s})}delete(t){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"delete",keys:[t]})).then(e=>e.numFailures?x.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:Bi})).then(t=>t.numFailures?x.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",e=>this.core.getMany({keys:t,trans:e}).then(n=>n.map(r=>this.hook.reading.fire(r))))}bulkAdd(t,e,n){let r=Array.isArray(e)?e:void 0;n=n||(r?void 0:e);let i=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:o,keyPath:a}=this.schema.primKey;if(a&&r)throw new k.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==t.length)throw new k.InvalidArgument("Arguments objects and keys must have the same length");let u=t.length,d=a&&o?t.map(qt(a)):t;return this.core.mutate({trans:s,type:"add",keys:r,values:d,wantResults:i}).then(({numFailures:h,results:c,lastResult:l,failures:f})=>{let y=i?c:l;if(h===0)return y;throw new pt(`${this.name}.bulkAdd(): ${h} of ${u} operations failed`,f)})})}bulkPut(t,e,n){let r=Array.isArray(e)?e:void 0;n=n||(r?void 0:e);let i=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:o,keyPath:a}=this.schema.primKey;if(a&&r)throw new k.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==t.length)throw new k.InvalidArgument("Arguments objects and keys must have the same length");let u=t.length,d=a&&o?t.map(qt(a)):t;return this.core.mutate({trans:s,type:"put",keys:r,values:d,wantResults:i}).then(({numFailures:h,results:c,lastResult:l,failures:f})=>{let y=i?c:l;if(h===0)return y;throw new pt(`${this.name}.bulkPut(): ${h} of ${u} operations failed`,f)})})}bulkDelete(t){let e=t.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:t})).then(({numFailures:n,lastResult:r,failures:i})=>{if(n===0)return r;throw new pt(`${this.name}.bulkDelete(): ${n} of ${e} operations failed`,i)})}};function Mt(t){var e={},n=function(a,u){if(u){for(var d=arguments.length,h=new Array(d-1);--d;)h[d-1]=arguments[d];return e[a].subscribe.apply(null,h),t}else if(typeof a=="string")return e[a]};n.addEventType=s;for(var r=1,i=arguments.length;rOe(r(),e()):e,t.justLimit=n&&!r}function va(t,e){t.isMatch=Oe(t.isMatch,e)}function Jt(t,e){if(t.isPrimKey)return e.primaryKey;let n=e.getIndexByKeyPath(t.index);if(!n)throw new k.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function ci(t,e,n){let r=Jt(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function Nt(t,e,n,r){let i=t.replayFilter?Oe(t.filter,t.replayFilter()):t.filter;if(t.or){let s={},o=(a,u,d)=>{if(!i||i(u,d,l=>u.stop(l),l=>u.fail(l))){var h=u.primaryKey,c=""+h;c==="[object ArrayBuffer]"&&(c=""+new Uint8Array(h)),V(s,c)||(s[c]=!0,e(a,u,d))}};return Promise.all([t.or._iterate(o,n),hi(ci(t,r,n),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}else return hi(ci(t,r,n),Oe(t.algorithm,i),e,!t.keysOnly&&t.valueMapper)}function hi(t,e,n,r){var i=r?(o,a,u)=>n(r(o),a,u):n,s=O(i);return t.then(o=>{if(o)return o.start(()=>{var a=()=>o.continue();(!e||e(o,u=>a=u,u=>{o.stop(u),a=F},u=>{o.fail(u),a=F}))&&s(o.value,o,u=>a=u),a()})})}function $(t,e){try{let n=pi(t),r=pi(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tNt(e,t,n,e.table.core))}count(t){return this._read(e=>{let n=this._ctx,r=n.table.core;if(He(n,!0))return r.count({trans:e,query:{index:Jt(n,r.schema),range:n.range}}).then(s=>Math.min(s,n.limit));var i=0;return Nt(n,()=>(++i,!1),e,r).then(()=>i)}).then(t)}sortBy(t,e){let n=t.split(".").reverse(),r=n[0],i=n.length-1;function s(u,d){return d?s(u[n[d]],d-1):u[r]}var o=this._ctx.dir==="next"?1:-1;function a(u,d){var h=s(u,i),c=s(d,i);return hc?o:0}return this.toArray(function(u){return u.sort(a)}).then(e)}toArray(t){return this._read(e=>{var n=this._ctx;if(n.dir==="next"&&He(n,!0)&&n.limit>0){let{valueMapper:r}=n,i=Jt(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(({result:s})=>r?s.map(r):s)}else{let r=[];return Nt(n,i=>r.push(i),e,n.table.core).then(()=>r)}},t)}offset(t){var e=this._ctx;return t<=0?this:(e.offset+=t,He(e)?Un(e,()=>{var n=t;return(r,i)=>n===0?!0:n===1?(--n,!1):(i(()=>{r.advance(n),n=0}),!1)}):Un(e,()=>{var n=t;return()=>--n<0}),this)}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Un(this._ctx,()=>{var e=t;return function(n,r,i){return--e<=0&&r(i),e>=0}},!0),this}until(t,e){return Qn(this._ctx,function(n,r,i){return t(n.value)?(r(i),e):!0}),this}first(t){return this.limit(1).toArray(function(e){return e[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){return Qn(this._ctx,function(e){return t(e.value)}),va(this._ctx,t),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(n,r){t(r.key,r)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(n,r){t(r.primaryKey,r)})}keys(t){var e=this._ctx;e.keysOnly=!e.isMatch;var n=[];return this.each(function(r,i){n.push(i.key)}).then(function(){return n}).then(t)}primaryKeys(t){var e=this._ctx;if(e.dir==="next"&&He(e,!0)&&e.limit>0)return this._read(r=>{var i=Jt(e,e.table.core.schema);return e.table.core.query({trans:r,values:!1,limit:e.limit,query:{index:i,range:e.range}})}).then(({result:r})=>r).then(t);e.keysOnly=!e.isMatch;var n=[];return this.each(function(r,i){n.push(i.primaryKey)}).then(function(){return n}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(e){return e[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var n={};return Qn(this._ctx,function(r){var i=r.primaryKey.toString(),s=V(n,i);return n[i]=!0,!s}),this}modify(t){var e=this._ctx;return this._write(n=>{var r;if(typeof t=="function")r=t;else{var i=j(t),s=i.length;r=function(y){for(var m=!1,p=0;p{let{failures:p,numFailures:b}=m;c+=y-b;for(let C of j(p))h.push(p[C])};return this.clone().primaryKeys().then(y=>{let m=p=>{let b=Math.min(d,y.length-p);return o.getMany({trans:n,keys:y.slice(p,p+b),cache:"immutable"}).then(C=>{let _=[],w=[],A=a?[]:null,v=[];for(let M=0;M0&&o.mutate({trans:n,type:"add",values:_}).then(M=>{for(let L in M.failures)v.splice(parseInt(L),1);f(_.length,M)})).then(()=>(w.length>0||S&&typeof t=="object")&&o.mutate({trans:n,type:"put",keys:A,values:w,criteria:S,changeSpec:typeof t!="function"&&t}).then(M=>f(w.length,M))).then(()=>(v.length>0||S&&t===Kn)&&o.mutate({trans:n,type:"delete",keys:v,criteria:S}).then(M=>f(v.length,M))).then(()=>y.length>p+b&&m(p+d))})};return m(0).then(()=>{if(h.length>0)throw new Zt("Error modifying one or more objects",h,c,l);return y.length})})})}delete(){var t=this._ctx,e=t.range;return He(t)&&(t.isPrimKey&&!Ca||e.type===3)?this._write(n=>{let{primaryKey:r}=t.table.core.schema,i=e;return t.table.core.count({trans:n,query:{index:r,range:i}}).then(s=>t.table.core.mutate({trans:n,type:"deleteRange",range:i}).then(({failures:o,lastResult:a,results:u,numFailures:d})=>{if(d)throw new Zt("Could not delete some values",Object.keys(o).map(h=>o[h]),s-d);return s-d}))}):this.modify(Kn)}},Kn=(t,e)=>e.value=null;function Ra(t){return kt(Sa.prototype,function(e,n){this.db=t;let r=Bi,i=null;if(n)try{r=n()}catch(u){i=u}let s=e._ctx,o=s.table,a=o.hook.reading.fire;this._ctx={table:o,index:s.index,isPrimKey:!s.index||o.schema.primKey.keyPath&&s.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:s.or,valueMapper:a!==At?a:null}})}function Ma(t,e){return te?-1:t===e?0:1}function W(t,e,n){var r=t instanceof Ni?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Ge(t){return new t.Collection(t,()=>qi("")).limit(0)}function Ta(t){return t==="next"?e=>e.toUpperCase():e=>e.toLowerCase()}function Ia(t){return t==="next"?e=>e.toLowerCase():e=>e.toUpperCase()}function Ea(t,e,n,r,i,s){for(var o=Math.min(t.length,r.length),a=-1,u=0;u=0?t.substr(0,a)+e[a]+n.substr(a+1):null;i(t[u],d)<0&&(a=u)}return otypeof m=="string"))return W(t,Ki);function l(m){i=Ta(m),s=Ia(m),o=m==="next"?Ma:ka;var p=n.map(function(b){return{lower:s(b),upper:i(b)}}).sort(function(b,C){return o(b.lower,C.lower)});a=p.map(function(b){return b.upper}),u=p.map(function(b){return b.lower}),d=m,h=m==="next"?"":r}l("next");var f=new t.Collection(t,()=>be(a[0],u[c-1]+r));f._ondirectionchange=function(m){l(m)};var y=0;return f._addAlgorithm(function(m,p,b){var C=m.key;if(typeof C!="string")return!1;var _=s(C);if(e(_,u,y))return!0;for(var w=null,A=y;A0)&&(w=v)}return p(w!==null?function(){m.continue(w+h)}:b),!1}),f}function be(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function qi(t){return{type:1,lower:t,upper:t}}var Ni=class{get Collection(){return this._ctx.table.db.Collection}between(t,e,n,r){n=n!==!1,r=r===!0;try{return this._cmp(t,e)>0||this._cmp(t,e)===0&&(n||r)&&!(n&&r)?Ge(this):new this.Collection(this,()=>be(t,e,!n,!r))}catch{return W(this,ae)}}equals(t){return t==null?W(this,ae):new this.Collection(this,()=>qi(t))}above(t){return t==null?W(this,ae):new this.Collection(this,()=>be(t,void 0,!0))}aboveOrEqual(t){return t==null?W(this,ae):new this.Collection(this,()=>be(t,void 0,!1))}below(t){return t==null?W(this,ae):new this.Collection(this,()=>be(void 0,t,!1,!0))}belowOrEqual(t){return t==null?W(this,ae):new this.Collection(this,()=>be(void 0,t))}startsWith(t){return typeof t!="string"?W(this,Ki):this.between(t,t+Ie,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):$t(this,(e,n)=>e.indexOf(n[0])===0,[t],Ie)}equalsIgnoreCase(t){return $t(this,(e,n)=>e===n[0],[t],"")}anyOfIgnoreCase(){var t=le.apply(We,arguments);return t.length===0?Ge(this):$t(this,(e,n)=>n.indexOf(e)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=le.apply(We,arguments);return t.length===0?Ge(this):$t(this,(e,n)=>n.some(r=>e.indexOf(r)===0),t,Ie)}anyOf(){let t=le.apply(We,arguments),e=this._cmp;try{t.sort(e)}catch{return W(this,ae)}if(t.length===0)return Ge(this);let n=new this.Collection(this,()=>be(t[0],t[t.length-1]));n._ondirectionchange=i=>{e=i==="next"?this._ascending:this._descending,t.sort(e)};let r=0;return n._addAlgorithm((i,s,o)=>{let a=i.key;for(;e(a,t[r])>0;)if(++r,r===t.length)return s(o),!1;return e(a,t[r])===0?!0:(s(()=>{i.continue(t[r])}),!1)}),n}notEqual(t){return this.inAnyRange([[Zn,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let t=le.apply(We,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return W(this,ae)}let e=t.reduce((n,r)=>n?n.concat([[n[n.length-1][1],r]]):[[Zn,r]],null);return e.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,e){let n=this._cmp,r=this._ascending,i=this._descending,s=this._min,o=this._max;if(t.length===0)return Ge(this);if(!t.every(_=>_[0]!==void 0&&_[1]!==void 0&&r(_[0],_[1])<=0))return W(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",k.InvalidArgument);let a=!e||e.includeLowers!==!1,u=e&&e.includeUppers===!0;function d(_,w){let A=0,v=_.length;for(;A0){S[0]=s(S[0],w[0]),S[1]=o(S[1],w[1]);break}}return A===v&&_.push(w),_}let h=r;function c(_,w){return h(_[0],w[0])}let l;try{l=t.reduce(d,[]),l.sort(c)}catch{return W(this,ae)}let f=0,y=u?_=>r(_,l[f][1])>0:_=>r(_,l[f][1])>=0,m=a?_=>i(_,l[f][0])>0:_=>i(_,l[f][0])>=0;function p(_){return!y(_)&&!m(_)}let b=y,C=new this.Collection(this,()=>be(l[0][0],l[l.length-1][1],!a,!u));return C._ondirectionchange=_=>{_==="next"?(b=y,h=r):(b=m,h=i),l.sort(c)},C._addAlgorithm((_,w,A)=>{for(var v=_.key;b(v);)if(++f,f===l.length)return w(A),!1;return p(v)?!0:(this._cmp(v,l[f][1])===0||this._cmp(v,l[f][0])===0||w(()=>{h===r?_.continue(l[f][0]):_.continue(l[f][1])}),!1)}),C}startsWithAnyOf(){let t=le.apply(We,arguments);return t.every(e=>typeof e=="string")?t.length===0?Ge(this):this.inAnyRange(t.map(e=>[e,e+Ie])):W(this,"startsWithAnyOf() only works with strings")}};function Fa(t){return kt(Ni.prototype,function(e,n,r){this.db=t,this._ctx={table:e,index:n===":id"?null:n,or:r};let i=t._deps.indexedDB;if(!i)throw new k.MissingAPI;this._cmp=this._ascending=i.cmp.bind(i),this._descending=(s,o)=>i.cmp(o,s),this._max=(s,o)=>i.cmp(s,o)>0?s:o,this._min=(s,o)=>i.cmp(s,o)<0?s:o,this._IDBKeyRange=t._deps.IDBKeyRange})}function te(t){return O(function(e){return Ct(e),t(e.target.error),!1})}function Ct(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}var _t="storagemutated",_e="x-storagemutated-1",xe=Mt(null,_t),Pa=class{_lock(){return ct(!R.global),++this._reculock,this._reculock===1&&!R.global&&(R.lockOwnerFor=this),this}_unlock(){if(ct(!R.global),--this._reculock===0)for(R.global||(R.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Ze(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&R.lockOwnerFor!==this}create(t){if(!this.mode)return this;let e=this.db.idbdb,n=this.db._state.dbOpenError;if(ct(!this.idbtrans),!t&&!e)switch(n&&n.name){case"DatabaseClosedError":throw new k.DatabaseClosed(n);case"MissingAPIError":throw new k.MissingAPI(n.message,n);default:throw new k.OpenFailed(n)}if(!this.active)throw new k.TransactionInactive;return ct(this._completion._state===null),t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):e.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})),t.onerror=O(r=>{Ct(r),this._reject(t.error)}),t.onabort=O(r=>{Ct(r),this.active&&this._reject(new k.Abort(t.error)),this.active=!1,this.on("abort").fire(r)}),t.oncomplete=O(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&xe.storagemutated.fire(t.mutatedParts)}),this}_promise(t,e,n){if(t==="readwrite"&&this.mode!=="readwrite")return Q(new k.ReadOnly("Transaction is readonly"));if(!this.active)return Q(new k.TransactionInactive);if(this._locked())return new x((i,s)=>{this._blockedFuncs.push([()=>{this._promise(t,e,n).then(i,s)},R])});if(n)return we(()=>{var i=new x((s,o)=>{this._lock();let a=e(s,o,this);a&&a.then&&a.then(s,o)});return i.finally(()=>this._unlock()),i._lib=!0,i});var r=new x((i,s)=>{var o=e(i,s,this);o&&o.then&&o.then(i,s)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(t){var e=this._root();let n=x.resolve(t);if(e._waitingFor)e._waitingFor=e._waitingFor.then(()=>n);else{e._waitingFor=n,e._waitingQueue=[];var r=e.idbtrans.objectStore(e.storeNames[0]);(function s(){for(++e._spinCount;e._waitingQueue.length;)e._waitingQueue.shift()();e._waitingFor&&(r.get(-1/0).onsuccess=s)})()}var i=e._waitingFor;return new x((s,o)=>{n.then(a=>e._waitingQueue.push(O(s.bind(null,a))),a=>e._waitingQueue.push(O(o.bind(null,a)))).finally(()=>{e._waitingFor===i&&(e._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new k.Abort))}table(t){let e=this._memoizedTables||(this._memoizedTables={});if(V(e,t))return e[t];let n=this.schema[t];if(!n)throw new k.NotFound("Table "+t+" not part of transaction");let r=new this.db.Table(t,n,this);return r.core=this.db.core.table(t),e[t]=r,r}};function Oa(t){return kt(Pa.prototype,function(e,n,r,i,s){this.db=t,this.mode=e,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=i,this.idbtrans=null,this.on=Mt(this,"complete","error","abort"),this.parent=s||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 x((o,a)=>{this._resolve=o,this._reject=a}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},o=>{var a=this.active;return this.active=!1,this.on.error.fire(o),this.parent?this.parent._reject(o):a&&this.idbtrans&&this.idbtrans.abort(),Q(o)})})}function er(t,e,n,r,i,s,o){return{name:t,keyPath:e,unique:n,multi:r,auto:i,compound:s,src:(n&&!o?"&":"")+(r?"*":"")+(i?"++":"")+$i(e)}}function $i(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Hi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:vi(n,r=>[r.name,r])}}function La(t){return t.length===1?t[0]:t}var wt=t=>{try{return t.only([[]]),wt=()=>[[]],[[]]}catch{return wt=()=>Ie,Ie}};function tr(t){return t==null?()=>{}:typeof t=="string"?ja(t):e=>ce(e,t)}function ja(t){return t.split(".").length===1?e=>e[t]:e=>ce(e,t)}function gi(t){return[].slice.call(t)}var Qa=0;function gt(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Ua(t,e,n){function r(h,c){let l=gi(h.objectStoreNames);return{schema:{name:h.name,tables:l.map(f=>c.objectStore(f)).map(f=>{let{keyPath:y,autoIncrement:m}=f,p=B(y),b=y==null,C={},_={name:f.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:b,compound:p,keyPath:y,autoIncrement:m,unique:!0,extractKey:tr(y)},indexes:gi(f.indexNames).map(w=>f.index(w)).map(w=>{let{name:A,unique:v,multiEntry:S,keyPath:M}=w,L=B(M),E={name:A,compound:L,keyPath:M,unique:v,multiEntry:S,extractKey:tr(M)};return C[gt(M)]=E,E}),getIndexByKeyPath:w=>C[gt(w)]};return C[":id"]=_.primaryKey,y!=null&&(C[gt(y)]=_.primaryKey),_})},hasGetAll:l.length>0&&"getAll"in c.objectStore(l[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function i(h){if(h.type===3)return null;if(h.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:c,upper:l,lowerOpen:f,upperOpen:y}=h;return c===void 0?l===void 0?null:e.upperBound(l,!!y):l===void 0?e.lowerBound(c,!!f):e.bound(c,l,!!f,!!y)}function s(h){let c=h.name;function l({trans:m,type:p,keys:b,values:C,range:_}){return new Promise((w,A)=>{w=O(w);let v=m.objectStore(c),S=v.keyPath==null,M=p==="put"||p==="add";if(!M&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);let{length:L}=b||C||{length:1};if(b&&C&&b.length!==C.length)throw new Error("Given keys array must have same length as given values array.");if(L===0)return w({numFailures:0,failures:{},results:[],lastResult:void 0});let E,I=[],z=[],T=0,J=G=>{++T,Ct(G)};if(p==="deleteRange"){if(_.type===4)return w({numFailures:T,failures:z,results:[],lastResult:void 0});_.type===3?I.push(E=v.clear()):I.push(E=v.delete(i(_)))}else{let[G,Y]=M?S?[C,b]:[C,null]:[b,null];if(M)for(let U=0;U{let Y=G.target.result;I.forEach((U,et)=>U.error!=null&&(z[et]=U.error)),w({numFailures:T,failures:z,results:p==="delete"?b:I.map(U=>U.result),lastResult:Y})};E.onerror=G=>{J(G),X(G)},E.onsuccess=X})}function f({trans:m,values:p,query:b,reverse:C,unique:_}){return new Promise((w,A)=>{w=O(w);let{index:v,range:S}=b,M=m.objectStore(c),L=v.isPrimaryKey?M:M.index(v.name),E=C?_?"prevunique":"prev":_?"nextunique":"next",I=p||!("openKeyCursor"in L)?L.openCursor(i(S),E):L.openKeyCursor(i(S),E);I.onerror=te(A),I.onsuccess=O(z=>{let T=I.result;if(!T){w(null);return}T.___id=++Qa,T.done=!1;let J=T.continue.bind(T),X=T.continuePrimaryKey;X&&(X=X.bind(T));let G=T.advance.bind(T),Y=()=>{throw new Error("Cursor not started")},U=()=>{throw new Error("Cursor not stopped")};T.trans=m,T.stop=T.continue=T.continuePrimaryKey=T.advance=Y,T.fail=O(A),T.next=function(){let et=1;return this.start(()=>et--?this.continue():this.stop()).then(()=>this)},T.start=et=>{let Yi=new Promise((je,Ar)=>{je=O(je),I.onerror=te(Ar),T.fail=Ar,T.stop=Ji=>{T.stop=T.continue=T.continuePrimaryKey=T.advance=U,je(Ji)}}),mn=()=>{if(I.result)try{et()}catch(je){T.fail(je)}else T.done=!0,T.start=()=>{throw new Error("Cursor behind last entry")},T.stop()};return I.onsuccess=O(je=>{I.onsuccess=mn,mn()}),T.continue=J,T.continuePrimaryKey=X,T.advance=G,mn(),Yi},w(T)},A)})}function y(m){return p=>new Promise((b,C)=>{b=O(b);let{trans:_,values:w,limit:A,query:v}=p,S=A===1/0?void 0:A,{index:M,range:L}=v,E=_.objectStore(c),I=M.isPrimaryKey?E:E.index(M.name),z=i(L);if(A===0)return b({result:[]});if(m){let T=w?I.getAll(z,S):I.getAllKeys(z,S);T.onsuccess=J=>b({result:J.target.result}),T.onerror=te(C)}else{let T=0,J=w||!("openKeyCursor"in I)?I.openCursor(z):I.openKeyCursor(z),X=[];J.onsuccess=G=>{let Y=J.result;if(!Y)return b({result:X});if(X.push(w?Y.value:Y.primaryKey),++T===A)return b({result:X});Y.continue()},J.onerror=te(C)}})}return{name:c,schema:h,mutate:l,getMany({trans:m,keys:p}){return new Promise((b,C)=>{b=O(b);let _=m.objectStore(c),w=p.length,A=new Array(w),v=0,S=0,M,L=I=>{let z=I.target;(A[z._pos]=z.result)!=null,++S===v&&b(A)},E=te(C);for(let I=0;I{b=O(b);let _=m.objectStore(c).get(p);_.onsuccess=w=>b(w.target.result),_.onerror=te(C)})},query:y(a),openCursor:f,count({query:m,trans:p}){let{index:b,range:C}=m;return new Promise((_,w)=>{let A=p.objectStore(c),v=b.isPrimaryKey?A:A.index(b.name),S=i(C),M=S?v.count(S):v.count();M.onsuccess=O(L=>_(L.target.result)),M.onerror=te(w)})}}}let{schema:o,hasGetAll:a}=r(t,n),u=o.tables.map(h=>s(h)),d={};return u.forEach(h=>d[h.name]=h),{stack:"dbcore",transaction:t.transaction.bind(t),table(h){if(!d[h])throw new Error(`Table '${h}' not found`);return d[h]},MIN_KEY:-1/0,MAX_KEY:wt(e),schema:o}}function Ka(t,e){return e.reduce((n,{create:r})=>({...n,...r(n)}),t)}function Da(t,e,{IDBKeyRange:n,indexedDB:r},i){return{dbcore:Ka(Ua(e,n,i),t.dbcore)}}function fr({_novip:t},e){let n=e.db,r=Da(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(i=>{let s=i.name;t.core.schema.tables.some(o=>o.name===s)&&(i.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=i.core))})}function on({_novip:t},e,n,r){n.forEach(i=>{let s=r[i];e.forEach(o=>{let a=lr(o,i);(!a||"value"in a&&a.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?he(o,i,{get(){return this.table(i)},set(u){Ci(this,i,{value:u,writable:!0,configurable:!0,enumerable:!0})}}):o[i]=new t.Table(i,s))})})}function nr({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Ba(t,e){return t._cfg.version-e._cfg.version}function qa(t,e,n,r){let i=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,i);s.create(n),s._completion.catch(r);let o=s._reject.bind(s),a=R.transless||R;we(()=>{R.trans=s,R.transless=a,e===0?(j(i).forEach(u=>{br(n,u,i[u].primKey,i[u].indexes)}),fr(t,n),x.follow(()=>t.on.populate.fire(s)).catch(o)):Na(t,e,s,n).catch(o)})}function Na({_novip:t},e,n,r){let i=[],s=t._versions,o=t._dbSchema=Cr(t,t.idbdb,r),a=!1;s.filter(d=>d._cfg.version>=e).forEach(d=>{i.push(()=>{let h=o,c=d._cfg.dbschema;ir(t,h,r),ir(t,c,r),o=t._dbSchema=c;let l=Gi(h,c);l.add.forEach(y=>{br(r,y[0],y[1].primKey,y[1].indexes)}),l.change.forEach(y=>{if(y.recreate)throw new k.Upgrade("Not yet support for changing primary key");{let m=r.objectStore(y.name);y.add.forEach(p=>rr(m,p)),y.change.forEach(p=>{m.deleteIndex(p.name),rr(m,p)}),y.del.forEach(p=>m.deleteIndex(p))}});let f=d._cfg.contentUpgrade;if(f&&d._cfg.version>e){fr(t,r),n._memoizedTables={},a=!0;let y=xi(c);l.del.forEach(C=>{y[C]=h[C]}),nr(t,[t.Transaction.prototype]),on(t,[t.Transaction.prototype],j(y),y),n.schema=y;let m=dr(f);m&&Xe();let p,b=x.follow(()=>{if(p=f(n),p&&m){var C=pe.bind(null,null);p.then(C,C)}});return p&&typeof p.then=="function"?x.resolve(p):b.then(()=>p)}}),i.push(h=>{if(!a||!ba){let c=d._cfg.dbschema;Ha(c,h)}nr(t,[t.Transaction.prototype]),on(t,[t.Transaction.prototype],t._storeNames,t._dbSchema),n.schema=t._dbSchema})});function u(){return i.length?x.resolve(i.shift()(n.idbtrans)).then(u):x.resolve()}return u().then(()=>{$a(o,r)})}function Gi(t,e){let n={del:[],add:[],change:[]},r;for(r in t)e[r]||n.del.push(r);for(r in e){let i=t[r],s=e[r];if(!i)n.add.push([r,s]);else{let o={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||i.primKey.auto!==s.primKey.auto&&!cn)o.recreate=!0,n.change.push(o);else{let a=i.idxByName,u=s.idxByName,d;for(d in a)u[d]||o.del.push(d);for(d in u){let h=a[d],c=u[d];h?h.src!==c.src&&o.change.push(c):o.add.push(c)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}}return n}function br(t,e,n,r){let i=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>rr(i,s)),i}function $a(t,e){j(t).forEach(n=>{e.db.objectStoreNames.contains(n)||br(e,n,t[n].primKey,t[n].indexes)})}function Ha(t,e){[].slice.call(e.db.objectStoreNames).forEach(n=>t[n]==null&&e.db.deleteObjectStore(n))}function rr(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Cr(t,e,n){let r={};return ln(e.objectStoreNames,0).forEach(i=>{let s=n.objectStore(i),o=s.keyPath,a=er($i(o),o||"",!1,!1,!!s.autoIncrement,o&&typeof o!="string",!0),u=[];for(let h=0;hi.add.length||i.change.length))}function ir({_novip:t},e,n){let r=n.db.objectStoreNames;for(let i=0;i{e=e.trim();let r=e.replace(/([&*]|\+\+)/g,""),i=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return er(r,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),B(i),n===0)})}var za=class{_parseStoresSpec(t,e){j(t).forEach(n=>{if(t[n]!==null){var r=Va(t[n]),i=r.shift();if(i.multi)throw new k.Schema("Primary key cannot be multi-valued");r.forEach(s=>{if(s.auto)throw new k.Schema("Only primary key can be marked as autoIncrement (++)");if(!s.keyPath)throw new k.Schema("Index must have a name and cannot be an empty string")}),e[n]=Hi(n,i,r)}})}stores(t){let e=this.db;this._cfg.storesSource=this._cfg.storesSource?H(this._cfg.storesSource,t):t;let n=e._versions,r={},i={};return n.forEach(s=>{H(r,s._cfg.storesSource),i=s._cfg.dbschema={},s._parseStoresSpec(r,i)}),e._dbSchema=i,nr(e,[e._allTables,e,e.Transaction.prototype]),on(e,[e._allTables,e,e.Transaction.prototype,this._cfg.tables],j(i),i),e._storeNames=j(i),this}upgrade(t){return this._cfg.contentUpgrade=pr(this._cfg.contentUpgrade||F,t),this}};function Ya(t){return kt(za.prototype,function(e){this.db=t,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}function _r(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Tt(hn,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function wr(t){return t&&typeof t.databases=="function"}function Ja({indexedDB:t,IDBKeyRange:e}){return wr(t)?Promise.resolve(t.databases()).then(n=>n.map(r=>r.name).filter(r=>r!==hn)):_r(t,e).toCollection().primaryKeys()}function Xa({indexedDB:t,IDBKeyRange:e},n){!wr(t)&&n!==hn&&_r(t,e).put({name:n}).catch(F)}function Za({indexedDB:t,IDBKeyRange:e},n){!wr(t)&&n!==hn&&_r(t,e).delete(n).catch(F)}function sr(t){return we(function(){return R.letThrough=!0,t()})}function eu(){var t=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!t||!indexedDB.databases)return Promise.resolve();var e;return new Promise(function(n){var r=function(){return indexedDB.databases().finally(n)};e=setInterval(r,100),r()}).finally(function(){return clearInterval(e)})}function tu(t){let e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Q(e.dbOpenError):t);ne&&(e.openCanceller._stackHolder=Le()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;let r=e.openCanceller;function i(){if(e.openCanceller!==r)throw new k.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,o=null,a=!1,u=()=>new x((d,h)=>{if(i(),!n)throw new k.MissingAPI;let c=t.name,l=e.autoSchema?n.open(c):n.open(c,Math.round(t.verno*10));if(!l)throw new k.MissingAPI;l.onerror=te(h),l.onblocked=O(t._fireOnBlocked),l.onupgradeneeded=O(f=>{if(o=l.transaction,e.autoSchema&&!t._options.allowEmptyDB){l.onerror=Ct,o.abort(),l.result.close();let m=n.deleteDatabase(c);m.onsuccess=m.onerror=O(()=>{h(new k.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{o.onerror=te(h);var y=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;a=y<1,t._novip.idbdb=l.result,qa(t,y/10,o,h)}},h),l.onsuccess=O(()=>{o=null;let f=t._novip.idbdb=l.result,y=ln(f.objectStoreNames);if(y.length>0)try{let m=f.transaction(La(y),"readonly");e.autoSchema?Ga(t,f,m):(ir(t,t._dbSchema,m),Wa(t,m)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),fr(t,m)}catch{}mt.push(t),f.onversionchange=O(m=>{e.vcFired=!0,t.on("versionchange").fire(m)}),f.onclose=O(m=>{t.on("close").fire(m)}),a&&Xa(t._deps,c),d()},h)}).catch(d=>d&&d.name==="UnknownError"&&e.PR1398_maxLoop>0?(e.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u()):x.reject(d));return x.race([r,(typeof navigator>"u"?x.resolve():eu()).then(u)]).then(()=>(i(),e.onReadyBeingFired=[],x.resolve(sr(()=>t.on.ready.fire(t.vip))).then(function d(){if(e.onReadyBeingFired.length>0){let h=e.onReadyBeingFired.reduce(pr,F);return e.onReadyBeingFired=[],x.resolve(sr(()=>h(t.vip))).then(d)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(d=>{e.dbOpenError=d;try{o&&o.abort()}catch{}return r===e.openCanceller&&t._close(),Q(d)}).finally(()=>{e.openComplete=!0,s()})}function or(t){var e=o=>t.next(o),n=o=>t.throw(o),r=s(e),i=s(n);function s(o){return a=>{var u=o(a),d=u.value;return u.done?d:!d||typeof d.then!="function"?B(d)?Promise.all(d).then(r,i):r(d):d.then(r,i)}}return s(e)()}function nu(t,e,n){var r=arguments.length;if(r<2)throw new k.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];n=i.pop();var s=Ai(i);return[t,s,n]}function Wi(t,e,n,r,i){return x.resolve().then(()=>{let s=R.transless||R,o=t._createTransaction(e,n,t._dbSchema,r),a={trans:o,transless:s};if(r)o.idbtrans=r.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(c){return c.name===hr.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Wi(t,e,n,null,i))):Q(c)}let u=dr(i);u&&Xe();let d,h=x.follow(()=>{if(d=i.call(o,o),d)if(u){var c=pe.bind(null,null);d.then(c,c)}else typeof d.next=="function"&&typeof d.throw=="function"&&(d=or(d))},a);return(d&&typeof d.then=="function"?x.resolve(d).then(c=>o.active?c:Q(new k.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):h.then(()=>d)).then(c=>(r&&o._resolve(),o._completion.then(()=>c))).catch(c=>(o._reject(c),Q(c)))})}function Ht(t,e,n){let r=B(t)?t.slice():[t];for(let i=0;i0,C={...f,isVirtual:b,keyTail:l,keyLength:p,extractKey:tr(c),unique:!b&&f.unique};if(m.push(C),C.isPrimaryKey||s.push(C),p>1){let _=p===2?c[0]:c.slice(0,p-1);o(_,l+1,f)}return m.sort((_,w)=>_.keyTail-w.keyTail),C}let a=o(r.primaryKey.keyPath,0,r.primaryKey);i[":id"]=[a];for(let c of r.indexes)o(c.keyPath,0,c);function u(c){let l=i[gt(c)];return l&&l[0]}function d(c,l){return{type:c.type===1?2:c.type,lower:Ht(c.lower,c.lowerOpen?t.MAX_KEY:t.MIN_KEY,l),lowerOpen:!0,upper:Ht(c.upper,c.upperOpen?t.MIN_KEY:t.MAX_KEY,l),upperOpen:!0}}function h(c){let l=c.query.index;return l.isVirtual?{...c,query:{index:l,range:d(c.query.range,l.keyTail)}}:c}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:u},count(c){return n.count(h(c))},query(c){return n.query(h(c))},openCursor(c){let{keyTail:l,isVirtual:f,keyLength:y}=c.query.index;if(!f)return n.openCursor(c);function m(p){function b(C){C!=null?p.continue(Ht(C,c.reverse?t.MAX_KEY:t.MIN_KEY,l)):c.unique?p.continue(p.key.slice(0,y).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,l)):p.continue()}return Object.create(p,{continue:{value:b},continuePrimaryKey:{value(C,_){p.continuePrimaryKey(Ht(C,t.MAX_KEY,l),_)}},primaryKey:{get(){return p.primaryKey}},key:{get(){let C=p.key;return y===1?C[0]:C.slice(0,y)}},value:{get(){return p.value}}})}return n.openCursor(h(c)).then(p=>p&&m(p))}}}}}var iu={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:ru};function vr(t,e,n,r){return n=n||{},r=r||"",j(t).forEach(i=>{if(!V(e,i))n[r+i]=void 0;else{var s=t[i],o=e[i];if(typeof s=="object"&&typeof o=="object"&&s&&o){let a=Bn(s),u=Bn(o);a!==u?n[r+i]=e[i]:a==="Object"?vr(s,o,n,r+i+"."):s!==o&&(n[r+i]=e[i])}else s!==o&&(n[r+i]=e[i])}}),j(e).forEach(i=>{V(t,i)||(n[r+i]=e[i])}),n}function su(t,e){return e.type==="delete"?e.keys:e.keys||e.values.map(t.extractKey)}var ou={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){let n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(i){let s=R.trans,{deleting:o,creating:a,updating:u}=s.table(e).hook;switch(i.type){case"add":if(a.fire===F)break;return s._promise("readwrite",()=>d(i),!0);case"put":if(a.fire===F&&u.fire===F)break;return s._promise("readwrite",()=>d(i),!0);case"delete":if(o.fire===F)break;return s._promise("readwrite",()=>d(i),!0);case"deleteRange":if(o.fire===F)break;return s._promise("readwrite",()=>h(i),!0)}return n.mutate(i);function d(l){let f=R.trans,y=l.keys||su(r,l);if(!y)throw new Error("Keys missing");return l=l.type==="add"||l.type==="put"?{...l,keys:y}:{...l},l.type!=="delete"&&(l.values=[...l.values]),l.keys&&(l.keys=[...l.keys]),au(n,l,y).then(m=>{let p=y.map((b,C)=>{let _=m[C],w={onerror:null,onsuccess:null};if(l.type==="delete")o.fire.call(w,b,_,f);else if(l.type==="add"||_===void 0){let A=a.fire.call(w,b,l.values[C],f);b==null&&A!=null&&(b=A,l.keys[C]=b,r.outbound||Z(l.values[C],r.keyPath,b))}else{let A=vr(_,l.values[C]),v=u.fire.call(w,A,b,_,f);if(v){let S=l.values[C];Object.keys(v).forEach(M=>{V(S,M)?S[M]=v[M]:Z(S,M,v[M])})}}return w});return n.mutate(l).then(({failures:b,results:C,numFailures:_,lastResult:w})=>{for(let A=0;A(p.forEach(C=>C.onerror&&C.onerror(b)),Promise.reject(b)))})}function h(l){return c(l.trans,l.range,1e4)}function c(l,f,y){return n.query({trans:l,values:!1,query:{index:r,range:f},limit:y}).then(({result:m})=>d({type:"delete",keys:m,trans:l}).then(p=>p.numFailures>0?Promise.reject(p.failures[0]):m.length({table:e=>{let n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);let i=Vi(r.keys,r.trans._cache,r.cache==="clone");return i?x.resolve(i):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?xt(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function xr(t){return!("from"in t)}var ue=function(t,e){if(this)H(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0});else{let n=new ue;return t&&"d"in t&&H(n,t),n}};ze(ue.prototype,{add(t){return an(this,t),this},addKey(t){return vt(this,t,t),this},addKeys(t){return t.forEach(e=>vt(this,e,e)),this},[qn](){return ar(this)}});function vt(t,e,n){let r=$(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(xr(t))return H(t,{from:e,to:n,d:1});let i=t.l,s=t.r;if($(n,t.from)<0)return i?vt(i,e,n):t.l={from:e,to:n,d:1,l:null,r:null},yi(t);if($(e,t.to)>0)return s?vt(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},yi(t);$(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),$(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);let o=!t.r;i&&!t.l&&an(t,i),s&&o&&an(t,s)}function an(t,e){function n(r,{from:i,to:s,l:o,r:a}){vt(r,i,s),o&&n(r,o),a&&n(r,a)}xr(e)||n(t,e)}function lu(t,e){let n=ar(e),r=n.next();if(r.done)return!1;let i=r.value,s=ar(t),o=s.next(i.from),a=o.value;for(;!r.done&&!o.done;){if($(a.from,i.to)<=0&&$(a.to,i.from)>=0)return!0;$(i.from,a.from)<0?i=(r=n.next(a.from)).value:a=(o=s.next(i.from)).value}return!1}function ar(t){let e=xr(t)?null:{s:0,n:t};return{next(n){let r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&$(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||$(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function yi(t){var e,n;let r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),i=r>1?"r":r<-1?"l":"";if(i){let s=i==="r"?"l":"r",o={...t},a=t[i];t.from=a.from,t.to=a.to,t[i]=a[i],o[i]=a[s],t[s]=o,o.d=fi(o)}t.d=fi(t)}function fi({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}var du={stack:"dbcore",level:0,create:t=>{let e=t.schema.name,n=new ue(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{let i=t.table(r),{schema:s}=i,{primaryKey:o}=s,{extractKey:a,outbound:u}=o,d={...i,mutate:l=>{let f=l.trans,y=f.mutatedParts||(f.mutatedParts={}),m=v=>{let S=`idb://${e}/${r}/${v}`;return y[S]||(y[S]=new ue)},p=m(""),b=m(":dels"),{type:C}=l,[_,w]=l.type==="deleteRange"?[l.range]:l.type==="delete"?[l.keys]:l.values.length<50?[[],l.values]:[],A=l.trans._cache;return i.mutate(l).then(v=>{if(B(_)){C!=="delete"&&(_=v.results),p.addKeys(_);let S=Vi(_,A);!S&&C!=="add"&&b.addKeys(_),(S||w)&&cu(m,s,S,w)}else if(_){let S={from:_.lower,to:_.upper};b.add(S),p.add(S)}else p.add(n),b.add(n),s.indexes.forEach(S=>m(S.name).add(n));return v})}},h=({query:{index:l,range:f}})=>{var y,m;return[l,new ue((y=f.lower)!==null&&y!==void 0?y:t.MIN_KEY,(m=f.upper)!==null&&m!==void 0?m:t.MAX_KEY)]},c={get:l=>[o,new ue(l.key)],getMany:l=>[o,new ue().addKeys(l.keys)],count:h,query:h,openCursor:h};return j(c).forEach(l=>{d[l]=function(f){let{subscr:y}=R;if(y){let m=w=>{let A=`idb://${e}/${r}/${w}`;return y[A]||(y[A]=new ue)},p=m(""),b=m(":dels"),[C,_]=c[l](f);if(m(C.name||"").add(_),!C.isPrimaryKey)if(l==="count")b.add(n);else{let w=l==="query"&&u&&f.values&&i.query({...f,values:!1});return i[l].apply(this,arguments).then(A=>{if(l==="query"){if(u&&f.values)return w.then(({result:S})=>(p.addKeys(S),A));let v=f.values?A.result.map(a):A.result;f.values?p.addKeys(v):b.addKeys(v)}else if(l==="openCursor"){let v=A,S=f.values;return v&&Object.create(v,{key:{get(){return b.addKey(v.primaryKey),v.key}},primaryKey:{get(){let M=v.primaryKey;return b.addKey(M),M}},value:{get(){return S&&p.addKey(v.primaryKey),v.value}}})}return A})}}return i[l].apply(this,arguments)}}),d}}}};function cu(t,e,n,r){function i(s){let o=t(s.name||"");function a(d){return d!=null?s.extractKey(d):null}let u=d=>s.multiEntry&&B(d)?d.forEach(h=>o.addKey(h)):o.addKey(d);(n||r).forEach((d,h)=>{let c=n&&a(n[h]),l=r&&a(r[h]);$(c,l)!==0&&(c!=null&&u(c),l!=null&&u(l))})}e.indexes.forEach(i)}var Tt=class Xt{constructor(e,n){this._middlewares={},this.verno=0;let r=Xt.dependencies;this._options=n={addons:Xt.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};let{addons:i}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:F,dbReadyPromise:null,cancelOpen:F,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};s.dbReadyPromise=new x(o=>{s.dbReadyResolve=o}),s.openCanceller=new x((o,a)=>{s.cancelOpen=a}),this._state=s,this.name=e,this.on=Mt(this,"populate","blocked","versionchange","close",{ready:[pr,F]}),this.on.ready.subscribe=_i(this.on.ready.subscribe,o=>(a,u)=>{Xt.vip(()=>{let d=this._state;if(d.openComplete)d.dbOpenError||x.resolve().then(a),u&&o(a);else if(d.onReadyBeingFired)d.onReadyBeingFired.push(a),u&&o(a);else{o(a);let h=this;u||o(function c(){h.on.ready.unsubscribe(a),h.on.ready.unsubscribe(c)})}})}),this.Collection=Ra(this),this.Table=wa(this),this.Transaction=Oa(this),this.Version=Ya(this),this.WhereClause=Fa(this),this.on("versionchange",o=>{o.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",o=>{!o.newVersion||o.newVersionnew this.Transaction(o,a,u,this._options.chromeTransactionDurability,d),this._fireOnBlocked=o=>{this.on("blocked").fire(o),mt.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(o))},this.use(iu),this.use(ou),this.use(du),this.use(uu),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(o=>o(this))}version(e){if(isNaN(e)||e<.1)throw new k.Type("Given version is not a positive number");if(e=Math.round(e*10)/10,this.idbdb||this._state.isBeingOpened)throw new k.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var r=n.filter(i=>i._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(Ba),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||R.letThrough||this._vip)?e():new x((n,r)=>{if(this._state.openComplete)return r(new k.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen){r(new k.DatabaseClosed);return}this.open().catch(F)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:i}){i&&this.unuse({stack:e,name:i});let s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:i}),s.sort((o,a)=>o.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(i=>r?i.create!==r:n?i.name!==n:!1)),this}open(){return tu(this)}_close(){let e=this._state,n=mt.indexOf(this);if(n>=0&&mt.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new x(r=>{e.dbReadyResolve=r}),e.openCanceller=new x((r,i)=>{e.cancelOpen=i})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new k.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new x((r,i)=>{let s=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=O(()=>{Za(this._deps,this.name),r()}),o.onerror=te(i),o.onblocked=this._fireOnBlocked};if(e)throw new k.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return j(this._allTables).map(e=>this._allTables[e])}transaction(){let e=nu.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let i=R.trans;(!i||i.db!==this||e.indexOf("!")!==-1)&&(i=null);let s=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");let o,a;try{if(a=n.map(d=>{var h=d instanceof this.Table?d.name:d;if(typeof h!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return h}),e=="r"||e===Ln)o=Ln;else if(e=="rw"||e==jn)o=jn;else throw new k.InvalidArgument("Invalid transaction mode: "+e);if(i){if(i.mode===Ln&&o===jn)if(s)i=null;else throw new k.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i&&a.forEach(d=>{if(i&&i.storeNames.indexOf(d)===-1)if(s)i=null;else throw new k.SubTransaction("Table "+d+" not included in parent transaction.")}),s&&i&&!i.active&&(i=null)}}catch(d){return i?i._promise(null,(h,c)=>{c(d)}):Q(d)}let u=Wi.bind(null,this,o,a,i,r);return i?i._promise(o,u,"lock"):R.trans?Ze(R.transless,()=>this._whenReady(u)):this._whenReady(u)}table(e){if(!V(this._allTables,e))throw new k.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}},hu=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",pu=class{constructor(t){this._subscribe=t}subscribe(t,e,n){return this._subscribe(!t||typeof t=="function"?{next:t,error:e,complete:n}:t)}[hu](){return this}};function zi(t,e){return j(e).forEach(n=>{let r=t[n]||(t[n]=new ue);an(r,e[n])}),t}function mu(t){let e=!1,n,r=new pu(i=>{let s=dr(t);function o(p){s&&Xe();let b=()=>we(t,{subscr:p,trans:null}),C=R.trans?Ze(R.transless,b):b();return s&&C.then(pe,pe),C}let a=!1,u={},d={},h={get closed(){return a},unsubscribe:()=>{a=!0,xe.storagemutated.unsubscribe(y)}};i.start&&i.start(h);let c=!1,l=!1;function f(){return j(d).some(p=>u[p]&&lu(u[p],d[p]))}let y=p=>{zi(u,p),f()&&m()},m=()=>{if(c||a)return;u={};let p={},b=o(p);l||(xe(_t,y),l=!0),c=!0,Promise.resolve(b).then(C=>{e=!0,n=C,c=!1,!a&&(f()?m():(u={},d=p,i.next&&i.next(C)))},C=>{c=!1,e=!1,i.error&&i.error(C),h.unsubscribe()})};return m(),h});return r.hasValue=()=>e,r.getValue=()=>n,r}var ur;try{ur={indexedDB:P.indexedDB||P.mozIndexedDB||P.webkitIndexedDB||P.msIndexedDB,IDBKeyRange:P.IDBKeyRange||P.webkitIDBKeyRange}}catch{ur={indexedDB:null,IDBKeyRange:null}}var Te=Tt;ze(Te,{...dn,delete(t){return new Te(t,{addons:[]}).delete()},exists(t){return new Te(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1)},getDatabaseNames(t){try{return Ja(Te.dependencies).then(t)}catch{return Q(new k.MissingAPI)}},defineClass(){function t(e){H(this,e)}return t},ignoreTransaction(t){return R.trans?Ze(R.transless,t):t()},vip:sr,async:function(t){return function(){try{var e=or(t.apply(this,arguments));return!e||typeof e.then!="function"?x.resolve(e):e}catch(n){return Q(n)}}},spawn:function(t,e,n){try{var r=or(t.apply(n,e||[]));return!r||typeof r.then!="function"?x.resolve(r):r}catch(i){return Q(i)}},currentTransaction:{get:()=>R.trans||null},waitFor:function(t,e){let n=x.resolve(typeof t=="function"?Te.ignoreTransaction(t):t).timeout(e||6e4);return R.trans?R.trans.waitFor(n):n},Promise:x,debug:{get:()=>ne,set:t=>{Ri(t,t==="dexie"?()=>!0:Di)}},derive:Ye,extend:H,props:ze,override:_i,Events:Mt,on:xe,liveQuery:mu,extendObservabilitySet:zi,getByKeyPath:ce,setByKeyPath:Z,delByKeyPath:Go,shallowClone:xi,deepClone:xt,getObjectDiff:vr,cmp:$,asap:wi,minKey:Zn,addons:[],connections:mt,errnames:hr,dependencies:ur,semVer:di,version:di.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,n*2))});Te.maxKey=wt(Te.dependencies.IDBKeyRange);typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(xe(_t,t=>{if(!de){let e;cn?(e=document.createEvent("CustomEvent"),e.initCustomEvent(_e,!0,!0,t)):e=new CustomEvent(_e,{detail:t}),de=!0,dispatchEvent(e),de=!1}}),addEventListener(_e,({detail:t})=>{de||un(t)}));function un(t){let e=de;try{de=!0,xe.storagemutated.fire(t)}finally{de=e}}var de=!1;if(typeof BroadcastChannel<"u"){let t=new BroadcastChannel(_e);typeof t.unref=="function"&&t.unref(),xe(_t,e=>{de||t.postMessage(e)}),t.onmessage=e=>{e.data&&un(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){xe(_t,e=>{try{de||(typeof localStorage<"u"&&localStorage.setItem(_e,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:_e,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===_e){let n=JSON.parse(e.newValue);n&&un(n.changedParts)}});let t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",gu)}function gu({data:t}){t&&t.type===_e&&un(t.changedParts)}x.rejectionMapper=ta;Ri(ne,Di);var pn=class extends Tt{updates;constructor(e){super(`update-explorer_${e}`),this.version(1).stores({updates:"++id, &updateId"})}};addEventListener("message",async t=>{let e=new at(t.data),n=new pn(t.data),r=Date.now();try{await e.init(),postMessage({_:"me",me:e.me})}catch(i){let s="";i instanceof se?s=i.description=="Unauthorized"?"Invalid bot token":i.description:s=String(i),s=`Authorization failed: ${s}`,postMessage({_:"error",error:s});return}e.use(i=>{n.updates.put({updateId:i.update.update_id,data:i.update}),(!i.msg?.date||i.msg.date<=r)&&postMessage({_:"sound"})}),e.start()},{once:!0}); +From previous: `);return this._state!==null&&(this._stack=e),e}finally{Gn=!1}}},timeout:function(t,e){return t<1/0?new x((n,r)=>{var i=setTimeout(()=>r(new k.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,i))}):this}});typeof Symbol<"u"&&Symbol.toStringTag&&he(x.prototype,Symbol.toStringTag,"Dexie.Promise");Ve.env=Qi();function Fi(t,e,n,r,i){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=i}ze(x,{all:function(){var t=le.apply(null,arguments).map(rn);return new x(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((i,s)=>x.resolve(i).then(o=>{t[s]=o,--r||e(t)},n))})},resolve:t=>{if(t instanceof x)return t;if(t&&typeof t.then=="function")return new x((n,r)=>{t.then(n,r)});var e=new x(ft,!0,t);return ji(e,Vn),e},reject:zt,race:function(){var t=le.apply(null,arguments).map(rn);return new x((e,n)=>{t.map(r=>x.resolve(r).then(e,n))})},PSD:{get:()=>R,set:t=>R=t},totalEchoes:{get:()=>nn},newPSD:we,usePSD:Ze,scheduler:{get:()=>bt,set:t=>{bt=t}},rejectionMapper:{get:()=>zn,set:t=>{zn=t}},follow:(t,e)=>new x((n,r)=>we((i,s)=>{var o=R;o.unhandleds=[],o.onunhandled=s,o.finalize=Pe(function(){ca(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),t()},e,n,r))});Gt&&(Gt.allSettled&&he(x,"allSettled",function(){let t=le.apply(null,arguments).map(rn);return new x(e=>{t.length===0&&e([]);let n=t.length,r=new Array(n);t.forEach((i,s)=>x.resolve(i).then(o=>r[s]={status:"fulfilled",value:o},o=>r[s]={status:"rejected",reason:o}).then(()=>--n||e(r)))})}),Gt.any&&typeof AggregateError<"u"&&he(x,"any",function(){let t=le.apply(null,arguments).map(rn);return new x((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length,i=new Array(r);t.forEach((s,o)=>x.resolve(s).then(a=>e(a),a=>{i[o]=a,--r||n(new AggregateError(i))}))})}));function Pi(t,e){try{e(n=>{if(t._state===null){if(n===t)throw new TypeError("A promise cannot be resolved with itself.");var r=t._lib&&St();n&&typeof n.then=="function"?Pi(t,(i,s)=>{n instanceof x?n._then(i,s):n.then(i,s)}):(t._state=!0,t._value=n,Oi(t)),r&&Rt()}},Jn.bind(null,t))}catch(n){Jn(t,n)}}function Jn(t,e){if(Wt.push(e),t._state===null){var n=t._lib&&St();e=zn(e),t._state=!1,t._value=e,ne&&e!==null&&typeof e=="object"&&!e._promise&&Ho(()=>{var r=lr(e,"stack");e._promise=t,he(e,"stack",{get:()=>Gn?r&&(r.get?r.get.apply(e):r.value):t.stack})}),ha(t),Oi(t),n&&Rt()}}function Oi(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n{--Fe===0&&yr()},[]))}function gr(t,e){if(t._state===null){t._listeners.push(e);return}var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++Fe,bt(da,[n,t,e])}function da(t,e,n){try{Vn=e;var r,i=e._value;e._state?r=t(i):(Wt.length&&(Wt=[]),r=t(i),Wt.indexOf(i)===-1&&pa(e)),n.resolve(r)}catch(s){n.reject(s)}finally{Vn=null,--Fe===0&&yr(),--n.psd.ref||n.psd.finalize()}}function Li(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var i=t._value,s,o;i!=null?(s=i.name||"Error",o=i.message||i,r=Nn(i,0)):(s=i,o=""),e.push(s+(o?": "+o:"")+r)}return ne&&(r=Nn(t._stackHolder,2),r&&e.indexOf(r)===-1&&e.push(r),t._prev&&Li(t._prev,e,n)),e}function ji(t,e){var n=e?e._numPrev+1:0;n0;)for(t=ht,ht=[],n=t.length,e=0;e0);Wn=!0,tn=!0}function yr(){var t=Ee;Ee=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=Vt.slice(0),n=e.length;n;)e[--n]()}function ca(t){function e(){t(),Vt.splice(Vt.indexOf(e),1)}Vt.push(e),++Fe,bt(()=>{--Fe===0&&yr()},[])}function ha(t){Ee.some(e=>e._value===t._value)||Ee.push(t)}function pa(t){for(var e=Ee.length;e;)if(Ee[--e]._value===t._value){Ee.splice(e,1);return}}function zt(t){return new x(ft,!1,t)}function O(t,e){var n=R;return function(){var r=St(),i=R;try{return ve(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{ve(i,!1),r&&Rt()}}}var D={awaits:0,echoes:0,id:0},ma=0,Yt=[],On=0,nn=0,ga=0;function we(t,e,n,r){var i=R,s=Object.create(i);s.parent=i,s.ref=0,s.global=!1,s.id=++ga;var o=Ve.env;s.env=mr?{Promise:x,PromiseProp:{value:x,configurable:!0,writable:!0},all:x.all,race:x.race,allSettled:x.allSettled,any:x.any,resolve:x.resolve,reject:x.reject,nthen:ai(o.nthen,s),gthen:ai(o.gthen,s)}:{},e&&H(s,e),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=Ze(s,t,n,r);return s.ref===0&&s.finalize(),a}function Xe(){return D.id||(D.id=++ma),++D.awaits,D.echoes+=Ii,D.id}function pe(){return D.awaits?(--D.awaits===0&&(D.id=0),D.echoes=D.awaits*Ii,!0):!1}(""+Ei).indexOf("[native code]")===-1&&(Xe=pe=F);function rn(t){return D.echoes&&t&&t.constructor===Gt?(Xe(),t.then(e=>(pe(),e),e=>(pe(),Q(e)))):t}function ya(t){++nn,(!D.echoes||--D.echoes===0)&&(D.echoes=D.id=0),Yt.push(R),ve(t,!0)}function fa(){var t=Yt[Yt.length-1];Yt.pop(),ve(t,!1)}function ve(t,e){var n=R;if((e?D.echoes&&(!On++||t!==R):On&&(!--On||t!==R))&&Ui(e?ya.bind(null,t):fa),t!==R&&(R=t,n===Ve&&(Ve.env=Qi()),mr)){var r=Ve.env.Promise,i=t.env;en.then=i.nthen,r.prototype.then=i.gthen,(n.global||t.global)&&(Object.defineProperty(P,"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 Qi(){var t=P.Promise;return mr?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(P,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:en.then,gthen:t.prototype.then}:{}}function Ze(t,e,n,r,i){var s=R;try{return ve(t,!0),e(n,r,i)}finally{ve(s,!1)}}function Ui(t){Ei.call($n,t)}function sn(t,e,n,r){return typeof t!="function"?t:function(){var i=R;n&&Xe(),ve(e,!0);try{return t.apply(this,arguments)}finally{ve(i,!1),r&&Ui(pe)}}}function ai(t,e){return function(n,r){return t.call(this,sn(n,e),sn(r,e))}}var ui="unhandledrejection";function li(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,i={promise:e,reason:t};if(P.document&&document.createEvent?(r=document.createEvent("Event"),r.initEvent(ui,!0,!0),H(r,i)):P.CustomEvent&&(r=new CustomEvent(ui,{detail:i}),H(r,i)),r&&P.dispatchEvent&&(dispatchEvent(r),!P.PromiseRejectionEvent&&P.onunhandledrejection))try{P.onunhandledrejection(r)}catch{}ne&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var Q=x.reject;function Xn(t,e,n,r){if(!t.idbdb||!t._state.openComplete&&!R.letThrough&&!t._vip){if(t._state.openComplete)return Q(new k.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return Q(new k.DatabaseClosed);t.open().catch(F)}return t._state.dbReadyPromise.then(()=>Xn(t,e,n,r))}else{var i=t._createTransaction(e,n,t._dbSchema);try{i.create(),t._state.PR1398_maxLoop=3}catch(s){return s.name===hr.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Xn(t,e,n,r))):Q(s)}return i._promise(e,(s,o)=>we(()=>(R.trans=i,r(s,o,i)))).then(s=>i._completion.then(()=>s))}}var di="3.2.6",Ie="\uFFFF",Zn=-1/0,ae="Invalid key provided. Keys must be of type string, number, Date or Array.",Ki="String expected.",mt=[],cn=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),ba=cn,Ca=cn,Di=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),hn="__dbnames",Ln="readonly",jn="readwrite";function Oe(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}var Bi={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function qt(t){return typeof t=="string"&&!/\./.test(t)?e=>(e[t]===void 0&&t in e&&(e=xt(e),delete e[t]),e):e=>e}var _a=class{_trans(t,e,n){let r=this._tx||R.trans,i=this.name;function s(a,u,d){if(!d.schema[i])throw new k.NotFound("Table "+i+" not part of transaction");return e(d.idbtrans,d)}let o=St();try{return r&&r.db===this.db?r===R.trans?r._promise(t,s,n):we(()=>r._promise(t,s,n),{trans:r,transless:R.transless||R}):Xn(this.db,t,[this.name],s)}finally{o&&Rt()}}get(t,e){return t&&t.constructor===Object?this.where(t).first(e):this._trans("readonly",n=>this.core.get({trans:n,key:t}).then(r=>this.hook.reading.fire(r))).then(e)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(B(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);let e=j(t);if(e.length===1)return this.where(e[0]).equals(t[e[0]]);let n=this.schema.indexes.concat(this.schema.primKey).filter(u=>{if(u.compound&&e.every(d=>u.keyPath.indexOf(d)>=0)){for(let d=0;du.keyPath.length-d.keyPath.length)[0];if(n&&this.db._maxKey!==Ie){let u=n.keyPath.slice(0,e.length);return this.where(u).equals(u.map(d=>t[d]))}!n&&ne&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${e.join("+")}]`);let{idxByName:r}=this.schema,i=this.db._deps.indexedDB;function s(u,d){try{return i.cmp(u,d)===0}catch{return!1}}let[o,a]=e.reduce(([u,d],h)=>{let c=r[h],l=t[h];return[u||c,u||!c?Oe(d,c&&c.multi?f=>{let y=ce(f,h);return B(y)&&y.some(m=>s(l,m))}:f=>s(l,ce(f,h))):d]},[null,null]);return o?this.where(o.name).equals(t[o.keyPath]).filter(a):n?this.filter(a):this.where(e).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,B(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;let e=n=>{if(!n)return n;let r=Object.create(t.prototype);for(var i in n)if(V(n,i))try{r[i]=n[i]}catch{}return r};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=e,this.hook("reading",e),t}defineClass(){function t(e){H(this,e)}return this.mapToClass(t)}add(t,e){let{auto:n,keyPath:r}=this.schema.primKey,i=t;return r&&n&&(i=qt(r)(t)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"add",keys:e!=null?[e]:null,values:[i]})).then(s=>s.numFailures?x.reject(s.failures[0]):s.lastResult).then(s=>{if(r)try{Z(t,r,s)}catch{}return s})}update(t,e){if(typeof t=="object"&&!B(t)){let n=ce(t,this.schema.primKey.keyPath);if(n===void 0)return Q(new k.InvalidArgument("Given object does not contain its primary key"));try{typeof e!="function"?j(e).forEach(r=>{Z(t,r,e[r])}):e(t,{value:t,primKey:n})}catch{}return this.where(":id").equals(n).modify(e)}else return this.where(":id").equals(t).modify(e)}put(t,e){let{auto:n,keyPath:r}=this.schema.primKey,i=t;return r&&n&&(i=qt(r)(t)),this._trans("readwrite",s=>this.core.mutate({trans:s,type:"put",values:[i],keys:e!=null?[e]:null})).then(s=>s.numFailures?x.reject(s.failures[0]):s.lastResult).then(s=>{if(r)try{Z(t,r,s)}catch{}return s})}delete(t){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"delete",keys:[t]})).then(e=>e.numFailures?x.reject(e.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:Bi})).then(t=>t.numFailures?x.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",e=>this.core.getMany({keys:t,trans:e}).then(n=>n.map(r=>this.hook.reading.fire(r))))}bulkAdd(t,e,n){let r=Array.isArray(e)?e:void 0;n=n||(r?void 0:e);let i=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:o,keyPath:a}=this.schema.primKey;if(a&&r)throw new k.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(r&&r.length!==t.length)throw new k.InvalidArgument("Arguments objects and keys must have the same length");let u=t.length,d=a&&o?t.map(qt(a)):t;return this.core.mutate({trans:s,type:"add",keys:r,values:d,wantResults:i}).then(({numFailures:h,results:c,lastResult:l,failures:f})=>{let y=i?c:l;if(h===0)return y;throw new pt(`${this.name}.bulkAdd(): ${h} of ${u} operations failed`,f)})})}bulkPut(t,e,n){let r=Array.isArray(e)?e:void 0;n=n||(r?void 0:e);let i=n?n.allKeys:void 0;return this._trans("readwrite",s=>{let{auto:o,keyPath:a}=this.schema.primKey;if(a&&r)throw new k.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(r&&r.length!==t.length)throw new k.InvalidArgument("Arguments objects and keys must have the same length");let u=t.length,d=a&&o?t.map(qt(a)):t;return this.core.mutate({trans:s,type:"put",keys:r,values:d,wantResults:i}).then(({numFailures:h,results:c,lastResult:l,failures:f})=>{let y=i?c:l;if(h===0)return y;throw new pt(`${this.name}.bulkPut(): ${h} of ${u} operations failed`,f)})})}bulkDelete(t){let e=t.length;return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:t})).then(({numFailures:n,lastResult:r,failures:i})=>{if(n===0)return r;throw new pt(`${this.name}.bulkDelete(): ${n} of ${e} operations failed`,i)})}};function Mt(t){var e={},n=function(a,u){if(u){for(var d=arguments.length,h=new Array(d-1);--d;)h[d-1]=arguments[d];return e[a].subscribe.apply(null,h),t}else if(typeof a=="string")return e[a]};n.addEventType=s;for(var r=1,i=arguments.length;rOe(r(),e()):e,t.justLimit=n&&!r}function va(t,e){t.isMatch=Oe(t.isMatch,e)}function Jt(t,e){if(t.isPrimKey)return e.primaryKey;let n=e.getIndexByKeyPath(t.index);if(!n)throw new k.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function ci(t,e,n){let r=Jt(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:t.dir==="prev",unique:!!t.unique,query:{index:r,range:t.range}})}function Nt(t,e,n,r){let i=t.replayFilter?Oe(t.filter,t.replayFilter()):t.filter;if(t.or){let s={},o=(a,u,d)=>{if(!i||i(u,d,l=>u.stop(l),l=>u.fail(l))){var h=u.primaryKey,c=""+h;c==="[object ArrayBuffer]"&&(c=""+new Uint8Array(h)),V(s,c)||(s[c]=!0,e(a,u,d))}};return Promise.all([t.or._iterate(o,n),hi(ci(t,r,n),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}else return hi(ci(t,r,n),Oe(t.algorithm,i),e,!t.keysOnly&&t.valueMapper)}function hi(t,e,n,r){var i=r?(o,a,u)=>n(r(o),a,u):n,s=O(i);return t.then(o=>{if(o)return o.start(()=>{var a=()=>o.continue();(!e||e(o,u=>a=u,u=>{o.stop(u),a=F},u=>{o.fail(u),a=F}))&&s(o.value,o,u=>a=u),a()})})}function $(t,e){try{let n=pi(t),r=pi(e);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return t>e?1:tNt(e,t,n,e.table.core))}count(t){return this._read(e=>{let n=this._ctx,r=n.table.core;if(He(n,!0))return r.count({trans:e,query:{index:Jt(n,r.schema),range:n.range}}).then(s=>Math.min(s,n.limit));var i=0;return Nt(n,()=>(++i,!1),e,r).then(()=>i)}).then(t)}sortBy(t,e){let n=t.split(".").reverse(),r=n[0],i=n.length-1;function s(u,d){return d?s(u[n[d]],d-1):u[r]}var o=this._ctx.dir==="next"?1:-1;function a(u,d){var h=s(u,i),c=s(d,i);return hc?o:0}return this.toArray(function(u){return u.sort(a)}).then(e)}toArray(t){return this._read(e=>{var n=this._ctx;if(n.dir==="next"&&He(n,!0)&&n.limit>0){let{valueMapper:r}=n,i=Jt(n,n.table.core.schema);return n.table.core.query({trans:e,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(({result:s})=>r?s.map(r):s)}else{let r=[];return Nt(n,i=>r.push(i),e,n.table.core).then(()=>r)}},t)}offset(t){var e=this._ctx;return t<=0?this:(e.offset+=t,He(e)?Un(e,()=>{var n=t;return(r,i)=>n===0?!0:n===1?(--n,!1):(i(()=>{r.advance(n),n=0}),!1)}):Un(e,()=>{var n=t;return()=>--n<0}),this)}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Un(this._ctx,()=>{var e=t;return function(n,r,i){return--e<=0&&r(i),e>=0}},!0),this}until(t,e){return Qn(this._ctx,function(n,r,i){return t(n.value)?(r(i),e):!0}),this}first(t){return this.limit(1).toArray(function(e){return e[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){return Qn(this._ctx,function(e){return t(e.value)}),va(this._ctx,t),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(n,r){t(r.key,r)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(n,r){t(r.primaryKey,r)})}keys(t){var e=this._ctx;e.keysOnly=!e.isMatch;var n=[];return this.each(function(r,i){n.push(i.key)}).then(function(){return n}).then(t)}primaryKeys(t){var e=this._ctx;if(e.dir==="next"&&He(e,!0)&&e.limit>0)return this._read(r=>{var i=Jt(e,e.table.core.schema);return e.table.core.query({trans:r,values:!1,limit:e.limit,query:{index:i,range:e.range}})}).then(({result:r})=>r).then(t);e.keysOnly=!e.isMatch;var n=[];return this.each(function(r,i){n.push(i.primaryKey)}).then(function(){return n}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(e){return e[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,e=t.index&&t.table.schema.idxByName[t.index];if(!e||!e.multi)return this;var n={};return Qn(this._ctx,function(r){var i=r.primaryKey.toString(),s=V(n,i);return n[i]=!0,!s}),this}modify(t){var e=this._ctx;return this._write(n=>{var r;if(typeof t=="function")r=t;else{var i=j(t),s=i.length;r=function(y){for(var m=!1,p=0;p{let{failures:p,numFailures:b}=m;c+=y-b;for(let C of j(p))h.push(p[C])};return this.clone().primaryKeys().then(y=>{let m=p=>{let b=Math.min(d,y.length-p);return o.getMany({trans:n,keys:y.slice(p,p+b),cache:"immutable"}).then(C=>{let _=[],w=[],A=a?[]:null,v=[];for(let M=0;M0&&o.mutate({trans:n,type:"add",values:_}).then(M=>{for(let L in M.failures)v.splice(parseInt(L),1);f(_.length,M)})).then(()=>(w.length>0||S&&typeof t=="object")&&o.mutate({trans:n,type:"put",keys:A,values:w,criteria:S,changeSpec:typeof t!="function"&&t}).then(M=>f(w.length,M))).then(()=>(v.length>0||S&&t===Kn)&&o.mutate({trans:n,type:"delete",keys:v,criteria:S}).then(M=>f(v.length,M))).then(()=>y.length>p+b&&m(p+d))})};return m(0).then(()=>{if(h.length>0)throw new Zt("Error modifying one or more objects",h,c,l);return y.length})})})}delete(){var t=this._ctx,e=t.range;return He(t)&&(t.isPrimKey&&!Ca||e.type===3)?this._write(n=>{let{primaryKey:r}=t.table.core.schema,i=e;return t.table.core.count({trans:n,query:{index:r,range:i}}).then(s=>t.table.core.mutate({trans:n,type:"deleteRange",range:i}).then(({failures:o,lastResult:a,results:u,numFailures:d})=>{if(d)throw new Zt("Could not delete some values",Object.keys(o).map(h=>o[h]),s-d);return s-d}))}):this.modify(Kn)}},Kn=(t,e)=>e.value=null;function Ra(t){return kt(Sa.prototype,function(e,n){this.db=t;let r=Bi,i=null;if(n)try{r=n()}catch(u){i=u}let s=e._ctx,o=s.table,a=o.hook.reading.fire;this._ctx={table:o,index:s.index,isPrimKey:!s.index||o.schema.primKey.keyPath&&s.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:s.or,valueMapper:a!==At?a:null}})}function Ma(t,e){return te?-1:t===e?0:1}function W(t,e,n){var r=t instanceof Ni?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Ge(t){return new t.Collection(t,()=>qi("")).limit(0)}function Ta(t){return t==="next"?e=>e.toUpperCase():e=>e.toLowerCase()}function Ia(t){return t==="next"?e=>e.toLowerCase():e=>e.toUpperCase()}function Ea(t,e,n,r,i,s){for(var o=Math.min(t.length,r.length),a=-1,u=0;u=0?t.substr(0,a)+e[a]+n.substr(a+1):null;i(t[u],d)<0&&(a=u)}return otypeof m=="string"))return W(t,Ki);function l(m){i=Ta(m),s=Ia(m),o=m==="next"?Ma:ka;var p=n.map(function(b){return{lower:s(b),upper:i(b)}}).sort(function(b,C){return o(b.lower,C.lower)});a=p.map(function(b){return b.upper}),u=p.map(function(b){return b.lower}),d=m,h=m==="next"?"":r}l("next");var f=new t.Collection(t,()=>be(a[0],u[c-1]+r));f._ondirectionchange=function(m){l(m)};var y=0;return f._addAlgorithm(function(m,p,b){var C=m.key;if(typeof C!="string")return!1;var _=s(C);if(e(_,u,y))return!0;for(var w=null,A=y;A0)&&(w=v)}return p(w!==null?function(){m.continue(w+h)}:b),!1}),f}function be(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function qi(t){return{type:1,lower:t,upper:t}}var Ni=class{get Collection(){return this._ctx.table.db.Collection}between(t,e,n,r){n=n!==!1,r=r===!0;try{return this._cmp(t,e)>0||this._cmp(t,e)===0&&(n||r)&&!(n&&r)?Ge(this):new this.Collection(this,()=>be(t,e,!n,!r))}catch{return W(this,ae)}}equals(t){return t==null?W(this,ae):new this.Collection(this,()=>qi(t))}above(t){return t==null?W(this,ae):new this.Collection(this,()=>be(t,void 0,!0))}aboveOrEqual(t){return t==null?W(this,ae):new this.Collection(this,()=>be(t,void 0,!1))}below(t){return t==null?W(this,ae):new this.Collection(this,()=>be(void 0,t,!1,!0))}belowOrEqual(t){return t==null?W(this,ae):new this.Collection(this,()=>be(void 0,t))}startsWith(t){return typeof t!="string"?W(this,Ki):this.between(t,t+Ie,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):$t(this,(e,n)=>e.indexOf(n[0])===0,[t],Ie)}equalsIgnoreCase(t){return $t(this,(e,n)=>e===n[0],[t],"")}anyOfIgnoreCase(){var t=le.apply(We,arguments);return t.length===0?Ge(this):$t(this,(e,n)=>n.indexOf(e)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=le.apply(We,arguments);return t.length===0?Ge(this):$t(this,(e,n)=>n.some(r=>e.indexOf(r)===0),t,Ie)}anyOf(){let t=le.apply(We,arguments),e=this._cmp;try{t.sort(e)}catch{return W(this,ae)}if(t.length===0)return Ge(this);let n=new this.Collection(this,()=>be(t[0],t[t.length-1]));n._ondirectionchange=i=>{e=i==="next"?this._ascending:this._descending,t.sort(e)};let r=0;return n._addAlgorithm((i,s,o)=>{let a=i.key;for(;e(a,t[r])>0;)if(++r,r===t.length)return s(o),!1;return e(a,t[r])===0?!0:(s(()=>{i.continue(t[r])}),!1)}),n}notEqual(t){return this.inAnyRange([[Zn,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){let t=le.apply(We,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return W(this,ae)}let e=t.reduce((n,r)=>n?n.concat([[n[n.length-1][1],r]]):[[Zn,r]],null);return e.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,e){let n=this._cmp,r=this._ascending,i=this._descending,s=this._min,o=this._max;if(t.length===0)return Ge(this);if(!t.every(_=>_[0]!==void 0&&_[1]!==void 0&&r(_[0],_[1])<=0))return W(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",k.InvalidArgument);let a=!e||e.includeLowers!==!1,u=e&&e.includeUppers===!0;function d(_,w){let A=0,v=_.length;for(;A0){S[0]=s(S[0],w[0]),S[1]=o(S[1],w[1]);break}}return A===v&&_.push(w),_}let h=r;function c(_,w){return h(_[0],w[0])}let l;try{l=t.reduce(d,[]),l.sort(c)}catch{return W(this,ae)}let f=0,y=u?_=>r(_,l[f][1])>0:_=>r(_,l[f][1])>=0,m=a?_=>i(_,l[f][0])>0:_=>i(_,l[f][0])>=0;function p(_){return!y(_)&&!m(_)}let b=y,C=new this.Collection(this,()=>be(l[0][0],l[l.length-1][1],!a,!u));return C._ondirectionchange=_=>{_==="next"?(b=y,h=r):(b=m,h=i),l.sort(c)},C._addAlgorithm((_,w,A)=>{for(var v=_.key;b(v);)if(++f,f===l.length)return w(A),!1;return p(v)?!0:(this._cmp(v,l[f][1])===0||this._cmp(v,l[f][0])===0||w(()=>{h===r?_.continue(l[f][0]):_.continue(l[f][1])}),!1)}),C}startsWithAnyOf(){let t=le.apply(We,arguments);return t.every(e=>typeof e=="string")?t.length===0?Ge(this):this.inAnyRange(t.map(e=>[e,e+Ie])):W(this,"startsWithAnyOf() only works with strings")}};function Fa(t){return kt(Ni.prototype,function(e,n,r){this.db=t,this._ctx={table:e,index:n===":id"?null:n,or:r};let i=t._deps.indexedDB;if(!i)throw new k.MissingAPI;this._cmp=this._ascending=i.cmp.bind(i),this._descending=(s,o)=>i.cmp(o,s),this._max=(s,o)=>i.cmp(s,o)>0?s:o,this._min=(s,o)=>i.cmp(s,o)<0?s:o,this._IDBKeyRange=t._deps.IDBKeyRange})}function te(t){return O(function(e){return Ct(e),t(e.target.error),!1})}function Ct(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}var _t="storagemutated",_e="x-storagemutated-1",xe=Mt(null,_t),Pa=class{_lock(){return ct(!R.global),++this._reculock,this._reculock===1&&!R.global&&(R.lockOwnerFor=this),this}_unlock(){if(ct(!R.global),--this._reculock===0)for(R.global||(R.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Ze(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&R.lockOwnerFor!==this}create(t){if(!this.mode)return this;let e=this.db.idbdb,n=this.db._state.dbOpenError;if(ct(!this.idbtrans),!t&&!e)switch(n&&n.name){case"DatabaseClosedError":throw new k.DatabaseClosed(n);case"MissingAPIError":throw new k.MissingAPI(n.message,n);default:throw new k.OpenFailed(n)}if(!this.active)throw new k.TransactionInactive;return ct(this._completion._state===null),t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):e.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})),t.onerror=O(r=>{Ct(r),this._reject(t.error)}),t.onabort=O(r=>{Ct(r),this.active&&this._reject(new k.Abort(t.error)),this.active=!1,this.on("abort").fire(r)}),t.oncomplete=O(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&xe.storagemutated.fire(t.mutatedParts)}),this}_promise(t,e,n){if(t==="readwrite"&&this.mode!=="readwrite")return Q(new k.ReadOnly("Transaction is readonly"));if(!this.active)return Q(new k.TransactionInactive);if(this._locked())return new x((i,s)=>{this._blockedFuncs.push([()=>{this._promise(t,e,n).then(i,s)},R])});if(n)return we(()=>{var i=new x((s,o)=>{this._lock();let a=e(s,o,this);a&&a.then&&a.then(s,o)});return i.finally(()=>this._unlock()),i._lib=!0,i});var r=new x((i,s)=>{var o=e(i,s,this);o&&o.then&&o.then(i,s)});return r._lib=!0,r}_root(){return this.parent?this.parent._root():this}waitFor(t){var e=this._root();let n=x.resolve(t);if(e._waitingFor)e._waitingFor=e._waitingFor.then(()=>n);else{e._waitingFor=n,e._waitingQueue=[];var r=e.idbtrans.objectStore(e.storeNames[0]);(function s(){for(++e._spinCount;e._waitingQueue.length;)e._waitingQueue.shift()();e._waitingFor&&(r.get(-1/0).onsuccess=s)})()}var i=e._waitingFor;return new x((s,o)=>{n.then(a=>e._waitingQueue.push(O(s.bind(null,a))),a=>e._waitingQueue.push(O(o.bind(null,a)))).finally(()=>{e._waitingFor===i&&(e._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new k.Abort))}table(t){let e=this._memoizedTables||(this._memoizedTables={});if(V(e,t))return e[t];let n=this.schema[t];if(!n)throw new k.NotFound("Table "+t+" not part of transaction");let r=new this.db.Table(t,n,this);return r.core=this.db.core.table(t),e[t]=r,r}};function Oa(t){return kt(Pa.prototype,function(e,n,r,i,s){this.db=t,this.mode=e,this.storeNames=n,this.schema=r,this.chromeTransactionDurability=i,this.idbtrans=null,this.on=Mt(this,"complete","error","abort"),this.parent=s||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 x((o,a)=>{this._resolve=o,this._reject=a}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},o=>{var a=this.active;return this.active=!1,this.on.error.fire(o),this.parent?this.parent._reject(o):a&&this.idbtrans&&this.idbtrans.abort(),Q(o)})})}function er(t,e,n,r,i,s,o){return{name:t,keyPath:e,unique:n,multi:r,auto:i,compound:s,src:(n&&!o?"&":"")+(r?"*":"")+(i?"++":"")+$i(e)}}function $i(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function Hi(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:vi(n,r=>[r.name,r])}}function La(t){return t.length===1?t[0]:t}var wt=t=>{try{return t.only([[]]),wt=()=>[[]],[[]]}catch{return wt=()=>Ie,Ie}};function tr(t){return t==null?()=>{}:typeof t=="string"?ja(t):e=>ce(e,t)}function ja(t){return t.split(".").length===1?e=>e[t]:e=>ce(e,t)}function gi(t){return[].slice.call(t)}var Qa=0;function gt(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Ua(t,e,n){function r(h,c){let l=gi(h.objectStoreNames);return{schema:{name:h.name,tables:l.map(f=>c.objectStore(f)).map(f=>{let{keyPath:y,autoIncrement:m}=f,p=B(y),b=y==null,C={},_={name:f.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:b,compound:p,keyPath:y,autoIncrement:m,unique:!0,extractKey:tr(y)},indexes:gi(f.indexNames).map(w=>f.index(w)).map(w=>{let{name:A,unique:v,multiEntry:S,keyPath:M}=w,L=B(M),E={name:A,compound:L,keyPath:M,unique:v,multiEntry:S,extractKey:tr(M)};return C[gt(M)]=E,E}),getIndexByKeyPath:w=>C[gt(w)]};return C[":id"]=_.primaryKey,y!=null&&(C[gt(y)]=_.primaryKey),_})},hasGetAll:l.length>0&&"getAll"in c.objectStore(l[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}function i(h){if(h.type===3)return null;if(h.type===4)throw new Error("Cannot convert never type to IDBKeyRange");let{lower:c,upper:l,lowerOpen:f,upperOpen:y}=h;return c===void 0?l===void 0?null:e.upperBound(l,!!y):l===void 0?e.lowerBound(c,!!f):e.bound(c,l,!!f,!!y)}function s(h){let c=h.name;function l({trans:m,type:p,keys:b,values:C,range:_}){return new Promise((w,A)=>{w=O(w);let v=m.objectStore(c),S=v.keyPath==null,M=p==="put"||p==="add";if(!M&&p!=="delete"&&p!=="deleteRange")throw new Error("Invalid operation type: "+p);let{length:L}=b||C||{length:1};if(b&&C&&b.length!==C.length)throw new Error("Given keys array must have same length as given values array.");if(L===0)return w({numFailures:0,failures:{},results:[],lastResult:void 0});let E,I=[],z=[],T=0,J=G=>{++T,Ct(G)};if(p==="deleteRange"){if(_.type===4)return w({numFailures:T,failures:z,results:[],lastResult:void 0});_.type===3?I.push(E=v.clear()):I.push(E=v.delete(i(_)))}else{let[G,Y]=M?S?[C,b]:[C,null]:[b,null];if(M)for(let U=0;U{let Y=G.target.result;I.forEach((U,et)=>U.error!=null&&(z[et]=U.error)),w({numFailures:T,failures:z,results:p==="delete"?b:I.map(U=>U.result),lastResult:Y})};E.onerror=G=>{J(G),X(G)},E.onsuccess=X})}function f({trans:m,values:p,query:b,reverse:C,unique:_}){return new Promise((w,A)=>{w=O(w);let{index:v,range:S}=b,M=m.objectStore(c),L=v.isPrimaryKey?M:M.index(v.name),E=C?_?"prevunique":"prev":_?"nextunique":"next",I=p||!("openKeyCursor"in L)?L.openCursor(i(S),E):L.openKeyCursor(i(S),E);I.onerror=te(A),I.onsuccess=O(z=>{let T=I.result;if(!T){w(null);return}T.___id=++Qa,T.done=!1;let J=T.continue.bind(T),X=T.continuePrimaryKey;X&&(X=X.bind(T));let G=T.advance.bind(T),Y=()=>{throw new Error("Cursor not started")},U=()=>{throw new Error("Cursor not stopped")};T.trans=m,T.stop=T.continue=T.continuePrimaryKey=T.advance=Y,T.fail=O(A),T.next=function(){let et=1;return this.start(()=>et--?this.continue():this.stop()).then(()=>this)},T.start=et=>{let Yi=new Promise((je,Ar)=>{je=O(je),I.onerror=te(Ar),T.fail=Ar,T.stop=Ji=>{T.stop=T.continue=T.continuePrimaryKey=T.advance=U,je(Ji)}}),mn=()=>{if(I.result)try{et()}catch(je){T.fail(je)}else T.done=!0,T.start=()=>{throw new Error("Cursor behind last entry")},T.stop()};return I.onsuccess=O(je=>{I.onsuccess=mn,mn()}),T.continue=J,T.continuePrimaryKey=X,T.advance=G,mn(),Yi},w(T)},A)})}function y(m){return p=>new Promise((b,C)=>{b=O(b);let{trans:_,values:w,limit:A,query:v}=p,S=A===1/0?void 0:A,{index:M,range:L}=v,E=_.objectStore(c),I=M.isPrimaryKey?E:E.index(M.name),z=i(L);if(A===0)return b({result:[]});if(m){let T=w?I.getAll(z,S):I.getAllKeys(z,S);T.onsuccess=J=>b({result:J.target.result}),T.onerror=te(C)}else{let T=0,J=w||!("openKeyCursor"in I)?I.openCursor(z):I.openKeyCursor(z),X=[];J.onsuccess=G=>{let Y=J.result;if(!Y)return b({result:X});if(X.push(w?Y.value:Y.primaryKey),++T===A)return b({result:X});Y.continue()},J.onerror=te(C)}})}return{name:c,schema:h,mutate:l,getMany({trans:m,keys:p}){return new Promise((b,C)=>{b=O(b);let _=m.objectStore(c),w=p.length,A=new Array(w),v=0,S=0,M,L=I=>{let z=I.target;(A[z._pos]=z.result)!=null,++S===v&&b(A)},E=te(C);for(let I=0;I{b=O(b);let _=m.objectStore(c).get(p);_.onsuccess=w=>b(w.target.result),_.onerror=te(C)})},query:y(a),openCursor:f,count({query:m,trans:p}){let{index:b,range:C}=m;return new Promise((_,w)=>{let A=p.objectStore(c),v=b.isPrimaryKey?A:A.index(b.name),S=i(C),M=S?v.count(S):v.count();M.onsuccess=O(L=>_(L.target.result)),M.onerror=te(w)})}}}let{schema:o,hasGetAll:a}=r(t,n),u=o.tables.map(h=>s(h)),d={};return u.forEach(h=>d[h.name]=h),{stack:"dbcore",transaction:t.transaction.bind(t),table(h){if(!d[h])throw new Error(`Table '${h}' not found`);return d[h]},MIN_KEY:-1/0,MAX_KEY:wt(e),schema:o}}function Ka(t,e){return e.reduce((n,{create:r})=>({...n,...r(n)}),t)}function Da(t,e,{IDBKeyRange:n,indexedDB:r},i){return{dbcore:Ka(Ua(e,n,i),t.dbcore)}}function fr({_novip:t},e){let n=e.db,r=Da(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(i=>{let s=i.name;t.core.schema.tables.some(o=>o.name===s)&&(i.core=t.core.table(s),t[s]instanceof t.Table&&(t[s].core=i.core))})}function on({_novip:t},e,n,r){n.forEach(i=>{let s=r[i];e.forEach(o=>{let a=lr(o,i);(!a||"value"in a&&a.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?he(o,i,{get(){return this.table(i)},set(u){Ci(this,i,{value:u,writable:!0,configurable:!0,enumerable:!0})}}):o[i]=new t.Table(i,s))})})}function nr({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Ba(t,e){return t._cfg.version-e._cfg.version}function qa(t,e,n,r){let i=t._dbSchema,s=t._createTransaction("readwrite",t._storeNames,i);s.create(n),s._completion.catch(r);let o=s._reject.bind(s),a=R.transless||R;we(()=>{R.trans=s,R.transless=a,e===0?(j(i).forEach(u=>{br(n,u,i[u].primKey,i[u].indexes)}),fr(t,n),x.follow(()=>t.on.populate.fire(s)).catch(o)):Na(t,e,s,n).catch(o)})}function Na({_novip:t},e,n,r){let i=[],s=t._versions,o=t._dbSchema=Cr(t,t.idbdb,r),a=!1;s.filter(d=>d._cfg.version>=e).forEach(d=>{i.push(()=>{let h=o,c=d._cfg.dbschema;ir(t,h,r),ir(t,c,r),o=t._dbSchema=c;let l=Gi(h,c);l.add.forEach(y=>{br(r,y[0],y[1].primKey,y[1].indexes)}),l.change.forEach(y=>{if(y.recreate)throw new k.Upgrade("Not yet support for changing primary key");{let m=r.objectStore(y.name);y.add.forEach(p=>rr(m,p)),y.change.forEach(p=>{m.deleteIndex(p.name),rr(m,p)}),y.del.forEach(p=>m.deleteIndex(p))}});let f=d._cfg.contentUpgrade;if(f&&d._cfg.version>e){fr(t,r),n._memoizedTables={},a=!0;let y=xi(c);l.del.forEach(C=>{y[C]=h[C]}),nr(t,[t.Transaction.prototype]),on(t,[t.Transaction.prototype],j(y),y),n.schema=y;let m=dr(f);m&&Xe();let p,b=x.follow(()=>{if(p=f(n),p&&m){var C=pe.bind(null,null);p.then(C,C)}});return p&&typeof p.then=="function"?x.resolve(p):b.then(()=>p)}}),i.push(h=>{if(!a||!ba){let c=d._cfg.dbschema;Ha(c,h)}nr(t,[t.Transaction.prototype]),on(t,[t.Transaction.prototype],t._storeNames,t._dbSchema),n.schema=t._dbSchema})});function u(){return i.length?x.resolve(i.shift()(n.idbtrans)).then(u):x.resolve()}return u().then(()=>{$a(o,r)})}function Gi(t,e){let n={del:[],add:[],change:[]},r;for(r in t)e[r]||n.del.push(r);for(r in e){let i=t[r],s=e[r];if(!i)n.add.push([r,s]);else{let o={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||i.primKey.auto!==s.primKey.auto&&!cn)o.recreate=!0,n.change.push(o);else{let a=i.idxByName,u=s.idxByName,d;for(d in a)u[d]||o.del.push(d);for(d in u){let h=a[d],c=u[d];h?h.src!==c.src&&o.change.push(c):o.add.push(c)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}}return n}function br(t,e,n,r){let i=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>rr(i,s)),i}function $a(t,e){j(t).forEach(n=>{e.db.objectStoreNames.contains(n)||br(e,n,t[n].primKey,t[n].indexes)})}function Ha(t,e){[].slice.call(e.db.objectStoreNames).forEach(n=>t[n]==null&&e.db.deleteObjectStore(n))}function rr(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function Cr(t,e,n){let r={};return ln(e.objectStoreNames,0).forEach(i=>{let s=n.objectStore(i),o=s.keyPath,a=er($i(o),o||"",!1,!1,!!s.autoIncrement,o&&typeof o!="string",!0),u=[];for(let h=0;hi.add.length||i.change.length))}function ir({_novip:t},e,n){let r=n.db.objectStoreNames;for(let i=0;i{e=e.trim();let r=e.replace(/([&*]|\+\+)/g,""),i=/^\[/.test(r)?r.match(/^\[(.*)\]$/)[1].split("+"):r;return er(r,i||null,/\&/.test(e),/\*/.test(e),/\+\+/.test(e),B(i),n===0)})}var za=class{_parseStoresSpec(t,e){j(t).forEach(n=>{if(t[n]!==null){var r=Va(t[n]),i=r.shift();if(i.multi)throw new k.Schema("Primary key cannot be multi-valued");r.forEach(s=>{if(s.auto)throw new k.Schema("Only primary key can be marked as autoIncrement (++)");if(!s.keyPath)throw new k.Schema("Index must have a name and cannot be an empty string")}),e[n]=Hi(n,i,r)}})}stores(t){let e=this.db;this._cfg.storesSource=this._cfg.storesSource?H(this._cfg.storesSource,t):t;let n=e._versions,r={},i={};return n.forEach(s=>{H(r,s._cfg.storesSource),i=s._cfg.dbschema={},s._parseStoresSpec(r,i)}),e._dbSchema=i,nr(e,[e._allTables,e,e.Transaction.prototype]),on(e,[e._allTables,e,e.Transaction.prototype,this._cfg.tables],j(i),i),e._storeNames=j(i),this}upgrade(t){return this._cfg.contentUpgrade=pr(this._cfg.contentUpgrade||F,t),this}};function Ya(t){return kt(za.prototype,function(e){this.db=t,this._cfg={version:e,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}function _r(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new Tt(hn,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function wr(t){return t&&typeof t.databases=="function"}function Ja({indexedDB:t,IDBKeyRange:e}){return wr(t)?Promise.resolve(t.databases()).then(n=>n.map(r=>r.name).filter(r=>r!==hn)):_r(t,e).toCollection().primaryKeys()}function Xa({indexedDB:t,IDBKeyRange:e},n){!wr(t)&&n!==hn&&_r(t,e).put({name:n}).catch(F)}function Za({indexedDB:t,IDBKeyRange:e},n){!wr(t)&&n!==hn&&_r(t,e).delete(n).catch(F)}function sr(t){return we(function(){return R.letThrough=!0,t()})}function eu(){var t=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!t||!indexedDB.databases)return Promise.resolve();var e;return new Promise(function(n){var r=function(){return indexedDB.databases().finally(n)};e=setInterval(r,100),r()}).finally(function(){return clearInterval(e)})}function tu(t){let e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?Q(e.dbOpenError):t);ne&&(e.openCanceller._stackHolder=Le()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;let r=e.openCanceller;function i(){if(e.openCanceller!==r)throw new k.DatabaseClosed("db.open() was cancelled")}let s=e.dbReadyResolve,o=null,a=!1,u=()=>new x((d,h)=>{if(i(),!n)throw new k.MissingAPI;let c=t.name,l=e.autoSchema?n.open(c):n.open(c,Math.round(t.verno*10));if(!l)throw new k.MissingAPI;l.onerror=te(h),l.onblocked=O(t._fireOnBlocked),l.onupgradeneeded=O(f=>{if(o=l.transaction,e.autoSchema&&!t._options.allowEmptyDB){l.onerror=Ct,o.abort(),l.result.close();let m=n.deleteDatabase(c);m.onsuccess=m.onerror=O(()=>{h(new k.NoSuchDatabase(`Database ${c} doesnt exist`))})}else{o.onerror=te(h);var y=f.oldVersion>Math.pow(2,62)?0:f.oldVersion;a=y<1,t._novip.idbdb=l.result,qa(t,y/10,o,h)}},h),l.onsuccess=O(()=>{o=null;let f=t._novip.idbdb=l.result,y=ln(f.objectStoreNames);if(y.length>0)try{let m=f.transaction(La(y),"readonly");e.autoSchema?Ga(t,f,m):(ir(t,t._dbSchema,m),Wa(t,m)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),fr(t,m)}catch{}mt.push(t),f.onversionchange=O(m=>{e.vcFired=!0,t.on("versionchange").fire(m)}),f.onclose=O(m=>{t.on("close").fire(m)}),a&&Xa(t._deps,c),d()},h)}).catch(d=>d&&d.name==="UnknownError"&&e.PR1398_maxLoop>0?(e.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),u()):x.reject(d));return x.race([r,(typeof navigator>"u"?x.resolve():eu()).then(u)]).then(()=>(i(),e.onReadyBeingFired=[],x.resolve(sr(()=>t.on.ready.fire(t.vip))).then(function d(){if(e.onReadyBeingFired.length>0){let h=e.onReadyBeingFired.reduce(pr,F);return e.onReadyBeingFired=[],x.resolve(sr(()=>h(t.vip))).then(d)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(d=>{e.dbOpenError=d;try{o&&o.abort()}catch{}return r===e.openCanceller&&t._close(),Q(d)}).finally(()=>{e.openComplete=!0,s()})}function or(t){var e=o=>t.next(o),n=o=>t.throw(o),r=s(e),i=s(n);function s(o){return a=>{var u=o(a),d=u.value;return u.done?d:!d||typeof d.then!="function"?B(d)?Promise.all(d).then(r,i):r(d):d.then(r,i)}}return s(e)()}function nu(t,e,n){var r=arguments.length;if(r<2)throw new k.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];n=i.pop();var s=Ai(i);return[t,s,n]}function Wi(t,e,n,r,i){return x.resolve().then(()=>{let s=R.transless||R,o=t._createTransaction(e,n,t._dbSchema,r),a={trans:o,transless:s};if(r)o.idbtrans=r.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(c){return c.name===hr.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Wi(t,e,n,null,i))):Q(c)}let u=dr(i);u&&Xe();let d,h=x.follow(()=>{if(d=i.call(o,o),d)if(u){var c=pe.bind(null,null);d.then(c,c)}else typeof d.next=="function"&&typeof d.throw=="function"&&(d=or(d))},a);return(d&&typeof d.then=="function"?x.resolve(d).then(c=>o.active?c:Q(new k.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):h.then(()=>d)).then(c=>(r&&o._resolve(),o._completion.then(()=>c))).catch(c=>(o._reject(c),Q(c)))})}function Ht(t,e,n){let r=B(t)?t.slice():[t];for(let i=0;i0,C={...f,isVirtual:b,keyTail:l,keyLength:p,extractKey:tr(c),unique:!b&&f.unique};if(m.push(C),C.isPrimaryKey||s.push(C),p>1){let _=p===2?c[0]:c.slice(0,p-1);o(_,l+1,f)}return m.sort((_,w)=>_.keyTail-w.keyTail),C}let a=o(r.primaryKey.keyPath,0,r.primaryKey);i[":id"]=[a];for(let c of r.indexes)o(c.keyPath,0,c);function u(c){let l=i[gt(c)];return l&&l[0]}function d(c,l){return{type:c.type===1?2:c.type,lower:Ht(c.lower,c.lowerOpen?t.MAX_KEY:t.MIN_KEY,l),lowerOpen:!0,upper:Ht(c.upper,c.upperOpen?t.MIN_KEY:t.MAX_KEY,l),upperOpen:!0}}function h(c){let l=c.query.index;return l.isVirtual?{...c,query:{index:l,range:d(c.query.range,l.keyTail)}}:c}return{...n,schema:{...r,primaryKey:a,indexes:s,getIndexByKeyPath:u},count(c){return n.count(h(c))},query(c){return n.query(h(c))},openCursor(c){let{keyTail:l,isVirtual:f,keyLength:y}=c.query.index;if(!f)return n.openCursor(c);function m(p){function b(C){C!=null?p.continue(Ht(C,c.reverse?t.MAX_KEY:t.MIN_KEY,l)):c.unique?p.continue(p.key.slice(0,y).concat(c.reverse?t.MIN_KEY:t.MAX_KEY,l)):p.continue()}return Object.create(p,{continue:{value:b},continuePrimaryKey:{value(C,_){p.continuePrimaryKey(Ht(C,t.MAX_KEY,l),_)}},primaryKey:{get(){return p.primaryKey}},key:{get(){let C=p.key;return y===1?C[0]:C.slice(0,y)}},value:{get(){return p.value}}})}return n.openCursor(h(c)).then(p=>p&&m(p))}}}}}var iu={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:ru};function vr(t,e,n,r){return n=n||{},r=r||"",j(t).forEach(i=>{if(!V(e,i))n[r+i]=void 0;else{var s=t[i],o=e[i];if(typeof s=="object"&&typeof o=="object"&&s&&o){let a=Bn(s),u=Bn(o);a!==u?n[r+i]=e[i]:a==="Object"?vr(s,o,n,r+i+"."):s!==o&&(n[r+i]=e[i])}else s!==o&&(n[r+i]=e[i])}}),j(e).forEach(i=>{V(t,i)||(n[r+i]=e[i])}),n}function su(t,e){return e.type==="delete"?e.keys:e.keys||e.values.map(t.extractKey)}var ou={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){let n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(i){let s=R.trans,{deleting:o,creating:a,updating:u}=s.table(e).hook;switch(i.type){case"add":if(a.fire===F)break;return s._promise("readwrite",()=>d(i),!0);case"put":if(a.fire===F&&u.fire===F)break;return s._promise("readwrite",()=>d(i),!0);case"delete":if(o.fire===F)break;return s._promise("readwrite",()=>d(i),!0);case"deleteRange":if(o.fire===F)break;return s._promise("readwrite",()=>h(i),!0)}return n.mutate(i);function d(l){let f=R.trans,y=l.keys||su(r,l);if(!y)throw new Error("Keys missing");return l=l.type==="add"||l.type==="put"?{...l,keys:y}:{...l},l.type!=="delete"&&(l.values=[...l.values]),l.keys&&(l.keys=[...l.keys]),au(n,l,y).then(m=>{let p=y.map((b,C)=>{let _=m[C],w={onerror:null,onsuccess:null};if(l.type==="delete")o.fire.call(w,b,_,f);else if(l.type==="add"||_===void 0){let A=a.fire.call(w,b,l.values[C],f);b==null&&A!=null&&(b=A,l.keys[C]=b,r.outbound||Z(l.values[C],r.keyPath,b))}else{let A=vr(_,l.values[C]),v=u.fire.call(w,A,b,_,f);if(v){let S=l.values[C];Object.keys(v).forEach(M=>{V(S,M)?S[M]=v[M]:Z(S,M,v[M])})}}return w});return n.mutate(l).then(({failures:b,results:C,numFailures:_,lastResult:w})=>{for(let A=0;A(p.forEach(C=>C.onerror&&C.onerror(b)),Promise.reject(b)))})}function h(l){return c(l.trans,l.range,1e4)}function c(l,f,y){return n.query({trans:l,values:!1,query:{index:r,range:f},limit:y}).then(({result:m})=>d({type:"delete",keys:m,trans:l}).then(p=>p.numFailures>0?Promise.reject(p.failures[0]):m.length({table:e=>{let n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);let i=Vi(r.keys,r.trans._cache,r.cache==="clone");return i?x.resolve(i):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?xt(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function xr(t){return!("from"in t)}var ue=function(t,e){if(this)H(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0});else{let n=new ue;return t&&"d"in t&&H(n,t),n}};ze(ue.prototype,{add(t){return an(this,t),this},addKey(t){return vt(this,t,t),this},addKeys(t){return t.forEach(e=>vt(this,e,e)),this},[qn](){return ar(this)}});function vt(t,e,n){let r=$(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(xr(t))return H(t,{from:e,to:n,d:1});let i=t.l,s=t.r;if($(n,t.from)<0)return i?vt(i,e,n):t.l={from:e,to:n,d:1,l:null,r:null},yi(t);if($(e,t.to)>0)return s?vt(s,e,n):t.r={from:e,to:n,d:1,l:null,r:null},yi(t);$(e,t.from)<0&&(t.from=e,t.l=null,t.d=s?s.d+1:1),$(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);let o=!t.r;i&&!t.l&&an(t,i),s&&o&&an(t,s)}function an(t,e){function n(r,{from:i,to:s,l:o,r:a}){vt(r,i,s),o&&n(r,o),a&&n(r,a)}xr(e)||n(t,e)}function lu(t,e){let n=ar(e),r=n.next();if(r.done)return!1;let i=r.value,s=ar(t),o=s.next(i.from),a=o.value;for(;!r.done&&!o.done;){if($(a.from,i.to)<=0&&$(a.to,i.from)>=0)return!0;$(i.from,a.from)<0?i=(r=n.next(a.from)).value:a=(o=s.next(i.from)).value}return!1}function ar(t){let e=xr(t)?null:{s:0,n:t};return{next(n){let r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&$(n,e.n.from)<0;)e={up:e,n:e.n.l,s:1};else for(;e.n.l;)e={up:e,n:e.n.l,s:1};case 1:if(e.s=2,!r||$(n,e.n.to)<=0)return{value:e.n,done:!1};case 2:if(e.n.r){e.s=3,e={up:e,n:e.n.r,s:0};continue}case 3:e=e.up}return{done:!0}}}}function yi(t){var e,n;let r=(((e=t.r)===null||e===void 0?void 0:e.d)||0)-(((n=t.l)===null||n===void 0?void 0:n.d)||0),i=r>1?"r":r<-1?"l":"";if(i){let s=i==="r"?"l":"r",o={...t},a=t[i];t.from=a.from,t.to=a.to,t[i]=a[i],o[i]=a[s],t[s]=o,o.d=fi(o)}t.d=fi(t)}function fi({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}var du={stack:"dbcore",level:0,create:t=>{let e=t.schema.name,n=new ue(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{let i=t.table(r),{schema:s}=i,{primaryKey:o}=s,{extractKey:a,outbound:u}=o,d={...i,mutate:l=>{let f=l.trans,y=f.mutatedParts||(f.mutatedParts={}),m=v=>{let S=`idb://${e}/${r}/${v}`;return y[S]||(y[S]=new ue)},p=m(""),b=m(":dels"),{type:C}=l,[_,w]=l.type==="deleteRange"?[l.range]:l.type==="delete"?[l.keys]:l.values.length<50?[[],l.values]:[],A=l.trans._cache;return i.mutate(l).then(v=>{if(B(_)){C!=="delete"&&(_=v.results),p.addKeys(_);let S=Vi(_,A);!S&&C!=="add"&&b.addKeys(_),(S||w)&&cu(m,s,S,w)}else if(_){let S={from:_.lower,to:_.upper};b.add(S),p.add(S)}else p.add(n),b.add(n),s.indexes.forEach(S=>m(S.name).add(n));return v})}},h=({query:{index:l,range:f}})=>{var y,m;return[l,new ue((y=f.lower)!==null&&y!==void 0?y:t.MIN_KEY,(m=f.upper)!==null&&m!==void 0?m:t.MAX_KEY)]},c={get:l=>[o,new ue(l.key)],getMany:l=>[o,new ue().addKeys(l.keys)],count:h,query:h,openCursor:h};return j(c).forEach(l=>{d[l]=function(f){let{subscr:y}=R;if(y){let m=w=>{let A=`idb://${e}/${r}/${w}`;return y[A]||(y[A]=new ue)},p=m(""),b=m(":dels"),[C,_]=c[l](f);if(m(C.name||"").add(_),!C.isPrimaryKey)if(l==="count")b.add(n);else{let w=l==="query"&&u&&f.values&&i.query({...f,values:!1});return i[l].apply(this,arguments).then(A=>{if(l==="query"){if(u&&f.values)return w.then(({result:S})=>(p.addKeys(S),A));let v=f.values?A.result.map(a):A.result;f.values?p.addKeys(v):b.addKeys(v)}else if(l==="openCursor"){let v=A,S=f.values;return v&&Object.create(v,{key:{get(){return b.addKey(v.primaryKey),v.key}},primaryKey:{get(){let M=v.primaryKey;return b.addKey(M),M}},value:{get(){return S&&p.addKey(v.primaryKey),v.value}}})}return A})}}return i[l].apply(this,arguments)}}),d}}}};function cu(t,e,n,r){function i(s){let o=t(s.name||"");function a(d){return d!=null?s.extractKey(d):null}let u=d=>s.multiEntry&&B(d)?d.forEach(h=>o.addKey(h)):o.addKey(d);(n||r).forEach((d,h)=>{let c=n&&a(n[h]),l=r&&a(r[h]);$(c,l)!==0&&(c!=null&&u(c),l!=null&&u(l))})}e.indexes.forEach(i)}var Tt=class Xt{constructor(e,n){this._middlewares={},this.verno=0;let r=Xt.dependencies;this._options=n={addons:Xt.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};let{addons:i}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;let s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:F,dbReadyPromise:null,cancelOpen:F,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};s.dbReadyPromise=new x(o=>{s.dbReadyResolve=o}),s.openCanceller=new x((o,a)=>{s.cancelOpen=a}),this._state=s,this.name=e,this.on=Mt(this,"populate","blocked","versionchange","close",{ready:[pr,F]}),this.on.ready.subscribe=_i(this.on.ready.subscribe,o=>(a,u)=>{Xt.vip(()=>{let d=this._state;if(d.openComplete)d.dbOpenError||x.resolve().then(a),u&&o(a);else if(d.onReadyBeingFired)d.onReadyBeingFired.push(a),u&&o(a);else{o(a);let h=this;u||o(function c(){h.on.ready.unsubscribe(a),h.on.ready.unsubscribe(c)})}})}),this.Collection=Ra(this),this.Table=wa(this),this.Transaction=Oa(this),this.Version=Ya(this),this.WhereClause=Fa(this),this.on("versionchange",o=>{o.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",o=>{!o.newVersion||o.newVersionnew this.Transaction(o,a,u,this._options.chromeTransactionDurability,d),this._fireOnBlocked=o=>{this.on("blocked").fire(o),mt.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(o))},this.use(iu),this.use(ou),this.use(du),this.use(uu),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(o=>o(this))}version(e){if(isNaN(e)||e<.1)throw new k.Type("Given version is not a positive number");if(e=Math.round(e*10)/10,this.idbdb||this._state.isBeingOpened)throw new k.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);let n=this._versions;var r=n.filter(i=>i._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(Ba),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||R.letThrough||this._vip)?e():new x((n,r)=>{if(this._state.openComplete)return r(new k.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen){r(new k.DatabaseClosed);return}this.open().catch(F)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:i}){i&&this.unuse({stack:e,name:i});let s=this._middlewares[e]||(this._middlewares[e]=[]);return s.push({stack:e,create:n,level:r??10,name:i}),s.sort((o,a)=>o.level-a.level),this}unuse({stack:e,name:n,create:r}){return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(i=>r?i.create!==r:n?i.name!==n:!1)),this}open(){return tu(this)}_close(){let e=this._state,n=mt.indexOf(this);if(n>=0&&mt.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new x(r=>{e.dbReadyResolve=r}),e.openCanceller=new x((r,i)=>{e.cancelOpen=i})}close(){this._close();let e=this._state;this._options.autoOpen=!1,e.dbOpenError=new k.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){let e=arguments.length>0,n=this._state;return new x((r,i)=>{let s=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=O(()=>{Za(this._deps,this.name),r()}),o.onerror=te(i),o.onblocked=this._fireOnBlocked};if(e)throw new k.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){let e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return j(this._allTables).map(e=>this._allTables[e])}transaction(){let e=nu.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let i=R.trans;(!i||i.db!==this||e.indexOf("!")!==-1)&&(i=null);let s=e.indexOf("?")!==-1;e=e.replace("!","").replace("?","");let o,a;try{if(a=n.map(d=>{var h=d instanceof this.Table?d.name:d;if(typeof h!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return h}),e=="r"||e===Ln)o=Ln;else if(e=="rw"||e==jn)o=jn;else throw new k.InvalidArgument("Invalid transaction mode: "+e);if(i){if(i.mode===Ln&&o===jn)if(s)i=null;else throw new k.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i&&a.forEach(d=>{if(i&&i.storeNames.indexOf(d)===-1)if(s)i=null;else throw new k.SubTransaction("Table "+d+" not included in parent transaction.")}),s&&i&&!i.active&&(i=null)}}catch(d){return i?i._promise(null,(h,c)=>{c(d)}):Q(d)}let u=Wi.bind(null,this,o,a,i,r);return i?i._promise(o,u,"lock"):R.trans?Ze(R.transless,()=>this._whenReady(u)):this._whenReady(u)}table(e){if(!V(this._allTables,e))throw new k.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}},hu=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable",pu=class{constructor(t){this._subscribe=t}subscribe(t,e,n){return this._subscribe(!t||typeof t=="function"?{next:t,error:e,complete:n}:t)}[hu](){return this}};function zi(t,e){return j(e).forEach(n=>{let r=t[n]||(t[n]=new ue);an(r,e[n])}),t}function mu(t){let e=!1,n,r=new pu(i=>{let s=dr(t);function o(p){s&&Xe();let b=()=>we(t,{subscr:p,trans:null}),C=R.trans?Ze(R.transless,b):b();return s&&C.then(pe,pe),C}let a=!1,u={},d={},h={get closed(){return a},unsubscribe:()=>{a=!0,xe.storagemutated.unsubscribe(y)}};i.start&&i.start(h);let c=!1,l=!1;function f(){return j(d).some(p=>u[p]&&lu(u[p],d[p]))}let y=p=>{zi(u,p),f()&&m()},m=()=>{if(c||a)return;u={};let p={},b=o(p);l||(xe(_t,y),l=!0),c=!0,Promise.resolve(b).then(C=>{e=!0,n=C,c=!1,!a&&(f()?m():(u={},d=p,i.next&&i.next(C)))},C=>{c=!1,e=!1,i.error&&i.error(C),h.unsubscribe()})};return m(),h});return r.hasValue=()=>e,r.getValue=()=>n,r}var ur;try{ur={indexedDB:P.indexedDB||P.mozIndexedDB||P.webkitIndexedDB||P.msIndexedDB,IDBKeyRange:P.IDBKeyRange||P.webkitIDBKeyRange}}catch{ur={indexedDB:null,IDBKeyRange:null}}var Te=Tt;ze(Te,{...dn,delete(t){return new Te(t,{addons:[]}).delete()},exists(t){return new Te(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1)},getDatabaseNames(t){try{return Ja(Te.dependencies).then(t)}catch{return Q(new k.MissingAPI)}},defineClass(){function t(e){H(this,e)}return t},ignoreTransaction(t){return R.trans?Ze(R.transless,t):t()},vip:sr,async:function(t){return function(){try{var e=or(t.apply(this,arguments));return!e||typeof e.then!="function"?x.resolve(e):e}catch(n){return Q(n)}}},spawn:function(t,e,n){try{var r=or(t.apply(n,e||[]));return!r||typeof r.then!="function"?x.resolve(r):r}catch(i){return Q(i)}},currentTransaction:{get:()=>R.trans||null},waitFor:function(t,e){let n=x.resolve(typeof t=="function"?Te.ignoreTransaction(t):t).timeout(e||6e4);return R.trans?R.trans.waitFor(n):n},Promise:x,debug:{get:()=>ne,set:t=>{Ri(t,t==="dexie"?()=>!0:Di)}},derive:Ye,extend:H,props:ze,override:_i,Events:Mt,on:xe,liveQuery:mu,extendObservabilitySet:zi,getByKeyPath:ce,setByKeyPath:Z,delByKeyPath:Go,shallowClone:xi,deepClone:xt,getObjectDiff:vr,cmp:$,asap:wi,minKey:Zn,addons:[],connections:mt,errnames:hr,dependencies:ur,semVer:di,version:di.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,n*2))});Te.maxKey=wt(Te.dependencies.IDBKeyRange);typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(xe(_t,t=>{if(!de){let e;cn?(e=document.createEvent("CustomEvent"),e.initCustomEvent(_e,!0,!0,t)):e=new CustomEvent(_e,{detail:t}),de=!0,dispatchEvent(e),de=!1}}),addEventListener(_e,({detail:t})=>{de||un(t)}));function un(t){let e=de;try{de=!0,xe.storagemutated.fire(t)}finally{de=e}}var de=!1;if(typeof BroadcastChannel<"u"){let t=new BroadcastChannel(_e);typeof t.unref=="function"&&t.unref(),xe(_t,e=>{de||t.postMessage(e)}),t.onmessage=e=>{e.data&&un(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){xe(_t,e=>{try{de||(typeof localStorage<"u"&&localStorage.setItem(_e,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:_e,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===_e){let n=JSON.parse(e.newValue);n&&un(n.changedParts)}});let t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",gu)}function gu({data:t}){t&&t.type===_e&&un(t.changedParts)}x.rejectionMapper=ta;Ri(ne,Di);var pn=class extends Tt{updates;constructor(e){super(`update-explorer_${e}`),this.version(1).stores({updates:"++id, &updateId"})}};addEventListener("message",async t=>{let e=new at(t.data);globalThis.bot=e;let n=new pn(t.data),r=Date.now();try{await e.init(),postMessage({_:"me",me:e.me})}catch(i){let s="";i instanceof se?s=i.description=="Unauthorized"?"Invalid bot token":i.description:s=String(i),s=`Authorization failed: ${s}`,postMessage({_:"error",error:s});return}e.use((i,s)=>(n.updates.put({updateId:i.update.update_id,data:i.update}),(!i.msg?.date||i.msg.date<=r)&&postMessage({_:"sound"}),s())),e.start()},{once:!0});