@soomo/text-annotator 3.2.0-staging.8 → 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,50 +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;
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
271
  return {
272
- annotation: k,
273
- rects: U,
274
- state: { selected: H, hovered: K }
272
+ annotation: N,
273
+ rects: P,
274
+ state: { selected: $, hovered: F }
275
275
  };
276
276
  });
277
- o.redraw(M, v, c, S, b), setTimeout(() => y(B.map(({ annotation: k }) => k)), 1);
278
- }, w = (b) => {
279
- S = b, r();
280
- }, C = (b) => {
281
- c = b, r();
282
- }, T = (b) => {
283
- 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);
284
284
  }, x = () => r();
285
285
  s.observe(x);
286
- const E = i.subscribe(() => r()), f = () => r(!0);
287
- document.addEventListener("scroll", f, { capture: !0, passive: !0 });
288
- const l = Q(() => {
289
- 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();
290
290
  }, 10);
291
- window.addEventListener("resize", l);
292
- const m = new ResizeObserver(l);
293
- m.observe(t);
294
- const d = { attributes: !0, childList: !0, subtree: !0 }, h = new MutationObserver((b) => {
295
- 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);
296
296
  });
297
- return h.observe(document.body, d), {
297
+ return w.observe(document.body, h), {
298
298
  destroy: () => {
299
- 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();
300
300
  },
301
301
  redraw: r,
302
- setStyle: C,
302
+ setStyle: S,
303
303
  setFilter: T,
304
- setPainter: w,
304
+ setPainter: A,
305
305
  setVisible: o.setVisible
306
306
  };
307
307
  }, Yt = () => {
@@ -313,28 +313,28 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
313
313
  t.classList.add("r6o-annotatable");
314
314
  const n = Yt(), e = n.getContext("2d");
315
315
  document.body.appendChild(n);
316
- const o = (c, u, S, y) => requestAnimationFrame(() => {
316
+ const o = (c, u, b, y) => requestAnimationFrame(() => {
317
317
  const { width: g, height: r } = n;
318
318
  e.clearRect(-0.5, -0.5, g + 1, r + 1), y && y.clear();
319
- const { top: w, left: C } = u;
320
- [...c].sort((x, E) => {
321
- const { annotation: { target: { created: f } } } = x, { annotation: { target: { created: l } } } = E;
322
- 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();
323
323
  }).forEach((x) => {
324
- var m;
325
- 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 }) => ({
326
- x: d + C,
327
- y: h + w,
328
- width: A,
329
- 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
330
330
  }));
331
- if (e.fillStyle = f.fill, e.globalAlpha = f.fillOpacity || 1, l.forEach(
332
- ({ x: d, y: h, width: A, height: b }) => e.fillRect(d, h, A, b)
333
- ), f.underlineColor) {
334
- e.globalAlpha = 1, e.strokeStyle = f.underlineColor, e.lineWidth = f.underlineThickness ?? 1;
335
- const d = f.underlineOffset ?? 0;
336
- l.forEach(({ x: h, y: A, width: b, height: v }) => {
337
- 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();
338
338
  });
339
339
  }
340
340
  });
@@ -349,7 +349,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
349
349
  redraw: o
350
350
  };
351
351
  }, qt = (t, n, e) => Z(t, n, e, zt(t)), jt = (t) => [
352
- `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()}`,
353
353
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
354
354
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
355
355
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
@@ -367,18 +367,18 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
367
367
  },
368
368
  redraw: (i, a, c, u) => {
369
369
  u && u.clear();
370
- const S = new Set(i.map((g) => g.annotation.id));
371
- 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));
372
372
  const y = i.map((g) => {
373
- var C;
374
- 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;
375
- 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)} }`;
376
376
  });
377
377
  t.innerHTML = y.join(`
378
378
  `), CSS.highlights.clear(), i.forEach(({ annotation: g }) => {
379
- const r = g.target.selector.map((C) => C.range), w = new Highlight(...r);
380
- CSS.highlights.set(`_${g.id}`, w);
381
- }), 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;
382
382
  }
383
383
  };
384
384
  }, Qt = (t, n, e) => Z(t, n, e, Gt()), Zt = (t, n) => {
@@ -393,18 +393,18 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
393
393
  destroy: () => {
394
394
  n.remove();
395
395
  },
396
- redraw: (a, c, u, S, y) => {
396
+ redraw: (a, c, u, b, y) => {
397
397
  const r = !(dt(e, a) && y);
398
- if (!S && !r) return;
399
- r && (n.innerHTML = ""), [...a].sort((C, T) => {
400
- const { annotation: { target: { created: x } } } = C, { annotation: { target: { created: E } } } = T;
401
- return x && E ? x.getTime() - E.getTime() : 0;
402
- }).forEach((C) => {
403
- C.rects.map((T) => {
404
- 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);
405
405
  if (r) {
406
- const f = document.createElement("span");
407
- 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);
408
408
  }
409
409
  });
410
410
  }), e = a;
@@ -486,29 +486,29 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
486
486
  selector: a,
487
487
  creator: c,
488
488
  created: u,
489
- updated: S,
489
+ updated: b,
490
490
  ...y
491
491
  } = s, g = a.map((r) => {
492
- 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 = {
493
493
  type: "TextQuoteSelector",
494
- exact: C
494
+ exact: S
495
495
  };
496
496
  if (e) {
497
- const { prefix: m, suffix: d } = Nt(E, e);
498
- f.prefix = m, f.suffix = d;
497
+ const { prefix: f, suffix: l } = Nt(C, e);
498
+ m.prefix = f, m.suffix = l;
499
499
  }
500
- const l = {
500
+ const d = {
501
501
  type: "TextPositionSelector",
502
502
  start: T,
503
503
  end: x
504
504
  };
505
505
  return {
506
506
  ...y,
507
- id: w,
507
+ id: A,
508
508
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
509
509
  scope: "scope" in r ? r.scope : void 0,
510
510
  source: n,
511
- selector: [f, l]
511
+ selector: [m, d]
512
512
  };
513
513
  });
514
514
  return {
@@ -519,132 +519,132 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
519
519
  body: ut(t.bodies),
520
520
  creator: c,
521
521
  created: u == null ? void 0 : u.toISOString(),
522
- modified: S == null ? void 0 : S.toISOString(),
522
+ modified: b == null ? void 0 : b.toISOString(),
523
523
  target: g
524
524
  };
525
525
  }, re = (t, n) => {
526
- const e = new wt(), o = /* @__PURE__ */ new Map(), s = At(), i = (l, m) => {
527
- const d = l.selector.flatMap((A) => {
528
- const b = I([A]) ? A.range : rt(A, n).range;
529
- return Array.from(b.getClientRects());
530
- }), h = Pt(d).map((A) => Dt(A, m));
531
- return h.map((A) => {
532
- 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;
533
533
  return {
534
- minX: b,
535
- minY: v,
536
- maxX: b + L,
537
- maxY: v + O,
534
+ minX: v,
535
+ minY: E,
536
+ maxX: v + L,
537
+ maxY: E + I,
538
538
  annotation: {
539
- id: l.annotation,
539
+ id: d.annotation,
540
540
  rects: h
541
541
  }
542
542
  };
543
543
  });
544
544
  }, a = () => [...o.values()], c = () => {
545
545
  e.clear(), o.clear();
546
- }, u = (l) => {
547
- const m = i(l, n.getBoundingClientRect());
548
- m.length !== 0 && (m.forEach((d) => e.insert(d)), o.set(l.annotation, m));
549
- }, S = (l) => {
550
- const m = o.get(l.annotation);
551
- m && (m.forEach((d) => e.remove(d)), o.delete(l.annotation));
552
- }, y = (l) => {
553
- S(l), u(l);
554
- }, g = (l, m = !0) => {
555
- m && c();
556
- const d = n.getBoundingClientRect(), h = l.map((b) => ({ target: b, rects: i(b, d) }));
557
- h.forEach(({ target: b, rects: v }) => {
558
- 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);
559
559
  });
560
- const A = h.flatMap(({ rects: b }) => b);
561
- e.load(A);
562
- }, r = (l, m, d = !1) => {
560
+ const w = h.flatMap(({ rects: v }) => v);
561
+ e.load(w);
562
+ }, r = (d, f, l = !1) => {
563
563
  const h = e.search({
564
- minX: l,
565
- minY: m,
566
- maxX: l,
567
- maxY: m
568
- }), A = (b) => b.annotation.rects.reduce((v, L) => v + L.width * L.height, 0);
569
- return h.length > 0 ? (h.sort((b, v) => A(b) - A(v)), d ? h.map((b) => b.annotation.id) : [h[0].annotation.id]) : [];
570
- }, w = (l) => {
571
- const m = C(l);
572
- 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)
573
573
  return;
574
- let d = m[0].left, h = m[0].top, A = m[0].right, b = m[0].bottom;
575
- for (let v = 1; v < m.length; v++) {
576
- const L = m[v];
577
- 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);
578
578
  }
579
- return new DOMRect(d, h, A - d, b - h);
580
- }, C = (l) => {
581
- const m = o.get(l);
582
- 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 : [];
583
583
  };
584
584
  return {
585
585
  all: a,
586
586
  clear: c,
587
587
  getAt: r,
588
- getAnnotationBounds: w,
589
- getAnnotationRects: C,
590
- getIntersecting: (l, m, d, h) => {
591
- const A = e.search({ minX: l, minY: m, maxX: d, maxY: h }), b = new Set(A.map((v) => v.annotation.id));
592
- return Array.from(b).map((v) => ({
593
- annotation: t.getAnnotation(v),
594
- rects: C(v)
595
- })).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);
596
596
  },
597
597
  insert: u,
598
598
  recalculate: () => {
599
- g(t.all().map((l) => l.target), !0), s.emit("recalculate");
599
+ g(t.all().map((d) => d.target), !0), s.emit("recalculate");
600
600
  },
601
- remove: S,
601
+ remove: b,
602
602
  set: g,
603
603
  size: () => e.all().length,
604
604
  update: y,
605
- on: (l, m) => s.on(l, m)
605
+ on: (d, f) => s.on(d, f)
606
606
  };
607
607
  }, ie = (t, n) => {
608
- const e = mt(), o = re(e, t), s = pt(e, n.userSelectAction, n.adapter), i = ht(e), a = yt(), c = (f, l = $.LOCAL) => {
609
- const m = q(f, t), d = I(m.target.selector);
610
- return d && e.addAnnotation(m, l), d;
611
- }, u = (f, l = !0, m = $.LOCAL) => {
612
- const d = f.map((A) => q(A, t)), h = d.filter((A) => !I(A.target.selector));
613
- return e.bulkAddAnnotations(d, l, m), h;
614
- }, S = (f, l = $.LOCAL) => {
615
- const m = f.map((h) => q(h, t)), d = m.filter((h) => !I(h.target.selector));
616
- return m.forEach((h) => {
617
- e.getAnnotation(h.id) ? e.updateAnnotation(h, l) : e.addAnnotation(h, l);
618
- }), d;
619
- }, y = (f, l = $.LOCAL) => {
620
- const m = Y(f, t);
621
- e.updateTarget(m, l);
622
- }, g = (f, l = $.LOCAL) => {
623
- const m = f.map((d) => Y(d, t));
624
- 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);
625
625
  };
626
- function r(f, l, m, d) {
627
- const h = m || !!d, A = o.getAt(f, l, h).map((v) => e.getAnnotation(v)), b = d ? A.filter(d) : A;
628
- if (b.length !== 0)
629
- 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];
630
630
  }
631
- 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);
632
- return e.observe(({ changes: f }) => {
633
- 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));
634
- (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));
635
635
  }), {
636
636
  store: {
637
637
  ...e,
638
638
  addAnnotation: c,
639
639
  bulkAddAnnotations: u,
640
640
  bulkUpdateTargets: g,
641
- bulkUpsertAnnotations: S,
642
- getAnnotationBounds: w,
641
+ bulkUpsertAnnotations: b,
642
+ getAnnotationBounds: A,
643
643
  getAnnotationRects: T,
644
- getIntersecting: C,
644
+ getIntersecting: S,
645
645
  getAt: r,
646
646
  recalculatePositions: x,
647
- onRecalculatePositions: E,
647
+ onRecalculatePositions: C,
648
648
  updateTarget: y
649
649
  },
650
650
  selection: s,
@@ -661,7 +661,7 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
661
661
  document.body.appendChild(e);
662
662
  const s = /* @__PURE__ */ new Map(), i = (y) => Array.from(s.entries()).filter(([g, r]) => r.presenceKey === y.presenceKey).map(([g, r]) => g);
663
663
  return t.on("selectionChange", (y, g) => {
664
- 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));
665
665
  }), {
666
666
  clear: () => {
667
667
  const { width: y, height: g } = e;
@@ -672,13 +672,13 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
672
672
  },
673
673
  paint: (y, g, r) => {
674
674
  n.font && (o.font = n.font);
675
- const w = s.get(y.annotation.id);
676
- if (w) {
677
- const { height: C } = y.rects[0], T = y.rects[0].x + g.left, x = y.rects[0].y + g.top;
678
- o.fillStyle = w.appearance.color, o.fillRect(T - 2, x - 2.5, 2, C + 5);
679
- const E = o.measureText(w.appearance.label), f = E.width + 6, l = E.actualBoundingBoxAscent + E.actualBoundingBoxDescent + 8, m = E.fontBoundingBoxAscent ? 8 : 6.5;
680
- return o.fillRect(T - 2, x - 2.5 - l, f, l), o.fillStyle = "#fff", o.fillText(w.appearance.label, T + 1, x - m), {
681
- 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,
682
682
  fillOpacity: r ? 0.45 : 0.18
683
683
  };
684
684
  }
@@ -695,95 +695,95 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
695
695
  ], de = (t, n, e) => {
696
696
  const { store: o, selection: s } = n;
697
697
  let i;
698
- 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;
699
699
  let y;
700
700
  const g = (p) => y = p;
701
- let r, w, C, T = a;
701
+ let r, A, S, T = a;
702
702
  const x = (p) => {
703
- T = p, f.clear(), p || (r = void 0, w = void 0, C = void 0);
704
- }, E = (p) => {
705
- 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 : {
706
706
  annotation: ot(),
707
707
  selector: [],
708
708
  creator: i,
709
709
  created: /* @__PURE__ */ new Date()
710
710
  });
711
- }, f = Q((p) => {
711
+ }, m = Q((p) => {
712
712
  if (!T) return;
713
713
  const R = document.getSelection();
714
714
  if (!(R != null && R.anchorNode))
715
715
  return;
716
- if (F(R.anchorNode)) {
716
+ if (W(R.anchorNode)) {
717
717
  r = void 0;
718
718
  return;
719
719
  }
720
- const B = p.timeStamp - ((C == null ? void 0 : C.timeStamp) || p.timeStamp);
721
- 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;
722
722
  if (R.isCollapsed) {
723
723
  o.getAnnotation(r.annotation) && (s.clear(), o.deleteAnnotation(r.annotation));
724
724
  return;
725
725
  }
726
- const N = R.getRangeAt(0), M = _t(N, t);
727
- if (It(M)) return;
728
- const k = Bt(M.cloneRange());
729
- (k.length !== r.selector.length || k.some((H, K) => {
730
- var z;
731
- 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);
732
732
  })) && (r = {
733
733
  ...r,
734
- selector: k.map((H) => Kt(H, t, c)),
734
+ selector: O.map((P) => Kt(P, t, c)),
735
735
  updated: /* @__PURE__ */ new Date()
736
- }, o.getAnnotation(r.annotation) ? o.updateTarget(r, $.LOCAL) : s.clear());
737
- }, 10), l = (p) => {
738
- F(p.target) || (C = j(p), w = C.button === 0);
739
- }, m = async (p) => {
740
- 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;
741
741
  const R = () => {
742
- 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);
743
- if (k) {
744
- const { selected: U } = s, H = new Set(U.map((D) => D.id)), K = Array.isArray(k) ? k.map((D) => D.id) : [k.id];
745
- (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);
746
746
  } else
747
747
  s.clear();
748
748
  };
749
- if (p.timeStamp - C.timeStamp < tt) {
750
- await d();
751
- const N = document.getSelection();
752
- 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) {
753
753
  r = void 0, R();
754
754
  return;
755
755
  }
756
756
  }
757
757
  r && r.selector.length > 0 && (L(), s.userSelect(r.annotation, j(p)));
758
- }, d = async () => {
758
+ }, l = async () => {
759
759
  const p = document.getSelection();
760
- let R = !1, B = p == null ? void 0 : p.isCollapsed;
761
- const N = () => B || R, M = 1;
762
- 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);
763
763
  }, h = (p) => {
764
764
  const R = document.getSelection();
765
- R != null && R.isCollapsed || ((!r || r.selector.length === 0) && f(p), r && (L(), s.userSelect(r.annotation, j(p))));
766
- }, A = (p) => {
767
- T && p.key === "Shift" && r && (document.getSelection().isCollapsed || (L(), s.userSelect(r.annotation, V(p))));
768
- }, 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) => {
769
769
  const R = () => setTimeout(() => {
770
770
  (r == null ? void 0 : r.selector.length) > 0 && (s.clear(), o.addAnnotation({
771
771
  id: r.annotation,
772
772
  bodies: [],
773
773
  target: r
774
- }), s.userSelect(r.annotation, V(p))), document.removeEventListener("selectionchange", R);
774
+ }), s.userSelect(r.annotation, Y(p))), document.removeEventListener("selectionchange", R);
775
775
  }, 100);
776
- document.addEventListener("selectionchange", R), E(p);
776
+ document.addEventListener("selectionchange", R), C(p);
777
777
  };
778
- W(le.join(","), { element: t, keydown: !0, keyup: !1 }, (p) => {
779
- p.repeat || (C = V(p));
780
- }), W(lt, { keydown: !0, keyup: !1 }, (p) => {
781
- 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);
782
782
  });
783
- const v = (p) => {
783
+ const E = (p) => {
784
784
  p.repeat || p.target !== t && p.target !== document.body || (r = void 0, s.clear());
785
785
  };
786
- W(ct.join(","), { keydown: !0, keyup: !1 }, v);
786
+ V(ct.join(","), { keydown: !0, keyup: !1 }, E);
787
787
  const L = () => {
788
788
  const p = o.getAnnotation(r.annotation);
789
789
  if (!p) {
@@ -794,15 +794,15 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
794
794
  });
795
795
  return;
796
796
  }
797
- const { target: { updated: R } } = p, { updated: B } = r;
798
- (!R || !B || R < B) && o.updateTarget(r);
797
+ const { target: { updated: R } } = p, { updated: k } = r;
798
+ (!R || !k || R < k) && o.updateTarget(r);
799
799
  };
800
- 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), {
801
801
  destroy: () => {
802
- 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();
803
803
  },
804
804
  setFilter: g,
805
- setUser: S,
805
+ setUser: b,
806
806
  setAnnotatingEnabled: x
807
807
  };
808
808
  }, ue = (t, n) => ({
@@ -815,40 +815,40 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
815
815
  annotatingEnabled: !0,
816
816
  user: bt()
817
817
  }), o = ie(t, e), { selection: s, viewport: i } = o, a = o.store, c = St(a), u = Ct(o, c, e.adapter);
818
- let S = e.user;
818
+ let b = e.user;
819
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;
820
820
  if (!g)
821
821
  throw `Unknown renderer implementation: ${y}`;
822
822
  console.debug(`Using ${y} renderer`), e.style && g.setStyle(e.style);
823
823
  const r = de(t, o, e);
824
- r.setUser(S), r.setAnnotatingEnabled(e.annotatingEnabled);
825
- 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) => {
826
826
  r.setAnnotatingEnabled(
827
- d === void 0 ? !0 : d
827
+ l === void 0 ? !0 : l
828
828
  );
829
- }, x = (d) => {
830
- g.setFilter(d), r.setFilter(d);
831
- }, E = (d) => {
832
- S = d, r.setUser(d);
833
- }, f = (d) => {
834
- d && (g.setPainter(ce(d, e.presence)), d.on("selectionChange", () => g.redraw()));
835
- }, l = (d) => {
836
- 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();
837
837
  };
838
838
  return {
839
- ...w,
839
+ ...A,
840
840
  destroy: () => {
841
841
  g.destroy(), r.destroy(), c.destroy();
842
842
  },
843
843
  element: t,
844
- getUser: C,
844
+ getUser: S,
845
845
  setAnnotatingEnabled: T,
846
846
  setFilter: x,
847
847
  setStyle: g.setStyle.bind(g),
848
848
  redraw: g.redraw.bind(g),
849
- setUser: E,
850
- setSelected: l,
851
- setPresenceProvider: f,
849
+ setUser: C,
850
+ setSelected: d,
851
+ setPresenceProvider: m,
852
852
  setVisible: g.setVisible.bind(g),
853
853
  on: u.on,
854
854
  off: u.off,
@@ -857,15 +857,15 @@ const st = "not-annotatable", _ = `.${st}`, F = (t) => {
857
857
  };
858
858
  };
859
859
  export {
860
- X as DEFAULT_SELECTED_STYLE,
861
- P as DEFAULT_STYLE,
860
+ z as DEFAULT_SELECTED_STYLE,
861
+ K as DEFAULT_STYLE,
862
862
  st as NOT_ANNOTATABLE_CLASS,
863
- _ as NOT_ANNOTATABLE_SELECTOR,
863
+ D as NOT_ANNOTATABLE_SELECTOR,
864
864
  Re as Origin,
865
865
  Le as UserSelectAction,
866
866
  Ae as W3CTextFormat,
867
867
  Tt as cancelSingleClickEvents,
868
- V as cloneKeyboardEvent,
868
+ Y as cloneKeyboardEvent,
869
869
  j as clonePointerEvent,
870
870
  ke as createBody,
871
871
  qt as createCanvasRenderer,
@@ -880,9 +880,9 @@ export {
880
880
  Nt as getQuoteContext,
881
881
  G as getRangeAnnotatableContents,
882
882
  Rt as isMac,
883
- F as isNotAnnotatable,
883
+ W as isNotAnnotatable,
884
884
  xt as isRangeAnnotatable,
885
- I as isRevived,
885
+ M as isRevived,
886
886
  It as isWhitespaceOrEmpty,
887
887
  Pt as mergeClientRects,
888
888
  Ut as paint,
@@ -892,7 +892,7 @@ export {
892
892
  Kt as rangeToSelector,
893
893
  q as reviveAnnotation,
894
894
  rt as reviveSelector,
895
- Y as reviveTarget,
895
+ X as reviveTarget,
896
896
  Ft as scrollIntoView,
897
897
  se as serializeW3CTextAnnotation,
898
898
  Bt as splitAnnotatableRanges,