@soomo/text-annotator 3.0.0-staging.7 → 3.0.0-staging.8

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.
@@ -73,8 +73,8 @@ const $ = {
73
73
  }), s = mt(n, e), u = mt(i, e), f = () => {
74
74
  const l = e;
75
75
  l.replaceChildren(...a);
76
- const m = bt(s, l), p = bt(u, l);
77
- return t.setStart(m, o), t.setEnd(p, r), t;
76
+ const m = bt(s, l), g = bt(u, l);
77
+ return t.setStart(m, o), t.setEnd(g, r), t;
78
78
  }, b = (l) => {
79
79
  const m = document.createElement("SPAN");
80
80
  return l.surroundContents(m), m;
@@ -84,9 +84,9 @@ const $ = {
84
84
  {
85
85
  const l = document.createRange();
86
86
  l.selectNodeContents(n), l.setStart(n, o);
87
- const m = b(l), p = document.createRange();
88
- p.selectNode(i), p.setEnd(i, r);
89
- const y = b(p), h = Jt(t).reverse().map((d) => {
87
+ const m = b(l), g = document.createRange();
88
+ g.selectNode(i), g.setEnd(i, r);
89
+ const y = b(g), h = Jt(t).reverse().map((d) => {
90
90
  var w;
91
91
  const c = document.createElement("SPAN");
92
92
  return (w = d.parentNode) == null || w.insertBefore(c, d), c.appendChild(d), c;
@@ -181,8 +181,8 @@ const $ = {
181
181
  e,
182
182
  NodeFilter.SHOW_TEXT,
183
183
  (m) => {
184
- var p;
185
- return (p = m.parentElement) != null && p.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
184
+ var g;
185
+ return (g = m.parentElement) != null && g.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
186
186
  }
187
187
  );
188
188
  let a = 0;
@@ -225,27 +225,27 @@ const $ = {
225
225
  const i = o.map((r) => r.id);
226
226
  (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
227
227
  };
228
- }, pt = (t, e, n, o) => {
228
+ }, gt = (t, e, n, o) => {
229
229
  const { store: i, selection: r, hover: a } = e;
230
230
  let s, u, f;
231
- const b = ae(n), l = (g) => {
232
- const { x: A, y: x } = t.getBoundingClientRect(), S = i.getAt(g.clientX - A, g.clientY - x);
231
+ const b = ae(n), l = (p) => {
232
+ const { x: A, y: x } = t.getBoundingClientRect(), S = i.getAt(p.clientX - A, p.clientY - x);
233
233
  S && (!u || u(S)) ? a.current !== S.id && (t.classList.add("hovered"), a.set(S.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
234
234
  };
235
235
  t.addEventListener("pointermove", l);
236
- const m = (g = !1) => {
236
+ const m = (p = !1) => {
237
237
  f && f.clear();
238
238
  const A = se(t), { minX: x, minY: S, maxX: B, maxY: I } = A, k = u ? i.getIntersecting(x, S, B, I).filter(({ annotation: Y }) => u(Y)) : i.getIntersecting(x, S, B, I), Ht = r.selected.map(({ id: Y }) => Y), Pt = k.map(({ annotation: Y, rects: zt }) => {
239
239
  const Ft = Ht.includes(Y.id), Wt = Y.id === a.current;
240
240
  return { annotation: Y, rects: zt, state: { selected: Ft, hover: Wt, custom: {} } };
241
241
  });
242
- o.redraw(Pt, A, s, f, g), setTimeout(() => b(k.map(({ annotation: Y }) => Y)), 1);
243
- }, p = (g) => {
244
- f = g, m();
245
- }, y = (g) => {
246
- s = g, m();
247
- }, v = (g) => {
248
- u = g, m(!1);
242
+ o.redraw(Pt, A, s, f, p), setTimeout(() => b(k.map(({ annotation: Y }) => Y)), 1);
243
+ }, g = (p) => {
244
+ f = p, m();
245
+ }, y = (p) => {
246
+ s = p, m();
247
+ }, v = (p) => {
248
+ u = p, m(!1);
249
249
  }, h = () => m();
250
250
  i.observe(h);
251
251
  const d = r.subscribe(() => m()), c = () => m(!0);
@@ -256,8 +256,8 @@ const $ = {
256
256
  window.addEventListener("resize", w);
257
257
  const L = new ResizeObserver(w);
258
258
  L.observe(t);
259
- const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((g) => {
260
- g.every((x) => x.target === t || t.contains(x.target)) || m(!0);
259
+ const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((p) => {
260
+ p.every((x) => x.target === t || t.contains(x.target)) || m(!0);
261
261
  });
262
262
  return E.observe(document.body, C), {
263
263
  destroy: () => {
@@ -266,7 +266,7 @@ const $ = {
266
266
  redraw: m,
267
267
  setStyle: y,
268
268
  setFilter: v,
269
- setPainter: p,
269
+ setPainter: g,
270
270
  setVisible: o.setVisible
271
271
  };
272
272
  }, le = () => {
@@ -281,29 +281,29 @@ const $ = {
281
281
  const o = (s, u, f, b) => requestAnimationFrame(() => {
282
282
  const { width: l, height: m } = e;
283
283
  n.clearRect(-0.5, -0.5, l + 1, m + 1), b && b.clear();
284
- const { top: p, left: y } = u;
284
+ const { top: g, left: y } = u;
285
285
  s.forEach((v) => {
286
286
  var L;
287
- const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (L = v.state) != null && L.selected ? ht : $, d = b && b.paint(v, u) || h, c = v.rects.map(({ x: C, y: E, width: T, height: g }) => ({
287
+ const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (L = v.state) != null && L.selected ? ht : $, d = b && b.paint(v, u) || h, c = v.rects.map(({ x: C, y: E, width: T, height: p }) => ({
288
288
  x: C + y,
289
- y: E + p,
289
+ y: E + g,
290
290
  width: T,
291
- height: g
291
+ height: p
292
292
  }));
293
293
  n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1;
294
294
  const w = 5;
295
295
  if (c.forEach(
296
- ({ x: C, y: E, width: T, height: g }) => n.fillRect(
296
+ ({ x: C, y: E, width: T, height: p }) => n.fillRect(
297
297
  C,
298
298
  E - w / 2,
299
299
  T,
300
- g + w
300
+ p + w
301
301
  )
302
302
  ), d.underlineColor) {
303
303
  n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
304
304
  const C = w / 2 + (d.underlineOffset ?? 0);
305
- c.forEach(({ x: E, y: T, width: g, height: A }) => {
306
- n.beginPath(), n.moveTo(E, T + A + C), n.lineTo(E + g, T + A + C), n.stroke();
305
+ c.forEach(({ x: E, y: T, width: p, height: A }) => {
306
+ n.beginPath(), n.moveTo(E, T + A + C), n.lineTo(E + p, T + A + C), n.stroke();
307
307
  });
308
308
  }
309
309
  });
@@ -319,7 +319,7 @@ const $ = {
319
319
  },
320
320
  redraw: o
321
321
  };
322
- }, ue = (t, e, n) => pt(t, e, n, de(t));
322
+ }, ue = (t, e, n) => gt(t, e, n, de(t));
323
323
  var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
324
324
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
325
325
  }, M = function(t, e, n) {
@@ -353,14 +353,14 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
353
353
  }, G = function(t) {
354
354
  return { h: (e = Vt(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
355
  var e, n, o, i;
356
- }, pe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, be = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, At = { string: [[function(t) {
356
+ }, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, pe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, be = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, At = { string: [[function(t) {
357
357
  var e = fe.exec(t);
358
358
  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 ? M(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 ? M(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
359
359
  }, "hex"], [function(t) {
360
360
  var e = me.exec(t) || be.exec(t);
361
361
  return e ? e[2] !== e[4] || e[4] !== e[6] ? null : vt({ 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
362
  }, "rgb"], [function(t) {
363
- var e = pe.exec(t) || ge.exec(t);
363
+ var e = ge.exec(t) || pe.exec(t);
364
364
  if (!e)
365
365
  return null;
366
366
  var n, o, i = wt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (he[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
@@ -477,17 +477,17 @@ const we = (t) => [
477
477
  Array.from(e).filter((l) => !f.has(l));
478
478
  const b = r.map((l) => {
479
479
  var y;
480
- const m = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (y = l.state) != null && y.selected ? ht : $, p = u && u.paint(l, a) || m;
481
- return `::highlight(_${l.annotation.id}) { ${we(p)} }`;
480
+ const m = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (y = l.state) != null && y.selected ? ht : $, g = u && u.paint(l, a) || m;
481
+ return `::highlight(_${l.annotation.id}) { ${we(g)} }`;
482
482
  });
483
483
  t.innerHTML = b.join(`
484
484
  `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
485
- const m = l.target.selector.map((y) => y.range), p = new Highlight(...m);
486
- CSS.highlights.set(`_${l.id}`, p);
485
+ const m = l.target.selector.map((y) => y.range), g = new Highlight(...m);
486
+ CSS.highlights.set(`_${l.id}`, g);
487
487
  }), e = f;
488
488
  }
489
489
  };
490
- }, xe = (t, e, n) => pt(t, e, n, ye());
490
+ }, xe = (t, e, n) => gt(t, e, n, ye());
491
491
  var Lt = Object.prototype.hasOwnProperty;
492
492
  function ut(t, e) {
493
493
  var n, o;
@@ -530,22 +530,22 @@ const Ae = (t, e) => {
530
530
  if (ut(n, a) && b)
531
531
  return;
532
532
  e.innerHTML = "";
533
- const m = a.reduce((p, { rects: y }) => [...p, ...y], []);
534
- a.forEach((p) => {
535
- const y = p.rects.map((v) => {
533
+ const m = a.reduce((g, { rects: y }) => [...g, ...y], []);
534
+ a.forEach((g) => {
535
+ const y = g.rects.map((v) => {
536
536
  const h = document.createElement("span");
537
- h.className = "r6o-annotation", h.dataset.annotation = p.annotation.id, h.style.left = `${v.x}px`, h.style.top = `${v.y}px`, h.style.width = `${v.width}px`, h.style.height = `${v.height}px`;
538
- const d = Ae(v, m), c = qt(p, s, u, f, d), w = V((c == null ? void 0 : c.fill) || $.fill).alpha((c == null ? void 0 : c.fillOpacity) === void 0 ? $.fillOpacity : c.fillOpacity).toHex();
537
+ h.className = "r6o-annotation", h.dataset.annotation = g.annotation.id, h.style.left = `${v.x}px`, h.style.top = `${v.y}px`, h.style.width = `${v.width}px`, h.style.height = `${v.height}px`;
538
+ const d = Ae(v, m), c = qt(g, s, u, f, d), w = V((c == null ? void 0 : c.fill) || $.fill).alpha((c == null ? void 0 : c.fillOpacity) === void 0 ? $.fillOpacity : c.fillOpacity).toHex();
539
539
  return h.style.backgroundColor = w, c.underlineStyle && (h.style.borderStyle = c.underlineStyle), c.underlineColor && (h.style.borderColor = c.underlineColor), c.underlineThickness && (h.style.borderBottomWidth = `${c.underlineThickness}px`), c.underlineOffset && (h.style.paddingBottom = `${c.underlineOffset}px`), e.appendChild(h), h;
540
540
  });
541
- return { id: p.annotation.id, spans: y };
541
+ return { id: g.annotation.id, spans: y };
542
542
  }), n = a;
543
543
  },
544
544
  setVisible: (a) => {
545
545
  a ? e.classList.remove("hidden") : e.classList.add("hidden");
546
546
  }
547
547
  };
548
- }, Se = (t, e, n) => pt(t, e, n, Ee(t));
548
+ }, Se = (t, e, n) => gt(t, e, n, Ee(t));
549
549
  let Q;
550
550
  const Ce = new Uint8Array(16);
551
551
  function Le() {
@@ -601,7 +601,7 @@ function Re(t, e) {
601
601
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
602
602
  }
603
603
  const H = [];
604
- function gt(t, e = st) {
604
+ function pt(t, e = st) {
605
605
  let n;
606
606
  const o = /* @__PURE__ */ new Set();
607
607
  function i(s) {
@@ -628,7 +628,7 @@ function gt(t, e = st) {
628
628
  return { set: i, update: r, subscribe: a };
629
629
  }
630
630
  const Ie = (t) => {
631
- const { subscribe: e, set: n } = gt();
631
+ const { subscribe: e, set: n } = pt();
632
632
  let o;
633
633
  return e((i) => o = i), t.observe(({ changes: i }) => {
634
634
  if (o) {
@@ -646,7 +646,7 @@ const Ie = (t) => {
646
646
  };
647
647
  var Me = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Me || {});
648
648
  const at = { selected: [] }, Oe = (t, e = "EDIT") => {
649
- const { subscribe: n, set: o } = gt(at);
649
+ const { subscribe: n, set: o } = pt(at);
650
650
  let i = at;
651
651
  n((l) => i = l);
652
652
  const r = () => o(at), a = () => {
@@ -656,22 +656,22 @@ const at = { selected: [] }, Oe = (t, e = "EDIT") => {
656
656
  if (i.selected.length === 0)
657
657
  return !1;
658
658
  const m = typeof l == "string" ? l : l.id;
659
- return i.selected.some((p) => p.id === m);
659
+ return i.selected.some((g) => g.id === m);
660
660
  }, u = (l, m) => {
661
- const p = t.getAnnotation(l);
662
- if (p) {
663
- const y = Ne(p, e);
661
+ const g = t.getAnnotation(l);
662
+ if (g) {
663
+ const y = Ne(g, e);
664
664
  o(y === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: m } : y === "SELECT" ? { selected: [{ id: l }], pointerEvent: m } : { selected: [], pointerEvent: m });
665
665
  } else
666
666
  console.warn("Invalid selection: " + l);
667
667
  }, f = (l, m = !0) => {
668
- const p = Array.isArray(l) ? l : [l], y = p.map((v) => t.getAnnotation(v)).filter(Boolean);
669
- o({ selected: y.map(({ id: v }) => ({ id: v, editable: m })) }), y.length !== p.length && console.warn("Invalid selection", l);
668
+ const g = Array.isArray(l) ? l : [l], y = g.map((v) => t.getAnnotation(v)).filter(Boolean);
669
+ o({ selected: y.map(({ id: v }) => ({ id: v, editable: m })) }), y.length !== g.length && console.warn("Invalid selection", l);
670
670
  }, b = (l) => {
671
671
  if (i.selected.length === 0)
672
672
  return !1;
673
673
  const { selected: m } = i;
674
- m.filter(({ id: p }) => l.includes(p)).length > 0 && o({ selected: m.filter(({ id: p }) => !l.includes(p)) });
674
+ m.filter(({ id: g }) => l.includes(g)).length > 0 && o({ selected: m.filter(({ id: g }) => !l.includes(g)) });
675
675
  };
676
676
  return t.observe(({ changes: l }) => b((l.deleted || []).map((m) => m.id))), {
677
677
  clear: r,
@@ -769,9 +769,9 @@ const Pe = (t, e) => {
769
769
  ...(e.deleted || []).filter((l) => !n.has(l.id))
770
770
  ], b = [
771
771
  ...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
772
- const { oldValue: m, newValue: p } = l;
773
- if (a.has(p.id)) {
774
- const y = e.updated.find((v) => v.oldValue.id === p.id).newValue;
772
+ const { oldValue: m, newValue: g } = l;
773
+ if (a.has(g.id)) {
774
+ const y = e.updated.find((v) => v.oldValue.id === g.id).newValue;
775
775
  return _t(m, y);
776
776
  } else
777
777
  return l;
@@ -780,12 +780,12 @@ const Pe = (t, e) => {
780
780
  ];
781
781
  return { created: u, deleted: f, updated: b };
782
782
  }, Fe = (t) => t.id !== void 0, We = () => {
783
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (g, A = {}) => n.push({ onChange: g, options: A }), i = (g) => {
784
- const A = n.findIndex((x) => x.onChange == g);
783
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (p, A = {}) => n.push({ onChange: p, options: A }), i = (p) => {
784
+ const A = n.findIndex((x) => x.onChange == p);
785
785
  A > -1 && n.splice(A, 1);
786
- }, r = (g, A) => {
786
+ }, r = (p, A) => {
787
787
  const x = {
788
- origin: g,
788
+ origin: p,
789
789
  changes: {
790
790
  created: A.created || [],
791
791
  updated: A.updated || [],
@@ -796,83 +796,83 @@ const Pe = (t, e) => {
796
796
  n.forEach((S) => {
797
797
  Pe(S, x) && S.onChange(x);
798
798
  });
799
- }, a = (g, A = R.LOCAL) => {
800
- if (t.get(g.id))
801
- throw Error(`Cannot add annotation ${g.id} - exists already`);
802
- t.set(g.id, g), g.bodies.forEach((x) => e.set(x.id, g.id)), r(A, { created: [g] });
803
- }, s = (g, A) => {
804
- const x = typeof g == "string" ? A : g, S = typeof g == "string" ? g : g.id, B = t.get(S);
799
+ }, a = (p, A = R.LOCAL) => {
800
+ if (t.get(p.id))
801
+ throw Error(`Cannot add annotation ${p.id} - exists already`);
802
+ t.set(p.id, p), p.bodies.forEach((x) => e.set(x.id, p.id)), r(A, { created: [p] });
803
+ }, s = (p, A) => {
804
+ const x = typeof p == "string" ? A : p, S = typeof p == "string" ? p : p.id, B = t.get(S);
805
805
  if (B) {
806
806
  const I = _t(B, x);
807
807
  return S === x.id ? t.set(S, x) : (t.delete(S), t.set(x.id, x)), B.bodies.forEach((k) => e.delete(k.id)), x.bodies.forEach((k) => e.set(k.id, x.id)), I;
808
808
  } else
809
809
  console.warn(`Cannot update annotation ${S} - does not exist`);
810
- }, u = (g, A = R.LOCAL, x = R.LOCAL) => {
811
- const S = Fe(A) ? x : A, B = s(g, A);
810
+ }, u = (p, A = R.LOCAL, x = R.LOCAL) => {
811
+ const S = Fe(A) ? x : A, B = s(p, A);
812
812
  B && r(S, { updated: [B] });
813
- }, f = (g, A = R.LOCAL) => {
814
- const x = g.reduce((S, B) => {
813
+ }, f = (p, A = R.LOCAL) => {
814
+ const x = p.reduce((S, B) => {
815
815
  const I = s(B);
816
816
  return I ? [...S, I] : S;
817
817
  }, []);
818
818
  x.length > 0 && r(A, { updated: x });
819
- }, b = (g, A = R.LOCAL) => {
820
- const x = t.get(g.annotation);
819
+ }, b = (p, A = R.LOCAL) => {
820
+ const x = t.get(p.annotation);
821
821
  if (x) {
822
822
  const S = {
823
823
  ...x,
824
- bodies: [...x.bodies, g]
824
+ bodies: [...x.bodies, p]
825
825
  };
826
- t.set(x.id, S), e.set(g.id, S.id), r(A, { updated: [{
826
+ t.set(x.id, S), e.set(p.id, S.id), r(A, { updated: [{
827
827
  oldValue: x,
828
828
  newValue: S,
829
- bodiesCreated: [g]
829
+ bodiesCreated: [p]
830
830
  }] });
831
831
  } else
832
- console.warn(`Attempt to add body to missing annotation: ${g.annotation}`);
833
- }, l = () => [...t.values()], m = (g = R.LOCAL) => {
832
+ console.warn(`Attempt to add body to missing annotation: ${p.annotation}`);
833
+ }, l = () => [...t.values()], m = (p = R.LOCAL) => {
834
834
  const A = [...t.values()];
835
- t.clear(), e.clear(), r(g, { deleted: A });
836
- }, p = (g, A = !0, x = R.LOCAL) => {
835
+ t.clear(), e.clear(), r(p, { deleted: A });
836
+ }, g = (p, A = !0, x = R.LOCAL) => {
837
837
  if (A) {
838
838
  const S = [...t.values()];
839
- t.clear(), e.clear(), g.forEach((B) => {
839
+ t.clear(), e.clear(), p.forEach((B) => {
840
840
  t.set(B.id, B), B.bodies.forEach((I) => e.set(I.id, B.id));
841
- }), r(x, { created: g, deleted: S });
841
+ }), r(x, { created: p, deleted: S });
842
842
  } else {
843
- const S = g.reduce((B, I) => {
843
+ const S = p.reduce((B, I) => {
844
844
  const k = t.get(I.id);
845
845
  return k ? [...B, k] : B;
846
846
  }, []);
847
847
  if (S.length > 0)
848
848
  throw Error(`Bulk insert would overwrite the following annotations: ${S.map((B) => B.id).join(", ")}`);
849
- g.forEach((B) => {
849
+ p.forEach((B) => {
850
850
  t.set(B.id, B), B.bodies.forEach((I) => e.set(I.id, B.id));
851
- }), r(x, { created: g });
851
+ }), r(x, { created: p });
852
852
  }
853
- }, y = (g) => {
854
- const A = typeof g == "string" ? g : g.id, x = t.get(A);
853
+ }, y = (p) => {
854
+ const A = typeof p == "string" ? p : p.id, x = t.get(A);
855
855
  if (x)
856
856
  return t.delete(A), x.bodies.forEach((S) => e.delete(S.id)), x;
857
857
  console.warn(`Attempt to delete missing annotation: ${A}`);
858
- }, v = (g, A = R.LOCAL) => {
859
- const x = y(g);
858
+ }, v = (p, A = R.LOCAL) => {
859
+ const x = y(p);
860
860
  x && r(A, { deleted: [x] });
861
- }, h = (g, A = R.LOCAL) => {
862
- const x = g.reduce((S, B) => {
861
+ }, h = (p, A = R.LOCAL) => {
862
+ const x = p.reduce((S, B) => {
863
863
  const I = y(B);
864
864
  return I ? [...S, I] : S;
865
865
  }, []);
866
866
  x.length > 0 && r(A, { deleted: x });
867
- }, d = (g, A = R.LOCAL) => {
868
- const x = t.get(g.annotation);
867
+ }, d = (p, A = R.LOCAL) => {
868
+ const x = t.get(p.annotation);
869
869
  if (x) {
870
- const S = x.bodies.find((B) => B.id === g.id);
870
+ const S = x.bodies.find((B) => B.id === p.id);
871
871
  if (S) {
872
872
  e.delete(S.id);
873
873
  const B = {
874
874
  ...x,
875
- bodies: x.bodies.filter((I) => I.id !== g.id)
875
+ bodies: x.bodies.filter((I) => I.id !== p.id)
876
876
  };
877
877
  t.set(x.id, B), r(A, { updated: [{
878
878
  oldValue: x,
@@ -880,27 +880,27 @@ const Pe = (t, e) => {
880
880
  bodiesDeleted: [S]
881
881
  }] });
882
882
  } else
883
- console.warn(`Attempt to delete missing body ${g.id} from annotation ${g.annotation}`);
883
+ console.warn(`Attempt to delete missing body ${p.id} from annotation ${p.annotation}`);
884
884
  } else
885
- console.warn(`Attempt to delete body from missing annotation ${g.annotation}`);
886
- }, c = (g) => {
887
- const A = t.get(g);
885
+ console.warn(`Attempt to delete body from missing annotation ${p.annotation}`);
886
+ }, c = (p) => {
887
+ const A = t.get(p);
888
888
  return A ? { ...A } : void 0;
889
- }, w = (g) => {
890
- const A = e.get(g);
889
+ }, w = (p) => {
890
+ const A = e.get(p);
891
891
  if (A) {
892
- const x = c(A).bodies.find((S) => S.id === g);
892
+ const x = c(A).bodies.find((S) => S.id === p);
893
893
  if (x)
894
894
  return x;
895
- console.error(`Store integrity error: body ${g} in index, but not in annotation`);
895
+ console.error(`Store integrity error: body ${p} in index, but not in annotation`);
896
896
  } else
897
- console.warn(`Attempt to retrieve missing body: ${g}`);
898
- }, L = (g, A) => {
899
- if (g.annotation !== A.annotation)
897
+ console.warn(`Attempt to retrieve missing body: ${p}`);
898
+ }, L = (p, A) => {
899
+ if (p.annotation !== A.annotation)
900
900
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
901
- const x = t.get(g.annotation);
901
+ const x = t.get(p.annotation);
902
902
  if (x) {
903
- const S = x.bodies.find((I) => I.id === g.id), B = {
903
+ const S = x.bodies.find((I) => I.id === p.id), B = {
904
904
  ...x,
905
905
  bodies: x.bodies.map((I) => I.id === S.id ? A : I)
906
906
  };
@@ -910,21 +910,21 @@ const Pe = (t, e) => {
910
910
  bodiesUpdated: [{ oldBody: S, newBody: A }]
911
911
  };
912
912
  } else
913
- console.warn(`Attempt to add body to missing annotation ${g.annotation}`);
914
- }, C = (g, A, x = R.LOCAL) => {
915
- const S = L(g, A);
913
+ console.warn(`Attempt to add body to missing annotation ${p.annotation}`);
914
+ }, C = (p, A, x = R.LOCAL) => {
915
+ const S = L(p, A);
916
916
  S && r(x, { updated: [S] });
917
- }, E = (g, A = R.LOCAL) => {
918
- const x = g.map((S) => L({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
917
+ }, E = (p, A = R.LOCAL) => {
918
+ const x = p.map((S) => L({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
919
919
  r(A, { updated: x });
920
- }, T = (g) => {
921
- const A = t.get(g.annotation);
920
+ }, T = (p) => {
921
+ const A = t.get(p.annotation);
922
922
  if (A) {
923
923
  const x = {
924
924
  ...A,
925
925
  target: {
926
926
  ...A.target,
927
- ...g
927
+ ...p
928
928
  }
929
929
  };
930
930
  return t.set(A.id, x), {
@@ -932,22 +932,22 @@ const Pe = (t, e) => {
932
932
  newValue: x,
933
933
  targetUpdated: {
934
934
  oldTarget: A.target,
935
- newTarget: g
935
+ newTarget: p
936
936
  }
937
937
  };
938
938
  } else
939
- console.warn(`Attempt to update target on missing annotation: ${g.annotation}`);
939
+ console.warn(`Attempt to update target on missing annotation: ${p.annotation}`);
940
940
  };
941
941
  return {
942
942
  addAnnotation: a,
943
943
  addBody: b,
944
944
  all: l,
945
- bulkAddAnnotation: p,
945
+ bulkAddAnnotation: g,
946
946
  bulkDeleteAnnotation: h,
947
947
  bulkUpdateAnnotation: f,
948
948
  bulkUpdateBodies: E,
949
- bulkUpdateTargets: (g, A = R.LOCAL) => {
950
- const x = g.map((S) => T(S)).filter(Boolean);
949
+ bulkUpdateTargets: (p, A = R.LOCAL) => {
950
+ const x = p.map((S) => T(S)).filter(Boolean);
951
951
  x.length > 0 && r(A, { updated: x });
952
952
  },
953
953
  clear: m,
@@ -959,8 +959,8 @@ const Pe = (t, e) => {
959
959
  unobserve: i,
960
960
  updateAnnotation: u,
961
961
  updateBody: C,
962
- updateTarget: (g, A = R.LOCAL) => {
963
- const x = T(g);
962
+ updateTarget: (p, A = R.LOCAL) => {
963
+ const x = T(p);
964
964
  x && r(A, { updated: [x] });
965
965
  }
966
966
  };
@@ -982,9 +982,9 @@ let qe = () => ({
982
982
  const je = 250, Ge = (t) => {
983
983
  const e = qe(), n = [];
984
984
  let o = -1, i = !1, r = 0;
985
- const a = (p) => {
985
+ const a = (g) => {
986
986
  if (!i) {
987
- const { changes: y } = p, v = performance.now();
987
+ const { changes: y } = g, v = performance.now();
988
988
  if (v - r > je)
989
989
  n.splice(o + 1), n.push(y), o = n.length - 1;
990
990
  else {
@@ -996,29 +996,29 @@ const je = 250, Ge = (t) => {
996
996
  i = !1;
997
997
  };
998
998
  t.observe(a, { origin: R.LOCAL });
999
- const s = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: y }) => y)), b = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: y }) => y)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), m = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
999
+ const s = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), b = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), m = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1000
1000
  return {
1001
1001
  canRedo: () => n.length - 1 > o,
1002
1002
  canUndo: () => o > -1,
1003
1003
  destroy: () => t.unobserve(a),
1004
- on: (p, y) => e.on(p, y),
1004
+ on: (g, y) => e.on(g, y),
1005
1005
  redo: () => {
1006
1006
  if (n.length - 1 > o) {
1007
1007
  i = !0;
1008
- const { created: p, updated: y, deleted: v } = n[o + 1];
1009
- u(p), b(y), m(v), e.emit("redo", n[o + 1]), o += 1;
1008
+ const { created: g, updated: y, deleted: v } = n[o + 1];
1009
+ u(g), b(y), m(v), e.emit("redo", n[o + 1]), o += 1;
1010
1010
  }
1011
1011
  },
1012
1012
  undo: () => {
1013
1013
  if (o > -1) {
1014
1014
  i = !0;
1015
- const { created: p, updated: y, deleted: v } = n[o];
1016
- s(p), f(y), l(v), e.emit("undo", n[o]), o -= 1;
1015
+ const { created: g, updated: y, deleted: v } = n[o];
1016
+ s(g), f(y), l(v), e.emit("undo", n[o]), o -= 1;
1017
1017
  }
1018
1018
  }
1019
1019
  };
1020
1020
  }, Ke = () => {
1021
- const { subscribe: t, set: e } = gt([]);
1021
+ const { subscribe: t, set: e } = pt([]);
1022
1022
  return {
1023
1023
  subscribe: t,
1024
1024
  set: e
@@ -1031,7 +1031,7 @@ const je = 250, Ge = (t) => {
1031
1031
  }, m = (v, h) => {
1032
1032
  const d = u.get(v);
1033
1033
  d && d.indexOf(h) > 0 && d.splice(d.indexOf(h), 1);
1034
- }, p = (v, h, d) => {
1034
+ }, g = (v, h, d) => {
1035
1035
  u.has(v) && setTimeout(() => {
1036
1036
  u.get(v).forEach((c) => {
1037
1037
  if (n) {
@@ -1049,13 +1049,13 @@ const je = 250, Ge = (t) => {
1049
1049
  else if (f.length > 0 && v.length === 0)
1050
1050
  f.forEach((h) => {
1051
1051
  const d = i.getAnnotation(h.id);
1052
- d && !F(d, h) && p("updateAnnotation", d, h);
1052
+ d && !F(d, h) && g("updateAnnotation", d, h);
1053
1053
  }), f = [];
1054
1054
  else {
1055
1055
  const h = new Set(f.map((c) => c.id)), d = new Set(v.map(({ id: c }) => c));
1056
1056
  f.filter((c) => !d.has(c.id)).forEach((c) => {
1057
1057
  const w = i.getAnnotation(c.id);
1058
- w && !F(w, c) && p("updateAnnotation", w, c);
1058
+ w && !F(w, c) && g("updateAnnotation", w, c);
1059
1059
  }), f = [
1060
1060
  // Remove annotations that were deselected
1061
1061
  ...f.filter((c) => d.has(c.id)),
@@ -1063,19 +1063,19 @@ const je = 250, Ge = (t) => {
1063
1063
  ...v.filter(({ id: c }) => !h.has(c)).map(({ id: c }) => i.getAnnotation(c))
1064
1064
  ];
1065
1065
  }
1066
- p("selectionChanged", f);
1066
+ g("selectionChanged", f);
1067
1067
  }
1068
1068
  }), a.subscribe((v) => {
1069
- !b && v ? p("mouseEnterAnnotation", i.getAnnotation(v)) : b && !v ? p("mouseLeaveAnnotation", i.getAnnotation(b)) : b && v && (p("mouseLeaveAnnotation", i.getAnnotation(b)), p("mouseEnterAnnotation", i.getAnnotation(v))), b = v;
1070
- }), s == null || s.subscribe((v) => p("viewportIntersect", v.map((h) => i.getAnnotation(h)))), i.observe((v) => {
1069
+ !b && v ? g("mouseEnterAnnotation", i.getAnnotation(v)) : b && !v ? g("mouseLeaveAnnotation", i.getAnnotation(b)) : b && v && (g("mouseLeaveAnnotation", i.getAnnotation(b)), g("mouseEnterAnnotation", i.getAnnotation(v))), b = v;
1070
+ }), s == null || s.subscribe((v) => g("viewportIntersect", v.map((h) => i.getAnnotation(h)))), i.observe((v) => {
1071
1071
  const { created: h, deleted: d } = v.changes;
1072
- (h || []).forEach((c) => p("createAnnotation", c)), (d || []).forEach((c) => p("deleteAnnotation", c)), (v.changes.updated || []).filter((c) => [
1072
+ (h || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (v.changes.updated || []).filter((c) => [
1073
1073
  ...c.bodiesCreated || [],
1074
1074
  ...c.bodiesDeleted || [],
1075
1075
  ...c.bodiesUpdated || []
1076
1076
  ].length > 0).forEach(({ oldValue: c, newValue: w }) => {
1077
1077
  const L = f.find((C) => C.id === c.id) || c;
1078
- f = f.map((C) => C.id === c.id ? w : C), p("updateAnnotation", w, L);
1078
+ f = f.map((C) => C.id === c.id ? w : C), g("updateAnnotation", w, L);
1079
1079
  });
1080
1080
  }, { origin: R.LOCAL }), i.observe((v) => {
1081
1081
  if (f) {
@@ -1085,9 +1085,9 @@ const je = 250, Ge = (t) => {
1085
1085
  }, { origin: R.REMOTE });
1086
1086
  const y = (v) => (h) => {
1087
1087
  const { updated: d } = h;
1088
- v ? (d || []).forEach((c) => p("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => p("updateAnnotation", c.newValue, c.oldValue));
1088
+ v ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
1089
1089
  };
1090
- return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: l, off: m, emit: p };
1090
+ return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: l, off: m, emit: g };
1091
1091
  }, Je = (t) => (e) => e.reduce((n, o) => {
1092
1092
  const { parsed: i, error: r } = t.parse(o);
1093
1093
  return r ? {
@@ -1113,7 +1113,7 @@ const je = 250, Ge = (t) => {
1113
1113
  var h;
1114
1114
  const d = (((h = i.selected) == null ? void 0 : h.map((c) => c.id)) || []).map((c) => o.getAnnotation(c)).filter(Boolean);
1115
1115
  return n ? d.map(n.serialize) : d;
1116
- }, l = (h, d = !0) => fetch(h).then((c) => c.json()).then((c) => (p(c, d), c)), m = (h) => {
1116
+ }, l = (h, d = !0) => fetch(h).then((c) => c.json()).then((c) => (g(c, d), c)), m = (h) => {
1117
1117
  if (typeof h == "string") {
1118
1118
  const d = o.getAnnotation(h);
1119
1119
  if (o.deleteAnnotation(h), d)
@@ -1123,7 +1123,7 @@ const je = 250, Ge = (t) => {
1123
1123
  if (d)
1124
1124
  return o.deleteAnnotation(d), h;
1125
1125
  }
1126
- }, p = (h, d = !0) => {
1126
+ }, g = (h, d = !0) => {
1127
1127
  if (n) {
1128
1128
  const { parsed: c, failed: w } = Je(n)(h);
1129
1129
  w.length > 0 && console.warn(`Discarded ${w.length} invalid annotations`, w), o.bulkAddAnnotation(c, d, R.REMOTE);
@@ -1152,7 +1152,7 @@ const je = 250, Ge = (t) => {
1152
1152
  loadAnnotations: l,
1153
1153
  redo: e.redo,
1154
1154
  removeAnnotation: m,
1155
- setAnnotations: p,
1155
+ setAnnotations: g,
1156
1156
  setSelected: y,
1157
1157
  undo: e.undo,
1158
1158
  updateAnnotation: v
@@ -1269,9 +1269,9 @@ const On = (t, e) => ({
1269
1269
  updated: f,
1270
1270
  ...b
1271
1271
  } = i, l = a.map((m) => {
1272
- const { quote: p, start: y, end: v, range: h } = m, { prefix: d, suffix: c } = Zt(h, n), w = [{
1272
+ const { quote: g, start: y, end: v, range: h } = m, { prefix: d, suffix: c } = Zt(h, n), w = [{
1273
1273
  type: "TextQuoteSelector",
1274
- exact: p,
1274
+ exact: g,
1275
1275
  prefix: d,
1276
1276
  suffix: c
1277
1277
  }, {
@@ -1298,8 +1298,8 @@ const On = (t, e) => ({
1298
1298
  target: l
1299
1299
  };
1300
1300
  };
1301
- function pn(t, e, n, o, i) {
1302
- Dt(t, e, n || 0, o || t.length - 1, i || gn);
1301
+ function gn(t, e, n, o, i) {
1302
+ Dt(t, e, n || 0, o || t.length - 1, i || pn);
1303
1303
  }
1304
1304
  function Dt(t, e, n, o, i) {
1305
1305
  for (; o > n; ) {
@@ -1307,10 +1307,10 @@ function Dt(t, e, n, o, i) {
1307
1307
  var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), f = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), b = Math.max(n, Math.floor(e - a * u / r + f)), l = Math.min(o, Math.floor(e + (r - a) * u / r + f));
1308
1308
  Dt(t, e, b, l, i);
1309
1309
  }
1310
- var m = t[e], p = n, y = o;
1311
- for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); p < y; ) {
1312
- for (W(t, p, y), p++, y--; i(t[p], m) < 0; )
1313
- p++;
1310
+ var m = t[e], g = n, y = o;
1311
+ for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); g < y; ) {
1312
+ for (W(t, g, y), g++, y--; i(t[g], m) < 0; )
1313
+ g++;
1314
1314
  for (; i(t[y], m) > 0; )
1315
1315
  y--;
1316
1316
  }
@@ -1321,7 +1321,7 @@ function W(t, e, n) {
1321
1321
  var o = t[e];
1322
1322
  t[e] = t[n], t[n] = o;
1323
1323
  }
1324
- function gn(t, e) {
1324
+ function pn(t, e) {
1325
1325
  return t < e ? -1 : t > e ? 1 : 0;
1326
1326
  }
1327
1327
  class mn {
@@ -1441,8 +1441,8 @@ class mn {
1441
1441
  const l = Math.min(b + f - 1, o);
1442
1442
  It(e, b, l, u, this.compareMinY);
1443
1443
  for (let m = b; m <= l; m += u) {
1444
- const p = Math.min(m + u - 1, l);
1445
- s.children.push(this._build(e, m, p, i - 1));
1444
+ const g = Math.min(m + u - 1, l);
1445
+ s.children.push(this._build(e, m, g, i - 1));
1446
1446
  }
1447
1447
  }
1448
1448
  return P(s, this.toBBox), s;
@@ -1575,7 +1575,7 @@ function It(t, e, n, o, i) {
1575
1575
  if (n = r.pop(), e = r.pop(), n - e <= o)
1576
1576
  continue;
1577
1577
  const a = e + Math.ceil((n - e) / o / 2) * o;
1578
- pn(t, a, e, n, i), r.push(e, a, a, n);
1578
+ gn(t, a, e, n, i), r.push(e, a, a, n);
1579
1579
  }
1580
1580
  }
1581
1581
  const An = (t, e) => {
@@ -1583,13 +1583,13 @@ const An = (t, e) => {
1583
1583
  const w = d.selector.flatMap((C) => {
1584
1584
  const E = X([C]) ? C.range : Nt(C, e).range;
1585
1585
  return Array.from(E.getClientRects());
1586
- }), L = ie(w).map(({ left: C, top: E, right: T, bottom: g }) => new DOMRect(C - c.left, E - c.top, T - C, g - E));
1586
+ }), L = ie(w).map(({ left: C, top: E, right: T, bottom: p }) => new DOMRect(C - c.left, E - c.top, T - C, p - E));
1587
1587
  return L.map((C) => {
1588
- const { x: E, y: T, width: g, height: A } = C;
1588
+ const { x: E, y: T, width: p, height: A } = C;
1589
1589
  return {
1590
1590
  minX: E,
1591
1591
  minY: T,
1592
- maxX: E + g,
1592
+ maxX: E + p,
1593
1593
  maxY: T + A,
1594
1594
  annotation: {
1595
1595
  id: d.annotation,
@@ -1623,16 +1623,16 @@ const An = (t, e) => {
1623
1623
  if (w.length > 0)
1624
1624
  return w.sort((C, E) => L(C) - L(E)), w[0].annotation.id;
1625
1625
  }, m = (d) => {
1626
- const c = p(d);
1626
+ const c = g(d);
1627
1627
  if (c.length === 0)
1628
1628
  return;
1629
1629
  let w = c[0].left, L = c[0].top, C = c[0].right, E = c[0].bottom;
1630
1630
  for (let T = 1; T < c.length; T++) {
1631
- const g = c[T];
1632
- w = Math.min(w, g.left), L = Math.min(L, g.top), C = Math.max(C, g.right), E = Math.max(E, g.bottom);
1631
+ const p = c[T];
1632
+ w = Math.min(w, p.left), L = Math.min(L, p.top), C = Math.max(C, p.right), E = Math.max(E, p.bottom);
1633
1633
  }
1634
1634
  return new DOMRect(w, L, C - w, E - L);
1635
- }, p = (d) => {
1635
+ }, g = (d) => {
1636
1636
  const c = o.get(d);
1637
1637
  return c ? c[0].annotation.rects : [];
1638
1638
  };
@@ -1641,12 +1641,12 @@ const An = (t, e) => {
1641
1641
  clear: a,
1642
1642
  getAt: l,
1643
1643
  getAnnotationBounds: m,
1644
- getAnnotationRects: p,
1644
+ getAnnotationRects: g,
1645
1645
  getIntersecting: (d, c, w, L) => {
1646
- const C = n.search({ minX: d, minY: c, maxX: w, maxY: L }), E = new Set(C.reduce((T, g) => [...T, g.annotation.id], []));
1646
+ const C = n.search({ minX: d, minY: c, maxX: w, maxY: L }), E = new Set(C.reduce((T, p) => [...T, p.annotation.id], []));
1647
1647
  return Array.from(E).map((T) => ({
1648
1648
  annotation: t.getAnnotation(T),
1649
- rects: p(T)
1649
+ rects: g(T)
1650
1650
  })).filter((T) => !!T.annotation);
1651
1651
  },
1652
1652
  insert: s,
@@ -1677,11 +1677,11 @@ const An = (t, e) => {
1677
1677
  }, m = (v, h) => {
1678
1678
  const d = o.getAt(v, h);
1679
1679
  return d ? n.getAnnotation(d) : void 0;
1680
- }, p = (v, h, d, c = 5) => {
1680
+ }, g = (v, h, d, c = 5) => {
1681
1681
  const w = o.getAnnotationRects(v);
1682
1682
  if (w.length !== 0) {
1683
1683
  if (h && d) {
1684
- const L = w.find(({ top: C, right: E, bottom: T, left: g }) => h >= g - c && h <= E + c && d >= C - c && d <= T + c);
1684
+ const L = w.find(({ top: C, right: E, bottom: T, left: p }) => h >= p - c && h <= E + c && d >= C - c && d <= T + c);
1685
1685
  if (L)
1686
1686
  return L;
1687
1687
  }
@@ -1698,7 +1698,7 @@ const An = (t, e) => {
1698
1698
  bulkAddAnnotation: u,
1699
1699
  bulkUpdateTargets: l,
1700
1700
  bulkUpsertAnnotations: f,
1701
- getAnnotationBounds: p,
1701
+ getAnnotationBounds: g,
1702
1702
  getAt: m,
1703
1703
  getIntersecting: o.getIntersecting,
1704
1704
  recalculatePositions: y,
@@ -1716,7 +1716,7 @@ const An = (t, e) => {
1716
1716
  }, Cn = (t, e, n = {}) => {
1717
1717
  const o = Sn(), i = o.getContext("2d");
1718
1718
  t.appendChild(o);
1719
- const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([m, p]) => p.presenceKey === l.presenceKey).map(([m, p]) => m);
1719
+ const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([m, g]) => g.presenceKey === l.presenceKey).map(([m, g]) => m);
1720
1720
  return e.on("selectionChange", (l, m) => {
1721
1721
  a(l).forEach((y) => r.delete(y)), m && m.forEach((y) => r.set(y, l));
1722
1722
  }), {
@@ -1727,7 +1727,7 @@ const An = (t, e) => {
1727
1727
  destroy: () => {
1728
1728
  o.remove();
1729
1729
  },
1730
- paint: (l, m, p) => {
1730
+ paint: (l, m, g) => {
1731
1731
  n.font && (i.font = n.font);
1732
1732
  const y = r.get(l.annotation.id);
1733
1733
  if (y) {
@@ -1736,7 +1736,7 @@ const An = (t, e) => {
1736
1736
  const c = i.measureText(y.appearance.label), w = c.width + 6, L = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, C = c.fontBoundingBoxAscent ? 8 : 6.5;
1737
1737
  return i.fillRect(h - 2, d - 2.5 - L, w, L), i.fillStyle = "#fff", i.fillText(y.appearance.label, h + 1, d - C), {
1738
1738
  fill: y.appearance.color,
1739
- fillOpacity: p ? 0.45 : 0.18
1739
+ fillOpacity: g ? 0.45 : 0.18
1740
1740
  };
1741
1741
  }
1742
1742
  },
@@ -1753,7 +1753,7 @@ const An = (t, e) => {
1753
1753
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : $t(t.parentElement);
1754
1754
  }, Ln = (t, e) => (n) => {
1755
1755
  const o = (r) => {
1756
- const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = f.top - a.top, p = f.left - a.left, y = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = m + y - (s - l) / 2, d = p + v - (u - b) / 2;
1756
+ const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = f.top - a.top, g = f.left - a.left, y = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = m + y - (s - l) / 2, d = g + v - (u - b) / 2;
1757
1757
  i.scroll({ top: h, left: d, behavior: "smooth" });
1758
1758
  }, i = $t(t);
1759
1759
  if (i) {
@@ -1808,11 +1808,11 @@ const An = (t, e) => {
1808
1808
  }, R.LOCAL), r.clickSelect(s.annotation, b)));
1809
1809
  });
1810
1810
  n && document.addEventListener("selectionchange", m);
1811
- const p = (h) => {
1811
+ const g = (h) => {
1812
1812
  const { target: d, timeStamp: c, offsetX: w, offsetY: L, type: C } = h;
1813
1813
  b = { ...h, target: d, timeStamp: c, offsetX: w, offsetY: L, type: C }, f = h.button === 0;
1814
1814
  };
1815
- t.addEventListener("pointerdown", p);
1815
+ t.addEventListener("pointerdown", g);
1816
1816
  const y = (h) => {
1817
1817
  var L;
1818
1818
  if (!!((L = h.target.parentElement) != null && L.closest(D)) || !f)
@@ -1820,8 +1820,8 @@ const An = (t, e) => {
1820
1820
  const c = () => {
1821
1821
  const { x: C, y: E } = t.getBoundingClientRect(), T = i.getAt(h.clientX - C, h.clientY - E);
1822
1822
  if (T) {
1823
- const { selected: g } = r;
1824
- (g.length !== 1 || g[0].id !== T.id) && r.clickSelect(T.id, h);
1823
+ const { selected: p } = r;
1824
+ (p.length !== 1 || p[0].id !== T.id) && r.clickSelect(T.id, h);
1825
1825
  } else
1826
1826
  r.isEmpty() || r.clear();
1827
1827
  }, w = h.timeStamp - b.timeStamp;
@@ -1829,12 +1829,14 @@ const An = (t, e) => {
1829
1829
  };
1830
1830
  return document.addEventListener("pointerup", y), {
1831
1831
  destroy: () => {
1832
- t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", m), t.removeEventListener("pointerdown", p), document.removeEventListener("pointerup", y);
1832
+ t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", m), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", y);
1833
1833
  },
1834
1834
  setUser: u
1835
1835
  };
1836
1836
  }, Mt = "SPANS", Nn = (t, e = {}) => {
1837
- t.addEventListener("click", (E) => !E.target.closest("a") && E.preventDefault());
1837
+ t.addEventListener("click", (E) => {
1838
+ !E.target.closest(D) && !E.target.closest("a") && E.preventDefault();
1839
+ });
1838
1840
  const n = Tn(e, {
1839
1841
  annotationEnabled: !0
1840
1842
  }), o = En(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Ge(a), u = Qe(o, s, n.adapter);