@annotorious/core 3.8.2 → 3.8.4

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,5 +1,5 @@
1
1
  var G = Object.prototype.hasOwnProperty;
2
- function $(e, t) {
2
+ function Y(e, t) {
3
3
  var n, o;
4
4
  if (e === t) return !0;
5
5
  if (e && t && (n = e.constructor) === t.constructor) {
@@ -7,21 +7,21 @@ function $(e, t) {
7
7
  if (n === RegExp) return e.toString() === t.toString();
8
8
  if (n === Array) {
9
9
  if ((o = e.length) === t.length)
10
- for (; o-- && $(e[o], t[o]); ) ;
10
+ for (; o-- && Y(e[o], t[o]); ) ;
11
11
  return o === -1;
12
12
  }
13
13
  if (!n || typeof e == "object") {
14
14
  o = 0;
15
15
  for (n in e)
16
- if (G.call(e, n) && ++o && !G.call(t, n) || !(n in t) || !$(e[n], t[n])) return !1;
16
+ if (G.call(e, n) && ++o && !G.call(t, n) || !(n in t) || !Y(e[n], t[n])) return !1;
17
17
  return Object.keys(t).length === o;
18
18
  }
19
19
  }
20
20
  return e !== e && t !== t;
21
21
  }
22
22
  const X = Symbol("clean");
23
- let N = [], _ = 0;
24
- const z = 4, Z = globalThis.nanostoresGlobal || (globalThis.nanostoresGlobal = { epoch: 0 }), M = /* @__NO_SIDE_EFFECTS__ */ (e) => {
23
+ let x = [], k = 0;
24
+ const P = 4, Z = globalThis.nanostoresGlobal || (globalThis.nanostoresGlobal = { epoch: 0 }), M = /* @__NO_SIDE_EFFECTS__ */ (e) => {
25
25
  let t = [], n = {
26
26
  get() {
27
27
  return n.lc || n.listen(() => {
@@ -31,25 +31,25 @@ const z = 4, Z = globalThis.nanostoresGlobal || (globalThis.nanostoresGlobal = {
31
31
  lc: 0,
32
32
  listen(o) {
33
33
  return n.lc = t.push(o), () => {
34
- for (let f = _ + z; f < N.length; )
35
- N[f] === o ? N.splice(f, z) : f += z;
34
+ for (let f = k + P; f < x.length; )
35
+ x[f] === o ? x.splice(f, P) : f += P;
36
36
  let s = t.indexOf(o);
37
37
  ~s && (t.splice(s, 1), --n.lc || n.off());
38
38
  };
39
39
  },
40
40
  notify(o, s) {
41
41
  Z.epoch++;
42
- let f = !N.length;
42
+ let f = !x.length;
43
43
  for (let A of t)
44
- N.push(A, n.value, o, s);
44
+ x.push(A, n.value, o, s);
45
45
  if (f) {
46
- for (_ = 0; _ < N.length; _ += z)
47
- N[_](
48
- N[_ + 1],
49
- N[_ + 2],
50
- N[_ + 3]
46
+ for (k = 0; k < x.length; k += P)
47
+ x[k](
48
+ x[k + 1],
49
+ x[k + 2],
50
+ x[k + 3]
51
51
  );
52
- N.length = 0;
52
+ x.length = 0;
53
53
  }
54
54
  },
55
55
  /* It will be called on last listener unsubscribing.
@@ -87,20 +87,20 @@ const z = 4, Z = globalThis.nanostoresGlobal || (globalThis.nanostoresGlobal = {
87
87
  };
88
88
  };
89
89
  var F = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(F || {});
90
- const P = { selected: [] }, Be = (e, t, n) => {
91
- const o = /* @__PURE__ */ M(P);
90
+ const z = { selected: [] }, Re = (e, t, n) => {
91
+ const o = /* @__PURE__ */ M(z);
92
92
  let s = t;
93
93
  const f = () => {
94
- $(o.get(), P) || o.set(P);
94
+ Y(o.get(), z) || o.set(z);
95
95
  }, A = () => {
96
96
  var g;
97
97
  return ((g = o.get().selected) == null ? void 0 : g.length) === 0;
98
- }, w = (g) => {
98
+ }, C = (g) => {
99
99
  if (A())
100
100
  return !1;
101
- const b = typeof g == "string" ? g : g.id;
102
- return o.get().selected.some((L) => L.id === b);
103
- }, C = (g, b) => {
101
+ const E = typeof g == "string" ? g : g.id;
102
+ return o.get().selected.some((L) => L.id === E);
103
+ }, w = (g, E) => {
104
104
  let L;
105
105
  if (Array.isArray(g)) {
106
106
  if (L = g.map((i) => e.getAnnotation(i)).filter(Boolean), L.length < g.length) {
@@ -115,29 +115,29 @@ const P = { selected: [] }, Be = (e, t, n) => {
115
115
  }
116
116
  L = [i];
117
117
  }
118
- const B = L.reduce((i, u) => {
119
- const h = v(u);
118
+ const R = L.reduce((i, u) => {
119
+ const h = b(u);
120
120
  return h === "EDIT" ? [...i, { id: u.id, editable: !0 }] : h === "SELECT" ? [...i, { id: u.id }] : i;
121
121
  }, []);
122
- o.set({ selected: B, event: b });
123
- }, m = (g, b) => {
124
- const L = Array.isArray(g) ? g : [g], B = L.map((i) => e.getAnnotation(i)).filter((i) => !!i);
122
+ o.set({ selected: R, event: E });
123
+ }, m = (g, E) => {
124
+ const L = Array.isArray(g) ? g : [g], R = L.map((i) => e.getAnnotation(i)).filter((i) => !!i);
125
125
  o.set({
126
- selected: B.map((i) => {
127
- const u = b === void 0 ? v(i) === "EDIT" : b;
126
+ selected: R.map((i) => {
127
+ const u = E === void 0 ? b(i) === "EDIT" : E;
128
128
  return { id: i.id, editable: u };
129
129
  })
130
- }), B.length !== L.length && console.warn("Invalid selection", g);
130
+ }), R.length !== L.length && console.warn("Invalid selection", g);
131
131
  }, T = (g) => {
132
132
  if (A())
133
133
  return !1;
134
- const { selected: b } = o.get();
135
- b.some(({ id: B }) => g.includes(B)) && o.set({ selected: b.filter(({ id: B }) => !g.includes(B)) });
134
+ const { selected: E } = o.get();
135
+ E.some(({ id: R }) => g.includes(R)) && o.set({ selected: E.filter(({ id: R }) => !g.includes(R)) });
136
136
  }, l = (g) => {
137
- s = g, m(o.get().selected.map(({ id: b }) => b));
138
- }, v = (g) => K(g, s, n);
137
+ s = g, m(o.get().selected.map(({ id: E }) => E));
138
+ }, b = (g) => K(g, s, n);
139
139
  return e.observe(
140
- ({ changes: g }) => T((g.deleted || []).map((b) => b.id))
140
+ ({ changes: g }) => T((g.deleted || []).map((E) => E.id))
141
141
  ), {
142
142
  get event() {
143
143
  const g = o.get();
@@ -151,22 +151,22 @@ const P = { selected: [] }, Be = (e, t, n) => {
151
151
  return s;
152
152
  },
153
153
  clear: f,
154
- evalSelectAction: v,
154
+ evalSelectAction: b,
155
155
  isEmpty: A,
156
- isSelected: w,
156
+ isSelected: C,
157
157
  setSelected: m,
158
158
  setUserSelectAction: l,
159
159
  subscribe: o.subscribe.bind(o),
160
- userSelect: C
160
+ userSelect: w
161
161
  };
162
162
  }, K = (e, t, n) => {
163
163
  const o = n ? n.serialize(e) : e;
164
164
  return typeof t == "function" ? t(o) : t || "EDIT";
165
- }, R = [];
165
+ }, D = [];
166
166
  for (let e = 0; e < 256; ++e)
167
- R.push((e + 256).toString(16).slice(1));
167
+ D.push((e + 256).toString(16).slice(1));
168
168
  function ee(e, t = 0) {
169
- return (R[e[t + 0]] + R[e[t + 1]] + R[e[t + 2]] + R[e[t + 3]] + "-" + R[e[t + 4]] + R[e[t + 5]] + "-" + R[e[t + 6]] + R[e[t + 7]] + "-" + R[e[t + 8]] + R[e[t + 9]] + "-" + R[e[t + 10]] + R[e[t + 11]] + R[e[t + 12]] + R[e[t + 13]] + R[e[t + 14]] + R[e[t + 15]]).toLowerCase();
169
+ return (D[e[t + 0]] + D[e[t + 1]] + D[e[t + 2]] + D[e[t + 3]] + "-" + D[e[t + 4]] + D[e[t + 5]] + "-" + D[e[t + 6]] + D[e[t + 7]] + "-" + D[e[t + 8]] + D[e[t + 9]] + "-" + D[e[t + 10]] + D[e[t + 11]] + D[e[t + 12]] + D[e[t + 13]] + D[e[t + 14]] + D[e[t + 15]]).toLowerCase();
170
170
  }
171
171
  const te = new Uint8Array(16);
172
172
  function ne() {
@@ -183,7 +183,7 @@ function oe(e, t, n) {
183
183
  throw new Error("Random bytes length must be >= 16");
184
184
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, ee(o);
185
185
  }
186
- const De = (e) => {
186
+ const Be = (e) => {
187
187
  const { creator: t, updatedBy: n } = e.target, o = e.bodies.reduce((s, f) => [...s, f.creator, f.updatedBy].filter(Boolean), []);
188
188
  return [
189
189
  t,
@@ -200,7 +200,7 @@ const De = (e) => {
200
200
  bodies: (e.bodies || []).map(t),
201
201
  target: t(e.target)
202
202
  };
203
- }, Re = (e, t, n, o) => ({
203
+ }, De = (e, t, n, o) => ({
204
204
  id: H(),
205
205
  annotation: typeof e == "string" ? e : e.id,
206
206
  created: n || /* @__PURE__ */ new Date(),
@@ -214,8 +214,8 @@ const De = (e) => {
214
214
  return e.bodies.filter((o) => !n.has(o.id));
215
215
  }, de = (e, t) => t.bodies.map((n) => {
216
216
  const o = e.bodies.find((s) => s.id === n.id);
217
- return { newBody: n, oldBody: o && !$(o, n) ? o : void 0 };
218
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), re = (e, t) => !$(e.target, t.target), W = (e, t) => {
217
+ return { newBody: n, oldBody: o && !Y(o, n) ? o : void 0 };
218
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), re = (e, t) => !Y(e.target, t.target), W = (e, t) => {
219
219
  const n = se(e, t), o = ie(e, t), s = de(e, t);
220
220
  return {
221
221
  oldValue: e,
@@ -233,42 +233,42 @@ const ce = (e, t) => {
233
233
  if (!(e.options.origin ? e.options.origin === o : o !== "SILENT"))
234
234
  return !1;
235
235
  if (e.options.ignore) {
236
- const { ignore: w } = e.options, C = (T) => T && T.length > 0;
237
- if (!(C(n.created) || C(n.deleted))) {
238
- const T = (f = n.updated) == null ? void 0 : f.some((v) => C(v.bodiesCreated) || C(v.bodiesDeleted) || C(v.bodiesUpdated)), l = (A = n.updated) == null ? void 0 : A.some((v) => v.targetUpdated);
239
- if (w === "BODY_ONLY" && T && !l || w === "TARGET_ONLY" && l && !T)
236
+ const { ignore: C } = e.options, w = (T) => T && T.length > 0;
237
+ if (!(w(n.created) || w(n.deleted))) {
238
+ const T = (f = n.updated) == null ? void 0 : f.some((b) => w(b.bodiesCreated) || w(b.bodiesDeleted) || w(b.bodiesUpdated)), l = (A = n.updated) == null ? void 0 : A.some((b) => b.targetUpdated);
239
+ if (C === "BODY_ONLY" && T && !l || C === "TARGET_ONLY" && l && !T)
240
240
  return !1;
241
241
  }
242
242
  }
243
243
  if (e.options.annotations) {
244
- const w = /* @__PURE__ */ new Set([
244
+ const C = /* @__PURE__ */ new Set([
245
245
  ...(n.created || []).map((m) => m.id),
246
246
  ...(n.deleted || []).map((m) => m.id),
247
247
  ...(n.updated || []).map(({ oldValue: m }) => m.id)
248
248
  ]);
249
- return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((m) => w.has(m));
249
+ return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((m) => C.has(m));
250
250
  } else
251
251
  return !0;
252
252
  }, le = (e, t) => {
253
- const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), s = new Set((t.created || []).map((l) => l.id)), f = new Set((t.deleted || []).map((l) => l.id)), A = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), w = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), C = [
254
- ...(e.created || []).filter((l) => !f.has(l.id)).map((l) => A.has(l.id) ? t.updated.find(({ oldValue: v }) => v.id === l.id).newValue : l),
253
+ const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), s = new Set((t.created || []).map((l) => l.id)), f = new Set((t.deleted || []).map((l) => l.id)), A = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), C = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), w = [
254
+ ...(e.created || []).filter((l) => !f.has(l.id)).map((l) => A.has(l.id) ? t.updated.find(({ oldValue: b }) => b.id === l.id).newValue : l),
255
255
  ...t.created || []
256
256
  ], m = [
257
257
  ...(e.deleted || []).filter((l) => !s.has(l.id)),
258
258
  ...(t.deleted || []).filter((l) => !n.has(l.id))
259
259
  ], T = [
260
260
  ...(e.updated || []).filter(({ newValue: l }) => !f.has(l.id)).map((l) => {
261
- const { oldValue: v, newValue: g } = l;
261
+ const { oldValue: b, newValue: g } = l;
262
262
  if (A.has(g.id)) {
263
- const b = t.updated.find((L) => L.oldValue.id === g.id).newValue;
264
- return W(v, b);
263
+ const E = t.updated.find((L) => L.oldValue.id === g.id).newValue;
264
+ return W(b, E);
265
265
  } else
266
266
  return l;
267
267
  }),
268
- ...(t.updated || []).filter(({ oldValue: l }) => !w.has(l.id))
268
+ ...(t.updated || []).filter(({ oldValue: l }) => !C.has(l.id))
269
269
  ];
270
- return { created: C, deleted: m, updated: T };
271
- }, Y = (e) => {
270
+ return { created: w, deleted: m, updated: T };
271
+ }, $ = (e) => {
272
272
  const t = e.id === void 0 ? H() : e.id;
273
273
  return {
274
274
  ...e,
@@ -282,7 +282,7 @@ const ce = (e, t) => {
282
282
  annotation: t
283
283
  }
284
284
  };
285
- }, ue = (e) => e.id !== void 0, xe = () => {
285
+ }, ue = (e) => e.id !== void 0, Ne = () => {
286
286
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (d, r = {}) => {
287
287
  n.push({ onChange: d, options: r });
288
288
  }, s = (d) => {
@@ -305,33 +305,33 @@ const ce = (e, t) => {
305
305
  if (d.id && e.get(d.id))
306
306
  throw Error(`Cannot add annotation ${d.id} - exists already`);
307
307
  {
308
- const p = Y(d);
309
- e.set(p.id, p), p.bodies.forEach((U) => t.set(U.id, p.id)), f(r, { created: [p] });
308
+ const p = $(d);
309
+ e.set(p.id, p), p.bodies.forEach((S) => t.set(S.id, p.id)), f(r, { created: [p] });
310
310
  }
311
- }, w = (d, r) => {
312
- const c = Y(typeof d == "string" ? r : d), p = typeof d == "string" ? d : d.id, U = p && e.get(p);
313
- if (U) {
314
- const y = W(U, c);
315
- return p === c.id ? e.set(p, c) : (e.delete(p), e.set(c.id, c)), U.bodies.forEach((D) => t.delete(D.id)), c.bodies.forEach((D) => t.set(D.id, c.id)), y;
311
+ }, C = (d, r) => {
312
+ const c = $(typeof d == "string" ? r : d), p = typeof d == "string" ? d : d.id, S = p && e.get(p);
313
+ if (S) {
314
+ const U = W(S, c);
315
+ return p === c.id ? e.set(p, c) : (e.delete(p), e.set(c.id, c)), S.bodies.forEach((B) => t.delete(B.id)), c.bodies.forEach((B) => t.set(B.id, c.id)), U;
316
316
  } else
317
317
  console.warn(`Cannot update annotation ${p} - does not exist`);
318
- }, C = (d, r = O.LOCAL, c = O.LOCAL) => {
319
- const p = ue(r) ? c : r, U = w(d, r);
320
- U && f(p, { updated: [U] });
318
+ }, w = (d, r = O.LOCAL, c = O.LOCAL) => {
319
+ const p = ue(r) ? c : r, S = C(d, r);
320
+ S && f(p, { updated: [S] });
321
321
  }, m = (d, r = O.LOCAL) => {
322
- !!e.get(d.id) ? C(d, r) : A(d, r);
322
+ !!e.get(d.id) ? w(d, r) : A(d, r);
323
323
  }, T = (d, r = O.LOCAL) => {
324
- const c = d.reduce((p, U) => {
325
- const y = w(U);
326
- return y ? [...p, y] : p;
324
+ const c = d.reduce((p, S) => {
325
+ const U = C(S);
326
+ return U ? [...p, U] : p;
327
327
  }, []);
328
328
  c.length > 0 && f(r, { updated: c });
329
329
  }, l = (d, r = O.LOCAL) => {
330
- const c = d.map(Y), { toAdd: p, toUpdate: U } = c.reduce((D, I) => e.get(I.id) ? { ...D, toUpdate: [...D.toUpdate, I] } : { ...D, toAdd: [...D.toAdd, I] }, { toAdd: [], toUpdate: [] }), y = U.map((D) => w(D, r)).filter(Boolean);
331
- p.forEach((D) => {
332
- e.set(D.id, D), D.bodies.forEach((I) => t.set(I.id, D.id));
333
- }), f(r, { created: p, updated: y });
334
- }, v = (d, r = O.LOCAL) => {
330
+ const c = d.map($), { toAdd: p, toUpdate: S } = c.reduce((B, _) => e.get(_.id) ? { ...B, toUpdate: [...B.toUpdate, _] } : { ...B, toAdd: [...B.toAdd, _] }, { toAdd: [], toUpdate: [] }), U = S.map((B) => C(B, r)).filter(Boolean);
331
+ p.forEach((B) => {
332
+ e.set(B.id, B), B.bodies.forEach((_) => t.set(_.id, B.id));
333
+ }), f(r, { created: p, updated: U });
334
+ }, b = (d, r = O.LOCAL) => {
335
335
  const c = e.get(d.annotation);
336
336
  if (c) {
337
337
  const p = {
@@ -345,39 +345,39 @@ const ce = (e, t) => {
345
345
  }] });
346
346
  } else
347
347
  console.warn(`Attempt to add body to missing annotation: ${d.annotation}`);
348
- }, g = () => [...e.values()], b = (d = O.LOCAL) => {
348
+ }, g = () => [...e.values()], E = (d = O.LOCAL) => {
349
349
  const r = [...e.values()];
350
350
  e.clear(), t.clear(), f(d, { deleted: r });
351
351
  }, L = (d, r = !0, c = O.LOCAL) => {
352
- const p = d.map(Y);
352
+ const p = d.map($);
353
353
  if (r) {
354
- const U = [...e.values()];
355
- e.clear(), t.clear(), p.forEach((y) => {
356
- e.set(y.id, y), y.bodies.forEach((D) => t.set(D.id, y.id));
357
- }), f(c, { created: p, deleted: U });
354
+ const S = [...e.values()];
355
+ e.clear(), t.clear(), p.forEach((U) => {
356
+ e.set(U.id, U), U.bodies.forEach((B) => t.set(B.id, U.id));
357
+ }), f(c, { created: p, deleted: S });
358
358
  } else {
359
- const U = d.reduce((y, D) => {
360
- const I = D.id && e.get(D.id);
361
- return I ? [...y, I] : y;
359
+ const S = d.reduce((U, B) => {
360
+ const _ = B.id && e.get(B.id);
361
+ return _ ? [...U, _] : U;
362
362
  }, []);
363
- if (U.length > 0)
364
- throw Error(`Bulk insert would overwrite the following annotations: ${U.map((y) => y.id).join(", ")}`);
365
- p.forEach((y) => {
366
- e.set(y.id, y), y.bodies.forEach((D) => t.set(D.id, y.id));
363
+ if (S.length > 0)
364
+ throw Error(`Bulk insert would overwrite the following annotations: ${S.map((U) => U.id).join(", ")}`);
365
+ p.forEach((U) => {
366
+ e.set(U.id, U), U.bodies.forEach((B) => t.set(B.id, U.id));
367
367
  }), f(c, { created: p });
368
368
  }
369
- }, B = (d) => {
369
+ }, R = (d) => {
370
370
  const r = typeof d == "string" ? d : d.id, c = e.get(r);
371
371
  if (c)
372
372
  return e.delete(r), c.bodies.forEach((p) => t.delete(p.id)), c;
373
373
  console.warn(`Attempt to delete missing annotation: ${r}`);
374
374
  }, i = (d, r = O.LOCAL) => {
375
- const c = B(d);
375
+ const c = R(d);
376
376
  c && f(r, { deleted: [c] });
377
377
  }, u = (d, r = O.LOCAL) => {
378
- const c = d.reduce((p, U) => {
379
- const y = B(U);
380
- return y ? [...p, y] : p;
378
+ const c = d.reduce((p, S) => {
379
+ const U = R(S);
380
+ return U ? [...p, U] : p;
381
381
  }, []);
382
382
  c.length > 0 && f(r, { deleted: c });
383
383
  }, h = (d) => {
@@ -388,7 +388,7 @@ const ce = (e, t) => {
388
388
  t.delete(c.id);
389
389
  const p = {
390
390
  ...r,
391
- bodies: r.bodies.filter((y) => y.id !== d.id)
391
+ bodies: r.bodies.filter((U) => U.id !== d.id)
392
392
  };
393
393
  return e.set(r.id, p), {
394
394
  oldValue: r,
@@ -399,45 +399,45 @@ const ce = (e, t) => {
399
399
  console.warn(`Attempt to delete missing body ${d.id} from annotation ${d.annotation}`);
400
400
  } else
401
401
  console.warn(`Attempt to delete body from missing annotation ${d.annotation}`);
402
- }, E = (d, r = O.LOCAL) => {
402
+ }, v = (d, r = O.LOCAL) => {
403
403
  const c = h(d);
404
404
  c && f(r, { updated: [c] });
405
405
  }, a = (d, r = O.LOCAL) => {
406
406
  const c = d.map((p) => h(p)).filter(Boolean);
407
407
  c.length > 0 && f(r, { updated: c });
408
- }, S = (d) => {
408
+ }, y = (d) => {
409
409
  const r = e.get(d);
410
410
  return r ? { ...r } : void 0;
411
- }, x = (d) => {
411
+ }, N = (d) => {
412
412
  const r = t.get(d);
413
413
  if (r) {
414
- const p = S(r).bodies.find((U) => U.id === d);
414
+ const p = y(r).bodies.find((S) => S.id === d);
415
415
  if (p)
416
416
  return p;
417
417
  console.error(`Store integrity error: body ${d} in index, but not in annotation`);
418
418
  } else
419
419
  console.warn(`Attempt to retrieve missing body: ${d}`);
420
- }, k = (d, r) => {
420
+ }, I = (d, r) => {
421
421
  if (d.annotation !== r.annotation)
422
422
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
423
423
  const c = e.get(d.annotation);
424
424
  if (c) {
425
- const p = c.bodies.find((y) => y.id === d.id), U = {
425
+ const p = c.bodies.find((U) => U.id === d.id), S = {
426
426
  ...c,
427
- bodies: c.bodies.map((y) => y.id === p.id ? r : y)
427
+ bodies: c.bodies.map((U) => U.id === p.id ? r : U)
428
428
  };
429
- return e.set(c.id, U), p.id !== r.id && (t.delete(p.id), t.set(r.id, U.id)), {
429
+ return e.set(c.id, S), p.id !== r.id && (t.delete(p.id), t.set(r.id, S.id)), {
430
430
  oldValue: c,
431
- newValue: U,
431
+ newValue: S,
432
432
  bodiesUpdated: [{ oldBody: p, newBody: r }]
433
433
  };
434
434
  } else
435
435
  console.warn(`Attempt to add body to missing annotation ${d.annotation}`);
436
436
  }, Q = (d, r, c = O.LOCAL) => {
437
- const p = k(d, r);
437
+ const p = I(d, r);
438
438
  p && f(c, { updated: [p] });
439
439
  }, J = (d, r = O.LOCAL) => {
440
- const c = d.map((p) => k({ id: p.id, annotation: p.annotation }, p)).filter(Boolean);
440
+ const c = d.map((p) => I({ id: p.id, annotation: p.annotation }, p)).filter(Boolean);
441
441
  f(r, { updated: c });
442
442
  }, j = (d) => {
443
443
  const r = e.get(d.annotation);
@@ -462,7 +462,7 @@ const ce = (e, t) => {
462
462
  };
463
463
  return {
464
464
  addAnnotation: A,
465
- addBody: v,
465
+ addBody: b,
466
466
  all: g,
467
467
  bulkAddAnnotations: L,
468
468
  bulkDeleteAnnotations: u,
@@ -474,14 +474,14 @@ const ce = (e, t) => {
474
474
  c.length > 0 && f(r, { updated: c });
475
475
  },
476
476
  bulkUpsertAnnotations: l,
477
- clear: b,
477
+ clear: E,
478
478
  deleteAnnotation: i,
479
- deleteBody: E,
480
- getAnnotation: S,
481
- getBody: x,
479
+ deleteBody: v,
480
+ getAnnotation: y,
481
+ getBody: N,
482
482
  observe: o,
483
483
  unobserve: s,
484
- updateAnnotation: C,
484
+ updateAnnotation: w,
485
485
  updateBody: Q,
486
486
  updateTarget: (d, r = O.LOCAL) => {
487
487
  const c = j(d);
@@ -504,80 +504,80 @@ let q = () => ({
504
504
  };
505
505
  }
506
506
  });
507
- const fe = 250, Ne = (e, t) => {
507
+ const fe = 250, xe = (e, t) => {
508
508
  const n = q(), o = (t == null ? void 0 : t.changes) || [];
509
509
  let s = t ? t.pointer : -1, f = !1, A = 0;
510
- const w = (a) => {
510
+ const C = (a) => {
511
511
  if (!f) {
512
- const { changes: S } = a, x = performance.now();
513
- if (x - A > fe)
514
- o.splice(s + 1), o.push(S), s = o.length - 1;
512
+ const { changes: y } = a, N = performance.now();
513
+ if (N - A > fe)
514
+ o.splice(s + 1), o.push(y), s = o.length - 1;
515
515
  else {
516
- const k = o.length - 1;
517
- o[k] = le(o[k], S);
516
+ const I = o.length - 1;
517
+ o[I] = le(o[I], y);
518
518
  }
519
- A = x;
519
+ A = N;
520
520
  }
521
521
  f = !1;
522
522
  };
523
- e.observe(w, { origin: O.LOCAL });
524
- const C = (a) => a && a.length > 0 && e.bulkDeleteAnnotations(a), m = (a) => a && a.length > 0 && e.bulkAddAnnotations(a, !1), T = (a) => a && a.length > 0 && e.bulkUpdateAnnotations(a.map(({ oldValue: S }) => S)), l = (a) => a && a.length > 0 && e.bulkUpdateAnnotations(a.map(({ newValue: S }) => S)), v = (a) => a && a.length > 0 && e.bulkAddAnnotations(a, !1), g = (a) => a && a.length > 0 && e.bulkDeleteAnnotations(a);
523
+ e.observe(C, { origin: O.LOCAL });
524
+ const w = (a) => a && a.length > 0 && e.bulkDeleteAnnotations(a), m = (a) => a && a.length > 0 && e.bulkAddAnnotations(a, !1), T = (a) => a && a.length > 0 && e.bulkUpdateAnnotations(a.map(({ oldValue: y }) => y)), l = (a) => a && a.length > 0 && e.bulkUpdateAnnotations(a.map(({ newValue: y }) => y)), b = (a) => a && a.length > 0 && e.bulkAddAnnotations(a, !1), g = (a) => a && a.length > 0 && e.bulkDeleteAnnotations(a);
525
525
  return {
526
526
  canRedo: () => o.length - 1 > s,
527
527
  canUndo: () => s > -1,
528
- destroy: () => e.unobserve(w),
528
+ destroy: () => e.unobserve(C),
529
529
  getHistory: () => ({ changes: [...o], pointer: s }),
530
- on: (a, S) => n.on(a, S),
530
+ on: (a, y) => n.on(a, y),
531
531
  redo: () => {
532
532
  if (o.length - 1 > s) {
533
533
  f = !0;
534
- const { created: a, updated: S, deleted: x } = o[s + 1];
535
- m(a), l(S), g(x), n.emit("redo", o[s + 1]), s += 1;
534
+ const { created: a, updated: y, deleted: N } = o[s + 1];
535
+ m(a), l(y), g(N), n.emit("redo", o[s + 1]), s += 1;
536
536
  }
537
537
  },
538
538
  undo: () => {
539
539
  if (s > -1) {
540
540
  f = !0;
541
- const { created: a, updated: S, deleted: x } = o[s];
542
- C(a), T(S), v(x), n.emit("undo", o[s]), s -= 1;
541
+ const { created: a, updated: y, deleted: N } = o[s];
542
+ w(a), T(y), b(N), n.emit("undo", o[s]), s -= 1;
543
543
  }
544
544
  }
545
545
  };
546
- }, ke = () => {
546
+ }, Ie = () => {
547
547
  const e = /* @__PURE__ */ M([]);
548
548
  return {
549
549
  subscribe: e.subscribe.bind(e),
550
550
  set: e.set.bind(e)
551
551
  };
552
- }, Ie = (e, t, n, o) => {
553
- const { hover: s, selection: f, store: A, viewport: w } = e, C = /* @__PURE__ */ new Map();
552
+ }, _e = (e, t, n, o) => {
553
+ const { hover: s, selection: f, store: A, viewport: C } = e, w = /* @__PURE__ */ new Map();
554
554
  let m = [], T, l;
555
- const v = (i, u) => {
556
- C.has(i) ? C.get(i).push(u) : C.set(i, [u]);
555
+ const b = (i, u) => {
556
+ w.has(i) ? w.get(i).push(u) : w.set(i, [u]);
557
557
  }, g = (i, u) => {
558
- const h = C.get(i);
558
+ const h = w.get(i);
559
559
  if (h) {
560
- const E = h.indexOf(u);
561
- E !== -1 && h.splice(E, 1);
560
+ const v = h.indexOf(u);
561
+ v !== -1 && h.splice(v, 1);
562
562
  }
563
- }, b = (i, u, h) => {
564
- C.has(i) && setTimeout(() => {
565
- C.get(i).forEach((E) => {
563
+ }, E = (i, u, h) => {
564
+ w.has(i) && setTimeout(() => {
565
+ w.get(i).forEach((v) => {
566
566
  if (n) {
567
- const a = Array.isArray(u) ? u.map((x) => n.serialize(x)) : n.serialize(u), S = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
568
- E(a, S);
567
+ const a = Array.isArray(u) ? u.map((N) => n.serialize(N)) : n.serialize(u), y = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
568
+ v(a, y);
569
569
  } else
570
- E(u, h);
570
+ v(u, h);
571
571
  });
572
572
  }, 1);
573
573
  }, L = () => {
574
574
  const { selected: i } = f, u = (i || []).map(({ id: h }) => A.getAnnotation(h));
575
575
  u.forEach((h) => {
576
- const E = m.find((a) => a.id === h.id);
577
- (!E || !$(E, h)) && b("updateAnnotation", h, E);
576
+ const v = m.find((a) => a.id === h.id);
577
+ (!v || !Y(v, h)) && E("updateAnnotation", h, v);
578
578
  }), m = m.map((h) => {
579
- const E = u.find(({ id: a }) => a === h.id);
580
- return E || h;
579
+ const v = u.find(({ id: a }) => a === h.id);
580
+ return v || h;
581
581
  });
582
582
  };
583
583
  f.subscribe(({ selected: i }) => {
@@ -587,13 +587,13 @@ const fe = 250, Ne = (e, t) => {
587
587
  else if (m.length > 0 && i.length === 0)
588
588
  m.forEach((u) => {
589
589
  const h = A.getAnnotation(u.id);
590
- h && !$(h, u) && b("updateAnnotation", h, u);
590
+ h && !Y(h, u) && E("updateAnnotation", h, u);
591
591
  }), m = [];
592
592
  else {
593
593
  const u = new Set(m.map((a) => a.id)), h = new Set(i.map(({ id: a }) => a));
594
594
  m.filter((a) => !h.has(a.id)).forEach((a) => {
595
- const S = A.getAnnotation(a.id);
596
- S && !$(S, a) && b("updateAnnotation", S, a);
595
+ const y = A.getAnnotation(a.id);
596
+ y && !Y(y, a) && E("updateAnnotation", y, a);
597
597
  }), m = [
598
598
  // Remove annotations that were deselected
599
599
  ...m.filter((a) => h.has(a.id)),
@@ -601,36 +601,36 @@ const fe = 250, Ne = (e, t) => {
601
601
  ...i.filter(({ id: a }) => !u.has(a)).map(({ id: a }) => A.getAnnotation(a))
602
602
  ];
603
603
  }
604
- b("selectionChanged", m);
604
+ E("selectionChanged", m);
605
605
  }
606
606
  }), s.subscribe((i) => {
607
- !T && i ? b("mouseEnterAnnotation", A.getAnnotation(i)) : T && !i ? b("mouseLeaveAnnotation", A.getAnnotation(T)) : T && i && (b("mouseLeaveAnnotation", A.getAnnotation(T)), b("mouseEnterAnnotation", A.getAnnotation(i))), T = i;
608
- }), w == null || w.subscribe((i) => b("viewportIntersect", i.map((u) => A.getAnnotation(u)))), A.observe((i) => {
607
+ !T && i ? E("mouseEnterAnnotation", A.getAnnotation(i)) : T && !i ? E("mouseLeaveAnnotation", A.getAnnotation(T)) : T && i && (E("mouseLeaveAnnotation", A.getAnnotation(T)), E("mouseEnterAnnotation", A.getAnnotation(i))), T = i;
608
+ }), C == null || C.subscribe((i) => E("viewportIntersect", i.map((u) => A.getAnnotation(u)))), A.observe((i) => {
609
609
  o && (l && clearTimeout(l), l = setTimeout(L, 1e3));
610
610
  const { created: u, deleted: h } = i.changes;
611
- (u || []).forEach((a) => b("createAnnotation", a)), (h || []).forEach((a) => b("deleteAnnotation", a)), (i.changes.updated || []).filter((a) => [
611
+ (u || []).forEach((a) => E("createAnnotation", a)), (h || []).forEach((a) => E("deleteAnnotation", a)), (i.changes.updated || []).filter((a) => [
612
612
  ...a.bodiesCreated || [],
613
613
  ...a.bodiesDeleted || [],
614
614
  ...a.bodiesUpdated || []
615
- ].length > 0).forEach(({ oldValue: a, newValue: S }) => {
616
- const x = m.find((k) => k.id === a.id) || a;
617
- m = m.map((k) => k.id === a.id ? S : k), b("updateAnnotation", S, x);
615
+ ].length > 0).forEach(({ oldValue: a, newValue: y }) => {
616
+ const N = m.find((I) => I.id === a.id) || a;
617
+ m = m.map((I) => I.id === a.id ? y : I), E("updateAnnotation", y, N);
618
618
  });
619
619
  }, { origin: O.LOCAL }), A.observe((i) => {
620
620
  if (m) {
621
- const u = new Set(m.map((E) => E.id)), h = (i.changes.updated || []).filter(({ newValue: E }) => u.has(E.id)).map(({ newValue: E }) => E);
622
- h.length > 0 && (m = m.map((E) => {
623
- const a = h.find((S) => S.id === E.id);
624
- return a || E;
621
+ const u = new Set(m.map((v) => v.id)), h = (i.changes.updated || []).filter(({ newValue: v }) => u.has(v.id)).map(({ newValue: v }) => v);
622
+ h.length > 0 && (m = m.map((v) => {
623
+ const a = h.find((y) => y.id === v.id);
624
+ return a || v;
625
625
  }));
626
626
  }
627
627
  }, { origin: O.REMOTE });
628
- const B = (i) => (u) => {
628
+ const R = (i) => (u) => {
629
629
  const { updated: h } = u;
630
- i ? (h || []).forEach((E) => b("updateAnnotation", E.oldValue, E.newValue)) : (h || []).forEach((E) => b("updateAnnotation", E.newValue, E.oldValue));
630
+ i ? (h || []).forEach((v) => E("updateAnnotation", v.oldValue, v.newValue)) : (h || []).forEach((v) => E("updateAnnotation", v.newValue, v.oldValue));
631
631
  };
632
- return t.on("undo", B(!0)), t.on("redo", B(!1)), { on: v, off: g, emit: b };
633
- }, _e = (e) => (t) => t.map((n) => e.serialize(n)), pe = (e) => (t) => t.reduce((n, o) => {
632
+ return t.on("undo", R(!0)), t.on("redo", R(!1)), { on: b, off: g, emit: E };
633
+ }, ke = (e) => (t) => t.map((n) => e.serialize(n)), pe = (e) => (t) => t.reduce((n, o) => {
634
634
  const { parsed: s, error: f } = e.parse(o);
635
635
  return f ? {
636
636
  parsed: n.parsed,
@@ -641,21 +641,21 @@ const fe = 250, Ne = (e, t) => {
641
641
  } : {
642
642
  ...n
643
643
  };
644
- }, { parsed: [], failed: [] }), $e = (e, t, n) => {
644
+ }, { parsed: [], failed: [] }), Ye = (e, t, n) => {
645
645
  const { store: o, selection: s } = e, f = (i) => {
646
646
  if (n) {
647
647
  const { parsed: u, error: h } = n.parse(i);
648
648
  u ? o.addAnnotation(u, O.REMOTE) : console.error(h);
649
649
  } else
650
650
  o.addAnnotation(V(i), O.REMOTE);
651
- }, A = () => s.clear(), w = () => o.clear(), C = (i) => {
651
+ }, A = () => s.clear(), C = () => o.clear(), w = (i) => {
652
652
  const u = o.getAnnotation(i);
653
653
  return n && u ? n.serialize(u) : u;
654
654
  }, m = () => n ? o.all().map(n.serialize) : o.all(), T = () => {
655
655
  var h;
656
- const u = (((h = s.selected) == null ? void 0 : h.map((E) => E.id)) || []).map((E) => o.getAnnotation(E)).filter(Boolean);
656
+ const u = (((h = s.selected) == null ? void 0 : h.map((v) => v.id)) || []).map((v) => o.getAnnotation(v)).filter(Boolean);
657
657
  return n ? u.map(n.serialize) : u;
658
- }, l = (i, u = !0) => fetch(i).then((h) => h.json()).then((h) => (g(h, u), h)), v = (i) => {
658
+ }, l = (i, u = !0) => fetch(i).then((h) => h.json()).then((h) => (g(h, u), h)), b = (i) => {
659
659
  if (typeof i == "string") {
660
660
  const u = o.getAnnotation(i);
661
661
  if (o.deleteAnnotation(i), u)
@@ -667,15 +667,15 @@ const fe = 250, Ne = (e, t) => {
667
667
  }
668
668
  }, g = (i, u = !0) => {
669
669
  if (n) {
670
- const h = n.parseAll || pe(n), { parsed: E, failed: a } = h(i);
671
- a.length > 0 && console.warn(`Discarded ${a.length} invalid annotations`, a), o.bulkAddAnnotations(E, u, O.REMOTE);
670
+ const h = n.parseAll || pe(n), { parsed: v, failed: a } = h(i);
671
+ a.length > 0 && console.warn(`Discarded ${a.length} invalid annotations`, a), o.bulkAddAnnotations(v, u, O.REMOTE);
672
672
  } else
673
673
  o.bulkAddAnnotations(i.map(V), u, O.REMOTE);
674
- }, b = (i, u) => {
674
+ }, E = (i, u) => {
675
675
  i ? s.setSelected(i, u) : s.clear();
676
676
  }, L = (i) => {
677
677
  s.setUserSelectAction(i);
678
- }, B = (i) => {
678
+ }, R = (i) => {
679
679
  if (n) {
680
680
  const u = n.parse(i).parsed, h = n.serialize(o.getAnnotation(u.id));
681
681
  return o.updateAnnotation(u), h;
@@ -689,21 +689,21 @@ const fe = 250, Ne = (e, t) => {
689
689
  cancelSelected: A,
690
690
  canRedo: t.canRedo,
691
691
  canUndo: t.canUndo,
692
- clearAnnotations: w,
693
- getAnnotationById: C,
692
+ clearAnnotations: C,
693
+ getAnnotationById: w,
694
694
  getAnnotations: m,
695
695
  getHistory: t.getHistory,
696
696
  getSelected: T,
697
697
  loadAnnotations: l,
698
698
  redo: t.redo,
699
- removeAnnotation: v,
699
+ removeAnnotation: b,
700
700
  setAnnotations: g,
701
- setSelected: b,
701
+ setSelected: E,
702
702
  setUserSelectAction: L,
703
703
  undo: t.undo,
704
- updateAnnotation: B
704
+ updateAnnotation: R
705
705
  };
706
- }, Ye = (e, t, n) => typeof t == "function" ? t(e, n) : t, ze = (e, t) => typeof e != "function" && typeof t != "function" ? {
706
+ }, $e = (e, t, n) => typeof t == "function" ? t(e, n) : t, Pe = (e, t) => typeof e != "function" && typeof t != "function" ? {
707
707
  ...e || {},
708
708
  ...t || {}
709
709
  } : (n, o) => {
@@ -719,11 +719,11 @@ let ge = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", he
719
719
  let f = e.length - 1;
720
720
  return (A = t) => {
721
721
  if (!A) return "";
722
- let w = "";
722
+ let C = "";
723
723
  for (; ; ) {
724
- let C = n(A), m = A;
724
+ let w = n(A), m = A;
725
725
  for (; m--; )
726
- if (w += e[C[m] & f], w.length >= A) return w;
726
+ if (C += e[w[m] & f], C.length >= A) return C;
727
727
  }
728
728
  };
729
729
  }
@@ -732,19 +732,19 @@ let ge = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", he
732
732
  if (!f) return "";
733
733
  let A = "";
734
734
  for (; ; ) {
735
- let w = n(s), C = s;
736
- for (; C--; )
737
- if (w[C] < o && (A += e[w[C] % e.length], A.length >= f))
735
+ let C = n(s), w = s;
736
+ for (; w--; )
737
+ if (C[w] < o && (A += e[C[w] % e.length], A.length >= f))
738
738
  return A;
739
739
  }
740
740
  };
741
- }, me = (e, t = 21) => Ae(e, t | 0, he), be = (e = 21) => {
741
+ }, me = (e, t = 21) => Ae(e, t | 0, he), Ee = (e = 21) => {
742
742
  let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
743
743
  for (; e--; )
744
744
  t += ge[n[e] & 63];
745
745
  return t;
746
746
  };
747
- const Pe = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), ve = (e) => {
747
+ const ze = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), be = (e) => {
748
748
  const t = JSON.stringify(e);
749
749
  let n = 0;
750
750
  for (let o = 0, s = t.length; o < s; o++) {
@@ -752,28 +752,28 @@ const Pe = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABC
752
752
  n = (n << 5) - n + f, n |= 0;
753
753
  }
754
754
  return `${n}`;
755
- }, Ee = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ve = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
756
- const { id: o, type: s, purpose: f, value: A, created: w, modified: C, creator: m, ...T } = n;
755
+ }, ve = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Ve = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
756
+ const { id: o, type: s, purpose: f, value: A, created: C, modified: w, creator: m, ...T } = n;
757
757
  return {
758
- id: o || `temp-${ve(n)}`,
758
+ id: o || `temp-${be(n)}`,
759
759
  annotation: t,
760
760
  type: s,
761
761
  purpose: f,
762
762
  value: A,
763
- creator: Ee(m),
764
- created: w ? new Date(w) : void 0,
765
- updated: C ? new Date(C) : void 0,
763
+ creator: ve(m),
764
+ created: C ? new Date(C) : void 0,
765
+ updated: w ? new Date(w) : void 0,
766
766
  ...T
767
767
  };
768
768
  }), Me = (e) => e.map((t) => {
769
- var w;
769
+ var C;
770
770
  const { annotation: n, created: o, updated: s, ...f } = t, A = {
771
771
  ...f,
772
772
  created: o == null ? void 0 : o.toISOString(),
773
773
  modified: s == null ? void 0 : s.toISOString()
774
774
  };
775
- return (w = A.id) != null && w.startsWith("temp-") && delete A.id, A;
776
- }), je = (e) => "@context" in e && "creator" in e && "body" in e, we = [
775
+ return (C = A.id) != null && C.startsWith("temp-") && delete A.id, A;
776
+ }), je = (e) => "@context" in e && "creator" in e && "body" in e, Ce = [
777
777
  "#ff7c00",
778
778
  // orange
779
779
  "#1ac938",
@@ -792,14 +792,14 @@ const Pe = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABC
792
792
  // cyan
793
793
  "#023eff"
794
794
  // blue
795
- ], Ce = () => {
796
- const e = [...we];
795
+ ], we = () => {
796
+ const e = [...Ce];
797
797
  return { assignRandomColor: () => {
798
798
  const o = Math.floor(Math.random() * e.length), s = e[o];
799
799
  return e.splice(o, 1), s;
800
800
  }, releaseColor: (o) => e.push(o) };
801
801
  }, Le = () => {
802
- const e = Ce();
802
+ const e = we();
803
803
  return { addUser: (o, s) => {
804
804
  const f = e.assignRandomColor();
805
805
  return {
@@ -808,53 +808,55 @@ const Pe = () => ({ isGuest: !0, id: me("1234567890abcdefghijklmnopqrstuvwxyzABC
808
808
  color: f
809
809
  };
810
810
  }, removeUser: (o) => e.releaseColor(o.appearance.color) };
811
- }, ye = (e, t) => e.every((n) => e.includes(n)) && t.every((n) => e.includes(n)), Ge = be(), He = (e = Le()) => {
812
- const t = q(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (l, v) => {
811
+ }, Ue = (e, t) => e.every((n) => e.includes(n)) && t.every((n) => e.includes(n));
812
+ globalThis.ANNOTORIOUS_PRESENCE_KEY || (globalThis.ANNOTORIOUS_PRESENCE_KEY = Ee());
813
+ const Ge = globalThis.ANNOTORIOUS_PRESENCE_KEY, He = (e = Le()) => {
814
+ const t = q(), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = (l, b) => {
813
815
  if (n.has(l)) {
814
- console.warn("Attempt to add user that is already present", l, v);
816
+ console.warn("Attempt to add user that is already present", l, b);
815
817
  return;
816
818
  }
817
- const g = e.addUser(l, v);
819
+ const g = e.addUser(l, b);
818
820
  n.set(l, {
819
- ...v,
821
+ ...b,
820
822
  presenceKey: l,
821
823
  appearance: g
822
824
  });
823
825
  }, f = (l) => {
824
- const v = n.get(l);
825
- if (!v) {
826
+ const b = n.get(l);
827
+ if (!b) {
826
828
  console.warn("Attempt to remove user that is not present", l);
827
829
  return;
828
830
  }
829
- e.removeUser(v), n.delete(l);
831
+ e.removeUser(b), n.delete(l);
830
832
  }, A = (l) => {
831
- const v = new Set(l.map((L) => L.presenceKey)), g = l.filter(({ presenceKey: L }) => !n.has(L)), b = Array.from(n.values()).filter((L) => !v.has(L.presenceKey));
832
- g.forEach(({ presenceKey: L, user: B }) => s(L, B)), b.forEach((L) => {
833
- const { presenceKey: B } = L;
834
- o.has(B) && t.emit("selectionChange", L, null), f(B);
835
- }), (g.length > 0 || b.length > 0) && t.emit("presence", m());
836
- }, w = (l, v) => {
833
+ const b = new Set(l.map((L) => L.presenceKey)), g = l.filter(({ presenceKey: L }) => !n.has(L)), E = Array.from(n.values()).filter((L) => !b.has(L.presenceKey));
834
+ g.forEach(({ presenceKey: L, user: R }) => s(L, R)), E.forEach((L) => {
835
+ const { presenceKey: R } = L;
836
+ o.has(R) && t.emit("selectionChange", L, null), f(R);
837
+ }), (g.length > 0 || E.length > 0) && t.emit("presence", m());
838
+ }, C = (l, b) => {
837
839
  const g = n.get(l);
838
840
  if (!g) {
839
841
  console.warn("Activity notification from user that is not present");
840
842
  return;
841
843
  }
842
- const b = o.get(l);
843
- (!b || !ye(b, v)) && (o.set(l, v), t.emit("selectionChange", g, v));
844
- }, C = (l, v) => {
844
+ const E = o.get(l);
845
+ (!E || !Ue(E, b)) && (o.set(l, b), t.emit("selectionChange", g, b));
846
+ }, w = (l, b) => {
845
847
  const g = n.get(l);
846
848
  if (!g) {
847
849
  console.warn("Selection change for user that is not present", l);
848
850
  return;
849
851
  }
850
- v ? o.set(l, v) : o.delete(l), t.emit("selectionChange", g, v);
852
+ b ? o.set(l, b) : o.delete(l), t.emit("selectionChange", g, b);
851
853
  }, m = () => [...Array.from(n.values())];
852
854
  return {
853
855
  getPresentUsers: m,
854
- notifyActivity: w,
855
- on: (l, v) => t.on(l, v),
856
+ notifyActivity: C,
857
+ on: (l, b) => t.on(l, b),
856
858
  syncUsers: A,
857
- updateSelection: C
859
+ updateSelection: w
858
860
  };
859
861
  };
860
862
  export {
@@ -862,30 +864,30 @@ export {
862
864
  O as Origin,
863
865
  Ge as PRESENCE_KEY,
864
866
  F as UserSelectAction,
865
- ze as chainStyles,
866
- Ye as computeStyle,
867
- Pe as createAnonymousGuest,
868
- $e as createBaseAnnotator,
869
- Re as createBody,
867
+ Pe as chainStyles,
868
+ $e as computeStyle,
869
+ ze as createAnonymousGuest,
870
+ Ye as createBaseAnnotator,
871
+ De as createBody,
870
872
  Le as createDefaultAppearanceProvider,
871
873
  Oe as createHoverState,
872
- Ie as createLifecycleObserver,
874
+ _e as createLifecycleObserver,
873
875
  He as createPresenceState,
874
- Be as createSelectionState,
875
- xe as createStore,
876
- Ne as createUndoStack,
877
- ke as createViewportState,
878
- Ce as defaultColorProvider,
876
+ Re as createSelectionState,
877
+ Ne as createStore,
878
+ xe as createUndoStack,
879
+ Ie as createViewportState,
880
+ we as defaultColorProvider,
879
881
  W as diffAnnotations,
880
- De as getContributors,
882
+ Be as getContributors,
881
883
  je as isW3CAnnotation,
882
884
  le as mergeChanges,
883
885
  K as onUserSelect,
884
886
  pe as parseAll,
885
887
  Ve as parseW3CBodies,
886
- Ee as parseW3CUser,
888
+ ve as parseW3CUser,
887
889
  V as reviveDates,
888
- _e as serializeAll,
890
+ ke as serializeAll,
889
891
  Me as serializeW3CBodies,
890
892
  ce as shouldNotify
891
893
  };