snap-records 1.1.0
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/README.md +471 -0
- package/dist/index.d.ts +322 -0
- package/dist/snap-records.css +1 -0
- package/dist/snap-records.css.map +1 -0
- package/dist/snap-records.es.js +7325 -0
- package/dist/snap-records.es.js.map +1 -0
- package/dist/snap-records.umd.js +2 -0
- package/dist/snap-records.umd.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).SnapRecords={})}(this,function(t){"use strict";var e,n,r,i,s,a,o,l,c,u,h,d,f,p,m,g,y,v,b,w,_,C,S,E,O,x,k,P,A,R,T,F,M,D,I,L,N,j,K,W,B,q,z,U,H,$,G,V,Y,X,Q,J,Z,tt,et,nt,rt,it,st,at,ot,lt,ct,ut,ht,dt,ft,pt,mt,gt,yt,vt,bt,wt,_t,Ct,St,Et,Ot,xt,kt,Pt,At,Rt,Tt,Ft,Mt,Dt,It,Lt,Nt,jt,Kt,Wt,Bt,qt,zt,Ut,Ht,$t,Gt,Vt,Yt,Xt,Qt,Jt,Zt,te,ee,ne,re,ie,se,ae,oe,le,ce,ue,he,de,fe,pe=Object.defineProperty,me=t=>{throw TypeError(t)},ge=(t,e,n)=>((t,e,n)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n)(t,"symbol"!=typeof e?e+"":e,n),ye=(t,e,n)=>e.has(t)||me("Cannot "+n),ve=(t,e,n)=>(ye(t,e,"read from private field"),n?n.call(t):e.get(t)),be=(t,e,n)=>e.has(t)?me("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),we=(t,e,n,r)=>(ye(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n),_e=(t,e,n)=>(ye(t,e,"access private method"),n),Ce=(t,e,n,r)=>({set _(r){we(t,e,r,n)},get _(){return ve(t,e,r)}}),Se=(t=>(t.LOG="log",t.INFO="info",t.WARN="warn",t.ERROR="error",t))(Se||{}),Ee=(t=>(t.TABLE="table",t.LIST="list",t.MOBILE_CARDS="mobile_cards",t))(Ee||{}),Oe=(t=>(t.ASC="ASC",t.DESC="DESC",t))(Oe||{}),xe=(t=>(t[t.DEFAULT=10]="DEFAULT",t[t.TWENTY=20]="TWENTY",t[t.FIFTY=50]="FIFTY",t[t.HUNDRED=100]="HUNDRED",t[t.TWO_HUNDRED_FIFTY=250]="TWO_HUNDRED_FIFTY",t[t.FIVE_HUNDRED=500]="FIVE_HUNDRED",t[t.THOUSAND=1e3]="THOUSAND",t))(xe||{});class ke extends Error{constructor(t){super(t),this.name="SnapRecordsConfigError"}}class Pe extends Error{constructor(t){super(t),this.name="SnapRecordsDataError"}}const Ae="object"==typeof performance&&performance&&"function"==typeof performance.now?performance:Date,Re=new Set,Te="object"==typeof process&&process?process:{},Fe=(t,e,n,r)=>{"function"==typeof Te.emitWarning&&Te.emitWarning(t,e,n,r)};let Me=globalThis.AbortController,De=globalThis.AbortSignal;if(void 0===Me){De=class{constructor(){ge(this,"onabort"),ge(this,"_onabort",[]),ge(this,"reason"),ge(this,"aborted",!1)}addEventListener(t,e){this._onabort.push(e)}},Me=class{constructor(){ge(this,"signal",new De),n()}abort(t){var e,n;if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=!0;for(const e of this.signal._onabort)e(t);null==(n=(e=this.signal).onabort)||n.call(e,t)}}};let t="1"!==(null==(e=Te.env)?void 0:e.LRU_CACHE_IGNORE_AC_WARNING);const n=()=>{t&&(t=!1,Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",n))}}const Ie=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),Le=t=>Ie(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?Ne:null:null;class Ne extends Array{constructor(t){super(t),this.fill(0)}}const je=class t{constructor(e,r){if(ge(this,"heap"),ge(this,"length"),!ve(t,n))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(e),this.length=0}static create(e){const r=Le(e);if(!r)return[];we(t,n,!0);const i=new t(e,r);return we(t,n,!1),i}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}};n=new WeakMap,be(je,n,!1);let Ke=je;const We=class t{constructor(e){be(this,R),be(this,s),be(this,a),be(this,o),be(this,l),be(this,c),be(this,u),be(this,h),ge(this,"ttl"),ge(this,"ttlResolution"),ge(this,"ttlAutopurge"),ge(this,"updateAgeOnGet"),ge(this,"updateAgeOnHas"),ge(this,"allowStale"),ge(this,"noDisposeOnSet"),ge(this,"noUpdateTTL"),ge(this,"maxEntrySize"),ge(this,"sizeCalculation"),ge(this,"noDeleteOnFetchRejection"),ge(this,"noDeleteOnStaleGet"),ge(this,"allowStaleOnFetchAbort"),ge(this,"allowStaleOnFetchRejection"),ge(this,"ignoreFetchAbort"),be(this,d),be(this,f),be(this,p),be(this,m),be(this,g),be(this,y),be(this,v),be(this,b),be(this,w),be(this,_),be(this,C),be(this,S),be(this,E),be(this,O),be(this,x),be(this,k),be(this,P),be(this,A),be(this,F,()=>{}),be(this,M,()=>{}),be(this,D,()=>{}),be(this,I,()=>!1),be(this,N,t=>{}),be(this,j,(t,e,n)=>{}),be(this,K,(t,e,n,r)=>{if(n||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0}),ge(this,r,"LRUCache");const{max:n=0,ttl:i,ttlResolution:W=1,ttlAutopurge:B,updateAgeOnGet:q,updateAgeOnHas:z,allowStale:U,dispose:H,onInsert:$,disposeAfter:G,noDisposeOnSet:V,noUpdateTTL:Y,maxSize:X=0,maxEntrySize:Q=0,sizeCalculation:J,fetchMethod:Z,memoMethod:tt,noDeleteOnFetchRejection:et,noDeleteOnStaleGet:nt,allowStaleOnFetchRejection:rt,allowStaleOnFetchAbort:it,ignoreFetchAbort:st}=e;if(0!==n&&!Ie(n))throw new TypeError("max option must be a nonnegative integer");const at=n?Le(n):Array;if(!at)throw new Error("invalid max value: "+n);if(we(this,s,n),we(this,a,X),this.maxEntrySize=Q||ve(this,a),this.sizeCalculation=J,this.sizeCalculation){if(!ve(this,a)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if("function"!=typeof this.sizeCalculation)throw new TypeError("sizeCalculation set to non-function")}if(void 0!==tt&&"function"!=typeof tt)throw new TypeError("memoMethod must be a function if defined");if(we(this,h,tt),void 0!==Z&&"function"!=typeof Z)throw new TypeError("fetchMethod must be a function if specified");if(we(this,u,Z),we(this,k,!!Z),we(this,p,new Map),we(this,m,new Array(n).fill(void 0)),we(this,g,new Array(n).fill(void 0)),we(this,y,new at(n)),we(this,v,new at(n)),we(this,b,0),we(this,w,0),we(this,_,Ke.create(n)),we(this,d,0),we(this,f,0),"function"==typeof H&&we(this,o,H),"function"==typeof $&&we(this,l,$),"function"==typeof G?(we(this,c,G),we(this,C,[])):(we(this,c,void 0),we(this,C,void 0)),we(this,x,!!ve(this,o)),we(this,A,!!ve(this,l)),we(this,P,!!ve(this,c)),this.noDisposeOnSet=!!V,this.noUpdateTTL=!!Y,this.noDeleteOnFetchRejection=!!et,this.allowStaleOnFetchRejection=!!rt,this.allowStaleOnFetchAbort=!!it,this.ignoreFetchAbort=!!st,0!==this.maxEntrySize){if(0!==ve(this,a)&&!Ie(ve(this,a)))throw new TypeError("maxSize must be a positive integer if specified");if(!Ie(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");_e(this,R,L).call(this)}if(this.allowStale=!!U,this.noDeleteOnStaleGet=!!nt,this.updateAgeOnGet=!!q,this.updateAgeOnHas=!!z,this.ttlResolution=Ie(W)||0===W?W:1,this.ttlAutopurge=!!B,this.ttl=i||0,this.ttl){if(!Ie(this.ttl))throw new TypeError("ttl must be a positive integer if specified");_e(this,R,T).call(this)}if(0===ve(this,s)&&0===this.ttl&&0===ve(this,a))throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!ve(this,s)&&!ve(this,a)){const e="LRU_CACHE_UNBOUNDED";if((t=>!Re.has(t))(e)){Re.add(e);Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",e,t)}}}static unsafeExposeInternals(t){return{starts:ve(t,E),ttls:ve(t,O),sizes:ve(t,S),keyMap:ve(t,p),keyList:ve(t,m),valList:ve(t,g),next:ve(t,y),prev:ve(t,v),get head(){return ve(t,b)},get tail(){return ve(t,w)},free:ve(t,_),isBackgroundFetch:e=>{var n;return _e(n=t,R,H).call(n,e)},backgroundFetch:(e,n,r,i)=>{var s;return _e(s=t,R,U).call(s,e,n,r,i)},moveToTail:e=>{var n;return _e(n=t,R,G).call(n,e)},indexes:e=>{var n;return _e(n=t,R,W).call(n,e)},rindexes:e=>{var n;return _e(n=t,R,B).call(n,e)},isStale:e=>{var n;return ve(n=t,I).call(n,e)}}}get max(){return ve(this,s)}get maxSize(){return ve(this,a)}get calculatedSize(){return ve(this,f)}get size(){return ve(this,d)}get fetchMethod(){return ve(this,u)}get memoMethod(){return ve(this,h)}get dispose(){return ve(this,o)}get onInsert(){return ve(this,l)}get disposeAfter(){return ve(this,c)}getRemainingTTL(t){return ve(this,p).has(t)?1/0:0}*entries(){for(const t of _e(this,R,W).call(this))void 0===ve(this,g)[t]||void 0===ve(this,m)[t]||_e(this,R,H).call(this,ve(this,g)[t])||(yield[ve(this,m)[t],ve(this,g)[t]])}*rentries(){for(const t of _e(this,R,B).call(this))void 0===ve(this,g)[t]||void 0===ve(this,m)[t]||_e(this,R,H).call(this,ve(this,g)[t])||(yield[ve(this,m)[t],ve(this,g)[t]])}*keys(){for(const t of _e(this,R,W).call(this)){const e=ve(this,m)[t];void 0===e||_e(this,R,H).call(this,ve(this,g)[t])||(yield e)}}*rkeys(){for(const t of _e(this,R,B).call(this)){const e=ve(this,m)[t];void 0===e||_e(this,R,H).call(this,ve(this,g)[t])||(yield e)}}*values(){for(const t of _e(this,R,W).call(this)){void 0===ve(this,g)[t]||_e(this,R,H).call(this,ve(this,g)[t])||(yield ve(this,g)[t])}}*rvalues(){for(const t of _e(this,R,B).call(this)){void 0===ve(this,g)[t]||_e(this,R,H).call(this,ve(this,g)[t])||(yield ve(this,g)[t])}}[(i=Symbol.iterator,r=Symbol.toStringTag,i)](){return this.entries()}find(t,e={}){for(const n of _e(this,R,W).call(this)){const r=ve(this,g)[n],i=_e(this,R,H).call(this,r)?r.__staleWhileFetching:r;if(void 0!==i&&t(i,ve(this,m)[n],this))return this.get(ve(this,m)[n],e)}}forEach(t,e=this){for(const n of _e(this,R,W).call(this)){const r=ve(this,g)[n],i=_e(this,R,H).call(this,r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,ve(this,m)[n],this)}}rforEach(t,e=this){for(const n of _e(this,R,B).call(this)){const r=ve(this,g)[n],i=_e(this,R,H).call(this,r)?r.__staleWhileFetching:r;void 0!==i&&t.call(e,i,ve(this,m)[n],this)}}purgeStale(){let t=!1;for(const e of _e(this,R,B).call(this,{allowStale:!0}))ve(this,I).call(this,e)&&(_e(this,R,V).call(this,ve(this,m)[e],"expire"),t=!0);return t}info(t){const e=ve(this,p).get(t);if(void 0===e)return;const n=ve(this,g)[e],r=_e(this,R,H).call(this,n)?n.__staleWhileFetching:n;if(void 0===r)return;const i={value:r};if(ve(this,O)&&ve(this,E)){const t=ve(this,O)[e],n=ve(this,E)[e];if(t&&n){const e=t-(Ae.now()-n);i.ttl=e,i.start=Date.now()}}return ve(this,S)&&(i.size=ve(this,S)[e]),i}dump(){const t=[];for(const e of _e(this,R,W).call(this,{allowStale:!0})){const n=ve(this,m)[e],r=ve(this,g)[e],i=_e(this,R,H).call(this,r)?r.__staleWhileFetching:r;if(void 0===i||void 0===n)continue;const s={value:i};if(ve(this,O)&&ve(this,E)){s.ttl=ve(this,O)[e];const t=Ae.now()-ve(this,E)[e];s.start=Math.floor(Date.now()-t)}ve(this,S)&&(s.size=ve(this,S)[e]),t.unshift([n,s])}return t}load(t){this.clear();for(const[e,n]of t){if(n.start){const t=Date.now()-n.start;n.start=Ae.now()-t}this.set(e,n.value,n)}}set(t,e,n={}){var r,i,a,u,h,f,b;if(void 0===e)return this.delete(t),this;const{ttl:S=this.ttl,start:E,noDisposeOnSet:F=this.noDisposeOnSet,sizeCalculation:I=this.sizeCalculation,status:L}=n;let{noUpdateTTL:W=this.noUpdateTTL}=n;const B=ve(this,K).call(this,t,e,n.size||0,I);if(this.maxEntrySize&&B>this.maxEntrySize)return L&&(L.set="miss",L.maxEntrySizeExceeded=!0),_e(this,R,V).call(this,t,"set"),this;let q=0===ve(this,d)?void 0:ve(this,p).get(t);if(void 0===q)q=0===ve(this,d)?ve(this,w):0!==ve(this,_).length?ve(this,_).pop():ve(this,d)===ve(this,s)?_e(this,R,z).call(this,!1):ve(this,d),ve(this,m)[q]=t,ve(this,g)[q]=e,ve(this,p).set(t,q),ve(this,y)[ve(this,w)]=q,ve(this,v)[q]=ve(this,w),we(this,w,q),Ce(this,d)._++,ve(this,j).call(this,q,B,L),L&&(L.set="add"),W=!1,ve(this,A)&&(null==(r=ve(this,l))||r.call(this,e,t,"add"));else{_e(this,R,G).call(this,q);const n=ve(this,g)[q];if(e!==n){if(ve(this,k)&&_e(this,R,H).call(this,n)){n.__abortController.abort(new Error("replaced"));const{__staleWhileFetching:e}=n;void 0===e||F||(ve(this,x)&&(null==(i=ve(this,o))||i.call(this,e,t,"set")),ve(this,P)&&(null==(a=ve(this,C))||a.push([e,t,"set"])))}else F||(ve(this,x)&&(null==(u=ve(this,o))||u.call(this,n,t,"set")),ve(this,P)&&(null==(h=ve(this,C))||h.push([n,t,"set"])));if(ve(this,N).call(this,q),ve(this,j).call(this,q,B,L),ve(this,g)[q]=e,L){L.set="replace";const t=n&&_e(this,R,H).call(this,n)?n.__staleWhileFetching:n;void 0!==t&&(L.oldValue=t)}}else L&&(L.set="update");ve(this,A)&&(null==(f=this.onInsert)||f.call(this,e,t,e===n?"update":"replace"))}if(0===S||ve(this,O)||_e(this,R,T).call(this),ve(this,O)&&(W||ve(this,D).call(this,q,S,E),L&&ve(this,M).call(this,L,q)),!F&&ve(this,P)&&ve(this,C)){const t=ve(this,C);let e;for(;e=null==t?void 0:t.shift();)null==(b=ve(this,c))||b.call(this,...e)}return this}pop(){var t;try{for(;ve(this,d);){const t=ve(this,g)[ve(this,b)];if(_e(this,R,z).call(this,!0),_e(this,R,H).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(void 0!==t)return t}}finally{if(ve(this,P)&&ve(this,C)){const e=ve(this,C);let n;for(;n=null==e?void 0:e.shift();)null==(t=ve(this,c))||t.call(this,...n)}}}has(t,e={}){const{updateAgeOnHas:n=this.updateAgeOnHas,status:r}=e,i=ve(this,p).get(t);if(void 0!==i){const t=ve(this,g)[i];if(_e(this,R,H).call(this,t)&&void 0===t.__staleWhileFetching)return!1;if(!ve(this,I).call(this,i))return n&&ve(this,F).call(this,i),r&&(r.has="hit",ve(this,M).call(this,r,i)),!0;r&&(r.has="stale",ve(this,M).call(this,r,i))}else r&&(r.has="miss");return!1}peek(t,e={}){const{allowStale:n=this.allowStale}=e,r=ve(this,p).get(t);if(void 0===r||!n&&ve(this,I).call(this,r))return;const i=ve(this,g)[r];return _e(this,R,H).call(this,i)?i.__staleWhileFetching:i}async fetch(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:o=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:c=this.noUpdateTTL,noDeleteOnFetchRejection:u=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:h=this.allowStaleOnFetchRejection,ignoreFetchAbort:d=this.ignoreFetchAbort,allowStaleOnFetchAbort:f=this.allowStaleOnFetchAbort,context:m,forceRefresh:y=!1,status:v,signal:b}=e;if(!ve(this,k))return v&&(v.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,status:v});const w={allowStale:n,updateAgeOnGet:r,noDeleteOnStaleGet:i,ttl:s,noDisposeOnSet:a,size:o,sizeCalculation:l,noUpdateTTL:c,noDeleteOnFetchRejection:u,allowStaleOnFetchRejection:h,allowStaleOnFetchAbort:f,ignoreFetchAbort:d,status:v,signal:b};let _=ve(this,p).get(t);if(void 0===_){v&&(v.fetch="miss");const e=_e(this,R,U).call(this,t,_,w,m);return e.__returned=e}{const e=ve(this,g)[_];if(_e(this,R,H).call(this,e)){const t=n&&void 0!==e.__staleWhileFetching;return v&&(v.fetch="inflight",t&&(v.returnedStale=!0)),t?e.__staleWhileFetching:e.__returned=e}const i=ve(this,I).call(this,_);if(!y&&!i)return v&&(v.fetch="hit"),_e(this,R,G).call(this,_),r&&ve(this,F).call(this,_),v&&ve(this,M).call(this,v,_),e;const s=_e(this,R,U).call(this,t,_,w,m),a=void 0!==s.__staleWhileFetching&&n;return v&&(v.fetch=i?"stale":"refresh",a&&i&&(v.returnedStale=!0)),a?s.__staleWhileFetching:s.__returned=s}}async forceFetch(t,e={}){const n=await this.fetch(t,e);if(void 0===n)throw new Error("fetch() returned undefined");return n}memo(t,e={}){const n=ve(this,h);if(!n)throw new Error("no memoMethod provided to constructor");const{context:r,forceRefresh:i,...s}=e,a=this.get(t,s);if(!i&&void 0!==a)return a;const o=n(t,a,{options:s,context:r});return this.set(t,o,s),o}get(t,e={}){const{allowStale:n=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:i=this.noDeleteOnStaleGet,status:s}=e,a=ve(this,p).get(t);if(void 0!==a){const e=ve(this,g)[a],o=_e(this,R,H).call(this,e);return s&&ve(this,M).call(this,s,a),ve(this,I).call(this,a)?(s&&(s.get="stale"),o?(s&&n&&void 0!==e.__staleWhileFetching&&(s.returnedStale=!0),n?e.__staleWhileFetching:void 0):(i||_e(this,R,V).call(this,t,"expire"),s&&n&&(s.returnedStale=!0),n?e:void 0)):(s&&(s.get="hit"),o?e.__staleWhileFetching:(_e(this,R,G).call(this,a),r&&ve(this,F).call(this,a),e))}s&&(s.get="miss")}delete(t){return _e(this,R,V).call(this,t,"delete")}clear(){return _e(this,R,Y).call(this,"delete")}};s=new WeakMap,a=new WeakMap,o=new WeakMap,l=new WeakMap,c=new WeakMap,u=new WeakMap,h=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap,m=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,b=new WeakMap,w=new WeakMap,_=new WeakMap,C=new WeakMap,S=new WeakMap,E=new WeakMap,O=new WeakMap,x=new WeakMap,k=new WeakMap,P=new WeakMap,A=new WeakMap,R=new WeakSet,T=function(){const t=new Ne(ve(this,s)),e=new Ne(ve(this,s));we(this,O,t),we(this,E,e),we(this,D,(n,r,i=Ae.now())=>{if(e[n]=0!==r?i:0,t[n]=r,0!==r&&this.ttlAutopurge){const t=setTimeout(()=>{ve(this,I).call(this,n)&&_e(this,R,V).call(this,ve(this,m)[n],"expire")},r+1);t.unref&&t.unref()}}),we(this,F,n=>{e[n]=0!==t[n]?Ae.now():0}),we(this,M,(i,s)=>{if(t[s]){const a=t[s],o=e[s];if(!a||!o)return;i.ttl=a,i.start=o,i.now=n||r();const l=i.now-o;i.remainingTTL=a-l}});let n=0;const r=()=>{const t=Ae.now();if(this.ttlResolution>0){n=t;const e=setTimeout(()=>n=0,this.ttlResolution);e.unref&&e.unref()}return t};this.getRemainingTTL=i=>{const s=ve(this,p).get(i);if(void 0===s)return 0;const a=t[s],o=e[s];if(!a||!o)return 1/0;return a-((n||r())-o)},we(this,I,i=>{const s=e[i],a=t[i];return!!a&&!!s&&(n||r())-s>a})},F=new WeakMap,M=new WeakMap,D=new WeakMap,I=new WeakMap,L=function(){const t=new Ne(ve(this,s));we(this,f,0),we(this,S,t),we(this,N,e=>{we(this,f,ve(this,f)-t[e]),t[e]=0}),we(this,K,(t,e,n,r)=>{if(_e(this,R,H).call(this,e))return 0;if(!Ie(n)){if(!r)throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");if("function"!=typeof r)throw new TypeError("sizeCalculation must be a function");if(n=r(e,t),!Ie(n))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}return n}),we(this,j,(e,n,r)=>{if(t[e]=n,ve(this,a)){const n=ve(this,a)-t[e];for(;ve(this,f)>n;)_e(this,R,z).call(this,!0)}we(this,f,ve(this,f)+t[e]),r&&(r.entrySize=n,r.totalCalculatedSize=ve(this,f))})},N=new WeakMap,j=new WeakMap,K=new WeakMap,W=function*({allowStale:t=this.allowStale}={}){if(ve(this,d))for(let e=ve(this,w);_e(this,R,q).call(this,e)&&(!t&&ve(this,I).call(this,e)||(yield e),e!==ve(this,b));)e=ve(this,v)[e]},B=function*({allowStale:t=this.allowStale}={}){if(ve(this,d))for(let e=ve(this,b);_e(this,R,q).call(this,e)&&(!t&&ve(this,I).call(this,e)||(yield e),e!==ve(this,w));)e=ve(this,y)[e]},q=function(t){return void 0!==t&&ve(this,p).get(ve(this,m)[t])===t},z=function(t){var e,n;const r=ve(this,b),i=ve(this,m)[r],s=ve(this,g)[r];return ve(this,k)&&_e(this,R,H).call(this,s)?s.__abortController.abort(new Error("evicted")):(ve(this,x)||ve(this,P))&&(ve(this,x)&&(null==(e=ve(this,o))||e.call(this,s,i,"evict")),ve(this,P)&&(null==(n=ve(this,C))||n.push([s,i,"evict"]))),ve(this,N).call(this,r),t&&(ve(this,m)[r]=void 0,ve(this,g)[r]=void 0,ve(this,_).push(r)),1===ve(this,d)?(we(this,b,we(this,w,0)),ve(this,_).length=0):we(this,b,ve(this,y)[r]),ve(this,p).delete(i),Ce(this,d)._--,r},U=function(t,e,n,r){const i=void 0===e?void 0:ve(this,g)[e];if(_e(this,R,H).call(this,i))return i;const s=new Me,{signal:a}=n;null==a||a.addEventListener("abort",()=>s.abort(a.reason),{signal:s.signal});const o={signal:s.signal,options:n,context:r},l=(r,i=!1)=>{const{aborted:a}=s.signal,l=n.ignoreFetchAbort&&void 0!==r;if(n.status&&(a&&!i?(n.status.fetchAborted=!0,n.status.fetchError=s.signal.reason,l&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),a&&!l&&!i)return c(s.signal.reason);const u=h;return ve(this,g)[e]===h&&(void 0===r?u.__staleWhileFetching?ve(this,g)[e]=u.__staleWhileFetching:_e(this,R,V).call(this,t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,r,o.options))),r},c=r=>{const{aborted:i}=s.signal,a=i&&n.allowStaleOnFetchAbort,o=a||n.allowStaleOnFetchRejection,l=o||n.noDeleteOnFetchRejection,c=h;if(ve(this,g)[e]===h){!l||void 0===c.__staleWhileFetching?_e(this,R,V).call(this,t,"fetch"):a||(ve(this,g)[e]=c.__staleWhileFetching)}if(o)return n.status&&void 0!==c.__staleWhileFetching&&(n.status.returnedStale=!0),c.__staleWhileFetching;if(c.__returned===c)throw r};n.status&&(n.status.fetchDispatched=!0);const h=new Promise((e,r)=>{var a;const c=null==(a=ve(this,u))?void 0:a.call(this,t,i,o);c&&c instanceof Promise&&c.then(t=>e(void 0===t?void 0:t),r),s.signal.addEventListener("abort",()=>{n.ignoreFetchAbort&&!n.allowStaleOnFetchAbort||(e(void 0),n.allowStaleOnFetchAbort&&(e=t=>l(t,!0)))})}).then(l,t=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=t),c(t))),d=Object.assign(h,{__abortController:s,__staleWhileFetching:i,__returned:void 0});return void 0===e?(this.set(t,d,{...o.options,status:void 0}),e=ve(this,p).get(t)):ve(this,g)[e]=d,d},H=function(t){if(!ve(this,k))return!1;const e=t;return!!e&&e instanceof Promise&&e.hasOwnProperty("__staleWhileFetching")&&e.__abortController instanceof Me},$=function(t,e){ve(this,v)[e]=t,ve(this,y)[t]=e},G=function(t){t!==ve(this,w)&&(t===ve(this,b)?we(this,b,ve(this,y)[t]):_e(this,R,$).call(this,ve(this,v)[t],ve(this,y)[t]),_e(this,R,$).call(this,ve(this,w),t),we(this,w,t))},V=function(t,e){var n,r,i,s;let a=!1;if(0!==ve(this,d)){const i=ve(this,p).get(t);if(void 0!==i)if(a=!0,1===ve(this,d))_e(this,R,Y).call(this,e);else{ve(this,N).call(this,i);const s=ve(this,g)[i];if(_e(this,R,H).call(this,s)?s.__abortController.abort(new Error("deleted")):(ve(this,x)||ve(this,P))&&(ve(this,x)&&(null==(n=ve(this,o))||n.call(this,s,t,e)),ve(this,P)&&(null==(r=ve(this,C))||r.push([s,t,e]))),ve(this,p).delete(t),ve(this,m)[i]=void 0,ve(this,g)[i]=void 0,i===ve(this,w))we(this,w,ve(this,v)[i]);else if(i===ve(this,b))we(this,b,ve(this,y)[i]);else{const t=ve(this,v)[i];ve(this,y)[t]=ve(this,y)[i];const e=ve(this,y)[i];ve(this,v)[e]=ve(this,v)[i]}Ce(this,d)._--,ve(this,_).push(i)}}if(ve(this,P)&&(null==(i=ve(this,C))?void 0:i.length)){const t=ve(this,C);let e;for(;e=null==t?void 0:t.shift();)null==(s=ve(this,c))||s.call(this,...e)}return a},Y=function(t){var e,n,r;for(const i of _e(this,R,B).call(this,{allowStale:!0})){const r=ve(this,g)[i];if(_e(this,R,H).call(this,r))r.__abortController.abort(new Error("deleted"));else{const s=ve(this,m)[i];ve(this,x)&&(null==(e=ve(this,o))||e.call(this,r,s,t)),ve(this,P)&&(null==(n=ve(this,C))||n.push([r,s,t]))}}if(ve(this,p).clear(),ve(this,g).fill(void 0),ve(this,m).fill(void 0),ve(this,O)&&ve(this,E)&&(ve(this,O).fill(0),ve(this,E).fill(0)),ve(this,S)&&ve(this,S).fill(0),we(this,b,0),we(this,w,0),ve(this,_).length=0,we(this,f,0),we(this,d,0),ve(this,P)&&ve(this,C)){const t=ve(this,C);let e;for(;e=null==t?void 0:t.shift();)null==(r=ve(this,c))||r.call(this,...e)}};let Be=We;class qe{constructor(t){be(this,X),we(this,X,t)}reset(){ve(this,X).reset()}refresh(){ve(this,X).refresh()}destroy(){ve(this,X).destroy()}clearSelection(){ve(this,X).clearSelection()}gotoPage(t){ve(this,X).gotoPage(t)}getData(){return ve(this,X).getData()}getSelectedRows(){return ve(this,X).getSelectedRows()}getTotals(){return ve(this,X).getTotals()}setTheme(t){ve(this,X).setTheme(t)}setRenderMode(t){ve(this,X).setRenderMode(t)}setRowsPerPage(t){ve(this,X).setRowsPerPage(t)}async setLanguage(t){await ve(this,X).setLanguage(t)}search(t,e=!1){ve(this,X).search(t,e)}updateParams(t){ve(this,X).updateParams(t)}}X=new WeakMap;const ze={url:"",columns:[],debug:!1,theme:"default",useCache:!1,retryAttempts:3,columnTitles:[],language:"en_US",langPath:"/lang",selectable:!1,usePushState:!1,persistState:!1,formatCacheSize:500,lazyLoadMedia:!1,destroyOnUnload:!0,preloadNextPage:!1,draggableColumns:!1,format:Ee.TABLE,rowsPerPage:xe.DEFAULT},Ue={constants:{defaultDebounceDelay:250,defaultCacheExpiry:288e5,paginationPageRange:2,paginationMaxPageDistance:3,paginationEllipsisDistance:4,paginationLastPageBuffer:2,paginationEllipsisLastPageBuffer:3},pagination:{prevButton:{text:'<span aria-hidden="true">«</span>',isHtml:!0,classNames:{base:"snap-prev",disabled:"snap-disabled"}},nextButton:{text:'<span aria-hidden="true">»</span>',isHtml:!0,classNames:{base:"snap-next",disabled:"snap-disabled"}},numberButton:{classNames:{base:"snap-page-number",disabled:"snap-active"}},ellipsis:{classNames:{base:"snap-pagination-ellipsis"}}},classes:{tableContainer:"snap-records-container",contentContainer:"snap-records-content",errorContainer:"snap-records-error",tableResponsive:"table-responsive",table:{containerClass:"snap-records snap-table",headerClass:"snap-records-header",bodyClass:"snap-records-body",footerClass:"snap-records-footer"},list:{containerClass:"snap-list",itemClass:"snap-list-item"},mobileCardsContainer:"snap-mobile-cards-container",mobileCard:"snap-mobile-card",cardRow:"snap-card-row",cardLabel:"snap-card-label",cardValue:"snap-card-value",footerContainer:"snap-records-footer-container",footer:"snap-footer",totals:"snap-totals",paginationContainer:"snap-pagination-container",loadingOverlay:"snap-loading-overlay",noData:"snap-no-data",selected:"snap-selected",currentRow:"snap-current-row",columnResizeHandle:"snap-column-resize-handle",sortAscOrder:"snap-asc-order",sortDescOrder:"snap-desc-order",sortNoOrder:"snap-no-order",recordStart:"snap-record-start",recordEnd:"snap-record-end",recordsTotal:"snap-records-total",draggableColumn:"snap-draggable-column",dragging:"snap-dragging",dragOver:"snap-drag-over"}};function He(t){const e=document.createElement("div");return e.innerHTML=t,e.querySelectorAll("script, style").forEach(t=>t.remove()),e.querySelectorAll("*").forEach(t=>{for(const e of Array.from(t.attributes))e.name.toLowerCase().startsWith("on")&&t.removeAttribute(e.name)}),e.innerHTML}function $e(t,e,...n){if(!t)return}class Ge{constructor(t){be(this,Q),we(this,Q,t)}buildUrl(t){const e=new URLSearchParams;return e.append("page",t.page.toString()),e.append("perPage",t.perPage.toString()),e.append("offset",t.offset.toString()),t.filtering&&Object.entries(t.filtering).forEach(([t,n])=>{const r=He(String(n));e.append(`filtering[${t}]`,r)}),t.sorting&&Object.entries(t.sorting).forEach(([t,n])=>{e.append(`sorting[${t}]`,n)}),`${ve(this,Q).baseUrl}?${e.toString()}`}getServerParams(t=ve(this,Q).state.currentPage){const e={page:t,perPage:ve(this,Q).state.rowsPerPage,offset:(t-1)*ve(this,Q).state.rowsPerPage};if(Object.keys(ve(this,Q).state.filters).length>0){const t={};Object.entries(ve(this,Q).state.filters).forEach(([e,n])=>{t[e]=He(String(n))}),e.filtering=t}return ve(this,Q).state.sortConditions.length>0&&(e.sorting=Object.fromEntries(ve(this,Q).state.sortConditions)),e}}Q=new WeakMap;const Ve={loading:"Loading...",totalRecords:"Total records: {total}",filteredRecords:"Filtered records: {filtered}",previous:"Previous",next:"Next",errorTitle:"Error",errorMessage:"An error occurred.",noDataAvailable:"No data available.",columnResizeHandle:"Resize column",sortAscending:"Sort ascending",sortDescending:"Sort descending",removeSort:"Remove sort",rowSelected:"Row selected",rowDeselected:"Row deselected",currentPage:"Current page: {page}",pageNavigation:"Page navigation",loadMore:"Load More",jumpToPage:"Jump to page",retry:"Retry",dragColumn:"Drag column {col}",errors:{containerNotFound:"Container not found.",invalidConfig:"Invalid configuration.",dataLoadingFailed:"Failed to load data: {error}",renderFailed:"Failed to render: {error}",generic:"An error occurred."},pagination:{showingRecords:"Showing {start} to {end} of {total} records"}};class Ye{constructor(t,e){be(this,J),this.cardsContainer=null,this.tableElement=null,this.listContainer=null,this.tableBody=null,this.tableHeader=null,this.footerElement=null,this.totalsElement=null,this.paginationElement=null,this.parent=t,this.contentContainer=e}navigateToNextRow(){0!==this.parent.state.data.length&&(this.parent.currentRowIndex=Math.min(this.parent.currentRowIndex+1,this.parent.state.data.length-1),this.highlightCurrentRow())}navigateToPrevRow(){0!==this.parent.state.data.length&&(this.parent.currentRowIndex=Math.max(0,this.parent.currentRowIndex-1),this.highlightCurrentRow())}createContainers(){$e(this.parent.debug,Se.INFO),this.parent.container.innerHTML="",this.parent.container.classList.add(Ue.classes.tableContainer),this.contentContainer.classList.add(Ue.classes.contentContainer),this.parent.container.appendChild(this.contentContainer),this.parent.errorContainer=document.createElement("div"),this.parent.errorContainer.classList.add(Ue.classes.errorContainer),this.parent.errorContainer.style.display="none",this.parent.container.appendChild(this.parent.errorContainer),"static"===getComputedStyle(this.parent.container).position&&(this.parent.container.style.position="relative")}showLoading(){if(this.parent.isLoading)return;this.parent.isLoading=!0,$e(this.parent.debug,Se.INFO);const t=this.parent.state.translations??Ve,e=document.createElement("div");e.className=Ue.classes.loadingOverlay,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.textContent=t.loading;let n=null;switch(this.parent.state.format){case Ee.TABLE:n=this.tableBody,n&&(n.style.position="relative");break;case Ee.LIST:n=this.listContainer;break;case Ee.MOBILE_CARDS:n=this.cardsContainer}n?n.appendChild(e):this.parent.contentContainer.appendChild(e)}applyThemeClass(){$e(this.parent.debug,Se.INFO,this.parent.state.theme),this.parent.container.classList.remove("theme-light","theme-dark","theme-default"),this.parent.container.classList.add(`theme-${this.parent.state.theme}`)}hideLoading(){var t;this.parent.isLoading&&($e(this.parent.debug,Se.INFO),null==(t=this.parent.container.querySelector(`.${Ue.classes.loadingOverlay}`))||t.remove(),this.parent.isLoading=!1)}showError(t){if($e(this.parent.debug,Se.ERROR),this.parent.errorContainer&&this.parent.state.translations){const e=this.parent.state.translations;this.parent.errorContainer.innerHTML="";const n=document.createElement("strong");n.textContent=e.errorTitle;const r=document.createElement("p");r.textContent=t;const i=document.createElement("button");i.className="snap-retry-button",i.textContent=e.retry,i.addEventListener("click",()=>this.parent.refresh()),this.parent.errorContainer.append(n,r,i),this.parent.errorContainer.style.display="block",this.contentContainer.style.display="none"}}applyColumnWidths(){requestAnimationFrame(()=>{this.parent.state.columns.forEach((t,e)=>{var n;const r=this.parent.state.columnWidths.get(t);if(r){const t=null==(n=this.tableHeader)?void 0:n.querySelector(`th:nth-child(${e+1})`);t&&(t.style.width=`${r}px`)}})})}highlightSelectedRows(){this.contentContainer.querySelectorAll("tr[data-index], li[data-index], .snap-mobile-card[data-index]").forEach(t=>{const e=t,n=parseInt(e.dataset.index,10),r=this.parent.selectedRows.has(n);e.classList.toggle(Ue.classes.selected,r),e.setAttribute("aria-selected",String(r))})}highlightCurrentRow(){this.contentContainer.querySelectorAll("tr[data-index], li[data-index], .snap-mobile-card[data-index]").forEach(t=>{const e=t,n=parseInt(e.dataset.index,10)===this.parent.currentRowIndex;e.classList.toggle(Ue.classes.currentRow,n),n&&(e.scrollIntoView({block:"nearest"}),e.focus())})}render(){this.parent.state.translations&&($e(this.parent.debug,Se.INFO),this.parent.lifecycleHooks.preRender&&this.parent.lifecycleHooks.preRender(),_e(this,J,ft).call(this,this.parent.state.format),this.parent.state.format===Ee.TABLE?(_e(this,J,ut).call(this),_e(this,J,tt).call(this)):this.parent.state.format===Ee.LIST?_e(this,J,et).call(this):this.parent.state.format===Ee.MOBILE_CARDS&&_e(this,J,nt).call(this),_e(this,J,at).call(this),this.parent.lifecycleHooks.postRender&&this.parent.lifecycleHooks.postRender(),$e(this.parent.debug,Se.INFO))}announceScreenReaderUpdate(t){const e=document.createElement("div");e.setAttribute("aria-live","polite"),e.style.cssText="position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);",e.textContent=t,document.body.appendChild(e),setTimeout(()=>e.remove(),1e3)}destroy(){$e(this.parent.debug,Se.INFO),this.parent.container.innerHTML=""}}J=new WeakSet,Z=function(){this.footerElement=document.createElement("div"),this.footerElement.classList.add(Ue.classes.footer),this.contentContainer.appendChild(this.footerElement)},tt=function(){this.tableBody&&_e(this,J,it).call(this,this.tableBody,this.parent.state.data,(t,e)=>this.parent.createTableRow(t,e,t.id),(t,e,n)=>this.parent.updateRow(t,e,n))},et=function(){this.listContainer&&_e(this,J,it).call(this,this.listContainer,this.parent.state.data,(t,e)=>this.parent.createListItem(t,e),(t,e,n)=>this.parent.updateListItem(t,e,n))},nt=function(){this.cardsContainer&&_e(this,J,it).call(this,this.cardsContainer,this.parent.state.data,(t,e)=>this.parent.createMobileCard(t,e),(t,e,n)=>this.parent.updateMobileCard(t,e,n))},rt=function(t,e,n){const r=document.createElement("button");let i;switch(r.type="button",r.disabled=e,n){case"prev":i=Ue.pagination.prevButton,r.classList.add(i.classNames.base);break;case"next":i=Ue.pagination.nextButton,r.classList.add(i.classNames.base);break;case"number":i=Ue.pagination.numberButton,r.classList.add(i.classNames.base)}return e&&r.classList.add(i.classNames.disabled),r.innerHTML=t,r},it=function(t,e,n,r){const i=new Map;t.querySelectorAll("[data-key]").forEach(t=>{i.set(t.dataset.key,t)});const s=document.createDocumentFragment();e.forEach((t,e)=>{const a=t.id.toString(),o=i.get(a);let l;o?(r(o,t,e),l=o,i.delete(a)):l=n(t,e),s.appendChild(l)}),t.innerHTML="",t.appendChild(s),0===e.length&&this.parent.state.translations&&_e(this,J,st).call(this,t,"TBODY"===t.tagName?this.parent.state.columns.length:1)},st=function(t,e){$e(this.parent.debug,Se.INFO);const n="TBODY"===t.tagName,r=document.createElement(n?"tr":"li"),i=document.createElement(n?"td":"div");n&&(i.colSpan=e),i.classList.add(Ue.classes.noData),i.textContent=this.parent.state.translations.noDataAvailable,r.appendChild(i),t.appendChild(r)},at=function(){var t;const e=(null==(t=this.tableElement)?void 0:t.querySelector(`.${Ue.classes.footerContainer}`))??this.footerElement;e&&this.parent.state.translations&&(e.innerHTML="",this.totalsElement=_e(this,J,dt).call(this),this.paginationElement=_e(this,J,ht).call(this),e.appendChild(this.totalsElement),e.appendChild(this.paginationElement))},ot=function(){$e(this.parent.debug,Se.LOG);const t=document.createElement("div");t.classList.add(Ue.classes.tableResponsive),this.tableElement=document.createElement("table"),this.tableElement.classList.add(...Ue.classes.table.containerClass.split(" ")),this.tableElement.setAttribute("role","grid"),t.appendChild(this.tableElement),this.contentContainer.appendChild(t),this.tableHeader=this.tableElement.createTHead(),this.tableHeader.classList.add(...Ue.classes.table.headerClass.split(" ")),this.tableBody=this.tableElement.createTBody(),this.tableBody.classList.add(...Ue.classes.table.bodyClass.split(" "));const e=this.tableElement.createTFoot();e.classList.add(...Ue.classes.table.footerClass.split(" "));const n=e.insertRow().insertCell();n.colSpan=this.parent.state.columns.length;const r=document.createElement("div");r.classList.add(Ue.classes.footerContainer),n.appendChild(r)},lt=function(){$e(this.parent.debug,Se.LOG),this.cardsContainer=document.createElement("div"),this.cardsContainer.classList.add(Ue.classes.mobileCardsContainer),this.contentContainer.appendChild(this.cardsContainer),_e(this,J,Z).call(this)},ct=function(){$e(this.parent.debug,Se.LOG),this.listContainer=document.createElement("ul"),this.listContainer.classList.add(...Ue.classes.list.containerClass.split(" ")),this.contentContainer.appendChild(this.listContainer),_e(this,J,Z).call(this)},ut=function(){if(!this.tableHeader||!this.parent.state.translations)return;this.tableHeader.innerHTML="";const t=this.tableHeader.insertRow();t.setAttribute("role","row"),this.parent.state.columns.forEach((e,n)=>{var r;const i=document.createElement("th");i.setAttribute("role","columnheader"),i.setAttribute("data-col-id",e);const s=this.parent.state.columnWidths.get(e);s&&(i.style.width=`${s}px`),this.parent.headerCellClasses[n]&&(i.className=this.parent.headerCellClasses[n]);if(!(null==(r=this.parent.headerCellClasses[n])?void 0:r.includes("no-sorting"))){const t=document.createElement("a");t.href="#",t.innerHTML=this.parent.state.columnTitles[n],t.setAttribute("role","button");const r=this.parent.state.sortConditions.find(t=>t[0]===e);if(r){const e=r[1]===Oe.ASC?Ue.classes.sortAscOrder:Ue.classes.sortDescOrder;t.classList.add(e),t.setAttribute("aria-sort","ASC"===r[1]?"ascending":"descending")}else t.classList.add(Ue.classes.sortNoOrder),t.setAttribute("aria-sort","none");i.appendChild(t)}else i.textContent=this.parent.state.columnTitles[n];this.parent.draggableColumns&&(i.setAttribute("draggable","true"),i.classList.add(Ue.classes.draggableColumn));const a=document.createElement("div");a.className=Ue.classes.columnResizeHandle,i.appendChild(a),t.appendChild(i)})},ht=function(){const t=this.parent.state,e=Math.max(1,Math.ceil(t.totalRecords/t.rowsPerPage)),n=document.createElement("nav");if(n.classList.add(Ue.classes.paginationContainer),n.setAttribute("aria-label",t.translations.pageNavigation),n.appendChild(_e(this,J,rt).call(this,this.parent.prevButtonConfig.text||t.translations.previous,1===t.currentPage,"prev")),t.currentPage>Ue.constants.paginationMaxPageDistance&&(n.appendChild(_e(this,J,rt).call(this,"1",!1,"number")),t.currentPage>Ue.constants.paginationEllipsisDistance)){const t=document.createElement("span");t.textContent="...",t.setAttribute("aria-hidden","true"),t.classList.add(Ue.pagination.ellipsis.classNames.base),n.appendChild(t)}const r=Math.max(1,t.currentPage-Ue.constants.paginationPageRange),i=Math.min(e,t.currentPage+Ue.constants.paginationPageRange);for(let s=r;s<=i;s++)n.appendChild(_e(this,J,rt).call(this,s.toString(),s===t.currentPage,"number"));if(i<e-Ue.constants.paginationLastPageBuffer){if(i<e-Ue.constants.paginationEllipsisLastPageBuffer){const t=document.createElement("span");t.textContent="...",t.setAttribute("aria-hidden","true"),t.classList.add(Ue.pagination.ellipsis.classNames.base),n.appendChild(t)}n.appendChild(_e(this,J,rt).call(this,e.toString(),!1,"number"))}return n.appendChild(_e(this,J,rt).call(this,this.parent.nextButtonConfig.text||t.translations.next,t.currentPage===e,"next")),n},dt=function(){const t=this.parent.state,e=document.createElement("div");if(e.classList.add(Ue.classes.totals),0===t.totalRecords)return e.textContent=t.translations.noDataAvailable,e;const n=(t.currentPage-1)*t.rowsPerPage+1,r=Math.min(t.currentPage*t.rowsPerPage,t.totalRecords),i=t.translations.pagination.showingRecords.replace("{start}",`<span class="${Ue.classes.recordStart}">${n}</span>`).replace("{end}",`<span class="${Ue.classes.recordEnd}">${r}</span>`).replace("{total}",`<span class="${Ue.classes.recordsTotal}">${t.totalRecords}</span>`);return e.innerHTML=i,e},ft=function(t){var e,n,r;$e(this.parent.debug,Se.LOG);const i=t===Ee.TABLE,s=t===Ee.LIST,a=t===Ee.MOBILE_CARDS;i&&!this.tableElement&&_e(this,J,ot).call(this),s&&!this.listContainer&&_e(this,J,ct).call(this),a&&!this.cardsContainer&&_e(this,J,lt).call(this);const o=null==(e=this.tableElement)?void 0:e.parentElement;o&&(o.style.display=i?"":"none"),this.listContainer&&(this.listContainer.style.display=s?"":"none"),this.cardsContainer&&(this.cardsContainer.style.display=a?"":"none");const l=(null==(r=null==(n=this.tableElement)?void 0:n.querySelector(`.${Ue.classes.footerContainer}`))?void 0:r.parentElement)??this.footerElement;l&&(l.style.display=s||a||i?"":"none")};class Xe{constructor(t,e){be(this,yt),be(this,pt),be(this,mt),be(this,gt,5e3),we(this,pt,t),we(this,mt,e)}invalidateCache(){if(!ve(this,pt).useCache)return;const t=JSON.stringify(ve(this,pt).state.filters);t!==ve(this,pt).lastFilterHash&&(ve(this,pt).db.cache.clear(),ve(this,pt).lastFilterHash=t,$e(ve(this,pt).debug,Se.LOG))}async preloadNextPage(){if(!ve(this,pt).preloadNextPageEnabled)return;const t=navigator.connection;if(t&&(t.saveData||"slow-2g"===t.effectiveType||"2g"===t.effectiveType))return void $e(ve(this,pt).debug,Se.INFO);const e=ve(this,pt).state.currentPage+1;if(e>Math.ceil(ve(this,pt).state.totalRecords/ve(this,pt).state.rowsPerPage))return;const n=ve(this,mt).getServerParams(e),r=ve(this,mt).buildUrl(n);if(ve(this,pt).useCache){const t=await this.getCachedData(r);if(t&&Date.now()-t.timestamp<ve(this,pt).cacheExpiry)return void $e(ve(this,pt).debug,Se.INFO)}try{$e(ve(this,pt).debug,Se.INFO);const t=await fetch(r);if(t.ok){const e=await t.json();ve(this,pt).useCache&&await this.cacheData(r,{url:r,data:e.data||[],totalRecords:e.totalRecords||0,timestamp:Date.now()})}}catch(i){$e(ve(this,pt).debug,Se.LOG)}}async cacheData(t,e){if(ve(this,pt).useCache)try{await ve(this,pt).db.cache.put(e),$e(ve(this,pt).debug,Se.INFO)}catch(n){$e(ve(this,pt).debug,Se.ERROR)}}async getCachedData(t){if(ve(this,pt).useCache)try{const e=await Promise.race([ve(this,pt).db.cache.get(t),new Promise((t,e)=>setTimeout(()=>e(new Error("Cache timeout")),ve(this,gt)))]);return e&&_e(this,yt,vt).call(this,e)?e:void 0}catch(e){return void $e(ve(this,pt).debug,Se.ERROR)}}}pt=new WeakMap,mt=new WeakMap,gt=new WeakMap,yt=new WeakSet,vt=function(t){return"number"==typeof t.timestamp&&Array.isArray(t.data)&&"number"==typeof t.totalRecords&&t.timestamp>Date.now()-ve(this,pt).cacheExpiry};var Qe=Symbol.for("immer-nothing"),Je=Symbol.for("immer-draftable"),Ze=Symbol.for("immer-state");function tn(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var en=Object.getPrototypeOf;function nn(t){return!!t&&!!t[Ze]}function rn(t){var e;return!!t&&(an(t)||Array.isArray(t)||!!t[Je]||!!(null==(e=t.constructor)?void 0:e[Je])||hn(t)||dn(t))}var sn=Object.prototype.constructor.toString();function an(t){if(!t||"object"!=typeof t)return!1;const e=en(t);if(null===e)return!0;const n=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===sn}function on(t,e){0===ln(t)?Reflect.ownKeys(t).forEach(n=>{e(n,t[n],t)}):t.forEach((n,r)=>e(r,n,t))}function ln(t){const e=t[Ze];return e?e.type_:Array.isArray(t)?1:hn(t)?2:dn(t)?3:0}function cn(t,e){return 2===ln(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function un(t,e,n){const r=ln(t);2===r?t.set(e,n):3===r?t.add(n):t[e]=n}function hn(t){return t instanceof Map}function dn(t){return t instanceof Set}function fn(t){return t.copy_||t.base_}function pn(t,e){if(hn(t))return new Map(t);if(dn(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=an(t);if(!0===e||"class_only"===e&&!n){const e=Object.getOwnPropertyDescriptors(t);delete e[Ze];let n=Reflect.ownKeys(e);for(let r=0;r<n.length;r++){const i=n[r],s=e[i];!1===s.writable&&(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(e[i]={configurable:!0,writable:!0,enumerable:s.enumerable,value:t[i]})}return Object.create(en(t),e)}{const e=en(t);if(null!==e&&n)return{...t};const r=Object.create(e);return Object.assign(r,t)}}function mn(t,e=!1){return yn(t)||nn(t)||!rn(t)||(ln(t)>1&&(t.set=t.add=t.clear=t.delete=gn),Object.freeze(t),e&&Object.entries(t).forEach(([t,e])=>mn(e,!0))),t}function gn(){tn(2)}function yn(t){return Object.isFrozen(t)}var vn,bn={};function wn(t){const e=bn[t];return e||tn(0),e}function _n(){return vn}function Cn(t,e){e&&(wn("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Sn(t){En(t),t.drafts_.forEach(xn),t.drafts_=null}function En(t){t===vn&&(vn=t.parent_)}function On(t){return vn={drafts_:[],parent_:vn,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function xn(t){const e=t[Ze];0===e.type_||1===e.type_?e.revoke_():e.revoked_=!0}function kn(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return void 0!==t&&t!==n?(n[Ze].modified_&&(Sn(e),tn(4)),rn(t)&&(t=Pn(e,t),e.parent_||Rn(e,t)),e.patches_&&wn("Patches").generateReplacementPatches_(n[Ze].base_,t,e.patches_,e.inversePatches_)):t=Pn(e,n,[]),Sn(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Qe?t:void 0}function Pn(t,e,n){if(yn(e))return e;const r=e[Ze];if(!r)return on(e,(i,s)=>An(t,r,e,i,s,n)),e;if(r.scope_!==t)return e;if(!r.modified_)return Rn(t,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const e=r.copy_;let i=e,s=!1;3===r.type_&&(i=new Set(e),e.clear(),s=!0),on(i,(i,a)=>An(t,r,e,i,a,n,s)),Rn(t,e,!1),n&&t.patches_&&wn("Patches").generatePatches_(r,n,t.patches_,t.inversePatches_)}return r.copy_}function An(t,e,n,r,i,s,a){if(nn(i)){const a=Pn(t,i,s&&e&&3!==e.type_&&!cn(e.assigned_,r)?s.concat(r):void 0);if(un(n,r,a),!nn(a))return;t.canAutoFreeze_=!1}else a&&n.add(i);if(rn(i)&&!yn(i)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Pn(t,i),e&&e.scope_.parent_||"symbol"==typeof r||!Object.prototype.propertyIsEnumerable.call(n,r)||Rn(t,i)}}function Rn(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&mn(e,n)}var Tn={get(t,e){if(e===Ze)return t;const n=fn(t);if(!cn(n,e))return function(t,e,n){var r;const i=Dn(e,n);return i?"value"in i?i.value:null==(r=i.get)?void 0:r.call(t.draft_):void 0}(t,n,e);const r=n[e];return t.finalized_||!rn(r)?r:r===Mn(t.base_,e)?(Ln(t),t.copy_[e]=Nn(r,t)):r},has:(t,e)=>e in fn(t),ownKeys:t=>Reflect.ownKeys(fn(t)),set(t,e,n){const r=Dn(fn(t),e);if(null==r?void 0:r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const r=Mn(fn(t),e),a=null==r?void 0:r[Ze];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(((i=n)===(s=r)?0!==i||1/i==1/s:i!=i&&s!=s)&&(void 0!==n||cn(t.base_,e)))return!0;Ln(t),In(t)}var i,s;return t.copy_[e]===n&&(void 0!==n||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_[e]=!0),!0},deleteProperty:(t,e)=>(void 0!==Mn(t.base_,e)||e in t.base_?(t.assigned_[e]=!1,Ln(t),In(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0),getOwnPropertyDescriptor(t,e){const n=fn(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r?{writable:!0,configurable:1!==t.type_||"length"!==e,enumerable:r.enumerable,value:n[e]}:r},defineProperty(){tn(11)},getPrototypeOf:t=>en(t.base_),setPrototypeOf(){tn(12)}},Fn={};function Mn(t,e){const n=t[Ze];return(n?fn(n):t)[e]}function Dn(t,e){if(!(e in t))return;let n=en(t);for(;n;){const t=Object.getOwnPropertyDescriptor(n,e);if(t)return t;n=en(n)}}function In(t){t.modified_||(t.modified_=!0,t.parent_&&In(t.parent_))}function Ln(t){t.copy_||(t.copy_=pn(t.base_,t.scope_.immer_.useStrictShallowCopy_))}on(Tn,(t,e)=>{Fn[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}}),Fn.deleteProperty=function(t,e){return Fn.set.call(this,t,e,void 0)},Fn.set=function(t,e,n){return Tn.set.call(this,t[0],e,n,t[0])};function Nn(t,e){const n=hn(t)?wn("MapSet").proxyMap_(t,e):dn(t)?wn("MapSet").proxySet_(t,e):function(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:_n(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=Tn;n&&(i=[r],s=Fn);const{revoke:a,proxy:o}=Proxy.revocable(i,s);return r.draft_=o,r.revoke_=a,o}(t,e);return(e?e.scope_:_n()).drafts_.push(n),n}function jn(t){if(!rn(t)||yn(t))return t;const e=t[Ze];let n;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=pn(t,e.scope_.immer_.useStrictShallowCopy_)}else n=pn(t,!0);return on(n,(t,e)=>{un(n,t,jn(e))}),e&&(e.finalized_=!1),n}var Kn=new class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,e,n)=>{if("function"==typeof t&&"function"!=typeof e){const n=e;e=t;const r=this;return function(t=n,...i){return r.produce(t,t=>e.call(this,t,...i))}}let r;if("function"!=typeof e&&tn(6),void 0!==n&&"function"!=typeof n&&tn(7),rn(t)){const i=On(this),s=Nn(t,void 0);let a=!0;try{r=e(s),a=!1}finally{a?Sn(i):En(i)}return Cn(i,n),kn(r,i)}if(!t||"object"!=typeof t){if(r=e(t),void 0===r&&(r=t),r===Qe&&(r=void 0),this.autoFreeze_&&mn(r,!0),n){const e=[],i=[];wn("Patches").generateReplacementPatches_(t,r,e,i),n(e,i)}return r}tn(1)},this.produceWithPatches=(t,e)=>{if("function"==typeof t)return(e,...n)=>this.produceWithPatches(e,e=>t(e,...n));let n,r;return[this.produce(t,e,(t,e)=>{n=t,r=e}),n,r]},"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),"boolean"==typeof(null==t?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){rn(t)||tn(8),nn(t)&&(t=function(t){nn(t)||tn(10);return jn(t)}(t));const e=On(this),n=Nn(t,void 0);return n[Ze].isManual_=!0,En(e),n}finishDraft(t,e){const n=t&&t[Ze];n&&n.isManual_||tn(9);const{scope_:r}=n;return Cn(r,e),kn(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const r=e[n];if(0===r.path.length&&"replace"===r.op){t=r.value;break}}n>-1&&(e=e.slice(n+1));const r=wn("Patches").applyPatches_;return nn(t)?r(t,e):this.produce(t,t=>r(t,e))}},Wn=Kn.produce;Kn.produceWithPatches.bind(Kn),Kn.setAutoFreeze.bind(Kn),Kn.setUseStrictShallowCopy.bind(Kn),Kn.applyPatches.bind(Kn),Kn.createDraft.bind(Kn),Kn.finishDraft.bind(Kn);class Bn{constructor(t){be(this,Ct),be(this,bt),be(this,wt,500),be(this,_t,null),we(this,bt,t)}setState(t){const e=Wn(ve(this,bt).state,t);e!==ve(this,bt).state&&(ve(this,bt).state=e,$e(ve(this,bt).debug,Se.INFO,ve(this,bt).state),this.saveStateToStorage(),this.updateURLState())}updateURLState(){if(!ve(this,bt).usePushState)return;$e(ve(this,bt).debug,Se.INFO);const t=new URLSearchParams;t.set("page",ve(this,bt).state.currentPage.toString()),t.set("perPage",ve(this,bt).state.rowsPerPage.toString()),Object.entries(ve(this,bt).state.filters).forEach(([e,n])=>{n&&t.set(`filtering[${e}]`,String(n))}),ve(this,bt).state.sortConditions.forEach(([e,n])=>{t.append(`sorting[${e}]`,n)});const e=`${window.location.pathname}?${t.toString()}`;window.history.pushState({path:e},"",e)}loadFromURL(){if(!ve(this,bt).usePushState)return;$e(ve(this,bt).debug,Se.INFO);const t=new URLSearchParams(window.location.search);""!==t.toString()?this.setState(e=>{const n=t.get("page");if(n){const t=parseInt(n,10);e.currentPage=isNaN(t)?1:Math.max(1,t)}const r=t.get("perPage");if(r){const t=parseInt(r,10),n=[xe.DEFAULT,xe.TWENTY,xe.FIFTY,xe.HUNDRED,xe.TWO_HUNDRED_FIFTY,xe.FIVE_HUNDRED,xe.THOUSAND];e.rowsPerPage=isNaN(t)||!n.includes(t)?xe.DEFAULT:t}const i={};t.forEach((t,e)=>{if(e.startsWith("filtering[")){const n=e.substring(10,e.length-1);i[n]=t}}),e.filters=i;const s=[];t.forEach((t,e)=>{if(e.startsWith("sorting[")){const n=e.substring(e.indexOf("[")+1,e.indexOf("]"));Object.values(Oe).includes(t.toUpperCase())&&s.push([n,t.toUpperCase()])}}),e.sortConditions=s}):$e(ve(this,bt).debug,Se.INFO)}saveStateToStorage(){if(!ve(this,bt).persistState)return;ve(this,_t)&&clearTimeout(ve(this,_t)),$e(ve(this,bt).debug,Se.INFO);const{columns:t,columnWidths:e,sortConditions:n,filters:r,currentPage:i,rowsPerPage:s,headerCellClasses:a}=ve(this,bt).state,o={columns:[...t],columnWidths:Array.from(e.entries()),sortConditions:[...n],filters:{...r},currentPage:i,rowsPerPage:s,headerCellClasses:[...a]};we(this,_t,setTimeout(()=>{try{localStorage.setItem(ve(this,bt).storageKey,JSON.stringify(o)),$e(ve(this,bt).debug,Se.INFO)}catch(t){$e(ve(this,bt).debug,Se.ERROR)}},ve(this,wt)))}loadStateFromStorage(){if(ve(this,bt).persistState){$e(ve(this,bt).debug,Se.INFO);try{const t=localStorage.getItem(ve(this,bt).storageKey);if(!t)return void $e(ve(this,bt).debug,Se.INFO);const e=JSON.parse(t);$e(ve(this,bt).debug,Se.INFO),this.setState(t=>{if(e.columns&&Array.isArray(e.columns)&&_e(this,Ct,St).call(this,t,e.columns),e.columnWidths&&Array.isArray(e.columnWidths)){const n=e.columnWidths.filter(t=>Array.isArray(t)&&2===t.length&&"string"==typeof t[0]&&"number"==typeof t[1]);t.columnWidths=new Map(n)}if(e.sortConditions){const n=e.sortConditions.filter(t=>Array.isArray(t)&&2===t.length&&"string"==typeof t[0]&&Object.values(Oe).includes(t[1]));t.sortConditions=n}if(e.filters&&"object"==typeof e.filters){const n={};for(const[t,r]of Object.entries(e.filters))"string"==typeof r&&(n[t]=r);t.filters=n}if("number"==typeof e.currentPage&&(t.currentPage=Math.max(1,e.currentPage)),"number"==typeof e.rowsPerPage){[xe.DEFAULT,xe.TWENTY,xe.FIFTY,xe.HUNDRED,xe.TWO_HUNDRED_FIFTY,xe.FIVE_HUNDRED,xe.THOUSAND].includes(e.rowsPerPage)&&(t.rowsPerPage=e.rowsPerPage)}})}catch(t){$e(ve(this,bt).debug,Se.ERROR),localStorage.removeItem(ve(this,bt).storageKey)}}}}bt=new WeakMap,wt=new WeakMap,_t=new WeakMap,Ct=new WeakSet,St=function(t,e){const n=[...t.columns],r=[...t.columnTitles],i=[...t.headerCellClasses],s=e.filter(t=>n.includes(t)),a=n.filter(t=>!s.includes(t)),o=[...s,...a],l=[],c=[];o.forEach(t=>{const e=n.indexOf(t);-1!==e&&(l.push(r[e]),i.length>e&&c.push(i[e]))}),$e(ve(this,bt).debug,Se.LOG),t.columns=o,t.columnTitles=l,t.headerCellClasses=c};class qn{constructor(t,e,n){be(this,Rt),be(this,Et),be(this,Ot),be(this,xt),be(this,kt,null),be(this,Pt,0),be(this,At,0),be(this,Ft,t=>{$e(ve(this,Et).debug,Se.INFO),ve(this,Et).stateManager.setState(e=>{const n=e.sortConditions,r=n.findIndex(e=>e[0]===t);-1===r?n.push([t,Oe.ASC]):n[r][1]===Oe.ASC?n[r][1]=Oe.DESC:n.splice(r,1)}),ve(this,xt).requestDataLoad()}),be(this,It,t=>{var e;t.preventDefault();const n=t.target.closest("th");(null==n?void 0:n.dataset.colId)&&(null==(e=ve(this,Ot).tableHeader)||e.querySelectorAll("th").forEach(t=>{t.classList.remove(Ue.classes.dragOver)}),n.classList.add(Ue.classes.dragOver))}),be(this,jt,(t,e)=>{t.preventDefault(),we(this,kt,e);const n=ve(this,Ot).tableHeader.querySelector(`th[data-col-id="${e}"]`);n&&(we(this,Pt,t.clientX),we(this,At,n.offsetWidth),$e(ve(this,Et).debug,Se.INFO),document.addEventListener("mousemove",ve(this,Wt)),document.addEventListener("mouseup",ve(this,Bt)))}),be(this,Kt,t=>{const e={PageUp:()=>{ve(this,Et).state.currentPage>1&&ve(this,Et).gotoPage(ve(this,Et).state.currentPage-1)},PageDown:()=>{const t=Math.ceil(ve(this,Et).state.totalRecords/ve(this,Et).state.rowsPerPage);ve(this,Et).state.currentPage<t&&ve(this,Et).gotoPage(ve(this,Et).state.currentPage+1)}}[t.key];if(e)return $e(ve(this,Et).debug,Se.INFO,t.key),t.preventDefault(),void e();if(!ve(this,Et).selectable)return;const n={ArrowDown:()=>ve(this,Ot).navigateToNextRow(),ArrowUp:()=>ve(this,Ot).navigateToPrevRow(),Home:()=>ve(this,Et).reset(),End:()=>{ve(this,Et).currentRowIndex=ve(this,Et).state.data.length-1,ve(this,Ot).highlightCurrentRow()},Enter:()=>{ve(this,Et).currentRowIndex>=0&&_e(this,Rt,Mt).call(this,ve(this,Et).currentRowIndex)}," ":()=>{ve(this,Et).currentRowIndex>=0&&_e(this,Rt,Mt).call(this,ve(this,Et).currentRowIndex)}}[t.key];n&&($e(ve(this,Et).debug,Se.INFO,t.key),t.preventDefault(),n())}),be(this,Wt,t=>{if(null===ve(this,kt))return;const e=ve(this,At)+(t.clientX-ve(this,Pt));$e(ve(this,Et).debug,Se.LOG,ve(this,kt)),ve(this,Et).stateManager.setState(t=>{t.columnWidths.set(ve(this,kt),e)}),ve(this,Ot).applyColumnWidths()}),be(this,Bt,()=>{null!==ve(this,kt)&&($e(ve(this,Et).debug,Se.INFO,ve(this,kt)),we(this,kt,null),document.removeEventListener("mousemove",ve(this,Wt)),document.removeEventListener("mouseup",ve(this,Bt)),ve(this,Et).stateManager.saveStateToStorage())}),be(this,qt,t=>{const e=t.target.closest("th");(null==e?void 0:e.dataset.colId)&&e.draggable?($e(ve(this,Et).debug,Se.INFO,e.dataset.colId),t.dataTransfer&&(t.dataTransfer.setData("text/plain",e.dataset.colId),t.dataTransfer.effectAllowed="move"),e.classList.add(Ue.classes.dragging)):t.preventDefault()}),be(this,zt,t=>{var e;const n=t.target.closest("th");$e(ve(this,Et).debug,Se.INFO,null==n||n.dataset.colId),null==(e=ve(this,Ot).tableHeader)||e.querySelectorAll("th").forEach(t=>{t.classList.remove(Ue.classes.dragging),t.classList.remove(Ue.classes.dragOver)})}),be(this,Ut,t=>{var e;const n=t.target,r=n.closest('th a[role="button"]');if(r){t.preventDefault();const e=r.closest("th");return void((null==e?void 0:e.dataset.colId)&&ve(this,Ft).call(this,e.dataset.colId))}const i=n.closest(".snap-pagination-container button");if(i){if(t.preventDefault(),i.disabled)return;const n=null==(e=i.textContent)?void 0:e.trim(),r=n?parseInt(n,10):NaN;return $e(ve(this,Et).debug,Se.INFO),void(i.classList.contains(Ue.pagination.prevButton.classNames.base)?ve(this,Et).gotoPage(ve(this,Et).state.currentPage-1):i.classList.contains(Ue.pagination.nextButton.classNames.base)?ve(this,Et).gotoPage(ve(this,Et).state.currentPage+1):isNaN(r)||ve(this,Et).gotoPage(r))}const s=n.closest("[data-index]");if(ve(this,Et).selectable&&(null==s?void 0:s.dataset.index)){const t=parseInt(s.dataset.index,10);return void(isNaN(t)||(_e(this,Rt,Mt).call(this,t),s.focus()))}}),be(this,Ht,t=>{var e;t.preventDefault();const n=t.target.closest("th"),r=null==(e=t.dataTransfer)?void 0:e.getData("text/plain"),i=null==n?void 0:n.dataset.colId;r&&i&&r!==i&&($e(ve(this,Et).debug,Se.INFO),ve(this,xt).reorderColumns(r,i)),null==n||n.classList.remove(Ue.classes.dragOver)}),we(this,Et,t),we(this,Ot,e),we(this,xt,n)}setupAllHandlers(){_e(this,Rt,Tt).call(this),_e(this,Rt,Dt).call(this),_e(this,Rt,Lt).call(this),_e(this,Rt,Nt).call(this)}destroy(){$e(ve(this,Et).debug,Se.INFO),ve(this,Et).container.removeEventListener("click",ve(this,Ut)),ve(this,Et).container.removeEventListener("keydown",ve(this,Kt)),ve(this,Et).container.removeEventListener("mousedown",ve(this,jt)),ve(this,Et).container.removeEventListener("dragstart",ve(this,qt)),ve(this,Et).container.removeEventListener("dragover",ve(this,It)),ve(this,Et).container.removeEventListener("drop",ve(this,Ht)),ve(this,Et).container.removeEventListener("dragend",ve(this,zt)),document.removeEventListener("mouseup",ve(this,Bt)),document.removeEventListener("mousemove",ve(this,Wt))}}Et=new WeakMap,Ot=new WeakMap,xt=new WeakMap,kt=new WeakMap,Pt=new WeakMap,At=new WeakMap,Rt=new WeakSet,Tt=function(){ve(this,Et).container.removeEventListener("click",ve(this,Ut)),ve(this,Et).container.addEventListener("click",ve(this,Ut))},Ft=new WeakMap,Mt=function(t){const e=ve(this,Et).selectedRows.has(t);$e(ve(this,Et).debug,Se.INFO),e?ve(this,Et).selectedRows.delete(t):ve(this,Et).selectedRows.add(t),ve(this,Et).lifecycleHooks.selectionChanged&&ve(this,Et).lifecycleHooks.selectionChanged(ve(this,Et).getSelectedRows()),ve(this,Ot).highlightSelectedRows();const n=ve(this,Et).state.translations??Ve,r=ve(this,Et).selectedRows.has(t)?n.rowSelected:n.rowDeselected;ve(this,Ot).announceScreenReaderUpdate(r)},Dt=function(){ve(this,Et).container.addEventListener("mousedown",t=>{const e=t.target;if(e.classList.contains(Ue.classes.columnResizeHandle)){const n=e.closest("th");(null==n?void 0:n.dataset.colId)&&ve(this,jt).call(this,t,n.dataset.colId)}})},It=new WeakMap,Lt=function(){ve(this,Et).draggableColumns&&(ve(this,Et).container.addEventListener("dragstart",ve(this,qt)),ve(this,Et).container.addEventListener("dragover",ve(this,It)),ve(this,Et).container.addEventListener("drop",ve(this,Ht)),ve(this,Et).container.addEventListener("dragend",ve(this,zt)))},Nt=function(){ve(this,Et).container.removeEventListener("keydown",ve(this,Kt)),ve(this,Et).container.addEventListener("keydown",ve(this,Kt)),ve(this,Et).container.setAttribute("tabindex","0")},jt=new WeakMap,Kt=new WeakMap,Wt=new WeakMap,Bt=new WeakMap,qt=new WeakMap,zt=new WeakMap,Ut=new WeakMap,Ht=new WeakMap;var zn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Un(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Hn,$n={exports:{}};var Gn=(Hn||(Hn=1,$n.exports=function(){var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)},e=function(){return(e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e,n){for(var r,i=0,s=e.length;i<s;i++)!r&&i in e||((r=r||Array.prototype.slice.call(e,0,i))[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:zn,i=Object.keys,s=Array.isArray;function a(t,e){return"object"!=typeof e||i(e).forEach(function(n){t[n]=e[n]}),t}"undefined"==typeof Promise||r.Promise||(r.Promise=Promise);var o=Object.getPrototypeOf,l={}.hasOwnProperty;function c(t,e){return l.call(t,e)}function u(t,e){"function"==typeof e&&(e=e(o(t))),("undefined"==typeof Reflect?i:Reflect.ownKeys)(e).forEach(function(n){d(t,n,e[n])})}var h=Object.defineProperty;function d(t,e,n,r){h(t,e,a(n&&c(n,"get")&&"function"==typeof n.get?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function f(t){return{from:function(e){return t.prototype=Object.create(e.prototype),d(t.prototype,"constructor",t),{extend:u.bind(null,t.prototype)}}}}var p=Object.getOwnPropertyDescriptor,m=[].slice;function g(t,e,n){return m.call(t,e,n)}function y(t,e){return e(t)}function v(t){if(!t)throw new Error("Assertion Failed")}function b(t){r.setImmediate?setImmediate(t):setTimeout(t,0)}function w(t,e){if("string"==typeof e&&c(t,e))return t[e];if(!e)return t;if("string"!=typeof e){for(var n=[],r=0,i=e.length;r<i;++r){var s=w(t,e[r]);n.push(s)}return n}var a=e.indexOf(".");if(-1!==a){var o=t[e.substr(0,a)];return null==o?void 0:w(o,e.substr(a+1))}}function _(t,e,n){if(t&&void 0!==e&&(!("isFrozen"in Object)||!Object.isFrozen(t)))if("string"!=typeof e&&"length"in e){v("string"!=typeof n&&"length"in n);for(var r=0,i=e.length;r<i;++r)_(t,e[r],n[r])}else{var a,o,l=e.indexOf(".");-1!==l?(a=e.substr(0,l),""===(o=e.substr(l+1))?void 0===n?s(t)&&!isNaN(parseInt(a))?t.splice(a,1):delete t[a]:t[a]=n:_(l=(l=t[a])&&c(t,a)?l:t[a]={},o,n)):void 0===n?s(t)&&!isNaN(parseInt(e))?t.splice(e,1):delete t[e]:t[e]=n}}function C(t){var e,n={};for(e in t)c(t,e)&&(n[e]=t[e]);return n}var S=[].concat;function E(t){return S.apply([],t)}var O="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(E([8,16,32,64].map(function(t){return["Int","Uint","Float"].map(function(e){return e+t+"Array"})}))).filter(function(t){return r[t]}),x=new Set(O.map(function(t){return r[t]})),k=null;function P(t){return k=new WeakMap,t=function t(e){if(!e||"object"!=typeof e)return e;var n=k.get(e);if(n)return n;if(s(e)){n=[],k.set(e,n);for(var r=0,i=e.length;r<i;++r)n.push(t(e[r]))}else if(x.has(e.constructor))n=e;else{var a,l=o(e);for(a in n=l===Object.prototype?{}:Object.create(l),k.set(e,n),e)c(e,a)&&(n[a]=t(e[a]))}return n}(t),k=null,t}var A={}.toString;function R(t){return A.call(t).slice(8,-1)}var T="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator",F="symbol"==typeof T?function(t){var e;return null!=t&&(e=t[T])&&e.apply(t)}:function(){return null};function M(t,e){return 0<=(e=t.indexOf(e))&&t.splice(e,1),0<=e}var D={};function I(t){var e,n,r,i;if(1===arguments.length){if(s(t))return t.slice();if(this===D&&"string"==typeof t)return[t];if(i=F(t)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(null==t)return[t];if("number"!=typeof(e=t.length))return[t];for(n=new Array(e);e--;)n[e]=t[e];return n}for(e=arguments.length,n=new Array(e);e--;)n[e]=arguments[e];return n}var L="undefined"!=typeof Symbol?function(t){return"AsyncFunction"===t[Symbol.toStringTag]}:function(){return!1},N=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(ot=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"]),j={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 K(t,e){this.name=t,this.message=e}function W(t,e){return t+". Errors: "+Object.keys(e).map(function(t){return e[t].toString()}).filter(function(t,e,n){return n.indexOf(t)===e}).join("\n")}function B(t,e,n,r){this.failures=e,this.failedKeys=r,this.successCount=n,this.message=W(t,e)}function q(t,e){this.name="BulkError",this.failures=Object.keys(e).map(function(t){return e[t]}),this.failuresByPos=e,this.message=W(t,this.failures)}f(K).from(Error).extend({toString:function(){return this.name+": "+this.message}}),f(B).from(K),f(q).from(K);var z=N.reduce(function(t,e){return t[e]=e+"Error",t},{}),U=K,H=N.reduce(function(t,e){var n=e+"Error";function r(t,r){this.name=n,t?"string"==typeof t?(this.message="".concat(t).concat(r?"\n "+r:""),this.inner=r||null):"object"==typeof t&&(this.message="".concat(t.name," ").concat(t.message),this.inner=t):(this.message=j[e]||n,this.inner=null)}return f(r).from(U),t[e]=r,t},{});H.Syntax=SyntaxError,H.Type=TypeError,H.Range=RangeError;var $=ot.reduce(function(t,e){return t[e+"Error"]=H[e],t},{}),G=N.reduce(function(t,e){return-1===["Syntax","Type","Range"].indexOf(e)&&(t[e+"Error"]=H[e]),t},{});function V(){}function Y(t){return t}function X(t,e){return null==t||t===Y?e:function(n){return e(t(n))}}function Q(t,e){return function(){t.apply(this,arguments),e.apply(this,arguments)}}function J(t,e){return t===V?e:function(){var n=t.apply(this,arguments);void 0!==n&&(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?Q(r,this.onsuccess):r),i&&(this.onerror=this.onerror?Q(i,this.onerror):i),void 0!==s?s:n}}function Z(t,e){return t===V?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?Q(n,this.onsuccess):n),r&&(this.onerror=this.onerror?Q(r,this.onerror):r)}}function tt(t,e){return t===V?e:function(n){var r=t.apply(this,arguments);a(n,r);var i=this.onsuccess,s=this.onerror;return this.onsuccess=null,this.onerror=null,n=e.apply(this,arguments),i&&(this.onsuccess=this.onsuccess?Q(i,this.onsuccess):i),s&&(this.onerror=this.onerror?Q(s,this.onerror):s),void 0===r?void 0===n?void 0:n:a(r,n)}}function et(t,e){return t===V?e:function(){return!1!==e.apply(this,arguments)&&t.apply(this,arguments)}}function nt(t,e){return t===V?e:function(){var n=t.apply(this,arguments);if(n&&"function"==typeof n.then){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)}}G.ModifyError=B,G.DexieError=K,G.BulkError=q;var rt="undefined"!=typeof location&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function it(t){rt=t}var st={},at=100,ot=(O="undefined"==typeof Promise?[]:function(){var t=Promise.resolve();if("undefined"==typeof crypto||!crypto.subtle)return[t,o(t),t];var e=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[e,o(e),t]}())[0],lt=(N=O[1],O=O[2],N=N&&N.then,ot&&ot.constructor),ct=!!O,ut=function(t,e){vt.push([t,e]),dt&&(queueMicrotask(Pt),dt=!1)},ht=!0,dt=!0,ft=[],pt=[],mt=Y,gt={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:V,pgp:!1,env:{},finalize:V},yt=gt,vt=[],bt=0,wt=[];function _t(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var e=this._PSD=yt;if("function"!=typeof t){if(t!==st)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(!1===this._state&&Et(this,this._value))}this._state=null,this._value=null,++e.ref,function t(e,n){try{n(function(n){if(null===e._state){if(n===e)throw new TypeError("A promise cannot be resolved with itself.");var r=e._lib&&At();n&&"function"==typeof n.then?t(e,function(t,e){n instanceof _t?n._then(t,e):n.then(t,e)}):(e._state=!0,e._value=n,Ot(e)),r&&Rt()}},Et.bind(null,e))}catch(r){Et(e,r)}}(this,t)}var Ct={get:function(){var t=yt,e=jt;function n(n,r){var i=this,s=!t.global&&(t!==yt||e!==jt),a=s&&!qt(),o=new _t(function(e,o){xt(i,new St(Vt(n,t,s,a),Vt(r,t,s,a),e,o,t))});return this._consoleTask&&(o._consoleTask=this._consoleTask),o}return n.prototype=st,n},set:function(t){d(this,"then",t&&t.prototype===st?Ct:{get:function(){return t},set:Ct.set})}};function St(t,e,n,r,i){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.resolve=n,this.reject=r,this.psd=i}function Et(t,e){var n,r;pt.push(e),null===t._state&&(n=t._lib&&At(),e=mt(e),t._state=!1,t._value=e,r=t,ft.some(function(t){return t._value===r._value})||ft.push(r),Ot(t),n&&Rt())}function Ot(t){var e=t._listeners;t._listeners=[];for(var n=0,r=e.length;n<r;++n)xt(t,e[n]);var i=t._PSD;--i.ref||i.finalize(),0===bt&&(++bt,ut(function(){0==--bt&&Tt()},[]))}function xt(t,e){if(null!==t._state){var n=t._state?e.onFulfilled:e.onRejected;if(null===n)return(t._state?e.resolve:e.reject)(t._value);++e.psd.ref,++bt,ut(kt,[n,t,e])}else t._listeners.push(e)}function kt(t,e,n){try{var r,i=e._value;!e._state&&pt.length&&(pt=[]),r=rt&&e._consoleTask?e._consoleTask.run(function(){return t(i)}):t(i),e._state||-1!==pt.indexOf(i)||function(t){for(var e=ft.length;e;)if(ft[--e]._value===t._value)return ft.splice(e,1)}(e),n.resolve(r)}catch(s){n.reject(s)}finally{0==--bt&&Tt(),--n.psd.ref||n.psd.finalize()}}function Pt(){Gt(gt,function(){At()&&Rt()})}function At(){var t=ht;return dt=ht=!1,t}function Rt(){var t,e,n;do{for(;0<vt.length;)for(t=vt,vt=[],n=t.length,e=0;e<n;++e){var r=t[e];r[0].apply(null,r[1])}}while(0<vt.length);dt=ht=!0}function Tt(){var t=ft;ft=[],t.forEach(function(t){t._PSD.onunhandled.call(null,t._value,t)});for(var e=wt.slice(0),n=e.length;n;)e[--n]()}function Ft(t){return new _t(st,!1,t)}function Mt(t,e){var n=yt;return function(){var r=At(),i=yt;try{return Ht(n,!0),t.apply(this,arguments)}catch(s){e&&e(s)}finally{Ht(i,!1),r&&Rt()}}}u(_t.prototype,{then:Ct,_then:function(t,e){xt(this,new St(null,null,t,e,yt))},catch:function(t){if(1===arguments.length)return this.then(null,t);var e=t,n=arguments[1];return"function"==typeof e?this.then(null,function(t){return(t instanceof e?n:Ft)(t)}):this.then(null,function(t){return(t&&t.name===e?n:Ft)(t)})},finally:function(t){return this.then(function(e){return _t.resolve(t()).then(function(){return e})},function(e){return _t.resolve(t()).then(function(){return Ft(e)})})},timeout:function(t,e){var n=this;return t<1/0?new _t(function(r,i){var s=setTimeout(function(){return i(new H.Timeout(e))},t);n.then(r,i).finally(clearTimeout.bind(null,s))}):this}}),"undefined"!=typeof Symbol&&Symbol.toStringTag&&d(_t.prototype,Symbol.toStringTag,"Dexie.Promise"),gt.env=$t(),u(_t,{all:function(){var t=I.apply(null,arguments).map(zt);return new _t(function(e,n){0===t.length&&e([]);var r=t.length;t.forEach(function(i,s){return _t.resolve(i).then(function(n){t[s]=n,--r||e(t)},n)})})},resolve:function(t){return t instanceof _t?t:t&&"function"==typeof t.then?new _t(function(e,n){t.then(e,n)}):new _t(st,!0,t)},reject:Ft,race:function(){var t=I.apply(null,arguments).map(zt);return new _t(function(e,n){t.map(function(t){return _t.resolve(t).then(e,n)})})},PSD:{get:function(){return yt},set:function(t){return yt=t}},totalEchoes:{get:function(){return jt}},newPSD:Wt,usePSD:Gt,scheduler:{get:function(){return ut},set:function(t){ut=t}},rejectionMapper:{get:function(){return mt},set:function(t){mt=t}},follow:function(t,e){return new _t(function(n,r){return Wt(function(e,n){var r=yt;r.unhandleds=[],r.onunhandled=n,r.finalize=Q(function(){var t,r=this;t=function(){0===r.unhandleds.length?e():n(r.unhandleds[0])},wt.push(function e(){t(),wt.splice(wt.indexOf(e),1)}),++bt,ut(function(){0==--bt&&Tt()},[])},r.finalize),t()},e,n,r)})}}),lt&&(lt.allSettled&&d(_t,"allSettled",function(){var t=I.apply(null,arguments).map(zt);return new _t(function(e){0===t.length&&e([]);var n=t.length,r=new Array(n);t.forEach(function(t,i){return _t.resolve(t).then(function(t){return r[i]={status:"fulfilled",value:t}},function(t){return r[i]={status:"rejected",reason:t}}).then(function(){return--n||e(r)})})})}),lt.any&&"undefined"!=typeof AggregateError&&d(_t,"any",function(){var t=I.apply(null,arguments).map(zt);return new _t(function(e,n){0===t.length&&n(new AggregateError([]));var r=t.length,i=new Array(r);t.forEach(function(t,s){return _t.resolve(t).then(function(t){return e(t)},function(t){i[s]=t,--r||n(new AggregateError(i))})})})}),lt.withResolvers&&(_t.withResolvers=lt.withResolvers));var Dt={awaits:0,echoes:0,id:0},It=0,Lt=[],Nt=0,jt=0,Kt=0;function Wt(t,e,n,r){var i=yt,s=Object.create(i);return s.parent=i,s.ref=0,s.global=!1,s.id=++Kt,gt.env,s.env=ct?{Promise:_t,PromiseProp:{value:_t,configurable:!0,writable:!0},all:_t.all,race:_t.race,allSettled:_t.allSettled,any:_t.any,resolve:_t.resolve,reject:_t.reject}:{},e&&a(s,e),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()},r=Gt(s,t,n,r),0===s.ref&&s.finalize(),r}function Bt(){return Dt.id||(Dt.id=++It),++Dt.awaits,Dt.echoes+=at,Dt.id}function qt(){return!!Dt.awaits&&(0==--Dt.awaits&&(Dt.id=0),Dt.echoes=Dt.awaits*at,!0)}function zt(t){return Dt.echoes&&t&&t.constructor===lt?(Bt(),t.then(function(t){return qt(),t},function(t){return qt(),Xt(t)})):t}function Ut(){var t=Lt[Lt.length-1];Lt.pop(),Ht(t,!1)}function Ht(t,e){var n,i=yt;(e?!Dt.echoes||Nt++&&t===yt:!Nt||--Nt&&t===yt)||queueMicrotask(e?function(t){++jt,Dt.echoes&&0!=--Dt.echoes||(Dt.echoes=Dt.awaits=Dt.id=0),Lt.push(yt),Ht(t,!0)}.bind(null,t):Ut),t!==yt&&(yt=t,i===gt&&(gt.env=$t()),ct&&(n=gt.env.Promise,e=t.env,(i.global||t.global)&&(Object.defineProperty(r,"Promise",e.PromiseProp),n.all=e.all,n.race=e.race,n.resolve=e.resolve,n.reject=e.reject,e.allSettled&&(n.allSettled=e.allSettled),e.any&&(n.any=e.any))))}function $t(){var t=r.Promise;return ct?{Promise:t,PromiseProp:Object.getOwnPropertyDescriptor(r,"Promise"),all:t.all,race:t.race,allSettled:t.allSettled,any:t.any,resolve:t.resolve,reject:t.reject}:{}}function Gt(t,e,n,r,i){var s=yt;try{return Ht(t,!0),e(n,r,i)}finally{Ht(s,!1)}}function Vt(t,e,n,r){return"function"!=typeof t?t:function(){var i=yt;n&&Bt(),Ht(e,!0);try{return t.apply(this,arguments)}finally{Ht(i,!1),r&&queueMicrotask(qt)}}}function Yt(t){Promise===lt&&0===Dt.echoes?0===Nt?t():enqueueNativeMicroTask(t):setTimeout(t,0)}-1===(""+N).indexOf("[native code]")&&(Bt=qt=V);var Xt=_t.reject,Qt=String.fromCharCode(65535),Jt="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",Zt="String expected.",te=[],ee="__dbnames",ne="readonly",re="readwrite";function ie(t,e){return t?e?function(){return t.apply(this,arguments)&&e.apply(this,arguments)}:t:e}var se={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function ae(t){return"string"!=typeof t||/\./.test(t)?function(t){return t}:function(e){return void 0===e[t]&&t in e&&delete(e=P(e))[t],e}}function oe(){throw H.Type()}function le(t,e){try{var n=ce(t),r=ce(e);if(n!==r)return"Array"===n?1:"Array"===r?-1:"binary"===n?1:"binary"===r?-1:"string"===n?1:"string"===r?-1:"Date"===n?1:"Date"!==r?NaN:-1;switch(n){case"number":case"Date":case"string":return e<t?1:t<e?-1:0;case"binary":return function(t,e){for(var n=t.length,r=e.length,i=n<r?n:r,s=0;s<i;++s)if(t[s]!==e[s])return t[s]<e[s]?-1:1;return n===r?0:n<r?-1:1}(ue(t),ue(e));case"Array":return function(t,e){for(var n=t.length,r=e.length,i=n<r?n:r,s=0;s<i;++s){var a=le(t[s],e[s]);if(0!==a)return a}return n===r?0:n<r?-1:1}(t,e)}}catch(i){}return NaN}function ce(t){var e=typeof t;return"object"!=e?e:ArrayBuffer.isView(t)||"ArrayBuffer"===(t=R(t))?"binary":t}function ue(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}var he=(de.prototype._trans=function(t,e,n){var r=this._tx||yt.trans,i=this.name,s=rt&&"undefined"!=typeof console&&console.createTask&&void 0;function a(t,n,r){if(!r.schema[i])throw new H.NotFound("Table "+i+" not part of transaction");return e(r.idbtrans,r)}var o=At();try{var l=r&&r.db._novip===this.db._novip?r===yt.trans?r._promise(t,a,n):Wt(function(){return r._promise(t,a,n)},{trans:r,transless:yt.transless||yt}):function t(e,n,r,i){if(e.idbdb&&(e._state.openComplete||yt.letThrough||e._vip)){var s=e._createTransaction(n,r,e._dbSchema);try{s.create(),e._state.PR1398_maxLoop=3}catch(a){return a.name===z.InvalidState&&e.isOpen()&&0<--e._state.PR1398_maxLoop?(e.close({disableAutoOpen:!1}),e.open().then(function(){return t(e,n,r,i)})):Xt(a)}return s._promise(n,function(t,e){return Wt(function(){return yt.trans=s,i(t,e,s)})}).then(function(t){if("readwrite"===n)try{s.idbtrans.commit()}catch(e){}return"readonly"===n?t:s._completion.then(function(){return t})})}if(e._state.openComplete)return Xt(new H.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._state.autoOpen)return Xt(new H.DatabaseClosed);e.open().catch(V)}return e._state.dbReadyPromise.then(function(){return t(e,n,r,i)})}(this.db,t,[this.name],a);return s&&(l._consoleTask=s,l=l.catch(function(t){return Xt(t)})),l}finally{o&&Rt()}},de.prototype.get=function(t,e){var n=this;return t&&t.constructor===Object?this.where(t).first(e):null==t?Xt(new H.Type("Invalid argument to Table.get()")):this._trans("readonly",function(e){return n.core.get({trans:e,key:t}).then(function(t){return n.hook.reading.fire(t)})}).then(e)},de.prototype.where=function(t){if("string"==typeof t)return new this.db.WhereClause(this,t);if(s(t))return new this.db.WhereClause(this,"[".concat(t.join("+"),"]"));var e=i(t);if(1===e.length)return this.where(e[0]).equals(t[e[0]]);var n=this.schema.indexes.concat(this.schema.primKey).filter(function(t){if(t.compound&&e.every(function(e){return 0<=t.keyPath.indexOf(e)})){for(var n=0;n<e.length;++n)if(-1===e.indexOf(t.keyPath[n]))return!1;return!0}return!1}).sort(function(t,e){return t.keyPath.length-e.keyPath.length})[0];if(n&&this.db._maxKey!==Qt){var r=n.keyPath.slice(0,e.length);return this.where(r).equals(r.map(function(e){return t[e]}))}var a=this.schema.idxByName;function o(t,e){return 0===le(t,e)}r=(l=e.reduce(function(e,n){var r=e[0],i=e[1],l=(e=a[n],t[n]);return[r||e,r||!e?ie(i,e&&e.multi?function(t){return t=w(t,n),s(t)&&t.some(function(t){return o(l,t)})}:function(t){return o(l,w(t,n))}):i]},[null,null]))[0];var l=l[1];return r?this.where(r.name).equals(t[r.keyPath]).filter(l):n?this.filter(l):this.where(e).equals("")},de.prototype.filter=function(t){return this.toCollection().and(t)},de.prototype.count=function(t){return this.toCollection().count(t)},de.prototype.offset=function(t){return this.toCollection().offset(t)},de.prototype.limit=function(t){return this.toCollection().limit(t)},de.prototype.each=function(t){return this.toCollection().each(t)},de.prototype.toArray=function(t){return this.toCollection().toArray(t)},de.prototype.toCollection=function(){return new this.db.Collection(new this.db.WhereClause(this))},de.prototype.orderBy=function(t){return new this.db.Collection(new this.db.WhereClause(this,s(t)?"[".concat(t.join("+"),"]"):t))},de.prototype.reverse=function(){return this.toCollection().reverse()},de.prototype.mapToClass=function(e){var n,r=this.db,i=this.name;function s(){return null!==n&&n.apply(this,arguments)||this}(this.schema.mappedClass=e).prototype instanceof oe&&(function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(s,n=e),Object.defineProperty(s.prototype,"db",{get:function(){return r},enumerable:!1,configurable:!0}),s.prototype.table=function(){return i},e=s);for(var a=new Set,l=e.prototype;l;l=o(l))Object.getOwnPropertyNames(l).forEach(function(t){return a.add(t)});function c(t){if(!t)return t;var n,r=Object.create(e.prototype);for(n in t)if(!a.has(n))try{r[n]=t[n]}catch(i){}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=c,this.hook("reading",c),e},de.prototype.defineClass=function(){return this.mapToClass(function(t){a(this,t)})},de.prototype.add=function(t,e){var n=this,r=this.schema.primKey,i=r.auto,s=r.keyPath,a=t;return s&&i&&(a=ae(s)(t)),this._trans("readwrite",function(t){return n.core.mutate({trans:t,type:"add",keys:null!=e?[e]:null,values:[a]})}).then(function(t){return t.numFailures?_t.reject(t.failures[0]):t.lastResult}).then(function(e){if(s)try{_(t,s,e)}catch(n){}return e})},de.prototype.update=function(t,e){return"object"!=typeof t||s(t)?this.where(":id").equals(t).modify(e):void 0===(t=w(t,this.schema.primKey.keyPath))?Xt(new H.InvalidArgument("Given object does not contain its primary key")):this.where(":id").equals(t).modify(e)},de.prototype.put=function(t,e){var n=this,r=this.schema.primKey,i=r.auto,s=r.keyPath,a=t;return s&&i&&(a=ae(s)(t)),this._trans("readwrite",function(t){return n.core.mutate({trans:t,type:"put",values:[a],keys:null!=e?[e]:null})}).then(function(t){return t.numFailures?_t.reject(t.failures[0]):t.lastResult}).then(function(e){if(s)try{_(t,s,e)}catch(n){}return e})},de.prototype.delete=function(t){var e=this;return this._trans("readwrite",function(n){return e.core.mutate({trans:n,type:"delete",keys:[t]})}).then(function(t){return t.numFailures?_t.reject(t.failures[0]):void 0})},de.prototype.clear=function(){var t=this;return this._trans("readwrite",function(e){return t.core.mutate({trans:e,type:"deleteRange",range:se})}).then(function(t){return t.numFailures?_t.reject(t.failures[0]):void 0})},de.prototype.bulkGet=function(t){var e=this;return this._trans("readonly",function(n){return e.core.getMany({keys:t,trans:n}).then(function(t){return t.map(function(t){return e.hook.reading.fire(t)})})})},de.prototype.bulkAdd=function(t,e,n){var r=this,i=Array.isArray(e)?e:void 0,s=(n=n||(i?void 0:e))?n.allKeys:void 0;return this._trans("readwrite",function(e){var n=(o=r.schema.primKey).auto;if((o=o.keyPath)&&i)throw new H.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new H.InvalidArgument("Arguments objects and keys must have the same length");var a=t.length,o=o&&n?t.map(ae(o)):t;return r.core.mutate({trans:e,type:"add",keys:i,values:o,wantResults:s}).then(function(t){var e=t.numFailures,n=t.results,i=t.lastResult;if(t=t.failures,0===e)return s?n:i;throw new q("".concat(r.name,".bulkAdd(): ").concat(e," of ").concat(a," operations failed"),t)})})},de.prototype.bulkPut=function(t,e,n){var r=this,i=Array.isArray(e)?e:void 0,s=(n=n||(i?void 0:e))?n.allKeys:void 0;return this._trans("readwrite",function(e){var n=(o=r.schema.primKey).auto;if((o=o.keyPath)&&i)throw new H.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new H.InvalidArgument("Arguments objects and keys must have the same length");var a=t.length,o=o&&n?t.map(ae(o)):t;return r.core.mutate({trans:e,type:"put",keys:i,values:o,wantResults:s}).then(function(t){var e=t.numFailures,n=t.results,i=t.lastResult;if(t=t.failures,0===e)return s?n:i;throw new q("".concat(r.name,".bulkPut(): ").concat(e," of ").concat(a," operations failed"),t)})})},de.prototype.bulkUpdate=function(t){var e=this,n=this.core,r=t.map(function(t){return t.key}),i=t.map(function(t){return t.changes}),s=[];return this._trans("readwrite",function(a){return n.getMany({trans:a,keys:r,cache:"clone"}).then(function(o){var l=[],c=[];t.forEach(function(t,n){var r=t.key,i=t.changes,a=o[n];if(a){for(var u=0,h=Object.keys(i);u<h.length;u++){var d=h[u],f=i[d];if(d===e.schema.primKey.keyPath){if(0!==le(f,r))throw new H.Constraint("Cannot update primary key in bulkUpdate()")}else _(a,d,f)}s.push(n),l.push(r),c.push(a)}});var u=l.length;return n.mutate({trans:a,type:"put",keys:l,values:c,updates:{keys:r,changeSpecs:i}}).then(function(t){var n=t.numFailures,r=t.failures;if(0===n)return u;for(var i=0,a=Object.keys(r);i<a.length;i++){var o,l=a[i],c=s[Number(l)];null!=c&&(o=r[l],delete r[l],r[c]=o)}throw new q("".concat(e.name,".bulkUpdate(): ").concat(n," of ").concat(u," operations failed"),r)})})})},de.prototype.bulkDelete=function(t){var e=this,n=t.length;return this._trans("readwrite",function(n){return e.core.mutate({trans:n,type:"delete",keys:t})}).then(function(t){var r=t.numFailures,i=t.lastResult;if(t=t.failures,0===r)return i;throw new q("".concat(e.name,".bulkDelete(): ").concat(r," of ").concat(n," operations failed"),t)})},de);function de(){}function fe(t){function e(e,r){if(r){for(var i=arguments.length,s=new Array(i-1);--i;)s[i-1]=arguments[i];return n[e].subscribe.apply(null,s),t}if("string"==typeof e)return n[e]}var n={};e.addEventType=o;for(var r=1,a=arguments.length;r<a;++r)o(arguments[r]);return e;function o(t,r,a){if("object"!=typeof t){var l;r=r||et;var c={subscribers:[],fire:a=a||V,subscribe:function(t){-1===c.subscribers.indexOf(t)&&(c.subscribers.push(t),c.fire=r(c.fire,t))},unsubscribe:function(t){c.subscribers=c.subscribers.filter(function(e){return e!==t}),c.fire=c.subscribers.reduce(r,a)}};return n[t]=e[t]=c}i(l=t).forEach(function(t){var e=l[t];if(s(e))o(t,l[t][0],l[t][1]);else{if("asap"!==e)throw new H.InvalidArgument("Invalid event config");var n=o(t,Y,function(){for(var t=arguments.length,e=new Array(t);t--;)e[t]=arguments[t];n.subscribers.forEach(function(t){b(function(){t.apply(null,e)})})})}})}}function pe(t,e){return f(e).from({prototype:t}),e}function me(t,e){return!(t.filter||t.algorithm||t.or)&&(e?t.justLimit:!t.replayFilter)}function ge(t,e){t.filter=ie(t.filter,e)}function ye(t,e,n){var r=t.replayFilter;t.replayFilter=r?function(){return ie(r(),e())}:e,t.justLimit=n&&!r}function ve(t,e){if(t.isPrimKey)return e.primaryKey;var n=e.getIndexByKeyPath(t.index);if(!n)throw new H.Schema("KeyPath "+t.index+" on object store "+e.name+" is not indexed");return n}function be(t,e,n){var r=ve(t,e.schema);return e.openCursor({trans:n,values:!t.keysOnly,reverse:"prev"===t.dir,unique:!!t.unique,query:{index:r,range:t.range}})}function we(t,e,n,r){var i=t.replayFilter?ie(t.filter,t.replayFilter()):t.filter;if(t.or){var s={},a=function(t,n,r){var a,o;i&&!i(n,r,function(t){return n.stop(t)},function(t){return n.fail(t)})||("[object ArrayBuffer]"==(o=""+(a=n.primaryKey))&&(o=""+new Uint8Array(a)),c(s,o)||(s[o]=!0,e(t,n,r)))};return Promise.all([t.or._iterate(a,n),_e(be(t,r,n),t.algorithm,a,!t.keysOnly&&t.valueMapper)])}return _e(be(t,r,n),ie(t.algorithm,i),e,!t.keysOnly&&t.valueMapper)}function _e(t,e,n,r){var i=Mt(r?function(t,e,i){return n(r(t),e,i)}:n);return t.then(function(t){if(t)return t.start(function(){var n=function(){return t.continue()};e&&!e(t,function(t){return n=t},function(e){t.stop(e),n=V},function(e){t.fail(e),n=V})||i(t.value,t,function(t){return n=t}),n()})})}var Ce=(Se.prototype.execute=function(t){var e=this["@@propmod"];if(void 0!==e.add){var r=e.add;if(s(r))return n(n([],s(t)?t:[],!0),r).sort();if("number"==typeof r)return(Number(t)||0)+r;if("bigint"==typeof r)try{return BigInt(t)+r}catch(a){return BigInt(0)+r}throw new TypeError("Invalid term ".concat(r))}if(void 0!==e.remove){var i=e.remove;if(s(i))return s(t)?t.filter(function(t){return!i.includes(t)}).sort():[];if("number"==typeof i)return Number(t)-i;if("bigint"==typeof i)try{return BigInt(t)-i}catch(a){return BigInt(0)-i}throw new TypeError("Invalid subtrahend ".concat(i))}return(r=null===(r=e.replacePrefix)||void 0===r?void 0:r[0])&&"string"==typeof t&&t.startsWith(r)?e.replacePrefix[1]+t.substring(r.length):t},Se);function Se(t){this["@@propmod"]=t}var Ee=(Oe.prototype._read=function(t,e){var n=this._ctx;return n.error?n.table._trans(null,Xt.bind(null,n.error)):n.table._trans("readonly",t).then(e)},Oe.prototype._write=function(t){var e=this._ctx;return e.error?e.table._trans(null,Xt.bind(null,e.error)):e.table._trans("readwrite",t,"locked")},Oe.prototype._addAlgorithm=function(t){var e=this._ctx;e.algorithm=ie(e.algorithm,t)},Oe.prototype._iterate=function(t,e){return we(this._ctx,t,e,this._ctx.table.core)},Oe.prototype.clone=function(t){var e=Object.create(this.constructor.prototype),n=Object.create(this._ctx);return t&&a(n,t),e._ctx=n,e},Oe.prototype.raw=function(){return this._ctx.valueMapper=null,this},Oe.prototype.each=function(t){var e=this._ctx;return this._read(function(n){return we(e,t,n,e.table.core)})},Oe.prototype.count=function(t){var e=this;return this._read(function(t){var n=e._ctx,r=n.table.core;if(me(n,!0))return r.count({trans:t,query:{index:ve(n,r.schema),range:n.range}}).then(function(t){return Math.min(t,n.limit)});var i=0;return we(n,function(){return++i,!1},t,r).then(function(){return i})}).then(t)},Oe.prototype.sortBy=function(t,e){var n=t.split(".").reverse(),r=n[0],i=n.length-1;function s(t,e){return e?s(t[n[e]],e-1):t[r]}var a="next"===this._ctx.dir?1:-1;function o(t,e){return le(s(t,i),s(e,i))*a}return this.toArray(function(t){return t.sort(o)}).then(e)},Oe.prototype.toArray=function(t){var e=this;return this._read(function(t){var n=e._ctx;if("next"===n.dir&&me(n,!0)&&0<n.limit){var r=n.valueMapper,i=ve(n,n.table.core.schema);return n.table.core.query({trans:t,limit:n.limit,values:!0,query:{index:i,range:n.range}}).then(function(t){return t=t.result,r?t.map(r):t})}var s=[];return we(n,function(t){return s.push(t)},t,n.table.core).then(function(){return s})},t)},Oe.prototype.offset=function(t){var e=this._ctx;return t<=0||(e.offset+=t,me(e)?ye(e,function(){var e=t;return function(t,n){return 0===e||(1===e?--e:n(function(){t.advance(e),e=0}),!1)}}):ye(e,function(){var e=t;return function(){return--e<0}})),this},Oe.prototype.limit=function(t){return this._ctx.limit=Math.min(this._ctx.limit,t),ye(this._ctx,function(){var e=t;return function(t,n,r){return--e<=0&&n(r),0<=e}},!0),this},Oe.prototype.until=function(t,e){return ge(this._ctx,function(n,r,i){return!t(n.value)||(r(i),e)}),this},Oe.prototype.first=function(t){return this.limit(1).toArray(function(t){return t[0]}).then(t)},Oe.prototype.last=function(t){return this.reverse().first(t)},Oe.prototype.filter=function(t){var e;return ge(this._ctx,function(e){return t(e.value)}),(e=this._ctx).isMatch=ie(e.isMatch,t),this},Oe.prototype.and=function(t){return this.filter(t)},Oe.prototype.or=function(t){return new this.db.WhereClause(this._ctx.table,t,this)},Oe.prototype.reverse=function(){return this._ctx.dir="prev"===this._ctx.dir?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this},Oe.prototype.desc=function(){return this.reverse()},Oe.prototype.eachKey=function(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,n){t(n.key,n)})},Oe.prototype.eachUniqueKey=function(t){return this._ctx.unique="unique",this.eachKey(t)},Oe.prototype.eachPrimaryKey=function(t){var e=this._ctx;return e.keysOnly=!e.isMatch,this.each(function(e,n){t(n.primaryKey,n)})},Oe.prototype.keys=function(t){var e=this._ctx;e.keysOnly=!e.isMatch;var n=[];return this.each(function(t,e){n.push(e.key)}).then(function(){return n}).then(t)},Oe.prototype.primaryKeys=function(t){var e=this._ctx;if("next"===e.dir&&me(e,!0)&&0<e.limit)return this._read(function(t){var n=ve(e,e.table.core.schema);return e.table.core.query({trans:t,values:!1,limit:e.limit,query:{index:n,range:e.range}})}).then(function(t){return t.result}).then(t);e.keysOnly=!e.isMatch;var n=[];return this.each(function(t,e){n.push(e.primaryKey)}).then(function(){return n}).then(t)},Oe.prototype.uniqueKeys=function(t){return this._ctx.unique="unique",this.keys(t)},Oe.prototype.firstKey=function(t){return this.limit(1).keys(function(t){return t[0]}).then(t)},Oe.prototype.lastKey=function(t){return this.reverse().firstKey(t)},Oe.prototype.distinct=function(){var t;if(!(t=(t=this._ctx).index&&t.table.schema.idxByName[t.index])||!t.multi)return this;var e={};return ge(this._ctx,function(t){var n=t.primaryKey.toString();return t=c(e,n),e[n]=!0,!t}),this},Oe.prototype.modify=function(t){var e=this,n=this._ctx;return this._write(function(r){var s,a,o;o="function"==typeof t?t:(s=i(t),a=s.length,function(e){for(var n=!1,r=0;r<a;++r){var i=s[r],o=t[i],l=w(e,i);o instanceof Ce?(_(e,i,o.execute(l)),n=!0):l!==o&&(_(e,i,o),n=!0)}return n});var l,c=n.table.core,u=(l=c.schema.primaryKey).outbound,h=l.extractKey,d=200;function f(t,e){var n=e.failures;e=e.numFailures,m+=t-e;for(var r=0,s=i(n);r<s.length;r++){var a=s[r];p.push(n[a])}}(l=e.db._options.modifyChunkSize)&&(d="object"==typeof l?l[c.name]||l["*"]||200:l);var p=[],m=0,g=[];return e.clone().primaryKeys().then(function(e){function i(n){var a=Math.min(d,e.length-n);return c.getMany({trans:r,keys:e.slice(n,n+a),cache:"immutable"}).then(function(l){for(var p=[],m=[],g=u?[]:null,y=[],v=0;v<a;++v){var b=l[v],w={value:P(b),primKey:e[n+v]};!1!==o.call(w,w.value,w)&&(null==w.value?y.push(e[n+v]):u||0===le(h(b),h(w.value))?(m.push(w.value),u&&g.push(e[n+v])):(y.push(e[n+v]),p.push(w.value)))}return Promise.resolve(0<p.length&&c.mutate({trans:r,type:"add",values:p}).then(function(t){for(var e in t.failures)y.splice(parseInt(e),1);f(p.length,t)})).then(function(){return(0<m.length||s&&"object"==typeof t)&&c.mutate({trans:r,type:"put",keys:g,values:m,criteria:s,changeSpec:"function"!=typeof t&&t,isAdditionalChunk:0<n}).then(function(t){return f(m.length,t)})}).then(function(){return(0<y.length||s&&t===xe)&&c.mutate({trans:r,type:"delete",keys:y,criteria:s,isAdditionalChunk:0<n}).then(function(t){return f(y.length,t)})}).then(function(){return e.length>n+a&&i(n+d)})})}var s=me(n)&&n.limit===1/0&&("function"!=typeof t||t===xe)&&{index:n.index,range:n.range};return i(0).then(function(){if(0<p.length)throw new B("Error modifying one or more objects",p,m,g);return e.length})})})},Oe.prototype.delete=function(){var t=this._ctx,e=t.range;return me(t)&&(t.isPrimKey||3===e.type)?this._write(function(n){var r=t.table.core.schema.primaryKey,i=e;return t.table.core.count({trans:n,query:{index:r,range:i}}).then(function(e){return t.table.core.mutate({trans:n,type:"deleteRange",range:i}).then(function(t){var n=t.failures;if(t.lastResult,t.results,t=t.numFailures)throw new B("Could not delete some values",Object.keys(n).map(function(t){return n[t]}),e-t);return e-t})})}):this.modify(xe)},Oe);function Oe(){}var xe=function(t,e){return e.value=null};function ke(t,e){return t<e?-1:t===e?0:1}function Pe(t,e){return e<t?-1:t===e?0:1}function Ae(t,e,n){return(t=t instanceof De?new t.Collection(t):t)._ctx.error=new(n||TypeError)(e),t}function Re(t){return new t.Collection(t,function(){return Me("")}).limit(0)}function Te(t,e,n,r){var i,s,a,o,l,c,u,h=n.length;if(!n.every(function(t){return"string"==typeof t}))return Ae(t,Zt);function d(t){i="next"===t?function(t){return t.toUpperCase()}:function(t){return t.toLowerCase()},s="next"===t?function(t){return t.toLowerCase()}:function(t){return t.toUpperCase()},a="next"===t?ke:Pe;var e=n.map(function(t){return{lower:s(t),upper:i(t)}}).sort(function(t,e){return a(t.lower,e.lower)});o=e.map(function(t){return t.upper}),l=e.map(function(t){return t.lower}),u="next"===(c=t)?"":r}d("next"),(t=new t.Collection(t,function(){return Fe(o[0],l[h-1]+r)}))._ondirectionchange=function(t){d(t)};var f=0;return t._addAlgorithm(function(t,n,r){var i=t.key;if("string"!=typeof i)return!1;var d=s(i);if(e(d,l,f))return!0;for(var p=null,m=f;m<h;++m){var g=function(t,e,n,r,i,s){for(var a=Math.min(t.length,r.length),o=-1,l=0;l<a;++l){var c=e[l];if(c!==r[l])return i(t[l],n[l])<0?t.substr(0,l)+n[l]+n.substr(l+1):i(t[l],r[l])<0?t.substr(0,l)+r[l]+n.substr(l+1):0<=o?t.substr(0,o)+e[o]+n.substr(o+1):null;i(t[l],c)<0&&(o=l)}return a<r.length&&"next"===s?t+n.substr(t.length):a<t.length&&"prev"===s?t.substr(0,n.length):o<0?null:t.substr(0,o)+r[o]+n.substr(o+1)}(i,d,o[m],l[m],a,c);null===g&&null===p?f=m+1:(null===p||0<a(p,g))&&(p=g)}return n(null!==p?function(){t.continue(p+u)}:r),!1}),t}function Fe(t,e,n,r){return{type:2,lower:t,upper:e,lowerOpen:n,upperOpen:r}}function Me(t){return{type:1,lower:t,upper:t}}var De=(Object.defineProperty(Ie.prototype,"Collection",{get:function(){return this._ctx.table.db.Collection},enumerable:!1,configurable:!0}),Ie.prototype.between=function(t,e,n,r){n=!1!==n,r=!0===r;try{return 0<this._cmp(t,e)||0===this._cmp(t,e)&&(n||r)&&(!n||!r)?Re(this):new this.Collection(this,function(){return Fe(t,e,!n,!r)})}catch(i){return Ae(this,Jt)}},Ie.prototype.equals=function(t){return null==t?Ae(this,Jt):new this.Collection(this,function(){return Me(t)})},Ie.prototype.above=function(t){return null==t?Ae(this,Jt):new this.Collection(this,function(){return Fe(t,void 0,!0)})},Ie.prototype.aboveOrEqual=function(t){return null==t?Ae(this,Jt):new this.Collection(this,function(){return Fe(t,void 0,!1)})},Ie.prototype.below=function(t){return null==t?Ae(this,Jt):new this.Collection(this,function(){return Fe(void 0,t,!1,!0)})},Ie.prototype.belowOrEqual=function(t){return null==t?Ae(this,Jt):new this.Collection(this,function(){return Fe(void 0,t)})},Ie.prototype.startsWith=function(t){return"string"!=typeof t?Ae(this,Zt):this.between(t,t+Qt,!0,!0)},Ie.prototype.startsWithIgnoreCase=function(t){return""===t?this.startsWith(t):Te(this,function(t,e){return 0===t.indexOf(e[0])},[t],Qt)},Ie.prototype.equalsIgnoreCase=function(t){return Te(this,function(t,e){return t===e[0]},[t],"")},Ie.prototype.anyOfIgnoreCase=function(){var t=I.apply(D,arguments);return 0===t.length?Re(this):Te(this,function(t,e){return-1!==e.indexOf(t)},t,"")},Ie.prototype.startsWithAnyOfIgnoreCase=function(){var t=I.apply(D,arguments);return 0===t.length?Re(this):Te(this,function(t,e){return e.some(function(e){return 0===t.indexOf(e)})},t,Qt)},Ie.prototype.anyOf=function(){var t=this,e=I.apply(D,arguments),n=this._cmp;try{e.sort(n)}catch(s){return Ae(this,Jt)}if(0===e.length)return Re(this);var r=new this.Collection(this,function(){return Fe(e[0],e[e.length-1])});r._ondirectionchange=function(r){n="next"===r?t._ascending:t._descending,e.sort(n)};var i=0;return r._addAlgorithm(function(t,r,s){for(var a=t.key;0<n(a,e[i]);)if(++i===e.length)return r(s),!1;return 0===n(a,e[i])||(r(function(){t.continue(e[i])}),!1)}),r},Ie.prototype.notEqual=function(t){return this.inAnyRange([[-1/0,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})},Ie.prototype.noneOf=function(){var t=I.apply(D,arguments);if(0===t.length)return new this.Collection(this);try{t.sort(this._ascending)}catch(n){return Ae(this,Jt)}var e=t.reduce(function(t,e){return t?t.concat([[t[t.length-1][1],e]]):[[-1/0,e]]},null);return e.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(e,{includeLowers:!1,includeUppers:!1})},Ie.prototype.inAnyRange=function(t,e){var n=this,r=this._cmp,i=this._ascending,s=this._descending,a=this._min,o=this._max;if(0===t.length)return Re(this);if(!t.every(function(t){return void 0!==t[0]&&void 0!==t[1]&&i(t[0],t[1])<=0}))return Ae(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",H.InvalidArgument);var l,c=!e||!1!==e.includeLowers,u=e&&!0===e.includeUppers,h=i;function d(t,e){return h(t[0],e[0])}try{(l=t.reduce(function(t,e){for(var n=0,i=t.length;n<i;++n){var s=t[n];if(r(e[0],s[1])<0&&0<r(e[1],s[0])){s[0]=a(s[0],e[0]),s[1]=o(s[1],e[1]);break}}return n===i&&t.push(e),t},[])).sort(d)}catch(y){return Ae(this,Jt)}var f=0,p=u?function(t){return 0<i(t,l[f][1])}:function(t){return 0<=i(t,l[f][1])},m=c?function(t){return 0<s(t,l[f][0])}:function(t){return 0<=s(t,l[f][0])},g=p;return(t=new this.Collection(this,function(){return Fe(l[0][0],l[l.length-1][1],!c,!u)}))._ondirectionchange=function(t){h="next"===t?(g=p,i):(g=m,s),l.sort(d)},t._addAlgorithm(function(t,e,r){for(var s,a=t.key;g(a);)if(++f===l.length)return e(r),!1;return!p(s=a)&&!m(s)||(0===n._cmp(a,l[f][1])||0===n._cmp(a,l[f][0])||e(function(){h===i?t.continue(l[f][0]):t.continue(l[f][1])}),!1)}),t},Ie.prototype.startsWithAnyOf=function(){var t=I.apply(D,arguments);return t.every(function(t){return"string"==typeof t})?0===t.length?Re(this):this.inAnyRange(t.map(function(t){return[t,t+Qt]})):Ae(this,"startsWithAnyOf() only works with strings")},Ie);function Ie(){}function Le(t){return Mt(function(e){return Ne(e),t(e.target.error),!1})}function Ne(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault()}var je="storagemutated",Ke="x-storagemutated-1",We=fe(null,je),Be=(qe.prototype._lock=function(){return v(!yt.global),++this._reculock,1!==this._reculock||yt.global||(yt.lockOwnerFor=this),this},qe.prototype._unlock=function(){if(v(!yt.global),0==--this._reculock)for(yt.global||(yt.lockOwnerFor=null);0<this._blockedFuncs.length&&!this._locked();){var t=this._blockedFuncs.shift();try{Gt(t[1],t[0])}catch(e){}}return this},qe.prototype._locked=function(){return this._reculock&&yt.lockOwnerFor!==this},qe.prototype.create=function(t){var e=this;if(!this.mode)return this;var n=this.db.idbdb,r=this.db._state.dbOpenError;if(v(!this.idbtrans),!t&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new H.DatabaseClosed(r);case"MissingAPIError":throw new H.MissingAPI(r.message,r);default:throw new H.OpenFailed(r)}if(!this.active)throw new H.TransactionInactive;return v(null===this._completion._state),(t=this.idbtrans=t||(this.db.core||n).transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability})).onerror=Mt(function(n){Ne(n),e._reject(t.error)}),t.onabort=Mt(function(n){Ne(n),e.active&&e._reject(new H.Abort(t.error)),e.active=!1,e.on("abort").fire(n)}),t.oncomplete=Mt(function(){e.active=!1,e._resolve(),"mutatedParts"in t&&We.storagemutated.fire(t.mutatedParts)}),this},qe.prototype._promise=function(t,e,n){var r=this;if("readwrite"===t&&"readwrite"!==this.mode)return Xt(new H.ReadOnly("Transaction is readonly"));if(!this.active)return Xt(new H.TransactionInactive);if(this._locked())return new _t(function(i,s){r._blockedFuncs.push([function(){r._promise(t,e,n).then(i,s)},yt])});if(n)return Wt(function(){var t=new _t(function(t,n){r._lock();var i=e(t,n,r);i&&i.then&&i.then(t,n)});return t.finally(function(){return r._unlock()}),t._lib=!0,t});var i=new _t(function(t,n){var i=e(t,n,r);i&&i.then&&i.then(t,n)});return i._lib=!0,i},qe.prototype._root=function(){return this.parent?this.parent._root():this},qe.prototype.waitFor=function(t){var e,n=this._root(),r=_t.resolve(t);n._waitingFor?n._waitingFor=n._waitingFor.then(function(){return r}):(n._waitingFor=r,n._waitingQueue=[],e=n.idbtrans.objectStore(n.storeNames[0]),function t(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(e.get(-1/0).onsuccess=t)}());var i=n._waitingFor;return new _t(function(t,e){r.then(function(e){return n._waitingQueue.push(Mt(t.bind(null,e)))},function(t){return n._waitingQueue.push(Mt(e.bind(null,t)))}).finally(function(){n._waitingFor===i&&(n._waitingFor=null)})})},qe.prototype.abort=function(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new H.Abort))},qe.prototype.table=function(t){var e=this._memoizedTables||(this._memoizedTables={});if(c(e,t))return e[t];var n=this.schema[t];if(!n)throw new H.NotFound("Table "+t+" not part of transaction");return(n=new this.db.Table(t,n,this)).core=this.db.core.table(t),e[t]=n},qe);function qe(){}function ze(t,e,n,r,i,s,a){return{name:t,keyPath:e,unique:n,multi:r,auto:i,compound:s,src:(n&&!a?"&":"")+(r?"*":"")+(i?"++":"")+Ue(e)}}function Ue(t){return"string"==typeof t?t:t?"["+[].join.call(t,"+")+"]":""}function He(t,e,n){return{name:t,primKey:e,indexes:n,mappedClass:null,idxByName:(r=function(t){return[t.name,t]},n.reduce(function(t,e,n){return(n=r(e,n))&&(t[n[0]]=n[1]),t},{}))};var r}var $e=function(t){try{return t.only([[]]),$e=function(){return[[]]},[[]]}catch(e){return $e=function(){return Qt},Qt}};function Ge(t){return null==t?function(){}:"string"==typeof t?1===(e=t).split(".").length?function(t){return t[e]}:function(t){return w(t,e)}:function(e){return w(e,t)};var e}function Ve(t){return[].slice.call(t)}var Ye=0;function Xe(t){return null==t?":id":"string"==typeof t?t:"[".concat(t.join("+"),"]")}function Qe(t,e,n){function r(t){if(3===t.type)return null;if(4===t.type)throw new Error("Cannot convert never type to IDBKeyRange");var n=t.lower,r=t.upper,i=t.lowerOpen;return t=t.upperOpen,void 0===n?void 0===r?null:e.upperBound(r,!!t):void 0===r?e.lowerBound(n,!!i):e.bound(n,r,!!i,!!t)}function i(t){var e,n=t.name;return{name:n,schema:t,mutate:function(t){var e=t.trans,i=t.type,s=t.keys,a=t.values,o=t.range;return new Promise(function(t,l){t=Mt(t);var c=e.objectStore(n),u=null==c.keyPath,h="put"===i||"add"===i;if(!h&&"delete"!==i&&"deleteRange"!==i)throw new Error("Invalid operation type: "+i);var d,f=(s||a||{length:1}).length;if(s&&a&&s.length!==a.length)throw new Error("Given keys array must have same length as given values array.");if(0===f)return t({numFailures:0,failures:{},results:[],lastResult:void 0});function p(t){++y,Ne(t)}var m=[],g=[],y=0;if("deleteRange"===i){if(4===o.type)return t({numFailures:y,failures:g,results:[],lastResult:void 0});3===o.type?m.push(d=c.clear()):m.push(d=c.delete(r(o)))}else{var v=(u=h?u?[a,s]:[a,null]:[s,null])[0],b=u[1];if(h)for(var w=0;w<f;++w)m.push(d=b&&void 0!==b[w]?c[i](v[w],b[w]):c[i](v[w])),d.onerror=p;else for(w=0;w<f;++w)m.push(d=c[i](v[w])),d.onerror=p}function _(e){e=e.target.result,m.forEach(function(t,e){return null!=t.error&&(g[e]=t.error)}),t({numFailures:y,failures:g,results:"delete"===i?s:m.map(function(t){return t.result}),lastResult:e})}d.onerror=function(t){p(t),_(t)},d.onsuccess=_})},getMany:function(t){var e=t.trans,r=t.keys;return new Promise(function(t,i){t=Mt(t);for(var s,a=e.objectStore(n),o=r.length,l=new Array(o),c=0,u=0,h=function(e){e=e.target,l[e._pos]=e.result,++u===c&&t(l)},d=Le(i),f=0;f<o;++f)null!=r[f]&&((s=a.get(r[f]))._pos=f,s.onsuccess=h,s.onerror=d,++c);0===c&&t(l)})},get:function(t){var e=t.trans,r=t.key;return new Promise(function(t,i){t=Mt(t);var s=e.objectStore(n).get(r);s.onsuccess=function(e){return t(e.target.result)},s.onerror=Le(i)})},query:(e=c,function(t){return new Promise(function(i,s){i=Mt(i);var a,o,l,c=t.trans,u=t.values,h=t.limit,d=t.query,f=h===1/0?void 0:h,p=d.index;if(d=d.range,c=c.objectStore(n),p=p.isPrimaryKey?c:c.index(p.name),d=r(d),0===h)return i({result:[]});e?((f=u?p.getAll(d,f):p.getAllKeys(d,f)).onsuccess=function(t){return i({result:t.target.result})},f.onerror=Le(s)):(a=0,o=!u&&"openKeyCursor"in p?p.openKeyCursor(d):p.openCursor(d),l=[],o.onsuccess=function(t){var e=o.result;return e?(l.push(u?e.value:e.primaryKey),++a===h?i({result:l}):void e.continue()):i({result:l})},o.onerror=Le(s))})}),openCursor:function(t){var e=t.trans,i=t.values,s=t.query,a=t.reverse,o=t.unique;return new Promise(function(t,l){t=Mt(t);var c=s.index,u=s.range,h=e.objectStore(n),d=(h=c.isPrimaryKey?h:h.index(c.name),c=a?o?"prevunique":"prev":o?"nextunique":"next",!i&&"openKeyCursor"in h?h.openKeyCursor(r(u),c):h.openCursor(r(u),c));d.onerror=Le(l),d.onsuccess=Mt(function(n){var r,i,s,a,o=d.result;o?(o.___id=++Ye,o.done=!1,r=o.continue.bind(o),i=(i=o.continuePrimaryKey)&&i.bind(o),s=o.advance.bind(o),a=function(){throw new Error("Cursor not stopped")},o.trans=e,o.stop=o.continue=o.continuePrimaryKey=o.advance=function(){throw new Error("Cursor not started")},o.fail=Mt(l),o.next=function(){var t=this,e=1;return this.start(function(){return e--?t.continue():t.stop()}).then(function(){return t})},o.start=function(t){function e(){if(d.result)try{t()}catch(e){o.fail(e)}else o.done=!0,o.start=function(){throw new Error("Cursor behind last entry")},o.stop()}var n=new Promise(function(t,e){t=Mt(t),d.onerror=Le(e),o.fail=e,o.stop=function(e){o.stop=o.continue=o.continuePrimaryKey=o.advance=a,t(e)}});return d.onsuccess=Mt(function(t){d.onsuccess=e,e()}),o.continue=r,o.continuePrimaryKey=i,o.advance=s,e(),n},t(o)):t(null)},l)})},count:function(t){var e=t.query,i=t.trans,s=e.index,a=e.range;return new Promise(function(t,e){var o=i.objectStore(n),l=s.isPrimaryKey?o:o.index(s.name);(l=(o=r(a))?l.count(o):l.count()).onsuccess=Mt(function(e){return t(e.target.result)}),l.onerror=Le(e)})}}}n=(o=n,l=Ve((a=t).objectStoreNames),u={schema:{name:a.name,tables:l.map(function(t){return o.objectStore(t)}).map(function(t){var e=t.keyPath,n=t.autoIncrement,r=s(e),i={};return n={name:t.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:null==e,compound:r,keyPath:e,autoIncrement:n,unique:!0,extractKey:Ge(e)},indexes:Ve(t.indexNames).map(function(e){return t.index(e)}).map(function(t){var e=t.name,n=t.unique,r=t.multiEntry;return t=t.keyPath,r={name:e,compound:s(t),keyPath:t,unique:n,multiEntry:r,extractKey:Ge(t)},i[Xe(t)]=r}),getIndexByKeyPath:function(t){return i[Xe(t)]}},i[":id"]=n.primaryKey,null!=e&&(i[Xe(e)]=n.primaryKey),n})},hasGetAll:0<l.length&&"getAll"in o.objectStore(l[0])&&!("undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}).schema;var a,o,l,c=u.hasGetAll,u=n.tables.map(i),h={};return u.forEach(function(t){return h[t.name]=t}),{stack:"dbcore",transaction:t.transaction.bind(t),table:function(t){if(!h[t])throw new Error("Table '".concat(t,"' not found"));return h[t]},MIN_KEY:-1/0,MAX_KEY:$e(e),schema:n}}function Je(t,n,r,i){var s=r.IDBKeyRange;return r.indexedDB,{dbcore:(i=Qe(n,s,i),t.dbcore.reduce(function(t,n){return n=n.create,e(e({},t),n(t))},i))}}function Ze(t,e){var n=e.db;e=Je(t._middlewares,n,t._deps,e),t.core=e.dbcore,t.tables.forEach(function(e){var n=e.name;t.core.schema.tables.some(function(t){return t.name===n})&&(e.core=t.core.table(n),t[n]instanceof t.Table&&(t[n].core=e.core))})}function tn(t,e,n,r){n.forEach(function(n){var i=r[n];e.forEach(function(e){var r=function t(e,n){return p(e,n)||(e=o(e))&&t(e,n)}(e,n);(!r||"value"in r&&void 0===r.value)&&(e===t.Transaction.prototype||e instanceof t.Transaction?d(e,n,{get:function(){return this.table(n)},set:function(t){h(this,n,{value:t,writable:!0,configurable:!0,enumerable:!0})}}):e[n]=new t.Table(n,i))})})}function en(t,e){e.forEach(function(e){for(var n in e)e[n]instanceof t.Table&&delete e[n]})}function nn(t,e){return t._cfg.version-e._cfg.version}function rn(t,e,n,r){var s=t._dbSchema;n.objectStoreNames.contains("$meta")&&!s.$meta&&(s.$meta=He("$meta",dn("")[0],[]),t._storeNames.push("$meta"));var a=t._createTransaction("readwrite",t._storeNames,s);a.create(n),a._completion.catch(r);var o=a._reject.bind(a),l=yt.transless||yt;Wt(function(){return yt.trans=a,yt.transless=l,0!==e?(Ze(t,n),c=e,((r=a).storeNames.includes("$meta")?r.table("$meta").get("version").then(function(t){return null!=t?t:c}):_t.resolve(c)).then(function(e){return s=e,o=a,l=n,c=[],e=(r=t)._versions,u=r._dbSchema=un(0,r.idbdb,l),0!==(e=e.filter(function(t){return t._cfg.version>=s})).length?(e.forEach(function(t){c.push(function(){var e=u,n=t._cfg.dbschema;hn(r,e,l),hn(r,n,l),u=r._dbSchema=n;var a=an(e,n);a.add.forEach(function(t){on(l,t[0],t[1].primKey,t[1].indexes)}),a.change.forEach(function(t){if(t.recreate)throw new H.Upgrade("Not yet support for changing primary key");var e=l.objectStore(t.name);t.add.forEach(function(t){return cn(e,t)}),t.change.forEach(function(t){e.deleteIndex(t.name),cn(e,t)}),t.del.forEach(function(t){return e.deleteIndex(t)})});var c=t._cfg.contentUpgrade;if(c&&t._cfg.version>s){Ze(r,l),o._memoizedTables={};var h=C(n);a.del.forEach(function(t){h[t]=e[t]}),en(r,[r.Transaction.prototype]),tn(r,[r.Transaction.prototype],i(h),h),o.schema=h;var d,f=L(c);return f&&Bt(),a=_t.follow(function(){var t;(d=c(o))&&f&&(t=qt.bind(null,null),d.then(t,t))}),d&&"function"==typeof d.then?_t.resolve(d):a.then(function(){return d})}}),c.push(function(e){var n,i,s=t._cfg.dbschema;n=s,i=e,[].slice.call(i.db.objectStoreNames).forEach(function(t){return null==n[t]&&i.db.deleteObjectStore(t)}),en(r,[r.Transaction.prototype]),tn(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),o.schema=r._dbSchema}),c.push(function(e){r.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(r.idbdb.version/10)===t._cfg.version?(r.idbdb.deleteObjectStore("$meta"),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter(function(t){return"$meta"!==t})):e.objectStore("$meta").put(t._cfg.version,"version"))})}),function t(){return c.length?_t.resolve(c.shift()(o.idbtrans)).then(t):_t.resolve()}().then(function(){ln(u,l)})):_t.resolve();var r,s,o,l,c,u}).catch(o)):(i(s).forEach(function(t){on(n,t,s[t].primKey,s[t].indexes)}),Ze(t,n),void _t.follow(function(){return t.on.populate.fire(a)}).catch(o));var r,c})}function sn(t,e){ln(t._dbSchema,e),e.db.version%10!=0||e.objectStoreNames.contains("$meta")||e.db.createObjectStore("$meta").add(Math.ceil(e.db.version/10-1),"version");var n=un(0,t.idbdb,e);hn(t,t._dbSchema,e);for(var r=0,i=an(n,t._dbSchema).change;r<i.length;r++){var s=function(t){if(t.change.length||t.recreate)return{value:void 0};var n=e.objectStore(t.name);t.add.forEach(function(t){cn(n,t)})}(i[r]);if("object"==typeof s)return s.value}}function an(t,e){var n,r={del:[],add:[],change:[]};for(n in t)e[n]||r.del.push(n);for(n in e){var i=t[n],s=e[n];if(i){var a={name:n,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||i.primKey.auto!==s.primKey.auto)a.recreate=!0,r.change.push(a);else{var o=i.idxByName,l=s.idxByName,c=void 0;for(c in o)l[c]||a.del.push(c);for(c in l){var u=o[c],h=l[c];u?u.src!==h.src&&a.change.push(h):a.add.push(h)}(0<a.del.length||0<a.add.length||0<a.change.length)&&r.change.push(a)}}else r.add.push([n,s])}return r}function on(t,e,n,r){var i=t.db.createObjectStore(e,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(function(t){return cn(i,t)}),i}function ln(t,e){i(t).forEach(function(n){e.db.objectStoreNames.contains(n)||on(e,n,t[n].primKey,t[n].indexes)})}function cn(t,e){t.createIndex(e.name,e.keyPath,{unique:e.unique,multiEntry:e.multi})}function un(t,e,n){var r={};return g(e.objectStoreNames,0).forEach(function(t){for(var e=n.objectStore(t),i=ze(Ue(o=e.keyPath),o||"",!0,!1,!!e.autoIncrement,o&&"string"!=typeof o,!0),s=[],a=0;a<e.indexNames.length;++a){var o=(l=e.index(e.indexNames[a])).keyPath,l=ze(l.name,o,!!l.unique,!!l.multiEntry,!1,o&&"string"!=typeof o,!1);s.push(l)}r[t]=He(t,i,s)}),r}function hn(t,e,n){for(var i=n.db.objectStoreNames,s=0;s<i.length;++s){var a=i[s],o=n.objectStore(a);t._hasGetAll="getAll"in o;for(var l=0;l<o.indexNames.length;++l){var c=o.indexNames[l],u=o.index(c).keyPath,h="string"==typeof u?u:"["+g(u).join("+")+"]";!e[a]||(u=e[a].idxByName[h])&&(u.name=c,delete e[a].idxByName[h],e[a].idxByName[c]=u)}}"undefined"!=typeof navigator&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&r.WorkerGlobalScope&&r instanceof r.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(t._hasGetAll=!1)}function dn(t){return t.split(",").map(function(t,e){var n=(t=t.trim()).replace(/([&*]|\+\+)/g,""),r=/^\[/.test(n)?n.match(/^\[(.*)\]$/)[1].split("+"):n;return ze(n,r||null,/\&/.test(t),/\*/.test(t),/\+\+/.test(t),s(r),0===e)})}var fn=(pn.prototype._parseStoresSpec=function(t,e){i(t).forEach(function(n){if(null!==t[n]){var r=dn(t[n]),i=r.shift();if(i.unique=!0,i.multi)throw new H.Schema("Primary key cannot be multi-valued");r.forEach(function(t){if(t.auto)throw new H.Schema("Only primary key can be marked as autoIncrement (++)");if(!t.keyPath)throw new H.Schema("Index must have a name and cannot be an empty string")}),e[n]=He(n,i,r)}})},pn.prototype.stores=function(t){var e=this.db;this._cfg.storesSource=this._cfg.storesSource?a(this._cfg.storesSource,t):t,t=e._versions;var n={},r={};return t.forEach(function(t){a(n,t._cfg.storesSource),r=t._cfg.dbschema={},t._parseStoresSpec(n,r)}),e._dbSchema=r,en(e,[e._allTables,e,e.Transaction.prototype]),tn(e,[e._allTables,e,e.Transaction.prototype,this._cfg.tables],i(r),r),e._storeNames=i(r),this},pn.prototype.upgrade=function(t){return this._cfg.contentUpgrade=nt(this._cfg.contentUpgrade||V,t),this},pn);function pn(){}function mn(t,e){var n=t._dbNamesDB;return n||(n=t._dbNamesDB=new er(ee,{addons:[],indexedDB:t,IDBKeyRange:e})).version(1).stores({dbnames:"name"}),n.table("dbnames")}function gn(t){return t&&"function"==typeof t.databases}function yn(t){return Wt(function(){return yt.letThrough=!0,t()})}function vn(t){return!("from"in t)}var bn=function(t,e){if(!this){var n=new bn;return t&&"d"in t&&a(n,t),n}a(this,arguments.length?{d:1,from:t,to:1<arguments.length?e:t}:{d:0})};function wn(t,e,n){var r=le(e,n);if(!isNaN(r)){if(0<r)throw RangeError();if(vn(t))return a(t,{from:e,to:n,d:1});var i=t.l;if(r=t.r,le(n,t.from)<0)return i?wn(i,e,n):t.l={from:e,to:n,d:1,l:null,r:null},En(t);if(0<le(e,t.to))return r?wn(r,e,n):t.r={from:e,to:n,d:1,l:null,r:null},En(t);le(e,t.from)<0&&(t.from=e,t.l=null,t.d=r?r.d+1:1),0<le(n,t.to)&&(t.to=n,t.r=null,t.d=t.l?t.l.d+1:1),n=!t.r,i&&!t.l&&_n(t,i),r&&n&&_n(t,r)}}function _n(t,e){vn(e)||function t(e,n){var r=n.from,i=n.to,s=n.l;n=n.r,wn(e,r,i),s&&t(e,s),n&&t(e,n)}(t,e)}function Cn(t,e){var n=Sn(e),r=n.next();if(r.done)return!1;for(var i=r.value,s=Sn(t),a=s.next(i.from),o=a.value;!r.done&&!a.done;){if(le(o.from,i.to)<=0&&0<=le(o.to,i.from))return!0;le(i.from,o.from)<0?i=(r=n.next(o.from)).value:o=(a=s.next(i.from)).value}return!1}function Sn(t){var e=vn(t)?null:{s:0,n:t};return{next:function(t){for(var n=0<arguments.length;e;)switch(e.s){case 0:if(e.s=1,n)for(;e.n.l&&le(t,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,!n||le(t,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 En(t){var n,r,i=((null===(n=t.r)||void 0===n?void 0:n.d)||0)-((null===(r=t.l)||void 0===r?void 0:r.d)||0),s=1<i?"r":i<-1?"l":"";s&&(n="r"==s?"l":"r",r=e({},t),i=t[s],t.from=i.from,t.to=i.to,t[s]=i[s],r[s]=i[n],(t[n]=r).d=On(r)),t.d=On(t)}function On(t){var e=t.r;return t=t.l,(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}function xn(t,e){return i(e).forEach(function(n){t[n]?_n(t[n],e[n]):t[n]=function t(e){var n,r,i={};for(n in e)c(e,n)&&(r=e[n],i[n]=!r||"object"!=typeof r||x.has(r.constructor)?r:t(r));return i}(e[n])}),t}function kn(t,e){return t.all||e.all||Object.keys(t).some(function(n){return e[n]&&Cn(e[n],t[n])})}u(bn.prototype,((N={add:function(t){return _n(this,t),this},addKey:function(t){return wn(this,t,t),this},addKeys:function(t){var e=this;return t.forEach(function(t){return wn(e,t,t)}),this},hasKey:function(t){var e=Sn(this).next(t).value;return e&&le(e.from,t)<=0&&0<=le(e.to,t)}})[T]=function(){return Sn(this)},N));var Pn={},An={},Rn=!1;function Tn(t){xn(An,t),Rn||(Rn=!0,setTimeout(function(){Rn=!1,Fn(An,!(An={}))},0))}function Fn(t,e){void 0===e&&(e=!1);var n=new Set;if(t.all)for(var r=0,i=Object.values(Pn);r<i.length;r++)Mn(a=i[r],t,n,e);else for(var s in t){var a,o=/^idb\:\/\/(.*)\/(.*)\//.exec(s);o&&(s=o[1],o=o[2],(a=Pn["idb://".concat(s,"/").concat(o)])&&Mn(a,t,n,e))}n.forEach(function(t){return t()})}function Mn(t,e,n,r){for(var i=[],s=0,a=Object.entries(t.queries.query);s<a.length;s++){for(var o=a[s],l=o[0],c=[],u=0,h=o[1];u<h.length;u++){var d=h[u];kn(e,d.obsSet)?d.subscribers.forEach(function(t){return n.add(t)}):r&&c.push(d)}r&&i.push([l,c])}if(r)for(var f=0,p=i;f<p.length;f++){var m=p[f];l=m[0],c=m[1],t.queries.query[l]=c}}function Dn(t){var e=t._state,n=t._deps.indexedDB;if(e.isBeingOpened||t.idbdb)return e.dbReadyPromise.then(function(){return e.dbOpenError?Xt(e.dbOpenError):t});e.isBeingOpened=!0,e.dbOpenError=null,e.openComplete=!1;var r=e.openCanceller,s=Math.round(10*t.verno),a=!1;function o(){if(e.openCanceller!==r)throw new H.DatabaseClosed("db.open() was cancelled")}function l(){return new _t(function(r,c){if(o(),!n)throw new H.MissingAPI;var u=t.name,f=e.autoSchema||!s?n.open(u):n.open(u,s);if(!f)throw new H.MissingAPI;f.onerror=Le(c),f.onblocked=Mt(t._fireOnBlocked),f.onupgradeneeded=Mt(function(r){var i;h=f.transaction,e.autoSchema&&!t._options.allowEmptyDB?(f.onerror=Ne,h.abort(),f.result.close(),(i=n.deleteDatabase(u)).onsuccess=i.onerror=Mt(function(){c(new H.NoSuchDatabase("Database ".concat(u," doesnt exist")))})):(h.onerror=Le(c),r=r.oldVersion>Math.pow(2,62)?0:r.oldVersion,d=r<1,t.idbdb=f.result,a&&sn(t,h),rn(t,r/10,h,c))},c),f.onsuccess=Mt(function(){h=null;var n,o,c,p,m,y=t.idbdb=f.result,v=g(y.objectStoreNames);if(0<v.length)try{var b=y.transaction(1===(p=v).length?p[0]:p,"readonly");if(e.autoSchema)o=y,c=b,(n=t).verno=o.version/10,c=n._dbSchema=un(0,o,c),n._storeNames=g(o.objectStoreNames,0),tn(n,[n._allTables],i(c),c);else if(hn(t,t._dbSchema,b),((m=an(un(0,(m=t).idbdb,b),m._dbSchema)).add.length||m.change.some(function(t){return t.add.length||t.change.length}))&&!a)return y.close(),s=y.version+1,a=!0,r(l());Ze(t,b)}catch(w){}te.push(t),y.onversionchange=Mt(function(n){e.vcFired=!0,t.on("versionchange").fire(n)}),y.onclose=Mt(function(e){t.on("close").fire(e)}),d&&(m=t._deps,b=u,y=m.indexedDB,m=m.IDBKeyRange,gn(y)||b===ee||mn(y,m).put({name:b}).catch(V)),r()},c)}).catch(function(t){switch(null==t?void 0:t.name){case"UnknownError":if(0<e.PR1398_maxLoop)return e.PR1398_maxLoop--,l();break;case"VersionError":if(0<s)return s=0,l()}return _t.reject(t)})}var c,u=e.dbReadyResolve,h=null,d=!1;return _t.race([r,("undefined"==typeof navigator?_t.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){function e(){return indexedDB.databases().finally(t)}c=setInterval(e,100),e()}).finally(function(){return clearInterval(c)}):Promise.resolve()).then(l)]).then(function(){return o(),e.onReadyBeingFired=[],_t.resolve(yn(function(){return t.on.ready.fire(t.vip)})).then(function n(){if(0<e.onReadyBeingFired.length){var r=e.onReadyBeingFired.reduce(nt,V);return e.onReadyBeingFired=[],_t.resolve(yn(function(){return r(t.vip)})).then(n)}})}).finally(function(){e.openCanceller===r&&(e.onReadyBeingFired=null,e.isBeingOpened=!1)}).catch(function(n){e.dbOpenError=n;try{h&&h.abort()}catch(i){}return r===e.openCanceller&&t._close(),Xt(n)}).finally(function(){e.openComplete=!0,u()}).then(function(){var e;return d&&(e={},t.tables.forEach(function(n){n.schema.indexes.forEach(function(r){r.name&&(e["idb://".concat(t.name,"/").concat(n.name,"/").concat(r.name)]=new bn(-1/0,[[[]]]))}),e["idb://".concat(t.name,"/").concat(n.name,"/")]=e["idb://".concat(t.name,"/").concat(n.name,"/:dels")]=new bn(-1/0,[[[]]])}),We(je).fire(e),Fn(e,!0)),t})}function In(t){function e(e){return t.next(e)}var n=i(e),r=i(function(e){return t.throw(e)});function i(t){return function(e){var i=t(e);return e=i.value,i.done?e:e&&"function"==typeof e.then?e.then(n,r):s(e)?Promise.all(e).then(n,r):n(e)}}return i(e)()}function Ln(t,e,n){for(var r=s(t)?t.slice():[t],i=0;i<n;++i)r.push(e);return r}var Nn={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(t){return e(e({},t),{table:function(n){var r=t.table(n),i=r.schema,s={},a=[];function o(t,n,r){var i=Xe(t),l=s[i]=s[i]||[],c=null==t?0:"string"==typeof t?1:t.length,u=0<n;return u=e(e({},r),{name:u?"".concat(i,"(virtual-from:").concat(r.name,")"):r.name,lowLevelIndex:r,isVirtual:u,keyTail:n,keyLength:c,extractKey:Ge(t),unique:!u&&r.unique}),l.push(u),u.isPrimaryKey||a.push(u),1<c&&o(2===c?t[0]:t.slice(0,c-1),n+1,r),l.sort(function(t,e){return t.keyTail-e.keyTail}),u}n=o(i.primaryKey.keyPath,0,i.primaryKey),s[":id"]=[n];for(var l=0,c=i.indexes;l<c.length;l++){var u=c[l];o(u.keyPath,0,u)}function h(n){var r,i=n.query.index;return i.isVirtual?e(e({},n),{query:{index:i.lowLevelIndex,range:(r=n.query.range,i=i.keyTail,{type:1===r.type?2:r.type,lower:Ln(r.lower,r.lowerOpen?t.MAX_KEY:t.MIN_KEY,i),lowerOpen:!0,upper:Ln(r.upper,r.upperOpen?t.MIN_KEY:t.MAX_KEY,i),upperOpen:!0})}}):n}return e(e({},r),{schema:e(e({},i),{primaryKey:n,indexes:a,getIndexByKeyPath:function(t){return(t=s[Xe(t)])&&t[0]}}),count:function(t){return r.count(h(t))},query:function(t){return r.query(h(t))},openCursor:function(e){var n=e.query.index,i=n.keyTail,s=n.isVirtual,a=n.keyLength;return s?r.openCursor(h(e)).then(function(t){return t&&o(t)}):r.openCursor(e);function o(n){return Object.create(n,{continue:{value:function(r){null!=r?n.continue(Ln(r,e.reverse?t.MAX_KEY:t.MIN_KEY,i)):e.unique?n.continue(n.key.slice(0,a).concat(e.reverse?t.MIN_KEY:t.MAX_KEY,i)):n.continue()}},continuePrimaryKey:{value:function(e,r){n.continuePrimaryKey(Ln(e,t.MAX_KEY,i),r)}},primaryKey:{get:function(){return n.primaryKey}},key:{get:function(){var t=n.key;return 1===a?t[0]:t.slice(0,a)}},value:{get:function(){return n.value}}})}}})}})}};function jn(t,e,n,r){return n=n||{},r=r||"",i(t).forEach(function(i){var s,a,o;c(e,i)?(s=t[i],a=e[i],"object"==typeof s&&"object"==typeof a&&s&&a?(o=R(s))!==R(a)?n[r+i]=e[i]:"Object"===o?jn(s,a,n,r+i+"."):s!==a&&(n[r+i]=e[i]):s!==a&&(n[r+i]=e[i])):n[r+i]=void 0}),i(e).forEach(function(i){c(t,i)||(n[r+i]=e[i])}),n}function Kn(t,e){return"delete"===e.type?e.keys:e.keys||e.values.map(t.extractKey)}var Wn={stack:"dbcore",name:"HooksMiddleware",level:2,create:function(t){return e(e({},t),{table:function(r){var i=t.table(r),s=i.schema.primaryKey;return e(e({},i),{mutate:function(t){var a=yt.trans,o=a.table(r).hook,l=o.deleting,u=o.creating,h=o.updating;switch(t.type){case"add":if(u.fire===V)break;return a._promise("readwrite",function(){return d(t)},!0);case"put":if(u.fire===V&&h.fire===V)break;return a._promise("readwrite",function(){return d(t)},!0);case"delete":if(l.fire===V)break;return a._promise("readwrite",function(){return d(t)},!0);case"deleteRange":if(l.fire===V)break;return a._promise("readwrite",function(){return function t(n,r,a){return i.query({trans:n,values:!1,query:{index:s,range:r},limit:a}).then(function(i){var s=i.result;return d({type:"delete",keys:s,trans:n}).then(function(i){return 0<i.numFailures?Promise.reject(i.failures[0]):s.length<a?{failures:[],numFailures:0,lastResult:void 0}:t(n,e(e({},r),{lower:s[s.length-1],lowerOpen:!0}),a)})})}(t.trans,t.range,1e4)},!0)}return i.mutate(t);function d(t){var r,a,o,d=yt.trans,f=t.keys||Kn(s,t);if(!f)throw new Error("Keys missing");return"delete"!==(t="add"===t.type||"put"===t.type?e(e({},t),{keys:f}):e({},t)).type&&(t.values=n([],t.values)),t.keys&&(t.keys=n([],t.keys)),r=i,o=f,("add"===(a=t).type?Promise.resolve([]):r.getMany({trans:a.trans,keys:o,cache:"immutable"})).then(function(e){var n=f.map(function(n,r){var i,a,o,f=e[r],p={onerror:null,onsuccess:null};return"delete"===t.type?l.fire.call(p,n,f,d):"add"===t.type||void 0===f?(i=u.fire.call(p,n,t.values[r],d),null==n&&null!=i&&(t.keys[r]=n=i,s.outbound||_(t.values[r],s.keyPath,n))):(i=jn(f,t.values[r]),(a=h.fire.call(p,i,n,f,d))&&(o=t.values[r],Object.keys(a).forEach(function(t){c(o,t)?o[t]=a[t]:_(o,t,a[t])}))),p});return i.mutate(t).then(function(r){for(var i=r.failures,s=r.results,a=r.numFailures,o=(r=r.lastResult,0);o<f.length;++o){var l=(s||f)[o],c=n[o];null==l?c.onerror&&c.onerror(i[o]):c.onsuccess&&c.onsuccess("put"===t.type&&e[o]?t.values[o]:l)}return{failures:i,results:s,numFailures:a,lastResult:r}}).catch(function(t){return n.forEach(function(e){return e.onerror&&e.onerror(t)}),Promise.reject(t)})})}}})}})}};function Bn(t,e,n){try{if(!e)return null;if(e.keys.length<t.length)return null;for(var r=[],i=0,s=0;i<e.keys.length&&s<t.length;++i)0===le(e.keys[i],t[s])&&(r.push(n?P(e.values[i]):e.values[i]),++s);return r.length===t.length?r:null}catch(a){return null}}var qn={stack:"dbcore",level:-1,create:function(t){return{table:function(n){var r=t.table(n);return e(e({},r),{getMany:function(t){if(!t.cache)return r.getMany(t);var e=Bn(t.keys,t.trans._cache,"clone"===t.cache);return e?_t.resolve(e):r.getMany(t).then(function(e){return t.trans._cache={keys:t.keys,values:"clone"===t.cache?P(e):e},e})},mutate:function(t){return"add"!==t.type&&(t.trans._cache=null),r.mutate(t)}})}}}};function Un(t,e){return"readonly"===t.trans.mode&&!!t.subscr&&!t.trans.explicit&&"disabled"!==t.trans.db._options.cache&&!e.schema.primaryKey.outbound}function Hn(t,e){switch(t){case"query":return e.values&&!e.unique;case"get":case"getMany":case"count":case"openCursor":return!1}}var $n={stack:"dbcore",level:0,name:"Observability",create:function(t){var n=t.schema.name,r=new bn(t.MIN_KEY,t.MAX_KEY);return e(e({},t),{transaction:function(e,n,r){if(yt.subscr&&"readonly"!==n)throw new H.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(yt.querier));return t.transaction(e,n,r)},table:function(a){var o=t.table(a),l=o.schema,c=l.primaryKey,u=l.indexes,h=c.extractKey,d=c.outbound,f=c.autoIncrement&&u.filter(function(t){return t.compound&&t.keyPath.includes(c.keyPath)}),p=e(e({},o),{mutate:function(e){function i(t){return t="idb://".concat(n,"/").concat(a,"/").concat(t),m[t]||(m[t]=new bn)}var u,h,d,p=e.trans,m=e.mutatedParts||(e.mutatedParts={}),g=i(""),y=i(":dels"),v=e.type,b=(_="deleteRange"===e.type?[e.range]:"delete"===e.type?[e.keys]:e.values.length<50?[Kn(c,e).filter(function(t){return t}),e.values]:[])[0],w=_[1],_=e.trans._cache;return s(b)?(g.addKeys(b),(_="delete"===v||b.length===w.length?Bn(b,_):null)||y.addKeys(b),(_||w)&&(u=i,h=_,d=w,l.indexes.forEach(function(t){var e=u(t.name||"");function n(e){return null!=e?t.extractKey(e):null}function r(n){return t.multiEntry&&s(n)?n.forEach(function(t){return e.addKey(t)}):e.addKey(n)}(h||d).forEach(function(t,e){var i=h&&n(h[e]);0!==le(i,e=d&&n(d[e]))&&(null!=i&&r(i),null!=e&&r(e))})}))):b?(w={from:null!==(w=b.lower)&&void 0!==w?w:t.MIN_KEY,to:null!==(w=b.upper)&&void 0!==w?w:t.MAX_KEY},y.add(w),g.add(w)):(g.add(r),y.add(r),l.indexes.forEach(function(t){return i(t.name).add(r)})),o.mutate(e).then(function(t){return!b||"add"!==e.type&&"put"!==e.type||(g.addKeys(t.results),f&&f.forEach(function(n){for(var r=e.values.map(function(t){return n.extractKey(t)}),s=n.keyPath.findIndex(function(t){return t===c.keyPath}),a=0,o=t.results.length;a<o;++a)r[a][s]=t.results[a];i(n.name).addKeys(r)})),p.mutatedParts=xn(p.mutatedParts||{},m),t})}}),m={get:function(t){return[c,new bn(t.key)]},getMany:function(t){return[c,(new bn).addKeys(t.keys)]},count:u=function(e){e=(n=e.query).index;var n=n.range;return[e,new bn(null!==(e=n.lower)&&void 0!==e?e:t.MIN_KEY,null!==(n=n.upper)&&void 0!==n?n:t.MAX_KEY)]},query:u,openCursor:u};return i(m).forEach(function(t){p[t]=function(i){var s=!!(p=yt.subscr),l=Un(yt,o)&&Hn(t,i)?i.obsSet={}:p;if(s){var c=function(t){return t="idb://".concat(n,"/").concat(a,"/").concat(t),l[t]||(l[t]=new bn)},u=c(""),f=c(":dels"),p=(s=(p=m[t](i))[0],p[1]);if(("query"===t&&s.isPrimaryKey&&!i.values?f:c(s.name||"")).add(p),!s.isPrimaryKey){if("count"!==t){var g="query"===t&&d&&i.values&&o.query(e(e({},i),{values:!1}));return o[t].apply(this,arguments).then(function(e){if("query"===t){if(d&&i.values)return g.then(function(t){return t=t.result,u.addKeys(t),e});var n=i.values?e.result.map(h):e.result;(i.values?u:f).addKeys(n)}else if("openCursor"===t){var r=e,s=i.values;return r&&Object.create(r,{key:{get:function(){return f.addKey(r.primaryKey),r.key}},primaryKey:{get:function(){var t=r.primaryKey;return f.addKey(t),t}},value:{get:function(){return s&&u.addKey(r.primaryKey),r.value}}})}return e})}f.add(r)}}return o[t].apply(this,arguments)}}),p}})}};function Gn(t,n,r){if(0===r.numFailures)return n;if("deleteRange"===n.type)return null;var i=n.keys?n.keys.length:"values"in n&&n.values?n.values.length:1;return r.numFailures===i?null:(n=e({},n),s(n.keys)&&(n.keys=n.keys.filter(function(t,e){return!(e in r.failures)})),"values"in n&&s(n.values)&&(n.values=n.values.filter(function(t,e){return!(e in r.failures)})),n)}function Vn(t,e){return n=t,(void 0===(r=e).lower||(r.lowerOpen?0<le(n,r.lower):0<=le(n,r.lower)))&&(void 0===e.upper||(e.upperOpen?le(t,e.upper)<0:le(t,e.upper)<=0));var n,r}function Yn(t,e,n,r,i,a){if(!n||0===n.length)return t;var o=e.query.index,l=o.multiEntry,c=e.query.range,u=r.schema.primaryKey.extractKey,h=o.extractKey,d=(o.lowLevelIndex||o).extractKey;return(n=n.reduce(function(t,n){var r=t,i=[];if("add"===n.type||"put"===n.type)for(var a=new bn,o=n.values.length-1;0<=o;--o){var d,f=n.values[o],p=u(f);a.hasKey(p)||(d=h(f),(l&&s(d)?d.some(function(t){return Vn(t,c)}):Vn(d,c))&&(a.addKey(p),i.push(f)))}switch(n.type){case"add":var m=(new bn).addKeys(e.values?t.map(function(t){return u(t)}):t);r=t.concat(e.values?i.filter(function(t){return t=u(t),!m.hasKey(t)&&(m.addKey(t),!0)}):i.map(function(t){return u(t)}).filter(function(t){return!m.hasKey(t)&&(m.addKey(t),!0)}));break;case"put":var g=(new bn).addKeys(n.values.map(function(t){return u(t)}));r=t.filter(function(t){return!g.hasKey(e.values?u(t):t)}).concat(e.values?i:i.map(function(t){return u(t)}));break;case"delete":var y=(new bn).addKeys(n.keys);r=t.filter(function(t){return!y.hasKey(e.values?u(t):t)});break;case"deleteRange":var v=n.range;r=t.filter(function(t){return!Vn(u(t),v)})}return r},t))===t?t:(n.sort(function(t,e){return le(d(t),d(e))||le(u(t),u(e))}),e.limit&&e.limit<1/0&&(n.length>e.limit?n.length=e.limit:t.length===e.limit&&n.length<e.limit&&(i.dirty=!0)),a?Object.freeze(n):n)}function Xn(t,e){return 0===le(t.lower,e.lower)&&0===le(t.upper,e.upper)&&!!t.lowerOpen==!!e.lowerOpen&&!!t.upperOpen==!!e.upperOpen}function Qn(t,e){return function(t,e,n,r){if(void 0===t)return void 0!==e?-1:0;if(void 0===e)return 1;if(0===(e=le(t,e))){if(n&&r)return 0;if(n)return 1;if(r)return-1}return e}(t.lower,e.lower,t.lowerOpen,e.lowerOpen)<=0&&0<=function(t,e,n,r){if(void 0===t)return void 0!==e?1:0;if(void 0===e)return-1;if(0===(e=le(t,e))){if(n&&r)return 0;if(n)return-1;if(r)return 1}return e}(t.upper,e.upper,t.upperOpen,e.upperOpen)}function Jn(t,e,n,r){t.subscribers.add(n),r.addEventListener("abort",function(){var r,i;t.subscribers.delete(n),0===t.subscribers.size&&(r=t,i=e,setTimeout(function(){0===r.subscribers.size&&M(i,r)},3e3))})}var Zn={stack:"dbcore",level:0,name:"Cache",create:function(t){var n=t.schema.name;return e(e({},t),{transaction:function(e,r,i){var s,a,o=t.transaction(e,r,i);return"readwrite"===r&&(a=(s=new AbortController).signal,i=function(i){return function(){if(s.abort(),"readwrite"===r){for(var a=new Set,l=0,c=e;l<c.length;l++){var u=c[l],h=Pn["idb://".concat(n,"/").concat(u)];if(h){var d=t.table(u),f=h.optimisticOps.filter(function(t){return t.trans===o});if(o._explicit&&i&&o.mutatedParts)for(var p=0,m=Object.values(h.queries.query);p<m.length;p++)for(var g=0,y=(w=m[p]).slice();g<y.length;g++)kn((_=y[g]).obsSet,o.mutatedParts)&&(M(w,_),_.subscribers.forEach(function(t){return a.add(t)}));else if(0<f.length){h.optimisticOps=h.optimisticOps.filter(function(t){return t.trans!==o});for(var v=0,b=Object.values(h.queries.query);v<b.length;v++)for(var w,_,C,S=0,E=(w=b[v]).slice();S<E.length;S++)null!=(_=E[S]).res&&o.mutatedParts&&(i&&!_.dirty?(C=Object.isFrozen(_.res),C=Yn(_.res,_.req,f,d,_,C),_.dirty?(M(w,_),_.subscribers.forEach(function(t){return a.add(t)})):C!==_.res&&(_.res=C,_.promise=_t.resolve({result:C}))):(_.dirty&&M(w,_),_.subscribers.forEach(function(t){return a.add(t)})))}}}a.forEach(function(t){return t()})}}},o.addEventListener("abort",i(!1),{signal:a}),o.addEventListener("error",i(!1),{signal:a}),o.addEventListener("complete",i(!0),{signal:a})),o},table:function(r){var i=t.table(r),s=i.schema.primaryKey;return e(e({},i),{mutate:function(t){var a=yt.trans;if(s.outbound||"disabled"===a.db._options.cache||a.explicit||"readwrite"!==a.idbtrans.mode)return i.mutate(t);var o=Pn["idb://".concat(n,"/").concat(r)];return o?(a=i.mutate(t),"add"!==t.type&&"put"!==t.type||!(50<=t.values.length||Kn(s,t).some(function(t){return null==t}))?(o.optimisticOps.push(t),t.mutatedParts&&Tn(t.mutatedParts),a.then(function(e){0<e.numFailures&&(M(o.optimisticOps,t),(e=Gn(0,t,e))&&o.optimisticOps.push(e),t.mutatedParts&&Tn(t.mutatedParts))}),a.catch(function(){M(o.optimisticOps,t),t.mutatedParts&&Tn(t.mutatedParts)})):a.then(function(n){var r=Gn(0,e(e({},t),{values:t.values.map(function(t,r){var i;return n.failures[r]||_(t=null!==(i=s.keyPath)&&void 0!==i&&i.includes(".")?P(t):e({},t),s.keyPath,n.results[r]),t})}),n);o.optimisticOps.push(r),queueMicrotask(function(){return t.mutatedParts&&Tn(t.mutatedParts)})}),a):i.mutate(t)},query:function(t){if(!Un(yt,i)||!Hn("query",t))return i.query(t);var e="immutable"===(null===(o=yt.trans)||void 0===o?void 0:o.db._options.cache),s=(c=yt).requery,a=c.signal,o=function(t,e,n,r){var i=Pn["idb://".concat(t,"/").concat(e)];if(!i)return[];if(!(e=i.queries[n]))return[null,!1,i,null];var s=e[(r.query?r.query.index.name:null)||""];if(!s)return[null,!1,i,null];switch(n){case"query":var a=s.find(function(t){return t.req.limit===r.limit&&t.req.values===r.values&&Xn(t.req.query.range,r.query.range)});return a?[a,!0,i,s]:[s.find(function(t){return("limit"in t.req?t.req.limit:1/0)>=r.limit&&(!r.values||t.req.values)&&Qn(t.req.query.range,r.query.range)}),!1,i,s];case"count":return[a=s.find(function(t){return Xn(t.req.query.range,r.query.range)}),!!a,i,s]}}(n,r,"query",t),l=o[0],c=o[1],u=o[2],h=o[3];return l&&c?l.obsSet=t.obsSet:(c=i.query(t).then(function(t){var n=t.result;if(l&&(l.res=n),e){for(var r=0,i=n.length;r<i;++r)Object.freeze(n[r]);Object.freeze(n)}else t.result=P(n);return t}).catch(function(t){return h&&l&&M(h,l),Promise.reject(t)}),l={obsSet:t.obsSet,promise:c,subscribers:new Set,type:"query",req:t,dirty:!1},h?h.push(l):(h=[l],(u=u||(Pn["idb://".concat(n,"/").concat(r)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[t.query.index.name||""]=h)),Jn(l,h,s,a),l.promise.then(function(n){return{result:Yn(n.result,t,null==u?void 0:u.optimisticOps,i,l,e)}})}})}})}};function tr(t,e){return new Proxy(t,{get:function(t,n,r){return"db"===n?e:Reflect.get(t,n,r)}})}var er=(nr.prototype.version=function(t){if(isNaN(t)||t<.1)throw new H.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new H.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);var e=this._versions,n=e.filter(function(e){return e._cfg.version===t})[0];return n||(n=new this.Version(t),e.push(n),e.sort(nn),n.stores({}),this._state.autoSchema=!1,n)},nr.prototype._whenReady=function(t){var e=this;return this.idbdb&&(this._state.openComplete||yt.letThrough||this._vip)?t():new _t(function(t,n){if(e._state.openComplete)return n(new H.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._state.autoOpen)return void n(new H.DatabaseClosed);e.open().catch(V)}e._state.dbReadyPromise.then(t,n)}).then(t)},nr.prototype.use=function(t){var e=t.stack,n=t.create,r=t.level,i=t.name;return i&&this.unuse({stack:e,name:i}),(t=this._middlewares[e]||(this._middlewares[e]=[])).push({stack:e,create:n,level:null==r?10:r,name:i}),t.sort(function(t,e){return t.level-e.level}),this},nr.prototype.unuse=function(t){var e=t.stack,n=t.name,r=t.create;return e&&this._middlewares[e]&&(this._middlewares[e]=this._middlewares[e].filter(function(t){return r?t.create!==r:!!n&&t.name!==n})),this},nr.prototype.open=function(){var t=this;return Gt(gt,function(){return Dn(t)})},nr.prototype._close=function(){var t=this._state,e=te.indexOf(this);if(0<=e&&te.splice(e,1),this.idbdb){try{this.idbdb.close()}catch(n){}this.idbdb=null}t.isBeingOpened||(t.dbReadyPromise=new _t(function(e){t.dbReadyResolve=e}),t.openCanceller=new _t(function(e,n){t.cancelOpen=n}))},nr.prototype.close=function(t){var e=(void 0===t?{disableAutoOpen:!0}:t).disableAutoOpen;t=this._state,e?(t.isBeingOpened&&t.cancelOpen(new H.DatabaseClosed),this._close(),t.autoOpen=!1,t.dbOpenError=new H.DatabaseClosed):(this._close(),t.autoOpen=this._options.autoOpen||t.isBeingOpened,t.openComplete=!1,t.dbOpenError=null)},nr.prototype.delete=function(t){var e=this;void 0===t&&(t={disableAutoOpen:!0});var n=0<arguments.length&&"object"!=typeof arguments[0],r=this._state;return new _t(function(i,s){function a(){e.close(t);var n=e._deps.indexedDB.deleteDatabase(e.name);n.onsuccess=Mt(function(){var t,n,r;t=e._deps,n=e.name,r=t.indexedDB,t=t.IDBKeyRange,gn(r)||n===ee||mn(r,t).delete(n).catch(V),i()}),n.onerror=Le(s),n.onblocked=e._fireOnBlocked}if(n)throw new H.InvalidArgument("Invalid closeOptions argument to db.delete()");r.isBeingOpened?r.dbReadyPromise.then(a):a()})},nr.prototype.backendDB=function(){return this.idbdb},nr.prototype.isOpen=function(){return null!==this.idbdb},nr.prototype.hasBeenClosed=function(){var t=this._state.dbOpenError;return t&&"DatabaseClosed"===t.name},nr.prototype.hasFailed=function(){return null!==this._state.dbOpenError},nr.prototype.dynamicallyOpened=function(){return this._state.autoSchema},Object.defineProperty(nr.prototype,"tables",{get:function(){var t=this;return i(this._allTables).map(function(e){return t._allTables[e]})},enumerable:!1,configurable:!0}),nr.prototype.transaction=function(){var t=function(t,e,n){var r=arguments.length;if(r<2)throw new H.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[t,E(i),n]}.apply(this,arguments);return this._transaction.apply(this,t)},nr.prototype._transaction=function(t,e,n){var r=this,i=yt.trans;i&&i.db===this&&-1===t.indexOf("!")||(i=null);var s,a,o=-1!==t.indexOf("?");t=t.replace("!","").replace("?","");try{if(a=e.map(function(t){if("string"!=typeof(t=t instanceof r.Table?t.name:t))throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return t}),"r"==t||t===ne)s=ne;else{if("rw"!=t&&t!=re)throw new H.InvalidArgument("Invalid transaction mode: "+t);s=re}if(i){if(i.mode===ne&&s===re){if(!o)throw new H.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&a.forEach(function(t){if(i&&-1===i.storeNames.indexOf(t)){if(!o)throw new H.SubTransaction("Table "+t+" not included in parent transaction.");i=null}}),o&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,function(t,e){e(c)}):Xt(c)}var l=function t(e,n,r,i,s){return _t.resolve().then(function(){var a=yt.transless||yt,o=e._createTransaction(n,r,e._dbSchema,i);if(o.explicit=!0,a={trans:o,transless:a},i)o.idbtrans=i.idbtrans;else try{o.create(),o.idbtrans._explicit=!0,e._state.PR1398_maxLoop=3}catch(u){return u.name===z.InvalidState&&e.isOpen()&&0<--e._state.PR1398_maxLoop?(e.close({disableAutoOpen:!1}),e.open().then(function(){return t(e,n,r,null,s)})):Xt(u)}var l,c=L(s);return c&&Bt(),a=_t.follow(function(){var t;(l=s.call(o,o))&&(c?(t=qt.bind(null,null),l.then(t,t)):"function"==typeof l.next&&"function"==typeof l.throw&&(l=In(l)))},a),(l&&"function"==typeof l.then?_t.resolve(l).then(function(t){return o.active?t:Xt(new H.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))}):a.then(function(){return l})).then(function(t){return i&&o._resolve(),o._completion.then(function(){return t})}).catch(function(t){return o._reject(t),Xt(t)})})}.bind(null,this,s,a,i,n);return i?i._promise(s,l,"lock"):yt.trans?Gt(yt.transless,function(){return r._whenReady(l)}):this._whenReady(l)},nr.prototype.table=function(t){if(!c(this._allTables,t))throw new H.InvalidTable("Table ".concat(t," does not exist"));return this._allTables[t]},nr);function nr(t,n){var r=this;this._middlewares={},this.verno=0;var i=nr.dependencies;this._options=n=e({addons:nr.addons,autoOpen:!0,indexedDB:i.indexedDB,IDBKeyRange:i.IDBKeyRange,cache:"cloned"},n),this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange},i=n.addons,this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;var s,a,o,l,c,u={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:V,dbReadyPromise:null,cancelOpen:V,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3,autoOpen:n.autoOpen};u.dbReadyPromise=new _t(function(t){u.dbReadyResolve=t}),u.openCanceller=new _t(function(t,e){u.cancelOpen=e}),this._state=u,this.name=t,this.on=fe(this,"populate","blocked","versionchange","close",{ready:[nt,V]}),this.on.ready.subscribe=y(this.on.ready.subscribe,function(t){return function(e,n){nr.vip(function(){var i,s=r._state;s.openComplete?(s.dbOpenError||_t.resolve().then(e),n&&t(e)):s.onReadyBeingFired?(s.onReadyBeingFired.push(e),n&&t(e)):(t(e),i=r,n||t(function t(){i.on.ready.unsubscribe(e),i.on.ready.unsubscribe(t)}))})}}),this.Collection=(s=this,pe(Ee.prototype,function(t,e){this.db=s;var n=se,r=null;if(e)try{n=e()}catch(a){r=a}var i=t._ctx;t=(e=i.table).hook.reading.fire,this._ctx={table:e,index:i.index,isPrimKey:!i.index||e.schema.primKey.keyPath&&i.index===e.schema.primKey.name,range:n,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:r,or:i.or,valueMapper:t!==Y?t:null}})),this.Table=(a=this,pe(he.prototype,function(t,e,n){this.db=a,this._tx=n,this.name=t,this.schema=e,this.hook=a._allTables[t]?a._allTables[t].hook:fe(null,{creating:[J,V],reading:[X,Y],updating:[tt,V],deleting:[Z,V]})})),this.Transaction=(o=this,pe(Be.prototype,function(t,e,n,r,i){var s=this;this.db=o,this.mode=t,this.storeNames=e,this.schema=n,this.chromeTransactionDurability=r,this.idbtrans=null,this.on=fe(this,"complete","error","abort"),this.parent=i||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new _t(function(t,e){s._resolve=t,s._reject=e}),this._completion.then(function(){s.active=!1,s.on.complete.fire()},function(t){var e=s.active;return s.active=!1,s.on.error.fire(t),s.parent?s.parent._reject(t):e&&s.idbtrans&&s.idbtrans.abort(),Xt(t)})})),this.Version=(l=this,pe(fn.prototype,function(t){this.db=l,this._cfg={version:t,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})),this.WhereClause=(c=this,pe(De.prototype,function(t,e,n){if(this.db=c,this._ctx={table:t,index:":id"===e?null:e,or:n},this._cmp=this._ascending=le,this._descending=function(t,e){return le(e,t)},this._max=function(t,e){return 0<le(t,e)?t:e},this._min=function(t,e){return le(t,e)<0?t:e},this._IDBKeyRange=c._deps.IDBKeyRange,!this._IDBKeyRange)throw new H.MissingAPI})),this.on("versionchange",function(t){t.newVersion,r.close({disableAutoOpen:!1})}),this.on("blocked",function(t){!t.newVersion||(t.newVersion,t.oldVersion)}),this._maxKey=$e(n.IDBKeyRange),this._createTransaction=function(t,e,n,i){return new r.Transaction(t,e,n,r._options.chromeTransactionDurability,i)},this._fireOnBlocked=function(t){r.on("blocked").fire(t),te.filter(function(t){return t.name===r.name&&t!==r&&!t._state.vcFired}).map(function(e){return e.on("versionchange").fire(t)})},this.use(qn),this.use(Zn),this.use($n),this.use(Nn),this.use(Wn);var h=new Proxy(this,{get:function(t,e,n){if("_vip"===e)return!0;if("table"===e)return function(t){return tr(r.table(t),h)};var i=Reflect.get(t,e,n);return i instanceof he?tr(i,h):"tables"===e?i.map(function(t){return tr(t,h)}):"_createTransaction"===e?function(){return tr(i.apply(this,arguments),h)}:i}});this.vip=h,i.forEach(function(t){return t(r)})}N="undefined"!=typeof Symbol&&"observable"in Symbol?Symbol.observable:"@@observable";var rr,ir=(sr.prototype.subscribe=function(t,e,n){return this._subscribe(t&&"function"!=typeof t?t:{next:t,error:e,complete:n})},sr.prototype[N]=function(){return this},sr);function sr(t){this._subscribe=t}try{rr={indexedDB:r.indexedDB||r.mozIndexedDB||r.webkitIndexedDB||r.msIndexedDB,IDBKeyRange:r.IDBKeyRange||r.webkitIDBKeyRange}}catch(dr){rr={indexedDB:null,IDBKeyRange:null}}function ar(t){var e,n=!1,r=new ir(function(r){var i,s=L(t),a=!1,o={},l={},u={get closed(){return a},unsubscribe:function(){a||(a=!0,i&&i.abort(),h&&We.storagemutated.unsubscribe(f))}};r.start&&r.start(u);var h=!1,d=function(){return Yt(p)},f=function(t){xn(o,t),kn(l,o)&&d()},p=function(){var u,p,m;!a&&rr.indexedDB&&(o={},u={},i&&i.abort(),i=new AbortController,m=function(e){var n=At();try{s&&Bt();var r=Wt(t,e);return r=s?r.finally(qt):r}finally{n&&Rt()}}(p={subscr:u,signal:i.signal,requery:d,querier:t,trans:null}),Promise.resolve(m).then(function(t){n=!0,e=t,a||p.signal.aborted||(o={},function(t){for(var e in t)if(c(t,e))return;return 1}(l=u)||h||(We(je,f),h=!0),Yt(function(){return!a&&r.next&&r.next(t)}))},function(t){n=!1,["DatabaseClosedError","AbortError"].includes(null==t?void 0:t.name)||a||Yt(function(){a||r.error&&r.error(t)})}))};return setTimeout(d,0),u});return r.hasValue=function(){return n},r.getValue=function(){return e},r}var or=er;function lr(t){var e=ur;try{ur=!0,We.storagemutated.fire(t),Fn(t,!0)}finally{ur=e}}u(or,e(e({},G),{delete:function(t){return new or(t,{addons:[]}).delete()},exists:function(t){return new or(t,{addons:[]}).open().then(function(t){return t.close(),!0}).catch("NoSuchDatabaseError",function(){return!1})},getDatabaseNames:function(t){try{return n=(e=or.dependencies).indexedDB,e=e.IDBKeyRange,(gn(n)?Promise.resolve(n.databases()).then(function(t){return t.map(function(t){return t.name}).filter(function(t){return t!==ee})}):mn(n,e).toCollection().primaryKeys()).then(t)}catch(r){return Xt(new H.MissingAPI)}var e,n},defineClass:function(){return function(t){a(this,t)}},ignoreTransaction:function(t){return yt.trans?Gt(yt.transless,t):t()},vip:yn,async:function(t){return function(){try{var e=In(t.apply(this,arguments));return e&&"function"==typeof e.then?e:_t.resolve(e)}catch(n){return Xt(n)}}},spawn:function(t,e,n){try{var r=In(t.apply(n,e||[]));return r&&"function"==typeof r.then?r:_t.resolve(r)}catch(i){return Xt(i)}},currentTransaction:{get:function(){return yt.trans||null}},waitFor:function(t,e){return e=_t.resolve("function"==typeof t?or.ignoreTransaction(t):t).timeout(e||6e4),yt.trans?yt.trans.waitFor(e):e},Promise:_t,debug:{get:function(){return rt},set:function(t){it(t)}},derive:f,extend:a,props:u,override:y,Events:fe,on:We,liveQuery:ar,extendObservabilitySet:xn,getByKeyPath:w,setByKeyPath:_,delByKeyPath:function(t,e){"string"==typeof e?_(t,e,void 0):"length"in e&&[].map.call(e,function(e){_(t,e,void 0)})},shallowClone:C,deepClone:P,getObjectDiff:jn,cmp:le,asap:b,minKey:-1/0,addons:[],connections:te,errnames:z,dependencies:rr,cache:Pn,semVer:"4.0.11",version:"4.0.11".split(".").map(function(t){return parseInt(t)}).reduce(function(t,e,n){return t+e/Math.pow(10,2*n)})})),or.maxKey=$e(or.dependencies.IDBKeyRange),"undefined"!=typeof dispatchEvent&&"undefined"!=typeof addEventListener&&(We(je,function(t){ur||(t=new CustomEvent(Ke,{detail:t}),ur=!0,dispatchEvent(t),ur=!1)}),addEventListener(Ke,function(t){t=t.detail,ur||lr(t)}));var cr,ur=!1,hr=function(){};return"undefined"!=typeof BroadcastChannel&&((hr=function(){(cr=new BroadcastChannel(Ke)).onmessage=function(t){return t.data&&lr(t.data)}})(),"function"==typeof cr.unref&&cr.unref(),We(je,function(t){ur||cr.postMessage(t)})),"undefined"!=typeof addEventListener&&(addEventListener("pagehide",function(t){if(!er.disableBfCache&&t.persisted){null!=cr&&cr.close();for(var e=0,n=te;e<n.length;e++)n[e].close({disableAutoOpen:!1})}}),addEventListener("pageshow",function(t){!er.disableBfCache&&t.persisted&&(hr(),lr({all:new bn(-1/0,[[]])}))})),_t.rejectionMapper=function(t,e){return!t||t instanceof K||t instanceof TypeError||t instanceof SyntaxError||!t.name||!$[t.name]?t:(e=new $[t.name](e||t.message,t),"stack"in t&&d(e,"stack",{get:function(){return this.inner.stack}}),e)},it(rt),e(er,Object.freeze({__proto__:null,Dexie:er,liveQuery:ar,Entity:oe,cmp:le,PropModification:Ce,replacePrefix:function(t,e){return new Ce({replacePrefix:[t,e]})},add:function(t){return new Ce({add:t})},remove:function(t){return new Ce({remove:t})},default:er,RangeSet:bn,mergeRanges:_n,rangesOverlap:Cn}),{default:er}),er}()),$n.exports);const Vn=Un(Gn),Yn=Symbol.for("Dexie"),Xn=globalThis[Yn]||(globalThis[Yn]=Vn);if(Vn.semVer!==Xn.semVer)throw new Error(`Two different versions of Dexie loaded in the same app: ${Vn.semVer} and ${Xn.semVer}`);const{liveQuery:Qn,mergeRanges:Jn,rangesOverlap:Zn,RangeSet:tr,cmp:er,Entity:nr,PropModification:rr,replacePrefix:ir,add:sr,remove:ar}=Xn;class or extends Xn{constructor(t){super(t);this.version(1).stores({cache:"url, timestamp"}),this.open().catch(()=>{})}}class lr{constructor(t,e,n){this.options={...ze,...t},this.logger=n||((t,n,...r)=>$e(e,t,n,...r)),this.validate()}validate(){this.validateUrl(),this.validateColumns(),this.validateRowsPerPage(),this.validateFormatters(),this.validateLifecycleHooks()}validateLifecycleHooks(){if(this.options.lifecycleHooks)for(const t in this.options.lifecycleHooks)"function"!=typeof this.options.lifecycleHooks[t]&&this.logger(Se.WARN,`lifecycleHook '${t}' is not a function.`)}validateUrl(){if(!this.options.url||"string"!=typeof this.options.url)throw new ke("URL option is mandatory and must be a string.");try{new URL(this.options.url,document.baseURI)}catch{throw new ke(`Invalid URL provided: ${this.options.url}`)}}validateFormatters(){if(this.options.columnFormatters)for(const t in this.options.columnFormatters)"function"!=typeof this.options.columnFormatters[t]&&this.logger(Se.WARN,`columnFormatters for column '${t}' is not a function.`)}validateColumns(){if(!this.options.columns||!Array.isArray(this.options.columns)||0===this.options.columns.length)throw new ke("Columns option must be a non-empty array.");this.options.columnTitles&&this.options.columns.length!==this.options.columnTitles.length&&this.logger(Se.WARN,"The number of columns does not match the number of column titles.")}validateRowsPerPage(){const t=this.options.rowsPerPage??xe.DEFAULT;("number"!=typeof t||t<1||t>1e3)&&this.logger(Se.WARN,`rowsPerPage value '${t}' is outside the recommended range (1-1000).`)}}class cr{constructor(t="/lang",e=!1,n){be(this,$t),be(this,Gt,3),be(this,Vt,"/lang"),be(this,Yt,500),be(this,Xt,"en_US"),be(this,Qt,new Map),be(this,Jt),we(this,Vt,t),we(this,$t,e),we(this,Jt,n||((t,e,...n)=>$e(ve(this,$t),t,e,...n)))}clearCache(){ve(this,Qt).clear(),ve(this,Jt).call(this,Se.INFO,"Translation cache cleared.")}async get(t){if(ve(this,Qt).has(t))return ve(this,Jt).call(this,Se.INFO,`Translation for ${t} found in cache.`),ve(this,Qt).get(t);ve(this,Jt).call(this,Se.INFO,`Attempting to load translation for: ${t}`);for(let n=1;n<=ve(this,Gt)+1;n++)try{const e=await fetch(`${ve(this,Vt)}/${t}.json`);if(!e.ok)throw new Error(`Translation file for ${t} not found (status: ${e.status}).`);const n=await e.json();return ve(this,Qt).set(t,n),ve(this,Jt).call(this,Se.INFO,`Translation for ${t} loaded and cached.`),n}catch(e){if(ve(this,Jt).call(this,Se.ERROR,`Failed to load translation for ${t} (attempt ${n}):`,e),n>ve(this,Gt)){if(t===ve(this,Xt))throw ve(this,Jt).call(this,Se.ERROR,`CRITICAL: Fallback translation '${ve(this,Xt)}' failed to load.`),new Error(`CRITICAL: Fallback translation '${ve(this,Xt)}' failed to load.`);return ve(this,Jt).call(this,Se.WARN,`All retries failed for ${t}. Falling back to ${ve(this,Xt)}.`),this.get(ve(this,Xt))}await new Promise(t=>setTimeout(t,ve(this,Yt)*n))}throw new Error(`Failed to load translation for ${t} and its fallback.`)}}$t=new WeakMap,Gt=new WeakMap,Vt=new WeakMap,Yt=new WeakMap,Xt=new WeakMap,Qt=new WeakMap,Jt=new WeakMap;Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,ne=new WeakMap,re=new WeakMap,ie=new WeakSet,se=async function(t){this.log(Se.INFO,"Using cached response for URL:",t.url),this.stateManager.setState(e=>{e.data=t.data,e.totalRecords=t.totalRecords}),this.renderer.render(),this.eventManager.setupAllHandlers(),this.preloadNextPageEnabled&&this.cacheManager.preloadNextPage()},ae=async function(t,e){this.log(Se.INFO,`Fetching data from URL (Attempt ${e}): ${t}`),this.lifecycleHooks.preDataLoad&&this.lifecycleHooks.preDataLoad(this.urlManager.getServerParams());const n=await fetch(t);if(!n.ok)throw new Pe(`HTTP error! status: ${n.status}`);const r=await n.json();await _e(this,ie,oe).call(this,r,t)},oe=async function(t,e){const n=t.data||[];this.log(Se.INFO,"Successfully fetched and processed data.",{url:e,totalRecords:t.totalRecords,receivedCount:n.length}),this.stateManager.setState(e=>{e.data=n,e.totalRecords=t.totalRecords||0}),this.useCache&&await this.cacheManager.cacheData(e,{url:e,data:[...this.state.data],totalRecords:this.state.totalRecords,timestamp:Date.now()}),this.lifecycleHooks.postDataLoad&&this.lifecycleHooks.postDataLoad(this.state.data),this.clearFormatCache(),this.renderer.render(),this.eventManager.setupAllHandlers(),this.preloadNextPageEnabled&&this.cacheManager.preloadNextPage()},le=function(t){this.debug&&performance.mark(`${t}-start`)},ce=function(t){if(this.debug){performance.mark(`${t}-end`),performance.measure(t,`${t}-start`,`${t}-end`);const e=performance.getEntriesByName(t)[0];this.log(Se.INFO,`${t} took ${e.duration}ms`)}},ue=function(t,e){let n=null;return(...r)=>{n&&clearTimeout(n),n=window.setTimeout(()=>t(...r),e)}},he=function(t,e,n){if(e<=this.retryAttempts&&!(t instanceof Pe))return this.log(Se.WARN,`Retry attempt ${e} for URL:`,n,{error:t}),void this.loadData(e+1);const r=(this.state.translations??Ve).errors.dataLoadingFailed.replace("{error}",t.message);this.log(Se.ERROR,"Data load failed after all retries:",{error:t,url:n}),this.renderer.showError(r)},de=async function(){this.log(Se.INFO,"Starting component initialization..."),this.renderer.createContainers(),this.persistState&&this.stateManager.loadStateFromStorage(),this.stateManager.loadFromURL(),this.renderer.applyThemeClass();try{const t=await this.translationManager.get(this.state.language)??Ve;this.stateManager.setState(e=>{e.translations=t})}catch(t){this.log(Se.ERROR,"Failed to initialize translations",t);const e=Ve;this.stateManager.setState(t=>{t.translations=e}),this.renderer.showError(e.errors.generic)}finally{this.renderer.render(),this.eventManager.setupAllHandlers(),ve(this,te).call(this),this.log(Se.INFO,"Component initialization finished.")}},fe=function(t){this.log(Se.LOG,"Initializing instance properties from options."),this.baseUrl=t.url,this.useCache=t.useCache??!1,this.usePushState=t.usePushState??!1,this.columnFormatters=t.columnFormatters,this.debounceDelay=Ue.constants.defaultDebounceDelay,this.cacheExpiry=t.cacheExpiry??Ue.constants.defaultCacheExpiry,this.selectable=t.selectable??!1,this.lifecycleHooks=t.lifecycleHooks??{},this.draggableColumns=t.draggableColumns??!1,this.preloadNextPageEnabled=t.preloadNextPage??!1,this.lazyLoadMedia=t.lazyLoadMedia??!1,this.persistState=t.persistState??!1,this.destroyOnUnload=t.destroyOnUnload??!0,this.retryAttempts=t.retryAttempts??3,this.formatCacheSize=t.formatCacheSize??500,this.prevButtonConfig={...Ue.pagination.prevButton,...t.prevButton},this.nextButtonConfig={...Ue.pagination.nextButton,...t.nextButton},we(this,re,this.destroy.bind(this)),this.destroyOnUnload&&window.addEventListener("beforeunload",ve(this,re))},t.OrderDirection=Oe,t.RenderType=Ee,t.RowsPerPage=xe,t.SnapRecords=class{constructor(t,e={}){var n,r,i,s,a;be(this,ie),be(this,Zt),be(this,te),be(this,ee),be(this,ne),be(this,re),this.errorContainer=null,this.isLoading=!1,this.headerCellClasses=[],this.selectedRows=new Set,this.currentRowIndex=-1,this.debug=!1,this.lastFilterHash="";const o=performance.now(),l=document.getElementById(t);if(!l)throw new ke(`Container with ID '${t}' not found.`);this.container=l,this.contentContainer=document.createElement("div"),this.debug=e.debug??!1,we(this,ne,new lr(e,this.debug,this.log.bind(this)));const c=ve(this,ne).options;_e(this,ie,fe).call(this,c),window.addEventListener("error",t=>{this.log(Se.ERROR,"Unhandled error",t.error)}),window.addEventListener("unhandledrejection",t=>{this.log(Se.ERROR,"Unhandled promise rejection",t.reason)}),we(this,ee,new Be({max:this.formatCacheSize})),this.state={currentPage:1,rowsPerPage:c.rowsPerPage??xe.DEFAULT,filters:{},sortConditions:[],columns:[...c.columns],columnTitles:[...c.columnTitles??c.columns],columnWidths:new Map,data:[],totalRecords:0,format:c.format??Ee.TABLE,language:c.language??"en_US",translations:null,theme:c.theme??"default",headerCellClasses:[...c.headerCellClasses??[]]};const u={reorderColumns:this.reorderColumns.bind(this),requestDataLoad:this.refresh.bind(this)};this.db=new or(`SnapRecordsDB_${this.container.id}`),this.translationManager=new cr(c.langPath,this.debug,this.log.bind(this)),this.stateManager=(null==(n=e.stateManager)?void 0:n.call(e,this))??new Bn(this),this.urlManager=(null==(r=e.urlManager)?void 0:r.call(e,this))??new Ge(this),this.cacheManager=(null==(i=e.cacheManager)?void 0:i.call(e,this,this.urlManager))??new Xe(this,this.urlManager),this.renderer=(null==(s=e.renderer)?void 0:s.call(e,this,this.contentContainer))??new Ye(this,this.contentContainer),this.eventManager=(null==(a=e.eventManager)?void 0:a.call(e,this,this.renderer,u))??new qn(this,this.renderer,u),we(this,Zt,new qe(this)),we(this,te,_e(this,ie,ue).call(this,()=>this.loadData(),this.debounceDelay)),_e(this,ie,de).call(this),this.log(Se.INFO,`SnapRecords initialized in ${performance.now()-o}ms.`)}get storageKey(){return`snap-records-state-${this.container.id}`}getApi(){return ve(this,Zt)}getData(){return this.state.data}getTotals(){return{totalRecords:this.state.totalRecords}}log(t,...e){$e(this.debug,t,...e)}refresh(){this.log(Se.INFO,"Data refresh requested."),ve(this,te).call(this)}clearSelection(){this.log(Se.INFO,"Clearing all row selections."),this.selectedRows.clear(),this.renderer.highlightSelectedRows()}gotoPage(t){this.log(Se.INFO,`Navigating to page ${t}.`),this.stateManager.setState(e=>{e.currentPage=t}),this.clearFormatCache(),ve(this,te).call(this)}setTheme(t){this.state.theme!==t&&(this.log(Se.INFO,`Setting theme to: ${t}`),this.stateManager.setState(e=>{e.theme=t}),this.renderer.applyThemeClass())}createMobileCard(t,e){const n=document.createElement("div");return n.classList.add(Ue.classes.mobileCard),n.setAttribute("data-key",t.id.toString()),n.setAttribute("role","rowgroup"),this.updateMobileCard(n,t,e),n}createListItem(t,e){const n=document.createElement("li");return n.classList.add(...Ue.classes.list.itemClass.split(" ")),n.setAttribute("data-index",e.toString()),n.setAttribute("data-key",t.id.toString()),n.setAttribute("role","listitem"),this.updateListItem(n,t,e),n}setRenderMode(t){this.state.format!==t&&(this.log(Se.INFO,`Setting render mode to: ${t}`),this.stateManager.setState(e=>{e.format=t}),this.clearFormatCache(),this.renderer.render(),this.eventManager.setupAllHandlers())}clearFormatCache(){ve(this,ee).clear(),this.log(Se.INFO,"In-memory format cache cleared.")}destroy(){this.log(Se.LOG,"Destroying SnapRecords Instance..."),this.eventManager.destroy(),this.renderer.destroy(),this.db.close(),this.translationManager.clearCache(),this.destroyOnUnload&&window.removeEventListener("beforeunload",ve(this,re))}updateMobileCard(t,e,n){t.setAttribute("data-index",n.toString()),t.innerHTML="",this.state.columns.forEach(n=>{const r=document.createElement("div");r.classList.add(Ue.classes.cardRow),r.setAttribute("role","row");const i=document.createElement("span");i.classList.add(Ue.classes.cardLabel),i.setAttribute("role","columnheader");const s=document.createElement("span");s.classList.add(Ue.classes.cardValue),s.setAttribute("role","cell");const a=this.state.columns.indexOf(n),o=-1!==a?this.state.columnTitles[a]:n;i.textContent=`${o}:`,s.innerHTML=this.getFormattedValue(e[n],n,e),r.appendChild(i),r.appendChild(s),t.appendChild(r)})}reorderColumns(t,e){this.stateManager.setState(n=>{const r=n.columns.indexOf(t),i=n.columns.indexOf(e);if(-1===r||-1===i)return;const s=n.columns,a=n.columnTitles,o=n.headerCellClasses,[l]=s.splice(r,1);s.splice(i,0,l);const[c]=a.splice(r,1);if(a.splice(i,0,c),o.length>0){const[t]=o.splice(r,1);o.splice(i,0,t)}this.log(Se.INFO,`Columns reordered. New order: ${s.join(", ")}`)}),this.clearFormatCache(),this.renderer.render(),this.eventManager.setupAllHandlers()}getFormattedValue(t,e,n){const r=`${n.id}_${e}`;if(ve(this,ee).has(r))return ve(this,ee).get(r);let i=He(this.columnFormatters&&this.columnFormatters[e]?this.columnFormatters[e](t,n):String(t??""));return this.lazyLoadMedia&&(i=i.replace(/<img /g,'<img loading="lazy" ')),ve(this,ee).set(r,i),i}async loadData(t=1){if(this.baseUrl){_e(this,ie,le).call(this,"data-load"),this.log(Se.INFO,"Starting data load process..."),this.renderer.showLoading();try{this.cacheManager.invalidateCache();const e=this.urlManager.buildUrl(this.urlManager.getServerParams());if(this.useCache){const t=await this.cacheManager.getCachedData(e);if(t&&Date.now()-t.timestamp<this.cacheExpiry)return void(await _e(this,ie,se).call(this,t))}await _e(this,ie,ae).call(this,e,t)}catch(e){_e(this,ie,he).call(this,e,t,this.baseUrl)}finally{this.renderer.hideLoading(),_e(this,ie,ce).call(this,"data-load")}}}search(t,e=!1){this.log(Se.INFO,"Performing search with filters:",{filters:t,merge:e}),this.stateManager.setState(n=>{n.currentPage=1,n.filters=e?{...n.filters,...t}:t}),this.clearFormatCache(),ve(this,te).call(this)}getSelectedRows(){return Array.from(this.selectedRows).map(t=>this.state.data[t])}updateListItem(t,e,n){t.setAttribute("data-index",n.toString());const r=this.state.columns.map(t=>{const n=this.state.columns.indexOf(t);return`<strong>${-1!==n?this.state.columnTitles[n]:t}:</strong> ${this.getFormattedValue(e[t],t,e)}`}).join(" | ");t.innerHTML=r}setRowsPerPage(t){this.state.rowsPerPage!==t&&(this.log(Se.INFO,`Setting rows per page to: ${t}`),this.stateManager.setState(e=>{e.rowsPerPage=t,e.currentPage=1}),this.clearFormatCache(),ve(this,te).call(this),this.renderer.announceScreenReaderUpdate(`Rows per page changed to ${t}`))}updateRow(t,e,n){t.setAttribute("data-index",n.toString());const r=document.createDocumentFragment();this.state.columns.forEach(t=>{const n=t,i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("data-col-id",n);const s=this.getFormattedValue(e[n],n,e);i.innerHTML=s,i.dataset.lastValue=s,r.appendChild(i)}),t.innerHTML="",t.appendChild(r)}createTableRow(t,e,n){const r=document.createElement("tr");return r.setAttribute("role","row"),r.setAttribute("data-index",e.toString()),r.setAttribute("data-key",String(n)),this.state.columns.forEach(e=>{const n=e,i=document.createElement("td");i.setAttribute("role","gridcell"),i.setAttribute("data-col-id",n);const s=this.getFormattedValue(t[n],n,t);i.innerHTML=s,i.dataset.lastValue=s,r.appendChild(i)}),r}reset(){this.log(Se.INFO,"Resetting instance to initial state."),this.persistState&&localStorage.removeItem(this.storageKey),this.stateManager.setState(t=>{const e=ve(this,ne).options;t.currentPage=1,t.filters={},t.sortConditions=[],t.columns=[...e.columns||[]],t.columnTitles=[...e.columnTitles||e.columns||[]],t.headerCellClasses=[...e.headerCellClasses||[]],t.columnWidths=new Map}),this.clearFormatCache(),ve(this,te).call(this)}updateParams(t){this.log(Se.INFO,"Updating parameters.",t),this.stateManager.setState(e=>{Object.assign(e,t)}),this.clearFormatCache(),ve(this,te).call(this)}async setLanguage(t){if(this.state.language!==t){this.log(Se.INFO,`Setting language to: ${t}`);const e=await this.translationManager.get(t)??Ve;this.stateManager.setState(n=>{n.language=t,n.translations=e}),this.clearFormatCache(),this.renderer.render(),this.eventManager.setupAllHandlers()}}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})});
|
|
2
|
+
//# sourceMappingURL=snap-records.umd.js.map
|