@recogito/text-annotator 3.0.0-rc.52 → 3.0.0-rc.53

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.
@@ -139,7 +139,14 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
139
139
  }
140
140
  }
141
141
  return i ? o : [...o, n];
142
- }, []), Ve = (t, e, n) => {
142
+ }, []), wo = (t) => ({
143
+ length: t.length,
144
+ item: (e) => t[e],
145
+ [Symbol.iterator]: function* () {
146
+ for (let e = 0; e < this.length; e++)
147
+ yield this.item(e);
148
+ }
149
+ }), Ve = (t, e, n) => {
143
150
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
144
151
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
145
152
  const s = Nt(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
@@ -195,7 +202,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
195
202
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
196
203
  }, Ke = (t, e) => (n) => {
197
204
  const o = typeof n == "string" ? n : n.id, i = (a) => {
198
- const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), g = h.top - r.top, b = h.left - r.left, w = s.parentElement ? s.scrollTop : 0, y = s.parentElement ? s.scrollLeft : 0, d = g + w - (l - p) / 2, c = b + y - (f - u) / 2;
205
+ const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), g = h.top - r.top, y = h.left - r.left, b = s.parentElement ? s.scrollTop : 0, v = s.parentElement ? s.scrollLeft : 0, d = g + b - (l - p) / 2, c = y + v - (f - u) / 2;
199
206
  s.scroll({ top: d, left: c, behavior: "smooth" });
200
207
  }, s = ce(t);
201
208
  if (s) {
@@ -232,43 +239,43 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
232
239
  const { store: i, selection: s, hover: a } = e;
233
240
  let r, l, f;
234
241
  const h = Pe(n), u = (M) => {
235
- const { x: L, y: m } = t.getBoundingClientRect(), v = i.getAt(M.clientX - L, M.clientY - m, !1, l);
236
- v ? a.current !== v.id && (t.classList.add("hovered"), a.set(v.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
242
+ const { x: T, y: m } = t.getBoundingClientRect(), x = i.getAt(M.clientX - T, M.clientY - m, !1, l);
243
+ x ? a.current !== x.id && (t.classList.add("hovered"), a.set(x.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
237
244
  };
238
245
  t.addEventListener("pointermove", u);
239
246
  const p = (M = !1) => {
240
247
  f && f.clear();
241
- const L = Xe(t), { minX: m, minY: v, maxX: x, maxY: C } = L, B = l ? i.getIntersecting(m, v, x, C).filter(({ annotation: U }) => l(U)) : i.getIntersecting(m, v, x, C), R = s.selected.map(({ id: U }) => U), N = B.map(({ annotation: U, rects: et }) => {
248
+ const T = Xe(t), { minX: m, minY: x, maxX: A, maxY: L } = T, B = l ? i.getIntersecting(m, x, A, L).filter(({ annotation: U }) => l(U)) : i.getIntersecting(m, x, A, L), R = s.selected.map(({ id: U }) => U), N = B.map(({ annotation: U, rects: et }) => {
242
249
  const q = R.includes(U.id), Se = U.id === a.current;
243
250
  return { annotation: U, rects: et, state: { selected: q, hover: Se } };
244
251
  });
245
- o.redraw(N, L, r, f, M), setTimeout(() => h(B.map(({ annotation: U }) => U)), 1);
252
+ o.redraw(N, T, r, f, M), setTimeout(() => h(B.map(({ annotation: U }) => U)), 1);
246
253
  }, g = (M) => {
247
254
  f = M, p();
248
- }, b = (M) => {
255
+ }, y = (M) => {
249
256
  r = M, p();
250
- }, w = (M) => {
257
+ }, b = (M) => {
251
258
  l = M, p(!1);
252
- }, y = () => p();
253
- i.observe(y);
259
+ }, v = () => p();
260
+ i.observe(v);
254
261
  const d = s.subscribe(() => p()), c = () => p(!0);
255
262
  document.addEventListener("scroll", c, { capture: !0, passive: !0 });
256
- const A = Yt(() => {
263
+ const w = Yt(() => {
257
264
  i.recalculatePositions(), f && f.reset(), p();
258
265
  });
259
- window.addEventListener("resize", A);
260
- const E = new ResizeObserver(A);
261
- E.observe(t);
262
- const T = { attributes: !0, childList: !0, subtree: !0 }, S = new MutationObserver((M) => {
266
+ window.addEventListener("resize", w);
267
+ const S = new ResizeObserver(w);
268
+ S.observe(t);
269
+ const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
263
270
  M.every((m) => m.target === t || t.contains(m.target)) || p(!0);
264
271
  });
265
- return S.observe(document.body, T), {
272
+ return C.observe(document.body, E), {
266
273
  destroy: () => {
267
- t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(y), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", A), E.disconnect(), S.disconnect();
274
+ t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(v), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", w), S.disconnect(), C.disconnect();
268
275
  },
269
276
  redraw: p,
270
- setStyle: b,
271
- setFilter: w,
277
+ setStyle: y,
278
+ setFilter: b,
272
279
  setPainter: g,
273
280
  setVisible: o.setVisible
274
281
  };
@@ -284,25 +291,25 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
284
291
  const o = (r, l, f, h) => requestAnimationFrame(() => {
285
292
  const { width: u, height: p } = e;
286
293
  n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
287
- const { top: g, left: b } = l;
288
- [...r].sort((y, d) => {
289
- const { annotation: { target: { created: c } } } = y, { annotation: { target: { created: A } } } = d;
290
- return c.getTime() - A.getTime();
291
- }).forEach((y) => {
292
- var E;
293
- const d = f ? typeof f == "function" ? f(y.annotation, y.state) : f : (E = y.state) != null && E.selected ? wt : W, c = h && h.paint(y, l) || d, A = y.rects.map(({ x: T, y: S, width: O, height: M }) => ({
294
- x: T + b,
295
- y: S + g,
294
+ const { top: g, left: y } = l;
295
+ [...r].sort((v, d) => {
296
+ const { annotation: { target: { created: c } } } = v, { annotation: { target: { created: w } } } = d;
297
+ return c.getTime() - w.getTime();
298
+ }).forEach((v) => {
299
+ var S;
300
+ const d = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (S = v.state) != null && S.selected ? wt : W, c = h && h.paint(v, l) || d, w = v.rects.map(({ x: E, y: C, width: O, height: M }) => ({
301
+ x: E + y,
302
+ y: C + g,
296
303
  width: O,
297
304
  height: M
298
305
  }));
299
- if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, A.forEach(
300
- ({ x: T, y: S, width: O, height: M }) => n.fillRect(T, S, O, M)
306
+ if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, w.forEach(
307
+ ({ x: E, y: C, width: O, height: M }) => n.fillRect(E, C, O, M)
301
308
  ), c.underlineColor) {
302
309
  n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
303
- const T = c.underlineOffset ?? 0;
304
- A.forEach(({ x: S, y: O, width: M, height: L }) => {
305
- n.beginPath(), n.moveTo(S, O + L + T), n.lineTo(S + M, O + L + T), n.stroke();
310
+ const E = c.underlineOffset ?? 0;
311
+ w.forEach(({ x: C, y: O, width: M, height: T }) => {
312
+ n.beginPath(), n.moveTo(C, O + T + E), n.lineTo(C + M, O + T + E), n.stroke();
306
313
  });
307
314
  }
308
315
  });
@@ -471,13 +478,13 @@ const tn = (t) => [
471
478
  const f = new Set(s.map((u) => u.annotation.id));
472
479
  Array.from(e).filter((u) => !f.has(u));
473
480
  const h = s.map((u) => {
474
- var b;
475
- const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (b = u.state) != null && b.selected ? wt : W, g = l && l.paint(u, a) || p;
481
+ var y;
482
+ const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (y = u.state) != null && y.selected ? wt : W, g = l && l.paint(u, a) || p;
476
483
  return `::highlight(_${u.annotation.id}) { ${tn(g)} }`;
477
484
  });
478
485
  t.innerHTML = h.join(`
479
486
  `), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
480
- const p = u.target.selector.map((b) => b.range), g = new Highlight(...p);
487
+ const p = u.target.selector.map((y) => y.range), g = new Highlight(...p);
481
488
  CSS.highlights.set(`_${u.id}`, g);
482
489
  }), e = f;
483
490
  }
@@ -519,15 +526,15 @@ const on = (t, e) => {
519
526
  redraw: (a, r, l, f, h) => {
520
527
  const p = !(Ut(n, a) && h);
521
528
  if (!f && !p) return;
522
- p && (e.innerHTML = ""), [...a].sort((b, w) => {
523
- const { annotation: { target: { created: y } } } = b, { annotation: { target: { created: d } } } = w;
524
- return y && d ? y.getTime() - d.getTime() : 0;
525
- }).forEach((b) => {
526
- b.rects.map((w) => {
527
- const y = on(w, a), d = De(b, r, l, f, y);
529
+ p && (e.innerHTML = ""), [...a].sort((y, b) => {
530
+ const { annotation: { target: { created: v } } } = y, { annotation: { target: { created: d } } } = b;
531
+ return v && d ? v.getTime() - d.getTime() : 0;
532
+ }).forEach((y) => {
533
+ y.rects.map((b) => {
534
+ const v = on(b, a), d = De(y, r, l, f, v);
528
535
  if (p) {
529
536
  const c = document.createElement("span");
530
- c.className = "r6o-annotation", c.dataset.annotation = b.annotation.id, c.style.left = `${w.x}px`, c.style.top = `${w.y}px`, c.style.width = `${w.width}px`, c.style.height = `${w.height}px`, c.style.backgroundColor = $((d == null ? void 0 : d.fill) || W.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? W.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
537
+ c.className = "r6o-annotation", c.dataset.annotation = y.annotation.id, c.style.left = `${b.x}px`, c.style.top = `${b.y}px`, c.style.width = `${b.width}px`, c.style.height = `${b.height}px`, c.style.backgroundColor = $((d == null ? void 0 : d.fill) || W.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? W.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
531
538
  }
532
539
  });
533
540
  }), n = a;
@@ -634,53 +641,53 @@ var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE =
634
641
  const pt = { selected: [] }, pn = (t, e, n) => {
635
642
  const { subscribe: o, set: i } = Dt(pt);
636
643
  let s = e, a = pt;
637
- o((b) => a = b);
644
+ o((y) => a = y);
638
645
  const r = () => {
639
646
  G(a, pt) || i(pt);
640
647
  }, l = () => {
641
- var b;
642
- return ((b = a.selected) == null ? void 0 : b.length) === 0;
643
- }, f = (b) => {
648
+ var y;
649
+ return ((y = a.selected) == null ? void 0 : y.length) === 0;
650
+ }, f = (y) => {
644
651
  if (l())
645
652
  return !1;
646
- const w = typeof b == "string" ? b : b.id;
647
- return a.selected.some((y) => y.id === w);
648
- }, h = (b, w) => {
649
- let y;
650
- if (Array.isArray(b)) {
651
- if (y = b.map((c) => t.getAnnotation(c)).filter(Boolean), y.length < b.length) {
652
- console.warn("Invalid selection: " + b.filter((c) => !y.some((A) => A.id === c)));
653
+ const b = typeof y == "string" ? y : y.id;
654
+ return a.selected.some((v) => v.id === b);
655
+ }, h = (y, b) => {
656
+ let v;
657
+ if (Array.isArray(y)) {
658
+ if (v = y.map((c) => t.getAnnotation(c)).filter(Boolean), v.length < y.length) {
659
+ console.warn("Invalid selection: " + y.filter((c) => !v.some((w) => w.id === c)));
653
660
  return;
654
661
  }
655
662
  } else {
656
- const c = t.getAnnotation(b);
663
+ const c = t.getAnnotation(y);
657
664
  if (!c) {
658
- console.warn("Invalid selection: " + b);
665
+ console.warn("Invalid selection: " + y);
659
666
  return;
660
667
  }
661
- y = [c];
668
+ v = [c];
662
669
  }
663
- const d = y.reduce((c, A) => {
664
- const E = Zt(A, s);
665
- return E === "EDIT" ? [...c, { id: A.id, editable: !0 }] : E === "SELECT" ? [...c, { id: A.id }] : c;
670
+ const d = v.reduce((c, w) => {
671
+ const S = Zt(w, s);
672
+ return S === "EDIT" ? [...c, { id: w.id, editable: !0 }] : S === "SELECT" ? [...c, { id: w.id }] : c;
666
673
  }, []);
667
- i({ selected: d, event: w });
668
- }, u = (b, w) => {
669
- const y = Array.isArray(b) ? b : [b], d = y.map((c) => t.getAnnotation(c)).filter((c) => !!c);
674
+ i({ selected: d, event: b });
675
+ }, u = (y, b) => {
676
+ const v = Array.isArray(y) ? y : [y], d = v.map((c) => t.getAnnotation(c)).filter((c) => !!c);
670
677
  i({
671
678
  selected: d.map((c) => {
672
- const A = w === void 0 ? Zt(c, s) === "EDIT" : w;
673
- return { id: c.id, editable: A };
679
+ const w = b === void 0 ? Zt(c, s) === "EDIT" : b;
680
+ return { id: c.id, editable: w };
674
681
  })
675
- }), d.length !== y.length && console.warn("Invalid selection", b);
676
- }, p = (b) => {
682
+ }), d.length !== v.length && console.warn("Invalid selection", y);
683
+ }, p = (y) => {
677
684
  if (l())
678
685
  return !1;
679
- const { selected: w } = a;
680
- w.some(({ id: y }) => b.includes(y)) && i({ selected: w.filter(({ id: y }) => !b.includes(y)) });
681
- }, g = (b) => s = b;
686
+ const { selected: b } = a;
687
+ b.some(({ id: v }) => y.includes(v)) && i({ selected: b.filter(({ id: v }) => !y.includes(v)) });
688
+ }, g = (y) => s = y;
682
689
  return t.observe(
683
- ({ changes: b }) => p((b.deleted || []).map((w) => w.id))
690
+ ({ changes: y }) => p((y.deleted || []).map((b) => b.id))
684
691
  ), {
685
692
  get event() {
686
693
  return a ? a.event : null;
@@ -733,7 +740,7 @@ const Ot = (t) => {
733
740
  bodies: (t.bodies || []).map(e),
734
741
  target: e(t.target)
735
742
  };
736
- }, wo = (t, e, n, o) => ({
743
+ }, Ao = (t, e, n, o) => ({
737
744
  id: he(),
738
745
  annotation: typeof t == "string" ? t : t.id,
739
746
  created: n || /* @__PURE__ */ new Date(),
@@ -793,8 +800,8 @@ const En = (t, e) => {
793
800
  ...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
794
801
  const { oldValue: p, newValue: g } = u;
795
802
  if (a.has(g.id)) {
796
- const b = e.updated.find((w) => w.oldValue.id === g.id).newValue;
797
- return pe(p, b);
803
+ const y = e.updated.find((b) => b.oldValue.id === g.id).newValue;
804
+ return pe(p, y);
798
805
  } else
799
806
  return u;
800
807
  }),
@@ -816,71 +823,71 @@ const En = (t, e) => {
816
823
  }
817
824
  };
818
825
  }, Cn = (t) => t.id !== void 0, Ln = () => {
819
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, v = {}) => {
820
- n.push({ onChange: m, options: v });
826
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, x = {}) => {
827
+ n.push({ onChange: m, options: x });
821
828
  }, i = (m) => {
822
- const v = n.findIndex((x) => x.onChange == m);
823
- v > -1 && n.splice(v, 1);
824
- }, s = (m, v) => {
825
- const x = {
829
+ const x = n.findIndex((A) => A.onChange == m);
830
+ x > -1 && n.splice(x, 1);
831
+ }, s = (m, x) => {
832
+ const A = {
826
833
  origin: m,
827
834
  changes: {
828
- created: v.created || [],
829
- updated: v.updated || [],
830
- deleted: v.deleted || []
835
+ created: x.created || [],
836
+ updated: x.updated || [],
837
+ deleted: x.deleted || []
831
838
  },
832
839
  state: [...t.values()]
833
840
  };
834
- n.forEach((C) => {
835
- En(C, x) && C.onChange(x);
841
+ n.forEach((L) => {
842
+ En(L, A) && L.onChange(A);
836
843
  });
837
- }, a = (m, v = k.LOCAL) => {
844
+ }, a = (m, x = k.LOCAL) => {
838
845
  if (m.id && t.get(m.id))
839
846
  throw Error(`Cannot add annotation ${m.id} - exists already`);
840
847
  {
841
- const x = Mt(m);
842
- t.set(x.id, x), x.bodies.forEach((C) => e.set(C.id, x.id)), s(v, { created: [x] });
848
+ const A = Mt(m);
849
+ t.set(A.id, A), A.bodies.forEach((L) => e.set(L.id, A.id)), s(x, { created: [A] });
843
850
  }
844
- }, r = (m, v) => {
845
- const x = Mt(typeof m == "string" ? v : m), C = typeof m == "string" ? m : m.id, B = C && t.get(C);
851
+ }, r = (m, x) => {
852
+ const A = Mt(typeof m == "string" ? x : m), L = typeof m == "string" ? m : m.id, B = L && t.get(L);
846
853
  if (B) {
847
- const R = pe(B, x);
848
- return C === x.id ? t.set(C, x) : (t.delete(C), t.set(x.id, x)), B.bodies.forEach((N) => e.delete(N.id)), x.bodies.forEach((N) => e.set(N.id, x.id)), R;
854
+ const R = pe(B, A);
855
+ return L === A.id ? t.set(L, A) : (t.delete(L), t.set(A.id, A)), B.bodies.forEach((N) => e.delete(N.id)), A.bodies.forEach((N) => e.set(N.id, A.id)), R;
849
856
  } else
850
- console.warn(`Cannot update annotation ${C} - does not exist`);
851
- }, l = (m, v = k.LOCAL, x = k.LOCAL) => {
852
- const C = Cn(v) ? x : v, B = r(m, v);
853
- B && s(C, { updated: [B] });
854
- }, f = (m, v = k.LOCAL) => {
855
- const x = m.reduce((C, B) => {
857
+ console.warn(`Cannot update annotation ${L} - does not exist`);
858
+ }, l = (m, x = k.LOCAL, A = k.LOCAL) => {
859
+ const L = Cn(x) ? A : x, B = r(m, x);
860
+ B && s(L, { updated: [B] });
861
+ }, f = (m, x = k.LOCAL) => {
862
+ const A = m.reduce((L, B) => {
856
863
  const R = r(B);
857
- return R ? [...C, R] : C;
864
+ return R ? [...L, R] : L;
858
865
  }, []);
859
- x.length > 0 && s(v, { updated: x });
860
- }, h = (m, v = k.LOCAL) => {
861
- const x = t.get(m.annotation);
862
- if (x) {
863
- const C = {
864
- ...x,
865
- bodies: [...x.bodies, m]
866
+ A.length > 0 && s(x, { updated: A });
867
+ }, h = (m, x = k.LOCAL) => {
868
+ const A = t.get(m.annotation);
869
+ if (A) {
870
+ const L = {
871
+ ...A,
872
+ bodies: [...A.bodies, m]
866
873
  };
867
- t.set(x.id, C), e.set(m.id, C.id), s(v, { updated: [{
868
- oldValue: x,
869
- newValue: C,
874
+ t.set(A.id, L), e.set(m.id, L.id), s(x, { updated: [{
875
+ oldValue: A,
876
+ newValue: L,
870
877
  bodiesCreated: [m]
871
878
  }] });
872
879
  } else
873
880
  console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
874
881
  }, u = () => [...t.values()], p = (m = k.LOCAL) => {
875
- const v = [...t.values()];
876
- t.clear(), e.clear(), s(m, { deleted: v });
877
- }, g = (m, v = !0, x = k.LOCAL) => {
878
- const C = m.map(Mt);
879
- if (v) {
882
+ const x = [...t.values()];
883
+ t.clear(), e.clear(), s(m, { deleted: x });
884
+ }, g = (m, x = !0, A = k.LOCAL) => {
885
+ const L = m.map(Mt);
886
+ if (x) {
880
887
  const B = [...t.values()];
881
- t.clear(), e.clear(), C.forEach((R) => {
888
+ t.clear(), e.clear(), L.forEach((R) => {
882
889
  t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
883
- }), s(x, { created: C, deleted: B });
890
+ }), s(A, { created: L, deleted: B });
884
891
  } else {
885
892
  const B = m.reduce((R, N) => {
886
893
  const U = N.id && t.get(N.id);
@@ -888,98 +895,98 @@ const En = (t, e) => {
888
895
  }, []);
889
896
  if (B.length > 0)
890
897
  throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
891
- C.forEach((R) => {
898
+ L.forEach((R) => {
892
899
  t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
893
- }), s(x, { created: C });
900
+ }), s(A, { created: L });
894
901
  }
895
- }, b = (m) => {
896
- const v = typeof m == "string" ? m : m.id, x = t.get(v);
897
- if (x)
898
- return t.delete(v), x.bodies.forEach((C) => e.delete(C.id)), x;
899
- console.warn(`Attempt to delete missing annotation: ${v}`);
900
- }, w = (m, v = k.LOCAL) => {
901
- const x = b(m);
902
- x && s(v, { deleted: [x] });
903
- }, y = (m, v = k.LOCAL) => {
904
- const x = m.reduce((C, B) => {
905
- const R = b(B);
906
- return R ? [...C, R] : C;
902
+ }, y = (m) => {
903
+ const x = typeof m == "string" ? m : m.id, A = t.get(x);
904
+ if (A)
905
+ return t.delete(x), A.bodies.forEach((L) => e.delete(L.id)), A;
906
+ console.warn(`Attempt to delete missing annotation: ${x}`);
907
+ }, b = (m, x = k.LOCAL) => {
908
+ const A = y(m);
909
+ A && s(x, { deleted: [A] });
910
+ }, v = (m, x = k.LOCAL) => {
911
+ const A = m.reduce((L, B) => {
912
+ const R = y(B);
913
+ return R ? [...L, R] : L;
907
914
  }, []);
908
- x.length > 0 && s(v, { deleted: x });
915
+ A.length > 0 && s(x, { deleted: A });
909
916
  }, d = (m) => {
910
- const v = t.get(m.annotation);
911
- if (v) {
912
- const x = v.bodies.find((C) => C.id === m.id);
913
- if (x) {
914
- e.delete(x.id);
915
- const C = {
916
- ...v,
917
- bodies: v.bodies.filter((B) => B.id !== m.id)
917
+ const x = t.get(m.annotation);
918
+ if (x) {
919
+ const A = x.bodies.find((L) => L.id === m.id);
920
+ if (A) {
921
+ e.delete(A.id);
922
+ const L = {
923
+ ...x,
924
+ bodies: x.bodies.filter((B) => B.id !== m.id)
918
925
  };
919
- return t.set(v.id, C), {
920
- oldValue: v,
921
- newValue: C,
922
- bodiesDeleted: [x]
926
+ return t.set(x.id, L), {
927
+ oldValue: x,
928
+ newValue: L,
929
+ bodiesDeleted: [A]
923
930
  };
924
931
  } else
925
932
  console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
926
933
  } else
927
934
  console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
928
- }, c = (m, v = k.LOCAL) => {
929
- const x = d(m);
930
- x && s(v, { updated: [x] });
931
- }, A = (m, v = k.LOCAL) => {
932
- const x = m.map((C) => d(C)).filter(Boolean);
933
- x.length > 0 && s(v, { updated: x });
935
+ }, c = (m, x = k.LOCAL) => {
936
+ const A = d(m);
937
+ A && s(x, { updated: [A] });
938
+ }, w = (m, x = k.LOCAL) => {
939
+ const A = m.map((L) => d(L)).filter(Boolean);
940
+ A.length > 0 && s(x, { updated: A });
941
+ }, S = (m) => {
942
+ const x = t.get(m);
943
+ return x ? { ...x } : void 0;
934
944
  }, E = (m) => {
935
- const v = t.get(m);
936
- return v ? { ...v } : void 0;
937
- }, T = (m) => {
938
- const v = e.get(m);
939
- if (v) {
940
- const x = E(v).bodies.find((C) => C.id === m);
941
- if (x)
942
- return x;
945
+ const x = e.get(m);
946
+ if (x) {
947
+ const A = S(x).bodies.find((L) => L.id === m);
948
+ if (A)
949
+ return A;
943
950
  console.error(`Store integrity error: body ${m} in index, but not in annotation`);
944
951
  } else
945
952
  console.warn(`Attempt to retrieve missing body: ${m}`);
946
- }, S = (m, v) => {
947
- if (m.annotation !== v.annotation)
953
+ }, C = (m, x) => {
954
+ if (m.annotation !== x.annotation)
948
955
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
949
- const x = t.get(m.annotation);
950
- if (x) {
951
- const C = x.bodies.find((R) => R.id === m.id), B = {
952
- ...x,
953
- bodies: x.bodies.map((R) => R.id === C.id ? v : R)
956
+ const A = t.get(m.annotation);
957
+ if (A) {
958
+ const L = A.bodies.find((R) => R.id === m.id), B = {
959
+ ...A,
960
+ bodies: A.bodies.map((R) => R.id === L.id ? x : R)
954
961
  };
955
- return t.set(x.id, B), C.id !== v.id && (e.delete(C.id), e.set(v.id, B.id)), {
956
- oldValue: x,
962
+ return t.set(A.id, B), L.id !== x.id && (e.delete(L.id), e.set(x.id, B.id)), {
963
+ oldValue: A,
957
964
  newValue: B,
958
- bodiesUpdated: [{ oldBody: C, newBody: v }]
965
+ bodiesUpdated: [{ oldBody: L, newBody: x }]
959
966
  };
960
967
  } else
961
968
  console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
962
- }, O = (m, v, x = k.LOCAL) => {
963
- const C = S(m, v);
964
- C && s(x, { updated: [C] });
965
- }, M = (m, v = k.LOCAL) => {
966
- const x = m.map((C) => S({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
967
- s(v, { updated: x });
968
- }, L = (m) => {
969
- const v = t.get(m.annotation);
970
- if (v) {
971
- const x = {
972
- ...v,
969
+ }, O = (m, x, A = k.LOCAL) => {
970
+ const L = C(m, x);
971
+ L && s(A, { updated: [L] });
972
+ }, M = (m, x = k.LOCAL) => {
973
+ const A = m.map((L) => C({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
974
+ s(x, { updated: A });
975
+ }, T = (m) => {
976
+ const x = t.get(m.annotation);
977
+ if (x) {
978
+ const A = {
979
+ ...x,
973
980
  target: {
974
- ...v.target,
981
+ ...x.target,
975
982
  ...m
976
983
  }
977
984
  };
978
- return t.set(v.id, x), {
979
- oldValue: v,
980
- newValue: x,
985
+ return t.set(x.id, A), {
986
+ oldValue: x,
987
+ newValue: A,
981
988
  targetUpdated: {
982
- oldTarget: v.target,
989
+ oldTarget: x.target,
983
990
  newTarget: m
984
991
  }
985
992
  };
@@ -991,26 +998,26 @@ const En = (t, e) => {
991
998
  addBody: h,
992
999
  all: u,
993
1000
  bulkAddAnnotation: g,
994
- bulkDeleteAnnotation: y,
995
- bulkDeleteBodies: A,
1001
+ bulkDeleteAnnotation: v,
1002
+ bulkDeleteBodies: w,
996
1003
  bulkUpdateAnnotation: f,
997
1004
  bulkUpdateBodies: M,
998
- bulkUpdateTargets: (m, v = k.LOCAL) => {
999
- const x = m.map((C) => L(C)).filter(Boolean);
1000
- x.length > 0 && s(v, { updated: x });
1005
+ bulkUpdateTargets: (m, x = k.LOCAL) => {
1006
+ const A = m.map((L) => T(L)).filter(Boolean);
1007
+ A.length > 0 && s(x, { updated: A });
1001
1008
  },
1002
1009
  clear: p,
1003
- deleteAnnotation: w,
1010
+ deleteAnnotation: b,
1004
1011
  deleteBody: c,
1005
- getAnnotation: E,
1006
- getBody: T,
1012
+ getAnnotation: S,
1013
+ getBody: E,
1007
1014
  observe: o,
1008
1015
  unobserve: i,
1009
1016
  updateAnnotation: l,
1010
1017
  updateBody: O,
1011
- updateTarget: (m, v = k.LOCAL) => {
1012
- const x = L(m);
1013
- x && s(v, { updated: [x] });
1018
+ updateTarget: (m, x = k.LOCAL) => {
1019
+ const A = T(m);
1020
+ A && s(x, { updated: [A] });
1014
1021
  }
1015
1022
  };
1016
1023
  };
@@ -1033,36 +1040,36 @@ const On = 250, Mn = (t) => {
1033
1040
  let o = -1, i = !1, s = 0;
1034
1041
  const a = (g) => {
1035
1042
  if (!i) {
1036
- const { changes: b } = g, w = performance.now();
1037
- if (w - s > On)
1038
- n.splice(o + 1), n.push(b), o = n.length - 1;
1043
+ const { changes: y } = g, b = performance.now();
1044
+ if (b - s > On)
1045
+ n.splice(o + 1), n.push(y), o = n.length - 1;
1039
1046
  else {
1040
- const y = n.length - 1;
1041
- n[y] = Sn(n[y], b);
1047
+ const v = n.length - 1;
1048
+ n[v] = Sn(n[v], y);
1042
1049
  }
1043
- s = w;
1050
+ s = b;
1044
1051
  }
1045
1052
  i = !1;
1046
1053
  };
1047
1054
  t.observe(a, { origin: k.LOCAL });
1048
- const r = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: b }) => b)), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: b }) => b)), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1055
+ const r = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1049
1056
  return {
1050
1057
  canRedo: () => n.length - 1 > o,
1051
1058
  canUndo: () => o > -1,
1052
1059
  destroy: () => t.unobserve(a),
1053
- on: (g, b) => e.on(g, b),
1060
+ on: (g, y) => e.on(g, y),
1054
1061
  redo: () => {
1055
1062
  if (n.length - 1 > o) {
1056
1063
  i = !0;
1057
- const { created: g, updated: b, deleted: w } = n[o + 1];
1058
- l(g), h(b), p(w), e.emit("redo", n[o + 1]), o += 1;
1064
+ const { created: g, updated: y, deleted: b } = n[o + 1];
1065
+ l(g), h(y), p(b), e.emit("redo", n[o + 1]), o += 1;
1059
1066
  }
1060
1067
  },
1061
1068
  undo: () => {
1062
1069
  if (o > -1) {
1063
1070
  i = !0;
1064
- const { created: g, updated: b, deleted: w } = n[o];
1065
- r(g), f(b), u(w), e.emit("undo", n[o]), o -= 1;
1071
+ const { created: g, updated: y, deleted: b } = n[o];
1072
+ r(g), f(y), u(b), e.emit("undo", n[o]), o -= 1;
1066
1073
  }
1067
1074
  }
1068
1075
  };
@@ -1075,71 +1082,71 @@ const On = 250, Mn = (t) => {
1075
1082
  }, Rn = (t, e, n, o) => {
1076
1083
  const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
1077
1084
  let f = [], h;
1078
- const u = (w, y) => {
1079
- l.has(w) ? l.get(w).push(y) : l.set(w, [y]);
1080
- }, p = (w, y) => {
1081
- const d = l.get(w);
1085
+ const u = (b, v) => {
1086
+ l.has(b) ? l.get(b).push(v) : l.set(b, [v]);
1087
+ }, p = (b, v) => {
1088
+ const d = l.get(b);
1082
1089
  if (d) {
1083
- const c = d.indexOf(y);
1090
+ const c = d.indexOf(v);
1084
1091
  c !== -1 && d.splice(c, 1);
1085
1092
  }
1086
- }, g = (w, y, d) => {
1087
- l.has(w) && setTimeout(() => {
1088
- l.get(w).forEach((c) => {
1093
+ }, g = (b, v, d) => {
1094
+ l.has(b) && setTimeout(() => {
1095
+ l.get(b).forEach((c) => {
1089
1096
  if (n) {
1090
- const A = Array.isArray(y) ? y.map((T) => n.serialize(T)) : n.serialize(y), E = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1091
- c(A, E);
1097
+ const w = Array.isArray(v) ? v.map((E) => n.serialize(E)) : n.serialize(v), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1098
+ c(w, S);
1092
1099
  } else
1093
- c(y, d);
1100
+ c(v, d);
1094
1101
  });
1095
1102
  }, 1);
1096
1103
  };
1097
- s.subscribe(({ selected: w }) => {
1098
- if (!(f.length === 0 && w.length === 0)) {
1099
- if (f.length === 0 && w.length > 0)
1100
- f = w.map(({ id: y }) => a.getAnnotation(y));
1101
- else if (f.length > 0 && w.length === 0)
1102
- f.forEach((y) => {
1103
- const d = a.getAnnotation(y.id);
1104
- d && !G(d, y) && g("updateAnnotation", d, y);
1104
+ s.subscribe(({ selected: b }) => {
1105
+ if (!(f.length === 0 && b.length === 0)) {
1106
+ if (f.length === 0 && b.length > 0)
1107
+ f = b.map(({ id: v }) => a.getAnnotation(v));
1108
+ else if (f.length > 0 && b.length === 0)
1109
+ f.forEach((v) => {
1110
+ const d = a.getAnnotation(v.id);
1111
+ d && !G(d, v) && g("updateAnnotation", d, v);
1105
1112
  }), f = [];
1106
1113
  else {
1107
- const y = new Set(f.map((c) => c.id)), d = new Set(w.map(({ id: c }) => c));
1114
+ const v = new Set(f.map((c) => c.id)), d = new Set(b.map(({ id: c }) => c));
1108
1115
  f.filter((c) => !d.has(c.id)).forEach((c) => {
1109
- const A = a.getAnnotation(c.id);
1110
- A && !G(A, c) && g("updateAnnotation", A, c);
1116
+ const w = a.getAnnotation(c.id);
1117
+ w && !G(w, c) && g("updateAnnotation", w, c);
1111
1118
  }), f = [
1112
1119
  // Remove annotations that were deselected
1113
1120
  ...f.filter((c) => d.has(c.id)),
1114
1121
  // Add editable annotations that were selected
1115
- ...w.filter(({ id: c }) => !y.has(c)).map(({ id: c }) => a.getAnnotation(c))
1122
+ ...b.filter(({ id: c }) => !v.has(c)).map(({ id: c }) => a.getAnnotation(c))
1116
1123
  ];
1117
1124
  }
1118
1125
  g("selectionChanged", f);
1119
1126
  }
1120
- }), i.subscribe((w) => {
1121
- !h && w ? g("mouseEnterAnnotation", a.getAnnotation(w)) : h && !w ? g("mouseLeaveAnnotation", a.getAnnotation(h)) : h && w && (g("mouseLeaveAnnotation", a.getAnnotation(h)), g("mouseEnterAnnotation", a.getAnnotation(w))), h = w;
1122
- }), r == null || r.subscribe((w) => g("viewportIntersect", w.map((y) => a.getAnnotation(y)))), a.observe((w) => {
1123
- const { created: y, deleted: d } = w.changes;
1124
- (y || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (w.changes.updated || []).filter((c) => [
1127
+ }), i.subscribe((b) => {
1128
+ !h && b ? g("mouseEnterAnnotation", a.getAnnotation(b)) : h && !b ? g("mouseLeaveAnnotation", a.getAnnotation(h)) : h && b && (g("mouseLeaveAnnotation", a.getAnnotation(h)), g("mouseEnterAnnotation", a.getAnnotation(b))), h = b;
1129
+ }), r == null || r.subscribe((b) => g("viewportIntersect", b.map((v) => a.getAnnotation(v)))), a.observe((b) => {
1130
+ const { created: v, deleted: d } = b.changes;
1131
+ (v || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (b.changes.updated || []).filter((c) => [
1125
1132
  ...c.bodiesCreated || [],
1126
1133
  ...c.bodiesDeleted || [],
1127
1134
  ...c.bodiesUpdated || []
1128
- ].length > 0).forEach(({ oldValue: c, newValue: A }) => {
1129
- const E = f.find((T) => T.id === c.id) || c;
1130
- f = f.map((T) => T.id === c.id ? A : T), g("updateAnnotation", A, E);
1135
+ ].length > 0).forEach(({ oldValue: c, newValue: w }) => {
1136
+ const S = f.find((E) => E.id === c.id) || c;
1137
+ f = f.map((E) => E.id === c.id ? w : E), g("updateAnnotation", w, S);
1131
1138
  });
1132
- }, { origin: k.LOCAL }), a.observe((w) => {
1139
+ }, { origin: k.LOCAL }), a.observe((b) => {
1133
1140
  if (f) {
1134
- const y = new Set(f.map((c) => c.id)), d = (w.changes.updated || []).filter(({ newValue: c }) => y.has(c.id)).map(({ newValue: c }) => c);
1135
- d.length > 0 && (f = f.map((c) => d.find((E) => E.id === c.id) || c));
1141
+ const v = new Set(f.map((c) => c.id)), d = (b.changes.updated || []).filter(({ newValue: c }) => v.has(c.id)).map(({ newValue: c }) => c);
1142
+ d.length > 0 && (f = f.map((c) => d.find((S) => S.id === c.id) || c));
1136
1143
  }
1137
1144
  }, { origin: k.REMOTE });
1138
- const b = (w) => (y) => {
1139
- const { updated: d } = y;
1140
- w ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
1145
+ const y = (b) => (v) => {
1146
+ const { updated: d } = v;
1147
+ b ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
1141
1148
  };
1142
- return e.on("undo", b(!0)), e.on("redo", b(!1)), { on: u, off: p, emit: g };
1149
+ return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: u, off: p, emit: g };
1143
1150
  }, kn = (t) => (e) => e.reduce((n, o) => {
1144
1151
  const { parsed: i, error: s } = t.parse(o);
1145
1152
  return s ? {
@@ -1154,8 +1161,8 @@ const On = 250, Mn = (t) => {
1154
1161
  }, { parsed: [], failed: [] }), In = (t, e, n) => {
1155
1162
  const { store: o, selection: i } = t, s = (d) => {
1156
1163
  if (n) {
1157
- const { parsed: c, error: A } = n.parse(d);
1158
- c ? o.addAnnotation(c, k.REMOTE) : console.error(A);
1164
+ const { parsed: c, error: w } = n.parse(d);
1165
+ c ? o.addAnnotation(c, k.REMOTE) : console.error(w);
1159
1166
  } else
1160
1167
  o.addAnnotation(Ot(d), k.REMOTE);
1161
1168
  }, a = () => i.clear(), r = () => o.clear(), l = (d) => {
@@ -1163,9 +1170,9 @@ const On = 250, Mn = (t) => {
1163
1170
  return n && c ? n.serialize(c) : c;
1164
1171
  }, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1165
1172
  var d;
1166
- const c = (((d = i.selected) == null ? void 0 : d.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
1173
+ const c = (((d = i.selected) == null ? void 0 : d.map((w) => w.id)) || []).map((w) => o.getAnnotation(w)).filter(Boolean);
1167
1174
  return n ? c.map(n.serialize) : c;
1168
- }, u = (d, c = !0) => fetch(d).then((A) => A.json()).then((A) => (g(A, c), A)), p = (d) => {
1175
+ }, u = (d, c = !0) => fetch(d).then((w) => w.json()).then((w) => (g(w, c), w)), p = (d) => {
1169
1176
  if (typeof d == "string") {
1170
1177
  const c = o.getAnnotation(d);
1171
1178
  if (o.deleteAnnotation(d), c)
@@ -1177,18 +1184,18 @@ const On = 250, Mn = (t) => {
1177
1184
  }
1178
1185
  }, g = (d, c = !0) => {
1179
1186
  if (n) {
1180
- const A = n.parseAll || kn(n), { parsed: E, failed: T } = A(d);
1181
- T.length > 0 && console.warn(`Discarded ${T.length} invalid annotations`, T), o.bulkAddAnnotation(E, c, k.REMOTE);
1187
+ const w = n.parseAll || kn(n), { parsed: S, failed: E } = w(d);
1188
+ E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(S, c, k.REMOTE);
1182
1189
  } else
1183
1190
  o.bulkAddAnnotation(d.map(Ot), c, k.REMOTE);
1184
- }, b = (d, c) => {
1191
+ }, y = (d, c) => {
1185
1192
  d ? i.setSelected(d, c) : i.clear();
1186
- }, w = (d) => {
1193
+ }, b = (d) => {
1187
1194
  i.clear(), i.setUserSelectAction(d);
1188
- }, y = (d) => {
1195
+ }, v = (d) => {
1189
1196
  if (n) {
1190
- const c = n.parse(d).parsed, A = n.serialize(o.getAnnotation(c.id));
1191
- return o.updateAnnotation(c), A;
1197
+ const c = n.parse(d).parsed, w = n.serialize(o.getAnnotation(c.id));
1198
+ return o.updateAnnotation(c), w;
1192
1199
  } else {
1193
1200
  const c = o.getAnnotation(d.id);
1194
1201
  return o.updateAnnotation(Ot(d)), c;
@@ -1207,10 +1214,10 @@ const On = 250, Mn = (t) => {
1207
1214
  redo: e.redo,
1208
1215
  removeAnnotation: p,
1209
1216
  setAnnotations: g,
1210
- setSelected: b,
1211
- setUserSelectAction: w,
1217
+ setSelected: y,
1218
+ setUserSelectAction: b,
1212
1219
  undo: e.undo,
1213
- updateAnnotation: y
1220
+ updateAnnotation: v
1214
1221
  };
1215
1222
  }, _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1216
1223
  let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
@@ -1260,7 +1267,7 @@ const Kn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
1260
1267
  return (n = r.id) != null && n.startsWith("temp-") && delete r.id, r;
1261
1268
  });
1262
1269
  Yn();
1263
- const Ao = (t, e) => ({
1270
+ const xo = (t, e) => ({
1264
1271
  parse: (n) => jn(n),
1265
1272
  serialize: (n) => zn(n, t, e)
1266
1273
  }), $n = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Hn = (t) => {
@@ -1336,15 +1343,15 @@ const Ao = (t, e) => ({
1336
1343
  updated: f,
1337
1344
  ...h
1338
1345
  } = i, u = a.map((p) => {
1339
- const { id: g, quote: b, start: w, end: y, range: d } = p, { prefix: c, suffix: A } = Re(d, n), E = [{
1346
+ const { id: g, quote: y, start: b, end: v, range: d } = p, { prefix: c, suffix: w } = Re(d, n), S = [{
1340
1347
  type: "TextQuoteSelector",
1341
- exact: b,
1348
+ exact: y,
1342
1349
  prefix: c,
1343
- suffix: A
1350
+ suffix: w
1344
1351
  }, {
1345
1352
  type: "TextPositionSelector",
1346
- start: w,
1347
- end: y
1353
+ start: b,
1354
+ end: v
1348
1355
  }];
1349
1356
  return {
1350
1357
  ...h,
@@ -1352,7 +1359,7 @@ const Ao = (t, e) => ({
1352
1359
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1353
1360
  scope: "scope" in p ? p.scope : void 0,
1354
1361
  source: e,
1355
- selector: E
1362
+ selector: S
1356
1363
  };
1357
1364
  });
1358
1365
  return {
@@ -1370,8 +1377,8 @@ const Ao = (t, e) => ({
1370
1377
  function me(t, e, n = 0, o = t.length - 1, i = Fn) {
1371
1378
  for (; o > n; ) {
1372
1379
  if (o - n > 600) {
1373
- const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * u / l + p)), b = Math.min(o, Math.floor(e + (l - f) * u / l + p));
1374
- me(t, e, g, b, i);
1380
+ const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * u / l + p)), y = Math.min(o, Math.floor(e + (l - f) * u / l + p));
1381
+ me(t, e, g, y, i);
1375
1382
  }
1376
1383
  const s = t[e];
1377
1384
  let a = n, r = o;
@@ -1637,20 +1644,20 @@ function ee(t, e, n, o, i) {
1637
1644
  }
1638
1645
  const to = (t, e) => {
1639
1646
  const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
1640
- const A = d.selector.flatMap((T) => {
1641
- const S = F([T]) ? T.range : ae(T, e).range;
1642
- return Array.from(S.getClientRects());
1643
- }), E = Ue(A).map(({ left: T, top: S, right: O, bottom: M }) => new DOMRect(T - c.left, S - c.top, O - T, M - S));
1644
- return E.map((T) => {
1645
- const { x: S, y: O, width: M, height: L } = T;
1647
+ const w = d.selector.flatMap((E) => {
1648
+ const C = F([E]) ? E.range : ae(E, e).range;
1649
+ return Array.from(C.getClientRects());
1650
+ }), S = Ue(w).map(({ left: E, top: C, right: O, bottom: M }) => new DOMRect(E - c.left, C - c.top, O - E, M - C));
1651
+ return S.map((E) => {
1652
+ const { x: C, y: O, width: M, height: T } = E;
1646
1653
  return {
1647
- minX: S,
1654
+ minX: C,
1648
1655
  minY: O,
1649
- maxX: S + M,
1650
- maxY: O + L,
1656
+ maxX: C + M,
1657
+ maxY: O + T,
1651
1658
  annotation: {
1652
1659
  id: d.annotation,
1653
- rects: E
1660
+ rects: S
1654
1661
  }
1655
1662
  };
1656
1663
  });
@@ -1658,36 +1665,38 @@ const to = (t, e) => {
1658
1665
  n.clear(), o.clear();
1659
1666
  }, r = (d) => {
1660
1667
  const c = i(d, e.getBoundingClientRect());
1661
- c.forEach((A) => n.insert(A)), o.set(d.annotation, c);
1668
+ c.length !== 0 && (c.forEach((w) => n.insert(w)), o.set(d.annotation, c));
1662
1669
  }, l = (d) => {
1663
1670
  const c = o.get(d.annotation);
1664
- c && (c.forEach((A) => n.remove(A)), o.delete(d.annotation));
1671
+ c && (c.forEach((w) => n.remove(w)), o.delete(d.annotation));
1665
1672
  }, f = (d) => {
1666
1673
  l(d), r(d);
1667
1674
  }, h = (d, c = !0) => {
1668
1675
  c && a();
1669
- const A = e.getBoundingClientRect(), E = d.map((S) => ({ target: S, rects: i(S, A) }));
1670
- E.forEach(({ target: S, rects: O }) => o.set(S.annotation, O));
1671
- const T = E.flatMap(({ rects: S }) => S);
1672
- n.load(T);
1673
- }, u = (d, c, A = !1) => {
1674
- const E = n.search({
1676
+ const w = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: i(C, w) }));
1677
+ S.forEach(({ target: C, rects: O }) => {
1678
+ O.length > 0 && o.set(C.annotation, O);
1679
+ });
1680
+ const E = S.flatMap(({ rects: C }) => C);
1681
+ n.load(E);
1682
+ }, u = (d, c, w = !1) => {
1683
+ const S = n.search({
1675
1684
  minX: d,
1676
1685
  minY: c,
1677
1686
  maxX: d,
1678
1687
  maxY: c
1679
- }), T = (S) => S.annotation.rects.reduce((O, M) => O + M.width * M.height, 0);
1680
- return E.length > 0 ? (E.sort((S, O) => T(S) - T(O)), A ? E.map((S) => S.annotation.id) : [E[0].annotation.id]) : [];
1688
+ }), E = (C) => C.annotation.rects.reduce((O, M) => O + M.width * M.height, 0);
1689
+ return S.length > 0 ? (S.sort((C, O) => E(C) - E(O)), w ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
1681
1690
  }, p = (d) => {
1682
1691
  const c = g(d);
1683
1692
  if (c.length === 0)
1684
1693
  return;
1685
- let A = c[0].left, E = c[0].top, T = c[0].right, S = c[0].bottom;
1694
+ let w = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
1686
1695
  for (let O = 1; O < c.length; O++) {
1687
1696
  const M = c[O];
1688
- A = Math.min(A, M.left), E = Math.min(E, M.top), T = Math.max(T, M.right), S = Math.max(S, M.bottom);
1697
+ w = Math.min(w, M.left), S = Math.min(S, M.top), E = Math.max(E, M.right), C = Math.max(C, M.bottom);
1689
1698
  }
1690
- return new DOMRect(A, E, T - A, S - E);
1699
+ return new DOMRect(w, S, E - w, C - S);
1691
1700
  }, g = (d) => {
1692
1701
  const c = o.get(d);
1693
1702
  return c ? c[0].annotation.rects : [];
@@ -1698,9 +1707,9 @@ const to = (t, e) => {
1698
1707
  getAt: u,
1699
1708
  getAnnotationBounds: p,
1700
1709
  getAnnotationRects: g,
1701
- getIntersecting: (d, c, A, E) => {
1702
- const T = n.search({ minX: d, minY: c, maxX: A, maxY: E }), S = new Set(T.map((O) => O.annotation.id));
1703
- return Array.from(S).map((O) => ({
1710
+ getIntersecting: (d, c, w, S) => {
1711
+ const E = n.search({ minX: d, minY: c, maxX: w, maxY: S }), C = new Set(E.map((O) => O.annotation.id));
1712
+ return Array.from(C).map((O) => ({
1704
1713
  annotation: t.getAnnotation(O),
1705
1714
  rects: g(O)
1706
1715
  })).filter((O) => !!O.annotation);
@@ -1715,42 +1724,36 @@ const to = (t, e) => {
1715
1724
  }, eo = (t, e) => {
1716
1725
  const n = Ln(), o = to(n, t), i = pn(n);
1717
1726
  i.setUserSelectAction(e);
1718
- const s = fn(n), a = Bn(), r = (y, d = k.LOCAL) => {
1719
- const c = xt(y, t), A = F(c.target.selector);
1720
- return A && n.addAnnotation(c, d), A;
1721
- }, l = (y, d = !0, c = k.LOCAL) => {
1722
- const A = y.map((T) => xt(T, t)), E = A.filter((T) => !F(T.target.selector));
1723
- return n.bulkAddAnnotation(A, d, c), E;
1724
- }, f = (y, d = k.LOCAL) => {
1725
- const c = y.map((E) => xt(E, t)), A = c.filter((E) => !F(E.target.selector));
1726
- return c.forEach((E) => {
1727
- n.getAnnotation(E.id) ? n.updateAnnotation(E, d) : n.addAnnotation(E, d);
1728
- }), A;
1729
- }, h = (y, d = k.LOCAL) => {
1730
- const c = bt(y, t);
1731
- n.updateTarget(c, d);
1732
- }, u = (y, d = k.LOCAL) => {
1733
- const c = y.map((A) => bt(A, t));
1734
- n.bulkUpdateTargets(c, d);
1727
+ const s = fn(n), a = Bn(), r = (d, c = k.LOCAL) => {
1728
+ const w = xt(d, t), S = F(w.target.selector);
1729
+ return S && n.addAnnotation(w, c), S;
1730
+ }, l = (d, c = !0, w = k.LOCAL) => {
1731
+ const S = d.map((C) => xt(C, t)), E = S.filter((C) => !F(C.target.selector));
1732
+ return n.bulkAddAnnotation(S, c, w), E;
1733
+ }, f = (d, c = k.LOCAL) => {
1734
+ const w = d.map((E) => xt(E, t)), S = w.filter((E) => !F(E.target.selector));
1735
+ return w.forEach((E) => {
1736
+ n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
1737
+ }), S;
1738
+ }, h = (d, c = k.LOCAL) => {
1739
+ const w = bt(d, t);
1740
+ n.updateTarget(w, c);
1741
+ }, u = (d, c = k.LOCAL) => {
1742
+ const w = d.map((S) => bt(S, t));
1743
+ n.bulkUpdateTargets(w, c);
1735
1744
  };
1736
- function p(y, d, c, A) {
1737
- const E = c || !!A, T = o.getAt(y, d, E).map((O) => n.getAnnotation(O)), S = A ? T.filter(A) : T;
1738
- if (S.length !== 0)
1739
- return c ? S : S[0];
1745
+ function p(d, c, w, S) {
1746
+ const E = w || !!S, C = o.getAt(d, c, E).map((M) => n.getAnnotation(M)), O = S ? C.filter(S) : C;
1747
+ if (O.length !== 0)
1748
+ return w ? O : O[0];
1740
1749
  }
1741
- const g = (y, d, c, A = 5) => {
1742
- const E = o.getAnnotationRects(y);
1743
- if (E.length !== 0) {
1744
- if (d && c) {
1745
- const T = E.find(({ top: S, right: O, bottom: M, left: L }) => d >= L - A && d <= O + A && c >= S - A && c <= M + A);
1746
- if (T) return T;
1747
- }
1748
- return o.getAnnotationBounds(y);
1749
- }
1750
- }, b = (y) => o.getAnnotationRects(y), w = () => o.recalculate();
1751
- return n.observe(({ changes: y }) => {
1752
- const d = (y.deleted || []).filter((E) => F(E.target.selector)), c = (y.created || []).filter((E) => F(E.target.selector)), A = (y.updated || []).filter((E) => F(E.newValue.target.selector));
1753
- (d == null ? void 0 : d.length) > 0 && d.forEach((E) => o.remove(E.target)), c.length > 0 && o.set(c.map((E) => E.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: E }) => o.update(E.target));
1750
+ const g = (d) => {
1751
+ if (o.getAnnotationRects(d).length !== 0)
1752
+ return o.getAnnotationBounds(d);
1753
+ }, y = (d, c, w, S) => o.getIntersecting(d, c, w, S), b = (d) => o.getAnnotationRects(d), v = () => o.recalculate();
1754
+ return n.observe(({ changes: d }) => {
1755
+ const c = (d.deleted || []).filter((E) => F(E.target.selector)), w = (d.created || []).filter((E) => F(E.target.selector)), S = (d.updated || []).filter((E) => F(E.newValue.target.selector));
1756
+ (c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), w.length > 0 && o.set(w.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
1754
1757
  }), {
1755
1758
  store: {
1756
1759
  ...n,
@@ -1760,9 +1763,9 @@ const to = (t, e) => {
1760
1763
  bulkUpsertAnnotations: f,
1761
1764
  getAnnotationBounds: g,
1762
1765
  getAnnotationRects: b,
1766
+ getIntersecting: y,
1763
1767
  getAt: p,
1764
- getIntersecting: o.getIntersecting,
1765
- recalculatePositions: w,
1768
+ recalculatePositions: v,
1766
1769
  updateTarget: h
1767
1770
  },
1768
1771
  selection: i,
@@ -1792,10 +1795,10 @@ const to = (t, e) => {
1792
1795
  e.font && (o.font = e.font);
1793
1796
  const g = i.get(h.annotation.id);
1794
1797
  if (g) {
1795
- const { height: b } = h.rects[0], w = h.rects[0].x + u.left, y = h.rects[0].y + u.top;
1796
- o.fillStyle = g.appearance.color, o.fillRect(w - 2, y - 2.5, 2, b + 5);
1797
- const d = o.measureText(g.appearance.label), c = d.width + 6, A = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, E = d.fontBoundingBoxAscent ? 8 : 6.5;
1798
- return o.fillRect(w - 2, y - 2.5 - A, c, A), o.fillStyle = "#fff", o.fillText(g.appearance.label, w + 1, y - E), {
1798
+ const { height: y } = h.rects[0], b = h.rects[0].x + u.left, v = h.rects[0].y + u.top;
1799
+ o.fillStyle = g.appearance.color, o.fillRect(b - 2, v - 2.5, 2, y + 5);
1800
+ const d = o.measureText(g.appearance.label), c = d.width + 6, w = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
1801
+ return o.fillRect(b - 2, v - 2.5 - w, c, w), o.fillStyle = "#fff", o.fillText(g.appearance.label, b + 1, v - S), {
1799
1802
  fill: g.appearance.color,
1800
1803
  fillOpacity: p ? 0.45 : 0.18
1801
1804
  };
@@ -2021,8 +2024,8 @@ const yt = (t) => {
2021
2024
  n || (n = dt());
2022
2025
  const u = l > 1 ? ye(H, r) : [], p = [];
2023
2026
  _[h] = _[h].filter((g) => {
2024
- const w = (o ? g.method === o : !0) && g.scope === n && io(g.mods, u);
2025
- return w && p.push(g.element), !w;
2027
+ const b = (o ? g.method === o : !0) && g.scope === n && io(g.mods, u);
2028
+ return b && p.push(g.element), !b;
2026
2029
  }), p.forEach((g) => Xt(g));
2027
2030
  });
2028
2031
  };
@@ -2088,17 +2091,17 @@ function P(t, e, n) {
2088
2091
  if (typeof a < "u" && window) {
2089
2092
  if (!z.has(a)) {
2090
2093
  const g = function() {
2091
- let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2092
- return oe(w, a);
2093
- }, b = function() {
2094
- let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2095
- oe(w, a), po(w);
2094
+ let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2095
+ return oe(b, a);
2096
+ }, y = function() {
2097
+ let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2098
+ oe(b, a), po(b);
2096
2099
  };
2097
2100
  z.set(a, {
2098
2101
  keydownListener: g,
2099
- keyupListenr: b,
2102
+ keyupListenr: y,
2100
2103
  capture: u
2101
- }), It(a, "keydown", g, u), It(a, "keyup", b, u);
2104
+ }), It(a, "keydown", g, u), It(a, "keyup", y, u);
2102
2105
  }
2103
2106
  if (!ct) {
2104
2107
  const g = () => {
@@ -2175,32 +2178,34 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2175
2178
  Ee
2176
2179
  ], yo = (t, e, n) => {
2177
2180
  let o;
2178
- const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (L) => o = L;
2181
+ const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (T) => o = T;
2179
2182
  let l;
2180
- const f = (L) => l = L, { store: h, selection: u } = e;
2181
- let p, g, b;
2182
- const w = (L) => {
2183
- g !== !1 && (p = it(L.target) ? void 0 : {
2183
+ const f = (T) => l = T, { store: h, selection: u } = e;
2184
+ let p, g, y;
2185
+ const b = (T) => {
2186
+ g !== !1 && (p = it(T.target) ? void 0 : {
2184
2187
  annotation: fe(),
2185
2188
  selector: [],
2186
2189
  creator: o,
2187
2190
  created: /* @__PURE__ */ new Date()
2188
2191
  });
2189
- }, y = Yt((L) => {
2192
+ }, v = Yt((T) => {
2190
2193
  const m = document.getSelection();
2194
+ if (!(m != null && m.anchorNode))
2195
+ return;
2191
2196
  if (it(m.anchorNode)) {
2192
2197
  p = void 0;
2193
2198
  return;
2194
2199
  }
2195
- const v = L.timeStamp - ((b == null ? void 0 : b.timeStamp) || L.timeStamp);
2196
- if ((b == null ? void 0 : b.type) === "pointerdown" && (v < 1e3 && !p || m.isCollapsed && v < ie) && w(b || L), !p) return;
2200
+ const x = T.timeStamp - ((y == null ? void 0 : y.timeStamp) || T.timeStamp);
2201
+ if ((y == null ? void 0 : y.type) === "pointerdown" && (x < 1e3 && !p || m.isCollapsed && x < ie) && b(y || T), !p) return;
2197
2202
  if (m.isCollapsed) {
2198
2203
  h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
2199
2204
  return;
2200
2205
  }
2201
- const x = m.getRangeAt(0), C = Ye(x, t);
2202
- if (Ie(C)) return;
2203
- const B = Be(C.cloneRange());
2206
+ const A = m.getRangeAt(0), L = Ye(A, t);
2207
+ if (Ie(L)) return;
2208
+ const B = Be(L.cloneRange());
2204
2209
  (B.length !== p.selector.length || B.some((N, U) => {
2205
2210
  var et;
2206
2211
  return N.toString() !== ((et = p.selector[U]) == null ? void 0 : et.quote);
@@ -2209,49 +2214,49 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2209
2214
  selector: B.map((N) => Ve(N, t, s)),
2210
2215
  updated: /* @__PURE__ */ new Date()
2211
2216
  }, h.getAnnotation(p.annotation) ? h.updateTarget(p, k.LOCAL) : u.clear());
2212
- }), d = (L) => {
2213
- it(L.target) || (b = At(L), g = b.button === 0);
2214
- }, c = (L) => {
2215
- if (it(L.target) || !g) return;
2217
+ }), d = (T) => {
2218
+ it(T.target) || (y = At(T), g = y.button === 0);
2219
+ }, c = (T) => {
2220
+ if (it(T.target) || !g) return;
2216
2221
  const m = () => {
2217
- const { x, y: C } = t.getBoundingClientRect(), B = L.target instanceof Node && t.contains(L.target) && h.getAt(L.clientX - x, L.clientY - C, a === "all", l);
2222
+ const { x: A, y: L } = t.getBoundingClientRect(), B = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - A, T.clientY - L, a === "all", l);
2218
2223
  if (B) {
2219
2224
  const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(B) ? B.map((q) => q.id) : [B.id];
2220
- (N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U, L);
2225
+ (N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U, T);
2221
2226
  } else
2222
2227
  u.clear();
2223
- }, v = L.timeStamp - b.timeStamp;
2228
+ }, x = T.timeStamp - y.timeStamp;
2224
2229
  setTimeout(() => {
2225
- const x = document.getSelection();
2226
- x != null && x.isCollapsed && v < ie ? (p = void 0, m()) : p && p.selector.length > 0 && (u.clear(), O(), u.userSelect(p.annotation, At(L)));
2230
+ const A = document.getSelection();
2231
+ A != null && A.isCollapsed && x < ie ? (p = void 0, m()) : p && p.selector.length > 0 && (O(), u.userSelect(p.annotation, At(T)));
2227
2232
  });
2228
- }, A = (L) => {
2233
+ }, w = (T) => {
2229
2234
  const m = document.getSelection();
2230
- m != null && m.isCollapsed || ((!p || p.selector.length === 0) && y(L), O(), u.userSelect(p.annotation, At(L)));
2231
- }, E = (L) => {
2232
- L.key === "Shift" && p && (document.getSelection().isCollapsed || (u.clear(), O(), u.userSelect(p.annotation, ft(L))));
2233
- }, T = (L) => {
2235
+ m != null && m.isCollapsed || ((!p || p.selector.length === 0) && v(T), O(), u.userSelect(p.annotation, At(T)));
2236
+ }, S = (T) => {
2237
+ T.key === "Shift" && p && (document.getSelection().isCollapsed || (O(), u.userSelect(p.annotation, ft(T))));
2238
+ }, E = (T) => {
2234
2239
  const m = () => setTimeout(() => {
2235
2240
  (p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
2236
2241
  id: p.annotation,
2237
2242
  bodies: [],
2238
2243
  target: p
2239
- }), u.userSelect(p.annotation, ft(L))), document.removeEventListener("selectionchange", m);
2244
+ }), u.userSelect(p.annotation, ft(T))), document.removeEventListener("selectionchange", m);
2240
2245
  }, 100);
2241
- document.addEventListener("selectionchange", m), w(L);
2246
+ document.addEventListener("selectionchange", m), b(T);
2242
2247
  };
2243
- P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (L) => {
2244
- L.repeat || (b = ft(L));
2245
- }), P(Ee, { keydown: !0, keyup: !1 }, (L) => {
2246
- b = ft(L), T(L);
2248
+ P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
2249
+ T.repeat || (y = ft(T));
2250
+ }), P(Ee, { keydown: !0, keyup: !1 }, (T) => {
2251
+ y = ft(T), E(T);
2247
2252
  });
2248
- const S = (L) => {
2249
- L.repeat || L.target !== t && L.target !== document.body || (p = void 0, u.clear());
2253
+ const C = (T) => {
2254
+ T.repeat || T.target !== t && T.target !== document.body || (p = void 0, u.clear());
2250
2255
  };
2251
- P(ve.join(","), { keydown: !0, keyup: !1 }, S);
2256
+ P(ve.join(","), { keydown: !0, keyup: !1 }, C);
2252
2257
  const O = () => {
2253
- const L = h.getAnnotation(p.annotation);
2254
- if (!L) {
2258
+ const T = h.getAnnotation(p.annotation);
2259
+ if (!T) {
2255
2260
  h.addAnnotation({
2256
2261
  id: p.annotation,
2257
2262
  bodies: [],
@@ -2259,12 +2264,12 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2259
2264
  });
2260
2265
  return;
2261
2266
  }
2262
- const { target: { updated: m } } = L, { updated: v } = p;
2263
- (!m || !v || m < v) && h.updateTarget(p);
2267
+ const { target: { updated: m } } = T, { updated: x } = p;
2268
+ (!m || !x || m < x) && h.updateTarget(p);
2264
2269
  };
2265
- return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", A), i && (t.addEventListener("keyup", E), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", y)), {
2270
+ return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", w), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", b), document.addEventListener("selectionchange", v)), {
2266
2271
  destroy: () => {
2267
- t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", E), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", y), P.unbind();
2272
+ t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", w), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", b), document.removeEventListener("selectionchange", v), P.unbind();
2268
2273
  },
2269
2274
  setFilter: f,
2270
2275
  setUser: r
@@ -2273,7 +2278,7 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2273
2278
  ...t,
2274
2279
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
2275
2280
  user: t.user || e.user
2276
- }), se = "SPANS", xo = (t, e = {}) => {
2281
+ }), se = "SPANS", vo = (t, e = {}) => {
2277
2282
  Le(t), Oe(t);
2278
2283
  const n = bo(e, {
2279
2284
  annotatingEnabled: !0,
@@ -2292,20 +2297,20 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2292
2297
  },
2293
2298
  element: t,
2294
2299
  getUser: () => f,
2295
- setFilter: (S) => {
2296
- u.setFilter(S), p.setFilter(S);
2300
+ setFilter: (C) => {
2301
+ u.setFilter(C), p.setFilter(C);
2297
2302
  },
2298
- setStyle: (S) => u.setStyle(S),
2299
- setUser: (S) => {
2300
- f = S, p.setUser(S);
2303
+ setStyle: (C) => u.setStyle(C),
2304
+ setUser: (C) => {
2305
+ f = C, p.setUser(C);
2301
2306
  },
2302
- setSelected: (S) => {
2303
- S ? i.setSelected(S) : i.clear();
2307
+ setSelected: (C) => {
2308
+ C ? i.setSelected(C) : i.clear();
2304
2309
  },
2305
- setPresenceProvider: (S) => {
2306
- S && (u.setPainter(oo(S, n.presence)), S.on("selectionChange", () => u.redraw()));
2310
+ setPresenceProvider: (C) => {
2311
+ C && (u.setPainter(oo(C, n.presence)), C.on("selectionChange", () => u.redraw()));
2307
2312
  },
2308
- setVisible: (S) => u.setVisible(S),
2313
+ setVisible: (C) => u.setVisible(C),
2309
2314
  on: l.on,
2310
2315
  off: l.off,
2311
2316
  scrollIntoView: Ke(t, a),
@@ -2320,17 +2325,17 @@ export {
2320
2325
  k as Origin,
2321
2326
  yo as SelectionHandler,
2322
2327
  hn as UserSelectAction,
2323
- Ao as W3CTextFormat,
2328
+ xo as W3CTextFormat,
2324
2329
  Le as cancelSingleClickEvents,
2325
2330
  ft as cloneKeyboardEvent,
2326
2331
  At as clonePointerEvent,
2327
- wo as createBody,
2332
+ Ao as createBody,
2328
2333
  ze as createCanvasRenderer,
2329
2334
  nn as createHighlightsRenderer,
2330
2335
  oo as createPresencePainter,
2331
2336
  en as createRenderer,
2332
2337
  rn as createSpansRenderer,
2333
- xo as createTextAnnotator,
2338
+ vo as createTextAnnotator,
2334
2339
  eo as createTextAnnotatorState,
2335
2340
  Yt as debounce,
2336
2341
  bo as fillDefaults,
@@ -2352,6 +2357,7 @@ export {
2352
2357
  Ke as scrollIntoView,
2353
2358
  zn as serializeW3CTextAnnotation,
2354
2359
  Be as splitAnnotatableRanges,
2360
+ wo as toDomRectList,
2355
2361
  Ye as trimRangeToContainer,
2356
2362
  ke as whitespaceOrEmptyRegex
2357
2363
  };