@soomo/text-annotator 3.1.0-staging.25 → 3.1.0-staging.27

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.
@@ -109,9 +109,9 @@ const ue = "not-annotatable", et = `.${ue}`, st = (t) => {
109
109
  const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
110
110
  e,
111
111
  NodeFilter.SHOW_TEXT,
112
- (f) => {
112
+ (h) => {
113
113
  var A;
114
- return (A = f.parentElement) != null && A.closest(et) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
114
+ return (A = h.parentElement) != null && A.closest(et) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
115
115
  }
116
116
  );
117
117
  let a = 0;
@@ -121,22 +121,22 @@ const ue = "not-annotatable", et = `.${ue}`, st = (t) => {
121
121
  let d = !i;
122
122
  for (; l !== null; ) {
123
123
  if (d || (d = i == null ? void 0 : i.contains(l)), d) {
124
- const f = ((g = l.textContent) == null ? void 0 : g.length) || 0;
125
- if (a + f > n) {
124
+ const h = ((g = l.textContent) == null ? void 0 : g.length) || 0;
125
+ if (a + h > n) {
126
126
  r.setStart(l, n - a);
127
127
  break;
128
128
  }
129
- a += f;
129
+ a += h;
130
130
  }
131
131
  l = s.nextNode();
132
132
  }
133
133
  for (; l !== null; ) {
134
- const f = ((u = l.textContent) == null ? void 0 : u.length) || 0;
135
- if (a + f >= o) {
134
+ const h = ((u = l.textContent) == null ? void 0 : u.length) || 0;
135
+ if (a + h >= o) {
136
136
  r.setEnd(l, o - a);
137
137
  break;
138
138
  }
139
- a += f, l = s.nextNode();
139
+ a += h, l = s.nextNode();
140
140
  }
141
141
  return {
142
142
  ...t,
@@ -213,7 +213,7 @@ const ue = "not-annotatable", et = `.${ue}`, st = (t) => {
213
213
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : pe(t.parentElement);
214
214
  }, ze = (t, e) => (n) => {
215
215
  const o = typeof n == "string" ? n : n.id, i = (a) => {
216
- const r = s.getBoundingClientRect(), l = s.clientHeight, d = s.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: u, height: f } = e.getAnnotationBounds(o), A = g.top - r.top, p = g.left - r.left, b = s.parentElement ? s.scrollTop : 0, x = s.parentElement ? s.scrollLeft : 0, m = A + b - (l - f) / 2, c = p + x - (d - u) / 2;
216
+ const r = s.getBoundingClientRect(), l = s.clientHeight, d = s.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: u, height: h } = e.getAnnotationBounds(o), A = g.top - r.top, p = g.left - r.left, b = s.parentElement ? s.scrollTop : 0, x = s.parentElement ? s.scrollLeft : 0, m = A + b - (l - h) / 2, c = p + x - (d - u) / 2;
217
217
  s.scroll({ top: m, left: c, behavior: "smooth" });
218
218
  }, s = pe(t);
219
219
  if (s) {
@@ -260,24 +260,24 @@ function qe() {
260
260
  const A = Date.now() - l;
261
261
  A < n && A >= 0 ? r = setTimeout(u, n - A) : (r = void 0, i || (d = g()));
262
262
  }
263
- const f = function(...A) {
263
+ const h = function(...A) {
264
264
  if (s && this !== s && Object.getPrototypeOf(this) === Object.getPrototypeOf(s))
265
265
  throw new Error("Debounced method called with different contexts of the same prototype.");
266
266
  s = this, a = A, l = Date.now();
267
267
  const p = i && !r;
268
268
  return r || (r = setTimeout(u, n)), p && (d = g()), d;
269
269
  };
270
- return Object.defineProperty(f, "isPending", {
270
+ return Object.defineProperty(h, "isPending", {
271
271
  get() {
272
272
  return r !== void 0;
273
273
  }
274
- }), f.clear = () => {
274
+ }), h.clear = () => {
275
275
  r && (clearTimeout(r), r = void 0);
276
- }, f.flush = () => {
277
- r && f.trigger();
278
- }, f.trigger = () => {
279
- d = g(), f.clear();
280
- }, f;
276
+ }, h.flush = () => {
277
+ r && h.trigger();
278
+ }, h.trigger = () => {
279
+ d = g(), h.clear();
280
+ }, h;
281
281
  }
282
282
  return gt.exports.debounce = t, gt.exports = t, gt.exports;
283
283
  }
@@ -299,37 +299,37 @@ const Xt = /* @__PURE__ */ We(Ge), Qe = (t) => {
299
299
  v ? a.current !== v.id && (t.classList.add("hovered"), a.set(v.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
300
300
  };
301
301
  t.addEventListener("pointermove", u);
302
- const f = (T = !1) => {
302
+ const h = (T = !1) => {
303
303
  d && d.clear();
304
- const R = Qe(t), { minX: w, minY: v, maxX: h, maxY: E } = R, M = l ? i.getIntersecting(w, v, h, E).filter(({ annotation: _ }) => l(_)) : i.getIntersecting(w, v, h, E), O = s.selected.map(({ id: _ }) => _), U = M.map(({ annotation: _, rects: ht }) => {
304
+ const R = Qe(t), { minX: w, minY: v, maxX: f, maxY: E } = R, M = l ? i.getIntersecting(w, v, f, E).filter(({ annotation: _ }) => l(_)) : i.getIntersecting(w, v, f, E), O = s.selected.map(({ id: _ }) => _), U = M.map(({ annotation: _, rects: ht }) => {
305
305
  const W = O.includes(_.id), G = _.id === a.current;
306
306
  return { annotation: _, rects: ht, state: { selected: W, hover: G } };
307
307
  });
308
308
  o.redraw(U, R, r, d, T), setTimeout(() => g(M.map(({ annotation: _ }) => _)), 1);
309
309
  }, A = (T) => {
310
- d = T, f();
310
+ d = T, h();
311
311
  }, p = (T) => {
312
- r = T, f();
312
+ r = T, h();
313
313
  }, b = (T) => {
314
- l = T, f(!1);
315
- }, x = () => f();
314
+ l = T, h(!1);
315
+ }, x = () => h();
316
316
  i.observe(x);
317
- const m = s.subscribe(() => f()), c = () => f(!0);
317
+ const m = s.subscribe(() => h()), c = () => h(!0);
318
318
  document.addEventListener("scroll", c, { capture: !0, passive: !0 });
319
319
  const y = Xt(() => {
320
- i.recalculatePositions(), d == null || d.reset(), f();
320
+ i.recalculatePositions(), d == null || d.reset(), h();
321
321
  }, 10);
322
322
  window.addEventListener("resize", y);
323
323
  const C = new ResizeObserver(y);
324
324
  C.observe(t);
325
325
  const S = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((T) => {
326
- T.every((w) => w.target === t || t.contains(w.target)) || f(!0);
326
+ T.every((w) => w.target === t || t.contains(w.target)) || h(!0);
327
327
  });
328
328
  return L.observe(document.body, S), {
329
329
  destroy: () => {
330
330
  t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(x), m(), document.removeEventListener("scroll", c), y.clear(), window.removeEventListener("resize", y), C.disconnect(), L.disconnect();
331
331
  },
332
- redraw: f,
332
+ redraw: h,
333
333
  setStyle: p,
334
334
  setFilter: b,
335
335
  setPainter: A,
@@ -345,8 +345,8 @@ const Xt = /* @__PURE__ */ We(Ge), Qe = (t) => {
345
345
  const e = Ze(), n = e.getContext("2d");
346
346
  document.body.appendChild(e);
347
347
  const o = (r, l, d, g) => requestAnimationFrame(() => {
348
- const { width: u, height: f } = e;
349
- n.clearRect(-0.5, -0.5, u + 1, f + 1), g && g.clear();
348
+ const { width: u, height: h } = e;
349
+ n.clearRect(-0.5, -0.5, u + 1, h + 1), g && g.clear();
350
350
  const { top: A, left: p } = l;
351
351
  [...r].sort((x, m) => {
352
352
  const { annotation: { target: { created: c } } } = x, { annotation: { target: { created: y } } } = m;
@@ -533,12 +533,12 @@ const un = (t) => [
533
533
  Array.from(e).filter((u) => !d.has(u));
534
534
  const g = s.map((u) => {
535
535
  var p;
536
- const f = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (p = u.state) != null && p.selected ? Et : q, A = l && l.paint(u, a) || f;
536
+ const h = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (p = u.state) != null && p.selected ? Et : q, A = l && l.paint(u, a) || h;
537
537
  return `::highlight(_${u.annotation.id}) { ${un(A)} }`;
538
538
  });
539
539
  t.innerHTML = g.join(`
540
540
  `), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
541
- const f = u.target.selector.map((p) => p.range), A = new Highlight(...f);
541
+ const h = u.target.selector.map((p) => p.range), A = new Highlight(...h);
542
542
  CSS.highlights.set(`_${u.id}`, A);
543
543
  }), e = d;
544
544
  }
@@ -578,15 +578,15 @@ const pn = (t, e) => {
578
578
  e.remove();
579
579
  },
580
580
  redraw: (a, r, l, d, g) => {
581
- const f = !(Pt(n, a) && g);
582
- if (!d && !f) return;
583
- f && (e.innerHTML = ""), [...a].sort((p, b) => {
581
+ const h = !(Pt(n, a) && g);
582
+ if (!d && !h) return;
583
+ h && (e.innerHTML = ""), [...a].sort((p, b) => {
584
584
  const { annotation: { target: { created: x } } } = p, { annotation: { target: { created: m } } } = b;
585
585
  return x && m ? x.getTime() - m.getTime() : 0;
586
586
  }).forEach((p) => {
587
587
  p.rects.map((b) => {
588
588
  const x = pn(b, a), m = Fe(p, r, l, d, x);
589
- if (f) {
589
+ if (h) {
590
590
  const c = document.createElement("span");
591
591
  c.className = "r6o-annotation", c.dataset.annotation = p.annotation.id, c.style.left = `${b.x}px`, c.style.top = `${b.y}px`, c.style.width = `${b.width}px`, c.style.height = `${b.height}px`, c.style.backgroundColor = $((m == null ? void 0 : m.fill) || q.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? q.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (c.style.borderStyle = m.underlineStyle), m.underlineColor && (c.style.borderColor = m.underlineColor), m.underlineThickness && (c.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (c.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(c);
592
592
  }
@@ -734,14 +734,14 @@ const yt = { selected: [] }, Sn = (t, e, n) => {
734
734
  return { id: c.id, editable: y };
735
735
  })
736
736
  }), m.length !== x.length && console.warn("Invalid selection", p);
737
- }, f = (p) => {
737
+ }, h = (p) => {
738
738
  if (l())
739
739
  return !1;
740
740
  const { selected: b } = a;
741
741
  b.some(({ id: x }) => p.includes(x)) && i({ selected: b.filter(({ id: x }) => !p.includes(x)) });
742
742
  }, A = (p) => s = p;
743
743
  return t.observe(
744
- ({ changes: p }) => f((p.deleted || []).map((b) => b.id))
744
+ ({ changes: p }) => h((p.deleted || []).map((b) => b.id))
745
745
  ), {
746
746
  get event() {
747
747
  return a ? a.event : null;
@@ -848,17 +848,17 @@ const In = (t, e) => {
848
848
  return !0;
849
849
  }, Nn = (t, e) => {
850
850
  const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), l = [
851
- ...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: f }) => f.id === u.id).newValue : u),
851
+ ...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: h }) => h.id === u.id).newValue : u),
852
852
  ...e.created || []
853
853
  ], d = [
854
854
  ...(t.deleted || []).filter((u) => !i.has(u.id)),
855
855
  ...(e.deleted || []).filter((u) => !n.has(u.id))
856
856
  ], g = [
857
857
  ...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
858
- const { oldValue: f, newValue: A } = u;
858
+ const { oldValue: h, newValue: A } = u;
859
859
  if (a.has(A.id)) {
860
860
  const p = e.updated.find((b) => b.oldValue.id === A.id).newValue;
861
- return Ae(f, p);
861
+ return Ae(h, p);
862
862
  } else
863
863
  return u;
864
864
  }),
@@ -883,10 +883,10 @@ const In = (t, e) => {
883
883
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (w, v = {}) => {
884
884
  n.push({ onChange: w, options: v });
885
885
  }, i = (w) => {
886
- const v = n.findIndex((h) => h.onChange == w);
886
+ const v = n.findIndex((f) => f.onChange == w);
887
887
  v > -1 && n.splice(v, 1);
888
888
  }, s = (w, v) => {
889
- const h = {
889
+ const f = {
890
890
  origin: w,
891
891
  changes: {
892
892
  created: v.created || [],
@@ -896,55 +896,55 @@ const In = (t, e) => {
896
896
  state: [...t.values()]
897
897
  };
898
898
  n.forEach((E) => {
899
- In(E, h) && E.onChange(h);
899
+ In(E, f) && E.onChange(f);
900
900
  });
901
901
  }, a = (w, v = k.LOCAL) => {
902
902
  if (w.id && t.get(w.id))
903
903
  throw Error(`Cannot add annotation ${w.id} - exists already`);
904
904
  {
905
- const h = Nt(w);
906
- t.set(h.id, h), h.bodies.forEach((E) => e.set(E.id, h.id)), s(v, { created: [h] });
905
+ const f = Nt(w);
906
+ t.set(f.id, f), f.bodies.forEach((E) => e.set(E.id, f.id)), s(v, { created: [f] });
907
907
  }
908
908
  }, r = (w, v) => {
909
- const h = Nt(typeof w == "string" ? v : w), E = typeof w == "string" ? w : w.id, M = E && t.get(E);
909
+ const f = Nt(typeof w == "string" ? v : w), E = typeof w == "string" ? w : w.id, M = E && t.get(E);
910
910
  if (M) {
911
- const O = Ae(M, h);
912
- return E === h.id ? t.set(E, h) : (t.delete(E), t.set(h.id, h)), M.bodies.forEach((U) => e.delete(U.id)), h.bodies.forEach((U) => e.set(U.id, h.id)), O;
911
+ const O = Ae(M, f);
912
+ return E === f.id ? t.set(E, f) : (t.delete(E), t.set(f.id, f)), M.bodies.forEach((U) => e.delete(U.id)), f.bodies.forEach((U) => e.set(U.id, f.id)), O;
913
913
  } else
914
914
  console.warn(`Cannot update annotation ${E} - does not exist`);
915
- }, l = (w, v = k.LOCAL, h = k.LOCAL) => {
916
- const E = _n(v) ? h : v, M = r(w, v);
915
+ }, l = (w, v = k.LOCAL, f = k.LOCAL) => {
916
+ const E = _n(v) ? f : v, M = r(w, v);
917
917
  M && s(E, { updated: [M] });
918
918
  }, d = (w, v = k.LOCAL) => {
919
- const h = w.reduce((E, M) => {
919
+ const f = w.reduce((E, M) => {
920
920
  const O = r(M);
921
921
  return O ? [...E, O] : E;
922
922
  }, []);
923
- h.length > 0 && s(v, { updated: h });
923
+ f.length > 0 && s(v, { updated: f });
924
924
  }, g = (w, v = k.LOCAL) => {
925
- const h = t.get(w.annotation);
926
- if (h) {
925
+ const f = t.get(w.annotation);
926
+ if (f) {
927
927
  const E = {
928
- ...h,
929
- bodies: [...h.bodies, w]
928
+ ...f,
929
+ bodies: [...f.bodies, w]
930
930
  };
931
- t.set(h.id, E), e.set(w.id, E.id), s(v, { updated: [{
932
- oldValue: h,
931
+ t.set(f.id, E), e.set(w.id, E.id), s(v, { updated: [{
932
+ oldValue: f,
933
933
  newValue: E,
934
934
  bodiesCreated: [w]
935
935
  }] });
936
936
  } else
937
937
  console.warn(`Attempt to add body to missing annotation: ${w.annotation}`);
938
- }, u = () => [...t.values()], f = (w = k.LOCAL) => {
938
+ }, u = () => [...t.values()], h = (w = k.LOCAL) => {
939
939
  const v = [...t.values()];
940
940
  t.clear(), e.clear(), s(w, { deleted: v });
941
- }, A = (w, v = !0, h = k.LOCAL) => {
941
+ }, A = (w, v = !0, f = k.LOCAL) => {
942
942
  const E = w.map(Nt);
943
943
  if (v) {
944
944
  const M = [...t.values()];
945
945
  t.clear(), e.clear(), E.forEach((O) => {
946
946
  t.set(O.id, O), O.bodies.forEach((U) => e.set(U.id, O.id));
947
- }), s(h, { created: E, deleted: M });
947
+ }), s(f, { created: E, deleted: M });
948
948
  } else {
949
949
  const M = w.reduce((O, U) => {
950
950
  const _ = U.id && t.get(U.id);
@@ -954,28 +954,28 @@ const In = (t, e) => {
954
954
  throw Error(`Bulk insert would overwrite the following annotations: ${M.map((O) => O.id).join(", ")}`);
955
955
  E.forEach((O) => {
956
956
  t.set(O.id, O), O.bodies.forEach((U) => e.set(U.id, O.id));
957
- }), s(h, { created: E });
957
+ }), s(f, { created: E });
958
958
  }
959
959
  }, p = (w) => {
960
- const v = typeof w == "string" ? w : w.id, h = t.get(v);
961
- if (h)
962
- return t.delete(v), h.bodies.forEach((E) => e.delete(E.id)), h;
960
+ const v = typeof w == "string" ? w : w.id, f = t.get(v);
961
+ if (f)
962
+ return t.delete(v), f.bodies.forEach((E) => e.delete(E.id)), f;
963
963
  console.warn(`Attempt to delete missing annotation: ${v}`);
964
964
  }, b = (w, v = k.LOCAL) => {
965
- const h = p(w);
966
- h && s(v, { deleted: [h] });
965
+ const f = p(w);
966
+ f && s(v, { deleted: [f] });
967
967
  }, x = (w, v = k.LOCAL) => {
968
- const h = w.reduce((E, M) => {
968
+ const f = w.reduce((E, M) => {
969
969
  const O = p(M);
970
970
  return O ? [...E, O] : E;
971
971
  }, []);
972
- h.length > 0 && s(v, { deleted: h });
972
+ f.length > 0 && s(v, { deleted: f });
973
973
  }, m = (w) => {
974
974
  const v = t.get(w.annotation);
975
975
  if (v) {
976
- const h = v.bodies.find((E) => E.id === w.id);
977
- if (h) {
978
- e.delete(h.id);
976
+ const f = v.bodies.find((E) => E.id === w.id);
977
+ if (f) {
978
+ e.delete(f.id);
979
979
  const E = {
980
980
  ...v,
981
981
  bodies: v.bodies.filter((M) => M.id !== w.id)
@@ -983,65 +983,65 @@ const In = (t, e) => {
983
983
  return t.set(v.id, E), {
984
984
  oldValue: v,
985
985
  newValue: E,
986
- bodiesDeleted: [h]
986
+ bodiesDeleted: [f]
987
987
  };
988
988
  } else
989
989
  console.warn(`Attempt to delete missing body ${w.id} from annotation ${w.annotation}`);
990
990
  } else
991
991
  console.warn(`Attempt to delete body from missing annotation ${w.annotation}`);
992
992
  }, c = (w, v = k.LOCAL) => {
993
- const h = m(w);
994
- h && s(v, { updated: [h] });
993
+ const f = m(w);
994
+ f && s(v, { updated: [f] });
995
995
  }, y = (w, v = k.LOCAL) => {
996
- const h = w.map((E) => m(E)).filter(Boolean);
997
- h.length > 0 && s(v, { updated: h });
996
+ const f = w.map((E) => m(E)).filter(Boolean);
997
+ f.length > 0 && s(v, { updated: f });
998
998
  }, C = (w) => {
999
999
  const v = t.get(w);
1000
1000
  return v ? { ...v } : void 0;
1001
1001
  }, S = (w) => {
1002
1002
  const v = e.get(w);
1003
1003
  if (v) {
1004
- const h = C(v).bodies.find((E) => E.id === w);
1005
- if (h)
1006
- return h;
1004
+ const f = C(v).bodies.find((E) => E.id === w);
1005
+ if (f)
1006
+ return f;
1007
1007
  console.error(`Store integrity error: body ${w} in index, but not in annotation`);
1008
1008
  } else
1009
1009
  console.warn(`Attempt to retrieve missing body: ${w}`);
1010
1010
  }, L = (w, v) => {
1011
1011
  if (w.annotation !== v.annotation)
1012
1012
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
1013
- const h = t.get(w.annotation);
1014
- if (h) {
1015
- const E = h.bodies.find((O) => O.id === w.id), M = {
1016
- ...h,
1017
- bodies: h.bodies.map((O) => O.id === E.id ? v : O)
1013
+ const f = t.get(w.annotation);
1014
+ if (f) {
1015
+ const E = f.bodies.find((O) => O.id === w.id), M = {
1016
+ ...f,
1017
+ bodies: f.bodies.map((O) => O.id === E.id ? v : O)
1018
1018
  };
1019
- return t.set(h.id, M), E.id !== v.id && (e.delete(E.id), e.set(v.id, M.id)), {
1020
- oldValue: h,
1019
+ return t.set(f.id, M), E.id !== v.id && (e.delete(E.id), e.set(v.id, M.id)), {
1020
+ oldValue: f,
1021
1021
  newValue: M,
1022
1022
  bodiesUpdated: [{ oldBody: E, newBody: v }]
1023
1023
  };
1024
1024
  } else
1025
1025
  console.warn(`Attempt to add body to missing annotation ${w.annotation}`);
1026
- }, B = (w, v, h = k.LOCAL) => {
1026
+ }, B = (w, v, f = k.LOCAL) => {
1027
1027
  const E = L(w, v);
1028
- E && s(h, { updated: [E] });
1028
+ E && s(f, { updated: [E] });
1029
1029
  }, T = (w, v = k.LOCAL) => {
1030
- const h = w.map((E) => L({ id: E.id, annotation: E.annotation }, E)).filter(Boolean);
1031
- s(v, { updated: h });
1030
+ const f = w.map((E) => L({ id: E.id, annotation: E.annotation }, E)).filter(Boolean);
1031
+ s(v, { updated: f });
1032
1032
  }, R = (w) => {
1033
1033
  const v = t.get(w.annotation);
1034
1034
  if (v) {
1035
- const h = {
1035
+ const f = {
1036
1036
  ...v,
1037
1037
  target: {
1038
1038
  ...v.target,
1039
1039
  ...w
1040
1040
  }
1041
1041
  };
1042
- return t.set(v.id, h), {
1042
+ return t.set(v.id, f), {
1043
1043
  oldValue: v,
1044
- newValue: h,
1044
+ newValue: f,
1045
1045
  targetUpdated: {
1046
1046
  oldTarget: v.target,
1047
1047
  newTarget: w
@@ -1060,10 +1060,10 @@ const In = (t, e) => {
1060
1060
  bulkUpdateAnnotation: d,
1061
1061
  bulkUpdateBodies: T,
1062
1062
  bulkUpdateTargets: (w, v = k.LOCAL) => {
1063
- const h = w.map((E) => R(E)).filter(Boolean);
1064
- h.length > 0 && s(v, { updated: h });
1063
+ const f = w.map((E) => R(E)).filter(Boolean);
1064
+ f.length > 0 && s(v, { updated: f });
1065
1065
  },
1066
- clear: f,
1066
+ clear: h,
1067
1067
  deleteAnnotation: b,
1068
1068
  deleteBody: c,
1069
1069
  getAnnotation: C,
@@ -1073,8 +1073,8 @@ const In = (t, e) => {
1073
1073
  updateAnnotation: l,
1074
1074
  updateBody: B,
1075
1075
  updateTarget: (w, v = k.LOCAL) => {
1076
- const h = R(w);
1077
- h && s(v, { updated: [h] });
1076
+ const f = R(w);
1077
+ f && s(v, { updated: [f] });
1078
1078
  }
1079
1079
  };
1080
1080
  };
@@ -1109,7 +1109,7 @@ const Vn = 250, Yn = (t, e) => {
1109
1109
  s = !1;
1110
1110
  };
1111
1111
  t.observe(r, { origin: k.LOCAL });
1112
- const l = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: b }) => b)), u = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: b }) => b)), f = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), A = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1112
+ const l = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: b }) => b)), u = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: b }) => b)), h = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), A = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1113
1113
  return {
1114
1114
  canRedo: () => o.length - 1 > i,
1115
1115
  canUndo: () => i > -1,
@@ -1127,7 +1127,7 @@ const Vn = 250, Yn = (t, e) => {
1127
1127
  if (i > -1) {
1128
1128
  s = !0;
1129
1129
  const { created: p, updated: b, deleted: x } = o[i];
1130
- l(p), g(b), f(x), n.emit("undo", o[i]), i -= 1;
1130
+ l(p), g(b), h(x), n.emit("undo", o[i]), i -= 1;
1131
1131
  }
1132
1132
  }
1133
1133
  };
@@ -1142,7 +1142,7 @@ const Vn = 250, Yn = (t, e) => {
1142
1142
  let d = [], g;
1143
1143
  const u = (b, x) => {
1144
1144
  l.has(b) ? l.get(b).push(x) : l.set(b, [x]);
1145
- }, f = (b, x) => {
1145
+ }, h = (b, x) => {
1146
1146
  const m = l.get(b);
1147
1147
  if (m) {
1148
1148
  const c = m.indexOf(x);
@@ -1204,7 +1204,7 @@ const Vn = 250, Yn = (t, e) => {
1204
1204
  const { updated: m } = x;
1205
1205
  b ? (m || []).forEach((c) => A("updateAnnotation", c.oldValue, c.newValue)) : (m || []).forEach((c) => A("updateAnnotation", c.newValue, c.oldValue));
1206
1206
  };
1207
- return e.on("undo", p(!0)), e.on("redo", p(!1)), { on: u, off: f, emit: A };
1207
+ return e.on("undo", p(!0)), e.on("redo", p(!1)), { on: u, off: h, emit: A };
1208
1208
  }, Xn = (t) => (e) => e.reduce((n, o) => {
1209
1209
  const { parsed: i, error: s } = t.parse(o);
1210
1210
  return s ? {
@@ -1230,7 +1230,7 @@ const Vn = 250, Yn = (t, e) => {
1230
1230
  var m;
1231
1231
  const c = (((m = i.selected) == null ? void 0 : m.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
1232
1232
  return n ? c.map(n.serialize) : c;
1233
- }, u = (m, c = !0) => fetch(m).then((y) => y.json()).then((y) => (A(y, c), y)), f = (m) => {
1233
+ }, u = (m, c = !0) => fetch(m).then((y) => y.json()).then((y) => (A(y, c), y)), h = (m) => {
1234
1234
  if (typeof m == "string") {
1235
1235
  const c = o.getAnnotation(m);
1236
1236
  if (o.deleteAnnotation(m), c)
@@ -1271,7 +1271,7 @@ const Vn = 250, Yn = (t, e) => {
1271
1271
  getSelected: g,
1272
1272
  loadAnnotations: u,
1273
1273
  redo: e.redo,
1274
- removeAnnotation: f,
1274
+ removeAnnotation: h,
1275
1275
  setAnnotations: A,
1276
1276
  setSelected: p,
1277
1277
  setUserSelectAction: b,
@@ -1349,19 +1349,19 @@ const No = (t, e) => ({
1349
1349
  styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
1350
1350
  };
1351
1351
  for (const l of a) {
1352
- const g = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, f) => {
1353
- switch (f.type) {
1352
+ const g = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, h) => {
1353
+ switch (h.type) {
1354
1354
  case "TextQuoteSelector":
1355
- u.quote = f.exact;
1355
+ u.quote = h.exact;
1356
1356
  break;
1357
1357
  case "TextPositionSelector":
1358
- u.start = f.start, u.end = f.end;
1358
+ u.start = h.start, u.end = h.end;
1359
1359
  break;
1360
1360
  }
1361
1361
  return u;
1362
1362
  }, {});
1363
- if (Zn(g))
1364
- "outdated" in l && l.outdated, r.selector.push(
1363
+ if (r.outdated || (r.outdated = "outdated" in l ? l.outdated : void 0), Zn(g))
1364
+ r.selector.push(
1365
1365
  {
1366
1366
  ...g,
1367
1367
  id: l.id,
@@ -1401,8 +1401,8 @@ const No = (t, e) => ({
1401
1401
  created: l,
1402
1402
  updated: d,
1403
1403
  ...g
1404
- } = i, u = a.map((f) => {
1405
- const { id: A, quote: p, start: b, end: x, range: m } = f, { prefix: c, suffix: y } = Ue(m, n), C = [{
1404
+ } = i, u = a.map((h) => {
1405
+ const { id: A, quote: p, start: b, end: x, range: m } = h, { prefix: c, suffix: y } = Ue(m, n), C = [{
1406
1406
  type: "TextQuoteSelector",
1407
1407
  exact: p,
1408
1408
  prefix: c,
@@ -1415,10 +1415,8 @@ const No = (t, e) => ({
1415
1415
  return {
1416
1416
  ...g,
1417
1417
  id: A,
1418
- // @ts-expect-error: `outdated` is not part of the core `TextSelector` type
1419
- outdated: "outdated" in f ? f.outdated : void 0,
1420
1418
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1421
- scope: "scope" in f ? f.scope : void 0,
1419
+ scope: "scope" in h ? h.scope : void 0,
1422
1420
  source: e,
1423
1421
  selector: C
1424
1422
  };
@@ -1438,7 +1436,7 @@ const No = (t, e) => ({
1438
1436
  function ve(t, e, n = 0, o = t.length - 1, i = oo) {
1439
1437
  for (; o > n; ) {
1440
1438
  if (o - n > 600) {
1441
- const l = o - n + 1, d = e - n + 1, g = Math.log(l), u = 0.5 * Math.exp(2 * g / 3), f = 0.5 * Math.sqrt(g * u * (l - u) / l) * (d - l / 2 < 0 ? -1 : 1), A = Math.max(n, Math.floor(e - d * u / l + f)), p = Math.min(o, Math.floor(e + (l - d) * u / l + f));
1439
+ const l = o - n + 1, d = e - n + 1, g = Math.log(l), u = 0.5 * Math.exp(2 * g / 3), h = 0.5 * Math.sqrt(g * u * (l - u) / l) * (d - l / 2 < 0 ? -1 : 1), A = Math.max(n, Math.floor(e - d * u / l + h)), p = Math.min(o, Math.floor(e + (l - d) * u / l + h));
1442
1440
  ve(t, e, A, p, i);
1443
1441
  }
1444
1442
  const s = t[e];
@@ -1568,9 +1566,9 @@ class io {
1568
1566
  for (let g = n; g <= o; g += d) {
1569
1567
  const u = Math.min(g + d - 1, o);
1570
1568
  re(e, g, u, l, this.compareMinY);
1571
- for (let f = g; f <= u; f += l) {
1572
- const A = Math.min(f + l - 1, u);
1573
- r.children.push(this._build(e, f, A, i - 1));
1569
+ for (let h = g; h <= u; h += l) {
1570
+ const A = Math.min(h + l - 1, u);
1571
+ r.children.push(this._build(e, h, A, i - 1));
1574
1572
  }
1575
1573
  }
1576
1574
  return Z(r, this.toBBox), r;
@@ -1754,7 +1752,7 @@ const fo = (t, e) => {
1754
1752
  });
1755
1753
  const B = L.flatMap(({ rects: T }) => T);
1756
1754
  n.load(B);
1757
- }, f = (y, C, S = !1) => {
1755
+ }, h = (y, C, S = !1) => {
1758
1756
  const L = n.search({
1759
1757
  minX: y,
1760
1758
  minY: C,
@@ -1779,7 +1777,7 @@ const fo = (t, e) => {
1779
1777
  return {
1780
1778
  all: a,
1781
1779
  clear: r,
1782
- getAt: f,
1780
+ getAt: h,
1783
1781
  getAnnotationBounds: A,
1784
1782
  getAnnotationRects: p,
1785
1783
  getIntersecting: (y, C, S, L) => {
@@ -1818,7 +1816,7 @@ const fo = (t, e) => {
1818
1816
  const C = c.map((S) => vt(S, t));
1819
1817
  n.bulkUpdateTargets(C, y);
1820
1818
  };
1821
- function f(c, y, C, S) {
1819
+ function h(c, y, C, S) {
1822
1820
  const L = C || !!S, B = o.getAt(c, y, L).map((R) => n.getAnnotation(R)), T = S ? B.filter(S) : B;
1823
1821
  if (T.length !== 0)
1824
1822
  return C ? T : T[0];
@@ -1837,7 +1835,7 @@ const fo = (t, e) => {
1837
1835
  getAnnotationBounds: A,
1838
1836
  getAnnotationRects: b,
1839
1837
  getIntersecting: p,
1840
- getAt: f,
1838
+ getAt: h,
1841
1839
  recalculatePositions: x,
1842
1840
  onRecalculatePositions: m,
1843
1841
  updateTarget: g
@@ -1854,7 +1852,7 @@ const fo = (t, e) => {
1854
1852
  }, go = (t, e = {}) => {
1855
1853
  const n = po(), o = n.getContext("2d");
1856
1854
  document.body.appendChild(n);
1857
- const i = /* @__PURE__ */ new Map(), s = (g) => Array.from(i.entries()).filter(([u, f]) => f.presenceKey === g.presenceKey).map(([u, f]) => u);
1855
+ const i = /* @__PURE__ */ new Map(), s = (g) => Array.from(i.entries()).filter(([u, h]) => h.presenceKey === g.presenceKey).map(([u, h]) => u);
1858
1856
  return t.on("selectionChange", (g, u) => {
1859
1857
  s(g).forEach((A) => i.delete(A)), u && u.forEach((A) => i.set(A, g));
1860
1858
  }), {
@@ -1865,7 +1863,7 @@ const fo = (t, e) => {
1865
1863
  destroy: () => {
1866
1864
  n.remove();
1867
1865
  },
1868
- paint: (g, u, f) => {
1866
+ paint: (g, u, h) => {
1869
1867
  e.font && (o.font = e.font);
1870
1868
  const A = i.get(g.annotation.id);
1871
1869
  if (A) {
@@ -1874,7 +1872,7 @@ const fo = (t, e) => {
1874
1872
  const m = o.measureText(A.appearance.label), c = m.width + 6, y = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, C = m.fontBoundingBoxAscent ? 8 : 6.5;
1875
1873
  return o.fillRect(b - 2, x - 2.5 - y, c, y), o.fillStyle = "#fff", o.fillText(A.appearance.label, b + 1, x - C), {
1876
1874
  fill: A.appearance.color,
1877
- fillOpacity: f ? 0.45 : 0.18
1875
+ fillOpacity: h ? 0.45 : 0.18
1878
1876
  };
1879
1877
  }
1880
1878
  },
@@ -2096,11 +2094,11 @@ const At = (t) => {
2096
2094
  const r = a.split(i), l = r.length, d = r[l - 1], g = d === "*" ? "*" : ft(d);
2097
2095
  if (!N[g]) return;
2098
2096
  n || (n = ut());
2099
- const u = l > 1 ? Ee(H, r) : [], f = [];
2097
+ const u = l > 1 ? Ee(H, r) : [], h = [];
2100
2098
  N[g] = N[g].filter((A) => {
2101
2099
  const b = (o ? A.method === o : !0) && A.scope === n && mo(A.mods, u);
2102
- return b && f.push(A.element), !b;
2103
- }), f.forEach((A) => jt(A));
2100
+ return b && h.push(A.element), !b;
2101
+ }), h.forEach((A) => jt(A));
2104
2102
  });
2105
2103
  };
2106
2104
  function ae(t, e, n, o) {
@@ -2141,16 +2139,16 @@ function ce(t, e) {
2141
2139
  const l = s[r], {
2142
2140
  splitKey: d
2143
2141
  } = l, g = l.key.split(d), u = [];
2144
- for (let f = 0; f < g.length; f++)
2145
- u.push(ft(g[f]));
2142
+ for (let h = 0; h < g.length; h++)
2143
+ u.push(ft(g[h]));
2146
2144
  u.sort().join("") === I.sort().join("") && ae(t, l, i, e);
2147
2145
  }
2148
2146
  }
2149
2147
  function X(t, e, n) {
2150
2148
  I = [];
2151
2149
  const o = Se(t);
2152
- let i = [], s = "all", a = document, r = 0, l = !1, d = !0, g = "+", u = !1, f = !1;
2153
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (d = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (g = e.splitKey), e.single === !0 && (f = !0)), typeof e == "string" && (s = e), f && Te(t, s); r < o.length; r++)
2150
+ let i = [], s = "all", a = document, r = 0, l = !1, d = !0, g = "+", u = !1, h = !1;
2151
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (d = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (g = e.splitKey), e.single === !0 && (h = !0)), typeof e == "string" && (s = e), h && Te(t, s); r < o.length; r++)
2154
2152
  t = o[r].split(g), i = [], t.length > 1 && (i = Ee(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ft(t), t in N || (N[t] = []), N[t].push({
2155
2153
  keyup: l,
2156
2154
  keydown: d,
@@ -2260,111 +2258,111 @@ const le = 300, Oe = ["up", "down", "left", "right"], Be = ke ? "⌘+a" : "ctrl+
2260
2258
  ], Bo = (t, e, n) => {
2261
2259
  const { store: o, selection: i } = e;
2262
2260
  let s;
2263
- const { annotatingEnabled: a, offsetReferenceSelector: r, selectionMode: l } = n, d = (h) => s = h;
2261
+ const { annotatingEnabled: a, offsetReferenceSelector: r, selectionMode: l } = n, d = (f) => s = f;
2264
2262
  let g;
2265
- const u = (h) => g = h;
2266
- let f, A, p, b = a;
2267
- const x = (h) => {
2268
- b = h, c.clear(), h || (f = void 0, A = void 0, p = void 0);
2269
- }, m = (h) => {
2270
- b && A !== !1 && (f = st(h.target) ? void 0 : {
2263
+ const u = (f) => g = f;
2264
+ let h, A, p, b = a;
2265
+ const x = (f) => {
2266
+ b = f, c.clear(), f || (h = void 0, A = void 0, p = void 0);
2267
+ }, m = (f) => {
2268
+ b && A !== !1 && (h = st(f.target) ? void 0 : {
2271
2269
  annotation: be(),
2272
2270
  selector: [],
2273
2271
  creator: s,
2274
2272
  created: /* @__PURE__ */ new Date()
2275
2273
  });
2276
- }, c = Xt((h) => {
2274
+ }, c = Xt((f) => {
2277
2275
  if (!b) return;
2278
2276
  const E = document.getSelection();
2279
2277
  if (!(E != null && E.anchorNode))
2280
2278
  return;
2281
2279
  if (st(E.anchorNode)) {
2282
- f = void 0;
2280
+ h = void 0;
2283
2281
  return;
2284
2282
  }
2285
- const M = h.timeStamp - ((p == null ? void 0 : p.timeStamp) || h.timeStamp);
2286
- if ((p == null ? void 0 : p.type) === "pointerdown" && (M < 1e3 && !f || E.isCollapsed && M < le) && m(p || h), !f) return;
2283
+ const M = f.timeStamp - ((p == null ? void 0 : p.timeStamp) || f.timeStamp);
2284
+ if ((p == null ? void 0 : p.type) === "pointerdown" && (M < 1e3 && !h || E.isCollapsed && M < le) && m(p || f), !h) return;
2287
2285
  if (E.isCollapsed) {
2288
- o.getAnnotation(f.annotation) && (i.clear(), o.deleteAnnotation(f.annotation));
2286
+ o.getAnnotation(h.annotation) && (i.clear(), o.deleteAnnotation(h.annotation));
2289
2287
  return;
2290
2288
  }
2291
2289
  const O = E.getRangeAt(0), U = He(O, t);
2292
2290
  if (Ve(U)) return;
2293
2291
  const _ = _e(U.cloneRange());
2294
- (_.length !== f.selector.length || _.some((W, G) => {
2292
+ (_.length !== h.selector.length || _.some((W, G) => {
2295
2293
  var St;
2296
- return W.toString() !== ((St = f.selector[G]) == null ? void 0 : St.quote);
2297
- })) && (f = {
2298
- ...f,
2294
+ return W.toString() !== ((St = h.selector[G]) == null ? void 0 : St.quote);
2295
+ })) && (h = {
2296
+ ...h,
2299
2297
  selector: _.map((W) => Xe(W, t, r)),
2300
2298
  updated: /* @__PURE__ */ new Date()
2301
- }, o.getAnnotation(f.annotation) ? o.updateTarget(f, k.LOCAL) : i.clear());
2302
- }, 10), y = (h) => {
2303
- st(h.target) || (p = Lt(h), A = p.button === 0);
2304
- }, C = async (h) => {
2305
- if (st(h.target) || !A) return;
2299
+ }, o.getAnnotation(h.annotation) ? o.updateTarget(h, k.LOCAL) : i.clear());
2300
+ }, 10), y = (f) => {
2301
+ st(f.target) || (p = Lt(f), A = p.button === 0);
2302
+ }, C = async (f) => {
2303
+ if (st(f.target) || !A) return;
2306
2304
  const E = () => {
2307
- const { x: O, y: U } = t.getBoundingClientRect(), _ = h.target instanceof Node && t.contains(h.target) && o.getAt(h.clientX - O, h.clientY - U, l === "all", g);
2305
+ const { x: O, y: U } = t.getBoundingClientRect(), _ = f.target instanceof Node && t.contains(f.target) && o.getAt(f.clientX - O, f.clientY - U, l === "all", g);
2308
2306
  if (_) {
2309
2307
  const { selected: ht } = i, W = new Set(ht.map((nt) => nt.id)), G = Array.isArray(_) ? _.map((nt) => nt.id) : [_.id];
2310
- (W.size !== G.length || !G.every((nt) => W.has(nt))) && i.userSelect(G, h);
2308
+ (W.size !== G.length || !G.every((nt) => W.has(nt))) && i.userSelect(G, f);
2311
2309
  } else
2312
2310
  i.clear();
2313
2311
  };
2314
- if (h.timeStamp - p.timeStamp < le) {
2312
+ if (f.timeStamp - p.timeStamp < le) {
2315
2313
  await S();
2316
2314
  const O = document.getSelection();
2317
2315
  if (O != null && O.isCollapsed) {
2318
- f = void 0, E();
2316
+ h = void 0, E();
2319
2317
  return;
2320
2318
  }
2321
2319
  }
2322
- f && f.selector.length > 0 && (w(), i.userSelect(f.annotation, Lt(h)));
2320
+ h && h.selector.length > 0 && (w(), i.userSelect(h.annotation, Lt(f)));
2323
2321
  }, S = async () => {
2324
- const h = document.getSelection();
2325
- let E = !1, M = h == null ? void 0 : h.isCollapsed;
2322
+ const f = document.getSelection();
2323
+ let E = !1, M = f == null ? void 0 : f.isCollapsed;
2326
2324
  const O = () => M || E, U = 1;
2327
- return setTimeout(() => E = !0, 50), To(() => M = h == null ? void 0 : h.isCollapsed, U, O);
2328
- }, L = (h) => {
2325
+ return setTimeout(() => E = !0, 50), To(() => M = f == null ? void 0 : f.isCollapsed, U, O);
2326
+ }, L = (f) => {
2329
2327
  const E = document.getSelection();
2330
- E != null && E.isCollapsed || ((!f || f.selector.length === 0) && c(h), w(), i.userSelect(f.annotation, Lt(h)));
2331
- }, B = (h) => {
2332
- b && h.key === "Shift" && f && (document.getSelection().isCollapsed || (w(), i.userSelect(f.annotation, pt(h))));
2333
- }, T = (h) => {
2328
+ E != null && E.isCollapsed || ((!h || h.selector.length === 0) && c(f), w(), i.userSelect(h.annotation, Lt(f)));
2329
+ }, B = (f) => {
2330
+ b && f.key === "Shift" && h && (document.getSelection().isCollapsed || (w(), i.userSelect(h.annotation, pt(f))));
2331
+ }, T = (f) => {
2334
2332
  const E = () => setTimeout(() => {
2335
- (f == null ? void 0 : f.selector.length) > 0 && (i.clear(), o.addAnnotation({
2336
- id: f.annotation,
2333
+ (h == null ? void 0 : h.selector.length) > 0 && (i.clear(), o.addAnnotation({
2334
+ id: h.annotation,
2337
2335
  bodies: [],
2338
- target: f
2339
- }), i.userSelect(f.annotation, pt(h))), document.removeEventListener("selectionchange", E);
2336
+ target: h
2337
+ }), i.userSelect(h.annotation, pt(f))), document.removeEventListener("selectionchange", E);
2340
2338
  }, 100);
2341
- document.addEventListener("selectionchange", E), m(h);
2339
+ document.addEventListener("selectionchange", E), m(f);
2342
2340
  };
2343
- X(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (h) => {
2344
- h.repeat || (p = pt(h));
2345
- }), X(Be, { keydown: !0, keyup: !1 }, (h) => {
2346
- p = pt(h), T(h);
2341
+ X(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (f) => {
2342
+ f.repeat || (p = pt(f));
2343
+ }), X(Be, { keydown: !0, keyup: !1 }, (f) => {
2344
+ p = pt(f), T(f);
2347
2345
  });
2348
- const R = (h) => {
2349
- h.repeat || h.target !== t && h.target !== document.body || (f = void 0, i.clear());
2346
+ const R = (f) => {
2347
+ f.repeat || f.target !== t && f.target !== document.body || (h = void 0, i.clear());
2350
2348
  };
2351
2349
  X(Oe.join(","), { keydown: !0, keyup: !1 }, R);
2352
2350
  const w = () => {
2353
- const h = o.getAnnotation(f.annotation);
2354
- if (!h) {
2351
+ const f = o.getAnnotation(h.annotation);
2352
+ if (!f) {
2355
2353
  o.addAnnotation({
2356
- id: f.annotation,
2354
+ id: h.annotation,
2357
2355
  bodies: [],
2358
- target: f
2356
+ target: h
2359
2357
  });
2360
2358
  return;
2361
2359
  }
2362
- const { target: { updated: E } } = h, { updated: M } = f;
2363
- (!E || !M || E < M) && o.updateTarget(f);
2360
+ const { target: { updated: E } } = f, { updated: M } = h;
2361
+ (!E || !M || E < M) && o.updateTarget(h);
2364
2362
  };
2365
2363
  return document.addEventListener("pointerdown", y), document.addEventListener("pointerup", C), document.addEventListener("contextmenu", L), t.addEventListener("keyup", B), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", c), {
2366
2364
  destroy: () => {
2367
- f = void 0, A = void 0, p = void 0, c.clear(), document.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", C), document.removeEventListener("contextmenu", L), t.removeEventListener("keyup", B), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", c), X.unbind();
2365
+ h = void 0, A = void 0, p = void 0, c.clear(), document.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", C), document.removeEventListener("contextmenu", L), t.removeEventListener("keyup", B), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", c), X.unbind();
2368
2366
  },
2369
2367
  setFilter: u,
2370
2368
  setUser: d,
@@ -2385,16 +2383,16 @@ const le = 300, Oe = ["up", "down", "left", "right"], Be = ke ? "⌘+a" : "ctrl+
2385
2383
  if (!u)
2386
2384
  throw `Unknown renderer implementation: ${g}`;
2387
2385
  console.debug(`Using ${g} renderer`), n.style && u.setStyle(n.style);
2388
- const f = Bo(t, o, n);
2389
- f.setUser(d), f.setAnnotatingEnabled(n.annotatingEnabled);
2386
+ const h = Bo(t, o, n);
2387
+ h.setUser(d), h.setAnnotatingEnabled(n.annotatingEnabled);
2390
2388
  const A = $n(o, r, n.adapter), p = () => d, b = (S) => {
2391
- f.setAnnotatingEnabled(
2389
+ h.setAnnotatingEnabled(
2392
2390
  S === void 0 ? !0 : S
2393
2391
  );
2394
2392
  }, x = (S) => {
2395
- u.setFilter(S), f.setFilter(S);
2393
+ u.setFilter(S), h.setFilter(S);
2396
2394
  }, m = (S) => {
2397
- d = S, f.setUser(S);
2395
+ d = S, h.setUser(S);
2398
2396
  }, c = (S) => {
2399
2397
  S && (u.setPainter(go(S, n.presence)), S.on("selectionChange", () => u.redraw()));
2400
2398
  }, y = (S) => {
@@ -2403,7 +2401,7 @@ const le = 300, Oe = ["up", "down", "left", "right"], Be = ke ? "⌘+a" : "ctrl+
2403
2401
  return {
2404
2402
  ...A,
2405
2403
  destroy: () => {
2406
- u.destroy(), f.destroy(), r.destroy();
2404
+ u.destroy(), h.destroy(), r.destroy();
2407
2405
  },
2408
2406
  element: t,
2409
2407
  getUser: p,