@aerogel/plugin-local-first 0.1.0 → 0.1.1-next.26f3c2c807213724de7500a899a6712abae430ad

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