@aerogel/plugin-local-first 0.1.1 → 0.1.2-next.0532ffc3845be5e86d770e8e823f5216ef34dfbf

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.
@@ -1,470 +1,522 @@
1
- var Ge = Object.defineProperty;
2
- var Xe = (o, s, e) => s in o ? Ge(o, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[s] = e;
3
- var M = (o, s, e) => Xe(o, typeof s != "symbol" ? s + "" : s, e);
4
- import { Service as et, appNamespace as tt, Events as D, App as oe, Job as ye, Errors as Z, defineServiceState as nt, replaceExisting as $e, translateWithDefault as C, dispatch as ae, Modal as Ee, Markdown as E, Link as he, Button as T, UI as le, Storage as st, defineSettings as ot, useEvent as it, SettingsModal as Oe, ProgressBar as rt, AdvancedOptions as at, Checkbox as ce, EditableContent as lt, DropdownMenu as ct, bootServices as dt } from "@aerogel/core";
5
- import { facade as we, IndexedDBMap as ut, isInstanceOf as O, arrayFilter as ht, after as G, arrayRemove as ft, required as I, tap as Te, urlRoute as qe, urlResolveDirectory as mt, objectWithout as gt, requireUrlParentDirectory as X, fail as Pe, arrayFrom as pt, map as L, arrayChunk as yt, mixed as _e, objectMap as wt, round as Mt, toString as bt, Semaphore as Ct, isArray as vt, isTesting as Se, hasLocationQueryParameter as De, parseBoolean as ke, getLocationQueryParameter as Re } from "@noeldemartin/utils";
6
- import { Solid as $, SolidLogin as $t, SolidAvatar as xe } from "@aerogel/plugin-solid";
7
- import { SolidModel as J, SolidContainsRelation as Je, SolidACLAuthorization as St, SolidDocument as Dt, Metadata as kt, Operation as Rt, SolidContainer as W, isContainerClass as x, isContainer as A, Tombstone as N, PropertyOperation as ee, isSolidModel as Lt } from "soukai-solid";
8
- import { getTrackedModels as Me, trackModelsCollection as te, ignoreModelsCollection as Ut, trackModels as At } from "@aerogel/plugin-soukai";
9
- import { watchEffect as It, markRaw as P, createElementBlock as b, openBlock as f, createElementVNode as m, defineComponent as j, createBlock as k, unref as d, withCtx as v, createVNode as u, createTextVNode as K, toDisplayString as S, createCommentVNode as _, useTemplateRef as zt, ref as Et, computed as Y, normalizeClass as Ne } from "vue";
10
- import { bootModels as Ot, requireEngine as Tt, DocumentNotFound as qt, InvalidModelAttributes as Pt, requireBootedModel as _t, getBootedModels as xt } from "soukai";
11
- import { MalformedSolidDocumentError as Jt } from "@noeldemartin/solid-utils";
12
- class Nt extends et {
13
- constructor() {
14
- super(...arguments);
15
- M(this, "cache", new ut(`${tt()}-documents-cache`));
16
- }
17
- async isFresh(e, t) {
18
- const n = await this.cache.get(e), i = typeof t != "number" ? t.getTime() : t;
19
- return !!(n != null && n.modifiedAt) && n.modifiedAt >= i;
20
- }
21
- async remember(e, t) {
22
- await this.cache.set(e, {
23
- modifiedAt: typeof t != "number" ? t.getTime() : t
24
- });
25
- }
26
- async forget(e) {
27
- await this.cache.delete(e);
28
- }
29
- async clear() {
30
- await this.cache.clear();
31
- }
32
- async boot() {
33
- D.on("auth:logout", async () => {
34
- await this.cache.clear(), this.cache.close();
35
- });
36
- }
37
- }
38
- const q = we(Nt), de = /* @__PURE__ */ new WeakMap();
39
- function fe(o) {
40
- return ht(
41
- R(o).map((s) => {
42
- const e = o.instance().requireRelation(s).relatedClass;
43
- return x(e) ? !1 : e;
1
+ var lt = Object.defineProperty;
2
+ var ct = (o, n, e) => n in o ? lt(o, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[n] = e;
3
+ var v = (o, n, e) => ct(o, typeof n != "symbol" ? n + "" : n, e);
4
+ import { App as X, Job as ve, Errors as re, defineServiceState as dt, replaceExisting as Re, translateWithDefault as S, Events as L, dispatch as ue, appNamespace as ut, Modal as _e, Markdown as q, Link as pe, Button as N, UI as he, Storage as ht, defineSettings as ft, useModal as mt, useEvent as gt, SettingsModal as We, ProgressBar as pt, AdvancedOptions as yt, Checkbox as fe, EditableContent as wt, DropdownMenu as Mt, bootServices as Ct } from "@aerogel/core";
5
+ import { isInstanceOf as O, arrayFilter as bt, required as z, facade as Ne, after as ae, arrayRemove as vt, urlRoute as Je, tap as xe, urlResolveDirectory as Dt, requireUrlParentDirectory as U, fail as Be, arrayFrom as St, arrayChunk as ke, map as E, mixed as je, objectMap as $t, round as Rt, arrayWithout as kt, toString as Lt, Semaphore as At, isArray as Ut, isTesting as Le, hasLocationQueryParameter as Ae, parseBoolean as Ue, getLocationQueryParameter as Ee } from "@noeldemartin/utils";
6
+ import { Solid as b, SolidLogin as Et, SolidAvatar as Fe } from "@aerogel/plugin-solid";
7
+ import { SolidModel as F, SolidContainsRelation as It, SolidIsContainedByRelation as zt, SolidACLAuthorization as Pt, SolidDocument as Ot, SolidResource as qt, Metadata as Tt, Operation as _t, SolidContainer as ee, isContainerClass as V, isContainer as T, Tombstone as B, PropertyOperation as le, DocumentsCache as Wt, isSolidModel as Nt } from "soukai-solid";
8
+ import { getTrackedModels as De, trackModelsCollection as Z, ignoreModelsCollection as Ie, trackModels as Jt } from "@aerogel/plugin-soukai";
9
+ import { watchEffect as xt, markRaw as J, createElementBlock as D, openBlock as p, createElementVNode as y, defineComponent as H, createBlock as A, unref as u, withCtx as $, createVNode as f, createTextVNode as se, toDisplayString as k, createCommentVNode as x, ref as Bt, computed as oe, normalizeClass as Ve } from "vue";
10
+ import { bootModels as jt, requireEngine as Se, DocumentNotFound as He, InvalidModelAttributes as Ft, requireBootedModel as Vt, getBootedModels as Ht } from "soukai";
11
+ import { MalformedSolidDocumentError as Kt } from "@noeldemartin/solid-utils";
12
+ const me = /* @__PURE__ */ new WeakMap();
13
+ function ye(o) {
14
+ return bt(
15
+ _(o).map((n) => {
16
+ const e = o.instance().requireRelation(n).relatedClass;
17
+ return V(e) ? !1 : e;
44
18
  })
45
19
  );
46
20
  }
47
- function R(o) {
48
- return de.has(o) || de.set(
21
+ function _(o) {
22
+ return me.has(o) || me.set(
49
23
  o,
50
- o.relations.filter((s) => J.reservedRelations.includes(s) ? !1 : o.instance().requireRelation(s) instanceof Je)
51
- ), de.get(o) ?? [];
24
+ o.relations.filter((n) => F.reservedRelations.includes(n) ? !1 : o.instance().requireRelation(n) instanceof It)
25
+ ), me.get(o) ?? [];
52
26
  }
53
- function We(o) {
54
- return R(o.static()).reduce(
27
+ function Ke(o) {
28
+ return _(o.static()).reduce(
55
29
  (e, t) => e.concat(o.getRelationModels(t) ?? []),
56
30
  []
57
31
  );
58
32
  }
59
- function Le(o) {
60
- const s = /* @__PURE__ */ new Set(), e = o.instance();
61
- s.add(o);
33
+ function ze(o) {
34
+ const n = /* @__PURE__ */ new Set(), e = o.instance();
35
+ n.add(o);
62
36
  for (const t of o.relations)
63
- o.reservedRelations.includes(t) || s.add(e.requireRelation(t).relatedClass);
64
- return [...s.values()];
37
+ o.reservedRelations.includes(t) || n.add(e.requireRelation(t).relatedClass);
38
+ return [...n.values()];
65
39
  }
66
- function ne(o) {
40
+ function j(o) {
67
41
  return o.getRelatedModels().filter(
68
- (s) => !O(s, St) && !O(s, Dt) && !O(s, kt) && !O(s, Rt) && s.static() !== W
42
+ (n) => !O(n, Pt) && !O(n, Ot) && !O(n, qt) && !O(n, Tt) && !O(n, _t) && n.static() !== ee
69
43
  );
70
44
  }
71
- function je(o) {
45
+ function Ye(o) {
72
46
  if (o.isDirty())
73
47
  return !0;
74
- if (!(o instanceof W))
48
+ if (!(o instanceof ee))
75
49
  return !1;
76
- const s = (e) => {
50
+ const n = (e) => {
77
51
  var t;
78
- return (t = o.getRelationModels(e)) == null ? void 0 : t.some((n) => je(n));
52
+ return (t = o.getRelationModels(e)) == null ? void 0 : t.some((s) => Ye(s));
79
53
  };
80
- return R(o.static()).some(s);
54
+ return _(o.static()).some(n);
81
55
  }
82
- const Wt = I(() => oe.service("$cloud"));
83
- class jt {
56
+ async function we(o, n) {
57
+ const e = ["authorizations", "metadata", "operations", "tombstone"];
58
+ let t;
59
+ do {
60
+ t = !1;
61
+ const s = j(o);
62
+ for (const i of s)
63
+ for (const l of i.static("relations"))
64
+ if (!(e.includes(l) || i.isRelationLoaded(l) || i.getRelation(l) instanceof zt))
65
+ try {
66
+ await i.loadRelation(l), t = !0;
67
+ } catch (a) {
68
+ if (!n)
69
+ throw a;
70
+ n(a);
71
+ }
72
+ } while (t);
73
+ }
74
+ const Yt = z(() => X.service("$cloud"));
75
+ class Qt {
84
76
  constructor() {
85
- M(this, "models", /* @__PURE__ */ new Set());
86
- M(this, "promises", []);
77
+ v(this, "models", /* @__PURE__ */ new Set());
78
+ v(this, "promises", []);
87
79
  }
88
- push(s) {
89
- this.models.add(s), this.syncAfter(G({ seconds: 1 }));
80
+ push(n) {
81
+ this.models.add(n), this.syncAfter(ae({ seconds: 1 }));
90
82
  }
91
- clear(s) {
92
- if (!s) {
83
+ clear(n) {
84
+ if (!n) {
93
85
  this.models = /* @__PURE__ */ new Set();
94
86
  return;
95
87
  }
96
- for (const e of s)
88
+ for (const e of n)
97
89
  this.models.delete(e);
98
90
  }
99
- async syncAfter(s) {
100
- const e = typeof s == "function" ? s() : s;
101
- return this.promises.push(e), e.then(() => ft(this.promises, e)), this.promises.length === 1 && this.schedule(), e;
91
+ async syncAfter(n) {
92
+ const e = typeof n == "function" ? n() : n;
93
+ return this.promises.push(e), e.then(() => vt(this.promises, e)), this.promises.length === 1 && this.schedule(), e;
102
94
  }
103
95
  schedule() {
104
- Promise.all(this.promises).then(() => G()).then(() => {
96
+ Promise.all(this.promises).then(() => ae()).then(() => {
105
97
  if (this.promises.length !== 0) {
106
98
  this.schedule();
107
99
  return;
108
100
  }
109
- const s = this.consume();
110
- s.length !== 0 && Wt.syncIfOnline(s);
101
+ const n = this.consume();
102
+ n.length !== 0 && Yt.syncIfOnline(n);
111
103
  });
112
104
  }
113
105
  consume() {
114
- const s = [], e = /* @__PURE__ */ new Set();
106
+ const n = [], e = /* @__PURE__ */ new Set();
115
107
  for (const t of this.models)
116
- A(t) && (this.models.delete(t), We(t).forEach((n) => e.add(n)), s.push(t));
108
+ T(t) && (this.models.delete(t), Ke(t).forEach((s) => e.add(s)), n.push(t));
117
109
  for (const t of this.models)
118
- this.models.delete(t), !e.has(t) && s.push(t);
119
- return s;
110
+ this.models.delete(t), !e.has(t) && n.push(t);
111
+ return n;
120
112
  }
121
113
  }
122
- const se = we(jt), g = I(() => oe.service("$cloud")), Be = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap();
123
- function Bt(o) {
124
- const s = o.getRelatedModels().concat([o]);
125
- for (const e of s)
114
+ const ce = Ne(Qt), w = z(() => X.service("$cloud")), Qe = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap();
115
+ function Ze(o, n) {
116
+ if (n ?? (n = /* @__PURE__ */ new Set()), !n.has(o)) {
117
+ n.add(o);
118
+ for (const e of o.relations)
119
+ Ze(o.instance().requireRelation(e).relatedClass, n);
120
+ }
121
+ return n;
122
+ }
123
+ function Zt(o) {
124
+ const n = o.getRelatedModels().concat([o]);
125
+ for (const e of n)
126
126
  e.cleanDirty(!0);
127
127
  }
128
- function Vt(o) {
129
- const s = ne(o).concat([o]);
130
- for (const e of s) {
128
+ function Gt(o) {
129
+ const n = j(o).concat([o]);
130
+ for (const e of n) {
131
131
  if (!e.operations || e.operations.length === 0)
132
132
  continue;
133
- const t = (e.operations ?? []).filter((n) => !(n instanceof ee) || !e.ignoreRdfPropertyHistory(n.property, !0));
134
- if (!t.some((n) => !n.isInception(e))) {
133
+ const t = (e.operations ?? []).filter((s) => !(s instanceof le) || !e.ignoreRdfPropertyHistory(s.property, !0));
134
+ if (!t.some((s) => !s.isInception(e))) {
135
135
  e.setRelationModels("operations", []);
136
136
  continue;
137
137
  }
138
138
  e.setRelationModels("operations", t);
139
139
  }
140
140
  }
141
- async function Ue(o) {
142
- g.setState({
141
+ async function Pe(o) {
142
+ w.setState({
143
143
  localModelUpdates: {
144
- ...g.localModelUpdates,
144
+ ...w.localModelUpdates,
145
145
  [o.url]: 1
146
146
  }
147
- }), Xt(o.static()) && await me(o.static(), X(o.url)), g.autoPush && g.ready && !g.syncing && se.push(o);
147
+ }), an(o.static()) && await Me(o.static(), U(o.url)), w.autoPush && w.ready && !w.syncing && ce.push(o);
148
148
  }
149
- async function me(o, s) {
150
- var e, t;
151
- (e = g.modelCollections[o.modelName]) != null && e.includes(s) || (g.setState("modelCollections", {
152
- ...g.modelCollections,
153
- [o.modelName]: (g.modelCollections[o.modelName] ?? []).concat(s)
154
- }), (t = g.modelCollections[o.modelName]) != null && t.includes(o.collection) || (o.collection = s), await te(o, s));
149
+ function Xt(o, n) {
150
+ var s;
151
+ const e = P(ee), t = (s = w.registeredModels.find(
152
+ ({ modelClass: i }) => i === o.static()
153
+ )) == null ? void 0 : s.path;
154
+ return new e({
155
+ url: ie(et(o, n).static(), t)
156
+ });
157
+ }
158
+ async function Me(o, n) {
159
+ var e;
160
+ (e = w.modelCollections[o.modelName]) != null && e.includes(n) || (w.setState("modelCollections", {
161
+ ...w.modelCollections,
162
+ [o.modelName]: (w.modelCollections[o.modelName] ?? []).concat(n)
163
+ }), await Z(o, n));
155
164
  }
156
- async function Ae(o) {
157
- if (Ft(o))
165
+ async function Oe(o) {
166
+ if (en(o))
158
167
  return;
159
- const s = g.localModelUpdates[o.url] ?? 0;
160
- g.setState({
161
- localModelUpdates: o.isSoftDeleted() ? gt(g.localModelUpdates, o.url) : {
162
- ...g.localModelUpdates,
163
- [o.url]: s + 1
168
+ const n = w.localModelUpdates[o.url] ?? 0;
169
+ w.setState({
170
+ localModelUpdates: {
171
+ ...w.localModelUpdates,
172
+ [o.url]: o.isSoftDeleted() ? 1 : n + 1
164
173
  }
165
- }), await q.forget(o.requireDocumentUrl()), g.autoPush && g.ready && !g.syncing && se.push(o);
174
+ }), await w.getDocumentsCache().forget(
175
+ U(o.requireDocumentUrl()),
176
+ o.requireDocumentUrl()
177
+ ), w.autoPush && w.ready && !w.syncing && ce.push(o);
166
178
  }
167
- function ge(o, s) {
179
+ function Ce(o, n) {
168
180
  const e = {}, t = Array.from(o);
169
- for (const [n, i] of Object.entries(g.localModelUpdates)) {
170
- const l = qe(n);
171
- (o.has(n) || t.some((r) => r.endsWith("/") && n.startsWith(r))) && !(s != null && s.has(l)) || (e[n] = i);
181
+ for (const [s, i] of Object.entries(w.localModelUpdates)) {
182
+ const l = Je(s);
183
+ (o.has(s) || t.some((r) => r.endsWith("/") && s.startsWith(r))) && !(n != null && n.has(l)) || (e[s] = i);
172
184
  }
173
- g.setState({ localModelUpdates: e });
185
+ w.setState({ localModelUpdates: e });
174
186
  }
175
- function Ce(o, s = {}) {
176
- const e = /* @__PURE__ */ new Set();
177
- if (e.add(o.static()), o instanceof W)
178
- for (const n of R(o.static()))
179
- e.add(o.requireRelation(n).relatedClass);
180
- const t = [...e.values()].map(
181
- (n) => [n, z(n)]
187
+ function Ge(o, n = {}) {
188
+ const e = Array.from(new Set(j(o).map((t) => t.static()))).map(
189
+ (t) => [t, P(t)]
182
190
  );
183
- return Te(o.clone({ constructors: t }), (n) => {
184
- Vt(n), s.clean && Bt(n);
191
+ return xe(o.clone({ constructors: e }), (t) => {
192
+ Gt(t), n.clean && Zt(t);
185
193
  });
186
194
  }
187
- function Ve(o) {
188
- const s = /* @__PURE__ */ new Set();
189
- if (s.add(o.static()), o instanceof W)
190
- for (const t of R(o.static()))
191
- s.add(o.requireRelation(t).relatedClass);
192
- const e = [...s.values()].map(
193
- (t) => [t, tn(t)]
194
- );
195
- return o.clone({ constructors: e });
195
+ function Xe(o) {
196
+ return o.clone({ constructors: Q(o) });
196
197
  }
197
- async function Ie(o, s, e) {
198
- const t = z(N), n = s.map((a) => a.url), i = o.filter((a) => !n.includes(a.url)).map((a) => a.requireDocumentUrl()).filter((a) => !e.has(a)), l = await t.all({ $in: i });
199
- return s.concat(l);
198
+ async function qe(o, n, e) {
199
+ const t = P(B), s = n.map((a) => a.url), i = o.filter((a) => !s.includes(a.url)).map((a) => a.requireDocumentUrl()).filter((a) => !e.has(a)), l = await t.all({ $in: i });
200
+ return n.concat(l);
200
201
  }
201
- function Ft(o) {
202
+ function en(o) {
202
203
  return !o.getDocumentModels().flatMap(
203
204
  (t) => {
204
- var n;
205
- return ((n = t.operations) == null ? void 0 : n.map((i) => [t, i])) ?? [];
205
+ var s;
206
+ return ((s = t.operations) == null ? void 0 : s.map((i) => [t, i])) ?? [];
206
207
  }
207
- ).some(([t, n]) => {
208
+ ).some(([t, s]) => {
208
209
  var i, l;
209
- return n.date.getTime() !== ((l = (i = t.metadata) == null ? void 0 : i.updatedAt) == null ? void 0 : l.getTime()) ? !1 : n instanceof ee ? !t.ignoreRdfPropertyHistory(n.property, !0) : !0;
210
+ return s.date.getTime() !== ((l = (i = t.metadata) == null ? void 0 : i.updatedAt) == null ? void 0 : l.getTime()) ? !1 : s instanceof le ? !t.ignoreRdfPropertyHistory(s.property, !0) : !0;
210
211
  });
211
212
  }
212
- function Ht(o, s) {
213
- return s.get(o.url) ?? Ve(o);
213
+ function Q(o) {
214
+ const n = o.static();
215
+ if (!ge.has(n)) {
216
+ const e = Array.from(Ze(n)).map((t) => tt(t) ? [t, cn(t)] : [t, P(t)]).map(([t, s]) => [
217
+ [t, s],
218
+ [s, t]
219
+ ]).flat();
220
+ for (const t of e)
221
+ ge.set(t[0], e);
222
+ }
223
+ return z(ge.get(n));
224
+ }
225
+ function et(o, n) {
226
+ return n.get(o.url) ?? Xe(o);
214
227
  }
215
- function pe() {
216
- return [...g.registeredModels].map(({ modelClass: o }) => Me(o, { includeSoftDeleted: !0 })).flat();
228
+ function be() {
229
+ return [...w.registeredModels].map(({ modelClass: o }) => De(o, { includeSoftDeleted: !0 })).flat();
217
230
  }
218
- function Kt() {
219
- return g.schemaMigrations;
231
+ function tn() {
232
+ return w.schemaMigrations;
220
233
  }
221
- function Yt() {
222
- g.schemaMigrations.clear();
234
+ function nn() {
235
+ w.schemaMigrations.clear();
223
236
  }
224
- function ze(o) {
225
- return g.schemaMigrations.get(o);
237
+ function Te(o) {
238
+ return w.schemaMigrations.get(o);
226
239
  }
227
- function z(o) {
228
- return Be.get(o) ?? en(o);
240
+ function P(o) {
241
+ return Qe.get(o) ?? ln(o);
229
242
  }
230
- function ue(o, s) {
231
- const e = $.requireUser().storageUrls[0], t = x(o) && R(o).map((n) => {
232
- const i = o.instance().requireRelation(n).relatedClass;
233
- return x(i) ? null : i;
243
+ function ie(o, n) {
244
+ const e = b.requireUser().storageUrls[0], t = V(o) && _(o).map((s) => {
245
+ const i = o.instance().requireRelation(s).relatedClass;
246
+ return V(i) ? null : i;
234
247
  }).filter(Boolean)[0];
235
- return s ?? (s = `/${(t || o).modelName.toLowerCase()}s/`), mt((s.startsWith("/") ? e.slice(0, -1) : e) + s);
248
+ return n ?? (n = `/${(t || o).modelName.toLowerCase()}s/`), Dt((n.startsWith("/") ? e.slice(0, -1) : e) + n);
236
249
  }
237
- function Qt(o, s) {
238
- return s.get(o.url) ?? Ce(o);
250
+ function sn(o, n) {
251
+ return n.get(o.url) ?? Ge(o);
239
252
  }
240
- function Zt(o) {
241
- for (const { modelClass: s } of g.registeredModels)
242
- if (Me(s).some((t) => t.url === o.url))
253
+ function on(o) {
254
+ for (const { modelClass: n } of w.registeredModels)
255
+ if (De(n).some((t) => t.url === o.url))
243
256
  return !0;
244
257
  return !1;
245
258
  }
246
- function Q(o) {
247
- return be.has(o.static());
259
+ function G(o) {
260
+ return tt(o.static());
248
261
  }
249
- function Gt(o) {
250
- return !Q(o);
262
+ function tt(o) {
263
+ return $e.has(o);
251
264
  }
252
- function Xt(o) {
253
- return g.registeredModels.some(({ modelClass: s }) => s === o);
265
+ function rn(o) {
266
+ return !G(o);
254
267
  }
255
- function en(o) {
256
- var n;
257
- const s = o, e = (i, l) => {
258
- i.timestamps = s.timestamps, i.history = s.history, l(), i.timestamps = [], i.history = !1;
259
- }, t = (n = class extends s {
268
+ function an(o) {
269
+ return w.registeredModels.some(({ modelClass: n }) => n === o);
270
+ }
271
+ function ln(o) {
272
+ var s;
273
+ const n = o, e = (i, l) => {
274
+ i.timestamps = n.timestamps, i.history = n.history, l(), i.timestamps = [], i.history = !1;
275
+ }, t = (s = class extends n {
260
276
  initialize(i, l) {
261
277
  e(this._proxy.static(), () => super.initialize(i, l));
262
278
  }
263
279
  initializeRelations() {
264
280
  super.initializeRelations();
265
281
  for (const i of Object.values(this._relations))
266
- i instanceof Je && (i.relatedClass = z(i.relatedClass));
282
+ i.relatedClass = P(i.relatedClass);
267
283
  }
268
284
  fixMalformedAttributes() {
269
285
  e(this.static(), () => super.fixMalformedAttributes());
270
286
  }
271
- }, M(n, "timestamps", !1), M(n, "history", !1), n);
272
- return Be.set(s, t), be.set(t, s), s.on("schema-updated", async (i) => {
287
+ }, v(s, "timestamps", !1), v(s, "history", !1), s);
288
+ return n.on("schema-updated", async (i) => {
273
289
  await t.updateSchema({
274
290
  ...i,
275
291
  timestamps: !1,
276
292
  history: !1
277
293
  });
278
- }), Ot({ [`Remote${o.modelName}`]: t }), t;
294
+ }), o.ensureBooted(), jt({ [`Remote${o.modelName}`]: t }), X.service("$cloud") && w.getEngine() && t.setEngine(w.requireEngine()), Qe.set(n, t), $e.set(t, n), t;
279
295
  }
280
- function tn(o) {
281
- return be.get(o) ?? Pe(`Couldn't find local class for ${o.modelName}`);
296
+ function cn(o) {
297
+ return $e.get(o) ?? Be(`Couldn't find local class for ${o.modelName}`);
282
298
  }
283
- class nn extends ye {
299
+ class dn extends ve {
284
300
  constructor() {
285
301
  super(...arguments);
286
- M(this, "urlMigrations", []);
287
- M(this, "collectionMigrations", []);
302
+ v(this, "urlMigrations", []);
303
+ v(this, "collectionMigrations", []);
288
304
  }
289
- migrateUrl(e, t, n) {
305
+ migrateUrl(e, t, s) {
290
306
  this.urlMigrations.push({
291
307
  modelClass: e,
292
308
  local: t,
293
- remote: n
309
+ remote: s
294
310
  });
295
311
  }
296
- migrateCollection(e, t, n) {
312
+ migrateCollection(e, t, s) {
297
313
  this.collectionMigrations.push({
298
314
  modelClass: e,
299
315
  local: t,
300
- remote: n
316
+ remote: s
301
317
  });
302
318
  }
303
319
  async run() {
304
- const e = Tt(), t = await e.getCollections();
305
- for (const n of t) {
306
- const i = await e.readMany(n);
307
- for (const [l, a] of Object.entries(i)) {
308
- const r = this.replaceUrl(l);
309
- await e.create(X(r), this.replaceDocumentUrls(a), r), await e.delete(n, l);
320
+ const e = Se(), t = await e.getCollections(), s = /* @__PURE__ */ new Set();
321
+ for (const i of t) {
322
+ const l = await e.readMany(i);
323
+ for (const [a, r] of Object.entries(l)) {
324
+ const c = this.replaceUrl(a);
325
+ await e.create(
326
+ U(c),
327
+ this.replaceDocumentUrls(r),
328
+ c
329
+ ), await e.delete(i, a);
330
+ }
331
+ }
332
+ for (const { modelClass: i, remote: l } of this.urlMigrations)
333
+ Z(i, U(l));
334
+ for (const { modelClass: i, local: l, remote: a } of this.collectionMigrations) {
335
+ const r = Object.assign({}, b.collections), c = (b.collections[i.modelName] ?? []).filter(
336
+ (d) => !l.startsWith(d)
337
+ );
338
+ Ie(i, l), Z(i, a);
339
+ for (const d of b.collections[i.modelName] ?? []) {
340
+ const m = this.replaceUrl(d);
341
+ m !== d && (Ie(i, d), Z(i, m));
310
342
  }
343
+ b.collections = r, t.filter((d) => l.startsWith(d)).forEach((d) => s.add(d)), c.length > 0 ? r[i.modelName] = c : delete r[i.modelName];
311
344
  }
312
- for (const { modelClass: n, remote: i } of this.urlMigrations)
313
- te(n, X(i), { refresh: !1 });
314
- for (const { modelClass: n, local: i, remote: l } of this.collectionMigrations)
315
- Ut(n, i), te(n, l, { refresh: !1 });
345
+ await e.dropCollections(Array.from(s));
316
346
  }
317
347
  replaceDocumentUrls(e) {
318
- for (const [t, n] of Object.entries(e)) {
319
- if (t === "@id" && typeof n == "string") {
320
- e[t] = this.replaceUrl(n);
348
+ for (const [t, s] of Object.entries(e)) {
349
+ if (t === "@id" && typeof s == "string") {
350
+ e[t] = this.replaceUrl(s);
321
351
  continue;
322
352
  }
323
- typeof n != "object" || n === null || (e[t] = this.replaceDocumentUrls(n));
353
+ typeof s != "object" || s === null || (e[t] = this.replaceDocumentUrls(s));
324
354
  }
325
355
  return e;
326
356
  }
327
357
  replaceUrl(e) {
328
- for (const { local: t, remote: n } of this.urlMigrations)
358
+ for (const { local: t, remote: s } of this.urlMigrations)
329
359
  if (e.startsWith(t))
330
- return e.replace(t, n);
331
- for (const { local: t, remote: n } of this.collectionMigrations)
360
+ return e.replace(t, s);
361
+ for (const { local: t, remote: s } of this.collectionMigrations)
332
362
  if (e.startsWith(t))
333
- return e.replace(t, n);
363
+ return e.replace(t, s);
334
364
  return e;
335
365
  }
336
366
  }
337
- function sn(o) {
338
- const s = {};
339
- return async () => ("value" in s || (s.value = await o()), s.value);
367
+ function un(o) {
368
+ const n = {};
369
+ return async () => ("value" in n || (n.value = await o()), n.value);
340
370
  }
341
- class Fe {
342
- async loadContainedModels(s, e = {}) {
343
- if (Gt(s)) {
344
- const h = [];
345
- for (const p of R(s.static())) {
346
- const y = await s.loadRelationIfUnloaded(p) ?? [];
347
- h.push(...pt(y));
371
+ class nt {
372
+ async loadContainedModels(n, e = {}) {
373
+ if (rn(n)) {
374
+ const d = [];
375
+ for (const m of _(n.static())) {
376
+ const g = await n.loadRelationIfUnloaded(m) ?? [];
377
+ d.push(...St(g));
348
378
  }
349
- return h;
379
+ return d;
350
380
  }
351
- const t = {}, n = [], i = L(s.documents, "url"), l = yt(s.resourceUrls, 10), a = l.flat().map((h) => ({
352
- documentUrl: h,
381
+ const t = {}, s = [], i = ke(n.resourceUrls, 10), l = i.flat().map((d) => ({
382
+ documentUrl: d,
353
383
  completed: !1
354
- })), r = L(a, "documentUrl");
355
- e.status && (e.status.children = a);
356
- for (const h of l)
384
+ })), a = E(l, "documentUrl"), r = e.updateProgress ?? ((d) => Promise.resolve(d == null ? void 0 : d()));
385
+ e.status && (e.status.children = l);
386
+ for (const d of i)
357
387
  await Promise.all(
358
- h.map(async (p) => {
359
- var ve;
360
- const { children: y, tombstones: V } = await this.loadDocumentChildren(
361
- s,
362
- p,
363
- i,
364
- e.onDocumentError,
365
- e.onDocumentRead
366
- );
367
- n.push(...V);
368
- for (const [re, Ze] of Object.entries(y))
369
- (t[re] ?? (t[re] = [])).push(...Ze);
370
- p.endsWith("/") || (I(r.get(p)).completed = !0, await ((ve = e.onDocumentLoaded) == null ? void 0 : ve.call(e)));
388
+ d.map(async (m) => {
389
+ var R;
390
+ if (n.resources.some(
391
+ (C) => C.url === m && C.types.some((K) => K.startsWith("http://www.w3.org/ns/iana/media-types/image/"))
392
+ ))
393
+ return;
394
+ const { children: g, tombstones: h } = await this.loadDocumentChildren(n, m, e);
395
+ s.push(...h);
396
+ for (const [C, K] of Object.entries(g))
397
+ (t[C] ?? (t[C] = [])).push(...K);
398
+ m.endsWith("/") || (await r(() => {
399
+ z(a.get(m)).completed = !0;
400
+ }), await ((R = e.onDocumentLoaded) == null ? void 0 : R.call(e)));
401
+ })
402
+ );
403
+ for (const [d, m] of Object.entries(t))
404
+ n.setRelationModels(d, m);
405
+ const c = e.ignoreTombstones ? Object.values(t).flat() : Object.values(t).flat().concat(s);
406
+ return await r(() => {
407
+ e.status && (e.status.children = c.map((d) => z(a.get(d.requireDocumentUrl()))));
408
+ }), c;
409
+ }
410
+ async loadContainedDocuments(n, e = {}) {
411
+ if (!G(n))
412
+ throw Error("Cannot get contained models from local model");
413
+ const t = {}, s = n.requireEngine(), i = ke(n.resourceUrls, 10), l = i.flat().map((c) => ({
414
+ documentUrl: c,
415
+ completed: !1
416
+ })), a = E(l, "documentUrl"), r = e.updateProgress ?? ((c) => Promise.resolve(c == null ? void 0 : c()));
417
+ e.status && (e.status.children = l);
418
+ for (const c of i)
419
+ await Promise.all(
420
+ c.map(async (d) => {
421
+ var g, h, R;
422
+ if (!d || d.endsWith("/") || n.resources.some(
423
+ (C) => C.url === d && C.types.some((K) => K.startsWith("http://www.w3.org/ns/iana/media-types/image/"))
424
+ )) {
425
+ await r(() => {
426
+ z(a.get(d)).completed = !0;
427
+ });
428
+ return;
429
+ }
430
+ const m = n.documents.find(({ url: C }) => C === d);
431
+ try {
432
+ t[d] = await s.readOne(n.url, d);
433
+ } catch (C) {
434
+ if (!e.onDocumentError)
435
+ throw C;
436
+ await ((g = e.onDocumentError) == null ? void 0 : g.call(e, C));
437
+ }
438
+ m && await ((h = e.onDocumentRead) == null ? void 0 : h.call(e, m)), await r(() => {
439
+ z(a.get(d)).completed = !0;
440
+ }), await ((R = e.onDocumentLoaded) == null ? void 0 : R.call(e));
371
441
  })
372
442
  );
373
- for (const [h, p] of Object.entries(t))
374
- s.setRelationModels(h, p);
375
- const c = e.ignoreTombstones ? Object.values(t).flat() : Object.values(t).flat().concat(n);
376
- return e.status && (e.status.children = c.map((h) => I(r.get(h.requireDocumentUrl())))), c;
377
- }
378
- async loadDocumentChildren(s, e, t, n, i) {
379
- var a;
380
- const l = t.get(e);
381
- return l && l.updatedAt && await q.isFresh(l.url, l.updatedAt) && ((a = this.localModels) != null && a.hasKey(s.url)) ? {
382
- children: await this.loadDocumentChildrenFromLocal(s, l),
383
- tombstones: []
384
- } : this.loadDocumentChildrenFromRemote(s, e, n, i);
385
- }
386
- async loadDocumentChildrenFromLocal(s, e) {
387
- var n, i;
388
- const t = {};
389
- for (const l of R(s.static())) {
390
- const a = s.requireRelation(l);
391
- if (a.loaded) {
392
- t[l] = a.getLoadedModels();
393
- continue;
394
- }
395
- const r = ((i = (n = this.localModels) == null ? void 0 : n.get(s.url)) == null ? void 0 : i.getRelationModels(l)) ?? [];
396
- t[l] = r.filter((c) => c.getDocumentUrl() === e.url).map((c) => Ce(c, { clean: !0 }));
397
- }
398
443
  return t;
399
444
  }
400
- async loadDocumentChildrenFromRemote(s, e, t, n) {
401
- const i = {}, l = [], a = sn(async () => {
445
+ async loadDocumentChildren(n, e, t = {}) {
446
+ return this.loadDocumentChildrenFromRemote(n, e, t);
447
+ }
448
+ async loadDocumentChildrenFromRemote(n, e, t = {}) {
449
+ const s = {}, i = [], l = un(async () => {
450
+ var r;
402
451
  try {
403
- const r = s.documents.find((p) => p.url === e), c = await s.requireEngine().readOne(s.static("collection"), e), h = await N.createManyFromEngineDocuments({
404
- [e]: c
452
+ const c = n.documents.find((g) => g.url === e), d = await n.requireEngine().readOne(U(e), e), m = await B.createManyFromEngineDocuments({
453
+ [e]: d
405
454
  });
406
- return l.push(...h), r && (n == null || n(r)), c;
407
- } catch (r) {
408
- if (O(r, qt))
455
+ return i.push(...m), c && ((r = t.onDocumentRead) == null || r.call(t, c)), d;
456
+ } catch (c) {
457
+ if (O(c, He))
409
458
  return null;
410
- if (!t)
411
- throw r;
412
- return t(r), null;
459
+ if (!t.onDocumentError)
460
+ throw c;
461
+ return t.onDocumentError(c), null;
413
462
  }
414
463
  });
415
- for (const r of R(s.static())) {
416
- const c = s.requireRelation(r);
464
+ let a = !1;
465
+ for (const r of _(n.static())) {
466
+ const c = n.requireRelation(r);
417
467
  if (c.loaded) {
418
- i[r] = c.getLoadedModels();
468
+ s[r] = c.getLoadedModels();
419
469
  continue;
420
470
  }
421
- const h = await a();
422
- if (h)
471
+ const d = await l();
472
+ if (d)
423
473
  try {
424
- const p = await c.relatedClass.createManyFromEngineDocuments({
425
- [e]: h
474
+ const m = await c.relatedClass.createManyFromEngineDocuments({
475
+ [e]: d
426
476
  });
427
- i[r] = p;
428
- } catch (p) {
429
- if (!t)
430
- throw p;
431
- t(p);
477
+ s[r] = m, a || (a = m.length > 0);
478
+ } catch (m) {
479
+ if (!t.onDocumentError)
480
+ throw m;
481
+ t.onDocumentError(m);
432
482
  }
433
483
  }
434
- return { children: i, tombstones: l };
484
+ if (!a && t.onDocumentIgnored) {
485
+ const r = n.documents.find((c) => c.url === e);
486
+ r && await t.onDocumentIgnored(r);
487
+ }
488
+ return { children: s, tombstones: i };
435
489
  }
436
490
  }
437
- const B = /* @__PURE__ */ new WeakMap();
438
- class He {
439
- async loadTypeIndex(s = {}) {
440
- const e = $.requireUser();
441
- return (s.fresh || !B.has(e)) && B.set(e, await $.findPrivateTypeIndex({ fresh: s.fresh })), s.create && !B.get(e) && B.set(e, await $.findOrCreatePrivateTypeIndex()), B.get(e) ?? null;
491
+ const Y = /* @__PURE__ */ new WeakMap();
492
+ class st {
493
+ async loadTypeIndex(n = {}) {
494
+ const e = b.requireUser();
495
+ return (n.fresh || !Y.has(e)) && Y.set(e, await b.findPrivateTypeIndex({ fresh: n.fresh })), n.create && !Y.get(e) && Y.set(e, await b.findOrCreatePrivateTypeIndex()), Y.get(e) ?? null;
442
496
  }
443
497
  }
444
- class Ke {
445
- async indexLocalModels(s) {
446
- for (const e of s)
498
+ class ot {
499
+ async indexLocalModels(n) {
500
+ for (const e of n)
447
501
  await this.addLocalModel(e);
448
502
  }
449
- async addLocalModel(s) {
450
- if (!this.localModels.hasKey(s.url)) {
451
- this.localModels.add(s);
452
- for (const e of R(s.static()))
453
- await s.loadRelationIfUnloaded(e);
454
- for (const e of ne(s))
503
+ async addLocalModel(n) {
504
+ if (!this.localModels.hasKey(n.url)) {
505
+ this.localModels.add(n), await we(n);
506
+ for (const e of j(n))
455
507
  await this.addLocalModel(e);
456
508
  }
457
509
  }
458
510
  }
459
- const on = ye;
460
- class ie extends _e(on, [Fe, He, Ke]) {
511
+ const hn = ve;
512
+ class de extends je(hn, [nt, st, ot]) {
461
513
  constructor() {
462
514
  super();
463
- M(this, "_models");
464
- this.localModels = L([], "url");
515
+ v(this, "_models");
516
+ this.localModels = E([], "url");
465
517
  }
466
518
  static restore(e) {
467
- return Te(new ie(), (t) => {
519
+ return xe(new de(), (t) => {
468
520
  t.status = e;
469
521
  });
470
522
  }
@@ -473,13 +525,13 @@ class ie extends _e(on, [Fe, He, Ke]) {
473
525
  }
474
526
  set models(e) {
475
527
  if (!e) {
476
- delete this._models, this.localModels = L([], "url");
528
+ delete this._models, this.localModels = E([], "url");
477
529
  return;
478
530
  }
479
- const t = wt(this.status.children ?? [], "modelUrl");
480
- this._models = e, this.localModels = L([], "url"), this.status.children = e.map(
481
- (n) => t[n.url] ?? {
482
- modelUrl: n.url,
531
+ const t = $t(this.status.children ?? [], "modelUrl");
532
+ this._models = e, this.localModels = E([], "url"), this.status.children = e.map(
533
+ (s) => t[s.url] ?? {
534
+ modelUrl: s.url,
483
535
  completed: !1
484
536
  }
485
537
  );
@@ -489,83 +541,83 @@ class ie extends _e(on, [Fe, He, Ke]) {
489
541
  throw new Error("Cant start migration without models");
490
542
  await this.indexLocalModels(this.models);
491
543
  const e = this.status.children ?? [], t = await this.loadTypeIndex();
492
- for (const n of e) {
493
- const i = this.models.find(({ url: l }) => n.modelUrl === l);
494
- !i || n.completed || (await this.migrateRegisteredModel(i, n, t), await this.updateProgress(() => n.completed = !0));
544
+ for (const s of e) {
545
+ const i = this.models.find(({ url: l }) => s.modelUrl === l);
546
+ !i || s.completed || (await this.migrateRegisteredModel(i, s, t), await this.updateProgress(() => s.completed = !0));
495
547
  }
496
- for (const [n, i] of Kt())
497
- await n.updateSchema(i);
498
- Yt();
548
+ for (const [s, i] of tn())
549
+ await s.updateSchema(i);
550
+ nn();
499
551
  }
500
- async migrateRegisteredModel(e, t, n) {
501
- if (await this.migrate(e, t), !A(e))
552
+ async migrateRegisteredModel(e, t, s) {
553
+ if (await this.migrate(e, t), !T(e))
502
554
  return;
503
- const i = fe(e.static()), l = n == null ? void 0 : n.registrations.find(({ instanceContainer: a }) => a === e.url);
504
- !n || !l || i.length === 0 || (l.setAttribute(
555
+ const i = ye(e.static()), l = s == null ? void 0 : s.registrations.find(({ instanceContainer: a }) => a === e.url);
556
+ !s || !l || i.length === 0 || (l.setAttribute(
505
557
  "forClass",
506
558
  i.map((a) => {
507
559
  var r;
508
- return ((r = ze(a)) == null ? void 0 : r.rdfsClasses) ?? a.rdfsClass;
560
+ return ((r = Te(a)) == null ? void 0 : r.rdfsClasses) ?? a.rdfsClass;
509
561
  }).flat()
510
- ), await n.save());
562
+ ), await s.save());
511
563
  }
512
564
  async migrate(e, t) {
513
565
  this.assertNotCancelled(), await this.migrateChildren(e, t);
514
- const n = ze(e.static());
515
- if (!n)
566
+ const s = Te(e.static());
567
+ if (!s)
516
568
  return;
517
- const i = await z(e.static()).find(e.url), l = await (i == null ? void 0 : i.migrateSchema(n));
518
- await e.migrateSchema(n, {
569
+ const i = await P(e.static()).find(e.url), l = await (i == null ? void 0 : i.migrateSchema(s));
570
+ await e.migrateSchema(s, {
519
571
  mintOperationUrl: (a) => {
520
572
  var r, c;
521
- return (c = (r = l == null ? void 0 : l.operations) == null ? void 0 : r.find((h) => !O(a, ee) || !O(h, ee) ? !1 : a.property === h.property && a.date.getTime() === h.date.getTime())) == null ? void 0 : c.url;
573
+ return (c = (r = l == null ? void 0 : l.operations) == null ? void 0 : r.find((d) => !O(a, le) || !O(d, le) ? !1 : a.property === d.property && a.date.getTime() === d.date.getTime())) == null ? void 0 : c.url;
522
574
  }
523
575
  });
524
576
  }
525
577
  async migrateChildren(e, t) {
526
- if (!A(e))
578
+ if (!T(e))
527
579
  return;
528
- const n = await this.loadContainedModels(e, { ignoreTombstones: !0 });
529
- t.children ?? (t.children = n.map((i) => ({
580
+ const s = await this.loadContainedModels(e, { ignoreTombstones: !0 });
581
+ t.children ?? (t.children = s.map((i) => ({
530
582
  modelUrl: i.url,
531
583
  completed: !1
532
584
  })));
533
585
  for (const i of t.children) {
534
- const l = n.find(({ url: a }) => i.modelUrl === a);
586
+ const l = s.find(({ url: a }) => i.modelUrl === a);
535
587
  !l || i.completed || (await this.migrate(l, i), await this.updateProgress(() => i.completed = !0));
536
588
  }
537
589
  }
538
590
  }
539
- const rn = I(() => oe.service("$cloud")), an = ye;
540
- function ln(o) {
591
+ const W = z(() => X.service("$cloud")), fn = ve;
592
+ function mn(o) {
541
593
  return !!o && "root" in o;
542
594
  }
543
- class cn extends _e(an, [Fe, He, Ke]) {
595
+ class gn extends je(fn, [nt, st, ot]) {
544
596
  constructor(e) {
545
597
  super();
546
- M(this, "documentsWithErrors");
547
- M(this, "models");
548
- M(this, "dirtyRemoteModels");
549
- M(this, "rootLocalModels");
550
- M(this, "tombstones");
551
- M(this, "syncedModelUrls");
552
- M(this, "documentsModifiedAt");
553
- M(this, "screenLock", null);
554
- M(this, "localModels");
555
- this.documentsWithErrors = /* @__PURE__ */ new Set(), this.models = e, this.rootLocalModels = [], this.localModels = L([], "url"), this.tombstones = L([], "resourceUrl"), this.syncedModelUrls = /* @__PURE__ */ new Set(), this.documentsModifiedAt = {};
598
+ v(this, "documentsWithErrors");
599
+ v(this, "models");
600
+ v(this, "dirtyRemoteModels");
601
+ v(this, "rootLocalModels");
602
+ v(this, "tombstones");
603
+ v(this, "syncedModelUrls");
604
+ v(this, "documentsModifiedAt");
605
+ v(this, "screenLock", null);
606
+ v(this, "localModels");
607
+ this.documentsWithErrors = /* @__PURE__ */ new Set(), this.models = e, this.rootLocalModels = [], this.localModels = E([], "url"), this.tombstones = E([], "resourceUrl"), this.syncedModelUrls = /* @__PURE__ */ new Set(), this.documentsModifiedAt = {};
556
608
  }
557
609
  async run() {
558
- const e = $.requireAuthenticator().engine, t = (i, { headers: l }, a) => {
610
+ const e = b.requireAuthenticator().engine, t = (i, { headers: l }, a) => {
559
611
  const r = (l == null ? void 0 : l.get("last-modified")) ?? a;
560
612
  !r || i.endsWith("/") || (this.documentsModifiedAt[i] = new Date(r));
561
- }, n = e.listeners.add({
613
+ }, s = e.listeners.add({
562
614
  onDocumentRead: (i, l) => t(i, l),
563
615
  onDocumentUpdated: (i, l) => t(i, l, /* @__PURE__ */ new Date())
564
616
  });
565
617
  try {
566
- this.lockScreen(), this.rootLocalModels = this.models ?? pe(), await this.indexLocalModels(this.rootLocalModels), await this.pullChanges(), await this.pushChanges();
618
+ this.lockScreen(), this.rootLocalModels = this.models ?? be(), e.setConfig({ cachesDocuments: !0, persistentCache: W.getDocumentsCache() }), await this.indexLocalModels(this.rootLocalModels), await this.pullChanges(), await this.pushChanges();
567
619
  } finally {
568
- this.releaseScreen(), n();
620
+ e.clearCache(), e.setConfig({ cachesDocuments: !1, persistentCache: void 0 }), this.releaseScreen(), s();
569
621
  }
570
622
  }
571
623
  lockScreen() {
@@ -573,10 +625,10 @@ class cn extends _e(an, [Fe, He, Ke]) {
573
625
  if (e.wakeLock)
574
626
  try {
575
627
  this.screenLock = e.wakeLock.request("screen").catch((t) => {
576
- Z.reportDevelopmentError(t, "Could not request screen wake lock");
628
+ re.reportDevelopmentError(t, "Could not request screen wake lock");
577
629
  });
578
630
  } catch (t) {
579
- Z.reportDevelopmentError(t, "Could not request screen wake lock");
631
+ re.reportDevelopmentError(t, "Could not request screen wake lock");
580
632
  }
581
633
  }
582
634
  releaseScreen() {
@@ -590,83 +642,148 @@ class cn extends _e(an, [Fe, He, Ke]) {
590
642
  };
591
643
  }
592
644
  calculateCurrentProgress(e) {
593
- return e ?? (e = this.status), ln(e) ? Mt(
645
+ return e ?? (e = this.status), mn(e) ? Rt(
594
646
  this.calculateCurrentProgress(e.children[0]) * 0.9 + this.calculateCurrentProgress(e.children[1]) * 0.1,
595
647
  2
596
648
  ) : super.calculateCurrentProgress(e);
597
649
  }
598
650
  async pullChanges() {
599
- const e = this.models ? await this.fetchRemoteModelsForLocal(this.models) : await this.fetchRemoteModels(), t = L(e, (n) => n instanceof N ? n.resourceUrl : n.url);
600
- this.dirtyRemoteModels = await this.synchronizeModels(t), await this.updateProgress((n) => n.children[0].completed = !0);
651
+ const e = this.models ? await this.fetchRemoteModelsForLocal(this.models) : await this.fetchRemoteModels(), t = E(e, (s) => s instanceof B ? s.resourceUrl : s.url);
652
+ this.dirtyRemoteModels = await this.synchronizeModels(t), await this.updateProgress((s) => s.children[0].completed = !0);
601
653
  }
602
654
  async pushChanges() {
603
- const e = this.dirtyRemoteModels ?? [], t = this.status.children[1].children = e.map(() => ({ completed: !1 }));
604
- for (let n = 0; n < e.length; n++) {
605
- const i = e[n], l = t[n];
606
- if (i.isSoftDeleted()) {
607
- i.enableHistory(), i.enableTombstone(), await i.forceDelete(), await this.updateProgress(() => l.completed = !0);
608
- return;
655
+ const e = new Set(this.localModels.getItems().map((a) => a.getDocumentUrl())), t = this.dirtyRemoteModels ?? [], s = this.status.children[1].children = t.map(() => ({ completed: !1 }));
656
+ for (let a = 0; a < t.length; a++) {
657
+ const r = t[a], c = s[a];
658
+ if (r.isSoftDeleted()) {
659
+ r.enableHistory(), r.enableTombstone(), await r.forceDelete(), await this.updateProgress(() => c.completed = !0), this.syncedModelUrls.add(r.url ?? r.getDeletedPrimaryKey());
660
+ continue;
661
+ }
662
+ await this.saveModelAndRelated(r, c), await this.updateTypeRegistrations(r), await this.updateProgress(() => c.completed = !0);
663
+ }
664
+ const i = W.getDocumentsCache(), l = E(this.tombstones.getItems(), (a) => a.requireDocumentUrl());
665
+ for (const [a, r] of Object.entries(this.documentsModifiedAt)) {
666
+ if (l.hasKey(a)) {
667
+ const c = l.require(a);
668
+ await i.remember(U(a), a, r, {
669
+ tombstone: {
670
+ url: c.url,
671
+ resourceUrl: c.resourceUrl
672
+ }
673
+ });
674
+ continue;
675
+ }
676
+ if (e.has(a)) {
677
+ await i.remember(U(a), a, r);
678
+ continue;
609
679
  }
610
- await this.saveModelAndChildren(i, l), await this.updateTypeRegistrations(i), await this.updateProgress(() => l.completed = !0);
611
680
  }
612
- for (const [n, i] of Object.entries(this.documentsModifiedAt))
613
- await q.remember(n, i);
614
- ge(this.syncedModelUrls, this.documentsWithErrors), await this.updateProgress((n) => n.children[1].completed = !0);
681
+ Ce(this.syncedModelUrls, this.documentsWithErrors), await this.updateProgress((a) => a.children[1].completed = !0);
615
682
  }
616
683
  async fetchRemoteModels() {
684
+ var l, a, r;
617
685
  const e = this.status.children[0], t = await this.loadTypeIndex({ fresh: !0 });
618
686
  if (!t)
619
687
  return [];
620
- const n = [], i = this.getTypeRegistrations(t);
688
+ const s = [], i = this.getTypeRegistrations(t);
621
689
  e.children = i.map(() => ({ completed: !1 }));
622
- for (let l = 0; l < i.length; l++)
623
- await this.ignoringDocumentErrors(async () => {
624
- var h;
625
- const { registration: a, registeredModel: r } = I(i[l]), c = z(r.modelClass);
626
- if (a.instanceContainer) {
627
- if (x(c)) {
628
- await me(
629
- r.modelClass,
630
- X(a.instanceContainer)
631
- );
632
- const p = await c.find(a.instanceContainer);
633
- p && (await this.loadChildren(p, I((h = e.children) == null ? void 0 : h[l])), n.push(p)), await this.updateProgress(() => {
634
- var y;
635
- return I((y = e.children) == null ? void 0 : y[l]).completed = !0;
636
- });
637
- return;
638
- }
639
- await me(r.modelClass, a.instanceContainer), n.push(...await c.from(a.instanceContainer).all()), await this.updateProgress(() => {
640
- var p;
641
- return I((p = e.children) == null ? void 0 : p[l]).completed = !0;
642
- });
643
- }
644
- });
645
- return Ie(this.rootLocalModels, n, this.documentsWithErrors);
690
+ for (let c = 0; c < i.length; c++) {
691
+ const d = z((l = e.children) == null ? void 0 : l[c]), { registration: m, registeredModel: g } = z(i[c]), h = P(g.modelClass);
692
+ if (!m.instanceContainer)
693
+ continue;
694
+ if ((a = W.rootModelCollections)[r = g.modelClass.modelName] ?? (a[r] = m.instanceContainer), V(h)) {
695
+ await Me(
696
+ g.modelClass,
697
+ U(m.instanceContainer)
698
+ );
699
+ const C = await h.find(m.instanceContainer);
700
+ C && (await this.loadChildren(C, d), s.push(C)), await this.updateProgress(() => d.completed = !0);
701
+ continue;
702
+ }
703
+ const R = await this.fetchRemoteModelsFromContainer(
704
+ d,
705
+ g.modelClass,
706
+ h,
707
+ m.instanceContainer
708
+ );
709
+ s.push(...R), await this.updateProgress(() => d.completed = !0);
710
+ }
711
+ for (const c of s)
712
+ await we(c, (d) => this.handleDocumentError(d));
713
+ return qe(this.rootLocalModels, s, this.documentsWithErrors);
714
+ }
715
+ async fetchRemoteModelsFromContainer(e, t, s, i) {
716
+ var g;
717
+ const l = await P(ee).find(i);
718
+ if (!l)
719
+ return [];
720
+ e.children = l.resourceUrls.map(() => ({ completed: !1 }));
721
+ const a = await this.loadContainedDocuments(l, {
722
+ status: e,
723
+ updateProgress: (h) => this.updateProgress(h),
724
+ onDocumentError: (h) => this.handleDocumentError(h),
725
+ onDocumentRead: (h) => {
726
+ h.url.endsWith("/") || !h.updatedAt || h.url in this.documentsModifiedAt || (this.documentsModifiedAt[h.url] = h.updatedAt);
727
+ },
728
+ onDocumentLoaded: async () => {
729
+ this.assertNotCancelled(), await this.updateProgress();
730
+ }
731
+ }), r = await s.createManyFromEngineDocuments(a), c = await B.createManyFromEngineDocuments(a), d = W.getDocumentsCache(), m = new Set(r.map((h) => h.requireDocumentUrl()));
732
+ for (const h of c)
733
+ this.tombstones.add(h), m.add(h.requireDocumentUrl());
734
+ for (const h of l.documents) {
735
+ if (!h.updatedAt || m.has(h.url))
736
+ continue;
737
+ await d.remember(U(h.url), h.url, h.updatedAt);
738
+ const R = Se();
739
+ try {
740
+ await R.readOne(U(h.url), h.url);
741
+ } catch (C) {
742
+ if (!O(C, He))
743
+ throw C;
744
+ await R.create(U(h.url), {}, h.url);
745
+ }
746
+ }
747
+ r.length > 0 && await Me(t, i);
748
+ for (let h = 0; h < l.resourceUrls.length; h++) {
749
+ const R = l.resourceUrls[h];
750
+ if (!(R != null && R.endsWith("/")))
751
+ continue;
752
+ const C = await this.fetchRemoteModelsFromContainer(
753
+ z((g = e.children) == null ? void 0 : g[h]),
754
+ t,
755
+ s,
756
+ R
757
+ );
758
+ r.push(...C), await this.updateProgress();
759
+ }
760
+ return await this.updateProgress(() => e.completed = !0), r;
646
761
  }
647
762
  async fetchRemoteModelsForLocal(e) {
648
- const t = [], n = this.status.children[0].children = e.map(() => ({ completed: !1 }));
763
+ const t = [], s = this.status.children[0].children = e.map(() => ({ completed: !1 }));
649
764
  for (let i = 0; i < e.length; i++)
650
765
  await this.ignoringDocumentErrors(async () => {
651
- const l = e[i], a = n[i], r = await z(l.static()).find(l.url);
766
+ const l = e[i], a = s[i], r = await P(l.static()).find(l.url);
652
767
  if (!r) {
653
768
  await this.updateProgress(() => a.completed = !0);
654
769
  return;
655
770
  }
656
- A(r) && await this.loadChildren(r, a), t.push(r), await this.updateProgress(() => a.completed = !0);
771
+ T(r) && await this.loadChildren(r, a), t.push(r), await this.updateProgress(() => a.completed = !0);
657
772
  });
658
- return Ie(e, t, this.documentsWithErrors);
773
+ for (const i of t)
774
+ await we(i, (l) => this.handleDocumentError(l));
775
+ return qe(e, t, this.documentsWithErrors);
659
776
  }
660
777
  getTypeRegistrations(e) {
661
- const t = /* @__PURE__ */ new Set(), n = [...rn.registeredModels].map(({ modelClass: a }) => {
662
- const r = x(a) ? fe(a) : [];
778
+ const t = /* @__PURE__ */ new Set(), s = [...W.registeredModels].map(({ modelClass: a }) => {
779
+ const r = V(a) ? ye(a) : [];
663
780
  return {
664
781
  modelClass: a,
665
782
  rdfsClasses: r.length > 0 ? r.map((c) => c.rdfsClasses).flat() : a.rdfsClasses
666
783
  };
667
784
  }), i = e.registrations.map((a) => {
668
- const r = n.find(
669
- ({ rdfsClasses: c }) => !!a.instanceContainer && c.some((h) => a.forClass.includes(h))
785
+ const r = s.find(
786
+ ({ rdfsClasses: c }) => !!a.instanceContainer && c.some((d) => a.forClass.includes(d))
670
787
  );
671
788
  return !r || !a.instanceContainer || t.has(a.instanceContainer) ? null : (t.add(a.instanceContainer), { registration: a, registeredModel: r });
672
789
  }).filter((a) => !!a), l = i.map(({ registration: a }) => a.instanceContainer);
@@ -678,31 +795,41 @@ class cn extends _e(an, [Fe, He, Ke]) {
678
795
  ));
679
796
  }
680
797
  async updateTypeRegistrations(e) {
681
- if (!Zt(e))
798
+ if (!on(e))
682
799
  return;
683
- const t = A(e) ? fe(e.static()) : [e.static()], n = z(W), i = A(e) ? e : new n({ url: e.requireContainerUrl() });
684
- if (t.length === 0)
800
+ const t = T(e) ? e : Xt(e, this.localModels), s = T(e) ? ye(e.static()) : [e.static()];
801
+ if (s.length === 0)
685
802
  return;
686
- const l = await this.loadTypeIndex({ create: !0 });
687
- l.registrations.some((a) => a.instanceContainer === e.url) || await i.register(l, t);
803
+ const i = await this.loadTypeIndex({ create: !0 });
804
+ i.registrations.some(
805
+ (l) => l.instanceContainer && e.url.startsWith(l.instanceContainer)
806
+ ) || await t.register(i, s);
688
807
  }
689
808
  async loadChildren(e, t) {
690
809
  var i, l;
691
- if (this.assertNotCancelled(), !A(e))
810
+ if (this.assertNotCancelled(), !T(e))
692
811
  return;
693
- const n = await this.loadContainedModels(e, {
812
+ const s = await this.loadContainedModels(e, {
694
813
  status: t,
814
+ updateProgress: (a) => this.updateProgress(a),
695
815
  onDocumentError: (a) => this.handleDocumentError(a),
696
816
  onDocumentRead: (a) => {
697
817
  a.url.endsWith("/") || !a.updatedAt || a.url in this.documentsModifiedAt || (this.documentsModifiedAt[a.url] = a.updatedAt);
698
818
  },
699
819
  onDocumentLoaded: async () => {
700
820
  this.assertNotCancelled(), await this.updateProgress();
821
+ },
822
+ onDocumentIgnored: async (a) => {
823
+ a.updatedAt && await W.getDocumentsCache().remember(
824
+ U(a.url),
825
+ a.url,
826
+ a.updatedAt
827
+ );
701
828
  }
702
829
  });
703
- for (let a = 0; a < n.length; a++) {
704
- const r = n[a];
705
- if (r instanceof N) {
830
+ for (let a = 0; a < s.length; a++) {
831
+ const r = s[a];
832
+ if (r instanceof B) {
706
833
  this.tombstones.add(r);
707
834
  continue;
708
835
  }
@@ -712,13 +839,13 @@ class cn extends _e(an, [Fe, He, Ke]) {
712
839
  }
713
840
  await this.loadChildren(r, (i = t == null ? void 0 : t.children) == null ? void 0 : i[a]), (l = t == null ? void 0 : t.children) != null && l[a] && await this.updateProgress(() => {
714
841
  var c;
715
- return I((c = t.children) == null ? void 0 : c[a]).completed = !0;
842
+ return z((c = t.children) == null ? void 0 : c[a]).completed = !0;
716
843
  });
717
844
  }
718
845
  }
719
846
  async deleteChild(e, t) {
720
- for (const n of e.static("relations")) {
721
- const i = e.requireRelation(n);
847
+ for (const s of e.static("relations")) {
848
+ const i = e.requireRelation(s);
722
849
  if (i.related) {
723
850
  if (Array.isArray(i.related)) {
724
851
  i.related = i.related.filter((l) => l !== t);
@@ -732,49 +859,56 @@ class cn extends _e(an, [Fe, He, Ke]) {
732
859
  }
733
860
  await t.forceDelete();
734
861
  }
735
- async saveModelAndChildren(e, t) {
736
- if (this.assertNotCancelled(), Q(e) && e.isSoftDeleted()) {
862
+ async saveModelAndRelated(e, t, s) {
863
+ if (this.assertNotCancelled(), s ?? (s = /* @__PURE__ */ new Set()), s.has(e))
864
+ return;
865
+ if (s.add(e), G(e) && e.isSoftDeleted()) {
737
866
  e.enableHistory(), e.enableTombstone(), await e.forceDelete();
738
867
  return;
739
868
  }
740
- if (this.documentsWithErrors.has(e.requireDocumentUrl()))
741
- return;
742
- const n = e.isDirty();
743
- if (await e.save(), (n || Q(e)) && this.syncedModelUrls.add(e.url), !A(e)) {
744
- if (Q(e)) {
745
- const a = e.requireDocumentUrl(), r = this.documentsModifiedAt[a];
746
- r && (await q.remember(a, r), delete this.documentsModifiedAt[a]);
747
- }
869
+ if (e.getDocumentUrl() && this.documentsWithErrors.has(e.requireDocumentUrl()))
748
870
  return;
871
+ const i = e.isDirty();
872
+ if (await e.save(), (i || G(e)) && this.syncedModelUrls.add(e.url), G(e)) {
873
+ const r = e.requireDocumentUrl(), c = this.documentsModifiedAt[r];
874
+ c && (await W.getDocumentsCache().remember(
875
+ U(r),
876
+ r,
877
+ c
878
+ ), delete this.documentsModifiedAt[r]);
749
879
  }
750
- const i = R(e.static()).map((a) => e.getRelationModels(a) ?? []).flat(), l = t ? i.map(() => ({ completed: !1 })) : [];
751
- t && (t.children = l);
752
- for (let a = 0; a < i.length; a++) {
753
- const r = i[a], c = l[a];
754
- await this.saveModelAndChildren(r, c), c && await this.updateProgress(() => c.completed = !0);
880
+ const l = kt(j(e), e), a = t ? l.map(() => ({ completed: !1 })) : [];
881
+ t && (t.children = a);
882
+ for (let r = 0; r < l.length; r++) {
883
+ const c = l[r], d = a[r];
884
+ await this.saveModelAndRelated(c, d, s), d && await this.updateProgress(() => d.completed = !0);
755
885
  }
756
886
  }
757
887
  async synchronizeModels(e) {
758
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
888
+ const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
759
889
  for (const l of e.items()) {
760
- if (l instanceof N) {
890
+ if (l instanceof B) {
761
891
  const r = this.localModels.get(l.resourceUrl);
762
- r && (await r.forceDelete(), n.add(r));
892
+ r && (await r.forceDelete(), s.add(r));
763
893
  continue;
764
894
  }
765
- const a = Ht(l, this.localModels);
766
- a.exists() || this.syncedModelUrls.add(a.url), await this.loadChildren(a), await J.synchronize(a, l), await this.reconcileInconsistencies(a, l), await this.saveModelAndChildren(a), await this.addLocalModel(a), this.rootLocalModels.push(a), t.add(a.url);
895
+ const a = et(l, this.localModels);
896
+ a.exists() || this.syncedModelUrls.add(a.url), await this.loadChildren(a), await F.synchronize(a, l, {
897
+ constructors: Q(a)
898
+ }), await this.reconcileInconsistencies(a, l), await this.saveModelAndRelated(a), await this.addLocalModel(a), this.rootLocalModels.includes(a) || this.rootLocalModels.push(a), t.add(a.url);
767
899
  }
768
900
  for (const l of this.rootLocalModels) {
769
- if (n.has(l) || t.has(l.url))
901
+ if (s.has(l) || t.has(l.url))
770
902
  continue;
771
903
  await this.loadChildren(l);
772
- const a = Qt(l, e);
773
- await J.synchronize(l, a), e.add(a);
904
+ const a = sn(l, e);
905
+ await F.synchronize(l, a, {
906
+ constructors: Q(l)
907
+ }), e.add(a);
774
908
  }
775
909
  const i = [];
776
910
  for (const l of e.getItems()) {
777
- if (je(l)) {
911
+ if (Ye(l)) {
778
912
  i.push(l);
779
913
  continue;
780
914
  }
@@ -782,46 +916,54 @@ class cn extends _e(an, [Fe, He, Ke]) {
782
916
  }
783
917
  return i;
784
918
  }
785
- async reconcileInconsistencies(e, t, n) {
786
- e.rebuildAttributesFromHistory(), e.setAttributes(t.getAttributes(!0)), n ?? (n = /* @__PURE__ */ new Set()), n.add(e);
787
- for (const l of R(e.static()))
919
+ async reconcileInconsistencies(e, t, s) {
920
+ e.rebuildAttributesFromHistory(), e.setAttributes(t.getAttributes(!0)), s ?? (s = /* @__PURE__ */ new Set()), s.add(e);
921
+ for (const l of _(e.static()))
788
922
  await this.synchronizeContainerDocuments(
789
923
  e.requireRelation(l),
790
924
  t.requireRelation(l)
791
925
  );
792
- const i = L(ne(t), "url");
793
- for (const l of ne(e))
794
- n.has(l) || !l.isRelationLoaded("operations") || !i.hasKey(l.url) || await this.reconcileInconsistencies(
926
+ const i = E(j(t), "url");
927
+ for (const l of j(e))
928
+ s.has(l) || !l.isRelationLoaded("operations") || !i.hasKey(l.url) || await this.reconcileInconsistencies(
795
929
  l,
796
930
  i.require(l.url),
797
- n
931
+ s
798
932
  );
799
- e.isDirty() && await J.synchronize(e, t);
933
+ e.isDirty() && await F.synchronize(e, t, {
934
+ constructors: Q(e)
935
+ });
800
936
  }
801
937
  async synchronizeContainerDocuments(e, t) {
802
- const n = L(e.related ?? [], "url"), i = L(t.related ?? [], "url"), l = n.getKeys().filter((r) => !i.hasKey(r) && !i.hasKey(encodeURI(r))), a = i.getKeys().filter((r) => !n.hasKey(r) && !n.hasKey(encodeURI(r)));
938
+ const s = E(e.related ?? [], "url"), i = E(t.related ?? [], "url"), l = s.getKeys().filter((r) => !i.hasKey(r) && !i.hasKey(encodeURI(r))), a = i.getKeys().filter((r) => !s.hasKey(r) && !s.hasKey(encodeURI(r)));
803
939
  for (const r of l) {
804
- const c = n.require(r), h = Ce(c);
805
- t.addRelated(h), i.add(h);
940
+ const c = s.require(r), d = Ge(c);
941
+ t.addRelated(d), i.add(d);
806
942
  }
807
943
  for (const r of a) {
808
- const c = i.require(r), h = Ve(c);
809
- e.addRelated(h), n.add(h), this.syncedModelUrls.add(h.url);
944
+ const c = i.require(r), d = Xe(c);
945
+ e.addRelated(d), s.add(d), this.syncedModelUrls.add(d.url);
810
946
  }
811
- for (const r of n.items()) {
947
+ for (const r of s.items()) {
812
948
  const c = i.require(r.url);
813
- await J.synchronize(r, c), await this.saveModelAndChildren(r);
949
+ await F.synchronize(r, c, {
950
+ constructors: Q(r)
951
+ }), await this.saveModelAndRelated(r);
814
952
  }
815
953
  }
816
954
  async rememberModelDocuments(e) {
817
- if (!A(e)) {
818
- const n = e.requireDocumentUrl(), i = this.documentsModifiedAt[n];
819
- i && (await q.remember(n, i), delete this.documentsModifiedAt[n]);
955
+ if (this.syncedModelUrls.add(e.url), !T(e)) {
956
+ const s = e.requireDocumentUrl(), i = this.documentsModifiedAt[s];
957
+ i && (await W.getDocumentsCache().remember(
958
+ U(s),
959
+ s,
960
+ i
961
+ ), delete this.documentsModifiedAt[s]);
820
962
  return;
821
963
  }
822
- const t = R(e.static()).map((n) => e.getRelationModels(n) ?? []).flat();
823
- for (const n of t)
824
- await this.rememberModelDocuments(n);
964
+ const t = _(e.static()).map((s) => e.getRelationModels(s) ?? []).flat();
965
+ for (const s of t)
966
+ await this.rememberModelDocuments(s);
825
967
  }
826
968
  async ignoringDocumentErrors(e) {
827
969
  try {
@@ -831,32 +973,33 @@ class cn extends _e(an, [Fe, He, Ke]) {
831
973
  }
832
974
  }
833
975
  handleDocumentError(e) {
834
- if (O(e, Jt)) {
976
+ if (O(e, Kt)) {
835
977
  console.warn(e.message), e.documentUrl && this.documentsWithErrors.add(e.documentUrl);
836
978
  return;
837
979
  }
838
- if (O(e, Pt)) {
980
+ if (O(e, Ft)) {
839
981
  console.warn(e.message);
840
- const t = e.attributes[_t(e.modelName).primaryKey], n = t && qe(bt(t));
841
- n && this.documentsWithErrors.add(n);
982
+ const t = e.attributes[Vt(e.modelName).primaryKey], s = t && Je(Lt(t));
983
+ s && this.documentsWithErrors.add(s);
842
984
  return;
843
985
  }
844
986
  throw e;
845
987
  }
846
988
  }
847
- const w = {
989
+ const M = {
848
990
  Disconnected: "disconnected",
849
991
  Offline: "offline",
850
992
  Online: "online",
851
993
  Syncing: "syncing",
852
994
  Migrating: "migrating"
853
- }, dn = nt({
995
+ }, it = { manualSetup: !1 }, pn = dt({
854
996
  name: "cloud",
855
997
  persist: [
856
998
  "localModelUpdates",
857
999
  "migrationDismissed",
858
1000
  "migrationJob",
859
1001
  "modelCollections",
1002
+ "rootModelCollections",
860
1003
  "pollingEnabled",
861
1004
  "pollingMinutes",
862
1005
  "ready",
@@ -869,24 +1012,26 @@ const w = {
869
1012
  migrationJob: null,
870
1013
  migrationPostponed: !1,
871
1014
  modelCollections: {},
1015
+ rootModelCollections: {},
872
1016
  pollingEnabled: !0,
873
1017
  pollingMinutes: 10,
874
1018
  ready: !1,
1019
+ manualSetup: it.manualSetup,
875
1020
  registeredModels: [],
876
1021
  schemaMigrations: /* @__PURE__ */ new Map(),
877
1022
  setupDismissed: !1,
878
1023
  setupOngoing: !1,
879
1024
  startupSync: !0,
880
- status: w.Disconnected,
1025
+ status: M.Disconnected,
881
1026
  syncError: null,
882
1027
  syncJob: null
883
1028
  }),
884
1029
  serialize: (o) => {
885
- var s;
886
- return $e(o, { migrationJob: (s = o.migrationJob) == null ? void 0 : s.serialize() });
1030
+ var n;
1031
+ return Re(o, { migrationJob: (n = o.migrationJob) == null ? void 0 : n.serialize() });
887
1032
  },
888
- restore: (o) => $e(o, {
889
- migrationJob: o.migrationJob && ie.restore(o.migrationJob)
1033
+ restore: (o) => Re(o, {
1034
+ migrationJob: o.migrationJob && de.restore(o.migrationJob)
890
1035
  }),
891
1036
  watch: {
892
1037
  migrationJob(o) {
@@ -894,13 +1039,13 @@ const w = {
894
1039
  }
895
1040
  },
896
1041
  computed: {
897
- disconnected: ({ status: o }) => o === w.Disconnected,
898
- online: ({ status: o }) => o === w.Online,
899
- offline: ({ status: o }) => o === w.Offline,
900
- syncing: ({ status: o }) => o === w.Syncing,
901
- migrating: ({ status: o }) => o === w.Migrating,
1042
+ disconnected: ({ status: o }) => o === M.Disconnected,
1043
+ online: ({ status: o }) => o === M.Online,
1044
+ offline: ({ status: o }) => o === M.Offline,
1045
+ syncing: ({ status: o }) => o === M.Syncing,
1046
+ migrating: ({ status: o }) => o === M.Migrating,
902
1047
  localChanges({ localModelUpdates: o }) {
903
- return Object.values(o).reduce((s, e) => s + e, 0);
1048
+ return Object.values(o).reduce((n, e) => n + e, 0);
904
1049
  },
905
1050
  dirty() {
906
1051
  return this.localChanges > 0;
@@ -908,34 +1053,35 @@ const w = {
908
1053
  migrationStarted({ migrationJob: o }) {
909
1054
  return !!o;
910
1055
  },
911
- migrationDisabledReason({ status: o, ready: s }) {
912
- return $.isLoggedIn() ? s ? o === w.Syncing || o === w.Migrating ? C(
1056
+ migrationDisabledReason({ status: o, ready: n }) {
1057
+ return b.isLoggedIn() ? n ? o === M.Syncing || o === M.Migrating ? S(
913
1058
  "cloud.migrationNotSyncing",
914
1059
  "Wait for syncing to finish before starting the migration"
915
- ) : this.online ? null : C(
1060
+ ) : this.online ? null : S(
916
1061
  "cloud.migrationNotOnline",
917
1062
  "You need to be online in order to start the migration"
918
- ) : C(
1063
+ ) : S(
919
1064
  "cloud.migrationNotReady",
920
1065
  "You need to backup your data before starting the migration"
921
- ) : C(
1066
+ ) : S(
922
1067
  "cloud.migrationNotLoggedIn",
923
1068
  "You need to reconnect before starting the migration"
924
1069
  );
925
1070
  }
926
1071
  }
927
1072
  });
928
- class un extends dn {
1073
+ class yn extends pn {
929
1074
  constructor() {
930
1075
  super(...arguments);
931
- M(this, "asyncLock", new Ct());
932
- M(this, "engine", null);
933
- M(this, "pollingInterval", null);
1076
+ v(this, "asyncLock", new At());
1077
+ v(this, "engine", null);
1078
+ v(this, "pollingInterval", null);
1079
+ v(this, "documentsCache", null);
934
1080
  }
935
1081
  async whenReady(e) {
936
1082
  return this.ready ? e() : new Promise((t) => {
937
- const n = () => t(e());
938
- D.once("cloud:ready", n);
1083
+ const s = () => t(e());
1084
+ L.once("cloud:ready", s);
939
1085
  });
940
1086
  }
941
1087
  async setup(e) {
@@ -946,6 +1092,12 @@ class un extends dn {
946
1092
  this.setupOngoing = !1;
947
1093
  }
948
1094
  }
1095
+ getEngine() {
1096
+ return this.engine;
1097
+ }
1098
+ requireEngine() {
1099
+ return this.engine ?? Be("Could not get required Engine");
1100
+ }
949
1101
  dismissSetup() {
950
1102
  this.setupDismissed = !0;
951
1103
  }
@@ -959,32 +1111,32 @@ class un extends dn {
959
1111
  this.online && await this.sync(e);
960
1112
  }
961
1113
  async sync(e = {}) {
962
- const t = vt(e) ? { models: e } : e instanceof J ? { model: e } : e;
963
- !$.isLoggedIn() || !this.ready || !this.online || await this.asyncLock.run(async () => {
964
- let n = t.model ? [t.model] : t.models;
1114
+ const t = Ut(e) ? { models: e } : e instanceof F ? { model: e } : e;
1115
+ !b.isLoggedIn() || !this.ready || !this.online || await this.asyncLock.run(async () => {
1116
+ let s = t.model ? [t.model] : t.models;
965
1117
  const i = Date.now();
966
- this.syncError = null, this.status = w.Syncing, se.clear(n);
1118
+ this.syncError = null, this.status = M.Syncing, ce.clear(s);
967
1119
  try {
968
- await D.emit("cloud:sync-started", n), t.refreshUserProfile && await $.refreshUserProfile();
1120
+ await L.emit("cloud:sync-started", s), t.refreshUserProfile && await b.refreshUserProfile();
969
1121
  const l = t.syncDirty ?? !0;
970
1122
  let a = 0;
971
1123
  do {
972
- if (this.syncJob = new cn(n), this.syncJob.listeners.add(t), await ae(this.syncJob), this.syncJob.cancelled)
1124
+ if (this.syncJob = new gn(s), this.syncJob.listeners.add(t), await ue(this.syncJob), this.syncJob.cancelled)
973
1125
  return;
974
- a++, n = this.getDirtyLocalModels().filter(
1126
+ a++, s = this.getDirtyLocalModels().filter(
975
1127
  (r) => {
976
1128
  var c;
977
1129
  return !((c = this.syncJob) != null && c.documentsWithErrors.has(r.requireDocumentUrl()));
978
1130
  }
979
1131
  );
980
- } while (l && n.length > 0 && a < 3);
981
- Se("unit") || await G({ milliseconds: Math.max(500, 1e3 - (Date.now() - i)) }), this.syncJob = null;
1132
+ } while (l && s.length > 0 && a < 3);
1133
+ Le("unit") || await ae({ milliseconds: Math.max(500, 1e3 - (Date.now() - i)) }), this.syncJob = null;
982
1134
  } catch (l) {
983
- if (Se())
1135
+ if (Le())
984
1136
  throw l;
985
- this.syncJob = null, this.syncError = l, await Z.report(l, C("cloud.syncFailed", "Sync failed"));
1137
+ this.syncJob = null, this.syncError = l, await re.report(l, S("cloud.syncFailed", "Sync failed"));
986
1138
  } finally {
987
- this.status = w.Online, await D.emit("cloud:sync-completed", n);
1139
+ this.status = M.Online, await L.emit("cloud:sync-completed", s);
988
1140
  }
989
1141
  });
990
1142
  }
@@ -992,46 +1144,48 @@ class un extends dn {
992
1144
  return this.schemaMigrations.size > 0;
993
1145
  }
994
1146
  async migrate(e) {
995
- if (!this.online || !$.isLoggedIn() || !this.ready)
1147
+ if (!this.online || !b.isLoggedIn() || !this.ready)
996
1148
  throw new Error("Data cannot be migrated at the moment");
997
1149
  this.shouldMigrate() && await this.asyncLock.run(async () => {
998
1150
  var l;
999
- this.status = w.Migrating, this.migrationJob ?? (this.migrationJob = new ie());
1000
- const t = Date.now(), n = [], i = (l = this.migrationJob).models ?? (l.models = pe());
1001
- se.clear(i);
1151
+ this.status = M.Migrating, this.migrationJob ?? (this.migrationJob = new de());
1152
+ const t = Date.now(), s = [], i = (l = this.migrationJob).models ?? (l.models = be());
1153
+ ce.clear(i);
1002
1154
  try {
1003
- if (e && n.push(this.migrationJob.listeners.add(e)), await D.emit("cloud:migration-started", i), await ae(this.migrationJob), this.migrationJob.cancelled) {
1004
- await D.emit("cloud:migration-cancelled", i);
1155
+ if (e && s.push(this.migrationJob.listeners.add(e)), await L.emit("cloud:migration-started", i), await ue(this.migrationJob), this.migrationJob.cancelled) {
1156
+ await L.emit("cloud:migration-cancelled", i);
1005
1157
  return;
1006
1158
  }
1007
- this.migrationJob = null, this.migrationDismissed = !1, this.migrationPostponed = !1, await G({ milliseconds: Math.max(0, 1e3 - (Date.now() - t)) }), await D.emit("cloud:migration-completed", i);
1159
+ this.migrationJob = null, this.migrationDismissed = !1, this.migrationPostponed = !1, await ae({ milliseconds: Math.max(0, 1e3 - (Date.now() - t)) }), await L.emit("cloud:migration-completed", i);
1008
1160
  } catch (a) {
1009
- await Z.report(a, C("cloud.migrationFailed", "Migration failed"));
1161
+ await re.report(a, S("cloud.migrationFailed", "Migration failed"));
1010
1162
  } finally {
1011
- this.status = w.Online, n.forEach((a) => a == null ? void 0 : a());
1163
+ this.status = M.Online, s.forEach((a) => a == null ? void 0 : a());
1012
1164
  }
1013
1165
  });
1014
1166
  }
1015
1167
  async register(e, t = {}) {
1016
1168
  if (this.registeredModels.find((i) => e === i.modelClass))
1017
1169
  return;
1018
- const n = this.engine;
1019
- n && Le(e).forEach((i) => z(i).setEngine(n)), this.whenReady(() => {
1020
- const [i] = this.modelCollections[e.modelName] ?? [];
1021
- e.useSoftDeletes(!0), e.collection = i ?? ue(e, t.path);
1022
- }), await At(e, {
1023
- created: (i) => this.ready && Ue(i),
1024
- updated: (i) => this.ready && Ae(i),
1025
- deleted: (i) => this.ready && ge(/* @__PURE__ */ new Set([i.url ?? i.getDeletedPrimaryKey()]))
1026
- }), x(e) && R(e).forEach((i) => {
1170
+ const s = this.engine;
1171
+ s && ze(e).forEach((i) => P(i).setEngine(s)), this.whenReady(async () => {
1172
+ const i = this.rootModelCollections[e.modelName];
1173
+ e.useSoftDeletes(!0), await e.exclusive(
1174
+ async () => e.collection = i ?? ie(e, t.path)
1175
+ );
1176
+ }), await Jt(e, {
1177
+ created: (i) => this.ready && Pe(i),
1178
+ updated: (i) => this.ready && Oe(i),
1179
+ deleted: (i) => this.ready && Ce(/* @__PURE__ */ new Set([i.url ?? i.getDeletedPrimaryKey()]))
1180
+ }), V(e) && _(e).forEach((i) => {
1027
1181
  const l = e.instance().requireRelation(i).relatedClass;
1028
- l.on("created", (a) => this.ready && Ue(a)), l.on("updated", (a) => this.ready && Ae(a)), l.on(
1182
+ l.on("created", (a) => this.ready && Pe(a)), l.on("updated", (a) => this.ready && Oe(a)), l.on(
1029
1183
  "deleted",
1030
- (a) => this.ready && ge(/* @__PURE__ */ new Set([a.url ?? a.getDeletedPrimaryKey()]))
1184
+ (a) => this.ready && Ce(/* @__PURE__ */ new Set([a.url ?? a.getDeletedPrimaryKey()]))
1031
1185
  );
1032
1186
  }), this.registeredModels.push({ modelClass: e, path: t.path });
1033
1187
  for (const i of this.modelCollections[e.modelName] ?? [])
1034
- await te(e, i);
1188
+ await Z(e, i);
1035
1189
  }
1036
1190
  registerSchemaMigration(e, t) {
1037
1191
  this.schemaMigrations.set(e, t);
@@ -1039,11 +1193,14 @@ class un extends dn {
1039
1193
  requireRemoteCollection(e) {
1040
1194
  for (const t of this.registeredModels)
1041
1195
  if (e === t.modelClass)
1042
- return ue(t.modelClass, t.path);
1196
+ return ie(t.modelClass, t.path);
1043
1197
  throw new Error(`Failed resolving remote collection for '${e.modelName}' model`);
1044
1198
  }
1199
+ getDocumentsCache() {
1200
+ return this.documentsCache || (this.documentsCache = new Wt(ut(), Se())), this.documentsCache;
1201
+ }
1045
1202
  async boot() {
1046
- await $.booted, $.isLoggedIn() && this.login($.authenticator), D.on("auth:login", ({ authenticator: e }) => this.login(e)), D.on("auth:logout", () => this.logout()), D.once("application-ready", () => this.onApplicationReady()), D.once("application-mounted", () => this.onApplicationMounted()), It(() => {
1203
+ await b.booted, b.isLoggedIn() && this.login(b.authenticator), L.on("auth:login", ({ authenticator: e }) => this.login(e)), L.on("auth:logout", () => this.logout()), L.on("purge-storage", () => this.getDocumentsCache().clear()), L.once("application-ready", () => this.onApplicationReady()), L.once("application-mounted", () => this.onApplicationMounted()), xt(() => {
1047
1204
  if (this.pollingInterval && clearInterval(this.pollingInterval), !this.pollingEnabled || this.migrationJob) {
1048
1205
  this.pollingInterval = null;
1049
1206
  return;
@@ -1053,49 +1210,48 @@ class un extends dn {
1053
1210
  }
1054
1211
  getDirtyLocalModels() {
1055
1212
  const e = Object.keys(this.localModelUpdates), t = [];
1056
- for (const { modelClass: n } of this.registeredModels)
1057
- for (const i of Me(n, { includeSoftDeleted: !0 }))
1213
+ for (const { modelClass: s } of this.registeredModels)
1214
+ for (const i of De(s, { includeSoftDeleted: !0 }))
1058
1215
  t.push(...this.getModelsIn(e, i));
1059
1216
  return t;
1060
1217
  }
1061
1218
  getModelsIn(e, t) {
1062
- const n = [];
1063
- return e.includes(t.url) && n.push(t), A(t) && n.push(
1064
- ...We(t).map((i) => this.getModelsIn(e, i)).flat()
1065
- ), n;
1066
- }
1067
- requireEngine() {
1068
- return this.engine ?? Pe("Could not get required Engine");
1219
+ const s = [];
1220
+ return e.includes(t.url) && s.push(t), T(t) && s.push(
1221
+ ...Ke(t).map((i) => this.getModelsIn(e, i)).flat()
1222
+ ), s;
1069
1223
  }
1070
1224
  async setReady(e) {
1071
- this.ready || !e || (await D.emit("cloud:ready"), this.ready = !0);
1225
+ this.ready || !e || (await L.emit("cloud:ready"), this.ready = !0);
1072
1226
  }
1073
1227
  async backup(e) {
1074
- await D.emit("cloud:backup-started"), e ?? (e = /* @__PURE__ */ new WeakMap());
1075
- const t = new nn();
1076
- for (const { modelClass: n, path: i } of this.registeredModels) {
1077
- if (!x(n))
1078
- continue;
1079
- for (const [r, c] of Object.entries(e.get(n) ?? {}))
1080
- t.migrateUrl(n, r, c);
1081
- const l = n.collection, a = ue(n, i);
1082
- n.collection = a, t.migrateCollection(n, l, a);
1228
+ await L.emit("cloud:backup-started"), e ?? (e = /* @__PURE__ */ new WeakMap());
1229
+ const t = new dn();
1230
+ for (const { modelClass: s, path: i } of this.registeredModels) {
1231
+ for (const [r, c] of Object.entries(e.get(s) ?? {}))
1232
+ t.migrateUrl(s, r, c);
1233
+ const l = s.instance().getDefaultCollection(), a = ie(s, i);
1234
+ await s.exclusive(async () => s.collection = a), t.migrateCollection(s, l, a);
1083
1235
  }
1084
- await ae(t), await D.emit("cloud:backup-completed");
1236
+ await ue(t), await L.emit("cloud:backup-completed");
1085
1237
  }
1086
1238
  async onApplicationReady() {
1087
- this.ready || !$.isLoggedIn() || await this.setReady(!pe().some((e) => e.url.startsWith("solid://")));
1239
+ this.ready || !b.isLoggedIn() || await this.setReady(!be().some((e) => e.url.startsWith("solid://")));
1088
1240
  }
1089
1241
  async onApplicationMounted() {
1242
+ if (b.isLoggedIn() && !this.ready && !this.manualSetup) {
1243
+ await this.setup();
1244
+ return;
1245
+ }
1090
1246
  this.syncOnStartup() && await this.sync();
1091
1247
  }
1092
1248
  login(e) {
1093
- const t = [...this.registeredModels].map(({ modelClass: n }) => Le(n)).flat().concat([N]);
1094
- this.status = w.Online, this.engine = e.engine, z(W).setEngine(this.engine);
1095
- for (const n of t)
1096
- z(n).setEngine(this.engine);
1249
+ const t = [...this.registeredModels].map(({ modelClass: s }) => ze(s)).flat().concat([B]);
1250
+ this.status = M.Online, this.engine = e.engine, P(ee).setEngine(this.engine);
1251
+ for (const s of t)
1252
+ P(s).setEngine(this.engine);
1097
1253
  }
1098
- logout() {
1254
+ async logout() {
1099
1255
  this.setState({
1100
1256
  autoPush: !0,
1101
1257
  localModelUpdates: {},
@@ -1103,6 +1259,7 @@ class un extends dn {
1103
1259
  migrationJob: null,
1104
1260
  migrationPostponed: !1,
1105
1261
  modelCollections: {},
1262
+ rootModelCollections: {},
1106
1263
  pollingEnabled: !0,
1107
1264
  pollingMinutes: 10,
1108
1265
  ready: !1,
@@ -1110,59 +1267,59 @@ class un extends dn {
1110
1267
  setupDismissed: !1,
1111
1268
  setupOngoing: !1,
1112
1269
  startupSync: !0,
1113
- status: w.Disconnected,
1270
+ status: M.Disconnected,
1114
1271
  syncError: null,
1115
1272
  syncJob: null
1116
- });
1273
+ }), await this.getDocumentsCache().clear();
1117
1274
  }
1118
1275
  watchNetworkStatus() {
1119
1276
  globalThis.addEventListener("online", () => {
1120
- this.status === w.Offline && (this.status = w.Online);
1277
+ this.status === M.Offline && (this.status = M.Online);
1121
1278
  }), globalThis.addEventListener("offline", () => {
1122
- this.status === w.Online && (this.status = w.Offline);
1279
+ this.status === M.Online && (this.status = M.Offline);
1123
1280
  });
1124
1281
  }
1125
1282
  syncOnStartup() {
1126
- return De("startupSync") ? ke(Re("startupSync")) : this.migrationJob ? !1 : this.startupSync;
1283
+ return Ae("startupSync") ? Ue(Ee("startupSync")) : this.migrationJob ? !1 : this.startupSync;
1127
1284
  }
1128
1285
  async bustDocumentsCache() {
1129
- !De("bustDocumentsCache") || !ke(Re("bustDocumentsCache")) || (await q.booted, await q.clear());
1286
+ !Ae("bustDocumentsCache") || !Ue(Ee("bustDocumentsCache")) || await this.getDocumentsCache().clear();
1130
1287
  }
1131
1288
  async registerModels() {
1132
- const e = xt();
1289
+ const e = Ht();
1133
1290
  for (const t of e.values())
1134
- !Lt(t) || !t.cloud || await this.register(t, typeof t.cloud == "boolean" ? {} : t.cloud);
1291
+ !Nt(t) || !t.cloud || await this.register(t, typeof t.cloud == "boolean" ? {} : t.cloud);
1135
1292
  }
1136
1293
  }
1137
- const U = we(un), hn = {
1294
+ const I = Ne(yn), wn = {
1138
1295
  viewBox: "0 0 20 20",
1139
1296
  width: "1.2em",
1140
1297
  height: "1.2em"
1141
1298
  };
1142
- function fn(o, s) {
1143
- return f(), b("svg", hn, s[0] || (s[0] = [
1144
- m("path", {
1299
+ function Mn(o, n) {
1300
+ return p(), D("svg", wn, n[0] || (n[0] = [
1301
+ y("path", {
1145
1302
  fill: "currentColor",
1146
1303
  d: "m6 2l2-2h4l2 2h4v2H2V2zM3 6h14l-1 14H4zm5 2v10h1V8zm3 0v10h1V8z"
1147
1304
  }, null, -1)
1148
1305
  ]));
1149
1306
  }
1150
- const mn = P({ name: "zondicons-trash", render: fn }), Ye = /* @__PURE__ */ j({
1307
+ const Cn = J({ name: "zondicons-trash", render: Mn }), rt = /* @__PURE__ */ H({
1151
1308
  __name: "AccountLoginModal",
1152
1309
  setup(o) {
1153
- return (s, e) => (f(), k(d(Ee), {
1154
- title: s.$td("cloud.logIn.title", "Connect account")
1310
+ return (n, e) => (p(), A(u(_e), {
1311
+ title: n.$td("cloud.logIn.title", "Connect account")
1155
1312
  }, {
1156
- default: v(() => [
1157
- u(d(E), {
1313
+ default: $(() => [
1314
+ f(u(q), {
1158
1315
  "lang-key": "cloud.logIn.info",
1159
1316
  "lang-default": "Log in to your [Solid account](https://solidproject.org) to keep data safe across devices."
1160
1317
  }),
1161
- u(d(he), {
1318
+ f(u(pe), {
1162
1319
  class: "text-sm",
1163
- onClick: e[0] || (e[0] = (t) => s.$ui.alert(
1164
- s.$td("cloud.logIn.learnMore", "What is Solid?"),
1165
- s.$td(
1320
+ onClick: e[0] || (e[0] = (t) => n.$ui.alert(
1321
+ n.$td("cloud.logIn.learnMore", "What is Solid?"),
1322
+ n.$td(
1166
1323
  "cloud.logIn.learnMoreMessage",
1167
1324
  `Solid is a decentralized storage protocol built on top of web standards. If you want to use this app across devices, you can use Solid to keep changes in sync. Even if you use it in a single device, this will also keep your data secure in case your device is lost.
1168
1325
 
@@ -1172,12 +1329,12 @@ In any case, Focus works 100% offline and you can connect your Solid POD later o
1172
1329
  )
1173
1330
  ))
1174
1331
  }, {
1175
- default: v(() => [
1176
- K(S(s.$td("cloud.logIn.learnMore", "What is Solid?")), 1)
1332
+ default: $(() => [
1333
+ se(k(n.$td("cloud.logIn.learnMore", "What is Solid?")), 1)
1177
1334
  ]),
1178
1335
  _: 1
1179
1336
  }),
1180
- u(d($t), {
1337
+ f(u(Et), {
1181
1338
  "no-loading": "",
1182
1339
  class: "mt-4"
1183
1340
  })
@@ -1185,331 +1342,327 @@ In any case, Focus works 100% offline and you can connect your Solid POD later o
1185
1342
  _: 1
1186
1343
  }, 8, ["title"]));
1187
1344
  }
1188
- }), gn = {
1345
+ }), bn = {
1189
1346
  key: 0,
1190
1347
  class: "mt-4"
1191
- }, pn = { class: "text-base font-semibold" }, yn = { class: "ml-1" }, wn = /* @__PURE__ */ j({
1348
+ }, vn = { class: "text-base font-semibold" }, Dn = { class: "ml-1" }, Sn = /* @__PURE__ */ H({
1192
1349
  __name: "PurgeData",
1193
1350
  setup(o) {
1194
- async function s() {
1195
- await le.confirm(
1196
- C("settings.purgeConfirmTitle", "Delete everything?"),
1197
- C(
1351
+ async function n() {
1352
+ await he.confirm(
1353
+ S("settings.purgeConfirmTitle", "Delete everything?"),
1354
+ S(
1198
1355
  "settings.purgeConfirmMessage",
1199
1356
  "If you proceed, all your data will be deleted forever. If you want to save it before wiping this device, you can [connect to your Solid account](#action:connect) first."
1200
1357
  ),
1201
1358
  {
1202
1359
  acceptVariant: "danger",
1203
- acceptText: C("settings.purgeConfirmAccept", "Purge data"),
1204
- actions: { connect: () => le.modal(Ye) }
1360
+ acceptText: S("settings.purgeConfirmAccept", "Purge data"),
1361
+ actions: { connect: () => he.modal(rt) }
1205
1362
  }
1206
- ) && (await le.closeAllModals(), await st.purge());
1363
+ ) && (await he.closeAllModals(), await ht.purge());
1207
1364
  }
1208
- return (e, t) => e.$solid.hasLoggedIn() ? _("", !0) : (f(), b("details", gn, [
1209
- m("summary", null, [
1210
- m("span", pn, S(e.$td("settings.dangerZone", "Danger zone")), 1)
1365
+ return (e, t) => e.$solid.hasLoggedIn() ? x("", !0) : (p(), D("details", bn, [
1366
+ y("summary", null, [
1367
+ y("span", vn, k(e.$td("settings.dangerZone", "Danger zone")), 1)
1211
1368
  ]),
1212
- u(d(T), {
1369
+ f(u(N), {
1213
1370
  variant: "danger",
1214
1371
  class: "mt-4",
1215
- onClick: t[0] || (t[0] = (n) => s())
1372
+ onClick: t[0] || (t[0] = (s) => n())
1216
1373
  }, {
1217
- default: v(() => [
1218
- u(d(mn), { class: "size-4" }),
1219
- m("span", yn, S(e.$td("settings.purge", "Purge data")), 1)
1374
+ default: $(() => [
1375
+ f(u(Cn), { class: "size-4" }),
1376
+ y("span", Dn, k(e.$td("settings.purge", "Purge data")), 1)
1220
1377
  ]),
1221
1378
  _: 1
1222
1379
  })
1223
1380
  ]));
1224
1381
  }
1225
- }), Mn = ot([
1382
+ }), $n = ft([
1226
1383
  {
1227
1384
  priority: 0,
1228
- component: wn
1385
+ component: Sn
1229
1386
  }
1230
- ]), bn = {
1387
+ ]), Rn = {
1231
1388
  viewBox: "0 0 20 20",
1232
1389
  width: "1.2em",
1233
1390
  height: "1.2em"
1234
1391
  };
1235
- function Cn(o, s) {
1236
- return f(), b("svg", bn, s[0] || (s[0] = [
1237
- m("path", {
1392
+ function kn(o, n) {
1393
+ return p(), D("svg", Rn, n[0] || (n[0] = [
1394
+ y("path", {
1238
1395
  fill: "currentColor",
1239
1396
  d: "M2.93 17.07A10 10 0 1 1 17.07 2.93A10 10 0 0 1 2.93 17.07m12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32M6.7 9.29L9 11.6l4.3-4.3l1.4 1.42L9 14.4l-3.7-3.7l1.4-1.42z"
1240
1397
  }, null, -1)
1241
1398
  ]));
1242
1399
  }
1243
- const vn = P({ name: "zondicons-checkmark-outline", render: Cn }), $n = {
1400
+ const Ln = J({ name: "zondicons-checkmark-outline", render: kn }), An = {
1244
1401
  viewBox: "0 0 24 24",
1245
1402
  width: "1.2em",
1246
1403
  height: "1.2em"
1247
1404
  };
1248
- function Sn(o, s) {
1249
- return f(), b("svg", $n, s[0] || (s[0] = [
1250
- m("path", {
1405
+ function Un(o, n) {
1406
+ return p(), D("svg", An, n[0] || (n[0] = [
1407
+ y("path", {
1251
1408
  fill: "currentColor",
1252
1409
  d: "M19.35 10.04A7.49 7.49 0 0 0 12 4C9.11 4 6.6 5.64 5.35 8.04A5.994 5.994 0 0 0 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.65-4.96M14 13v4h-4v-4H7l5-5l5 5z"
1253
1410
  }, null, -1)
1254
1411
  ]));
1255
1412
  }
1256
- const Dn = P({ name: "ic-sharp-cloud-upload", render: Sn }), kn = {
1413
+ const En = J({ name: "ic-sharp-cloud-upload", render: Un }), In = {
1257
1414
  viewBox: "0 0 20 20",
1258
1415
  width: "1.2em",
1259
1416
  height: "1.2em"
1260
1417
  };
1261
- function Rn(o, s) {
1262
- return f(), b("svg", kn, s[0] || (s[0] = [
1263
- m("path", {
1418
+ function zn(o, n) {
1419
+ return p(), D("svg", In, n[0] || (n[0] = [
1420
+ y("path", {
1264
1421
  fill: "currentColor",
1265
1422
  d: "M3.94 6.5L2.22 3.64l1.42-1.42L6.5 3.94c.52-.3 1.1-.54 1.7-.7L9 0h2l.8 3.24c.6.16 1.18.4 1.7.7l2.86-1.72l1.42 1.42l-1.72 2.86c.3.52.54 1.1.7 1.7L20 9v2l-3.24.8c-.16.6-.4 1.18-.7 1.7l1.72 2.86l-1.42 1.42l-2.86-1.72c-.52.3-1.1.54-1.7.7L11 20H9l-.8-3.24c-.6-.16-1.18-.4-1.7-.7l-2.86 1.72l-1.42-1.42l1.72-2.86c-.3-.52-.54-1.1-.7-1.7L0 11V9l3.24-.8c.16-.6.4-1.18.7-1.7M10 13a3 3 0 1 0 0-6a3 3 0 0 0 0 6"
1266
1423
  }, null, -1)
1267
1424
  ]));
1268
1425
  }
1269
- const Qe = P({ name: "zondicons-cog", render: Rn }), Ln = {
1426
+ const at = J({ name: "zondicons-cog", render: zn }), Pn = {
1270
1427
  viewBox: "0 0 24 24",
1271
1428
  width: "1.2em",
1272
1429
  height: "1.2em"
1273
1430
  };
1274
- function Un(o, s) {
1275
- return f(), b("svg", Ln, s[0] || (s[0] = [
1276
- m("path", {
1431
+ function On(o, n) {
1432
+ return p(), D("svg", Pn, n[0] || (n[0] = [
1433
+ y("path", {
1277
1434
  fill: "currentColor",
1278
1435
  d: "M5 21q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h6q.425 0 .713.288T12 4t-.288.713T11 5H5v14h6q.425 0 .713.288T12 20t-.288.713T11 21zm12.175-8H10q-.425 0-.712-.288T9 12t.288-.712T10 11h7.175L15.3 9.125q-.275-.275-.275-.675t.275-.7t.7-.313t.725.288L20.3 11.3q.3.3.3.7t-.3.7l-3.575 3.575q-.3.3-.712.288t-.713-.313q-.275-.3-.262-.712t.287-.688z"
1279
1436
  }, null, -1)
1280
1437
  ]));
1281
1438
  }
1282
- const An = P({ name: "material-symbols-logout-rounded", render: Un }), In = {
1439
+ const qn = J({ name: "material-symbols-logout-rounded", render: On }), Tn = {
1283
1440
  viewBox: "0 0 20 20",
1284
1441
  width: "1.2em",
1285
1442
  height: "1.2em"
1286
1443
  };
1287
- function zn(o, s) {
1288
- return f(), b("svg", In, s[0] || (s[0] = [
1289
- m("path", {
1444
+ function _n(o, n) {
1445
+ return p(), D("svg", Tn, n[0] || (n[0] = [
1446
+ y("path", {
1290
1447
  fill: "currentColor",
1291
1448
  d: "M10 3v2a5 5 0 0 0-3.54 8.54l-1.41 1.41A7 7 0 0 1 10 3m4.95 2.05A7 7 0 0 1 10 17v-2a5 5 0 0 0 3.54-8.54zM10 20l-4-4l4-4zm0-12V0l4 4z"
1292
1449
  }, null, -1)
1293
1450
  ]));
1294
1451
  }
1295
- const F = P({ name: "zondicons-refresh", render: zn }), En = {
1452
+ const te = J({ name: "zondicons-refresh", render: _n }), Wn = {
1296
1453
  viewBox: "0 0 24 24",
1297
1454
  width: "1.2em",
1298
1455
  height: "1.2em"
1299
1456
  };
1300
- function On(o, s) {
1301
- return f(), b("svg", En, s[0] || (s[0] = [
1302
- m("path", {
1457
+ function Nn(o, n) {
1458
+ return p(), D("svg", Wn, n[0] || (n[0] = [
1459
+ y("path", {
1303
1460
  fill: "currentColor",
1304
1461
  d: "M6 6h12v12H6z"
1305
1462
  }, null, -1)
1306
1463
  ]));
1307
1464
  }
1308
- const Tn = P({ name: "ic-baseline-stop", render: On }), qn = {
1465
+ const Jn = J({ name: "ic-baseline-stop", render: Nn }), xn = {
1309
1466
  viewBox: "0 0 512 512",
1310
1467
  width: "1.2em",
1311
1468
  height: "1.2em"
1312
1469
  };
1313
- function Pn(o, s) {
1314
- return f(), b("svg", qn, s[0] || (s[0] = [
1315
- m("path", {
1470
+ function Bn(o, n) {
1471
+ return p(), D("svg", xn, n[0] || (n[0] = [
1472
+ y("path", {
1316
1473
  fill: "currentColor",
1317
1474
  d: "M449.07 399.08L278.64 82.58c-12.08-22.44-44.26-22.44-56.35 0L51.87 399.08A32 32 0 0 0 80 446.25h340.89a32 32 0 0 0 28.18-47.17m-198.6-1.83a20 20 0 1 1 20-20a20 20 0 0 1-20 20m21.72-201.15l-5.74 122a16 16 0 0 1-32 0l-5.74-121.95a21.73 21.73 0 0 1 21.5-22.69h.21a21.74 21.74 0 0 1 21.73 22.7Z"
1318
1475
  }, null, -1)
1319
1476
  ]));
1320
1477
  }
1321
- const H = P({ name: "ion-warning", render: Pn }), _n = { class: "relative flex items-center rounded-md bg-gray-100 p-4 pr-12" }, xn = { class: "flex flex-col overflow-hidden" }, Jn = { class: "font-semibold" }, Nn = { class: "px-2" }, Wn = {
1478
+ const ne = J({ name: "ion-warning", render: Bn }), jn = { class: "relative flex items-center rounded-md bg-gray-100 p-4 pr-12" }, Fn = { class: "flex flex-col overflow-hidden" }, Vn = { class: "font-semibold" }, Hn = { class: "px-2" }, Kn = {
1322
1479
  key: 0,
1323
1480
  class: "mt-4 flex items-center gap-2"
1324
- }, jn = { class: "flex w-full flex-col" }, Bn = {
1481
+ }, Yn = { class: "flex w-full flex-col" }, Qn = {
1325
1482
  key: 1,
1326
1483
  class: "mt-4 flex items-center gap-2"
1327
- }, Vn = {
1484
+ }, Zn = {
1328
1485
  key: 2,
1329
1486
  class: "mt-4 flex items-center gap-2"
1330
- }, Fn = {
1487
+ }, Gn = {
1331
1488
  key: 3,
1332
1489
  class: "mt-4 flex items-center gap-2"
1333
- }, Hn = {
1490
+ }, Xn = {
1334
1491
  key: 4,
1335
1492
  class: "mt-4 flex items-center gap-2"
1336
- }, Kn = {
1493
+ }, es = {
1337
1494
  key: 5,
1338
1495
  class: "mt-4 flex items-center gap-2"
1339
- }, Yn = {
1496
+ }, ts = {
1340
1497
  key: 6,
1341
1498
  class: "mt-4 flex items-center gap-2"
1342
- }, Qn = { class: "flex flex-col gap-2" }, Zn = { class: "flex items-center" }, Gn = { "aria-hidden": "true" }, Xn = {
1499
+ }, ns = { class: "flex flex-col gap-2" }, ss = { class: "flex items-center" }, os = { "aria-hidden": "true" }, is = {
1343
1500
  key: 0,
1344
1501
  "aria-hidden": "true"
1345
- }, es = {
1502
+ }, rs = {
1346
1503
  key: 0,
1347
1504
  class: "mt-4 flex flex-row-reverse justify-start gap-2"
1348
- }, ts = /* @__PURE__ */ j({
1505
+ }, as = /* @__PURE__ */ H({
1349
1506
  __name: "AccountModal",
1350
1507
  setup(o) {
1351
- const s = zt("$modalRef"), e = Et(!1), t = C("cloud.advanced.polling", "Synchronize every {minutes} minutes", {
1508
+ const { close: n } = mt(), e = Bt(!1), t = S("cloud.advanced.polling", "Synchronize every {minutes} minutes", {
1352
1509
  minutes: "%%separator%%"
1353
- }).split("%%separator%%"), n = Y(() => $.error ?? U.syncError), i = Y(() => {
1354
- if (n.value)
1355
- return typeof n.value == "string" ? n.value : C("cloud.info.error", "There has been an error connecting.");
1356
- }), l = Y(() => n.value && typeof n.value != "string");
1510
+ }).split("%%separator%%"), s = oe(() => b.error ?? I.syncError), i = oe(() => {
1511
+ if (s.value)
1512
+ return typeof s.value == "string" ? s.value : S("cloud.info.error", "There has been an error connecting.");
1513
+ }), l = oe(() => s.value && typeof s.value != "string");
1357
1514
  async function a() {
1358
- U.syncJob && (e.value = !0, await Promise.race([U.syncJob.cancel(), U.syncJob.completed]), e.value = !1);
1515
+ I.syncJob && (e.value = !0, await Promise.race([I.syncJob.cancel(), I.syncJob.completed]), e.value = !1);
1359
1516
  }
1360
- return it("auth:logout", () => {
1361
- var r;
1362
- return (r = s.value) == null ? void 0 : r.close();
1363
- }), (r, c) => (f(), k(d(Ee), {
1364
- ref: "$modalRef",
1517
+ return gt("auth:logout", n), (r, c) => (p(), A(u(_e), {
1365
1518
  "title-hidden": "",
1366
1519
  "close-hidden": "",
1367
1520
  title: r.$td("account.title", "Account")
1368
1521
  }, {
1369
- default: v(() => {
1370
- var h, p;
1522
+ default: $(() => {
1523
+ var d, m;
1371
1524
  return [
1372
- m("div", _n, [
1373
- u(d(xe), { class: "mr-2 size-16 shrink-0" }),
1374
- m("div", xn, [
1375
- m("span", Jn, S(((h = r.$solid.user) == null ? void 0 : h.name) ?? r.$td("user.anonymous", "Anonymous")), 1),
1376
- u(d(he), {
1377
- href: (p = r.$solid.user) == null ? void 0 : p.webId,
1525
+ y("div", jn, [
1526
+ f(u(Fe), { class: "mr-2 size-16 shrink-0" }),
1527
+ y("div", Fn, [
1528
+ y("span", Vn, k(((d = r.$solid.user) == null ? void 0 : d.name) ?? r.$td("user.anonymous", "Anonymous")), 1),
1529
+ f(u(pe), {
1530
+ href: (m = r.$solid.user) == null ? void 0 : m.webId,
1378
1531
  class: "mt-0.5 truncate text-sm font-light text-gray-500"
1379
1532
  }, {
1380
- default: v(() => {
1381
- var y;
1533
+ default: $(() => {
1534
+ var g;
1382
1535
  return [
1383
- K(S((y = r.$solid.user) == null ? void 0 : y.webId), 1)
1536
+ se(k((g = r.$solid.user) == null ? void 0 : g.webId), 1)
1384
1537
  ];
1385
1538
  }),
1386
1539
  _: 1
1387
1540
  }, 8, ["href"])
1388
1541
  ]),
1389
- u(d(T), {
1542
+ f(u(N), {
1390
1543
  size: "icon",
1391
1544
  variant: "ghost",
1392
1545
  class: "absolute top-1 right-1 hover:bg-gray-200",
1393
1546
  "aria-label": r.$td("user.settings", "Settings"),
1394
1547
  title: r.$td("user.settings", "Settings"),
1395
- onClick: c[0] || (c[0] = (y) => r.$ui.modal(d(Oe)))
1548
+ onClick: c[0] || (c[0] = (g) => r.$ui.modal(u(We)))
1396
1549
  }, {
1397
- default: v(() => [
1398
- u(d(Qe), { class: "size-5" })
1550
+ default: $(() => [
1551
+ f(u(at), { class: "size-5" })
1399
1552
  ]),
1400
1553
  _: 1
1401
1554
  }, 8, ["aria-label", "title"])
1402
1555
  ]),
1403
- m("div", Nn, [
1404
- r.$cloud.syncing ? (f(), b("div", Wn, [
1405
- u(d(F), { class: "mt-0.5 size-6 shrink-0 animate-spin self-start text-green-500" }),
1406
- m("div", jn, [
1407
- u(d(E), {
1556
+ y("div", Hn, [
1557
+ r.$cloud.syncing ? (p(), D("div", Kn, [
1558
+ f(u(te), { class: "mt-0.5 size-6 shrink-0 animate-spin self-start text-green-500" }),
1559
+ y("div", Yn, [
1560
+ f(u(q), {
1408
1561
  "lang-key": "cloud.info.syncing",
1409
1562
  "lang-default": "Synchronizing..."
1410
1563
  }),
1411
- r.$cloud.syncJob ? (f(), k(d(rt), {
1564
+ r.$cloud.syncJob ? (p(), A(u(pt), {
1412
1565
  key: 0,
1413
1566
  job: r.$cloud.syncJob,
1414
1567
  "filled-class": "bg-green-500"
1415
- }, null, 8, ["job"])) : _("", !0)
1568
+ }, null, 8, ["job"])) : x("", !0)
1416
1569
  ])
1417
- ])) : r.$solid.loginOngoing ? (f(), b("div", Bn, [
1418
- u(d(F), { class: "mt-0.5 size-6 shrink-0 animate-spin self-start text-green-500" }),
1419
- u(d(E), {
1570
+ ])) : r.$solid.loginOngoing ? (p(), D("div", Qn, [
1571
+ f(u(te), { class: "mt-0.5 size-6 shrink-0 animate-spin self-start text-green-500" }),
1572
+ f(u(q), {
1420
1573
  "lang-key": "cloud.info.reconnecting",
1421
1574
  "lang-default": "Reconnecting..."
1422
1575
  })
1423
- ])) : n.value ? (f(), b("div", Vn, [
1424
- u(d(H), { class: "mt-0.5 size-6 shrink-0 self-start text-red-500" }),
1425
- m("div", null, [
1426
- u(d(E), { text: i.value }, null, 8, ["text"]),
1427
- l.value ? (f(), k(d(he), {
1576
+ ])) : s.value ? (p(), D("div", Zn, [
1577
+ f(u(ne), { class: "mt-0.5 size-6 shrink-0 self-start text-red-500" }),
1578
+ y("div", null, [
1579
+ f(u(q), { text: i.value }, null, 8, ["text"]),
1580
+ l.value ? (p(), A(u(pe), {
1428
1581
  key: 0,
1429
1582
  class: "text-sm text-red-700 opacity-50 hover:opacity-75 focus-visible:opacity-75",
1430
- onClick: c[1] || (c[1] = (y) => r.$errors.inspect(n.value))
1583
+ onClick: c[1] || (c[1] = (g) => r.$errors.inspect(s.value))
1431
1584
  }, {
1432
- default: v(() => [
1433
- K(S(r.$td("errors.viewDetails", "View details")), 1)
1585
+ default: $(() => [
1586
+ se(k(r.$td("errors.viewDetails", "View details")), 1)
1434
1587
  ]),
1435
1588
  _: 1
1436
- })) : _("", !0)
1589
+ })) : x("", !0)
1437
1590
  ])
1438
- ])) : r.$cloud.ready ? r.$cloud.dirty ? (f(), b("div", Hn, [
1439
- u(d(H), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
1440
- u(d(E), {
1591
+ ])) : r.$cloud.ready ? r.$cloud.dirty ? (p(), D("div", Xn, [
1592
+ f(u(ne), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
1593
+ f(u(q), {
1441
1594
  "lang-key": "cloud.info.changes",
1442
1595
  "lang-default": "Everything is up to date. | There is one local change. | There are {n} local changes.",
1443
1596
  "lang-params": r.$cloud.localChanges
1444
1597
  }, null, 8, ["lang-params"])
1445
- ])) : r.$cloud.online || r.$cloud.offline ? (f(), b("div", Kn, [
1446
- u(d(vn), {
1447
- class: Ne(["mt-0.5 size-6 shrink-0 self-start", { "text-green-500": r.$cloud.online, "text-gray-700": r.$cloud.offline }])
1598
+ ])) : r.$cloud.online || r.$cloud.offline ? (p(), D("div", es, [
1599
+ f(u(Ln), {
1600
+ class: Ve(["mt-0.5 size-6 shrink-0 self-start", { "text-green-500": r.$cloud.online, "text-gray-700": r.$cloud.offline }])
1448
1601
  }, null, 8, ["class"]),
1449
- r.$cloud.online ? (f(), k(d(E), {
1602
+ r.$cloud.online ? (p(), A(u(q), {
1450
1603
  key: 0,
1451
1604
  "lang-key": "cloud.info.changes",
1452
1605
  "lang-default": "Everything is up to date.",
1453
1606
  "lang-params": 0
1454
- })) : (f(), k(d(E), {
1607
+ })) : (p(), A(u(q), {
1455
1608
  key: 1,
1456
1609
  "lang-key": "cloud.info.offline",
1457
1610
  "lang-default": "Everything is up to date, but you're currently offline."
1458
1611
  }))
1459
- ])) : (f(), b("div", Yn, [
1460
- u(d(H), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
1461
- u(d(E), {
1612
+ ])) : (p(), D("div", ts, [
1613
+ f(u(ne), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
1614
+ f(u(q), {
1462
1615
  "lang-key": "cloud.info.disconnected",
1463
1616
  "lang-default": "You are disconnected from your Solid account, all the changes you make will remain in your device."
1464
1617
  })
1465
- ])) : (f(), b("div", Fn, [
1466
- u(d(H), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
1467
- u(d(E), {
1618
+ ])) : (p(), D("div", Gn, [
1619
+ f(u(ne), { class: "mt-0.5 size-6 shrink-0 self-start text-yellow-500" }),
1620
+ f(u(q), {
1468
1621
  "lang-key": "cloud.info.setup",
1469
1622
  "lang-default": "Your data is not backed up yet."
1470
1623
  })
1471
1624
  ])),
1472
- u(d(at), { class: "mt-2" }, {
1473
- default: v(() => [
1474
- m("ul", Qn, [
1475
- m("li", null, [
1476
- u(d(ce), {
1625
+ f(u(yt), { class: "mt-2" }, {
1626
+ default: $(() => [
1627
+ y("ul", ns, [
1628
+ y("li", null, [
1629
+ f(u(fe), {
1477
1630
  modelValue: r.$solid.autoReconnect,
1478
- "onUpdate:modelValue": c[2] || (c[2] = (y) => r.$solid.autoReconnect = y),
1631
+ "onUpdate:modelValue": c[2] || (c[2] = (g) => r.$solid.autoReconnect = g),
1479
1632
  "label-class": "text-base",
1480
1633
  label: r.$td("cloud.advanced.reconnect", "Reconnect on startup")
1481
1634
  }, null, 8, ["modelValue", "label"])
1482
1635
  ]),
1483
- m("li", null, [
1484
- u(d(ce), {
1636
+ y("li", null, [
1637
+ f(u(fe), {
1485
1638
  modelValue: r.$cloud.startupSync,
1486
- "onUpdate:modelValue": c[3] || (c[3] = (y) => r.$cloud.startupSync = y),
1639
+ "onUpdate:modelValue": c[3] || (c[3] = (g) => r.$cloud.startupSync = g),
1487
1640
  "label-class": "text-base",
1488
1641
  label: r.$td("cloud.advanced.startupSync", "Synchronize on startup")
1489
1642
  }, null, 8, ["modelValue", "label"])
1490
1643
  ]),
1491
- m("li", null, [
1492
- u(d(ce), {
1644
+ y("li", null, [
1645
+ f(u(fe), {
1493
1646
  modelValue: r.$cloud.pollingEnabled,
1494
- "onUpdate:modelValue": c[5] || (c[5] = (y) => r.$cloud.pollingEnabled = y),
1647
+ "onUpdate:modelValue": c[5] || (c[5] = (g) => r.$cloud.pollingEnabled = g),
1495
1648
  "label-class": "text-base"
1496
1649
  }, {
1497
- default: v(() => [
1498
- m("div", Zn, [
1499
- m("span", Gn, S(d(t)[0]), 1),
1500
- u(d(lt), {
1650
+ default: $(() => [
1651
+ y("div", ss, [
1652
+ y("span", os, k(u(t)[0]), 1),
1653
+ f(u(wt), {
1501
1654
  type: "number",
1502
1655
  text: `${r.$cloud.pollingMinutes}`,
1503
1656
  "aria-label": r.$td("cloud.advanced.pollingMinutes", "Synchronization interval (in minutes)"),
1504
1657
  class: "focus-within:border-primary-600 mx-1 -mb-px border-b",
1505
- onUpdate: c[4] || (c[4] = (y) => r.$cloud.pollingMinutes = y)
1658
+ onUpdate: c[4] || (c[4] = (g) => r.$cloud.pollingMinutes = g)
1506
1659
  }, {
1507
- default: v(() => [
1508
- K(S(r.$cloud.pollingMinutes), 1)
1660
+ default: $(() => [
1661
+ se(k(r.$cloud.pollingMinutes), 1)
1509
1662
  ]),
1510
1663
  _: 1
1511
1664
  }, 8, ["text", "aria-label"]),
1512
- d(t).length > 1 ? (f(), b("span", Xn, S(d(t)[1]), 1)) : _("", !0)
1665
+ u(t).length > 1 ? (p(), D("span", is, k(u(t)[1]), 1)) : x("", !0)
1513
1666
  ])
1514
1667
  ]),
1515
1668
  _: 1
@@ -1520,58 +1673,55 @@ const H = P({ name: "ion-warning", render: Pn }), _n = { class: "relative flex i
1520
1673
  _: 1
1521
1674
  })
1522
1675
  ]),
1523
- r.$solid.loginOngoing ? _("", !0) : (f(), b("div", es, [
1524
- r.$cloud.syncing ? (f(), k(d(T), {
1676
+ r.$solid.loginOngoing ? x("", !0) : (p(), D("div", rs, [
1677
+ r.$cloud.syncing ? (p(), A(u(N), {
1525
1678
  key: 0,
1526
1679
  variant: "secondary",
1527
1680
  disabled: e.value,
1528
- onClick: c[6] || (c[6] = (y) => a())
1681
+ onClick: c[6] || (c[6] = (g) => a())
1529
1682
  }, {
1530
- default: v(() => [
1531
- u(d(Tn), { class: "size-5" }),
1532
- m("span", null, S(e.value ? r.$td("cloud.stopping", "Stopping...") : r.$td("cloud.stop", "Stop synchronization")), 1)
1683
+ default: $(() => [
1684
+ f(u(Jn), { class: "size-5" }),
1685
+ y("span", null, k(e.value ? r.$td("cloud.stopping", "Stopping...") : r.$td("cloud.stop", "Stop synchronization")), 1)
1533
1686
  ]),
1534
1687
  _: 1
1535
- }, 8, ["disabled"])) : r.$solid.isLoggedIn() ? r.$cloud.ready ? (f(), k(d(T), {
1688
+ }, 8, ["disabled"])) : r.$solid.isLoggedIn() ? r.$cloud.ready ? (p(), A(u(N), {
1536
1689
  key: 2,
1537
1690
  disabled: r.$cloud.offline,
1538
- onClick: c[8] || (c[8] = (y) => r.$cloud.sync({ refreshUserProfile: !0 }))
1691
+ onClick: c[8] || (c[8] = (g) => r.$cloud.sync({ refreshUserProfile: !0 }))
1539
1692
  }, {
1540
- default: v(() => [
1541
- u(d(F), { class: "size-5" }),
1542
- m("span", null, S(r.$td("cloud.sync", "Synchronize")), 1)
1693
+ default: $(() => [
1694
+ f(u(te), { class: "size-5" }),
1695
+ y("span", null, k(r.$td("cloud.sync", "Synchronize")), 1)
1543
1696
  ]),
1544
1697
  _: 1
1545
- }, 8, ["disabled"])) : (f(), k(d(T), {
1698
+ }, 8, ["disabled"])) : (p(), A(u(N), {
1546
1699
  key: 3,
1547
- onClick: c[9] || (c[9] = (y) => {
1548
- var V;
1549
- return r.$cloud.setupDismissed = !1, (V = s.value) == null ? void 0 : V.close();
1550
- })
1700
+ onClick: c[9] || (c[9] = (g) => (r.$cloud.setupDismissed = !1, u(n)(), r.$cloud.manualSetup || r.$cloud.setup()))
1551
1701
  }, {
1552
- default: v(() => [
1553
- u(d(Dn), { class: "size-5" }),
1554
- m("span", null, S(r.$td("cloud.setup.submit", "Back up now")), 1)
1702
+ default: $(() => [
1703
+ f(u(En), { class: "size-5" }),
1704
+ y("span", null, k(r.$td("cloud.setup.submit", "Back up now")), 1)
1555
1705
  ]),
1556
1706
  _: 1
1557
- })) : (f(), k(d(T), {
1707
+ })) : (p(), A(u(N), {
1558
1708
  key: 1,
1559
- onClick: c[7] || (c[7] = (y) => r.$solid.reconnect({ force: !0 }))
1709
+ onClick: c[7] || (c[7] = (g) => r.$solid.reconnect({ force: !0 }))
1560
1710
  }, {
1561
- default: v(() => [
1562
- u(d(F), { class: "size-5" }),
1563
- m("span", null, S(r.$td("cloud.reconnect", "Reconnect")), 1)
1711
+ default: $(() => [
1712
+ f(u(te), { class: "size-5" }),
1713
+ y("span", null, k(r.$td("cloud.reconnect", "Reconnect")), 1)
1564
1714
  ]),
1565
1715
  _: 1
1566
1716
  })),
1567
- r.$cloud.syncing ? _("", !0) : (f(), k(d(T), {
1717
+ r.$cloud.syncing ? x("", !0) : (p(), A(u(N), {
1568
1718
  key: 4,
1569
1719
  variant: "secondary",
1570
- onClick: c[10] || (c[10] = (y) => r.$solid.logout())
1720
+ onClick: c[10] || (c[10] = (g) => r.$solid.logout())
1571
1721
  }, {
1572
- default: v(() => [
1573
- u(d(An), { class: "size-5" }),
1574
- m("span", null, S(r.$cloud.ready ? r.$td("cloud.logOut", "Log out") : r.$td("cloud.disconnect", "Disconnect")), 1)
1722
+ default: $(() => [
1723
+ f(u(qn), { class: "size-5" }),
1724
+ y("span", null, k(r.$cloud.ready ? r.$td("cloud.logOut", "Log out") : r.$td("cloud.disconnect", "Disconnect")), 1)
1575
1725
  ]),
1576
1726
  _: 1
1577
1727
  }))
@@ -1581,80 +1731,80 @@ const H = P({ name: "ion-warning", render: Pn }), _n = { class: "relative flex i
1581
1731
  _: 1
1582
1732
  }, 8, ["title"]));
1583
1733
  }
1584
- }), ns = { class: "relative size-12" }, ss = ["aria-label", "title"], os = {
1734
+ }), ls = { class: "relative size-12" }, cs = ["aria-label", "title"], ds = {
1585
1735
  key: 0,
1586
1736
  class: "absolute -inset-1 animate-spin rounded-full border-2 border-[currentColor_transparent] text-green-500"
1587
- }, is = { class: "sr-only" }, rs = /* @__PURE__ */ j({
1737
+ }, us = { class: "sr-only" }, hs = /* @__PURE__ */ H({
1588
1738
  __name: "AccountLoggedIn",
1589
1739
  setup(o) {
1590
- const s = Y(() => U.syncing || $.loginOngoing ? {
1740
+ const n = oe(() => I.syncing || b.loginOngoing ? {
1591
1741
  loading: !0,
1592
1742
  classes: "bg-green-500 sr-only",
1593
1743
  message: e() ?? ""
1594
- } : $.error || U.syncError ? {
1744
+ } : b.error || I.syncError ? {
1595
1745
  classes: "bg-red-500",
1596
- message: C("account.error", "There has been an error connecting with your account.")
1597
- } : !$.isLoggedIn() || U.dirty || !U.ready ? {
1746
+ message: S("account.error", "There has been an error connecting with your account.")
1747
+ } : !b.isLoggedIn() || I.dirty || !I.ready ? {
1598
1748
  classes: "bg-yellow-500",
1599
- message: C(
1749
+ message: S(
1600
1750
  "account.dirty",
1601
1751
  "There are local changes that haven't been synchronized yet."
1602
1752
  )
1603
1753
  } : {
1604
- classes: U.status === w.Online ? "bg-green-500" : "bg-gray-500",
1754
+ classes: I.status === M.Online ? "bg-green-500" : "bg-gray-500",
1605
1755
  message: e() ?? ""
1606
1756
  });
1607
1757
  function e() {
1608
- switch (U.status) {
1609
- case w.Syncing:
1610
- return C("cloud.status.syncing", "Synchronization in progress");
1611
- case w.Migrating:
1612
- return C("cloud.status.migrating", "Migration in progress");
1613
- case w.Online:
1614
- return C("cloud.status.online", "Online");
1615
- case w.Offline:
1616
- return C("cloud.status.offline", "Offline");
1617
- case w.Disconnected:
1618
- return C("cloud.status.disconnected", "Disconnected");
1758
+ switch (I.status) {
1759
+ case M.Syncing:
1760
+ return S("cloud.status.syncing", "Synchronization in progress");
1761
+ case M.Migrating:
1762
+ return S("cloud.status.migrating", "Migration in progress");
1763
+ case M.Online:
1764
+ return S("cloud.status.online", "Online");
1765
+ case M.Offline:
1766
+ return S("cloud.status.offline", "Offline");
1767
+ case M.Disconnected:
1768
+ return S("cloud.status.disconnected", "Disconnected");
1619
1769
  }
1620
1770
  }
1621
- return (t, n) => (f(), b("div", ns, [
1622
- m("button", {
1771
+ return (t, s) => (p(), D("div", ls, [
1772
+ y("button", {
1623
1773
  class: "clickable focus-visible:outline-primary-600 flex size-full rounded-full focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2",
1624
1774
  type: "button",
1625
1775
  "aria-label": t.$td("account.open", "Open account"),
1626
1776
  title: t.$td("account.open", "Open account"),
1627
- onClick: n[0] || (n[0] = (i) => t.$ui.modal(ts))
1777
+ onClick: s[0] || (s[0] = (i) => t.$ui.modal(as))
1628
1778
  }, [
1629
- u(d(xe), { class: "size-full" }),
1630
- s.value.loading ? (f(), b("div", os)) : _("", !0)
1631
- ], 8, ss),
1632
- m("div", {
1633
- class: Ne(["pointer-events-none absolute right-0 bottom-0 size-3 rounded-full border-2 border-white", s.value.classes])
1779
+ f(u(Fe), { class: "size-full" }),
1780
+ n.value.loading ? (p(), D("div", ds)) : x("", !0)
1781
+ ], 8, cs),
1782
+ y("div", {
1783
+ class: Ve(["pointer-events-none absolute right-0 bottom-0 size-3 rounded-full border-2 border-white", n.value.classes])
1634
1784
  }, [
1635
- m("span", is, S(s.value.message), 1)
1785
+ y("span", us, k(n.value.message), 1)
1636
1786
  ], 2)
1637
1787
  ]));
1638
1788
  }
1639
- }), as = /* @__PURE__ */ j({
1789
+ }), fs = /* @__PURE__ */ H({
1640
1790
  __name: "AccountLoggedOut",
1641
1791
  setup(o) {
1642
- return (s, e) => (f(), k(d(ct), {
1792
+ return (n, e) => (p(), A(u(Mt), {
1643
1793
  align: "start",
1644
1794
  options: [
1645
- { label: s.$td("user.logIn", "Connect account"), click: () => s.$ui.modal(Ye) },
1646
- { label: s.$td("user.settings", "Settings"), click: () => s.$ui.modal(d(Oe)) }
1795
+ { label: n.$td("user.logIn", "Connect account"), click: () => n.$ui.modal(rt) },
1796
+ { label: n.$td("user.settings", "Settings"), click: () => n.$ui.modal(u(We)) }
1647
1797
  ]
1648
1798
  }, {
1649
- default: v(() => [
1650
- u(d(T), {
1799
+ default: $(() => [
1800
+ f(u(N), {
1651
1801
  size: "icon",
1652
1802
  variant: "ghost",
1653
- "aria-label": s.$td("user.menu", "Configuration"),
1654
- title: s.$td("user.menu", "Configuration")
1803
+ "aria-label": n.$td("user.menu", "Configuration"),
1804
+ title: n.$td("user.menu", "Configuration")
1655
1805
  }, {
1656
- default: v(() => [
1657
- u(d(Qe), { class: "size-5" })
1806
+ default: $(() => [
1807
+ f(u(at), { class: "size-5" })
1658
1808
  ]),
1659
1809
  _: 1
1660
1810
  }, 8, ["aria-label", "title"])
@@ -1662,31 +1812,28 @@ const H = P({ name: "ion-warning", render: Pn }), _n = { class: "relative flex i
1662
1812
  _: 1
1663
1813
  }, 8, ["options"]));
1664
1814
  }
1665
- }), Ms = /* @__PURE__ */ j({
1815
+ }), $s = /* @__PURE__ */ H({
1666
1816
  __name: "Account",
1667
1817
  setup(o) {
1668
- return (s, e) => s.$solid.hasLoggedIn() ? (f(), k(rs, { key: 0 })) : (f(), k(as, { key: 1 }));
1818
+ return (n, e) => n.$solid.hasLoggedIn() ? (p(), A(hs, { key: 0 })) : (p(), A(fs, { key: 1 }));
1669
1819
  }
1670
- }), ls = { $cloud: U };
1671
- function bs() {
1820
+ }), ms = { $cloud: I };
1821
+ function Rs(o = {}) {
1672
1822
  return {
1673
1823
  name: "@aerogel/local-first",
1674
- async install(o) {
1675
- Mn.forEach((s) => oe.addSetting(s)), await dt(o, {
1676
- ...ls,
1677
- $_documentsCache: q
1678
- });
1824
+ async install(n) {
1825
+ $n.forEach((e) => X.addSetting(e)), typeof o.manualSetup == "boolean" && (it.manualSetup = o.manualSetup, I.manualSetup = o.manualSetup), await Ct(n, ms);
1679
1826
  }
1680
1827
  };
1681
1828
  }
1682
1829
  export {
1683
- Ms as Account,
1684
- rs as AccountLoggedIn,
1685
- as as AccountLoggedOut,
1686
- Ye as AccountLoginModal,
1687
- ts as AccountModal,
1688
- U as Cloud,
1689
- un as CloudService,
1690
- bs as default
1830
+ $s as Account,
1831
+ hs as AccountLoggedIn,
1832
+ fs as AccountLoggedOut,
1833
+ rt as AccountLoginModal,
1834
+ as as AccountModal,
1835
+ I as Cloud,
1836
+ yn as CloudService,
1837
+ Rs as default
1691
1838
  };
1692
1839
  //# sourceMappingURL=aerogel-plugin-local-first.js.map