@recogito/text-annotator 3.0.0-rc.19 → 3.0.0-rc.20

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,4 +1,4 @@
1
- import { HighlightStyleExpression } from './highlight/HighlightStyle';
1
+ import { HighlightStyleExpression } from './highlight';
2
2
  import { TextAnnotation } from './model';
3
3
  import { PresencePainterOptions } from './presence';
4
4
  import { FormatAdapter, PointerSelectAction } from '@annotorious/core';
@@ -7,7 +7,7 @@ import { Filter, ViewportState } from '@annotorious/core';
7
7
 
8
8
  export interface RendererImplementation {
9
9
  destroy(): void;
10
- redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, force?: boolean): void;
10
+ redraw(highlights: Highlight[], bounds: ViewportBounds, style?: HighlightStyleExpression, painter?: HighlightPainter, lazy?: boolean): void;
11
11
  setVisible(visible: boolean): void;
12
12
  }
13
13
  export interface Renderer {
@@ -1,3 +1,6 @@
1
+ export * from './Highlight';
2
+ export * from './HighlightStyle';
3
+ export * from './HighlightPainter';
1
4
  export * from './canvas';
2
5
  export * from './highlights';
3
6
  export * from './span';
@@ -1,4 +1,4 @@
1
- import { _Origin } from '@annotorious/core';
1
+ import { Origin as _Origin } from '@annotorious/core';
2
2
  export * from './highlight';
3
3
  export * from './model';
4
4
  export * from './state';
@@ -1,3 +1,4 @@
1
+ export declare const NOT_ANNOTATABLE_CLASS = "not-annotatable";
1
2
  export declare const NOT_ANNOTATABLE_SELECTOR = ".not-annotatable";
2
3
  /**
3
4
  * Splits a DOM Range into one or more ranges that span annotatable content only.
@@ -1,13 +1,23 @@
1
- const dt = (t, e = 10) => {
1
+ const D = {
2
+ fill: "rgb(0, 128, 255)",
3
+ fillOpacity: 0.18
4
+ }, dt = {
5
+ fill: "rgb(0, 128, 255)",
6
+ fillOpacity: 0.45
7
+ }, zt = (t, e, n, o, i) => {
8
+ var s;
9
+ const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (s = t.state) != null && s.selected ? dt : D;
10
+ return o && o.paint(t, e) || r;
11
+ }, ut = (t, e = 10) => {
2
12
  let n;
3
13
  return (...o) => {
4
14
  clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
5
15
  };
6
- }, Nt = "not-annotatable", D = `.${Nt}`, zt = (t) => {
16
+ }, Nt = "not-annotatable", H = `.${Nt}`, Ft = (t) => {
7
17
  var n;
8
18
  const e = t.commonAncestorContainer;
9
- return e instanceof HTMLElement ? !e.closest(D) : !((n = e.parentElement) != null && n.closest(D));
10
- }, Ft = function* (t) {
19
+ return e instanceof HTMLElement ? !e.closest(H) : !((n = e.parentElement) != null && n.closest(H));
20
+ }, Wt = function* (t) {
11
21
  const e = document.createNodeIterator(
12
22
  t.commonAncestorContainer,
13
23
  NodeFilter.SHOW_ELEMENT,
@@ -16,12 +26,12 @@ const dt = (t, e = 10) => {
16
26
  let n;
17
27
  for (; n = e.nextNode(); )
18
28
  n instanceof HTMLElement && (yield n);
19
- }, Wt = (t) => {
20
- if (!zt(t))
29
+ }, qt = (t) => {
30
+ if (!Ft(t))
21
31
  return [];
22
32
  const e = [];
23
33
  let n = null;
24
- for (const o of Ft(t)) {
34
+ for (const o of Wt(t)) {
25
35
  let i;
26
36
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
27
37
  }
@@ -32,10 +42,10 @@ const dt = (t, e = 10) => {
32
42
  return e.length > 0 ? e : [t];
33
43
  }, ct = (t) => {
34
44
  const e = t.cloneContents();
35
- return e.querySelectorAll(D).forEach((n) => n.remove()), e;
45
+ return e.querySelectorAll(H).forEach((n) => n.remove()), e;
36
46
  }, wn = (t) => {
37
47
  const e = t.cloneContents();
38
- return e.querySelectorAll(D).forEach((n) => n.remove()), e;
48
+ return e.querySelectorAll(H).forEach((n) => n.remove()), e;
39
49
  }, gt = (t, e) => {
40
50
  const n = document.createNodeIterator(e);
41
51
  let o = 0, i = n.nextNode();
@@ -50,7 +60,7 @@ const dt = (t, e = 10) => {
50
60
  for (let i = 0; i < t + 1; i++)
51
61
  o = n.nextNode();
52
62
  return o;
53
- }, qt = (t) => {
63
+ }, jt = (t) => {
54
64
  const {
55
65
  commonAncestorContainer: e,
56
66
  startContainer: n,
@@ -76,14 +86,14 @@ const dt = (t, e = 10) => {
76
86
  c.selectNodeContents(n), c.setStart(n, o);
77
87
  const m = v(c), g = document.createRange();
78
88
  g.selectNode(i), g.setEnd(i, r);
79
- const y = v(g), w = jt(t).reverse().map((l) => {
89
+ const y = v(g), w = Gt(t).reverse().map((l) => {
80
90
  var f;
81
91
  const d = document.createElement("SPAN");
82
92
  return (f = l.parentNode) == null || f.insertBefore(d, l), d.appendChild(l), d;
83
93
  });
84
94
  return { unwrap: h, nodes: [m, ...w, y] };
85
95
  }
86
- }, jt = (t) => {
96
+ }, Gt = (t) => {
87
97
  const {
88
98
  commonAncestorContainer: e,
89
99
  startContainer: n,
@@ -99,10 +109,10 @@ const dt = (t, e = 10) => {
99
109
  if (e === n)
100
110
  return Array.from(t.getClientRects());
101
111
  {
102
- const { unwrap: o, nodes: i } = qt(t), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
112
+ const { unwrap: o, nodes: i } = jt(t), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
103
113
  return o(), r;
104
114
  }
105
- }, Gt = (t, e, n = 10, o) => {
115
+ }, Kt = (t, e, n = 10, o) => {
106
116
  const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
107
117
  r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
108
118
  const s = ct(r).textContent, a = document.createRange();
@@ -112,7 +122,7 @@ const dt = (t, e = 10) => {
112
122
  prefix: s.substring(s.length - n),
113
123
  suffix: u.substring(0, n)
114
124
  };
115
- }, k = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Kt = (t, e) => {
125
+ }, k = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Qt = (t, e) => {
116
126
  const n = (r) => Math.round(r * 10) / 10, o = {
117
127
  top: n(t.top),
118
128
  bottom: n(t.bottom),
@@ -136,17 +146,17 @@ const dt = (t, e = 10) => {
136
146
  return "block-contains";
137
147
  } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
138
148
  return "block-is-contained";
139
- }, Qt = (t, e) => {
149
+ }, Jt = (t, e) => {
140
150
  const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
141
151
  return new DOMRect(n, i, o - n, r - i);
142
- }, Jt = (t) => t.reduce((e, n) => {
152
+ }, Zt = (t) => t.reduce((e, n) => {
143
153
  if (n.width === 0 || n.height === 0)
144
154
  return e;
145
155
  let o = [...e], i = !1;
146
156
  for (const r of e) {
147
- const s = Kt(n, r);
157
+ const s = Qt(n, r);
148
158
  if (s === "inline-adjacent") {
149
- o = o.map((a) => a === r ? Qt(n, r) : a), i = !0;
159
+ o = o.map((a) => a === r ? Jt(n, r) : a), i = !0;
150
160
  break;
151
161
  } else if (s === "inline-contains") {
152
162
  o = o.map((a) => a === r ? n : a), i = !0;
@@ -160,7 +170,7 @@ const dt = (t, e = 10) => {
160
170
  }
161
171
  }
162
172
  return i ? o : [...o, n];
163
- }, []), Zt = (t, e, n) => {
173
+ }, []), te = (t, e, n) => {
164
174
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
165
175
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
166
176
  const r = ct(o).textContent, s = t.toString(), a = r.length || 0, u = a + s.length;
@@ -172,7 +182,7 @@ const dt = (t, e = 10) => {
172
182
  NodeFilter.SHOW_TEXT,
173
183
  (m) => {
174
184
  var g;
175
- return (g = m.parentElement) != null && g.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
185
+ return (g = m.parentElement) != null && g.closest(H) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
176
186
  }
177
187
  );
178
188
  let s = 0;
@@ -206,7 +216,7 @@ const dt = (t, e = 10) => {
206
216
  }, Z = (t, e) => k(t.selector) ? t : {
207
217
  ...t,
208
218
  selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Bt(n, e))
209
- }, tt = (t, e) => k(t.target.selector) ? t : { ...t, target: Z(t.target, e) }, te = (t) => {
219
+ }, tt = (t, e) => k(t.target.selector) ? t : { ...t, target: Z(t.target, e) }, ee = (t) => {
210
220
  var i;
211
221
  const { startContainer: e, endContainer: n } = t;
212
222
  if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)
@@ -220,16 +230,10 @@ const dt = (t, e = 10) => {
220
230
  t.setEnd(s, ((i = s == null ? void 0 : s.textContent) == null ? void 0 : i.length) || 0);
221
231
  }
222
232
  return t;
223
- }, H = {
224
- fill: "rgb(0, 128, 255)",
225
- fillOpacity: 0.18
226
- }, ut = {
227
- fill: "rgb(0, 128, 255)",
228
- fillOpacity: 0.45
229
- }, ee = (t) => {
233
+ }, ne = (t) => {
230
234
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -e, a = o - n, u = i - e;
231
235
  return { top: e, left: n, minX: r, minY: s, maxX: a, maxY: u };
232
- }, ne = (t) => {
236
+ }, oe = (t) => {
233
237
  let e = /* @__PURE__ */ new Set();
234
238
  return (o) => {
235
239
  const i = o.map((r) => r.id);
@@ -238,14 +242,14 @@ const dt = (t, e = 10) => {
238
242
  }, ht = (t, e, n, o) => {
239
243
  const { store: i, selection: r, hover: s } = e;
240
244
  let a, u, h;
241
- const v = ne(n), c = (p) => {
245
+ const v = oe(n), c = (p) => {
242
246
  const { x: S, y: E } = t.getBoundingClientRect(), C = i.getAt(p.clientX - S, p.clientY - E);
243
247
  C && (!u || u(C)) ? s.current !== C.id && (t.classList.add("hovered"), s.set(C.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
244
248
  };
245
249
  t.addEventListener("pointermove", c);
246
- const m = (p = !1) => {
250
+ const m = (p = !0) => {
247
251
  h && h.clear();
248
- const S = ee(t), { minX: E, minY: C, maxX: L, maxY: B } = S, _ = u ? i.getIntersecting(E, C, L, B).filter(({ annotation: U }) => u(U)) : i.getIntersecting(E, C, L, B), Yt = r.selected.map(({ id: U }) => U), Dt = _.map(({ annotation: U, rects: Ht }) => {
252
+ const S = ne(t), { minX: E, minY: C, maxX: L, maxY: B } = S, _ = u ? i.getIntersecting(E, C, L, B).filter(({ annotation: U }) => u(U)) : i.getIntersecting(E, C, L, B), Yt = r.selected.map(({ id: U }) => U), Dt = _.map(({ annotation: U, rects: Ht }) => {
249
253
  const $t = Yt.includes(U.id), Pt = U.id === s.current;
250
254
  return { annotation: U, rects: Ht, state: { selected: $t, hover: Pt, custom: {} } };
251
255
  });
@@ -258,9 +262,9 @@ const dt = (t, e = 10) => {
258
262
  u = p, m();
259
263
  }, w = () => m();
260
264
  i.observe(w);
261
- const l = r.subscribe(() => m()), d = () => m();
265
+ const l = r.subscribe(() => m()), d = () => m(!0);
262
266
  document.addEventListener("scroll", d, { capture: !0, passive: !0 });
263
- const f = dt(() => {
267
+ const f = ut(() => {
264
268
  i.recalculatePositions(), h && h.reset(), m();
265
269
  });
266
270
  window.addEventListener("resize", f);
@@ -279,17 +283,17 @@ const dt = (t, e = 10) => {
279
283
  setPainter: g,
280
284
  setVisible: o.setVisible
281
285
  };
282
- }, oe = () => {
286
+ }, ie = () => {
283
287
  const t = document.createElement("canvas");
284
288
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
285
- }, ie = (t, e) => {
289
+ }, re = (t, e) => {
286
290
  if (t.width = e ? 2 * window.innerWidth : window.innerWidth, t.height = e ? 2 * window.innerHeight : window.innerHeight, e) {
287
291
  const n = t.getContext("2d");
288
292
  n.scale(2, 2), n.translate(0.5, 0.5);
289
293
  }
290
- }, re = (t) => {
294
+ }, se = (t) => {
291
295
  t.classList.add("r6o-annotatable");
292
- const e = oe(), n = e.getContext("2d");
296
+ const e = ie(), n = e.getContext("2d");
293
297
  t.insertBefore(e, t.firstChild);
294
298
  const o = (a, u, h, v) => requestAnimationFrame(() => {
295
299
  const { width: c, height: m } = e;
@@ -297,7 +301,7 @@ const dt = (t, e = 10) => {
297
301
  const { top: g, left: y } = u;
298
302
  a.forEach((x) => {
299
303
  var f;
300
- const w = h ? typeof h == "function" ? h(x.annotation, x.state) : h : (f = x.state) != null && f.selected ? ut : H, l = v && v.paint(x, u) || w, d = x.rects.map(({ x: b, y: A, width: R, height: T }) => ({
304
+ const w = h ? typeof h == "function" ? h(x.annotation, x.state) : h : (f = x.state) != null && f.selected ? dt : D, l = v && v.paint(x, u) || w, d = x.rects.map(({ x: b, y: A, width: R, height: T }) => ({
301
305
  x: b + y,
302
306
  y: A + g,
303
307
  width: R,
@@ -307,8 +311,8 @@ const dt = (t, e = 10) => {
307
311
  n.beginPath(), n.moveTo(b, A + T + 4), n.lineTo(b + R, A + T + 4), n.stroke();
308
312
  }));
309
313
  });
310
- }), i = dt(() => {
311
- ie(e);
314
+ }), i = ut(() => {
315
+ re(e);
312
316
  });
313
317
  return window.addEventListener("resize", i), {
314
318
  destroy: () => {
@@ -319,8 +323,8 @@ const dt = (t, e = 10) => {
319
323
  },
320
324
  redraw: o
321
325
  };
322
- }, se = (t, e, n) => ht(t, e, n, re(t));
323
- var ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
326
+ }, ae = (t, e, n) => ht(t, e, n, se(t));
327
+ var ce = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
324
328
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
325
329
  }, O = function(t, e, n) {
326
330
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
@@ -332,7 +336,7 @@ var ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
332
336
  return { r: I(t.r, 0, 255), g: I(t.g, 0, 255), b: I(t.b, 0, 255), a: I(t.a) };
333
337
  }, et = function(t) {
334
338
  return { r: O(t.r), g: O(t.g), b: O(t.b), a: O(t.a, 3) };
335
- }, ce = /^#([0-9a-f]{3,8})$/i, G = function(t) {
339
+ }, le = /^#([0-9a-f]{3,8})$/i, G = function(t) {
336
340
  var e = t.toString(16);
337
341
  return e.length < 2 ? "0" + e : e;
338
342
  }, Mt = function(t) {
@@ -353,17 +357,17 @@ var ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
353
357
  }, j = function(t) {
354
358
  return { h: (e = Mt(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
355
359
  var e, n, o, i;
356
- }, le = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, de = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ue = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, he = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, yt = { string: [[function(t) {
357
- var e = ce.exec(t);
360
+ }, de = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ue = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, he = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, fe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, yt = { string: [[function(t) {
361
+ var e = le.exec(t);
358
362
  return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? O(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? O(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
359
363
  }, "hex"], [function(t) {
360
- var e = ue.exec(t) || he.exec(t);
364
+ var e = he.exec(t) || fe.exec(t);
361
365
  return e ? e[2] !== e[4] || e[4] !== e[6] ? null : mt({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
362
366
  }, "rgb"], [function(t) {
363
- var e = le.exec(t) || de.exec(t);
367
+ var e = de.exec(t) || ue.exec(t);
364
368
  if (!e)
365
369
  return null;
366
- var n, o, i = bt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (ae[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
370
+ var n, o, i = bt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (ce[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
367
371
  return wt(i);
368
372
  }, "hsl"]], object: [[function(t) {
369
373
  var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
@@ -389,7 +393,7 @@ var ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
389
393
  return [o, e[n][1]];
390
394
  }
391
395
  return [null, void 0];
392
- }, fe = function(t) {
396
+ }, ge = function(t) {
393
397
  return typeof t == "string" ? xt(t.trim(), yt.string) : typeof t == "object" && t !== null ? xt(t, yt.object) : [null, void 0];
394
398
  }, nt = function(t, e) {
395
399
  var n = j(t);
@@ -401,7 +405,7 @@ var ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
401
405
  return { h: n.h, s: n.s, l: I(n.l + 100 * e, 0, 100), a: n.a };
402
406
  }, Et = function() {
403
407
  function t(e) {
404
- this.parsed = fe(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
408
+ this.parsed = ge(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
405
409
  }
406
410
  return t.prototype.isValid = function() {
407
411
  return this.parsed !== null;
@@ -454,13 +458,13 @@ var ae = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
454
458
  }(), V = function(t) {
455
459
  return t instanceof Et ? t : new Et(t);
456
460
  };
457
- const ge = (t) => [
458
- `background-color:${V((t == null ? void 0 : t.fill) || H.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? H.fillOpacity : t.fillOpacity).toHex()}`,
461
+ const pe = (t) => [
462
+ `background-color:${V((t == null ? void 0 : t.fill) || D.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? D.fillOpacity : t.fillOpacity).toHex()}`,
459
463
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
460
464
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
461
465
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
462
466
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
463
- ].filter(Boolean).join(";"), pe = () => {
467
+ ].filter(Boolean).join(";"), me = () => {
464
468
  const t = document.createElement("style");
465
469
  document.getElementsByTagName("head")[0].appendChild(t);
466
470
  let e = /* @__PURE__ */ new Set();
@@ -477,8 +481,8 @@ const ge = (t) => [
477
481
  Array.from(e).filter((c) => !h.has(c));
478
482
  const v = r.map((c) => {
479
483
  var y;
480
- const m = a ? typeof a == "function" ? a(c.annotation, c.state) : a : (y = c.state) != null && y.selected ? ut : H, g = u && u.paint(c, s) || m;
481
- return `::highlight(_${c.annotation.id}) { ${ge(g)} }`;
484
+ const m = a ? typeof a == "function" ? a(c.annotation, c.state) : a : (y = c.state) != null && y.selected ? dt : D, g = u && u.paint(c, s) || m;
485
+ return `::highlight(_${c.annotation.id}) { ${pe(g)} }`;
482
486
  });
483
487
  t.innerHTML = v.join(`
484
488
  `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
@@ -487,7 +491,7 @@ const ge = (t) => [
487
491
  }), e = h;
488
492
  }
489
493
  };
490
- }, me = (t, e, n) => ht(t, e, n, pe());
494
+ }, be = (t, e, n) => ht(t, e, n, me());
491
495
  var St = Object.prototype.hasOwnProperty;
492
496
  function lt(t, e) {
493
497
  var n, o;
@@ -514,11 +518,7 @@ function lt(t, e) {
514
518
  }
515
519
  return t !== t && e !== e;
516
520
  }
517
- const be = (t, e, n, o, i) => {
518
- var s;
519
- const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (s = t.state) != null && s.selected ? ut : H;
520
- return o && o.paint(t, e) || r;
521
- }, ve = (t, e) => {
521
+ const ve = (t, e) => {
522
522
  const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y;
523
523
  return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;
524
524
  }, we = (t) => {
@@ -531,7 +531,7 @@ const be = (t, e, n, o, i) => {
531
531
  e.remove();
532
532
  },
533
533
  redraw: (s, a, u, h, v) => {
534
- if (lt(n, s) && !v)
534
+ if (lt(n, s) && v)
535
535
  return;
536
536
  e.innerHTML = "";
537
537
  const m = s.reduce((g, { rects: y }) => [...g, ...y], []);
@@ -539,7 +539,7 @@ const be = (t, e, n, o, i) => {
539
539
  const y = g.rects.map((x) => {
540
540
  const w = document.createElement("span");
541
541
  w.className = "r6o-annotation", w.dataset.annotation = g.annotation.id, w.style.left = `${x.x}px`, w.style.top = `${x.y}px`, w.style.width = `${x.width}px`, w.style.height = `${x.height}px`;
542
- const l = ve(x, m), d = be(g, a, u, h, l), f = V((d == null ? void 0 : d.fill) || H.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? H.fillOpacity : d.fillOpacity).toHex();
542
+ const l = ve(x, m), d = zt(g, a, u, h, l), f = V((d == null ? void 0 : d.fill) || D.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? D.fillOpacity : d.fillOpacity).toHex();
543
543
  return w.style.backgroundColor = f, d.underlineStyle && (w.style.borderStyle = d.underlineStyle), d.underlineColor && (w.style.borderColor = d.underlineColor), d.underlineThickness && (w.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (w.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(w), w;
544
544
  });
545
545
  return { id: g.annotation.id, spans: y };
@@ -1254,7 +1254,7 @@ const xn = (t, e) => ({
1254
1254
  updated: h,
1255
1255
  ...v
1256
1256
  } = i, c = s.map((m) => {
1257
- const { quote: g, start: y, end: x, range: w } = m, { prefix: l, suffix: d } = Gt(w, n), f = [{
1257
+ const { quote: g, start: y, end: x, range: w } = m, { prefix: l, suffix: d } = Kt(w, n), f = [{
1258
1258
  type: "TextQuoteSelector",
1259
1259
  exact: g,
1260
1260
  prefix: l,
@@ -1568,7 +1568,7 @@ const fn = (t, e) => {
1568
1568
  const f = l.selector.flatMap((A) => {
1569
1569
  const T = A.range instanceof Range && !A.range.collapsed && A.range.startContainer.nodeType === Node.TEXT_NODE && A.range.endContainer.nodeType === Node.TEXT_NODE ? A.range : Bt(A, e).range;
1570
1570
  return Array.from(T.getClientRects());
1571
- }), b = Jt(f).map(({ left: A, top: R, right: T, bottom: p }) => new DOMRect(A - d.left, R - d.top, T - A, p - R));
1571
+ }), b = Zt(f).map(({ left: A, top: R, right: T, bottom: p }) => new DOMRect(A - d.left, R - d.top, T - A, p - R));
1572
1572
  return b.map((A) => {
1573
1573
  const { x: R, y: T, width: p, height: S } = A;
1574
1574
  return {
@@ -1761,7 +1761,7 @@ const fn = (t, e) => {
1761
1761
  var l;
1762
1762
  if (!u)
1763
1763
  return;
1764
- !((l = x.target.parentElement) != null && l.closest(D)) ? s = {
1764
+ !((l = x.target.parentElement) != null && l.closest(H)) ? s = {
1765
1765
  annotation: Vt(),
1766
1766
  selector: [],
1767
1767
  creator: r,
@@ -1769,17 +1769,17 @@ const fn = (t, e) => {
1769
1769
  } : s = void 0;
1770
1770
  };
1771
1771
  t.addEventListener("selectstart", v);
1772
- const c = dt((x) => {
1772
+ const c = ut((x) => {
1773
1773
  const w = document.getSelection();
1774
1774
  if (x.timeStamp - ((h == null ? void 0 : h.timeStamp) || x.timeStamp) < 1e3 && !s && v(h), w.isCollapsed || !u || !s)
1775
1775
  return;
1776
- const l = w.getRangeAt(0), d = te(l.cloneRange()), f = Wt(d);
1776
+ const l = w.getRangeAt(0), d = ee(l.cloneRange()), f = qt(d);
1777
1777
  (f.length !== s.selector.length || f.some((A, R) => {
1778
1778
  var T;
1779
1779
  return A.toString() !== ((T = s.selector[R]) == null ? void 0 : T.quote);
1780
1780
  })) && (s = {
1781
1781
  ...s,
1782
- selector: f.map((A) => Zt(A, t, n))
1782
+ selector: f.map((A) => te(A, t, n))
1783
1783
  }, o.getAnnotation(s.annotation) ? o.updateTarget(s, N.LOCAL) : (o.addAnnotation({
1784
1784
  id: s.annotation,
1785
1785
  bodies: [],
@@ -1794,7 +1794,7 @@ const fn = (t, e) => {
1794
1794
  t.addEventListener("pointerdown", m);
1795
1795
  const g = (x) => {
1796
1796
  var f;
1797
- if (!!((f = x.target.parentElement) != null && f.closest(D)) || !u)
1797
+ if (!!((f = x.target.parentElement) != null && f.closest(H)) || !u)
1798
1798
  return;
1799
1799
  const l = () => {
1800
1800
  const { x: b, y: A } = t.getBoundingClientRect(), R = o.getAt(x.clientX - b, x.clientY - A);
@@ -1820,10 +1820,10 @@ const fn = (t, e) => {
1820
1820
  e.adapter
1821
1821
  );
1822
1822
  let u = Ke();
1823
- const h = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Lt : e.renderer || Lt, v = h === "SPANS" ? ye(t, n, i) : h === "CSS_HIGHLIGHTS" ? me(t, n, i) : h === "CANVAS" ? se(t, n, i) : void 0;
1823
+ const h = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Lt : e.renderer || Lt, v = h === "SPANS" ? ye(t, n, i) : h === "CSS_HIGHLIGHTS" ? be(t, n, i) : h === "CANVAS" ? ae(t, n, i) : void 0;
1824
1824
  if (!v)
1825
1825
  throw `Unknown renderer implementation: ${h}`;
1826
- console.log(`Using ${h} renderer`), e.style && v.setStyle(e.style);
1826
+ console.debug(`Using ${h} renderer`), e.style && v.setStyle(e.style);
1827
1827
  const c = vn(t, n, e.offsetReferenceSelector);
1828
1828
  return c.setUser(u), {
1829
1829
  ...ze(n, s, e.adapter),
@@ -1841,7 +1841,7 @@ const fn = (t, e) => {
1841
1841
  A ? o.setSelected(A) : o.clear();
1842
1842
  },
1843
1843
  setPresenceProvider: (A) => {
1844
- A && (v.setPainter(mn(t, A, e.presence)), A.on("selectionChange", () => v.redraw(!0)));
1844
+ A && (v.setPainter(mn(t, A, e.presence)), A.on("selectionChange", () => v.redraw()));
1845
1845
  },
1846
1846
  setVisible: (A) => v.setVisible(A),
1847
1847
  on: a.on,
@@ -1851,29 +1851,33 @@ const fn = (t, e) => {
1851
1851
  };
1852
1852
  };
1853
1853
  export {
1854
- D as NOT_ANNOTATABLE_SELECTOR,
1854
+ dt as DEFAULT_SELECTED_STYLE,
1855
+ D as DEFAULT_STYLE,
1856
+ Nt as NOT_ANNOTATABLE_CLASS,
1857
+ H as NOT_ANNOTATABLE_SELECTOR,
1855
1858
  N as Origin,
1856
1859
  xn as W3CTextFormat,
1857
- se as createCanvasRenderer,
1858
- me as createHighlightsRenderer,
1859
- pe as createRenderer,
1860
+ ae as createCanvasRenderer,
1861
+ be as createHighlightsRenderer,
1862
+ me as createRenderer,
1860
1863
  ye as createSpansRenderer,
1861
1864
  An as createTextAnnotator,
1862
1865
  gn as createTextAnnotatorState,
1863
- dt as debounce,
1866
+ ut as debounce,
1864
1867
  wn as getAnnotatableFragment,
1865
1868
  yn as getClientRectsPonyfill,
1866
- Gt as getQuoteContext,
1869
+ Kt as getQuoteContext,
1867
1870
  ct as getRangeAnnotatableContents,
1868
1871
  k as isRevived,
1869
- Jt as mergeClientRects,
1872
+ Zt as mergeClientRects,
1873
+ zt as paint,
1870
1874
  nn as parseW3CTextAnnotation,
1871
- Zt as rangeToSelector,
1875
+ te as rangeToSelector,
1872
1876
  tt as reviveAnnotation,
1873
1877
  Bt as reviveSelector,
1874
1878
  Z as reviveTarget,
1875
1879
  on as serializeW3CTextAnnotation,
1876
- Wt as splitAnnotatableRanges,
1877
- te as trimRange
1880
+ qt as splitAnnotatableRanges,
1881
+ ee as trimRange
1878
1882
  };
1879
1883
  //# sourceMappingURL=text-annotator.es.js.map