@soomo/text-annotator 3.3.0-staging.0 → 3.4.0-staging.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,19 +1,19 @@
1
- import X from "debounce";
1
+ import z from "debounce";
2
2
  import { colord as ot } from "colord";
3
3
  import { dequal as ut } from "dequal/lite";
4
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 wt } from "@annotorious/core";
6
- import { Origin as Le, UserSelectAction as ke, createBody as Ne } from "@annotorious/core";
7
- import At from "rbush";
8
- import { createNanoEvents as vt } from "nanoevents";
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 U, createAnonymousGuest as St, createUndoStack as Ct, createLifecycleObserver as Et, createBaseAnnotator as vt } from "@annotorious/core";
6
+ import { Origin as ke, UserSelectAction as Ne, createBody as Be } from "@annotorious/core";
7
+ import wt from "rbush";
8
+ import { createNanoEvents as At } from "nanoevents";
9
9
  import V from "hotkeys-js";
10
10
  import { poll as xt } from "poll";
11
- const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
11
+ const rt = "not-annotatable", _ = `.${rt}`, X = (t, n) => {
12
12
  var o;
13
13
  return t.contains(n) ? !!(n instanceof HTMLElement ? n.closest(_) : (o = n.parentElement) == null ? void 0 : o.closest(_)) : !0;
14
14
  }, Rt = (t, n) => {
15
15
  const e = n.commonAncestorContainer;
16
- return !U(t, e);
16
+ return !X(t, e);
17
17
  }, Tt = (t) => t.addEventListener("click", (n) => {
18
18
  // Allow clicks within not-annotatable elements
19
19
  !n.target.closest(_) && !n.target.closest("a") && n.preventDefault();
@@ -116,7 +116,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
116
116
  const r = Z(o).textContent, i = t.toString(), a = r.length || 0, u = a + i.length;
117
117
  return e ? { quote: i, start: a, end: u, range: t, offsetReference: s } : { quote: i, start: a, end: u, range: t };
118
118
  }, it = (t, n) => {
119
- var b, f;
119
+ var y, f;
120
120
  const { start: e, end: o } = t, s = t.offsetReference || n, r = document.createNodeIterator(
121
121
  n,
122
122
  NodeFilter.SHOW_TEXT,
@@ -132,7 +132,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
132
132
  let S = !s;
133
133
  for (; u !== null; ) {
134
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;
135
+ const p = ((y = u.textContent) == null ? void 0 : y.length) || 0;
136
136
  if (i + p > e) {
137
137
  a.setStart(u, e - i);
138
138
  break;
@@ -153,10 +153,10 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
153
153
  ...t,
154
154
  range: a
155
155
  };
156
- }, z = (t, n) => M(t.selector) ? t : {
156
+ }, q = (t, n) => M(t.selector) ? t : {
157
157
  ...t,
158
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) => {
159
+ }, G = (t, n) => M(t.target.selector) ? t : { ...t, target: q(t.target, n) }, at = (t, n) => {
160
160
  if (t.isEqualNode(n))
161
161
  return !0;
162
162
  for (let e of t.childNodes)
@@ -166,7 +166,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
166
166
  }, $t = (t, n) => {
167
167
  const e = t.cloneContents();
168
168
  return at(e, n);
169
- }, _t = (t, n) => {
169
+ }, Ut = (t, n) => {
170
170
  const e = t.cloneRange(), o = n.contains(e.startContainer), s = n.contains(e.endContainer);
171
171
  return !o && !s && !$t(e, n) ? (e.collapse(), e) : (o || e.setStart(n, 0), s || e.setEnd(n, n.childNodes.length), e);
172
172
  }, Q = (t) => ({
@@ -211,7 +211,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
211
211
  defaultPrevented: t.defaultPrevented,
212
212
  detail: t.detail,
213
213
  timeStamp: t.timeStamp
214
- }), Ft = (t, n) => {
214
+ }), _t = (t, n) => {
215
215
  const { left: e, top: o, right: s, bottom: r } = t;
216
216
  return new DOMRect(e - n.left, o - n.top, s - e, r - o);
217
217
  }, Ae = (t, n) => {
@@ -223,9 +223,9 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
223
223
  const { overflowY: n } = window.getComputedStyle(t);
224
224
  return n !== "visible" && n !== "hidden" && t.scrollHeight > t.clientHeight ? t : ct(t.parentElement);
225
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) => {
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, y = i.left - o.left, f = e.parentElement ? e.scrollTop : 0, p = e.parentElement ? e.scrollLeft : 0, c = S + f - (s - u) / 2, R = y + p - (r - a) / 2;
227
+ e.scroll({ top: c, left: R, behavior: "smooth" });
228
+ }, Ft = (t, n) => (e, o) => {
229
229
  const s = typeof e == "string" ? e : e.id, r = o ? typeof o == "string" ? document.getElementById(o) : o : ct(t);
230
230
  if (!r)
231
231
  return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: t }), !1;
@@ -235,17 +235,17 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
235
235
  const { range: a } = i.target.selector[0];
236
236
  if (a && !a.collapsed)
237
237
  return tt(n, i.target, r), !0;
238
- const u = z(i.target, t), { range: S } = u.selector[0];
238
+ const u = q(i.target, t), { range: S } = u.selector[0];
239
239
  return S && !S.collapsed ? (tt(n, u, r), !0) : !1;
240
- }, P = {
240
+ }, H = {
241
241
  fill: "rgb(0, 128, 255)",
242
242
  fillOpacity: 0.18
243
- }, q = {
243
+ }, j = {
244
244
  fill: "rgb(0, 128, 255)",
245
245
  fillOpacity: 0.45
246
246
  }, Wt = (t, n, e, o, s) => {
247
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;
248
+ const r = e ? typeof e == "function" ? e(t.annotation, t.state, s) || ((i = t.state) != null && i.selected ? j : H) : e : (a = t.state) != null && a.selected ? j : H;
249
249
  return o && o.paint(t, n) || r;
250
250
  }, Vt = (t) => {
251
251
  const { top: n, left: e } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: s } = window, r = -e, i = -n, a = o - e, u = s - n;
@@ -259,48 +259,48 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
259
259
  }, J = (t, n, e, o) => {
260
260
  const { store: s, selection: r, hover: i } = n;
261
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));
262
+ const y = Yt(e), f = (C) => {
263
+ const { x: L, y: B } = t.getBoundingClientRect(), P = s.getAt(C.clientX - L, C.clientY - B, !1, u);
264
+ P ? i.current !== P.id && (t.classList.add("hovered"), i.set(P.id)) : i.current && (t.classList.remove("hovered"), i.set(null));
265
265
  };
266
266
  t.addEventListener("pointermove", f);
267
267
  const p = (C = !1) => {
268
268
  S && S.clear();
269
- const k = Vt(t), { minX: B, minY: D, maxX: h, maxY: T } = k, O = u ? s.getIntersecting(B, D, h, T).filter(({ annotation: L }) => u(L)) : s.getIntersecting(B, D, h, T), 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;
269
+ const L = Vt(t), { minX: B, minY: P, maxX: b, maxY: x } = L, O = u ? s.getIntersecting(B, P, b, x).filter(({ annotation: k }) => u(k)) : s.getIntersecting(B, P, b, x), F = r.selected.map(({ id: k }) => k), I = O.map(({ annotation: k, rects: D }) => {
270
+ const N = F.includes(k.id), K = k.id === i.current;
271
271
  return {
272
- annotation: L,
273
- rects: W,
272
+ annotation: k,
273
+ rects: D,
274
274
  state: { selected: N, hovered: K }
275
275
  };
276
276
  });
277
- o.redraw(H, k, a, S, C), setTimeout(() => b(O.map(({ annotation: L }) => L)), 1);
277
+ o.redraw(I, L, a, S, C), setTimeout(() => y(O.map(({ annotation: k }) => k)), 1);
278
278
  }, c = (C) => {
279
279
  S = C, p();
280
- }, x = (C) => {
280
+ }, R = (C) => {
281
281
  a = C, p();
282
- }, A = (C) => {
282
+ }, w = (C) => {
283
283
  u = C, p(!1);
284
- }, R = () => p();
285
- s.observe(R);
284
+ }, T = () => p();
285
+ s.observe(T);
286
286
  const E = r.subscribe(() => p()), m = i.subscribe(() => p()), l = () => p(!0);
287
287
  document.addEventListener("scroll", l, { capture: !0, passive: !0 });
288
- const g = X(() => {
288
+ const g = z(() => {
289
289
  s.recalculatePositions(), S == null || S.reset(), p();
290
290
  }, 10);
291
291
  window.addEventListener("resize", g);
292
292
  const d = new ResizeObserver(g);
293
293
  d.observe(t);
294
- const y = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver(X((C) => {
294
+ const h = { attributes: !0, childList: !0, subtree: !0 }, v = new MutationObserver(z((C) => {
295
295
  C.every((B) => B.target === t || t.contains(B.target)) || p(!0);
296
296
  }, 150));
297
- return w.observe(document.body, y), {
297
+ return v.observe(document.body, h), {
298
298
  destroy: () => {
299
- t.removeEventListener("pointermove", f), o.destroy(), s.unobserve(R), E(), m(), document.removeEventListener("scroll", l), g.clear(), window.removeEventListener("resize", g), d.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(), v.disconnect();
300
300
  },
301
301
  redraw: p,
302
- setStyle: x,
303
- setFilter: A,
302
+ setStyle: R,
303
+ setFilter: w,
304
304
  setPainter: c,
305
305
  setVisible: o.setVisible
306
306
  };
@@ -313,32 +313,32 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
313
313
  t.classList.add("r6o-annotatable");
314
314
  const n = Xt(), e = n.getContext("2d");
315
315
  document.body.appendChild(n);
316
- const o = (a, u, S, b) => requestAnimationFrame(() => {
316
+ const o = (a, u, S, y) => requestAnimationFrame(() => {
317
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((R, E) => {
321
- const { annotation: { target: { created: m } } } = R, { annotation: { target: { created: l } } } = E;
318
+ e.clearRect(-0.5, -0.5, f + 1, p + 1), y && y.clear();
319
+ const { top: c, left: R } = u;
320
+ [...a].sort((T, E) => {
321
+ const { annotation: { target: { created: m } } } = T, { annotation: { target: { created: l } } } = E;
322
322
  return m.getTime() - l.getTime();
323
- }).forEach((R) => {
323
+ }).forEach((T) => {
324
324
  var g;
325
- const E = S ? typeof S == "function" ? S(R.annotation, R.state) : S : (g = R.state) != null && g.selected ? q : P, m = b && b.paint(R, u) || E, l = R.rects.map(({ x: d, y, width: w, height: v }) => ({
326
- x: d + x,
327
- y: y + c,
328
- width: w,
329
- height: v
325
+ const E = S ? typeof S == "function" ? S(T.annotation, T.state) : S : (g = T.state) != null && g.selected ? j : H, m = y && y.paint(T, u) || E, l = T.rects.map(({ x: d, y: h, width: v, height: A }) => ({
326
+ x: d + R,
327
+ y: h + c,
328
+ width: v,
329
+ height: A
330
330
  }));
331
331
  if (e.fillStyle = m.fill, e.globalAlpha = m.fillOpacity || 1, l.forEach(
332
- ({ x: d, y, width: w, height: v }) => e.fillRect(d, y, w, v)
332
+ ({ x: d, y: h, width: v, height: A }) => e.fillRect(d, h, v, A)
333
333
  ), m.underlineColor) {
334
334
  e.globalAlpha = 1, e.strokeStyle = m.underlineColor, e.lineWidth = m.underlineThickness ?? 1;
335
335
  const d = m.underlineOffset ?? 0;
336
- l.forEach(({ x: y, y: w, width: v, height: C }) => {
337
- e.beginPath(), e.moveTo(y, w + C + d), e.lineTo(y + v, w + C + d), e.stroke();
336
+ l.forEach(({ x: h, y: v, width: A, height: C }) => {
337
+ e.beginPath(), e.moveTo(h, v + C + d), e.lineTo(h + A, v + C + d), e.stroke();
338
338
  });
339
339
  }
340
340
  });
341
- }), s = X(() => zt(n), 10);
341
+ }), s = z(() => zt(n), 10);
342
342
  return window.addEventListener("resize", s), {
343
343
  destroy: () => {
344
344
  n.remove(), s.clear(), window.removeEventListener("resize", s);
@@ -349,7 +349,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
349
349
  redraw: o
350
350
  };
351
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()}`,
352
+ `background-color:${ot((t == null ? void 0 : t.fill) || H.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? H.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,
@@ -369,14 +369,14 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
369
369
  u && u.clear();
370
370
  const S = new Set(r.map((f) => f.annotation.id));
371
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;
372
+ const y = r.map((f) => {
373
+ var R;
374
+ const p = a ? typeof a == "function" ? a(f.annotation, f.state) : a : (R = f.state) != null && R.selected ? j : H, c = u && u.paint(f, i) || p;
375
375
  return `::highlight(_${f.annotation.id}) { ${Gt(c)} }`;
376
376
  });
377
- t.innerHTML = b.join(`
377
+ t.innerHTML = y.join(`
378
378
  `), CSS.highlights.clear(), r.forEach(({ annotation: f }) => {
379
- const p = f.target.selector.map((x) => x.range), c = new Highlight(...p);
379
+ const p = f.target.selector.map((R) => R.range), c = new Highlight(...p);
380
380
  CSS.highlights.set(`_${f.id}`, c);
381
381
  }), n = S;
382
382
  }
@@ -393,18 +393,18 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
393
393
  destroy: () => {
394
394
  n.remove();
395
395
  },
396
- redraw: (i, a, u, S, b) => {
397
- const p = !(ut(e, i) && b);
396
+ redraw: (i, a, u, S, y) => {
397
+ const p = !(ut(e, i) && y);
398
398
  if (!S && !p) return;
399
- p && (n.innerHTML = ""), [...i].sort((x, A) => {
400
- const { annotation: { target: { created: R } } } = x, { annotation: { target: { created: E } } } = A;
401
- return R && E ? R.getTime() - E.getTime() : 0;
402
- }).forEach((x) => {
403
- x.rects.map((A) => {
404
- const R = Jt(A, i), E = Wt(x, a, u, S, R);
399
+ p && (n.innerHTML = ""), [...i].sort((R, w) => {
400
+ const { annotation: { target: { created: T } } } = R, { annotation: { target: { created: E } } } = w;
401
+ return T && E ? T.getTime() - E.getTime() : 0;
402
+ }).forEach((R) => {
403
+ R.rects.map((w) => {
404
+ const T = Jt(w, i), E = Wt(R, a, u, S, T);
405
405
  if (p) {
406
406
  const m = document.createElement("span");
407
- m.className = "r6o-annotation", m.dataset.annotation = x.annotation.id, m.style.left = `${A.x}px`, m.style.top = `${A.y}px`, m.style.width = `${A.width}px`, m.style.height = `${A.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);
407
+ m.className = "r6o-annotation", m.dataset.annotation = R.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) || H.fill).alpha((E == null ? void 0 : E.fillOpacity) === void 0 ? H.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
410
  }), e = i;
@@ -413,7 +413,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
413
413
  i ? n.classList.remove("hidden") : n.classList.add("hidden");
414
414
  }
415
415
  };
416
- }, ee = (t, n, e) => J(t, n, e, te(t)), ve = (t, n) => ({
416
+ }, ee = (t, n, e) => J(t, n, e, te(t)), xe = (t, n) => ({
417
417
  parse: (e) => se(e),
418
418
  serialize: (e) => re(e, t, n)
419
419
  }), ne = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, oe = (t) => {
@@ -436,7 +436,7 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
436
436
  styleClass: "styleClass" in i[0] ? i[0].styleClass : void 0
437
437
  };
438
438
  for (const u of i) {
439
- const b = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((f, p) => {
439
+ const y = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((f, p) => {
440
440
  switch (p.type) {
441
441
  case "TextQuoteSelector":
442
442
  f.quote = p.exact;
@@ -447,10 +447,10 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
447
447
  }
448
448
  return f;
449
449
  }, {});
450
- if (a.outdated || (a.outdated = "outdated" in u ? u.outdated : void 0), ne(b))
450
+ if (a.outdated || (a.outdated = "outdated" in u ? u.outdated : void 0), ne(y))
451
451
  a.selector.push(
452
452
  {
453
- ...b,
453
+ ...y,
454
454
  id: u.id,
455
455
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
456
456
  scope: u.scope
@@ -458,8 +458,8 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
458
458
  );
459
459
  else {
460
460
  const f = [
461
- b.start ? void 0 : "TextPositionSelector",
462
- b.quote ? void 0 : "TextQuoteSelector"
461
+ y.start ? void 0 : "TextPositionSelector",
462
+ y.quote ? void 0 : "TextQuoteSelector"
463
463
  ].filter(Boolean);
464
464
  return { error: Error(`Missing selector types: ${f.join(" and ")} for annotation: ${t.id}`) };
465
465
  }
@@ -487,11 +487,11 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
487
487
  creator: a,
488
488
  created: u,
489
489
  updated: S,
490
- ...b
490
+ ...y
491
491
  } = s, f = i.map((p) => {
492
- const { id: c, quote: x, start: A, end: R, range: E } = p, m = {
492
+ const { id: c, quote: R, start: w, end: T, range: E } = p, m = {
493
493
  type: "TextQuoteSelector",
494
- exact: x
494
+ exact: R
495
495
  };
496
496
  if (e) {
497
497
  const { prefix: g, suffix: d } = Ot(E, e);
@@ -499,11 +499,11 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
499
499
  }
500
500
  const l = {
501
501
  type: "TextPositionSelector",
502
- start: A,
503
- end: R
502
+ start: w,
503
+ end: T
504
504
  };
505
505
  return {
506
- ...b,
506
+ ...y,
507
507
  id: c,
508
508
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
509
509
  scope: "scope" in p ? p.scope : void 0,
@@ -523,21 +523,21 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
523
523
  target: f
524
524
  };
525
525
  }, ie = (t, n) => {
526
- const e = new At(), o = /* @__PURE__ */ new Map(), s = vt(), r = (l, g) => {
527
- const d = l.selector.flatMap((w) => {
528
- const v = M([w]) ? w.range : it(w, n).range;
529
- return Array.from(v.getClientRects());
530
- }), y = Dt(d).map((w) => Ft(w, g));
531
- return y.map((w) => {
532
- const { x: v, y: C, width: k, height: B } = w;
526
+ const e = new wt(), o = /* @__PURE__ */ new Map(), s = At(), r = (l, g) => {
527
+ const d = l.selector.flatMap((v) => {
528
+ const A = M([v]) ? v.range : it(v, n).range;
529
+ return Array.from(A.getClientRects());
530
+ }), h = Dt(d).map((v) => _t(v, g));
531
+ return h.map((v) => {
532
+ const { x: A, y: C, width: L, height: B } = v;
533
533
  return {
534
- minX: v,
534
+ minX: A,
535
535
  minY: C,
536
- maxX: v + k,
536
+ maxX: A + L,
537
537
  maxY: C + B,
538
538
  annotation: {
539
539
  id: l.annotation,
540
- rects: y
540
+ rects: h
541
541
  }
542
542
  };
543
543
  });
@@ -549,35 +549,35 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
549
549
  }, S = (l) => {
550
550
  const g = o.get(l.annotation);
551
551
  g && (g.forEach((d) => e.remove(d)), o.delete(l.annotation));
552
- }, b = (l) => {
552
+ }, y = (l) => {
553
553
  S(l), u(l);
554
554
  }, f = (l, g = !0) => {
555
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);
556
+ const d = n.getBoundingClientRect(), h = l.map((A) => ({ target: A, rects: r(A, d) }));
557
+ h.forEach(({ target: A, rects: C }) => {
558
+ C.length > 0 && o.set(A.annotation, C);
559
559
  });
560
- const w = y.flatMap(({ rects: v }) => v);
561
- e.load(w);
560
+ const v = h.flatMap(({ rects: A }) => A);
561
+ e.load(v);
562
562
  }, p = (l, g, d = !1) => {
563
- const y = e.search({
563
+ const h = e.search({
564
564
  minX: l,
565
565
  minY: g,
566
566
  maxX: l,
567
567
  maxY: g
568
- }), w = (v) => v.annotation.rects.reduce((C, k) => C + k.width * k.height, 0);
569
- return y.length > 0 ? (y.sort((v, C) => w(v) - w(C)), d ? y.map((v) => v.annotation.id) : [y[0].annotation.id]) : [];
568
+ }), v = (A) => A.annotation.rects.reduce((C, L) => C + L.width * L.height, 0);
569
+ return h.length > 0 ? (h.sort((A, C) => v(A) - v(C)), d ? h.map((A) => A.annotation.id) : [h[0].annotation.id]) : [];
570
570
  }, c = (l) => {
571
- const g = x(l);
571
+ const g = R(l);
572
572
  if (g.length === 0)
573
573
  return;
574
- let d = g[0].left, y = g[0].top, w = g[0].right, v = g[0].bottom;
574
+ let d = g[0].left, h = g[0].top, v = g[0].right, A = g[0].bottom;
575
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), w = Math.max(w, k.right), v = Math.max(v, k.bottom);
576
+ const L = g[C];
577
+ d = Math.min(d, L.left), h = Math.min(h, L.top), v = Math.max(v, L.right), A = Math.max(A, L.bottom);
578
578
  }
579
- return new DOMRect(d, y, w - d, v - y);
580
- }, x = (l) => {
579
+ return new DOMRect(d, h, v - d, A - h);
580
+ }, R = (l) => {
581
581
  const g = o.get(l);
582
582
  return g ? g[0].annotation.rects : [];
583
583
  };
@@ -586,12 +586,12 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
586
586
  clear: a,
587
587
  getAt: p,
588
588
  getAnnotationBounds: c,
589
- getAnnotationRects: x,
590
- getIntersecting: (l, g, d, y) => {
591
- const w = e.search({ minX: l, minY: g, maxX: d, maxY: y }), v = new Set(w.map((C) => C.annotation.id));
592
- return Array.from(v).map((C) => ({
589
+ getAnnotationRects: R,
590
+ getIntersecting: (l, g, d, h) => {
591
+ const v = e.search({ minX: l, minY: g, maxX: d, maxY: h }), A = new Set(v.map((C) => C.annotation.id));
592
+ return Array.from(A).map((C) => ({
593
593
  annotation: t.getAnnotation(C),
594
- rects: x(C)
594
+ rects: R(C)
595
595
  })).filter((C) => !!C.annotation);
596
596
  },
597
597
  insert: u,
@@ -601,37 +601,37 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
601
601
  remove: S,
602
602
  set: f,
603
603
  size: () => e.all().length,
604
- update: b,
604
+ update: y,
605
605
  on: (l, g) => s.on(l, g)
606
606
  };
607
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) => {
608
+ const e = pt(), o = ie(e, t), s = ht(e, n.userSelectAction, n.adapter), r = yt(e), i = bt(), a = (m, l = U.LOCAL) => {
609
609
  const g = G(m, t), d = M(g.target.selector);
610
610
  return d && e.addAnnotation(g, l), d;
611
- }, u = (m, l = !0, g = $.LOCAL) => {
612
- const d = m.map((w) => G(w, t)), y = d.filter((w) => !M(w.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);
611
+ }, u = (m, l = !0, g = U.LOCAL) => {
612
+ const d = m.map((v) => G(v, t)), h = d.filter((v) => !M(v.target.selector));
613
+ return e.bulkAddAnnotations(d, l, g), h;
614
+ }, S = (m, l = U.LOCAL) => {
615
+ const g = m.map((h) => G(h, t)), d = g.filter((h) => !M(h.target.selector));
616
+ return g.forEach((h) => {
617
+ e.getAnnotation(h.id) ? e.updateAnnotation(h, l) : e.addAnnotation(h, l);
618
618
  }), d;
619
- }, b = (m, l = $.LOCAL) => {
620
- const g = z(m, t);
619
+ }, y = (m, l = U.LOCAL) => {
620
+ const g = q(m, t);
621
621
  e.updateTarget(g, l);
622
- }, f = (m, l = $.LOCAL) => {
623
- const g = m.map((d) => z(d, t));
622
+ }, f = (m, l = U.LOCAL) => {
623
+ const g = m.map((d) => q(d, t));
624
624
  e.bulkUpdateTargets(g, l);
625
625
  };
626
626
  function p(m, l, g, d) {
627
- const y = g || !!d, w = o.getAt(m, l, y).map((C) => e.getAnnotation(C)), v = d ? w.filter(d) : w;
628
- if (v.length !== 0)
629
- return g ? v : v[0];
627
+ const h = g || !!d, v = o.getAt(m, l, h).map((C) => e.getAnnotation(C)), A = d ? v.filter(d) : v;
628
+ if (A.length !== 0)
629
+ return g ? A : A[0];
630
630
  }
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), A = (m) => o.getAnnotationRects(m), R = () => o.recalculate(), E = (m) => o.on("recalculate", m);
631
+ const c = (m) => o.getAnnotationRects(m).length > 0 ? o.getAnnotationBounds(m) : void 0, R = (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 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));
633
+ const l = (m.deleted || []).filter((h) => M(h.target.selector)), g = (m.created || []).filter((h) => M(h.target.selector)), d = (m.updated || []).filter((h) => M(h.newValue.target.selector));
634
+ (l == null ? void 0 : l.length) > 0 && l.forEach((h) => o.remove(h.target)), g.length > 0 && o.set(g.map((h) => h.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: h }) => o.update(h.target));
635
635
  }), {
636
636
  store: {
637
637
  ...e,
@@ -640,12 +640,12 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
640
640
  bulkUpdateTargets: f,
641
641
  bulkUpsertAnnotations: S,
642
642
  getAnnotationBounds: c,
643
- getAnnotationRects: A,
644
- getIntersecting: x,
643
+ getAnnotationRects: w,
644
+ getIntersecting: R,
645
645
  getAt: p,
646
- recalculatePositions: R,
646
+ recalculatePositions: T,
647
647
  onRecalculatePositions: E,
648
- updateTarget: b
648
+ updateTarget: y
649
649
  },
650
650
  selection: s,
651
651
  hover: r,
@@ -659,25 +659,25 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
659
659
  }, le = (t, n = {}) => {
660
660
  const e = ce(), o = e.getContext("2d");
661
661
  document.body.appendChild(e);
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));
662
+ const s = /* @__PURE__ */ new Map(), r = (y) => Array.from(s.entries()).filter(([f, p]) => p.presenceKey === y.presenceKey).map(([f, p]) => f);
663
+ return t.on("selectionChange", (y, f) => {
664
+ r(y).forEach((c) => s.delete(c)), f && f.forEach((c) => s.set(c, y));
665
665
  }), {
666
666
  clear: () => {
667
- const { width: b, height: f } = e;
668
- o.clearRect(-0.5, -0.5, b + 1, f + 1);
667
+ const { width: y, height: f } = e;
668
+ o.clearRect(-0.5, -0.5, y + 1, f + 1);
669
669
  },
670
670
  destroy: () => {
671
671
  e.remove();
672
672
  },
673
- paint: (b, f, p) => {
673
+ paint: (y, f, p) => {
674
674
  n.font && (o.font = n.font);
675
- const c = s.get(b.annotation.id);
675
+ const c = s.get(y.annotation.id);
676
676
  if (c) {
677
- const { height: x } = b.rects[0], A = b.rects[0].x + f.left, R = b.rects[0].y + f.top;
678
- o.fillStyle = c.appearance.color, o.fillRect(A - 2, R - 2.5, 2, x + 5);
677
+ const { height: R } = y.rects[0], w = y.rects[0].x + f.left, T = y.rects[0].y + f.top;
678
+ o.fillStyle = c.appearance.color, o.fillRect(w - 2, T - 2.5, 2, R + 5);
679
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(A - 2, R - 2.5 - l, m, l), o.fillStyle = "#fff", o.fillText(c.appearance.label, A + 1, R - g), {
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
681
  fill: c.appearance.color,
682
682
  fillOpacity: p ? 0.45 : 0.18
683
683
  };
@@ -685,8 +685,8 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
685
685
  },
686
686
  reset: () => {
687
687
  e.width = 2 * window.innerWidth, e.height = 2 * window.innerHeight;
688
- const b = e.getContext("2d");
689
- b.scale(2, 2), b.translate(0.5, 0.5);
688
+ const y = e.getContext("2d");
689
+ y.scale(2, 2), y.translate(0.5, 0.5);
690
690
  }
691
691
  };
692
692
  }, et = 300, lt = ["up", "down", "left", "right"], dt = Lt ? "⌘+a" : "ctrl+a", de = [
@@ -700,102 +700,108 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
700
700
  offsetReferenceSelector: a,
701
701
  selectionMode: u,
702
702
  dismissOnNotAnnotatable: S = "NEVER"
703
- } = e, b = (h) => r = h;
703
+ } = e, y = (b) => r = b;
704
704
  let f;
705
- const p = (h) => f = h;
706
- let c, x, A, R = i;
707
- const E = (h) => {
708
- R = h, l.clear(), h || (c = void 0, x = void 0, A = void 0);
709
- }, m = (h) => {
710
- R && x !== !1 && (c = U(t, h.target) ? void 0 : {
705
+ const p = (b) => f = b;
706
+ let c, R, w, T = i;
707
+ const E = (b) => {
708
+ T = b, l.clear(), b || (c = void 0, R = void 0, w = void 0);
709
+ }, m = (b) => {
710
+ T && R !== !1 && (c = X(t, b.target) ? void 0 : {
711
711
  annotation: st(),
712
712
  selector: [],
713
713
  creator: r,
714
714
  created: /* @__PURE__ */ new Date()
715
715
  });
716
- }, l = X((h) => {
717
- if (!R) return;
718
- const T = document.getSelection();
719
- if (!(T != null && T.anchorNode))
716
+ }, l = z((b) => {
717
+ if (!T) return;
718
+ const x = document.getSelection();
719
+ if (!(x != null && x.anchorNode))
720
720
  return;
721
- if (U(t, T.anchorNode)) {
721
+ if (X(t, x.anchorNode)) {
722
722
  c = void 0;
723
723
  return;
724
724
  }
725
- const O = h.timeStamp - ((A == null ? void 0 : A.timeStamp) || h.timeStamp);
726
- if ((A == null ? void 0 : A.type) === "pointerdown" && (O < 1e3 && !c || T.isCollapsed && O < et) && m(A || h), !c) return;
727
- if (T.isCollapsed) {
725
+ const O = b.timeStamp - ((w == null ? void 0 : w.timeStamp) || b.timeStamp);
726
+ if ((w == null ? void 0 : w.type) === "pointerdown" && (O < 1e3 && !c || x.isCollapsed && O < et) && m(w || b), !c) return;
727
+ if (x.isCollapsed) {
728
728
  o.getAnnotation(c.annotation) && (s.clear(), o.deleteAnnotation(c.annotation));
729
729
  return;
730
730
  }
731
- const H = Array.from(Array(T.rangeCount).keys()).map((N) => T.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);
731
+ const I = Array.from(Array(x.rangeCount).keys()).map((N) => x.getRangeAt(N)).map((N) => Ut(N, t));
732
+ if (I.every((N) => Mt(N))) return;
733
+ const k = I.flatMap((N) => Bt(t, N.cloneRange()));
734
+ (k.length !== c.selector.length || k.some((N, K) => {
735
+ var $;
736
+ return N.toString() !== (($ = c.selector[K]) == null ? void 0 : $.quote);
737
737
  })) && (c = {
738
738
  ...c,
739
- selector: L.map((N) => Kt(N, t, a)),
739
+ selector: k.map((N) => Kt(N, t, a)),
740
740
  updated: /* @__PURE__ */ new Date()
741
- }, o.getAnnotation(c.annotation) ? o.updateTarget(c, $.LOCAL) : s.clear());
742
- }, 10), g = (h) => {
743
- U(t, h.target) || (A = Q(h), x = A.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
- }
750
- const T = () => {
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);
741
+ }, o.getAnnotation(c.annotation) ? o.updateTarget(c, U.LOCAL) : s.clear());
742
+ }, 10), g = (b) => {
743
+ w = Q(b), R = w.button === 0;
744
+ }, d = async (b) => {
745
+ if (!R) return;
746
+ const x = Q(b), O = () => {
747
+ const { x: I, y: k } = t.getBoundingClientRect();
748
+ if (X(t, x.target)) {
749
+ (typeof S == "function" ? S(x, t) : S === "ALWAYS") && s.clear();
750
+ return;
751
+ }
752
+ const D = x.target instanceof Node && t.contains(x.target) && o.getAt(
753
+ x.clientX - I,
754
+ x.clientY - k,
755
+ u === "all",
756
+ f
757
+ );
758
+ if (D) {
759
+ const { selected: N } = s, K = new Set(N.map((W) => W.id)), $ = Array.isArray(D) ? D.map((W) => W.id) : [D.id];
760
+ (K.size !== $.length || !$.every((W) => K.has(W))) && s.userSelect($, x);
755
761
  } else
756
762
  s.clear();
757
763
  };
758
- if (h.timeStamp - A.timeStamp < et) {
759
- await y();
764
+ if (x.timeStamp - w.timeStamp < et) {
765
+ await h();
760
766
  const I = document.getSelection();
761
767
  if (I != null && I.isCollapsed) {
762
- c = void 0, T();
768
+ c = void 0, O();
763
769
  return;
764
770
  }
765
771
  }
766
- c && c.selector.length > 0 && (B(), s.userSelect(c.annotation, Q(h)));
767
- }, y = async () => {
768
- const h = document.getSelection();
769
- let T = !1, O = h == null ? void 0 : h.isCollapsed;
770
- const I = () => O || T, H = 1;
771
- return setTimeout(() => T = !0, 50), xt(() => O = h == null ? void 0 : h.isCollapsed, H, I);
772
- }, w = (h) => {
773
- const T = document.getSelection();
774
- T != null && T.isCollapsed || ((!c || c.selector.length === 0) && l(h), c && (B(), s.userSelect(c.annotation, Q(h))));
775
- }, v = (h) => {
776
- R && h.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, Y(h))));
777
- }, C = (h) => {
778
- const T = () => setTimeout(() => {
772
+ c && c.selector.length > 0 && (B(), s.userSelect(c.annotation, x));
773
+ }, h = async () => {
774
+ const b = document.getSelection();
775
+ let x = !1, O = b == null ? void 0 : b.isCollapsed;
776
+ const F = () => O || x, I = 1;
777
+ return setTimeout(() => x = !0, 50), xt(() => O = b == null ? void 0 : b.isCollapsed, I, F);
778
+ }, v = (b) => {
779
+ const x = document.getSelection();
780
+ x != null && x.isCollapsed || ((!c || c.selector.length === 0) && l(b), c && (B(), s.userSelect(c.annotation, Q(b))));
781
+ }, A = (b) => {
782
+ T && b.key === "Shift" && c && (document.getSelection().isCollapsed || (B(), s.userSelect(c.annotation, Y(b))));
783
+ }, C = (b) => {
784
+ const x = () => setTimeout(() => {
779
785
  (c == null ? void 0 : c.selector.length) > 0 && (s.clear(), o.addAnnotation({
780
786
  id: c.annotation,
781
787
  bodies: [],
782
788
  target: c
783
- }), s.userSelect(c.annotation, Y(h))), document.removeEventListener("selectionchange", T);
789
+ }), s.userSelect(c.annotation, Y(b))), document.removeEventListener("selectionchange", x);
784
790
  }, 100);
785
- document.addEventListener("selectionchange", T), m(h);
791
+ document.addEventListener("selectionchange", x), m(b);
786
792
  };
787
- V(de.join(","), { element: t, keydown: !0, keyup: !1 }, (h) => {
788
- h.repeat || (A = Y(h));
789
- }), V(dt, { keydown: !0, keyup: !1 }, (h) => {
790
- A = Y(h), C(h);
793
+ V(de.join(","), { element: t, keydown: !0, keyup: !1 }, (b) => {
794
+ b.repeat || (w = Y(b));
795
+ }), V(dt, { keydown: !0, keyup: !1 }, (b) => {
796
+ w = Y(b), C(b);
791
797
  });
792
- const k = (h) => {
793
- h.repeat || h.target !== t && h.target !== document.body || (c = void 0, s.clear());
798
+ const L = (b) => {
799
+ b.repeat || b.target !== t && b.target !== document.body || (c = void 0, s.clear());
794
800
  };
795
- V(lt.join(","), { keydown: !0, keyup: !1 }, k);
801
+ V(lt.join(","), { keydown: !0, keyup: !1 }, L);
796
802
  const B = () => {
797
- const h = o.getAnnotation(c.annotation);
798
- if (!h) {
803
+ const b = o.getAnnotation(c.annotation);
804
+ if (!b) {
799
805
  o.addAnnotation({
800
806
  id: c.annotation,
801
807
  bodies: [],
@@ -803,39 +809,39 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
803
809
  });
804
810
  return;
805
811
  }
806
- const { target: { updated: T } } = h, { updated: O } = c;
807
- (!T || !O || T < O) && o.updateTarget(c);
812
+ const { target: { updated: x } } = b, { updated: O } = c;
813
+ (!x || !O || x < O) && o.updateTarget(c);
808
814
  };
809
- return t.addEventListener("pointerdown", g), document.addEventListener("pointerup", d), document.addEventListener("contextmenu", w), t.addEventListener("keyup", v), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", l), {
815
+ return document.addEventListener("pointerdown", g), document.addEventListener("pointerup", d), document.addEventListener("contextmenu", v), t.addEventListener("keyup", A), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", l), {
810
816
  destroy: () => {
811
- c = void 0, x = void 0, A = void 0, l.clear(), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", d), document.removeEventListener("contextmenu", w), t.removeEventListener("keyup", v), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", l), V.unbind();
817
+ c = void 0, R = void 0, w = void 0, l.clear(), document.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", d), document.removeEventListener("contextmenu", v), t.removeEventListener("keyup", A), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", l), V.unbind();
812
818
  },
813
819
  setFilter: p,
814
- setUser: b,
820
+ setUser: y,
815
821
  setAnnotatingEnabled: E
816
822
  };
817
823
  }, fe = (t, n) => ({
818
824
  ...t,
819
825
  annotatingEnabled: t.annotatingEnabled ?? n.annotatingEnabled,
820
826
  user: t.user || n.user
821
- }), nt = "SPANS", xe = (t, n = {}) => {
827
+ }), nt = "SPANS", Re = (t, n = {}) => {
822
828
  Tt(t), kt(t);
823
829
  const e = fe(n, {
824
830
  annotatingEnabled: !0,
825
831
  user: St()
826
832
  }), o = ae(t, e), { selection: s, viewport: r } = o, i = o.store, a = Ct(i), u = Et(o, a, e.adapter);
827
833
  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;
834
+ const y = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : nt : e.renderer || nt, f = y === "SPANS" ? ee(t, o, r) : y === "CSS_HIGHLIGHTS" ? Zt(t, o, r) : y === "CANVAS" ? jt(t, o, r) : void 0;
829
835
  if (!f)
830
- throw `Unknown renderer implementation: ${b}`;
831
- console.debug(`Using ${b} renderer`), e.style && f.setStyle(e.style);
836
+ throw `Unknown renderer implementation: ${y}`;
837
+ console.debug(`Using ${y} renderer`), e.style && f.setStyle(e.style);
832
838
  const p = ue(t, o, e);
833
839
  p.setUser(S), p.setAnnotatingEnabled(e.annotatingEnabled);
834
- const c = wt(o, a, e.adapter), x = () => S, A = (d) => {
840
+ const c = vt(o, a, e.adapter), R = () => S, w = (d) => {
835
841
  p.setAnnotatingEnabled(
836
842
  d === void 0 ? !0 : d
837
843
  );
838
- }, R = (d) => {
844
+ }, T = (d) => {
839
845
  f.setFilter(d), p.setFilter(d);
840
846
  }, E = (d) => {
841
847
  S = d, p.setUser(d);
@@ -850,9 +856,9 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
850
856
  f.destroy(), p.destroy(), a.destroy();
851
857
  },
852
858
  element: t,
853
- getUser: x,
854
- setAnnotatingEnabled: A,
855
- setFilter: R,
859
+ getUser: R,
860
+ setAnnotatingEnabled: w,
861
+ setFilter: T,
856
862
  setStyle: f.setStyle.bind(f),
857
863
  redraw: f.redraw.bind(f),
858
864
  setUser: E,
@@ -861,35 +867,35 @@ const rt = "not-annotatable", _ = `.${rt}`, U = (t, n) => {
861
867
  setVisible: f.setVisible.bind(f),
862
868
  on: u.on,
863
869
  off: u.off,
864
- scrollIntoView: Ut(t, i),
870
+ scrollIntoView: Ft(t, i),
865
871
  state: o
866
872
  };
867
873
  };
868
874
  export {
869
- q as DEFAULT_SELECTED_STYLE,
870
- P as DEFAULT_STYLE,
875
+ j as DEFAULT_SELECTED_STYLE,
876
+ H as DEFAULT_STYLE,
871
877
  rt as NOT_ANNOTATABLE_CLASS,
872
878
  _ as NOT_ANNOTATABLE_SELECTOR,
873
- Le as Origin,
874
- ke as UserSelectAction,
875
- ve as W3CTextFormat,
879
+ ke as Origin,
880
+ Ne as UserSelectAction,
881
+ xe as W3CTextFormat,
876
882
  Tt as cancelSingleClickEvents,
877
883
  Y as cloneKeyboardEvent,
878
884
  Q as clonePointerEvent,
879
- Ne as createBody,
885
+ Be as createBody,
880
886
  jt as createCanvasRenderer,
881
887
  Zt as createHighlightsRenderer,
882
888
  le as createPresencePainter,
883
889
  Qt as createRenderer,
884
890
  ue as createSelectionHandler,
885
891
  ee as createSpansRenderer,
886
- xe as createTextAnnotator,
892
+ Re as createTextAnnotator,
887
893
  ae as createTextAnnotatorState,
888
894
  fe as fillDefaults,
889
895
  Ot as getQuoteContext,
890
896
  Z as getRangeAnnotatableContents,
891
897
  Lt as isMac,
892
- U as isNotAnnotatable,
898
+ X as isNotAnnotatable,
893
899
  Rt as isRangeAnnotatable,
894
900
  M as isRevived,
895
901
  Mt as isWhitespaceOrEmpty,
@@ -901,14 +907,14 @@ export {
901
907
  Kt as rangeToSelector,
902
908
  G as reviveAnnotation,
903
909
  it as reviveSelector,
904
- z as reviveTarget,
905
- Ut as scrollIntoView,
910
+ q as reviveTarget,
911
+ Ft as scrollIntoView,
906
912
  re as serializeW3CTextAnnotation,
907
913
  Bt as splitAnnotatableRanges,
908
914
  we as toDomRectList,
909
- Ft as toParentBounds,
915
+ _t as toParentBounds,
910
916
  Ae as toViewportBounds,
911
- _t as trimRangeToContainer,
917
+ Ut as trimRangeToContainer,
912
918
  It as whitespaceOrEmptyRegex
913
919
  };
914
920
  //# sourceMappingURL=text-annotator.es.js.map