@soomo/text-annotator 3.0.0-staging.54 → 3.0.0-staging.55

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.
@@ -265,20 +265,20 @@ const Ie = /* @__PURE__ */ Be(ke), Ut = (t, e = 10, n) => {
265
265
  const { store: i, selection: r, hover: a } = e;
266
266
  let s, l, f;
267
267
  const h = Ce(n), c = (O) => {
268
- const { x: R, y: m } = t.getBoundingClientRect(), v = i.getAt(O.clientX - R, O.clientY - m, l);
269
- v ? a.current !== v.id && (t.classList.add("hovered"), a.set(v.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
268
+ const { x: R, y: m } = t.getBoundingClientRect(), A = i.getAt(O.clientX - R, O.clientY - m, l);
269
+ A ? a.current !== A.id && (t.classList.add("hovered"), a.set(A.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
270
270
  };
271
271
  t.addEventListener("pointermove", c);
272
272
  const g = (O = !1) => {
273
273
  f && f.clear();
274
- const R = Se(t), { minX: m, minY: v, maxX: x, maxY: L } = R, B = l ? i.getIntersecting(m, v, x, L).filter(({ annotation: Y }) => l(Y)) : i.getIntersecting(m, v, x, L), M = r.selected.map(({ id: Y }) => Y), K = B.map(({ annotation: Y, rects: lt }) => {
274
+ const R = Se(t), { minX: m, minY: A, maxX: v, maxY: L } = R, B = l ? i.getIntersecting(m, A, v, L).filter(({ annotation: Y }) => l(Y)) : i.getIntersecting(m, A, v, L), M = r.selected.map(({ id: Y }) => Y), K = B.map(({ annotation: Y, rects: lt }) => {
275
275
  const Ae = M.includes(Y.id), xe = Y.id === a.current;
276
276
  return { annotation: Y, rects: lt, state: { selected: Ae, hover: xe } };
277
277
  });
278
278
  o.redraw(K, R, s, f, O), setTimeout(() => h(B.map(({ annotation: Y }) => Y)), 1);
279
279
  }, u = (O) => {
280
280
  f = O, g();
281
- }, A = (O) => {
281
+ }, x = (O) => {
282
282
  s = O, g();
283
283
  }, b = (O) => {
284
284
  l = O, g(!1);
@@ -300,7 +300,7 @@ const Ie = /* @__PURE__ */ Be(ke), Ut = (t, e = 10, n) => {
300
300
  t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(C), p(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), S.disconnect(), w.disconnect();
301
301
  },
302
302
  redraw: g,
303
- setStyle: A,
303
+ setStyle: x,
304
304
  setFilter: b,
305
305
  setPainter: u,
306
306
  setVisible: o.setVisible
@@ -317,14 +317,14 @@ const Ie = /* @__PURE__ */ Be(ke), Ut = (t, e = 10, n) => {
317
317
  const o = (s, l, f, h) => requestAnimationFrame(() => {
318
318
  const { width: c, height: g } = e;
319
319
  n.clearRect(-0.5, -0.5, c + 1, g + 1), h && h.clear();
320
- const { top: u, left: A } = l;
320
+ const { top: u, left: x } = l;
321
321
  [...s].sort((C, p) => {
322
322
  const { annotation: { target: { created: d } } } = C, { annotation: { target: { created: y } } } = p;
323
323
  return d.getTime() - y.getTime();
324
324
  }).forEach((C) => {
325
325
  var S;
326
326
  const p = f ? typeof f == "function" ? f(C.annotation, C.state) : f : (S = C.state) != null && S.selected ? yt : q, d = h && h.paint(C, l) || p, y = C.rects.map(({ x: E, y: w, width: T, height: O }) => ({
327
- x: E + A,
327
+ x: E + x,
328
328
  y: w + u,
329
329
  width: T,
330
330
  height: O
@@ -502,13 +502,13 @@ const nn = (t) => [
502
502
  const f = new Set(r.map((c) => c.annotation.id));
503
503
  Array.from(e).filter((c) => !f.has(c));
504
504
  const h = r.map((c) => {
505
- var A;
506
- const g = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (A = c.state) != null && A.selected ? yt : q, u = l && l.paint(c, a) || g;
505
+ var x;
506
+ const g = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? yt : q, u = l && l.paint(c, a) || g;
507
507
  return `::highlight(_${c.annotation.id}) { ${nn(u)} }`;
508
508
  });
509
509
  t.innerHTML = h.join(`
510
510
  `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
511
- const g = c.target.selector.map((A) => A.range), u = new Highlight(...g);
511
+ const g = c.target.selector.map((x) => x.range), u = new Highlight(...g);
512
512
  CSS.highlights.set(`_${c.id}`, u);
513
513
  }), e = f;
514
514
  }
@@ -550,15 +550,15 @@ const sn = (t, e) => {
550
550
  redraw: (a, s, l, f, h) => {
551
551
  const g = !(It(n, a) && h);
552
552
  if (!f && !g) return;
553
- g && (e.innerHTML = ""), [...a].sort((A, b) => {
554
- const { annotation: { target: { created: C } } } = A, { annotation: { target: { created: p } } } = b;
555
- return console.log(A.annotation), console.log(b.annotation), C && p ? C.getTime() - p.getTime() : 0;
556
- }).forEach((A) => {
557
- A.rects.map((b) => {
558
- const C = sn(b, a), p = Ee(A, s, l, f, C);
553
+ g && (e.innerHTML = ""), [...a].sort((x, b) => {
554
+ const { annotation: { target: { created: C } } } = x, { annotation: { target: { created: p } } } = b;
555
+ return console.log(x.annotation), console.log(b.annotation), C && p ? C.getTime() - p.getTime() : 0;
556
+ }).forEach((x) => {
557
+ x.rects.map((b) => {
558
+ const C = sn(b, a), p = Ee(x, s, l, f, C);
559
559
  if (g) {
560
560
  const d = document.createElement("span");
561
- d.className = "r6o-annotation", d.dataset.annotation = A.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = P((p == null ? void 0 : p.fill) || q.fill).alpha((p == null ? void 0 : p.fillOpacity) === void 0 ? q.fillOpacity : p.fillOpacity).toHex(), p.underlineStyle && (d.style.borderStyle = p.underlineStyle), p.underlineColor && (d.style.borderColor = p.underlineColor), p.underlineThickness && (d.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (d.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(d);
561
+ d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = P((p == null ? void 0 : p.fill) || q.fill).alpha((p == null ? void 0 : p.fillOpacity) === void 0 ? q.fillOpacity : p.fillOpacity).toHex(), p.underlineStyle && (d.style.borderStyle = p.underlineStyle), p.underlineColor && (d.style.borderColor = p.underlineColor), p.underlineThickness && (d.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (d.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(d);
562
562
  }
563
563
  });
564
564
  }), n = a;
@@ -674,9 +674,9 @@ const ft = { selected: [] }, mn = (t, e) => {
674
674
  }, l = (u) => {
675
675
  if (s())
676
676
  return !1;
677
- const A = typeof u == "string" ? u : u.id;
678
- return r.selected.some((b) => b.id === A);
679
- }, f = (u, A) => {
677
+ const x = typeof u == "string" ? u : u.id;
678
+ return r.selected.some((b) => b.id === x);
679
+ }, f = (u, x) => {
680
680
  const b = t.getAnnotation(u);
681
681
  if (!b) {
682
682
  console.warn("Invalid selection: " + u);
@@ -684,30 +684,30 @@ const ft = { selected: [] }, mn = (t, e) => {
684
684
  }
685
685
  switch (Qt(b, i)) {
686
686
  case "EDIT":
687
- o({ selected: [{ id: u, editable: !0 }], event: A });
687
+ o({ selected: [{ id: u, editable: !0 }], event: x });
688
688
  break;
689
689
  case "SELECT":
690
- o({ selected: [{ id: u }], event: A });
690
+ o({ selected: [{ id: u }], event: x });
691
691
  break;
692
692
  default:
693
- o({ selected: [], event: A });
693
+ o({ selected: [], event: x });
694
694
  }
695
- }, h = (u, A) => {
695
+ }, h = (u, x) => {
696
696
  const b = Array.isArray(u) ? u : [u], C = b.map((p) => t.getAnnotation(p)).filter((p) => !!p);
697
697
  o({
698
698
  selected: C.map((p) => {
699
- const d = A === void 0 ? Qt(p, i) === "EDIT" : A;
699
+ const d = x === void 0 ? Qt(p, i) === "EDIT" : x;
700
700
  return { id: p.id, editable: d };
701
701
  })
702
702
  }), C.length !== b.length && console.warn("Invalid selection", u);
703
703
  }, c = (u) => {
704
704
  if (s())
705
705
  return !1;
706
- const { selected: A } = r;
707
- A.some(({ id: b }) => u.includes(b)) && o({ selected: A.filter(({ id: b }) => !u.includes(b)) });
706
+ const { selected: x } = r;
707
+ x.some(({ id: b }) => u.includes(b)) && o({ selected: x.filter(({ id: b }) => !u.includes(b)) });
708
708
  }, g = (u) => i = u;
709
709
  return t.observe(
710
- ({ changes: u }) => c((u.deleted || []).map((A) => A.id))
710
+ ({ changes: u }) => c((u.deleted || []).map((x) => x.id))
711
711
  ), {
712
712
  get event() {
713
713
  return r ? r.event : null;
@@ -810,8 +810,8 @@ const Cn = (t, e) => {
810
810
  ...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
811
811
  const { oldValue: g, newValue: u } = c;
812
812
  if (a.has(u.id)) {
813
- const A = e.updated.find((b) => b.oldValue.id === u.id).newValue;
814
- return fe(g, A);
813
+ const x = e.updated.find((b) => b.oldValue.id === u.id).newValue;
814
+ return fe(g, x);
815
815
  } else
816
816
  return c;
817
817
  }),
@@ -833,71 +833,71 @@ const Cn = (t, e) => {
833
833
  }
834
834
  };
835
835
  }, On = (t) => t.id !== void 0, Tn = () => {
836
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, v = {}) => {
837
- n.push({ onChange: m, options: v });
836
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, A = {}) => {
837
+ n.push({ onChange: m, options: A });
838
838
  }, i = (m) => {
839
- const v = n.findIndex((x) => x.onChange == m);
840
- v > -1 && n.splice(v, 1);
841
- }, r = (m, v) => {
842
- const x = {
839
+ const A = n.findIndex((v) => v.onChange == m);
840
+ A > -1 && n.splice(A, 1);
841
+ }, r = (m, A) => {
842
+ const v = {
843
843
  origin: m,
844
844
  changes: {
845
- created: v.created || [],
846
- updated: v.updated || [],
847
- deleted: v.deleted || []
845
+ created: A.created || [],
846
+ updated: A.updated || [],
847
+ deleted: A.deleted || []
848
848
  },
849
849
  state: [...t.values()]
850
850
  };
851
851
  n.forEach((L) => {
852
- Cn(L, x) && L.onChange(x);
852
+ Cn(L, v) && L.onChange(v);
853
853
  });
854
- }, a = (m, v = k.LOCAL) => {
854
+ }, a = (m, A = k.LOCAL) => {
855
855
  if (m.id && t.get(m.id))
856
856
  throw Error(`Cannot add annotation ${m.id} - exists already`);
857
857
  {
858
- const x = Lt(m);
859
- t.set(x.id, x), x.bodies.forEach((L) => e.set(L.id, x.id)), r(v, { created: [x] });
858
+ const v = Lt(m);
859
+ t.set(v.id, v), v.bodies.forEach((L) => e.set(L.id, v.id)), r(A, { created: [v] });
860
860
  }
861
- }, s = (m, v) => {
862
- const x = Lt(typeof m == "string" ? v : m), L = typeof m == "string" ? m : m.id, B = L && t.get(L);
861
+ }, s = (m, A) => {
862
+ const v = Lt(typeof m == "string" ? A : m), L = typeof m == "string" ? m : m.id, B = L && t.get(L);
863
863
  if (B) {
864
- const M = fe(B, x);
865
- return L === x.id ? t.set(L, x) : (t.delete(L), t.set(x.id, x)), B.bodies.forEach((K) => e.delete(K.id)), x.bodies.forEach((K) => e.set(K.id, x.id)), M;
864
+ const M = fe(B, v);
865
+ return L === v.id ? t.set(L, v) : (t.delete(L), t.set(v.id, v)), B.bodies.forEach((K) => e.delete(K.id)), v.bodies.forEach((K) => e.set(K.id, v.id)), M;
866
866
  } else
867
867
  console.warn(`Cannot update annotation ${L} - does not exist`);
868
- }, l = (m, v = k.LOCAL, x = k.LOCAL) => {
869
- const L = On(v) ? x : v, B = s(m, v);
868
+ }, l = (m, A = k.LOCAL, v = k.LOCAL) => {
869
+ const L = On(A) ? v : A, B = s(m, A);
870
870
  B && r(L, { updated: [B] });
871
- }, f = (m, v = k.LOCAL) => {
872
- const x = m.reduce((L, B) => {
871
+ }, f = (m, A = k.LOCAL) => {
872
+ const v = m.reduce((L, B) => {
873
873
  const M = s(B);
874
874
  return M ? [...L, M] : L;
875
875
  }, []);
876
- x.length > 0 && r(v, { updated: x });
877
- }, h = (m, v = k.LOCAL) => {
878
- const x = t.get(m.annotation);
879
- if (x) {
876
+ v.length > 0 && r(A, { updated: v });
877
+ }, h = (m, A = k.LOCAL) => {
878
+ const v = t.get(m.annotation);
879
+ if (v) {
880
880
  const L = {
881
- ...x,
882
- bodies: [...x.bodies, m]
881
+ ...v,
882
+ bodies: [...v.bodies, m]
883
883
  };
884
- t.set(x.id, L), e.set(m.id, L.id), r(v, { updated: [{
885
- oldValue: x,
884
+ t.set(v.id, L), e.set(m.id, L.id), r(A, { updated: [{
885
+ oldValue: v,
886
886
  newValue: L,
887
887
  bodiesCreated: [m]
888
888
  }] });
889
889
  } else
890
890
  console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
891
891
  }, c = () => [...t.values()], g = (m = k.LOCAL) => {
892
- const v = [...t.values()];
893
- t.clear(), e.clear(), r(m, { deleted: v });
894
- }, u = (m, v = !0, x = k.LOCAL) => {
892
+ const A = [...t.values()];
893
+ t.clear(), e.clear(), r(m, { deleted: A });
894
+ }, u = (m, A = !0, v = k.LOCAL) => {
895
895
  const L = m.map(Lt);
896
- if (v) {
896
+ if (A) {
897
897
  const B = [...t.values()];
898
898
  t.clear(), e.clear(), L.forEach((M) => {
899
899
  t.set(M.id, M), M.bodies.forEach((K) => e.set(K.id, M.id));
900
- }), r(x, { created: L, deleted: B });
900
+ }), r(v, { created: L, deleted: B });
901
901
  } else {
902
902
  const B = m.reduce((M, K) => {
903
903
  const Y = K.id && t.get(K.id);
@@ -907,96 +907,96 @@ const Cn = (t, e) => {
907
907
  throw Error(`Bulk insert would overwrite the following annotations: ${B.map((M) => M.id).join(", ")}`);
908
908
  L.forEach((M) => {
909
909
  t.set(M.id, M), M.bodies.forEach((K) => e.set(K.id, M.id));
910
- }), r(x, { created: L });
910
+ }), r(v, { created: L });
911
911
  }
912
- }, A = (m) => {
913
- const v = typeof m == "string" ? m : m.id, x = t.get(v);
914
- if (x)
915
- return t.delete(v), x.bodies.forEach((L) => e.delete(L.id)), x;
916
- console.warn(`Attempt to delete missing annotation: ${v}`);
917
- }, b = (m, v = k.LOCAL) => {
918
- const x = A(m);
919
- x && r(v, { deleted: [x] });
920
- }, C = (m, v = k.LOCAL) => {
921
- const x = m.reduce((L, B) => {
922
- const M = A(B);
912
+ }, x = (m) => {
913
+ const A = typeof m == "string" ? m : m.id, v = t.get(A);
914
+ if (v)
915
+ return t.delete(A), v.bodies.forEach((L) => e.delete(L.id)), v;
916
+ console.warn(`Attempt to delete missing annotation: ${A}`);
917
+ }, b = (m, A = k.LOCAL) => {
918
+ const v = x(m);
919
+ v && r(A, { deleted: [v] });
920
+ }, C = (m, A = k.LOCAL) => {
921
+ const v = m.reduce((L, B) => {
922
+ const M = x(B);
923
923
  return M ? [...L, M] : L;
924
924
  }, []);
925
- x.length > 0 && r(v, { deleted: x });
925
+ v.length > 0 && r(A, { deleted: v });
926
926
  }, p = (m) => {
927
- const v = t.get(m.annotation);
928
- if (v) {
929
- const x = v.bodies.find((L) => L.id === m.id);
930
- if (x) {
931
- e.delete(x.id);
927
+ const A = t.get(m.annotation);
928
+ if (A) {
929
+ const v = A.bodies.find((L) => L.id === m.id);
930
+ if (v) {
931
+ e.delete(v.id);
932
932
  const L = {
933
- ...v,
934
- bodies: v.bodies.filter((B) => B.id !== m.id)
933
+ ...A,
934
+ bodies: A.bodies.filter((B) => B.id !== m.id)
935
935
  };
936
- return t.set(v.id, L), {
937
- oldValue: v,
936
+ return t.set(A.id, L), {
937
+ oldValue: A,
938
938
  newValue: L,
939
- bodiesDeleted: [x]
939
+ bodiesDeleted: [v]
940
940
  };
941
941
  } else
942
942
  console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
943
943
  } else
944
944
  console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
945
- }, d = (m, v = k.LOCAL) => {
946
- const x = p(m);
947
- x && r(v, { updated: [x] });
948
- }, y = (m, v = k.LOCAL) => {
949
- const x = m.map((L) => p(L)).filter(Boolean);
950
- x.length > 0 && r(v, { updated: x });
945
+ }, d = (m, A = k.LOCAL) => {
946
+ const v = p(m);
947
+ v && r(A, { updated: [v] });
948
+ }, y = (m, A = k.LOCAL) => {
949
+ const v = m.map((L) => p(L)).filter(Boolean);
950
+ v.length > 0 && r(A, { updated: v });
951
951
  }, S = (m) => {
952
- const v = t.get(m);
953
- return v ? { ...v } : void 0;
952
+ const A = t.get(m);
953
+ return A ? { ...A } : void 0;
954
954
  }, E = (m) => {
955
- const v = e.get(m);
956
- if (v) {
957
- const x = S(v).bodies.find((L) => L.id === m);
958
- if (x)
959
- return x;
955
+ const A = e.get(m);
956
+ if (A) {
957
+ const v = S(A).bodies.find((L) => L.id === m);
958
+ if (v)
959
+ return v;
960
960
  console.error(`Store integrity error: body ${m} in index, but not in annotation`);
961
961
  } else
962
962
  console.warn(`Attempt to retrieve missing body: ${m}`);
963
- }, w = (m, v) => {
964
- if (m.annotation !== v.annotation)
963
+ }, w = (m, A) => {
964
+ if (m.annotation !== A.annotation)
965
965
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
966
- const x = t.get(m.annotation);
967
- if (x) {
968
- const L = x.bodies.find((M) => M.id === m.id), B = {
969
- ...x,
970
- bodies: x.bodies.map((M) => M.id === L.id ? v : M)
966
+ const v = t.get(m.annotation);
967
+ if (v) {
968
+ const L = v.bodies.find((M) => M.id === m.id), B = {
969
+ ...v,
970
+ bodies: v.bodies.map((M) => M.id === L.id ? A : M)
971
971
  };
972
- return t.set(x.id, B), L.id !== v.id && (e.delete(L.id), e.set(v.id, B.id)), {
973
- oldValue: x,
972
+ return t.set(v.id, B), L.id !== A.id && (e.delete(L.id), e.set(A.id, B.id)), {
973
+ oldValue: v,
974
974
  newValue: B,
975
- bodiesUpdated: [{ oldBody: L, newBody: v }]
975
+ bodiesUpdated: [{ oldBody: L, newBody: A }]
976
976
  };
977
977
  } else
978
978
  console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
979
- }, T = (m, v, x = k.LOCAL) => {
980
- const L = w(m, v);
981
- L && r(x, { updated: [L] });
982
- }, O = (m, v = k.LOCAL) => {
983
- const x = m.map((L) => w({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
984
- r(v, { updated: x });
979
+ }, T = (m, A, v = k.LOCAL) => {
980
+ const L = w(m, A);
981
+ L && r(v, { updated: [L] });
982
+ }, O = (m, A = k.LOCAL) => {
983
+ const v = m.map((L) => w({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
984
+ r(A, { updated: v });
985
985
  }, R = (m) => {
986
- const v = t.get(m.annotation);
987
- if (v) {
988
- const x = {
989
- ...v,
986
+ const A = t.get(m.annotation);
987
+ if (A) {
988
+ const v = {
989
+ ...A,
990
990
  target: {
991
- ...v.target,
991
+ ...A.target,
992
992
  ...m
993
993
  }
994
994
  };
995
- return t.set(v.id, x), {
996
- oldValue: v,
997
- newValue: x,
995
+ return t.set(A.id, v), {
996
+ oldValue: A,
997
+ newValue: v,
998
998
  targetUpdated: {
999
- oldTarget: v.target,
999
+ oldTarget: A.target,
1000
1000
  newTarget: m
1001
1001
  }
1002
1002
  };
@@ -1012,9 +1012,9 @@ const Cn = (t, e) => {
1012
1012
  bulkDeleteBodies: y,
1013
1013
  bulkUpdateAnnotation: f,
1014
1014
  bulkUpdateBodies: O,
1015
- bulkUpdateTargets: (m, v = k.LOCAL) => {
1016
- const x = m.map((L) => R(L)).filter(Boolean);
1017
- x.length > 0 && r(v, { updated: x });
1015
+ bulkUpdateTargets: (m, A = k.LOCAL) => {
1016
+ const v = m.map((L) => R(L)).filter(Boolean);
1017
+ v.length > 0 && r(A, { updated: v });
1018
1018
  },
1019
1019
  clear: g,
1020
1020
  deleteAnnotation: b,
@@ -1025,9 +1025,9 @@ const Cn = (t, e) => {
1025
1025
  unobserve: i,
1026
1026
  updateAnnotation: l,
1027
1027
  updateBody: T,
1028
- updateTarget: (m, v = k.LOCAL) => {
1029
- const x = R(m);
1030
- x && r(v, { updated: [x] });
1028
+ updateTarget: (m, A = k.LOCAL) => {
1029
+ const v = R(m);
1030
+ v && r(A, { updated: [v] });
1031
1031
  }
1032
1032
  };
1033
1033
  };
@@ -1050,36 +1050,36 @@ const Mn = 250, Bn = (t) => {
1050
1050
  let o = -1, i = !1, r = 0;
1051
1051
  const a = (u) => {
1052
1052
  if (!i) {
1053
- const { changes: A } = u, b = performance.now();
1053
+ const { changes: x } = u, b = performance.now();
1054
1054
  if (b - r > Mn)
1055
- n.splice(o + 1), n.push(A), o = n.length - 1;
1055
+ n.splice(o + 1), n.push(x), o = n.length - 1;
1056
1056
  else {
1057
1057
  const C = n.length - 1;
1058
- n[C] = Ln(n[C], A);
1058
+ n[C] = Ln(n[C], x);
1059
1059
  }
1060
1060
  r = b;
1061
1061
  }
1062
1062
  i = !1;
1063
1063
  };
1064
1064
  t.observe(a, { origin: k.LOCAL });
1065
- const s = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u), l = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), f = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ oldValue: A }) => A)), h = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ newValue: A }) => A)), c = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), g = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u);
1065
+ const s = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u), l = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), f = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ oldValue: x }) => x)), h = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ newValue: x }) => x)), c = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), g = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u);
1066
1066
  return {
1067
1067
  canRedo: () => n.length - 1 > o,
1068
1068
  canUndo: () => o > -1,
1069
1069
  destroy: () => t.unobserve(a),
1070
- on: (u, A) => e.on(u, A),
1070
+ on: (u, x) => e.on(u, x),
1071
1071
  redo: () => {
1072
1072
  if (n.length - 1 > o) {
1073
1073
  i = !0;
1074
- const { created: u, updated: A, deleted: b } = n[o + 1];
1075
- l(u), h(A), g(b), e.emit("redo", n[o + 1]), o += 1;
1074
+ const { created: u, updated: x, deleted: b } = n[o + 1];
1075
+ l(u), h(x), g(b), e.emit("redo", n[o + 1]), o += 1;
1076
1076
  }
1077
1077
  },
1078
1078
  undo: () => {
1079
1079
  if (o > -1) {
1080
1080
  i = !0;
1081
- const { created: u, updated: A, deleted: b } = n[o];
1082
- s(u), f(A), c(b), e.emit("undo", n[o]), o -= 1;
1081
+ const { created: u, updated: x, deleted: b } = n[o];
1082
+ s(u), f(x), c(b), e.emit("undo", n[o]), o -= 1;
1083
1083
  }
1084
1084
  }
1085
1085
  };
@@ -1152,11 +1152,11 @@ const Mn = 250, Bn = (t) => {
1152
1152
  p.length > 0 && (f = f.map((d) => p.find((S) => S.id === d.id) || d));
1153
1153
  }
1154
1154
  }, { origin: k.REMOTE });
1155
- const A = (b) => (C) => {
1155
+ const x = (b) => (C) => {
1156
1156
  const { updated: p } = C;
1157
1157
  b ? (p || []).forEach((d) => u("updateAnnotation", d.oldValue, d.newValue)) : (p || []).forEach((d) => u("updateAnnotation", d.newValue, d.oldValue));
1158
1158
  };
1159
- return e.on("undo", A(!0)), e.on("redo", A(!1)), { on: c, off: g, emit: u };
1159
+ return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: c, off: g, emit: u };
1160
1160
  }, Nn = (t) => (e) => e.reduce((n, o) => {
1161
1161
  const { parsed: i, error: r } = t.parse(o);
1162
1162
  return r ? {
@@ -1198,7 +1198,7 @@ const Mn = 250, Bn = (t) => {
1198
1198
  S.length > 0 && console.warn(`Discarded ${S.length} invalid annotations`, S), o.bulkAddAnnotation(y, d, k.REMOTE);
1199
1199
  } else
1200
1200
  o.bulkAddAnnotation(p, d, k.REMOTE);
1201
- }, A = (p, d) => {
1201
+ }, x = (p, d) => {
1202
1202
  p ? i.setSelected(p, d) : i.clear();
1203
1203
  }, b = (p) => {
1204
1204
  i.clear(), i.setUserSelectAction(p);
@@ -1224,7 +1224,7 @@ const Mn = 250, Bn = (t) => {
1224
1224
  redo: e.redo,
1225
1225
  removeAnnotation: g,
1226
1226
  setAnnotations: u,
1227
- setSelected: A,
1227
+ setSelected: x,
1228
1228
  setUserSelectAction: b,
1229
1229
  undo: e.undo,
1230
1230
  updateAnnotation: C
@@ -1345,14 +1345,14 @@ const Lo = (t, e) => ({
1345
1345
  updated: f,
1346
1346
  ...h
1347
1347
  } = i, c = a.map((g) => {
1348
- const { quote: u, start: A, end: b, range: C } = g, { prefix: p, suffix: d } = Ne(C, n), y = [{
1348
+ const { quote: u, start: x, end: b, range: C } = g, { prefix: p, suffix: d } = Ne(C, n), y = [{
1349
1349
  type: "TextQuoteSelector",
1350
1350
  exact: u,
1351
1351
  prefix: p,
1352
1352
  suffix: d
1353
1353
  }, {
1354
1354
  type: "TextPositionSelector",
1355
- start: A,
1355
+ start: x,
1356
1356
  end: b
1357
1357
  }];
1358
1358
  return {
@@ -1377,8 +1377,8 @@ const Lo = (t, e) => ({
1377
1377
  function ge(t, e, n = 0, o = t.length - 1, i = qn) {
1378
1378
  for (; o > n; ) {
1379
1379
  if (o - n > 600) {
1380
- const l = o - n + 1, f = e - n + 1, h = Math.log(l), c = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * c * (l - c) / l) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + g)), A = Math.min(o, Math.floor(e + (l - f) * c / l + g));
1381
- ge(t, e, u, A, i);
1380
+ const l = o - n + 1, f = e - n + 1, h = Math.log(l), c = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * c * (l - c) / l) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + g)), x = Math.min(o, Math.floor(e + (l - f) * c / l + g));
1381
+ ge(t, e, u, x, i);
1382
1382
  }
1383
1383
  const r = t[e];
1384
1384
  let a = n, s = o;
@@ -1663,12 +1663,12 @@ const oo = (t, e) => {
1663
1663
  return Array.from(O.getClientRects());
1664
1664
  }), w = Ke(E).map((T) => Pe(T, S));
1665
1665
  return w.map((T) => {
1666
- const { x: O, y: R, width: m, height: v } = T;
1666
+ const { x: O, y: R, width: m, height: A } = T;
1667
1667
  return {
1668
1668
  minX: O,
1669
1669
  minY: R,
1670
1670
  maxX: O + m,
1671
- maxY: R + v,
1671
+ maxY: R + A,
1672
1672
  annotation: {
1673
1673
  id: y.annotation,
1674
1674
  rects: w
@@ -1700,7 +1700,7 @@ const oo = (t, e) => {
1700
1700
  }), T = (O) => O.annotation.rects.reduce((R, m) => R + m.width * m.height, 0);
1701
1701
  return w.length > 0 ? (w.sort((O, R) => T(O) - T(R)), E ? w.map((O) => O.annotation.id) : [w[0].annotation.id]) : [];
1702
1702
  }, u = (y) => {
1703
- const S = A(y);
1703
+ const S = x(y);
1704
1704
  if (S.length === 0)
1705
1705
  return;
1706
1706
  let E = S[0].left, w = S[0].top, T = S[0].right, O = S[0].bottom;
@@ -1709,7 +1709,7 @@ const oo = (t, e) => {
1709
1709
  E = Math.min(E, m.left), w = Math.min(w, m.top), T = Math.max(T, m.right), O = Math.max(O, m.bottom);
1710
1710
  }
1711
1711
  return new DOMRect(E, w, T - E, O - w);
1712
- }, A = (y) => {
1712
+ }, x = (y) => {
1713
1713
  const S = o.get(y);
1714
1714
  return S ? S[0].annotation.rects : [];
1715
1715
  };
@@ -1718,12 +1718,12 @@ const oo = (t, e) => {
1718
1718
  clear: s,
1719
1719
  getAt: g,
1720
1720
  getAnnotationBounds: u,
1721
- getAnnotationRects: A,
1721
+ getAnnotationRects: x,
1722
1722
  getIntersecting: (y, S, E, w) => {
1723
1723
  const T = n.search({ minX: y, minY: S, maxX: E, maxY: w }), O = new Set(T.map((R) => R.annotation.id));
1724
1724
  return Array.from(O).map((R) => ({
1725
1725
  annotation: t.getAnnotation(R),
1726
- rects: A(R)
1726
+ rects: x(R)
1727
1727
  })).filter((R) => !!R.annotation);
1728
1728
  },
1729
1729
  insert: l,
@@ -1763,12 +1763,12 @@ const oo = (t, e) => {
1763
1763
  const w = o.getAnnotationRects(d);
1764
1764
  if (w.length !== 0) {
1765
1765
  if (y && S) {
1766
- const T = w.find(({ top: O, right: R, bottom: m, left: v }) => y >= v - E && y <= R + E && S >= O - E && S <= m + E);
1766
+ const T = w.find(({ top: O, right: R, bottom: m, left: A }) => y >= A - E && y <= R + E && S >= O - E && S <= m + E);
1767
1767
  if (T) return T;
1768
1768
  }
1769
1769
  return o.getAnnotationBounds(d);
1770
1770
  }
1771
- }, A = (d, y, S, E) => o.getIntersecting(d, y, S, E), b = (d) => o.getAnnotationRects(d), C = () => o.recalculate(), p = (d) => o.on("recalculate", d);
1771
+ }, x = (d, y, S, E) => o.getIntersecting(d, y, S, E), b = (d) => o.getAnnotationRects(d), C = () => o.recalculate(), p = (d) => o.on("recalculate", d);
1772
1772
  return n.observe(({ changes: d }) => {
1773
1773
  const y = (d.deleted || []).filter((w) => W(w.target.selector)), S = (d.created || []).filter((w) => W(w.target.selector)), E = (d.updated || []).filter((w) => W(w.newValue.target.selector));
1774
1774
  (y == null ? void 0 : y.length) > 0 && y.forEach((w) => o.remove(w.target)), S.length > 0 && o.set(S.map((w) => w.target), !1), (E == null ? void 0 : E.length) > 0 && E.forEach(({ newValue: w }) => o.update(w.target));
@@ -1781,7 +1781,7 @@ const oo = (t, e) => {
1781
1781
  bulkUpsertAnnotations: f,
1782
1782
  getAnnotationBounds: u,
1783
1783
  getAnnotationRects: b,
1784
- getIntersecting: A,
1784
+ getIntersecting: x,
1785
1785
  getAt: g,
1786
1786
  recalculatePositions: C,
1787
1787
  onRecalculatePositions: p,
@@ -2074,15 +2074,15 @@ function $(t, e, n) {
2074
2074
  const u = function() {
2075
2075
  let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2076
2076
  return ee(b, a);
2077
- }, A = function() {
2077
+ }, x = function() {
2078
2078
  let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2079
2079
  ee(b, a), po(b);
2080
2080
  };
2081
2081
  F.set(a, {
2082
2082
  keydownListener: u,
2083
- keyupListenr: A,
2083
+ keyupListenr: x,
2084
2084
  capture: c
2085
- }), Mt(a, "keydown", u, c), Mt(a, "keyup", A, c);
2085
+ }), Mt(a, "keydown", u, c), Mt(a, "keyup", x, c);
2086
2086
  }
2087
2087
  if (!rt) {
2088
2088
  const u = () => {
@@ -2164,7 +2164,7 @@ const ne = 300, yo = (t, e, n) => {
2164
2164
  s = w, b.clear(), w || (c = void 0, g = void 0, u = void 0);
2165
2165
  }, { store: f, selection: h } = e;
2166
2166
  let c, g, u;
2167
- const A = (w) => {
2167
+ const x = (w) => {
2168
2168
  var O;
2169
2169
  if (!s || g === !1) return;
2170
2170
  c = !((O = w.target.parentElement) != null && O.closest(j)) ? {
@@ -2182,20 +2182,20 @@ const ne = 300, yo = (t, e, n) => {
2182
2182
  return;
2183
2183
  }
2184
2184
  const R = w.timeStamp - ((u == null ? void 0 : u.timeStamp) || w.timeStamp);
2185
- if ((u == null ? void 0 : u.type) === "pointerdown" && (R < 1e3 && !c || T.isCollapsed && R < ne) && A(u), !c) return;
2185
+ if ((u == null ? void 0 : u.type) === "pointerdown" && (R < 1e3 && !c || T.isCollapsed && R < ne) && x(u), !c) return;
2186
2186
  if (T.isCollapsed) {
2187
2187
  f.getAnnotation(c.annotation) && (h.clear(), f.deleteAnnotation(c.annotation));
2188
2188
  return;
2189
2189
  }
2190
- const m = T.getRangeAt(0), v = Xe(m, t);
2191
- if (Ue(v)) return;
2192
- const x = Te(v.cloneRange());
2193
- (x.length !== c.selector.length || x.some((K, Y) => {
2190
+ const m = T.getRangeAt(0), A = Xe(m, t);
2191
+ if (Ue(A)) return;
2192
+ const v = Te(A.cloneRange());
2193
+ (v.length !== c.selector.length || v.some((K, Y) => {
2194
2194
  var lt;
2195
2195
  return K.toString() !== ((lt = c.selector[Y]) == null ? void 0 : lt.quote);
2196
2196
  })) && (c = {
2197
2197
  ...c,
2198
- selector: x.map((K) => Ye(K, t, n)),
2198
+ selector: v.map((K) => Ye(K, t, n)),
2199
2199
  updated: /* @__PURE__ */ new Date()
2200
2200
  }, f.getAnnotation(c.annotation) ? f.updateTarget(c, k.LOCAL) : (h.clear(), f.addAnnotation({
2201
2201
  id: c.annotation,
@@ -2205,24 +2205,23 @@ const ne = 300, yo = (t, e, n) => {
2205
2205
  }), C = (w) => {
2206
2206
  u = $e(w), g = u.button === 0;
2207
2207
  }, p = (w) => {
2208
- var m;
2209
- if (!!((m = w.target.parentElement) != null && m.closest(j)) || !g)
2208
+ var A;
2209
+ const T = w.target;
2210
+ if (!!((A = T.parentElement) != null && A.closest(j)) || !g)
2210
2211
  return;
2211
- const O = () => {
2212
- const { x: v, y: x } = t.getBoundingClientRect(), L = w.target instanceof Node && t.contains(w.target) && f.getAt(w.clientX - v, w.clientY - x, r);
2213
- if (L) {
2214
- const { selected: B } = h;
2215
- (B.length !== 1 || B[0].id !== L.id) && h.userSelect(L.id, w);
2212
+ const R = () => {
2213
+ const { x: v, y: L } = t.getBoundingClientRect(), B = w.target instanceof Node && t.contains(w.target) && f.getAt(w.clientX - v, w.clientY - L, r);
2214
+ if (B) {
2215
+ const { selected: M } = h;
2216
+ (M.length !== 1 || M[0].id !== B.id) && h.userSelect(B.id, w);
2216
2217
  } else h.isEmpty() || h.clear();
2217
- };
2218
- document.getSelection();
2219
- const R = w.timeStamp - u.timeStamp;
2218
+ }, m = w.timeStamp - u.timeStamp;
2220
2219
  setTimeout(() => {
2221
2220
  const v = document.getSelection();
2222
- v != null && v.isCollapsed && R < ne ? (c = void 0, O()) : c && f.getAnnotation(c.annotation) && h.userSelect(c.annotation, w);
2221
+ v != null && v.isCollapsed && m < ne ? T !== document.documentElement && (c = void 0, R()) : c && f.getAnnotation(c.annotation) && h.userSelect(c.annotation, w);
2223
2222
  });
2224
2223
  };
2225
- document.addEventListener("pointerdown", C), document.addEventListener("pointerup", p), t.addEventListener("selectstart", A), document.addEventListener("selectionchange", b);
2224
+ document.addEventListener("pointerdown", C), document.addEventListener("pointerup", p), t.addEventListener("selectstart", x), document.addEventListener("selectionchange", b);
2226
2225
  const d = ["up", "down", "left", "right"], y = [
2227
2226
  ...d.map((w) => `shift+${w}`),
2228
2227
  "ctrl+a",
@@ -2236,7 +2235,7 @@ const ne = 300, yo = (t, e, n) => {
2236
2235
  };
2237
2236
  return $(d.join(","), { keydown: !0, keyup: !1 }, S), {
2238
2237
  destroy: () => {
2239
- c = void 0, g = void 0, u = void 0, b.clear(), document.removeEventListener("pointerdown", C), document.removeEventListener("pointerup", p), t.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", b), $.unbind();
2238
+ c = void 0, g = void 0, u = void 0, b.clear(), document.removeEventListener("pointerdown", C), document.removeEventListener("pointerup", p), t.removeEventListener("selectstart", x), document.removeEventListener("selectionchange", b), $.unbind();
2240
2239
  },
2241
2240
  setFilter: a,
2242
2241
  setUser: i,
@@ -2252,7 +2251,7 @@ const ne = 300, yo = (t, e, n) => {
2252
2251
  document.body.appendChild(o);
2253
2252
  const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([g, u]) => u.presenceKey === c.presenceKey).map(([g, u]) => g);
2254
2253
  return e.on("selectionChange", (c, g) => {
2255
- a(c).forEach((A) => r.delete(A)), g && g.forEach((A) => r.set(A, c));
2254
+ a(c).forEach((x) => r.delete(x)), g && g.forEach((x) => r.set(x, c));
2256
2255
  }), {
2257
2256
  clear: () => {
2258
2257
  const { width: c, height: g } = o;
@@ -2263,13 +2262,13 @@ const ne = 300, yo = (t, e, n) => {
2263
2262
  },
2264
2263
  paint: (c, g, u) => {
2265
2264
  n.font && (i.font = n.font);
2266
- const A = r.get(c.annotation.id);
2267
- if (A) {
2265
+ const x = r.get(c.annotation.id);
2266
+ if (x) {
2268
2267
  const { height: b } = c.rects[0], C = c.rects[0].x + g.left, p = c.rects[0].y + g.top;
2269
- i.fillStyle = A.appearance.color, i.fillRect(C - 2, p - 2.5, 2, b + 5);
2270
- const d = i.measureText(A.appearance.label), y = d.width + 6, S = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, E = d.fontBoundingBoxAscent ? 8 : 6.5;
2271
- return i.fillRect(C - 2, p - 2.5 - S, y, S), i.fillStyle = "#fff", i.fillText(A.appearance.label, C + 1, p - E), {
2272
- fill: A.appearance.color,
2268
+ i.fillStyle = x.appearance.color, i.fillRect(C - 2, p - 2.5, 2, b + 5);
2269
+ const d = i.measureText(x.appearance.label), y = d.width + 6, S = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, E = d.fontBoundingBoxAscent ? 8 : 6.5;
2270
+ return i.fillRect(C - 2, p - 2.5 - S, y, S), i.fillStyle = "#fff", i.fillText(x.appearance.label, C + 1, p - E), {
2271
+ fill: x.appearance.color,
2273
2272
  fillOpacity: u ? 0.45 : 0.18
2274
2273
  };
2275
2274
  }
@@ -2287,7 +2286,7 @@ const ne = 300, yo = (t, e, n) => {
2287
2286
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ve(t.parentElement);
2288
2287
  }, vo = (t, e) => (n) => {
2289
2288
  const o = typeof n == "string" ? n : n.id, i = (a) => {
2290
- const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: c, height: g } = e.getAnnotationBounds(o), u = h.top - s.top, A = h.left - s.left, b = r.parentElement ? r.scrollTop : 0, C = r.parentElement ? r.scrollLeft : 0, p = u + b - (l - g) / 2, d = A + C - (f - c) / 2;
2289
+ const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: c, height: g } = e.getAnnotationBounds(o), u = h.top - s.top, x = h.left - s.left, b = r.parentElement ? r.scrollTop : 0, C = r.parentElement ? r.scrollLeft : 0, p = u + b - (l - g) / 2, d = x + C - (f - c) / 2;
2291
2290
  r.scroll({ top: p, left: d, behavior: "smooth" });
2292
2291
  }, r = ve(t);
2293
2292
  if (r) {
@@ -2318,7 +2317,7 @@ const ne = 300, yo = (t, e, n) => {
2318
2317
  console.debug(`Using ${h} renderer`), n.style && c.setStyle(n.style);
2319
2318
  const g = yo(t, o, n.offsetReferenceSelector);
2320
2319
  g.setUser(f), g.setAnnotatingEnabled(n.annotatingEnabled);
2321
- const u = _n(o, s, n.adapter), A = () => f, b = (E) => {
2320
+ const u = _n(o, s, n.adapter), x = () => f, b = (E) => {
2322
2321
  g.setAnnotatingEnabled(
2323
2322
  E === void 0 ? !0 : E
2324
2323
  );
@@ -2337,7 +2336,7 @@ const ne = 300, yo = (t, e, n) => {
2337
2336
  c.destroy(), g.destroy(), s.destroy();
2338
2337
  },
2339
2338
  element: t,
2340
- getUser: A,
2339
+ getUser: x,
2341
2340
  setAnnotatingEnabled: b,
2342
2341
  setFilter: C,
2343
2342
  setStyle: c.setStyle.bind(c),