@soomo/text-annotator 3.2.0-staging.7 → 3.2.0-staging.9

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.
@@ -2,21 +2,21 @@ import Q from "debounce";
2
2
  import { colord as nt } from "colord";
3
3
  import { dequal as dt } from "dequal/lite";
4
4
  import { v4 as ot } from "uuid";
5
- import { serializeW3CBodies as ut, parseW3CBodies as ft, parseW3CUser as gt, createStore as mt, createSelectionState as pt, createHoverState as ht, createViewportState as yt, Origin as $, createAnonymousGuest as bt, createUndoStack as St, createLifecycleObserver as Ct, createBaseAnnotator as Et } from "@annotorious/core";
5
+ import { serializeW3CBodies as ut, parseW3CBodies as ft, parseW3CUser as gt, createStore as mt, createSelectionState as pt, createHoverState as ht, createViewportState as yt, Origin as _, createAnonymousGuest as bt, createUndoStack as St, createLifecycleObserver as Ct, createBaseAnnotator as Et } from "@annotorious/core";
6
6
  import { Origin as Re, UserSelectAction as Le, createBody as ke } from "@annotorious/core";
7
7
  import wt from "rbush";
8
8
  import { createNanoEvents as At } from "nanoevents";
9
- import W from "hotkeys-js";
9
+ import V from "hotkeys-js";
10
10
  import { poll as vt } from "poll";
11
- const st = "not-annotatable", _ = `.${st}`, F = (t) => {
11
+ const st = "not-annotatable", D = `.${st}`, W = (t) => {
12
12
  var e;
13
- return !!(t instanceof HTMLElement ? t.closest(_) : (e = t.parentElement) == null ? void 0 : e.closest(_));
13
+ return !!(t instanceof HTMLElement ? t.closest(D) : (e = t.parentElement) == null ? void 0 : e.closest(D));
14
14
  }, xt = (t) => {
15
15
  const n = t.commonAncestorContainer;
16
- return !F(n);
16
+ return !W(n);
17
17
  }, Tt = (t) => t.addEventListener("click", (n) => {
18
18
  // Allow clicks within not-annotatable elements
19
- !n.target.closest(_) && !n.target.closest("a") && n.preventDefault();
19
+ !n.target.closest(D) && !n.target.closest("a") && n.preventDefault();
20
20
  }), Rt = typeof navigator < "u" && // @ts-ignore
21
21
  /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Lt = (t) => {
22
22
  !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
@@ -24,7 +24,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
24
24
  const n = document.createNodeIterator(
25
25
  t.commonAncestorContainer,
26
26
  NodeFilter.SHOW_ELEMENT,
27
- (o) => o instanceof HTMLElement && o.classList.contains(st) && !o.parentElement.closest(_) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
27
+ (o) => o instanceof HTMLElement && o.classList.contains(st) && !o.parentElement.closest(D) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
28
28
  );
29
29
  let e;
30
30
  for (; e = n.nextNode(); )
@@ -44,7 +44,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
44
44
  return n.length > 0 ? n : [t];
45
45
  }, G = (t) => {
46
46
  const n = t.cloneContents();
47
- return n.querySelectorAll(_).forEach((e) => e.remove()), n;
47
+ return n.querySelectorAll(D).forEach((e) => e.remove()), n;
48
48
  }, Nt = (t, n, e = 10, o) => {
49
49
  const s = o ? t.startContainer.parentElement.closest(o) : n, i = document.createRange();
50
50
  i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
@@ -55,7 +55,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
55
55
  prefix: a.substring(a.length - e),
56
56
  suffix: u.substring(0, e)
57
57
  };
58
- }, I = (t) => t.every((n) => n.range instanceof Range && !n.range.collapsed), Ot = /^\s*$/, It = (t) => Ot.test(t.toString()), Mt = (t, n) => {
58
+ }, M = (t) => t.every((n) => n.range instanceof Range && !n.range.collapsed), Ot = /^\s*$/, It = (t) => Ot.test(t.toString()), Mt = (t, n) => {
59
59
  const e = (i) => Math.round(i * 10) / 10, o = {
60
60
  top: e(t.top),
61
61
  bottom: e(t.bottom),
@@ -121,17 +121,17 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
121
121
  n,
122
122
  NodeFilter.SHOW_TEXT,
123
123
  (r) => {
124
- var w;
125
- return (w = r.parentElement) != null && w.closest(_) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
124
+ var A;
125
+ return (A = r.parentElement) != null && A.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
126
126
  }
127
127
  );
128
128
  let a = 0;
129
129
  const c = document.createRange();
130
130
  let u = i.nextNode();
131
131
  u === null && console.error("Could not revive annotation target. Content missing.");
132
- let S = !s;
132
+ let b = !s;
133
133
  for (; u !== null; ) {
134
- if (S || (S = typeof (s == null ? void 0 : s.contains) == "function" ? s.contains(u) : !1), S) {
134
+ if (b || (b = typeof (s == null ? void 0 : s.contains) == "function" ? s.contains(u) : !1), b) {
135
135
  const r = ((y = u.textContent) == null ? void 0 : y.length) || 0;
136
136
  if (a + r > e) {
137
137
  c.setStart(u, e - a);
@@ -153,10 +153,10 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
153
153
  ...t,
154
154
  range: c
155
155
  };
156
- }, Y = (t, n) => I(t.selector) ? t : {
156
+ }, X = (t, n) => M(t.selector) ? t : {
157
157
  ...t,
158
158
  selector: t.selector.map((e) => e.range instanceof Range && !e.range.collapsed ? e : rt(e, n))
159
- }, q = (t, n) => I(t.target.selector) ? t : { ...t, target: Y(t.target, n) }, it = (t, n) => {
159
+ }, q = (t, n) => M(t.target.selector) ? t : { ...t, target: X(t.target, n) }, it = (t, n) => {
160
160
  if (t.isEqualNode(n))
161
161
  return !0;
162
162
  for (let e of t.childNodes)
@@ -195,7 +195,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
195
195
  pointerId: t.pointerId,
196
196
  pointerType: t.pointerType,
197
197
  timeStamp: t.timeStamp
198
- }), V = (t) => ({
198
+ }), Y = (t) => ({
199
199
  ...t,
200
200
  type: t.type,
201
201
  key: t.key,
@@ -223,8 +223,8 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
223
223
  const { overflowY: n } = window.getComputedStyle(t);
224
224
  return n !== "visible" && n !== "hidden" && t.scrollHeight > t.clientHeight ? t : at(t.parentElement);
225
225
  }, J = (t, n, e) => {
226
- const o = e.getBoundingClientRect(), s = e.clientHeight, i = e.clientWidth, a = n.selector[0].range.getBoundingClientRect(), { width: c, height: u } = t.getAnnotationBounds(n.annotation), S = a.top - o.top, y = a.left - o.left, g = e.parentElement ? e.scrollTop : 0, r = e.parentElement ? e.scrollLeft : 0, w = S + g - (s - u) / 2, C = y + r - (i - c) / 2;
227
- e.scroll({ top: w, left: C, behavior: "smooth" });
226
+ const o = e.getBoundingClientRect(), s = e.clientHeight, i = e.clientWidth, a = n.selector[0].range.getBoundingClientRect(), { width: c, height: u } = t.getAnnotationBounds(n.annotation), b = a.top - o.top, y = a.left - o.left, g = e.parentElement ? e.scrollTop : 0, r = e.parentElement ? e.scrollLeft : 0, A = b + g - (s - u) / 2, S = y + r - (i - c) / 2;
227
+ e.scroll({ top: A, left: S, behavior: "smooth" });
228
228
  }, Ft = (t, n) => (e, o) => {
229
229
  const s = typeof e == "string" ? e : e.id, i = o ? typeof o == "string" ? document.getElementById(o) : o : at(t);
230
230
  if (!i)
@@ -235,17 +235,17 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
235
235
  const { range: c } = a.target.selector[0];
236
236
  if (c && !c.collapsed)
237
237
  return J(n, a.target, i), !0;
238
- const u = Y(a.target, t), { range: S } = u.selector[0];
239
- return S && !S.collapsed ? (J(n, u, i), !0) : !1;
240
- }, P = {
238
+ const u = X(a.target, t), { range: b } = u.selector[0];
239
+ return b && !b.collapsed ? (J(n, u, i), !0) : !1;
240
+ }, K = {
241
241
  fill: "rgb(0, 128, 255)",
242
242
  fillOpacity: 0.18
243
- }, X = {
243
+ }, z = {
244
244
  fill: "rgb(0, 128, 255)",
245
245
  fillOpacity: 0.45
246
246
  }, Ut = (t, n, e, o, s) => {
247
247
  var a, c;
248
- const i = e ? typeof e == "function" ? e(t.annotation, t.state, s) || ((a = t.state) != null && a.selected ? X : P) : e : (c = t.state) != null && c.selected ? X : P;
248
+ const i = e ? typeof e == "function" ? e(t.annotation, t.state, s) || ((a = t.state) != null && a.selected ? z : K) : e : (c = t.state) != null && c.selected ? z : K;
249
249
  return o && o.paint(t, n) || i;
250
250
  }, Wt = (t) => {
251
251
  const { top: n, left: e } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: s } = window, i = -e, a = -n, c = o - e, u = s - n;
@@ -258,46 +258,50 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
258
258
  };
259
259
  }, Z = (t, n, e, o) => {
260
260
  const { store: s, selection: i, hover: a } = n;
261
- let c, u, S;
262
- const y = Vt(e), g = (b) => {
263
- const { x: v, y: L } = t.getBoundingClientRect(), O = s.getAt(b.clientX - v, b.clientY - L, !1, u);
264
- O ? a.current !== O.id && (t.classList.add("hovered"), a.set(O.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
261
+ let c, u, b;
262
+ const y = Vt(e), g = (E) => {
263
+ const { x: L, y: I } = t.getBoundingClientRect(), p = s.getAt(E.clientX - L, E.clientY - I, !1, u);
264
+ p ? a.current !== p.id && (t.classList.add("hovered"), a.set(p.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
265
265
  };
266
266
  t.addEventListener("pointermove", g);
267
- const r = (b = !1) => {
268
- S && S.clear();
269
- const v = Wt(t), { minX: L, minY: O, maxX: p, maxY: R } = v, B = u ? s.getIntersecting(L, O, p, R).filter(({ annotation: k }) => u(k)) : s.getIntersecting(L, O, p, R), N = i.selected.map(({ id: k }) => k), M = B.map(({ annotation: k, rects: U }) => {
270
- const H = N.includes(k.id), K = k.id === a.current;
271
- return { annotation: k, rects: U, state: { selected: H, hover: K } };
267
+ const r = (E = !1) => {
268
+ b && b.clear();
269
+ const L = Wt(t), { minX: I, minY: p, maxX: R, maxY: k } = L, B = u ? s.getIntersecting(I, p, R, k).filter(({ annotation: N }) => u(N)) : s.getIntersecting(I, p, R, k), H = i.selected.map(({ id: N }) => N), O = B.map(({ annotation: N, rects: P }) => {
270
+ const $ = H.includes(N.id), F = N.id === a.current;
271
+ return {
272
+ annotation: N,
273
+ rects: P,
274
+ state: { selected: $, hovered: F }
275
+ };
272
276
  });
273
- o.redraw(M, v, c, S, b), setTimeout(() => y(B.map(({ annotation: k }) => k)), 1);
274
- }, w = (b) => {
275
- S = b, r();
276
- }, C = (b) => {
277
- c = b, r();
278
- }, T = (b) => {
279
- u = b, r(!1);
277
+ o.redraw(O, L, c, b, E), setTimeout(() => y(B.map(({ annotation: N }) => N)), 1);
278
+ }, A = (E) => {
279
+ b = E, r();
280
+ }, S = (E) => {
281
+ c = E, r();
282
+ }, T = (E) => {
283
+ u = E, r(!1);
280
284
  }, x = () => r();
281
285
  s.observe(x);
282
- const E = i.subscribe(() => r()), f = () => r(!0);
283
- document.addEventListener("scroll", f, { capture: !0, passive: !0 });
284
- const l = Q(() => {
285
- s.recalculatePositions(), S == null || S.reset(), r();
286
+ const C = i.subscribe(() => r()), m = a.subscribe(() => r()), d = () => r(!0);
287
+ document.addEventListener("scroll", d, { capture: !0, passive: !0 });
288
+ const f = Q(() => {
289
+ s.recalculatePositions(), b == null || b.reset(), r();
286
290
  }, 10);
287
- window.addEventListener("resize", l);
288
- const m = new ResizeObserver(l);
289
- m.observe(t);
290
- const d = { attributes: !0, childList: !0, subtree: !0 }, h = new MutationObserver((b) => {
291
- b.every((L) => L.target === t || t.contains(L.target)) || r(!0);
291
+ window.addEventListener("resize", f);
292
+ const l = new ResizeObserver(f);
293
+ l.observe(t);
294
+ const h = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver((E) => {
295
+ E.every((I) => I.target === t || t.contains(I.target)) || r(!0);
292
296
  });
293
- return h.observe(document.body, d), {
297
+ return w.observe(document.body, h), {
294
298
  destroy: () => {
295
- t.removeEventListener("pointermove", g), o.destroy(), s.unobserve(x), E(), document.removeEventListener("scroll", f), l.clear(), window.removeEventListener("resize", l), m.disconnect(), h.disconnect();
299
+ t.removeEventListener("pointermove", g), o.destroy(), s.unobserve(x), C(), m(), document.removeEventListener("scroll", d), f.clear(), window.removeEventListener("resize", f), l.disconnect(), w.disconnect();
296
300
  },
297
301
  redraw: r,
298
- setStyle: C,
302
+ setStyle: S,
299
303
  setFilter: T,
300
- setPainter: w,
304
+ setPainter: A,
301
305
  setVisible: o.setVisible
302
306
  };
303
307
  }, Yt = () => {
@@ -309,28 +313,28 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
309
313
  t.classList.add("r6o-annotatable");
310
314
  const n = Yt(), e = n.getContext("2d");
311
315
  document.body.appendChild(n);
312
- const o = (c, u, S, y) => requestAnimationFrame(() => {
316
+ const o = (c, u, b, y) => requestAnimationFrame(() => {
313
317
  const { width: g, height: r } = n;
314
318
  e.clearRect(-0.5, -0.5, g + 1, r + 1), y && y.clear();
315
- const { top: w, left: C } = u;
316
- [...c].sort((x, E) => {
317
- const { annotation: { target: { created: f } } } = x, { annotation: { target: { created: l } } } = E;
318
- return f.getTime() - l.getTime();
319
+ const { top: A, left: S } = u;
320
+ [...c].sort((x, C) => {
321
+ const { annotation: { target: { created: m } } } = x, { annotation: { target: { created: d } } } = C;
322
+ return m.getTime() - d.getTime();
319
323
  }).forEach((x) => {
320
- var m;
321
- const E = S ? typeof S == "function" ? S(x.annotation, x.state) : S : (m = x.state) != null && m.selected ? X : P, f = y && y.paint(x, u) || E, l = x.rects.map(({ x: d, y: h, width: A, height: b }) => ({
322
- x: d + C,
323
- y: h + w,
324
- width: A,
325
- height: b
324
+ var f;
325
+ const C = b ? typeof b == "function" ? b(x.annotation, x.state) : b : (f = x.state) != null && f.selected ? z : K, m = y && y.paint(x, u) || C, d = x.rects.map(({ x: l, y: h, width: w, height: v }) => ({
326
+ x: l + S,
327
+ y: h + A,
328
+ width: w,
329
+ height: v
326
330
  }));
327
- if (e.fillStyle = f.fill, e.globalAlpha = f.fillOpacity || 1, l.forEach(
328
- ({ x: d, y: h, width: A, height: b }) => e.fillRect(d, h, A, b)
329
- ), f.underlineColor) {
330
- e.globalAlpha = 1, e.strokeStyle = f.underlineColor, e.lineWidth = f.underlineThickness ?? 1;
331
- const d = f.underlineOffset ?? 0;
332
- l.forEach(({ x: h, y: A, width: b, height: v }) => {
333
- e.beginPath(), e.moveTo(h, A + v + d), e.lineTo(h + b, A + v + d), e.stroke();
331
+ if (e.fillStyle = m.fill, e.globalAlpha = m.fillOpacity || 1, d.forEach(
332
+ ({ x: l, y: h, width: w, height: v }) => e.fillRect(l, h, w, v)
333
+ ), m.underlineColor) {
334
+ e.globalAlpha = 1, e.strokeStyle = m.underlineColor, e.lineWidth = m.underlineThickness ?? 1;
335
+ const l = m.underlineOffset ?? 0;
336
+ d.forEach(({ x: h, y: w, width: v, height: E }) => {
337
+ e.beginPath(), e.moveTo(h, w + E + l), e.lineTo(h + v, w + E + l), e.stroke();
334
338
  });
335
339
  }
336
340
  });
@@ -345,7 +349,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
345
349
  redraw: o
346
350
  };
347
351
  }, qt = (t, n, e) => Z(t, n, e, zt(t)), jt = (t) => [
348
- `background-color:${nt((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
352
+ `background-color:${nt((t == null ? void 0 : t.fill) || K.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? K.fillOpacity : t.fillOpacity).toHex()}`,
349
353
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
350
354
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
351
355
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
@@ -363,18 +367,18 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
363
367
  },
364
368
  redraw: (i, a, c, u) => {
365
369
  u && u.clear();
366
- const S = new Set(i.map((g) => g.annotation.id));
367
- Array.from(n).filter((g) => !S.has(g));
370
+ const b = new Set(i.map((g) => g.annotation.id));
371
+ Array.from(n).filter((g) => !b.has(g));
368
372
  const y = i.map((g) => {
369
- var C;
370
- const r = c ? typeof c == "function" ? c(g.annotation, g.state) : c : (C = g.state) != null && C.selected ? X : P, w = u && u.paint(g, a) || r;
371
- return `::highlight(_${g.annotation.id}) { ${jt(w)} }`;
373
+ var S;
374
+ const r = c ? typeof c == "function" ? c(g.annotation, g.state) : c : (S = g.state) != null && S.selected ? z : K, A = u && u.paint(g, a) || r;
375
+ return `::highlight(_${g.annotation.id}) { ${jt(A)} }`;
372
376
  });
373
377
  t.innerHTML = y.join(`
374
378
  `), CSS.highlights.clear(), i.forEach(({ annotation: g }) => {
375
- const r = g.target.selector.map((C) => C.range), w = new Highlight(...r);
376
- CSS.highlights.set(`_${g.id}`, w);
377
- }), n = S;
379
+ const r = g.target.selector.map((S) => S.range), A = new Highlight(...r);
380
+ CSS.highlights.set(`_${g.id}`, A);
381
+ }), n = b;
378
382
  }
379
383
  };
380
384
  }, Qt = (t, n, e) => Z(t, n, e, Gt()), Zt = (t, n) => {
@@ -389,18 +393,18 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
389
393
  destroy: () => {
390
394
  n.remove();
391
395
  },
392
- redraw: (a, c, u, S, y) => {
396
+ redraw: (a, c, u, b, y) => {
393
397
  const r = !(dt(e, a) && y);
394
- if (!S && !r) return;
395
- r && (n.innerHTML = ""), [...a].sort((C, T) => {
396
- const { annotation: { target: { created: x } } } = C, { annotation: { target: { created: E } } } = T;
397
- return x && E ? x.getTime() - E.getTime() : 0;
398
- }).forEach((C) => {
399
- C.rects.map((T) => {
400
- const x = Zt(T, a), E = Ut(C, c, u, S, x);
398
+ if (!b && !r) return;
399
+ r && (n.innerHTML = ""), [...a].sort((S, T) => {
400
+ const { annotation: { target: { created: x } } } = S, { annotation: { target: { created: C } } } = T;
401
+ return x && C ? x.getTime() - C.getTime() : 0;
402
+ }).forEach((S) => {
403
+ S.rects.map((T) => {
404
+ const x = Zt(T, a), C = Ut(S, c, u, b, x);
401
405
  if (r) {
402
- const f = document.createElement("span");
403
- f.className = "r6o-annotation", f.dataset.annotation = C.annotation.id, f.style.left = `${T.x}px`, f.style.top = `${T.y}px`, f.style.width = `${T.width}px`, f.style.height = `${T.height}px`, f.style.backgroundColor = nt((E == null ? void 0 : E.fill) || P.fill).alpha((E == null ? void 0 : E.fillOpacity) === void 0 ? P.fillOpacity : E.fillOpacity).toHex(), E.underlineStyle && (f.style.borderStyle = E.underlineStyle), E.underlineColor && (f.style.borderColor = E.underlineColor), E.underlineThickness && (f.style.borderBottomWidth = `${E.underlineThickness}px`), E.underlineOffset && (f.style.paddingBottom = `${E.underlineOffset}px`), n.appendChild(f);
406
+ const m = document.createElement("span");
407
+ m.className = "r6o-annotation", m.dataset.annotation = S.annotation.id, m.style.left = `${T.x}px`, m.style.top = `${T.y}px`, m.style.width = `${T.width}px`, m.style.height = `${T.height}px`, m.style.backgroundColor = nt((C == null ? void 0 : C.fill) || K.fill).alpha((C == null ? void 0 : C.fillOpacity) === void 0 ? K.fillOpacity : C.fillOpacity).toHex(), C.underlineStyle && (m.style.borderStyle = C.underlineStyle), C.underlineColor && (m.style.borderColor = C.underlineColor), C.underlineThickness && (m.style.borderBottomWidth = `${C.underlineThickness}px`), C.underlineOffset && (m.style.paddingBottom = `${C.underlineOffset}px`), n.appendChild(m);
404
408
  }
405
409
  });
406
410
  }), e = a;
@@ -482,29 +486,29 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
482
486
  selector: a,
483
487
  creator: c,
484
488
  created: u,
485
- updated: S,
489
+ updated: b,
486
490
  ...y
487
491
  } = s, g = a.map((r) => {
488
- const { id: w, quote: C, start: T, end: x, range: E } = r, f = {
492
+ const { id: A, quote: S, start: T, end: x, range: C } = r, m = {
489
493
  type: "TextQuoteSelector",
490
- exact: C
494
+ exact: S
491
495
  };
492
496
  if (e) {
493
- const { prefix: m, suffix: d } = Nt(E, e);
494
- f.prefix = m, f.suffix = d;
497
+ const { prefix: f, suffix: l } = Nt(C, e);
498
+ m.prefix = f, m.suffix = l;
495
499
  }
496
- const l = {
500
+ const d = {
497
501
  type: "TextPositionSelector",
498
502
  start: T,
499
503
  end: x
500
504
  };
501
505
  return {
502
506
  ...y,
503
- id: w,
507
+ id: A,
504
508
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
505
509
  scope: "scope" in r ? r.scope : void 0,
506
510
  source: n,
507
- selector: [f, l]
511
+ selector: [m, d]
508
512
  };
509
513
  });
510
514
  return {
@@ -515,132 +519,132 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
515
519
  body: ut(t.bodies),
516
520
  creator: c,
517
521
  created: u == null ? void 0 : u.toISOString(),
518
- modified: S == null ? void 0 : S.toISOString(),
522
+ modified: b == null ? void 0 : b.toISOString(),
519
523
  target: g
520
524
  };
521
525
  }, re = (t, n) => {
522
- const e = new wt(), o = /* @__PURE__ */ new Map(), s = At(), i = (l, m) => {
523
- const d = l.selector.flatMap((A) => {
524
- const b = I([A]) ? A.range : rt(A, n).range;
525
- return Array.from(b.getClientRects());
526
- }), h = Pt(d).map((A) => Dt(A, m));
527
- return h.map((A) => {
528
- const { x: b, y: v, width: L, height: O } = A;
526
+ const e = new wt(), o = /* @__PURE__ */ new Map(), s = At(), i = (d, f) => {
527
+ const l = d.selector.flatMap((w) => {
528
+ const v = M([w]) ? w.range : rt(w, n).range;
529
+ return Array.from(v.getClientRects());
530
+ }), h = Pt(l).map((w) => Dt(w, f));
531
+ return h.map((w) => {
532
+ const { x: v, y: E, width: L, height: I } = w;
529
533
  return {
530
- minX: b,
531
- minY: v,
532
- maxX: b + L,
533
- maxY: v + O,
534
+ minX: v,
535
+ minY: E,
536
+ maxX: v + L,
537
+ maxY: E + I,
534
538
  annotation: {
535
- id: l.annotation,
539
+ id: d.annotation,
536
540
  rects: h
537
541
  }
538
542
  };
539
543
  });
540
544
  }, a = () => [...o.values()], c = () => {
541
545
  e.clear(), o.clear();
542
- }, u = (l) => {
543
- const m = i(l, n.getBoundingClientRect());
544
- m.length !== 0 && (m.forEach((d) => e.insert(d)), o.set(l.annotation, m));
545
- }, S = (l) => {
546
- const m = o.get(l.annotation);
547
- m && (m.forEach((d) => e.remove(d)), o.delete(l.annotation));
548
- }, y = (l) => {
549
- S(l), u(l);
550
- }, g = (l, m = !0) => {
551
- m && c();
552
- const d = n.getBoundingClientRect(), h = l.map((b) => ({ target: b, rects: i(b, d) }));
553
- h.forEach(({ target: b, rects: v }) => {
554
- v.length > 0 && o.set(b.annotation, v);
546
+ }, u = (d) => {
547
+ const f = i(d, n.getBoundingClientRect());
548
+ f.length !== 0 && (f.forEach((l) => e.insert(l)), o.set(d.annotation, f));
549
+ }, b = (d) => {
550
+ const f = o.get(d.annotation);
551
+ f && (f.forEach((l) => e.remove(l)), o.delete(d.annotation));
552
+ }, y = (d) => {
553
+ b(d), u(d);
554
+ }, g = (d, f = !0) => {
555
+ f && c();
556
+ const l = n.getBoundingClientRect(), h = d.map((v) => ({ target: v, rects: i(v, l) }));
557
+ h.forEach(({ target: v, rects: E }) => {
558
+ E.length > 0 && o.set(v.annotation, E);
555
559
  });
556
- const A = h.flatMap(({ rects: b }) => b);
557
- e.load(A);
558
- }, r = (l, m, d = !1) => {
560
+ const w = h.flatMap(({ rects: v }) => v);
561
+ e.load(w);
562
+ }, r = (d, f, l = !1) => {
559
563
  const h = e.search({
560
- minX: l,
561
- minY: m,
562
- maxX: l,
563
- maxY: m
564
- }), A = (b) => b.annotation.rects.reduce((v, L) => v + L.width * L.height, 0);
565
- return h.length > 0 ? (h.sort((b, v) => A(b) - A(v)), d ? h.map((b) => b.annotation.id) : [h[0].annotation.id]) : [];
566
- }, w = (l) => {
567
- const m = C(l);
568
- if (m.length === 0)
564
+ minX: d,
565
+ minY: f,
566
+ maxX: d,
567
+ maxY: f
568
+ }), w = (v) => v.annotation.rects.reduce((E, L) => E + L.width * L.height, 0);
569
+ return h.length > 0 ? (h.sort((v, E) => w(v) - w(E)), l ? h.map((v) => v.annotation.id) : [h[0].annotation.id]) : [];
570
+ }, A = (d) => {
571
+ const f = S(d);
572
+ if (f.length === 0)
569
573
  return;
570
- let d = m[0].left, h = m[0].top, A = m[0].right, b = m[0].bottom;
571
- for (let v = 1; v < m.length; v++) {
572
- const L = m[v];
573
- d = Math.min(d, L.left), h = Math.min(h, L.top), A = Math.max(A, L.right), b = Math.max(b, L.bottom);
574
+ let l = f[0].left, h = f[0].top, w = f[0].right, v = f[0].bottom;
575
+ for (let E = 1; E < f.length; E++) {
576
+ const L = f[E];
577
+ l = Math.min(l, L.left), h = Math.min(h, L.top), w = Math.max(w, L.right), v = Math.max(v, L.bottom);
574
578
  }
575
- return new DOMRect(d, h, A - d, b - h);
576
- }, C = (l) => {
577
- const m = o.get(l);
578
- return m ? m[0].annotation.rects : [];
579
+ return new DOMRect(l, h, w - l, v - h);
580
+ }, S = (d) => {
581
+ const f = o.get(d);
582
+ return f ? f[0].annotation.rects : [];
579
583
  };
580
584
  return {
581
585
  all: a,
582
586
  clear: c,
583
587
  getAt: r,
584
- getAnnotationBounds: w,
585
- getAnnotationRects: C,
586
- getIntersecting: (l, m, d, h) => {
587
- const A = e.search({ minX: l, minY: m, maxX: d, maxY: h }), b = new Set(A.map((v) => v.annotation.id));
588
- return Array.from(b).map((v) => ({
589
- annotation: t.getAnnotation(v),
590
- rects: C(v)
591
- })).filter((v) => !!v.annotation);
588
+ getAnnotationBounds: A,
589
+ getAnnotationRects: S,
590
+ getIntersecting: (d, f, l, h) => {
591
+ const w = e.search({ minX: d, minY: f, maxX: l, maxY: h }), v = new Set(w.map((E) => E.annotation.id));
592
+ return Array.from(v).map((E) => ({
593
+ annotation: t.getAnnotation(E),
594
+ rects: S(E)
595
+ })).filter((E) => !!E.annotation);
592
596
  },
593
597
  insert: u,
594
598
  recalculate: () => {
595
- g(t.all().map((l) => l.target), !0), s.emit("recalculate");
599
+ g(t.all().map((d) => d.target), !0), s.emit("recalculate");
596
600
  },
597
- remove: S,
601
+ remove: b,
598
602
  set: g,
599
603
  size: () => e.all().length,
600
604
  update: y,
601
- on: (l, m) => s.on(l, m)
605
+ on: (d, f) => s.on(d, f)
602
606
  };
603
607
  }, ie = (t, n) => {
604
- const e = mt(), o = re(e, t), s = pt(e, n.userSelectAction, n.adapter), i = ht(e), a = yt(), c = (f, l = $.LOCAL) => {
605
- const m = q(f, t), d = I(m.target.selector);
606
- return d && e.addAnnotation(m, l), d;
607
- }, u = (f, l = !0, m = $.LOCAL) => {
608
- const d = f.map((A) => q(A, t)), h = d.filter((A) => !I(A.target.selector));
609
- return e.bulkAddAnnotations(d, l, m), h;
610
- }, S = (f, l = $.LOCAL) => {
611
- const m = f.map((h) => q(h, t)), d = m.filter((h) => !I(h.target.selector));
612
- return m.forEach((h) => {
613
- e.getAnnotation(h.id) ? e.updateAnnotation(h, l) : e.addAnnotation(h, l);
614
- }), d;
615
- }, y = (f, l = $.LOCAL) => {
616
- const m = Y(f, t);
617
- e.updateTarget(m, l);
618
- }, g = (f, l = $.LOCAL) => {
619
- const m = f.map((d) => Y(d, t));
620
- e.bulkUpdateTargets(m, l);
608
+ const e = mt(), o = re(e, t), s = pt(e, n.userSelectAction, n.adapter), i = ht(e), a = yt(), c = (m, d = _.LOCAL) => {
609
+ const f = q(m, t), l = M(f.target.selector);
610
+ return l && e.addAnnotation(f, d), l;
611
+ }, u = (m, d = !0, f = _.LOCAL) => {
612
+ const l = m.map((w) => q(w, t)), h = l.filter((w) => !M(w.target.selector));
613
+ return e.bulkAddAnnotations(l, d, f), h;
614
+ }, b = (m, d = _.LOCAL) => {
615
+ const f = m.map((h) => q(h, t)), l = f.filter((h) => !M(h.target.selector));
616
+ return f.forEach((h) => {
617
+ e.getAnnotation(h.id) ? e.updateAnnotation(h, d) : e.addAnnotation(h, d);
618
+ }), l;
619
+ }, y = (m, d = _.LOCAL) => {
620
+ const f = X(m, t);
621
+ e.updateTarget(f, d);
622
+ }, g = (m, d = _.LOCAL) => {
623
+ const f = m.map((l) => X(l, t));
624
+ e.bulkUpdateTargets(f, d);
621
625
  };
622
- function r(f, l, m, d) {
623
- const h = m || !!d, A = o.getAt(f, l, h).map((v) => e.getAnnotation(v)), b = d ? A.filter(d) : A;
624
- if (b.length !== 0)
625
- return m ? b : b[0];
626
+ function r(m, d, f, l) {
627
+ const h = f || !!l, w = o.getAt(m, d, h).map((E) => e.getAnnotation(E)), v = l ? w.filter(l) : w;
628
+ if (v.length !== 0)
629
+ return f ? v : v[0];
626
630
  }
627
- const w = (f) => o.getAnnotationRects(f).length > 0 ? o.getAnnotationBounds(f) : void 0, C = (f, l, m, d) => o.getIntersecting(f, l, m, d), T = (f) => o.getAnnotationRects(f), x = () => o.recalculate(), E = (f) => o.on("recalculate", f);
628
- return e.observe(({ changes: f }) => {
629
- const l = (f.deleted || []).filter((h) => I(h.target.selector)), m = (f.created || []).filter((h) => I(h.target.selector)), d = (f.updated || []).filter((h) => I(h.newValue.target.selector));
630
- (l == null ? void 0 : l.length) > 0 && l.forEach((h) => o.remove(h.target)), m.length > 0 && o.set(m.map((h) => h.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: h }) => o.update(h.target));
631
+ const A = (m) => o.getAnnotationRects(m).length > 0 ? o.getAnnotationBounds(m) : void 0, S = (m, d, f, l) => o.getIntersecting(m, d, f, l), T = (m) => o.getAnnotationRects(m), x = () => o.recalculate(), C = (m) => o.on("recalculate", m);
632
+ return e.observe(({ changes: m }) => {
633
+ const d = (m.deleted || []).filter((h) => M(h.target.selector)), f = (m.created || []).filter((h) => M(h.target.selector)), l = (m.updated || []).filter((h) => M(h.newValue.target.selector));
634
+ (d == null ? void 0 : d.length) > 0 && d.forEach((h) => o.remove(h.target)), f.length > 0 && o.set(f.map((h) => h.target), !1), (l == null ? void 0 : l.length) > 0 && l.forEach(({ newValue: h }) => o.update(h.target));
631
635
  }), {
632
636
  store: {
633
637
  ...e,
634
638
  addAnnotation: c,
635
639
  bulkAddAnnotations: u,
636
640
  bulkUpdateTargets: g,
637
- bulkUpsertAnnotations: S,
638
- getAnnotationBounds: w,
641
+ bulkUpsertAnnotations: b,
642
+ getAnnotationBounds: A,
639
643
  getAnnotationRects: T,
640
- getIntersecting: C,
644
+ getIntersecting: S,
641
645
  getAt: r,
642
646
  recalculatePositions: x,
643
- onRecalculatePositions: E,
647
+ onRecalculatePositions: C,
644
648
  updateTarget: y
645
649
  },
646
650
  selection: s,
@@ -657,7 +661,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
657
661
  document.body.appendChild(e);
658
662
  const s = /* @__PURE__ */ new Map(), i = (y) => Array.from(s.entries()).filter(([g, r]) => r.presenceKey === y.presenceKey).map(([g, r]) => g);
659
663
  return t.on("selectionChange", (y, g) => {
660
- i(y).forEach((w) => s.delete(w)), g && g.forEach((w) => s.set(w, y));
664
+ i(y).forEach((A) => s.delete(A)), g && g.forEach((A) => s.set(A, y));
661
665
  }), {
662
666
  clear: () => {
663
667
  const { width: y, height: g } = e;
@@ -668,13 +672,13 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
668
672
  },
669
673
  paint: (y, g, r) => {
670
674
  n.font && (o.font = n.font);
671
- const w = s.get(y.annotation.id);
672
- if (w) {
673
- const { height: C } = y.rects[0], T = y.rects[0].x + g.left, x = y.rects[0].y + g.top;
674
- o.fillStyle = w.appearance.color, o.fillRect(T - 2, x - 2.5, 2, C + 5);
675
- const E = o.measureText(w.appearance.label), f = E.width + 6, l = E.actualBoundingBoxAscent + E.actualBoundingBoxDescent + 8, m = E.fontBoundingBoxAscent ? 8 : 6.5;
676
- return o.fillRect(T - 2, x - 2.5 - l, f, l), o.fillStyle = "#fff", o.fillText(w.appearance.label, T + 1, x - m), {
677
- fill: w.appearance.color,
675
+ const A = s.get(y.annotation.id);
676
+ if (A) {
677
+ const { height: S } = y.rects[0], T = y.rects[0].x + g.left, x = y.rects[0].y + g.top;
678
+ o.fillStyle = A.appearance.color, o.fillRect(T - 2, x - 2.5, 2, S + 5);
679
+ const C = o.measureText(A.appearance.label), m = C.width + 6, d = C.actualBoundingBoxAscent + C.actualBoundingBoxDescent + 8, f = C.fontBoundingBoxAscent ? 8 : 6.5;
680
+ return o.fillRect(T - 2, x - 2.5 - d, m, d), o.fillStyle = "#fff", o.fillText(A.appearance.label, T + 1, x - f), {
681
+ fill: A.appearance.color,
678
682
  fillOpacity: r ? 0.45 : 0.18
679
683
  };
680
684
  }
@@ -691,95 +695,95 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
691
695
  ], de = (t, n, e) => {
692
696
  const { store: o, selection: s } = n;
693
697
  let i;
694
- const { annotatingEnabled: a, offsetReferenceSelector: c, selectionMode: u } = e, S = (p) => i = p;
698
+ const { annotatingEnabled: a, offsetReferenceSelector: c, selectionMode: u } = e, b = (p) => i = p;
695
699
  let y;
696
700
  const g = (p) => y = p;
697
- let r, w, C, T = a;
701
+ let r, A, S, T = a;
698
702
  const x = (p) => {
699
- T = p, f.clear(), p || (r = void 0, w = void 0, C = void 0);
700
- }, E = (p) => {
701
- T && w !== !1 && (r = F(p.target) ? void 0 : {
703
+ T = p, m.clear(), p || (r = void 0, A = void 0, S = void 0);
704
+ }, C = (p) => {
705
+ T && A !== !1 && (r = W(p.target) ? void 0 : {
702
706
  annotation: ot(),
703
707
  selector: [],
704
708
  creator: i,
705
709
  created: /* @__PURE__ */ new Date()
706
710
  });
707
- }, f = Q((p) => {
711
+ }, m = Q((p) => {
708
712
  if (!T) return;
709
713
  const R = document.getSelection();
710
714
  if (!(R != null && R.anchorNode))
711
715
  return;
712
- if (F(R.anchorNode)) {
716
+ if (W(R.anchorNode)) {
713
717
  r = void 0;
714
718
  return;
715
719
  }
716
- const B = p.timeStamp - ((C == null ? void 0 : C.timeStamp) || p.timeStamp);
717
- if ((C == null ? void 0 : C.type) === "pointerdown" && (B < 1e3 && !r || R.isCollapsed && B < tt) && E(C || p), !r) return;
720
+ const k = p.timeStamp - ((S == null ? void 0 : S.timeStamp) || p.timeStamp);
721
+ if ((S == null ? void 0 : S.type) === "pointerdown" && (k < 1e3 && !r || R.isCollapsed && k < tt) && C(S || p), !r) return;
718
722
  if (R.isCollapsed) {
719
723
  o.getAnnotation(r.annotation) && (s.clear(), o.deleteAnnotation(r.annotation));
720
724
  return;
721
725
  }
722
- const N = R.getRangeAt(0), M = _t(N, t);
723
- if (It(M)) return;
724
- const k = Bt(M.cloneRange());
725
- (k.length !== r.selector.length || k.some((H, K) => {
726
- var z;
727
- return H.toString() !== ((z = r.selector[K]) == null ? void 0 : z.quote);
726
+ const B = R.getRangeAt(0), H = _t(B, t);
727
+ if (It(H)) return;
728
+ const O = Bt(H.cloneRange());
729
+ (O.length !== r.selector.length || O.some((P, $) => {
730
+ var F;
731
+ return P.toString() !== ((F = r.selector[$]) == null ? void 0 : F.quote);
728
732
  })) && (r = {
729
733
  ...r,
730
- selector: k.map((H) => Kt(H, t, c)),
734
+ selector: O.map((P) => Kt(P, t, c)),
731
735
  updated: /* @__PURE__ */ new Date()
732
- }, o.getAnnotation(r.annotation) ? o.updateTarget(r, $.LOCAL) : s.clear());
733
- }, 10), l = (p) => {
734
- F(p.target) || (C = j(p), w = C.button === 0);
735
- }, m = async (p) => {
736
- if (F(p.target) || !w) return;
736
+ }, o.getAnnotation(r.annotation) ? o.updateTarget(r, _.LOCAL) : s.clear());
737
+ }, 10), d = (p) => {
738
+ W(p.target) || (S = j(p), A = S.button === 0);
739
+ }, f = async (p) => {
740
+ if (W(p.target) || !A) return;
737
741
  const R = () => {
738
- const { x: N, y: M } = t.getBoundingClientRect(), k = p.target instanceof Node && t.contains(p.target) && o.getAt(p.clientX - N, p.clientY - M, u === "all", y);
739
- if (k) {
740
- const { selected: U } = s, H = new Set(U.map((D) => D.id)), K = Array.isArray(k) ? k.map((D) => D.id) : [k.id];
741
- (H.size !== K.length || !K.every((D) => H.has(D))) && s.userSelect(K, p);
742
+ const { x: B, y: H } = t.getBoundingClientRect(), O = p.target instanceof Node && t.contains(p.target) && o.getAt(p.clientX - B, p.clientY - H, u === "all", y);
743
+ if (O) {
744
+ const { selected: N } = s, P = new Set(N.map((U) => U.id)), $ = Array.isArray(O) ? O.map((U) => U.id) : [O.id];
745
+ (P.size !== $.length || !$.every((U) => P.has(U))) && s.userSelect($, p);
742
746
  } else
743
747
  s.clear();
744
748
  };
745
- if (p.timeStamp - C.timeStamp < tt) {
746
- await d();
747
- const N = document.getSelection();
748
- if (N != null && N.isCollapsed) {
749
+ if (p.timeStamp - S.timeStamp < tt) {
750
+ await l();
751
+ const B = document.getSelection();
752
+ if (B != null && B.isCollapsed) {
749
753
  r = void 0, R();
750
754
  return;
751
755
  }
752
756
  }
753
757
  r && r.selector.length > 0 && (L(), s.userSelect(r.annotation, j(p)));
754
- }, d = async () => {
758
+ }, l = async () => {
755
759
  const p = document.getSelection();
756
- let R = !1, B = p == null ? void 0 : p.isCollapsed;
757
- const N = () => B || R, M = 1;
758
- return setTimeout(() => R = !0, 50), vt(() => B = p == null ? void 0 : p.isCollapsed, M, N);
760
+ let R = !1, k = p == null ? void 0 : p.isCollapsed;
761
+ const B = () => k || R, H = 1;
762
+ return setTimeout(() => R = !0, 50), vt(() => k = p == null ? void 0 : p.isCollapsed, H, B);
759
763
  }, h = (p) => {
760
764
  const R = document.getSelection();
761
- R != null && R.isCollapsed || ((!r || r.selector.length === 0) && f(p), r && (L(), s.userSelect(r.annotation, j(p))));
762
- }, A = (p) => {
763
- T && p.key === "Shift" && r && (document.getSelection().isCollapsed || (L(), s.userSelect(r.annotation, V(p))));
764
- }, b = (p) => {
765
+ R != null && R.isCollapsed || ((!r || r.selector.length === 0) && m(p), r && (L(), s.userSelect(r.annotation, j(p))));
766
+ }, w = (p) => {
767
+ T && p.key === "Shift" && r && (document.getSelection().isCollapsed || (L(), s.userSelect(r.annotation, Y(p))));
768
+ }, v = (p) => {
765
769
  const R = () => setTimeout(() => {
766
770
  (r == null ? void 0 : r.selector.length) > 0 && (s.clear(), o.addAnnotation({
767
771
  id: r.annotation,
768
772
  bodies: [],
769
773
  target: r
770
- }), s.userSelect(r.annotation, V(p))), document.removeEventListener("selectionchange", R);
774
+ }), s.userSelect(r.annotation, Y(p))), document.removeEventListener("selectionchange", R);
771
775
  }, 100);
772
- document.addEventListener("selectionchange", R), E(p);
776
+ document.addEventListener("selectionchange", R), C(p);
773
777
  };
774
- W(le.join(","), { element: t, keydown: !0, keyup: !1 }, (p) => {
775
- p.repeat || (C = V(p));
776
- }), W(lt, { keydown: !0, keyup: !1 }, (p) => {
777
- C = V(p), b(p);
778
+ V(le.join(","), { element: t, keydown: !0, keyup: !1 }, (p) => {
779
+ p.repeat || (S = Y(p));
780
+ }), V(lt, { keydown: !0, keyup: !1 }, (p) => {
781
+ S = Y(p), v(p);
778
782
  });
779
- const v = (p) => {
783
+ const E = (p) => {
780
784
  p.repeat || p.target !== t && p.target !== document.body || (r = void 0, s.clear());
781
785
  };
782
- W(ct.join(","), { keydown: !0, keyup: !1 }, v);
786
+ V(ct.join(","), { keydown: !0, keyup: !1 }, E);
783
787
  const L = () => {
784
788
  const p = o.getAnnotation(r.annotation);
785
789
  if (!p) {
@@ -790,15 +794,15 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
790
794
  });
791
795
  return;
792
796
  }
793
- const { target: { updated: R } } = p, { updated: B } = r;
794
- (!R || !B || R < B) && o.updateTarget(r);
797
+ const { target: { updated: R } } = p, { updated: k } = r;
798
+ (!R || !k || R < k) && o.updateTarget(r);
795
799
  };
796
- return document.addEventListener("pointerdown", l), document.addEventListener("pointerup", m), document.addEventListener("contextmenu", h), t.addEventListener("keyup", A), t.addEventListener("selectstart", E), document.addEventListener("selectionchange", f), {
800
+ return document.addEventListener("pointerdown", d), document.addEventListener("pointerup", f), document.addEventListener("contextmenu", h), t.addEventListener("keyup", w), t.addEventListener("selectstart", C), document.addEventListener("selectionchange", m), {
797
801
  destroy: () => {
798
- r = void 0, w = void 0, C = void 0, f.clear(), document.removeEventListener("pointerdown", l), document.removeEventListener("pointerup", m), document.removeEventListener("contextmenu", h), t.removeEventListener("keyup", A), t.removeEventListener("selectstart", E), document.removeEventListener("selectionchange", f), W.unbind();
802
+ r = void 0, A = void 0, S = void 0, m.clear(), document.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", f), document.removeEventListener("contextmenu", h), t.removeEventListener("keyup", w), t.removeEventListener("selectstart", C), document.removeEventListener("selectionchange", m), V.unbind();
799
803
  },
800
804
  setFilter: g,
801
- setUser: S,
805
+ setUser: b,
802
806
  setAnnotatingEnabled: x
803
807
  };
804
808
  }, ue = (t, n) => ({
@@ -811,40 +815,40 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
811
815
  annotatingEnabled: !0,
812
816
  user: bt()
813
817
  }), o = ie(t, e), { selection: s, viewport: i } = o, a = o.store, c = St(a), u = Ct(o, c, e.adapter);
814
- let S = e.user;
818
+ let b = e.user;
815
819
  const y = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : et : e.renderer || et, g = y === "SPANS" ? te(t, o, i) : y === "CSS_HIGHLIGHTS" ? Qt(t, o, i) : y === "CANVAS" ? qt(t, o, i) : void 0;
816
820
  if (!g)
817
821
  throw `Unknown renderer implementation: ${y}`;
818
822
  console.debug(`Using ${y} renderer`), e.style && g.setStyle(e.style);
819
823
  const r = de(t, o, e);
820
- r.setUser(S), r.setAnnotatingEnabled(e.annotatingEnabled);
821
- const w = Et(o, c, e.adapter), C = () => S, T = (d) => {
824
+ r.setUser(b), r.setAnnotatingEnabled(e.annotatingEnabled);
825
+ const A = Et(o, c, e.adapter), S = () => b, T = (l) => {
822
826
  r.setAnnotatingEnabled(
823
- d === void 0 ? !0 : d
827
+ l === void 0 ? !0 : l
824
828
  );
825
- }, x = (d) => {
826
- g.setFilter(d), r.setFilter(d);
827
- }, E = (d) => {
828
- S = d, r.setUser(d);
829
- }, f = (d) => {
830
- d && (g.setPainter(ce(d, e.presence)), d.on("selectionChange", () => g.redraw()));
831
- }, l = (d) => {
832
- d ? s.setSelected(d) : s.clear();
829
+ }, x = (l) => {
830
+ g.setFilter(l), r.setFilter(l);
831
+ }, C = (l) => {
832
+ b = l, r.setUser(l);
833
+ }, m = (l) => {
834
+ l && (g.setPainter(ce(l, e.presence)), l.on("selectionChange", () => g.redraw()));
835
+ }, d = (l) => {
836
+ l ? s.setSelected(l) : s.clear();
833
837
  };
834
838
  return {
835
- ...w,
839
+ ...A,
836
840
  destroy: () => {
837
841
  g.destroy(), r.destroy(), c.destroy();
838
842
  },
839
843
  element: t,
840
- getUser: C,
844
+ getUser: S,
841
845
  setAnnotatingEnabled: T,
842
846
  setFilter: x,
843
847
  setStyle: g.setStyle.bind(g),
844
848
  redraw: g.redraw.bind(g),
845
- setUser: E,
846
- setSelected: l,
847
- setPresenceProvider: f,
849
+ setUser: C,
850
+ setSelected: d,
851
+ setPresenceProvider: m,
848
852
  setVisible: g.setVisible.bind(g),
849
853
  on: u.on,
850
854
  off: u.off,
@@ -853,15 +857,15 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
853
857
  };
854
858
  };
855
859
  export {
856
- X as DEFAULT_SELECTED_STYLE,
857
- P as DEFAULT_STYLE,
860
+ z as DEFAULT_SELECTED_STYLE,
861
+ K as DEFAULT_STYLE,
858
862
  st as NOT_ANNOTATABLE_CLASS,
859
- _ as NOT_ANNOTATABLE_SELECTOR,
863
+ D as NOT_ANNOTATABLE_SELECTOR,
860
864
  Re as Origin,
861
865
  Le as UserSelectAction,
862
866
  Ae as W3CTextFormat,
863
867
  Tt as cancelSingleClickEvents,
864
- V as cloneKeyboardEvent,
868
+ Y as cloneKeyboardEvent,
865
869
  j as clonePointerEvent,
866
870
  ke as createBody,
867
871
  qt as createCanvasRenderer,
@@ -876,9 +880,9 @@ export {
876
880
  Nt as getQuoteContext,
877
881
  G as getRangeAnnotatableContents,
878
882
  Rt as isMac,
879
- F as isNotAnnotatable,
883
+ W as isNotAnnotatable,
880
884
  xt as isRangeAnnotatable,
881
- I as isRevived,
885
+ M as isRevived,
882
886
  It as isWhitespaceOrEmpty,
883
887
  Pt as mergeClientRects,
884
888
  Ut as paint,
@@ -888,7 +892,7 @@ export {
888
892
  Kt as rangeToSelector,
889
893
  q as reviveAnnotation,
890
894
  rt as reviveSelector,
891
- Y as reviveTarget,
895
+ X as reviveTarget,
892
896
  Ft as scrollIntoView,
893
897
  se as serializeW3CTextAnnotation,
894
898
  Bt as splitAnnotatableRanges,