import{r as e,t}from"./rolldown-runtime-S-ySWqyJ.js";var n=e(t(((e,t)=>{((n,r)=>{typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).Dexie=r()})(e,function(){var e=function(t,n){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}))(t,n)},t=function(){return(t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n`u`||r.Promise||(r.Promise=Promise);var s=Object.getPrototypeOf,c={}.hasOwnProperty;function l(e,t){return c.call(e,t)}function u(e,t){typeof t==`function`&&(t=t(s(e))),(typeof Reflect>`u`?i:Reflect.ownKeys)(t).forEach(function(n){f(e,n,t[n])})}var d=Object.defineProperty;function f(e,t,n,r){d(e,t,o(n&&l(n,`get`)&&typeof n.get==`function`?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function p(e){return{from:function(t){return e.prototype=Object.create(t.prototype),f(e.prototype,`constructor`,e),{extend:u.bind(null,e.prototype)}}}}var m=Object.getOwnPropertyDescriptor,h=[].slice;function g(e,t,n){return h.call(e,t,n)}function _(e,t){return t(e)}function v(e){if(!e)throw Error(`Assertion Failed`)}function y(e){r.setImmediate?setImmediate(e):setTimeout(e,0)}function b(e,t){if(typeof t==`string`&&l(e,t))return e[t];if(!t)return e;if(typeof t!=`string`){for(var n=[],r=0,i=t.length;r`u`?[]:(E=Promise.resolve(),typeof crypto<`u`&&crypto.subtle?[Ae=crypto.subtle.digest(`SHA-512`,new Uint8Array([0])),s(Ae),E]:[E,s(E),E]),E=Ae[0],je=Ae[1],je=je&&je.then,Me=E&&E.constructor,Ne=!!Ae[2],Pe=function(e,t){Be.push([e,t]),Ie&&=(queueMicrotask(Ye),!1)},Fe=!0,Ie=!0,Le=[],Re=[],ze=ye,A={id:`global`,global:!0,ref:0,unhandleds:[],onunhandled:O,pgp:!1,env:{},finalize:O},j=A,Be=[],Ve=0,He=[];function M(e){if(typeof this!=`object`)throw TypeError(`Promises must be constructed via new`);this._listeners=[],this._lib=!1;var t=this._PSD=j;if(typeof e!=`function`){if(e!==Oe)throw TypeError(`Not a function`);this._state=arguments[1],this._value=arguments[2],!1===this._state&&Ge(this,this._value)}else this._state=null,this._value=null,++t.ref,function e(t,n){try{n(function(n){if(t._state===null){if(n===t)throw TypeError(`A promise cannot be resolved with itself.`);var r=t._lib&&Xe();n&&typeof n.then==`function`?e(t,function(e,t){n instanceof M?n._then(e,t):n.then(e,t)}):(t._state=!0,t._value=n,Ke(t)),r&&Ze()}},Ge.bind(null,t))}catch(e){Ge(t,e)}}(this,e)}var Ue={get:function(){var e=j,t=rt;function n(n,r){var i=this,a=!e.global&&(e!==j||t!==rt),o=a&&!I(),s=new M(function(t,s){qe(i,new We(ut(n,e,a,o),ut(r,e,a,o),t,s,e))});return this._consoleTask&&(s._consoleTask=this._consoleTask),s}return n.prototype=Oe,n},set:function(e){f(this,`then`,e&&e.prototype===Oe?Ue:{get:function(){return e},set:Ue.set})}};function We(e,t,n,r,i){this.onFulfilled=typeof e==`function`?e:null,this.onRejected=typeof t==`function`?t:null,this.resolve=n,this.reject=r,this.psd=i}function Ge(e,t){var n,r;Re.push(t),e._state===null&&(n=e._lib&&Xe(),t=ze(t),e._state=!1,e._value=t,r=e,Le.some(function(e){return e._value===r._value})||Le.push(r),Ke(e),n)&&Ze()}function Ke(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n{for(var t=Le.length;t;)if(Le[--t]._value===e._value)return Le.splice(t,1)})(t),n.resolve(r)}catch(e){n.reject(e)}finally{--Ve==0&&Qe(),--n.psd.ref||n.psd.finalize()}}function Ye(){lt(A,function(){Xe()&&Ze()})}function Xe(){var e=Fe;return Ie=Fe=!1,e}function Ze(){var e,t,n;do for(;0.`,pt=`String expected.`,mt=[],ht=`__dbnames`,gt=`readonly`,_t=`readwrite`;function B(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}var vt={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function yt(e){return typeof e!=`string`||/\./.test(e)?function(e){return e}:function(t){return t[e]===void 0&&e in t&&delete(t=re(t))[e],t}}function bt(){throw D.Type(`Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.`)}function V(e,t){try{var n=xt(e),r=xt(t);if(n!==r)return n===`Array`?1:r===`Array`?-1:n===`binary`?1:r===`binary`?-1:n===`string`?1:r===`string`?-1:n===`Date`?1:r===`Date`?-1:NaN;switch(n){case`number`:case`Date`:case`string`:return t{var i=s,a=t;if(typeof a!=`function`&&a!==null)throw TypeError(`Class extends value `+String(a)+` is not a constructor or null`);function o(){this.constructor=i}function s(){return t!==null&&t.apply(this,arguments)||this}return e(i,a),i.prototype=a===null?Object.create(a):(o.prototype=a.prototype,new o),Object.defineProperty(s.prototype,`db`,{get:function(){return n},enumerable:!1,configurable:!0}),s.prototype.table=function(){return r},s})(t)),new Set),a=t.prototype;a;a=s(a))Object.getOwnPropertyNames(a).forEach(function(e){return i.add(e)});function o(e){if(!e)return e;var n,r=Object.create(t.prototype);for(n in e)if(!i.has(n))try{r[n]=e[n]}catch{}return r}return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=o,this.hook(`reading`,o),t},H.prototype.defineClass=function(){return this.mapToClass(function(e){o(this,e)})},H.prototype.add=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,a=r.keyPath,o=e;return a&&i&&(o=yt(a)(e)),this._trans(`readwrite`,function(e){return n.core.mutate({trans:e,type:`add`,keys:t==null?null:[t],values:[o]})}).then(function(e){return e.numFailures?M.reject(e.failures[0]):e.lastResult}).then(function(t){if(a)try{x(e,a,t)}catch{}return t})},H.prototype.upsert=function(e,t){var n=this,r=this.schema.primKey.keyPath;return this._trans(`readwrite`,function(i){return n.core.get({trans:i,key:e}).then(function(a){var o=a??{};return Et(o,t),r&&x(o,r,e),n.core.mutate({trans:i,type:`put`,values:[o],keys:[e],upsert:!0,updates:{keys:[e],changeSpecs:[t]}}).then(function(e){return e.numFailures?M.reject(e.failures[0]):!!a})})})},H.prototype.update=function(e,t){return typeof e!=`object`||a(e)?this.where(`:id`).equals(e).modify(t):(e=b(e,this.schema.primKey.keyPath))===void 0?R(new D.InvalidArgument(`Given object does not contain its primary key`)):this.where(`:id`).equals(e).modify(t)},H.prototype.put=function(e,t){var n=this,r=this.schema.primKey,i=r.auto,a=r.keyPath,o=e;return a&&i&&(o=yt(a)(e)),this._trans(`readwrite`,function(e){return n.core.mutate({trans:e,type:`put`,values:[o],keys:t==null?null:[t]})}).then(function(e){return e.numFailures?M.reject(e.failures[0]):e.lastResult}).then(function(t){if(a)try{x(e,a,t)}catch{}return t})},H.prototype.delete=function(e){var t=this;return this._trans(`readwrite`,function(n){return t.core.mutate({trans:n,type:`delete`,keys:[e]}).then(function(n){return Ct(t,[e],n)}).then(function(e){return e.numFailures?M.reject(e.failures[0]):void 0})})},H.prototype.clear=function(){var e=this;return this._trans(`readwrite`,function(t){return e.core.mutate({trans:t,type:`deleteRange`,range:vt}).then(function(t){return Ct(e,null,t)})}).then(function(e){return e.numFailures?M.reject(e.failures[0]):void 0})},H.prototype.bulkGet=function(e){var t=this;return this._trans(`readonly`,function(n){return t.core.getMany({keys:e,trans:n}).then(function(e){return e.map(function(e){return t.hook.reading.fire(e)})})})},H.prototype.bulkAdd=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,a=(n||=i?void 0:t)?n.allKeys:void 0;return this._trans(`readwrite`,function(t){var n=r.schema.primKey,o=n.auto,n=n.keyPath;if(n&&i)throw new D.InvalidArgument(`bulkAdd(): keys argument invalid on tables with inbound keys`);if(i&&i.length!==e.length)throw new D.InvalidArgument(`Arguments objects and keys must have the same length`);var s=e.length,o=n&&o?e.map(yt(n)):e;return r.core.mutate({trans:t,type:`add`,keys:i,values:o,wantResults:a}).then(function(e){var t=e.numFailures,n=e.failures;if(t===0)return a?e.results:e.lastResult;throw new he(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`,n)})})},H.prototype.bulkPut=function(e,t,n){var r=this,i=Array.isArray(t)?t:void 0,a=(n||=i?void 0:t)?n.allKeys:void 0;return this._trans(`readwrite`,function(t){var n=r.schema.primKey,o=n.auto,n=n.keyPath;if(n&&i)throw new D.InvalidArgument(`bulkPut(): keys argument invalid on tables with inbound keys`);if(i&&i.length!==e.length)throw new D.InvalidArgument(`Arguments objects and keys must have the same length`);var s=e.length,o=n&&o?e.map(yt(n)):e;return r.core.mutate({trans:t,type:`put`,keys:i,values:o,wantResults:a}).then(function(e){var t=e.numFailures,n=e.failures;if(t===0)return a?e.results:e.lastResult;throw new he(`${r.name}.bulkPut(): ${t} of ${s} operations failed`,n)})})},H.prototype.bulkUpdate=function(e){var t=this,n=this.core,r=e.map(function(e){return e.key}),i=e.map(function(e){return e.changes}),a=[];return this._trans(`readwrite`,function(o){return n.getMany({trans:o,keys:r,cache:`clone`}).then(function(s){var c=[],l=[],u=(e.forEach(function(e,n){var r=e.key,i=e.changes,o=s[n];if(o){for(var u=0,d=Object.keys(i);uf+p&&i(f+d)})})}var c=At(n)&&n.limit===1/0&&(typeof e!=`function`||h)&&{index:n.index,range:n.range};return i(0).then(function(){if(0{for(var o=Math.min(e.length,r.length),s=-1,c=0;c=a})).length===0?M.resolve():(t.forEach(function(e){l.push(function(){var t,n,o,l=u,d=e._cfg.dbschema,f=(_n(r,l,c),_n(r,d,c),u=r._dbSchema=d,fn(l,d)),p=(f.add.forEach(function(e){pn(c,e[0],e[1].primKey,e[1].indexes)}),f.change.forEach(function(e){if(e.recreate)throw new D.Upgrade(`Not yet support for changing primary key`);var t=c.objectStore(e.name);e.add.forEach(function(e){return hn(t,e)}),e.change.forEach(function(e){t.deleteIndex(e.name),hn(t,e)}),e.del.forEach(function(e){return t.deleteIndex(e)})}),e._cfg.contentUpgrade);if(p&&e._cfg.version>a)return on(r,c),s._memoizedTables={},t=S(d),f.del.forEach(function(e){t[e]=l[e]}),cn(r,[r.Transaction.prototype]),sn(r,[r.Transaction.prototype],i(t),t),s.schema=t,(n=ue(p))&&at(),d=M.follow(function(){var e;(o=p(s))&&n&&(e=I.bind(null,null),o.then(e,e))}),o&&typeof o.then==`function`?M.resolve(o):d.then(function(){return o})}),l.push(function(t){var n=e._cfg.dbschema,i=t;[].slice.call(i.db.objectStoreNames).forEach(function(e){return n[e]==null&&i.db.deleteObjectStore(e)}),cn(r,[r.Transaction.prototype]),sn(r,[r.Transaction.prototype],r._storeNames,r._dbSchema),s.schema=r._dbSchema}),l.push(function(t){r.idbdb.objectStoreNames.contains(`$meta`)&&(Math.ceil(r.idbdb.version/10)===e._cfg.version?(r.idbdb.deleteObjectStore(`$meta`),delete r._dbSchema.$meta,r._storeNames=r._storeNames.filter(function(e){return e!==`$meta`})):t.objectStore(`$meta`).put(e._cfg.version,`version`))})}),function e(){return l.length?M.resolve(l.shift()(s.idbtrans)).then(e):M.resolve()}().then(function(){mn(u,c)}))}).catch(s);var r,l;i(a).forEach(function(e){pn(n,e,a[e].primKey,a[e].indexes)}),on(e,n),M.follow(function(){return e.on.populate.fire(o)}).catch(s)})}function dn(e,t){mn(e._dbSchema,t),t.db.version%10!=0||t.objectStoreNames.contains(`$meta`)||t.db.createObjectStore(`$meta`).add(Math.ceil(t.db.version/10-1),`version`);var n=gn(0,e.idbdb,t);_n(e,e._dbSchema,t);for(var r=0,i=fn(n,e._dbSchema).change;r{if(e.change.length||e.recreate)return console.warn(`Unable to patch indexes of table ${e.name} because it has changes on the type of index or primary key.`),{value:void 0};var n=t.objectStore(e.name);e.add.forEach(function(t){k&&console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`),hn(n,t)})})(i[r]);if(typeof a==`object`)return a.value}}function fn(e,t){var n,r={del:[],add:[],change:[]};for(n in e)t[n]||r.del.push(n);for(n in t){var i=e[n],a=t[n];if(i){var o={name:n,def:a,recreate:!1,del:[],add:[],change:[]};if(``+(i.primKey.keyPath||``)!=``+(a.primKey.keyPath||``)||i.primKey.auto!==a.primKey.auto)o.recreate=!0,r.change.push(o);else{var s=i.idxByName,c=a.idxByName,l=void 0;for(l in s)c[l]||o.del.push(l);for(l in c){var u=s[l],d=c[l];u?u.src!==d.src&&o.change.push(d):o.add.push(d)}(02**62?0:r.oldVersion,f=i<1,e.idbdb=p.result,o&&dn(e,d),un(e,i/10,d,l))},l),p.onsuccess=N(function(){d=null;var n,s,l,m,h,_,v=e.idbdb=p.result,y=g(v.objectStoreNames);if(0`u`?M.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(e){function t(){return indexedDB.databases().finally(e)}l=setInterval(t,100),t()}).finally(function(){return clearInterval(l)}):Promise.resolve()).then(c)]).then(function(){return s(),t.onReadyBeingFired=[],M.resolve(Cn(function(){return e.on.ready.fire(e.vip)})).then(function n(){var r;if(0t.limit?r.length=t.limit:e.length===t.limit&&r.length{if(e===void 0)return t===void 0?0:-1;if(t===void 0)return 1;if((e=V(e,t))===0){if(n&&r)return 0;if(n)return 1;if(r)return-1}return e})(e.lower,t.lower,e.lowerOpen,t.lowerOpen)<=0&&0<=((e,t,n,r)=>{if(e===void 0)return t===void 0?0:1;if(t===void 0)return-1;if((e=V(e,t))===0){if(n&&r)return 0;if(n)return-1;if(r)return 1}return e})(e.upper,t.upper,e.upperOpen,t.upperOpen)}function nr(e,t,n,r){e.subscribers.add(n),r.addEventListener(`abort`,function(){var r,i;e.subscribers.delete(n),e.subscribers.size===0&&(r=e,i=t,setTimeout(function(){r.subscribers.size===0&&ce(i,r)},3e3))})}var rr={stack:`dbcore`,level:0,name:`Cache`,create:function(e){var n=e.schema.name;return t(t({},e),{transaction:function(t,r,i){var a,o,s=e.transaction(t,r,i);return r===`readwrite`&&(i=(a=new AbortController).signal,s.addEventListener(`abort`,(o=function(i){return function(){if(a.abort(),r===`readwrite`){for(var o=new Set,c=0,l=t;c{var i=Nn[`idb://${e}/${t}`];if(!i)return[];if(!(e=i.queries[n]))return[null,!1,i,null];var a=e[(r.query?r.query.index.name:null)||``];if(!a)return[null,!1,i,null];switch(n){case`query`:var o=a.find(function(e){return e.req.limit===r.limit&&e.req.values===r.values&&er(e.req.query.range,r.query.range)});return o?[o,!0,i,a]:[a.find(function(e){return(`limit`in e.req?e.req.limit:1/0)>=r.limit&&(!r.values||e.req.values)&&tr(e.req.query.range,r.query.range)}),!1,i,a];case`count`:return o=a.find(function(e){return er(e.req.query.range,r.query.range)}),[o,!!o,i,a]}})(n,r,`query`,e),u=l[0],s=l[2],c=l[3],u&&l[1]?u.obsSet=e.obsSet:(l=i.query(e).then(function(e){var n=e.result;if(u&&(u.res=n),t){for(var r=0,i=n.length;r{var n=Xe();try{i&&at();var r=F(e,t);return r=i?r.finally(I):r}finally{n&&Ze()}})(m={subscr:u,signal:a.signal,requery:f,querier:e,trans:null}),Promise.resolve(h).then(function(e){n=!0,t=e,o||m.signal.aborted||(s={},(e=>{for(var t in e)if(l(e,t))return;return 1})(c=u)||d||(J(Kt,p),d=!0),dt(function(){return!o&&r.next&&r.next(e)}))},function(e){n=!1,[`DatabaseClosedError`,`AbortError`].includes(e?.name)||o||dt(function(){o||r.error&&r.error(e)})}))};return setTimeout(f,0),u});return r.hasValue=function(){return n},r.getValue=function(){return t},r}var $=Z;function lr(e){var t=dr;try{dr=!0,J.storagemutated.fire(e),Ln(e,!0)}finally{dr=t}}u($,t(t({},w),{delete:function(e){return new $(e,{addons:[]}).delete()},exists:function(e){return new $(e,{addons:[]}).open().then(function(e){return e.close(),!0}).catch(`NoSuchDatabaseError`,function(){return!1})},getDatabaseNames:function(e){try{return t=$.dependencies,n=t.indexedDB,t=t.IDBKeyRange,(Sn(n)?Promise.resolve(n.databases()).then(function(e){return e.map(function(e){return e.name}).filter(function(e){return e!==ht})}):xn(n,t).toCollection().primaryKeys()).then(e)}catch{return R(new D.MissingAPI)}var t,n},defineClass:function(){return function(e){o(this,e)}},ignoreTransaction:function(e){return j.trans?lt(j.transless,e):e()},vip:Cn,async:function(e){return function(){try{var t=Bn(e.apply(this,arguments));return t&&typeof t.then==`function`?t:M.resolve(t)}catch(e){return R(e)}}},spawn:function(e,t,n){try{var r=Bn(e.apply(n,t||[]));return r&&typeof r.then==`function`?r:M.resolve(r)}catch(e){return R(e)}},currentTransaction:{get:function(){return j.trans||null}},waitFor:function(e,t){return e=M.resolve(typeof e==`function`?$.ignoreTransaction(e):e).timeout(t||6e4),j.trans?j.trans.waitFor(e):e},Promise:M,debug:{get:function(){return k},set:function(e){De(e)}},derive:p,extend:o,props:u,override:_,Events:Ot,on:J,liveQuery:cr,extendObservabilitySet:jn,getByKeyPath:b,setByKeyPath:x,delByKeyPath:function(e,t){typeof t==`string`?x(e,t,void 0):`length`in t&&[].map.call(t,function(t){x(e,t,void 0)})},shallowClone:S,deepClone:re,getObjectDiff:Un,cmp:V,asap:y,minKey:-1/0,addons:[],connections:mt,errnames:ge,dependencies:ar,cache:Nn,semVer:`4.3.0`,version:`4.3.0`.split(`.`).map(function(e){return parseInt(e)}).reduce(function(e,t,n){return e+t/10**(2*n)})})),$.maxKey=Qt($.dependencies.IDBKeyRange),typeof dispatchEvent<`u`&&typeof addEventListener<`u`&&(J(Kt,function(e){dr||=(e=new CustomEvent(qt,{detail:e}),dr=!0,dispatchEvent(e),!1)}),addEventListener(qt,function(e){e=e.detail,dr||lr(e)}));var ur,dr=!1,fr=function(){};return typeof BroadcastChannel<`u`&&((fr=function(){(ur=new BroadcastChannel(qt)).onmessage=function(e){return e.data&&lr(e.data)}})(),typeof ur.unref==`function`&&ur.unref(),J(Kt,function(e){dr||ur.postMessage(e)})),typeof addEventListener<`u`&&(addEventListener(`pagehide`,function(e){if(!Z.disableBfCache&&e.persisted){k&&console.debug(`Dexie: handling persisted pagehide`),ur?.close();for(var t=0,n=mt;t