@nylas/react 1.1.0-canary.9 → 1.1.1

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 (154) hide show
  1. package/README.md +110 -2
  2. package/dist/add-circle-icon_2.entry-b14ecb5c.js +25 -0
  3. package/dist/add-circle-icon_2.entry-c6211866.cjs +1 -0
  4. package/dist/archive-icon_7.entry-3fe7721a.js +75 -0
  5. package/dist/archive-icon_7.entry-54fc1f03.cjs +1 -0
  6. package/dist/arrow-icon.entry-1dfee3bc.cjs +1 -0
  7. package/dist/arrow-icon.entry-cc936041.js +15 -0
  8. package/dist/bold-icon_3.entry-4b9de887.cjs +1 -0
  9. package/dist/bold-icon_3.entry-e2a1d434.js +35 -0
  10. package/dist/button-component_2.entry-3639ade6.js +26 -0
  11. package/dist/button-component_2.entry-5666fdfa.cjs +1 -0
  12. package/dist/calendar-agenda-fill-icon_48.entry-56e364cd.js +5256 -0
  13. package/dist/calendar-agenda-fill-icon_48.entry-bf278e34.cjs +7 -0
  14. package/dist/calendar-cancel-icon.entry-ac1cb5dd.cjs +1 -0
  15. package/dist/calendar-cancel-icon.entry-dcd777cd.js +15 -0
  16. package/dist/calendar-check-icon_2.entry-6330bd2d.js +25 -0
  17. package/dist/calendar-check-icon_2.entry-7ad1b2a0.cjs +1 -0
  18. package/dist/calendar-icon.entry-5849a547.cjs +1 -0
  19. package/dist/calendar-icon.entry-8559fa0d.js +15 -0
  20. package/dist/checkbox-component_2.entry-1474c465.js +79 -0
  21. package/dist/checkbox-component_2.entry-6cf5da6b.cjs +1 -0
  22. package/dist/chevron-icon_3.entry-41170718.cjs +1 -0
  23. package/dist/chevron-icon_3.entry-cb757aa3.js +132 -0
  24. package/dist/clock-icon_4.entry-36a33de5.cjs +1 -0
  25. package/dist/clock-icon_4.entry-642f4dc6.js +45 -0
  26. package/dist/constants-50c3e067-4e027da4.cjs +15 -0
  27. package/dist/constants-50c3e067-83f1d865.js +3883 -0
  28. package/dist/copy-icon.entry-60740516.js +15 -0
  29. package/dist/copy-icon.entry-fb63cf53.cjs +1 -0
  30. package/dist/core-js-38e53e34.cjs +4 -0
  31. package/dist/core-js-a9d3b6e1.js +3297 -0
  32. package/dist/delete-icon_2.entry-45851bc5.js +25 -0
  33. package/dist/delete-icon_2.entry-d1af0606.cjs +1 -0
  34. package/dist/document-refresh-icon.entry-1731d4d9.cjs +1 -0
  35. package/dist/document-refresh-icon.entry-5db0830a.js +15 -0
  36. package/dist/dom-68f08be9.cjs +15 -0
  37. package/dist/dom-86e17616.js +664 -0
  38. package/dist/{types/elements → elements}/index.d.ts +48 -1
  39. package/dist/elements-dc5b338e-3099ee02.js +28031 -0
  40. package/dist/elements-dc5b338e-ab9afb63.cjs +16516 -0
  41. package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
  42. package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
  43. package/dist/focus-visible-e8093c16-067a8f23.js +84 -0
  44. package/dist/focus-visible-e8093c16-811f50fa.cjs +1 -0
  45. package/dist/forward-icon_6.entry-4e9c9686.cjs +3 -0
  46. package/dist/forward-icon_6.entry-e7c5fa46.js +953 -0
  47. package/dist/globe-icon.entry-74f79652.cjs +1 -0
  48. package/dist/globe-icon.entry-aa3f3ea3.js +15 -0
  49. package/dist/google-logo-icon_4.entry-0332a181.cjs +1 -0
  50. package/dist/google-logo-icon_4.entry-3fe41d69.js +673 -0
  51. package/dist/index-2a53b6a8.cjs +82 -0
  52. package/dist/index-a134f625.js +12842 -0
  53. package/dist/index.es-79f5b771-64a1baf0.cjs +7 -0
  54. package/dist/index.es-79f5b771-ce07d6fc.js +3135 -0
  55. package/dist/info-icon_2.entry-a3f40027.cjs +1 -0
  56. package/dist/info-icon_2.entry-fed731f4.js +34 -0
  57. package/dist/input-color-picker.entry-37826630.js +48 -0
  58. package/dist/input-color-picker.entry-cbdce7a1.cjs +1 -0
  59. package/dist/input-component.entry-b83b7103.js +70 -0
  60. package/dist/input-component.entry-e71b7062.cjs +1 -0
  61. package/dist/input-dropdown.entry-150819cd.cjs +1 -0
  62. package/dist/input-dropdown.entry-db0dae5f.js +134 -0
  63. package/dist/mailbox-store-9c52a3fa-04f22f60.cjs +1 -0
  64. package/dist/mailbox-store-9c52a3fa-80fe343c.js +380 -0
  65. package/dist/multi-select-dropdown.entry-629329d7.cjs +1 -0
  66. package/dist/multi-select-dropdown.entry-6b429b39.js +95 -0
  67. package/dist/nylas-booked-event-card_12.entry-660af56a.cjs +1 -0
  68. package/dist/nylas-booked-event-card_12.entry-c22c02b4.js +1133 -0
  69. package/dist/nylas-form-card.entry-2ced5eef.cjs +1 -0
  70. package/dist/nylas-form-card.entry-f3d6a1e4.js +57 -0
  71. package/dist/nylas-if-state.entry-55c32c0c.cjs +1 -0
  72. package/dist/nylas-if-state.entry-862ad978.js +94 -0
  73. package/dist/nylas-list-folders.entry-544fd38d.js +120 -0
  74. package/dist/nylas-list-folders.entry-77e936f7.cjs +1 -0
  75. package/dist/nylas-list-threads.entry-71411da7.js +70 -0
  76. package/dist/nylas-list-threads.entry-82e04782.cjs +1 -0
  77. package/dist/nylas-login.entry-3ccc2bef.cjs +1 -0
  78. package/dist/nylas-login.entry-48179c01.js +73 -0
  79. package/dist/nylas-mailbox-pagination.entry-77cf03b5.js +101 -0
  80. package/dist/nylas-mailbox-pagination.entry-d31f9aa4.cjs +1 -0
  81. package/dist/nylas-mailbox-toolbar-button.entry-33aad610.cjs +1 -0
  82. package/dist/nylas-mailbox-toolbar-button.entry-40e3c373.js +82 -0
  83. package/dist/nylas-mailbox.entry-963de1c3.cjs +1 -0
  84. package/dist/nylas-mailbox.entry-f4066fb2.js +134 -0
  85. package/dist/nylas-provider.entry-08767da3.cjs +1 -0
  86. package/dist/nylas-provider.entry-c61428b1.js +145 -0
  87. package/dist/nylas-reminder-emails.entry-cd8e1d2e.js +129 -0
  88. package/dist/nylas-reminder-emails.entry-d42a7f1d.cjs +4 -0
  89. package/dist/nylas-reminder-time_2.entry-d7115393.js +105 -0
  90. package/dist/nylas-reminder-time_2.entry-e5540fdd.cjs +1 -0
  91. package/dist/nylas-scheduler-editor.entry-65eb4938.js +1447 -0
  92. package/dist/nylas-scheduler-editor.entry-67904653.cjs +2 -0
  93. package/dist/nylas-scheduling.entry-50e41d85.cjs +1 -0
  94. package/dist/nylas-scheduling.entry-7aad4f63.js +345 -0
  95. package/dist/nylas-threads-refresh.entry-1b8befab.cjs +1 -0
  96. package/dist/nylas-threads-refresh.entry-d025575a.js +74 -0
  97. package/dist/nylas-threads-search.entry-78c06183.cjs +1 -0
  98. package/dist/nylas-threads-search.entry-a254c36e.js +69 -0
  99. package/dist/nylas-time-window-picker.entry-30baeb50.cjs +1 -0
  100. package/dist/nylas-time-window-picker.entry-89c15823.js +316 -0
  101. package/dist/nylas-view-thread.entry-939a4561.cjs +1 -0
  102. package/dist/nylas-view-thread.entry-c8d56573.js +203 -0
  103. package/dist/person-icon.entry-5ab75598.cjs +1 -0
  104. package/dist/person-icon.entry-8aef4041.js +15 -0
  105. package/dist/play-icon_2.entry-392ad303.cjs +1 -0
  106. package/dist/play-icon_2.entry-4b068c1b.js +25 -0
  107. package/dist/react.cjs +1 -0
  108. package/dist/react.js +145 -0
  109. package/dist/refresh-icon.entry-9ea254c9.cjs +1 -0
  110. package/dist/refresh-icon.entry-a754a2b5.js +15 -0
  111. package/dist/register-component-ea95564d-ab3d630f.cjs +1 -0
  112. package/dist/register-component-ea95564d-e19ec159.js +109 -0
  113. package/dist/scheduler-config-store-2a3b403d-4e10b542.cjs +1 -0
  114. package/dist/scheduler-config-store-2a3b403d-581c70cf.js +27 -0
  115. package/dist/scheduler-store-9ff4914b-6e28240e.cjs +1 -0
  116. package/dist/scheduler-store-9ff4914b-b71a0aca.js +474 -0
  117. package/dist/textarea-component.entry-70bb02bf.cjs +1 -0
  118. package/dist/textarea-component.entry-a5daab6c.js +37 -0
  119. package/dist/time-period-selector.entry-25348de7.js +80 -0
  120. package/dist/time-period-selector.entry-6306e456.cjs +1 -0
  121. package/dist/translate-icon.entry-785fa109.cjs +1 -0
  122. package/dist/translate-icon.entry-b6094ecc.js +15 -0
  123. package/dist/warning-icon.entry-4b400ee2.js +15 -0
  124. package/dist/warning-icon.entry-94e34c58.cjs +1 -0
  125. package/package.json +12 -8
  126. package/dist/elements/index.js +0 -92
  127. package/dist/elements/index.js.map +0 -1
  128. package/dist/elements/react-component-lib/createComponent.js +0 -65
  129. package/dist/elements/react-component-lib/createComponent.js.map +0 -1
  130. package/dist/elements/react-component-lib/createOverlayComponent.js +0 -98
  131. package/dist/elements/react-component-lib/createOverlayComponent.js.map +0 -1
  132. package/dist/elements/react-component-lib/index.js +0 -3
  133. package/dist/elements/react-component-lib/index.js.map +0 -1
  134. package/dist/elements/react-component-lib/interfaces.js +0 -2
  135. package/dist/elements/react-component-lib/interfaces.js.map +0 -1
  136. package/dist/elements/react-component-lib/utils/attachProps.js +0 -92
  137. package/dist/elements/react-component-lib/utils/attachProps.js.map +0 -1
  138. package/dist/elements/react-component-lib/utils/case.js +0 -7
  139. package/dist/elements/react-component-lib/utils/case.js.map +0 -1
  140. package/dist/elements/react-component-lib/utils/dev.js +0 -13
  141. package/dist/elements/react-component-lib/utils/dev.js.map +0 -1
  142. package/dist/elements/react-component-lib/utils/index.js +0 -31
  143. package/dist/elements/react-component-lib/utils/index.js.map +0 -1
  144. package/dist/index.js +0 -29
  145. package/dist/index.js.map +0 -1
  146. /package/dist/{types/elements → elements}/react-component-lib/createComponent.d.ts +0 -0
  147. /package/dist/{types/elements → elements}/react-component-lib/createOverlayComponent.d.ts +0 -0
  148. /package/dist/{types/elements → elements}/react-component-lib/index.d.ts +0 -0
  149. /package/dist/{types/elements → elements}/react-component-lib/interfaces.d.ts +0 -0
  150. /package/dist/{types/elements → elements}/react-component-lib/utils/attachProps.d.ts +0 -0
  151. /package/dist/{types/elements → elements}/react-component-lib/utils/case.d.ts +0 -0
  152. /package/dist/{types/elements → elements}/react-component-lib/utils/dev.d.ts +0 -0
  153. /package/dist/{types/elements → elements}/react-component-lib/utils/index.d.ts +0 -0
  154. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
@@ -0,0 +1,3135 @@
1
+ import { o as nr, d as T, u as rr, q as hn } from "./index-a134f625.js";
2
+ class sr {
3
+ constructor(e, n, r = !0, s) {
4
+ this.automaticComponentRegistration = !0, this.registeredComponents = {}, this.propStateRegistrations = /* @__PURE__ */ new Map(), this.eventListenerRegistrations = /* @__PURE__ */ new Map(), this.host = e, this.stores = n, this.automaticComponentRegistration = r, this.eventOverrides = s, T(`[${this.hostTagName}] Initializing (abstract) provider.`, { eventOverrides: s }), this.registerComponent = this.registerComponent.bind(this), this.getStore = this.getStore.bind(this), Object.keys(this.stores).forEach((i) => {
5
+ this.propStateRegistrations.set(i, /* @__PURE__ */ new Map());
6
+ });
7
+ }
8
+ async componentWillLoad(e) {
9
+ T(`[${this.hostTagName}] Will load`), this.setupStoreListeners(), this.nylasConnector = e;
10
+ const n = Array.from(this.host.querySelectorAll("*")).filter((r) => r.tagName.toLowerCase().startsWith("nylas-"));
11
+ T(`[${this.hostTagName}] Found ${n.length} child component(s).`, { childComponents: n }), n.forEach((r) => {
12
+ const s = r;
13
+ if (!s) {
14
+ T(`[~${this.hostTagName}] Component ${s.tagName} does not have a name. Skipping.`);
15
+ return;
16
+ }
17
+ if (!s.registerNylasComponent) {
18
+ T(`[~${this.hostTagName}] Component ${s.tagName} is not a component that can be registered. Skipping.`, { component: s });
19
+ return;
20
+ }
21
+ const i = {
22
+ element: s,
23
+ name: s.tagName.toLowerCase(),
24
+ getStoresToProp: s.getStoresToProp,
25
+ storeToProps: s.storeToProps,
26
+ stateToProps: s.stateToProps,
27
+ authToProp: s.authToProp,
28
+ eventToProps: s.eventToProps,
29
+ connectorToProp: s.connectorToProp,
30
+ localPropsToProp: s.localPropsToProp
31
+ };
32
+ this.registerComponent(i);
33
+ });
34
+ }
35
+ async componentDidLoad() {
36
+ T(`[${this.hostTagName}] Did load`);
37
+ }
38
+ async componentDisconnected() {
39
+ Object.values(this.stores).forEach((e) => {
40
+ e.dispose();
41
+ });
42
+ }
43
+ async registerComponentHandler(e) {
44
+ if (e.stopPropagation(), !this.automaticComponentRegistration) {
45
+ T(`[${this.hostTagName}] Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);
46
+ return;
47
+ }
48
+ this.registerComponent(e.detail);
49
+ }
50
+ async unregisterComponentHandler(e) {
51
+ if (e.stopPropagation(), !this.automaticComponentRegistration) {
52
+ T(`[${this.hostTagName}] Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);
53
+ return;
54
+ }
55
+ this.unregisterComponent(e.detail);
56
+ }
57
+ registerComponent(e) {
58
+ T(`[${this.hostTagName}] Registering component ${e.name}.`);
59
+ const n = e.element.dataset.nylasId;
60
+ if (n && this.registeredComponents[n]) {
61
+ T(`[${this.hostTagName}] Component ${e.name} already registered. Skipping.`);
62
+ return;
63
+ }
64
+ const { stateToProps: r, getStoresToProp: s, eventToProps: i, storeToProps: o, connectorToProp: u, localPropsToProp: a, element: c } = e;
65
+ c.dataset.nylasId = rr(), this.registeredComponents[c.dataset.nylasId] = e;
66
+ const d = this.eventOverrides;
67
+ i == null || i.forEach((l, h) => {
68
+ var y;
69
+ const f = this.nylasConnector, m = async (g) => {
70
+ T(`[${this.hostTagName}] Handling "${e.name}" prop "${String(h)}" event.`, { event: g }), h in d && (T(`[${this.hostTagName}] Found event override for "${String(h)}" event. Calling override.`), await d[h](g, f)), g.defaultPrevented || await l(g, f);
71
+ }, p = e.element.dataset.nylasId;
72
+ p && !this.eventListenerRegistrations.has(p) && this.eventListenerRegistrations.set(p, []), p && ((y = this.eventListenerRegistrations.get(p)) == null || y.push([c, h, m])), T(`[${this.hostTagName}] Setting "${e.name}" event "${String(h)}" to automcially call NylasConnector method.`);
73
+ const v = hn(h.toString());
74
+ T(`[${this.hostTagName}] Adding event listener for "${v}" on "${c.tagName}"`), c.addEventListener(v, m);
75
+ }), r == null || r.forEach((l, h) => {
76
+ var y, g, b, k;
77
+ const [f, m] = h.split("."), v = this.getStore(f).state[m];
78
+ if (!c.dataset.nylasId) {
79
+ T(`[${this.hostTagName}] Component "${e.name}" not registered. Skipping.`, { component: e });
80
+ return;
81
+ }
82
+ this.propStateRegistrations.has(f) || this.propStateRegistrations.set(f, /* @__PURE__ */ new Map()), (y = this.propStateRegistrations.get(f)) != null && y.has(m) ? (k = (b = this.propStateRegistrations.get(f)) == null ? void 0 : b.get(m)) == null || k.push({
83
+ elementId: c.dataset.nylasId,
84
+ propKey: l
85
+ }) : (g = this.propStateRegistrations.get(f)) == null || g.set(m, [
86
+ {
87
+ elementId: c.dataset.nylasId,
88
+ propKey: l
89
+ }
90
+ ]), c[l.toString()] = v, T(`[${this.hostTagName}] Setting "${e.name}" prop "${l.toString()}" to "${h}" value.`, { stateValue: v });
91
+ }), a == null || a.forEach((l, h) => {
92
+ const f = this.host[h];
93
+ c[l.toString()] = f, T(`[${this.hostTagName}] Setting "${e.name}" prop "${l.toString()}" to the value of "${h}" value.`, { value: h, mappedPropValue: f });
94
+ }), s && (c[s == null ? void 0 : s.toString()] = this.getStore, T(`[${this.hostTagName}] Setting "${e.name}" prop "${s.toString()}" to "getStore" method.`)), o == null || o.forEach((l, h) => {
95
+ const f = this.getStore(h);
96
+ c[l.toString()] = f, T(`[${this.hostTagName}] Setting "${e.name}" prop "${l.toString()}" to "${h}" store.`, { store: f });
97
+ }), u && (c[u == null ? void 0 : u.toString()] = this.nylasConnector, T(`[${this.hostTagName}] Setting "${e.name}" prop "${u.toString()}" to "nylasConnector" value.`, { connectorToProp: u })), T(`[${this.hostTagName}] Component ${e.name} registered.`);
98
+ }
99
+ unregisterComponent(e) {
100
+ T(`[${this.hostTagName}] Unregistering component ${e.name}.`);
101
+ const n = e.element.dataset.nylasId;
102
+ if (!n) {
103
+ T(`[${this.hostTagName}] Component ${e.name} not registered. Skipping.`);
104
+ return;
105
+ }
106
+ if (this.registeredComponents[n]) {
107
+ T(`[${this.hostTagName}] Component ${e.name} not registered. Skipping.`);
108
+ return;
109
+ }
110
+ this.propStateRegistrations.forEach((s, i) => {
111
+ s.forEach((o, u) => {
112
+ var d, l;
113
+ const a = (d = this.propStateRegistrations.get(i)) == null ? void 0 : d.get(u), c = a == null ? void 0 : a.filter((h) => h.elementId !== n);
114
+ c && ((l = this.propStateRegistrations.get(i)) == null || l.set(u, c));
115
+ });
116
+ });
117
+ const r = this.eventListenerRegistrations.get(n);
118
+ r == null || r.forEach(([s, i, o]) => {
119
+ const u = hn(i.toString());
120
+ T(`[${this.hostTagName}] Removing event listener for "${u}" on "${s.tagName}"`), s.removeEventListener(u, o);
121
+ }), delete this.registeredComponents[n];
122
+ }
123
+ getStore(e) {
124
+ const n = this.stores[e];
125
+ if (!n)
126
+ throw new Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);
127
+ return n;
128
+ }
129
+ async setupStoreListeners() {
130
+ const e = this;
131
+ Object.entries(this.stores).forEach(([n, r]) => {
132
+ T(`[${e.hostTagName}] Listening for changes in "${n}" store.`), r.use({
133
+ set(s, i, o) {
134
+ var c;
135
+ if (T(`[${e.hostTagName}] Store "${n}" state "${s.toString()}" changed`, { newValue: i, oldValue: o }), i === o) {
136
+ T(`[${e.hostTagName}] Store "${n}" state "${s.toString()}" unchanged. Skipping.`);
137
+ return;
138
+ }
139
+ const u = e.registeredComponents;
140
+ if (!u) {
141
+ T(`[${e.hostTagName}] No registered components found. Skipping.`);
142
+ return;
143
+ }
144
+ const a = ((c = e.propStateRegistrations.get(n)) == null ? void 0 : c.get(s.toString())) || [];
145
+ T(`[${e.hostTagName}] Found ${a.length} prop(s) registered for "${s.toString()}" store.`, {
146
+ props: a,
147
+ propStateRegistrations: e.propStateRegistrations
148
+ }), a.forEach(({ elementId: d, propKey: l }) => {
149
+ const h = u[d];
150
+ if (!h) {
151
+ T(`[${e.hostTagName}] Component "${d}" not found. Skipping.`, { component: h });
152
+ return;
153
+ }
154
+ const m = e.getStore(n).state[s];
155
+ h.element[l.toString()] = m, T(`[${e.hostTagName}] Setting "${h.name}" prop "${l.toString()}" to "${s.toString()}" value.`, { stateValue: m });
156
+ });
157
+ }
158
+ });
159
+ });
160
+ }
161
+ get hostTagName() {
162
+ var e, n;
163
+ return ((n = (e = this.host) == null ? void 0 : e.tagName) == null ? void 0 : n.toLowerCase()) ?? "nylas-provider";
164
+ }
165
+ }
166
+ class ns extends sr {
167
+ }
168
+ var ir = Object.defineProperty, or = (t, e, n) => e in t ? ir(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ut = (t, e, n) => (or(t, typeof e != "symbol" ? e + "" : e, n), n), ar = /* @__PURE__ */ ((t) => (t.Error = "error", t.Warning = "warning", t.Info = "info", t.Success = "success", t))(ar || {});
169
+ const rs = (t) => t !== null && typeof t == "object" && "error" in t;
170
+ class ss extends Error {
171
+ constructor(e) {
172
+ super(e == null ? void 0 : e.message), ut(this, "apiError"), this.name = "NylasAPIError", this.stack = new Error().stack, this.apiError = e;
173
+ }
174
+ }
175
+ async function dn(t) {
176
+ const e = new TextEncoder().encode(t), n = await crypto.subtle.digest("SHA-256", e), r = Array.from(new Uint8Array(n)).map((s) => s.toString(16).padStart(2, "0")).join("");
177
+ return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
178
+ }
179
+ const K = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : nr, $ = Object.keys, M = Array.isArray;
180
+ function U(t, e) {
181
+ return typeof e != "object" || $(e).forEach(function(n) {
182
+ t[n] = e[n];
183
+ }), t;
184
+ }
185
+ typeof Promise > "u" || K.Promise || (K.Promise = Promise);
186
+ const Be = Object.getPrototypeOf, ur = {}.hasOwnProperty;
187
+ function z(t, e) {
188
+ return ur.call(t, e);
189
+ }
190
+ function Pe(t, e) {
191
+ typeof e == "function" && (e = e(Be(t))), (typeof Reflect > "u" ? $ : Reflect.ownKeys)(e).forEach((n) => {
192
+ ee(t, n, e[n]);
193
+ });
194
+ }
195
+ const Pn = Object.defineProperty;
196
+ function ee(t, e, n, r) {
197
+ Pn(t, e, U(n && z(n, "get") && typeof n.get == "function" ? { get: n.get, set: n.set, configurable: !0 } : { value: n, configurable: !0, writable: !0 }, r));
198
+ }
199
+ function ke(t) {
200
+ return { from: function(e) {
201
+ return t.prototype = Object.create(e.prototype), ee(t.prototype, "constructor", t), { extend: Pe.bind(null, t.prototype) };
202
+ } };
203
+ }
204
+ const lr = Object.getOwnPropertyDescriptor;
205
+ function Jt(t, e) {
206
+ let n;
207
+ return lr(t, e) || (n = Be(t)) && Jt(n, e);
208
+ }
209
+ const cr = [].slice;
210
+ function lt(t, e, n) {
211
+ return cr.call(t, e, n);
212
+ }
213
+ function En(t, e) {
214
+ return e(t);
215
+ }
216
+ function Ie(t) {
217
+ if (!t)
218
+ throw new Error("Assertion Failed");
219
+ }
220
+ function Cn(t) {
221
+ K.setImmediate ? setImmediate(t) : setTimeout(t, 0);
222
+ }
223
+ function Tn(t, e) {
224
+ return t.reduce((n, r, s) => {
225
+ var i = e(r, s);
226
+ return i && (n[i[0]] = i[1]), n;
227
+ }, {});
228
+ }
229
+ function te(t, e) {
230
+ if (z(t, e))
231
+ return t[e];
232
+ if (!e)
233
+ return t;
234
+ if (typeof e != "string") {
235
+ for (var n = [], r = 0, s = e.length; r < s; ++r) {
236
+ var i = te(t, e[r]);
237
+ n.push(i);
238
+ }
239
+ return n;
240
+ }
241
+ var o = e.indexOf(".");
242
+ if (o !== -1) {
243
+ var u = t[e.substr(0, o)];
244
+ return u === void 0 ? void 0 : te(u, e.substr(o + 1));
245
+ }
246
+ }
247
+ function H(t, e, n) {
248
+ if (t && e !== void 0 && (!("isFrozen" in Object) || !Object.isFrozen(t)))
249
+ if (typeof e != "string" && "length" in e) {
250
+ Ie(typeof n != "string" && "length" in n);
251
+ for (var r = 0, s = e.length; r < s; ++r)
252
+ H(t, e[r], n[r]);
253
+ } else {
254
+ var i = e.indexOf(".");
255
+ if (i !== -1) {
256
+ var o = e.substr(0, i), u = e.substr(i + 1);
257
+ if (u === "")
258
+ n === void 0 ? M(t) && !isNaN(parseInt(o)) ? t.splice(o, 1) : delete t[o] : t[o] = n;
259
+ else {
260
+ var a = t[o];
261
+ a && z(t, o) || (a = t[o] = {}), H(a, u, n);
262
+ }
263
+ } else
264
+ n === void 0 ? M(t) && !isNaN(parseInt(e)) ? t.splice(e, 1) : delete t[e] : t[e] = n;
265
+ }
266
+ }
267
+ function An(t) {
268
+ var e = {};
269
+ for (var n in t)
270
+ z(t, n) && (e[n] = t[n]);
271
+ return e;
272
+ }
273
+ const hr = [].concat;
274
+ function On(t) {
275
+ return hr.apply([], t);
276
+ }
277
+ const In = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(On([8, 16, 32, 64].map((t) => ["Int", "Uint", "Float"].map((e) => e + t + "Array")))).filter((t) => K[t]), dr = In.map((t) => K[t]);
278
+ Tn(In, (t) => [t, !0]);
279
+ let se = null;
280
+ function We(t) {
281
+ se = typeof WeakMap < "u" && /* @__PURE__ */ new WeakMap();
282
+ const e = Ct(t);
283
+ return se = null, e;
284
+ }
285
+ function Ct(t) {
286
+ if (!t || typeof t != "object")
287
+ return t;
288
+ let e = se && se.get(t);
289
+ if (e)
290
+ return e;
291
+ if (M(t)) {
292
+ e = [], se && se.set(t, e);
293
+ for (var n = 0, r = t.length; n < r; ++n)
294
+ e.push(Ct(t[n]));
295
+ } else if (dr.indexOf(t.constructor) >= 0)
296
+ e = t;
297
+ else {
298
+ const i = Be(t);
299
+ for (var s in e = i === Object.prototype ? {} : Object.create(i), se && se.set(t, e), t)
300
+ z(t, s) && (e[s] = Ct(t[s]));
301
+ }
302
+ return e;
303
+ }
304
+ const { toString: fr } = {};
305
+ function Tt(t) {
306
+ return fr.call(t).slice(8, -1);
307
+ }
308
+ const At = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", pr = typeof At == "symbol" ? function(t) {
309
+ var e;
310
+ return t != null && (e = t[At]) && e.apply(t);
311
+ } : function() {
312
+ return null;
313
+ }, _e = {};
314
+ function J(t) {
315
+ var e, n, r, s;
316
+ if (arguments.length === 1) {
317
+ if (M(t))
318
+ return t.slice();
319
+ if (this === _e && typeof t == "string")
320
+ return [t];
321
+ if (s = pr(t)) {
322
+ for (n = []; !(r = s.next()).done; )
323
+ n.push(r.value);
324
+ return n;
325
+ }
326
+ if (t == null)
327
+ return [t];
328
+ if (typeof (e = t.length) == "number") {
329
+ for (n = new Array(e); e--; )
330
+ n[e] = t[e];
331
+ return n;
332
+ }
333
+ return [t];
334
+ }
335
+ for (e = arguments.length, n = new Array(e); e--; )
336
+ n[e] = arguments[e];
337
+ return n;
338
+ }
339
+ const Zt = typeof Symbol < "u" ? (t) => t[Symbol.toStringTag] === "AsyncFunction" : () => !1;
340
+ var G = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
341
+ function Kn(t, e) {
342
+ G = t, jn = e;
343
+ }
344
+ var jn = () => !0;
345
+ const mr = !new Error("").stack;
346
+ function Ee() {
347
+ if (mr)
348
+ try {
349
+ throw new Error();
350
+ } catch (t) {
351
+ return t;
352
+ }
353
+ return new Error();
354
+ }
355
+ function Ot(t, e) {
356
+ var n = t.stack;
357
+ return n ? (e = e || 0, n.indexOf(t.name) === 0 && (e += (t.name + t.message).split(`
358
+ `).length), n.split(`
359
+ `).slice(e).filter(jn).map((r) => `
360
+ ` + r).join("")) : "";
361
+ }
362
+ var Rn = ["Unknown", "Constraint", "Data", "TransactionInactive", "ReadOnly", "Version", "NotFound", "InvalidState", "InvalidAccess", "Abort", "Timeout", "QuotaExceeded", "Syntax", "DataClone"], en = ["Modify", "Bulk", "OpenFailed", "VersionChange", "Schema", "Upgrade", "InvalidTable", "MissingAPI", "NoSuchDatabase", "InvalidArgument", "SubTransaction", "Unsupported", "Internal", "DatabaseClosed", "PrematureCommit", "ForeignAwait"].concat(Rn), gr = { VersionChanged: "Database version changed by other database connection", DatabaseClosed: "Database has been closed", Abort: "Transaction aborted", TransactionInactive: "Transaction has already completed or failed", MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb" };
363
+ function xe(t, e) {
364
+ this._e = Ee(), this.name = t, this.message = e;
365
+ }
366
+ function Nn(t, e) {
367
+ return t + ". Errors: " + Object.keys(e).map((n) => e[n].toString()).filter((n, r, s) => s.indexOf(n) === r).join(`
368
+ `);
369
+ }
370
+ function ct(t, e, n, r) {
371
+ this._e = Ee(), this.failures = e, this.failedKeys = r, this.successCount = n, this.message = Nn(t, e);
372
+ }
373
+ function je(t, e) {
374
+ this._e = Ee(), this.name = "BulkError", this.failures = Object.keys(e).map((n) => e[n]), this.failuresByPos = e, this.message = Nn(t, e);
375
+ }
376
+ ke(xe).from(Error).extend({ stack: { get: function() {
377
+ return this._stack || (this._stack = this.name + ": " + this.message + Ot(this._e, 2));
378
+ } }, toString: function() {
379
+ return this.name + ": " + this.message;
380
+ } }), ke(ct).from(xe), ke(je).from(xe);
381
+ var tn = en.reduce((t, e) => (t[e] = e + "Error", t), {});
382
+ const yr = xe;
383
+ var C = en.reduce((t, e) => {
384
+ var n = e + "Error";
385
+ function r(s, i) {
386
+ this._e = Ee(), this.name = n, s ? typeof s == "string" ? (this.message = `${s}${i ? `
387
+ ` + i : ""}`, this.inner = i || null) : typeof s == "object" && (this.message = `${s.name} ${s.message}`, this.inner = s) : (this.message = gr[e] || n, this.inner = null);
388
+ }
389
+ return ke(r).from(yr), t[e] = r, t;
390
+ }, {});
391
+ C.Syntax = SyntaxError, C.Type = TypeError, C.Range = RangeError;
392
+ var fn = Rn.reduce((t, e) => (t[e + "Error"] = C[e], t), {}), tt = en.reduce((t, e) => (["Syntax", "Type", "Range"].indexOf(e) === -1 && (t[e + "Error"] = C[e]), t), {});
393
+ function I() {
394
+ }
395
+ function Fe(t) {
396
+ return t;
397
+ }
398
+ function vr(t, e) {
399
+ return t == null || t === Fe ? e : function(n) {
400
+ return e(t(n));
401
+ };
402
+ }
403
+ function me(t, e) {
404
+ return function() {
405
+ t.apply(this, arguments), e.apply(this, arguments);
406
+ };
407
+ }
408
+ function br(t, e) {
409
+ return t === I ? e : function() {
410
+ var n = t.apply(this, arguments);
411
+ n !== void 0 && (arguments[0] = n);
412
+ var r = this.onsuccess, s = this.onerror;
413
+ this.onsuccess = null, this.onerror = null;
414
+ var i = e.apply(this, arguments);
415
+ return r && (this.onsuccess = this.onsuccess ? me(r, this.onsuccess) : r), s && (this.onerror = this.onerror ? me(s, this.onerror) : s), i !== void 0 ? i : n;
416
+ };
417
+ }
418
+ function wr(t, e) {
419
+ return t === I ? e : function() {
420
+ t.apply(this, arguments);
421
+ var n = this.onsuccess, r = this.onerror;
422
+ this.onsuccess = this.onerror = null, e.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? me(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? me(r, this.onerror) : r);
423
+ };
424
+ }
425
+ function _r(t, e) {
426
+ return t === I ? e : function(n) {
427
+ var r = t.apply(this, arguments);
428
+ U(n, r);
429
+ var s = this.onsuccess, i = this.onerror;
430
+ this.onsuccess = null, this.onerror = null;
431
+ var o = e.apply(this, arguments);
432
+ return s && (this.onsuccess = this.onsuccess ? me(s, this.onsuccess) : s), i && (this.onerror = this.onerror ? me(i, this.onerror) : i), r === void 0 ? o === void 0 ? void 0 : o : U(r, o);
433
+ };
434
+ }
435
+ function kr(t, e) {
436
+ return t === I ? e : function() {
437
+ return e.apply(this, arguments) !== !1 && t.apply(this, arguments);
438
+ };
439
+ }
440
+ function nn(t, e) {
441
+ return t === I ? e : function() {
442
+ var n = t.apply(this, arguments);
443
+ if (n && typeof n.then == "function") {
444
+ for (var r = this, s = arguments.length, i = new Array(s); s--; )
445
+ i[s] = arguments[s];
446
+ return n.then(function() {
447
+ return e.apply(r, i);
448
+ });
449
+ }
450
+ return e.apply(this, arguments);
451
+ };
452
+ }
453
+ tt.ModifyError = ct, tt.DexieError = xe, tt.BulkError = je;
454
+ var Me = {};
455
+ const $n = 100, [It, ht, Kt] = typeof Promise > "u" ? [] : (() => {
456
+ let t = Promise.resolve();
457
+ if (typeof crypto > "u" || !crypto.subtle)
458
+ return [t, Be(t), t];
459
+ const e = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
460
+ return [e, Be(e), t];
461
+ })(), Dn = ht && ht.then, nt = It && It.constructor, rn = !!Kt;
462
+ var jt = !1, xr = Kt ? () => {
463
+ Kt.then(Ye);
464
+ } : K.setImmediate ? setImmediate.bind(null, Ye) : K.MutationObserver ? () => {
465
+ var t = document.createElement("div");
466
+ new MutationObserver(() => {
467
+ Ye(), t = null;
468
+ }).observe(t, { attributes: !0 }), t.setAttribute("i", "1");
469
+ } : () => {
470
+ setTimeout(Ye, 0);
471
+ }, Re = function(t, e) {
472
+ Ke.push([t, e]), dt && (xr(), dt = !1);
473
+ }, Rt = !0, dt = !0, de = [], rt = [], Nt = null, $t = Fe, Se = { id: "global", global: !0, ref: 0, unhandleds: [], onunhandled: gn, pgp: !1, env: {}, finalize: function() {
474
+ this.unhandleds.forEach((t) => {
475
+ try {
476
+ gn(t[0], t[1]);
477
+ } catch {
478
+ }
479
+ });
480
+ } }, E = Se, Ke = [], fe = 0, st = [];
481
+ function S(t) {
482
+ if (typeof this != "object")
483
+ throw new TypeError("Promises must be constructed via new");
484
+ this._listeners = [], this.onuncatched = I, this._lib = !1;
485
+ var e = this._PSD = E;
486
+ if (G && (this._stackHolder = Ee(), this._prev = null, this._numPrev = 0), typeof t != "function") {
487
+ if (t !== Me)
488
+ throw new TypeError("Not a function");
489
+ return this._state = arguments[1], this._value = arguments[2], void (this._state === !1 && Bt(this, this._value));
490
+ }
491
+ this._state = null, this._value = null, ++e.ref, Fn(this, t);
492
+ }
493
+ const Dt = { get: function() {
494
+ var t = E, e = ft;
495
+ function n(r, s) {
496
+ var i = !t.global && (t !== E || e !== ft);
497
+ const o = i && !ne();
498
+ var u = new S((a, c) => {
499
+ sn(this, new Bn(pt(r, t, i, o), pt(s, t, i, o), a, c, t));
500
+ });
501
+ return G && Ln(u, this), u;
502
+ }
503
+ return n.prototype = Me, n;
504
+ }, set: function(t) {
505
+ ee(this, "then", t && t.prototype === Me ? Dt : { get: function() {
506
+ return t;
507
+ }, set: Dt.set });
508
+ } };
509
+ function Bn(t, e, n, r, s) {
510
+ this.onFulfilled = typeof t == "function" ? t : null, this.onRejected = typeof e == "function" ? e : null, this.resolve = n, this.reject = r, this.psd = s;
511
+ }
512
+ function Fn(t, e) {
513
+ try {
514
+ e((n) => {
515
+ if (t._state === null) {
516
+ if (n === t)
517
+ throw new TypeError("A promise cannot be resolved with itself.");
518
+ var r = t._lib && ze();
519
+ n && typeof n.then == "function" ? Fn(t, (s, i) => {
520
+ n instanceof S ? n._then(s, i) : n.then(s, i);
521
+ }) : (t._state = !0, t._value = n, Mn(t)), r && He();
522
+ }
523
+ }, Bt.bind(null, t));
524
+ } catch (n) {
525
+ Bt(t, n);
526
+ }
527
+ }
528
+ function Bt(t, e) {
529
+ if (rt.push(e), t._state === null) {
530
+ var n = t._lib && ze();
531
+ e = $t(e), t._state = !1, t._value = e, G && e !== null && typeof e == "object" && !e._promise && function(r, s, i) {
532
+ try {
533
+ r.apply(null, i);
534
+ } catch (o) {
535
+ s && s(o);
536
+ }
537
+ }(() => {
538
+ var r = Jt(e, "stack");
539
+ e._promise = t, ee(e, "stack", { get: () => jt ? r && (r.get ? r.get.apply(e) : r.value) : t.stack });
540
+ }), function(r) {
541
+ de.some((s) => s._value === r._value) || de.push(r);
542
+ }(t), Mn(t), n && He();
543
+ }
544
+ }
545
+ function Mn(t) {
546
+ var e = t._listeners;
547
+ t._listeners = [];
548
+ for (var n = 0, r = e.length; n < r; ++n)
549
+ sn(t, e[n]);
550
+ var s = t._PSD;
551
+ --s.ref || s.finalize(), fe === 0 && (++fe, Re(() => {
552
+ --fe == 0 && on();
553
+ }, []));
554
+ }
555
+ function sn(t, e) {
556
+ if (t._state !== null) {
557
+ var n = t._state ? e.onFulfilled : e.onRejected;
558
+ if (n === null)
559
+ return (t._state ? e.resolve : e.reject)(t._value);
560
+ ++e.psd.ref, ++fe, Re(Sr, [n, t, e]);
561
+ } else
562
+ t._listeners.push(e);
563
+ }
564
+ function Sr(t, e, n) {
565
+ try {
566
+ Nt = e;
567
+ var r, s = e._value;
568
+ e._state ? r = t(s) : (rt.length && (rt = []), r = t(s), rt.indexOf(s) === -1 && function(i) {
569
+ for (var o = de.length; o; )
570
+ if (de[--o]._value === i._value)
571
+ return void de.splice(o, 1);
572
+ }(e)), n.resolve(r);
573
+ } catch (i) {
574
+ n.reject(i);
575
+ } finally {
576
+ Nt = null, --fe == 0 && on(), --n.psd.ref || n.psd.finalize();
577
+ }
578
+ }
579
+ function qn(t, e, n) {
580
+ if (e.length === n)
581
+ return e;
582
+ var r = "";
583
+ if (t._state === !1) {
584
+ var s, i, o = t._value;
585
+ o != null ? (s = o.name || "Error", i = o.message || o, r = Ot(o, 0)) : (s = o, i = ""), e.push(s + (i ? ": " + i : "") + r);
586
+ }
587
+ return G && ((r = Ot(t._stackHolder, 2)) && e.indexOf(r) === -1 && e.push(r), t._prev && qn(t._prev, e, n)), e;
588
+ }
589
+ function Ln(t, e) {
590
+ var n = e ? e._numPrev + 1 : 0;
591
+ n < 100 && (t._prev = e, t._numPrev = n);
592
+ }
593
+ function Ye() {
594
+ ze() && He();
595
+ }
596
+ function ze() {
597
+ var t = Rt;
598
+ return Rt = !1, dt = !1, t;
599
+ }
600
+ function He() {
601
+ var t, e, n;
602
+ do
603
+ for (; Ke.length > 0; )
604
+ for (t = Ke, Ke = [], n = t.length, e = 0; e < n; ++e) {
605
+ var r = t[e];
606
+ r[0].apply(null, r[1]);
607
+ }
608
+ while (Ke.length > 0);
609
+ Rt = !0, dt = !0;
610
+ }
611
+ function on() {
612
+ var t = de;
613
+ de = [], t.forEach((r) => {
614
+ r._PSD.onunhandled.call(null, r._value, r);
615
+ });
616
+ for (var e = st.slice(0), n = e.length; n; )
617
+ e[--n]();
618
+ }
619
+ function Ge(t) {
620
+ return new S(Me, !1, t);
621
+ }
622
+ function j(t, e) {
623
+ var n = E;
624
+ return function() {
625
+ var r = ze(), s = E;
626
+ try {
627
+ return ae(n, !0), t.apply(this, arguments);
628
+ } catch (i) {
629
+ e && e(i);
630
+ } finally {
631
+ ae(s, !1), r && He();
632
+ }
633
+ };
634
+ }
635
+ Pe(S.prototype, { then: Dt, _then: function(t, e) {
636
+ sn(this, new Bn(null, null, t, e, E));
637
+ }, catch: function(t) {
638
+ if (arguments.length === 1)
639
+ return this.then(null, t);
640
+ var e = arguments[0], n = arguments[1];
641
+ return typeof e == "function" ? this.then(null, (r) => r instanceof e ? n(r) : Ge(r)) : this.then(null, (r) => r && r.name === e ? n(r) : Ge(r));
642
+ }, finally: function(t) {
643
+ return this.then((e) => (t(), e), (e) => (t(), Ge(e)));
644
+ }, stack: { get: function() {
645
+ if (this._stack)
646
+ return this._stack;
647
+ try {
648
+ jt = !0;
649
+ var t = qn(this, [], 20).join(`
650
+ From previous: `);
651
+ return this._state !== null && (this._stack = t), t;
652
+ } finally {
653
+ jt = !1;
654
+ }
655
+ } }, timeout: function(t, e) {
656
+ return t < 1 / 0 ? new S((n, r) => {
657
+ var s = setTimeout(() => r(new C.Timeout(e)), t);
658
+ this.then(n, r).finally(clearTimeout.bind(null, s));
659
+ }) : this;
660
+ } }), typeof Symbol < "u" && Symbol.toStringTag && ee(S.prototype, Symbol.toStringTag, "Dexie.Promise"), Se.env = Un(), Pe(S, { all: function() {
661
+ var t = J.apply(null, arguments).map(Xe);
662
+ return new S(function(e, n) {
663
+ t.length === 0 && e([]);
664
+ var r = t.length;
665
+ t.forEach((s, i) => S.resolve(s).then((o) => {
666
+ t[i] = o, --r || e(t);
667
+ }, n));
668
+ });
669
+ }, resolve: (t) => {
670
+ if (t instanceof S)
671
+ return t;
672
+ if (t && typeof t.then == "function")
673
+ return new S((n, r) => {
674
+ t.then(n, r);
675
+ });
676
+ var e = new S(Me, !0, t);
677
+ return Ln(e, Nt), e;
678
+ }, reject: Ge, race: function() {
679
+ var t = J.apply(null, arguments).map(Xe);
680
+ return new S((e, n) => {
681
+ t.map((r) => S.resolve(r).then(e, n));
682
+ });
683
+ }, PSD: { get: () => E, set: (t) => E = t }, totalEchoes: { get: () => ft }, newPSD: oe, usePSD: Te, scheduler: { get: () => Re, set: (t) => {
684
+ Re = t;
685
+ } }, rejectionMapper: { get: () => $t, set: (t) => {
686
+ $t = t;
687
+ } }, follow: (t, e) => new S((n, r) => oe((s, i) => {
688
+ var o = E;
689
+ o.unhandleds = [], o.onunhandled = i, o.finalize = me(function() {
690
+ (function(u) {
691
+ function a() {
692
+ u(), st.splice(st.indexOf(a), 1);
693
+ }
694
+ st.push(a), ++fe, Re(() => {
695
+ --fe == 0 && on();
696
+ }, []);
697
+ })(() => {
698
+ this.unhandleds.length === 0 ? s() : i(this.unhandleds[0]);
699
+ });
700
+ }, o.finalize), t();
701
+ }, e, n, r)) }), nt && (nt.allSettled && ee(S, "allSettled", function() {
702
+ const t = J.apply(null, arguments).map(Xe);
703
+ return new S((e) => {
704
+ t.length === 0 && e([]);
705
+ let n = t.length;
706
+ const r = new Array(n);
707
+ t.forEach((s, i) => S.resolve(s).then((o) => r[i] = { status: "fulfilled", value: o }, (o) => r[i] = { status: "rejected", reason: o }).then(() => --n || e(r)));
708
+ });
709
+ }), nt.any && typeof AggregateError < "u" && ee(S, "any", function() {
710
+ const t = J.apply(null, arguments).map(Xe);
711
+ return new S((e, n) => {
712
+ t.length === 0 && n(new AggregateError([]));
713
+ let r = t.length;
714
+ const s = new Array(r);
715
+ t.forEach((i, o) => S.resolve(i).then((u) => e(u), (u) => {
716
+ s[o] = u, --r || n(new AggregateError(s));
717
+ }));
718
+ });
719
+ }));
720
+ const F = { awaits: 0, echoes: 0, id: 0 };
721
+ var Pr = 0, it = [], wt = 0, ft = 0, Er = 0;
722
+ function oe(t, e, n, r) {
723
+ var s = E, i = Object.create(s);
724
+ i.parent = s, i.ref = 0, i.global = !1, i.id = ++Er;
725
+ var o = Se.env;
726
+ i.env = rn ? { Promise: S, PromiseProp: { value: S, configurable: !0, writable: !0 }, all: S.all, race: S.race, allSettled: S.allSettled, any: S.any, resolve: S.resolve, reject: S.reject, nthen: pn(o.nthen, i), gthen: pn(o.gthen, i) } : {}, e && U(i, e), ++s.ref, i.finalize = function() {
727
+ --this.parent.ref || this.parent.finalize();
728
+ };
729
+ var u = Te(i, t, n, r);
730
+ return i.ref === 0 && i.finalize(), u;
731
+ }
732
+ function Ce() {
733
+ return F.id || (F.id = ++Pr), ++F.awaits, F.echoes += $n, F.id;
734
+ }
735
+ function ne() {
736
+ return !!F.awaits && (--F.awaits == 0 && (F.id = 0), F.echoes = F.awaits * $n, !0);
737
+ }
738
+ function Xe(t) {
739
+ return F.echoes && t && t.constructor === nt ? (Ce(), t.then((e) => (ne(), e), (e) => (ne(), D(e)))) : t;
740
+ }
741
+ function Cr(t) {
742
+ ++ft, F.echoes && --F.echoes != 0 || (F.echoes = F.id = 0), it.push(E), ae(t, !0);
743
+ }
744
+ function Tr() {
745
+ var t = it[it.length - 1];
746
+ it.pop(), ae(t, !1);
747
+ }
748
+ function ae(t, e) {
749
+ var n = E;
750
+ if ((e ? !F.echoes || wt++ && t === E : !wt || --wt && t === E) || Vn(e ? Cr.bind(null, t) : Tr), t !== E && (E = t, n === Se && (Se.env = Un()), rn)) {
751
+ var r = Se.env.Promise, s = t.env;
752
+ ht.then = s.nthen, r.prototype.then = s.gthen, (n.global || t.global) && (Object.defineProperty(K, "Promise", s.PromiseProp), r.all = s.all, r.race = s.race, r.resolve = s.resolve, r.reject = s.reject, s.allSettled && (r.allSettled = s.allSettled), s.any && (r.any = s.any));
753
+ }
754
+ }
755
+ function Un() {
756
+ var t = K.Promise;
757
+ return rn ? { Promise: t, PromiseProp: Object.getOwnPropertyDescriptor(K, "Promise"), all: t.all, race: t.race, allSettled: t.allSettled, any: t.any, resolve: t.resolve, reject: t.reject, nthen: ht.then, gthen: t.prototype.then } : {};
758
+ }
759
+ function Te(t, e, n, r, s) {
760
+ var i = E;
761
+ try {
762
+ return ae(t, !0), e(n, r, s);
763
+ } finally {
764
+ ae(i, !1);
765
+ }
766
+ }
767
+ function Vn(t) {
768
+ Dn.call(It, t);
769
+ }
770
+ function pt(t, e, n, r) {
771
+ return typeof t != "function" ? t : function() {
772
+ var s = E;
773
+ n && Ce(), ae(e, !0);
774
+ try {
775
+ return t.apply(this, arguments);
776
+ } finally {
777
+ ae(s, !1), r && Vn(ne);
778
+ }
779
+ };
780
+ }
781
+ function pn(t, e) {
782
+ return function(n, r) {
783
+ return t.call(this, pt(n, e), pt(r, e));
784
+ };
785
+ }
786
+ ("" + Dn).indexOf("[native code]") === -1 && (Ce = ne = I);
787
+ const mn = "unhandledrejection";
788
+ function gn(t, e) {
789
+ var n;
790
+ try {
791
+ n = e.onuncatched(t);
792
+ } catch {
793
+ }
794
+ if (n !== !1)
795
+ try {
796
+ var r, s = { promise: e, reason: t };
797
+ if (K.document && document.createEvent ? ((r = document.createEvent("Event")).initEvent(mn, !0, !0), U(r, s)) : K.CustomEvent && U(r = new CustomEvent(mn, { detail: s }), s), r && K.dispatchEvent && (dispatchEvent(r), !K.PromiseRejectionEvent && K.onunhandledrejection))
798
+ try {
799
+ K.onunhandledrejection(r);
800
+ } catch {
801
+ }
802
+ G && r && !r.defaultPrevented && console.warn(`Unhandled rejection: ${t.stack || t}`);
803
+ } catch {
804
+ }
805
+ }
806
+ var D = S.reject;
807
+ function Ft(t, e, n, r) {
808
+ if (t.idbdb && (t._state.openComplete || E.letThrough || t._vip)) {
809
+ var s = t._createTransaction(e, n, t._dbSchema);
810
+ try {
811
+ s.create(), t._state.PR1398_maxLoop = 3;
812
+ } catch (i) {
813
+ return i.name === tn.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => Ft(t, e, n, r))) : D(i);
814
+ }
815
+ return s._promise(e, (i, o) => oe(() => (E.trans = s, r(i, o, s)))).then((i) => s._completion.then(() => i));
816
+ }
817
+ if (t._state.openComplete)
818
+ return D(new C.DatabaseClosed(t._state.dbOpenError));
819
+ if (!t._state.isBeingOpened) {
820
+ if (!t._options.autoOpen)
821
+ return D(new C.DatabaseClosed());
822
+ t.open().catch(I);
823
+ }
824
+ return t._state.dbReadyPromise.then(() => Ft(t, e, n, r));
825
+ }
826
+ const yn = "3.2.4", he = String.fromCharCode(65535), Mt = -1 / 0, X = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", Wn = "String expected.", Ne = [], yt = typeof navigator < "u" && /(MSIE|Trident|Edge)/.test(navigator.userAgent), Ar = yt, Or = yt, zn = (t) => !/(dexie\.js|dexie\.min\.js)/.test(t), vt = "__dbnames", _t = "readonly", kt = "readwrite";
827
+ function ge(t, e) {
828
+ return t ? e ? function() {
829
+ return t.apply(this, arguments) && e.apply(this, arguments);
830
+ } : t : e;
831
+ }
832
+ const Hn = { type: 3, lower: -1 / 0, lowerOpen: !1, upper: [[]], upperOpen: !1 };
833
+ function Qe(t) {
834
+ return typeof t != "string" || /\./.test(t) ? (e) => e : (e) => (e[t] === void 0 && t in e && delete (e = We(e))[t], e);
835
+ }
836
+ class Ir {
837
+ _trans(e, n, r) {
838
+ const s = this._tx || E.trans, i = this.name;
839
+ function o(a, c, d) {
840
+ if (!d.schema[i])
841
+ throw new C.NotFound("Table " + i + " not part of transaction");
842
+ return n(d.idbtrans, d);
843
+ }
844
+ const u = ze();
845
+ try {
846
+ return s && s.db === this.db ? s === E.trans ? s._promise(e, o, r) : oe(() => s._promise(e, o, r), { trans: s, transless: E.transless || E }) : Ft(this.db, e, [this.name], o);
847
+ } finally {
848
+ u && He();
849
+ }
850
+ }
851
+ get(e, n) {
852
+ return e && e.constructor === Object ? this.where(e).first(n) : this._trans("readonly", (r) => this.core.get({ trans: r, key: e }).then((s) => this.hook.reading.fire(s))).then(n);
853
+ }
854
+ where(e) {
855
+ if (typeof e == "string")
856
+ return new this.db.WhereClause(this, e);
857
+ if (M(e))
858
+ return new this.db.WhereClause(this, `[${e.join("+")}]`);
859
+ const n = $(e);
860
+ if (n.length === 1)
861
+ return this.where(n[0]).equals(e[n[0]]);
862
+ const r = this.schema.indexes.concat(this.schema.primKey).filter((c) => c.compound && n.every((d) => c.keyPath.indexOf(d) >= 0) && c.keyPath.every((d) => n.indexOf(d) >= 0))[0];
863
+ if (r && this.db._maxKey !== he)
864
+ return this.where(r.name).equals(r.keyPath.map((c) => e[c]));
865
+ !r && G && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);
866
+ const { idxByName: s } = this.schema, i = this.db._deps.indexedDB;
867
+ function o(c, d) {
868
+ try {
869
+ return i.cmp(c, d) === 0;
870
+ } catch {
871
+ return !1;
872
+ }
873
+ }
874
+ const [u, a] = n.reduce(([c, d], l) => {
875
+ const h = s[l], f = e[l];
876
+ return [c || h, c || !h ? ge(d, h && h.multi ? (m) => {
877
+ const p = te(m, l);
878
+ return M(p) && p.some((v) => o(f, v));
879
+ } : (m) => o(f, te(m, l))) : d];
880
+ }, [null, null]);
881
+ return u ? this.where(u.name).equals(e[u.keyPath]).filter(a) : r ? this.filter(a) : this.where(n).equals("");
882
+ }
883
+ filter(e) {
884
+ return this.toCollection().and(e);
885
+ }
886
+ count(e) {
887
+ return this.toCollection().count(e);
888
+ }
889
+ offset(e) {
890
+ return this.toCollection().offset(e);
891
+ }
892
+ limit(e) {
893
+ return this.toCollection().limit(e);
894
+ }
895
+ each(e) {
896
+ return this.toCollection().each(e);
897
+ }
898
+ toArray(e) {
899
+ return this.toCollection().toArray(e);
900
+ }
901
+ toCollection() {
902
+ return new this.db.Collection(new this.db.WhereClause(this));
903
+ }
904
+ orderBy(e) {
905
+ return new this.db.Collection(new this.db.WhereClause(this, M(e) ? `[${e.join("+")}]` : e));
906
+ }
907
+ reverse() {
908
+ return this.toCollection().reverse();
909
+ }
910
+ mapToClass(e) {
911
+ this.schema.mappedClass = e;
912
+ const n = (r) => {
913
+ if (!r)
914
+ return r;
915
+ const s = Object.create(e.prototype);
916
+ for (var i in r)
917
+ if (z(r, i))
918
+ try {
919
+ s[i] = r[i];
920
+ } catch {
921
+ }
922
+ return s;
923
+ };
924
+ return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = n, this.hook("reading", n), e;
925
+ }
926
+ defineClass() {
927
+ return this.mapToClass(function(e) {
928
+ U(this, e);
929
+ });
930
+ }
931
+ add(e, n) {
932
+ const { auto: r, keyPath: s } = this.schema.primKey;
933
+ let i = e;
934
+ return s && r && (i = Qe(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "add", keys: n != null ? [n] : null, values: [i] })).then((o) => o.numFailures ? S.reject(o.failures[0]) : o.lastResult).then((o) => {
935
+ if (s)
936
+ try {
937
+ H(e, s, o);
938
+ } catch {
939
+ }
940
+ return o;
941
+ });
942
+ }
943
+ update(e, n) {
944
+ if (typeof e != "object" || M(e))
945
+ return this.where(":id").equals(e).modify(n);
946
+ {
947
+ const r = te(e, this.schema.primKey.keyPath);
948
+ if (r === void 0)
949
+ return D(new C.InvalidArgument("Given object does not contain its primary key"));
950
+ try {
951
+ typeof n != "function" ? $(n).forEach((s) => {
952
+ H(e, s, n[s]);
953
+ }) : n(e, { value: e, primKey: r });
954
+ } catch {
955
+ }
956
+ return this.where(":id").equals(r).modify(n);
957
+ }
958
+ }
959
+ put(e, n) {
960
+ const { auto: r, keyPath: s } = this.schema.primKey;
961
+ let i = e;
962
+ return s && r && (i = Qe(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "put", values: [i], keys: n != null ? [n] : null })).then((o) => o.numFailures ? S.reject(o.failures[0]) : o.lastResult).then((o) => {
963
+ if (s)
964
+ try {
965
+ H(e, s, o);
966
+ } catch {
967
+ }
968
+ return o;
969
+ });
970
+ }
971
+ delete(e) {
972
+ return this._trans("readwrite", (n) => this.core.mutate({ trans: n, type: "delete", keys: [e] })).then((n) => n.numFailures ? S.reject(n.failures[0]) : void 0);
973
+ }
974
+ clear() {
975
+ return this._trans("readwrite", (e) => this.core.mutate({ trans: e, type: "deleteRange", range: Hn })).then((e) => e.numFailures ? S.reject(e.failures[0]) : void 0);
976
+ }
977
+ bulkGet(e) {
978
+ return this._trans("readonly", (n) => this.core.getMany({ keys: e, trans: n }).then((r) => r.map((s) => this.hook.reading.fire(s))));
979
+ }
980
+ bulkAdd(e, n, r) {
981
+ const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
982
+ return this._trans("readwrite", (o) => {
983
+ const { auto: u, keyPath: a } = this.schema.primKey;
984
+ if (a && s)
985
+ throw new C.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
986
+ if (s && s.length !== e.length)
987
+ throw new C.InvalidArgument("Arguments objects and keys must have the same length");
988
+ const c = e.length;
989
+ let d = a && u ? e.map(Qe(a)) : e;
990
+ return this.core.mutate({ trans: o, type: "add", keys: s, values: d, wantResults: i }).then(({ numFailures: l, results: h, lastResult: f, failures: m }) => {
991
+ if (l === 0)
992
+ return i ? h : f;
993
+ throw new je(`${this.name}.bulkAdd(): ${l} of ${c} operations failed`, m);
994
+ });
995
+ });
996
+ }
997
+ bulkPut(e, n, r) {
998
+ const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
999
+ return this._trans("readwrite", (o) => {
1000
+ const { auto: u, keyPath: a } = this.schema.primKey;
1001
+ if (a && s)
1002
+ throw new C.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
1003
+ if (s && s.length !== e.length)
1004
+ throw new C.InvalidArgument("Arguments objects and keys must have the same length");
1005
+ const c = e.length;
1006
+ let d = a && u ? e.map(Qe(a)) : e;
1007
+ return this.core.mutate({ trans: o, type: "put", keys: s, values: d, wantResults: i }).then(({ numFailures: l, results: h, lastResult: f, failures: m }) => {
1008
+ if (l === 0)
1009
+ return i ? h : f;
1010
+ throw new je(`${this.name}.bulkPut(): ${l} of ${c} operations failed`, m);
1011
+ });
1012
+ });
1013
+ }
1014
+ bulkDelete(e) {
1015
+ const n = e.length;
1016
+ return this._trans("readwrite", (r) => this.core.mutate({ trans: r, type: "delete", keys: e })).then(({ numFailures: r, lastResult: s, failures: i }) => {
1017
+ if (r === 0)
1018
+ return s;
1019
+ throw new je(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
1020
+ });
1021
+ }
1022
+ }
1023
+ function $e(t) {
1024
+ var e = {}, n = function(o, u) {
1025
+ if (u) {
1026
+ for (var a = arguments.length, c = new Array(a - 1); --a; )
1027
+ c[a - 1] = arguments[a];
1028
+ return e[o].subscribe.apply(null, c), t;
1029
+ }
1030
+ if (typeof o == "string")
1031
+ return e[o];
1032
+ };
1033
+ n.addEventType = i;
1034
+ for (var r = 1, s = arguments.length; r < s; ++r)
1035
+ i(arguments[r]);
1036
+ return n;
1037
+ function i(o, u, a) {
1038
+ if (typeof o != "object") {
1039
+ var c;
1040
+ u || (u = kr), a || (a = I);
1041
+ var d = { subscribers: [], fire: a, subscribe: function(l) {
1042
+ d.subscribers.indexOf(l) === -1 && (d.subscribers.push(l), d.fire = u(d.fire, l));
1043
+ }, unsubscribe: function(l) {
1044
+ d.subscribers = d.subscribers.filter(function(h) {
1045
+ return h !== l;
1046
+ }), d.fire = d.subscribers.reduce(u, a);
1047
+ } };
1048
+ return e[o] = n[o] = d, d;
1049
+ }
1050
+ $(c = o).forEach(function(l) {
1051
+ var h = c[l];
1052
+ if (M(h))
1053
+ i(l, c[l][0], c[l][1]);
1054
+ else {
1055
+ if (h !== "asap")
1056
+ throw new C.InvalidArgument("Invalid event config");
1057
+ var f = i(l, Fe, function() {
1058
+ for (var m = arguments.length, p = new Array(m); m--; )
1059
+ p[m] = arguments[m];
1060
+ f.subscribers.forEach(function(v) {
1061
+ Cn(function() {
1062
+ v.apply(null, p);
1063
+ });
1064
+ });
1065
+ });
1066
+ }
1067
+ });
1068
+ }
1069
+ }
1070
+ function Oe(t, e) {
1071
+ return ke(e).from({ prototype: t }), e;
1072
+ }
1073
+ function be(t, e) {
1074
+ return !(t.filter || t.algorithm || t.or) && (e ? t.justLimit : !t.replayFilter);
1075
+ }
1076
+ function xt(t, e) {
1077
+ t.filter = ge(t.filter, e);
1078
+ }
1079
+ function St(t, e, n) {
1080
+ var r = t.replayFilter;
1081
+ t.replayFilter = r ? () => ge(r(), e()) : e, t.justLimit = n && !r;
1082
+ }
1083
+ function ot(t, e) {
1084
+ if (t.isPrimKey)
1085
+ return e.primaryKey;
1086
+ const n = e.getIndexByKeyPath(t.index);
1087
+ if (!n)
1088
+ throw new C.Schema("KeyPath " + t.index + " on object store " + e.name + " is not indexed");
1089
+ return n;
1090
+ }
1091
+ function vn(t, e, n) {
1092
+ const r = ot(t, e.schema);
1093
+ return e.openCursor({ trans: n, values: !t.keysOnly, reverse: t.dir === "prev", unique: !!t.unique, query: { index: r, range: t.range } });
1094
+ }
1095
+ function Je(t, e, n, r) {
1096
+ const s = t.replayFilter ? ge(t.filter, t.replayFilter()) : t.filter;
1097
+ if (t.or) {
1098
+ const i = {}, o = (u, a, c) => {
1099
+ if (!s || s(a, c, (h) => a.stop(h), (h) => a.fail(h))) {
1100
+ var d = a.primaryKey, l = "" + d;
1101
+ l === "[object ArrayBuffer]" && (l = "" + new Uint8Array(d)), z(i, l) || (i[l] = !0, e(u, a, c));
1102
+ }
1103
+ };
1104
+ return Promise.all([t.or._iterate(o, n), bn(vn(t, r, n), t.algorithm, o, !t.keysOnly && t.valueMapper)]);
1105
+ }
1106
+ return bn(vn(t, r, n), ge(t.algorithm, s), e, !t.keysOnly && t.valueMapper);
1107
+ }
1108
+ function bn(t, e, n, r) {
1109
+ var s = j(r ? (i, o, u) => n(r(i), o, u) : n);
1110
+ return t.then((i) => {
1111
+ if (i)
1112
+ return i.start(() => {
1113
+ var o = () => i.continue();
1114
+ e && !e(i, (u) => o = u, (u) => {
1115
+ i.stop(u), o = I;
1116
+ }, (u) => {
1117
+ i.fail(u), o = I;
1118
+ }) || s(i.value, i, (u) => o = u), o();
1119
+ });
1120
+ });
1121
+ }
1122
+ function L(t, e) {
1123
+ try {
1124
+ const n = wn(t), r = wn(e);
1125
+ if (n !== r)
1126
+ return n === "Array" ? 1 : r === "Array" ? -1 : n === "binary" ? 1 : r === "binary" ? -1 : n === "string" ? 1 : r === "string" ? -1 : n === "Date" ? 1 : r !== "Date" ? NaN : -1;
1127
+ switch (n) {
1128
+ case "number":
1129
+ case "Date":
1130
+ case "string":
1131
+ return t > e ? 1 : t < e ? -1 : 0;
1132
+ case "binary":
1133
+ return function(s, i) {
1134
+ const o = s.length, u = i.length, a = o < u ? o : u;
1135
+ for (let c = 0; c < a; ++c)
1136
+ if (s[c] !== i[c])
1137
+ return s[c] < i[c] ? -1 : 1;
1138
+ return o === u ? 0 : o < u ? -1 : 1;
1139
+ }(_n(t), _n(e));
1140
+ case "Array":
1141
+ return function(s, i) {
1142
+ const o = s.length, u = i.length, a = o < u ? o : u;
1143
+ for (let c = 0; c < a; ++c) {
1144
+ const d = L(s[c], i[c]);
1145
+ if (d !== 0)
1146
+ return d;
1147
+ }
1148
+ return o === u ? 0 : o < u ? -1 : 1;
1149
+ }(t, e);
1150
+ }
1151
+ } catch {
1152
+ }
1153
+ return NaN;
1154
+ }
1155
+ function wn(t) {
1156
+ const e = typeof t;
1157
+ if (e !== "object")
1158
+ return e;
1159
+ if (ArrayBuffer.isView(t))
1160
+ return "binary";
1161
+ const n = Tt(t);
1162
+ return n === "ArrayBuffer" ? "binary" : n;
1163
+ }
1164
+ function _n(t) {
1165
+ return t instanceof Uint8Array ? t : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t);
1166
+ }
1167
+ class Kr {
1168
+ _read(e, n) {
1169
+ var r = this._ctx;
1170
+ return r.error ? r.table._trans(null, D.bind(null, r.error)) : r.table._trans("readonly", e).then(n);
1171
+ }
1172
+ _write(e) {
1173
+ var n = this._ctx;
1174
+ return n.error ? n.table._trans(null, D.bind(null, n.error)) : n.table._trans("readwrite", e, "locked");
1175
+ }
1176
+ _addAlgorithm(e) {
1177
+ var n = this._ctx;
1178
+ n.algorithm = ge(n.algorithm, e);
1179
+ }
1180
+ _iterate(e, n) {
1181
+ return Je(this._ctx, e, n, this._ctx.table.core);
1182
+ }
1183
+ clone(e) {
1184
+ var n = Object.create(this.constructor.prototype), r = Object.create(this._ctx);
1185
+ return e && U(r, e), n._ctx = r, n;
1186
+ }
1187
+ raw() {
1188
+ return this._ctx.valueMapper = null, this;
1189
+ }
1190
+ each(e) {
1191
+ var n = this._ctx;
1192
+ return this._read((r) => Je(n, e, r, n.table.core));
1193
+ }
1194
+ count(e) {
1195
+ return this._read((n) => {
1196
+ const r = this._ctx, s = r.table.core;
1197
+ if (be(r, !0))
1198
+ return s.count({ trans: n, query: { index: ot(r, s.schema), range: r.range } }).then((o) => Math.min(o, r.limit));
1199
+ var i = 0;
1200
+ return Je(r, () => (++i, !1), n, s).then(() => i);
1201
+ }).then(e);
1202
+ }
1203
+ sortBy(e, n) {
1204
+ const r = e.split(".").reverse(), s = r[0], i = r.length - 1;
1205
+ function o(c, d) {
1206
+ return d ? o(c[r[d]], d - 1) : c[s];
1207
+ }
1208
+ var u = this._ctx.dir === "next" ? 1 : -1;
1209
+ function a(c, d) {
1210
+ var l = o(c, i), h = o(d, i);
1211
+ return l < h ? -u : l > h ? u : 0;
1212
+ }
1213
+ return this.toArray(function(c) {
1214
+ return c.sort(a);
1215
+ }).then(n);
1216
+ }
1217
+ toArray(e) {
1218
+ return this._read((n) => {
1219
+ var r = this._ctx;
1220
+ if (r.dir === "next" && be(r, !0) && r.limit > 0) {
1221
+ const { valueMapper: s } = r, i = ot(r, r.table.core.schema);
1222
+ return r.table.core.query({ trans: n, limit: r.limit, values: !0, query: { index: i, range: r.range } }).then(({ result: o }) => s ? o.map(s) : o);
1223
+ }
1224
+ {
1225
+ const s = [];
1226
+ return Je(r, (i) => s.push(i), n, r.table.core).then(() => s);
1227
+ }
1228
+ }, e);
1229
+ }
1230
+ offset(e) {
1231
+ var n = this._ctx;
1232
+ return e <= 0 || (n.offset += e, be(n) ? St(n, () => {
1233
+ var r = e;
1234
+ return (s, i) => r === 0 || (r === 1 ? (--r, !1) : (i(() => {
1235
+ s.advance(r), r = 0;
1236
+ }), !1));
1237
+ }) : St(n, () => {
1238
+ var r = e;
1239
+ return () => --r < 0;
1240
+ })), this;
1241
+ }
1242
+ limit(e) {
1243
+ return this._ctx.limit = Math.min(this._ctx.limit, e), St(this._ctx, () => {
1244
+ var n = e;
1245
+ return function(r, s, i) {
1246
+ return --n <= 0 && s(i), n >= 0;
1247
+ };
1248
+ }, !0), this;
1249
+ }
1250
+ until(e, n) {
1251
+ return xt(this._ctx, function(r, s, i) {
1252
+ return !e(r.value) || (s(i), n);
1253
+ }), this;
1254
+ }
1255
+ first(e) {
1256
+ return this.limit(1).toArray(function(n) {
1257
+ return n[0];
1258
+ }).then(e);
1259
+ }
1260
+ last(e) {
1261
+ return this.reverse().first(e);
1262
+ }
1263
+ filter(e) {
1264
+ var n, r;
1265
+ return xt(this._ctx, function(s) {
1266
+ return e(s.value);
1267
+ }), n = this._ctx, r = e, n.isMatch = ge(n.isMatch, r), this;
1268
+ }
1269
+ and(e) {
1270
+ return this.filter(e);
1271
+ }
1272
+ or(e) {
1273
+ return new this.db.WhereClause(this._ctx.table, e, this);
1274
+ }
1275
+ reverse() {
1276
+ return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
1277
+ }
1278
+ desc() {
1279
+ return this.reverse();
1280
+ }
1281
+ eachKey(e) {
1282
+ var n = this._ctx;
1283
+ return n.keysOnly = !n.isMatch, this.each(function(r, s) {
1284
+ e(s.key, s);
1285
+ });
1286
+ }
1287
+ eachUniqueKey(e) {
1288
+ return this._ctx.unique = "unique", this.eachKey(e);
1289
+ }
1290
+ eachPrimaryKey(e) {
1291
+ var n = this._ctx;
1292
+ return n.keysOnly = !n.isMatch, this.each(function(r, s) {
1293
+ e(s.primaryKey, s);
1294
+ });
1295
+ }
1296
+ keys(e) {
1297
+ var n = this._ctx;
1298
+ n.keysOnly = !n.isMatch;
1299
+ var r = [];
1300
+ return this.each(function(s, i) {
1301
+ r.push(i.key);
1302
+ }).then(function() {
1303
+ return r;
1304
+ }).then(e);
1305
+ }
1306
+ primaryKeys(e) {
1307
+ var n = this._ctx;
1308
+ if (n.dir === "next" && be(n, !0) && n.limit > 0)
1309
+ return this._read((s) => {
1310
+ var i = ot(n, n.table.core.schema);
1311
+ return n.table.core.query({ trans: s, values: !1, limit: n.limit, query: { index: i, range: n.range } });
1312
+ }).then(({ result: s }) => s).then(e);
1313
+ n.keysOnly = !n.isMatch;
1314
+ var r = [];
1315
+ return this.each(function(s, i) {
1316
+ r.push(i.primaryKey);
1317
+ }).then(function() {
1318
+ return r;
1319
+ }).then(e);
1320
+ }
1321
+ uniqueKeys(e) {
1322
+ return this._ctx.unique = "unique", this.keys(e);
1323
+ }
1324
+ firstKey(e) {
1325
+ return this.limit(1).keys(function(n) {
1326
+ return n[0];
1327
+ }).then(e);
1328
+ }
1329
+ lastKey(e) {
1330
+ return this.reverse().firstKey(e);
1331
+ }
1332
+ distinct() {
1333
+ var e = this._ctx, n = e.index && e.table.schema.idxByName[e.index];
1334
+ if (!n || !n.multi)
1335
+ return this;
1336
+ var r = {};
1337
+ return xt(this._ctx, function(s) {
1338
+ var i = s.primaryKey.toString(), o = z(r, i);
1339
+ return r[i] = !0, !o;
1340
+ }), this;
1341
+ }
1342
+ modify(e) {
1343
+ var n = this._ctx;
1344
+ return this._write((r) => {
1345
+ var s;
1346
+ if (typeof e == "function")
1347
+ s = e;
1348
+ else {
1349
+ var i = $(e), o = i.length;
1350
+ s = function(p) {
1351
+ for (var v = !1, y = 0; y < o; ++y) {
1352
+ var g = i[y], b = e[g];
1353
+ te(p, g) !== b && (H(p, g, b), v = !0);
1354
+ }
1355
+ return v;
1356
+ };
1357
+ }
1358
+ const u = n.table.core, { outbound: a, extractKey: c } = u.schema.primaryKey, d = this.db._options.modifyChunkSize || 200, l = [];
1359
+ let h = 0;
1360
+ const f = [], m = (p, v) => {
1361
+ const { failures: y, numFailures: g } = v;
1362
+ h += p - g;
1363
+ for (let b of $(y))
1364
+ l.push(y[b]);
1365
+ };
1366
+ return this.clone().primaryKeys().then((p) => {
1367
+ const v = (y) => {
1368
+ const g = Math.min(d, p.length - y);
1369
+ return u.getMany({ trans: r, keys: p.slice(y, y + g), cache: "immutable" }).then((b) => {
1370
+ const k = [], P = [], x = a ? [] : null, w = [];
1371
+ for (let _ = 0; _ < g; ++_) {
1372
+ const R = b[_], O = { value: We(R), primKey: p[y + _] };
1373
+ s.call(O, O.value, O) !== !1 && (O.value == null ? w.push(p[y + _]) : a || L(c(R), c(O.value)) === 0 ? (P.push(O.value), a && x.push(p[y + _])) : (w.push(p[y + _]), k.push(O.value)));
1374
+ }
1375
+ const A = be(n) && n.limit === 1 / 0 && (typeof e != "function" || e === Pt) && { index: n.index, range: n.range };
1376
+ return Promise.resolve(k.length > 0 && u.mutate({ trans: r, type: "add", values: k }).then((_) => {
1377
+ for (let R in _.failures)
1378
+ w.splice(parseInt(R), 1);
1379
+ m(k.length, _);
1380
+ })).then(() => (P.length > 0 || A && typeof e == "object") && u.mutate({ trans: r, type: "put", keys: x, values: P, criteria: A, changeSpec: typeof e != "function" && e }).then((_) => m(P.length, _))).then(() => (w.length > 0 || A && e === Pt) && u.mutate({ trans: r, type: "delete", keys: w, criteria: A }).then((_) => m(w.length, _))).then(() => p.length > y + g && v(y + d));
1381
+ });
1382
+ };
1383
+ return v(0).then(() => {
1384
+ if (l.length > 0)
1385
+ throw new ct("Error modifying one or more objects", l, h, f);
1386
+ return p.length;
1387
+ });
1388
+ });
1389
+ });
1390
+ }
1391
+ delete() {
1392
+ var e = this._ctx, n = e.range;
1393
+ return be(e) && (e.isPrimKey && !Or || n.type === 3) ? this._write((r) => {
1394
+ const { primaryKey: s } = e.table.core.schema, i = n;
1395
+ return e.table.core.count({ trans: r, query: { index: s, range: i } }).then((o) => e.table.core.mutate({ trans: r, type: "deleteRange", range: i }).then(({ failures: u, lastResult: a, results: c, numFailures: d }) => {
1396
+ if (d)
1397
+ throw new ct("Could not delete some values", Object.keys(u).map((l) => u[l]), o - d);
1398
+ return o - d;
1399
+ }));
1400
+ }) : this.modify(Pt);
1401
+ }
1402
+ }
1403
+ const Pt = (t, e) => e.value = null;
1404
+ function jr(t, e) {
1405
+ return t < e ? -1 : t === e ? 0 : 1;
1406
+ }
1407
+ function Rr(t, e) {
1408
+ return t > e ? -1 : t === e ? 0 : 1;
1409
+ }
1410
+ function W(t, e, n) {
1411
+ var r = t instanceof Gn ? new t.Collection(t) : t;
1412
+ return r._ctx.error = n ? new n(e) : new TypeError(e), r;
1413
+ }
1414
+ function we(t) {
1415
+ return new t.Collection(t, () => Yn("")).limit(0);
1416
+ }
1417
+ function Nr(t, e, n, r, s, i) {
1418
+ for (var o = Math.min(t.length, r.length), u = -1, a = 0; a < o; ++a) {
1419
+ var c = e[a];
1420
+ if (c !== r[a])
1421
+ return s(t[a], n[a]) < 0 ? t.substr(0, a) + n[a] + n.substr(a + 1) : s(t[a], r[a]) < 0 ? t.substr(0, a) + r[a] + n.substr(a + 1) : u >= 0 ? t.substr(0, u) + e[u] + n.substr(u + 1) : null;
1422
+ s(t[a], c) < 0 && (u = a);
1423
+ }
1424
+ return o < r.length && i === "next" ? t + n.substr(t.length) : o < t.length && i === "prev" ? t.substr(0, n.length) : u < 0 ? null : t.substr(0, u) + r[u] + n.substr(u + 1);
1425
+ }
1426
+ function Ze(t, e, n, r) {
1427
+ var s, i, o, u, a, c, d, l = n.length;
1428
+ if (!n.every((p) => typeof p == "string"))
1429
+ return W(t, Wn);
1430
+ function h(p) {
1431
+ s = function(y) {
1432
+ return y === "next" ? (g) => g.toUpperCase() : (g) => g.toLowerCase();
1433
+ }(p), i = function(y) {
1434
+ return y === "next" ? (g) => g.toLowerCase() : (g) => g.toUpperCase();
1435
+ }(p), o = p === "next" ? jr : Rr;
1436
+ var v = n.map(function(y) {
1437
+ return { lower: i(y), upper: s(y) };
1438
+ }).sort(function(y, g) {
1439
+ return o(y.lower, g.lower);
1440
+ });
1441
+ u = v.map(function(y) {
1442
+ return y.upper;
1443
+ }), a = v.map(function(y) {
1444
+ return y.lower;
1445
+ }), c = p, d = p === "next" ? "" : r;
1446
+ }
1447
+ h("next");
1448
+ var f = new t.Collection(t, () => re(u[0], a[l - 1] + r));
1449
+ f._ondirectionchange = function(p) {
1450
+ h(p);
1451
+ };
1452
+ var m = 0;
1453
+ return f._addAlgorithm(function(p, v, y) {
1454
+ var g = p.key;
1455
+ if (typeof g != "string")
1456
+ return !1;
1457
+ var b = i(g);
1458
+ if (e(b, a, m))
1459
+ return !0;
1460
+ for (var k = null, P = m; P < l; ++P) {
1461
+ var x = Nr(g, b, u[P], a[P], o, c);
1462
+ x === null && k === null ? m = P + 1 : (k === null || o(k, x) > 0) && (k = x);
1463
+ }
1464
+ return v(k !== null ? function() {
1465
+ p.continue(k + d);
1466
+ } : y), !1;
1467
+ }), f;
1468
+ }
1469
+ function re(t, e, n, r) {
1470
+ return { type: 2, lower: t, upper: e, lowerOpen: n, upperOpen: r };
1471
+ }
1472
+ function Yn(t) {
1473
+ return { type: 1, lower: t, upper: t };
1474
+ }
1475
+ class Gn {
1476
+ get Collection() {
1477
+ return this._ctx.table.db.Collection;
1478
+ }
1479
+ between(e, n, r, s) {
1480
+ r = r !== !1, s = s === !0;
1481
+ try {
1482
+ return this._cmp(e, n) > 0 || this._cmp(e, n) === 0 && (r || s) && (!r || !s) ? we(this) : new this.Collection(this, () => re(e, n, !r, !s));
1483
+ } catch {
1484
+ return W(this, X);
1485
+ }
1486
+ }
1487
+ equals(e) {
1488
+ return e == null ? W(this, X) : new this.Collection(this, () => Yn(e));
1489
+ }
1490
+ above(e) {
1491
+ return e == null ? W(this, X) : new this.Collection(this, () => re(e, void 0, !0));
1492
+ }
1493
+ aboveOrEqual(e) {
1494
+ return e == null ? W(this, X) : new this.Collection(this, () => re(e, void 0, !1));
1495
+ }
1496
+ below(e) {
1497
+ return e == null ? W(this, X) : new this.Collection(this, () => re(void 0, e, !1, !0));
1498
+ }
1499
+ belowOrEqual(e) {
1500
+ return e == null ? W(this, X) : new this.Collection(this, () => re(void 0, e));
1501
+ }
1502
+ startsWith(e) {
1503
+ return typeof e != "string" ? W(this, Wn) : this.between(e, e + he, !0, !0);
1504
+ }
1505
+ startsWithIgnoreCase(e) {
1506
+ return e === "" ? this.startsWith(e) : Ze(this, (n, r) => n.indexOf(r[0]) === 0, [e], he);
1507
+ }
1508
+ equalsIgnoreCase(e) {
1509
+ return Ze(this, (n, r) => n === r[0], [e], "");
1510
+ }
1511
+ anyOfIgnoreCase() {
1512
+ var e = J.apply(_e, arguments);
1513
+ return e.length === 0 ? we(this) : Ze(this, (n, r) => r.indexOf(n) !== -1, e, "");
1514
+ }
1515
+ startsWithAnyOfIgnoreCase() {
1516
+ var e = J.apply(_e, arguments);
1517
+ return e.length === 0 ? we(this) : Ze(this, (n, r) => r.some((s) => n.indexOf(s) === 0), e, he);
1518
+ }
1519
+ anyOf() {
1520
+ const e = J.apply(_e, arguments);
1521
+ let n = this._cmp;
1522
+ try {
1523
+ e.sort(n);
1524
+ } catch {
1525
+ return W(this, X);
1526
+ }
1527
+ if (e.length === 0)
1528
+ return we(this);
1529
+ const r = new this.Collection(this, () => re(e[0], e[e.length - 1]));
1530
+ r._ondirectionchange = (i) => {
1531
+ n = i === "next" ? this._ascending : this._descending, e.sort(n);
1532
+ };
1533
+ let s = 0;
1534
+ return r._addAlgorithm((i, o, u) => {
1535
+ const a = i.key;
1536
+ for (; n(a, e[s]) > 0; )
1537
+ if (++s, s === e.length)
1538
+ return o(u), !1;
1539
+ return n(a, e[s]) === 0 || (o(() => {
1540
+ i.continue(e[s]);
1541
+ }), !1);
1542
+ }), r;
1543
+ }
1544
+ notEqual(e) {
1545
+ return this.inAnyRange([[Mt, e], [e, this.db._maxKey]], { includeLowers: !1, includeUppers: !1 });
1546
+ }
1547
+ noneOf() {
1548
+ const e = J.apply(_e, arguments);
1549
+ if (e.length === 0)
1550
+ return new this.Collection(this);
1551
+ try {
1552
+ e.sort(this._ascending);
1553
+ } catch {
1554
+ return W(this, X);
1555
+ }
1556
+ const n = e.reduce((r, s) => r ? r.concat([[r[r.length - 1][1], s]]) : [[Mt, s]], null);
1557
+ return n.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(n, { includeLowers: !1, includeUppers: !1 });
1558
+ }
1559
+ inAnyRange(e, n) {
1560
+ const r = this._cmp, s = this._ascending, i = this._descending, o = this._min, u = this._max;
1561
+ if (e.length === 0)
1562
+ return we(this);
1563
+ if (!e.every((g) => g[0] !== void 0 && g[1] !== void 0 && s(g[0], g[1]) <= 0))
1564
+ return W(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", C.InvalidArgument);
1565
+ const a = !n || n.includeLowers !== !1, c = n && n.includeUppers === !0;
1566
+ let d, l = s;
1567
+ function h(g, b) {
1568
+ return l(g[0], b[0]);
1569
+ }
1570
+ try {
1571
+ d = e.reduce(function(g, b) {
1572
+ let k = 0, P = g.length;
1573
+ for (; k < P; ++k) {
1574
+ const x = g[k];
1575
+ if (r(b[0], x[1]) < 0 && r(b[1], x[0]) > 0) {
1576
+ x[0] = o(x[0], b[0]), x[1] = u(x[1], b[1]);
1577
+ break;
1578
+ }
1579
+ }
1580
+ return k === P && g.push(b), g;
1581
+ }, []), d.sort(h);
1582
+ } catch {
1583
+ return W(this, X);
1584
+ }
1585
+ let f = 0;
1586
+ const m = c ? (g) => s(g, d[f][1]) > 0 : (g) => s(g, d[f][1]) >= 0, p = a ? (g) => i(g, d[f][0]) > 0 : (g) => i(g, d[f][0]) >= 0;
1587
+ let v = m;
1588
+ const y = new this.Collection(this, () => re(d[0][0], d[d.length - 1][1], !a, !c));
1589
+ return y._ondirectionchange = (g) => {
1590
+ g === "next" ? (v = m, l = s) : (v = p, l = i), d.sort(h);
1591
+ }, y._addAlgorithm((g, b, k) => {
1592
+ for (var P = g.key; v(P); )
1593
+ if (++f, f === d.length)
1594
+ return b(k), !1;
1595
+ return !!function(x) {
1596
+ return !m(x) && !p(x);
1597
+ }(P) || (this._cmp(P, d[f][1]) === 0 || this._cmp(P, d[f][0]) === 0 || b(() => {
1598
+ l === s ? g.continue(d[f][0]) : g.continue(d[f][1]);
1599
+ }), !1);
1600
+ }), y;
1601
+ }
1602
+ startsWithAnyOf() {
1603
+ const e = J.apply(_e, arguments);
1604
+ return e.every((n) => typeof n == "string") ? e.length === 0 ? we(this) : this.inAnyRange(e.map((n) => [n, n + he])) : W(this, "startsWithAnyOf() only works with strings");
1605
+ }
1606
+ }
1607
+ function Y(t) {
1608
+ return j(function(e) {
1609
+ return qe(e), t(e.target.error), !1;
1610
+ });
1611
+ }
1612
+ function qe(t) {
1613
+ t.stopPropagation && t.stopPropagation(), t.preventDefault && t.preventDefault();
1614
+ }
1615
+ const Le = "storagemutated", ie = "x-storagemutated-1", ue = $e(null, Le);
1616
+ class $r {
1617
+ _lock() {
1618
+ return Ie(!E.global), ++this._reculock, this._reculock !== 1 || E.global || (E.lockOwnerFor = this), this;
1619
+ }
1620
+ _unlock() {
1621
+ if (Ie(!E.global), --this._reculock == 0)
1622
+ for (E.global || (E.lockOwnerFor = null); this._blockedFuncs.length > 0 && !this._locked(); ) {
1623
+ var e = this._blockedFuncs.shift();
1624
+ try {
1625
+ Te(e[1], e[0]);
1626
+ } catch {
1627
+ }
1628
+ }
1629
+ return this;
1630
+ }
1631
+ _locked() {
1632
+ return this._reculock && E.lockOwnerFor !== this;
1633
+ }
1634
+ create(e) {
1635
+ if (!this.mode)
1636
+ return this;
1637
+ const n = this.db.idbdb, r = this.db._state.dbOpenError;
1638
+ if (Ie(!this.idbtrans), !e && !n)
1639
+ switch (r && r.name) {
1640
+ case "DatabaseClosedError":
1641
+ throw new C.DatabaseClosed(r);
1642
+ case "MissingAPIError":
1643
+ throw new C.MissingAPI(r.message, r);
1644
+ default:
1645
+ throw new C.OpenFailed(r);
1646
+ }
1647
+ if (!this.active)
1648
+ throw new C.TransactionInactive();
1649
+ return Ie(this._completion._state === null), (e = this.idbtrans = e || (this.db.core ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }) : n.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }))).onerror = j((s) => {
1650
+ qe(s), this._reject(e.error);
1651
+ }), e.onabort = j((s) => {
1652
+ qe(s), this.active && this._reject(new C.Abort(e.error)), this.active = !1, this.on("abort").fire(s);
1653
+ }), e.oncomplete = j(() => {
1654
+ this.active = !1, this._resolve(), "mutatedParts" in e && ue.storagemutated.fire(e.mutatedParts);
1655
+ }), this;
1656
+ }
1657
+ _promise(e, n, r) {
1658
+ if (e === "readwrite" && this.mode !== "readwrite")
1659
+ return D(new C.ReadOnly("Transaction is readonly"));
1660
+ if (!this.active)
1661
+ return D(new C.TransactionInactive());
1662
+ if (this._locked())
1663
+ return new S((i, o) => {
1664
+ this._blockedFuncs.push([() => {
1665
+ this._promise(e, n, r).then(i, o);
1666
+ }, E]);
1667
+ });
1668
+ if (r)
1669
+ return oe(() => {
1670
+ var i = new S((o, u) => {
1671
+ this._lock();
1672
+ const a = n(o, u, this);
1673
+ a && a.then && a.then(o, u);
1674
+ });
1675
+ return i.finally(() => this._unlock()), i._lib = !0, i;
1676
+ });
1677
+ var s = new S((i, o) => {
1678
+ var u = n(i, o, this);
1679
+ u && u.then && u.then(i, o);
1680
+ });
1681
+ return s._lib = !0, s;
1682
+ }
1683
+ _root() {
1684
+ return this.parent ? this.parent._root() : this;
1685
+ }
1686
+ waitFor(e) {
1687
+ var n = this._root();
1688
+ const r = S.resolve(e);
1689
+ if (n._waitingFor)
1690
+ n._waitingFor = n._waitingFor.then(() => r);
1691
+ else {
1692
+ n._waitingFor = r, n._waitingQueue = [];
1693
+ var s = n.idbtrans.objectStore(n.storeNames[0]);
1694
+ (function o() {
1695
+ for (++n._spinCount; n._waitingQueue.length; )
1696
+ n._waitingQueue.shift()();
1697
+ n._waitingFor && (s.get(-1 / 0).onsuccess = o);
1698
+ })();
1699
+ }
1700
+ var i = n._waitingFor;
1701
+ return new S((o, u) => {
1702
+ r.then((a) => n._waitingQueue.push(j(o.bind(null, a))), (a) => n._waitingQueue.push(j(u.bind(null, a)))).finally(() => {
1703
+ n._waitingFor === i && (n._waitingFor = null);
1704
+ });
1705
+ });
1706
+ }
1707
+ abort() {
1708
+ this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new C.Abort()));
1709
+ }
1710
+ table(e) {
1711
+ const n = this._memoizedTables || (this._memoizedTables = {});
1712
+ if (z(n, e))
1713
+ return n[e];
1714
+ const r = this.schema[e];
1715
+ if (!r)
1716
+ throw new C.NotFound("Table " + e + " not part of transaction");
1717
+ const s = new this.db.Table(e, r, this);
1718
+ return s.core = this.db.core.table(e), n[e] = s, s;
1719
+ }
1720
+ }
1721
+ function qt(t, e, n, r, s, i, o) {
1722
+ return { name: t, keyPath: e, unique: n, multi: r, auto: s, compound: i, src: (n && !o ? "&" : "") + (r ? "*" : "") + (s ? "++" : "") + Xn(e) };
1723
+ }
1724
+ function Xn(t) {
1725
+ return typeof t == "string" ? t : t ? "[" + [].join.call(t, "+") + "]" : "";
1726
+ }
1727
+ function Qn(t, e, n) {
1728
+ return { name: t, primKey: e, indexes: n, mappedClass: null, idxByName: Tn(n, (r) => [r.name, r]) };
1729
+ }
1730
+ let Ue = (t) => {
1731
+ try {
1732
+ return t.only([[]]), Ue = () => [[]], [[]];
1733
+ } catch {
1734
+ return Ue = () => he, he;
1735
+ }
1736
+ };
1737
+ function Lt(t) {
1738
+ return t == null ? () => {
1739
+ } : typeof t == "string" ? function(e) {
1740
+ return e.split(".").length === 1 ? (n) => n[e] : (n) => te(n, e);
1741
+ }(t) : (e) => te(e, t);
1742
+ }
1743
+ function kn(t) {
1744
+ return [].slice.call(t);
1745
+ }
1746
+ let Dr = 0;
1747
+ function De(t) {
1748
+ return t == null ? ":id" : typeof t == "string" ? t : `[${t.join("+")}]`;
1749
+ }
1750
+ function Br(t, e, n) {
1751
+ function r(a) {
1752
+ if (a.type === 3)
1753
+ return null;
1754
+ if (a.type === 4)
1755
+ throw new Error("Cannot convert never type to IDBKeyRange");
1756
+ const { lower: c, upper: d, lowerOpen: l, upperOpen: h } = a;
1757
+ return c === void 0 ? d === void 0 ? null : e.upperBound(d, !!h) : d === void 0 ? e.lowerBound(c, !!l) : e.bound(c, d, !!l, !!h);
1758
+ }
1759
+ const { schema: s, hasGetAll: i } = function(a, c) {
1760
+ const d = kn(a.objectStoreNames);
1761
+ return { schema: { name: a.name, tables: d.map((l) => c.objectStore(l)).map((l) => {
1762
+ const { keyPath: h, autoIncrement: f } = l, m = M(h), p = h == null, v = {}, y = { name: l.name, primaryKey: { name: null, isPrimaryKey: !0, outbound: p, compound: m, keyPath: h, autoIncrement: f, unique: !0, extractKey: Lt(h) }, indexes: kn(l.indexNames).map((g) => l.index(g)).map((g) => {
1763
+ const { name: b, unique: k, multiEntry: P, keyPath: x } = g, w = { name: b, compound: M(x), keyPath: x, unique: k, multiEntry: P, extractKey: Lt(x) };
1764
+ return v[De(x)] = w, w;
1765
+ }), getIndexByKeyPath: (g) => v[De(g)] };
1766
+ return v[":id"] = y.primaryKey, h != null && (v[De(h)] = y.primaryKey), y;
1767
+ }) }, hasGetAll: d.length > 0 && "getAll" in c.objectStore(d[0]) && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) };
1768
+ }(t, n), o = s.tables.map((a) => function(c) {
1769
+ const d = c.name;
1770
+ return { name: d, schema: c, mutate: function({ trans: l, type: h, keys: f, values: m, range: p }) {
1771
+ return new Promise((v, y) => {
1772
+ v = j(v);
1773
+ const g = l.objectStore(d), b = g.keyPath == null, k = h === "put" || h === "add";
1774
+ if (!k && h !== "delete" && h !== "deleteRange")
1775
+ throw new Error("Invalid operation type: " + h);
1776
+ const { length: P } = f || m || { length: 1 };
1777
+ if (f && m && f.length !== m.length)
1778
+ throw new Error("Given keys array must have same length as given values array.");
1779
+ if (P === 0)
1780
+ return v({ numFailures: 0, failures: {}, results: [], lastResult: void 0 });
1781
+ let x;
1782
+ const w = [], A = [];
1783
+ let _ = 0;
1784
+ const R = (q) => {
1785
+ ++_, qe(q);
1786
+ };
1787
+ if (h === "deleteRange") {
1788
+ if (p.type === 4)
1789
+ return v({ numFailures: _, failures: A, results: [], lastResult: void 0 });
1790
+ p.type === 3 ? w.push(x = g.clear()) : w.push(x = g.delete(r(p)));
1791
+ } else {
1792
+ const [q, B] = k ? b ? [m, f] : [m, null] : [f, null];
1793
+ if (k)
1794
+ for (let N = 0; N < P; ++N)
1795
+ w.push(x = B && B[N] !== void 0 ? g[h](q[N], B[N]) : g[h](q[N])), x.onerror = R;
1796
+ else
1797
+ for (let N = 0; N < P; ++N)
1798
+ w.push(x = g[h](q[N])), x.onerror = R;
1799
+ }
1800
+ const O = (q) => {
1801
+ const B = q.target.result;
1802
+ w.forEach((N, ye) => N.error != null && (A[ye] = N.error)), v({ numFailures: _, failures: A, results: h === "delete" ? f : w.map((N) => N.result), lastResult: B });
1803
+ };
1804
+ x.onerror = (q) => {
1805
+ R(q), O(q);
1806
+ }, x.onsuccess = O;
1807
+ });
1808
+ }, getMany: ({ trans: l, keys: h }) => new Promise((f, m) => {
1809
+ f = j(f);
1810
+ const p = l.objectStore(d), v = h.length, y = new Array(v);
1811
+ let g, b = 0, k = 0;
1812
+ const P = (w) => {
1813
+ const A = w.target;
1814
+ y[A._pos] = A.result, ++k === b && f(y);
1815
+ }, x = Y(m);
1816
+ for (let w = 0; w < v; ++w)
1817
+ h[w] != null && (g = p.get(h[w]), g._pos = w, g.onsuccess = P, g.onerror = x, ++b);
1818
+ b === 0 && f(y);
1819
+ }), get: ({ trans: l, key: h }) => new Promise((f, m) => {
1820
+ f = j(f);
1821
+ const p = l.objectStore(d).get(h);
1822
+ p.onsuccess = (v) => f(v.target.result), p.onerror = Y(m);
1823
+ }), query: function(l) {
1824
+ return (h) => new Promise((f, m) => {
1825
+ f = j(f);
1826
+ const { trans: p, values: v, limit: y, query: g } = h, b = y === 1 / 0 ? void 0 : y, { index: k, range: P } = g, x = p.objectStore(d), w = k.isPrimaryKey ? x : x.index(k.name), A = r(P);
1827
+ if (y === 0)
1828
+ return f({ result: [] });
1829
+ if (l) {
1830
+ const _ = v ? w.getAll(A, b) : w.getAllKeys(A, b);
1831
+ _.onsuccess = (R) => f({ result: R.target.result }), _.onerror = Y(m);
1832
+ } else {
1833
+ let _ = 0;
1834
+ const R = v || !("openKeyCursor" in w) ? w.openCursor(A) : w.openKeyCursor(A), O = [];
1835
+ R.onsuccess = (q) => {
1836
+ const B = R.result;
1837
+ return B ? (O.push(v ? B.value : B.primaryKey), ++_ === y ? f({ result: O }) : void B.continue()) : f({ result: O });
1838
+ }, R.onerror = Y(m);
1839
+ }
1840
+ });
1841
+ }(i), openCursor: function({ trans: l, values: h, query: f, reverse: m, unique: p }) {
1842
+ return new Promise((v, y) => {
1843
+ v = j(v);
1844
+ const { index: g, range: b } = f, k = l.objectStore(d), P = g.isPrimaryKey ? k : k.index(g.name), x = m ? p ? "prevunique" : "prev" : p ? "nextunique" : "next", w = h || !("openKeyCursor" in P) ? P.openCursor(r(b), x) : P.openKeyCursor(r(b), x);
1845
+ w.onerror = Y(y), w.onsuccess = j((A) => {
1846
+ const _ = w.result;
1847
+ if (!_)
1848
+ return void v(null);
1849
+ _.___id = ++Dr, _.done = !1;
1850
+ const R = _.continue.bind(_);
1851
+ let O = _.continuePrimaryKey;
1852
+ O && (O = O.bind(_));
1853
+ const q = _.advance.bind(_), B = () => {
1854
+ throw new Error("Cursor not stopped");
1855
+ };
1856
+ _.trans = l, _.stop = _.continue = _.continuePrimaryKey = _.advance = () => {
1857
+ throw new Error("Cursor not started");
1858
+ }, _.fail = j(y), _.next = function() {
1859
+ let N = 1;
1860
+ return this.start(() => N-- ? this.continue() : this.stop()).then(() => this);
1861
+ }, _.start = (N) => {
1862
+ const ye = new Promise((V, le) => {
1863
+ V = j(V), w.onerror = Y(le), _.fail = le, _.stop = (Ae) => {
1864
+ _.stop = _.continue = _.continuePrimaryKey = _.advance = B, V(Ae);
1865
+ };
1866
+ }), ve = () => {
1867
+ if (w.result)
1868
+ try {
1869
+ N();
1870
+ } catch (V) {
1871
+ _.fail(V);
1872
+ }
1873
+ else
1874
+ _.done = !0, _.start = () => {
1875
+ throw new Error("Cursor behind last entry");
1876
+ }, _.stop();
1877
+ };
1878
+ return w.onsuccess = j((V) => {
1879
+ w.onsuccess = ve, ve();
1880
+ }), _.continue = R, _.continuePrimaryKey = O, _.advance = q, ve(), ye;
1881
+ }, v(_);
1882
+ }, y);
1883
+ });
1884
+ }, count({ query: l, trans: h }) {
1885
+ const { index: f, range: m } = l;
1886
+ return new Promise((p, v) => {
1887
+ const y = h.objectStore(d), g = f.isPrimaryKey ? y : y.index(f.name), b = r(m), k = b ? g.count(b) : g.count();
1888
+ k.onsuccess = j((P) => p(P.target.result)), k.onerror = Y(v);
1889
+ });
1890
+ } };
1891
+ }(a)), u = {};
1892
+ return o.forEach((a) => u[a.name] = a), { stack: "dbcore", transaction: t.transaction.bind(t), table(a) {
1893
+ if (!u[a])
1894
+ throw new Error(`Table '${a}' not found`);
1895
+ return u[a];
1896
+ }, MIN_KEY: -1 / 0, MAX_KEY: Ue(e), schema: s };
1897
+ }
1898
+ function Ut({ _novip: t }, e) {
1899
+ const n = e.db, r = function(s, i, { IDBKeyRange: o, indexedDB: u }, a) {
1900
+ return { dbcore: function(c, d) {
1901
+ return d.reduce((l, { create: h }) => ({ ...l, ...h(l) }), c);
1902
+ }(Br(i, o, a), s.dbcore) };
1903
+ }(t._middlewares, n, t._deps, e);
1904
+ t.core = r.dbcore, t.tables.forEach((s) => {
1905
+ const i = s.name;
1906
+ t.core.schema.tables.some((o) => o.name === i) && (s.core = t.core.table(i), t[i] instanceof t.Table && (t[i].core = s.core));
1907
+ });
1908
+ }
1909
+ function mt({ _novip: t }, e, n, r) {
1910
+ n.forEach((s) => {
1911
+ const i = r[s];
1912
+ e.forEach((o) => {
1913
+ const u = Jt(o, s);
1914
+ (!u || "value" in u && u.value === void 0) && (o === t.Transaction.prototype || o instanceof t.Transaction ? ee(o, s, { get() {
1915
+ return this.table(s);
1916
+ }, set(a) {
1917
+ Pn(this, s, { value: a, writable: !0, configurable: !0, enumerable: !0 });
1918
+ } }) : o[s] = new t.Table(s, i));
1919
+ });
1920
+ });
1921
+ }
1922
+ function Vt({ _novip: t }, e) {
1923
+ e.forEach((n) => {
1924
+ for (let r in n)
1925
+ n[r] instanceof t.Table && delete n[r];
1926
+ });
1927
+ }
1928
+ function Fr(t, e) {
1929
+ return t._cfg.version - e._cfg.version;
1930
+ }
1931
+ function Mr(t, e, n, r) {
1932
+ const s = t._dbSchema, i = t._createTransaction("readwrite", t._storeNames, s);
1933
+ i.create(n), i._completion.catch(r);
1934
+ const o = i._reject.bind(i), u = E.transless || E;
1935
+ oe(() => {
1936
+ E.trans = i, E.transless = u, e === 0 ? ($(s).forEach((a) => {
1937
+ Et(n, a, s[a].primKey, s[a].indexes);
1938
+ }), Ut(t, n), S.follow(() => t.on.populate.fire(i)).catch(o)) : function({ _novip: a }, c, d, l) {
1939
+ const h = [], f = a._versions;
1940
+ let m = a._dbSchema = zt(a, a.idbdb, l), p = !1;
1941
+ const v = f.filter((g) => g._cfg.version >= c);
1942
+ function y() {
1943
+ return h.length ? S.resolve(h.shift()(d.idbtrans)).then(y) : S.resolve();
1944
+ }
1945
+ return v.forEach((g) => {
1946
+ h.push(() => {
1947
+ const b = m, k = g._cfg.dbschema;
1948
+ Ht(a, b, l), Ht(a, k, l), m = a._dbSchema = k;
1949
+ const P = Jn(b, k);
1950
+ P.add.forEach((w) => {
1951
+ Et(l, w[0], w[1].primKey, w[1].indexes);
1952
+ }), P.change.forEach((w) => {
1953
+ if (w.recreate)
1954
+ throw new C.Upgrade("Not yet support for changing primary key");
1955
+ {
1956
+ const A = l.objectStore(w.name);
1957
+ w.add.forEach((_) => Wt(A, _)), w.change.forEach((_) => {
1958
+ A.deleteIndex(_.name), Wt(A, _);
1959
+ }), w.del.forEach((_) => A.deleteIndex(_));
1960
+ }
1961
+ });
1962
+ const x = g._cfg.contentUpgrade;
1963
+ if (x && g._cfg.version > c) {
1964
+ Ut(a, l), d._memoizedTables = {}, p = !0;
1965
+ let w = An(k);
1966
+ P.del.forEach((O) => {
1967
+ w[O] = b[O];
1968
+ }), Vt(a, [a.Transaction.prototype]), mt(a, [a.Transaction.prototype], $(w), w), d.schema = w;
1969
+ const A = Zt(x);
1970
+ let _;
1971
+ A && Ce();
1972
+ const R = S.follow(() => {
1973
+ if (_ = x(d), _ && A) {
1974
+ var O = ne.bind(null, null);
1975
+ _.then(O, O);
1976
+ }
1977
+ });
1978
+ return _ && typeof _.then == "function" ? S.resolve(_) : R.then(() => _);
1979
+ }
1980
+ }), h.push((b) => {
1981
+ (!p || !Ar) && function(k, P) {
1982
+ [].slice.call(P.db.objectStoreNames).forEach((x) => k[x] == null && P.db.deleteObjectStore(x));
1983
+ }(g._cfg.dbschema, b), Vt(a, [a.Transaction.prototype]), mt(a, [a.Transaction.prototype], a._storeNames, a._dbSchema), d.schema = a._dbSchema;
1984
+ });
1985
+ }), y().then(() => {
1986
+ var g, b;
1987
+ b = l, $(g = m).forEach((k) => {
1988
+ b.db.objectStoreNames.contains(k) || Et(b, k, g[k].primKey, g[k].indexes);
1989
+ });
1990
+ });
1991
+ }(t, e, i, n).catch(o);
1992
+ });
1993
+ }
1994
+ function Jn(t, e) {
1995
+ const n = { del: [], add: [], change: [] };
1996
+ let r;
1997
+ for (r in t)
1998
+ e[r] || n.del.push(r);
1999
+ for (r in e) {
2000
+ const s = t[r], i = e[r];
2001
+ if (s) {
2002
+ const o = { name: r, def: i, recreate: !1, del: [], add: [], change: [] };
2003
+ if ("" + (s.primKey.keyPath || "") != "" + (i.primKey.keyPath || "") || s.primKey.auto !== i.primKey.auto && !yt)
2004
+ o.recreate = !0, n.change.push(o);
2005
+ else {
2006
+ const u = s.idxByName, a = i.idxByName;
2007
+ let c;
2008
+ for (c in u)
2009
+ a[c] || o.del.push(c);
2010
+ for (c in a) {
2011
+ const d = u[c], l = a[c];
2012
+ d ? d.src !== l.src && o.change.push(l) : o.add.push(l);
2013
+ }
2014
+ (o.del.length > 0 || o.add.length > 0 || o.change.length > 0) && n.change.push(o);
2015
+ }
2016
+ } else
2017
+ n.add.push([r, i]);
2018
+ }
2019
+ return n;
2020
+ }
2021
+ function Et(t, e, n, r) {
2022
+ const s = t.db.createObjectStore(e, n.keyPath ? { keyPath: n.keyPath, autoIncrement: n.auto } : { autoIncrement: n.auto });
2023
+ return r.forEach((i) => Wt(s, i)), s;
2024
+ }
2025
+ function Wt(t, e) {
2026
+ t.createIndex(e.name, e.keyPath, { unique: e.unique, multiEntry: e.multi });
2027
+ }
2028
+ function zt(t, e, n) {
2029
+ const r = {};
2030
+ return lt(e.objectStoreNames, 0).forEach((s) => {
2031
+ const i = n.objectStore(s);
2032
+ let o = i.keyPath;
2033
+ const u = qt(Xn(o), o || "", !1, !1, !!i.autoIncrement, o && typeof o != "string", !0), a = [];
2034
+ for (let d = 0; d < i.indexNames.length; ++d) {
2035
+ const l = i.index(i.indexNames[d]);
2036
+ o = l.keyPath;
2037
+ var c = qt(l.name, o, !!l.unique, !!l.multiEntry, !1, o && typeof o != "string", !1);
2038
+ a.push(c);
2039
+ }
2040
+ r[s] = Qn(s, u, a);
2041
+ }), r;
2042
+ }
2043
+ function Ht({ _novip: t }, e, n) {
2044
+ const r = n.db.objectStoreNames;
2045
+ for (let s = 0; s < r.length; ++s) {
2046
+ const i = r[s], o = n.objectStore(i);
2047
+ t._hasGetAll = "getAll" in o;
2048
+ for (let u = 0; u < o.indexNames.length; ++u) {
2049
+ const a = o.indexNames[u], c = o.index(a).keyPath, d = typeof c == "string" ? c : "[" + lt(c).join("+") + "]";
2050
+ if (e[i]) {
2051
+ const l = e[i].idxByName[d];
2052
+ l && (l.name = a, delete e[i].idxByName[d], e[i].idxByName[a] = l);
2053
+ }
2054
+ }
2055
+ }
2056
+ typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && K.WorkerGlobalScope && K instanceof K.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (t._hasGetAll = !1);
2057
+ }
2058
+ class qr {
2059
+ _parseStoresSpec(e, n) {
2060
+ $(e).forEach((r) => {
2061
+ if (e[r] !== null) {
2062
+ var s = e[r].split(",").map((o, u) => {
2063
+ const a = (o = o.trim()).replace(/([&*]|\+\+)/g, ""), c = /^\[/.test(a) ? a.match(/^\[(.*)\]$/)[1].split("+") : a;
2064
+ return qt(a, c || null, /\&/.test(o), /\*/.test(o), /\+\+/.test(o), M(c), u === 0);
2065
+ }), i = s.shift();
2066
+ if (i.multi)
2067
+ throw new C.Schema("Primary key cannot be multi-valued");
2068
+ s.forEach((o) => {
2069
+ if (o.auto)
2070
+ throw new C.Schema("Only primary key can be marked as autoIncrement (++)");
2071
+ if (!o.keyPath)
2072
+ throw new C.Schema("Index must have a name and cannot be an empty string");
2073
+ }), n[r] = Qn(r, i, s);
2074
+ }
2075
+ });
2076
+ }
2077
+ stores(e) {
2078
+ const n = this.db;
2079
+ this._cfg.storesSource = this._cfg.storesSource ? U(this._cfg.storesSource, e) : e;
2080
+ const r = n._versions, s = {};
2081
+ let i = {};
2082
+ return r.forEach((o) => {
2083
+ U(s, o._cfg.storesSource), i = o._cfg.dbschema = {}, o._parseStoresSpec(s, i);
2084
+ }), n._dbSchema = i, Vt(n, [n._allTables, n, n.Transaction.prototype]), mt(n, [n._allTables, n, n.Transaction.prototype, this._cfg.tables], $(i), i), n._storeNames = $(i), this;
2085
+ }
2086
+ upgrade(e) {
2087
+ return this._cfg.contentUpgrade = nn(this._cfg.contentUpgrade || I, e), this;
2088
+ }
2089
+ }
2090
+ function an(t, e) {
2091
+ let n = t._dbNamesDB;
2092
+ return n || (n = t._dbNamesDB = new pe(vt, { addons: [], indexedDB: t, IDBKeyRange: e }), n.version(1).stores({ dbnames: "name" })), n.table("dbnames");
2093
+ }
2094
+ function un(t) {
2095
+ return t && typeof t.databases == "function";
2096
+ }
2097
+ function Yt(t) {
2098
+ return oe(function() {
2099
+ return E.letThrough = !0, t();
2100
+ });
2101
+ }
2102
+ function Lr() {
2103
+ var t;
2104
+ return !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(e) {
2105
+ var n = function() {
2106
+ return indexedDB.databases().finally(e);
2107
+ };
2108
+ t = setInterval(n, 100), n();
2109
+ }).finally(function() {
2110
+ return clearInterval(t);
2111
+ }) : Promise.resolve();
2112
+ }
2113
+ function Ur(t) {
2114
+ const e = t._state, { indexedDB: n } = t._deps;
2115
+ if (e.isBeingOpened || t.idbdb)
2116
+ return e.dbReadyPromise.then(() => e.dbOpenError ? D(e.dbOpenError) : t);
2117
+ G && (e.openCanceller._stackHolder = Ee()), e.isBeingOpened = !0, e.dbOpenError = null, e.openComplete = !1;
2118
+ const r = e.openCanceller;
2119
+ function s() {
2120
+ if (e.openCanceller !== r)
2121
+ throw new C.DatabaseClosed("db.open() was cancelled");
2122
+ }
2123
+ let i = e.dbReadyResolve, o = null, u = !1;
2124
+ return S.race([r, (typeof navigator > "u" ? S.resolve() : Lr()).then(() => new S((a, c) => {
2125
+ if (s(), !n)
2126
+ throw new C.MissingAPI();
2127
+ const d = t.name, l = e.autoSchema ? n.open(d) : n.open(d, Math.round(10 * t.verno));
2128
+ if (!l)
2129
+ throw new C.MissingAPI();
2130
+ l.onerror = Y(c), l.onblocked = j(t._fireOnBlocked), l.onupgradeneeded = j((h) => {
2131
+ if (o = l.transaction, e.autoSchema && !t._options.allowEmptyDB) {
2132
+ l.onerror = qe, o.abort(), l.result.close();
2133
+ const m = n.deleteDatabase(d);
2134
+ m.onsuccess = m.onerror = j(() => {
2135
+ c(new C.NoSuchDatabase(`Database ${d} doesnt exist`));
2136
+ });
2137
+ } else {
2138
+ o.onerror = Y(c);
2139
+ var f = h.oldVersion > Math.pow(2, 62) ? 0 : h.oldVersion;
2140
+ u = f < 1, t._novip.idbdb = l.result, Mr(t, f / 10, o, c);
2141
+ }
2142
+ }, c), l.onsuccess = j(() => {
2143
+ o = null;
2144
+ const h = t._novip.idbdb = l.result, f = lt(h.objectStoreNames);
2145
+ if (f.length > 0)
2146
+ try {
2147
+ const p = h.transaction((m = f).length === 1 ? m[0] : m, "readonly");
2148
+ e.autoSchema ? function({ _novip: v }, y, g) {
2149
+ v.verno = y.version / 10;
2150
+ const b = v._dbSchema = zt(0, y, g);
2151
+ v._storeNames = lt(y.objectStoreNames, 0), mt(v, [v._allTables], $(b), b);
2152
+ }(t, h, p) : (Ht(t, t._dbSchema, p), function(v, y) {
2153
+ const g = Jn(zt(0, v.idbdb, y), v._dbSchema);
2154
+ return !(g.add.length || g.change.some((b) => b.add.length || b.change.length));
2155
+ }(t, p) || console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")), Ut(t, p);
2156
+ } catch {
2157
+ }
2158
+ var m;
2159
+ Ne.push(t), h.onversionchange = j((p) => {
2160
+ e.vcFired = !0, t.on("versionchange").fire(p);
2161
+ }), h.onclose = j((p) => {
2162
+ t.on("close").fire(p);
2163
+ }), u && function({ indexedDB: p, IDBKeyRange: v }, y) {
2164
+ !un(p) && y !== vt && an(p, v).put({ name: y }).catch(I);
2165
+ }(t._deps, d), a();
2166
+ }, c);
2167
+ }))]).then(() => (s(), e.onReadyBeingFired = [], S.resolve(Yt(() => t.on.ready.fire(t.vip))).then(function a() {
2168
+ if (e.onReadyBeingFired.length > 0) {
2169
+ let c = e.onReadyBeingFired.reduce(nn, I);
2170
+ return e.onReadyBeingFired = [], S.resolve(Yt(() => c(t.vip))).then(a);
2171
+ }
2172
+ }))).finally(() => {
2173
+ e.onReadyBeingFired = null, e.isBeingOpened = !1;
2174
+ }).then(() => t).catch((a) => {
2175
+ e.dbOpenError = a;
2176
+ try {
2177
+ o && o.abort();
2178
+ } catch {
2179
+ }
2180
+ return r === e.openCanceller && t._close(), D(a);
2181
+ }).finally(() => {
2182
+ e.openComplete = !0, i();
2183
+ });
2184
+ }
2185
+ function Gt(t) {
2186
+ var e = (i) => t.next(i), n = s(e), r = s((i) => t.throw(i));
2187
+ function s(i) {
2188
+ return (o) => {
2189
+ var u = i(o), a = u.value;
2190
+ return u.done ? a : a && typeof a.then == "function" ? a.then(n, r) : M(a) ? Promise.all(a).then(n, r) : n(a);
2191
+ };
2192
+ }
2193
+ return s(e)();
2194
+ }
2195
+ function Vr(t, e, n) {
2196
+ var r = arguments.length;
2197
+ if (r < 2)
2198
+ throw new C.InvalidArgument("Too few arguments");
2199
+ for (var s = new Array(r - 1); --r; )
2200
+ s[r - 1] = arguments[r];
2201
+ return n = s.pop(), [t, On(s), n];
2202
+ }
2203
+ function Zn(t, e, n, r, s) {
2204
+ return S.resolve().then(() => {
2205
+ const i = E.transless || E, o = t._createTransaction(e, n, t._dbSchema, r), u = { trans: o, transless: i };
2206
+ if (r)
2207
+ o.idbtrans = r.idbtrans;
2208
+ else
2209
+ try {
2210
+ o.create(), t._state.PR1398_maxLoop = 3;
2211
+ } catch (l) {
2212
+ return l.name === tn.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => Zn(t, e, n, null, s))) : D(l);
2213
+ }
2214
+ const a = Zt(s);
2215
+ let c;
2216
+ a && Ce();
2217
+ const d = S.follow(() => {
2218
+ if (c = s.call(o, o), c)
2219
+ if (a) {
2220
+ var l = ne.bind(null, null);
2221
+ c.then(l, l);
2222
+ } else
2223
+ typeof c.next == "function" && typeof c.throw == "function" && (c = Gt(c));
2224
+ }, u);
2225
+ return (c && typeof c.then == "function" ? S.resolve(c).then((l) => o.active ? l : D(new C.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))) : d.then(() => c)).then((l) => (r && o._resolve(), o._completion.then(() => l))).catch((l) => (o._reject(l), D(l)));
2226
+ });
2227
+ }
2228
+ function et(t, e, n) {
2229
+ const r = M(t) ? t.slice() : [t];
2230
+ for (let s = 0; s < n; ++s)
2231
+ r.push(e);
2232
+ return r;
2233
+ }
2234
+ const Wr = { stack: "dbcore", name: "VirtualIndexMiddleware", level: 1, create: function(t) {
2235
+ return { ...t, table(e) {
2236
+ const n = t.table(e), { schema: r } = n, s = {}, i = [];
2237
+ function o(c, d, l) {
2238
+ const h = De(c), f = s[h] = s[h] || [], m = c == null ? 0 : typeof c == "string" ? 1 : c.length, p = d > 0, v = { ...l, isVirtual: p, keyTail: d, keyLength: m, extractKey: Lt(c), unique: !p && l.unique };
2239
+ return f.push(v), v.isPrimaryKey || i.push(v), m > 1 && o(m === 2 ? c[0] : c.slice(0, m - 1), d + 1, l), f.sort((y, g) => y.keyTail - g.keyTail), v;
2240
+ }
2241
+ const u = o(r.primaryKey.keyPath, 0, r.primaryKey);
2242
+ s[":id"] = [u];
2243
+ for (const c of r.indexes)
2244
+ o(c.keyPath, 0, c);
2245
+ function a(c) {
2246
+ const d = c.query.index;
2247
+ return d.isVirtual ? { ...c, query: { index: d, range: (l = c.query.range, h = d.keyTail, { type: l.type === 1 ? 2 : l.type, lower: et(l.lower, l.lowerOpen ? t.MAX_KEY : t.MIN_KEY, h), lowerOpen: !0, upper: et(l.upper, l.upperOpen ? t.MIN_KEY : t.MAX_KEY, h), upperOpen: !0 }) } } : c;
2248
+ var l, h;
2249
+ }
2250
+ return { ...n, schema: { ...r, primaryKey: u, indexes: i, getIndexByKeyPath: function(c) {
2251
+ const d = s[De(c)];
2252
+ return d && d[0];
2253
+ } }, count: (c) => n.count(a(c)), query: (c) => n.query(a(c)), openCursor(c) {
2254
+ const { keyTail: d, isVirtual: l, keyLength: h } = c.query.index;
2255
+ return l ? n.openCursor(a(c)).then((f) => f && function(m) {
2256
+ return Object.create(m, { continue: { value: function(p) {
2257
+ p != null ? m.continue(et(p, c.reverse ? t.MAX_KEY : t.MIN_KEY, d)) : c.unique ? m.continue(m.key.slice(0, h).concat(c.reverse ? t.MIN_KEY : t.MAX_KEY, d)) : m.continue();
2258
+ } }, continuePrimaryKey: { value(p, v) {
2259
+ m.continuePrimaryKey(et(p, t.MAX_KEY, d), v);
2260
+ } }, primaryKey: { get: () => m.primaryKey }, key: { get() {
2261
+ const p = m.key;
2262
+ return h === 1 ? p[0] : p.slice(0, h);
2263
+ } }, value: { get: () => m.value } });
2264
+ }(f)) : n.openCursor(c);
2265
+ } };
2266
+ } };
2267
+ } };
2268
+ function ln(t, e, n, r) {
2269
+ return n = n || {}, r = r || "", $(t).forEach((s) => {
2270
+ if (z(e, s)) {
2271
+ var i = t[s], o = e[s];
2272
+ if (typeof i == "object" && typeof o == "object" && i && o) {
2273
+ const u = Tt(i);
2274
+ u !== Tt(o) ? n[r + s] = e[s] : u === "Object" ? ln(i, o, n, r + s + ".") : i !== o && (n[r + s] = e[s]);
2275
+ } else
2276
+ i !== o && (n[r + s] = e[s]);
2277
+ } else
2278
+ n[r + s] = void 0;
2279
+ }), $(e).forEach((s) => {
2280
+ z(t, s) || (n[r + s] = e[s]);
2281
+ }), n;
2282
+ }
2283
+ const zr = { stack: "dbcore", name: "HooksMiddleware", level: 2, create: (t) => ({ ...t, table(e) {
2284
+ const n = t.table(e), { primaryKey: r } = n.schema;
2285
+ return { ...n, mutate(s) {
2286
+ const i = E.trans, { deleting: o, creating: u, updating: a } = i.table(e).hook;
2287
+ switch (s.type) {
2288
+ case "add":
2289
+ if (u.fire === I)
2290
+ break;
2291
+ return i._promise("readwrite", () => c(s), !0);
2292
+ case "put":
2293
+ if (u.fire === I && a.fire === I)
2294
+ break;
2295
+ return i._promise("readwrite", () => c(s), !0);
2296
+ case "delete":
2297
+ if (o.fire === I)
2298
+ break;
2299
+ return i._promise("readwrite", () => c(s), !0);
2300
+ case "deleteRange":
2301
+ if (o.fire === I)
2302
+ break;
2303
+ return i._promise("readwrite", () => function(l) {
2304
+ return d(l.trans, l.range, 1e4);
2305
+ }(s), !0);
2306
+ }
2307
+ return n.mutate(s);
2308
+ function c(l) {
2309
+ const h = E.trans, f = l.keys || function(m, p) {
2310
+ return p.type === "delete" ? p.keys : p.keys || p.values.map(m.extractKey);
2311
+ }(r, l);
2312
+ if (!f)
2313
+ throw new Error("Keys missing");
2314
+ return (l = l.type === "add" || l.type === "put" ? { ...l, keys: f } : { ...l }).type !== "delete" && (l.values = [...l.values]), l.keys && (l.keys = [...l.keys]), function(m, p, v) {
2315
+ return p.type === "add" ? Promise.resolve([]) : m.getMany({ trans: p.trans, keys: v, cache: "immutable" });
2316
+ }(n, l, f).then((m) => {
2317
+ const p = f.map((v, y) => {
2318
+ const g = m[y], b = { onerror: null, onsuccess: null };
2319
+ if (l.type === "delete")
2320
+ o.fire.call(b, v, g, h);
2321
+ else if (l.type === "add" || g === void 0) {
2322
+ const k = u.fire.call(b, v, l.values[y], h);
2323
+ v == null && k != null && (v = k, l.keys[y] = v, r.outbound || H(l.values[y], r.keyPath, v));
2324
+ } else {
2325
+ const k = ln(g, l.values[y]), P = a.fire.call(b, k, v, g, h);
2326
+ if (P) {
2327
+ const x = l.values[y];
2328
+ Object.keys(P).forEach((w) => {
2329
+ z(x, w) ? x[w] = P[w] : H(x, w, P[w]);
2330
+ });
2331
+ }
2332
+ }
2333
+ return b;
2334
+ });
2335
+ return n.mutate(l).then(({ failures: v, results: y, numFailures: g, lastResult: b }) => {
2336
+ for (let k = 0; k < f.length; ++k) {
2337
+ const P = y ? y[k] : f[k], x = p[k];
2338
+ P == null ? x.onerror && x.onerror(v[k]) : x.onsuccess && x.onsuccess(l.type === "put" && m[k] ? l.values[k] : P);
2339
+ }
2340
+ return { failures: v, results: y, numFailures: g, lastResult: b };
2341
+ }).catch((v) => (p.forEach((y) => y.onerror && y.onerror(v)), Promise.reject(v)));
2342
+ });
2343
+ }
2344
+ function d(l, h, f) {
2345
+ return n.query({ trans: l, values: !1, query: { index: r, range: h }, limit: f }).then(({ result: m }) => c({ type: "delete", keys: m, trans: l }).then((p) => p.numFailures > 0 ? Promise.reject(p.failures[0]) : m.length < f ? { failures: [], numFailures: 0, lastResult: void 0 } : d(l, { ...h, lower: m[m.length - 1], lowerOpen: !0 }, f)));
2346
+ }
2347
+ } };
2348
+ } }) };
2349
+ function er(t, e, n) {
2350
+ try {
2351
+ if (!e || e.keys.length < t.length)
2352
+ return null;
2353
+ const r = [];
2354
+ for (let s = 0, i = 0; s < e.keys.length && i < t.length; ++s)
2355
+ L(e.keys[s], t[i]) === 0 && (r.push(n ? We(e.values[s]) : e.values[s]), ++i);
2356
+ return r.length === t.length ? r : null;
2357
+ } catch {
2358
+ return null;
2359
+ }
2360
+ }
2361
+ const Hr = { stack: "dbcore", level: -1, create: (t) => ({ table: (e) => {
2362
+ const n = t.table(e);
2363
+ return { ...n, getMany: (r) => {
2364
+ if (!r.cache)
2365
+ return n.getMany(r);
2366
+ const s = er(r.keys, r.trans._cache, r.cache === "clone");
2367
+ return s ? S.resolve(s) : n.getMany(r).then((i) => (r.trans._cache = { keys: r.keys, values: r.cache === "clone" ? We(i) : i }, i));
2368
+ }, mutate: (r) => (r.type !== "add" && (r.trans._cache = null), n.mutate(r)) };
2369
+ } }) };
2370
+ function cn(t) {
2371
+ return !("from" in t);
2372
+ }
2373
+ const Q = function(t, e) {
2374
+ if (!this) {
2375
+ const n = new Q();
2376
+ return t && "d" in t && U(n, t), n;
2377
+ }
2378
+ U(this, arguments.length ? { d: 1, from: t, to: arguments.length > 1 ? e : t } : { d: 0 });
2379
+ };
2380
+ function Ve(t, e, n) {
2381
+ const r = L(e, n);
2382
+ if (isNaN(r))
2383
+ return;
2384
+ if (r > 0)
2385
+ throw RangeError();
2386
+ if (cn(t))
2387
+ return U(t, { from: e, to: n, d: 1 });
2388
+ const s = t.l, i = t.r;
2389
+ if (L(n, t.from) < 0)
2390
+ return s ? Ve(s, e, n) : t.l = { from: e, to: n, d: 1, l: null, r: null }, xn(t);
2391
+ if (L(e, t.to) > 0)
2392
+ return i ? Ve(i, e, n) : t.r = { from: e, to: n, d: 1, l: null, r: null }, xn(t);
2393
+ L(e, t.from) < 0 && (t.from = e, t.l = null, t.d = i ? i.d + 1 : 1), L(n, t.to) > 0 && (t.to = n, t.r = null, t.d = t.l ? t.l.d + 1 : 1);
2394
+ const o = !t.r;
2395
+ s && !t.l && gt(t, s), i && o && gt(t, i);
2396
+ }
2397
+ function gt(t, e) {
2398
+ cn(e) || function n(r, { from: s, to: i, l: o, r: u }) {
2399
+ Ve(r, s, i), o && n(r, o), u && n(r, u);
2400
+ }(t, e);
2401
+ }
2402
+ function Yr(t, e) {
2403
+ const n = Xt(e);
2404
+ let r = n.next();
2405
+ if (r.done)
2406
+ return !1;
2407
+ let s = r.value;
2408
+ const i = Xt(t);
2409
+ let o = i.next(s.from), u = o.value;
2410
+ for (; !r.done && !o.done; ) {
2411
+ if (L(u.from, s.to) <= 0 && L(u.to, s.from) >= 0)
2412
+ return !0;
2413
+ L(s.from, u.from) < 0 ? s = (r = n.next(u.from)).value : u = (o = i.next(s.from)).value;
2414
+ }
2415
+ return !1;
2416
+ }
2417
+ function Xt(t) {
2418
+ let e = cn(t) ? null : { s: 0, n: t };
2419
+ return { next(n) {
2420
+ const r = arguments.length > 0;
2421
+ for (; e; )
2422
+ switch (e.s) {
2423
+ case 0:
2424
+ if (e.s = 1, r)
2425
+ for (; e.n.l && L(n, e.n.from) < 0; )
2426
+ e = { up: e, n: e.n.l, s: 1 };
2427
+ else
2428
+ for (; e.n.l; )
2429
+ e = { up: e, n: e.n.l, s: 1 };
2430
+ case 1:
2431
+ if (e.s = 2, !r || L(n, e.n.to) <= 0)
2432
+ return { value: e.n, done: !1 };
2433
+ case 2:
2434
+ if (e.n.r) {
2435
+ e.s = 3, e = { up: e, n: e.n.r, s: 0 };
2436
+ continue;
2437
+ }
2438
+ case 3:
2439
+ e = e.up;
2440
+ }
2441
+ return { done: !0 };
2442
+ } };
2443
+ }
2444
+ function xn(t) {
2445
+ var e, n;
2446
+ const r = (((e = t.r) === null || e === void 0 ? void 0 : e.d) || 0) - (((n = t.l) === null || n === void 0 ? void 0 : n.d) || 0), s = r > 1 ? "r" : r < -1 ? "l" : "";
2447
+ if (s) {
2448
+ const i = s === "r" ? "l" : "r", o = { ...t }, u = t[s];
2449
+ t.from = u.from, t.to = u.to, t[s] = u[s], o[s] = u[i], t[i] = o, o.d = Sn(o);
2450
+ }
2451
+ t.d = Sn(t);
2452
+ }
2453
+ function Sn({ r: t, l: e }) {
2454
+ return (t ? e ? Math.max(t.d, e.d) : t.d : e ? e.d : 0) + 1;
2455
+ }
2456
+ Pe(Q.prototype, { add(t) {
2457
+ return gt(this, t), this;
2458
+ }, addKey(t) {
2459
+ return Ve(this, t, t), this;
2460
+ }, addKeys(t) {
2461
+ return t.forEach((e) => Ve(this, e, e)), this;
2462
+ }, [At]() {
2463
+ return Xt(this);
2464
+ } });
2465
+ const Gr = { stack: "dbcore", level: 0, create: (t) => {
2466
+ const e = t.schema.name, n = new Q(t.MIN_KEY, t.MAX_KEY);
2467
+ return { ...t, table: (r) => {
2468
+ const s = t.table(r), { schema: i } = s, { primaryKey: o } = i, { extractKey: u, outbound: a } = o, c = { ...s, mutate: (h) => {
2469
+ const f = h.trans, m = f.mutatedParts || (f.mutatedParts = {}), p = (x) => {
2470
+ const w = `idb://${e}/${r}/${x}`;
2471
+ return m[w] || (m[w] = new Q());
2472
+ }, v = p(""), y = p(":dels"), { type: g } = h;
2473
+ let [b, k] = h.type === "deleteRange" ? [h.range] : h.type === "delete" ? [h.keys] : h.values.length < 50 ? [[], h.values] : [];
2474
+ const P = h.trans._cache;
2475
+ return s.mutate(h).then((x) => {
2476
+ if (M(b)) {
2477
+ g !== "delete" && (b = x.results), v.addKeys(b);
2478
+ const w = er(b, P);
2479
+ w || g === "add" || y.addKeys(b), (w || k) && function(A, _, R, O) {
2480
+ function q(B) {
2481
+ const N = A(B.name || "");
2482
+ function ye(V) {
2483
+ return V != null ? B.extractKey(V) : null;
2484
+ }
2485
+ const ve = (V) => B.multiEntry && M(V) ? V.forEach((le) => N.addKey(le)) : N.addKey(V);
2486
+ (R || O).forEach((V, le) => {
2487
+ const Ae = R && ye(R[le]), bt = O && ye(O[le]);
2488
+ L(Ae, bt) !== 0 && (Ae != null && ve(Ae), bt != null && ve(bt));
2489
+ });
2490
+ }
2491
+ _.indexes.forEach(q);
2492
+ }(p, i, w, k);
2493
+ } else if (b) {
2494
+ const w = { from: b.lower, to: b.upper };
2495
+ y.add(w), v.add(w);
2496
+ } else
2497
+ v.add(n), y.add(n), i.indexes.forEach((w) => p(w.name).add(n));
2498
+ return x;
2499
+ });
2500
+ } }, d = ({ query: { index: h, range: f } }) => {
2501
+ var m, p;
2502
+ return [h, new Q((m = f.lower) !== null && m !== void 0 ? m : t.MIN_KEY, (p = f.upper) !== null && p !== void 0 ? p : t.MAX_KEY)];
2503
+ }, l = { get: (h) => [o, new Q(h.key)], getMany: (h) => [o, new Q().addKeys(h.keys)], count: d, query: d, openCursor: d };
2504
+ return $(l).forEach((h) => {
2505
+ c[h] = function(f) {
2506
+ const { subscr: m } = E;
2507
+ if (m) {
2508
+ const p = (k) => {
2509
+ const P = `idb://${e}/${r}/${k}`;
2510
+ return m[P] || (m[P] = new Q());
2511
+ }, v = p(""), y = p(":dels"), [g, b] = l[h](f);
2512
+ if (p(g.name || "").add(b), !g.isPrimaryKey) {
2513
+ if (h !== "count") {
2514
+ const k = h === "query" && a && f.values && s.query({ ...f, values: !1 });
2515
+ return s[h].apply(this, arguments).then((P) => {
2516
+ if (h === "query") {
2517
+ if (a && f.values)
2518
+ return k.then(({ result: w }) => (v.addKeys(w), P));
2519
+ const x = f.values ? P.result.map(u) : P.result;
2520
+ f.values ? v.addKeys(x) : y.addKeys(x);
2521
+ } else if (h === "openCursor") {
2522
+ const x = P, w = f.values;
2523
+ return x && Object.create(x, { key: { get: () => (y.addKey(x.primaryKey), x.key) }, primaryKey: { get() {
2524
+ const A = x.primaryKey;
2525
+ return y.addKey(A), A;
2526
+ } }, value: { get: () => (w && v.addKey(x.primaryKey), x.value) } });
2527
+ }
2528
+ return P;
2529
+ });
2530
+ }
2531
+ y.add(n);
2532
+ }
2533
+ }
2534
+ return s[h].apply(this, arguments);
2535
+ };
2536
+ }), c;
2537
+ } };
2538
+ } };
2539
+ class pe {
2540
+ constructor(e, n) {
2541
+ this._middlewares = {}, this.verno = 0;
2542
+ const r = pe.dependencies;
2543
+ this._options = n = { addons: pe.addons, autoOpen: !0, indexedDB: r.indexedDB, IDBKeyRange: r.IDBKeyRange, ...n }, this._deps = { indexedDB: n.indexedDB, IDBKeyRange: n.IDBKeyRange };
2544
+ const { addons: s } = n;
2545
+ this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this;
2546
+ const i = { dbOpenError: null, isBeingOpened: !1, onReadyBeingFired: null, openComplete: !1, dbReadyResolve: I, dbReadyPromise: null, cancelOpen: I, openCanceller: null, autoSchema: !0, PR1398_maxLoop: 3 };
2547
+ var o;
2548
+ i.dbReadyPromise = new S((u) => {
2549
+ i.dbReadyResolve = u;
2550
+ }), i.openCanceller = new S((u, a) => {
2551
+ i.cancelOpen = a;
2552
+ }), this._state = i, this.name = e, this.on = $e(this, "populate", "blocked", "versionchange", "close", { ready: [nn, I] }), this.on.ready.subscribe = En(this.on.ready.subscribe, (u) => (a, c) => {
2553
+ pe.vip(() => {
2554
+ const d = this._state;
2555
+ if (d.openComplete)
2556
+ d.dbOpenError || S.resolve().then(a), c && u(a);
2557
+ else if (d.onReadyBeingFired)
2558
+ d.onReadyBeingFired.push(a), c && u(a);
2559
+ else {
2560
+ u(a);
2561
+ const l = this;
2562
+ c || u(function h() {
2563
+ l.on.ready.unsubscribe(a), l.on.ready.unsubscribe(h);
2564
+ });
2565
+ }
2566
+ });
2567
+ }), this.Collection = (o = this, Oe(Kr.prototype, function(u, a) {
2568
+ this.db = o;
2569
+ let c = Hn, d = null;
2570
+ if (a)
2571
+ try {
2572
+ c = a();
2573
+ } catch (m) {
2574
+ d = m;
2575
+ }
2576
+ const l = u._ctx, h = l.table, f = h.hook.reading.fire;
2577
+ this._ctx = { table: h, index: l.index, isPrimKey: !l.index || h.schema.primKey.keyPath && l.index === h.schema.primKey.name, range: c, keysOnly: !1, dir: "next", unique: "", algorithm: null, filter: null, replayFilter: null, justLimit: !0, isMatch: null, offset: 0, limit: 1 / 0, error: d, or: l.or, valueMapper: f !== Fe ? f : null };
2578
+ })), this.Table = function(u) {
2579
+ return Oe(Ir.prototype, function(a, c, d) {
2580
+ this.db = u, this._tx = d, this.name = a, this.schema = c, this.hook = u._allTables[a] ? u._allTables[a].hook : $e(null, { creating: [br, I], reading: [vr, Fe], updating: [_r, I], deleting: [wr, I] });
2581
+ });
2582
+ }(this), this.Transaction = function(u) {
2583
+ return Oe($r.prototype, function(a, c, d, l, h) {
2584
+ this.db = u, this.mode = a, this.storeNames = c, this.schema = d, this.chromeTransactionDurability = l, this.idbtrans = null, this.on = $e(this, "complete", "error", "abort"), this.parent = h || null, this.active = !0, this._reculock = 0, this._blockedFuncs = [], this._resolve = null, this._reject = null, this._waitingFor = null, this._waitingQueue = null, this._spinCount = 0, this._completion = new S((f, m) => {
2585
+ this._resolve = f, this._reject = m;
2586
+ }), this._completion.then(() => {
2587
+ this.active = !1, this.on.complete.fire();
2588
+ }, (f) => {
2589
+ var m = this.active;
2590
+ return this.active = !1, this.on.error.fire(f), this.parent ? this.parent._reject(f) : m && this.idbtrans && this.idbtrans.abort(), D(f);
2591
+ });
2592
+ });
2593
+ }(this), this.Version = function(u) {
2594
+ return Oe(qr.prototype, function(a) {
2595
+ this.db = u, this._cfg = { version: a, storesSource: null, dbschema: {}, tables: {}, contentUpgrade: null };
2596
+ });
2597
+ }(this), this.WhereClause = function(u) {
2598
+ return Oe(Gn.prototype, function(a, c, d) {
2599
+ this.db = u, this._ctx = { table: a, index: c === ":id" ? null : c, or: d };
2600
+ const l = u._deps.indexedDB;
2601
+ if (!l)
2602
+ throw new C.MissingAPI();
2603
+ this._cmp = this._ascending = l.cmp.bind(l), this._descending = (h, f) => l.cmp(f, h), this._max = (h, f) => l.cmp(h, f) > 0 ? h : f, this._min = (h, f) => l.cmp(h, f) < 0 ? h : f, this._IDBKeyRange = u._deps.IDBKeyRange;
2604
+ });
2605
+ }(this), this.on("versionchange", (u) => {
2606
+ u.newVersion > 0 ? console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`) : console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`), this.close();
2607
+ }), this.on("blocked", (u) => {
2608
+ !u.newVersion || u.newVersion < u.oldVersion ? console.warn(`Dexie.delete('${this.name}') was blocked`) : console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${u.oldVersion / 10}`);
2609
+ }), this._maxKey = Ue(n.IDBKeyRange), this._createTransaction = (u, a, c, d) => new this.Transaction(u, a, c, this._options.chromeTransactionDurability, d), this._fireOnBlocked = (u) => {
2610
+ this.on("blocked").fire(u), Ne.filter((a) => a.name === this.name && a !== this && !a._state.vcFired).map((a) => a.on("versionchange").fire(u));
2611
+ }, this.use(Wr), this.use(zr), this.use(Gr), this.use(Hr), this.vip = Object.create(this, { _vip: { value: !0 } }), s.forEach((u) => u(this));
2612
+ }
2613
+ version(e) {
2614
+ if (isNaN(e) || e < 0.1)
2615
+ throw new C.Type("Given version is not a positive number");
2616
+ if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened)
2617
+ throw new C.Schema("Cannot add version when database is open");
2618
+ this.verno = Math.max(this.verno, e);
2619
+ const n = this._versions;
2620
+ var r = n.filter((s) => s._cfg.version === e)[0];
2621
+ return r || (r = new this.Version(e), n.push(r), n.sort(Fr), r.stores({}), this._state.autoSchema = !1, r);
2622
+ }
2623
+ _whenReady(e) {
2624
+ return this.idbdb && (this._state.openComplete || E.letThrough || this._vip) ? e() : new S((n, r) => {
2625
+ if (this._state.openComplete)
2626
+ return r(new C.DatabaseClosed(this._state.dbOpenError));
2627
+ if (!this._state.isBeingOpened) {
2628
+ if (!this._options.autoOpen)
2629
+ return void r(new C.DatabaseClosed());
2630
+ this.open().catch(I);
2631
+ }
2632
+ this._state.dbReadyPromise.then(n, r);
2633
+ }).then(e);
2634
+ }
2635
+ use({ stack: e, create: n, level: r, name: s }) {
2636
+ s && this.unuse({ stack: e, name: s });
2637
+ const i = this._middlewares[e] || (this._middlewares[e] = []);
2638
+ return i.push({ stack: e, create: n, level: r ?? 10, name: s }), i.sort((o, u) => o.level - u.level), this;
2639
+ }
2640
+ unuse({ stack: e, name: n, create: r }) {
2641
+ return e && this._middlewares[e] && (this._middlewares[e] = this._middlewares[e].filter((s) => r ? s.create !== r : !!n && s.name !== n)), this;
2642
+ }
2643
+ open() {
2644
+ return Ur(this);
2645
+ }
2646
+ _close() {
2647
+ const e = this._state, n = Ne.indexOf(this);
2648
+ if (n >= 0 && Ne.splice(n, 1), this.idbdb) {
2649
+ try {
2650
+ this.idbdb.close();
2651
+ } catch {
2652
+ }
2653
+ this._novip.idbdb = null;
2654
+ }
2655
+ e.dbReadyPromise = new S((r) => {
2656
+ e.dbReadyResolve = r;
2657
+ }), e.openCanceller = new S((r, s) => {
2658
+ e.cancelOpen = s;
2659
+ });
2660
+ }
2661
+ close() {
2662
+ this._close();
2663
+ const e = this._state;
2664
+ this._options.autoOpen = !1, e.dbOpenError = new C.DatabaseClosed(), e.isBeingOpened && e.cancelOpen(e.dbOpenError);
2665
+ }
2666
+ delete() {
2667
+ const e = arguments.length > 0, n = this._state;
2668
+ return new S((r, s) => {
2669
+ const i = () => {
2670
+ this.close();
2671
+ var o = this._deps.indexedDB.deleteDatabase(this.name);
2672
+ o.onsuccess = j(() => {
2673
+ (function({ indexedDB: u, IDBKeyRange: a }, c) {
2674
+ !un(u) && c !== vt && an(u, a).delete(c).catch(I);
2675
+ })(this._deps, this.name), r();
2676
+ }), o.onerror = Y(s), o.onblocked = this._fireOnBlocked;
2677
+ };
2678
+ if (e)
2679
+ throw new C.InvalidArgument("Arguments not allowed in db.delete()");
2680
+ n.isBeingOpened ? n.dbReadyPromise.then(i) : i();
2681
+ });
2682
+ }
2683
+ backendDB() {
2684
+ return this.idbdb;
2685
+ }
2686
+ isOpen() {
2687
+ return this.idbdb !== null;
2688
+ }
2689
+ hasBeenClosed() {
2690
+ const e = this._state.dbOpenError;
2691
+ return e && e.name === "DatabaseClosed";
2692
+ }
2693
+ hasFailed() {
2694
+ return this._state.dbOpenError !== null;
2695
+ }
2696
+ dynamicallyOpened() {
2697
+ return this._state.autoSchema;
2698
+ }
2699
+ get tables() {
2700
+ return $(this._allTables).map((e) => this._allTables[e]);
2701
+ }
2702
+ transaction() {
2703
+ const e = Vr.apply(this, arguments);
2704
+ return this._transaction.apply(this, e);
2705
+ }
2706
+ _transaction(e, n, r) {
2707
+ let s = E.trans;
2708
+ s && s.db === this && e.indexOf("!") === -1 || (s = null);
2709
+ const i = e.indexOf("?") !== -1;
2710
+ let o, u;
2711
+ e = e.replace("!", "").replace("?", "");
2712
+ try {
2713
+ if (u = n.map((c) => {
2714
+ var d = c instanceof this.Table ? c.name : c;
2715
+ if (typeof d != "string")
2716
+ throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
2717
+ return d;
2718
+ }), e == "r" || e === _t)
2719
+ o = _t;
2720
+ else {
2721
+ if (e != "rw" && e != kt)
2722
+ throw new C.InvalidArgument("Invalid transaction mode: " + e);
2723
+ o = kt;
2724
+ }
2725
+ if (s) {
2726
+ if (s.mode === _t && o === kt) {
2727
+ if (!i)
2728
+ throw new C.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
2729
+ s = null;
2730
+ }
2731
+ s && u.forEach((c) => {
2732
+ if (s && s.storeNames.indexOf(c) === -1) {
2733
+ if (!i)
2734
+ throw new C.SubTransaction("Table " + c + " not included in parent transaction.");
2735
+ s = null;
2736
+ }
2737
+ }), i && s && !s.active && (s = null);
2738
+ }
2739
+ } catch (c) {
2740
+ return s ? s._promise(null, (d, l) => {
2741
+ l(c);
2742
+ }) : D(c);
2743
+ }
2744
+ const a = Zn.bind(null, this, o, u, s, r);
2745
+ return s ? s._promise(o, a, "lock") : E.trans ? Te(E.transless, () => this._whenReady(a)) : this._whenReady(a);
2746
+ }
2747
+ table(e) {
2748
+ if (!z(this._allTables, e))
2749
+ throw new C.InvalidTable(`Table ${e} does not exist`);
2750
+ return this._allTables[e];
2751
+ }
2752
+ }
2753
+ const Xr = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable";
2754
+ class Qr {
2755
+ constructor(e) {
2756
+ this._subscribe = e;
2757
+ }
2758
+ subscribe(e, n, r) {
2759
+ return this._subscribe(e && typeof e != "function" ? e : { next: e, error: n, complete: r });
2760
+ }
2761
+ [Xr]() {
2762
+ return this;
2763
+ }
2764
+ }
2765
+ function tr(t, e) {
2766
+ return $(e).forEach((n) => {
2767
+ gt(t[n] || (t[n] = new Q()), e[n]);
2768
+ }), t;
2769
+ }
2770
+ function Jr(t) {
2771
+ let e, n = !1;
2772
+ const r = new Qr((s) => {
2773
+ const i = Zt(t);
2774
+ let o = !1, u = {}, a = {};
2775
+ const c = { get closed() {
2776
+ return o;
2777
+ }, unsubscribe: () => {
2778
+ o = !0, ue.storagemutated.unsubscribe(f);
2779
+ } };
2780
+ s.start && s.start(c);
2781
+ let d = !1, l = !1;
2782
+ function h() {
2783
+ return $(a).some((p) => u[p] && Yr(u[p], a[p]));
2784
+ }
2785
+ const f = (p) => {
2786
+ tr(u, p), h() && m();
2787
+ }, m = () => {
2788
+ if (d || o)
2789
+ return;
2790
+ u = {};
2791
+ const p = {}, v = function(y) {
2792
+ i && Ce();
2793
+ const g = () => oe(t, { subscr: y, trans: null }), b = E.trans ? Te(E.transless, g) : g();
2794
+ return i && b.then(ne, ne), b;
2795
+ }(p);
2796
+ l || (ue(Le, f), l = !0), d = !0, Promise.resolve(v).then((y) => {
2797
+ n = !0, e = y, d = !1, o || (h() ? m() : (u = {}, a = p, s.next && s.next(y)));
2798
+ }, (y) => {
2799
+ d = !1, n = !1, s.error && s.error(y), c.unsubscribe();
2800
+ });
2801
+ };
2802
+ return m(), c;
2803
+ });
2804
+ return r.hasValue = () => n, r.getValue = () => e, r;
2805
+ }
2806
+ let Qt;
2807
+ try {
2808
+ Qt = { indexedDB: K.indexedDB || K.mozIndexedDB || K.webkitIndexedDB || K.msIndexedDB, IDBKeyRange: K.IDBKeyRange || K.webkitIDBKeyRange };
2809
+ } catch {
2810
+ Qt = { indexedDB: null, IDBKeyRange: null };
2811
+ }
2812
+ const ce = pe;
2813
+ function at(t) {
2814
+ let e = Z;
2815
+ try {
2816
+ Z = !0, ue.storagemutated.fire(t);
2817
+ } finally {
2818
+ Z = e;
2819
+ }
2820
+ }
2821
+ Pe(ce, { ...tt, delete: (t) => new ce(t, { addons: [] }).delete(), exists: (t) => new ce(t, { addons: [] }).open().then((e) => (e.close(), !0)).catch("NoSuchDatabaseError", () => !1), getDatabaseNames(t) {
2822
+ try {
2823
+ return function({ indexedDB: e, IDBKeyRange: n }) {
2824
+ return un(e) ? Promise.resolve(e.databases()).then((r) => r.map((s) => s.name).filter((s) => s !== vt)) : an(e, n).toCollection().primaryKeys();
2825
+ }(ce.dependencies).then(t);
2826
+ } catch {
2827
+ return D(new C.MissingAPI());
2828
+ }
2829
+ }, defineClass: () => function(t) {
2830
+ U(this, t);
2831
+ }, ignoreTransaction: (t) => E.trans ? Te(E.transless, t) : t(), vip: Yt, async: function(t) {
2832
+ return function() {
2833
+ try {
2834
+ var e = Gt(t.apply(this, arguments));
2835
+ return e && typeof e.then == "function" ? e : S.resolve(e);
2836
+ } catch (n) {
2837
+ return D(n);
2838
+ }
2839
+ };
2840
+ }, spawn: function(t, e, n) {
2841
+ try {
2842
+ var r = Gt(t.apply(n, e || []));
2843
+ return r && typeof r.then == "function" ? r : S.resolve(r);
2844
+ } catch (s) {
2845
+ return D(s);
2846
+ }
2847
+ }, currentTransaction: { get: () => E.trans || null }, waitFor: function(t, e) {
2848
+ const n = S.resolve(typeof t == "function" ? ce.ignoreTransaction(t) : t).timeout(e || 6e4);
2849
+ return E.trans ? E.trans.waitFor(n) : n;
2850
+ }, Promise: S, debug: { get: () => G, set: (t) => {
2851
+ Kn(t, t === "dexie" ? () => !0 : zn);
2852
+ } }, derive: ke, extend: U, props: Pe, override: En, Events: $e, on: ue, liveQuery: Jr, extendObservabilitySet: tr, getByKeyPath: te, setByKeyPath: H, delByKeyPath: function(t, e) {
2853
+ typeof e == "string" ? H(t, e, void 0) : "length" in e && [].map.call(e, function(n) {
2854
+ H(t, n, void 0);
2855
+ });
2856
+ }, shallowClone: An, deepClone: We, getObjectDiff: ln, cmp: L, asap: Cn, minKey: Mt, addons: [], connections: Ne, errnames: tn, dependencies: Qt, semVer: yn, version: yn.split(".").map((t) => parseInt(t)).reduce((t, e, n) => t + e / Math.pow(10, 2 * n)) }), ce.maxKey = Ue(ce.dependencies.IDBKeyRange), typeof dispatchEvent < "u" && typeof addEventListener < "u" && (ue(Le, (t) => {
2857
+ if (!Z) {
2858
+ let e;
2859
+ yt ? (e = document.createEvent("CustomEvent"), e.initCustomEvent(ie, !0, !0, t)) : e = new CustomEvent(ie, { detail: t }), Z = !0, dispatchEvent(e), Z = !1;
2860
+ }
2861
+ }), addEventListener(ie, ({ detail: t }) => {
2862
+ Z || at(t);
2863
+ }));
2864
+ let Z = !1;
2865
+ if (typeof BroadcastChannel < "u") {
2866
+ const t = new BroadcastChannel(ie);
2867
+ typeof t.unref == "function" && t.unref(), ue(Le, (e) => {
2868
+ Z || t.postMessage(e);
2869
+ }), t.onmessage = (e) => {
2870
+ e.data && at(e.data);
2871
+ };
2872
+ } else if (typeof self < "u" && typeof navigator < "u") {
2873
+ ue(Le, (e) => {
2874
+ try {
2875
+ Z || (typeof localStorage < "u" && localStorage.setItem(ie, JSON.stringify({ trig: Math.random(), changedParts: e })), typeof self.clients == "object" && [...self.clients.matchAll({ includeUncontrolled: !0 })].forEach((n) => n.postMessage({ type: ie, changedParts: e })));
2876
+ } catch {
2877
+ }
2878
+ }), typeof addEventListener < "u" && addEventListener("storage", (e) => {
2879
+ if (e.key === ie) {
2880
+ const n = JSON.parse(e.newValue);
2881
+ n && at(n.changedParts);
2882
+ }
2883
+ });
2884
+ const t = self.document && navigator.serviceWorker;
2885
+ t && t.addEventListener("message", function({ data: e }) {
2886
+ e && e.type === ie && at(e.changedParts);
2887
+ });
2888
+ }
2889
+ S.rejectionMapper = function(t, e) {
2890
+ if (!t || t instanceof xe || t instanceof TypeError || t instanceof SyntaxError || !t.name || !fn[t.name])
2891
+ return t;
2892
+ var n = new fn[t.name](e || t.message, t);
2893
+ return "stack" in t && ee(n, "stack", { get: function() {
2894
+ return this.inner.stack;
2895
+ } }), n;
2896
+ }, Kn(G, zn);
2897
+ class Zr extends pe {
2898
+ constructor() {
2899
+ super("NylasAuthDatabase"), ut(this, "grant"), ut(this, "pkce"), this.version(1).stores({
2900
+ grant: "++id,token",
2901
+ pkce: "++id,codeVerifier"
2902
+ }), this.grant = this.table("grant"), this.pkce = this.table("pkce");
2903
+ }
2904
+ }
2905
+ class es {
2906
+ constructor() {
2907
+ ut(this, "theDB"), this.theDB = new Zr();
2908
+ }
2909
+ async setCodeVerifier(e) {
2910
+ await this.theDB.pkce.put({ id: 1, codeVerifier: e }, 1);
2911
+ }
2912
+ async getCodeVerifier() {
2913
+ const [e] = await this.theDB.pkce.toArray();
2914
+ return e ? e.codeVerifier : null;
2915
+ }
2916
+ async getTokenInfo() {
2917
+ const e = await this.theDB.grant.get(1);
2918
+ return e ? e.token : null;
2919
+ }
2920
+ async setTokenInfo(e) {
2921
+ await this.theDB.grant.put({ id: 1, token: e }, 1);
2922
+ }
2923
+ async reset() {
2924
+ await this.theDB.grant.clear();
2925
+ }
2926
+ }
2927
+ function is(t) {
2928
+ const e = "NylasAuth";
2929
+ if (!t)
2930
+ throw new Error("NylasAuth requires a config object");
2931
+ let n = null;
2932
+ if (t.storageType === "indexeddb" && (n = new es()), !n)
2933
+ throw new Error("NylasAuth requires a storage object");
2934
+ const r = [
2935
+ {
2936
+ type: "read-only",
2937
+ value: "https://www.googleapis.com/auth/gmail.readonly"
2938
+ },
2939
+ {
2940
+ type: "modify",
2941
+ value: "https://www.googleapis.com/auth/gmail.modify"
2942
+ },
2943
+ {
2944
+ type: "compose",
2945
+ value: "https://www.googleapis.com/auth/gmail.compose"
2946
+ },
2947
+ {
2948
+ type: "insert",
2949
+ value: "https://www.googleapis.com/auth/gmail.insert"
2950
+ },
2951
+ {
2952
+ type: "labels",
2953
+ value: "https://www.googleapis.com/auth/gmail.labels"
2954
+ },
2955
+ {
2956
+ type: "metadata",
2957
+ value: "https://www.googleapis.com/auth/gmail.metadata"
2958
+ },
2959
+ {
2960
+ type: "settings.basic",
2961
+ value: "https://www.googleapis.com/auth/gmail.settings.basic"
2962
+ },
2963
+ {
2964
+ type: "settings.sharing",
2965
+ value: "https://www.googleapis.com/auth/gmail.settings.sharing"
2966
+ }
2967
+ ], s = [
2968
+ {
2969
+ type: "read-only",
2970
+ value: "https://outlook.office.com/mail.read"
2971
+ },
2972
+ {
2973
+ type: "modify",
2974
+ value: "https://outlook.office.com/mail.readwrite"
2975
+ },
2976
+ {
2977
+ type: "send",
2978
+ value: "https://outlook.office.com/mail.send"
2979
+ },
2980
+ {
2981
+ type: "offline",
2982
+ value: "offline_access"
2983
+ }
2984
+ ];
2985
+ async function i(o, u, a, c = !0, d, l) {
2986
+ const h = await (n == null ? void 0 : n.getTokenInfo()), f = new URL(o, d ?? t.apiUri), m = new Headers();
2987
+ m.append("Accept", "application/json"), m.append("Content-Type", "application/json"), m.append("User-Agent", e), h && m.append("Authorization", `Bearer ${h.access_token}`);
2988
+ const p = await fetch(f.toString(), {
2989
+ method: u || "GET",
2990
+ headers: m,
2991
+ mode: "cors",
2992
+ referrer: location.origin,
2993
+ body: a ? JSON.stringify(a) : void 0,
2994
+ ...l || {}
2995
+ });
2996
+ return c ? await p.json() : p.body;
2997
+ }
2998
+ return {
2999
+ config: t,
3000
+ /**
3001
+ * This method will make a request to the Nylas API to exchange an authorization code for an access token.
3002
+ * @param scopes The scopes that were used to generate the authorization code
3003
+ * @param email The email that was used to generate the authorization code
3004
+ * @param provider The provider that was used to generate the authorization code
3005
+ * @returns A promise that resolves to a URL string that can be used to redirect the user to the Nylas API to complete the authorization flow
3006
+ */
3007
+ async getHostedAuthRedirectURL(o = t.defaultScopes, u, a) {
3008
+ const c = await dn(Math.random().toString()), d = await dn(c);
3009
+ await (n == null ? void 0 : n.setCodeVerifier(c));
3010
+ const l = new URL(`${t.apiUri}/v3/connect/auth`);
3011
+ return l.searchParams.set("client_id", t.clientId), l.searchParams.set("response_type", "code"), l.searchParams.set("scope", o.join(" ")), l.searchParams.set("redirect_uri", t.redirectURI), l.searchParams.set("access_type", "offline"), l.searchParams.set("code_challenge", d), l.searchParams.set("code_challenge_method", "S256"), l.searchParams.set("options", "rotate_refresh_token"), a && l.searchParams.set("provider", a), u && l.searchParams.set("login_hint", u), l.toString();
3012
+ },
3013
+ /**
3014
+ * This method will make a request to the Nylas API to exchange an authorization code for an access token.
3015
+ * @param path A path to the Nylas API, e.g. `/v3/grants/methreads`
3016
+ * @param method GET, POST, PUT, DELETE, etc.
3017
+ * @param body A JSON object to send as the body of the request
3018
+ * @param domain The domain to use for the request, e.g. `api.us.nylas.com`
3019
+ * @param parseJSON Whether to parse the response as JSON or return the raw response (default: true)
3020
+ * @returns
3021
+ */
3022
+ nylasAPIRequest: i,
3023
+ /**
3024
+ * This method will make a request to the Nylas API to exchange an authorization code for an access token.
3025
+ * @param code The authorization code that was returned from the Nylas API
3026
+ * @returns A promise that resolves to a TokenExchangeResponse object
3027
+ */
3028
+ async exchangeAuthCodeForTokenInfo(o) {
3029
+ if (!o)
3030
+ return null;
3031
+ const u = await (n == null ? void 0 : n.getCodeVerifier()), a = await this.nylasAPIRequest("/v3/connect/token", "POST", {
3032
+ code: o,
3033
+ client_id: t.clientId,
3034
+ grant_type: "authorization_code",
3035
+ redirect_uri: t.redirectURI,
3036
+ code_verifier: u
3037
+ });
3038
+ return "error" in a || await (n == null ? void 0 : n.setTokenInfo(a)), a;
3039
+ },
3040
+ /**
3041
+ * This method will make a `application/octet-stream` request to the Nylas API to download a file.
3042
+ */
3043
+ async nylasDownloadFileRequest(o, u = "GET", a) {
3044
+ const c = await (n == null ? void 0 : n.getTokenInfo()), d = new URL(o, t.apiUri), l = new Headers();
3045
+ return l.append("Accept", "application/json"), l.append("Content-Type", "application/octet-stream"), l.append("User-Agent", e), c && l.append("Authorization", `Bearer ${c.access_token}`), (await fetch(d.toString(), {
3046
+ method: u,
3047
+ headers: l,
3048
+ mode: "cors",
3049
+ referrer: location.origin,
3050
+ body: a ? JSON.stringify(a) : void 0
3051
+ })).blob();
3052
+ },
3053
+ /**
3054
+ * This methid will clear the access token from the storage object
3055
+ */
3056
+ async logout() {
3057
+ const o = await (n == null ? void 0 : n.getTokenInfo());
3058
+ o && await this.nylasAPIRequest(`/v3/connect/revoke?token=${o.access_token}`, "POST"), await (n == null ? void 0 : n.reset());
3059
+ },
3060
+ /**
3061
+ * This method will make a request to the Nylas API to exchange an authorization code for an access token.
3062
+ * @returns A promise that resolves to a boolean indicating whether the user is authenticated
3063
+ */
3064
+ async isAuthenticated() {
3065
+ return !!await (n == null ? void 0 : n.getTokenInfo());
3066
+ },
3067
+ /**
3068
+ * This method will return information about the current access token.
3069
+ * @returns A promise with the token info
3070
+ */
3071
+ async getTokenInfo() {
3072
+ const o = await (n == null ? void 0 : n.getTokenInfo());
3073
+ if (!o)
3074
+ return null;
3075
+ const { access_token: u, ...a } = o;
3076
+ return a;
3077
+ },
3078
+ /**
3079
+ * This method will make a request to the Nylas API to validate if the current access token is valid.
3080
+ * @returns A promise that resolves to a boolean indicating whether the current access token is valid
3081
+ */
3082
+ async isAccessTokenValid() {
3083
+ const o = await (n == null ? void 0 : n.getTokenInfo());
3084
+ return o ? "data" in await this.nylasAPIRequest(`/v3/connect/tokeninfo?id_token=${o.id_token}`, "GET") : !1;
3085
+ },
3086
+ /**
3087
+ * This method will make a request to the Nylas API to refresh the current access token.
3088
+ * @returns A promise that resolves to a TokenExchangeResponse object
3089
+ */
3090
+ async refreshAccessToken() {
3091
+ const o = await (n == null ? void 0 : n.getTokenInfo());
3092
+ if (!o)
3093
+ return null;
3094
+ const u = await this.nylasAPIRequest("/v3/connect/token", "POST", {
3095
+ client_id: t.clientId,
3096
+ grant_type: "refresh_token",
3097
+ refresh_token: o.refresh_token
3098
+ });
3099
+ return "error" in u || await (n == null ? void 0 : n.setTokenInfo(u)), u;
3100
+ },
3101
+ /**
3102
+ * This method will return true if the current access token has the given scope
3103
+ * based on the type of scope (e.g. 'read-only', 'modify', 'compose', 'insert', 'labels', 'metadata', 'settings.basic', or 'settings.sharing')
3104
+ * @param type Either 'read-only', 'modify', 'compose', 'insert', 'labels', 'metadata', 'settings.basic', or 'settings.sharing'
3105
+ */
3106
+ async hasScopeByType(o = "email", u) {
3107
+ const a = await (n == null ? void 0 : n.getTokenInfo());
3108
+ if (!a)
3109
+ return !1;
3110
+ const c = a.scope.toLowerCase().split(" ");
3111
+ let d = [];
3112
+ const l = Array.isArray(u) ? u : [u];
3113
+ return o === "email" && (d = [...s, ...r].filter((h) => l.includes(h.type))), d.every((h) => c.includes(h.value));
3114
+ },
3115
+ /**
3116
+ * A helper method to check if the current access token has a given scope.
3117
+ * @param scope The scope(s) to check for in the current access token (e.g. https://www.googleapis.com/auth/gmail.modify)
3118
+ * @returns boolean indicating whether the current access token has the given scope
3119
+ */
3120
+ async hasScope(o) {
3121
+ const u = await (n == null ? void 0 : n.getTokenInfo());
3122
+ if (!u)
3123
+ return !1;
3124
+ const a = u.scope.toLowerCase().split(" ");
3125
+ return (Array.isArray(o) ? o : [o]).some((c) => a.includes(c.toLowerCase()));
3126
+ }
3127
+ };
3128
+ }
3129
+ export {
3130
+ ns as N,
3131
+ rs as X,
3132
+ ss as Z,
3133
+ is as e,
3134
+ ar as n
3135
+ };