@recogito/text-annotator 4.1.0 → 4.1.1

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,5 +1,5 @@
1
1
  import { v4 as lt } from "uuid";
2
- import { parseW3CBodies as Ct, serializeW3CBodies as Tt, parseW3CUser as At, UserSelectAction as Rt, createStore as vt, createSelectionState as wt, createHoverState as xt, createViewportState as Lt, Origin as F, createAnonymousGuest as Nt, createUndoStack as Ot, createLifecycleObserver as kt, createBaseAnnotator as Mt } from "@annotorious/core";
2
+ import { parseW3CBodies as Ct, serializeW3CBodies as Tt, parseW3CUser as At, UserSelectAction as Rt, createStore as vt, createSelectionState as wt, createHoverState as xt, createViewportState as Lt, Origin as $, createAnonymousGuest as Nt, createUndoStack as Ot, createLifecycleObserver as kt, createBaseAnnotator as Mt } from "@annotorious/core";
3
3
  import { Origin as Be, UserSelectAction as _e, createBody as Ie } from "@annotorious/core";
4
4
  import { createNanoEvents as dt } from "nanoevents";
5
5
  import { colord as et } from "colord";
@@ -8,9 +8,9 @@ import _t from "rbush";
8
8
  import It from "debounce";
9
9
  import q from "hotkeys-js";
10
10
  import { poll as Dt } from "poll";
11
- const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft = "not-annotatable", $ = `.${ft}`, W = (t, e) => t.contains(e) ? !!(e instanceof HTMLElement ? e.closest($) : e.parentElement?.closest($)) : !0, gt = (t, e) => {
11
+ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft = "not-annotatable", W = `.${ft}`, F = (t, e) => t.contains(e) ? !!(e instanceof HTMLElement ? e.closest(W) : e.parentElement?.closest(W)) : !0, gt = (t, e) => {
12
12
  const o = e.commonAncestorContainer;
13
- return !W(t, o);
13
+ return !F(t, o);
14
14
  }, mt = /^\s*$/, Ht = (t) => mt.test(t.toString()), we = (t) => mt.test(t.textContent || ""), Pt = (t) => {
15
15
  if (t.length === 0) return [];
16
16
  if (t.length === 1) return [t[0]];
@@ -26,12 +26,12 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
26
26
  const e = document.createTreeWalker(
27
27
  t.commonAncestorContainer,
28
28
  NodeFilter.SHOW_ELEMENT,
29
- (i) => i instanceof HTMLElement && i.classList.contains(ft) && !i.parentElement?.closest($) && t.intersectsNode(i) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
29
+ (i) => i instanceof HTMLElement && i.classList.contains(ft) && !i.parentElement?.closest(W) && t.intersectsNode(i) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
30
30
  );
31
31
  let o;
32
32
  for (; o = e.nextNode(); )
33
33
  o instanceof HTMLElement && (yield o);
34
- }, Ft = (t, e) => {
34
+ }, $t = (t, e) => {
35
35
  if (!gt(t, e)) return [];
36
36
  const o = [];
37
37
  let i = null;
@@ -46,19 +46,19 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
46
46
  return o.length > 0 ? o : [e];
47
47
  }, nt = (t) => {
48
48
  const e = t.cloneContents();
49
- return e.querySelectorAll($).forEach((o) => o.remove()), e;
50
- }, Wt = (t, e) => {
49
+ return e.querySelectorAll(W).forEach((o) => o.remove()), e;
50
+ }, Ft = (t, e) => {
51
51
  const o = t.cloneRange();
52
52
  return e.contains(o.startContainer) || o.setStart(e, 0), e.contains(o.endContainer) || o.setEnd(e, e.childNodes.length), o;
53
- }, rt = new Intl.Segmenter(void 0, { granularity: "grapheme" }), $t = (t, e, o = 10, i) => {
53
+ }, rt = new Intl.Segmenter(void 0, { granularity: "grapheme" }), Wt = (t, e, o = 10, i) => {
54
54
  const s = i ? t.startContainer.parentElement.closest(i) : e, n = document.createRange();
55
55
  n.setStart(s, 0), n.setEnd(t.startContainer, t.startOffset);
56
56
  const r = nt(n).textContent, a = document.createRange();
57
57
  a.setStart(t.endContainer, t.endOffset), s === document.body ? a.setEnd(s, s.childNodes.length) : a.setEndAfter(s);
58
58
  const l = nt(a).textContent, m = [...rt.segment(r)], g = [...rt.segment(l)];
59
59
  return {
60
- prefix: m.slice(-o).map((E) => E.segment).join(""),
61
- suffix: g.slice(0, o).map((E) => E.segment).join("")
60
+ prefix: m.slice(-o).map((y) => y.segment).join(""),
61
+ suffix: g.slice(0, o).map((y) => y.segment).join("")
62
62
  };
63
63
  }, Yt = (t, e, o) => {
64
64
  const i = document.createRange(), s = o ? t.startContainer.parentElement.closest(o) : e;
@@ -69,7 +69,7 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
69
69
  const { start: o, end: i } = t, s = t.offsetReference || e, n = document.createTreeWalker(
70
70
  e,
71
71
  NodeFilter.SHOW_TEXT,
72
- (g) => g.parentElement?.closest($) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT
72
+ (g) => g.parentElement?.closest(W) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT
73
73
  );
74
74
  let r = 0;
75
75
  const a = document.createRange();
@@ -108,8 +108,8 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
108
108
  const { overflowY: e } = window.getComputedStyle(t);
109
109
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ht(t.parentElement);
110
110
  }, it = (t, e, o) => {
111
- const i = o.getBoundingClientRect(), s = o.clientHeight, n = o.clientWidth, r = e.selector[0].range.getBoundingClientRect(), { width: a, height: l } = t.getAnnotationBounds(e.annotation), m = r.top - i.top, g = r.left - i.left, E = o.parentElement ? o.scrollTop : 0, h = o.parentElement ? o.scrollLeft : 0, A = m + E - (s - l) / 2, d = g + h - (n - a) / 2;
112
- o.scroll({ top: A, left: d, behavior: "smooth" });
111
+ const i = o.getBoundingClientRect(), s = o.clientHeight, n = o.clientWidth, r = e.selector[0].range.getBoundingClientRect(), { width: a, height: l } = t.getAnnotationBounds(e.annotation), m = r.top - i.top, g = r.left - i.left, y = o.parentElement ? o.scrollTop : 0, p = o.parentElement ? o.scrollLeft : 0, v = m + y - (s - l) / 2, u = g + p - (n - a) / 2;
112
+ o.scroll({ top: v, left: u, behavior: "smooth" });
113
113
  }, Xt = (t, e) => (o, i) => {
114
114
  const s = typeof o == "string" ? o : o.id, n = i ? typeof i == "string" ? document.getElementById(i) : i : ht(t);
115
115
  if (!n)
@@ -145,16 +145,16 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
145
145
  styleClass: "styleClass" in r[0] ? r[0].styleClass : void 0
146
146
  };
147
147
  for (const l of r) {
148
- const g = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((E, h) => {
149
- switch (h.type) {
148
+ const g = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((y, p) => {
149
+ switch (p.type) {
150
150
  case "TextQuoteSelector":
151
- E.quote = h.exact;
151
+ y.quote = p.exact;
152
152
  break;
153
153
  case "TextPositionSelector":
154
- E.start = h.start, E.end = h.end;
154
+ y.start = p.start, y.end = p.end;
155
155
  break;
156
156
  }
157
- return E;
157
+ return y;
158
158
  }, {});
159
159
  if (Vt(g))
160
160
  a.selector.push(
@@ -166,11 +166,11 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
166
166
  }
167
167
  );
168
168
  else {
169
- const E = [
169
+ const y = [
170
170
  g.start ? void 0 : "TextPositionSelector",
171
171
  g.quote ? void 0 : "TextQuoteSelector"
172
172
  ].filter(Boolean);
173
- return { error: Error(`Missing selector types: ${E.join(" and ")} for annotation: ${t.id}`) };
173
+ return { error: Error(`Missing selector types: ${y.join(" and ")} for annotation: ${t.id}`) };
174
174
  }
175
175
  }
176
176
  return { parsed: a };
@@ -197,27 +197,27 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
197
197
  created: l,
198
198
  updated: m,
199
199
  ...g
200
- } = s, E = r.map((h) => {
201
- const { id: A, quote: d, start: L, end: x, range: v } = h, p = {
200
+ } = s, y = r.map((p) => {
201
+ const { id: v, quote: u, start: x, end: N, range: A } = p, b = {
202
202
  type: "TextQuoteSelector",
203
- exact: d
203
+ exact: u
204
204
  };
205
205
  if (o) {
206
- const { prefix: w, suffix: c } = $t(v, o);
207
- p.prefix = w, p.suffix = c;
206
+ const { prefix: S, suffix: c } = Wt(A, o);
207
+ b.prefix = S, b.suffix = c;
208
208
  }
209
- const b = {
209
+ const C = {
210
210
  type: "TextPositionSelector",
211
- start: L,
212
- end: x
211
+ start: x,
212
+ end: N
213
213
  };
214
214
  return {
215
215
  ...g,
216
- id: A,
216
+ id: v,
217
217
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
218
- scope: "scope" in h ? h.scope : void 0,
218
+ scope: "scope" in p ? p.scope : void 0,
219
219
  source: e,
220
- selector: [p, b]
220
+ selector: [b, C]
221
221
  };
222
222
  });
223
223
  return {
@@ -229,11 +229,11 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
229
229
  creator: a,
230
230
  created: l?.toISOString(),
231
231
  modified: m?.toISOString(),
232
- target: E
232
+ target: y
233
233
  };
234
234
  }, Gt = (t) => t.addEventListener("click", (e) => {
235
235
  // Allow clicks within not-annotatable elements
236
- !e.target.closest($) && !e.target.closest("a") && e.preventDefault();
236
+ !e.target.closest(W) && !e.target.closest("a") && e.preventDefault();
237
237
  }), J = (t) => ({
238
238
  ...t,
239
239
  type: t.type,
@@ -286,65 +286,65 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
286
286
  let l;
287
287
  const m = /* @__PURE__ */ new Map();
288
288
  let g;
289
- const E = ae(i), h = (S) => {
290
- const { x: C, y: O } = e.getBoundingClientRect(), B = s.getAt(S.clientX - C, S.clientY - O, !1, g);
289
+ const y = ae(i), p = (E) => {
290
+ const { x: T, y: O } = e.getBoundingClientRect(), B = s.getAt(E.clientX - T, E.clientY - O, !1, g);
291
291
  B && o.selection.evalSelectAction(B) !== Rt.NONE ? r.current !== B.id && (e.classList.add("hovered"), r.set(B.id)) : r.current && (e.classList.remove("hovered"), r.set(null));
292
292
  };
293
- e.addEventListener("pointermove", h);
294
- const A = tt((S = !1) => requestAnimationFrame(() => {
295
- const C = ie(e), { minX: O, minY: B, maxX: V, maxY: z } = C, K = g ? s.getIntersecting(O, B, V, z).filter(({ annotation: y }) => g?.(y)) : s.getIntersecting(O, B, V, z), st = n.selected.map(({ id: y }) => y), f = K.map(({ annotation: y, rects: M }) => {
296
- const U = st.includes(y.id), _ = y.id === r.current;
293
+ e.addEventListener("pointermove", p);
294
+ const v = tt((E = !1) => requestAnimationFrame(() => {
295
+ const T = ie(e), { minX: O, minY: B, maxX: V, maxY: z } = T, K = g ? s.getIntersecting(O, B, V, z).filter(({ annotation: h }) => g?.(h)) : s.getIntersecting(O, B, V, z), st = n.selected.map(({ id: h }) => h), f = K.map(({ annotation: h, rects: M }) => {
296
+ const H = st.includes(h.id), _ = h.id === r.current;
297
297
  return {
298
- annotation: y,
298
+ annotation: h,
299
299
  rects: M,
300
- state: { selected: U, hovered: _ }
300
+ state: { selected: H, hovered: _ }
301
301
  };
302
302
  });
303
- t.redraw(f, C, l, m, S), setTimeout(() => {
304
- E(K.map(({ annotation: y }) => y)), a.emit("onRedraw");
303
+ t.redraw(f, T, l, m, E), setTimeout(() => {
304
+ y(K.map(({ annotation: h }) => h)), a.emit("onRedraw");
305
305
  }, 1);
306
- }), 10), d = (S, C) => {
307
- C ? S ? m.set(C, S) : m.delete(C) : l = S, A(!0);
308
- }, L = (S) => {
309
- g = S, A(!1);
310
- }, x = (S, C) => a.on(S, C), v = () => {
311
- A();
306
+ }), 10), u = (E, T) => {
307
+ T ? E ? m.set(T, E) : m.delete(T) : l = E, v(!0);
308
+ }, x = (E) => {
309
+ g = E, v(!1);
310
+ }, N = (E, T) => a.on(E, T), A = () => {
311
+ v();
312
312
  };
313
- s.observe(v);
314
- const p = n.subscribe(() => {
315
- A();
316
- }), b = r.subscribe(() => {
317
- A();
318
- }), w = () => {
319
- A(!0);
313
+ s.observe(A);
314
+ const b = n.subscribe(() => {
315
+ v();
316
+ }), C = r.subscribe(() => {
317
+ v();
318
+ }), S = () => {
319
+ v(!0);
320
320
  };
321
- document.addEventListener("scroll", w, { capture: !0, passive: !0 });
321
+ document.addEventListener("scroll", S, { capture: !0, passive: !0 });
322
322
  const c = tt(() => {
323
- s.recalculatePositions(), A();
323
+ s.recalculatePositions(), v();
324
324
  }, 10);
325
325
  window.addEventListener("resize", c);
326
- const u = new ResizeObserver(c);
327
- u.observe(e);
328
- const T = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver(tt((S) => {
329
- S.every((O) => O.target === e || e.contains(O.target)) || A(!0);
326
+ const d = new ResizeObserver(c);
327
+ d.observe(e);
328
+ const R = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver(tt((E) => {
329
+ E.every((O) => O.target === e || e.contains(O.target)) || v(!0);
330
330
  }, 150));
331
- return R.observe(document.body, T), {
331
+ return w.observe(document.body, R), {
332
332
  destroy: () => {
333
- e.removeEventListener("pointermove", h), t.destroy(), s.unobserve(v), p(), b(), document.removeEventListener("scroll", w), window.removeEventListener("resize", c), u.disconnect(), R.disconnect();
333
+ e.removeEventListener("pointermove", p), t.destroy(), s.unobserve(A), b(), C(), document.removeEventListener("scroll", S), window.removeEventListener("resize", c), d.disconnect(), w.disconnect();
334
334
  },
335
- on: x,
336
- redraw: A,
337
- setStyle: d,
338
- setFilter: L,
335
+ on: N,
336
+ redraw: v,
337
+ setStyle: u,
338
+ setFilter: x,
339
339
  setVisible: t.setVisible.bind(t)
340
340
  };
341
- }, P = {
341
+ }, U = {
342
342
  fill: "rgb(0, 128, 255)",
343
343
  fillOpacity: 0.18
344
344
  }, ot = {
345
345
  fill: "rgb(0, 128, 255)",
346
346
  fillOpacity: 0.45
347
- }, Qt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill || P.fill).alpha(t.fillOpacity).toHex() : t?.fill ? t.fill : et(P.fill).alpha(P.fillOpacity).toHex(), St = (t, e, o) => e ? typeof e == "function" ? e(t.annotation, t.state, o) || (t.state?.selected ? ot : P) : e : t.state?.selected ? ot : P, Zt = (t, e) => {
347
+ }, Qt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill || U.fill).alpha(t.fillOpacity).toHex() : t?.fill ? t.fill : et(U.fill).alpha(U.fillOpacity).toHex(), St = (t, e, o) => e ? typeof e == "function" ? e(t.annotation, t.state, o) || (t.state?.selected ? ot : U) : e : t.state?.selected ? ot : U, Zt = (t, e) => {
348
348
  const o = (n, r) => n.x <= r.x + r.width && n.x + n.width >= r.x && n.y <= r.y + r.height && n.y + n.height >= r.y, i = (n) => n.rects.reduce((r, a) => r + a.width, 0), s = e.filter(({ rects: n }) => n.some((r) => o(t, r)));
349
349
  return s.sort((n, r) => i(r) - i(n)), s.findIndex((n) => n.rects.includes(t));
350
350
  }, Jt = (t) => {
@@ -377,8 +377,8 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
377
377
  g ? l.setEndBefore(g) : l.setEndAfter(t.endContainer);
378
378
  }
379
379
  const m = (g) => {
380
- const E = document.createRange();
381
- return E.selectNode(g), Array.from(E.getClientRects());
380
+ const y = document.createRange();
381
+ return y.selectNode(g), Array.from(y.getClientRects());
382
382
  };
383
383
  return [
384
384
  ...Array.from(a.getClientRects()),
@@ -457,17 +457,18 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
457
457
  e.remove();
458
458
  },
459
459
  redraw: (r, a, l, m, g) => {
460
+ const y = performance.now();
460
461
  if (!(!Bt(o, r) || g)) return;
461
- e.innerHTML = "", [...r].sort((d, L) => {
462
- const { annotation: { target: { created: x } } } = d, { annotation: { target: { created: v } } } = L;
463
- return x && v ? x.getTime() - v.getTime() : 0;
464
- }).forEach((d) => {
465
- const L = m?.get(d.annotation.id) || l;
466
- d.rects.map((x) => {
467
- const v = Zt(x, r), p = St(d, L, v), b = document.createElement("span");
468
- b.className = "r6o-annotation", b.dataset.annotation = d.annotation.id, b.style.left = `${x.x}px`, b.style.top = `${x.y}px`, b.style.width = `${x.width}px`, b.style.height = `${x.height}px`, b.style.backgroundColor = Qt(p), p.underlineStyle && (b.style.borderStyle = p.underlineStyle), p.underlineColor && (b.style.borderColor = p.underlineColor), p.underlineThickness && (b.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (b.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(b);
462
+ e.innerHTML = "", [...r].sort((x, N) => {
463
+ const { annotation: { target: { created: A } } } = x, { annotation: { target: { created: b } } } = N;
464
+ return A && b ? A.getTime() - b.getTime() : 0;
465
+ }).forEach((x) => {
466
+ const N = m?.get(x.annotation.id) || l;
467
+ x.rects.map((A) => {
468
+ const b = Zt(A, r), C = St(x, N, b), S = document.createElement("span");
469
+ S.className = "r6o-annotation", S.dataset.annotation = x.annotation.id, S.style.left = `${A.x}px`, S.style.top = `${A.y}px`, S.style.width = `${A.width}px`, S.style.height = `${A.height}px`, S.style.backgroundColor = Qt(C), C.underlineStyle && (S.style.borderStyle = C.underlineStyle), C.underlineColor && (S.style.borderColor = C.underlineColor), C.underlineThickness && (S.style.borderBottomWidth = `${C.underlineThickness}px`), C.underlineOffset && (S.style.paddingBottom = `${C.underlineOffset}px`), e.appendChild(S);
469
470
  });
470
- }), o = r;
471
+ }), o = r, console.log(`Took ${performance.now() - y} ms`);
471
472
  },
472
473
  setVisible: (r) => {
473
474
  r ? e.classList.remove("hidden") : e.classList.add("hidden");
@@ -483,128 +484,128 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
483
484
  (e.size !== s.length || s.some((n) => !e.has(n))) && t.set(s), e = new Set(s);
484
485
  };
485
486
  }, ce = (t, e, o, i) => {
486
- const s = new _t(), n = /* @__PURE__ */ new Map(), r = dt(), a = (c, u) => {
487
- const T = c.selector.flatMap((N) => {
488
- const S = D([N]) ? N.range : pt(N, e).range;
489
- return Jt(S);
490
- }), R = ne(T, o, i).map((N) => oe(N, u));
491
- return R.map((N) => {
492
- const { x: S, y: C, width: O, height: B } = N;
487
+ const s = new _t(), n = /* @__PURE__ */ new Map(), r = dt(), a = (c, d) => {
488
+ const R = c.selector.flatMap((L) => {
489
+ const E = D([L]) ? L.range : pt(L, e).range;
490
+ return Jt(E);
491
+ }), w = ne(R, o, i).map((L) => oe(L, d));
492
+ return w.map((L) => {
493
+ const { x: E, y: T, width: O, height: B } = L;
493
494
  return {
494
- minX: S,
495
- minY: C,
496
- maxX: S + O,
497
- maxY: C + B,
495
+ minX: E,
496
+ minY: T,
497
+ maxX: E + O,
498
+ maxY: T + B,
498
499
  annotation: {
499
500
  id: c.annotation,
500
- rects: R
501
+ rects: w
501
502
  }
502
503
  };
503
504
  });
504
505
  }, l = () => [...n.values()], m = () => {
505
506
  s.clear(), n.clear();
506
507
  }, g = (c) => {
507
- const u = a(c, e.getBoundingClientRect());
508
- u.length !== 0 && (u.forEach((T) => s.insert(T)), n.set(c.annotation, u));
509
- }, E = (c) => {
510
- const u = n.get(c.annotation);
511
- u && (u.forEach((T) => s.remove(T)), n.delete(c.annotation));
512
- }, h = (c) => {
513
- E(c), g(c);
514
- }, A = (c, u = !0) => {
515
- u && m();
516
- const T = e.getBoundingClientRect(), R = c.map((S) => ({ target: S, rects: a(S, T) }));
517
- R.forEach(({ target: S, rects: C }) => {
518
- C.length > 0 && n.set(S.annotation, C);
508
+ const d = a(c, e.getBoundingClientRect());
509
+ d.length !== 0 && (d.forEach((R) => s.insert(R)), n.set(c.annotation, d));
510
+ }, y = (c) => {
511
+ const d = n.get(c.annotation);
512
+ d && (d.forEach((R) => s.remove(R)), n.delete(c.annotation));
513
+ }, p = (c) => {
514
+ y(c), g(c);
515
+ }, v = (c, d = !0) => {
516
+ d && m();
517
+ const R = e.getBoundingClientRect(), w = c.map((E) => ({ target: E, rects: a(E, R) }));
518
+ w.forEach(({ target: E, rects: T }) => {
519
+ T.length > 0 && n.set(E.annotation, T);
519
520
  });
520
- const N = R.flatMap(({ rects: S }) => S);
521
- s.load(N);
522
- }, d = (c, u, T = !1) => {
523
- const R = s.search({
521
+ const L = w.flatMap(({ rects: E }) => E);
522
+ s.load(L);
523
+ }, u = (c, d, R = !1) => {
524
+ const w = s.search({
524
525
  minX: c,
525
- minY: u,
526
+ minY: d,
526
527
  maxX: c,
527
- maxY: u
528
- }), N = (S) => S.annotation.rects.reduce((C, O) => C + O.width * O.height, 0);
529
- return R.length > 0 ? (R.sort((S, C) => N(S) - N(C)), T ? R.map((S) => S.annotation.id) : [R[0].annotation.id]) : [];
530
- }, L = (c) => {
531
- const u = x(c);
532
- if (u.length === 0)
528
+ maxY: d
529
+ }), L = (E) => E.annotation.rects.reduce((T, O) => T + O.width * O.height, 0);
530
+ return w.length > 0 ? (w.sort((E, T) => L(E) - L(T)), R ? w.map((E) => E.annotation.id) : [w[0].annotation.id]) : [];
531
+ }, x = (c) => {
532
+ const d = N(c);
533
+ if (d.length === 0)
533
534
  return;
534
- let T = u[0].left, R = u[0].top, N = u[0].right, S = u[0].bottom;
535
- for (let C = 1; C < u.length; C++) {
536
- const O = u[C];
537
- T = Math.min(T, O.left), R = Math.min(R, O.top), N = Math.max(N, O.right), S = Math.max(S, O.bottom);
535
+ let R = d[0].left, w = d[0].top, L = d[0].right, E = d[0].bottom;
536
+ for (let T = 1; T < d.length; T++) {
537
+ const O = d[T];
538
+ R = Math.min(R, O.left), w = Math.min(w, O.top), L = Math.max(L, O.right), E = Math.max(E, O.bottom);
538
539
  }
539
- return new DOMRect(T, R, N - T, S - R);
540
- }, x = (c) => {
541
- const u = n.get(c);
542
- return u ? u[0].annotation.rects : [];
540
+ return new DOMRect(R, w, L - R, E - w);
541
+ }, N = (c) => {
542
+ const d = n.get(c);
543
+ return d ? d[0].annotation.rects : [];
543
544
  };
544
545
  return {
545
546
  all: l,
546
547
  clear: m,
547
- getAt: d,
548
- getAnnotationBounds: L,
549
- getAnnotationRects: x,
550
- getIntersecting: (c, u, T, R) => {
551
- const N = s.search({ minX: c, minY: u, maxX: T, maxY: R }), S = new Set(N.map((C) => C.annotation.id));
552
- return Array.from(S).map((C) => ({
553
- annotation: t.getAnnotation(C),
554
- rects: x(C)
555
- })).filter((C) => !!C.annotation);
548
+ getAt: u,
549
+ getAnnotationBounds: x,
550
+ getAnnotationRects: N,
551
+ getIntersecting: (c, d, R, w) => {
552
+ const L = s.search({ minX: c, minY: d, maxX: R, maxY: w }), E = new Set(L.map((T) => T.annotation.id));
553
+ return Array.from(E).map((T) => ({
554
+ annotation: t.getAnnotation(T),
555
+ rects: N(T)
556
+ })).filter((T) => !!T.annotation);
556
557
  },
557
558
  insert: g,
558
559
  recalculate: () => {
559
- A(t.all().map((c) => c.target), !0), r.emit("recalculate");
560
+ v(t.all().map((c) => c.target), !0), r.emit("recalculate");
560
561
  },
561
- remove: E,
562
- set: A,
562
+ remove: y,
563
+ set: v,
563
564
  size: () => s.all().length,
564
- update: h,
565
- on: (c, u) => r.on(c, u)
565
+ update: p,
566
+ on: (c, d) => r.on(c, d)
566
567
  };
567
568
  }, le = (t, e) => {
568
- const o = vt(), i = ce(o, t, e.mergeHighlights?.horizontalTolerance, e.mergeHighlights?.verticalTolerance), s = wt(o, e.userSelectAction, e.adapter), n = xt(o), r = Lt(), a = (p, b = F.LOCAL) => {
569
- const w = Z(p, t), c = D(w.target.selector);
570
- return c && o.addAnnotation(w, b), c;
571
- }, l = (p, b = !0, w = F.LOCAL) => {
572
- const c = p.map((T) => Z(T, t)), u = c.filter((T) => !D(T.target.selector));
573
- return o.bulkAddAnnotations(c, b, w), u;
574
- }, m = (p, b = F.LOCAL) => {
575
- const w = p.map((u) => Z(u, t)), c = w.filter((u) => !D(u.target.selector));
576
- return w.forEach((u) => {
577
- o.getAnnotation(u.id) ? o.updateAnnotation(u, b) : o.addAnnotation(u, b);
569
+ const o = vt(), i = ce(o, t, e.mergeHighlights?.horizontalTolerance, e.mergeHighlights?.verticalTolerance), s = wt(o, e.userSelectAction, e.adapter), n = xt(o), r = Lt(), a = (b, C = $.LOCAL) => {
570
+ const S = Z(b, t), c = D(S.target.selector);
571
+ return c && o.addAnnotation(S, C), c;
572
+ }, l = (b, C = !0, S = $.LOCAL) => {
573
+ const c = b.map((R) => Z(R, t)), d = c.filter((R) => !D(R.target.selector));
574
+ return o.bulkAddAnnotations(c, C, S), d;
575
+ }, m = (b, C = $.LOCAL) => {
576
+ const S = b.map((d) => Z(d, t)), c = S.filter((d) => !D(d.target.selector));
577
+ return S.forEach((d) => {
578
+ o.getAnnotation(d.id) ? o.updateAnnotation(d, C) : o.addAnnotation(d, C);
578
579
  }), c;
579
- }, g = (p, b = F.LOCAL) => {
580
- const w = Q(p, t);
581
- o.updateTarget(w, b);
582
- }, E = (p, b = F.LOCAL) => {
583
- const w = p.map((c) => Q(c, t));
584
- o.bulkUpdateTargets(w, b);
580
+ }, g = (b, C = $.LOCAL) => {
581
+ const S = Q(b, t);
582
+ o.updateTarget(S, C);
583
+ }, y = (b, C = $.LOCAL) => {
584
+ const S = b.map((c) => Q(c, t));
585
+ o.bulkUpdateTargets(S, C);
585
586
  };
586
- function h(p, b, w, c) {
587
- const u = w || !!c, T = i.getAt(p, b, u).map((N) => o.getAnnotation(N)).filter(Boolean), R = c ? T.filter(c) : T;
588
- if (R.length !== 0)
589
- return w ? R : R[0];
587
+ function p(b, C, S, c) {
588
+ const d = S || !!c, R = i.getAt(b, C, d).map((L) => o.getAnnotation(L)).filter(Boolean), w = c ? R.filter(c) : R;
589
+ if (w.length !== 0)
590
+ return S ? w : w[0];
590
591
  }
591
- const A = (p) => i.getAnnotationRects(p).length > 0 ? i.getAnnotationBounds(p) : void 0, d = (p, b, w, c) => i.getIntersecting(p, b, w, c), L = (p) => i.getAnnotationRects(p), x = () => i.recalculate(), v = (p) => i.on("recalculate", p);
592
- return o.observe(({ changes: p }) => {
593
- const b = (p.deleted || []).filter((u) => D(u.target.selector)), w = (p.created || []).filter((u) => D(u.target.selector)), c = (p.updated || []).filter((u) => D(u.newValue.target.selector));
594
- b?.length > 0 && b.forEach((u) => i.remove(u.target)), w.length > 0 && i.set(w.map((u) => u.target), !1), c?.length > 0 && c.forEach(({ newValue: u }) => i.update(u.target));
592
+ const v = (b) => i.getAnnotationRects(b).length > 0 ? i.getAnnotationBounds(b) : void 0, u = (b, C, S, c) => i.getIntersecting(b, C, S, c), x = (b) => i.getAnnotationRects(b), N = () => i.recalculate(), A = (b) => i.on("recalculate", b);
593
+ return o.observe(({ changes: b }) => {
594
+ const C = (b.deleted || []).filter((d) => D(d.target.selector)), S = (b.created || []).filter((d) => D(d.target.selector)), c = (b.updated || []).filter((d) => D(d.newValue.target.selector));
595
+ C?.length > 0 && C.forEach((d) => i.remove(d.target)), S.length > 0 && i.set(S.map((d) => d.target), !1), c?.length > 0 && c.forEach(({ newValue: d }) => i.update(d.target));
595
596
  }), {
596
597
  store: {
597
598
  ...o,
598
599
  addAnnotation: a,
599
600
  bulkAddAnnotations: l,
600
- bulkUpdateTargets: E,
601
+ bulkUpdateTargets: y,
601
602
  bulkUpsertAnnotations: m,
602
- getAnnotationBounds: A,
603
- getAnnotationRects: L,
604
- getIntersecting: d,
605
- getAt: h,
606
- recalculatePositions: x,
607
- onRecalculatePositions: v,
603
+ getAnnotationBounds: v,
604
+ getAnnotationRects: x,
605
+ getIntersecting: u,
606
+ getAt: p,
607
+ recalculatePositions: N,
608
+ onRecalculatePositions: A,
608
609
  updateTarget: g
609
610
  },
610
611
  selection: s,
@@ -623,156 +624,155 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
623
624
  selectionMode: m,
624
625
  dismissOnNotAnnotatable: g = "NEVER"
625
626
  } = i;
626
- let E, h = a, A = "CREATE_NEW", d, L, x, v;
627
- const p = (f) => {
628
- h = f, R.clear(), f || (L = void 0, d = void 0, x = void 0, v = void 0);
629
- }, b = (f) => A = f || "CREATE_NEW", w = (f) => E = f, c = (f) => r = f, u = (f) => {
630
- if (A === "ADD_TO_CURRENT")
627
+ let y, p = a, v = "CREATE_NEW", u, x, N, A;
628
+ const b = (f) => {
629
+ p = f, w.clear(), f || (x = void 0, u = void 0, N = void 0, A = void 0);
630
+ }, C = (f) => v = f || "CREATE_NEW", S = (f) => y = f, c = (f) => r = f, d = (f) => {
631
+ if (v === "ADD_TO_CURRENT")
631
632
  return !0;
632
633
  if (i.allowModifierSelect) {
633
- const y = f;
634
- return ut ? y.metaKey : y.ctrlKey;
634
+ const h = f;
635
+ return ut ? h.metaKey : h.ctrlKey;
635
636
  } else
636
637
  return !1;
637
- }, T = () => {
638
- if (!h || x === !1) return;
638
+ }, R = () => {
639
+ if (!p || N === !1) return;
639
640
  const { selected: f } = n;
640
- if ((u(v) || A === "REPLACE_CURRENT") && f.length === 1 && f[0].editable) {
641
+ if ((d(A) || v === "REPLACE_CURRENT") && f.length === 1 && f[0].editable) {
641
642
  const M = s.getAnnotation(f[0].id);
642
643
  if (M?.target) {
643
- L = M.target, d = {
644
+ x = M.target, u = {
644
645
  annotation: M.id,
645
646
  selector: [],
646
- created: L.created,
647
- creator: L.creator,
647
+ created: x.created,
648
+ creator: x.creator,
648
649
  updated: /* @__PURE__ */ new Date(),
649
650
  updatedBy: r
650
651
  };
651
652
  return;
652
653
  }
653
654
  }
654
- L = void 0, d = {
655
+ x = void 0, u = {
655
656
  annotation: lt(),
656
657
  selector: [],
657
658
  created: /* @__PURE__ */ new Date(),
658
659
  creator: r
659
660
  };
660
- }, R = It((f) => {
661
- if (!h) return;
662
- const y = document.getSelection();
663
- if (!y?.anchorNode) return;
664
- const M = Array.from(Array(y.rangeCount).keys()).map((k) => y.getRangeAt(k));
665
- if (M.every((k) => !gt(t, k))) {
666
- d = void 0;
661
+ }, w = It((f) => {
662
+ if (!p) return;
663
+ const h = document.getSelection();
664
+ if (!h?.anchorNode) return;
665
+ const H = Array.from(Array(h.rangeCount).keys()).map((k) => h.getRangeAt(k)).map((k) => Ft(k, t));
666
+ if (H.every((k) => !gt(t, k))) {
667
+ u = void 0;
667
668
  return;
668
669
  }
669
- const U = f.timeStamp - (v?.timeStamp || f.timeStamp);
670
- if (v?.type === "pointerdown" && (U < 1e3 && !d || y.isCollapsed && U < at) && T(), !d && (T(), !d))
670
+ const _ = f.timeStamp - (A?.timeStamp || f.timeStamp);
671
+ if (A?.type === "pointerdown" && (_ < 1e3 && !u || h.isCollapsed && _ < at) && R(), !u && (R(), !u))
671
672
  return;
672
- if (y.isCollapsed) {
673
- s.getAnnotation(d.annotation) && !(u(v) || A === "REPLACE_CURRENT") && (n.clear(), s.deleteAnnotation(d.annotation));
673
+ if (h.isCollapsed) {
674
+ s.getAnnotation(u.annotation) && !(d(A) || v === "REPLACE_CURRENT") && (n.clear(), s.deleteAnnotation(u.annotation));
674
675
  return;
675
676
  }
676
- const _ = M.map((k) => Wt(k, t));
677
- if (_.every((k) => Ht(k))) return;
678
- const I = _.flatMap((k) => Ft(t, k.cloneRange()));
679
- if (!(I.length > 0 && !d || I.length !== d.selector.length || I.some((k, Y) => k.toString() !== d?.selector[Y]?.quote))) return;
680
- const j = u(v) && L ? Pt([
681
- ...L.selector.map((k) => k.range),
677
+ if (H.every((k) => Ht(k))) return;
678
+ const I = H.flatMap((k) => $t(t, k.cloneRange()));
679
+ if (!(I.length > 0 && !u || I.length !== u.selector.length || I.some((k, Y) => k.toString() !== u?.selector[Y]?.quote))) return;
680
+ const j = d(A) && x ? Pt([
681
+ ...x.selector.map((k) => k.range),
682
682
  ...I
683
683
  ]) : I;
684
- d = {
685
- ...d,
684
+ u = {
685
+ ...u,
686
686
  selector: j.map((k) => Yt(k, t, l)),
687
687
  updated: /* @__PURE__ */ new Date()
688
- }, !(u(v) || A === "REPLACE_CURRENT") && (s.getAnnotation(d.annotation) ? s.updateTarget(d, F.LOCAL) : n.clear());
689
- }, 10), N = (f) => {
690
- v = J(f), x = v.button === 0;
691
- }, S = async (f) => {
692
- if (!x) return;
693
- const y = J(f), M = () => {
688
+ }, !(d(A) || v === "REPLACE_CURRENT") && (s.getAnnotation(u.annotation) ? s.updateTarget(u, $.LOCAL) : n.clear());
689
+ }, 10), L = (f) => {
690
+ A = J(f), N = A.button === 0;
691
+ }, E = async (f) => {
692
+ if (!N) return;
693
+ const h = J(f), M = () => {
694
694
  const { x: _, y: I } = t.getBoundingClientRect();
695
- if (W(t, y.target)) {
696
- (typeof g == "function" ? g(y, t) : g === "ALWAYS") && n.clear();
695
+ if (F(t, h.target)) {
696
+ (typeof g == "function" ? g(h, t) : g === "ALWAYS") && n.clear();
697
697
  return;
698
698
  }
699
- const H = y.target instanceof Node && t.contains(y.target) && s.getAt(
700
- y.clientX - _,
701
- y.clientY - I,
699
+ const P = h.target instanceof Node && t.contains(h.target) && s.getAt(
700
+ h.clientX - _,
701
+ h.clientY - I,
702
702
  m === "all",
703
- E
703
+ y
704
704
  );
705
- if (H) {
706
- const { selected: j } = n, k = new Set(j.map((X) => X.id)), Y = Array.isArray(H) ? H.map((X) => X.id) : [H.id];
707
- (k.size !== Y.length || !Y.every((X) => k.has(X))) && (o.emit("clickAnnotation", H), n.userSelect(Y, y));
705
+ if (P) {
706
+ const { selected: j } = n, k = new Set(j.map((X) => X.id)), Y = Array.isArray(P) ? P.map((X) => X.id) : [P.id];
707
+ (k.size !== Y.length || !Y.every((X) => k.has(X))) && (o.emit("clickAnnotation", P), n.userSelect(Y, h));
708
708
  } else
709
709
  n.clear();
710
710
  };
711
- if (y.timeStamp - (v?.timeStamp || 0) < at) {
712
- await C();
713
- const _ = document.getSelection(), I = W(t, v?.target), H = W(t, y.target);
714
- if (_?.isCollapsed || I && H) {
715
- d = void 0, M();
711
+ if (h.timeStamp - (A?.timeStamp || 0) < at) {
712
+ await T();
713
+ const _ = document.getSelection(), I = F(t, A?.target), P = F(t, h.target);
714
+ if (_?.isCollapsed || I && P) {
715
+ u = void 0, M();
716
716
  return;
717
717
  }
718
718
  }
719
- d && d.selector.length > 0 && (K(), n.userSelect(d.annotation, y));
720
- }, C = async () => {
719
+ u && u.selector.length > 0 && (K(), n.userSelect(u.annotation, h));
720
+ }, T = async () => {
721
721
  const f = document.getSelection();
722
- let y = !1, M = f?.isCollapsed;
723
- const U = () => M || y, _ = 1;
724
- return setTimeout(() => y = !0, 50), Dt(() => M = f?.isCollapsed, _, U);
722
+ let h = !1, M = f?.isCollapsed;
723
+ const H = () => M || h, _ = 1;
724
+ return setTimeout(() => h = !0, 50), Dt(() => M = f?.isCollapsed, _, H);
725
725
  }, O = (f) => {
726
- document.getSelection()?.isCollapsed || ((!d || d.selector.length === 0) && R(f), d && (K(), n.userSelect(d.annotation, J(f))));
726
+ document.getSelection()?.isCollapsed || ((!u || u.selector.length === 0) && w(f), u && (K(), n.userSelect(u.annotation, J(f))));
727
727
  }, B = (f) => {
728
- if (h && !(f.repeat || f.target instanceof Node && W(t, f.target) && f.target !== document.body) && f.key === "Shift" && d) {
729
- const y = document.getSelection();
730
- y && !y.isCollapsed && (K(), n.userSelect(d.annotation, G(f)));
728
+ if (p && !(f.repeat || f.target instanceof Node && F(t, f.target) && f.target !== document.body) && f.key === "Shift" && u) {
729
+ const h = document.getSelection();
730
+ h && !h.isCollapsed && (K(), n.userSelect(u.annotation, G(f)));
731
731
  }
732
732
  }, V = (f) => {
733
- const y = () => setTimeout(() => {
734
- d && (d.selector.length > 0 && (n.clear(), s.addAnnotation({
735
- id: d.annotation,
733
+ const h = () => setTimeout(() => {
734
+ u && (u.selector.length > 0 && (n.clear(), s.addAnnotation({
735
+ id: u.annotation,
736
736
  bodies: [],
737
- target: d
738
- }), n.userSelect(d.annotation, G(f))), document.removeEventListener("selectionchange", y));
737
+ target: u
738
+ }), n.userSelect(u.annotation, G(f))), document.removeEventListener("selectionchange", h));
739
739
  }, 100);
740
- document.addEventListener("selectionchange", y), T();
740
+ document.addEventListener("selectionchange", h), R();
741
741
  };
742
742
  q(de.join(","), { element: t, keydown: !0, keyup: !1 }, (f) => {
743
- f.repeat || (v = G(f));
743
+ f.repeat || (A = G(f));
744
744
  }), q(bt, { keydown: !0, keyup: !1 }, (f) => {
745
- v = G(f), V(f);
745
+ A = G(f), V(f);
746
746
  });
747
747
  const z = (f) => {
748
- f.repeat || f.target instanceof Node && W(t, f.target) && f.target !== document.body || (d = void 0, n.clear());
748
+ f.repeat || f.target instanceof Node && F(t, f.target) && f.target !== document.body || (u = void 0, n.clear());
749
749
  };
750
750
  q(Et.join(","), { keydown: !0, keyup: !1 }, z);
751
751
  const K = () => {
752
- if (!d) return;
753
- const f = s.getAnnotation(d.annotation);
752
+ if (!u) return;
753
+ const f = s.getAnnotation(u.annotation);
754
754
  if (!f)
755
755
  s.addAnnotation({
756
- id: d.annotation,
756
+ id: u.annotation,
757
757
  bodies: [],
758
- target: d
758
+ target: u
759
759
  });
760
760
  else {
761
- const { target: { updated: y } } = f, { updated: M } = d;
762
- (!y || !M || y < M) && s.updateTarget(d);
761
+ const { target: { updated: h } } = f, { updated: M } = u;
762
+ (!h || !M || h < M) && s.updateTarget(u);
763
763
  }
764
764
  };
765
- return document.addEventListener("pointerdown", N), document.addEventListener("pointerup", S), document.addEventListener("contextmenu", O), document.addEventListener("keyup", B), t.addEventListener("selectstart", T), document.addEventListener("selectionchange", R), {
765
+ return document.addEventListener("pointerdown", L), document.addEventListener("pointerup", E), document.addEventListener("contextmenu", O), document.addEventListener("keyup", B), t.addEventListener("selectstart", R), document.addEventListener("selectionchange", w), {
766
766
  destroy: () => {
767
- d = void 0, L = void 0, x = void 0, v = void 0, R.clear(), document.removeEventListener("pointerdown", N), document.removeEventListener("pointerup", S), document.removeEventListener("contextmenu", O), document.removeEventListener("keyup", B), t.removeEventListener("selectstart", T), document.removeEventListener("selectionchange", R), q.unbind();
767
+ u = void 0, x = void 0, N = void 0, A = void 0, w.clear(), document.removeEventListener("pointerdown", L), document.removeEventListener("pointerup", E), document.removeEventListener("contextmenu", O), document.removeEventListener("keyup", B), t.removeEventListener("selectstart", R), document.removeEventListener("selectionchange", w), q.unbind();
768
768
  },
769
- setFilter: w,
769
+ setFilter: S,
770
770
  setUser: c,
771
- setAnnotatingEnabled: p,
772
- setAnnotatingMode: b
771
+ setAnnotatingEnabled: b,
772
+ setAnnotatingMode: C
773
773
  };
774
774
  }, fe = (t) => [
775
- `background-color:${et(t?.fill || P.fill).alpha(t?.fillOpacity === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
775
+ `background-color:${et(t?.fill || U.fill).alpha(t?.fillOpacity === void 0 ? U.fillOpacity : t.fillOpacity).toHex()}`,
776
776
  t?.underlineThickness ? "text-decoration:underline" : void 0,
777
777
  t?.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
778
778
  t?.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
@@ -789,17 +789,17 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
789
789
  console.log("setVisible not implemented on CSS Custom Highlights renderer");
790
790
  },
791
791
  redraw: (n, r, a, l, m) => {
792
- const g = new Set(n.map((h) => h.annotation.id));
793
- Array.from(e).filter((h) => !g.has(h));
794
- const E = n.map((h) => {
795
- a ? typeof a == "function" && a(h.annotation, h.state) : h.state?.selected;
796
- const A = St(h, a);
797
- return `::highlight(_${h.annotation.id}) { ${fe(A)} }`;
792
+ const g = new Set(n.map((p) => p.annotation.id));
793
+ Array.from(e).filter((p) => !g.has(p));
794
+ const y = n.map((p) => {
795
+ a ? typeof a == "function" && a(p.annotation, p.state) : p.state?.selected;
796
+ const v = St(p, a);
797
+ return `::highlight(_${p.annotation.id}) { ${fe(v)} }`;
798
798
  });
799
- t.innerHTML = E.join(`
800
- `), CSS.highlights.clear(), n.forEach(({ annotation: h }) => {
801
- const A = h.target.selector.map((L) => L.range), d = new Highlight(...A);
802
- CSS.highlights.set(`_${h.id}`, d);
799
+ t.innerHTML = y.join(`
800
+ `), CSS.highlights.clear(), n.forEach(({ annotation: p }) => {
801
+ const v = p.target.selector.map((x) => x.range), u = new Highlight(...v);
802
+ CSS.highlights.set(`_${p.id}`, u);
803
803
  }), e = g;
804
804
  }
805
805
  };
@@ -814,7 +814,7 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
814
814
  user: Nt()
815
815
  }), i = le(t, o), { selection: s, viewport: n } = i, r = i.store, a = Ot(r), l = kt(i, a, o.adapter);
816
816
  let m = o.user;
817
- const g = typeof o.renderer != "function" ? o.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ct : o.renderer || ct : null, E = g === null ? o.renderer(
817
+ const g = typeof o.renderer != "function" ? o.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ct : o.renderer || ct : null, y = g === null ? o.renderer(
818
818
  t,
819
819
  i,
820
820
  n
@@ -827,44 +827,44 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
827
827
  i,
828
828
  n
829
829
  ) : void 0;
830
- if (!E)
830
+ if (!y)
831
831
  throw `Unknown renderer implementation: ${o.renderer}`;
832
- console.debug(g ? `Using ${g} renderer` : "Using custom renderer implementation"), o.style && E.setStyle(o.style);
833
- const h = ue(
832
+ console.debug(g ? `Using ${g} renderer` : "Using custom renderer implementation"), o.style && y.setStyle(o.style);
833
+ const p = ue(
834
834
  t,
835
835
  i,
836
836
  l,
837
837
  o
838
838
  );
839
- h.setUser(m);
840
- const A = Mt(i, a, o.adapter), d = () => m, L = (c) => {
841
- h.setAnnotatingEnabled(
839
+ p.setUser(m);
840
+ const v = Mt(i, a, o.adapter), u = () => m, x = (c) => {
841
+ p.setAnnotatingEnabled(
842
842
  c === void 0 ? !0 : c
843
843
  );
844
- }, x = (c) => {
845
- h.setAnnotatingMode(c);
846
- }, v = (c) => {
847
- E.setFilter(c), h.setFilter(c);
848
- }, p = (c) => {
849
- m = c, h.setUser(c);
844
+ }, N = (c) => {
845
+ p.setAnnotatingMode(c);
846
+ }, A = (c) => {
847
+ y.setFilter(c), p.setFilter(c);
850
848
  }, b = (c) => {
849
+ m = c, p.setUser(c);
850
+ }, C = (c) => {
851
851
  c ? s.setSelected(c) : s.clear();
852
852
  };
853
853
  return {
854
- ...A,
854
+ ...v,
855
855
  destroy: () => {
856
- E.destroy(), h.destroy(), a.destroy();
856
+ y.destroy(), p.destroy(), a.destroy();
857
857
  },
858
858
  element: t,
859
- getUser: d,
860
- renderer: E,
861
- setAnnotatingEnabled: L,
862
- setAnnotatingMode: x,
863
- setFilter: v,
864
- setStyle: E.setStyle.bind(E),
865
- setUser: p,
866
- setSelected: b,
867
- setVisible: E.setVisible.bind(E),
859
+ getUser: u,
860
+ renderer: y,
861
+ setAnnotatingEnabled: x,
862
+ setAnnotatingMode: N,
863
+ setFilter: A,
864
+ setStyle: y.setStyle.bind(y),
865
+ setUser: b,
866
+ setSelected: C,
867
+ setVisible: y.setVisible.bind(y),
868
868
  on: l.on,
869
869
  off: l.off,
870
870
  // @ts-ignore - temporary
@@ -874,9 +874,9 @@ const ut = typeof navigator < "u" && navigator.platform.startsWith("Mac"), ft =
874
874
  };
875
875
  export {
876
876
  ot as DEFAULT_SELECTED_STYLE,
877
- P as DEFAULT_STYLE,
877
+ U as DEFAULT_STYLE,
878
878
  ft as NOT_ANNOTATABLE_CLASS,
879
- $ as NOT_ANNOTATABLE_SELECTOR,
879
+ W as NOT_ANNOTATABLE_SELECTOR,
880
880
  Be as Origin,
881
881
  _e as UserSelectAction,
882
882
  xe as W3CTextFormat,
@@ -895,12 +895,12 @@ export {
895
895
  pe as fillDefaults,
896
896
  Qt as getBackgroundColor,
897
897
  Jt as getHighlightClientRects,
898
- $t as getQuoteContext,
898
+ Wt as getQuoteContext,
899
899
  nt as getRangeAnnotatableContents,
900
900
  ie as getViewportBounds,
901
901
  ut as isMac,
902
902
  we as isNodeWhitespaceOrEmpty,
903
- W as isNotAnnotatable,
903
+ F as isNotAnnotatable,
904
904
  gt as isRangeAnnotatable,
905
905
  Ht as isRangeWhitespaceOrEmpty,
906
906
  D as isRevived,
@@ -914,12 +914,12 @@ export {
914
914
  Q as reviveTarget,
915
915
  Xt as scrollIntoView,
916
916
  qt as serializeW3CTextAnnotation,
917
- Ft as splitAnnotatableRanges,
917
+ $t as splitAnnotatableRanges,
918
918
  Le as toDomRectList,
919
919
  oe as toParentBounds,
920
920
  Ne as toViewportBounds,
921
921
  ae as trackViewport,
922
- Wt as trimRangeToContainer,
922
+ Ft as trimRangeToContainer,
923
923
  mt as whitespaceOrEmptyRegex
924
924
  };
925
925
  //# sourceMappingURL=text-annotator.es.js.map