@soomo/text-annotator 3.2.0-staging.11 → 3.2.0-staging.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,62 +1,62 @@
1
- import Q from "debounce";
2
- import { colord as nt } from "colord";
3
- import { dequal as dt } from "dequal/lite";
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";
6
- import { Origin as Re, UserSelectAction as Le, createBody as ke } from "@annotorious/core";
1
+ import X from "debounce";
2
+ import { colord as ot } from "colord";
3
+ import { dequal as ut } from "dequal/lite";
4
+ import { v4 as st } from "uuid";
5
+ import { serializeW3CBodies as ft, parseW3CBodies as gt, parseW3CUser as mt, createStore as pt, createSelectionState as ht, createHoverState as yt, createViewportState as bt, Origin as _, createAnonymousGuest as St, createUndoStack as Ct, createLifecycleObserver as Et, createBaseAnnotator as At } from "@annotorious/core";
6
+ import { Origin as Le, UserSelectAction as ke, createBody as Ne } from "@annotorious/core";
7
7
  import wt from "rbush";
8
- import { createNanoEvents as At } from "nanoevents";
8
+ import { createNanoEvents as vt } from "nanoevents";
9
9
  import V from "hotkeys-js";
10
- import { poll as vt } from "poll";
11
- const st = "not-annotatable", D = `.${st}`, W = (t) => {
12
- var e;
13
- return !!(t instanceof HTMLElement ? t.closest(D) : (e = t.parentElement) == null ? void 0 : e.closest(D));
14
- }, xt = (t) => {
15
- const n = t.commonAncestorContainer;
16
- return !W(n);
17
- }, Tt = (t) => t.addEventListener("click", (n) => {
10
+ import { poll as xt } from "poll";
11
+ const rt = "not-annotatable", $ = `.${rt}`, U = (t, n) => {
12
+ var o;
13
+ return t.contains(n) ? !!(n instanceof HTMLElement ? n.closest($) : (o = n.parentElement) == null ? void 0 : o.closest($)) : !0;
14
+ }, Tt = (t, n) => {
15
+ const e = n.commonAncestorContainer;
16
+ return !U(t, e);
17
+ }, Rt = (t) => t.addEventListener("click", (n) => {
18
18
  // Allow clicks within not-annotatable elements
19
- !n.target.closest(D) && !n.target.closest("a") && n.preventDefault();
20
- }), Rt = typeof navigator < "u" && // @ts-ignore
21
- /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Lt = (t) => {
19
+ !n.target.closest($) && !n.target.closest("a") && n.preventDefault();
20
+ }), Lt = typeof navigator < "u" && // @ts-ignore
21
+ /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), kt = (t) => {
22
22
  !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
23
- }, kt = function* (t) {
23
+ }, Nt = function* (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(D) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
27
+ (o) => o instanceof HTMLElement && o.classList.contains(rt) && !o.parentElement.closest($) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
28
28
  );
29
29
  let e;
30
30
  for (; e = n.nextNode(); )
31
31
  e instanceof HTMLElement && (yield e);
32
- }, Bt = (t) => {
33
- if (!xt(t)) return [];
34
- const n = [];
35
- let e = null;
36
- for (const o of kt(t)) {
37
- let s;
38
- e ? (s = document.createRange(), s.setStartAfter(e), s.setEndBefore(o)) : (s = t.cloneRange(), s.setEndBefore(o)), s.collapsed || n.push(s), e = o;
32
+ }, Bt = (t, n) => {
33
+ if (!Tt(t, n)) return [];
34
+ const e = [];
35
+ let o = null;
36
+ for (const s of Nt(n)) {
37
+ let r;
38
+ o ? (r = document.createRange(), r.setStartAfter(o), r.setEndBefore(s)) : (r = n.cloneRange(), r.setEndBefore(s)), r.collapsed || e.push(r), o = s;
39
39
  }
40
- if (e) {
41
- const o = t.cloneRange();
42
- o.setStartAfter(e), o.collapsed || n.push(o);
40
+ if (o) {
41
+ const s = n.cloneRange();
42
+ s.setStartAfter(o), s.collapsed || e.push(s);
43
43
  }
44
- return n.length > 0 ? n : [t];
45
- }, G = (t) => {
44
+ return e.length > 0 ? e : [n];
45
+ }, Z = (t) => {
46
46
  const n = t.cloneContents();
47
- return n.querySelectorAll(D).forEach((e) => e.remove()), n;
48
- }, Nt = (t, n, e = 10, o) => {
49
- const s = o ? t.startContainer.parentElement.closest(o) : n, i = document.createRange();
50
- i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
51
- const a = G(i).textContent, c = document.createRange();
52
- c.setStart(t.endContainer, t.endOffset), s === document.body ? c.setEnd(s, s.childNodes.length) : c.setEndAfter(s);
53
- const u = G(c).textContent;
47
+ return n.querySelectorAll($).forEach((e) => e.remove()), n;
48
+ }, Ot = (t, n, e = 10, o) => {
49
+ const s = o ? t.startContainer.parentElement.closest(o) : n, r = document.createRange();
50
+ r.setStart(s, 0), r.setEnd(t.startContainer, t.startOffset);
51
+ const i = Z(r).textContent, a = document.createRange();
52
+ a.setStart(t.endContainer, t.endOffset), s === document.body ? a.setEnd(s, s.childNodes.length) : a.setEndAfter(s);
53
+ const u = Z(a).textContent;
54
54
  return {
55
- prefix: a.substring(a.length - e),
55
+ prefix: i.substring(i.length - e),
56
56
  suffix: u.substring(0, e)
57
57
  };
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
- const e = (i) => Math.round(i * 10) / 10, o = {
58
+ }, M = (t) => t.every((n) => n.range instanceof Range && !n.range.collapsed), It = /^\s*$/, Mt = (t) => It.test(t.toString()), Ht = (t, n) => {
59
+ const e = (r) => Math.round(r * 10) / 10, o = {
60
60
  top: e(t.top),
61
61
  bottom: e(t.bottom),
62
62
  left: e(t.left),
@@ -79,31 +79,31 @@ const st = "not-annotatable", D = `.${st}`, W = (t) => {
79
79
  return "block-contains";
80
80
  } else if (o.top >= s.top && o.bottom <= s.bottom && o.left >= s.left && o.right <= s.right)
81
81
  return "block-is-contained";
82
- }, Ht = (t, n) => {
83
- const e = Math.min(t.left, n.left), o = Math.max(t.right, n.right), s = Math.min(t.top, n.top), i = Math.max(t.bottom, n.bottom);
84
- return new DOMRect(e, s, o - e, i - s);
85
- }, Pt = (t) => t.reduce((n, e) => {
82
+ }, Pt = (t, n) => {
83
+ const e = Math.min(t.left, n.left), o = Math.max(t.right, n.right), s = Math.min(t.top, n.top), r = Math.max(t.bottom, n.bottom);
84
+ return new DOMRect(e, s, o - e, r - s);
85
+ }, Dt = (t) => t.reduce((n, e) => {
86
86
  if (e.width === 0 || e.height === 0)
87
87
  return n;
88
88
  let o = [...n], s = !1;
89
- for (const i of n) {
90
- const a = Mt(e, i);
91
- if (a === "inline-adjacent") {
92
- o = o.map((c) => c === i ? Ht(e, i) : c), s = !0;
89
+ for (const r of n) {
90
+ const i = Ht(e, r);
91
+ if (i === "inline-adjacent") {
92
+ o = o.map((a) => a === r ? Pt(e, r) : a), s = !0;
93
93
  break;
94
- } else if (a === "inline-contains") {
95
- o = o.map((c) => c === i ? e : c), s = !0;
94
+ } else if (i === "inline-contains") {
95
+ o = o.map((a) => a === r ? e : a), s = !0;
96
96
  break;
97
- } else if (a === "inline-is-contained") {
97
+ } else if (i === "inline-is-contained") {
98
98
  s = !0;
99
99
  break;
100
- } else if (a === "block-contains" || a === "block-is-contained") {
101
- e.width < i.width && (o = o.map((c) => c === i ? e : c)), s = !0;
100
+ } else if (i === "block-contains" || i === "block-is-contained") {
101
+ e.width < r.width && (o = o.map((a) => a === r ? e : a)), s = !0;
102
102
  break;
103
103
  }
104
104
  }
105
105
  return s ? o : [...o, e];
106
- }, []), Ee = (t) => ({
106
+ }, []), Ae = (t) => ({
107
107
  length: t.length,
108
108
  item: (n) => t[n],
109
109
  [Symbol.iterator]: function* () {
@@ -113,63 +113,63 @@ const st = "not-annotatable", D = `.${st}`, W = (t) => {
113
113
  }), Kt = (t, n, e) => {
114
114
  const o = document.createRange(), s = e ? t.startContainer.parentElement.closest(e) : n;
115
115
  o.setStart(s, 0), o.setEnd(t.startContainer, t.startOffset);
116
- const i = G(o).textContent, a = t.toString(), c = i.length || 0, u = c + a.length;
117
- return e ? { quote: a, start: c, end: u, range: t, offsetReference: s } : { quote: a, start: c, end: u, range: t };
118
- }, rt = (t, n) => {
119
- var y, g;
120
- const { start: e, end: o } = t, s = t.offsetReference || n, i = document.createNodeIterator(
116
+ const r = Z(o).textContent, i = t.toString(), a = r.length || 0, u = a + i.length;
117
+ return e ? { quote: i, start: a, end: u, range: t, offsetReference: s } : { quote: i, start: a, end: u, range: t };
118
+ }, it = (t, n) => {
119
+ var b, f;
120
+ const { start: e, end: o } = t, s = t.offsetReference || n, r = document.createNodeIterator(
121
121
  n,
122
122
  NodeFilter.SHOW_TEXT,
123
- (r) => {
124
- var A;
125
- return (A = r.parentElement) != null && A.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
123
+ (p) => {
124
+ var c;
125
+ return (c = p.parentElement) != null && c.closest($) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
126
126
  }
127
127
  );
128
- let a = 0;
129
- const c = document.createRange();
130
- let u = i.nextNode();
128
+ let i = 0;
129
+ const a = document.createRange();
130
+ let u = r.nextNode();
131
131
  u === null && console.error("Could not revive annotation target. Content missing.");
132
- let b = !s;
132
+ let S = !s;
133
133
  for (; u !== null; ) {
134
- if (b || (b = typeof (s == null ? void 0 : s.contains) == "function" ? s.contains(u) : !1), b) {
135
- const r = ((y = u.textContent) == null ? void 0 : y.length) || 0;
136
- if (a + r > e) {
137
- c.setStart(u, e - a);
134
+ if (S || (S = typeof (s == null ? void 0 : s.contains) == "function" ? s.contains(u) : !1), S) {
135
+ const p = ((b = u.textContent) == null ? void 0 : b.length) || 0;
136
+ if (i + p > e) {
137
+ a.setStart(u, e - i);
138
138
  break;
139
139
  }
140
- a += r;
140
+ i += p;
141
141
  }
142
- u = i.nextNode();
142
+ u = r.nextNode();
143
143
  }
144
144
  for (; u !== null; ) {
145
- const r = ((g = u.textContent) == null ? void 0 : g.length) || 0;
146
- if (a + r >= o) {
147
- c.setEnd(u, o - a);
145
+ const p = ((f = u.textContent) == null ? void 0 : f.length) || 0;
146
+ if (i + p >= o) {
147
+ a.setEnd(u, o - i);
148
148
  break;
149
149
  }
150
- a += r, u = i.nextNode();
150
+ i += p, u = r.nextNode();
151
151
  }
152
152
  return {
153
153
  ...t,
154
- range: c
154
+ range: a
155
155
  };
156
- }, X = (t, n) => M(t.selector) ? t : {
156
+ }, z = (t, n) => M(t.selector) ? t : {
157
157
  ...t,
158
- selector: t.selector.map((e) => e.range instanceof Range && !e.range.collapsed ? e : rt(e, n))
159
- }, q = (t, n) => M(t.target.selector) ? t : { ...t, target: X(t.target, n) }, it = (t, n) => {
158
+ selector: t.selector.map((e) => e.range instanceof Range && !e.range.collapsed ? e : it(e, n))
159
+ }, G = (t, n) => M(t.target.selector) ? t : { ...t, target: z(t.target, n) }, at = (t, n) => {
160
160
  if (t.isEqualNode(n))
161
161
  return !0;
162
162
  for (let e of t.childNodes)
163
- if (it(e, n))
163
+ if (at(e, n))
164
164
  return !0;
165
165
  return !1;
166
- }, $t = (t, n) => {
167
- const e = t.cloneContents();
168
- return it(e, n);
169
166
  }, _t = (t, n) => {
167
+ const e = t.cloneContents();
168
+ return at(e, n);
169
+ }, $t = (t, n) => {
170
170
  const e = t.cloneRange(), o = n.contains(e.startContainer), s = n.contains(e.endContainer);
171
- return !o && !s && !$t(e, n) ? (e.collapse(), e) : (o || e.setStart(n, 0), s || e.setEnd(n, n.childNodes.length), e);
172
- }, j = (t) => ({
171
+ return !o && !s && !_t(e, n) ? (e.collapse(), e) : (o || e.setStart(n, 0), s || e.setEnd(n, n.childNodes.length), e);
172
+ }, Q = (t) => ({
173
173
  ...t,
174
174
  type: t.type,
175
175
  x: t.x,
@@ -211,150 +211,150 @@ const st = "not-annotatable", D = `.${st}`, W = (t) => {
211
211
  defaultPrevented: t.defaultPrevented,
212
212
  detail: t.detail,
213
213
  timeStamp: t.timeStamp
214
- }), Dt = (t, n) => {
215
- const { left: e, top: o, right: s, bottom: i } = t;
216
- return new DOMRect(e - n.left, o - n.top, s - e, i - o);
214
+ }), Ft = (t, n) => {
215
+ const { left: e, top: o, right: s, bottom: r } = t;
216
+ return new DOMRect(e - n.left, o - n.top, s - e, r - o);
217
217
  }, we = (t, n) => {
218
- const { left: e, top: o, right: s, bottom: i } = t;
219
- return new DOMRect(e + n.left, o + n.top, s - e, i - o);
220
- }, at = (t) => {
218
+ const { left: e, top: o, right: s, bottom: r } = t;
219
+ return new DOMRect(e + n.left, o + n.top, s - e, r - o);
220
+ }, ct = (t) => {
221
221
  if (!t)
222
222
  return document.scrollingElement;
223
223
  const { overflowY: n } = window.getComputedStyle(t);
224
- return n !== "visible" && n !== "hidden" && t.scrollHeight > t.clientHeight ? t : at(t.parentElement);
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), 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
- }, Ft = (t, n) => (e, o) => {
229
- const s = typeof e == "string" ? e : e.id, i = o ? typeof o == "string" ? document.getElementById(o) : o : at(t);
230
- if (!i)
224
+ return n !== "visible" && n !== "hidden" && t.scrollHeight > t.clientHeight ? t : ct(t.parentElement);
225
+ }, tt = (t, n, e) => {
226
+ const o = e.getBoundingClientRect(), s = e.clientHeight, r = e.clientWidth, i = n.selector[0].range.getBoundingClientRect(), { width: a, height: u } = t.getAnnotationBounds(n.annotation), S = i.top - o.top, b = i.left - o.left, f = e.parentElement ? e.scrollTop : 0, p = e.parentElement ? e.scrollLeft : 0, c = S + f - (s - u) / 2, x = b + p - (r - a) / 2;
227
+ e.scroll({ top: c, left: x, behavior: "smooth" });
228
+ }, Ut = (t, n) => (e, o) => {
229
+ const s = typeof e == "string" ? e : e.id, r = o ? typeof o == "string" ? document.getElementById(o) : o : ct(t);
230
+ if (!r)
231
231
  return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: t }), !1;
232
- const a = n.getAnnotation(s);
233
- if (!a)
232
+ const i = n.getAnnotation(s);
233
+ if (!i)
234
234
  return console.warn(`The annotation is missing in the store: ${s}`), !1;
235
- const { range: c } = a.target.selector[0];
236
- if (c && !c.collapsed)
237
- return J(n, a.target, i), !0;
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 = {
235
+ const { range: a } = i.target.selector[0];
236
+ if (a && !a.collapsed)
237
+ return tt(n, i.target, r), !0;
238
+ const u = z(i.target, t), { range: S } = u.selector[0];
239
+ return S && !S.collapsed ? (tt(n, u, r), !0) : !1;
240
+ }, P = {
241
241
  fill: "rgb(0, 128, 255)",
242
242
  fillOpacity: 0.18
243
- }, z = {
243
+ }, q = {
244
244
  fill: "rgb(0, 128, 255)",
245
245
  fillOpacity: 0.45
246
- }, Ut = (t, n, e, o, s) => {
247
- var a, c;
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
- return o && o.paint(t, n) || i;
250
- }, Wt = (t) => {
251
- const { top: n, left: e } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: s } = window, i = -e, a = -n, c = o - e, u = s - n;
252
- return { top: n, left: e, minX: i, minY: a, maxX: c, maxY: u };
246
+ }, Wt = (t, n, e, o, s) => {
247
+ var i, a;
248
+ const r = e ? typeof e == "function" ? e(t.annotation, t.state, s) || ((i = t.state) != null && i.selected ? q : P) : e : (a = t.state) != null && a.selected ? q : P;
249
+ return o && o.paint(t, n) || r;
253
250
  }, Vt = (t) => {
251
+ const { top: n, left: e } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: s } = window, r = -e, i = -n, a = o - e, u = s - n;
252
+ return { top: n, left: e, minX: r, minY: i, maxX: a, maxY: u };
253
+ }, Yt = (t) => {
254
254
  let n = /* @__PURE__ */ new Set();
255
255
  return (o) => {
256
- const s = o.map((i) => i.id);
257
- (n.size !== s.length || s.some((i) => !n.has(i))) && t.set(s), n = new Set(s);
256
+ const s = o.map((r) => r.id);
257
+ (n.size !== s.length || s.some((r) => !n.has(r))) && t.set(s), n = new Set(s);
258
258
  };
259
- }, Z = (t, n, e, o) => {
260
- const { store: s, selection: i, hover: a } = n;
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));
259
+ }, J = (t, n, e, o) => {
260
+ const { store: s, selection: r, hover: i } = n;
261
+ let a, u, S;
262
+ const b = Yt(e), f = (C) => {
263
+ const { x: k, y: B } = t.getBoundingClientRect(), D = s.getAt(C.clientX - k, C.clientY - B, !1, u);
264
+ D ? i.current !== D.id && (t.classList.add("hovered"), i.set(D.id)) : i.current && (t.classList.remove("hovered"), i.set(null));
265
265
  };
266
- t.addEventListener("pointermove", g);
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;
266
+ t.addEventListener("pointermove", f);
267
+ const p = (C = !1) => {
268
+ S && S.clear();
269
+ const k = Vt(t), { minX: B, minY: D, maxX: h, maxY: R } = k, O = u ? s.getIntersecting(B, D, h, R).filter(({ annotation: L }) => u(L)) : s.getIntersecting(B, D, h, R), I = r.selected.map(({ id: L }) => L), H = O.map(({ annotation: L, rects: W }) => {
270
+ const N = I.includes(L.id), K = L.id === i.current;
271
271
  return {
272
- annotation: N,
273
- rects: P,
274
- state: { selected: $, hovered: F }
272
+ annotation: L,
273
+ rects: W,
274
+ state: { selected: N, hovered: K }
275
275
  };
276
276
  });
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
- }, x = () => r();
285
- s.observe(x);
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();
277
+ o.redraw(H, k, a, S, C), setTimeout(() => b(O.map(({ annotation: L }) => L)), 1);
278
+ }, c = (C) => {
279
+ S = C, p();
280
+ }, x = (C) => {
281
+ a = C, p();
282
+ }, w = (C) => {
283
+ u = C, p(!1);
284
+ }, T = () => p();
285
+ s.observe(T);
286
+ const E = r.subscribe(() => p()), m = i.subscribe(() => p()), l = () => p(!0);
287
+ document.addEventListener("scroll", l, { capture: !0, passive: !0 });
288
+ const g = X(() => {
289
+ s.recalculatePositions(), S == null || S.reset(), p();
290
290
  }, 10);
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
- });
297
- return w.observe(document.body, h), {
291
+ window.addEventListener("resize", g);
292
+ const d = new ResizeObserver(g);
293
+ d.observe(t);
294
+ const y = { attributes: !0, childList: !0, subtree: !0 }, A = new MutationObserver(X((C) => {
295
+ C.every((B) => B.target === t || t.contains(B.target)) || p(!0);
296
+ }, 150));
297
+ return A.observe(document.body, y), {
298
298
  destroy: () => {
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();
299
+ t.removeEventListener("pointermove", f), o.destroy(), s.unobserve(T), E(), m(), document.removeEventListener("scroll", l), g.clear(), window.removeEventListener("resize", g), d.disconnect(), A.disconnect();
300
300
  },
301
- redraw: r,
302
- setStyle: S,
303
- setFilter: T,
304
- setPainter: A,
301
+ redraw: p,
302
+ setStyle: x,
303
+ setFilter: w,
304
+ setPainter: c,
305
305
  setVisible: o.setVisible
306
306
  };
307
- }, Yt = () => {
307
+ }, Xt = () => {
308
308
  const t = document.createElement("canvas");
309
309
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
310
- }, Xt = (t, n) => {
310
+ }, zt = (t, n) => {
311
311
  t.width = window.innerWidth, t.height = window.innerHeight;
312
- }, zt = (t) => {
312
+ }, qt = (t) => {
313
313
  t.classList.add("r6o-annotatable");
314
- const n = Yt(), e = n.getContext("2d");
314
+ const n = Xt(), e = n.getContext("2d");
315
315
  document.body.appendChild(n);
316
- const o = (c, u, b, y) => requestAnimationFrame(() => {
317
- const { width: g, height: r } = n;
318
- e.clearRect(-0.5, -0.5, g + 1, r + 1), y && y.clear();
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
- }).forEach((x) => {
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,
316
+ const o = (a, u, S, b) => requestAnimationFrame(() => {
317
+ const { width: f, height: p } = n;
318
+ e.clearRect(-0.5, -0.5, f + 1, p + 1), b && b.clear();
319
+ const { top: c, left: x } = u;
320
+ [...a].sort((T, E) => {
321
+ const { annotation: { target: { created: m } } } = T, { annotation: { target: { created: l } } } = E;
322
+ return m.getTime() - l.getTime();
323
+ }).forEach((T) => {
324
+ var g;
325
+ const E = S ? typeof S == "function" ? S(T.annotation, T.state) : S : (g = T.state) != null && g.selected ? q : P, m = b && b.paint(T, u) || E, l = T.rects.map(({ x: d, y, width: A, height: v }) => ({
326
+ x: d + x,
327
+ y: y + c,
328
+ width: A,
329
329
  height: v
330
330
  }));
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)
331
+ if (e.fillStyle = m.fill, e.globalAlpha = m.fillOpacity || 1, l.forEach(
332
+ ({ x: d, y, width: A, height: v }) => e.fillRect(d, y, A, v)
333
333
  ), m.underlineColor) {
334
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();
335
+ const d = m.underlineOffset ?? 0;
336
+ l.forEach(({ x: y, y: A, width: v, height: C }) => {
337
+ e.beginPath(), e.moveTo(y, A + C + d), e.lineTo(y + v, A + C + d), e.stroke();
338
338
  });
339
339
  }
340
340
  });
341
- }), s = Q(() => Xt(n), 10);
341
+ }), s = X(() => zt(n), 10);
342
342
  return window.addEventListener("resize", s), {
343
343
  destroy: () => {
344
344
  n.remove(), s.clear(), window.removeEventListener("resize", s);
345
345
  },
346
- setVisible: (c) => {
346
+ setVisible: (a) => {
347
347
  console.log("setVisible not implemented on Canvas renderer");
348
348
  },
349
349
  redraw: o
350
350
  };
351
- }, qt = (t, n, e) => Z(t, n, e, zt(t)), jt = (t) => [
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()}`,
351
+ }, jt = (t, n, e) => J(t, n, e, qt(t)), Gt = (t) => [
352
+ `background-color:${ot((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.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,
356
356
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
357
- ].filter(Boolean).join(";"), Gt = () => {
357
+ ].filter(Boolean).join(";"), Qt = () => {
358
358
  const t = document.createElement("style");
359
359
  document.getElementsByTagName("head")[0].appendChild(t);
360
360
  let n = /* @__PURE__ */ new Set();
@@ -362,29 +362,29 @@ const st = "not-annotatable", D = `.${st}`, W = (t) => {
362
362
  destroy: () => {
363
363
  CSS.highlights.clear(), t.remove();
364
364
  },
365
- setVisible: (i) => {
365
+ setVisible: (r) => {
366
366
  console.log("setVisible not implemented on CSS Custom Highlights renderer");
367
367
  },
368
- redraw: (i, a, c, u) => {
368
+ redraw: (r, i, a, u) => {
369
369
  u && u.clear();
370
- const b = new Set(i.map((g) => g.annotation.id));
371
- Array.from(n).filter((g) => !b.has(g));
372
- const y = i.map((g) => {
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)} }`;
370
+ const S = new Set(r.map((f) => f.annotation.id));
371
+ Array.from(n).filter((f) => !S.has(f));
372
+ const b = r.map((f) => {
373
+ var x;
374
+ const p = a ? typeof a == "function" ? a(f.annotation, f.state) : a : (x = f.state) != null && x.selected ? q : P, c = u && u.paint(f, i) || p;
375
+ return `::highlight(_${f.annotation.id}) { ${Gt(c)} }`;
376
376
  });
377
- t.innerHTML = y.join(`
378
- `), CSS.highlights.clear(), i.forEach(({ annotation: g }) => {
379
- const r = g.target.selector.map((S) => S.range), A = new Highlight(...r);
380
- CSS.highlights.set(`_${g.id}`, A);
381
- }), n = b;
377
+ t.innerHTML = b.join(`
378
+ `), CSS.highlights.clear(), r.forEach(({ annotation: f }) => {
379
+ const p = f.target.selector.map((x) => x.range), c = new Highlight(...p);
380
+ CSS.highlights.set(`_${f.id}`, c);
381
+ }), n = S;
382
382
  }
383
383
  };
384
- }, Qt = (t, n, e) => Z(t, n, e, Gt()), Zt = (t, n) => {
385
- const e = (i, a) => i.x <= a.x + a.width && i.x + i.width >= a.x && i.y <= a.y + a.height && i.y + i.height >= a.y, o = (i) => i.rects.reduce((a, c) => a + c.width, 0), s = n.filter(({ rects: i }) => i.some((a) => e(t, a)));
386
- return s.sort((i, a) => o(a) - o(i)), s.findIndex((i) => i.rects.includes(t));
387
- }, Jt = (t) => {
384
+ }, Zt = (t, n, e) => J(t, n, e, Qt()), Jt = (t, n) => {
385
+ const e = (r, i) => r.x <= i.x + i.width && r.x + r.width >= i.x && r.y <= i.y + i.height && r.y + r.height >= i.y, o = (r) => r.rects.reduce((i, a) => i + a.width, 0), s = n.filter(({ rects: r }) => r.some((i) => e(t, i)));
386
+ return s.sort((r, i) => o(i) - o(r)), s.findIndex((r) => r.rects.includes(t));
387
+ }, te = (t) => {
388
388
  t.classList.add("r6o-annotatable");
389
389
  const n = document.createElement("div");
390
390
  n.className = "r6o-span-highlight-layer", t.insertBefore(n, t.firstChild);
@@ -393,513 +393,522 @@ const st = "not-annotatable", D = `.${st}`, W = (t) => {
393
393
  destroy: () => {
394
394
  n.remove();
395
395
  },
396
- redraw: (a, c, u, b, y) => {
397
- const r = !(dt(e, a) && y);
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
- if (r) {
396
+ redraw: (i, a, u, S, b) => {
397
+ const p = !(ut(e, i) && b);
398
+ if (!S && !p) return;
399
+ p && (n.innerHTML = ""), [...i].sort((x, w) => {
400
+ const { annotation: { target: { created: T } } } = x, { annotation: { target: { created: E } } } = w;
401
+ return T && E ? T.getTime() - E.getTime() : 0;
402
+ }).forEach((x) => {
403
+ x.rects.map((w) => {
404
+ const T = Jt(w, i), E = Wt(x, a, u, S, T);
405
+ if (p) {
406
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);
407
+ m.className = "r6o-annotation", m.dataset.annotation = x.annotation.id, m.style.left = `${w.x}px`, m.style.top = `${w.y}px`, m.style.width = `${w.width}px`, m.style.height = `${w.height}px`, m.style.backgroundColor = ot((E == null ? void 0 : E.fill) || P.fill).alpha((E == null ? void 0 : E.fillOpacity) === void 0 ? P.fillOpacity : E.fillOpacity).toHex(), E.underlineStyle && (m.style.borderStyle = E.underlineStyle), E.underlineColor && (m.style.borderColor = E.underlineColor), E.underlineThickness && (m.style.borderBottomWidth = `${E.underlineThickness}px`), E.underlineOffset && (m.style.paddingBottom = `${E.underlineOffset}px`), n.appendChild(m);
408
408
  }
409
409
  });
410
- }), e = a;
410
+ }), e = i;
411
411
  },
412
- setVisible: (a) => {
413
- a ? n.classList.remove("hidden") : n.classList.add("hidden");
412
+ setVisible: (i) => {
413
+ i ? n.classList.remove("hidden") : n.classList.add("hidden");
414
414
  }
415
415
  };
416
- }, te = (t, n, e) => Z(t, n, e, Jt(t)), Ae = (t, n) => ({
417
- parse: (e) => oe(e),
418
- serialize: (e) => se(e, t, n)
419
- }), ee = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, ne = (t) => {
416
+ }, ee = (t, n, e) => J(t, n, e, te(t)), ve = (t, n) => ({
417
+ parse: (e) => se(e),
418
+ serialize: (e) => re(e, t, n)
419
+ }), ne = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, oe = (t) => {
420
420
  const {
421
421
  id: n,
422
422
  creator: e,
423
423
  created: o,
424
424
  modified: s,
425
- target: i
426
- } = t, a = Array.isArray(i) ? i : [i];
427
- if (a.length === 0)
425
+ target: r
426
+ } = t, i = Array.isArray(r) ? r : [r];
427
+ if (i.length === 0)
428
428
  return { error: Error(`No targets found for annotation: ${t.id}`) };
429
- const c = {
430
- creator: gt(e),
429
+ const a = {
430
+ creator: mt(e),
431
431
  created: o ? new Date(o) : void 0,
432
432
  updated: s ? new Date(s) : void 0,
433
433
  annotation: n,
434
434
  selector: [],
435
435
  // @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
436
- styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
436
+ styleClass: "styleClass" in i[0] ? i[0].styleClass : void 0
437
437
  };
438
- for (const u of a) {
439
- const y = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((g, r) => {
440
- switch (r.type) {
438
+ for (const u of i) {
439
+ const b = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((f, p) => {
440
+ switch (p.type) {
441
441
  case "TextQuoteSelector":
442
- g.quote = r.exact;
442
+ f.quote = p.exact;
443
443
  break;
444
444
  case "TextPositionSelector":
445
- g.start = r.start, g.end = r.end;
445
+ f.start = p.start, f.end = p.end;
446
446
  break;
447
447
  }
448
- return g;
448
+ return f;
449
449
  }, {});
450
- if (c.outdated || (c.outdated = "outdated" in u ? u.outdated : void 0), ee(y))
451
- c.selector.push(
450
+ if (a.outdated || (a.outdated = "outdated" in u ? u.outdated : void 0), ne(b))
451
+ a.selector.push(
452
452
  {
453
- ...y,
453
+ ...b,
454
454
  id: u.id,
455
455
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
456
456
  scope: u.scope
457
457
  }
458
458
  );
459
459
  else {
460
- const g = [
461
- y.start ? void 0 : "TextPositionSelector",
462
- y.quote ? void 0 : "TextQuoteSelector"
460
+ const f = [
461
+ b.start ? void 0 : "TextPositionSelector",
462
+ b.quote ? void 0 : "TextQuoteSelector"
463
463
  ].filter(Boolean);
464
- return { error: Error(`Missing selector types: ${g.join(" and ")} for annotation: ${t.id}`) };
464
+ return { error: Error(`Missing selector types: ${f.join(" and ")} for annotation: ${t.id}`) };
465
465
  }
466
466
  }
467
- return { parsed: c };
468
- }, oe = (t) => {
469
- const n = t.id || ot(), {
467
+ return { parsed: a };
468
+ }, se = (t) => {
469
+ const n = t.id || st(), {
470
470
  creator: e,
471
471
  created: o,
472
472
  modified: s,
473
- body: i,
474
- ...a
475
- } = t, c = ft(i, n), u = ne(t);
473
+ body: r,
474
+ ...i
475
+ } = t, a = gt(r, n), u = oe(t);
476
476
  return "error" in u ? { error: u.error } : {
477
477
  parsed: {
478
- ...a,
478
+ ...i,
479
479
  id: n,
480
- bodies: c,
480
+ bodies: a,
481
481
  target: u.parsed
482
482
  }
483
483
  };
484
- }, se = (t, n, e) => {
485
- const { bodies: o, target: s, ...i } = t, {
486
- selector: a,
487
- creator: c,
484
+ }, re = (t, n, e) => {
485
+ const { bodies: o, target: s, ...r } = t, {
486
+ selector: i,
487
+ creator: a,
488
488
  created: u,
489
- updated: b,
490
- ...y
491
- } = s, g = a.map((r) => {
492
- const { id: A, quote: S, start: T, end: x, range: C } = r, m = {
489
+ updated: S,
490
+ ...b
491
+ } = s, f = i.map((p) => {
492
+ const { id: c, quote: x, start: w, end: T, range: E } = p, m = {
493
493
  type: "TextQuoteSelector",
494
- exact: S
494
+ exact: x
495
495
  };
496
496
  if (e) {
497
- const { prefix: f, suffix: l } = Nt(C, e);
498
- m.prefix = f, m.suffix = l;
497
+ const { prefix: g, suffix: d } = Ot(E, e);
498
+ m.prefix = g, m.suffix = d;
499
499
  }
500
- const d = {
500
+ const l = {
501
501
  type: "TextPositionSelector",
502
- start: T,
503
- end: x
502
+ start: w,
503
+ end: T
504
504
  };
505
505
  return {
506
- ...y,
507
- id: A,
506
+ ...b,
507
+ id: c,
508
508
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
509
- scope: "scope" in r ? r.scope : void 0,
509
+ scope: "scope" in p ? p.scope : void 0,
510
510
  source: n,
511
- selector: [m, d]
511
+ selector: [m, l]
512
512
  };
513
513
  });
514
514
  return {
515
- ...i,
515
+ ...r,
516
516
  "@context": "http://www.w3.org/ns/anno.jsonld",
517
517
  id: t.id,
518
518
  type: "Annotation",
519
- body: ut(t.bodies),
520
- creator: c,
519
+ body: ft(t.bodies),
520
+ creator: a,
521
521
  created: u == null ? void 0 : u.toISOString(),
522
- modified: b == null ? void 0 : b.toISOString(),
523
- target: g
522
+ modified: S == null ? void 0 : S.toISOString(),
523
+ target: f
524
524
  };
525
- }, re = (t, n) => {
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;
525
+ }, ie = (t, n) => {
526
+ const e = new wt(), o = /* @__PURE__ */ new Map(), s = vt(), r = (l, g) => {
527
+ const d = l.selector.flatMap((A) => {
528
+ const v = M([A]) ? A.range : it(A, n).range;
529
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;
530
+ }), y = Dt(d).map((A) => Ft(A, g));
531
+ return y.map((A) => {
532
+ const { x: v, y: C, width: k, height: B } = A;
533
533
  return {
534
534
  minX: v,
535
- minY: E,
536
- maxX: v + L,
537
- maxY: E + I,
535
+ minY: C,
536
+ maxX: v + k,
537
+ maxY: C + B,
538
538
  annotation: {
539
- id: d.annotation,
540
- rects: h
539
+ id: l.annotation,
540
+ rects: y
541
541
  }
542
542
  };
543
543
  });
544
- }, a = () => [...o.values()], c = () => {
544
+ }, i = () => [...o.values()], a = () => {
545
545
  e.clear(), o.clear();
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);
546
+ }, u = (l) => {
547
+ const g = r(l, n.getBoundingClientRect());
548
+ g.length !== 0 && (g.forEach((d) => e.insert(d)), o.set(l.annotation, g));
549
+ }, S = (l) => {
550
+ const g = o.get(l.annotation);
551
+ g && (g.forEach((d) => e.remove(d)), o.delete(l.annotation));
552
+ }, b = (l) => {
553
+ S(l), u(l);
554
+ }, f = (l, g = !0) => {
555
+ g && a();
556
+ const d = n.getBoundingClientRect(), y = l.map((v) => ({ target: v, rects: r(v, d) }));
557
+ y.forEach(({ target: v, rects: C }) => {
558
+ C.length > 0 && o.set(v.annotation, C);
559
559
  });
560
- const w = h.flatMap(({ rects: v }) => v);
561
- e.load(w);
562
- }, r = (d, f, l = !1) => {
563
- const h = e.search({
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)
560
+ const A = y.flatMap(({ rects: v }) => v);
561
+ e.load(A);
562
+ }, p = (l, g, d = !1) => {
563
+ const y = e.search({
564
+ minX: l,
565
+ minY: g,
566
+ maxX: l,
567
+ maxY: g
568
+ }), A = (v) => v.annotation.rects.reduce((C, k) => C + k.width * k.height, 0);
569
+ return y.length > 0 ? (y.sort((v, C) => A(v) - A(C)), d ? y.map((v) => v.annotation.id) : [y[0].annotation.id]) : [];
570
+ }, c = (l) => {
571
+ const g = x(l);
572
+ if (g.length === 0)
573
573
  return;
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
+ let d = g[0].left, y = g[0].top, A = g[0].right, v = g[0].bottom;
575
+ for (let C = 1; C < g.length; C++) {
576
+ const k = g[C];
577
+ d = Math.min(d, k.left), y = Math.min(y, k.top), A = Math.max(A, k.right), v = Math.max(v, k.bottom);
578
578
  }
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
+ return new DOMRect(d, y, A - d, v - y);
580
+ }, x = (l) => {
581
+ const g = o.get(l);
582
+ return g ? g[0].annotation.rects : [];
583
583
  };
584
584
  return {
585
- all: a,
586
- clear: c,
587
- getAt: r,
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);
585
+ all: i,
586
+ clear: a,
587
+ getAt: p,
588
+ getAnnotationBounds: c,
589
+ getAnnotationRects: x,
590
+ getIntersecting: (l, g, d, y) => {
591
+ const A = e.search({ minX: l, minY: g, maxX: d, maxY: y }), v = new Set(A.map((C) => C.annotation.id));
592
+ return Array.from(v).map((C) => ({
593
+ annotation: t.getAnnotation(C),
594
+ rects: x(C)
595
+ })).filter((C) => !!C.annotation);
596
596
  },
597
597
  insert: u,
598
598
  recalculate: () => {
599
- g(t.all().map((d) => d.target), !0), s.emit("recalculate");
599
+ f(t.all().map((l) => l.target), !0), s.emit("recalculate");
600
600
  },
601
- remove: b,
602
- set: g,
601
+ remove: S,
602
+ set: f,
603
603
  size: () => e.all().length,
604
- update: y,
605
- on: (d, f) => s.on(d, f)
604
+ update: b,
605
+ on: (l, g) => s.on(l, g)
606
606
  };
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 = (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);
607
+ }, ae = (t, n) => {
608
+ const e = pt(), o = ie(e, t), s = ht(e, n.userSelectAction, n.adapter), r = yt(e), i = bt(), a = (m, l = _.LOCAL) => {
609
+ const g = G(m, t), d = M(g.target.selector);
610
+ return d && e.addAnnotation(g, l), d;
611
+ }, u = (m, l = !0, g = _.LOCAL) => {
612
+ const d = m.map((A) => G(A, t)), y = d.filter((A) => !M(A.target.selector));
613
+ return e.bulkAddAnnotations(d, l, g), y;
614
+ }, S = (m, l = _.LOCAL) => {
615
+ const g = m.map((y) => G(y, t)), d = g.filter((y) => !M(y.target.selector));
616
+ return g.forEach((y) => {
617
+ e.getAnnotation(y.id) ? e.updateAnnotation(y, l) : e.addAnnotation(y, l);
618
+ }), d;
619
+ }, b = (m, l = _.LOCAL) => {
620
+ const g = z(m, t);
621
+ e.updateTarget(g, l);
622
+ }, f = (m, l = _.LOCAL) => {
623
+ const g = m.map((d) => z(d, t));
624
+ e.bulkUpdateTargets(g, l);
625
625
  };
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;
626
+ function p(m, l, g, d) {
627
+ const y = g || !!d, A = o.getAt(m, l, y).map((C) => e.getAnnotation(C)), v = d ? A.filter(d) : A;
628
628
  if (v.length !== 0)
629
- return f ? v : v[0];
629
+ return g ? v : v[0];
630
630
  }
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);
631
+ const c = (m) => o.getAnnotationRects(m).length > 0 ? o.getAnnotationBounds(m) : void 0, x = (m, l, g, d) => o.getIntersecting(m, l, g, d), w = (m) => o.getAnnotationRects(m), T = () => o.recalculate(), E = (m) => o.on("recalculate", m);
632
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));
633
+ const l = (m.deleted || []).filter((y) => M(y.target.selector)), g = (m.created || []).filter((y) => M(y.target.selector)), d = (m.updated || []).filter((y) => M(y.newValue.target.selector));
634
+ (l == null ? void 0 : l.length) > 0 && l.forEach((y) => o.remove(y.target)), g.length > 0 && o.set(g.map((y) => y.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: y }) => o.update(y.target));
635
635
  }), {
636
636
  store: {
637
637
  ...e,
638
- addAnnotation: c,
638
+ addAnnotation: a,
639
639
  bulkAddAnnotations: u,
640
- bulkUpdateTargets: g,
641
- bulkUpsertAnnotations: b,
642
- getAnnotationBounds: A,
643
- getAnnotationRects: T,
644
- getIntersecting: S,
645
- getAt: r,
646
- recalculatePositions: x,
647
- onRecalculatePositions: C,
648
- updateTarget: y
640
+ bulkUpdateTargets: f,
641
+ bulkUpsertAnnotations: S,
642
+ getAnnotationBounds: c,
643
+ getAnnotationRects: w,
644
+ getIntersecting: x,
645
+ getAt: p,
646
+ recalculatePositions: T,
647
+ onRecalculatePositions: E,
648
+ updateTarget: b
649
649
  },
650
650
  selection: s,
651
- hover: i,
652
- viewport: a
651
+ hover: r,
652
+ viewport: i
653
653
  };
654
- }, ae = () => {
654
+ }, ce = () => {
655
655
  const t = document.createElement("canvas");
656
656
  t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
657
657
  const n = t.getContext("2d");
658
658
  return n.scale(2, 2), n.translate(0.5, 0.5), t;
659
- }, ce = (t, n = {}) => {
660
- const e = ae(), o = e.getContext("2d");
659
+ }, le = (t, n = {}) => {
660
+ const e = ce(), o = e.getContext("2d");
661
661
  document.body.appendChild(e);
662
- const s = /* @__PURE__ */ new Map(), i = (y) => Array.from(s.entries()).filter(([g, r]) => r.presenceKey === y.presenceKey).map(([g, r]) => g);
663
- return t.on("selectionChange", (y, g) => {
664
- i(y).forEach((A) => s.delete(A)), g && g.forEach((A) => s.set(A, y));
662
+ const s = /* @__PURE__ */ new Map(), r = (b) => Array.from(s.entries()).filter(([f, p]) => p.presenceKey === b.presenceKey).map(([f, p]) => f);
663
+ return t.on("selectionChange", (b, f) => {
664
+ r(b).forEach((c) => s.delete(c)), f && f.forEach((c) => s.set(c, b));
665
665
  }), {
666
666
  clear: () => {
667
- const { width: y, height: g } = e;
668
- o.clearRect(-0.5, -0.5, y + 1, g + 1);
667
+ const { width: b, height: f } = e;
668
+ o.clearRect(-0.5, -0.5, b + 1, f + 1);
669
669
  },
670
670
  destroy: () => {
671
671
  e.remove();
672
672
  },
673
- paint: (y, g, r) => {
673
+ paint: (b, f, p) => {
674
674
  n.font && (o.font = n.font);
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
- fillOpacity: r ? 0.45 : 0.18
675
+ const c = s.get(b.annotation.id);
676
+ if (c) {
677
+ const { height: x } = b.rects[0], w = b.rects[0].x + f.left, T = b.rects[0].y + f.top;
678
+ o.fillStyle = c.appearance.color, o.fillRect(w - 2, T - 2.5, 2, x + 5);
679
+ const E = o.measureText(c.appearance.label), m = E.width + 6, l = E.actualBoundingBoxAscent + E.actualBoundingBoxDescent + 8, g = E.fontBoundingBoxAscent ? 8 : 6.5;
680
+ return o.fillRect(w - 2, T - 2.5 - l, m, l), o.fillStyle = "#fff", o.fillText(c.appearance.label, w + 1, T - g), {
681
+ fill: c.appearance.color,
682
+ fillOpacity: p ? 0.45 : 0.18
683
683
  };
684
684
  }
685
685
  },
686
686
  reset: () => {
687
687
  e.width = 2 * window.innerWidth, e.height = 2 * window.innerHeight;
688
- const y = e.getContext("2d");
689
- y.scale(2, 2), y.translate(0.5, 0.5);
688
+ const b = e.getContext("2d");
689
+ b.scale(2, 2), b.translate(0.5, 0.5);
690
690
  }
691
691
  };
692
- }, tt = 300, ct = ["up", "down", "left", "right"], lt = Rt ? "⌘+a" : "ctrl+a", le = [
693
- ...ct.map((t) => `shift+${t}`),
694
- lt
695
- ], de = (t, n, e) => {
692
+ }, et = 300, lt = ["up", "down", "left", "right"], dt = Lt ? "⌘+a" : "ctrl+a", de = [
693
+ ...lt.map((t) => `shift+${t}`),
694
+ dt
695
+ ], ue = (t, n, e) => {
696
696
  const { store: o, selection: s } = n;
697
- let i;
698
- const { annotatingEnabled: a, offsetReferenceSelector: c, selectionMode: u } = e, b = (p) => i = p;
699
- let y;
700
- const g = (p) => y = p;
701
- let r, A, S, T = a;
702
- const x = (p) => {
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
- annotation: ot(),
697
+ let r;
698
+ const {
699
+ annotatingEnabled: i,
700
+ offsetReferenceSelector: a,
701
+ selectionMode: u,
702
+ dismissOnNotAnnotatable: S = "ANNOTATABLE_AREAS"
703
+ } = e, b = (h) => r = h;
704
+ let f;
705
+ const p = (h) => f = h;
706
+ let c, x, w, T = i;
707
+ const E = (h) => {
708
+ T = h, l.clear(), h || (c = void 0, x = void 0, w = void 0);
709
+ }, m = (h) => {
710
+ T && x !== !1 && (c = U(t, h.target) ? void 0 : {
711
+ annotation: st(),
707
712
  selector: [],
708
- creator: i,
713
+ creator: r,
709
714
  created: /* @__PURE__ */ new Date()
710
715
  });
711
- }, m = Q((p) => {
716
+ }, l = X((h) => {
712
717
  if (!T) return;
713
718
  const R = document.getSelection();
714
719
  if (!(R != null && R.anchorNode))
715
720
  return;
716
- if (W(R.anchorNode)) {
717
- r = void 0;
721
+ if (U(t, R.anchorNode)) {
722
+ c = void 0;
718
723
  return;
719
724
  }
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;
725
+ const O = h.timeStamp - ((w == null ? void 0 : w.timeStamp) || h.timeStamp);
726
+ if ((w == null ? void 0 : w.type) === "pointerdown" && (O < 1e3 && !c || R.isCollapsed && O < et) && m(w || h), !c) return;
722
727
  if (R.isCollapsed) {
723
- o.getAnnotation(r.annotation) && (s.clear(), o.deleteAnnotation(r.annotation));
728
+ o.getAnnotation(c.annotation) && (s.clear(), o.deleteAnnotation(c.annotation));
724
729
  return;
725
730
  }
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
- })) && (r = {
733
- ...r,
734
- selector: O.map((P) => Kt(P, t, c)),
731
+ const H = Array.from(Array(R.rangeCount).keys()).map((N) => R.getRangeAt(N)).map((N) => $t(N, t));
732
+ if (H.every((N) => Mt(N))) return;
733
+ const L = H.flatMap((N) => Bt(t, N.cloneRange()));
734
+ (L.length !== c.selector.length || L.some((N, K) => {
735
+ var j;
736
+ return N.toString() !== ((j = c.selector[K]) == null ? void 0 : j.quote);
737
+ })) && (c = {
738
+ ...c,
739
+ selector: L.map((N) => Kt(N, t, a)),
735
740
  updated: /* @__PURE__ */ new Date()
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
+ }, o.getAnnotation(c.annotation) ? o.updateTarget(c, _.LOCAL) : s.clear());
742
+ }, 10), g = (h) => {
743
+ U(t, h.target) || (w = Q(h), x = w.button === 0);
744
+ }, d = async (h) => {
745
+ if (!x) return;
746
+ if (U(t, h.target)) {
747
+ (typeof S == "function" ? S(h, t) : S === "ALWAYS") && s.clear();
748
+ return;
749
+ }
741
750
  const R = () => {
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);
751
+ const { x: I, y: H } = t.getBoundingClientRect(), L = h.target instanceof Node && t.contains(h.target) && o.getAt(h.clientX - I, h.clientY - H, u === "all", f);
752
+ if (L) {
753
+ const { selected: W } = s, N = new Set(W.map((F) => F.id)), K = Array.isArray(L) ? L.map((F) => F.id) : [L.id];
754
+ (N.size !== K.length || !K.every((F) => N.has(F))) && s.userSelect(K, h);
746
755
  } else
747
756
  s.clear();
748
757
  };
749
- if (p.timeStamp - S.timeStamp < tt) {
750
- await l();
751
- const B = document.getSelection();
752
- if (B != null && B.isCollapsed) {
753
- r = void 0, R();
758
+ if (h.timeStamp - w.timeStamp < et) {
759
+ await y();
760
+ const I = document.getSelection();
761
+ if (I != null && I.isCollapsed) {
762
+ c = void 0, R();
754
763
  return;
755
764
  }
756
765
  }
757
- r && r.selector.length > 0 && (L(), s.userSelect(r.annotation, j(p)));
758
- }, l = async () => {
759
- const p = document.getSelection();
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
- }, h = (p) => {
766
+ c && c.selector.length > 0 && (B(), s.userSelect(c.annotation, Q(h)));
767
+ }, y = async () => {
768
+ const h = document.getSelection();
769
+ let R = !1, O = h == null ? void 0 : h.isCollapsed;
770
+ const I = () => O || R, H = 1;
771
+ return setTimeout(() => R = !0, 50), xt(() => O = h == null ? void 0 : h.isCollapsed, H, I);
772
+ }, A = (h) => {
764
773
  const R = document.getSelection();
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) => {
774
+ R != null && R.isCollapsed || ((!c || c.selector.length === 0) && l(h), c && (B(), s.userSelect(c.annotation, Q(h))));
775
+ }, v = (h) => {
776
+ T && h.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, Y(h))));
777
+ }, C = (h) => {
769
778
  const R = () => setTimeout(() => {
770
- (r == null ? void 0 : r.selector.length) > 0 && (s.clear(), o.addAnnotation({
771
- id: r.annotation,
779
+ (c == null ? void 0 : c.selector.length) > 0 && (s.clear(), o.addAnnotation({
780
+ id: c.annotation,
772
781
  bodies: [],
773
- target: r
774
- }), s.userSelect(r.annotation, Y(p))), document.removeEventListener("selectionchange", R);
782
+ target: c
783
+ }), s.userSelect(c.annotation, Y(h))), document.removeEventListener("selectionchange", R);
775
784
  }, 100);
776
- document.addEventListener("selectionchange", R), C(p);
785
+ document.addEventListener("selectionchange", R), m(h);
777
786
  };
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);
787
+ V(de.join(","), { element: t, keydown: !0, keyup: !1 }, (h) => {
788
+ h.repeat || (w = Y(h));
789
+ }), V(dt, { keydown: !0, keyup: !1 }, (h) => {
790
+ w = Y(h), C(h);
782
791
  });
783
- const E = (p) => {
784
- p.repeat || p.target !== t && p.target !== document.body || (r = void 0, s.clear());
792
+ const k = (h) => {
793
+ h.repeat || h.target !== t && h.target !== document.body || (c = void 0, s.clear());
785
794
  };
786
- V(ct.join(","), { keydown: !0, keyup: !1 }, E);
787
- const L = () => {
788
- const p = o.getAnnotation(r.annotation);
789
- if (!p) {
795
+ V(lt.join(","), { keydown: !0, keyup: !1 }, k);
796
+ const B = () => {
797
+ const h = o.getAnnotation(c.annotation);
798
+ if (!h) {
790
799
  o.addAnnotation({
791
- id: r.annotation,
800
+ id: c.annotation,
792
801
  bodies: [],
793
- target: r
802
+ target: c
794
803
  });
795
804
  return;
796
805
  }
797
- const { target: { updated: R } } = p, { updated: k } = r;
798
- (!R || !k || R < k) && o.updateTarget(r);
806
+ const { target: { updated: R } } = h, { updated: O } = c;
807
+ (!R || !O || R < O) && o.updateTarget(c);
799
808
  };
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), {
809
+ return document.addEventListener("pointerdown", g), document.addEventListener("pointerup", d), document.addEventListener("contextmenu", A), t.addEventListener("keyup", v), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", l), {
801
810
  destroy: () => {
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();
811
+ c = void 0, x = void 0, w = void 0, l.clear(), document.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", d), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", v), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", l), V.unbind();
803
812
  },
804
- setFilter: g,
813
+ setFilter: p,
805
814
  setUser: b,
806
- setAnnotatingEnabled: x
815
+ setAnnotatingEnabled: E
807
816
  };
808
- }, ue = (t, n) => ({
817
+ }, fe = (t, n) => ({
809
818
  ...t,
810
819
  annotatingEnabled: t.annotatingEnabled ?? n.annotatingEnabled,
811
820
  user: t.user || n.user
812
- }), et = "SPANS", ve = (t, n = {}) => {
813
- Tt(t), Lt(t);
814
- const e = ue(n, {
821
+ }), nt = "SPANS", xe = (t, n = {}) => {
822
+ Rt(t), kt(t);
823
+ const e = fe(n, {
815
824
  annotatingEnabled: !0,
816
- user: bt()
817
- }), o = ie(t, e), { selection: s, viewport: i } = o, a = o.store, c = St(a), u = Ct(o, c, e.adapter);
818
- let b = e.user;
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
- if (!g)
821
- throw `Unknown renderer implementation: ${y}`;
822
- console.debug(`Using ${y} renderer`), e.style && g.setStyle(e.style);
823
- const r = de(t, o, e);
824
- r.setUser(b), r.setAnnotatingEnabled(e.annotatingEnabled);
825
- const A = Et(o, c, e.adapter), S = () => b, T = (l) => {
826
- r.setAnnotatingEnabled(
827
- l === void 0 ? !0 : l
825
+ user: St()
826
+ }), o = ae(t, e), { selection: s, viewport: r } = o, i = o.store, a = Ct(i), u = Et(o, a, e.adapter);
827
+ let S = e.user;
828
+ const b = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : nt : e.renderer || nt, f = b === "SPANS" ? ee(t, o, r) : b === "CSS_HIGHLIGHTS" ? Zt(t, o, r) : b === "CANVAS" ? jt(t, o, r) : void 0;
829
+ if (!f)
830
+ throw `Unknown renderer implementation: ${b}`;
831
+ console.debug(`Using ${b} renderer`), e.style && f.setStyle(e.style);
832
+ const p = ue(t, o, e);
833
+ p.setUser(S), p.setAnnotatingEnabled(e.annotatingEnabled);
834
+ const c = At(o, a, e.adapter), x = () => S, w = (d) => {
835
+ p.setAnnotatingEnabled(
836
+ d === void 0 ? !0 : d
828
837
  );
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();
838
+ }, T = (d) => {
839
+ f.setFilter(d), p.setFilter(d);
840
+ }, E = (d) => {
841
+ S = d, p.setUser(d);
842
+ }, m = (d) => {
843
+ d && (f.setPainter(le(d, e.presence)), d.on("selectionChange", () => f.redraw()));
844
+ }, l = (d) => {
845
+ d ? s.setSelected(d) : s.clear();
837
846
  };
838
847
  return {
839
- ...A,
848
+ ...c,
840
849
  destroy: () => {
841
- g.destroy(), r.destroy(), c.destroy();
850
+ f.destroy(), p.destroy(), a.destroy();
842
851
  },
843
852
  element: t,
844
- getUser: S,
845
- setAnnotatingEnabled: T,
846
- setFilter: x,
847
- setStyle: g.setStyle.bind(g),
848
- redraw: g.redraw.bind(g),
849
- setUser: C,
850
- setSelected: d,
853
+ getUser: x,
854
+ setAnnotatingEnabled: w,
855
+ setFilter: T,
856
+ setStyle: f.setStyle.bind(f),
857
+ redraw: f.redraw.bind(f),
858
+ setUser: E,
859
+ setSelected: l,
851
860
  setPresenceProvider: m,
852
- setVisible: g.setVisible.bind(g),
861
+ setVisible: f.setVisible.bind(f),
853
862
  on: u.on,
854
863
  off: u.off,
855
- scrollIntoView: Ft(t, a),
864
+ scrollIntoView: Ut(t, i),
856
865
  state: o
857
866
  };
858
867
  };
859
868
  export {
860
- z as DEFAULT_SELECTED_STYLE,
861
- K as DEFAULT_STYLE,
862
- st as NOT_ANNOTATABLE_CLASS,
863
- D as NOT_ANNOTATABLE_SELECTOR,
864
- Re as Origin,
865
- Le as UserSelectAction,
866
- Ae as W3CTextFormat,
867
- Tt as cancelSingleClickEvents,
869
+ q as DEFAULT_SELECTED_STYLE,
870
+ P as DEFAULT_STYLE,
871
+ rt as NOT_ANNOTATABLE_CLASS,
872
+ $ as NOT_ANNOTATABLE_SELECTOR,
873
+ Le as Origin,
874
+ ke as UserSelectAction,
875
+ ve as W3CTextFormat,
876
+ Rt as cancelSingleClickEvents,
868
877
  Y as cloneKeyboardEvent,
869
- j as clonePointerEvent,
870
- ke as createBody,
871
- qt as createCanvasRenderer,
872
- Qt as createHighlightsRenderer,
873
- ce as createPresencePainter,
874
- Gt as createRenderer,
875
- de as createSelectionHandler,
876
- te as createSpansRenderer,
877
- ve as createTextAnnotator,
878
- ie as createTextAnnotatorState,
879
- ue as fillDefaults,
880
- Nt as getQuoteContext,
881
- G as getRangeAnnotatableContents,
882
- Rt as isMac,
883
- W as isNotAnnotatable,
884
- xt as isRangeAnnotatable,
878
+ Q as clonePointerEvent,
879
+ Ne as createBody,
880
+ jt as createCanvasRenderer,
881
+ Zt as createHighlightsRenderer,
882
+ le as createPresencePainter,
883
+ Qt as createRenderer,
884
+ ue as createSelectionHandler,
885
+ ee as createSpansRenderer,
886
+ xe as createTextAnnotator,
887
+ ae as createTextAnnotatorState,
888
+ fe as fillDefaults,
889
+ Ot as getQuoteContext,
890
+ Z as getRangeAnnotatableContents,
891
+ Lt as isMac,
892
+ U as isNotAnnotatable,
893
+ Tt as isRangeAnnotatable,
885
894
  M as isRevived,
886
- It as isWhitespaceOrEmpty,
887
- Pt as mergeClientRects,
888
- Ut as paint,
889
- oe as parseW3CTextAnnotation,
890
- Lt as programmaticallyFocusable,
891
- $t as rangeContains,
895
+ Mt as isWhitespaceOrEmpty,
896
+ Dt as mergeClientRects,
897
+ Wt as paint,
898
+ se as parseW3CTextAnnotation,
899
+ kt as programmaticallyFocusable,
900
+ _t as rangeContains,
892
901
  Kt as rangeToSelector,
893
- q as reviveAnnotation,
894
- rt as reviveSelector,
895
- X as reviveTarget,
896
- Ft as scrollIntoView,
897
- se as serializeW3CTextAnnotation,
902
+ G as reviveAnnotation,
903
+ it as reviveSelector,
904
+ z as reviveTarget,
905
+ Ut as scrollIntoView,
906
+ re as serializeW3CTextAnnotation,
898
907
  Bt as splitAnnotatableRanges,
899
- Ee as toDomRectList,
900
- Dt as toParentBounds,
908
+ Ae as toDomRectList,
909
+ Ft as toParentBounds,
901
910
  we as toViewportBounds,
902
- _t as trimRangeToContainer,
903
- Ot as whitespaceOrEmptyRegex
911
+ $t as trimRangeToContainer,
912
+ It as whitespaceOrEmptyRegex
904
913
  };
905
914
  //# sourceMappingURL=text-annotator.es.js.map