buzzcasting-storage 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +75 -0
- package/dist/buzzcasting-storage.cjs +7 -0
- package/dist/buzzcasting-storage.d.ts +54 -0
- package/dist/buzzcasting-storage.iife.js +7 -0
- package/dist/buzzcasting-storage.js +3274 -0
- package/dist/buzzcasting-storage.umd.cjs +7 -0
- package/package.json +54 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(function(Q,N){typeof exports=="object"&&typeof module<"u"?module.exports=N():typeof define=="function"&&define.amd?define(N):(Q=typeof globalThis<"u"?globalThis:Q||self,Q.BuzzcastingStorage=N())})(this,function(){"use strict";var ps=Object.defineProperty;var ms=(Q,N,oe)=>N in Q?ps(Q,N,{enumerable:!0,configurable:!0,writable:!0,value:oe}):Q[N]=oe;var k=(Q,N,oe)=>(ms(Q,typeof N!="symbol"?N+"":N,oe),oe);class Q{constructor(e){k(this,"options");k(this,"url");k(this,"csrf",()=>{var e,n;if((e=this.options)!=null&&e.csrf)return{headers:new Headers({"X-Csrf-Token":(n=this.options)==null?void 0:n.csrf})}});this.options=e,this.url=`https://${e.app}.buzzcasting.net`}auth(){var n;if(!((n=this.options)!=null&&n.token))return;let e="";switch(this.options.token){case"meta":e="Bearer "+this.options.bearer;break}return{headers:new Headers({Authorization:e})}}async get(e){let n;const r=this.auth(),s=this.csrf();n={...r,...s};let i=Object.assign({},e);delete i.type;const o=Object.keys(i).length>0?"?"+new URLSearchParams(i).toString():"";return await fetch([this.url,"api",this.options.version,e.type].join("/")+o,{...n,method:"get"}).then(a=>{if(!a.ok)throw Error(a.statusText);return a}).then(a=>a.json()).then(a=>(a.query=e,a)).catch(a=>({succes:!1,message:a,data:[]}))}async hideMessage(e){const{app:n,version:r}=this.options,s=this.auth(),i="?action=visible";return console.log([n,"api",r,e.type,e.id].join("/")+i,{...s,method:"put"}),await fetch([n,"api",r,e.type,e.id].join("/")+i,{...s,method:"put"}).then(o=>{if(!o.ok)throw Error(o.statusText);return o}).then(o=>o.json()).catch(o=>({succes:!1,message:o,data:[]}))}}const N="messages",oe="cloud",xt="series",ur="topics",hr="keyval",dr="local",fr="session",pr="dexie",mr="window",D=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,R=Object.keys,$=Array.isArray;function W(t,e){return typeof e!="object"||R(e).forEach(function(n){t[n]=e[n]}),t}typeof Promise>"u"||D.Promise||(D.Promise=Promise);const Ie=Object.getPrototypeOf,yr={}.hasOwnProperty;function H(t,e){return yr.call(t,e)}function ke(t,e){typeof e=="function"&&(e=e(Ie(t))),(typeof Reflect>"u"?R:Reflect.ownKeys)(e).forEach(n=>{q(t,n,e[n])})}const wn=Object.defineProperty;function q(t,e,n,r){wn(t,e,W(n&&H(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function xe(t){return{from:function(e){return t.prototype=Object.create(e.prototype),q(t.prototype,"constructor",t),{extend:ke.bind(null,t.prototype)}}}}const gr=Object.getOwnPropertyDescriptor;function St(t,e){let n;return gr(t,e)||(n=Ie(t))&&St(n,e)}const br=[].slice;function qe(t,e,n){return br.call(t,e,n)}function _n(t,e){return e(t)}function Be(t){if(!t)throw new Error("Assertion Failed")}function kn(t){D.setImmediate?setImmediate(t):setTimeout(t,0)}function xn(t,e){return t.reduce((n,r,s)=>{var i=e(r,s);return i&&(n[i[0]]=i[1]),n},{})}function ee(t,e){if(typeof e=="string"&&H(t,e))return t[e];if(!e)return t;if(typeof e!="string"){for(var n=[],r=0,s=e.length;r<s;++r){var i=ee(t,e[r]);n.push(i)}return n}var o=e.indexOf(".");if(o!==-1){var a=t[e.substr(0,o)];return a===void 0?void 0:ee(a,e.substr(o+1))}}function J(t,e,n){if(t&&e!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(t)))if(typeof e!="string"&&"length"in e){Be(typeof n!="string"&&"length"in n);for(var r=0,s=e.length;r<s;++r)J(t,e[r],n[r])}else{var i=e.indexOf(".");if(i!==-1){var o=e.substr(0,i),a=e.substr(i+1);if(a==="")n===void 0?$(t)&&!isNaN(parseInt(o))?t.splice(o,1):delete t[o]:t[o]=n;else{var c=t[o];c&&H(t,o)||(c=t[o]={}),J(c,a,n)}}else n===void 0?$(t)&&!isNaN(parseInt(e))?t.splice(e,1):delete t[e]:t[e]=n}}function Sn(t){var e={};for(var n in t)H(t,n)&&(e[n]=t[n]);return e}const vr=[].concat;function En(t){return vr.apply([],t)}const Pn="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(En([8,16,32,64].map(t=>["Int","Uint","Float"].map(e=>e+t+"Array")))).filter(t=>D[t]),wr=Pn.map(t=>D[t]);xn(Pn,t=>[t,!0]);let ae=null;function Te(t){ae=typeof WeakMap<"u"&&new WeakMap;const e=Et(t);return ae=null,e}function Et(t){if(!t||typeof t!="object")return t;let e=ae&&ae.get(t);if(e)return e;if($(t)){e=[],ae&&ae.set(t,e);for(var n=0,r=t.length;n<r;++n)e.push(Et(t[n]))}else if(wr.indexOf(t.constructor)>=0)e=t;else{const i=Ie(t);for(var s in e=i===Object.prototype?{}:Object.create(i),ae&&ae.set(t,e),t)H(t,s)&&(e[s]=Et(t[s]))}return e}const{toString:_r}={};function Pt(t){return _r.call(t).slice(8,-1)}const Ot=typeof Symbol<"u"?Symbol.iterator:"@@iterator",kr=typeof Ot=="symbol"?function(t){var e;return t!=null&&(e=t[Ot])&&e.apply(t)}:function(){return null},Se={};function te(t){var e,n,r,s;if(arguments.length===1){if($(t))return t.slice();if(this===Se&&typeof t=="string")return[t];if(s=kr(t)){for(n=[];!(r=s.next()).done;)n.push(r.value);return n}if(t==null)return[t];if(typeof(e=t.length)=="number"){for(n=new Array(e);e--;)n[e]=t[e];return n}return[t]}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}const jt=typeof Symbol<"u"?t=>t[Symbol.toStringTag]==="AsyncFunction":()=>!1;var X=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function On(t,e){X=t,jn=e}var jn=()=>!0;const xr=!new Error("").stack;function fe(){if(xr)try{throw fe.arguments,new Error}catch(t){return t}return new Error}function Ct(t,e){var n=t.stack;return n?(e=e||0,n.indexOf(t.name)===0&&(e+=(t.name+t.message).split(`
|
|
2
|
+
`).length),n.split(`
|
|
3
|
+
`).slice(e).filter(jn).map(r=>`
|
|
4
|
+
`+r).join("")):""}var Cn=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],Kt=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Cn),Sr={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 Ee(t,e){this._e=fe(),this.name=t,this.message=e}function Kn(t,e){return t+". Errors: "+Object.keys(e).map(n=>e[n].toString()).filter((n,r,s)=>s.indexOf(n)===r).join(`
|
|
5
|
+
`)}function et(t,e,n,r){this._e=fe(),this.failures=e,this.failedKeys=r,this.successCount=n,this.message=Kn(t,e)}function Me(t,e){this._e=fe(),this.name="BulkError",this.failures=Object.keys(e).map(n=>e[n]),this.failuresByPos=e,this.message=Kn(t,e)}xe(Ee).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+Ct(this._e,2))}},toString:function(){return this.name+": "+this.message}}),xe(et).from(Ee),xe(Me).from(Ee);var At=Kt.reduce((t,e)=>(t[e]=e+"Error",t),{});const Er=Ee;var j=Kt.reduce((t,e)=>{var n=e+"Error";function r(s,i){this._e=fe(),this.name=n,s?typeof s=="string"?(this.message=`${s}${i?`
|
|
6
|
+
`+i:""}`,this.inner=i||null):typeof s=="object"&&(this.message=`${s.name} ${s.message}`,this.inner=s):(this.message=Sr[e]||n,this.inner=null)}return xe(r).from(Er),t[e]=r,t},{});j.Syntax=SyntaxError,j.Type=TypeError,j.Range=RangeError;var An=Cn.reduce((t,e)=>(t[e+"Error"]=j[e],t),{}),tt=Kt.reduce((t,e)=>(["Syntax","Type","Range"].indexOf(e)===-1&&(t[e+"Error"]=j[e]),t),{});function A(){}function Re(t){return t}function Pr(t,e){return t==null||t===Re?e:function(n){return e(t(n))}}function pe(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function Or(t,e){return t===A?e:function(){var n=t.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var i=e.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?pe(r,this.onsuccess):r),s&&(this.onerror=this.onerror?pe(s,this.onerror):s),i!==void 0?i:n}}function jr(t,e){return t===A?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 Cr(t,e){return t===A?e:function(n){var r=t.apply(this,arguments);W(n,r);var s=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var o=e.apply(this,arguments);return s&&(this.onsuccess=this.onsuccess?pe(s,this.onsuccess):s),i&&(this.onerror=this.onerror?pe(i,this.onerror):i),r===void 0?o===void 0?void 0:o:W(r,o)}}function Kr(t,e){return t===A?e:function(){return e.apply(this,arguments)!==!1&&t.apply(this,arguments)}}function Dt(t,e){return t===A?e:function(){var n=t.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,s=arguments.length,i=new Array(s);s--;)i[s]=arguments[s];return n.then(function(){return e.apply(r,i)})}return e.apply(this,arguments)}}tt.ModifyError=et,tt.DexieError=Ee,tt.BulkError=Me;var Fe={};const Dn=100,[It,nt,Bt]=typeof Promise>"u"?[]:(()=>{let t=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[t,Ie(t),t];const e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,Ie(e),t]})(),In=nt&&nt.then,rt=It&&It.constructor,Tt=!!Bt;var Mt=!1,Ar=Bt?()=>{Bt.then(at)}:D.setImmediate?setImmediate.bind(null,at):D.MutationObserver?()=>{var t=document.createElement("div");new MutationObserver(()=>{at(),t=null}).observe(t,{attributes:!0}),t.setAttribute("i","1")}:()=>{setTimeout(at,0)},Ne=function(t,e){$e.push([t,e]),st&&(Ar(),st=!1)},Rt=!0,st=!0,me=[],it=[],Ft=null,Nt=Re,Pe={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:Wn,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(t=>{try{Wn(t[0],t[1])}catch{}})}},O=Pe,$e=[],ye=0,ot=[];function S(t){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=A,this._lib=!1;var e=this._PSD=O;if(X&&(this._stackHolder=fe(),this._prev=null,this._numPrev=0),typeof t!="function"){if(t!==Fe)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Lt(this,this._value))}this._state=null,this._value=null,++e.ref,Tn(this,t)}const $t={get:function(){var t=O,e=ut;function n(r,s){var i=!t.global&&(t!==O||e!==ut);const o=i&&!ne();var a=new S((c,l)=>{Ut(this,new Bn(dt(r,t,i,o),dt(s,t,i,o),c,l,t))});return X&&Fn(a,this),a}return n.prototype=Fe,n},set:function(t){q(this,"then",t&&t.prototype===Fe?$t:{get:function(){return t},set:$t.set})}};function Bn(t,e,n,r,s){this.onFulfilled=typeof t=="function"?t:null,this.onRejected=typeof e=="function"?e:null,this.resolve=n,this.reject=r,this.psd=s}function Tn(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&&Le();n&&typeof n.then=="function"?Tn(t,(s,i)=>{n instanceof S?n._then(s,i):n.then(s,i)}):(t._state=!0,t._value=n,Mn(t)),r&&Ue()}},Lt.bind(null,t))}catch(n){Lt(t,n)}}function Lt(t,e){if(it.push(e),t._state===null){var n=t._lib&&Le();e=Nt(e),t._state=!1,t._value=e,X&&e!==null&&typeof e=="object"&&!e._promise&&function(r,s,i){try{r.apply(null,i)}catch(o){s&&s(o)}}(()=>{var r=St(e,"stack");e._promise=t,q(e,"stack",{get:()=>Mt?r&&(r.get?r.get.apply(e):r.value):t.stack})}),function(r){me.some(s=>s._value===r._value)||me.push(r)}(t),Mn(t),n&&Ue()}}function Mn(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n<r;++n)Ut(t,e[n]);var s=t._PSD;--s.ref||s.finalize(),ye===0&&(++ye,Ne(()=>{--ye==0&&Wt()},[]))}function Ut(t,e){if(t._state!==null){var n=t._state?e.onFulfilled:e.onRejected;if(n===null)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++ye,Ne(Dr,[n,t,e])}else t._listeners.push(e)}function Dr(t,e,n){try{Ft=e;var r,s=e._value;e._state?r=t(s):(it.length&&(it=[]),r=t(s),it.indexOf(s)===-1&&function(i){for(var o=me.length;o;)if(me[--o]._value===i._value)return void me.splice(o,1)}(e)),n.resolve(r)}catch(i){n.reject(i)}finally{Ft=null,--ye==0&&Wt(),--n.psd.ref||n.psd.finalize()}}function Rn(t,e,n){if(e.length===n)return e;var r="";if(t._state===!1){var s,i,o=t._value;o!=null?(s=o.name||"Error",i=o.message||o,r=Ct(o,0)):(s=o,i=""),e.push(s+(i?": "+i:"")+r)}return X&&((r=Ct(t._stackHolder,2))&&e.indexOf(r)===-1&&e.push(r),t._prev&&Rn(t._prev,e,n)),e}function Fn(t,e){var n=e?e._numPrev+1:0;n<100&&(t._prev=e,t._numPrev=n)}function at(){Le()&&Ue()}function Le(){var t=Rt;return Rt=!1,st=!1,t}function Ue(){var t,e,n;do for(;$e.length>0;)for(t=$e,$e=[],n=t.length,e=0;e<n;++e){var r=t[e];r[0].apply(null,r[1])}while($e.length>0);Rt=!0,st=!0}function Wt(){var t=me;me=[],t.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var e=ot.slice(0),n=e.length;n;)e[--n]()}function ct(t){return new S(Fe,!1,t)}function I(t,e){var n=O;return function(){var r=Le(),s=O;try{return le(n,!0),t.apply(this,arguments)}catch(i){e&&e(i)}finally{le(s,!1),r&&Ue()}}}ke(S.prototype,{then:$t,_then:function(t,e){Ut(this,new Bn(null,null,t,e,O))},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):ct(r)):this.then(null,r=>r&&r.name===e?n(r):ct(r))},finally:function(t){return this.then(e=>(t(),e),e=>(t(),ct(e)))},stack:{get:function(){if(this._stack)return this._stack;try{Mt=!0;var t=Rn(this,[],20).join(`
|
|
7
|
+
From previous: `);return this._state!==null&&(this._stack=t),t}finally{Mt=!1}}},timeout:function(t,e){return t<1/0?new S((n,r)=>{var s=setTimeout(()=>r(new j.Timeout(e)),t);this.then(n,r).finally(clearTimeout.bind(null,s))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&q(S.prototype,Symbol.toStringTag,"Dexie.Promise"),Pe.env=Nn(),ke(S,{all:function(){var t=te.apply(null,arguments).map(ht);return new S(function(e,n){t.length===0&&e([]);var r=t.length;t.forEach((s,i)=>S.resolve(s).then(o=>{t[i]=o,--r||e(t)},n))})},resolve:t=>{if(t instanceof S)return t;if(t&&typeof t.then=="function")return new S((n,r)=>{t.then(n,r)});var e=new S(Fe,!0,t);return Fn(e,Ft),e},reject:ct,race:function(){var t=te.apply(null,arguments).map(ht);return new S((e,n)=>{t.map(r=>S.resolve(r).then(e,n))})},PSD:{get:()=>O,set:t=>O=t},totalEchoes:{get:()=>ut},newPSD:ce,usePSD:je,scheduler:{get:()=>Ne,set:t=>{Ne=t}},rejectionMapper:{get:()=>Nt,set:t=>{Nt=t}},follow:(t,e)=>new S((n,r)=>ce((s,i)=>{var o=O;o.unhandleds=[],o.onunhandled=i,o.finalize=pe(function(){(function(a){function c(){a(),ot.splice(ot.indexOf(c),1)}ot.push(c),++ye,Ne(()=>{--ye==0&&Wt()},[])})(()=>{this.unhandleds.length===0?s():i(this.unhandleds[0])})},o.finalize),t()},e,n,r))}),rt&&(rt.allSettled&&q(S,"allSettled",function(){const t=te.apply(null,arguments).map(ht);return new S(e=>{t.length===0&&e([]);let n=t.length;const r=new Array(n);t.forEach((s,i)=>S.resolve(s).then(o=>r[i]={status:"fulfilled",value:o},o=>r[i]={status:"rejected",reason:o}).then(()=>--n||e(r)))})}),rt.any&&typeof AggregateError<"u"&&q(S,"any",function(){const t=te.apply(null,arguments).map(ht);return new S((e,n)=>{t.length===0&&n(new AggregateError([]));let r=t.length;const s=new Array(r);t.forEach((i,o)=>S.resolve(i).then(a=>e(a),a=>{s[o]=a,--r||n(new AggregateError(s))}))})}));const L={awaits:0,echoes:0,id:0};var Ir=0,lt=[],zt=0,ut=0,Br=0;function ce(t,e,n,r){var s=O,i=Object.create(s);i.parent=s,i.ref=0,i.global=!1,i.id=++Br;var o=Pe.env;i.env=Tt?{Promise:S,PromiseProp:{value:S,configurable:!0,writable:!0},all:S.all,race:S.race,allSettled:S.allSettled,any:S.any,resolve:S.resolve,reject:S.reject,nthen:Ln(o.nthen,i),gthen:Ln(o.gthen,i)}:{},e&&W(i,e),++s.ref,i.finalize=function(){--this.parent.ref||this.parent.finalize()};var a=je(i,t,n,r);return i.ref===0&&i.finalize(),a}function Oe(){return L.id||(L.id=++Ir),++L.awaits,L.echoes+=Dn,L.id}function ne(){return!!L.awaits&&(--L.awaits==0&&(L.id=0),L.echoes=L.awaits*Dn,!0)}function ht(t){return L.echoes&&t&&t.constructor===rt?(Oe(),t.then(e=>(ne(),e),e=>(ne(),F(e)))):t}function Tr(t){++ut,L.echoes&&--L.echoes!=0||(L.echoes=L.id=0),lt.push(O),le(t,!0)}function Mr(){var t=lt[lt.length-1];lt.pop(),le(t,!1)}function le(t,e){var n=O;if((e?!L.echoes||zt++&&t===O:!zt||--zt&&t===O)||$n(e?Tr.bind(null,t):Mr),t!==O&&(O=t,n===Pe&&(Pe.env=Nn()),Tt)){var r=Pe.env.Promise,s=t.env;nt.then=s.nthen,r.prototype.then=s.gthen,(n.global||t.global)&&(Object.defineProperty(D,"Promise",s.PromiseProp),r.all=s.all,r.race=s.race,r.resolve=s.resolve,r.reject=s.reject,s.allSettled&&(r.allSettled=s.allSettled),s.any&&(r.any=s.any))}}function Nn(){var t=D.Promise;return Tt?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(D,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject,nthen:nt.then,gthen:t.prototype.then}:{}}function je(t,e,n,r,s){var i=O;try{return le(t,!0),e(n,r,s)}finally{le(i,!1)}}function $n(t){In.call(It,t)}function dt(t,e,n,r){return typeof t!="function"?t:function(){var s=O;n&&Oe(),le(e,!0);try{return t.apply(this,arguments)}finally{le(s,!1),r&&$n(ne)}}}function Ln(t,e){return function(n,r){return t.call(this,dt(n,e),dt(r,e))}}(""+In).indexOf("[native code]")===-1&&(Oe=ne=A);const Un="unhandledrejection";function Wn(t,e){var n;try{n=e.onuncatched(t)}catch{}if(n!==!1)try{var r,s={promise:e,reason:t};if(D.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(Un,!0,!0),W(r,s)):D.CustomEvent&&W(r=new CustomEvent(Un,{detail:s}),s),r&&D.dispatchEvent&&(dispatchEvent(r),!D.PromiseRejectionEvent&&D.onunhandledrejection))try{D.onunhandledrejection(r)}catch{}X&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${t.stack||t}`)}catch{}}var F=S.reject;function Vt(t,e,n,r){if(t.idbdb&&(t._state.openComplete||O.letThrough||t._vip)){var s=t._createTransaction(e,n,t._dbSchema);try{s.create(),t._state.PR1398_maxLoop=3}catch(i){return i.name===At.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>Vt(t,e,n,r))):F(i)}return s._promise(e,(i,o)=>ce(()=>(O.trans=s,r(i,o,s)))).then(i=>s._completion.then(()=>i))}if(t._state.openComplete)return F(new j.DatabaseClosed(t._state.dbOpenError));if(!t._state.isBeingOpened){if(!t._options.autoOpen)return F(new j.DatabaseClosed);t.open().catch(A)}return t._state.dbReadyPromise.then(()=>Vt(t,e,n,r))}const zn="3.2.5",ge="",Gt=-1/0,re="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Vn="String expected.",We=[],ft=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),Rr=ft,Fr=ft,Gn=t=>!/(dexie\.js|dexie\.min\.js)/.test(t),pt="__dbnames",Ht="readonly",Yt="readwrite";function be(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}const Hn={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function mt(t){return typeof t!="string"||/\./.test(t)?e=>e:e=>(e[t]===void 0&&t in e&&delete(e=Te(e))[t],e)}class Nr{_trans(e,n,r){const s=this._tx||O.trans,i=this.name;function o(c,l,u){if(!u.schema[i])throw new j.NotFound("Table "+i+" not part of transaction");return n(u.idbtrans,u)}const a=Le();try{return s&&s.db===this.db?s===O.trans?s._promise(e,o,r):ce(()=>s._promise(e,o,r),{trans:s,transless:O.transless||O}):Vt(this.db,e,[this.name],o)}finally{a&&Ue()}}get(e,n){return e&&e.constructor===Object?this.where(e).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:e}).then(s=>this.hook.reading.fire(s))).then(n)}where(e){if(typeof e=="string")return new this.db.WhereClause(this,e);if($(e))return new this.db.WhereClause(this,`[${e.join("+")}]`);const n=R(e);if(n.length===1)return this.where(n[0]).equals(e[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(l=>{if(l.compound&&n.every(u=>l.keyPath.indexOf(u)>=0)){for(let u=0;u<n.length;++u)if(n.indexOf(l.keyPath[u])===-1)return!1;return!0}return!1}).sort((l,u)=>l.keyPath.length-u.keyPath.length)[0];if(r&&this.db._maxKey!==ge){const l=r.keyPath.slice(0,n.length);return this.where(l).equals(l.map(u=>e[u]))}!r&&X&&console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:s}=this.schema,i=this.db._deps.indexedDB;function o(l,u){try{return i.cmp(l,u)===0}catch{return!1}}const[a,c]=n.reduce(([l,u],d)=>{const h=s[d],p=e[d];return[l||h,l||!h?be(u,h&&h.multi?g=>{const y=ee(g,d);return $(y)&&y.some(b=>o(p,b))}:g=>o(p,ee(g,d))):u]},[null,null]);return a?this.where(a.name).equals(e[a.keyPath]).filter(c):r?this.filter(c):this.where(n).equals("")}filter(e){return this.toCollection().and(e)}count(e){return this.toCollection().count(e)}offset(e){return this.toCollection().offset(e)}limit(e){return this.toCollection().limit(e)}each(e){return this.toCollection().each(e)}toArray(e){return this.toCollection().toArray(e)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(e){return new this.db.Collection(new this.db.WhereClause(this,$(e)?`[${e.join("+")}]`:e))}reverse(){return this.toCollection().reverse()}mapToClass(e){this.schema.mappedClass=e;const n=r=>{if(!r)return r;const s=Object.create(e.prototype);for(var i in r)if(H(r,i))try{s[i]=r[i]}catch{}return s};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),e}defineClass(){return this.mapToClass(function(e){W(this,e)})}add(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=mt(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:n!=null?[n]:null,values:[i]})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{J(e,s,o)}catch{}return o})}update(e,n){if(typeof e!="object"||$(e))return this.where(":id").equals(e).modify(n);{const r=ee(e,this.schema.primKey.keyPath);if(r===void 0)return F(new j.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?R(n).forEach(s=>{J(e,s,n[s])}):n(e,{value:e,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(e,n){const{auto:r,keyPath:s}=this.schema.primKey;let i=e;return s&&r&&(i=mt(s)(e)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[i],keys:n!=null?[n]:null})).then(o=>o.numFailures?S.reject(o.failures[0]):o.lastResult).then(o=>{if(s)try{J(e,s,o)}catch{}return o})}delete(e){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[e]})).then(n=>n.numFailures?S.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",e=>this.core.mutate({trans:e,type:"deleteRange",range:Hn})).then(e=>e.numFailures?S.reject(e.failures[0]):void 0)}bulkGet(e){return this._trans("readonly",n=>this.core.getMany({keys:e,trans:n}).then(r=>r.map(s=>this.hook.reading.fire(s))))}bulkAdd(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:a,keyPath:c}=this.schema.primKey;if(c&&s)throw new j.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new j.InvalidArgument("Arguments objects and keys must have the same length");const l=e.length;let u=c&&a?e.map(mt(c)):e;return this.core.mutate({trans:o,type:"add",keys:s,values:u,wantResults:i}).then(({numFailures:d,results:h,lastResult:p,failures:g})=>{if(d===0)return i?h:p;throw new Me(`${this.name}.bulkAdd(): ${d} of ${l} operations failed`,g)})})}bulkPut(e,n,r){const s=Array.isArray(n)?n:void 0,i=(r=r||(s?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:a,keyPath:c}=this.schema.primKey;if(c&&s)throw new j.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(s&&s.length!==e.length)throw new j.InvalidArgument("Arguments objects and keys must have the same length");const l=e.length;let u=c&&a?e.map(mt(c)):e;return this.core.mutate({trans:o,type:"put",keys:s,values:u,wantResults:i}).then(({numFailures:d,results:h,lastResult:p,failures:g})=>{if(d===0)return i?h:p;throw new Me(`${this.name}.bulkPut(): ${d} of ${l} operations failed`,g)})})}bulkDelete(e){const n=e.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:e})).then(({numFailures:r,lastResult:s,failures:i})=>{if(r===0)return s;throw new Me(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,i)})}}function ze(t){var e={},n=function(o,a){if(a){for(var c=arguments.length,l=new Array(c-1);--c;)l[c-1]=arguments[c];return e[o].subscribe.apply(null,l),t}if(typeof o=="string")return e[o]};n.addEventType=i;for(var r=1,s=arguments.length;r<s;++r)i(arguments[r]);return n;function i(o,a,c){if(typeof o!="object"){var l;a||(a=Kr),c||(c=A);var u={subscribers:[],fire:c,subscribe:function(d){u.subscribers.indexOf(d)===-1&&(u.subscribers.push(d),u.fire=a(u.fire,d))},unsubscribe:function(d){u.subscribers=u.subscribers.filter(function(h){return h!==d}),u.fire=u.subscribers.reduce(a,c)}};return e[o]=n[o]=u,u}R(l=o).forEach(function(d){var h=l[d];if($(h))i(d,l[d][0],l[d][1]);else{if(h!=="asap")throw new j.InvalidArgument("Invalid event config");var p=i(d,Re,function(){for(var g=arguments.length,y=new Array(g);g--;)y[g]=arguments[g];p.subscribers.forEach(function(b){kn(function(){b.apply(null,y)})})})}})}}function Ve(t,e){return xe(e).from({prototype:t}),e}function Ce(t,e){return!(t.filter||t.algorithm||t.or)&&(e?t.justLimit:!t.replayFilter)}function Qt(t,e){t.filter=be(t.filter,e)}function Jt(t,e,n){var r=t.replayFilter;t.replayFilter=r?()=>be(r(),e()):e,t.justLimit=n&&!r}function yt(t,e){if(t.isPrimKey)return e.primaryKey;const n=e.getIndexByKeyPath(t.index);if(!n)throw new j.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function Yn(t,e,n){const r=yt(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 gt(t,e,n,r){const s=t.replayFilter?be(t.filter,t.replayFilter()):t.filter;if(t.or){const i={},o=(a,c,l)=>{if(!s||s(c,l,h=>c.stop(h),h=>c.fail(h))){var u=c.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),H(i,d)||(i[d]=!0,e(a,c,l))}};return Promise.all([t.or._iterate(o,n),Qn(Yn(t,r,n),t.algorithm,o,!t.keysOnly&&t.valueMapper)])}return Qn(Yn(t,r,n),be(t.algorithm,s),e,!t.keysOnly&&t.valueMapper)}function Qn(t,e,n,r){var s=I(r?(i,o,a)=>n(r(i),o,a):n);return t.then(i=>{if(i)return i.start(()=>{var o=()=>i.continue();e&&!e(i,a=>o=a,a=>{i.stop(a),o=A},a=>{i.fail(a),o=A})||s(i.value,i,a=>o=a),o()})})}function z(t,e){try{const n=Jn(t),r=Jn(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:t<e?-1:0;case"binary":return function(s,i){const o=s.length,a=i.length,c=o<a?o:a;for(let l=0;l<c;++l)if(s[l]!==i[l])return s[l]<i[l]?-1:1;return o===a?0:o<a?-1:1}(Xn(t),Xn(e));case"Array":return function(s,i){const o=s.length,a=i.length,c=o<a?o:a;for(let l=0;l<c;++l){const u=z(s[l],i[l]);if(u!==0)return u}return o===a?0:o<a?-1:1}(t,e)}}catch{}return NaN}function Jn(t){const e=typeof t;if(e!=="object")return e;if(ArrayBuffer.isView(t))return"binary";const n=Pt(t);return n==="ArrayBuffer"?"binary":n}function Xn(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class $r{_read(e,n){var r=this._ctx;return r.error?r.table._trans(null,F.bind(null,r.error)):r.table._trans("readonly",e).then(n)}_write(e){var n=this._ctx;return n.error?n.table._trans(null,F.bind(null,n.error)):n.table._trans("readwrite",e,"locked")}_addAlgorithm(e){var n=this._ctx;n.algorithm=be(n.algorithm,e)}_iterate(e,n){return gt(this._ctx,e,n,this._ctx.table.core)}clone(e){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return e&&W(r,e),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(e){var n=this._ctx;return this._read(r=>gt(n,e,r,n.table.core))}count(e){return this._read(n=>{const r=this._ctx,s=r.table.core;if(Ce(r,!0))return s.count({trans:n,query:{index:yt(r,s.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var i=0;return gt(r,()=>(++i,!1),n,s).then(()=>i)}).then(e)}sortBy(e,n){const r=e.split(".").reverse(),s=r[0],i=r.length-1;function o(l,u){return u?o(l[r[u]],u-1):l[s]}var a=this._ctx.dir==="next"?1:-1;function c(l,u){var d=o(l,i),h=o(u,i);return d<h?-a:d>h?a:0}return this.toArray(function(l){return l.sort(c)}).then(n)}toArray(e){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Ce(r,!0)&&r.limit>0){const{valueMapper:s}=r,i=yt(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:i,range:r.range}}).then(({result:o})=>s?o.map(s):o)}{const s=[];return gt(r,i=>s.push(i),n,r.table.core).then(()=>s)}},e)}offset(e){var n=this._ctx;return e<=0||(n.offset+=e,Ce(n)?Jt(n,()=>{var r=e;return(s,i)=>r===0||(r===1?(--r,!1):(i(()=>{s.advance(r),r=0}),!1))}):Jt(n,()=>{var r=e;return()=>--r<0})),this}limit(e){return this._ctx.limit=Math.min(this._ctx.limit,e),Jt(this._ctx,()=>{var n=e;return function(r,s,i){return--n<=0&&s(i),n>=0}},!0),this}until(e,n){return Qt(this._ctx,function(r,s,i){return!e(r.value)||(s(i),n)}),this}first(e){return this.limit(1).toArray(function(n){return n[0]}).then(e)}last(e){return this.reverse().first(e)}filter(e){var n,r;return Qt(this._ctx,function(s){return e(s.value)}),n=this._ctx,r=e,n.isMatch=be(n.isMatch,r),this}and(e){return this.filter(e)}or(e){return new this.db.WhereClause(this._ctx.table,e,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(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.key,s)})}eachUniqueKey(e){return this._ctx.unique="unique",this.eachKey(e)}eachPrimaryKey(e){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,s){e(s.primaryKey,s)})}keys(e){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.key)}).then(function(){return r}).then(e)}primaryKeys(e){var n=this._ctx;if(n.dir==="next"&&Ce(n,!0)&&n.limit>0)return this._read(s=>{var i=yt(n,n.table.core.schema);return n.table.core.query({trans:s,values:!1,limit:n.limit,query:{index:i,range:n.range}})}).then(({result:s})=>s).then(e);n.keysOnly=!n.isMatch;var r=[];return this.each(function(s,i){r.push(i.primaryKey)}).then(function(){return r}).then(e)}uniqueKeys(e){return this._ctx.unique="unique",this.keys(e)}firstKey(e){return this.limit(1).keys(function(n){return n[0]}).then(e)}lastKey(e){return this.reverse().firstKey(e)}distinct(){var e=this._ctx,n=e.index&&e.table.schema.idxByName[e.index];if(!n||!n.multi)return this;var r={};return Qt(this._ctx,function(s){var i=s.primaryKey.toString(),o=H(r,i);return r[i]=!0,!o}),this}modify(e){var n=this._ctx;return this._write(r=>{var s;if(typeof e=="function")s=e;else{var i=R(e),o=i.length;s=function(y){for(var b=!1,m=0;m<o;++m){var f=i[m],w=e[f];ee(y,f)!==w&&(J(y,f,w),b=!0)}return b}}const a=n.table.core,{outbound:c,extractKey:l}=a.schema.primaryKey,u=this.db._options.modifyChunkSize||200,d=[];let h=0;const p=[],g=(y,b)=>{const{failures:m,numFailures:f}=b;h+=y-f;for(let w of R(m))d.push(m[w])};return this.clone().primaryKeys().then(y=>{const b=m=>{const f=Math.min(u,y.length-m);return a.getMany({trans:r,keys:y.slice(m,m+f),cache:"immutable"}).then(w=>{const E=[],P=[],x=c?[]:null,v=[];for(let _=0;_<f;++_){const T=w[_],K={value:Te(T),primKey:y[m+_]};s.call(K,K.value,K)!==!1&&(K.value==null?v.push(y[m+_]):c||z(l(T),l(K.value))===0?(P.push(K.value),c&&x.push(y[m+_])):(v.push(y[m+_]),E.push(K.value)))}const C=Ce(n)&&n.limit===1/0&&(typeof e!="function"||e===Xt)&&{index:n.index,range:n.range};return Promise.resolve(E.length>0&&a.mutate({trans:r,type:"add",values:E}).then(_=>{for(let T in _.failures)v.splice(parseInt(T),1);g(E.length,_)})).then(()=>(P.length>0||C&&typeof e=="object")&&a.mutate({trans:r,type:"put",keys:x,values:P,criteria:C,changeSpec:typeof e!="function"&&e}).then(_=>g(P.length,_))).then(()=>(v.length>0||C&&e===Xt)&&a.mutate({trans:r,type:"delete",keys:v,criteria:C}).then(_=>g(v.length,_))).then(()=>y.length>m+f&&b(m+u))})};return b(0).then(()=>{if(d.length>0)throw new et("Error modifying one or more objects",d,h,p);return y.length})})})}delete(){var e=this._ctx,n=e.range;return Ce(e)&&(e.isPrimKey&&!Fr||n.type===3)?this._write(r=>{const{primaryKey:s}=e.table.core.schema,i=n;return e.table.core.count({trans:r,query:{index:s,range:i}}).then(o=>e.table.core.mutate({trans:r,type:"deleteRange",range:i}).then(({failures:a,lastResult:c,results:l,numFailures:u})=>{if(u)throw new et("Could not delete some values",Object.keys(a).map(d=>a[d]),o-u);return o-u}))}):this.modify(Xt)}}const Xt=(t,e)=>e.value=null;function Lr(t,e){return t<e?-1:t===e?0:1}function Ur(t,e){return t>e?-1:t===e?0:1}function Y(t,e,n){var r=t instanceof qn?new t.Collection(t):t;return r._ctx.error=n?new n(e):new TypeError(e),r}function Ke(t){return new t.Collection(t,()=>Zn("")).limit(0)}function Wr(t,e,n,r,s,i){for(var o=Math.min(t.length,r.length),a=-1,c=0;c<o;++c){var l=e[c];if(l!==r[c])return s(t[c],n[c])<0?t.substr(0,c)+n[c]+n.substr(c+1):s(t[c],r[c])<0?t.substr(0,c)+r[c]+n.substr(c+1):a>=0?t.substr(0,a)+e[a]+n.substr(a+1):null;s(t[c],l)<0&&(a=c)}return o<r.length&&i==="next"?t+n.substr(t.length):o<t.length&&i==="prev"?t.substr(0,n.length):a<0?null:t.substr(0,a)+r[a]+n.substr(a+1)}function bt(t,e,n,r){var s,i,o,a,c,l,u,d=n.length;if(!n.every(y=>typeof y=="string"))return Y(t,Vn);function h(y){s=function(m){return m==="next"?f=>f.toUpperCase():f=>f.toLowerCase()}(y),i=function(m){return m==="next"?f=>f.toLowerCase():f=>f.toUpperCase()}(y),o=y==="next"?Lr:Ur;var b=n.map(function(m){return{lower:i(m),upper:s(m)}}).sort(function(m,f){return o(m.lower,f.lower)});a=b.map(function(m){return m.upper}),c=b.map(function(m){return m.lower}),l=y,u=y==="next"?"":r}h("next");var p=new t.Collection(t,()=>ue(a[0],c[d-1]+r));p._ondirectionchange=function(y){h(y)};var g=0;return p._addAlgorithm(function(y,b,m){var f=y.key;if(typeof f!="string")return!1;var w=i(f);if(e(w,c,g))return!0;for(var E=null,P=g;P<d;++P){var x=Wr(f,w,a[P],c[P],o,l);x===null&&E===null?g=P+1:(E===null||o(E,x)>0)&&(E=x)}return b(E!==null?function(){y.continue(E+u)}:m),!1}),p}function ue(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Zn(t){return{type:1,lower:t,upper:t}}class qn{get Collection(){return this._ctx.table.db.Collection}between(e,n,r,s){r=r!==!1,s=s===!0;try{return this._cmp(e,n)>0||this._cmp(e,n)===0&&(r||s)&&(!r||!s)?Ke(this):new this.Collection(this,()=>ue(e,n,!r,!s))}catch{return Y(this,re)}}equals(e){return e==null?Y(this,re):new this.Collection(this,()=>Zn(e))}above(e){return e==null?Y(this,re):new this.Collection(this,()=>ue(e,void 0,!0))}aboveOrEqual(e){return e==null?Y(this,re):new this.Collection(this,()=>ue(e,void 0,!1))}below(e){return e==null?Y(this,re):new this.Collection(this,()=>ue(void 0,e,!1,!0))}belowOrEqual(e){return e==null?Y(this,re):new this.Collection(this,()=>ue(void 0,e))}startsWith(e){return typeof e!="string"?Y(this,Vn):this.between(e,e+ge,!0,!0)}startsWithIgnoreCase(e){return e===""?this.startsWith(e):bt(this,(n,r)=>n.indexOf(r[0])===0,[e],ge)}equalsIgnoreCase(e){return bt(this,(n,r)=>n===r[0],[e],"")}anyOfIgnoreCase(){var e=te.apply(Se,arguments);return e.length===0?Ke(this):bt(this,(n,r)=>r.indexOf(n)!==-1,e,"")}startsWithAnyOfIgnoreCase(){var e=te.apply(Se,arguments);return e.length===0?Ke(this):bt(this,(n,r)=>r.some(s=>n.indexOf(s)===0),e,ge)}anyOf(){const e=te.apply(Se,arguments);let n=this._cmp;try{e.sort(n)}catch{return Y(this,re)}if(e.length===0)return Ke(this);const r=new this.Collection(this,()=>ue(e[0],e[e.length-1]));r._ondirectionchange=i=>{n=i==="next"?this._ascending:this._descending,e.sort(n)};let s=0;return r._addAlgorithm((i,o,a)=>{const c=i.key;for(;n(c,e[s])>0;)if(++s,s===e.length)return o(a),!1;return n(c,e[s])===0||(o(()=>{i.continue(e[s])}),!1)}),r}notEqual(e){return this.inAnyRange([[Gt,e],[e,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const e=te.apply(Se,arguments);if(e.length===0)return new this.Collection(this);try{e.sort(this._ascending)}catch{return Y(this,re)}const n=e.reduce((r,s)=>r?r.concat([[r[r.length-1][1],s]]):[[Gt,s]],null);return n.push([e[e.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(e,n){const r=this._cmp,s=this._ascending,i=this._descending,o=this._min,a=this._max;if(e.length===0)return Ke(this);if(!e.every(f=>f[0]!==void 0&&f[1]!==void 0&&s(f[0],f[1])<=0))return Y(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",j.InvalidArgument);const c=!n||n.includeLowers!==!1,l=n&&n.includeUppers===!0;let u,d=s;function h(f,w){return d(f[0],w[0])}try{u=e.reduce(function(f,w){let E=0,P=f.length;for(;E<P;++E){const x=f[E];if(r(w[0],x[1])<0&&r(w[1],x[0])>0){x[0]=o(x[0],w[0]),x[1]=a(x[1],w[1]);break}}return E===P&&f.push(w),f},[]),u.sort(h)}catch{return Y(this,re)}let p=0;const g=l?f=>s(f,u[p][1])>0:f=>s(f,u[p][1])>=0,y=c?f=>i(f,u[p][0])>0:f=>i(f,u[p][0])>=0;let b=g;const m=new this.Collection(this,()=>ue(u[0][0],u[u.length-1][1],!c,!l));return m._ondirectionchange=f=>{f==="next"?(b=g,d=s):(b=y,d=i),u.sort(h)},m._addAlgorithm((f,w,E)=>{for(var P=f.key;b(P);)if(++p,p===u.length)return w(E),!1;return!!function(x){return!g(x)&&!y(x)}(P)||(this._cmp(P,u[p][1])===0||this._cmp(P,u[p][0])===0||w(()=>{d===s?f.continue(u[p][0]):f.continue(u[p][1])}),!1)}),m}startsWithAnyOf(){const e=te.apply(Se,arguments);return e.every(n=>typeof n=="string")?e.length===0?Ke(this):this.inAnyRange(e.map(n=>[n,n+ge])):Y(this,"startsWithAnyOf() only works with strings")}}function Z(t){return I(function(e){return Ge(e),t(e.target.error),!1})}function Ge(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}const He="storagemutated",he="x-storagemutated-1",de=ze(null,He);class zr{_lock(){return Be(!O.global),++this._reculock,this._reculock!==1||O.global||(O.lockOwnerFor=this),this}_unlock(){if(Be(!O.global),--this._reculock==0)for(O.global||(O.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var e=this._blockedFuncs.shift();try{je(e[1],e[0])}catch{}}return this}_locked(){return this._reculock&&O.lockOwnerFor!==this}create(e){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(Be(!this.idbtrans),!e&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new j.DatabaseClosed(r);case"MissingAPIError":throw new j.MissingAPI(r.message,r);default:throw new j.OpenFailed(r)}if(!this.active)throw new j.TransactionInactive;return Be(this._completion._state===null),(e=this.idbtrans=e||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=I(s=>{Ge(s),this._reject(e.error)}),e.onabort=I(s=>{Ge(s),this.active&&this._reject(new j.Abort(e.error)),this.active=!1,this.on("abort").fire(s)}),e.oncomplete=I(()=>{this.active=!1,this._resolve(),"mutatedParts"in e&&de.storagemutated.fire(e.mutatedParts)}),this}_promise(e,n,r){if(e==="readwrite"&&this.mode!=="readwrite")return F(new j.ReadOnly("Transaction is readonly"));if(!this.active)return F(new j.TransactionInactive);if(this._locked())return new S((i,o)=>{this._blockedFuncs.push([()=>{this._promise(e,n,r).then(i,o)},O])});if(r)return ce(()=>{var i=new S((o,a)=>{this._lock();const c=n(o,a,this);c&&c.then&&c.then(o,a)});return i.finally(()=>this._unlock()),i._lib=!0,i});var s=new S((i,o)=>{var a=n(i,o,this);a&&a.then&&a.then(i,o)});return s._lib=!0,s}_root(){return this.parent?this.parent._root():this}waitFor(e){var n=this._root();const r=S.resolve(e);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var s=n.idbtrans.objectStore(n.storeNames[0]);(function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(s.get(-1/0).onsuccess=o)})()}var i=n._waitingFor;return new S((o,a)=>{r.then(c=>n._waitingQueue.push(I(o.bind(null,c))),c=>n._waitingQueue.push(I(a.bind(null,c)))).finally(()=>{n._waitingFor===i&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new j.Abort))}table(e){const n=this._memoizedTables||(this._memoizedTables={});if(H(n,e))return n[e];const r=this.schema[e];if(!r)throw new j.NotFound("Table "+e+" not part of transaction");const s=new this.db.Table(e,r,this);return s.core=this.db.core.table(e),n[e]=s,s}}function Zt(t,e,n,r,s,i,o){return{name:t,keyPath:e,unique:n,multi:r,auto:s,compound:i,src:(n&&!o?"&":"")+(r?"*":"")+(s?"++":"")+er(e)}}function er(t){return typeof t=="string"?t:t?"["+[].join.call(t,"+")+"]":""}function tr(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:xn(n,r=>[r.name,r])}}let Ye=t=>{try{return t.only([[]]),Ye=()=>[[]],[[]]}catch{return Ye=()=>ge,ge}};function qt(t){return t==null?()=>{}:typeof t=="string"?function(e){return e.split(".").length===1?r=>r[e]:r=>ee(r,e)}(t):e=>ee(e,t)}function nr(t){return[].slice.call(t)}let Vr=0;function Qe(t){return t==null?":id":typeof t=="string"?t:`[${t.join("+")}]`}function Gr(t,e,n){function r(c){if(c.type===3)return null;if(c.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:l,upper:u,lowerOpen:d,upperOpen:h}=c;return l===void 0?u===void 0?null:e.upperBound(u,!!h):u===void 0?e.lowerBound(l,!!d):e.bound(l,u,!!d,!!h)}const{schema:s,hasGetAll:i}=function(c,l){const u=nr(c.objectStoreNames);return{schema:{name:c.name,tables:u.map(d=>l.objectStore(d)).map(d=>{const{keyPath:h,autoIncrement:p}=d,g=$(h),y=h==null,b={},m={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:y,compound:g,keyPath:h,autoIncrement:p,unique:!0,extractKey:qt(h)},indexes:nr(d.indexNames).map(f=>d.index(f)).map(f=>{const{name:w,unique:E,multiEntry:P,keyPath:x}=f,v={name:w,compound:$(x),keyPath:x,unique:E,multiEntry:P,extractKey:qt(x)};return b[Qe(x)]=v,v}),getIndexByKeyPath:f=>b[Qe(f)]};return b[":id"]=m.primaryKey,h!=null&&(b[Qe(h)]=m.primaryKey),m})},hasGetAll:u.length>0&&"getAll"in l.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(t,n),o=s.tables.map(c=>function(l){const u=l.name;return{name:u,schema:l,mutate:function({trans:d,type:h,keys:p,values:g,range:y}){return new Promise((b,m)=>{b=I(b);const f=d.objectStore(u),w=f.keyPath==null,E=h==="put"||h==="add";if(!E&&h!=="delete"&&h!=="deleteRange")throw new Error("Invalid operation type: "+h);const{length:P}=p||g||{length:1};if(p&&g&&p.length!==g.length)throw new Error("Given keys array must have same length as given values array.");if(P===0)return b({numFailures:0,failures:{},results:[],lastResult:void 0});let x;const v=[],C=[];let _=0;const T=V=>{++_,Ge(V)};if(h==="deleteRange"){if(y.type===4)return b({numFailures:_,failures:C,results:[],lastResult:void 0});y.type===3?v.push(x=f.clear()):v.push(x=f.delete(r(y)))}else{const[V,U]=E?w?[g,p]:[g,null]:[p,null];if(E)for(let M=0;M<P;++M)v.push(x=U&&U[M]!==void 0?f[h](V[M],U[M]):f[h](V[M])),x.onerror=T;else for(let M=0;M<P;++M)v.push(x=f[h](V[M])),x.onerror=T}const K=V=>{const U=V.target.result;v.forEach((M,Ae)=>M.error!=null&&(C[Ae]=M.error)),b({numFailures:_,failures:C,results:h==="delete"?p:v.map(M=>M.result),lastResult:U})};x.onerror=V=>{T(V),K(V)},x.onsuccess=K})},getMany:({trans:d,keys:h})=>new Promise((p,g)=>{p=I(p);const y=d.objectStore(u),b=h.length,m=new Array(b);let f,w=0,E=0;const P=v=>{const C=v.target;m[C._pos]=C.result,++E===w&&p(m)},x=Z(g);for(let v=0;v<b;++v)h[v]!=null&&(f=y.get(h[v]),f._pos=v,f.onsuccess=P,f.onerror=x,++w);w===0&&p(m)}),get:({trans:d,key:h})=>new Promise((p,g)=>{p=I(p);const y=d.objectStore(u).get(h);y.onsuccess=b=>p(b.target.result),y.onerror=Z(g)}),query:function(d){return h=>new Promise((p,g)=>{p=I(p);const{trans:y,values:b,limit:m,query:f}=h,w=m===1/0?void 0:m,{index:E,range:P}=f,x=y.objectStore(u),v=E.isPrimaryKey?x:x.index(E.name),C=r(P);if(m===0)return p({result:[]});if(d){const _=b?v.getAll(C,w):v.getAllKeys(C,w);_.onsuccess=T=>p({result:T.target.result}),_.onerror=Z(g)}else{let _=0;const T=b||!("openKeyCursor"in v)?v.openCursor(C):v.openKeyCursor(C),K=[];T.onsuccess=V=>{const U=T.result;return U?(K.push(b?U.value:U.primaryKey),++_===m?p({result:K}):void U.continue()):p({result:K})},T.onerror=Z(g)}})}(i),openCursor:function({trans:d,values:h,query:p,reverse:g,unique:y}){return new Promise((b,m)=>{b=I(b);const{index:f,range:w}=p,E=d.objectStore(u),P=f.isPrimaryKey?E:E.index(f.name),x=g?y?"prevunique":"prev":y?"nextunique":"next",v=h||!("openKeyCursor"in P)?P.openCursor(r(w),x):P.openKeyCursor(r(w),x);v.onerror=Z(m),v.onsuccess=I(C=>{const _=v.result;if(!_)return void b(null);_.___id=++Vr,_.done=!1;const T=_.continue.bind(_);let K=_.continuePrimaryKey;K&&(K=K.bind(_));const V=_.advance.bind(_),U=()=>{throw new Error("Cursor not stopped")};_.trans=d,_.stop=_.continue=_.continuePrimaryKey=_.advance=()=>{throw new Error("Cursor not started")},_.fail=I(m),_.next=function(){let M=1;return this.start(()=>M--?this.continue():this.stop()).then(()=>this)},_.start=M=>{const Ae=new Promise((G,_e)=>{G=I(G),v.onerror=Z(_e),_.fail=_e,_.stop=Ze=>{_.stop=_.continue=_.continuePrimaryKey=_.advance=U,G(Ze)}}),De=()=>{if(v.result)try{M()}catch(G){_.fail(G)}else _.done=!0,_.start=()=>{throw new Error("Cursor behind last entry")},_.stop()};return v.onsuccess=I(G=>{v.onsuccess=De,De()}),_.continue=T,_.continuePrimaryKey=K,_.advance=V,De(),Ae},b(_)},m)})},count({query:d,trans:h}){const{index:p,range:g}=d;return new Promise((y,b)=>{const m=h.objectStore(u),f=p.isPrimaryKey?m:m.index(p.name),w=r(g),E=w?f.count(w):f.count();E.onsuccess=I(P=>y(P.target.result)),E.onerror=Z(b)})}}}(c)),a={};return o.forEach(c=>a[c.name]=c),{stack:"dbcore",transaction:t.transaction.bind(t),table(c){if(!a[c])throw new Error(`Table '${c}' not found`);return a[c]},MIN_KEY:-1/0,MAX_KEY:Ye(e),schema:s}}function en({_novip:t},e){const n=e.db,r=function(s,i,{IDBKeyRange:o,indexedDB:a},c){return{dbcore:function(u,d){return d.reduce((h,{create:p})=>({...h,...p(h)}),u)}(Gr(i,o,c),s.dbcore)}}(t._middlewares,n,t._deps,e);t.core=r.dbcore,t.tables.forEach(s=>{const i=s.name;t.core.schema.tables.some(o=>o.name===i)&&(s.core=t.core.table(i),t[i]instanceof t.Table&&(t[i].core=s.core))})}function vt({_novip:t},e,n,r){n.forEach(s=>{const i=r[s];e.forEach(o=>{const a=St(o,s);(!a||"value"in a&&a.value===void 0)&&(o===t.Transaction.prototype||o instanceof t.Transaction?q(o,s,{get(){return this.table(s)},set(c){wn(this,s,{value:c,writable:!0,configurable:!0,enumerable:!0})}}):o[s]=new t.Table(s,i))})})}function tn({_novip:t},e){e.forEach(n=>{for(let r in n)n[r]instanceof t.Table&&delete n[r]})}function Hr(t,e){return t._cfg.version-e._cfg.version}function Yr(t,e,n,r){const s=t._dbSchema,i=t._createTransaction("readwrite",t._storeNames,s);i.create(n),i._completion.catch(r);const o=i._reject.bind(i),a=O.transless||O;ce(()=>{O.trans=i,O.transless=a,e===0?(R(s).forEach(c=>{nn(n,c,s[c].primKey,s[c].indexes)}),en(t,n),S.follow(()=>t.on.populate.fire(i)).catch(o)):function({_novip:c},l,u,d){const h=[],p=c._versions;let g=c._dbSchema=sn(c,c.idbdb,d),y=!1;const b=p.filter(f=>f._cfg.version>=l);function m(){return h.length?S.resolve(h.shift()(u.idbtrans)).then(m):S.resolve()}return b.forEach(f=>{h.push(()=>{const w=g,E=f._cfg.dbschema;on(c,w,d),on(c,E,d),g=c._dbSchema=E;const P=rr(w,E);P.add.forEach(v=>{nn(d,v[0],v[1].primKey,v[1].indexes)}),P.change.forEach(v=>{if(v.recreate)throw new j.Upgrade("Not yet support for changing primary key");{const C=d.objectStore(v.name);v.add.forEach(_=>rn(C,_)),v.change.forEach(_=>{C.deleteIndex(_.name),rn(C,_)}),v.del.forEach(_=>C.deleteIndex(_))}});const x=f._cfg.contentUpgrade;if(x&&f._cfg.version>l){en(c,d),u._memoizedTables={},y=!0;let v=Sn(E);P.del.forEach(K=>{v[K]=w[K]}),tn(c,[c.Transaction.prototype]),vt(c,[c.Transaction.prototype],R(v),v),u.schema=v;const C=jt(x);let _;C&&Oe();const T=S.follow(()=>{if(_=x(u),_&&C){var K=ne.bind(null,null);_.then(K,K)}});return _&&typeof _.then=="function"?S.resolve(_):T.then(()=>_)}}),h.push(w=>{(!y||!Rr)&&function(E,P){[].slice.call(P.db.objectStoreNames).forEach(x=>E[x]==null&&P.db.deleteObjectStore(x))}(f._cfg.dbschema,w),tn(c,[c.Transaction.prototype]),vt(c,[c.Transaction.prototype],c._storeNames,c._dbSchema),u.schema=c._dbSchema})}),m().then(()=>{var f,w;w=d,R(f=g).forEach(E=>{w.db.objectStoreNames.contains(E)||nn(w,E,f[E].primKey,f[E].indexes)})})}(t,e,i,n).catch(o)})}function rr(t,e){const n={del:[],add:[],change:[]};let r;for(r in t)e[r]||n.del.push(r);for(r in e){const s=t[r],i=e[r];if(s){const o={name:r,def:i,recreate:!1,del:[],add:[],change:[]};if(""+(s.primKey.keyPath||"")!=""+(i.primKey.keyPath||"")||s.primKey.auto!==i.primKey.auto&&!ft)o.recreate=!0,n.change.push(o);else{const a=s.idxByName,c=i.idxByName;let l;for(l in a)c[l]||o.del.push(l);for(l in c){const u=a[l],d=c[l];u?u.src!==d.src&&o.change.push(d):o.add.push(d)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}else n.add.push([r,i])}return n}function nn(t,e,n,r){const s=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(i=>rn(s,i)),s}function rn(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function sn(t,e,n){const r={};return qe(e.objectStoreNames,0).forEach(s=>{const i=n.objectStore(s);let o=i.keyPath;const a=Zt(er(o),o||"",!1,!1,!!i.autoIncrement,o&&typeof o!="string",!0),c=[];for(let u=0;u<i.indexNames.length;++u){const d=i.index(i.indexNames[u]);o=d.keyPath;var l=Zt(d.name,o,!!d.unique,!!d.multiEntry,!1,o&&typeof o!="string",!1);c.push(l)}r[s]=tr(s,a,c)}),r}function on({_novip:t},e,n){const r=n.db.objectStoreNames;for(let s=0;s<r.length;++s){const i=r[s],o=n.objectStore(i);t._hasGetAll="getAll"in o;for(let a=0;a<o.indexNames.length;++a){const c=o.indexNames[a],l=o.index(c).keyPath,u=typeof l=="string"?l:"["+qe(l).join("+")+"]";if(e[i]){const d=e[i].idxByName[u];d&&(d.name=c,delete e[i].idxByName[u],e[i].idxByName[c]=d)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&D.WorkerGlobalScope&&D instanceof D.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}class Qr{_parseStoresSpec(e,n){R(e).forEach(r=>{if(e[r]!==null){var s=e[r].split(",").map((o,a)=>{const c=(o=o.trim()).replace(/([&*]|\+\+)/g,""),l=/^\[/.test(c)?c.match(/^\[(.*)\]$/)[1].split("+"):c;return Zt(c,l||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),$(l),a===0)}),i=s.shift();if(i.multi)throw new j.Schema("Primary key cannot be multi-valued");s.forEach(o=>{if(o.auto)throw new j.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new j.Schema("Index must have a name and cannot be an empty string")}),n[r]=tr(r,i,s)}})}stores(e){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?W(this._cfg.storesSource,e):e;const r=n._versions,s={};let i={};return r.forEach(o=>{W(s,o._cfg.storesSource),i=o._cfg.dbschema={},o._parseStoresSpec(s,i)}),n._dbSchema=i,tn(n,[n._allTables,n,n.Transaction.prototype]),vt(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],R(i),i),n._storeNames=R(i),this}upgrade(e){return this._cfg.contentUpgrade=Dt(this._cfg.contentUpgrade||A,e),this}}function an(t,e){let n=t._dbNamesDB;return n||(n=t._dbNamesDB=new ve(pt,{addons:[],indexedDB:t,IDBKeyRange:e}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function cn(t){return t&&typeof t.databases=="function"}function ln(t){return ce(function(){return O.letThrough=!0,t()})}function Jr(){var t;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){var n=function(){return indexedDB.databases().finally(e)};t=setInterval(n,100),n()}).finally(function(){return clearInterval(t)}):Promise.resolve()}function Xr(t){const e=t._state,{indexedDB:n}=t._deps;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(()=>e.dbOpenError?F(e.dbOpenError):t);X&&(e.openCanceller._stackHolder=fe()),e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;const r=e.openCanceller;function s(){if(e.openCanceller!==r)throw new j.DatabaseClosed("db.open() was cancelled")}let i=e.dbReadyResolve,o=null,a=!1;const c=()=>new S((l,u)=>{if(s(),!n)throw new j.MissingAPI;const d=t.name,h=e.autoSchema?n.open(d):n.open(d,Math.round(10*t.verno));if(!h)throw new j.MissingAPI;h.onerror=Z(u),h.onblocked=I(t._fireOnBlocked),h.onupgradeneeded=I(p=>{if(o=h.transaction,e.autoSchema&&!t._options.allowEmptyDB){h.onerror=Ge,o.abort(),h.result.close();const y=n.deleteDatabase(d);y.onsuccess=y.onerror=I(()=>{u(new j.NoSuchDatabase(`Database ${d} doesnt exist`))})}else{o.onerror=Z(u);var g=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;a=g<1,t._novip.idbdb=h.result,Yr(t,g/10,o,u)}},u),h.onsuccess=I(()=>{o=null;const p=t._novip.idbdb=h.result,g=qe(p.objectStoreNames);if(g.length>0)try{const b=p.transaction((y=g).length===1?y[0]:y,"readonly");e.autoSchema?function({_novip:m},f,w){m.verno=f.version/10;const E=m._dbSchema=sn(0,f,w);m._storeNames=qe(f.objectStoreNames,0),vt(m,[m._allTables],R(E),E)}(t,p,b):(on(t,t._dbSchema,b),function(m,f){const w=rr(sn(0,m.idbdb,f),m._dbSchema);return!(w.add.length||w.change.some(E=>E.add.length||E.change.length))}(t,b)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),en(t,b)}catch{}var y;We.push(t),p.onversionchange=I(b=>{e.vcFired=!0,t.on("versionchange").fire(b)}),p.onclose=I(b=>{t.on("close").fire(b)}),a&&function({indexedDB:b,IDBKeyRange:m},f){!cn(b)&&f!==pt&&an(b,m).put({name:f}).catch(A)}(t._deps,d),l()},u)}).catch(l=>l&&l.name==="UnknownError"&&e.PR1398_maxLoop>0?(e.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),c()):S.reject(l));return S.race([r,(typeof navigator>"u"?S.resolve():Jr()).then(c)]).then(()=>(s(),e.onReadyBeingFired=[],S.resolve(ln(()=>t.on.ready.fire(t.vip))).then(function l(){if(e.onReadyBeingFired.length>0){let u=e.onReadyBeingFired.reduce(Dt,A);return e.onReadyBeingFired=[],S.resolve(ln(()=>u(t.vip))).then(l)}}))).finally(()=>{e.onReadyBeingFired=null,e.isBeingOpened=!1}).then(()=>t).catch(l=>{e.dbOpenError=l;try{o&&o.abort()}catch{}return r===e.openCanceller&&t._close(),F(l)}).finally(()=>{e.openComplete=!0,i()})}function un(t){var e=i=>t.next(i),n=s(e),r=s(i=>t.throw(i));function s(i){return o=>{var a=i(o),c=a.value;return a.done?c:c&&typeof c.then=="function"?c.then(n,r):$(c)?Promise.all(c).then(n,r):n(c)}}return s(e)()}function Zr(t,e,n){var r=arguments.length;if(r<2)throw new j.InvalidArgument("Too few arguments");for(var s=new Array(r-1);--r;)s[r-1]=arguments[r];return n=s.pop(),[t,En(s),n]}function sr(t,e,n,r,s){return S.resolve().then(()=>{const i=O.transless||O,o=t._createTransaction(e,n,t._dbSchema,r),a={trans:o,transless:i};if(r)o.idbtrans=r.idbtrans;else try{o.create(),t._state.PR1398_maxLoop=3}catch(d){return d.name===At.InvalidState&&t.isOpen()&&--t._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),t._close(),t.open().then(()=>sr(t,e,n,null,s))):F(d)}const c=jt(s);let l;c&&Oe();const u=S.follow(()=>{if(l=s.call(o,o),l)if(c){var d=ne.bind(null,null);l.then(d,d)}else typeof l.next=="function"&&typeof l.throw=="function"&&(l=un(l))},a);return(l&&typeof l.then=="function"?S.resolve(l).then(d=>o.active?d:F(new j.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>l)).then(d=>(r&&o._resolve(),o._completion.then(()=>d))).catch(d=>(o._reject(d),F(d)))})}function wt(t,e,n){const r=$(t)?t.slice():[t];for(let s=0;s<n;++s)r.push(e);return r}const qr={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(t){return{...t,table(e){const n=t.table(e),{schema:r}=n,s={},i=[];function o(u,d,h){const p=Qe(u),g=s[p]=s[p]||[],y=u==null?0:typeof u=="string"?1:u.length,b=d>0,m={...h,isVirtual:b,keyTail:d,keyLength:y,extractKey:qt(u),unique:!b&&h.unique};return g.push(m),m.isPrimaryKey||i.push(m),y>1&&o(y===2?u[0]:u.slice(0,y-1),d+1,h),g.sort((f,w)=>f.keyTail-w.keyTail),m}const a=o(r.primaryKey.keyPath,0,r.primaryKey);s[":id"]=[a];for(const u of r.indexes)o(u.keyPath,0,u);function c(u){const d=u.query.index;return d.isVirtual?{...u,query:{index:d,range:(h=u.query.range,p=d.keyTail,{type:h.type===1?2:h.type,lower:wt(h.lower,h.lowerOpen?t.MAX_KEY:t.MIN_KEY,p),lowerOpen:!0,upper:wt(h.upper,h.upperOpen?t.MIN_KEY:t.MAX_KEY,p),upperOpen:!0})}}:u;var h,p}return{...n,schema:{...r,primaryKey:a,indexes:i,getIndexByKeyPath:function(u){const d=s[Qe(u)];return d&&d[0]}},count:u=>n.count(c(u)),query:u=>n.query(c(u)),openCursor(u){const{keyTail:d,isVirtual:h,keyLength:p}=u.query.index;return h?n.openCursor(c(u)).then(g=>g&&function(y){return Object.create(y,{continue:{value:function(m){m!=null?y.continue(wt(m,u.reverse?t.MAX_KEY:t.MIN_KEY,d)):u.unique?y.continue(y.key.slice(0,p).concat(u.reverse?t.MIN_KEY:t.MAX_KEY,d)):y.continue()}},continuePrimaryKey:{value(m,f){y.continuePrimaryKey(wt(m,t.MAX_KEY,d),f)}},primaryKey:{get:()=>y.primaryKey},key:{get(){const m=y.key;return p===1?m[0]:m.slice(0,p)}},value:{get:()=>y.value}})}(g)):n.openCursor(u)}}}}}};function hn(t,e,n,r){return n=n||{},r=r||"",R(t).forEach(s=>{if(H(e,s)){var i=t[s],o=e[s];if(typeof i=="object"&&typeof o=="object"&&i&&o){const a=Pt(i);a!==Pt(o)?n[r+s]=e[s]:a==="Object"?hn(i,o,n,r+s+"."):i!==o&&(n[r+s]=e[s])}else i!==o&&(n[r+s]=e[s])}else n[r+s]=void 0}),R(e).forEach(s=>{H(t,s)||(n[r+s]=e[s])}),n}const es={stack:"dbcore",name:"HooksMiddleware",level:2,create:t=>({...t,table(e){const n=t.table(e),{primaryKey:r}=n.schema;return{...n,mutate(i){const o=O.trans,{deleting:a,creating:c,updating:l}=o.table(e).hook;switch(i.type){case"add":if(c.fire===A)break;return o._promise("readwrite",()=>u(i),!0);case"put":if(c.fire===A&&l.fire===A)break;return o._promise("readwrite",()=>u(i),!0);case"delete":if(a.fire===A)break;return o._promise("readwrite",()=>u(i),!0);case"deleteRange":if(a.fire===A)break;return o._promise("readwrite",()=>function(h){return d(h.trans,h.range,1e4)}(i),!0)}return n.mutate(i);function u(h){const p=O.trans,g=h.keys||function(y,b){return b.type==="delete"?b.keys:b.keys||b.values.map(y.extractKey)}(r,h);if(!g)throw new Error("Keys missing");return(h=h.type==="add"||h.type==="put"?{...h,keys:g}:{...h}).type!=="delete"&&(h.values=[...h.values]),h.keys&&(h.keys=[...h.keys]),function(y,b,m){return b.type==="add"?Promise.resolve([]):y.getMany({trans:b.trans,keys:m,cache:"immutable"})}(n,h,g).then(y=>{const b=g.map((m,f)=>{const w=y[f],E={onerror:null,onsuccess:null};if(h.type==="delete")a.fire.call(E,m,w,p);else if(h.type==="add"||w===void 0){const P=c.fire.call(E,m,h.values[f],p);m==null&&P!=null&&(m=P,h.keys[f]=m,r.outbound||J(h.values[f],r.keyPath,m))}else{const P=hn(w,h.values[f]),x=l.fire.call(E,P,m,w,p);if(x){const v=h.values[f];Object.keys(x).forEach(C=>{H(v,C)?v[C]=x[C]:J(v,C,x[C])})}}return E});return n.mutate(h).then(({failures:m,results:f,numFailures:w,lastResult:E})=>{for(let P=0;P<g.length;++P){const x=f?f[P]:g[P],v=b[P];x==null?v.onerror&&v.onerror(m[P]):v.onsuccess&&v.onsuccess(h.type==="put"&&y[P]?h.values[P]:x)}return{failures:m,results:f,numFailures:w,lastResult:E}}).catch(m=>(b.forEach(f=>f.onerror&&f.onerror(m)),Promise.reject(m)))})}function d(h,p,g){return n.query({trans:h,values:!1,query:{index:r,range:p},limit:g}).then(({result:y})=>u({type:"delete",keys:y,trans:h}).then(b=>b.numFailures>0?Promise.reject(b.failures[0]):y.length<g?{failures:[],numFailures:0,lastResult:void 0}:d(h,{...p,lower:y[y.length-1],lowerOpen:!0},g)))}}}}})};function ir(t,e,n){try{if(!e||e.keys.length<t.length)return null;const r=[];for(let s=0,i=0;s<e.keys.length&&i<t.length;++s)z(e.keys[s],t[i])===0&&(r.push(n?Te(e.values[s]):e.values[s]),++i);return r.length===t.length?r:null}catch{return null}}const ts={stack:"dbcore",level:-1,create:t=>({table:e=>{const n=t.table(e);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const s=ir(r.keys,r.trans._cache,r.cache==="clone");return s?S.resolve(s):n.getMany(r).then(i=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?Te(i):i},i))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function dn(t){return!("from"in t)}const se=function(t,e){if(!this){const n=new se;return t&&"d"in t&&W(n,t),n}W(this,arguments.length?{d:1,from:t,to:arguments.length>1?e:t}:{d:0})};function Je(t,e,n){const r=z(e,n);if(isNaN(r))return;if(r>0)throw RangeError();if(dn(t))return W(t,{from:e,to:n,d:1});const s=t.l,i=t.r;if(z(n,t.from)<0)return s?Je(s,e,n):t.l={from:e,to:n,d:1,l:null,r:null},or(t);if(z(e,t.to)>0)return i?Je(i,e,n):t.r={from:e,to:n,d:1,l:null,r:null},or(t);z(e,t.from)<0&&(t.from=e,t.l=null,t.d=i?i.d+1:1),z(n,t.to)>0&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1);const o=!t.r;s&&!t.l&&_t(t,s),i&&o&&_t(t,i)}function _t(t,e){dn(e)||function n(r,{from:s,to:i,l:o,r:a}){Je(r,s,i),o&&n(r,o),a&&n(r,a)}(t,e)}function ns(t,e){const n=fn(e);let r=n.next();if(r.done)return!1;let s=r.value;const i=fn(t);let o=i.next(s.from),a=o.value;for(;!r.done&&!o.done;){if(z(a.from,s.to)<=0&&z(a.to,s.from)>=0)return!0;z(s.from,a.from)<0?s=(r=n.next(a.from)).value:a=(o=i.next(s.from)).value}return!1}function fn(t){let e=dn(t)?null:{s:0,n:t};return{next(n){const r=arguments.length>0;for(;e;)switch(e.s){case 0:if(e.s=1,r)for(;e.n.l&&z(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||z(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 or(t){var e,n;const 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),s=r>1?"r":r<-1?"l":"";if(s){const i=s==="r"?"l":"r",o={...t},a=t[s];t.from=a.from,t.to=a.to,t[s]=a[s],o[s]=a[i],t[i]=o,o.d=ar(o)}t.d=ar(t)}function ar({r:t,l:e}){return(t?e?Math.max(t.d,e.d):t.d:e?e.d:0)+1}ke(se.prototype,{add(t){return _t(this,t),this},addKey(t){return Je(this,t,t),this},addKeys(t){return t.forEach(e=>Je(this,e,e)),this},[Ot](){return fn(this)}});const rs={stack:"dbcore",level:0,create:t=>{const e=t.schema.name,n=new se(t.MIN_KEY,t.MAX_KEY);return{...t,table:r=>{const s=t.table(r),{schema:i}=s,{primaryKey:o}=i,{extractKey:a,outbound:c}=o,l={...s,mutate:h=>{const p=h.trans,g=p.mutatedParts||(p.mutatedParts={}),y=x=>{const v=`idb://${e}/${r}/${x}`;return g[v]||(g[v]=new se)},b=y(""),m=y(":dels"),{type:f}=h;let[w,E]=h.type==="deleteRange"?[h.range]:h.type==="delete"?[h.keys]:h.values.length<50?[[],h.values]:[];const P=h.trans._cache;return s.mutate(h).then(x=>{if($(w)){f!=="delete"&&(w=x.results),b.addKeys(w);const v=ir(w,P);v||f==="add"||m.addKeys(w),(v||E)&&function(C,_,T,K){function V(U){const M=C(U.name||"");function Ae(G){return G!=null?U.extractKey(G):null}const De=G=>U.multiEntry&&$(G)?G.forEach(_e=>M.addKey(_e)):M.addKey(G);(T||K).forEach((G,_e)=>{const Ze=T&&Ae(T[_e]),vn=K&&Ae(K[_e]);z(Ze,vn)!==0&&(Ze!=null&&De(Ze),vn!=null&&De(vn))})}_.indexes.forEach(V)}(y,i,v,E)}else if(w){const v={from:w.lower,to:w.upper};m.add(v),b.add(v)}else b.add(n),m.add(n),i.indexes.forEach(v=>y(v.name).add(n));return x})}},u=({query:{index:h,range:p}})=>{var g,y;return[h,new se((g=p.lower)!==null&&g!==void 0?g:t.MIN_KEY,(y=p.upper)!==null&&y!==void 0?y:t.MAX_KEY)]},d={get:h=>[o,new se(h.key)],getMany:h=>[o,new se().addKeys(h.keys)],count:u,query:u,openCursor:u};return R(d).forEach(h=>{l[h]=function(p){const{subscr:g}=O;if(g){const y=E=>{const P=`idb://${e}/${r}/${E}`;return g[P]||(g[P]=new se)},b=y(""),m=y(":dels"),[f,w]=d[h](p);if(y(f.name||"").add(w),!f.isPrimaryKey){if(h!=="count"){const E=h==="query"&&c&&p.values&&s.query({...p,values:!1});return s[h].apply(this,arguments).then(P=>{if(h==="query"){if(c&&p.values)return E.then(({result:v})=>(b.addKeys(v),P));const x=p.values?P.result.map(a):P.result;p.values?b.addKeys(x):m.addKeys(x)}else if(h==="openCursor"){const x=P,v=p.values;return x&&Object.create(x,{key:{get:()=>(m.addKey(x.primaryKey),x.key)},primaryKey:{get(){const C=x.primaryKey;return m.addKey(C),C}},value:{get:()=>(v&&b.addKey(x.primaryKey),x.value)}})}return P})}m.add(n)}}return s[h].apply(this,arguments)}}),l}}}};class ve{constructor(e,n){this._middlewares={},this.verno=0;const r=ve.dependencies;this._options=n={addons:ve.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:s}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const i={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:A,dbReadyPromise:null,cancelOpen:A,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var o;i.dbReadyPromise=new S(a=>{i.dbReadyResolve=a}),i.openCanceller=new S((a,c)=>{i.cancelOpen=c}),this._state=i,this.name=e,this.on=ze(this,"populate","blocked","versionchange","close",{ready:[Dt,A]}),this.on.ready.subscribe=_n(this.on.ready.subscribe,a=>(c,l)=>{ve.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||S.resolve().then(c),l&&a(c);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(c),l&&a(c);else{a(c);const d=this;l||a(function h(){d.on.ready.unsubscribe(c),d.on.ready.unsubscribe(h)})}})}),this.Collection=(o=this,Ve($r.prototype,function(a,c){this.db=o;let l=Hn,u=null;if(c)try{l=c()}catch(g){u=g}const d=a._ctx,h=d.table,p=h.hook.reading.fire;this._ctx={table:h,index:d.index,isPrimKey:!d.index||h.schema.primKey.keyPath&&d.index===h.schema.primKey.name,range:l,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:p!==Re?p:null}})),this.Table=function(a){return Ve(Nr.prototype,function(c,l,u){this.db=a,this._tx=u,this.name=c,this.schema=l,this.hook=a._allTables[c]?a._allTables[c].hook:ze(null,{creating:[Or,A],reading:[Pr,Re],updating:[Cr,A],deleting:[jr,A]})})}(this),this.Transaction=function(a){return Ve(zr.prototype,function(c,l,u,d,h){this.db=a,this.mode=c,this.storeNames=l,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=ze(this,"complete","error","abort"),this.parent=h||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 S((p,g)=>{this._resolve=p,this._reject=g}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var g=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):g&&this.idbtrans&&this.idbtrans.abort(),F(p)})})}(this),this.Version=function(a){return Ve(Qr.prototype,function(c){this.db=a,this._cfg={version:c,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(a){return Ve(qn.prototype,function(c,l,u){this.db=a,this._ctx={table:c,index:l===":id"?null:l,or:u};const d=a._deps.indexedDB;if(!d)throw new j.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(h,p)=>d.cmp(p,h),this._max=(h,p)=>d.cmp(h,p)>0?h:p,this._min=(h,p)=>d.cmp(h,p)<0?h:p,this._IDBKeyRange=a._deps.IDBKeyRange})}(this),this.on("versionchange",a=>{a.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",a=>{!a.newVersion||a.newVersion<a.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${a.oldVersion/10}`)}),this._maxKey=Ye(n.IDBKeyRange),this._createTransaction=(a,c,l,u)=>new this.Transaction(a,c,l,this._options.chromeTransactionDurability,u),this._fireOnBlocked=a=>{this.on("blocked").fire(a),We.filter(c=>c.name===this.name&&c!==this&&!c._state.vcFired).map(c=>c.on("versionchange").fire(a))},this.use(qr),this.use(es),this.use(rs),this.use(ts),this.vip=Object.create(this,{_vip:{value:!0}}),s.forEach(a=>a(this))}version(e){if(isNaN(e)||e<.1)throw new j.Type("Given version is not a positive number");if(e=Math.round(10*e)/10,this.idbdb||this._state.isBeingOpened)throw new j.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,e);const n=this._versions;var r=n.filter(s=>s._cfg.version===e)[0];return r||(r=new this.Version(e),n.push(r),n.sort(Hr),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(e){return this.idbdb&&(this._state.openComplete||O.letThrough||this._vip)?e():new S((n,r)=>{if(this._state.openComplete)return r(new j.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new j.DatabaseClosed);this.open().catch(A)}this._state.dbReadyPromise.then(n,r)}).then(e)}use({stack:e,create:n,level:r,name:s}){s&&this.unuse({stack:e,name:s});const i=this._middlewares[e]||(this._middlewares[e]=[]);return i.push({stack:e,create:n,level:r??10,name:s}),i.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(s=>r?s.create!==r:!!n&&s.name!==n)),this}open(){return Xr(this)}_close(){const e=this._state,n=We.indexOf(this);if(n>=0&&We.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}e.dbReadyPromise=new S(r=>{e.dbReadyResolve=r}),e.openCanceller=new S((r,s)=>{e.cancelOpen=s})}close(){this._close();const e=this._state;this._options.autoOpen=!1,e.dbOpenError=new j.DatabaseClosed,e.isBeingOpened&&e.cancelOpen(e.dbOpenError)}delete(){const e=arguments.length>0,n=this._state;return new S((r,s)=>{const i=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=I(()=>{(function({indexedDB:a,IDBKeyRange:c},l){!cn(a)&&l!==pt&&an(a,c).delete(l).catch(A)})(this._deps,this.name),r()}),o.onerror=Z(s),o.onblocked=this._fireOnBlocked};if(e)throw new j.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(i):i()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const e=this._state.dbOpenError;return e&&e.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return R(this._allTables).map(e=>this._allTables[e])}transaction(){const e=Zr.apply(this,arguments);return this._transaction.apply(this,e)}_transaction(e,n,r){let s=O.trans;s&&s.db===this&&e.indexOf("!")===-1||(s=null);const i=e.indexOf("?")!==-1;let o,a;e=e.replace("!","").replace("?","");try{if(a=n.map(l=>{var u=l instanceof this.Table?l.name:l;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),e=="r"||e===Ht)o=Ht;else{if(e!="rw"&&e!=Yt)throw new j.InvalidArgument("Invalid transaction mode: "+e);o=Yt}if(s){if(s.mode===Ht&&o===Yt){if(!i)throw new j.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");s=null}s&&a.forEach(l=>{if(s&&s.storeNames.indexOf(l)===-1){if(!i)throw new j.SubTransaction("Table "+l+" not included in parent transaction.");s=null}}),i&&s&&!s.active&&(s=null)}}catch(l){return s?s._promise(null,(u,d)=>{d(l)}):F(l)}const c=sr.bind(null,this,o,a,s,r);return s?s._promise(o,c,"lock"):O.trans?je(O.transless,()=>this._whenReady(c)):this._whenReady(c)}table(e){if(!H(this._allTables,e))throw new j.InvalidTable(`Table ${e} does not exist`);return this._allTables[e]}}const ss=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class is{constructor(e){this._subscribe=e}subscribe(e,n,r){return this._subscribe(e&&typeof e!="function"?e:{next:e,error:n,complete:r})}[ss](){return this}}function cr(t,e){return R(e).forEach(n=>{_t(t[n]||(t[n]=new se),e[n])}),t}function os(t){let e,n=!1;const r=new is(s=>{const i=jt(t);let o=!1,a={},c={};const l={get closed(){return o},unsubscribe:()=>{o=!0,de.storagemutated.unsubscribe(p)}};s.start&&s.start(l);let u=!1,d=!1;function h(){return R(c).some(y=>a[y]&&ns(a[y],c[y]))}const p=y=>{cr(a,y),h()&&g()},g=()=>{if(u||o)return;a={};const y={},b=function(m){i&&Oe();const f=()=>ce(t,{subscr:m,trans:null}),w=O.trans?je(O.transless,f):f();return i&&w.then(ne,ne),w}(y);d||(de(He,p),d=!0),u=!0,Promise.resolve(b).then(m=>{n=!0,e=m,u=!1,o||(h()?g():(a={},c=y,s.next&&s.next(m)))},m=>{u=!1,n=!1,s.error&&s.error(m),l.unsubscribe()})};return g(),l});return r.hasValue=()=>n,r.getValue=()=>e,r}let pn;try{pn={indexedDB:D.indexedDB||D.mozIndexedDB||D.webkitIndexedDB||D.msIndexedDB,IDBKeyRange:D.IDBKeyRange||D.webkitIDBKeyRange}}catch{pn={indexedDB:null,IDBKeyRange:null}}const we=ve;function kt(t){let e=ie;try{ie=!0,de.storagemutated.fire(t)}finally{ie=e}}ke(we,{...tt,delete:t=>new we(t,{addons:[]}).delete(),exists:t=>new we(t,{addons:[]}).open().then(e=>(e.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(t){try{return function({indexedDB:e,IDBKeyRange:n}){return cn(e)?Promise.resolve(e.databases()).then(r=>r.map(s=>s.name).filter(s=>s!==pt)):an(e,n).toCollection().primaryKeys()}(we.dependencies).then(t)}catch{return F(new j.MissingAPI)}},defineClass:()=>function(t){W(this,t)},ignoreTransaction:t=>O.trans?je(O.transless,t):t(),vip:ln,async:function(t){return function(){try{var e=un(t.apply(this,arguments));return e&&typeof e.then=="function"?e:S.resolve(e)}catch(n){return F(n)}}},spawn:function(t,e,n){try{var r=un(t.apply(n,e||[]));return r&&typeof r.then=="function"?r:S.resolve(r)}catch(s){return F(s)}},currentTransaction:{get:()=>O.trans||null},waitFor:function(t,e){const n=S.resolve(typeof t=="function"?we.ignoreTransaction(t):t).timeout(e||6e4);return O.trans?O.trans.waitFor(n):n},Promise:S,debug:{get:()=>X,set:t=>{On(t,t==="dexie"?()=>!0:Gn)}},derive:xe,extend:W,props:ke,override:_n,Events:ze,on:de,liveQuery:os,extendObservabilitySet:cr,getByKeyPath:ee,setByKeyPath:J,delByKeyPath:function(t,e){typeof e=="string"?J(t,e,void 0):"length"in e&&[].map.call(e,function(n){J(t,n,void 0)})},shallowClone:Sn,deepClone:Te,getObjectDiff:hn,cmp:z,asap:kn,minKey:Gt,addons:[],connections:We,errnames:At,dependencies:pn,semVer:zn,version:zn.split(".").map(t=>parseInt(t)).reduce((t,e,n)=>t+e/Math.pow(10,2*n))}),we.maxKey=Ye(we.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(de(He,t=>{if(!ie){let e;ft?(e=document.createEvent("CustomEvent"),e.initCustomEvent(he,!0,!0,t)):e=new CustomEvent(he,{detail:t}),ie=!0,dispatchEvent(e),ie=!1}}),addEventListener(he,({detail:t})=>{ie||kt(t)}));let ie=!1;if(typeof BroadcastChannel<"u"){const t=new BroadcastChannel(he);typeof t.unref=="function"&&t.unref(),de(He,e=>{ie||t.postMessage(e)}),t.onmessage=e=>{e.data&&kt(e.data)}}else if(typeof self<"u"&&typeof navigator<"u"){de(He,e=>{try{ie||(typeof localStorage<"u"&&localStorage.setItem(he,JSON.stringify({trig:Math.random(),changedParts:e})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:he,changedParts:e})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",e=>{if(e.key===he){const n=JSON.parse(e.newValue);n&&kt(n.changedParts)}});const t=self.document&&navigator.serviceWorker;t&&t.addEventListener("message",function({data:e}){e&&e.type===he&&kt(e.changedParts)})}S.rejectionMapper=function(t,e){if(!t||t instanceof Ee||t instanceof TypeError||t instanceof SyntaxError||!t.name||!An[t.name])return t;var n=new An[t.name](e||t.message,t);return"stack"in t&&q(n,"stack",{get:function(){return this.inner.stack}}),n},On(X,Gn);const B=t=>{let e=`${t.type}.${t.topics}`;return t.hasOwnProperty("order")&&(e+=`.${t.order}`),t.hasOwnProperty("period")&&(e+=`.${t.period}`),e};function Xe(t,e){var n;switch(t.moderation){case"before":const r=new Date,s=(n=t.beforeTime)==null?void 0:n.split(":"),i=parseInt(s?s[0]:"00"),o=parseInt(s?s[1]:"00"),a=parseInt(s?s[2]:"00");e.before=r.setHours(i,o,a,0)/1e3,e.hasOwnProperty("period")||(e.period=r.getDay()===1?72:24);break;case"delayed":t.delay&&t.delay>0&&(e.delay=`${t.delay}`);break;case"approved":e.approved="1";break;default:t.period!==0&&(e.period=t.period)}return e}class as{constructor(e){k(this,"db");k(this,"subscribers",[]);k(this,"options");k(this,"setCloud",async(e,n)=>{n!==""&&await this.db.table("cloud").put({id:e.widget,dashboard_id:e.dashboard,data:n})});k(this,"getCloud",async e=>{const n=await this.db.table(oe).where({id:e.widget}).last();return n.presentation=(e==null?void 0:e.presentation)||"not set",n.slide=(e==null?void 0:e.slide)||"not set",n??{data:null}});k(this,"setSeries",async(e,n)=>{n!==""&&await this.db.table(xt).put({id:e.widget,dashboard_id:e.dashboard,data:n.data})});k(this,"getSeries",async e=>{const n=await this.db.table(xt).where({id:e.widget}).last();return n.presentation=(e==null?void 0:e.presentation)||"not set",n.slide=(e==null?void 0:e.slide)||"not set",n??{data:null}});k(this,"setMessages",async(e,n)=>{const r=n.title;n.messages.forEach(s=>{var i,o,a;this.db.table(N).put({id:s.id,utc:s.utc,data:s}),this.db.table(ur).put({widget_id:e.widget,message_id:s.id,dashboard_id:e.dashboard,title:r,engagement:(i=s.dynamics)==null?void 0:i.engagement,impressions:(o=s.dynamics)==null?void 0:o.semrush_visits,reach:(a=s.dynamics)==null?void 0:a.potential_reach,sentiment:s.topics[0].sentiment,utc:s.utc})})});k(this,"getMessages",async e=>{const n=l=>l.widget_id===e.widget,r=l=>l.utc>((e==null?void 0:e.since)||0),s=l=>!l.hasOwnProperty("visible")||(l==null?void 0:l.visible)!==0,i=await this.db.table("topics").orderBy("utc").reverse().filter(n).filter(r).filter(s).limit((e==null?void 0:e.limit)??25).toArray(),o=i[0].title||"No results",a=i.map(l=>l.message_id),c=await this.db.table("messages").where("id").anyOf(a).toArray().then(l=>l.sort(function(u,d){return d.utc-u.utc}));return{data:{presentation:(e==null?void 0:e.presentation)||"not set",slide:(e==null?void 0:e.slide)||"not set",messages:c.map(l=>l.data),title:o,topics:[e.dashboard,e.widget].join("-"),query:e}}});k(this,"cleanMessages",async e=>{const n=Date.now()/1e3,r=s=>s.utc<e-n;await this.db.table("topics").orderBy("utc").filter(r).modify((s,i)=>{delete i.value})});k(this,"subscribe",e=>{var r;if(e.widget===void 0){const s=(r=e.topics)==null?void 0:r.split("-");e.dashboard=s?s[0]:"",e.widget=s?s[1]:""}this.subscribers.filter(s=>s.widget==e.widget).length>0||(e.type===N&&(e=Xe(this.options,e)),console.log("[storage] subscribe",e),this.subscribers.push(e))});this.options=e,this.db=new ve(e.app),this.db.version(2).stores({player:"id,title,name,location",monitor:"id,player_id,cols,rows,order,width,height,physicalwidth,physicalheight,devicePixelRatio,screenLeft,screenTop,orientation,monitor",display:"id,monitor_id,presentation_id,colstart,colend,rowstart,rowend",channel:"id,slide_index",presentation:"id,name,data",cloud:"id,dashboard_id,data",messages:"id,utc,visible,data",series:"id,dashboard_id,data",topics:"[widget_id+message_id],widget_id,dashboard_id,title,engagement,impressions,reach,sentiment,visible,utc",widgets:"id,dashboard_id,type"}),this.db.open()}getSubscribers(){return this.subscribers}}function mn(t){return new Promise((e,n)=>{t.oncomplete=t.onsuccess=()=>e(t.result),t.onabort=t.onerror=()=>n(t.error)})}function cs(t,e){const n=indexedDB.open(t);n.onupgradeneeded=()=>n.result.createObjectStore(e);const r=mn(n);return(s,i)=>r.then(o=>i(o.transaction(e,s).objectStore(e)))}let yn;function lr(){return yn||(yn=cs("keyval-store","keyval")),yn}function gn(t,e=lr()){return e("readonly",n=>mn(n.get(t)))}function bn(t,e,n=lr()){return n("readwrite",r=>(r.put(e,t),mn(r.transaction)))}class ls{constructor(e){k(this,"subscribers",[]);k(this,"options");k(this,"setCloud",async(e,n)=>{const r=B(e);await bn(r,n)});k(this,"getCloud",async e=>{const n=B(e);return await gn(n)});k(this,"setSeries",async(e,n)=>{const r=B(e);await bn(r,n)});k(this,"getSeries",async e=>{const n=B(e);return await gn(n)});k(this,"setMessages",async(e,n)=>{const r=B(e);await bn(r,n)});k(this,"getMessages",async e=>{const n=B(e);return await gn(n)});k(this,"cleanMessages",async e=>{console.log("cleanMessages not implemented for ",this.options.storage)});k(this,"subscribe",e=>{var r;if(e.widget===void 0){const s=(r=e.topics)==null?void 0:r.split("-");e.dashboard=s?s[0]:"",e.widget=s?s[1]:""}e.type==="messages"&&(e=Xe(this.options,e)),!this.subscribers.filter(s=>s.widget==e.widget).length&&this.subscribers.push(e)});this.options=e}getSubscribers(){return this.subscribers}}class us{constructor(e){k(this,"subscribers",[]);k(this,"options");k(this,"setCloud",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.localStorage.setObject(r,n))})});k(this,"getCloud",async e=>{const n=B(e);return new Promise(async r=>{r(window.localStorage.getObject(n))})});k(this,"setSeries",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.localStorage.setObject(r,n))})});k(this,"getSeries",async e=>{const n=B(e);return new Promise(async r=>{r(window.localStorage.getObject(n))})});k(this,"setMessages",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.localStorage.setObject(r,n))})});k(this,"getMessages",async e=>{const n=B(e);return new Promise(async r=>{r(window.localStorage.getObject(n))})});k(this,"cleanMessages",async e=>{console.log("cleanMessages not implemented for ",this.options.storage)});k(this,"setWidget",async e=>{let n=`widget.${e.widget}`;return new Promise(async r=>{r(window.localStorage.setObject(n,e))})});k(this,"subscribe",e=>{var r;if(e.widget===void 0){const s=(r=e.topics)==null?void 0:r.split("-");e.dashboard=s?s[0]:"",e.widget=s?s[1]:""}e.type===N&&(e=Xe(this.options,e)),!this.subscribers.filter(s=>s.widget==e.widget).length&&this.subscribers.push(e)});this.options=e,Storage.prototype.setObject=function(n,r){this.setItem(n,JSON.stringify(r))},Storage.prototype.getObject=function(n){const r=this.getItem(n);return r&&JSON.parse(r)}}getSubscribers(){return this.subscribers}}class hs{constructor(e){k(this,"subscribers",[]);k(this,"options");k(this,"setCloud",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.sessionStorage.setObject(r,n))})});k(this,"getCloud",async e=>{const n=B(e);return new Promise(async r=>{r(window.sessionStorage.getObject(n))})});k(this,"setSeries",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.sessionStorage.setObject(r,n))})});k(this,"getSeries",async e=>{const n=B(e);return new Promise(async r=>{r(window.sessionStorage.getObject(n))})});k(this,"setMessages",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.sessionStorage.setObject(r,n))})});k(this,"getMessages",async e=>{const n=B(e);return new Promise(async r=>{r(window.sessionStorage.getObject(n))})});k(this,"cleanMessages",async e=>{console.log("cleanMessages not implemented for ",this.options.storage)});k(this,"setWidget",async e=>{let n=`widget.${e.widget}`;return new Promise(async r=>{r(window.sessionStorage.setObject(n,e))})});k(this,"subscribe",e=>{var r;if(e.widget===void 0){const s=(r=e.topics)==null?void 0:r.split("-");e.dashboard=s?s[0]:"",e.widget=s?s[1]:""}e.type===N&&(e=Xe(this.options,e)),!this.subscribers.filter(s=>s.widget==e.widget).length&&this.subscribers.push(e)});this.options=e,Storage.prototype.setObject=function(n,r){this.setItem(n,JSON.stringify(r))},Storage.prototype.getObject=function(n){const r=this.getItem(n);return r&&JSON.parse(r)}}getSubscribers(){return this.subscribers}}class ds{constructor(e){k(this,"subscribers",[]);k(this,"options");k(this,"setCloud",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.BuzzCasting.WidgetData[r]=n)})});k(this,"getCloud",async e=>{const n=B(e);return new Promise(async r=>{r(window.localStorage.getObject(n))})});k(this,"setSeries",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.localStorage.setObject(r,n))})});k(this,"getSeries",async e=>{const n=B(e);return new Promise(async r=>{r(window.localStorage.getObject(n))})});k(this,"setMessages",async(e,n)=>{const r=B(e);return new Promise(async s=>{s(window.localStorage.setObject(r,n))})});k(this,"getMessages",async e=>{const n=B(e);return new Promise(async r=>{r(window.localStorage.getObject(n))})});k(this,"cleanMessages",async e=>{console.log("cleanMessages not implemented for ",this.options.storage)});k(this,"setWidget",async e=>{let n=`widget.${e.widget}`;return new Promise(async r=>{r(window.localStorage.setObject(n,e))})});k(this,"subscribe",e=>{var r;if(e.widget===void 0){const s=(r=e.topics)==null?void 0:r.split("-");e.dashboard=s?s[0]:"",e.widget=s?s[1]:""}e.type===N&&(e=Xe(this.options,e)),!this.subscribers.filter(s=>s.widget==e.widget).length&&this.subscribers.push(e)});this.options=e,window.BuzzCasting.WidgetData=new Set}getSubscribers(){return this.subscribers}}class fs{constructor(e){k(this,"sm");k(this,"api");k(this,"bc");k(this,"options");k(this,"update",async()=>{var r;const e=(r=this.sm)==null?void 0:r.getSubscribers();if((e==null?void 0:e.length)===0)return;const n=[];e==null||e.forEach(s=>{n.push(this.api.get(s))}),await Promise.allSettled(n).then(s=>s.forEach(i=>{var o,a,c;if(i.status==="fulfilled"){const l=i.value;switch(l.query.type){case N:(o=this.sm)==null||o.setMessages(l.query,l.data);break;case oe:(a=this.sm)==null||a.setCloud(l.query,l.data);break;case xt:(c=this.sm)==null||c.setSeries(l.query,l.data);break;default:console.warn(`data type ${l.query.type} unknown`)}console.debug("[store]",l.data.title??l.query.widget),this.bc.postMessage({event:"widget-update",data:l.query})}else console.warn("[store error]")}))});k(this,"hide",e=>{this.api.hideMessage(e)});k(this,"actions",async e=>{var n;switch(e.data.event){case"subscribe":(n=this.sm)==null||n.subscribe(e.data.data);break;case"update":console.debug("[sm] update",e.data),await this.update();break}});k(this,"getCloud",async e=>{var n;return await((n=this.sm)==null?void 0:n.getCloud(e))});k(this,"getSeries",async e=>{var n;return await((n=this.sm)==null?void 0:n.getSeries(e))});k(this,"getMessages",async e=>{var n;return await((n=this.sm)==null?void 0:n.getMessages(e))});k(this,"cleanMessages",async()=>{var n,r;const e=((n=this.options)==null?void 0:n.retention)||345600;return await((r=this.sm)==null?void 0:r.cleanMessages(e))});k(this,"getSubscribers",async()=>{var e;return await((e=this.sm)==null?void 0:e.getSubscribers())});switch(this.options=e,this.bc=new BroadcastChannel(e.app),console.debug("[sm] broadcast channel",e.app),this.bc.onmessage=n=>{this.actions(n)},this.bc.postMessage({event:"sm-init",data:{}}),this.api=new Q(e),e.storage){case pr:this.sm=new as(e);break;case dr:this.sm=new hs(e);break;case fr:this.sm=new us(e);break;case hr:this.sm=new ls(e);break;case mr:this.sm=new ds(e);break;default:this.sm=null}}}return fs});
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "buzzcasting-storage",
|
|
3
|
+
"author": {
|
|
4
|
+
"name": "Mark Tamis, TouchFlows SAS",
|
|
5
|
+
"email": "mark.tamis@touchflows.com"
|
|
6
|
+
},
|
|
7
|
+
"type": "module",
|
|
8
|
+
"version": "1.0.3",
|
|
9
|
+
"private": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/buzzcasting-storage.js",
|
|
13
|
+
"require": "./dist/buzzcasting-storage.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"main": "./dist/buzzcasting-storage.cjs",
|
|
17
|
+
"module": "./dist/buzzcasting-storage.js",
|
|
18
|
+
"types": "./dist/buzzcasting-storage.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@antfu/eslint-config": "^2.6.4",
|
|
24
|
+
"@commitlint/cli": "^18.6.0",
|
|
25
|
+
"@commitlint/config-conventional": "^18.6.0",
|
|
26
|
+
"@types/node": "^20.11.17",
|
|
27
|
+
"@vitest/coverage-v8": "^1.2.2",
|
|
28
|
+
"camelcase": "^8.0.0",
|
|
29
|
+
"changelogen": "^0.5.5",
|
|
30
|
+
"eslint": "^8.56.0",
|
|
31
|
+
"husky": "^9.0.10",
|
|
32
|
+
"lint-staged": "^15.2.2",
|
|
33
|
+
"typescript": "^5.3.3",
|
|
34
|
+
"vite": "^5.1.1",
|
|
35
|
+
"vite-plugin-dts": "^3.7.2",
|
|
36
|
+
"vitest": "^1.2.2"
|
|
37
|
+
},
|
|
38
|
+
"lint-staged": {
|
|
39
|
+
"*.ts": "pnpm run lint"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"dexie": "^3.2.5",
|
|
43
|
+
"idb-keyval": "^6.2.1"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"dev": "vite",
|
|
47
|
+
"build": "tsc && vite build",
|
|
48
|
+
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
|
49
|
+
"lint": "eslint . --fix",
|
|
50
|
+
"test": "vitest --run",
|
|
51
|
+
"test:watch": "vitest",
|
|
52
|
+
"test:coverage": "vitest --coverage"
|
|
53
|
+
}
|
|
54
|
+
}
|