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

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.
@@ -280,7 +280,7 @@ const Ie = /* @__PURE__ */ Be(ke), Ut = (t, e = 10, n) => {
280
280
  f = O, g();
281
281
  }, x = (O) => {
282
282
  s = O, g();
283
- }, b = (O) => {
283
+ }, w = (O) => {
284
284
  l = O, g(!1);
285
285
  }, C = () => g();
286
286
  i.observe(C);
@@ -292,16 +292,16 @@ const Ie = /* @__PURE__ */ Be(ke), Ut = (t, e = 10, n) => {
292
292
  window.addEventListener("resize", y);
293
293
  const S = new ResizeObserver(y);
294
294
  S.observe(t);
295
- const E = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver((O) => {
295
+ const E = { attributes: !0, childList: !0, subtree: !0 }, b = new MutationObserver((O) => {
296
296
  O.every((m) => m.target === t || t.contains(m.target)) || g(!0);
297
297
  });
298
- return w.observe(document.body, E), {
298
+ return b.observe(document.body, E), {
299
299
  destroy: () => {
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();
300
+ t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(C), p(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), S.disconnect(), b.disconnect();
301
301
  },
302
302
  redraw: g,
303
303
  setStyle: x,
304
- setFilter: b,
304
+ setFilter: w,
305
305
  setPainter: u,
306
306
  setVisible: o.setVisible
307
307
  };
@@ -323,19 +323,19 @@ const Ie = /* @__PURE__ */ Be(ke), Ut = (t, e = 10, n) => {
323
323
  return d.getTime() - y.getTime();
324
324
  }).forEach((C) => {
325
325
  var S;
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 }) => ({
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: b, width: T, height: O }) => ({
327
327
  x: E + x,
328
- y: w + u,
328
+ y: b + u,
329
329
  width: T,
330
330
  height: O
331
331
  }));
332
332
  if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, y.forEach(
333
- ({ x: E, y: w, width: T, height: O }) => n.fillRect(E, w, T, O)
333
+ ({ x: E, y: b, width: T, height: O }) => n.fillRect(E, b, T, O)
334
334
  ), d.underlineColor) {
335
335
  n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
336
336
  const E = d.underlineOffset ?? 0;
337
- y.forEach(({ x: w, y: T, width: O, height: R }) => {
338
- n.beginPath(), n.moveTo(w, T + R + E), n.lineTo(w + O, T + R + E), n.stroke();
337
+ y.forEach(({ x: b, y: T, width: O, height: R }) => {
338
+ n.beginPath(), n.moveTo(b, T + R + E), n.lineTo(b + O, T + R + E), n.stroke();
339
339
  });
340
340
  }
341
341
  });
@@ -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((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;
553
+ g && (e.innerHTML = ""), [...a].sort((x, w) => {
554
+ const { annotation: { target: { created: C } } } = x, { annotation: { target: { created: p } } } = w;
555
+ return C && p ? C.getTime() - p.getTime() : 0;
556
556
  }).forEach((x) => {
557
- x.rects.map((b) => {
558
- const C = sn(b, a), p = Ee(x, s, l, f, C);
557
+ x.rects.map((w) => {
558
+ const C = sn(w, 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 = 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);
561
+ d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${w.x}px`, d.style.top = `${w.y}px`, d.style.width = `${w.width}px`, d.style.height = `${w.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;
@@ -675,14 +675,14 @@ const ft = { selected: [] }, mn = (t, e) => {
675
675
  if (s())
676
676
  return !1;
677
677
  const x = typeof u == "string" ? u : u.id;
678
- return r.selected.some((b) => b.id === x);
678
+ return r.selected.some((w) => w.id === x);
679
679
  }, f = (u, x) => {
680
- const b = t.getAnnotation(u);
681
- if (!b) {
680
+ const w = t.getAnnotation(u);
681
+ if (!w) {
682
682
  console.warn("Invalid selection: " + u);
683
683
  return;
684
684
  }
685
- switch (Qt(b, i)) {
685
+ switch (Qt(w, i)) {
686
686
  case "EDIT":
687
687
  o({ selected: [{ id: u, editable: !0 }], event: x });
688
688
  break;
@@ -693,18 +693,18 @@ const ft = { selected: [] }, mn = (t, e) => {
693
693
  o({ selected: [], event: x });
694
694
  }
695
695
  }, h = (u, x) => {
696
- const b = Array.isArray(u) ? u : [u], C = b.map((p) => t.getAnnotation(p)).filter((p) => !!p);
696
+ const w = Array.isArray(u) ? u : [u], C = w.map((p) => t.getAnnotation(p)).filter((p) => !!p);
697
697
  o({
698
698
  selected: C.map((p) => {
699
699
  const d = x === void 0 ? Qt(p, i) === "EDIT" : x;
700
700
  return { id: p.id, editable: d };
701
701
  })
702
- }), C.length !== b.length && console.warn("Invalid selection", u);
702
+ }), C.length !== w.length && console.warn("Invalid selection", u);
703
703
  }, c = (u) => {
704
704
  if (s())
705
705
  return !1;
706
706
  const { selected: x } = r;
707
- x.some(({ id: b }) => u.includes(b)) && o({ selected: x.filter(({ id: b }) => !u.includes(b)) });
707
+ x.some(({ id: w }) => u.includes(w)) && o({ selected: x.filter(({ id: w }) => !u.includes(w)) });
708
708
  }, g = (u) => i = u;
709
709
  return t.observe(
710
710
  ({ changes: u }) => c((u.deleted || []).map((x) => x.id))
@@ -810,7 +810,7 @@ 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 x = e.updated.find((b) => b.oldValue.id === u.id).newValue;
813
+ const x = e.updated.find((w) => w.oldValue.id === u.id).newValue;
814
814
  return fe(g, x);
815
815
  } else
816
816
  return c;
@@ -914,7 +914,7 @@ const Cn = (t, e) => {
914
914
  if (v)
915
915
  return t.delete(A), v.bodies.forEach((L) => e.delete(L.id)), v;
916
916
  console.warn(`Attempt to delete missing annotation: ${A}`);
917
- }, b = (m, A = k.LOCAL) => {
917
+ }, w = (m, A = k.LOCAL) => {
918
918
  const v = x(m);
919
919
  v && r(A, { deleted: [v] });
920
920
  }, C = (m, A = k.LOCAL) => {
@@ -960,7 +960,7 @@ const Cn = (t, e) => {
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, A) => {
963
+ }, b = (m, A) => {
964
964
  if (m.annotation !== A.annotation)
965
965
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
966
966
  const v = t.get(m.annotation);
@@ -977,10 +977,10 @@ const Cn = (t, e) => {
977
977
  } else
978
978
  console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
979
979
  }, T = (m, A, v = k.LOCAL) => {
980
- const L = w(m, A);
980
+ const L = b(m, A);
981
981
  L && r(v, { updated: [L] });
982
982
  }, O = (m, A = k.LOCAL) => {
983
- const v = m.map((L) => w({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
983
+ const v = m.map((L) => b({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
984
984
  r(A, { updated: v });
985
985
  }, R = (m) => {
986
986
  const A = t.get(m.annotation);
@@ -1017,7 +1017,7 @@ const Cn = (t, e) => {
1017
1017
  v.length > 0 && r(A, { updated: v });
1018
1018
  },
1019
1019
  clear: g,
1020
- deleteAnnotation: b,
1020
+ deleteAnnotation: w,
1021
1021
  deleteBody: d,
1022
1022
  getAnnotation: S,
1023
1023
  getBody: E,
@@ -1050,14 +1050,14 @@ 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: x } = u, b = performance.now();
1054
- if (b - r > Mn)
1053
+ const { changes: x } = u, w = performance.now();
1054
+ if (w - r > Mn)
1055
1055
  n.splice(o + 1), n.push(x), o = n.length - 1;
1056
1056
  else {
1057
1057
  const C = n.length - 1;
1058
1058
  n[C] = Ln(n[C], x);
1059
1059
  }
1060
- r = b;
1060
+ r = w;
1061
1061
  }
1062
1062
  i = !1;
1063
1063
  };
@@ -1071,15 +1071,15 @@ const Mn = 250, Bn = (t) => {
1071
1071
  redo: () => {
1072
1072
  if (n.length - 1 > o) {
1073
1073
  i = !0;
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;
1074
+ const { created: u, updated: x, deleted: w } = n[o + 1];
1075
+ l(u), h(x), g(w), 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: x, deleted: b } = n[o];
1082
- s(u), f(x), c(b), e.emit("undo", n[o]), o -= 1;
1081
+ const { created: u, updated: x, deleted: w } = n[o];
1082
+ s(u), f(x), c(w), e.emit("undo", n[o]), o -= 1;
1083
1083
  }
1084
1084
  }
1085
1085
  };
@@ -1092,17 +1092,17 @@ const Mn = 250, Bn = (t) => {
1092
1092
  }, In = (t, e, n, o) => {
1093
1093
  const { store: i, selection: r, hover: a, viewport: s } = t, l = /* @__PURE__ */ new Map();
1094
1094
  let f = [], h;
1095
- const c = (b, C) => {
1096
- l.has(b) ? l.get(b).push(C) : l.set(b, [C]);
1097
- }, g = (b, C) => {
1098
- const p = l.get(b);
1095
+ const c = (w, C) => {
1096
+ l.has(w) ? l.get(w).push(C) : l.set(w, [C]);
1097
+ }, g = (w, C) => {
1098
+ const p = l.get(w);
1099
1099
  if (p) {
1100
1100
  const d = p.indexOf(C);
1101
1101
  d !== -1 && p.splice(d, 1);
1102
1102
  }
1103
- }, u = (b, C, p) => {
1104
- l.has(b) && setTimeout(() => {
1105
- l.get(b).forEach((d) => {
1103
+ }, u = (w, C, p) => {
1104
+ l.has(w) && setTimeout(() => {
1105
+ l.get(w).forEach((d) => {
1106
1106
  if (n) {
1107
1107
  const y = Array.isArray(C) ? C.map((E) => n.serialize(E)) : n.serialize(C), S = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
1108
1108
  d(y, S);
@@ -1111,17 +1111,17 @@ const Mn = 250, Bn = (t) => {
1111
1111
  });
1112
1112
  }, 1);
1113
1113
  };
1114
- r.subscribe(({ selected: b }) => {
1115
- if (!(f.length === 0 && b.length === 0)) {
1116
- if (f.length === 0 && b.length > 0)
1117
- f = b.map(({ id: C }) => i.getAnnotation(C));
1118
- else if (f.length > 0 && b.length === 0)
1114
+ r.subscribe(({ selected: w }) => {
1115
+ if (!(f.length === 0 && w.length === 0)) {
1116
+ if (f.length === 0 && w.length > 0)
1117
+ f = w.map(({ id: C }) => i.getAnnotation(C));
1118
+ else if (f.length > 0 && w.length === 0)
1119
1119
  f.forEach((C) => {
1120
1120
  const p = i.getAnnotation(C.id);
1121
1121
  p && !G(p, C) && u("updateAnnotation", p, C);
1122
1122
  }), f = [];
1123
1123
  else {
1124
- const C = new Set(f.map((d) => d.id)), p = new Set(b.map(({ id: d }) => d));
1124
+ const C = new Set(f.map((d) => d.id)), p = new Set(w.map(({ id: d }) => d));
1125
1125
  f.filter((d) => !p.has(d.id)).forEach((d) => {
1126
1126
  const y = i.getAnnotation(d.id);
1127
1127
  y && !G(y, d) && u("updateAnnotation", y, d);
@@ -1129,16 +1129,16 @@ const Mn = 250, Bn = (t) => {
1129
1129
  // Remove annotations that were deselected
1130
1130
  ...f.filter((d) => p.has(d.id)),
1131
1131
  // Add editable annotations that were selected
1132
- ...b.filter(({ id: d }) => !C.has(d)).map(({ id: d }) => i.getAnnotation(d))
1132
+ ...w.filter(({ id: d }) => !C.has(d)).map(({ id: d }) => i.getAnnotation(d))
1133
1133
  ];
1134
1134
  }
1135
1135
  u("selectionChanged", f);
1136
1136
  }
1137
- }), a.subscribe((b) => {
1138
- !h && b ? u("mouseEnterAnnotation", i.getAnnotation(b)) : h && !b ? u("mouseLeaveAnnotation", i.getAnnotation(h)) : h && b && (u("mouseLeaveAnnotation", i.getAnnotation(h)), u("mouseEnterAnnotation", i.getAnnotation(b))), h = b;
1139
- }), s == null || s.subscribe((b) => u("viewportIntersect", b.map((C) => i.getAnnotation(C)))), i.observe((b) => {
1140
- const { created: C, deleted: p } = b.changes;
1141
- (C || []).forEach((d) => u("createAnnotation", d)), (p || []).forEach((d) => u("deleteAnnotation", d)), (b.changes.updated || []).filter((d) => [
1137
+ }), a.subscribe((w) => {
1138
+ !h && w ? u("mouseEnterAnnotation", i.getAnnotation(w)) : h && !w ? u("mouseLeaveAnnotation", i.getAnnotation(h)) : h && w && (u("mouseLeaveAnnotation", i.getAnnotation(h)), u("mouseEnterAnnotation", i.getAnnotation(w))), h = w;
1139
+ }), s == null || s.subscribe((w) => u("viewportIntersect", w.map((C) => i.getAnnotation(C)))), i.observe((w) => {
1140
+ const { created: C, deleted: p } = w.changes;
1141
+ (C || []).forEach((d) => u("createAnnotation", d)), (p || []).forEach((d) => u("deleteAnnotation", d)), (w.changes.updated || []).filter((d) => [
1142
1142
  ...d.bodiesCreated || [],
1143
1143
  ...d.bodiesDeleted || [],
1144
1144
  ...d.bodiesUpdated || []
@@ -1146,15 +1146,15 @@ const Mn = 250, Bn = (t) => {
1146
1146
  const S = f.find((E) => E.id === d.id) || d;
1147
1147
  f = f.map((E) => E.id === d.id ? y : E), u("updateAnnotation", y, S);
1148
1148
  });
1149
- }, { origin: k.LOCAL }), i.observe((b) => {
1149
+ }, { origin: k.LOCAL }), i.observe((w) => {
1150
1150
  if (f) {
1151
- const C = new Set(f.map((d) => d.id)), p = (b.changes.updated || []).filter(({ newValue: d }) => C.has(d.id)).map(({ newValue: d }) => d);
1151
+ const C = new Set(f.map((d) => d.id)), p = (w.changes.updated || []).filter(({ newValue: d }) => C.has(d.id)).map(({ newValue: d }) => d);
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 x = (b) => (C) => {
1155
+ const x = (w) => (C) => {
1156
1156
  const { updated: p } = C;
1157
- b ? (p || []).forEach((d) => u("updateAnnotation", d.oldValue, d.newValue)) : (p || []).forEach((d) => u("updateAnnotation", d.newValue, d.oldValue));
1157
+ w ? (p || []).forEach((d) => u("updateAnnotation", d.oldValue, d.newValue)) : (p || []).forEach((d) => u("updateAnnotation", d.newValue, d.oldValue));
1158
1158
  };
1159
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) => {
@@ -1200,7 +1200,7 @@ const Mn = 250, Bn = (t) => {
1200
1200
  o.bulkAddAnnotation(p, d, k.REMOTE);
1201
1201
  }, x = (p, d) => {
1202
1202
  p ? i.setSelected(p, d) : i.clear();
1203
- }, b = (p) => {
1203
+ }, w = (p) => {
1204
1204
  i.clear(), i.setUserSelectAction(p);
1205
1205
  }, C = (p) => {
1206
1206
  if (n) {
@@ -1225,7 +1225,7 @@ const Mn = 250, Bn = (t) => {
1225
1225
  removeAnnotation: g,
1226
1226
  setAnnotations: u,
1227
1227
  setSelected: x,
1228
- setUserSelectAction: b,
1228
+ setUserSelectAction: w,
1229
1229
  undo: e.undo,
1230
1230
  updateAnnotation: C
1231
1231
  };
@@ -1345,7 +1345,7 @@ const Lo = (t, e) => ({
1345
1345
  updated: f,
1346
1346
  ...h
1347
1347
  } = i, c = a.map((g) => {
1348
- const { quote: u, start: x, end: b, range: C } = g, { prefix: p, suffix: d } = Ne(C, n), y = [{
1348
+ const { quote: u, start: x, end: w, range: C } = g, { prefix: p, suffix: d } = Ne(C, n), y = [{
1349
1349
  type: "TextQuoteSelector",
1350
1350
  exact: u,
1351
1351
  prefix: p,
@@ -1353,7 +1353,7 @@ const Lo = (t, e) => ({
1353
1353
  }, {
1354
1354
  type: "TextPositionSelector",
1355
1355
  start: x,
1356
- end: b
1356
+ end: w
1357
1357
  }];
1358
1358
  return {
1359
1359
  ...h,
@@ -1661,8 +1661,8 @@ const oo = (t, e) => {
1661
1661
  const E = y.selector.flatMap((T) => {
1662
1662
  const O = W([T]) ? T.range : se(T, e).range;
1663
1663
  return Array.from(O.getClientRects());
1664
- }), w = Ke(E).map((T) => Pe(T, S));
1665
- return w.map((T) => {
1664
+ }), b = Ke(E).map((T) => Pe(T, S));
1665
+ return b.map((T) => {
1666
1666
  const { x: O, y: R, width: m, height: A } = T;
1667
1667
  return {
1668
1668
  minX: O,
@@ -1671,7 +1671,7 @@ const oo = (t, e) => {
1671
1671
  maxY: R + A,
1672
1672
  annotation: {
1673
1673
  id: y.annotation,
1674
- rects: w
1674
+ rects: b
1675
1675
  }
1676
1676
  };
1677
1677
  });
@@ -1687,28 +1687,28 @@ const oo = (t, e) => {
1687
1687
  f(y), l(y);
1688
1688
  }, c = (y, S = !0) => {
1689
1689
  S && s();
1690
- const E = e.getBoundingClientRect(), w = y.map((O) => ({ target: O, rects: r(O, E) }));
1691
- w.forEach(({ target: O, rects: R }) => o.set(O.annotation, R));
1692
- const T = w.flatMap(({ rects: O }) => O);
1690
+ const E = e.getBoundingClientRect(), b = y.map((O) => ({ target: O, rects: r(O, E) }));
1691
+ b.forEach(({ target: O, rects: R }) => o.set(O.annotation, R));
1692
+ const T = b.flatMap(({ rects: O }) => O);
1693
1693
  n.load(T);
1694
1694
  }, g = (y, S, E = !1) => {
1695
- const w = n.search({
1695
+ const b = n.search({
1696
1696
  minX: y,
1697
1697
  minY: S,
1698
1698
  maxX: y,
1699
1699
  maxY: S
1700
1700
  }), T = (O) => O.annotation.rects.reduce((R, m) => R + m.width * m.height, 0);
1701
- return w.length > 0 ? (w.sort((O, R) => T(O) - T(R)), E ? w.map((O) => O.annotation.id) : [w[0].annotation.id]) : [];
1701
+ return b.length > 0 ? (b.sort((O, R) => T(O) - T(R)), E ? b.map((O) => O.annotation.id) : [b[0].annotation.id]) : [];
1702
1702
  }, u = (y) => {
1703
1703
  const S = x(y);
1704
1704
  if (S.length === 0)
1705
1705
  return;
1706
- let E = S[0].left, w = S[0].top, T = S[0].right, O = S[0].bottom;
1706
+ let E = S[0].left, b = S[0].top, T = S[0].right, O = S[0].bottom;
1707
1707
  for (let R = 1; R < S.length; R++) {
1708
1708
  const m = S[R];
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);
1709
+ E = Math.min(E, m.left), b = Math.min(b, m.top), T = Math.max(T, m.right), O = Math.max(O, m.bottom);
1710
1710
  }
1711
- return new DOMRect(E, w, T - E, O - w);
1711
+ return new DOMRect(E, b, T - E, O - b);
1712
1712
  }, x = (y) => {
1713
1713
  const S = o.get(y);
1714
1714
  return S ? S[0].annotation.rects : [];
@@ -1719,8 +1719,8 @@ const oo = (t, e) => {
1719
1719
  getAt: g,
1720
1720
  getAnnotationBounds: u,
1721
1721
  getAnnotationRects: x,
1722
- getIntersecting: (y, S, E, w) => {
1723
- const T = n.search({ minX: y, minY: S, maxX: E, maxY: w }), O = new Set(T.map((R) => R.annotation.id));
1722
+ getIntersecting: (y, S, E, b) => {
1723
+ const T = n.search({ minX: y, minY: S, maxX: E, maxY: b }), O = new Set(T.map((R) => R.annotation.id));
1724
1724
  return Array.from(O).map((R) => ({
1725
1725
  annotation: t.getAnnotation(R),
1726
1726
  rects: x(R)
@@ -1743,12 +1743,12 @@ const oo = (t, e) => {
1743
1743
  const S = wt(d, t), E = W(S.target.selector);
1744
1744
  return E && n.addAnnotation(S, y), E;
1745
1745
  }, l = (d, y = !0, S = k.LOCAL) => {
1746
- const E = d.map((T) => wt(T, t)), w = E.filter((T) => !W(T.target.selector));
1747
- return w.length > 0 ? (console.warn("Could not revive all targets for these annotations:", w), n.bulkAddAnnotation(E, y, S), w) : (n.bulkAddAnnotation(E, y, S), []);
1746
+ const E = d.map((T) => wt(T, t)), b = E.filter((T) => !W(T.target.selector));
1747
+ return b.length > 0 ? (console.warn("Could not revive all targets for these annotations:", b), n.bulkAddAnnotation(E, y, S), b) : (n.bulkAddAnnotation(E, y, S), []);
1748
1748
  }, f = (d, y = k.LOCAL) => {
1749
- const S = d.map((w) => wt(w, t)), E = S.filter((w) => !W(w.target.selector));
1750
- return E.length > 0 && console.warn("Could not revive all targets for these annotations:", E), S.forEach((w) => {
1751
- n.getAnnotation(w.id) ? n.updateAnnotation(w, y) : n.addAnnotation(w, y);
1749
+ const S = d.map((b) => wt(b, t)), E = S.filter((b) => !W(b.target.selector));
1750
+ return E.length > 0 && console.warn("Could not revive all targets for these annotations:", E), S.forEach((b) => {
1751
+ n.getAnnotation(b.id) ? n.updateAnnotation(b, y) : n.addAnnotation(b, y);
1752
1752
  }), E;
1753
1753
  }, h = (d, y = k.LOCAL) => {
1754
1754
  const S = bt(d, t);
@@ -1757,21 +1757,21 @@ const oo = (t, e) => {
1757
1757
  const S = d.map((E) => bt(E, t));
1758
1758
  n.bulkUpdateTargets(S, y);
1759
1759
  }, g = (d, y, S) => {
1760
- const E = o.getAt(d, y, !!S).map((T) => n.getAnnotation(T)), w = S ? E.filter(S) : E;
1761
- return w.length > 0 ? w[0] : void 0;
1760
+ const E = o.getAt(d, y, !!S).map((T) => n.getAnnotation(T)), b = S ? E.filter(S) : E;
1761
+ return b.length > 0 ? b[0] : void 0;
1762
1762
  }, u = (d, y, S, E = 5) => {
1763
- const w = o.getAnnotationRects(d);
1764
- if (w.length !== 0) {
1763
+ const b = o.getAnnotationRects(d);
1764
+ if (b.length !== 0) {
1765
1765
  if (y && S) {
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);
1766
+ const T = b.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
- }, 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);
1771
+ }, x = (d, y, S, E) => o.getIntersecting(d, y, S, E), w = (d) => o.getAnnotationRects(d), C = () => o.recalculate(), p = (d) => o.on("recalculate", d);
1772
1772
  return n.observe(({ changes: d }) => {
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
- (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));
1773
+ const y = (d.deleted || []).filter((b) => W(b.target.selector)), S = (d.created || []).filter((b) => W(b.target.selector)), E = (d.updated || []).filter((b) => W(b.newValue.target.selector));
1774
+ (y == null ? void 0 : y.length) > 0 && y.forEach((b) => o.remove(b.target)), S.length > 0 && o.set(S.map((b) => b.target), !1), (E == null ? void 0 : E.length) > 0 && E.forEach(({ newValue: b }) => o.update(b.target));
1775
1775
  }), {
1776
1776
  store: {
1777
1777
  ...n,
@@ -1780,7 +1780,7 @@ const oo = (t, e) => {
1780
1780
  bulkUpdateTargets: c,
1781
1781
  bulkUpsertAnnotations: f,
1782
1782
  getAnnotationBounds: u,
1783
- getAnnotationRects: b,
1783
+ getAnnotationRects: w,
1784
1784
  getIntersecting: x,
1785
1785
  getAt: g,
1786
1786
  recalculatePositions: C,
@@ -2005,8 +2005,8 @@ const mt = (t) => {
2005
2005
  n || (n = at());
2006
2006
  const c = l > 1 ? pe(H, s) : [], g = [];
2007
2007
  N[h] = N[h].filter((u) => {
2008
- const b = (o ? u.method === o : !0) && u.scope === n && ro(u.mods, c);
2009
- return b && g.push(u.element), !b;
2008
+ const w = (o ? u.method === o : !0) && u.scope === n && ro(u.mods, c);
2009
+ return w && g.push(u.element), !w;
2010
2010
  }), g.forEach((u) => Kt(u));
2011
2011
  });
2012
2012
  };
@@ -2072,11 +2072,11 @@ function $(t, e, n) {
2072
2072
  if (typeof a < "u" && window) {
2073
2073
  if (!F.has(a)) {
2074
2074
  const u = function() {
2075
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2076
- return ee(b, a);
2075
+ let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2076
+ return ee(w, a);
2077
2077
  }, x = function() {
2078
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2079
- ee(b, a), po(b);
2078
+ let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2079
+ ee(w, a), po(w);
2080
2080
  };
2081
2081
  F.set(a, {
2082
2082
  keydownListener: u,
@@ -2156,24 +2156,24 @@ if (typeof window < "u") {
2156
2156
  }
2157
2157
  const ne = 300, yo = (t, e, n) => {
2158
2158
  let o;
2159
- const i = (w) => o = w;
2159
+ const i = (b) => o = b;
2160
2160
  let r;
2161
- const a = (w) => r = w;
2161
+ const a = (b) => r = b;
2162
2162
  let s = !0;
2163
- const l = (w) => {
2164
- s = w, b.clear(), w || (c = void 0, g = void 0, u = void 0);
2163
+ const l = (b) => {
2164
+ s = b, w.clear(), b || (c = void 0, g = void 0, u = void 0);
2165
2165
  }, { store: f, selection: h } = e;
2166
2166
  let c, g, u;
2167
- const x = (w) => {
2167
+ const x = (b) => {
2168
2168
  var O;
2169
2169
  if (!s || g === !1) return;
2170
- c = !((O = w.target.parentElement) != null && O.closest(j)) ? {
2170
+ c = !((O = b.target.parentElement) != null && O.closest(j)) ? {
2171
2171
  annotation: de(),
2172
2172
  selector: [],
2173
2173
  creator: o,
2174
2174
  created: /* @__PURE__ */ new Date()
2175
2175
  } : void 0;
2176
- }, b = Ut((w) => {
2176
+ }, w = Ut((b) => {
2177
2177
  var B, M;
2178
2178
  if (!s) return;
2179
2179
  const T = document.getSelection();
@@ -2181,7 +2181,7 @@ const ne = 300, yo = (t, e, n) => {
2181
2181
  c = void 0;
2182
2182
  return;
2183
2183
  }
2184
- const R = w.timeStamp - ((u == null ? void 0 : u.timeStamp) || w.timeStamp);
2184
+ const R = b.timeStamp - ((u == null ? void 0 : u.timeStamp) || b.timeStamp);
2185
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));
@@ -2202,40 +2202,40 @@ const ne = 300, yo = (t, e, n) => {
2202
2202
  bodies: [],
2203
2203
  target: c
2204
2204
  }, k.LOCAL), h.userSelect(c.annotation, u)));
2205
- }), C = (w) => {
2206
- u = $e(w), g = u.button === 0;
2207
- }, p = (w) => {
2205
+ }), C = (b) => {
2206
+ u = $e(b), g = u.button === 0;
2207
+ }, p = (b) => {
2208
2208
  var A;
2209
- const T = w.target;
2209
+ const T = b.target;
2210
2210
  if (!!((A = T.parentElement) != null && A.closest(j)) || !g)
2211
2211
  return;
2212
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);
2213
+ const { x: v, y: L } = t.getBoundingClientRect(), B = b.target instanceof Node && t.contains(b.target) && f.getAt(b.clientX - v, b.clientY - L, r);
2214
2214
  if (B) {
2215
2215
  const { selected: M } = h;
2216
- (M.length !== 1 || M[0].id !== B.id) && h.userSelect(B.id, w);
2216
+ (M.length !== 1 || M[0].id !== B.id) && h.userSelect(B.id, b);
2217
2217
  } else h.isEmpty() || h.clear();
2218
- }, m = w.timeStamp - u.timeStamp;
2218
+ }, m = b.timeStamp - u.timeStamp;
2219
2219
  setTimeout(() => {
2220
2220
  const v = document.getSelection();
2221
- v != null && v.isCollapsed && m < ne ? T !== document.documentElement && (c = void 0, R()) : 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, b);
2222
2222
  });
2223
2223
  };
2224
- document.addEventListener("pointerdown", C), document.addEventListener("pointerup", p), t.addEventListener("selectstart", x), document.addEventListener("selectionchange", b);
2224
+ document.addEventListener("pointerdown", C), document.addEventListener("pointerup", p), t.addEventListener("selectstart", x), document.addEventListener("selectionchange", w);
2225
2225
  const d = ["up", "down", "left", "right"], y = [
2226
- ...d.map((w) => `shift+${w}`),
2226
+ ...d.map((b) => `shift+${b}`),
2227
2227
  "ctrl+a",
2228
2228
  "⌘+a"
2229
2229
  ];
2230
- $(y.join(","), { element: t, keydown: !0, keyup: !1 }, (w) => {
2231
- w.repeat || (u = je(w));
2230
+ $(y.join(","), { element: t, keydown: !0, keyup: !1 }, (b) => {
2231
+ b.repeat || (u = je(b));
2232
2232
  });
2233
- const S = (w) => {
2234
- w.repeat || w.target !== t && w.target !== document.body || (c = void 0, h.clear());
2233
+ const S = (b) => {
2234
+ b.repeat || b.target !== t && b.target !== document.body || (c = void 0, h.clear());
2235
2235
  };
2236
2236
  return $(d.join(","), { keydown: !0, keyup: !1 }, S), {
2237
2237
  destroy: () => {
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();
2238
+ c = void 0, g = void 0, u = void 0, w.clear(), document.removeEventListener("pointerdown", C), document.removeEventListener("pointerup", p), t.removeEventListener("selectstart", x), document.removeEventListener("selectionchange", w), $.unbind();
2239
2239
  },
2240
2240
  setFilter: a,
2241
2241
  setUser: i,
@@ -2264,8 +2264,8 @@ const ne = 300, yo = (t, e, n) => {
2264
2264
  n.font && (i.font = n.font);
2265
2265
  const x = r.get(c.annotation.id);
2266
2266
  if (x) {
2267
- const { height: b } = c.rects[0], C = c.rects[0].x + g.left, p = c.rects[0].y + g.top;
2268
- i.fillStyle = x.appearance.color, i.fillRect(C - 2, p - 2.5, 2, b + 5);
2267
+ const { height: w } = c.rects[0], C = c.rects[0].x + g.left, p = c.rects[0].y + g.top;
2268
+ i.fillStyle = x.appearance.color, i.fillRect(C - 2, p - 2.5, 2, w + 5);
2269
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
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
2271
  fill: x.appearance.color,
@@ -2286,7 +2286,7 @@ const ne = 300, yo = (t, e, n) => {
2286
2286
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ve(t.parentElement);
2287
2287
  }, vo = (t, e) => (n) => {
2288
2288
  const o = typeof n == "string" ? n : n.id, i = (a) => {
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;
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, w = r.parentElement ? r.scrollTop : 0, C = r.parentElement ? r.scrollLeft : 0, p = u + w - (l - g) / 2, d = x + C - (f - c) / 2;
2290
2290
  r.scroll({ top: p, left: d, behavior: "smooth" });
2291
2291
  }, r = ve(t);
2292
2292
  if (r) {
@@ -2317,7 +2317,7 @@ const ne = 300, yo = (t, e, n) => {
2317
2317
  console.debug(`Using ${h} renderer`), n.style && c.setStyle(n.style);
2318
2318
  const g = yo(t, o, n.offsetReferenceSelector);
2319
2319
  g.setUser(f), g.setAnnotatingEnabled(n.annotatingEnabled);
2320
- const u = _n(o, s, n.adapter), x = () => f, b = (E) => {
2320
+ const u = _n(o, s, n.adapter), x = () => f, w = (E) => {
2321
2321
  g.setAnnotatingEnabled(
2322
2322
  E === void 0 ? !0 : E
2323
2323
  );
@@ -2337,7 +2337,7 @@ const ne = 300, yo = (t, e, n) => {
2337
2337
  },
2338
2338
  element: t,
2339
2339
  getUser: x,
2340
- setAnnotatingEnabled: b,
2340
+ setAnnotatingEnabled: w,
2341
2341
  setFilter: C,
2342
2342
  setStyle: c.setStyle.bind(c),
2343
2343
  redraw: c.redraw.bind(c),