@septkit/ui 0.0.74 → 0.0.76

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.
Files changed (27) hide show
  1. package/dist/dialecte/composables/use-live-data.js +2 -1
  2. package/dist/dialecte/create-document-store.js +4 -4
  3. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/dialecte-gIPrRzni.js +4415 -0
  4. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/helpers-DVShv41E.js +179 -0
  5. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/helpers.js +3 -0
  6. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/index.js +5 -0
  7. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/project-key-Ch34EtFa.js +1370 -0
  8. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/rolldown-runtime-CYdcPHCu.js +13 -0
  9. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/running-operations-vnijBvn7.js +61 -0
  10. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/same-json-value-C6kUaoyt.js +1543 -0
  11. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/utils-USNkj4sT.js +962 -0
  12. package/dist/external/.pnpm/@dialecte_core@0.8.0/node_modules/@dialecte/core/dist/utils.js +2 -0
  13. package/dist/external/.pnpm/{@dialecte_scl@0.8.1/node_modules/@dialecte/scl/dist/hooks-C05NpRNi.js → @dialecte_scl@0.11.0_libxml2-wasm@0.7.2_vitest@4.1.10/node_modules/@dialecte/scl/dist/hooks-F61-rgXT.js} +974 -242
  14. package/dist/external/.pnpm/{@dialecte_scl@0.8.1 → @dialecte_scl@0.11.0_libxml2-wasm@0.7.2_vitest@4.1.10}/node_modules/@dialecte/scl/dist/v2019C1/index.js +4 -4
  15. package/dist/merge/check-files/identity-warning.js +1 -1
  16. package/dist/merge/confirm/outcome.js +4 -3
  17. package/dist/merge/match/match.js +6 -7
  18. package/dist/merge/session/merge.service.js +2 -2
  19. package/dist/merge/session/use-merge-session.js +2 -0
  20. package/dist/merge/wording.js +6 -7
  21. package/dist/xpath-input/xpath-input.vue_vue_type_script_setup_true_lang.js +6 -2
  22. package/package.json +3 -3
  23. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/helpers.js +0 -229
  24. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/index.js +0 -3
  25. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/project-sK-5Xc-5.js +0 -7371
  26. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/utils-CTBHUFs9.js +0 -440
  27. package/dist/external/.pnpm/@dialecte_core@0.6.1/node_modules/@dialecte/core/dist/utils.js +0 -2
@@ -0,0 +1,4415 @@
1
+ import { W as e } from "./utils-USNkj4sT.js";
2
+ import { n as t, t as n } from "./rolldown-runtime-CYdcPHCu.js";
3
+ import { A as r, E as i, J as a, M as o, P as s, S as c, T as l, i as u, j as d, k as f, n as p, v as m, w as h, y as g } from "./project-key-Ch34EtFa.js";
4
+ import { i as _, n as v, r as y, t as b } from "./running-operations-vnijBvn7.js";
5
+ import "./helpers-DVShv41E.js";
6
+ import { T as x, d as S, f as C, i as ee, m as w, n as te, p as ne, r as T, t as re, u as ie } from "./same-json-value-C6kUaoyt.js";
7
+ //#region node_modules/.pnpm/@dialecte+core@0.8.0/node_modules/@dialecte/core/dist/dialecte-gIPrRzni.js
8
+ async function ae(e) {
9
+ let { store: t, isRunning: n } = e, r = await t.getDocuments();
10
+ for (let e of r) e.status === "importing" && (await n?.(e) || (await t.getDocument(e.id))?.status === "importing" && await t.removeDocument(e.id));
11
+ }
12
+ function oe(e) {
13
+ let { held: t, registered: n } = e;
14
+ return !t || !n || t.status !== "importing" ? !1 : t.id === n.id && t.writeId === n.writeId && t.createdAt === n.createdAt;
15
+ }
16
+ var E = /* @__PURE__ */ t((/* @__PURE__ */ n(((e, t, n) => {
17
+ ((n, r) => {
18
+ 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();
19
+ })(n, function() {
20
+ var e = function(t, n) {
21
+ return (e = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? function(e, t) {
22
+ e.__proto__ = t;
23
+ } : function(e, t) {
24
+ for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
25
+ }))(t, n);
26
+ }, t = function() {
27
+ return (t = Object.assign || function(e) {
28
+ for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
29
+ return e;
30
+ }).apply(this, arguments);
31
+ };
32
+ function n(e, t, n) {
33
+ if (n || arguments.length === 2) for (var r, i = 0, a = t.length; i < a; i++) !r && i in t || ((r ||= Array.prototype.slice.call(t, 0, i))[i] = t[i]);
34
+ return e.concat(r || Array.prototype.slice.call(t));
35
+ }
36
+ var r = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, i = Object.keys, a = Array.isArray;
37
+ function o(e, t) {
38
+ return typeof t == "object" && i(t).forEach(function(n) {
39
+ e[n] = t[n];
40
+ }), e;
41
+ }
42
+ typeof Promise > "u" || r.Promise || (r.Promise = Promise);
43
+ var s = Object.getPrototypeOf, c = {}.hasOwnProperty;
44
+ function l(e, t) {
45
+ return c.call(e, t);
46
+ }
47
+ function u(e, t) {
48
+ typeof t == "function" && (t = t(s(e))), (typeof Reflect > "u" ? i : Reflect.ownKeys)(t).forEach(function(n) {
49
+ f(e, n, t[n]);
50
+ });
51
+ }
52
+ var d = Object.defineProperty;
53
+ function f(e, t, n, r) {
54
+ d(e, t, o(n && l(n, "get") && typeof n.get == "function" ? {
55
+ get: n.get,
56
+ set: n.set,
57
+ configurable: !0
58
+ } : {
59
+ value: n,
60
+ configurable: !0,
61
+ writable: !0
62
+ }, r));
63
+ }
64
+ function p(e) {
65
+ return { from: function(t) {
66
+ return e.prototype = Object.create(t.prototype), f(e.prototype, "constructor", e), { extend: u.bind(null, e.prototype) };
67
+ } };
68
+ }
69
+ var m = Object.getOwnPropertyDescriptor, h = [].slice;
70
+ function g(e, t, n) {
71
+ return h.call(e, t, n);
72
+ }
73
+ function _(e, t) {
74
+ return t(e);
75
+ }
76
+ function v(e) {
77
+ if (!e) throw Error("Assertion Failed");
78
+ }
79
+ function y(e) {
80
+ r.setImmediate ? setImmediate(e) : setTimeout(e, 0);
81
+ }
82
+ function b(e, t) {
83
+ if (typeof t == "string" && l(e, t)) return e[t];
84
+ if (!t) return e;
85
+ if (typeof t != "string") {
86
+ for (var n = [], r = 0, i = t.length; r < i; ++r) {
87
+ var a = b(e, t[r]);
88
+ n.push(a);
89
+ }
90
+ return n;
91
+ }
92
+ var o, s = t.indexOf(".");
93
+ return s === -1 || (o = e[t.substr(0, s)]) == null ? void 0 : b(o, t.substr(s + 1));
94
+ }
95
+ function x(e, t, n) {
96
+ if (e && t !== void 0 && !("isFrozen" in Object && Object.isFrozen(e))) if (typeof t != "string" && "length" in t) {
97
+ v(typeof n != "string" && "length" in n);
98
+ for (var r = 0, i = t.length; r < i; ++r) x(e, t[r], n[r]);
99
+ } else {
100
+ var o = t.indexOf(".");
101
+ if (o !== -1) {
102
+ var s = t.substr(0, o), o = t.substr(o + 1);
103
+ if (o === "") n === void 0 ? a(e) && !isNaN(parseInt(s)) ? e.splice(s, 1) : delete e[s] : e[s] = n;
104
+ else {
105
+ var c = e[s];
106
+ if (!c || !l(e, s)) {
107
+ if (n === void 0) return;
108
+ c = e[s] = {};
109
+ }
110
+ x(c, o, n);
111
+ }
112
+ } else n === void 0 ? a(e) && !isNaN(parseInt(t)) ? e.splice(t, 1) : delete e[t] : e[t] = n;
113
+ }
114
+ }
115
+ function S(e) {
116
+ var t, n = {};
117
+ for (t in e) l(e, t) && (n[t] = e[t]);
118
+ return n;
119
+ }
120
+ var C = [].concat;
121
+ function ee(e) {
122
+ return C.apply([], e);
123
+ }
124
+ var w = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(ee([
125
+ 8,
126
+ 16,
127
+ 32,
128
+ 64
129
+ ].map(function(e) {
130
+ return [
131
+ "Int",
132
+ "Uint",
133
+ "Float"
134
+ ].map(function(t) {
135
+ return t + e + "Array";
136
+ });
137
+ }))).filter(function(e) {
138
+ return r[e];
139
+ }), te = new Set(w.map(function(e) {
140
+ return r[e];
141
+ })), ne = null;
142
+ function T(e) {
143
+ return ne = /* @__PURE__ */ new WeakMap(), e = function e(t) {
144
+ if (!t || typeof t != "object") return t;
145
+ var n = ne.get(t);
146
+ if (n) return n;
147
+ if (a(t)) {
148
+ n = [], ne.set(t, n);
149
+ for (var r = 0, i = t.length; r < i; ++r) n.push(e(t[r]));
150
+ } else if (te.has(t.constructor)) n = t;
151
+ else {
152
+ var o, c = s(t);
153
+ for (o in n = c === Object.prototype ? {} : Object.create(c), ne.set(t, n), t) l(t, o) && (n[o] = e(t[o]));
154
+ }
155
+ return n;
156
+ }(e), ne = null, e;
157
+ }
158
+ var re = {}.toString;
159
+ function ie(e) {
160
+ return re.call(e).slice(8, -1);
161
+ }
162
+ var ae = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", oe = typeof ae == "symbol" ? function(e) {
163
+ var t;
164
+ return e != null && (t = e[ae]) && t.apply(e);
165
+ } : function() {
166
+ return null;
167
+ };
168
+ function E(e, t) {
169
+ t = e.indexOf(t), 0 <= t && e.splice(t, 1);
170
+ }
171
+ var D = {};
172
+ function O(e) {
173
+ var t, n, r, i;
174
+ if (arguments.length === 1) {
175
+ if (a(e)) return e.slice();
176
+ if (this === D && typeof e == "string") return [e];
177
+ if (i = oe(e)) for (n = []; !(r = i.next()).done;) n.push(r.value);
178
+ else {
179
+ if (e == null || typeof (t = e.length) != "number") return [e];
180
+ for (n = Array(t); t--;) n[t] = e[t];
181
+ }
182
+ } else for (t = arguments.length, n = Array(t); t--;) n[t] = arguments[t];
183
+ return n;
184
+ }
185
+ var se = typeof Symbol < "u" ? function(e) {
186
+ return e[Symbol.toStringTag] === "AsyncFunction";
187
+ } : function() {
188
+ return !1;
189
+ }, w = [
190
+ "Unknown",
191
+ "Constraint",
192
+ "Data",
193
+ "TransactionInactive",
194
+ "ReadOnly",
195
+ "Version",
196
+ "NotFound",
197
+ "InvalidState",
198
+ "InvalidAccess",
199
+ "Abort",
200
+ "Timeout",
201
+ "QuotaExceeded",
202
+ "Syntax",
203
+ "DataClone"
204
+ ], k = [
205
+ "Modify",
206
+ "Bulk",
207
+ "OpenFailed",
208
+ "VersionChange",
209
+ "Schema",
210
+ "Upgrade",
211
+ "InvalidTable",
212
+ "MissingAPI",
213
+ "NoSuchDatabase",
214
+ "InvalidArgument",
215
+ "SubTransaction",
216
+ "Unsupported",
217
+ "Internal",
218
+ "DatabaseClosed",
219
+ "PrematureCommit",
220
+ "ForeignAwait"
221
+ ].concat(w), ce = {
222
+ VersionChanged: "Database version changed by other database connection",
223
+ DatabaseClosed: "Database has been closed",
224
+ Abort: "Transaction aborted",
225
+ TransactionInactive: "Transaction has already completed or failed",
226
+ MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"
227
+ };
228
+ function le(e, t) {
229
+ this.name = e, this.message = t;
230
+ }
231
+ function ue(e, t) {
232
+ return e + ". Errors: " + Object.keys(t).map(function(e) {
233
+ return t[e].toString();
234
+ }).filter(function(e, t, n) {
235
+ return n.indexOf(e) === t;
236
+ }).join("\n");
237
+ }
238
+ function de(e, t, n, r) {
239
+ this.failures = t, this.failedKeys = r, this.successCount = n, this.message = ue(e, t);
240
+ }
241
+ function fe(e, t) {
242
+ this.name = "BulkError", this.failures = Object.keys(t).map(function(e) {
243
+ return t[e];
244
+ }), this.failuresByPos = t, this.message = ue(e, this.failures);
245
+ }
246
+ p(le).from(Error).extend({ toString: function() {
247
+ return this.name + ": " + this.message;
248
+ } }), p(de).from(le), p(fe).from(le);
249
+ var pe = k.reduce(function(e, t) {
250
+ return e[t] = t + "Error", e;
251
+ }, {}), me = le, A = k.reduce(function(e, t) {
252
+ var n = t + "Error";
253
+ function r(e, r) {
254
+ this.name = n, e ? typeof e == "string" ? (this.message = `${e}${r ? "\n " + r : ""}`, this.inner = r || null) : typeof e == "object" && (this.message = `${e.name} ${e.message}`, this.inner = e) : (this.message = ce[t] || n, this.inner = null);
255
+ }
256
+ return p(r).from(me), e[t] = r, e;
257
+ }, {}), he = (A.Syntax = SyntaxError, A.Type = TypeError, A.Range = RangeError, w.reduce(function(e, t) {
258
+ return e[t + "Error"] = A[t], e;
259
+ }, {}));
260
+ w = k.reduce(function(e, t) {
261
+ return [
262
+ "Syntax",
263
+ "Type",
264
+ "Range"
265
+ ].indexOf(t) === -1 && (e[t + "Error"] = A[t]), e;
266
+ }, {});
267
+ function j() {}
268
+ function M(e) {
269
+ return e;
270
+ }
271
+ function ge(e, t) {
272
+ return e == null || e === M ? t : function(n) {
273
+ return t(e(n));
274
+ };
275
+ }
276
+ function N(e, t) {
277
+ return function() {
278
+ e.apply(this, arguments), t.apply(this, arguments);
279
+ };
280
+ }
281
+ function _e(e, t) {
282
+ return e === j ? t : function() {
283
+ var n = e.apply(this, arguments), r = (n !== void 0 && (arguments[0] = n), this.onsuccess), i = this.onerror, a = (this.onsuccess = null, this.onerror = null, t.apply(this, arguments));
284
+ return r && (this.onsuccess = this.onsuccess ? N(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? N(i, this.onerror) : i), a === void 0 ? n : a;
285
+ };
286
+ }
287
+ function ve(e, t) {
288
+ return e === j ? t : function() {
289
+ e.apply(this, arguments);
290
+ var n = this.onsuccess, r = this.onerror;
291
+ this.onsuccess = this.onerror = null, t.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? N(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? N(r, this.onerror) : r);
292
+ };
293
+ }
294
+ function ye(e, t) {
295
+ return e === j ? t : function() {
296
+ var n = e.apply(this, arguments), r = (o(arguments[0], n), this.onsuccess), i = this.onerror, a = (this.onsuccess = null, this.onerror = null, t.apply(this, arguments));
297
+ return r && (this.onsuccess = this.onsuccess ? N(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? N(i, this.onerror) : i), n === void 0 ? a === void 0 ? void 0 : a : o(n, a);
298
+ };
299
+ }
300
+ function be(e, t) {
301
+ return e === j ? t : function() {
302
+ return !1 !== t.apply(this, arguments) && e.apply(this, arguments);
303
+ };
304
+ }
305
+ function xe(e, t) {
306
+ return e === j ? t : function() {
307
+ var n = e.apply(this, arguments);
308
+ if (n && typeof n.then == "function") {
309
+ for (var r = this, i = arguments.length, a = Array(i); i--;) a[i] = arguments[i];
310
+ return n.then(function() {
311
+ return t.apply(r, a);
312
+ });
313
+ }
314
+ return t.apply(this, arguments);
315
+ };
316
+ }
317
+ w.ModifyError = de, w.DexieError = le, w.BulkError = fe;
318
+ var P = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
319
+ function Se(e) {
320
+ P = e;
321
+ }
322
+ var F = {}, Ce = 100, we = typeof Promise > "u" ? [] : (k = Promise.resolve(), typeof crypto < "u" && crypto.subtle ? [
323
+ we = crypto.subtle.digest("SHA-512", new Uint8Array([0])),
324
+ s(we),
325
+ k
326
+ ] : [
327
+ k,
328
+ s(k),
329
+ k
330
+ ]), k = we[0], Te = we[1], Te = Te && Te.then, I = k && k.constructor, Ee = !!we[2], De = function(e, t) {
331
+ Ne.push([e, t]), ke &&= (queueMicrotask(He), !1);
332
+ }, Oe = !0, ke = !0, Ae = [], je = [], Me = M, L = {
333
+ id: "global",
334
+ global: !0,
335
+ ref: 0,
336
+ unhandleds: [],
337
+ onunhandled: j,
338
+ pgp: !1,
339
+ env: {},
340
+ finalize: j
341
+ }, R = L, Ne = [], Pe = 0, Fe = [];
342
+ function z(e) {
343
+ if (typeof this != "object") throw TypeError("Promises must be constructed via new");
344
+ this._listeners = [], this._lib = !1;
345
+ var t = this._PSD = R;
346
+ if (typeof e != "function") {
347
+ if (e !== F) throw TypeError("Not a function");
348
+ this._state = arguments[1], this._value = arguments[2], !1 === this._state && Re(this, this._value);
349
+ } else this._state = null, this._value = null, ++t.ref, function e(t, n) {
350
+ try {
351
+ n(function(n) {
352
+ if (t._state === null) {
353
+ if (n === t) throw TypeError("A promise cannot be resolved with itself.");
354
+ var r = t._lib && Ue();
355
+ n && typeof n.then == "function" ? e(t, function(e, t) {
356
+ n instanceof z ? n._then(e, t) : n.then(e, t);
357
+ }) : (t._state = !0, t._value = n, ze(t)), r && We();
358
+ }
359
+ }, Re.bind(null, t));
360
+ } catch (e) {
361
+ Re(t, e);
362
+ }
363
+ }(this, e);
364
+ }
365
+ var Ie = {
366
+ get: function() {
367
+ var e = R, t = Xe;
368
+ function n(n, r) {
369
+ var i = this, a = !e.global && (e !== R || t !== Xe), o = a && !et(), s = new z(function(t, s) {
370
+ Be(i, new Le(ot(n, e, a, o), ot(r, e, a, o), t, s, e));
371
+ });
372
+ return this._consoleTask && (s._consoleTask = this._consoleTask), s;
373
+ }
374
+ return n.prototype = F, n;
375
+ },
376
+ set: function(e) {
377
+ f(this, "then", e && e.prototype === F ? Ie : {
378
+ get: function() {
379
+ return e;
380
+ },
381
+ set: Ie.set
382
+ });
383
+ }
384
+ };
385
+ function Le(e, t, n, r, i) {
386
+ this.onFulfilled = typeof e == "function" ? e : null, this.onRejected = typeof t == "function" ? t : null, this.resolve = n, this.reject = r, this.psd = i;
387
+ }
388
+ function Re(e, t) {
389
+ var n, r;
390
+ je.push(t), e._state === null && (n = e._lib && Ue(), t = Me(t), e._state = !1, e._value = t, r = e, Ae.some(function(e) {
391
+ return e._value === r._value;
392
+ }) || Ae.push(r), ze(e), n) && We();
393
+ }
394
+ function ze(e) {
395
+ var t = e._listeners;
396
+ e._listeners = [];
397
+ for (var n = 0, r = t.length; n < r; ++n) Be(e, t[n]);
398
+ var i = e._PSD;
399
+ --i.ref || i.finalize(), Pe === 0 && (++Pe, De(function() {
400
+ --Pe == 0 && Ge();
401
+ }, []));
402
+ }
403
+ function Be(e, t) {
404
+ if (e._state === null) e._listeners.push(t);
405
+ else {
406
+ var n = e._state ? t.onFulfilled : t.onRejected;
407
+ if (n === null) return (e._state ? t.resolve : t.reject)(e._value);
408
+ ++t.psd.ref, ++Pe, De(Ve, [
409
+ n,
410
+ e,
411
+ t
412
+ ]);
413
+ }
414
+ }
415
+ function Ve(e, t, n) {
416
+ try {
417
+ var r, i = t._value;
418
+ !t._state && je.length && (je = []), r = P && t._consoleTask ? t._consoleTask.run(function() {
419
+ return e(i);
420
+ }) : e(i), t._state || je.indexOf(i) !== -1 || ((e) => {
421
+ for (var t = Ae.length; t;) if (Ae[--t]._value === e._value) return Ae.splice(t, 1);
422
+ })(t), n.resolve(r);
423
+ } catch (e) {
424
+ n.reject(e);
425
+ } finally {
426
+ --Pe == 0 && Ge(), --n.psd.ref || n.psd.finalize();
427
+ }
428
+ }
429
+ function He() {
430
+ at(L, function() {
431
+ Ue() && We();
432
+ });
433
+ }
434
+ function Ue() {
435
+ var e = Oe;
436
+ return ke = Oe = !1, e;
437
+ }
438
+ function We() {
439
+ var e, t, n;
440
+ do
441
+ for (; 0 < Ne.length;) for (e = Ne, Ne = [], n = e.length, t = 0; t < n; ++t) {
442
+ var r = e[t];
443
+ r[0].apply(null, r[1]);
444
+ }
445
+ while (0 < Ne.length);
446
+ ke = Oe = !0;
447
+ }
448
+ function Ge() {
449
+ for (var e = Ae, t = (Ae = [], e.forEach(function(e) {
450
+ e._PSD.onunhandled.call(null, e._value, e);
451
+ }), Fe.slice(0)), n = t.length; n;) t[--n]();
452
+ }
453
+ function Ke(e) {
454
+ return new z(F, !1, e);
455
+ }
456
+ function B(e, t) {
457
+ var n = R;
458
+ return function() {
459
+ var r = Ue(), i = R;
460
+ try {
461
+ return rt(n, !0), e.apply(this, arguments);
462
+ } catch (e) {
463
+ t && t(e);
464
+ } finally {
465
+ rt(i, !1), r && We();
466
+ }
467
+ };
468
+ }
469
+ u(z.prototype, {
470
+ then: Ie,
471
+ _then: function(e, t) {
472
+ Be(this, new Le(null, null, e, t, R));
473
+ },
474
+ catch: function(e) {
475
+ var t, n;
476
+ return arguments.length === 1 ? this.then(null, e) : (t = e, n = arguments[1], typeof t == "function" ? this.then(null, function(e) {
477
+ return (e instanceof t ? n : Ke)(e);
478
+ }) : this.then(null, function(e) {
479
+ return (e && e.name === t ? n : Ke)(e);
480
+ }));
481
+ },
482
+ finally: function(e) {
483
+ return this.then(function(t) {
484
+ return z.resolve(e()).then(function() {
485
+ return t;
486
+ });
487
+ }, function(t) {
488
+ return z.resolve(e()).then(function() {
489
+ return Ke(t);
490
+ });
491
+ });
492
+ },
493
+ timeout: function(e, t) {
494
+ var n = this;
495
+ return e < Infinity ? new z(function(r, i) {
496
+ var a = setTimeout(function() {
497
+ return i(new A.Timeout(t));
498
+ }, e);
499
+ n.then(r, i).finally(clearTimeout.bind(null, a));
500
+ }) : this;
501
+ }
502
+ }), typeof Symbol < "u" && Symbol.toStringTag && f(z.prototype, Symbol.toStringTag, "Dexie.Promise"), L.env = it(), u(z, {
503
+ all: function() {
504
+ var e = O.apply(null, arguments).map(tt);
505
+ return new z(function(t, n) {
506
+ e.length === 0 && t([]);
507
+ var r = e.length;
508
+ e.forEach(function(i, a) {
509
+ return z.resolve(i).then(function(n) {
510
+ e[a] = n, --r || t(e);
511
+ }, n);
512
+ });
513
+ });
514
+ },
515
+ resolve: function(e) {
516
+ return e instanceof z ? e : e && typeof e.then == "function" ? new z(function(t, n) {
517
+ e.then(t, n);
518
+ }) : new z(F, !0, e);
519
+ },
520
+ reject: Ke,
521
+ race: function() {
522
+ var e = O.apply(null, arguments).map(tt);
523
+ return new z(function(t, n) {
524
+ e.map(function(e) {
525
+ return z.resolve(e).then(t, n);
526
+ });
527
+ });
528
+ },
529
+ PSD: {
530
+ get: function() {
531
+ return R;
532
+ },
533
+ set: function(e) {
534
+ return R = e;
535
+ }
536
+ },
537
+ totalEchoes: { get: function() {
538
+ return Xe;
539
+ } },
540
+ newPSD: Qe,
541
+ usePSD: at,
542
+ scheduler: {
543
+ get: function() {
544
+ return De;
545
+ },
546
+ set: function(e) {
547
+ De = e;
548
+ }
549
+ },
550
+ rejectionMapper: {
551
+ get: function() {
552
+ return Me;
553
+ },
554
+ set: function(e) {
555
+ Me = e;
556
+ }
557
+ },
558
+ follow: function(e, t) {
559
+ return new z(function(n, r) {
560
+ return Qe(function(t, n) {
561
+ var r = R;
562
+ r.unhandleds = [], r.onunhandled = n, r.finalize = N(function() {
563
+ var e, r = this;
564
+ e = function() {
565
+ r.unhandleds.length === 0 ? t() : n(r.unhandleds[0]);
566
+ }, Fe.push(function t() {
567
+ e(), Fe.splice(Fe.indexOf(t), 1);
568
+ }), ++Pe, De(function() {
569
+ --Pe == 0 && Ge();
570
+ }, []);
571
+ }, r.finalize), e();
572
+ }, t, n, r);
573
+ });
574
+ }
575
+ }), I && (I.allSettled && f(z, "allSettled", function() {
576
+ var e = O.apply(null, arguments).map(tt);
577
+ return new z(function(t) {
578
+ e.length === 0 && t([]);
579
+ var n = e.length, r = Array(n);
580
+ e.forEach(function(e, i) {
581
+ return z.resolve(e).then(function(e) {
582
+ return r[i] = {
583
+ status: "fulfilled",
584
+ value: e
585
+ };
586
+ }, function(e) {
587
+ return r[i] = {
588
+ status: "rejected",
589
+ reason: e
590
+ };
591
+ }).then(function() {
592
+ return --n || t(r);
593
+ });
594
+ });
595
+ });
596
+ }), I.any && typeof AggregateError < "u" && f(z, "any", function() {
597
+ var e = O.apply(null, arguments).map(tt);
598
+ return new z(function(t, n) {
599
+ e.length === 0 && n(/* @__PURE__ */ AggregateError([]));
600
+ var r = e.length, i = Array(r);
601
+ e.forEach(function(e, a) {
602
+ return z.resolve(e).then(function(e) {
603
+ return t(e);
604
+ }, function(e) {
605
+ i[a] = e, --r || n(AggregateError(i));
606
+ });
607
+ });
608
+ });
609
+ }), I.withResolvers) && (z.withResolvers = I.withResolvers);
610
+ var V = {
611
+ awaits: 0,
612
+ echoes: 0,
613
+ id: 0
614
+ }, qe = 0, Je = [], Ye = 0, Xe = 0, Ze = 0;
615
+ function Qe(e, t, n, r) {
616
+ var i = R, a = Object.create(i), t = (a.parent = i, a.ref = 0, a.global = !1, a.id = ++Ze, L.env, a.env = Ee ? {
617
+ Promise: z,
618
+ PromiseProp: {
619
+ value: z,
620
+ configurable: !0,
621
+ writable: !0
622
+ },
623
+ all: z.all,
624
+ race: z.race,
625
+ allSettled: z.allSettled,
626
+ any: z.any,
627
+ resolve: z.resolve,
628
+ reject: z.reject
629
+ } : {}, t && o(a, t), ++i.ref, a.finalize = function() {
630
+ --this.parent.ref || this.parent.finalize();
631
+ }, at(a, e, n, r));
632
+ return a.ref === 0 && a.finalize(), t;
633
+ }
634
+ function $e() {
635
+ return V.id ||= ++qe, ++V.awaits, V.echoes += Ce, V.id;
636
+ }
637
+ function et() {
638
+ return !!V.awaits && (--V.awaits == 0 && (V.id = 0), V.echoes = V.awaits * Ce, !0);
639
+ }
640
+ function tt(e) {
641
+ return V.echoes && e && e.constructor === I ? ($e(), e.then(function(e) {
642
+ return et(), e;
643
+ }, function(e) {
644
+ return et(), H(e);
645
+ })) : e;
646
+ }
647
+ function nt() {
648
+ var e = Je[Je.length - 1];
649
+ Je.pop(), rt(e, !1);
650
+ }
651
+ function rt(e, t) {
652
+ var n, i, a = R;
653
+ (t ? !V.echoes || Ye++ && e === R : !Ye || --Ye && e === R) || queueMicrotask(t ? function(e) {
654
+ ++Xe, V.echoes && --V.echoes != 0 || (V.echoes = V.awaits = V.id = 0), Je.push(R), rt(e, !0);
655
+ }.bind(null, e) : nt), e !== R && (R = e, a === L && (L.env = it()), Ee) && (n = L.env.Promise, i = e.env, a.global || e.global) && (Object.defineProperty(r, "Promise", i.PromiseProp), n.all = i.all, n.race = i.race, n.resolve = i.resolve, n.reject = i.reject, i.allSettled && (n.allSettled = i.allSettled), i.any) && (n.any = i.any);
656
+ }
657
+ function it() {
658
+ var e = r.Promise;
659
+ return Ee ? {
660
+ Promise: e,
661
+ PromiseProp: Object.getOwnPropertyDescriptor(r, "Promise"),
662
+ all: e.all,
663
+ race: e.race,
664
+ allSettled: e.allSettled,
665
+ any: e.any,
666
+ resolve: e.resolve,
667
+ reject: e.reject
668
+ } : {};
669
+ }
670
+ function at(e, t, n, r, i) {
671
+ var a = R;
672
+ try {
673
+ return rt(e, !0), t(n, r, i);
674
+ } finally {
675
+ rt(a, !1);
676
+ }
677
+ }
678
+ function ot(e, t, n, r) {
679
+ return typeof e == "function" ? function() {
680
+ var i = R;
681
+ n && $e(), rt(t, !0);
682
+ try {
683
+ return e.apply(this, arguments);
684
+ } finally {
685
+ rt(i, !1), r && queueMicrotask(et);
686
+ }
687
+ } : e;
688
+ }
689
+ function st(e) {
690
+ Promise === I && V.echoes === 0 ? Ye === 0 ? e() : enqueueNativeMicroTask(e) : setTimeout(e, 0);
691
+ }
692
+ ("" + Te).indexOf("[native code]") === -1 && ($e = et = j);
693
+ var H = z.reject, ct = "￿", U = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", lt = "String expected.", ut = "__dbnames", dt = "readonly", ft = "readwrite";
694
+ function pt(e, t) {
695
+ return e ? t ? function() {
696
+ return e.apply(this, arguments) && t.apply(this, arguments);
697
+ } : e : t;
698
+ }
699
+ var mt = {
700
+ type: 3,
701
+ lower: -Infinity,
702
+ lowerOpen: !1,
703
+ upper: [[]],
704
+ upperOpen: !1
705
+ };
706
+ function ht(e) {
707
+ return typeof e != "string" || /\./.test(e) ? function(e) {
708
+ return e;
709
+ } : function(t) {
710
+ return t[e] === void 0 && e in t && delete (t = T(t))[e], t;
711
+ };
712
+ }
713
+ function gt() {
714
+ throw A.Type("Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.");
715
+ }
716
+ function W(e, t) {
717
+ try {
718
+ var n = _t(e), r = _t(t);
719
+ 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;
720
+ switch (n) {
721
+ case "number":
722
+ case "Date":
723
+ case "string": return t < e ? 1 : e < t ? -1 : 0;
724
+ case "binary":
725
+ for (var i = vt(e), a = vt(t), o = i.length, s = a.length, c = o < s ? o : s, l = 0; l < c; ++l) if (i[l] !== a[l]) return i[l] < a[l] ? -1 : 1;
726
+ return o === s ? 0 : o < s ? -1 : 1;
727
+ case "Array":
728
+ for (var u = e, d = t, f = u.length, p = d.length, m = f < p ? f : p, h = 0; h < m; ++h) {
729
+ var g = W(u[h], d[h]);
730
+ if (g !== 0) return g;
731
+ }
732
+ return f === p ? 0 : f < p ? -1 : 1;
733
+ }
734
+ } catch {}
735
+ return NaN;
736
+ }
737
+ function _t(e) {
738
+ var t = typeof e;
739
+ return t == "object" && (ArrayBuffer.isView(e) || (t = ie(e)) === "ArrayBuffer") ? "binary" : t;
740
+ }
741
+ function vt(e) {
742
+ return e instanceof Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e);
743
+ }
744
+ function yt(e, t, n) {
745
+ var r = e.schema.yProps;
746
+ return r ? (t && 0 < n.numFailures && (t = t.filter(function(e, t) {
747
+ return !n.failures[t];
748
+ })), Promise.all(r.map(function(n) {
749
+ return n = n.updatesTable, t ? e.db.table(n).where("k").anyOf(t).delete() : e.db.table(n).clear();
750
+ })).then(function() {
751
+ return n;
752
+ })) : n;
753
+ }
754
+ xt.prototype.execute = function(e) {
755
+ var t = this["@@propmod"];
756
+ if (t.add !== void 0) {
757
+ var r = t.add;
758
+ if (a(r)) return n(n([], a(e) ? e : [], !0), r, !0).sort();
759
+ if (typeof r == "number") return (Number(e) || 0) + r;
760
+ if (typeof r == "bigint") try {
761
+ return BigInt(e) + r;
762
+ } catch {
763
+ return BigInt(0) + r;
764
+ }
765
+ throw TypeError(`Invalid term ${r}`);
766
+ }
767
+ if (t.remove !== void 0) {
768
+ var i = t.remove;
769
+ if (a(i)) return a(e) ? e.filter(function(e) {
770
+ return !i.includes(e);
771
+ }).sort() : [];
772
+ if (typeof i == "number") return Number(e) - i;
773
+ if (typeof i == "bigint") try {
774
+ return BigInt(e) - i;
775
+ } catch {
776
+ return BigInt(0) - i;
777
+ }
778
+ throw TypeError(`Invalid subtrahend ${i}`);
779
+ }
780
+ return r = (r = t.replacePrefix)?.[0], r && typeof e == "string" && e.startsWith(r) ? t.replacePrefix[1] + e.substring(r.length) : e;
781
+ };
782
+ var bt = xt;
783
+ function xt(e) {
784
+ this["@@propmod"] = e;
785
+ }
786
+ function St(e, t) {
787
+ for (var n = i(t), r = n.length, a = !1, o = 0; o < r; ++o) {
788
+ var s = n[o], c = t[s], l = b(e, s);
789
+ c instanceof bt ? (x(e, s, c.execute(l)), a = !0) : l !== c && (x(e, s, c), a = !0);
790
+ }
791
+ return a;
792
+ }
793
+ G.prototype._trans = function(e, t, n) {
794
+ var r = this._tx || R.trans, i = this.name, a = P && typeof console < "u" && console.createTask && console.createTask(`Dexie: ${e === "readonly" ? "read" : "write"} ${this.name}`);
795
+ function o(e, n, r) {
796
+ if (r.schema[i]) return t(r.idbtrans, r);
797
+ throw new A.NotFound("Table " + i + " not part of transaction");
798
+ }
799
+ var s = Ue();
800
+ try {
801
+ var c = r && r.db._novip === this.db._novip ? r === R.trans ? r._promise(e, o, n) : Qe(function() {
802
+ return r._promise(e, o, n);
803
+ }, {
804
+ trans: r,
805
+ transless: R.transless || R
806
+ }) : function e(t, n, r, i) {
807
+ if (t.idbdb && (t._state.openComplete || R.letThrough || t._vip)) {
808
+ var a = t._createTransaction(n, r, t._dbSchema);
809
+ try {
810
+ a.create(), t._state.PR1398_maxLoop = 3;
811
+ } catch (a) {
812
+ return a.name === pe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
813
+ return e(t, n, r, i);
814
+ })) : H(a);
815
+ }
816
+ return a._promise(n, function(e, t) {
817
+ return Qe(function() {
818
+ return R.trans = a, i(e, t, a);
819
+ });
820
+ }).then(function(e) {
821
+ if (n === "readwrite") try {
822
+ a.idbtrans.commit();
823
+ } catch {}
824
+ return n === "readonly" ? e : a._completion.then(function() {
825
+ return e;
826
+ });
827
+ });
828
+ }
829
+ if (t._state.openComplete) return H(new A.DatabaseClosed(t._state.dbOpenError));
830
+ if (!t._state.isBeingOpened) {
831
+ if (!t._state.autoOpen) return H(new A.DatabaseClosed());
832
+ t.open().catch(j);
833
+ }
834
+ return t._state.dbReadyPromise.then(function() {
835
+ return e(t, n, r, i);
836
+ });
837
+ }(this.db, e, [this.name], o);
838
+ return a && (c._consoleTask = a, c = c.catch(function(e) {
839
+ return console.trace(e), H(e);
840
+ })), c;
841
+ } finally {
842
+ s && We();
843
+ }
844
+ }, G.prototype.get = function(e, t) {
845
+ var n = this;
846
+ return e && e.constructor === Object ? this.where(e).first(t) : e == null ? H(new A.Type("Invalid argument to Table.get()")) : this._trans("readonly", function(t) {
847
+ return n.core.get({
848
+ trans: t,
849
+ key: e
850
+ }).then(function(e) {
851
+ return n.hook.reading.fire(e);
852
+ });
853
+ }).then(t);
854
+ }, G.prototype.where = function(e) {
855
+ if (typeof e == "string") return new this.db.WhereClause(this, e);
856
+ if (a(e)) return new this.db.WhereClause(this, `[${e.join("+")}]`);
857
+ var t = i(e);
858
+ if (t.length === 1) return this.where(t[0]).equals(e[t[0]]);
859
+ var n = this.schema.indexes.concat(this.schema.primKey).filter(function(e) {
860
+ if (e.compound && t.every(function(t) {
861
+ return 0 <= e.keyPath.indexOf(t);
862
+ })) {
863
+ for (var n = 0; n < t.length; ++n) if (t.indexOf(e.keyPath[n]) === -1) return !1;
864
+ return !0;
865
+ }
866
+ return !1;
867
+ }).sort(function(e, t) {
868
+ return e.keyPath.length - t.keyPath.length;
869
+ })[0];
870
+ if (n && this.db._maxKey !== ct) return s = n.keyPath.slice(0, t.length), this.where(s).equals(s.map(function(t) {
871
+ return e[t];
872
+ }));
873
+ !n && P && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit from a compound index [${t.join("+")}]`);
874
+ var r = this.schema.idxByName;
875
+ function o(e, t) {
876
+ return W(e, t) === 0;
877
+ }
878
+ var s = t.reduce(function(t, n) {
879
+ var i = t[0], t = t[1], s = r[n], c = e[n];
880
+ return [i || s, i || !s ? pt(t, s && s.multi ? function(e) {
881
+ return e = b(e, n), a(e) && e.some(function(e) {
882
+ return o(c, e);
883
+ });
884
+ } : function(e) {
885
+ return o(c, b(e, n));
886
+ }) : t];
887
+ }, [null, null]), c = s[0], s = s[1];
888
+ return c ? this.where(c.name).equals(e[c.keyPath]).filter(s) : n ? this.filter(s) : this.where(t).equals("");
889
+ }, G.prototype.filter = function(e) {
890
+ return this.toCollection().and(e);
891
+ }, G.prototype.count = function(e) {
892
+ return this.toCollection().count(e);
893
+ }, G.prototype.offset = function(e) {
894
+ return this.toCollection().offset(e);
895
+ }, G.prototype.limit = function(e) {
896
+ return this.toCollection().limit(e);
897
+ }, G.prototype.each = function(e) {
898
+ return this.toCollection().each(e);
899
+ }, G.prototype.toArray = function(e) {
900
+ return this.toCollection().toArray(e);
901
+ }, G.prototype.toCollection = function() {
902
+ return new this.db.Collection(new this.db.WhereClause(this));
903
+ }, G.prototype.orderBy = function(e) {
904
+ return new this.db.Collection(new this.db.WhereClause(this, a(e) ? `[${e.join("+")}]` : e));
905
+ }, G.prototype.reverse = function() {
906
+ return this.toCollection().reverse();
907
+ }, G.prototype.mapToClass = function(t) {
908
+ for (var n = this.db, r = this.name, i = ((this.schema.mappedClass = t).prototype instanceof gt && (t = ((t) => {
909
+ var i = s, a = t;
910
+ if (typeof a != "function" && a !== null) throw TypeError("Class extends value " + String(a) + " is not a constructor or null");
911
+ function o() {
912
+ this.constructor = i;
913
+ }
914
+ function s() {
915
+ return t !== null && t.apply(this, arguments) || this;
916
+ }
917
+ return e(i, a), i.prototype = a === null ? Object.create(a) : (o.prototype = a.prototype, new o()), Object.defineProperty(s.prototype, "db", {
918
+ get: function() {
919
+ return n;
920
+ },
921
+ enumerable: !1,
922
+ configurable: !0
923
+ }), s.prototype.table = function() {
924
+ return r;
925
+ }, s;
926
+ })(t)), /* @__PURE__ */ new Set()), a = t.prototype; a; a = s(a)) Object.getOwnPropertyNames(a).forEach(function(e) {
927
+ return i.add(e);
928
+ });
929
+ function o(e) {
930
+ if (!e) return e;
931
+ var n, r = Object.create(t.prototype);
932
+ for (n in e) if (!i.has(n)) try {
933
+ r[n] = e[n];
934
+ } catch {}
935
+ return r;
936
+ }
937
+ return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = o, this.hook("reading", o), t;
938
+ }, G.prototype.defineClass = function() {
939
+ return this.mapToClass(function(e) {
940
+ o(this, e);
941
+ });
942
+ }, G.prototype.add = function(e, t) {
943
+ var n = this, r = this.schema.primKey, i = r.auto, a = r.keyPath, o = e;
944
+ return a && i && (o = ht(a)(e)), this._trans("readwrite", function(e) {
945
+ return n.core.mutate({
946
+ trans: e,
947
+ type: "add",
948
+ keys: t == null ? null : [t],
949
+ values: [o]
950
+ });
951
+ }).then(function(e) {
952
+ return e.numFailures ? z.reject(e.failures[0]) : e.lastResult;
953
+ }).then(function(t) {
954
+ if (a) try {
955
+ x(e, a, t);
956
+ } catch {}
957
+ return t;
958
+ });
959
+ }, G.prototype.upsert = function(e, t) {
960
+ var n = this, r = this.schema.primKey.keyPath;
961
+ return this._trans("readwrite", function(i) {
962
+ return n.core.get({
963
+ trans: i,
964
+ key: e
965
+ }).then(function(a) {
966
+ var o = a ?? {};
967
+ return St(o, t), r && x(o, r, e), n.core.mutate({
968
+ trans: i,
969
+ type: "put",
970
+ values: [o],
971
+ keys: [e],
972
+ upsert: !0,
973
+ updates: {
974
+ keys: [e],
975
+ changeSpecs: [t]
976
+ }
977
+ }).then(function(e) {
978
+ return e.numFailures ? z.reject(e.failures[0]) : !!a;
979
+ });
980
+ });
981
+ });
982
+ }, G.prototype.update = function(e, t) {
983
+ return typeof e != "object" || a(e) ? this.where(":id").equals(e).modify(t) : (e = b(e, this.schema.primKey.keyPath)) === void 0 ? H(new A.InvalidArgument("Given object does not contain its primary key")) : this.where(":id").equals(e).modify(t);
984
+ }, G.prototype.put = function(e, t) {
985
+ var n = this, r = this.schema.primKey, i = r.auto, a = r.keyPath, o = e;
986
+ return a && i && (o = ht(a)(e)), this._trans("readwrite", function(e) {
987
+ return n.core.mutate({
988
+ trans: e,
989
+ type: "put",
990
+ values: [o],
991
+ keys: t == null ? null : [t]
992
+ });
993
+ }).then(function(e) {
994
+ return e.numFailures ? z.reject(e.failures[0]) : e.lastResult;
995
+ }).then(function(t) {
996
+ if (a) try {
997
+ x(e, a, t);
998
+ } catch {}
999
+ return t;
1000
+ });
1001
+ }, G.prototype.delete = function(e) {
1002
+ var t = this;
1003
+ return this._trans("readwrite", function(n) {
1004
+ return t.core.mutate({
1005
+ trans: n,
1006
+ type: "delete",
1007
+ keys: [e]
1008
+ }).then(function(n) {
1009
+ return yt(t, [e], n);
1010
+ }).then(function(e) {
1011
+ return e.numFailures ? z.reject(e.failures[0]) : void 0;
1012
+ });
1013
+ });
1014
+ }, G.prototype.clear = function() {
1015
+ var e = this;
1016
+ return this._trans("readwrite", function(t) {
1017
+ return e.core.mutate({
1018
+ trans: t,
1019
+ type: "deleteRange",
1020
+ range: mt
1021
+ }).then(function(t) {
1022
+ return yt(e, null, t);
1023
+ });
1024
+ }).then(function(e) {
1025
+ return e.numFailures ? z.reject(e.failures[0]) : void 0;
1026
+ });
1027
+ }, G.prototype.bulkGet = function(e) {
1028
+ var t = this;
1029
+ return this._trans("readonly", function(n) {
1030
+ return t.core.getMany({
1031
+ keys: e,
1032
+ trans: n
1033
+ }).then(function(e) {
1034
+ return e.map(function(e) {
1035
+ return t.hook.reading.fire(e);
1036
+ });
1037
+ });
1038
+ });
1039
+ }, G.prototype.bulkAdd = function(e, t, n) {
1040
+ var r = this, i = Array.isArray(t) ? t : void 0, a = (n ||= i ? void 0 : t) ? n.allKeys : void 0;
1041
+ return this._trans("readwrite", function(t) {
1042
+ var n = r.schema.primKey, o = n.auto, n = n.keyPath;
1043
+ if (n && i) throw new A.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
1044
+ if (i && i.length !== e.length) throw new A.InvalidArgument("Arguments objects and keys must have the same length");
1045
+ var s = e.length, o = n && o ? e.map(ht(n)) : e;
1046
+ return r.core.mutate({
1047
+ trans: t,
1048
+ type: "add",
1049
+ keys: i,
1050
+ values: o,
1051
+ wantResults: a
1052
+ }).then(function(e) {
1053
+ var t = e.numFailures, n = e.failures;
1054
+ if (t === 0) return a ? e.results : e.lastResult;
1055
+ throw new fe(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`, n);
1056
+ });
1057
+ });
1058
+ }, G.prototype.bulkPut = function(e, t, n) {
1059
+ var r = this, i = Array.isArray(t) ? t : void 0, a = (n ||= i ? void 0 : t) ? n.allKeys : void 0;
1060
+ return this._trans("readwrite", function(t) {
1061
+ var n = r.schema.primKey, o = n.auto, n = n.keyPath;
1062
+ if (n && i) throw new A.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
1063
+ if (i && i.length !== e.length) throw new A.InvalidArgument("Arguments objects and keys must have the same length");
1064
+ var s = e.length, o = n && o ? e.map(ht(n)) : e;
1065
+ return r.core.mutate({
1066
+ trans: t,
1067
+ type: "put",
1068
+ keys: i,
1069
+ values: o,
1070
+ wantResults: a
1071
+ }).then(function(e) {
1072
+ var t = e.numFailures, n = e.failures;
1073
+ if (t === 0) return a ? e.results : e.lastResult;
1074
+ throw new fe(`${r.name}.bulkPut(): ${t} of ${s} operations failed`, n);
1075
+ });
1076
+ });
1077
+ }, G.prototype.bulkUpdate = function(e) {
1078
+ var t = this, n = this.core, r = e.map(function(e) {
1079
+ return e.key;
1080
+ }), i = e.map(function(e) {
1081
+ return e.changes;
1082
+ }), a = [];
1083
+ return this._trans("readwrite", function(o) {
1084
+ return n.getMany({
1085
+ trans: o,
1086
+ keys: r,
1087
+ cache: "clone"
1088
+ }).then(function(s) {
1089
+ var c = [], l = [], u = (e.forEach(function(e, n) {
1090
+ var r = e.key, i = e.changes, o = s[n];
1091
+ if (o) {
1092
+ for (var u = 0, d = Object.keys(i); u < d.length; u++) {
1093
+ var f = d[u], p = i[f];
1094
+ if (f === t.schema.primKey.keyPath) {
1095
+ if (W(p, r) !== 0) throw new A.Constraint("Cannot update primary key in bulkUpdate()");
1096
+ } else x(o, f, p);
1097
+ }
1098
+ a.push(n), c.push(r), l.push(o);
1099
+ }
1100
+ }), c.length);
1101
+ return n.mutate({
1102
+ trans: o,
1103
+ type: "put",
1104
+ keys: c,
1105
+ values: l,
1106
+ updates: {
1107
+ keys: r,
1108
+ changeSpecs: i
1109
+ }
1110
+ }).then(function(e) {
1111
+ var n = e.numFailures, r = e.failures;
1112
+ if (n === 0) return u;
1113
+ for (var i = 0, o = Object.keys(r); i < o.length; i++) {
1114
+ var s, c = o[i], l = a[Number(c)];
1115
+ l != null && (s = r[c], delete r[c], r[l] = s);
1116
+ }
1117
+ throw new fe(`${t.name}.bulkUpdate(): ${n} of ${u} operations failed`, r);
1118
+ });
1119
+ });
1120
+ });
1121
+ }, G.prototype.bulkDelete = function(e) {
1122
+ var t = this, n = e.length;
1123
+ return this._trans("readwrite", function(n) {
1124
+ return t.core.mutate({
1125
+ trans: n,
1126
+ type: "delete",
1127
+ keys: e
1128
+ }).then(function(n) {
1129
+ return yt(t, e, n);
1130
+ });
1131
+ }).then(function(e) {
1132
+ var r = e.numFailures, i = e.failures;
1133
+ if (r === 0) return e.lastResult;
1134
+ throw new fe(`${t.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
1135
+ });
1136
+ };
1137
+ var Ct = G;
1138
+ function G() {}
1139
+ function wt(e) {
1140
+ function t(t, r) {
1141
+ if (r) {
1142
+ for (var i = arguments.length, a = Array(i - 1); --i;) a[i - 1] = arguments[i];
1143
+ return n[t].subscribe.apply(null, a), e;
1144
+ }
1145
+ if (typeof t == "string") return n[t];
1146
+ }
1147
+ var n = {};
1148
+ t.addEventType = s;
1149
+ for (var r = 1, o = arguments.length; r < o; ++r) s(arguments[r]);
1150
+ return t;
1151
+ function s(e, r, o) {
1152
+ var c, l;
1153
+ if (typeof e != "object") return r ||= be, l = {
1154
+ subscribers: [],
1155
+ fire: o ||= j,
1156
+ subscribe: function(e) {
1157
+ l.subscribers.indexOf(e) === -1 && (l.subscribers.push(e), l.fire = r(l.fire, e));
1158
+ },
1159
+ unsubscribe: function(e) {
1160
+ l.subscribers = l.subscribers.filter(function(t) {
1161
+ return t !== e;
1162
+ }), l.fire = l.subscribers.reduce(r, o);
1163
+ }
1164
+ }, n[e] = t[e] = l;
1165
+ i(c = e).forEach(function(e) {
1166
+ var t = c[e];
1167
+ if (a(t)) s(e, c[e][0], c[e][1]);
1168
+ else {
1169
+ if (t !== "asap") throw new A.InvalidArgument("Invalid event config");
1170
+ var n = s(e, M, function() {
1171
+ for (var e = arguments.length, t = Array(e); e--;) t[e] = arguments[e];
1172
+ n.subscribers.forEach(function(e) {
1173
+ y(function() {
1174
+ e.apply(null, t);
1175
+ });
1176
+ });
1177
+ });
1178
+ }
1179
+ });
1180
+ }
1181
+ }
1182
+ function Tt(e, t) {
1183
+ return p(t).from({ prototype: e }), t;
1184
+ }
1185
+ function Et(e, t) {
1186
+ return !(e.filter || e.algorithm || e.or) && (t ? e.justLimit : !e.replayFilter);
1187
+ }
1188
+ function Dt(e, t) {
1189
+ e.filter = pt(e.filter, t);
1190
+ }
1191
+ function Ot(e, t, n) {
1192
+ var r = e.replayFilter;
1193
+ e.replayFilter = r ? function() {
1194
+ return pt(r(), t());
1195
+ } : t, e.justLimit = n && !r;
1196
+ }
1197
+ function kt(e, t) {
1198
+ if (e.isPrimKey) return t.primaryKey;
1199
+ var n = t.getIndexByKeyPath(e.index);
1200
+ if (n) return n;
1201
+ throw new A.Schema("KeyPath " + e.index + " on object store " + t.name + " is not indexed");
1202
+ }
1203
+ function At(e, t, n) {
1204
+ var r = kt(e, t.schema);
1205
+ return t.openCursor({
1206
+ trans: n,
1207
+ values: !e.keysOnly,
1208
+ reverse: e.dir === "prev",
1209
+ unique: !!e.unique,
1210
+ query: {
1211
+ index: r,
1212
+ range: e.range
1213
+ }
1214
+ });
1215
+ }
1216
+ function jt(e, t, n, r) {
1217
+ var i, a, o = e.replayFilter ? pt(e.filter, e.replayFilter()) : e.filter;
1218
+ return e.or ? (i = {}, a = function(e, n, r) {
1219
+ var a, s;
1220
+ o && !o(n, r, function(e) {
1221
+ return n.stop(e);
1222
+ }, function(e) {
1223
+ return n.fail(e);
1224
+ }) || ((s = "" + (a = n.primaryKey)) == "[object ArrayBuffer]" && (s = "" + new Uint8Array(a)), l(i, s)) || (i[s] = !0, t(e, n, r));
1225
+ }, Promise.all([e.or._iterate(a, n), Mt(At(e, r, n), e.algorithm, a, !e.keysOnly && e.valueMapper)])) : Mt(At(e, r, n), pt(e.algorithm, o), t, !e.keysOnly && e.valueMapper);
1226
+ }
1227
+ function Mt(e, t, n, r) {
1228
+ var i = B(r ? function(e, t, i) {
1229
+ return n(r(e), t, i);
1230
+ } : n);
1231
+ return e.then(function(e) {
1232
+ if (e) return e.start(function() {
1233
+ var n = function() {
1234
+ return e.continue();
1235
+ };
1236
+ t && !t(e, function(e) {
1237
+ return n = e;
1238
+ }, function(t) {
1239
+ e.stop(t), n = j;
1240
+ }, function(t) {
1241
+ e.fail(t), n = j;
1242
+ }) || i(e.value, e, function(e) {
1243
+ return n = e;
1244
+ }), n();
1245
+ });
1246
+ });
1247
+ }
1248
+ K.prototype._read = function(e, t) {
1249
+ var n = this._ctx;
1250
+ return n.error ? n.table._trans(null, H.bind(null, n.error)) : n.table._trans("readonly", e).then(t);
1251
+ }, K.prototype._write = function(e) {
1252
+ var t = this._ctx;
1253
+ return t.error ? t.table._trans(null, H.bind(null, t.error)) : t.table._trans("readwrite", e, "locked");
1254
+ }, K.prototype._addAlgorithm = function(e) {
1255
+ var t = this._ctx;
1256
+ t.algorithm = pt(t.algorithm, e);
1257
+ }, K.prototype._iterate = function(e, t) {
1258
+ return jt(this._ctx, e, t, this._ctx.table.core);
1259
+ }, K.prototype.clone = function(e) {
1260
+ var t = Object.create(this.constructor.prototype), n = Object.create(this._ctx);
1261
+ return e && o(n, e), t._ctx = n, t;
1262
+ }, K.prototype.raw = function() {
1263
+ return this._ctx.valueMapper = null, this;
1264
+ }, K.prototype.each = function(e) {
1265
+ var t = this._ctx;
1266
+ return this._read(function(n) {
1267
+ return jt(t, e, n, t.table.core);
1268
+ });
1269
+ }, K.prototype.count = function(e) {
1270
+ var t = this;
1271
+ return this._read(function(e) {
1272
+ var n, r = t._ctx, i = r.table.core;
1273
+ return Et(r, !0) ? i.count({
1274
+ trans: e,
1275
+ query: {
1276
+ index: kt(r, i.schema),
1277
+ range: r.range
1278
+ }
1279
+ }).then(function(e) {
1280
+ return Math.min(e, r.limit);
1281
+ }) : (n = 0, jt(r, function() {
1282
+ return ++n, !1;
1283
+ }, e, i).then(function() {
1284
+ return n;
1285
+ }));
1286
+ }).then(e);
1287
+ }, K.prototype.sortBy = function(e, t) {
1288
+ var n = e.split(".").reverse(), r = n[0], i = n.length - 1;
1289
+ function a(e, t) {
1290
+ return t ? a(e[n[t]], t - 1) : e[r];
1291
+ }
1292
+ var o = this._ctx.dir === "next" ? 1 : -1;
1293
+ function s(e, t) {
1294
+ return W(a(e, i), a(t, i)) * o;
1295
+ }
1296
+ return this.toArray(function(e) {
1297
+ return e.slice().sort(s);
1298
+ }).then(t);
1299
+ }, K.prototype.toArray = function(e) {
1300
+ var t = this;
1301
+ return this._read(function(e) {
1302
+ var n, r, i, a = t._ctx;
1303
+ return Et(a, !0) && 0 < a.limit ? (n = a.valueMapper, r = kt(a, a.table.core.schema), a.table.core.query({
1304
+ trans: e,
1305
+ limit: a.limit,
1306
+ values: !0,
1307
+ direction: a.dir === "prev" ? "prev" : void 0,
1308
+ query: {
1309
+ index: r,
1310
+ range: a.range
1311
+ }
1312
+ }).then(function(e) {
1313
+ return e = e.result, n ? e.map(n) : e;
1314
+ })) : (i = [], jt(a, function(e) {
1315
+ return i.push(e);
1316
+ }, e, a.table.core).then(function() {
1317
+ return i;
1318
+ }));
1319
+ }, e);
1320
+ }, K.prototype.offset = function(e) {
1321
+ var t = this._ctx;
1322
+ return e <= 0 || (t.offset += e, Et(t) ? Ot(t, function() {
1323
+ var t = e;
1324
+ return function(e, n) {
1325
+ return t === 0 || (t === 1 ? --t : n(function() {
1326
+ e.advance(t), t = 0;
1327
+ }), !1);
1328
+ };
1329
+ }) : Ot(t, function() {
1330
+ var t = e;
1331
+ return function() {
1332
+ return --t < 0;
1333
+ };
1334
+ })), this;
1335
+ }, K.prototype.limit = function(e) {
1336
+ return this._ctx.limit = Math.min(this._ctx.limit, e), Ot(this._ctx, function() {
1337
+ var t = e;
1338
+ return function(e, n, r) {
1339
+ return --t <= 0 && n(r), 0 <= t;
1340
+ };
1341
+ }, !0), this;
1342
+ }, K.prototype.until = function(e, t) {
1343
+ return Dt(this._ctx, function(n, r, i) {
1344
+ return !e(n.value) || (r(i), t);
1345
+ }), this;
1346
+ }, K.prototype.first = function(e) {
1347
+ return this.limit(1).toArray(function(e) {
1348
+ return e[0];
1349
+ }).then(e);
1350
+ }, K.prototype.last = function(e) {
1351
+ return this.reverse().first(e);
1352
+ }, K.prototype.filter = function(e) {
1353
+ var t;
1354
+ return Dt(this._ctx, function(t) {
1355
+ return e(t.value);
1356
+ }), (t = this._ctx).isMatch = pt(t.isMatch, e), this;
1357
+ }, K.prototype.and = function(e) {
1358
+ return this.filter(e);
1359
+ }, K.prototype.or = function(e) {
1360
+ return new this.db.WhereClause(this._ctx.table, e, this);
1361
+ }, K.prototype.reverse = function() {
1362
+ return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
1363
+ }, K.prototype.desc = function() {
1364
+ return this.reverse();
1365
+ }, K.prototype.eachKey = function(e) {
1366
+ var t = this._ctx;
1367
+ return t.keysOnly = !t.isMatch, this.each(function(t, n) {
1368
+ e(n.key, n);
1369
+ });
1370
+ }, K.prototype.eachUniqueKey = function(e) {
1371
+ return this._ctx.unique = "unique", this.eachKey(e);
1372
+ }, K.prototype.eachPrimaryKey = function(e) {
1373
+ var t = this._ctx;
1374
+ return t.keysOnly = !t.isMatch, this.each(function(t, n) {
1375
+ e(n.primaryKey, n);
1376
+ });
1377
+ }, K.prototype.keys = function(e) {
1378
+ var t = this._ctx, n = (t.keysOnly = !t.isMatch, []);
1379
+ return this.each(function(e, t) {
1380
+ n.push(t.key);
1381
+ }).then(function() {
1382
+ return n;
1383
+ }).then(e);
1384
+ }, K.prototype.primaryKeys = function(e) {
1385
+ var t = this._ctx;
1386
+ if (Et(t, !0) && 0 < t.limit) return this._read(function(e) {
1387
+ var n = kt(t, t.table.core.schema);
1388
+ return t.table.core.query({
1389
+ trans: e,
1390
+ values: !1,
1391
+ limit: t.limit,
1392
+ direction: t.dir === "prev" ? "prev" : void 0,
1393
+ query: {
1394
+ index: n,
1395
+ range: t.range
1396
+ }
1397
+ });
1398
+ }).then(function(e) {
1399
+ return e.result;
1400
+ }).then(e);
1401
+ t.keysOnly = !t.isMatch;
1402
+ var n = [];
1403
+ return this.each(function(e, t) {
1404
+ n.push(t.primaryKey);
1405
+ }).then(function() {
1406
+ return n;
1407
+ }).then(e);
1408
+ }, K.prototype.uniqueKeys = function(e) {
1409
+ return this._ctx.unique = "unique", this.keys(e);
1410
+ }, K.prototype.firstKey = function(e) {
1411
+ return this.limit(1).keys(function(e) {
1412
+ return e[0];
1413
+ }).then(e);
1414
+ }, K.prototype.lastKey = function(e) {
1415
+ return this.reverse().firstKey(e);
1416
+ }, K.prototype.distinct = function() {
1417
+ var e, t = this._ctx, t = t.index && t.table.schema.idxByName[t.index];
1418
+ return t && t.multi && (e = {}, Dt(this._ctx, function(t) {
1419
+ var t = t.primaryKey.toString(), n = l(e, t);
1420
+ return e[t] = !0, !n;
1421
+ })), this;
1422
+ }, K.prototype.modify = function(e) {
1423
+ var t = this, n = this._ctx;
1424
+ return this._write(function(r) {
1425
+ function a(e, t) {
1426
+ var n = t.failures;
1427
+ p += e - t.numFailures;
1428
+ for (var r = 0, a = i(n); r < a.length; r++) {
1429
+ var o = a[r];
1430
+ f.push(n[o]);
1431
+ }
1432
+ }
1433
+ var o = typeof e == "function" ? e : function(t) {
1434
+ return St(t, e);
1435
+ }, s = n.table.core, c = s.schema.primaryKey, l = c.outbound, u = c.extractKey, d = 200, c = t.db._options.modifyChunkSize, f = (c && (d = typeof c == "object" ? c[s.name] || c["*"] || 200 : c), []), p = 0, m = [], h = e === Pt;
1436
+ return t.clone().primaryKeys().then(function(t) {
1437
+ function i(f) {
1438
+ var p = Math.min(d, t.length - f), m = t.slice(f, f + p);
1439
+ return (h ? Promise.resolve([]) : s.getMany({
1440
+ trans: r,
1441
+ keys: m,
1442
+ cache: "immutable"
1443
+ })).then(function(g) {
1444
+ var _ = [], v = [], y = l ? [] : null, b = h ? m : [];
1445
+ if (!h) for (var x = 0; x < p; ++x) {
1446
+ var S = g[x], C = {
1447
+ value: T(S),
1448
+ primKey: t[f + x]
1449
+ };
1450
+ !1 !== o.call(C, C.value, C) && (C.value == null ? b.push(t[f + x]) : l || W(u(S), u(C.value)) === 0 ? (v.push(C.value), l && y.push(t[f + x])) : (b.push(t[f + x]), _.push(C.value)));
1451
+ }
1452
+ return Promise.resolve(0 < _.length && s.mutate({
1453
+ trans: r,
1454
+ type: "add",
1455
+ values: _
1456
+ }).then(function(e) {
1457
+ for (var t in e.failures) b.splice(parseInt(t), 1);
1458
+ a(_.length, e);
1459
+ })).then(function() {
1460
+ return (0 < v.length || c && typeof e == "object") && s.mutate({
1461
+ trans: r,
1462
+ type: "put",
1463
+ keys: y,
1464
+ values: v,
1465
+ criteria: c,
1466
+ changeSpec: typeof e != "function" && e,
1467
+ isAdditionalChunk: 0 < f
1468
+ }).then(function(e) {
1469
+ return a(v.length, e);
1470
+ });
1471
+ }).then(function() {
1472
+ return (0 < b.length || c && h) && s.mutate({
1473
+ trans: r,
1474
+ type: "delete",
1475
+ keys: b,
1476
+ criteria: c,
1477
+ isAdditionalChunk: 0 < f
1478
+ }).then(function(e) {
1479
+ return yt(n.table, b, e);
1480
+ }).then(function(e) {
1481
+ return a(b.length, e);
1482
+ });
1483
+ }).then(function() {
1484
+ return t.length > f + p && i(f + d);
1485
+ });
1486
+ });
1487
+ }
1488
+ var c = Et(n) && n.limit === Infinity && (typeof e != "function" || h) && {
1489
+ index: n.index,
1490
+ range: n.range
1491
+ };
1492
+ return i(0).then(function() {
1493
+ if (0 < f.length) throw new de("Error modifying one or more objects", f, p, m);
1494
+ return t.length;
1495
+ });
1496
+ });
1497
+ });
1498
+ }, K.prototype.delete = function() {
1499
+ var e = this._ctx, t = e.range;
1500
+ return !Et(e) || e.table.schema.yProps || !e.isPrimKey && t.type !== 3 ? this.modify(Pt) : this._write(function(n) {
1501
+ var r = e.table.core.schema.primaryKey, i = t;
1502
+ return e.table.core.count({
1503
+ trans: n,
1504
+ query: {
1505
+ index: r,
1506
+ range: i
1507
+ }
1508
+ }).then(function(t) {
1509
+ return e.table.core.mutate({
1510
+ trans: n,
1511
+ type: "deleteRange",
1512
+ range: i
1513
+ }).then(function(e) {
1514
+ var n = e.failures, e = e.numFailures;
1515
+ if (e) throw new de("Could not delete some values", Object.keys(n).map(function(e) {
1516
+ return n[e];
1517
+ }), t - e);
1518
+ return t - e;
1519
+ });
1520
+ });
1521
+ });
1522
+ };
1523
+ var Nt = K;
1524
+ function K() {}
1525
+ var Pt = function(e, t) {
1526
+ return t.value = null;
1527
+ };
1528
+ function Ft(e, t) {
1529
+ return e < t ? -1 : e === t ? 0 : 1;
1530
+ }
1531
+ function It(e, t) {
1532
+ return t < e ? -1 : e === t ? 0 : 1;
1533
+ }
1534
+ function q(e, t, n) {
1535
+ return e = e instanceof Vt ? new e.Collection(e) : e, e._ctx.error = new (n || TypeError)(t), e;
1536
+ }
1537
+ function Lt(e) {
1538
+ return new e.Collection(e, function() {
1539
+ return Bt("");
1540
+ }).limit(0);
1541
+ }
1542
+ function Rt(e, t, n, r) {
1543
+ var i, a, o, s, c, l, u, d = n.length;
1544
+ if (!n.every(function(e) {
1545
+ return typeof e == "string";
1546
+ })) return q(e, lt);
1547
+ function f(e) {
1548
+ i = e === "next" ? function(e) {
1549
+ return e.toUpperCase();
1550
+ } : function(e) {
1551
+ return e.toLowerCase();
1552
+ }, a = e === "next" ? function(e) {
1553
+ return e.toLowerCase();
1554
+ } : function(e) {
1555
+ return e.toUpperCase();
1556
+ }, o = e === "next" ? Ft : It;
1557
+ var t = n.map(function(e) {
1558
+ return {
1559
+ lower: a(e),
1560
+ upper: i(e)
1561
+ };
1562
+ }).sort(function(e, t) {
1563
+ return o(e.lower, t.lower);
1564
+ });
1565
+ s = t.map(function(e) {
1566
+ return e.upper;
1567
+ }), c = t.map(function(e) {
1568
+ return e.lower;
1569
+ }), u = (l = e) === "next" ? "" : r;
1570
+ }
1571
+ f("next");
1572
+ var e = new e.Collection(e, function() {
1573
+ return zt(s[0], c[d - 1] + r);
1574
+ }), p = (e._ondirectionchange = function(e) {
1575
+ f(e);
1576
+ }, 0);
1577
+ return e._addAlgorithm(function(e, n, r) {
1578
+ var i = e.key;
1579
+ if (typeof i == "string") {
1580
+ var f = a(i);
1581
+ if (t(f, c, p)) return !0;
1582
+ for (var m = null, h = p; h < d; ++h) {
1583
+ var g = ((e, t, n, r, i, a) => {
1584
+ for (var o = Math.min(e.length, r.length), s = -1, c = 0; c < o; ++c) {
1585
+ var l = t[c];
1586
+ if (l !== r[c]) return i(e[c], n[c]) < 0 ? e.substr(0, c) + n[c] + n.substr(c + 1) : i(e[c], r[c]) < 0 ? e.substr(0, c) + r[c] + n.substr(c + 1) : 0 <= s ? e.substr(0, s) + t[s] + n.substr(s + 1) : null;
1587
+ i(e[c], l) < 0 && (s = c);
1588
+ }
1589
+ return o < r.length && a === "next" ? e + n.substr(e.length) : o < e.length && a === "prev" ? e.substr(0, n.length) : s < 0 ? null : e.substr(0, s) + r[s] + n.substr(s + 1);
1590
+ })(i, f, s[h], c[h], o, l);
1591
+ g === null && m === null ? p = h + 1 : (m === null || 0 < o(m, g)) && (m = g);
1592
+ }
1593
+ n(m === null ? r : function() {
1594
+ e.continue(m + u);
1595
+ });
1596
+ }
1597
+ return !1;
1598
+ }), e;
1599
+ }
1600
+ function zt(e, t, n, r) {
1601
+ return {
1602
+ type: 2,
1603
+ lower: e,
1604
+ upper: t,
1605
+ lowerOpen: n,
1606
+ upperOpen: r
1607
+ };
1608
+ }
1609
+ function Bt(e) {
1610
+ return {
1611
+ type: 1,
1612
+ lower: e,
1613
+ upper: e
1614
+ };
1615
+ }
1616
+ Object.defineProperty(J.prototype, "Collection", {
1617
+ get: function() {
1618
+ return this._ctx.table.db.Collection;
1619
+ },
1620
+ enumerable: !1,
1621
+ configurable: !0
1622
+ }), J.prototype.between = function(e, t, n, r) {
1623
+ n = !1 !== n, r = !0 === r;
1624
+ try {
1625
+ return 0 < this._cmp(e, t) || this._cmp(e, t) === 0 && (n || r) && (!n || !r) ? Lt(this) : new this.Collection(this, function() {
1626
+ return zt(e, t, !n, !r);
1627
+ });
1628
+ } catch {
1629
+ return q(this, U);
1630
+ }
1631
+ }, J.prototype.equals = function(e) {
1632
+ return e == null ? q(this, U) : new this.Collection(this, function() {
1633
+ return Bt(e);
1634
+ });
1635
+ }, J.prototype.above = function(e) {
1636
+ return e == null ? q(this, U) : new this.Collection(this, function() {
1637
+ return zt(e, void 0, !0);
1638
+ });
1639
+ }, J.prototype.aboveOrEqual = function(e) {
1640
+ return e == null ? q(this, U) : new this.Collection(this, function() {
1641
+ return zt(e, void 0, !1);
1642
+ });
1643
+ }, J.prototype.below = function(e) {
1644
+ return e == null ? q(this, U) : new this.Collection(this, function() {
1645
+ return zt(void 0, e, !1, !0);
1646
+ });
1647
+ }, J.prototype.belowOrEqual = function(e) {
1648
+ return e == null ? q(this, U) : new this.Collection(this, function() {
1649
+ return zt(void 0, e);
1650
+ });
1651
+ }, J.prototype.startsWith = function(e) {
1652
+ return typeof e == "string" ? this.between(e, e + ct, !0, !0) : q(this, lt);
1653
+ }, J.prototype.startsWithIgnoreCase = function(e) {
1654
+ return e === "" ? this.startsWith(e) : Rt(this, function(e, t) {
1655
+ return e.indexOf(t[0]) === 0;
1656
+ }, [e], ct);
1657
+ }, J.prototype.equalsIgnoreCase = function(e) {
1658
+ return Rt(this, function(e, t) {
1659
+ return e === t[0];
1660
+ }, [e], "");
1661
+ }, J.prototype.anyOfIgnoreCase = function() {
1662
+ var e = O.apply(D, arguments);
1663
+ return e.length === 0 ? Lt(this) : Rt(this, function(e, t) {
1664
+ return t.indexOf(e) !== -1;
1665
+ }, e, "");
1666
+ }, J.prototype.startsWithAnyOfIgnoreCase = function() {
1667
+ var e = O.apply(D, arguments);
1668
+ return e.length === 0 ? Lt(this) : Rt(this, function(e, t) {
1669
+ return t.some(function(t) {
1670
+ return e.indexOf(t) === 0;
1671
+ });
1672
+ }, e, ct);
1673
+ }, J.prototype.anyOf = function() {
1674
+ var e, t, n = this, r = O.apply(D, arguments), i = this._cmp;
1675
+ try {
1676
+ r.sort(i);
1677
+ } catch {
1678
+ return q(this, U);
1679
+ }
1680
+ return r.length === 0 ? Lt(this) : ((e = new this.Collection(this, function() {
1681
+ return zt(r[0], r[r.length - 1]);
1682
+ }))._ondirectionchange = function(e) {
1683
+ i = e === "next" ? n._ascending : n._descending, r.sort(i);
1684
+ }, t = 0, e._addAlgorithm(function(e, n, a) {
1685
+ for (var o = e.key; 0 < i(o, r[t]);) if (++t === r.length) return n(a), !1;
1686
+ return i(o, r[t]) === 0 || (n(function() {
1687
+ e.continue(r[t]);
1688
+ }), !1);
1689
+ }), e);
1690
+ }, J.prototype.notEqual = function(e) {
1691
+ return this.inAnyRange([[-Infinity, e], [e, this.db._maxKey]], {
1692
+ includeLowers: !1,
1693
+ includeUppers: !1
1694
+ });
1695
+ }, J.prototype.noneOf = function() {
1696
+ var e = O.apply(D, arguments);
1697
+ if (e.length === 0) return new this.Collection(this);
1698
+ try {
1699
+ e.sort(this._ascending);
1700
+ } catch {
1701
+ return q(this, U);
1702
+ }
1703
+ var t = e.reduce(function(e, t) {
1704
+ return e ? e.concat([[e[e.length - 1][1], t]]) : [[-Infinity, t]];
1705
+ }, null);
1706
+ return t.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(t, {
1707
+ includeLowers: !1,
1708
+ includeUppers: !1
1709
+ });
1710
+ }, J.prototype.inAnyRange = function(e, t) {
1711
+ var n = this, r = this._cmp, i = this._ascending, a = this._descending, o = this._min, s = this._max;
1712
+ if (e.length === 0) return Lt(this);
1713
+ if (!e.every(function(e) {
1714
+ return e[0] !== void 0 && e[1] !== void 0 && i(e[0], e[1]) <= 0;
1715
+ })) return q(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", A.InvalidArgument);
1716
+ var c = !t || !1 !== t.includeLowers, l = t && !0 === t.includeUppers, u, d = i;
1717
+ function f(e, t) {
1718
+ return d(e[0], t[0]);
1719
+ }
1720
+ try {
1721
+ (u = e.reduce(function(e, t) {
1722
+ for (var n = 0, i = e.length; n < i; ++n) {
1723
+ var a = e[n];
1724
+ if (r(t[0], a[1]) < 0 && 0 < r(t[1], a[0])) {
1725
+ a[0] = o(a[0], t[0]), a[1] = s(a[1], t[1]);
1726
+ break;
1727
+ }
1728
+ }
1729
+ return n === i && e.push(t), e;
1730
+ }, [])).sort(f);
1731
+ } catch {
1732
+ return q(this, U);
1733
+ }
1734
+ var p = 0, m = l ? function(e) {
1735
+ return 0 < i(e, u[p][1]);
1736
+ } : function(e) {
1737
+ return 0 <= i(e, u[p][1]);
1738
+ }, h = c ? function(e) {
1739
+ return 0 < a(e, u[p][0]);
1740
+ } : function(e) {
1741
+ return 0 <= a(e, u[p][0]);
1742
+ }, g = m, t = new this.Collection(this, function() {
1743
+ return zt(u[0][0], u[u.length - 1][1], !c, !l);
1744
+ });
1745
+ return t._ondirectionchange = function(e) {
1746
+ d = e === "next" ? (g = m, i) : (g = h, a), u.sort(f);
1747
+ }, t._addAlgorithm(function(e, t, r) {
1748
+ for (var a, o = e.key; g(o);) if (++p === u.length) return t(r), !1;
1749
+ return !m(a = o) && !h(a) || (n._cmp(o, u[p][1]) === 0 || n._cmp(o, u[p][0]) === 0 || t(function() {
1750
+ d === i ? e.continue(u[p][0]) : e.continue(u[p][1]);
1751
+ }), !1);
1752
+ }), t;
1753
+ }, J.prototype.startsWithAnyOf = function() {
1754
+ var e = O.apply(D, arguments);
1755
+ return e.every(function(e) {
1756
+ return typeof e == "string";
1757
+ }) ? e.length === 0 ? Lt(this) : this.inAnyRange(e.map(function(e) {
1758
+ return [e, e + ct];
1759
+ })) : q(this, "startsWithAnyOf() only works with strings");
1760
+ };
1761
+ var Vt = J;
1762
+ function J() {}
1763
+ function Y(e) {
1764
+ return B(function(t) {
1765
+ return Ht(t), e(t.target.error), !1;
1766
+ });
1767
+ }
1768
+ function Ht(e) {
1769
+ e.stopPropagation && e.stopPropagation(), e.preventDefault && e.preventDefault();
1770
+ }
1771
+ var Ut = "storagemutated", Wt = "x-storagemutated-1", Gt = wt(null, Ut), Kt = (X.prototype._lock = function() {
1772
+ return v(!R.global), ++this._reculock, this._reculock !== 1 || R.global || (R.lockOwnerFor = this), this;
1773
+ }, X.prototype._unlock = function() {
1774
+ if (v(!R.global), --this._reculock == 0) for (R.global || (R.lockOwnerFor = null); 0 < this._blockedFuncs.length && !this._locked();) {
1775
+ var e = this._blockedFuncs.shift();
1776
+ try {
1777
+ at(e[1], e[0]);
1778
+ } catch {}
1779
+ }
1780
+ return this;
1781
+ }, X.prototype._locked = function() {
1782
+ return this._reculock && R.lockOwnerFor !== this;
1783
+ }, X.prototype.create = function(e) {
1784
+ var t = this;
1785
+ if (this.mode) {
1786
+ var n = this.db.idbdb, r = this.db._state.dbOpenError;
1787
+ if (v(!this.idbtrans), !e && !n) switch (r && r.name) {
1788
+ case "DatabaseClosedError": throw new A.DatabaseClosed(r);
1789
+ case "MissingAPIError": throw new A.MissingAPI(r.message, r);
1790
+ default: throw new A.OpenFailed(r);
1791
+ }
1792
+ if (!this.active) throw new A.TransactionInactive();
1793
+ v(this._completion._state === null), (e = this.idbtrans = e || (this.db.core || n).transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })).onerror = B(function(n) {
1794
+ Ht(n), t._reject(e.error);
1795
+ }), e.onabort = B(function(n) {
1796
+ Ht(n), t.active && t._reject(new A.Abort(e.error)), t.active = !1, t.on("abort").fire(n);
1797
+ }), e.oncomplete = B(function() {
1798
+ t.active = !1, t._resolve(), "mutatedParts" in e && Gt.storagemutated.fire(e.mutatedParts);
1799
+ });
1800
+ }
1801
+ return this;
1802
+ }, X.prototype._promise = function(e, t, n) {
1803
+ var r, i = this;
1804
+ return e === "readwrite" && this.mode !== "readwrite" ? H(new A.ReadOnly("Transaction is readonly")) : this.active ? this._locked() ? new z(function(r, a) {
1805
+ i._blockedFuncs.push([function() {
1806
+ i._promise(e, t, n).then(r, a);
1807
+ }, R]);
1808
+ }) : n ? Qe(function() {
1809
+ var e = new z(function(e, n) {
1810
+ i._lock();
1811
+ var r = t(e, n, i);
1812
+ r && r.then && r.then(e, n);
1813
+ });
1814
+ return e.finally(function() {
1815
+ return i._unlock();
1816
+ }), e._lib = !0, e;
1817
+ }) : ((r = new z(function(e, n) {
1818
+ var r = t(e, n, i);
1819
+ r && r.then && r.then(e, n);
1820
+ }))._lib = !0, r) : H(new A.TransactionInactive());
1821
+ }, X.prototype._root = function() {
1822
+ return this.parent ? this.parent._root() : this;
1823
+ }, X.prototype.waitFor = function(e) {
1824
+ var t, n = this._root(), r = z.resolve(e), i = (n._waitingFor ? n._waitingFor = n._waitingFor.then(function() {
1825
+ return r;
1826
+ }) : (n._waitingFor = r, n._waitingQueue = [], t = n.idbtrans.objectStore(n.storeNames[0]), function e() {
1827
+ for (++n._spinCount; n._waitingQueue.length;) n._waitingQueue.shift()();
1828
+ n._waitingFor && (t.get(-Infinity).onsuccess = e);
1829
+ }()), n._waitingFor);
1830
+ return new z(function(e, t) {
1831
+ r.then(function(t) {
1832
+ return n._waitingQueue.push(B(e.bind(null, t)));
1833
+ }, function(e) {
1834
+ return n._waitingQueue.push(B(t.bind(null, e)));
1835
+ }).finally(function() {
1836
+ n._waitingFor === i && (n._waitingFor = null);
1837
+ });
1838
+ });
1839
+ }, X.prototype.abort = function() {
1840
+ this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new A.Abort()));
1841
+ }, X.prototype.table = function(e) {
1842
+ var t = this._memoizedTables ||= {};
1843
+ if (l(t, e)) return t[e];
1844
+ var n = this.schema[e];
1845
+ if (n) return (n = new this.db.Table(e, n, this)).core = this.db.core.table(e), t[e] = n;
1846
+ throw new A.NotFound("Table " + e + " not part of transaction");
1847
+ }, X);
1848
+ function X() {}
1849
+ function qt(e, t, n, r, i, a, o, s) {
1850
+ return {
1851
+ name: e,
1852
+ keyPath: t,
1853
+ unique: n,
1854
+ multi: r,
1855
+ auto: i,
1856
+ compound: a,
1857
+ src: (n && !o ? "&" : "") + (r ? "*" : "") + (i ? "++" : "") + Jt(t),
1858
+ type: s
1859
+ };
1860
+ }
1861
+ function Jt(e) {
1862
+ return typeof e == "string" ? e : e ? "[" + [].join.call(e, "+") + "]" : "";
1863
+ }
1864
+ function Yt(e, t, n) {
1865
+ return {
1866
+ name: e,
1867
+ primKey: t,
1868
+ indexes: n,
1869
+ mappedClass: null,
1870
+ idxByName: (r = function(e) {
1871
+ return [e.name, e];
1872
+ }, n.reduce(function(e, t, n) {
1873
+ return t = r(t, n), t && (e[t[0]] = t[1]), e;
1874
+ }, {}))
1875
+ };
1876
+ var r;
1877
+ }
1878
+ var Xt = function(e) {
1879
+ try {
1880
+ return e.only([[]]), Xt = function() {
1881
+ return [[]];
1882
+ }, [[]];
1883
+ } catch {
1884
+ return Xt = function() {
1885
+ return ct;
1886
+ }, ct;
1887
+ }
1888
+ };
1889
+ function Zt(e) {
1890
+ return e == null ? function() {} : typeof e == "string" ? (t = e).split(".").length === 1 ? function(e) {
1891
+ return e[t];
1892
+ } : function(e) {
1893
+ return b(e, t);
1894
+ } : function(t) {
1895
+ return b(t, e);
1896
+ };
1897
+ var t;
1898
+ }
1899
+ function Qt(e) {
1900
+ return [].slice.call(e);
1901
+ }
1902
+ var $t = 0;
1903
+ function en(e) {
1904
+ return e == null ? ":id" : typeof e == "string" ? e : `[${e.join("+")}]`;
1905
+ }
1906
+ function tn(e, t, n) {
1907
+ function r(e) {
1908
+ if (e.type === 3) return null;
1909
+ if (e.type === 4) throw Error("Cannot convert never type to IDBKeyRange");
1910
+ var n = e.lower, r = e.upper, i = e.lowerOpen, e = e.upperOpen;
1911
+ return n === void 0 ? r === void 0 ? null : t.upperBound(r, !!e) : r === void 0 ? t.lowerBound(n, !!i) : t.bound(n, r, !!i, !!e);
1912
+ }
1913
+ function i(e) {
1914
+ var t, n, i = e.name;
1915
+ return {
1916
+ name: i,
1917
+ schema: e,
1918
+ mutate: function(e) {
1919
+ var t = e.trans, n = e.type, a = e.keys, o = e.values, s = e.range;
1920
+ return new Promise(function(e, c) {
1921
+ e = B(e);
1922
+ var l = t.objectStore(i), u = l.keyPath == null, d = n === "put" || n === "add";
1923
+ if (!d && n !== "delete" && n !== "deleteRange") throw Error("Invalid operation type: " + n);
1924
+ var f, p = (a || o || { length: 1 }).length;
1925
+ if (a && o && a.length !== o.length) throw Error("Given keys array must have same length as given values array.");
1926
+ if (p === 0) return e({
1927
+ numFailures: 0,
1928
+ failures: {},
1929
+ results: [],
1930
+ lastResult: void 0
1931
+ });
1932
+ function m(e) {
1933
+ ++_, Ht(e);
1934
+ }
1935
+ var h = [], g = [], _ = 0;
1936
+ if (n === "deleteRange") {
1937
+ if (s.type === 4) return e({
1938
+ numFailures: _,
1939
+ failures: g,
1940
+ results: [],
1941
+ lastResult: void 0
1942
+ });
1943
+ s.type === 3 ? h.push(f = l.clear()) : h.push(f = l.delete(r(s)));
1944
+ } else {
1945
+ var u = d ? u ? [o, a] : [o, null] : [a, null], v = u[0], y = u[1];
1946
+ if (d) for (var b = 0; b < p; ++b) h.push(f = y && y[b] !== void 0 ? l[n](v[b], y[b]) : l[n](v[b])), f.onerror = m;
1947
+ else for (b = 0; b < p; ++b) h.push(f = l[n](v[b])), f.onerror = m;
1948
+ }
1949
+ function x(t) {
1950
+ t = t.target.result, h.forEach(function(e, t) {
1951
+ return e.error != null && (g[t] = e.error);
1952
+ }), e({
1953
+ numFailures: _,
1954
+ failures: g,
1955
+ results: n === "delete" ? a : h.map(function(e) {
1956
+ return e.result;
1957
+ }),
1958
+ lastResult: t
1959
+ });
1960
+ }
1961
+ f.onerror = function(e) {
1962
+ m(e), x(e);
1963
+ }, f.onsuccess = x;
1964
+ });
1965
+ },
1966
+ getMany: function(e) {
1967
+ var t = e.trans, n = e.keys;
1968
+ return new Promise(function(e, r) {
1969
+ e = B(e);
1970
+ for (var a, o = t.objectStore(i), s = n.length, c = Array(s), l = 0, u = 0, d = function(t) {
1971
+ t = t.target, c[t._pos] = t.result, ++u === l && e(c);
1972
+ }, f = Y(r), p = 0; p < s; ++p) n[p] != null && ((a = o.get(n[p]))._pos = p, a.onsuccess = d, a.onerror = f, ++l);
1973
+ l === 0 && e(c);
1974
+ });
1975
+ },
1976
+ get: function(e) {
1977
+ var t = e.trans, n = e.key;
1978
+ return new Promise(function(e, r) {
1979
+ e = B(e);
1980
+ var a = t.objectStore(i).get(n);
1981
+ a.onsuccess = function(t) {
1982
+ return e(t.target.result);
1983
+ }, a.onerror = Y(r);
1984
+ });
1985
+ },
1986
+ query: (t = c, n = l, function(e) {
1987
+ return new Promise(function(a, o) {
1988
+ a = B(a);
1989
+ var s, c, l, u, d = e.trans, f = e.values, p = e.limit, m = e.query, h = (h = e.direction) ?? "next", g = p === Infinity ? void 0 : p, _ = m.index, m = m.range, d = d.objectStore(i), d = _.isPrimaryKey ? d : d.index(_.name), _ = r(m);
1990
+ if (p === 0) return a({ result: [] });
1991
+ n ? (m = {
1992
+ query: _,
1993
+ count: g,
1994
+ direction: h
1995
+ }, (s = f ? d.getAll(m) : d.getAllKeys(m)).onsuccess = function(e) {
1996
+ return a({ result: e.target.result });
1997
+ }, s.onerror = Y(o)) : t && h === "next" ? ((s = f ? d.getAll(_, g) : d.getAllKeys(_, g)).onsuccess = function(e) {
1998
+ return a({ result: e.target.result });
1999
+ }, s.onerror = Y(o)) : (c = 0, l = !f && "openKeyCursor" in d ? d.openKeyCursor(_, h) : d.openCursor(_, h), u = [], l.onsuccess = function() {
2000
+ var e = l.result;
2001
+ return !e || (u.push(f ? e.value : e.primaryKey), ++c === p) ? a({ result: u }) : void e.continue();
2002
+ }, l.onerror = Y(o));
2003
+ });
2004
+ }),
2005
+ openCursor: function(e) {
2006
+ var t = e.trans, n = e.values, a = e.query, o = e.reverse, s = e.unique;
2007
+ return new Promise(function(e, c) {
2008
+ e = B(e);
2009
+ var l = a.index, u = a.range, d = t.objectStore(i), d = l.isPrimaryKey ? d : d.index(l.name), l = o ? s ? "prevunique" : "prev" : s ? "nextunique" : "next", f = !n && "openKeyCursor" in d ? d.openKeyCursor(r(u), l) : d.openCursor(r(u), l);
2010
+ f.onerror = Y(c), f.onsuccess = B(function(n) {
2011
+ var r, i, a, o, s = f.result;
2012
+ s ? (s.___id = ++$t, s.done = !1, r = s.continue.bind(s), i = (i = s.continuePrimaryKey) && i.bind(s), a = s.advance.bind(s), o = function() {
2013
+ throw Error("Cursor not stopped");
2014
+ }, s.trans = t, s.stop = s.continue = s.continuePrimaryKey = s.advance = function() {
2015
+ throw Error("Cursor not started");
2016
+ }, s.fail = B(c), s.next = function() {
2017
+ var e = this, t = 1;
2018
+ return this.start(function() {
2019
+ return t-- ? e.continue() : e.stop();
2020
+ }).then(function() {
2021
+ return e;
2022
+ });
2023
+ }, s.start = function(e) {
2024
+ function t() {
2025
+ if (f.result) try {
2026
+ e();
2027
+ } catch (e) {
2028
+ s.fail(e);
2029
+ }
2030
+ else s.done = !0, s.start = function() {
2031
+ throw Error("Cursor behind last entry");
2032
+ }, s.stop();
2033
+ }
2034
+ var n = new Promise(function(e, t) {
2035
+ e = B(e), f.onerror = Y(t), s.fail = t, s.stop = function(t) {
2036
+ s.stop = s.continue = s.continuePrimaryKey = s.advance = o, e(t);
2037
+ };
2038
+ });
2039
+ return f.onsuccess = B(function(e) {
2040
+ f.onsuccess = t, t();
2041
+ }), s.continue = r, s.continuePrimaryKey = i, s.advance = a, t(), n;
2042
+ }, e(s)) : e(null);
2043
+ }, c);
2044
+ });
2045
+ },
2046
+ count: function(e) {
2047
+ var t = e.query, n = e.trans, a = t.index, o = t.range;
2048
+ return new Promise(function(e, t) {
2049
+ var s = n.objectStore(i), s = a.isPrimaryKey ? s : s.index(a.name), c = r(o), c = c ? s.count(c) : s.count();
2050
+ c.onsuccess = B(function(t) {
2051
+ return e(t.target.result);
2052
+ }), c.onerror = Y(t);
2053
+ });
2054
+ }
2055
+ };
2056
+ }
2057
+ o = n, s = Qt((n = e).objectStoreNames), u = 0 < s.length ? o.objectStore(s[0]) : {};
2058
+ var o, n = {
2059
+ schema: {
2060
+ name: n.name,
2061
+ tables: s.map(function(e) {
2062
+ return o.objectStore(e);
2063
+ }).map(function(e) {
2064
+ var t = e.keyPath, n = e.autoIncrement, r = a(t), i = {}, r = {
2065
+ name: e.name,
2066
+ primaryKey: {
2067
+ name: null,
2068
+ isPrimaryKey: !0,
2069
+ outbound: t == null,
2070
+ compound: r,
2071
+ keyPath: t,
2072
+ autoIncrement: n,
2073
+ unique: !0,
2074
+ extractKey: Zt(t)
2075
+ },
2076
+ indexes: Qt(e.indexNames).map(function(t) {
2077
+ return e.index(t);
2078
+ }).map(function(e) {
2079
+ var t = e.name, n = e.unique, r = e.multiEntry, e = e.keyPath, t = {
2080
+ name: t,
2081
+ compound: a(e),
2082
+ keyPath: e,
2083
+ unique: n,
2084
+ multiEntry: r,
2085
+ extractKey: Zt(e)
2086
+ };
2087
+ return i[en(e)] = t;
2088
+ }),
2089
+ getIndexByKeyPath: function(e) {
2090
+ return i[en(e)];
2091
+ }
2092
+ };
2093
+ return i[":id"] = r.primaryKey, t != null && (i[en(t)] = r.primaryKey), r;
2094
+ })
2095
+ },
2096
+ hasGetAll: 0 < s.length && "getAll" in u && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604),
2097
+ hasIdb3Features: "getAllRecords" in u
2098
+ }, s = n.schema, c = n.hasGetAll, l = n.hasIdb3Features, u = s.tables.map(i), d = {};
2099
+ return u.forEach(function(e) {
2100
+ return d[e.name] = e;
2101
+ }), {
2102
+ stack: "dbcore",
2103
+ transaction: e.transaction.bind(e),
2104
+ table: function(e) {
2105
+ if (d[e]) return d[e];
2106
+ throw Error(`Table '${e}' not found`);
2107
+ },
2108
+ MIN_KEY: -Infinity,
2109
+ MAX_KEY: Xt(t),
2110
+ schema: s
2111
+ };
2112
+ }
2113
+ function nn(e, n, r, i) {
2114
+ return r = r.IDBKeyRange, n = tn(n, r, i), { dbcore: e.dbcore.reduce(function(e, n) {
2115
+ return n = n.create, t(t({}, e), n(e));
2116
+ }, n) };
2117
+ }
2118
+ function rn(e, t) {
2119
+ var n = t.db, n = nn(e._middlewares, n, e._deps, t);
2120
+ e.core = n.dbcore, e.tables.forEach(function(t) {
2121
+ var n = t.name;
2122
+ e.core.schema.tables.some(function(e) {
2123
+ return e.name === n;
2124
+ }) && (t.core = e.core.table(n), e[n] instanceof e.Table) && (e[n].core = t.core);
2125
+ });
2126
+ }
2127
+ function an(e, t, n, r) {
2128
+ n.forEach(function(n) {
2129
+ var i = r[n];
2130
+ t.forEach(function(t) {
2131
+ var r = function e(t, n) {
2132
+ return m(t, n) || (t = s(t)) && e(t, n);
2133
+ }(t, n);
2134
+ (!r || "value" in r && r.value === void 0) && (t === e.Transaction.prototype || t instanceof e.Transaction ? f(t, n, {
2135
+ get: function() {
2136
+ return this.table(n);
2137
+ },
2138
+ set: function(e) {
2139
+ d(this, n, {
2140
+ value: e,
2141
+ writable: !0,
2142
+ configurable: !0,
2143
+ enumerable: !0
2144
+ });
2145
+ }
2146
+ }) : t[n] = new e.Table(n, i));
2147
+ });
2148
+ });
2149
+ }
2150
+ function on(e, t) {
2151
+ t.forEach(function(t) {
2152
+ for (var n in t) t[n] instanceof e.Table && delete t[n];
2153
+ });
2154
+ }
2155
+ function sn(e, t) {
2156
+ return e._cfg.version - t._cfg.version;
2157
+ }
2158
+ function cn(e, t, n, r) {
2159
+ var a = e._dbSchema, o = (n.objectStoreNames.contains("$meta") && !a.$meta && (a.$meta = Yt("$meta", gn("")[0], []), e._storeNames.push("$meta")), e._createTransaction("readwrite", e._storeNames, a)), s = (o.create(n), o._completion.catch(r), o._reject.bind(o)), c = R.transless || R;
2160
+ Qe(function() {
2161
+ if (R.trans = o, R.transless = c, t !== 0) return rn(e, n), l = t, ((r = o).storeNames.includes("$meta") ? r.table("$meta").get("version").then(function(e) {
2162
+ return e ?? l;
2163
+ }) : z.resolve(l)).then(function(t) {
2164
+ var r = e, a = t, s = o, c = n, l = [], t = r._versions, u = r._dbSchema = mn(0, r.idbdb, c);
2165
+ return (t = t.filter(function(e) {
2166
+ return e._cfg.version >= a;
2167
+ })).length === 0 ? z.resolve() : (t.forEach(function(e) {
2168
+ l.push(function() {
2169
+ var t, n, o, l = u, d = e._cfg.dbschema, f = (hn(r, l, c), hn(r, d, c), u = r._dbSchema = d, un(l, d)), p = (f.add.forEach(function(e) {
2170
+ dn(c, e[0], e[1].primKey, e[1].indexes);
2171
+ }), f.change.forEach(function(e) {
2172
+ if (e.recreate) throw new A.Upgrade("Not yet support for changing primary key");
2173
+ var t = c.objectStore(e.name);
2174
+ e.add.forEach(function(e) {
2175
+ return pn(t, e);
2176
+ }), e.change.forEach(function(e) {
2177
+ t.deleteIndex(e.name), pn(t, e);
2178
+ }), e.del.forEach(function(e) {
2179
+ return t.deleteIndex(e);
2180
+ });
2181
+ }), e._cfg.contentUpgrade);
2182
+ if (p && e._cfg.version > a) return rn(r, c), s._memoizedTables = {}, t = S(d), f.del.forEach(function(e) {
2183
+ t[e] = l[e];
2184
+ }), on(r, [r.Transaction.prototype]), an(r, [r.Transaction.prototype], i(t), t), s.schema = t, (n = se(p)) && $e(), d = z.follow(function() {
2185
+ var e;
2186
+ (o = p(s)) && n && (e = et.bind(null, null), o.then(e, e));
2187
+ }), o && typeof o.then == "function" ? z.resolve(o) : d.then(function() {
2188
+ return o;
2189
+ });
2190
+ }), l.push(function(t) {
2191
+ var n = e._cfg.dbschema, i = t;
2192
+ [].slice.call(i.db.objectStoreNames).forEach(function(e) {
2193
+ return n[e] == null && i.db.deleteObjectStore(e);
2194
+ }), on(r, [r.Transaction.prototype]), an(r, [r.Transaction.prototype], r._storeNames, r._dbSchema), s.schema = r._dbSchema;
2195
+ }), l.push(function(t) {
2196
+ 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) {
2197
+ return e !== "$meta";
2198
+ })) : t.objectStore("$meta").put(e._cfg.version, "version"));
2199
+ });
2200
+ }), function e() {
2201
+ return l.length ? z.resolve(l.shift()(s.idbtrans)).then(e) : z.resolve();
2202
+ }().then(function() {
2203
+ fn(u, c);
2204
+ }));
2205
+ }).catch(s);
2206
+ var r, l;
2207
+ i(a).forEach(function(e) {
2208
+ dn(n, e, a[e].primKey, a[e].indexes);
2209
+ }), rn(e, n), z.follow(function() {
2210
+ return e.on.populate.fire(o);
2211
+ }).catch(s);
2212
+ });
2213
+ }
2214
+ function ln(e, t) {
2215
+ fn(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");
2216
+ var n = mn(0, e.idbdb, t);
2217
+ hn(e, e._dbSchema, t);
2218
+ for (var r = 0, i = un(n, e._dbSchema).change; r < i.length; r++) {
2219
+ var a = ((e) => {
2220
+ 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 };
2221
+ var n = t.objectStore(e.name);
2222
+ e.add.forEach(function(t) {
2223
+ P && console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`), pn(n, t);
2224
+ });
2225
+ })(i[r]);
2226
+ if (typeof a == "object") return a.value;
2227
+ }
2228
+ }
2229
+ function un(e, t) {
2230
+ var n, r = {
2231
+ del: [],
2232
+ add: [],
2233
+ change: []
2234
+ };
2235
+ for (n in e) t[n] || r.del.push(n);
2236
+ for (n in t) {
2237
+ var i = e[n], a = t[n];
2238
+ if (i) {
2239
+ var o = {
2240
+ name: n,
2241
+ def: a,
2242
+ recreate: !1,
2243
+ del: [],
2244
+ add: [],
2245
+ change: []
2246
+ };
2247
+ if ("" + (i.primKey.keyPath || "") != "" + (a.primKey.keyPath || "") || i.primKey.auto !== a.primKey.auto) o.recreate = !0, r.change.push(o);
2248
+ else {
2249
+ var s = i.idxByName, c = a.idxByName, l = void 0;
2250
+ for (l in s) c[l] || o.del.push(l);
2251
+ for (l in c) {
2252
+ var u = s[l], d = c[l];
2253
+ u ? u.src !== d.src && o.change.push(d) : o.add.push(d);
2254
+ }
2255
+ (0 < o.del.length || 0 < o.add.length || 0 < o.change.length) && r.change.push(o);
2256
+ }
2257
+ } else r.add.push([n, a]);
2258
+ }
2259
+ return r;
2260
+ }
2261
+ function dn(e, t, n, r) {
2262
+ var i = e.db.createObjectStore(t, n.keyPath ? {
2263
+ keyPath: n.keyPath,
2264
+ autoIncrement: n.auto
2265
+ } : { autoIncrement: n.auto });
2266
+ r.forEach(function(e) {
2267
+ return pn(i, e);
2268
+ });
2269
+ }
2270
+ function fn(e, t) {
2271
+ i(e).forEach(function(n) {
2272
+ t.db.objectStoreNames.contains(n) || (P && console.debug("Dexie: Creating missing table", n), dn(t, n, e[n].primKey, e[n].indexes));
2273
+ });
2274
+ }
2275
+ function pn(e, t) {
2276
+ e.createIndex(t.name, t.keyPath, {
2277
+ unique: t.unique,
2278
+ multiEntry: t.multi
2279
+ });
2280
+ }
2281
+ function mn(e, t, n) {
2282
+ var r = {};
2283
+ return g(t.objectStoreNames, 0).forEach(function(e) {
2284
+ for (var t = n.objectStore(e), i = qt(Jt(c = t.keyPath), c || "", !0, !1, !!t.autoIncrement, c && typeof c != "string", !0), a = [], o = 0; o < t.indexNames.length; ++o) {
2285
+ var s = t.index(t.indexNames[o]), c = s.keyPath, s = qt(s.name, c, !!s.unique, !!s.multiEntry, !1, c && typeof c != "string", !1);
2286
+ a.push(s);
2287
+ }
2288
+ r[e] = Yt(e, i, a);
2289
+ }), r;
2290
+ }
2291
+ function hn(e, t, n) {
2292
+ for (var i = n.db.objectStoreNames, a = 0; a < i.length; ++a) {
2293
+ var o = i[a], s = n.objectStore(o);
2294
+ e._hasGetAll = "getAll" in s;
2295
+ for (var c = 0; c < s.indexNames.length; ++c) {
2296
+ var l, u = s.indexNames[c], d = s.index(u).keyPath, d = typeof d == "string" ? d : "[" + g(d).join("+") + "]";
2297
+ t[o] && (l = t[o].idxByName[d]) && (l.name = u, delete t[o].idxByName[d], t[o].idxByName[u] = l);
2298
+ }
2299
+ }
2300
+ typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && r.WorkerGlobalScope && r instanceof r.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (e._hasGetAll = !1);
2301
+ }
2302
+ function gn(e) {
2303
+ return e.split(",").map(function(e, t) {
2304
+ var n = e.split(":"), r = (r = n[1])?.trim(), n = (e = n[0].trim()).replace(/([&*]|\+\+)/g, ""), i = /^\[/.test(n) ? n.match(/^\[(.*)\]$/)[1].split("+") : n;
2305
+ return qt(n, i || null, /\&/.test(e), /\*/.test(e), /\+\+/.test(e), a(i), t === 0, r);
2306
+ });
2307
+ }
2308
+ vn.prototype._createTableSchema = Yt, vn.prototype._parseIndexSyntax = gn, vn.prototype._parseStoresSpec = function(e, t) {
2309
+ var n = this;
2310
+ i(e).forEach(function(r) {
2311
+ if (e[r] !== null) {
2312
+ var i = n._parseIndexSyntax(e[r]), a = i.shift();
2313
+ if (!a) throw new A.Schema("Invalid schema for table " + r + ": " + e[r]);
2314
+ if (a.unique = !0, a.multi) throw new A.Schema("Primary key cannot be multiEntry*");
2315
+ i.forEach(function(e) {
2316
+ if (e.auto) throw new A.Schema("Only primary key can be marked as autoIncrement (++)");
2317
+ if (!e.keyPath) throw new A.Schema("Index must have a name and cannot be an empty string");
2318
+ }), a = n._createTableSchema(r, a, i), t[r] = a;
2319
+ }
2320
+ });
2321
+ }, vn.prototype.stores = function(e) {
2322
+ var t = this.db, e = (this._cfg.storesSource = this._cfg.storesSource ? o(this._cfg.storesSource, e) : e, t._versions), n = {}, r = {};
2323
+ return e.forEach(function(e) {
2324
+ o(n, e._cfg.storesSource), r = e._cfg.dbschema = {}, e._parseStoresSpec(n, r);
2325
+ }), t._dbSchema = r, on(t, [
2326
+ t._allTables,
2327
+ t,
2328
+ t.Transaction.prototype
2329
+ ]), an(t, [
2330
+ t._allTables,
2331
+ t,
2332
+ t.Transaction.prototype,
2333
+ this._cfg.tables
2334
+ ], i(r), r), t._storeNames = i(r), this;
2335
+ }, vn.prototype.upgrade = function(e) {
2336
+ return this._cfg.contentUpgrade = xe(this._cfg.contentUpgrade || j, e), this;
2337
+ };
2338
+ var _n = vn;
2339
+ function vn() {}
2340
+ var yn = (() => {
2341
+ var e, t, n;
2342
+ return typeof FinalizationRegistry < "u" && typeof WeakRef < "u" ? (e = /* @__PURE__ */ new Set(), t = new FinalizationRegistry(function(t) {
2343
+ e.delete(t);
2344
+ }), {
2345
+ toArray: function() {
2346
+ return Array.from(e).map(function(e) {
2347
+ return e.deref();
2348
+ }).filter(function(e) {
2349
+ return e !== void 0;
2350
+ });
2351
+ },
2352
+ add: function(n) {
2353
+ var r = new WeakRef(n._novip);
2354
+ e.add(r), t.register(n._novip, r, r), e.size > n._options.maxConnections && (r = e.values().next().value, e.delete(r), t.unregister(r));
2355
+ },
2356
+ remove: function(n) {
2357
+ if (n) for (var r = e.values(), i = r.next(); !i.done;) {
2358
+ var a = i.value;
2359
+ if (a.deref() === n._novip) return e.delete(a), void t.unregister(a);
2360
+ i = r.next();
2361
+ }
2362
+ }
2363
+ }) : (n = [], {
2364
+ toArray: function() {
2365
+ return n;
2366
+ },
2367
+ add: function(e) {
2368
+ n.push(e._novip);
2369
+ },
2370
+ remove: function(e) {
2371
+ e && (e = n.indexOf(e._novip)) !== -1 && n.splice(e, 1);
2372
+ }
2373
+ });
2374
+ })();
2375
+ function bn(e, t) {
2376
+ var n = e._dbNamesDB;
2377
+ return n || (n = e._dbNamesDB = new Q(ut, {
2378
+ addons: [],
2379
+ indexedDB: e,
2380
+ IDBKeyRange: t
2381
+ })).version(1).stores({ dbnames: "name" }), n.table("dbnames");
2382
+ }
2383
+ function xn(e) {
2384
+ return e && typeof e.databases == "function";
2385
+ }
2386
+ function Sn(e) {
2387
+ return Qe(function() {
2388
+ return R.letThrough = !0, e();
2389
+ });
2390
+ }
2391
+ function Cn(e) {
2392
+ return !("from" in e);
2393
+ }
2394
+ var Z = function(e, t) {
2395
+ var n;
2396
+ if (!this) return n = new Z(), e && "d" in e && o(n, e), n;
2397
+ o(this, arguments.length ? {
2398
+ d: 1,
2399
+ from: e,
2400
+ to: 1 < arguments.length ? t : e
2401
+ } : { d: 0 });
2402
+ };
2403
+ function wn(e, t, n) {
2404
+ var r = W(t, n);
2405
+ if (!isNaN(r)) {
2406
+ if (0 < r) throw RangeError();
2407
+ if (Cn(e)) return o(e, {
2408
+ from: t,
2409
+ to: n,
2410
+ d: 1
2411
+ });
2412
+ var r = e.l, i = e.r;
2413
+ if (W(n, e.from) < 0) return r ? wn(r, t, n) : e.l = {
2414
+ from: t,
2415
+ to: n,
2416
+ d: 1,
2417
+ l: null,
2418
+ r: null
2419
+ }, On(e);
2420
+ if (0 < W(t, e.to)) return i ? wn(i, t, n) : e.r = {
2421
+ from: t,
2422
+ to: n,
2423
+ d: 1,
2424
+ l: null,
2425
+ r: null
2426
+ }, On(e);
2427
+ W(t, e.from) < 0 && (e.from = t, e.l = null, e.d = i ? i.d + 1 : 1), 0 < W(n, e.to) && (e.to = n, e.r = null, e.d = e.l ? e.l.d + 1 : 1), t = !e.r, r && !e.l && Tn(e, r), i && t && Tn(e, i);
2428
+ }
2429
+ }
2430
+ function Tn(e, t) {
2431
+ Cn(t) || function e(t, n) {
2432
+ var r = n.from, i = n.l, a = n.r;
2433
+ wn(t, r, n.to), i && e(t, i), a && e(t, a);
2434
+ }(e, t);
2435
+ }
2436
+ function En(e, t) {
2437
+ var n = Dn(t), r = n.next();
2438
+ if (!r.done) for (var i = r.value, a = Dn(e), o = a.next(i.from), s = o.value; !r.done && !o.done;) {
2439
+ if (W(s.from, i.to) <= 0 && 0 <= W(s.to, i.from)) return !0;
2440
+ W(i.from, s.from) < 0 ? i = (r = n.next(s.from)).value : s = (o = a.next(i.from)).value;
2441
+ }
2442
+ return !1;
2443
+ }
2444
+ function Dn(e) {
2445
+ var t = Cn(e) ? null : {
2446
+ s: 0,
2447
+ n: e
2448
+ };
2449
+ return { next: function(e) {
2450
+ for (var n = 0 < arguments.length; t;) switch (t.s) {
2451
+ case 0: if (t.s = 1, n) for (; t.n.l && W(e, t.n.from) < 0;) t = {
2452
+ up: t,
2453
+ n: t.n.l,
2454
+ s: 1
2455
+ };
2456
+ else for (; t.n.l;) t = {
2457
+ up: t,
2458
+ n: t.n.l,
2459
+ s: 1
2460
+ };
2461
+ case 1: if (t.s = 2, !n || W(e, t.n.to) <= 0) return {
2462
+ value: t.n,
2463
+ done: !1
2464
+ };
2465
+ case 2: if (t.n.r) {
2466
+ t.s = 3, t = {
2467
+ up: t,
2468
+ n: t.n.r,
2469
+ s: 0
2470
+ };
2471
+ continue;
2472
+ }
2473
+ case 3: t = t.up;
2474
+ }
2475
+ return { done: !0 };
2476
+ } };
2477
+ }
2478
+ function On(e) {
2479
+ var n, r, i, a = ((a = e.r)?.d || 0) - ((a = e.l)?.d || 0), a = 1 < a ? "r" : a < -1 ? "l" : "";
2480
+ a && (n = a == "r" ? "l" : "r", r = t({}, e), i = e[a], e.from = i.from, e.to = i.to, e[a] = i[a], r[a] = i[n], (e[n] = r).d = kn(r)), e.d = kn(e);
2481
+ }
2482
+ function kn(e) {
2483
+ var t = e.r, e = e.l;
2484
+ return (t ? e ? Math.max(t.d, e.d) : t.d : e ? e.d : 0) + 1;
2485
+ }
2486
+ function An(e, t) {
2487
+ return i(t).forEach(function(n) {
2488
+ e[n] ? Tn(e[n], t[n]) : e[n] = function e(t) {
2489
+ var n, r, i = {};
2490
+ for (n in t) l(t, n) && (r = t[n], i[n] = !r || typeof r != "object" || te.has(r.constructor) ? r : e(r));
2491
+ return i;
2492
+ }(t[n]);
2493
+ }), e;
2494
+ }
2495
+ function jn(e, t) {
2496
+ return e.all || t.all || Object.keys(e).some(function(n) {
2497
+ return t[n] && En(t[n], e[n]);
2498
+ });
2499
+ }
2500
+ u(Z.prototype, ((k = {
2501
+ add: function(e) {
2502
+ return Tn(this, e), this;
2503
+ },
2504
+ addKey: function(e) {
2505
+ return wn(this, e, e), this;
2506
+ },
2507
+ addKeys: function(e) {
2508
+ var t = this;
2509
+ return e.forEach(function(e) {
2510
+ return wn(t, e, e);
2511
+ }), this;
2512
+ },
2513
+ hasKey: function(e) {
2514
+ var t = Dn(this).next(e).value;
2515
+ return t && W(t.from, e) <= 0 && 0 <= W(t.to, e);
2516
+ }
2517
+ })[ae] = function() {
2518
+ return Dn(this);
2519
+ }, k));
2520
+ var Mn = {}, Nn = {}, Pn = !1;
2521
+ function Fn(e) {
2522
+ An(Nn, e), Pn || (Pn = !0, setTimeout(function() {
2523
+ Pn = !1, In(Nn, !(Nn = {}));
2524
+ }, 0));
2525
+ }
2526
+ function In(e, t) {
2527
+ t === void 0 && (t = !1);
2528
+ var n = /* @__PURE__ */ new Set();
2529
+ if (e.all) for (var r = 0, i = Object.values(Mn); r < i.length; r++) Ln(s = i[r], e, n, t);
2530
+ else for (var a in e) {
2531
+ var o, s, a = /^idb\:\/\/(.*)\/(.*)\//.exec(a);
2532
+ a && (o = a[1], a = a[2], s = Mn[`idb://${o}/${a}`]) && Ln(s, e, n, t);
2533
+ }
2534
+ n.forEach(function(e) {
2535
+ return e();
2536
+ });
2537
+ }
2538
+ function Ln(e, t, n, r) {
2539
+ for (var i = [], a = 0, o = Object.entries(e.queries.query); a < o.length; a++) {
2540
+ for (var s = o[a], c = s[0], l = [], u = 0, d = s[1]; u < d.length; u++) {
2541
+ var f = d[u];
2542
+ jn(t, f.obsSet) ? f.subscribers.forEach(function(e) {
2543
+ return n.add(e);
2544
+ }) : r && l.push(f);
2545
+ }
2546
+ r && i.push([c, l]);
2547
+ }
2548
+ if (r) for (var p = 0, m = i; p < m.length; p++) {
2549
+ var h = m[p], c = h[0], l = h[1];
2550
+ e.queries.query[c] = l;
2551
+ }
2552
+ }
2553
+ function Rn(e) {
2554
+ var t = e._state, n = e._deps.indexedDB;
2555
+ if (t.isBeingOpened || e.idbdb) return t.dbReadyPromise.then(function() {
2556
+ return t.dbOpenError ? H(t.dbOpenError) : e;
2557
+ });
2558
+ t.isBeingOpened = !0, t.dbOpenError = null, t.openComplete = !1;
2559
+ var r = t.openCanceller, a = Math.round(10 * e.verno), o = !1;
2560
+ function s() {
2561
+ if (t.openCanceller !== r) throw new A.DatabaseClosed("db.open() was cancelled");
2562
+ }
2563
+ function c() {
2564
+ return new z(function(r, l) {
2565
+ if (s(), !n) throw new A.MissingAPI();
2566
+ var u = e.name, p = t.autoSchema || !a ? n.open(u) : n.open(u, a);
2567
+ if (!p) throw new A.MissingAPI();
2568
+ p.onerror = Y(l), p.onblocked = B(e._fireOnBlocked), p.onupgradeneeded = B(function(r) {
2569
+ var i;
2570
+ d = p.transaction, t.autoSchema && !e._options.allowEmptyDB ? (p.onerror = Ht, d.abort(), p.result.close(), (i = n.deleteDatabase(u)).onsuccess = i.onerror = B(function() {
2571
+ l(new A.NoSuchDatabase(`Database ${u} doesnt exist`));
2572
+ })) : (d.onerror = Y(l), i = r.oldVersion > 2 ** 62 ? 0 : r.oldVersion, f = i < 1, e.idbdb = p.result, o && ln(e, d), cn(e, i / 10, d, l));
2573
+ }, l), p.onsuccess = B(function() {
2574
+ d = null;
2575
+ var n, s, l, m, h, _, v = e.idbdb = p.result, y = g(v.objectStoreNames);
2576
+ if (0 < y.length) try {
2577
+ var b = v.transaction((h = y).length === 1 ? h[0] : h, "readonly");
2578
+ if (t.autoSchema) _ = v, m = b, (l = e).verno = _.version / 10, m = l._dbSchema = mn(0, _, m), l._storeNames = g(_.objectStoreNames, 0), an(l, [l._allTables], i(m), m);
2579
+ else if (hn(e, e._dbSchema, b), s = b, ((s = un(mn(0, (n = e).idbdb, s), n._dbSchema)).add.length || s.change.some(function(e) {
2580
+ return e.add.length || e.change.length;
2581
+ })) && !o) return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."), v.close(), a = v.version + 1, o = !0, r(c());
2582
+ rn(e, b);
2583
+ } catch {}
2584
+ yn.add(e), v.onversionchange = B(function(n) {
2585
+ t.vcFired = !0, e.on("versionchange").fire(n);
2586
+ }), v.onclose = B(function() {
2587
+ e.close({ disableAutoOpen: !1 });
2588
+ }), f && (y = e._deps, h = u, xn(_ = y.indexedDB) || h === ut || bn(_, y.IDBKeyRange).put({ name: h }).catch(j)), r();
2589
+ }, l);
2590
+ }).catch(function(e) {
2591
+ switch (e?.name) {
2592
+ case "UnknownError":
2593
+ if (0 < t.PR1398_maxLoop) return t.PR1398_maxLoop--, console.warn("Dexie: Workaround for Chrome UnknownError on open()"), c();
2594
+ break;
2595
+ case "VersionError": if (0 < a) return a = 0, c();
2596
+ }
2597
+ return z.reject(e);
2598
+ });
2599
+ }
2600
+ var l, u = t.dbReadyResolve, d = null, f = !1;
2601
+ return z.race([r, (typeof navigator > "u" ? z.resolve() : !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(e) {
2602
+ function t() {
2603
+ return indexedDB.databases().finally(e);
2604
+ }
2605
+ l = setInterval(t, 100), t();
2606
+ }).finally(function() {
2607
+ return clearInterval(l);
2608
+ }) : Promise.resolve()).then(c)]).then(function() {
2609
+ return s(), t.onReadyBeingFired = [], z.resolve(Sn(function() {
2610
+ return e.on.ready.fire(e.vip);
2611
+ })).then(function n() {
2612
+ var r;
2613
+ if (0 < t.onReadyBeingFired.length) return r = t.onReadyBeingFired.reduce(xe, j), t.onReadyBeingFired = [], z.resolve(Sn(function() {
2614
+ return r(e.vip);
2615
+ })).then(n);
2616
+ });
2617
+ }).finally(function() {
2618
+ t.openCanceller === r && (t.onReadyBeingFired = null, t.isBeingOpened = !1);
2619
+ }).catch(function(n) {
2620
+ t.dbOpenError = n;
2621
+ try {
2622
+ d && d.abort();
2623
+ } catch {}
2624
+ return r === t.openCanceller && e._close(), H(n);
2625
+ }).finally(function() {
2626
+ t.openComplete = !0, u();
2627
+ }).then(function() {
2628
+ var t;
2629
+ return f && (t = {}, e.tables.forEach(function(n) {
2630
+ n.schema.indexes.forEach(function(r) {
2631
+ r.name && (t[`idb://${e.name}/${n.name}/${r.name}`] = new Z(-Infinity, [[[]]]));
2632
+ }), t[`idb://${e.name}/${n.name}/`] = t[`idb://${e.name}/${n.name}/:dels`] = new Z(-Infinity, [[[]]]);
2633
+ }), Gt(Ut).fire(t), In(t, !0)), e;
2634
+ });
2635
+ }
2636
+ function zn(e) {
2637
+ function t(t) {
2638
+ return e.next(t);
2639
+ }
2640
+ var n = i(t), r = i(function(t) {
2641
+ return e.throw(t);
2642
+ });
2643
+ function i(e) {
2644
+ return function(t) {
2645
+ var t = e(t), i = t.value;
2646
+ return t.done ? i : i && typeof i.then == "function" ? i.then(n, r) : a(i) ? Promise.all(i).then(n, r) : n(i);
2647
+ };
2648
+ }
2649
+ return i(t)();
2650
+ }
2651
+ function Bn(e, t, n) {
2652
+ for (var r = a(e) ? e.slice() : [e], i = 0; i < n; ++i) r.push(t);
2653
+ return r;
2654
+ }
2655
+ var Vn = {
2656
+ stack: "dbcore",
2657
+ name: "VirtualIndexMiddleware",
2658
+ level: 1,
2659
+ create: function(e) {
2660
+ return t(t({}, e), { table: function(n) {
2661
+ var r = e.table(n), n = r.schema, i = Object.create(null), a = [];
2662
+ function o(e, n, r) {
2663
+ var s = en(e), c = i[s] = i[s] || [], l = e == null ? 0 : typeof e == "string" ? 1 : e.length, u = 0 < n, s = t(t({}, r), {
2664
+ name: u ? `${s}(virtual-from:${r.name})` : r.name,
2665
+ lowLevelIndex: r,
2666
+ isVirtual: u,
2667
+ keyTail: n,
2668
+ keyLength: l,
2669
+ extractKey: Zt(e),
2670
+ unique: !u && r.unique
2671
+ });
2672
+ return c.push(s), s.isPrimaryKey || a.push(s), 1 < l && o(l === 2 ? e[0] : e.slice(0, l - 1), n + 1, r), c.sort(function(e, t) {
2673
+ return e.keyTail - t.keyTail;
2674
+ }), s;
2675
+ }
2676
+ var s = o(n.primaryKey.keyPath, 0, n.primaryKey);
2677
+ i[":id"] = [s];
2678
+ for (var c = 0, l = n.indexes; c < l.length; c++) {
2679
+ var u = l[c];
2680
+ o(u.keyPath, 0, u);
2681
+ }
2682
+ function d(n) {
2683
+ var r, i = n.query.index;
2684
+ return i.isVirtual ? t(t({}, n), { query: {
2685
+ index: i.lowLevelIndex,
2686
+ range: (r = n.query.range, i = i.keyTail, {
2687
+ type: r.type === 1 ? 2 : r.type,
2688
+ lower: Bn(r.lower, r.lowerOpen ? e.MAX_KEY : e.MIN_KEY, i),
2689
+ lowerOpen: !0,
2690
+ upper: Bn(r.upper, r.upperOpen ? e.MIN_KEY : e.MAX_KEY, i),
2691
+ upperOpen: !0
2692
+ })
2693
+ } }) : n;
2694
+ }
2695
+ return t(t({}, r), {
2696
+ schema: t(t({}, n), {
2697
+ primaryKey: s,
2698
+ indexes: a,
2699
+ getIndexByKeyPath: function(e) {
2700
+ return (e = i[en(e)]) && e[0];
2701
+ }
2702
+ }),
2703
+ count: function(e) {
2704
+ return r.count(d(e));
2705
+ },
2706
+ query: function(e) {
2707
+ return r.query(d(e));
2708
+ },
2709
+ openCursor: function(t) {
2710
+ var n = t.query.index, i = n.keyTail, a = n.keyLength;
2711
+ return n.isVirtual ? r.openCursor(d(t)).then(function(e) {
2712
+ return e && o(e);
2713
+ }) : r.openCursor(t);
2714
+ function o(n) {
2715
+ return Object.create(n, {
2716
+ continue: { value: function(r) {
2717
+ r == null ? t.unique ? n.continue(n.key.slice(0, a).concat(t.reverse ? e.MIN_KEY : e.MAX_KEY, i)) : n.continue() : n.continue(Bn(r, t.reverse ? e.MAX_KEY : e.MIN_KEY, i));
2718
+ } },
2719
+ continuePrimaryKey: { value: function(t, r) {
2720
+ n.continuePrimaryKey(Bn(t, e.MAX_KEY, i), r);
2721
+ } },
2722
+ primaryKey: { get: function() {
2723
+ return n.primaryKey;
2724
+ } },
2725
+ key: { get: function() {
2726
+ var e = n.key;
2727
+ return a === 1 ? e[0] : e.slice(0, a);
2728
+ } },
2729
+ value: { get: function() {
2730
+ return n.value;
2731
+ } }
2732
+ });
2733
+ }
2734
+ }
2735
+ });
2736
+ } });
2737
+ }
2738
+ };
2739
+ function Hn(e, t, n, r) {
2740
+ return n ||= {}, r ||= "", i(e).forEach(function(i) {
2741
+ var a, o, s;
2742
+ l(t, i) ? (a = e[i], o = t[i], typeof a == "object" && typeof o == "object" && a && o ? (s = ie(a)) === ie(o) ? s === "Object" ? Hn(a, o, n, r + i + ".") : a !== o && (n[r + i] = t[i]) : n[r + i] = t[i] : a !== o && (n[r + i] = t[i])) : n[r + i] = void 0;
2743
+ }), i(t).forEach(function(i) {
2744
+ l(e, i) || (n[r + i] = t[i]);
2745
+ }), n;
2746
+ }
2747
+ function Un(e, t) {
2748
+ return t.type === "delete" ? t.keys : t.keys || t.values.map(e.extractKey);
2749
+ }
2750
+ var Wn = {
2751
+ stack: "dbcore",
2752
+ name: "HooksMiddleware",
2753
+ level: 2,
2754
+ create: function(e) {
2755
+ return t(t({}, e), { table: function(r) {
2756
+ var i = e.table(r), a = i.schema.primaryKey;
2757
+ return t(t({}, i), { mutate: function(e) {
2758
+ var o = R.trans, s = o.table(r).hook, c = s.deleting, u = s.creating, d = s.updating;
2759
+ switch (e.type) {
2760
+ case "add":
2761
+ if (u.fire === j) break;
2762
+ return o._promise("readwrite", function() {
2763
+ return f(e);
2764
+ }, !0);
2765
+ case "put":
2766
+ if (u.fire === j && d.fire === j) break;
2767
+ return o._promise("readwrite", function() {
2768
+ return f(e);
2769
+ }, !0);
2770
+ case "delete":
2771
+ if (c.fire === j) break;
2772
+ return o._promise("readwrite", function() {
2773
+ return f(e);
2774
+ }, !0);
2775
+ case "deleteRange":
2776
+ if (c.fire === j) break;
2777
+ return o._promise("readwrite", function() {
2778
+ return function e(n, r, o) {
2779
+ return i.query({
2780
+ trans: n,
2781
+ values: !1,
2782
+ query: {
2783
+ index: a,
2784
+ range: r
2785
+ },
2786
+ limit: o
2787
+ }).then(function(i) {
2788
+ var a = i.result;
2789
+ return f({
2790
+ type: "delete",
2791
+ keys: a,
2792
+ trans: n
2793
+ }).then(function(i) {
2794
+ return 0 < i.numFailures ? Promise.reject(i.failures[0]) : a.length < o ? {
2795
+ failures: [],
2796
+ numFailures: 0,
2797
+ lastResult: void 0
2798
+ } : e(n, t(t({}, r), {
2799
+ lower: a[a.length - 1],
2800
+ lowerOpen: !0
2801
+ }), o);
2802
+ });
2803
+ });
2804
+ }(e.trans, e.range, 1e4);
2805
+ }, !0);
2806
+ }
2807
+ return i.mutate(e);
2808
+ function f(e) {
2809
+ var r, o, s, f = R.trans, p = e.keys || Un(a, e);
2810
+ if (p) return (e = e.type === "add" || e.type === "put" ? t(t({}, e), { keys: p }) : t({}, e)).type !== "delete" && (e.values = n([], e.values, !0)), e.keys &&= n([], e.keys, !0), r = i, s = p, ((o = e).type === "add" ? Promise.resolve([]) : r.getMany({
2811
+ trans: o.trans,
2812
+ keys: s,
2813
+ cache: "immutable"
2814
+ })).then(function(t) {
2815
+ var n = p.map(function(n, r) {
2816
+ var i, o, s, p = t[r], m = {
2817
+ onerror: null,
2818
+ onsuccess: null
2819
+ };
2820
+ return e.type === "delete" ? c.fire.call(m, n, p, f) : e.type === "add" || p === void 0 ? (i = u.fire.call(m, n, e.values[r], f), n == null && i != null && (e.keys[r] = n = i, a.outbound || x(e.values[r], a.keyPath, n))) : (i = Hn(p, e.values[r]), (o = d.fire.call(m, i, n, p, f)) && (s = e.values[r], Object.keys(o).forEach(function(e) {
2821
+ l(s, e) ? s[e] = o[e] : x(s, e, o[e]);
2822
+ }))), m;
2823
+ });
2824
+ return i.mutate(e).then(function(r) {
2825
+ for (var i = r.failures, a = r.results, o = r.numFailures, r = r.lastResult, s = 0; s < p.length; ++s) {
2826
+ var c = (a || p)[s], l = n[s];
2827
+ c == null ? l.onerror && l.onerror(i[s]) : l.onsuccess && l.onsuccess(e.type === "put" && t[s] ? e.values[s] : c);
2828
+ }
2829
+ return {
2830
+ failures: i,
2831
+ results: a,
2832
+ numFailures: o,
2833
+ lastResult: r
2834
+ };
2835
+ }).catch(function(e) {
2836
+ return n.forEach(function(t) {
2837
+ return t.onerror && t.onerror(e);
2838
+ }), Promise.reject(e);
2839
+ });
2840
+ });
2841
+ throw Error("Keys missing");
2842
+ }
2843
+ } });
2844
+ } });
2845
+ }
2846
+ };
2847
+ function Gn(e, t, n) {
2848
+ try {
2849
+ if (!t || t.keys.length < e.length) return null;
2850
+ for (var r = [], i = 0, a = 0; i < t.keys.length && a < e.length; ++i) W(t.keys[i], e[a]) === 0 && (r.push(n ? T(t.values[i]) : t.values[i]), ++a);
2851
+ return r.length === e.length ? r : null;
2852
+ } catch {
2853
+ return null;
2854
+ }
2855
+ }
2856
+ var Kn = {
2857
+ stack: "dbcore",
2858
+ level: -1,
2859
+ create: function(e) {
2860
+ return { table: function(n) {
2861
+ var r = e.table(n);
2862
+ return t(t({}, r), {
2863
+ getMany: function(e) {
2864
+ var t;
2865
+ return e.cache ? (t = Gn(e.keys, e.trans._cache, e.cache === "clone")) ? z.resolve(t) : r.getMany(e).then(function(t) {
2866
+ return e.trans._cache = {
2867
+ keys: e.keys,
2868
+ values: e.cache === "clone" ? T(t) : t
2869
+ }, t;
2870
+ }) : r.getMany(e);
2871
+ },
2872
+ mutate: function(e) {
2873
+ return e.type !== "add" && (e.trans._cache = null), r.mutate(e);
2874
+ }
2875
+ });
2876
+ } };
2877
+ }
2878
+ };
2879
+ function qn(e, t) {
2880
+ return e.trans.mode === "readonly" && !!e.subscr && !e.trans.explicit && e.trans.db._options.cache !== "disabled" && !t.schema.primaryKey.outbound;
2881
+ }
2882
+ function Jn(e, t) {
2883
+ switch (e) {
2884
+ case "query": return t.values && !t.unique;
2885
+ case "get":
2886
+ case "getMany":
2887
+ case "count":
2888
+ case "openCursor": return !1;
2889
+ }
2890
+ }
2891
+ var Yn = {
2892
+ stack: "dbcore",
2893
+ level: 0,
2894
+ name: "Observability",
2895
+ create: function(e) {
2896
+ var n = e.schema.name, r = new Z(e.MIN_KEY, e.MAX_KEY);
2897
+ return t(t({}, e), {
2898
+ transaction: function(t, n, r) {
2899
+ if (R.subscr && n !== "readonly") throw new A.ReadOnly(`Readwrite transaction in liveQuery context. Querier source: ${R.querier}`);
2900
+ return e.transaction(t, n, r);
2901
+ },
2902
+ table: function(o) {
2903
+ function s(t) {
2904
+ var t = t.query;
2905
+ return [t.index, new Z((t = t.range).lower ?? e.MIN_KEY, t.upper ?? e.MAX_KEY)];
2906
+ }
2907
+ var c = e.table(o), l = c.schema, u = l.primaryKey, d = l.indexes, f = u.extractKey, p = u.outbound, m = u.autoIncrement && d.filter(function(e) {
2908
+ return e.compound && e.keyPath.includes(u.keyPath);
2909
+ }), h = t(t({}, c), { mutate: function(t) {
2910
+ function i(e) {
2911
+ return e = `idb://${n}/${o}/${e}`, h[e] || (h[e] = new Z());
2912
+ }
2913
+ var s, d, f, p = t.trans, h = t.mutatedParts ||= {}, g = i(""), _ = i(":dels"), v = t.type, y = t.type === "deleteRange" ? [t.range] : t.type === "delete" ? [t.keys] : t.values.length < 50 ? [Un(u, t).filter(function(e) {
2914
+ return e;
2915
+ }), t.values] : [], b = y[0], y = y[1], x = t.trans._cache;
2916
+ return a(b) ? (g.addKeys(b), (v = v === "delete" || b.length === y.length ? Gn(b, x) : null) || _.addKeys(b), (v || y) && (s = i, d = v, f = y, l.indexes.forEach(function(e) {
2917
+ var t = s(e.name || "");
2918
+ function n(t) {
2919
+ return t == null ? null : e.extractKey(t);
2920
+ }
2921
+ function r(n) {
2922
+ e.multiEntry && a(n) ? n.forEach(function(e) {
2923
+ return t.addKey(e);
2924
+ }) : t.addKey(n);
2925
+ }
2926
+ (d || f).forEach(function(e, t) {
2927
+ var i = d && n(d[t]), t = f && n(f[t]);
2928
+ W(i, t) !== 0 && (i != null && r(i), t != null) && r(t);
2929
+ });
2930
+ }))) : b ? (y = {
2931
+ from: (x = b.lower) ?? e.MIN_KEY,
2932
+ to: (v = b.upper) ?? e.MAX_KEY
2933
+ }, _.add(y), g.add(y)) : (g.add(r), _.add(r), l.indexes.forEach(function(e) {
2934
+ return i(e.name).add(r);
2935
+ })), c.mutate(t).then(function(e) {
2936
+ return !b || t.type !== "add" && t.type !== "put" || (g.addKeys(e.results), m && m.forEach(function(n) {
2937
+ for (var r = t.values.map(function(e) {
2938
+ return n.extractKey(e);
2939
+ }), a = n.keyPath.findIndex(function(e) {
2940
+ return e === u.keyPath;
2941
+ }), o = 0, s = e.results.length; o < s; ++o) r[o][a] = e.results[o];
2942
+ i(n.name).addKeys(r);
2943
+ })), p.mutatedParts = An(p.mutatedParts || {}, h), e;
2944
+ });
2945
+ } }), g = {
2946
+ get: function(e) {
2947
+ return [u, new Z(e.key)];
2948
+ },
2949
+ getMany: function(e) {
2950
+ return [u, new Z().addKeys(e.keys)];
2951
+ },
2952
+ count: s,
2953
+ query: s,
2954
+ openCursor: s
2955
+ };
2956
+ return i(g).forEach(function(e) {
2957
+ h[e] = function(i) {
2958
+ var a = R.subscr, s = !!a, l = qn(R, c) && Jn(e, i) ? i.obsSet = {} : a;
2959
+ if (s) {
2960
+ var u, a = function(e) {
2961
+ return e = `idb://${n}/${o}/${e}`, l[e] || (l[e] = new Z());
2962
+ }, d = a(""), m = a(":dels"), s = g[e](i), h = s[0], s = s[1];
2963
+ if ((e === "query" && h.isPrimaryKey && !i.values ? m : a(h.name || "")).add(s), !h.isPrimaryKey) {
2964
+ if (e !== "count") return u = e === "query" && p && i.values && c.query(t(t({}, i), { values: !1 })), c[e].apply(this, arguments).then(function(t) {
2965
+ if (e === "query") {
2966
+ if (p && i.values) return u.then(function(e) {
2967
+ return e = e.result, d.addKeys(e), t;
2968
+ });
2969
+ var n = i.values ? t.result.map(f) : t.result;
2970
+ (i.values ? d : m).addKeys(n);
2971
+ } else {
2972
+ var r, a;
2973
+ if (e === "openCursor") return a = i.values, (r = t) && Object.create(r, {
2974
+ key: { get: function() {
2975
+ return m.addKey(r.primaryKey), r.key;
2976
+ } },
2977
+ primaryKey: { get: function() {
2978
+ var e = r.primaryKey;
2979
+ return m.addKey(e), e;
2980
+ } },
2981
+ value: { get: function() {
2982
+ return a && d.addKey(r.primaryKey), r.value;
2983
+ } }
2984
+ });
2985
+ }
2986
+ return t;
2987
+ });
2988
+ m.add(r);
2989
+ }
2990
+ }
2991
+ return c[e].apply(this, arguments);
2992
+ };
2993
+ }), h;
2994
+ }
2995
+ });
2996
+ }
2997
+ };
2998
+ function Xn(e, n, r) {
2999
+ var i;
3000
+ return r.numFailures === 0 ? n : n.type === "deleteRange" || (i = n.keys ? n.keys.length : "values" in n && n.values ? n.values.length : 1, r.numFailures === i) ? null : (i = t({}, n), a(i.keys) && (i.keys = i.keys.filter(function(e, t) {
3001
+ return !(t in r.failures);
3002
+ })), "values" in i && a(i.values) && (i.values = i.values.filter(function(e, t) {
3003
+ return !(t in r.failures);
3004
+ })), i);
3005
+ }
3006
+ function Zn(e, t) {
3007
+ return n = e, ((r = t).lower === void 0 || (r.lowerOpen ? 0 < W(n, r.lower) : 0 <= W(n, r.lower))) && (n = e, (r = t).upper === void 0 || (r.upperOpen ? W(n, r.upper) < 0 : W(n, r.upper) <= 0));
3008
+ var n, r;
3009
+ }
3010
+ function Qn(e, t, n, r, i, o) {
3011
+ var s, c, l, u, d, f, p;
3012
+ return !n || n.length === 0 || (s = t.query.index, c = s.multiEntry, l = t.query.range, u = r.schema.primaryKey.extractKey, d = s.extractKey, f = (s.lowLevelIndex || s).extractKey, (r = n.reduce(function(e, n) {
3013
+ var r = e, i = [];
3014
+ if (n.type === "add" || n.type === "put") for (var o = new Z(), s = n.values.length - 1; 0 <= s; --s) {
3015
+ var f, p = n.values[s], m = u(p);
3016
+ !o.hasKey(m) && (f = d(p), c && a(f) ? f.some(function(e) {
3017
+ return Zn(e, l);
3018
+ }) : Zn(f, l)) && (o.addKey(m), i.push(p));
3019
+ }
3020
+ switch (n.type) {
3021
+ case "add":
3022
+ var h = new Z().addKeys(t.values ? e.map(function(e) {
3023
+ return u(e);
3024
+ }) : e), r = e.concat(t.values ? i.filter(function(e) {
3025
+ return e = u(e), !h.hasKey(e) && (h.addKey(e), !0);
3026
+ }) : i.map(function(e) {
3027
+ return u(e);
3028
+ }).filter(function(e) {
3029
+ return !h.hasKey(e) && (h.addKey(e), !0);
3030
+ }));
3031
+ break;
3032
+ case "put":
3033
+ var g = new Z().addKeys(n.values.map(function(e) {
3034
+ return u(e);
3035
+ }));
3036
+ r = e.filter(function(e) {
3037
+ return !g.hasKey(t.values ? u(e) : e);
3038
+ }).concat(t.values ? i : i.map(function(e) {
3039
+ return u(e);
3040
+ }));
3041
+ break;
3042
+ case "delete":
3043
+ var _ = new Z().addKeys(n.keys);
3044
+ r = e.filter(function(e) {
3045
+ return !_.hasKey(t.values ? u(e) : e);
3046
+ });
3047
+ break;
3048
+ case "deleteRange":
3049
+ var v = n.range;
3050
+ r = e.filter(function(e) {
3051
+ return !Zn(u(e), v);
3052
+ });
3053
+ }
3054
+ return r;
3055
+ }, e)) === e) ? e : (p = function(e, t) {
3056
+ return W(f(e), f(t)) || W(u(e), u(t));
3057
+ }, r.sort(t.direction === "prev" || t.direction === "prevunique" ? function(e, t) {
3058
+ return p(t, e);
3059
+ } : p), t.limit && t.limit < Infinity && (r.length > t.limit ? r.length = t.limit : e.length === t.limit && r.length < t.limit && (i.dirty = !0)), o ? Object.freeze(r) : r);
3060
+ }
3061
+ function $n(e, t) {
3062
+ return W(e.lower, t.lower) === 0 && W(e.upper, t.upper) === 0 && !!e.lowerOpen == !!t.lowerOpen && !!e.upperOpen == !!t.upperOpen;
3063
+ }
3064
+ function er(e, t) {
3065
+ return ((e, t, n, r) => {
3066
+ if (e === void 0) return t === void 0 ? 0 : -1;
3067
+ if (t === void 0) return 1;
3068
+ if ((e = W(e, t)) === 0) {
3069
+ if (n && r) return 0;
3070
+ if (n) return 1;
3071
+ if (r) return -1;
3072
+ }
3073
+ return e;
3074
+ })(e.lower, t.lower, e.lowerOpen, t.lowerOpen) <= 0 && 0 <= ((e, t, n, r) => {
3075
+ if (e === void 0) return t === void 0 ? 0 : 1;
3076
+ if (t === void 0) return -1;
3077
+ if ((e = W(e, t)) === 0) {
3078
+ if (n && r) return 0;
3079
+ if (n) return -1;
3080
+ if (r) return 1;
3081
+ }
3082
+ return e;
3083
+ })(e.upper, t.upper, e.upperOpen, t.upperOpen);
3084
+ }
3085
+ function tr(e, t, n, r) {
3086
+ e.subscribers.add(n), r.addEventListener("abort", function() {
3087
+ var r, i;
3088
+ e.subscribers.delete(n), e.subscribers.size === 0 && (r = e, i = t, setTimeout(function() {
3089
+ r.subscribers.size === 0 && E(i, r);
3090
+ }, 3e3));
3091
+ });
3092
+ }
3093
+ var nr = {
3094
+ stack: "dbcore",
3095
+ level: 0,
3096
+ name: "Cache",
3097
+ create: function(e) {
3098
+ var n = e.schema.name;
3099
+ return t(t({}, e), {
3100
+ transaction: function(t, r, i) {
3101
+ var a, o, s = e.transaction(t, r, i);
3102
+ return r === "readwrite" && (i = (a = new AbortController()).signal, s.addEventListener("abort", (o = function(i) {
3103
+ return function() {
3104
+ if (a.abort(), r === "readwrite") {
3105
+ for (var o = /* @__PURE__ */ new Set(), c = 0, l = t; c < l.length; c++) {
3106
+ var u = l[c], d = Mn[`idb://${n}/${u}`];
3107
+ if (d) {
3108
+ var f = e.table(u), p = d.optimisticOps.filter(function(e) {
3109
+ return e.trans === s;
3110
+ });
3111
+ if (s._explicit && i && s.mutatedParts) for (var m = 0, h = Object.values(d.queries.query); m < h.length; m++) for (var g = 0, _ = (b = h[m]).slice(); g < _.length; g++) jn((x = _[g]).obsSet, s.mutatedParts) && (E(b, x), x.subscribers.forEach(function(e) {
3112
+ return o.add(e);
3113
+ }));
3114
+ else if (0 < p.length) {
3115
+ d.optimisticOps = d.optimisticOps.filter(function(e) {
3116
+ return e.trans !== s;
3117
+ });
3118
+ for (var v = 0, y = Object.values(d.queries.query); v < y.length; v++) for (var b, x, S, C = 0, ee = (b = y[v]).slice(); C < ee.length; C++) (x = ee[C]).res != null && s.mutatedParts && (i && !x.dirty ? (S = Object.isFrozen(x.res), S = Qn(x.res, x.req, p, f, x, S), x.dirty ? (E(b, x), x.subscribers.forEach(function(e) {
3119
+ return o.add(e);
3120
+ })) : S !== x.res && (x.res = S, x.promise = z.resolve({ result: S }))) : (x.dirty && E(b, x), x.subscribers.forEach(function(e) {
3121
+ return o.add(e);
3122
+ })));
3123
+ }
3124
+ }
3125
+ }
3126
+ o.forEach(function(e) {
3127
+ return e();
3128
+ });
3129
+ }
3130
+ };
3131
+ })(!1), { signal: i }), s.addEventListener("error", o(!1), { signal: i }), s.addEventListener("complete", o(!0), { signal: i })), s;
3132
+ },
3133
+ table: function(r) {
3134
+ var i = e.table(r), a = i.schema.primaryKey;
3135
+ return t(t({}, i), {
3136
+ mutate: function(e) {
3137
+ var o, s = R.trans;
3138
+ return !a.outbound && s.db._options.cache !== "disabled" && !s.explicit && s.idbtrans.mode === "readwrite" && (o = Mn[`idb://${n}/${r}`]) ? (s = i.mutate(e), e.type !== "add" && e.type !== "put" || !(50 <= e.values.length || Un(a, e).some(function(e) {
3139
+ return e == null;
3140
+ })) ? (o.optimisticOps.push(e), e.mutatedParts && Fn(e.mutatedParts), s.then(function(t) {
3141
+ 0 < t.numFailures && (E(o.optimisticOps, e), (t = Xn(0, e, t)) && o.optimisticOps.push(t), e.mutatedParts) && Fn(e.mutatedParts);
3142
+ }), s.catch(function() {
3143
+ E(o.optimisticOps, e), e.mutatedParts && Fn(e.mutatedParts);
3144
+ })) : s.then(function(n) {
3145
+ var r = Xn(0, t(t({}, e), { values: e.values.map(function(e, r) {
3146
+ var i;
3147
+ return n.failures[r] ? e : (x(i = (i = a.keyPath) != null && i.includes(".") ? T(e) : t({}, e), a.keyPath, n.results[r]), i);
3148
+ }) }), n);
3149
+ o.optimisticOps.push(r), queueMicrotask(function() {
3150
+ return e.mutatedParts && Fn(e.mutatedParts);
3151
+ });
3152
+ }), s) : i.mutate(e);
3153
+ },
3154
+ query: function(e) {
3155
+ var t, a, o, s, c, l, u;
3156
+ return qn(R, i) && Jn("query", e) ? (t = (o = R.trans)?.db._options.cache === "immutable", a = (o = R).requery, o = o.signal, l = ((e, t, n, r) => {
3157
+ var i = Mn[`idb://${e}/${t}`];
3158
+ if (!i) return [];
3159
+ if (!(e = i.queries[n])) return [
3160
+ null,
3161
+ !1,
3162
+ i,
3163
+ null
3164
+ ];
3165
+ var a = e[(r.query ? r.query.index.name : null) || ""];
3166
+ if (!a) return [
3167
+ null,
3168
+ !1,
3169
+ i,
3170
+ null
3171
+ ];
3172
+ var o = (s = r.direction) ?? "next", s = a.find(function(e) {
3173
+ return e.req.limit === r.limit && e.req.values === r.values && (e.req.direction ?? "next") === o && $n(e.req.query.range, r.query.range);
3174
+ });
3175
+ return s ? [
3176
+ s,
3177
+ !0,
3178
+ i,
3179
+ a
3180
+ ] : [
3181
+ a.find(function(e) {
3182
+ return ("limit" in e.req ? e.req.limit : Infinity) >= r.limit && (e.req.direction ?? "next") === o && (!r.values || e.req.values) && er(e.req.query.range, r.query.range);
3183
+ }),
3184
+ !1,
3185
+ i,
3186
+ a
3187
+ ];
3188
+ })(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) {
3189
+ var n = e.result;
3190
+ if (u && (u.res = n), t) {
3191
+ for (var r = 0, i = n.length; r < i; ++r) Object.freeze(n[r]);
3192
+ Object.freeze(n);
3193
+ }
3194
+ return e;
3195
+ }).catch(function(e) {
3196
+ return c && u && E(c, u), Promise.reject(e);
3197
+ }), u = {
3198
+ obsSet: e.obsSet,
3199
+ promise: l,
3200
+ subscribers: /* @__PURE__ */ new Set(),
3201
+ type: "query",
3202
+ req: e,
3203
+ dirty: !1
3204
+ }, c ? c.push(u) : (c = [u], (s ||= Mn[`idb://${n}/${r}`] = {
3205
+ queries: {
3206
+ query: {},
3207
+ count: {}
3208
+ },
3209
+ objs: /* @__PURE__ */ new Map(),
3210
+ optimisticOps: [],
3211
+ unsignaledParts: {}
3212
+ }).queries.query[e.query.index.name || ""] = c)), tr(u, c, a, o), u.promise.then(function(n) {
3213
+ return n = Qn(n.result, e, s?.optimisticOps, i, u, t), { result: t ? n : T(n) };
3214
+ })) : i.query(e);
3215
+ }
3216
+ });
3217
+ }
3218
+ });
3219
+ }
3220
+ };
3221
+ function rr(e, t) {
3222
+ return new Proxy(e, { get: function(e, n, r) {
3223
+ return n === "db" ? t : Reflect.get(e, n, r);
3224
+ } });
3225
+ }
3226
+ $.prototype.version = function(e) {
3227
+ if (isNaN(e) || e < .1) throw new A.Type("Given version is not a positive number");
3228
+ if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened) throw new A.Schema("Cannot add version when database is open");
3229
+ this.verno = Math.max(this.verno, e);
3230
+ var t = this._versions, n = t.filter(function(t) {
3231
+ return t._cfg.version === e;
3232
+ })[0];
3233
+ return n || (n = new this.Version(e), t.push(n), t.sort(sn), n.stores({}), this._state.autoSchema = !1), n;
3234
+ }, $.prototype._whenReady = function(e) {
3235
+ var t = this;
3236
+ return this.idbdb && (this._state.openComplete || R.letThrough || this._vip) ? e() : new z(function(e, n) {
3237
+ if (t._state.openComplete) return n(new A.DatabaseClosed(t._state.dbOpenError));
3238
+ if (!t._state.isBeingOpened) {
3239
+ if (!t._state.autoOpen) return void n(new A.DatabaseClosed());
3240
+ t.open().catch(j);
3241
+ }
3242
+ t._state.dbReadyPromise.then(e, n);
3243
+ }).then(e);
3244
+ }, $.prototype.use = function(e) {
3245
+ var t = e.stack, n = e.create, r = e.level, e = e.name, i = (e && this.unuse({
3246
+ stack: t,
3247
+ name: e
3248
+ }), this._middlewares[t] || (this._middlewares[t] = []));
3249
+ return i.push({
3250
+ stack: t,
3251
+ create: n,
3252
+ level: r ?? 10,
3253
+ name: e
3254
+ }), i.sort(function(e, t) {
3255
+ return e.level - t.level;
3256
+ }), this;
3257
+ }, $.prototype.unuse = function(e) {
3258
+ var t = e.stack, n = e.name, r = e.create;
3259
+ return t && this._middlewares[t] && (this._middlewares[t] = this._middlewares[t].filter(function(e) {
3260
+ return r ? e.create !== r : !!n && e.name !== n;
3261
+ })), this;
3262
+ }, $.prototype.open = function() {
3263
+ var e = this;
3264
+ return at(L, function() {
3265
+ return Rn(e);
3266
+ });
3267
+ }, $.prototype._close = function() {
3268
+ this.on.close.fire(new CustomEvent("close"));
3269
+ var e = this._state;
3270
+ if (yn.remove(this), this.idbdb) {
3271
+ try {
3272
+ this.idbdb.close();
3273
+ } catch {}
3274
+ this.idbdb = null;
3275
+ }
3276
+ e.isBeingOpened || (e.dbReadyPromise = new z(function(t) {
3277
+ e.dbReadyResolve = t;
3278
+ }), e.openCanceller = new z(function(t, n) {
3279
+ e.cancelOpen = n;
3280
+ }));
3281
+ }, $.prototype.close = function(e) {
3282
+ var e = (e === void 0 ? { disableAutoOpen: !0 } : e).disableAutoOpen, t = this._state;
3283
+ e ? (t.isBeingOpened && t.cancelOpen(new A.DatabaseClosed()), this._close(), t.autoOpen = !1, t.dbOpenError = new A.DatabaseClosed()) : (this._close(), t.autoOpen = this._options.autoOpen || t.isBeingOpened, t.openComplete = !1, t.dbOpenError = null);
3284
+ }, $.prototype.delete = function(e) {
3285
+ var t = this, n = (e === void 0 && (e = { disableAutoOpen: !0 }), 0 < arguments.length && typeof arguments[0] != "object"), r = this._state;
3286
+ return new z(function(i, a) {
3287
+ function o() {
3288
+ t.close(e);
3289
+ var n = t._deps.indexedDB.deleteDatabase(t.name);
3290
+ n.onsuccess = B(function() {
3291
+ var e = t._deps, n = t.name, r;
3292
+ xn(r = e.indexedDB) || n === ut || bn(r, e.IDBKeyRange).delete(n).catch(j), i();
3293
+ }), n.onerror = Y(a), n.onblocked = t._fireOnBlocked;
3294
+ }
3295
+ if (n) throw new A.InvalidArgument("Invalid closeOptions argument to db.delete()");
3296
+ r.isBeingOpened ? r.dbReadyPromise.then(o) : o();
3297
+ });
3298
+ }, $.prototype.backendDB = function() {
3299
+ return this.idbdb;
3300
+ }, $.prototype.isOpen = function() {
3301
+ return this.idbdb !== null;
3302
+ }, $.prototype.hasBeenClosed = function() {
3303
+ var e = this._state.dbOpenError;
3304
+ return e && e.name === "DatabaseClosed";
3305
+ }, $.prototype.hasFailed = function() {
3306
+ return this._state.dbOpenError !== null;
3307
+ }, $.prototype.dynamicallyOpened = function() {
3308
+ return this._state.autoSchema;
3309
+ }, Object.defineProperty($.prototype, "tables", {
3310
+ get: function() {
3311
+ var e = this;
3312
+ return i(this._allTables).map(function(t) {
3313
+ return e._allTables[t];
3314
+ });
3315
+ },
3316
+ enumerable: !1,
3317
+ configurable: !0
3318
+ }), $.prototype.transaction = function() {
3319
+ var e = function(e, t, n) {
3320
+ var r = arguments.length;
3321
+ if (r < 2) throw new A.InvalidArgument("Too few arguments");
3322
+ for (var i = Array(r - 1); --r;) i[r - 1] = arguments[r];
3323
+ return n = i.pop(), [
3324
+ e,
3325
+ ee(i),
3326
+ n
3327
+ ];
3328
+ }.apply(this, arguments);
3329
+ return this._transaction.apply(this, e);
3330
+ }, $.prototype._transaction = function(e, t, n) {
3331
+ var r, i, a = this, o = R.trans, s = (o && o.db === this && e.indexOf("!") === -1 || (o = null), e.indexOf("?") !== -1);
3332
+ e = e.replace("!", "").replace("?", "");
3333
+ try {
3334
+ if (i = t.map(function(e) {
3335
+ if (e = e instanceof a.Table ? e.name : e, typeof e != "string") throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
3336
+ return e;
3337
+ }), e == "r" || e === dt) r = dt;
3338
+ else {
3339
+ if (e != "rw" && e != ft) throw new A.InvalidArgument("Invalid transaction mode: " + e);
3340
+ r = ft;
3341
+ }
3342
+ if (o) {
3343
+ if (o.mode === dt && r === ft) {
3344
+ if (!s) throw new A.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
3345
+ o = null;
3346
+ }
3347
+ o && i.forEach(function(e) {
3348
+ if (o && o.storeNames.indexOf(e) === -1) {
3349
+ if (!s) throw new A.SubTransaction("Table " + e + " not included in parent transaction.");
3350
+ o = null;
3351
+ }
3352
+ }), s && o && !o.active && (o = null);
3353
+ }
3354
+ } catch (e) {
3355
+ return o ? o._promise(null, function(t, n) {
3356
+ n(e);
3357
+ }) : H(e);
3358
+ }
3359
+ var c = function e(t, n, r, i, a) {
3360
+ return z.resolve().then(function() {
3361
+ var o = R.transless || R, s = t._createTransaction(n, r, t._dbSchema, i), o = (s.explicit = !0, {
3362
+ trans: s,
3363
+ transless: o
3364
+ });
3365
+ if (i) s.idbtrans = i.idbtrans;
3366
+ else try {
3367
+ s.create(), s.idbtrans._explicit = !0, t._state.PR1398_maxLoop = 3;
3368
+ } catch (i) {
3369
+ return i.name === pe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
3370
+ return e(t, n, r, null, a);
3371
+ })) : H(i);
3372
+ }
3373
+ var c, l = se(a), o = (l && $e(), z.follow(function() {
3374
+ var e;
3375
+ (c = a.call(s, s)) && (l ? (e = et.bind(null, null), c.then(e, e)) : typeof c.next == "function" && typeof c.throw == "function" && (c = zn(c)));
3376
+ }, o));
3377
+ return (c && typeof c.then == "function" ? z.resolve(c).then(function(e) {
3378
+ return s.active ? e : H(new A.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"));
3379
+ }) : o.then(function() {
3380
+ return c;
3381
+ })).then(function(e) {
3382
+ return i && s._resolve(), s._completion.then(function() {
3383
+ return e;
3384
+ });
3385
+ }).catch(function(e) {
3386
+ return s._reject(e), H(e);
3387
+ });
3388
+ });
3389
+ }.bind(null, this, r, i, o, n);
3390
+ return o ? o._promise(r, c, "lock") : R.trans ? at(R.transless, function() {
3391
+ return a._whenReady(c);
3392
+ }) : this._whenReady(c);
3393
+ }, $.prototype.table = function(e) {
3394
+ if (l(this._allTables, e)) return this._allTables[e];
3395
+ throw new A.InvalidTable(`Table ${e} does not exist`);
3396
+ };
3397
+ var Q = $;
3398
+ function $(e, n) {
3399
+ var r, i, a, o, s, c = this, l = (this._middlewares = {}, this.verno = 0, $.dependencies), l = (this._options = n = t({
3400
+ addons: $.addons,
3401
+ autoOpen: !0,
3402
+ indexedDB: l.indexedDB,
3403
+ IDBKeyRange: l.IDBKeyRange,
3404
+ cache: "cloned",
3405
+ maxConnections: 1e3
3406
+ }, n), this._deps = {
3407
+ indexedDB: n.indexedDB,
3408
+ IDBKeyRange: n.IDBKeyRange
3409
+ }, n.addons), u = (this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this, {
3410
+ dbOpenError: null,
3411
+ isBeingOpened: !1,
3412
+ onReadyBeingFired: null,
3413
+ openComplete: !1,
3414
+ dbReadyResolve: j,
3415
+ dbReadyPromise: null,
3416
+ cancelOpen: j,
3417
+ openCanceller: null,
3418
+ autoSchema: !0,
3419
+ PR1398_maxLoop: 3,
3420
+ autoOpen: n.autoOpen
3421
+ }), d = (u.dbReadyPromise = new z(function(e) {
3422
+ u.dbReadyResolve = e;
3423
+ }), u.openCanceller = new z(function(e, t) {
3424
+ u.cancelOpen = t;
3425
+ }), this._state = u, this.name = e, this.on = wt(this, "populate", "blocked", "versionchange", "close", { ready: [xe, j] }), this.once = function(e, t) {
3426
+ var n = function() {
3427
+ var r = [...arguments];
3428
+ c.on(e).unsubscribe(n), t.apply(c, r);
3429
+ };
3430
+ return c.on(e, n);
3431
+ }, this.on.ready.subscribe = _(this.on.ready.subscribe, function(e) {
3432
+ return function(t, n) {
3433
+ $.vip(function() {
3434
+ var r, i = c._state;
3435
+ i.openComplete ? (i.dbOpenError || z.resolve().then(t), n && e(t)) : i.onReadyBeingFired ? (i.onReadyBeingFired.push(t), n && e(t)) : (e(t), r = c, n || e(function e() {
3436
+ r.on.ready.unsubscribe(t), r.on.ready.unsubscribe(e);
3437
+ }));
3438
+ });
3439
+ };
3440
+ }), this.Collection = (r = this, Tt(Nt.prototype, function(e, t) {
3441
+ this.db = r;
3442
+ var n = mt, i = null;
3443
+ if (t) try {
3444
+ n = t();
3445
+ } catch (e) {
3446
+ i = e;
3447
+ }
3448
+ var t = e._ctx, e = t.table, a = e.hook.reading.fire;
3449
+ this._ctx = {
3450
+ table: e,
3451
+ index: t.index,
3452
+ isPrimKey: !t.index || e.schema.primKey.keyPath && t.index === e.schema.primKey.name,
3453
+ range: n,
3454
+ keysOnly: !1,
3455
+ dir: "next",
3456
+ unique: "",
3457
+ algorithm: null,
3458
+ filter: null,
3459
+ replayFilter: null,
3460
+ justLimit: !0,
3461
+ isMatch: null,
3462
+ offset: 0,
3463
+ limit: Infinity,
3464
+ error: i,
3465
+ or: t.or,
3466
+ valueMapper: a === M ? null : a
3467
+ };
3468
+ })), this.Table = (i = this, Tt(Ct.prototype, function(e, t, n) {
3469
+ this.db = i, this._tx = n, this.name = e, this.schema = t, this.hook = i._allTables[e] ? i._allTables[e].hook : wt(null, {
3470
+ creating: [_e, j],
3471
+ reading: [ge, M],
3472
+ updating: [ye, j],
3473
+ deleting: [ve, j]
3474
+ });
3475
+ })), this.Transaction = (a = this, Tt(Kt.prototype, function(e, t, n, r, i) {
3476
+ var o = this;
3477
+ e !== "readonly" && t.forEach(function(e) {
3478
+ e = (e = n[e])?.yProps, e && (t = t.concat(e.map(function(e) {
3479
+ return e.updatesTable;
3480
+ })));
3481
+ }), this.db = a, this.mode = e, this.storeNames = t, this.schema = n, this.chromeTransactionDurability = r, this.idbtrans = null, this.on = wt(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 z(function(e, t) {
3482
+ o._resolve = e, o._reject = t;
3483
+ }), this._completion.then(function() {
3484
+ o.active = !1, o.on.complete.fire();
3485
+ }, function(e) {
3486
+ var t = o.active;
3487
+ return o.active = !1, o.on.error.fire(e), o.parent ? o.parent._reject(e) : t && o.idbtrans && o.idbtrans.abort(), H(e);
3488
+ });
3489
+ })), this.Version = (o = this, Tt(_n.prototype, function(e) {
3490
+ this.db = o, this._cfg = {
3491
+ version: e,
3492
+ storesSource: null,
3493
+ dbschema: {},
3494
+ tables: {},
3495
+ contentUpgrade: null
3496
+ };
3497
+ })), this.WhereClause = (s = this, Tt(Vt.prototype, function(e, t, n) {
3498
+ if (this.db = s, this._ctx = {
3499
+ table: e,
3500
+ index: t === ":id" ? null : t,
3501
+ or: n
3502
+ }, this._cmp = this._ascending = W, this._descending = function(e, t) {
3503
+ return W(t, e);
3504
+ }, this._max = function(e, t) {
3505
+ return 0 < W(e, t) ? e : t;
3506
+ }, this._min = function(e, t) {
3507
+ return W(e, t) < 0 ? e : t;
3508
+ }, this._IDBKeyRange = s._deps.IDBKeyRange, !this._IDBKeyRange) throw new A.MissingAPI();
3509
+ })), this.on("versionchange", function(e) {
3510
+ 0 < e.newVersion ? console.warn(`Another connection wants to upgrade database '${c.name}'. Closing db now to resume the upgrade.`) : console.warn(`Another connection wants to delete database '${c.name}'. Closing db now to resume the delete request.`), c.close({ disableAutoOpen: !1 });
3511
+ }), this.on("blocked", function(e) {
3512
+ !e.newVersion || e.newVersion < e.oldVersion ? console.warn(`Dexie.delete('${c.name}') was blocked`) : console.warn(`Upgrade '${c.name}' blocked by other connection holding version ${e.oldVersion / 10}`);
3513
+ }), this._maxKey = Xt(n.IDBKeyRange), this._createTransaction = function(e, t, n, r) {
3514
+ return new c.Transaction(e, t, n, c._options.chromeTransactionDurability, r);
3515
+ }, this._fireOnBlocked = function(e) {
3516
+ c.on("blocked").fire(e), yn.toArray().filter(function(e) {
3517
+ return e.name === c.name && e !== c && !e._state.vcFired;
3518
+ }).map(function(t) {
3519
+ return t.on("versionchange").fire(e);
3520
+ });
3521
+ }, this.use(Kn), this.use(nr), this.use(Yn), this.use(Vn), this.use(Wn), new Proxy(this, { get: function(e, t, n) {
3522
+ var r;
3523
+ return t === "_vip" || (t === "table" ? function(e) {
3524
+ return rr(c.table(e), d);
3525
+ } : (r = Reflect.get(e, t, n)) instanceof Ct ? rr(r, d) : t === "tables" ? r.map(function(e) {
3526
+ return rr(e, d);
3527
+ }) : t === "_createTransaction" ? function() {
3528
+ return rr(r.apply(this, arguments), d);
3529
+ } : r);
3530
+ } }));
3531
+ this.vip = d, l.forEach(function(e) {
3532
+ return e(c);
3533
+ });
3534
+ }
3535
+ var ir, Te = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable", ar = (or.prototype.subscribe = function(e, t, n) {
3536
+ return this._subscribe(e && typeof e != "function" ? e : {
3537
+ next: e,
3538
+ error: t,
3539
+ complete: n
3540
+ });
3541
+ }, or.prototype[Te] = function() {
3542
+ return this;
3543
+ }, or);
3544
+ function or(e) {
3545
+ this._subscribe = e;
3546
+ }
3547
+ try {
3548
+ ir = {
3549
+ indexedDB: r.indexedDB || r.mozIndexedDB || r.webkitIndexedDB || r.msIndexedDB,
3550
+ IDBKeyRange: r.IDBKeyRange || r.webkitIDBKeyRange
3551
+ };
3552
+ } catch {
3553
+ ir = {
3554
+ indexedDB: null,
3555
+ IDBKeyRange: null
3556
+ };
3557
+ }
3558
+ function sr(e) {
3559
+ var t, n = !1, r = new ar(function(r) {
3560
+ var i = se(e), a, o = !1, s = {}, c = {}, l = {
3561
+ get closed() {
3562
+ return o;
3563
+ },
3564
+ unsubscribe: function() {
3565
+ o || (o = !0, a && a.abort(), u && Gt.storagemutated.unsubscribe(p));
3566
+ }
3567
+ }, u = (r.start && r.start(l), !1), d = function() {
3568
+ return st(m);
3569
+ };
3570
+ function f() {
3571
+ return jn(c, s);
3572
+ }
3573
+ var p = function(e) {
3574
+ An(s, e), f() && d();
3575
+ }, m = function() {
3576
+ var l, m, h;
3577
+ !o && ir.indexedDB && (s = {}, l = {}, a && a.abort(), a = new AbortController(), h = ((t) => {
3578
+ var n = Ue();
3579
+ try {
3580
+ i && $e();
3581
+ var r = Qe(e, t);
3582
+ return r = i ? r.finally(et) : r;
3583
+ } finally {
3584
+ n && We();
3585
+ }
3586
+ })(m = {
3587
+ subscr: l,
3588
+ signal: a.signal,
3589
+ requery: d,
3590
+ querier: e,
3591
+ trans: null
3592
+ }), u ||= (Gt.storagemutated.subscribe(p), !0), Promise.resolve(h).then(function(e) {
3593
+ n = !0, t = e, o || m.signal.aborted || (f() || (c = l, f()) ? d() : (s = {}, st(function() {
3594
+ return !o && r.next && r.next(e);
3595
+ })));
3596
+ }, function(e) {
3597
+ n = !1, ["DatabaseClosedError", "AbortError"].includes(e?.name) || o || st(function() {
3598
+ o || r.error && r.error(e);
3599
+ });
3600
+ }));
3601
+ };
3602
+ return setTimeout(d, 0), l;
3603
+ });
3604
+ return r.hasValue = function() {
3605
+ return n;
3606
+ }, r.getValue = function() {
3607
+ return t;
3608
+ }, r;
3609
+ }
3610
+ var cr = Q;
3611
+ function lr(e) {
3612
+ var t = dr;
3613
+ try {
3614
+ dr = !0, Gt.storagemutated.fire(e), In(e, !0);
3615
+ } finally {
3616
+ dr = t;
3617
+ }
3618
+ }
3619
+ u(cr, t(t({}, w), {
3620
+ delete: function(e) {
3621
+ return new cr(e, { addons: [] }).delete();
3622
+ },
3623
+ exists: function(e) {
3624
+ return new cr(e, { addons: [] }).open().then(function(e) {
3625
+ return e.close(), !0;
3626
+ }).catch("NoSuchDatabaseError", function() {
3627
+ return !1;
3628
+ });
3629
+ },
3630
+ getDatabaseNames: function(e) {
3631
+ try {
3632
+ return t = cr.dependencies, n = t.indexedDB, t = t.IDBKeyRange, (xn(n) ? Promise.resolve(n.databases()).then(function(e) {
3633
+ return e.map(function(e) {
3634
+ return e.name;
3635
+ }).filter(function(e) {
3636
+ return e !== ut;
3637
+ });
3638
+ }) : bn(n, t).toCollection().primaryKeys()).then(e);
3639
+ } catch {
3640
+ return H(new A.MissingAPI());
3641
+ }
3642
+ var t, n;
3643
+ },
3644
+ defineClass: function() {
3645
+ return function(e) {
3646
+ o(this, e);
3647
+ };
3648
+ },
3649
+ ignoreTransaction: function(e) {
3650
+ return R.trans ? at(R.transless || L, e) : e();
3651
+ },
3652
+ vip: Sn,
3653
+ async: function(e) {
3654
+ return function() {
3655
+ try {
3656
+ var t = zn(e.apply(this, arguments));
3657
+ return t && typeof t.then == "function" ? t : z.resolve(t);
3658
+ } catch (e) {
3659
+ return H(e);
3660
+ }
3661
+ };
3662
+ },
3663
+ spawn: function(e, t, n) {
3664
+ try {
3665
+ var r = zn(e.apply(n, t || []));
3666
+ return r && typeof r.then == "function" ? r : z.resolve(r);
3667
+ } catch (e) {
3668
+ return H(e);
3669
+ }
3670
+ },
3671
+ currentTransaction: { get: function() {
3672
+ return R.trans || null;
3673
+ } },
3674
+ waitFor: function(e, t) {
3675
+ return e = z.resolve(typeof e == "function" ? cr.ignoreTransaction(e) : e).timeout(t || 6e4), R.trans ? R.trans.waitFor(e) : e;
3676
+ },
3677
+ Promise: z,
3678
+ debug: {
3679
+ get: function() {
3680
+ return P;
3681
+ },
3682
+ set: function(e) {
3683
+ Se(e);
3684
+ }
3685
+ },
3686
+ derive: p,
3687
+ extend: o,
3688
+ props: u,
3689
+ override: _,
3690
+ Events: wt,
3691
+ on: Gt,
3692
+ liveQuery: sr,
3693
+ extendObservabilitySet: An,
3694
+ getByKeyPath: b,
3695
+ setByKeyPath: x,
3696
+ delByKeyPath: function(e, t) {
3697
+ typeof t == "string" ? x(e, t, void 0) : "length" in t && [].map.call(t, function(t) {
3698
+ x(e, t, void 0);
3699
+ });
3700
+ },
3701
+ shallowClone: S,
3702
+ deepClone: T,
3703
+ getObjectDiff: Hn,
3704
+ cmp: W,
3705
+ asap: y,
3706
+ minKey: -Infinity,
3707
+ addons: [],
3708
+ connections: { get: yn.toArray },
3709
+ errnames: pe,
3710
+ dependencies: ir,
3711
+ cache: Mn,
3712
+ semVer: "4.4.6",
3713
+ version: "4.4.6".split(".").map(function(e) {
3714
+ return parseInt(e);
3715
+ }).reduce(function(e, t, n) {
3716
+ return e + t / 10 ** (2 * n);
3717
+ })
3718
+ })), cr.maxKey = Xt(cr.dependencies.IDBKeyRange), typeof dispatchEvent < "u" && typeof addEventListener < "u" && (Gt(Ut, function(e) {
3719
+ dr ||= (e = new CustomEvent(Wt, { detail: e }), dr = !0, dispatchEvent(e), !1);
3720
+ }), addEventListener(Wt, function(e) {
3721
+ e = e.detail, dr || lr(e);
3722
+ }));
3723
+ var ur, dr = !1, fr = function() {};
3724
+ return typeof BroadcastChannel < "u" && ((fr = function() {
3725
+ (ur = new BroadcastChannel(Wt)).onmessage = function(e) {
3726
+ return e.data && lr(e.data);
3727
+ };
3728
+ })(), typeof ur.unref == "function" && ur.unref(), Gt(Ut, function(e) {
3729
+ dr || ur.postMessage(e);
3730
+ })), typeof addEventListener < "u" && (addEventListener("pagehide", function(e) {
3731
+ if (!Q.disableBfCache && e.persisted) {
3732
+ P && console.debug("Dexie: handling persisted pagehide"), ur?.close();
3733
+ for (var t = 0, n = yn.toArray(); t < n.length; t++) n[t].close({ disableAutoOpen: !1 });
3734
+ }
3735
+ }), addEventListener("pageshow", function(e) {
3736
+ !Q.disableBfCache && e.persisted && (P && console.debug("Dexie: handling persisted pageshow"), fr(), lr({ all: new Z(-Infinity, [[]]) }));
3737
+ })), z.rejectionMapper = function(e, t) {
3738
+ return !e || e instanceof le || e instanceof TypeError || e instanceof SyntaxError || !e.name || !he[e.name] ? e : (t = new he[e.name](t || e.message, e), "stack" in e && f(t, "stack", { get: function() {
3739
+ return this.inner.stack;
3740
+ } }), t);
3741
+ }, Se(P), t(Q, Object.freeze({
3742
+ __proto__: null,
3743
+ DEFAULT_MAX_CONNECTIONS: 1e3,
3744
+ Dexie: Q,
3745
+ Entity: gt,
3746
+ PropModification: bt,
3747
+ RangeSet: Z,
3748
+ add: function(e) {
3749
+ return new bt({ add: e });
3750
+ },
3751
+ cmp: W,
3752
+ default: Q,
3753
+ liveQuery: sr,
3754
+ mergeRanges: Tn,
3755
+ rangesOverlap: En,
3756
+ remove: function(e) {
3757
+ return new bt({ remove: e });
3758
+ },
3759
+ replacePrefix: function(e, t) {
3760
+ return new bt({ replacePrefix: [e, t] });
3761
+ }
3762
+ }), { default: Q }), Q;
3763
+ });
3764
+ })))(), 1), D = Symbol.for("Dexie"), O = globalThis[D] || (globalThis[D] = E.default);
3765
+ if (E.default.semVer !== O.semVer) throw Error(`Two different versions of Dexie loaded in the same app: ${E.default.semVer} and ${O.semVer}`);
3766
+ var { liveQuery: se, mergeRanges: k, rangesOverlap: ce, RangeSet: le, cmp: ue, Entity: de, PropModification: fe, replacePrefix: pe, add: me, remove: A, DexieYProvider: he } = O;
3767
+ v(), _();
3768
+ var j = /* @__PURE__ */ new Map(), M = v(), ge = _(), N = /* @__PURE__ */ new Map();
3769
+ function _e(e) {
3770
+ let { key: t, connection: n, listener: r } = e, i = N.get(t) ?? /* @__PURE__ */ new Set();
3771
+ N.set(t, i);
3772
+ let a = {
3773
+ connection: n,
3774
+ listener: r
3775
+ };
3776
+ return i.add(a), function() {
3777
+ i.delete(a), i.size === 0 && N.get(t) === i && N.delete(t);
3778
+ };
3779
+ }
3780
+ function ve(e) {
3781
+ let { key: t, name: n, connection: r, change: i } = e, a = {
3782
+ ...i,
3783
+ timestamp: Date.now()
3784
+ };
3785
+ for (let e of Array.from(N.get(t) ?? [])) g({
3786
+ listener: e.listener,
3787
+ value: {
3788
+ type: "change",
3789
+ message: a,
3790
+ own: e.connection === r
3791
+ },
3792
+ of: m({ name: n })
3793
+ });
3794
+ }
3795
+ function ye(e) {
3796
+ let { project: t, dialecteId: n } = e;
3797
+ return n === void 0 ? encodeURIComponent(t) : p({
3798
+ dialecteId: n,
3799
+ project: t
3800
+ });
3801
+ }
3802
+ function be(e) {
3803
+ return j.get(e.key);
3804
+ }
3805
+ function xe(e) {
3806
+ let { key: t } = e, n = j.get(t);
3807
+ if (n) return n;
3808
+ let r = Se();
3809
+ return j.set(t, r), r;
3810
+ }
3811
+ function P(e) {
3812
+ j.delete(e.key);
3813
+ }
3814
+ function Se() {
3815
+ return {
3816
+ documents: /* @__PURE__ */ new Map(),
3817
+ records: /* @__PURE__ */ new Map(),
3818
+ changelog: /* @__PURE__ */ new Map(),
3819
+ heads: /* @__PURE__ */ new Map(),
3820
+ discardedCommits: /* @__PURE__ */ new Map(),
3821
+ blobs: /* @__PURE__ */ new Map(),
3822
+ blobData: /* @__PURE__ */ new Map(),
3823
+ runningImports: /* @__PURE__ */ new Set(),
3824
+ versions: /* @__PURE__ */ new Map()
3825
+ };
3826
+ }
3827
+ function F(e) {
3828
+ let { state: t, documentId: n } = e;
3829
+ t.versions.set(n, (t.versions.get(n) ?? 0) + 1);
3830
+ }
3831
+ var Ce = /* @__PURE__ */ new Map(), we = Se();
3832
+ function Te(e) {
3833
+ let { table: t, creates: n, documentId: r } = e, i = /* @__PURE__ */ new Set(), a = [], o = [];
3834
+ for (let { id: e } of n) t.has(e) && a.push(e), i.has(e) && o.push(e), i.add(e);
3835
+ (a.length > 0 || o.length > 0) && f({
3836
+ documentId: r,
3837
+ held: a,
3838
+ repeated: o
3839
+ });
3840
+ }
3841
+ (class t {
3842
+ static {
3843
+ this.reconcileWarned = !1;
3844
+ }
3845
+ constructor(e, t) {
3846
+ this.closed = !1, this.closings = 0, this.operations = b(), s({
3847
+ project: e,
3848
+ dialecteId: t?.dialecteId
3849
+ }), this.name = e, this.writable = t?.writable ?? !0, this.runtime = t?.runtime, this.stateKey = ye({
3850
+ project: e,
3851
+ dialecteId: t?.dialecteId
3852
+ });
3853
+ }
3854
+ async open() {
3855
+ let e = this.closings;
3856
+ for (await this.operations.whenIdle(); this.destroying;) await this.destroying.catch(y);
3857
+ this.closings !== e && o({ storeName: this.name }), this.closed = !1, this.writable && M.markOpen({
3858
+ name: this.stateKey,
3859
+ connection: this
3860
+ }), await ae({
3861
+ store: this,
3862
+ isRunning: (e) => e.writeId !== void 0 && this.readState().runningImports.has(e.writeId)
3863
+ });
3864
+ }
3865
+ async close() {
3866
+ if (this.closed = !0, this.closings += 1, M.markClosed({
3867
+ name: this.stateKey,
3868
+ connection: this
3869
+ }), this.operations.count === 0) return;
3870
+ let e = this.operations.whenIdle();
3871
+ ge.markClosing({
3872
+ name: this.stateKey,
3873
+ until: e
3874
+ }), await e;
3875
+ }
3876
+ async destroy() {
3877
+ if (!this.writable) return;
3878
+ for (; this.destroying;) await this.destroying.catch(y);
3879
+ let e = this.destroyOnceIdle();
3880
+ this.destroying = e;
3881
+ try {
3882
+ await e;
3883
+ } finally {
3884
+ this.destroying === e && (this.destroying = void 0);
3885
+ }
3886
+ }
3887
+ async destroyOnceIdle() {
3888
+ await this.operations.whenIdle(), await ge.settled({ name: this.stateKey });
3889
+ let e = M.others({
3890
+ name: this.stateKey,
3891
+ connection: this
3892
+ });
3893
+ e > 0 && r({
3894
+ storeName: this.name,
3895
+ connections: e
3896
+ }), P({ key: this.stateKey }), M.markClosed({
3897
+ name: this.stateKey,
3898
+ connection: this
3899
+ });
3900
+ }
3901
+ async reconcile() {
3902
+ await this.guardOpen(), t.reconcileWarned || (t.reconcileWarned = !0, console.warn("[dialecte] InMemoryStore.reconcile() is a no-op: in-memory documents are not shared across realms/tabs. Use the local (IndexedDB) or sqlite store for cross-realm sync."));
3903
+ }
3904
+ async isDocumentReadable(e) {
3905
+ return await this.guardOpen(), this.readState().documents.has(e);
3906
+ }
3907
+ async registerDocument(e) {
3908
+ await this.guardOpen(), await this.registerDocumentUnguarded(e), this.announce({
3909
+ type: "init-empty-document",
3910
+ documentId: e.id
3911
+ });
3912
+ }
3913
+ async getDocument(e) {
3914
+ return await this.guardOpen(), this.getDocumentUnguarded(e);
3915
+ }
3916
+ async getDocuments() {
3917
+ return await this.guardOpen(), structuredClone([...this.readState().documents.values()].sort(te));
3918
+ }
3919
+ async updateDocument(e, t) {
3920
+ await this.guardOpen();
3921
+ let n = this.readState().documents.get(e);
3922
+ await this.updateDocumentUnguarded(e, t), re({
3923
+ first: n,
3924
+ second: this.readState().documents.get(e)
3925
+ }) || this.announce({
3926
+ type: "document-updated",
3927
+ documentId: e
3928
+ });
3929
+ }
3930
+ async removeDocument(e) {
3931
+ await this.guardOpen();
3932
+ let t = this.readState().documents.has(e);
3933
+ await this.removeDocumentUnguarded(e), t && this.announce({
3934
+ type: "document-removed",
3935
+ documentId: e
3936
+ });
3937
+ }
3938
+ async get(e, t) {
3939
+ return await this.guardOpen(), structuredClone(this.readTable(t).get(e));
3940
+ }
3941
+ async getByDocumentId(e) {
3942
+ return await this.guardOpen(), structuredClone([...this.readTable(e).values()].sort(te));
3943
+ }
3944
+ async count(e) {
3945
+ return await this.guardOpen(), this.countUnguarded(e);
3946
+ }
3947
+ async getByTagNameInDocument(e, t) {
3948
+ return await this.guardOpen(), this.getByTagNameInDocumentUnguarded(e, t);
3949
+ }
3950
+ async getMany(e, t) {
3951
+ return await this.guardOpen(), this.getManyUnguarded(e, t);
3952
+ }
3953
+ async importFile(e) {
3954
+ let t = this.guardOpen();
3955
+ t && await t, this.guardWritable();
3956
+ let { file: n, options: r, writeId: i = crypto.randomUUID(), onProgress: a, signal: o } = e, s = T({
3957
+ runtime: this.runtime,
3958
+ storeName: this.name,
3959
+ operation: "import"
3960
+ }), { runningImports: c } = xe({ key: this.stateKey });
3961
+ c.add(i), this.operations.start();
3962
+ try {
3963
+ let e = await ee({
3964
+ store: this.ownImportTarget(),
3965
+ runtime: s,
3966
+ file: n,
3967
+ options: r,
3968
+ writeId: i
3969
+ }, {
3970
+ onProgress: a,
3971
+ signal: o
3972
+ });
3973
+ return this.announce({
3974
+ type: "document-imported",
3975
+ documentId: e.record.id
3976
+ }), e;
3977
+ } finally {
3978
+ c.delete(i), this.operations.end();
3979
+ }
3980
+ }
3981
+ async exportFile(e) {
3982
+ let t = this.guardOpen();
3983
+ t && await t;
3984
+ let { documentId: n, options: r, onProgress: i, signal: a } = e, o = T({
3985
+ runtime: this.runtime,
3986
+ storeName: this.name,
3987
+ operation: "export"
3988
+ });
3989
+ this.operations.start();
3990
+ try {
3991
+ return await u({
3992
+ source: this.ownExportSource(),
3993
+ runtime: o,
3994
+ documentId: n,
3995
+ options: r
3996
+ }, {
3997
+ onProgress: i,
3998
+ signal: a
3999
+ });
4000
+ } finally {
4001
+ this.operations.end();
4002
+ }
4003
+ }
4004
+ async getWriteOutcome(e) {
4005
+ await this.guardOpen();
4006
+ let { writeId: t } = e, { documents: n, changelog: r, discardedCommits: i, runningImports: a } = this.readState(), o = [...r.values()].some((e) => e.some((e) => e.writeId === t)) || [...i.values()].some((e) => e.has(t));
4007
+ return x({
4008
+ documents: [...n.values()],
4009
+ writeId: t,
4010
+ committed: o,
4011
+ isRunning: (e) => a.has(e.writeId)
4012
+ });
4013
+ }
4014
+ async bulkWrite(e, t) {
4015
+ await this.guardOpen();
4016
+ let n = this.readTable(e), r = (t.deletes ?? []).filter(function(e) {
4017
+ return n.has(e);
4018
+ });
4019
+ await this.bulkWriteUnguarded(e, t), (t.creates?.length ?? 0) + (t.updates?.length ?? 0) + r.length > 0 && this.announce({
4020
+ type: "commit",
4021
+ documentId: e
4022
+ });
4023
+ }
4024
+ async commit(e) {
4025
+ await this.guardOpen(), this.guardWritable();
4026
+ let { documentId: t, writeId: n = crypto.randomUUID(), deletes: r, onProgress: a } = e, { state: o, table: s } = this.writeTarget(t);
4027
+ o.documents.get(t)?.status === "importing" && i({
4028
+ documentId: t,
4029
+ what: "a commit"
4030
+ }), c({ writeId: n });
4031
+ let l = e.updates.map((e) => {
4032
+ let n = s.get(e.id);
4033
+ return n || d({
4034
+ documentId: t,
4035
+ recordId: e.id
4036
+ }), n;
4037
+ }), u = C({ records: e.creates });
4038
+ Te({
4039
+ table: s,
4040
+ creates: u,
4041
+ documentId: t
4042
+ });
4043
+ let f = C({ records: e.updates });
4044
+ F({
4045
+ state: o,
4046
+ documentId: t
4047
+ });
4048
+ for (let e of u) s.set(e.id, e);
4049
+ for (let e of f) s.set(e.id, e);
4050
+ let p = r.flatMap((e) => {
4051
+ let t = s.get(e);
4052
+ return t ? [t] : [];
4053
+ });
4054
+ for (let e of r) s.delete(e);
4055
+ let { heads: m, changelog: h, discardedCommits: g } = o, _ = m.get(t) ?? 0, v = h.get(t) ?? [], y = v.filter((e) => e.sequenceNumber <= _), b = g.get(t) ?? /* @__PURE__ */ new Set();
4056
+ for (let e of v) e.sequenceNumber > _ && b.add(e.writeId);
4057
+ g.set(t, b);
4058
+ let x = _ + 1, S = {
4059
+ id: y.length + 1,
4060
+ documentId: t,
4061
+ sequenceNumber: x,
4062
+ timestamp: Date.now(),
4063
+ writeId: n,
4064
+ operations: {
4065
+ creates: u,
4066
+ updates: f.map((e, t) => ({
4067
+ before: l[t],
4068
+ after: e
4069
+ })),
4070
+ deletes: p
4071
+ }
4072
+ };
4073
+ y.push(S), h.set(t, y), m.set(t, x), ie({
4074
+ onProgress: a,
4075
+ parts: [
4076
+ u.length,
4077
+ f.length,
4078
+ r.length
4079
+ ]
4080
+ }), this.announce({
4081
+ type: "commit",
4082
+ documentId: t
4083
+ });
4084
+ }
4085
+ async undo(e) {
4086
+ await this.guardOpen(), this.guardWritable();
4087
+ let t = this.writeState(), n = t?.heads.get(e) ?? 0;
4088
+ if (!t || n === 0) return;
4089
+ let r = (t.changelog.get(e) ?? []).find((e) => e.sequenceNumber === n);
4090
+ if (!r) return;
4091
+ let { table: i } = this.writeTarget(e), { creates: a, updates: o, deletes: s } = r.operations;
4092
+ for (let e of s) i.set(e.id, e);
4093
+ for (let e of o) i.set(e.before.id, e.before);
4094
+ for (let e of a) i.delete(e.id);
4095
+ t.heads.set(e, n - 1), F({
4096
+ state: t,
4097
+ documentId: e
4098
+ }), this.announce({
4099
+ type: "commit",
4100
+ documentId: e
4101
+ });
4102
+ }
4103
+ async redo(e) {
4104
+ await this.guardOpen(), this.guardWritable();
4105
+ let t = this.writeState();
4106
+ if (!t) return;
4107
+ let n = (t.heads.get(e) ?? 0) + 1, r = (t.changelog.get(e) ?? []).find((e) => e.sequenceNumber === n);
4108
+ if (!r) return;
4109
+ let { table: i } = this.writeTarget(e), { creates: a, updates: o, deletes: s } = r.operations;
4110
+ for (let e of a) i.set(e.id, e);
4111
+ for (let e of o) i.set(e.after.id, e.after);
4112
+ for (let e of s) i.delete(e.id);
4113
+ t.heads.set(e, n), F({
4114
+ state: t,
4115
+ documentId: e
4116
+ }), this.announce({
4117
+ type: "commit",
4118
+ documentId: e
4119
+ });
4120
+ }
4121
+ async getHistoryStatus(e) {
4122
+ await this.guardOpen();
4123
+ let { heads: t, changelog: n } = this.readState(), r = t.get(e) ?? 0, i = n.get(e) ?? [];
4124
+ return {
4125
+ canUndo: r > 0,
4126
+ canRedo: i.some((e) => e.sequenceNumber === r + 1)
4127
+ };
4128
+ }
4129
+ async getChangeLog(e) {
4130
+ return await this.guardOpen(), structuredClone([...this.readState().changelog.get(e) ?? []]);
4131
+ }
4132
+ getDatabaseInstance() {
4133
+ return null;
4134
+ }
4135
+ async addBlob(e, t) {
4136
+ await this.guardOpen(), this.guardWritable();
4137
+ let n = this.writeState();
4138
+ n?.documents.has(e.documentId) || i({
4139
+ documentId: e.documentId,
4140
+ what: "a blob"
4141
+ }), n.blobs.set(e.id, h({ value: e }));
4142
+ let r = n.blobData.get(e.documentId) ?? /* @__PURE__ */ new Map();
4143
+ n.blobData.set(e.documentId, r.set(e.id, t)), this.announce({
4144
+ type: "blob-added",
4145
+ blobId: e.id,
4146
+ documentId: e.documentId
4147
+ });
4148
+ }
4149
+ async getBlob(e) {
4150
+ await this.guardOpen();
4151
+ let { blobs: t, blobData: n } = this.readState(), r = t.get(e);
4152
+ if (!r) return;
4153
+ let i = n.get(r.documentId)?.get(e);
4154
+ if (i) return {
4155
+ entry: structuredClone(r),
4156
+ data: i
4157
+ };
4158
+ }
4159
+ async getBlobsByDocument(e) {
4160
+ return await this.guardOpen(), structuredClone([...this.readState().blobs.values()].filter((t) => t.attachedTo.some((t) => t.documentId === e)).sort(te));
4161
+ }
4162
+ async getBlobsByRecord(e, t) {
4163
+ return await this.guardOpen(), structuredClone([...this.readState().blobs.values()].filter((n) => n.attachedTo.some((n) => n.documentId === e && n.recordRef === t)).sort(te));
4164
+ }
4165
+ async getStandaloneBlobs() {
4166
+ return await this.guardOpen(), structuredClone([...this.readState().blobs.values()].filter((e) => e.attachedTo.length === 0).sort(te));
4167
+ }
4168
+ async attachBlob(t, n) {
4169
+ await this.guardOpen(), this.guardWritable();
4170
+ let r = this.writeState(), i = r?.blobs.get(t);
4171
+ r && i || e("STORE_BLOB_NOT_FOUND", { detail: `Blob "${t}" not found` });
4172
+ let a = h({ value: n });
4173
+ i.attachedTo.some((e) => e.documentId === n.documentId && e.recordRef === n.recordRef && e.attribute === n.attribute) || (r.blobs.set(t, {
4174
+ ...i,
4175
+ attachedTo: [...i.attachedTo, a]
4176
+ }), this.announce({
4177
+ type: "blob-attached",
4178
+ blobId: t,
4179
+ ref: a
4180
+ }));
4181
+ }
4182
+ async detachBlob(t, n) {
4183
+ await this.guardOpen(), this.guardWritable();
4184
+ let r = this.writeState(), i = r?.blobs.get(t);
4185
+ r && i || e("STORE_BLOB_NOT_FOUND", { detail: `Blob "${t}" not found` });
4186
+ let a = i.attachedTo.filter((e) => e.documentId !== n.documentId || e.recordRef !== n.recordRef);
4187
+ a.length !== i.attachedTo.length && (r.blobs.set(t, {
4188
+ ...i,
4189
+ attachedTo: a
4190
+ }), this.announce({
4191
+ type: "blob-detached",
4192
+ blobId: t,
4193
+ ref: {
4194
+ documentId: n.documentId,
4195
+ recordRef: n.recordRef
4196
+ }
4197
+ }));
4198
+ }
4199
+ async removeBlob(e) {
4200
+ await this.guardOpen(), this.guardWritable();
4201
+ let t = this.writeState(), n = t?.blobs.get(e);
4202
+ t && n && (t.blobs.delete(e), t.blobData.get(n.documentId)?.delete(e), this.announce({
4203
+ type: "blob-removed",
4204
+ blobId: e
4205
+ }));
4206
+ }
4207
+ subscribe(e) {
4208
+ return this.writable ? _e({
4209
+ key: this.stateKey,
4210
+ connection: this,
4211
+ listener: (t) => {
4212
+ this.closed || e(t);
4213
+ }
4214
+ }) : I;
4215
+ }
4216
+ announce(e) {
4217
+ ve({
4218
+ key: this.stateKey,
4219
+ name: this.name,
4220
+ connection: this,
4221
+ change: e
4222
+ });
4223
+ }
4224
+ async registerDocumentUnguarded(e) {
4225
+ this.guardWritable();
4226
+ let t = xe({ key: this.stateKey });
4227
+ t.documents.has(e.id) && l({ documentId: e.id });
4228
+ let n = h({ value: e });
4229
+ w({
4230
+ document: n,
4231
+ documents: [...t.documents.values()]
4232
+ }), t.documents.set(e.id, n), t.records.set(a(e.id), /* @__PURE__ */ new Map()), t.blobData.set(e.id, /* @__PURE__ */ new Map());
4233
+ }
4234
+ async getDocumentUnguarded(e) {
4235
+ return structuredClone(this.readState().documents.get(e));
4236
+ }
4237
+ async updateDocumentUnguarded(e, t) {
4238
+ this.guardWritable();
4239
+ let n = h({ value: t }), r = this.writeState(), i = r?.documents.get(e);
4240
+ if (!r || !i) return;
4241
+ let a = ne({
4242
+ document: i,
4243
+ updates: n
4244
+ });
4245
+ a.path !== i.path && w({
4246
+ document: a,
4247
+ documents: [...r.documents.values()]
4248
+ }), r.documents.set(e, a);
4249
+ }
4250
+ async markReadyUnguarded(e) {
4251
+ let { documentId: t, registered: n } = e;
4252
+ this.guardWritable();
4253
+ let r = this.writeState(), a = r?.documents.get(t);
4254
+ r && a && oe({
4255
+ held: a,
4256
+ registered: n
4257
+ }) || i({
4258
+ documentId: t,
4259
+ what: "its ready state"
4260
+ }), r.documents.set(t, {
4261
+ ...a,
4262
+ status: "ready"
4263
+ });
4264
+ }
4265
+ async bulkWriteOwnImport(e) {
4266
+ let { documentId: t, ops: n, registered: r } = e, a = this.writeState()?.documents.get(t);
4267
+ oe({
4268
+ held: a,
4269
+ registered: r
4270
+ }) || i({
4271
+ documentId: t,
4272
+ what: "records"
4273
+ }), await this.bulkWriteUnguarded(t, n);
4274
+ }
4275
+ async removeOwnImport(e) {
4276
+ let { documentId: t, registered: n } = e, r = this.writeState()?.documents.get(t);
4277
+ oe({
4278
+ held: r,
4279
+ registered: n
4280
+ }) && await this.removeDocumentUnguarded(t);
4281
+ }
4282
+ async removeDocumentUnguarded(e) {
4283
+ this.guardWritable();
4284
+ let t = this.writeState();
4285
+ if (t) {
4286
+ t.documents.delete(e), t.records.delete(a(e)), t.changelog.delete(e), t.heads.delete(e), t.discardedCommits.delete(e), t.blobData.delete(e);
4287
+ for (let [n, r] of t.blobs) r.documentId === e && t.blobs.delete(n);
4288
+ }
4289
+ }
4290
+ async bulkWriteUnguarded(e, t) {
4291
+ this.guardWritable();
4292
+ let { state: n, table: r } = this.writeTarget(e), i = C({ records: t.creates ?? [] });
4293
+ Te({
4294
+ table: r,
4295
+ creates: i,
4296
+ documentId: e
4297
+ });
4298
+ let a = new Set(i.map((e) => e.id)), o = h({ value: (t.updates ?? []).filter((e) => r.has(e.recordId) || a.has(e.recordId)) });
4299
+ for (let e of i) r.set(e.id, e);
4300
+ for (let e of o) {
4301
+ let t = r.get(e.recordId);
4302
+ t && r.set(e.recordId, S({
4303
+ record: t,
4304
+ patch: e
4305
+ }));
4306
+ }
4307
+ if (t.deletes) for (let e of t.deletes) r.delete(e);
4308
+ F({
4309
+ state: n,
4310
+ documentId: e
4311
+ });
4312
+ }
4313
+ readState() {
4314
+ return this.writable ? be({ key: this.stateKey }) ?? we : we;
4315
+ }
4316
+ writeState() {
4317
+ return be({ key: this.stateKey });
4318
+ }
4319
+ readTable(e) {
4320
+ return this.readState().records.get(a(e)) ?? Ce;
4321
+ }
4322
+ writeTarget(e) {
4323
+ let t = this.writeState(), n = t?.records.get(a(e));
4324
+ return t && n || i({
4325
+ documentId: e,
4326
+ what: "records"
4327
+ }), {
4328
+ state: t,
4329
+ table: n
4330
+ };
4331
+ }
4332
+ guardOpen() {
4333
+ if (this.closed && o({ storeName: this.name }), this.destroying) return this.guardOpenAfterOwnDestroy({ destroying: this.destroying });
4334
+ this.writable && M.markOpen({
4335
+ name: this.stateKey,
4336
+ connection: this
4337
+ });
4338
+ }
4339
+ async guardOpenAfterOwnDestroy(e) {
4340
+ await e.destroying.catch(y), await this.guardOpen();
4341
+ }
4342
+ ownImportTarget() {
4343
+ let e;
4344
+ return {
4345
+ registerDocument: (t) => (e = t, this.registerDocumentUnguarded(t)),
4346
+ getDocument: (e) => this.getDocumentUnguarded(e),
4347
+ markReady: (t) => this.markReadyUnguarded({
4348
+ documentId: t,
4349
+ registered: e
4350
+ }),
4351
+ removeDocument: (t) => this.removeOwnImport({
4352
+ documentId: t,
4353
+ registered: e
4354
+ }),
4355
+ bulkWrite: (t, n) => this.bulkWriteOwnImport({
4356
+ documentId: t,
4357
+ ops: n,
4358
+ registered: e
4359
+ }),
4360
+ writeSession: (t, n) => this.bulkWriteOwnImport({
4361
+ documentId: t,
4362
+ ops: n,
4363
+ registered: e
4364
+ })
4365
+ };
4366
+ }
4367
+ ownExportSource() {
4368
+ return {
4369
+ getDocument: (e) => this.getDocumentUnguarded(e),
4370
+ count: (e) => this.countUnguarded(e),
4371
+ getByTagNameInDocument: (e, t) => this.getByTagNameInDocumentUnguarded(e, t),
4372
+ getMany: (e, t) => this.getManyUnguarded(e, t),
4373
+ getExportVersion: (e) => this.getExportVersion(e)
4374
+ };
4375
+ }
4376
+ async getExportVersion(e) {
4377
+ let { documentId: t } = e, { documents: n, versions: r } = this.readState();
4378
+ if (n.get(t)?.status === "ready") return r.get(t) ?? 0;
4379
+ }
4380
+ async countUnguarded(e) {
4381
+ return this.readTable(e).size;
4382
+ }
4383
+ async getByTagNameInDocumentUnguarded(e, t) {
4384
+ let n = [];
4385
+ for (let r of this.readTable(t).values()) r.tagName === e && n.push(r);
4386
+ return structuredClone(n.sort(te));
4387
+ }
4388
+ async getManyUnguarded(e, t) {
4389
+ let n = this.readTable(t);
4390
+ return structuredClone(e.map((e) => n.get(e)));
4391
+ }
4392
+ guardWritable() {
4393
+ this.writable || e("STORE_NOT_WRITABLE", { detail: "In-memory store is read-only. Hydrate with a real document before writing." });
4394
+ }
4395
+ });
4396
+ function I() {}
4397
+ function Ee(e, t) {
4398
+ return e ? De(e, t) : {};
4399
+ }
4400
+ function De(e, t) {
4401
+ let n = {};
4402
+ for (let r of Object.keys(e)) {
4403
+ let i = e[r];
4404
+ n[r] = typeof i == "function" ? (...e) => i(t, ...e) : De(i, t);
4405
+ }
4406
+ return n;
4407
+ }
4408
+ Object.freeze({
4409
+ plan() {},
4410
+ nextStep() {},
4411
+ endPlan() {},
4412
+ forceClear() {}
4413
+ });
4414
+ //#endregion
4415
+ export { Ee as V, ae as Y };