@recogito/text-annotator 3.0.0-rc.55 → 3.0.0-rc.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.
@@ -1,13 +1,13 @@
1
- const re = "not-annotatable", nt = `.${re}`, G = (t) => {
1
+ const re = "not-annotatable", et = `.${re}`, it = (t) => {
2
2
  var n;
3
- return !!(t instanceof HTMLElement ? t.closest(nt) : (n = t.parentElement) == null ? void 0 : n.closest(nt));
3
+ return !!(t instanceof HTMLElement ? t.closest(et) : (n = t.parentElement) == null ? void 0 : n.closest(et));
4
4
  }, Ce = (t) => {
5
5
  const e = t.commonAncestorContainer;
6
- return !G(e);
6
+ return !it(e);
7
7
  }, Le = (t) => t.addEventListener("click", (e) => {
8
8
  // Allow clicks within not-annotatable elements
9
- !e.target.closest(nt) && !e.target.closest("a") && e.preventDefault();
10
- }), Et = (t) => ({
9
+ !e.target.closest(et) && !e.target.closest("a") && e.preventDefault();
10
+ }), vt = (t) => ({
11
11
  ...t,
12
12
  type: t.type,
13
13
  x: t.x,
@@ -60,7 +60,7 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
60
60
  const e = document.createNodeIterator(
61
61
  t.commonAncestorContainer,
62
62
  NodeFilter.SHOW_ELEMENT,
63
- (o) => o instanceof HTMLElement && o.classList.contains(re) && !o.parentElement.closest(nt) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
63
+ (o) => o instanceof HTMLElement && o.classList.contains(re) && !o.parentElement.closest(et) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
64
64
  );
65
65
  let n;
66
66
  for (; n = e.nextNode(); )
@@ -70,8 +70,8 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
70
70
  const e = [];
71
71
  let n = null;
72
72
  for (const o of Re(t)) {
73
- let s;
74
- n ? (s = document.createRange(), s.setStartAfter(n), s.setEndBefore(o)) : (s = t.cloneRange(), s.setEndBefore(o)), s.collapsed || e.push(s), n = o;
73
+ let i;
74
+ n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
75
75
  }
76
76
  if (n) {
77
77
  const o = t.cloneRange();
@@ -80,65 +80,65 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
80
80
  return e.length > 0 ? e : [t];
81
81
  }, Nt = (t) => {
82
82
  const e = t.cloneContents();
83
- return e.querySelectorAll(nt).forEach((n) => n.remove()), e;
83
+ return e.querySelectorAll(et).forEach((n) => n.remove()), e;
84
84
  }, Be = (t, e, n = 10, o) => {
85
- const s = o ? t.startContainer.parentElement.closest(o) : e, i = document.createRange();
86
- i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
87
- const a = Nt(i).textContent, r = document.createRange();
88
- r.setStart(t.endContainer, t.endOffset), s === document.body ? r.setEnd(s, s.childNodes.length) : r.setEndAfter(s);
85
+ const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
86
+ s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
87
+ const a = Nt(s).textContent, r = document.createRange();
88
+ r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
89
89
  const l = Nt(r).textContent;
90
90
  return {
91
91
  prefix: a.substring(a.length - n),
92
92
  suffix: l.substring(0, n)
93
93
  };
94
94
  }, q = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()), Ue = (t, e) => {
95
- const n = (i) => Math.round(i * 10) / 10, o = {
95
+ const n = (s) => Math.round(s * 10) / 10, o = {
96
96
  top: n(t.top),
97
97
  bottom: n(t.bottom),
98
98
  left: n(t.left),
99
99
  right: n(t.right)
100
- }, s = {
100
+ }, i = {
101
101
  top: n(e.top),
102
102
  bottom: n(e.bottom),
103
103
  left: n(e.left),
104
104
  right: n(e.right)
105
105
  };
106
- if (Math.abs(o.top - s.top) < 0.5 && Math.abs(o.bottom - s.bottom) < 0.5) {
107
- if (Math.abs(o.left - s.right) < 0.5 || Math.abs(o.right - s.left) < 0.5)
106
+ if (Math.abs(o.top - i.top) < 0.5 && Math.abs(o.bottom - i.bottom) < 0.5) {
107
+ if (Math.abs(o.left - i.right) < 0.5 || Math.abs(o.right - i.left) < 0.5)
108
108
  return "inline-adjacent";
109
- if (o.left >= s.left && o.right <= s.right)
109
+ if (o.left >= i.left && o.right <= i.right)
110
110
  return "inline-is-contained";
111
- if (o.left <= s.left && o.right >= s.right)
111
+ if (o.left <= i.left && o.right >= i.right)
112
112
  return "inline-contains";
113
- } else if (o.top <= s.top && o.bottom >= s.bottom) {
114
- if (o.left <= s.left && o.right >= s.right)
113
+ } else if (o.top <= i.top && o.bottom >= i.bottom) {
114
+ if (o.left <= i.left && o.right >= i.right)
115
115
  return "block-contains";
116
- } else if (o.top >= s.top && o.bottom <= s.bottom && o.left >= s.left && o.right <= s.right)
116
+ } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
117
117
  return "block-is-contained";
118
118
  }, _e = (t, e) => {
119
- const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), s = Math.min(t.top, e.top), i = Math.max(t.bottom, e.bottom);
120
- return new DOMRect(n, s, o - n, i - s);
119
+ const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
120
+ return new DOMRect(n, i, o - n, s - i);
121
121
  }, Ne = (t) => t.reduce((e, n) => {
122
122
  if (n.width === 0 || n.height === 0)
123
123
  return e;
124
- let o = [...e], s = !1;
125
- for (const i of e) {
126
- const a = Ue(n, i);
124
+ let o = [...e], i = !1;
125
+ for (const s of e) {
126
+ const a = Ue(n, s);
127
127
  if (a === "inline-adjacent") {
128
- o = o.map((r) => r === i ? _e(n, i) : r), s = !0;
128
+ o = o.map((r) => r === s ? _e(n, s) : r), i = !0;
129
129
  break;
130
130
  } else if (a === "inline-contains") {
131
- o = o.map((r) => r === i ? n : r), s = !0;
131
+ o = o.map((r) => r === s ? n : r), i = !0;
132
132
  break;
133
133
  } else if (a === "inline-is-contained") {
134
- s = !0;
134
+ i = !0;
135
135
  break;
136
136
  } else if (a === "block-contains" || a === "block-is-contained") {
137
- n.width < i.width && (o = o.map((r) => r === i ? n : r)), s = !0;
137
+ n.width < s.width && (o = o.map((r) => r === s ? n : r)), i = !0;
138
138
  break;
139
139
  }
140
140
  }
141
- return s ? o : [...o, n];
141
+ return i ? o : [...o, n];
142
142
  }, []), wo = (t) => ({
143
143
  length: t.length,
144
144
  item: (e) => t[e],
@@ -147,27 +147,27 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
147
147
  yield this.item(e);
148
148
  }
149
149
  }), Ve = (t, e, n) => {
150
- const o = document.createRange(), s = n ? t.startContainer.parentElement.closest(n) : e;
151
- o.setStart(s, 0), o.setEnd(t.startContainer, t.startOffset);
152
- const i = Nt(o).textContent, a = t.toString(), r = i.length || 0, l = r + a.length;
153
- return n ? { quote: a, start: r, end: l, range: t, offsetReference: s } : { quote: a, start: r, end: l, range: t };
150
+ const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
151
+ o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
152
+ const s = Nt(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
153
+ return n ? { quote: a, start: r, end: l, range: t, offsetReference: i } : { quote: a, start: r, end: l, range: t };
154
154
  }, ae = (t, e) => {
155
155
  var h, u;
156
- const { start: n, end: o } = t, s = t.offsetReference || e, i = document.createNodeIterator(
156
+ const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
157
157
  e,
158
158
  NodeFilter.SHOW_TEXT,
159
159
  (p) => {
160
- var E;
161
- return (E = p.parentElement) != null && E.closest(nt) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
160
+ var v;
161
+ return (v = p.parentElement) != null && v.closest(et) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
162
162
  }
163
163
  );
164
164
  let a = 0;
165
165
  const r = document.createRange();
166
- let l = i.nextNode();
166
+ let l = s.nextNode();
167
167
  l === null && console.error("Could not revive annotation target. Content missing.");
168
- let f = !s;
168
+ let f = !i;
169
169
  for (; l !== null; ) {
170
- if (f || (f = s == null ? void 0 : s.contains(l)), f) {
170
+ if (f || (f = typeof (i == null ? void 0 : i.contains) == "function" ? i.contains(l) : !1), f) {
171
171
  const p = ((h = l.textContent) == null ? void 0 : h.length) || 0;
172
172
  if (a + p > n) {
173
173
  r.setStart(l, n - a);
@@ -175,7 +175,7 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
175
175
  }
176
176
  a += p;
177
177
  }
178
- l = i.nextNode();
178
+ l = s.nextNode();
179
179
  }
180
180
  for (; l !== null; ) {
181
181
  const p = ((u = l.textContent) == null ? void 0 : u.length) || 0;
@@ -183,7 +183,7 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
183
183
  r.setEnd(l, o - a);
184
184
  break;
185
185
  }
186
- a += p, l = i.nextNode();
186
+ a += p, l = s.nextNode();
187
187
  }
188
188
  return {
189
189
  ...t,
@@ -192,7 +192,7 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
192
192
  }, At = (t, e) => q(t.selector) ? t : {
193
193
  ...t,
194
194
  selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ae(n, e))
195
- }, vt = (t, e) => q(t.target.selector) ? t : { ...t, target: At(t.target, e) }, De = (t, e) => {
195
+ }, Et = (t, e) => q(t.target.selector) ? t : { ...t, target: At(t.target, e) }, De = (t, e) => {
196
196
  const n = t.cloneRange();
197
197
  return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
198
198
  }, ce = (t) => {
@@ -201,82 +201,82 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
201
201
  const { overflowY: e } = window.getComputedStyle(t);
202
202
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
203
203
  }, Ye = (t, e) => (n) => {
204
- const o = typeof n == "string" ? n : n.id, s = (a) => {
205
- const r = i.getBoundingClientRect(), l = i.clientHeight, f = i.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), E = h.top - r.top, g = h.left - r.left, m = i.parentElement ? i.scrollTop : 0, A = i.parentElement ? i.scrollLeft : 0, d = E + m - (l - p) / 2, c = g + A - (f - u) / 2;
206
- i.scroll({ top: d, left: c, behavior: "smooth" });
207
- }, i = ce(t);
208
- if (i) {
204
+ const o = typeof n == "string" ? n : n.id, i = (a) => {
205
+ const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), v = h.top - r.top, g = h.left - r.left, m = s.parentElement ? s.scrollTop : 0, A = s.parentElement ? s.scrollLeft : 0, d = v + m - (l - p) / 2, c = g + A - (f - u) / 2;
206
+ s.scroll({ top: d, left: c, behavior: "smooth" });
207
+ }, s = ce(t);
208
+ if (s) {
209
209
  const a = e.getAnnotation(o), { range: r } = a.target.selector[0];
210
210
  if (r && !r.collapsed)
211
- return s(a.target), !0;
211
+ return i(a.target), !0;
212
212
  {
213
213
  const l = At(a.target, t), { range: f } = l.selector[0];
214
214
  if (f && !f.collapsed)
215
- return s(l), !0;
215
+ return i(l), !0;
216
216
  }
217
217
  }
218
218
  return !1;
219
- }, Q = {
219
+ }, G = {
220
220
  fill: "rgb(0, 128, 255)",
221
221
  fillOpacity: 0.18
222
222
  }, xt = {
223
223
  fill: "rgb(0, 128, 255)",
224
224
  fillOpacity: 0.45
225
- }, Ke = (t, e, n, o, s) => {
225
+ }, Ke = (t, e, n, o, i) => {
226
226
  var a, r;
227
- const i = n ? typeof n == "function" ? n(t.annotation, t.state, s) || ((a = t.state) != null && a.selected ? xt : Q) : n : (r = t.state) != null && r.selected ? xt : Q;
228
- return o && o.paint(t, e) || i;
227
+ const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? xt : G) : n : (r = t.state) != null && r.selected ? xt : G;
228
+ return o && o.paint(t, e) || s;
229
229
  }, Xe = (t) => {
230
- const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: s } = window, i = -n, a = -e, r = o - n, l = s - e;
231
- return { top: e, left: n, minX: i, minY: a, maxX: r, maxY: l };
230
+ const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n, l = i - e;
231
+ return { top: e, left: n, minX: s, minY: a, maxX: r, maxY: l };
232
232
  }, Pe = (t) => {
233
233
  let e = /* @__PURE__ */ new Set();
234
234
  return (o) => {
235
- const s = o.map((i) => i.id);
236
- (e.size !== s.length || s.some((i) => !e.has(i))) && t.set(s), e = new Set(s);
235
+ const i = o.map((s) => s.id);
236
+ (e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
237
237
  };
238
238
  }, Yt = (t, e, n, o) => {
239
- const { store: s, selection: i, hover: a } = e;
239
+ const { store: i, selection: s, hover: a } = e;
240
240
  let r, l, f;
241
241
  const h = Pe(n), u = (M) => {
242
- const { x: T, y: I } = t.getBoundingClientRect(), D = s.getAt(M.clientX - T, M.clientY - I, !1, l);
242
+ const { x: T, y: I } = t.getBoundingClientRect(), D = i.getAt(M.clientX - T, M.clientY - I, !1, l);
243
243
  D ? a.current !== D.id && (t.classList.add("hovered"), a.set(D.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
244
244
  };
245
245
  t.addEventListener("pointermove", u);
246
246
  const p = (M = !1) => {
247
247
  f && f.clear();
248
- const T = Xe(t), { minX: I, minY: D, maxX: y, maxY: x } = T, w = l ? s.getIntersecting(I, D, y, x).filter(({ annotation: O }) => l(O)) : s.getIntersecting(I, D, y, x), L = i.selected.map(({ id: O }) => O), B = w.map(({ annotation: O, rects: U }) => {
248
+ const T = Xe(t), { minX: I, minY: D, maxX: y, maxY: x } = T, w = l ? i.getIntersecting(I, D, y, x).filter(({ annotation: O }) => l(O)) : i.getIntersecting(I, D, y, x), L = s.selected.map(({ id: O }) => O), B = w.map(({ annotation: O, rects: U }) => {
249
249
  const P = L.includes(O.id), Se = O.id === a.current;
250
250
  return { annotation: O, rects: U, state: { selected: P, hover: Se } };
251
251
  });
252
252
  o.redraw(B, T, r, f, M), setTimeout(() => h(w.map(({ annotation: O }) => O)), 1);
253
- }, E = (M) => {
253
+ }, v = (M) => {
254
254
  f = M, p();
255
255
  }, g = (M) => {
256
256
  r = M, p();
257
257
  }, m = (M) => {
258
258
  l = M, p(!1);
259
259
  }, A = () => p();
260
- s.observe(A);
261
- const d = i.subscribe(() => p()), c = () => p(!0);
260
+ i.observe(A);
261
+ const d = s.subscribe(() => p()), c = () => p(!0);
262
262
  document.addEventListener("scroll", c, { capture: !0, passive: !0 });
263
263
  const b = Dt(() => {
264
- s.recalculatePositions(), f && f.reset(), p();
264
+ i.recalculatePositions(), f && f.reset(), p();
265
265
  });
266
266
  window.addEventListener("resize", b);
267
267
  const S = new ResizeObserver(b);
268
268
  S.observe(t);
269
- const v = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
269
+ const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
270
270
  M.every((I) => I.target === t || t.contains(I.target)) || p(!0);
271
271
  });
272
- return C.observe(document.body, v), {
272
+ return C.observe(document.body, E), {
273
273
  destroy: () => {
274
- t.removeEventListener("pointermove", u), o.destroy(), s.unobserve(A), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), S.disconnect(), C.disconnect();
274
+ t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(A), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), S.disconnect(), C.disconnect();
275
275
  },
276
276
  redraw: p,
277
277
  setStyle: g,
278
278
  setFilter: m,
279
- setPainter: E,
279
+ setPainter: v,
280
280
  setVisible: o.setVisible
281
281
  };
282
282
  }, $e = () => {
@@ -291,34 +291,34 @@ const re = "not-annotatable", nt = `.${re}`, G = (t) => {
291
291
  const o = (r, l, f, h) => requestAnimationFrame(() => {
292
292
  const { width: u, height: p } = e;
293
293
  n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
294
- const { top: E, left: g } = l;
294
+ const { top: v, left: g } = l;
295
295
  [...r].sort((A, d) => {
296
296
  const { annotation: { target: { created: c } } } = A, { annotation: { target: { created: b } } } = d;
297
297
  return c.getTime() - b.getTime();
298
298
  }).forEach((A) => {
299
299
  var S;
300
- const d = f ? typeof f == "function" ? f(A.annotation, A.state) : f : (S = A.state) != null && S.selected ? xt : Q, c = h && h.paint(A, l) || d, b = A.rects.map(({ x: v, y: C, width: R, height: M }) => ({
301
- x: v + g,
302
- y: C + E,
300
+ const d = f ? typeof f == "function" ? f(A.annotation, A.state) : f : (S = A.state) != null && S.selected ? xt : G, c = h && h.paint(A, l) || d, b = A.rects.map(({ x: E, y: C, width: R, height: M }) => ({
301
+ x: E + g,
302
+ y: C + v,
303
303
  width: R,
304
304
  height: M
305
305
  }));
306
306
  if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(
307
- ({ x: v, y: C, width: R, height: M }) => n.fillRect(v, C, R, M)
307
+ ({ x: E, y: C, width: R, height: M }) => n.fillRect(E, C, R, M)
308
308
  ), c.underlineColor) {
309
309
  n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
310
- const v = c.underlineOffset ?? 0;
310
+ const E = c.underlineOffset ?? 0;
311
311
  b.forEach(({ x: C, y: R, width: M, height: T }) => {
312
- n.beginPath(), n.moveTo(C, R + T + v), n.lineTo(C + M, R + T + v), n.stroke();
312
+ n.beginPath(), n.moveTo(C, R + T + E), n.lineTo(C + M, R + T + E), n.stroke();
313
313
  });
314
314
  }
315
315
  });
316
- }), s = Dt(() => {
316
+ }), i = Dt(() => {
317
317
  He(e);
318
318
  });
319
- return window.addEventListener("resize", s), {
319
+ return window.addEventListener("resize", i), {
320
320
  destroy: () => {
321
- e.remove(), window.removeEventListener("resize", s);
321
+ e.remove(), window.removeEventListener("resize", i);
322
322
  },
323
323
  setVisible: (r) => {
324
324
  console.log("setVisible not implemented on Canvas renderer");
@@ -342,13 +342,13 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
342
342
  var e = t.toString(16);
343
343
  return e.length < 2 ? "0" + e : e;
344
344
  }, de = function(t) {
345
- var e = t.r, n = t.g, o = t.b, s = t.a, i = Math.max(e, n, o), a = i - Math.min(e, n, o), r = a ? i === e ? (n - o) / a : i === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
346
- return { h: 60 * (r < 0 ? r + 6 : r), s: i ? a / i * 100 : 0, v: i / 255 * 100, a: s };
345
+ var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), a = s - Math.min(e, n, o), r = a ? s === e ? (n - o) / a : s === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
346
+ return { h: 60 * (r < 0 ? r + 6 : r), s: s ? a / s * 100 : 0, v: s / 255 * 100, a: i };
347
347
  }, ue = function(t) {
348
- var e = t.h, n = t.s, o = t.v, s = t.a;
348
+ var e = t.h, n = t.s, o = t.v, i = t.a;
349
349
  e = e / 360 * 6, n /= 100, o /= 100;
350
- var i = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - i) * n), l = o * (1 - (1 - e + i) * n), f = i % 6;
351
- return { r: 255 * [o, r, a, a, l, o][f], g: 255 * [l, o, o, r, a, a][f], b: 255 * [a, a, l, o, o, r][f], a: s };
350
+ var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), f = s % 6;
351
+ return { r: 255 * [o, r, a, a, l, o][f], g: 255 * [l, o, o, r, a, a][f], b: 255 * [a, a, l, o, o, r][f], a: i };
352
352
  }, $t = function(t) {
353
353
  return { h: le(t.h), s: $(t.s, 0, 100), l: $(t.l, 0, 100), a: $(t.a) };
354
354
  }, Ht = function(t) {
@@ -357,8 +357,8 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
357
357
  return ue((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
358
358
  var e, n, o;
359
359
  }, at = function(t) {
360
- return { h: (e = de(t)).h, s: (s = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && s < 200 ? n * o / 100 / (s <= 100 ? s : 200 - s) * 100 : 0, l: s / 2, a: e.a };
361
- var e, n, o, s;
360
+ return { h: (e = de(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
361
+ var e, n, o, i;
362
362
  }, qe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Qe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Je = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, zt = { string: [[function(t) {
363
363
  var e = We.exec(t);
364
364
  return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? V(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? V(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
@@ -368,22 +368,22 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
368
368
  }, "rgb"], [function(t) {
369
369
  var e = qe.exec(t) || Ge.exec(t);
370
370
  if (!e) return null;
371
- var n, o, s = $t({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Fe[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
372
- return jt(s);
371
+ var n, o, i = $t({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Fe[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
372
+ return jt(i);
373
373
  }, "hsl"]], object: [[function(t) {
374
- var e = t.r, n = t.g, o = t.b, s = t.a, i = s === void 0 ? 1 : s;
375
- return F(e) && F(n) && F(o) ? Pt({ r: Number(e), g: Number(n), b: Number(o), a: Number(i) }) : null;
374
+ var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
375
+ return F(e) && F(n) && F(o) ? Pt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
376
376
  }, "rgb"], [function(t) {
377
- var e = t.h, n = t.s, o = t.l, s = t.a, i = s === void 0 ? 1 : s;
377
+ var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
378
378
  if (!F(e) || !F(n) || !F(o)) return null;
379
- var a = $t({ h: Number(e), s: Number(n), l: Number(o), a: Number(i) });
379
+ var a = $t({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
380
380
  return jt(a);
381
381
  }, "hsl"], [function(t) {
382
- var e = t.h, n = t.s, o = t.v, s = t.a, i = s === void 0 ? 1 : s;
382
+ var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
383
383
  if (!F(e) || !F(n) || !F(o)) return null;
384
384
  var a = function(r) {
385
385
  return { h: le(r.h), s: $(r.s, 0, 100), v: $(r.v, 0, 100), a: $(r.a) };
386
- }({ h: Number(e), s: Number(n), v: Number(o), a: Number(i) });
386
+ }({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
387
387
  return ue(a);
388
388
  }, "hsv"]] }, Ft = function(t, e) {
389
389
  for (var n = 0; n < e.length; n++) {
@@ -414,18 +414,18 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
414
414
  }, t.prototype.isLight = function() {
415
415
  return Lt(this.rgba) >= 0.5;
416
416
  }, t.prototype.toHex = function() {
417
- return e = St(this.rgba), n = e.r, o = e.g, s = e.b, a = (i = e.a) < 1 ? ht(V(255 * i)) : "", "#" + ht(n) + ht(o) + ht(s) + a;
418
- var e, n, o, s, i, a;
417
+ return e = St(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? ht(V(255 * s)) : "", "#" + ht(n) + ht(o) + ht(i) + a;
418
+ var e, n, o, i, s, a;
419
419
  }, t.prototype.toRgb = function() {
420
420
  return St(this.rgba);
421
421
  }, t.prototype.toRgbString = function() {
422
- return e = St(this.rgba), n = e.r, o = e.g, s = e.b, (i = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + s + ", " + i + ")" : "rgb(" + n + ", " + o + ", " + s + ")";
423
- var e, n, o, s, i;
422
+ return e = St(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
423
+ var e, n, o, i, s;
424
424
  }, t.prototype.toHsl = function() {
425
425
  return Ht(at(this.rgba));
426
426
  }, t.prototype.toHslString = function() {
427
- return e = Ht(at(this.rgba)), n = e.h, o = e.s, s = e.l, (i = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + s + "%, " + i + ")" : "hsl(" + n + ", " + o + "%, " + s + "%)";
428
- var e, n, o, s, i;
427
+ return e = Ht(at(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
428
+ var e, n, o, i, s;
429
429
  }, t.prototype.toHsv = function() {
430
430
  return e = de(this.rgba), { h: V(e.h), s: V(e.s), v: V(e.v), a: V(e.a, 3) };
431
431
  var e;
@@ -457,7 +457,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
457
457
  return t instanceof qt ? t : new qt(t);
458
458
  };
459
459
  const tn = (t) => [
460
- `background-color:${j((t == null ? void 0 : t.fill) || Q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? Q.fillOpacity : t.fillOpacity).toHex()}`,
460
+ `background-color:${j((t == null ? void 0 : t.fill) || G.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? G.fillOpacity : t.fillOpacity).toHex()}`,
461
461
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
462
462
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
463
463
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
@@ -470,22 +470,22 @@ const tn = (t) => [
470
470
  destroy: () => {
471
471
  CSS.highlights.clear(), t.remove();
472
472
  },
473
- setVisible: (i) => {
473
+ setVisible: (s) => {
474
474
  console.log("setVisible not implemented on CSS Custom Highlights renderer");
475
475
  },
476
- redraw: (i, a, r, l) => {
476
+ redraw: (s, a, r, l) => {
477
477
  l && l.clear();
478
- const f = new Set(i.map((u) => u.annotation.id));
478
+ const f = new Set(s.map((u) => u.annotation.id));
479
479
  Array.from(e).filter((u) => !f.has(u));
480
- const h = i.map((u) => {
480
+ const h = s.map((u) => {
481
481
  var g;
482
- const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (g = u.state) != null && g.selected ? xt : Q, E = l && l.paint(u, a) || p;
483
- return `::highlight(_${u.annotation.id}) { ${tn(E)} }`;
482
+ const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (g = u.state) != null && g.selected ? xt : G, v = l && l.paint(u, a) || p;
483
+ return `::highlight(_${u.annotation.id}) { ${tn(v)} }`;
484
484
  });
485
485
  t.innerHTML = h.join(`
486
- `), CSS.highlights.clear(), i.forEach(({ annotation: u }) => {
487
- const p = u.target.selector.map((g) => g.range), E = new Highlight(...p);
488
- CSS.highlights.set(`_${u.id}`, E);
486
+ `), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
487
+ const p = u.target.selector.map((g) => g.range), v = new Highlight(...p);
488
+ CSS.highlights.set(`_${u.id}`, v);
489
489
  }), e = f;
490
490
  }
491
491
  };
@@ -512,8 +512,8 @@ function Vt(t, e) {
512
512
  return t !== t && e !== e;
513
513
  }
514
514
  const on = (t, e) => {
515
- const n = (i, a) => i.x <= a.x + a.width && i.x + i.width >= a.x && i.y <= a.y + a.height && i.y + i.height >= a.y, o = (i) => i.rects.reduce((a, r) => a + r.width, 0), s = e.filter(({ rects: i }) => i.some((a) => n(t, a)));
516
- return s.sort((i, a) => o(a) - o(i)), s.findIndex((i) => i.rects.includes(t));
515
+ const n = (s, a) => s.x <= a.x + a.width && s.x + s.width >= a.x && s.y <= a.y + a.height && s.y + s.height >= a.y, o = (s) => s.rects.reduce((a, r) => a + r.width, 0), i = e.filter(({ rects: s }) => s.some((a) => n(t, a)));
516
+ return i.sort((s, a) => o(a) - o(s)), i.findIndex((s) => s.rects.includes(t));
517
517
  }, sn = (t) => {
518
518
  t.classList.add("r6o-annotatable");
519
519
  const e = document.createElement("div");
@@ -534,7 +534,7 @@ const on = (t, e) => {
534
534
  const A = on(m, a), d = Ke(g, r, l, f, A);
535
535
  if (p) {
536
536
  const c = document.createElement("span");
537
- c.className = "r6o-annotation", c.dataset.annotation = g.annotation.id, c.style.left = `${m.x}px`, c.style.top = `${m.y}px`, c.style.width = `${m.width}px`, c.style.height = `${m.height}px`, c.style.backgroundColor = j((d == null ? void 0 : d.fill) || Q.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? Q.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 = g.annotation.id, c.style.left = `${m.x}px`, c.style.top = `${m.y}px`, c.style.width = `${m.width}px`, c.style.height = `${m.height}px`, c.style.backgroundColor = j((d == null ? void 0 : d.fill) || G.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? G.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);
538
538
  }
539
539
  });
540
540
  }), n = a;
@@ -561,17 +561,17 @@ function ln() {
561
561
  }
562
562
  const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qt = { randomUUID: dn };
563
563
  function fe(t, e, n) {
564
- var s;
564
+ var i;
565
565
  if (Qt.randomUUID && !t)
566
566
  return Qt.randomUUID();
567
567
  t = t || {};
568
- const o = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? ln();
568
+ const o = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? ln();
569
569
  if (o.length < 16)
570
570
  throw new Error("Random bytes length must be >= 16");
571
571
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, an(o);
572
572
  }
573
573
  var Jt = Object.prototype.hasOwnProperty;
574
- function J(t, e) {
574
+ function Q(t, e) {
575
575
  var n, o;
576
576
  if (t === e) return !0;
577
577
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -579,13 +579,13 @@ function J(t, e) {
579
579
  if (n === RegExp) return t.toString() === e.toString();
580
580
  if (n === Array) {
581
581
  if ((o = t.length) === e.length)
582
- for (; o-- && J(t[o], e[o]); ) ;
582
+ for (; o-- && Q(t[o], e[o]); ) ;
583
583
  return o === -1;
584
584
  }
585
585
  if (!n || typeof t == "object") {
586
586
  o = 0;
587
587
  for (n in t)
588
- if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !J(t[n], e[n])) return !1;
588
+ if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !Q(t[n], e[n])) return !1;
589
589
  return Object.keys(e).length === o;
590
590
  }
591
591
  }
@@ -596,41 +596,41 @@ function Ot() {
596
596
  function un(t, e) {
597
597
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
598
598
  }
599
- const Z = [];
599
+ const J = [];
600
600
  function Kt(t, e = Ot) {
601
601
  let n;
602
602
  const o = /* @__PURE__ */ new Set();
603
- function s(r) {
603
+ function i(r) {
604
604
  if (un(t, r) && (t = r, n)) {
605
- const l = !Z.length;
605
+ const l = !J.length;
606
606
  for (const f of o)
607
- f[1](), Z.push(f, t);
607
+ f[1](), J.push(f, t);
608
608
  if (l) {
609
- for (let f = 0; f < Z.length; f += 2)
610
- Z[f][0](Z[f + 1]);
611
- Z.length = 0;
609
+ for (let f = 0; f < J.length; f += 2)
610
+ J[f][0](J[f + 1]);
611
+ J.length = 0;
612
612
  }
613
613
  }
614
614
  }
615
- function i(r) {
616
- s(r(t));
615
+ function s(r) {
616
+ i(r(t));
617
617
  }
618
618
  function a(r, l = Ot) {
619
619
  const f = [r, l];
620
- return o.add(f), o.size === 1 && (n = e(s, i) || Ot), r(t), () => {
620
+ return o.add(f), o.size === 1 && (n = e(i, s) || Ot), r(t), () => {
621
621
  o.delete(f), o.size === 0 && n && (n(), n = null);
622
622
  };
623
623
  }
624
- return { set: s, update: i, subscribe: a };
624
+ return { set: i, update: s, subscribe: a };
625
625
  }
626
626
  const fn = (t) => {
627
627
  const { subscribe: e, set: n } = Kt();
628
628
  let o;
629
- return e((s) => o = s), t.observe(({ changes: s }) => {
629
+ return e((i) => o = i), t.observe(({ changes: i }) => {
630
630
  if (o) {
631
- (s.deleted || []).some((a) => a.id === o) && n(void 0);
632
- const i = (s.updated || []).find(({ oldValue: a }) => a.id === o);
633
- i && n(i.newValue.id);
631
+ (i.deleted || []).some((a) => a.id === o) && n(void 0);
632
+ const s = (i.updated || []).find(({ oldValue: a }) => a.id === o);
633
+ s && n(s.newValue.id);
634
634
  }
635
635
  }), {
636
636
  get current() {
@@ -642,11 +642,11 @@ const fn = (t) => {
642
642
  };
643
643
  var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(hn || {});
644
644
  const pt = { selected: [] }, pn = (t, e, n) => {
645
- const { subscribe: o, set: s } = Kt(pt);
646
- let i = e, a = pt;
645
+ const { subscribe: o, set: i } = Kt(pt);
646
+ let s = e, a = pt;
647
647
  o((g) => a = g);
648
648
  const r = () => {
649
- J(a, pt) || s(pt);
649
+ Q(a, pt) || i(pt);
650
650
  }, l = () => {
651
651
  var g;
652
652
  return ((g = a.selected) == null ? void 0 : g.length) === 0;
@@ -671,15 +671,15 @@ const pt = { selected: [] }, pn = (t, e, n) => {
671
671
  A = [c];
672
672
  }
673
673
  const d = A.reduce((c, b) => {
674
- const S = Zt(b, i);
674
+ const S = Zt(b, s);
675
675
  return S === "EDIT" ? [...c, { id: b.id, editable: !0 }] : S === "SELECT" ? [...c, { id: b.id }] : c;
676
676
  }, []);
677
- s({ selected: d, event: m });
677
+ i({ selected: d, event: m });
678
678
  }, u = (g, m) => {
679
679
  const A = Array.isArray(g) ? g : [g], d = A.map((c) => t.getAnnotation(c)).filter((c) => !!c);
680
- s({
680
+ i({
681
681
  selected: d.map((c) => {
682
- const b = m === void 0 ? Zt(c, i) === "EDIT" : m;
682
+ const b = m === void 0 ? Zt(c, s) === "EDIT" : m;
683
683
  return { id: c.id, editable: b };
684
684
  })
685
685
  }), d.length !== A.length && console.warn("Invalid selection", g);
@@ -687,9 +687,9 @@ const pt = { selected: [] }, pn = (t, e, n) => {
687
687
  if (l())
688
688
  return !1;
689
689
  const { selected: m } = a;
690
- m.some(({ id: A }) => g.includes(A)) && s({ selected: m.filter(({ id: A }) => !g.includes(A)) });
691
- }, E = (g) => {
692
- i = g, u(a.selected.map(({ id: m }) => m));
690
+ m.some(({ id: A }) => g.includes(A)) && i({ selected: m.filter(({ id: A }) => !g.includes(A)) });
691
+ }, v = (g) => {
692
+ s = g, u(a.selected.map(({ id: m }) => m));
693
693
  };
694
694
  return t.observe(
695
695
  ({ changes: g }) => p((g.deleted || []).map((m) => m.id))
@@ -701,13 +701,13 @@ const pt = { selected: [] }, pn = (t, e, n) => {
701
701
  return a ? [...a.selected] : null;
702
702
  },
703
703
  get userSelectAction() {
704
- return i;
704
+ return s;
705
705
  },
706
706
  clear: r,
707
707
  isEmpty: l,
708
708
  isSelected: f,
709
709
  setSelected: u,
710
- setUserSelectAction: E,
710
+ setUserSelectAction: v,
711
711
  subscribe: o,
712
712
  userSelect: h
713
713
  };
@@ -733,10 +733,10 @@ function he(t, e, n) {
733
733
  if (te.randomUUID && !t)
734
734
  return te.randomUUID();
735
735
  t = t || {};
736
- const s = t.random ?? ((o = t.rng) == null ? void 0 : o.call(t)) ?? yn();
737
- if (s.length < 16)
736
+ const i = t.random ?? ((o = t.rng) == null ? void 0 : o.call(t)) ?? yn();
737
+ if (i.length < 16)
738
738
  throw new Error("Random bytes length must be >= 16");
739
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, gn(s);
739
+ return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, gn(i);
740
740
  }
741
741
  const Mt = (t) => {
742
742
  const e = (n) => {
@@ -761,54 +761,54 @@ const Mt = (t) => {
761
761
  const n = new Set(e.bodies.map((o) => o.id));
762
762
  return t.bodies.filter((o) => !n.has(o.id));
763
763
  }, xn = (t, e) => e.bodies.map((n) => {
764
- const o = t.bodies.find((s) => s.id === n.id);
765
- return { newBody: n, oldBody: o && !J(o, n) ? o : void 0 };
766
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), En = (t, e) => !J(t.target, e.target), pe = (t, e) => {
767
- const n = wn(t, e), o = An(t, e), s = xn(t, e);
764
+ const o = t.bodies.find((i) => i.id === n.id);
765
+ return { newBody: n, oldBody: o && !Q(o, n) ? o : void 0 };
766
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !Q(t.target, e.target), pe = (t, e) => {
767
+ const n = wn(t, e), o = An(t, e), i = xn(t, e);
768
768
  return {
769
769
  oldValue: t,
770
770
  newValue: e,
771
771
  bodiesCreated: n.length > 0 ? n : void 0,
772
772
  bodiesDeleted: o.length > 0 ? o : void 0,
773
- bodiesUpdated: s.length > 0 ? s : void 0,
774
- targetUpdated: En(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
773
+ bodiesUpdated: i.length > 0 ? i : void 0,
774
+ targetUpdated: vn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
775
775
  };
776
776
  };
777
777
  var k = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(k || {});
778
- const vn = (t, e) => {
778
+ const En = (t, e) => {
779
779
  var n, o;
780
- const { changes: s, origin: i } = e;
781
- if (!(t.options.origin ? t.options.origin === i : i !== "SILENT"))
780
+ const { changes: i, origin: s } = e;
781
+ if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
782
782
  return !1;
783
783
  if (t.options.ignore) {
784
784
  const { ignore: a } = t.options, r = (l) => l && l.length > 0;
785
- if (!(r(s.created) || r(s.deleted))) {
786
- const l = (n = s.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = s.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
785
+ if (!(r(i.created) || r(i.deleted))) {
786
+ const l = (n = i.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
787
787
  if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
788
788
  return !1;
789
789
  }
790
790
  }
791
791
  if (t.options.annotations) {
792
792
  const a = /* @__PURE__ */ new Set([
793
- ...(s.created || []).map((r) => r.id),
794
- ...(s.deleted || []).map((r) => r.id),
795
- ...(s.updated || []).map(({ oldValue: r }) => r.id)
793
+ ...(i.created || []).map((r) => r.id),
794
+ ...(i.deleted || []).map((r) => r.id),
795
+ ...(i.updated || []).map(({ oldValue: r }) => r.id)
796
796
  ]);
797
797
  return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((r) => a.has(r));
798
798
  } else
799
799
  return !0;
800
800
  }, Sn = (t, e) => {
801
- const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), s = new Set((e.created || []).map((u) => u.id)), i = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), l = [
802
- ...(t.created || []).filter((u) => !i.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: p }) => p.id === u.id).newValue : u),
801
+ const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), l = [
802
+ ...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: p }) => p.id === u.id).newValue : u),
803
803
  ...e.created || []
804
804
  ], f = [
805
- ...(t.deleted || []).filter((u) => !s.has(u.id)),
805
+ ...(t.deleted || []).filter((u) => !i.has(u.id)),
806
806
  ...(e.deleted || []).filter((u) => !n.has(u.id))
807
807
  ], h = [
808
- ...(t.updated || []).filter(({ newValue: u }) => !i.has(u.id)).map((u) => {
809
- const { oldValue: p, newValue: E } = u;
810
- if (a.has(E.id)) {
811
- const g = e.updated.find((m) => m.oldValue.id === E.id).newValue;
808
+ ...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
809
+ const { oldValue: p, newValue: v } = u;
810
+ if (a.has(v.id)) {
811
+ const g = e.updated.find((m) => m.oldValue.id === v.id).newValue;
812
812
  return pe(p, g);
813
813
  } else
814
814
  return u;
@@ -833,10 +833,10 @@ const vn = (t, e) => {
833
833
  }, Cn = (t) => t.id !== void 0, Ln = () => {
834
834
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (y, x = {}) => {
835
835
  n.push({ onChange: y, options: x });
836
- }, s = (y) => {
836
+ }, i = (y) => {
837
837
  const x = n.findIndex((w) => w.onChange == y);
838
838
  x > -1 && n.splice(x, 1);
839
- }, i = (y, x) => {
839
+ }, s = (y, x) => {
840
840
  const w = {
841
841
  origin: y,
842
842
  changes: {
@@ -847,14 +847,14 @@ const vn = (t, e) => {
847
847
  state: [...t.values()]
848
848
  };
849
849
  n.forEach((L) => {
850
- vn(L, w) && L.onChange(w);
850
+ En(L, w) && L.onChange(w);
851
851
  });
852
852
  }, a = (y, x = k.LOCAL) => {
853
853
  if (y.id && t.get(y.id))
854
854
  throw Error(`Cannot add annotation ${y.id} - exists already`);
855
855
  {
856
856
  const w = gt(y);
857
- t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), i(x, { created: [w] });
857
+ t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), s(x, { created: [w] });
858
858
  }
859
859
  }, r = (y, x) => {
860
860
  const w = gt(typeof y == "string" ? x : y), L = typeof y == "string" ? y : y.id, B = L && t.get(L);
@@ -865,7 +865,7 @@ const vn = (t, e) => {
865
865
  console.warn(`Cannot update annotation ${L} - does not exist`);
866
866
  }, l = (y, x = k.LOCAL, w = k.LOCAL) => {
867
867
  const L = Cn(x) ? w : x, B = r(y, x);
868
- B && i(L, { updated: [B] });
868
+ B && s(L, { updated: [B] });
869
869
  }, f = (y, x = k.LOCAL) => {
870
870
  t.get(y.id) ? l(y, x) : a(y, x);
871
871
  }, h = (y, x = k.LOCAL) => {
@@ -873,12 +873,12 @@ const vn = (t, e) => {
873
873
  const O = r(B);
874
874
  return O ? [...L, O] : L;
875
875
  }, []);
876
- w.length > 0 && i(x, { updated: w });
876
+ w.length > 0 && s(x, { updated: w });
877
877
  }, u = (y, x = k.LOCAL) => {
878
878
  const w = y.map(gt), { toAdd: L, toUpdate: B } = w.reduce((U, P) => t.get(P.id) ? { ...U, toUpdate: [...U.toUpdate, P] } : { ...U, toAdd: [...U.toAdd, P] }, { toAdd: [], toUpdate: [] }), O = B.map((U) => r(U, x)).filter(Boolean);
879
879
  L.forEach((U) => {
880
880
  t.set(U.id, U), U.bodies.forEach((P) => e.set(P.id, U.id));
881
- }), i(x, { created: L, updated: O });
881
+ }), s(x, { created: L, updated: O });
882
882
  }, p = (y, x = k.LOCAL) => {
883
883
  const w = t.get(y.annotation);
884
884
  if (w) {
@@ -886,23 +886,23 @@ const vn = (t, e) => {
886
886
  ...w,
887
887
  bodies: [...w.bodies, y]
888
888
  };
889
- t.set(w.id, L), e.set(y.id, L.id), i(x, { updated: [{
889
+ t.set(w.id, L), e.set(y.id, L.id), s(x, { updated: [{
890
890
  oldValue: w,
891
891
  newValue: L,
892
892
  bodiesCreated: [y]
893
893
  }] });
894
894
  } else
895
895
  console.warn(`Attempt to add body to missing annotation: ${y.annotation}`);
896
- }, E = () => [...t.values()], g = (y = k.LOCAL) => {
896
+ }, v = () => [...t.values()], g = (y = k.LOCAL) => {
897
897
  const x = [...t.values()];
898
- t.clear(), e.clear(), i(y, { deleted: x });
898
+ t.clear(), e.clear(), s(y, { deleted: x });
899
899
  }, m = (y, x = !0, w = k.LOCAL) => {
900
900
  const L = y.map(gt);
901
901
  if (x) {
902
902
  const B = [...t.values()];
903
903
  t.clear(), e.clear(), L.forEach((O) => {
904
904
  t.set(O.id, O), O.bodies.forEach((U) => e.set(U.id, O.id));
905
- }), i(w, { created: L, deleted: B });
905
+ }), s(w, { created: L, deleted: B });
906
906
  } else {
907
907
  const B = y.reduce((O, U) => {
908
908
  const P = U.id && t.get(U.id);
@@ -912,7 +912,7 @@ const vn = (t, e) => {
912
912
  throw Error(`Bulk insert would overwrite the following annotations: ${B.map((O) => O.id).join(", ")}`);
913
913
  L.forEach((O) => {
914
914
  t.set(O.id, O), O.bodies.forEach((U) => e.set(U.id, O.id));
915
- }), i(w, { created: L });
915
+ }), s(w, { created: L });
916
916
  }
917
917
  }, A = (y) => {
918
918
  const x = typeof y == "string" ? y : y.id, w = t.get(x);
@@ -921,13 +921,13 @@ const vn = (t, e) => {
921
921
  console.warn(`Attempt to delete missing annotation: ${x}`);
922
922
  }, d = (y, x = k.LOCAL) => {
923
923
  const w = A(y);
924
- w && i(x, { deleted: [w] });
924
+ w && s(x, { deleted: [w] });
925
925
  }, c = (y, x = k.LOCAL) => {
926
926
  const w = y.reduce((L, B) => {
927
927
  const O = A(B);
928
928
  return O ? [...L, O] : L;
929
929
  }, []);
930
- w.length > 0 && i(x, { deleted: w });
930
+ w.length > 0 && s(x, { deleted: w });
931
931
  }, b = (y) => {
932
932
  const x = t.get(y.annotation);
933
933
  if (x) {
@@ -949,10 +949,10 @@ const vn = (t, e) => {
949
949
  console.warn(`Attempt to delete body from missing annotation ${y.annotation}`);
950
950
  }, S = (y, x = k.LOCAL) => {
951
951
  const w = b(y);
952
- w && i(x, { updated: [w] });
953
- }, v = (y, x = k.LOCAL) => {
952
+ w && s(x, { updated: [w] });
953
+ }, E = (y, x = k.LOCAL) => {
954
954
  const w = y.map((L) => b(L)).filter(Boolean);
955
- w.length > 0 && i(x, { updated: w });
955
+ w.length > 0 && s(x, { updated: w });
956
956
  }, C = (y) => {
957
957
  const x = t.get(y);
958
958
  return x ? { ...x } : void 0;
@@ -983,10 +983,10 @@ const vn = (t, e) => {
983
983
  console.warn(`Attempt to add body to missing annotation ${y.annotation}`);
984
984
  }, T = (y, x, w = k.LOCAL) => {
985
985
  const L = M(y, x);
986
- L && i(w, { updated: [L] });
986
+ L && s(w, { updated: [L] });
987
987
  }, I = (y, x = k.LOCAL) => {
988
988
  const w = y.map((L) => M({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
989
- i(x, { updated: w });
989
+ s(x, { updated: w });
990
990
  }, D = (y) => {
991
991
  const x = t.get(y.annotation);
992
992
  if (x) {
@@ -1011,15 +1011,15 @@ const vn = (t, e) => {
1011
1011
  return {
1012
1012
  addAnnotation: a,
1013
1013
  addBody: p,
1014
- all: E,
1014
+ all: v,
1015
1015
  bulkAddAnnotations: m,
1016
1016
  bulkDeleteAnnotations: c,
1017
- bulkDeleteBodies: v,
1017
+ bulkDeleteBodies: E,
1018
1018
  bulkUpdateAnnotations: h,
1019
1019
  bulkUpdateBodies: I,
1020
1020
  bulkUpdateTargets: (y, x = k.LOCAL) => {
1021
1021
  const w = y.map((L) => D(L)).filter(Boolean);
1022
- w.length > 0 && i(x, { updated: w });
1022
+ w.length > 0 && s(x, { updated: w });
1023
1023
  },
1024
1024
  bulkUpsertAnnotations: u,
1025
1025
  clear: g,
@@ -1028,19 +1028,19 @@ const vn = (t, e) => {
1028
1028
  getAnnotation: C,
1029
1029
  getBody: R,
1030
1030
  observe: o,
1031
- unobserve: s,
1031
+ unobserve: i,
1032
1032
  updateAnnotation: l,
1033
1033
  updateBody: T,
1034
1034
  updateTarget: (y, x = k.LOCAL) => {
1035
1035
  const w = D(y);
1036
- w && i(x, { updated: [w] });
1036
+ w && s(x, { updated: [w] });
1037
1037
  },
1038
1038
  upsertAnnotation: f
1039
1039
  };
1040
1040
  };
1041
1041
  let Tn = () => ({
1042
1042
  emit(t, ...e) {
1043
- for (let n = this.events[t] || [], o = 0, s = n.length; o < s; o++)
1043
+ for (let n = this.events[t] || [], o = 0, i = n.length; o < i; o++)
1044
1044
  n[o](...e);
1045
1045
  },
1046
1046
  events: {},
@@ -1048,46 +1048,46 @@ let Tn = () => ({
1048
1048
  var n;
1049
1049
  return ((n = this.events)[t] || (n[t] = [])).push(e), () => {
1050
1050
  var o;
1051
- this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((s) => e !== s);
1051
+ this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((i) => e !== i);
1052
1052
  };
1053
1053
  }
1054
1054
  });
1055
1055
  const On = 250, Rn = (t, e) => {
1056
1056
  const n = Tn(), o = [];
1057
- let s = -1, i = !1, a = 0;
1057
+ let i = -1, s = !1, a = 0;
1058
1058
  const r = (g) => {
1059
- if (!i) {
1059
+ if (!s) {
1060
1060
  const { changes: m } = g, A = performance.now();
1061
1061
  if (A - a > On)
1062
- o.splice(s + 1), o.push(m), s = o.length - 1;
1062
+ o.splice(i + 1), o.push(m), i = o.length - 1;
1063
1063
  else {
1064
1064
  const d = o.length - 1;
1065
1065
  o[d] = Sn(o[d], m);
1066
1066
  }
1067
1067
  a = A;
1068
1068
  }
1069
- i = !1;
1069
+ s = !1;
1070
1070
  };
1071
1071
  t.observe(r, { origin: k.LOCAL });
1072
- const l = (g) => g && g.length > 0 && t.bulkDeleteAnnotations(g), f = (g) => g && g.length > 0 && t.bulkAddAnnotations(g, !1), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotations(g.map(({ oldValue: m }) => m)), u = (g) => g && g.length > 0 && t.bulkUpdateAnnotations(g.map(({ newValue: m }) => m)), p = (g) => g && g.length > 0 && t.bulkAddAnnotations(g, !1), E = (g) => g && g.length > 0 && t.bulkDeleteAnnotations(g);
1072
+ const l = (g) => g && g.length > 0 && t.bulkDeleteAnnotations(g), f = (g) => g && g.length > 0 && t.bulkAddAnnotations(g, !1), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotations(g.map(({ oldValue: m }) => m)), u = (g) => g && g.length > 0 && t.bulkUpdateAnnotations(g.map(({ newValue: m }) => m)), p = (g) => g && g.length > 0 && t.bulkAddAnnotations(g, !1), v = (g) => g && g.length > 0 && t.bulkDeleteAnnotations(g);
1073
1073
  return {
1074
- canRedo: () => o.length - 1 > s,
1075
- canUndo: () => s > -1,
1074
+ canRedo: () => o.length - 1 > i,
1075
+ canUndo: () => i > -1,
1076
1076
  destroy: () => t.unobserve(r),
1077
- getHistory: () => ({ changes: [...o], pointer: s }),
1077
+ getHistory: () => ({ changes: [...o], pointer: i }),
1078
1078
  on: (g, m) => n.on(g, m),
1079
1079
  redo: () => {
1080
- if (o.length - 1 > s) {
1081
- i = !0;
1082
- const { created: g, updated: m, deleted: A } = o[s + 1];
1083
- f(g), u(m), E(A), n.emit("redo", o[s + 1]), s += 1;
1080
+ if (o.length - 1 > i) {
1081
+ s = !0;
1082
+ const { created: g, updated: m, deleted: A } = o[i + 1];
1083
+ f(g), u(m), v(A), n.emit("redo", o[i + 1]), i += 1;
1084
1084
  }
1085
1085
  },
1086
1086
  undo: () => {
1087
- if (s > -1) {
1088
- i = !0;
1089
- const { created: g, updated: m, deleted: A } = o[s];
1090
- l(g), h(m), p(A), n.emit("undo", o[s]), s -= 1;
1087
+ if (i > -1) {
1088
+ s = !0;
1089
+ const { created: g, updated: m, deleted: A } = o[i];
1090
+ l(g), h(m), p(A), n.emit("undo", o[i]), i -= 1;
1091
1091
  }
1092
1092
  }
1093
1093
  };
@@ -1098,7 +1098,7 @@ const On = 250, Rn = (t, e) => {
1098
1098
  set: e
1099
1099
  };
1100
1100
  }, Bn = (t, e, n, o) => {
1101
- const { hover: s, selection: i, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
1101
+ const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
1102
1102
  let f = [], h;
1103
1103
  const u = (m, A) => {
1104
1104
  l.has(m) ? l.get(m).push(A) : l.set(m, [A]);
@@ -1108,31 +1108,31 @@ const On = 250, Rn = (t, e) => {
1108
1108
  const c = d.indexOf(A);
1109
1109
  c !== -1 && d.splice(c, 1);
1110
1110
  }
1111
- }, E = (m, A, d) => {
1111
+ }, v = (m, A, d) => {
1112
1112
  l.has(m) && setTimeout(() => {
1113
1113
  l.get(m).forEach((c) => {
1114
1114
  if (n) {
1115
- const b = Array.isArray(A) ? A.map((v) => n.serialize(v)) : n.serialize(A), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1115
+ const b = Array.isArray(A) ? A.map((E) => n.serialize(E)) : n.serialize(A), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1116
1116
  c(b, S);
1117
1117
  } else
1118
1118
  c(A, d);
1119
1119
  });
1120
1120
  }, 1);
1121
1121
  };
1122
- i.subscribe(({ selected: m }) => {
1122
+ s.subscribe(({ selected: m }) => {
1123
1123
  if (!(f.length === 0 && m.length === 0)) {
1124
1124
  if (f.length === 0 && m.length > 0)
1125
1125
  f = m.map(({ id: A }) => a.getAnnotation(A));
1126
1126
  else if (f.length > 0 && m.length === 0)
1127
1127
  f.forEach((A) => {
1128
1128
  const d = a.getAnnotation(A.id);
1129
- d && !J(d, A) && E("updateAnnotation", d, A);
1129
+ d && !Q(d, A) && v("updateAnnotation", d, A);
1130
1130
  }), f = [];
1131
1131
  else {
1132
1132
  const A = new Set(f.map((c) => c.id)), d = new Set(m.map(({ id: c }) => c));
1133
1133
  f.filter((c) => !d.has(c.id)).forEach((c) => {
1134
1134
  const b = a.getAnnotation(c.id);
1135
- b && !J(b, c) && E("updateAnnotation", b, c);
1135
+ b && !Q(b, c) && v("updateAnnotation", b, c);
1136
1136
  }), f = [
1137
1137
  // Remove annotations that were deselected
1138
1138
  ...f.filter((c) => d.has(c.id)),
@@ -1140,19 +1140,19 @@ const On = 250, Rn = (t, e) => {
1140
1140
  ...m.filter(({ id: c }) => !A.has(c)).map(({ id: c }) => a.getAnnotation(c))
1141
1141
  ];
1142
1142
  }
1143
- E("selectionChanged", f);
1143
+ v("selectionChanged", f);
1144
1144
  }
1145
- }), s.subscribe((m) => {
1146
- !h && m ? E("mouseEnterAnnotation", a.getAnnotation(m)) : h && !m ? E("mouseLeaveAnnotation", a.getAnnotation(h)) : h && m && (E("mouseLeaveAnnotation", a.getAnnotation(h)), E("mouseEnterAnnotation", a.getAnnotation(m))), h = m;
1147
- }), r == null || r.subscribe((m) => E("viewportIntersect", m.map((A) => a.getAnnotation(A)))), a.observe((m) => {
1145
+ }), i.subscribe((m) => {
1146
+ !h && m ? v("mouseEnterAnnotation", a.getAnnotation(m)) : h && !m ? v("mouseLeaveAnnotation", a.getAnnotation(h)) : h && m && (v("mouseLeaveAnnotation", a.getAnnotation(h)), v("mouseEnterAnnotation", a.getAnnotation(m))), h = m;
1147
+ }), r == null || r.subscribe((m) => v("viewportIntersect", m.map((A) => a.getAnnotation(A)))), a.observe((m) => {
1148
1148
  const { created: A, deleted: d } = m.changes;
1149
- (A || []).forEach((c) => E("createAnnotation", c)), (d || []).forEach((c) => E("deleteAnnotation", c)), (m.changes.updated || []).filter((c) => [
1149
+ (A || []).forEach((c) => v("createAnnotation", c)), (d || []).forEach((c) => v("deleteAnnotation", c)), (m.changes.updated || []).filter((c) => [
1150
1150
  ...c.bodiesCreated || [],
1151
1151
  ...c.bodiesDeleted || [],
1152
1152
  ...c.bodiesUpdated || []
1153
1153
  ].length > 0).forEach(({ oldValue: c, newValue: b }) => {
1154
- const S = f.find((v) => v.id === c.id) || c;
1155
- f = f.map((v) => v.id === c.id ? b : v), E("updateAnnotation", b, S);
1154
+ const S = f.find((E) => E.id === c.id) || c;
1155
+ f = f.map((E) => E.id === c.id ? b : E), v("updateAnnotation", b, S);
1156
1156
  });
1157
1157
  }, { origin: k.LOCAL }), a.observe((m) => {
1158
1158
  if (f) {
@@ -1162,35 +1162,35 @@ const On = 250, Rn = (t, e) => {
1162
1162
  }, { origin: k.REMOTE });
1163
1163
  const g = (m) => (A) => {
1164
1164
  const { updated: d } = A;
1165
- m ? (d || []).forEach((c) => E("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => E("updateAnnotation", c.newValue, c.oldValue));
1165
+ m ? (d || []).forEach((c) => v("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => v("updateAnnotation", c.newValue, c.oldValue));
1166
1166
  };
1167
- return e.on("undo", g(!0)), e.on("redo", g(!1)), { on: u, off: p, emit: E };
1167
+ return e.on("undo", g(!0)), e.on("redo", g(!1)), { on: u, off: p, emit: v };
1168
1168
  }, kn = (t) => (e) => e.reduce((n, o) => {
1169
- const { parsed: s, error: i } = t.parse(o);
1170
- return i ? {
1169
+ const { parsed: i, error: s } = t.parse(o);
1170
+ return s ? {
1171
1171
  parsed: n.parsed,
1172
1172
  failed: [...n.failed, o]
1173
- } : s ? {
1174
- parsed: [...n.parsed, s],
1173
+ } : i ? {
1174
+ parsed: [...n.parsed, i],
1175
1175
  failed: n.failed
1176
1176
  } : {
1177
1177
  ...n
1178
1178
  };
1179
1179
  }, { parsed: [], failed: [] }), In = (t, e, n) => {
1180
- const { store: o, selection: s } = t, i = (d) => {
1180
+ const { store: o, selection: i } = t, s = (d) => {
1181
1181
  if (n) {
1182
1182
  const { parsed: c, error: b } = n.parse(d);
1183
1183
  c ? o.addAnnotation(c, k.REMOTE) : console.error(b);
1184
1184
  } else
1185
1185
  o.addAnnotation(Mt(d), k.REMOTE);
1186
- }, a = () => s.clear(), r = () => o.clear(), l = (d) => {
1186
+ }, a = () => i.clear(), r = () => o.clear(), l = (d) => {
1187
1187
  const c = o.getAnnotation(d);
1188
1188
  return n && c ? n.serialize(c) : c;
1189
1189
  }, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1190
1190
  var d;
1191
- const c = (((d = s.selected) == null ? void 0 : d.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
1191
+ const c = (((d = i.selected) == null ? void 0 : d.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
1192
1192
  return n ? c.map(n.serialize) : c;
1193
- }, u = (d, c = !0) => fetch(d).then((b) => b.json()).then((b) => (E(b, c), b)), p = (d) => {
1193
+ }, u = (d, c = !0) => fetch(d).then((b) => b.json()).then((b) => (v(b, c), b)), p = (d) => {
1194
1194
  if (typeof d == "string") {
1195
1195
  const c = o.getAnnotation(d);
1196
1196
  if (o.deleteAnnotation(d), c)
@@ -1200,16 +1200,16 @@ const On = 250, Rn = (t, e) => {
1200
1200
  if (c)
1201
1201
  return o.deleteAnnotation(c), d;
1202
1202
  }
1203
- }, E = (d, c = !0) => {
1203
+ }, v = (d, c = !0) => {
1204
1204
  if (n) {
1205
- const b = n.parseAll || kn(n), { parsed: S, failed: v } = b(d);
1206
- v.length > 0 && console.warn(`Discarded ${v.length} invalid annotations`, v), o.bulkAddAnnotations(S, c, k.REMOTE);
1205
+ const b = n.parseAll || kn(n), { parsed: S, failed: E } = b(d);
1206
+ E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotations(S, c, k.REMOTE);
1207
1207
  } else
1208
1208
  o.bulkAddAnnotations(d.map(Mt), c, k.REMOTE);
1209
1209
  }, g = (d, c) => {
1210
- d ? s.setSelected(d, c) : s.clear();
1210
+ d ? i.setSelected(d, c) : i.clear();
1211
1211
  }, m = (d) => {
1212
- s.clear(), s.setUserSelectAction(d);
1212
+ i.clear(), i.setUserSelectAction(d);
1213
1213
  }, A = (d) => {
1214
1214
  if (n) {
1215
1215
  const c = n.parse(d).parsed, b = n.serialize(o.getAnnotation(c.id));
@@ -1220,7 +1220,7 @@ const On = 250, Rn = (t, e) => {
1220
1220
  }
1221
1221
  };
1222
1222
  return {
1223
- addAnnotation: i,
1223
+ addAnnotation: s,
1224
1224
  cancelSelected: a,
1225
1225
  canRedo: e.canRedo,
1226
1226
  canUndo: e.canUndo,
@@ -1232,7 +1232,7 @@ const On = 250, Rn = (t, e) => {
1232
1232
  loadAnnotations: u,
1233
1233
  redo: e.redo,
1234
1234
  removeAnnotation: p,
1235
- setAnnotations: E,
1235
+ setAnnotations: v,
1236
1236
  setSelected: g,
1237
1237
  setUserSelectAction: m,
1238
1238
  undo: e.undo,
@@ -1240,13 +1240,13 @@ const On = 250, Rn = (t, e) => {
1240
1240
  };
1241
1241
  }, Un = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1242
1242
  let _n = (t) => crypto.getRandomValues(new Uint8Array(t)), Nn = (t, e, n) => {
1243
- let o = (2 << Math.log2(t.length - 1)) - 1, s = -~(1.6 * o * e / t.length);
1244
- return (i = e) => {
1243
+ let o = (2 << Math.log2(t.length - 1)) - 1, i = -~(1.6 * o * e / t.length);
1244
+ return (s = e) => {
1245
1245
  let a = "";
1246
1246
  for (; ; ) {
1247
- let r = n(s), l = s | 0;
1247
+ let r = n(i), l = i | 0;
1248
1248
  for (; l--; )
1249
- if (a += t[r[l] & o] || "", a.length >= i) return a;
1249
+ if (a += t[r[l] & o] || "", a.length >= s) return a;
1250
1250
  }
1251
1251
  };
1252
1252
  }, Vn = (t, e = 21) => Nn(t, e | 0, _n), Dn = (t = 21) => {
@@ -1258,18 +1258,18 @@ let _n = (t) => crypto.getRandomValues(new Uint8Array(t)), Nn = (t, e, n) => {
1258
1258
  const Yn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Kn = (t) => {
1259
1259
  const e = JSON.stringify(t);
1260
1260
  let n = 0;
1261
- for (let o = 0, s = e.length; o < s; o++) {
1262
- let i = e.charCodeAt(o);
1263
- n = (n << 5) - n + i, n |= 0;
1261
+ for (let o = 0, i = e.length; o < i; o++) {
1262
+ let s = e.charCodeAt(o);
1263
+ n = (n << 5) - n + s, n |= 0;
1264
1264
  }
1265
1265
  return `${n}`;
1266
1266
  }, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1267
- const { id: o, type: s, purpose: i, value: a, created: r, modified: l, creator: f, ...h } = n;
1267
+ const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...h } = n;
1268
1268
  return {
1269
1269
  id: o || `temp-${Kn(n)}`,
1270
1270
  annotation: e,
1271
- type: s,
1272
- purpose: i,
1271
+ type: i,
1272
+ purpose: s,
1273
1273
  value: a,
1274
1274
  creator: ge(f),
1275
1275
  created: r ? new Date(r) : void 0,
@@ -1278,10 +1278,10 @@ const Yn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
1278
1278
  };
1279
1279
  }), Pn = (t) => t.map((e) => {
1280
1280
  var n;
1281
- const { annotation: o, created: s, updated: i, ...a } = e, r = {
1281
+ const { annotation: o, created: i, updated: s, ...a } = e, r = {
1282
1282
  ...a,
1283
- created: s == null ? void 0 : s.toISOString(),
1284
- modified: i == null ? void 0 : i.toISOString()
1283
+ created: i == null ? void 0 : i.toISOString(),
1284
+ modified: s == null ? void 0 : s.toISOString()
1285
1285
  };
1286
1286
  return (n = r.id) != null && n.startsWith("temp-") && delete r.id, r;
1287
1287
  });
@@ -1294,15 +1294,15 @@ const xo = (t, e) => ({
1294
1294
  id: e,
1295
1295
  creator: n,
1296
1296
  created: o,
1297
- modified: s,
1298
- target: i
1299
- } = t, a = Array.isArray(i) ? i : [i];
1297
+ modified: i,
1298
+ target: s
1299
+ } = t, a = Array.isArray(s) ? s : [s];
1300
1300
  if (a.length === 0)
1301
1301
  return { error: Error(`No targets found for annotation: ${t.id}`) };
1302
1302
  const r = {
1303
1303
  creator: ge(n),
1304
1304
  created: o ? new Date(o) : void 0,
1305
- updated: s ? new Date(s) : void 0,
1305
+ updated: i ? new Date(i) : void 0,
1306
1306
  annotation: e,
1307
1307
  selector: [],
1308
1308
  // @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
@@ -1342,10 +1342,10 @@ const xo = (t, e) => ({
1342
1342
  const e = t.id || fe(), {
1343
1343
  creator: n,
1344
1344
  created: o,
1345
- modified: s,
1346
- body: i,
1345
+ modified: i,
1346
+ body: s,
1347
1347
  ...a
1348
- } = t, r = Xn(i, e), l = Hn(t);
1348
+ } = t, r = Xn(s, e), l = Hn(t);
1349
1349
  return "error" in l ? { error: l.error } : {
1350
1350
  parsed: {
1351
1351
  ...a,
@@ -1355,14 +1355,14 @@ const xo = (t, e) => ({
1355
1355
  }
1356
1356
  };
1357
1357
  }, zn = (t, e, n) => {
1358
- const { bodies: o, target: s, ...i } = t, {
1358
+ const { bodies: o, target: i, ...s } = t, {
1359
1359
  selector: a,
1360
1360
  creator: r,
1361
1361
  created: l,
1362
1362
  updated: f,
1363
1363
  ...h
1364
- } = s, u = a.map((p) => {
1365
- const { id: E, quote: g, start: m, end: A, range: d } = p, { prefix: c, suffix: b } = Be(d, n), S = [{
1364
+ } = i, u = a.map((p) => {
1365
+ const { id: v, quote: g, start: m, end: A, range: d } = p, { prefix: c, suffix: b } = Be(d, n), S = [{
1366
1366
  type: "TextQuoteSelector",
1367
1367
  exact: g,
1368
1368
  prefix: c,
@@ -1374,7 +1374,7 @@ const xo = (t, e) => ({
1374
1374
  }];
1375
1375
  return {
1376
1376
  ...h,
1377
- id: E,
1377
+ id: v,
1378
1378
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1379
1379
  scope: "scope" in p ? p.scope : void 0,
1380
1380
  source: e,
@@ -1382,7 +1382,7 @@ const xo = (t, e) => ({
1382
1382
  };
1383
1383
  });
1384
1384
  return {
1385
- ...i,
1385
+ ...s,
1386
1386
  "@context": "http://www.w3.org/ns/anno.jsonld",
1387
1387
  id: t.id,
1388
1388
  type: "Annotation",
@@ -1393,22 +1393,22 @@ const xo = (t, e) => ({
1393
1393
  target: u
1394
1394
  };
1395
1395
  };
1396
- function me(t, e, n = 0, o = t.length - 1, s = Fn) {
1396
+ function me(t, e, n = 0, o = t.length - 1, i = Fn) {
1397
1397
  for (; o > n; ) {
1398
1398
  if (o - n > 600) {
1399
- 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), E = Math.max(n, Math.floor(e - f * u / l + p)), g = Math.min(o, Math.floor(e + (l - f) * u / l + p));
1400
- me(t, e, E, g, s);
1399
+ 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), v = Math.max(n, Math.floor(e - f * u / l + p)), g = Math.min(o, Math.floor(e + (l - f) * u / l + p));
1400
+ me(t, e, v, g, i);
1401
1401
  }
1402
- const i = t[e];
1402
+ const s = t[e];
1403
1403
  let a = n, r = o;
1404
- for (ot(t, n, e), s(t[o], i) > 0 && ot(t, n, o); a < r; ) {
1405
- for (ot(t, a, r), a++, r--; s(t[a], i) < 0; ) a++;
1406
- for (; s(t[r], i) > 0; ) r--;
1404
+ for (nt(t, n, e), i(t[o], s) > 0 && nt(t, n, o); a < r; ) {
1405
+ for (nt(t, a, r), a++, r--; i(t[a], s) < 0; ) a++;
1406
+ for (; i(t[r], s) > 0; ) r--;
1407
1407
  }
1408
- s(t[n], i) === 0 ? ot(t, n, r) : (r++, ot(t, r, o)), r <= e && (n = r + 1), e <= r && (o = r - 1);
1408
+ i(t[n], s) === 0 ? nt(t, n, r) : (r++, nt(t, r, o)), r <= e && (n = r + 1), e <= r && (o = r - 1);
1409
1409
  }
1410
1410
  }
1411
- function ot(t, e, n) {
1411
+ function nt(t, e, n) {
1412
1412
  const o = t[e];
1413
1413
  t[e] = t[n], t[n] = o;
1414
1414
  }
@@ -1426,13 +1426,13 @@ class Wn {
1426
1426
  let n = this.data;
1427
1427
  const o = [];
1428
1428
  if (!yt(e, n)) return o;
1429
- const s = this.toBBox, i = [];
1429
+ const i = this.toBBox, s = [];
1430
1430
  for (; n; ) {
1431
1431
  for (let a = 0; a < n.children.length; a++) {
1432
- const r = n.children[a], l = n.leaf ? s(r) : r;
1433
- yt(e, l) && (n.leaf ? o.push(r) : kt(e, l) ? this._all(r, o) : i.push(r));
1432
+ const r = n.children[a], l = n.leaf ? i(r) : r;
1433
+ yt(e, l) && (n.leaf ? o.push(r) : kt(e, l) ? this._all(r, o) : s.push(r));
1434
1434
  }
1435
- n = i.pop();
1435
+ n = s.pop();
1436
1436
  }
1437
1437
  return o;
1438
1438
  }
@@ -1441,11 +1441,11 @@ class Wn {
1441
1441
  if (!yt(e, n)) return !1;
1442
1442
  const o = [];
1443
1443
  for (; n; ) {
1444
- for (let s = 0; s < n.children.length; s++) {
1445
- const i = n.children[s], a = n.leaf ? this.toBBox(i) : i;
1444
+ for (let i = 0; i < n.children.length; i++) {
1445
+ const s = n.children[i], a = n.leaf ? this.toBBox(s) : s;
1446
1446
  if (yt(e, a)) {
1447
1447
  if (n.leaf || kt(e, a)) return !0;
1448
- o.push(i);
1448
+ o.push(s);
1449
1449
  }
1450
1450
  }
1451
1451
  n = o.pop();
@@ -1477,20 +1477,20 @@ class Wn {
1477
1477
  return e && this._insert(e, this.data.height - 1), this;
1478
1478
  }
1479
1479
  clear() {
1480
- return this.data = et([]), this;
1480
+ return this.data = tt([]), this;
1481
1481
  }
1482
1482
  remove(e, n) {
1483
1483
  if (!e) return this;
1484
1484
  let o = this.data;
1485
- const s = this.toBBox(e), i = [], a = [];
1485
+ const i = this.toBBox(e), s = [], a = [];
1486
1486
  let r, l, f;
1487
- for (; o || i.length; ) {
1488
- if (o || (o = i.pop(), l = i[i.length - 1], r = a.pop(), f = !0), o.leaf) {
1487
+ for (; o || s.length; ) {
1488
+ if (o || (o = s.pop(), l = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
1489
1489
  const h = qn(e, o.children, n);
1490
1490
  if (h !== -1)
1491
- return o.children.splice(h, 1), i.push(o), this._condense(i), this;
1491
+ return o.children.splice(h, 1), s.push(o), this._condense(s), this;
1492
1492
  }
1493
- !f && !o.leaf && kt(o, s) ? (i.push(o), a.push(r), r = 0, l = o, o = o.children[0]) : l ? (r++, o = l.children[r], f = !1) : o = null;
1493
+ !f && !o.leaf && kt(o, i) ? (s.push(o), a.push(r), r = 0, l = o, o = o.children[0]) : l ? (r++, o = l.children[r], f = !1) : o = null;
1494
1494
  }
1495
1495
  return this;
1496
1496
  }
@@ -1515,86 +1515,86 @@ class Wn {
1515
1515
  e.leaf ? n.push(...e.children) : o.push(...e.children), e = o.pop();
1516
1516
  return n;
1517
1517
  }
1518
- _build(e, n, o, s) {
1519
- const i = o - n + 1;
1518
+ _build(e, n, o, i) {
1519
+ const s = o - n + 1;
1520
1520
  let a = this._maxEntries, r;
1521
- if (i <= a)
1522
- return r = et(e.slice(n, o + 1)), tt(r, this.toBBox), r;
1523
- s || (s = Math.ceil(Math.log(i) / Math.log(a)), a = Math.ceil(i / Math.pow(a, s - 1))), r = et([]), r.leaf = !1, r.height = s;
1524
- const l = Math.ceil(i / a), f = l * Math.ceil(Math.sqrt(a));
1521
+ if (s <= a)
1522
+ return r = tt(e.slice(n, o + 1)), Z(r, this.toBBox), r;
1523
+ i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r = tt([]), r.leaf = !1, r.height = i;
1524
+ const l = Math.ceil(s / a), f = l * Math.ceil(Math.sqrt(a));
1525
1525
  ee(e, n, o, f, this.compareMinX);
1526
1526
  for (let h = n; h <= o; h += f) {
1527
1527
  const u = Math.min(h + f - 1, o);
1528
1528
  ee(e, h, u, l, this.compareMinY);
1529
1529
  for (let p = h; p <= u; p += l) {
1530
- const E = Math.min(p + l - 1, u);
1531
- r.children.push(this._build(e, p, E, s - 1));
1530
+ const v = Math.min(p + l - 1, u);
1531
+ r.children.push(this._build(e, p, v, i - 1));
1532
1532
  }
1533
1533
  }
1534
- return tt(r, this.toBBox), r;
1534
+ return Z(r, this.toBBox), r;
1535
1535
  }
1536
- _chooseSubtree(e, n, o, s) {
1537
- for (; s.push(n), !(n.leaf || s.length - 1 === o); ) {
1538
- let i = 1 / 0, a = 1 / 0, r;
1536
+ _chooseSubtree(e, n, o, i) {
1537
+ for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1538
+ let s = 1 / 0, a = 1 / 0, r;
1539
1539
  for (let l = 0; l < n.children.length; l++) {
1540
1540
  const f = n.children[l], h = Bt(f), u = Jn(e, f) - h;
1541
- u < a ? (a = u, i = h < i ? h : i, r = f) : u === a && h < i && (i = h, r = f);
1541
+ u < a ? (a = u, s = h < s ? h : s, r = f) : u === a && h < s && (s = h, r = f);
1542
1542
  }
1543
1543
  n = r || n.children[0];
1544
1544
  }
1545
1545
  return n;
1546
1546
  }
1547
1547
  _insert(e, n, o) {
1548
- const s = o ? e : this.toBBox(e), i = [], a = this._chooseSubtree(s, this.data, n, i);
1549
- for (a.children.push(e), rt(a, s); n >= 0 && i[n].children.length > this._maxEntries; )
1550
- this._split(i, n), n--;
1551
- this._adjustParentBBoxes(s, i, n);
1548
+ const i = o ? e : this.toBBox(e), s = [], a = this._chooseSubtree(i, this.data, n, s);
1549
+ for (a.children.push(e), rt(a, i); n >= 0 && s[n].children.length > this._maxEntries; )
1550
+ this._split(s, n), n--;
1551
+ this._adjustParentBBoxes(i, s, n);
1552
1552
  }
1553
1553
  // split overflowed node into two
1554
1554
  _split(e, n) {
1555
- const o = e[n], s = o.children.length, i = this._minEntries;
1556
- this._chooseSplitAxis(o, i, s);
1557
- const a = this._chooseSplitIndex(o, i, s), r = et(o.children.splice(a, o.children.length - a));
1558
- r.height = o.height, r.leaf = o.leaf, tt(o, this.toBBox), tt(r, this.toBBox), n ? e[n - 1].children.push(r) : this._splitRoot(o, r);
1555
+ const o = e[n], i = o.children.length, s = this._minEntries;
1556
+ this._chooseSplitAxis(o, s, i);
1557
+ const a = this._chooseSplitIndex(o, s, i), r = tt(o.children.splice(a, o.children.length - a));
1558
+ r.height = o.height, r.leaf = o.leaf, Z(o, this.toBBox), Z(r, this.toBBox), n ? e[n - 1].children.push(r) : this._splitRoot(o, r);
1559
1559
  }
1560
1560
  _splitRoot(e, n) {
1561
- this.data = et([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, tt(this.data, this.toBBox);
1561
+ this.data = tt([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, Z(this.data, this.toBBox);
1562
1562
  }
1563
1563
  _chooseSplitIndex(e, n, o) {
1564
- let s, i = 1 / 0, a = 1 / 0;
1564
+ let i, s = 1 / 0, a = 1 / 0;
1565
1565
  for (let r = n; r <= o - n; r++) {
1566
- const l = it(e, 0, r, this.toBBox), f = it(e, r, o, this.toBBox), h = Zn(l, f), u = Bt(l) + Bt(f);
1567
- h < i ? (i = h, s = r, a = u < a ? u : a) : h === i && u < a && (a = u, s = r);
1566
+ const l = st(e, 0, r, this.toBBox), f = st(e, r, o, this.toBBox), h = Zn(l, f), u = Bt(l) + Bt(f);
1567
+ h < s ? (s = h, i = r, a = u < a ? u : a) : h === s && u < a && (a = u, i = r);
1568
1568
  }
1569
- return s || o - n;
1569
+ return i || o - n;
1570
1570
  }
1571
1571
  // sorts node children by the best axis for split
1572
1572
  _chooseSplitAxis(e, n, o) {
1573
- const s = e.leaf ? this.compareMinX : Gn, i = e.leaf ? this.compareMinY : Qn, a = this._allDistMargin(e, n, o, s), r = this._allDistMargin(e, n, o, i);
1574
- a < r && e.children.sort(s);
1573
+ const i = e.leaf ? this.compareMinX : Gn, s = e.leaf ? this.compareMinY : Qn, a = this._allDistMargin(e, n, o, i), r = this._allDistMargin(e, n, o, s);
1574
+ a < r && e.children.sort(i);
1575
1575
  }
1576
1576
  // total margin of all possible split distributions where each node is at least m full
1577
- _allDistMargin(e, n, o, s) {
1578
- e.children.sort(s);
1579
- const i = this.toBBox, a = it(e, 0, n, i), r = it(e, o - n, o, i);
1577
+ _allDistMargin(e, n, o, i) {
1578
+ e.children.sort(i);
1579
+ const s = this.toBBox, a = st(e, 0, n, s), r = st(e, o - n, o, s);
1580
1580
  let l = mt(a) + mt(r);
1581
1581
  for (let f = n; f < o - n; f++) {
1582
1582
  const h = e.children[f];
1583
- rt(a, e.leaf ? i(h) : h), l += mt(a);
1583
+ rt(a, e.leaf ? s(h) : h), l += mt(a);
1584
1584
  }
1585
1585
  for (let f = o - n - 1; f >= n; f--) {
1586
1586
  const h = e.children[f];
1587
- rt(r, e.leaf ? i(h) : h), l += mt(r);
1587
+ rt(r, e.leaf ? s(h) : h), l += mt(r);
1588
1588
  }
1589
1589
  return l;
1590
1590
  }
1591
1591
  _adjustParentBBoxes(e, n, o) {
1592
- for (let s = o; s >= 0; s--)
1593
- rt(n[s], e);
1592
+ for (let i = o; i >= 0; i--)
1593
+ rt(n[i], e);
1594
1594
  }
1595
1595
  _condense(e) {
1596
1596
  for (let n = e.length - 1, o; n >= 0; n--)
1597
- e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : tt(e[n], this.toBBox);
1597
+ e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : Z(e[n], this.toBBox);
1598
1598
  }
1599
1599
  }
1600
1600
  function qn(t, e, n) {
@@ -1603,16 +1603,16 @@ function qn(t, e, n) {
1603
1603
  if (n(t, e[o])) return o;
1604
1604
  return -1;
1605
1605
  }
1606
- function tt(t, e) {
1607
- it(t, 0, t.children.length, e, t);
1606
+ function Z(t, e) {
1607
+ st(t, 0, t.children.length, e, t);
1608
1608
  }
1609
- function it(t, e, n, o, s) {
1610
- s || (s = et(null)), s.minX = 1 / 0, s.minY = 1 / 0, s.maxX = -1 / 0, s.maxY = -1 / 0;
1611
- for (let i = e; i < n; i++) {
1612
- const a = t.children[i];
1613
- rt(s, t.leaf ? o(a) : a);
1609
+ function st(t, e, n, o, i) {
1610
+ i || (i = tt(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1611
+ for (let s = e; s < n; s++) {
1612
+ const a = t.children[s];
1613
+ rt(i, t.leaf ? o(a) : a);
1614
1614
  }
1615
- return s;
1615
+ return i;
1616
1616
  }
1617
1617
  function rt(t, e) {
1618
1618
  return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
@@ -1633,8 +1633,8 @@ function Jn(t, e) {
1633
1633
  return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
1634
1634
  }
1635
1635
  function Zn(t, e) {
1636
- const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), s = Math.min(t.maxX, e.maxX), i = Math.min(t.maxY, e.maxY);
1637
- return Math.max(0, s - n) * Math.max(0, i - o);
1636
+ const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
1637
+ return Math.max(0, i - n) * Math.max(0, s - o);
1638
1638
  }
1639
1639
  function kt(t, e) {
1640
1640
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
@@ -1642,7 +1642,7 @@ function kt(t, e) {
1642
1642
  function yt(t, e) {
1643
1643
  return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
1644
1644
  }
1645
- function et(t) {
1645
+ function tt(t) {
1646
1646
  return {
1647
1647
  children: t,
1648
1648
  height: 1,
@@ -1653,22 +1653,22 @@ function et(t) {
1653
1653
  maxY: -1 / 0
1654
1654
  };
1655
1655
  }
1656
- function ee(t, e, n, o, s) {
1657
- const i = [e, n];
1658
- for (; i.length; ) {
1659
- if (n = i.pop(), e = i.pop(), n - e <= o) continue;
1656
+ function ee(t, e, n, o, i) {
1657
+ const s = [e, n];
1658
+ for (; s.length; ) {
1659
+ if (n = s.pop(), e = s.pop(), n - e <= o) continue;
1660
1660
  const a = e + Math.ceil((n - e) / o / 2) * o;
1661
- me(t, a, e, n, s), i.push(e, a, a, n);
1661
+ me(t, a, e, n, i), s.push(e, a, a, n);
1662
1662
  }
1663
1663
  }
1664
1664
  const to = (t, e) => {
1665
- const n = new Wn(), o = /* @__PURE__ */ new Map(), s = (d, c) => {
1666
- const b = d.selector.flatMap((v) => {
1667
- const C = q([v]) ? v.range : ae(v, e).range;
1665
+ const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
1666
+ const b = d.selector.flatMap((E) => {
1667
+ const C = q([E]) ? E.range : ae(E, e).range;
1668
1668
  return Array.from(C.getClientRects());
1669
- }), S = Ne(b).map(({ left: v, top: C, right: R, bottom: M }) => new DOMRect(v - c.left, C - c.top, R - v, M - C));
1670
- return S.map((v) => {
1671
- const { x: C, y: R, width: M, height: T } = v;
1669
+ }), S = Ne(b).map(({ left: E, top: C, right: R, bottom: M }) => new DOMRect(E - c.left, C - c.top, R - E, M - C));
1670
+ return S.map((E) => {
1671
+ const { x: C, y: R, width: M, height: T } = E;
1672
1672
  return {
1673
1673
  minX: C,
1674
1674
  minY: R,
@@ -1680,10 +1680,10 @@ const to = (t, e) => {
1680
1680
  }
1681
1681
  };
1682
1682
  });
1683
- }, i = () => [...o.values()], a = () => {
1683
+ }, s = () => [...o.values()], a = () => {
1684
1684
  n.clear(), o.clear();
1685
1685
  }, r = (d) => {
1686
- const c = s(d, e.getBoundingClientRect());
1686
+ const c = i(d, e.getBoundingClientRect());
1687
1687
  c.length !== 0 && (c.forEach((b) => n.insert(b)), o.set(d.annotation, c));
1688
1688
  }, l = (d) => {
1689
1689
  const c = o.get(d.annotation);
@@ -1692,45 +1692,45 @@ const to = (t, e) => {
1692
1692
  l(d), r(d);
1693
1693
  }, h = (d, c = !0) => {
1694
1694
  c && a();
1695
- const b = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: s(C, b) }));
1695
+ const b = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: i(C, b) }));
1696
1696
  S.forEach(({ target: C, rects: R }) => {
1697
1697
  R.length > 0 && o.set(C.annotation, R);
1698
1698
  });
1699
- const v = S.flatMap(({ rects: C }) => C);
1700
- n.load(v);
1699
+ const E = S.flatMap(({ rects: C }) => C);
1700
+ n.load(E);
1701
1701
  }, u = (d, c, b = !1) => {
1702
1702
  const S = n.search({
1703
1703
  minX: d,
1704
1704
  minY: c,
1705
1705
  maxX: d,
1706
1706
  maxY: c
1707
- }), v = (C) => C.annotation.rects.reduce((R, M) => R + M.width * M.height, 0);
1708
- return S.length > 0 ? (S.sort((C, R) => v(C) - v(R)), b ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
1707
+ }), E = (C) => C.annotation.rects.reduce((R, M) => R + M.width * M.height, 0);
1708
+ return S.length > 0 ? (S.sort((C, R) => E(C) - E(R)), b ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
1709
1709
  }, p = (d) => {
1710
- const c = E(d);
1710
+ const c = v(d);
1711
1711
  if (c.length === 0)
1712
1712
  return;
1713
- let b = c[0].left, S = c[0].top, v = c[0].right, C = c[0].bottom;
1713
+ let b = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
1714
1714
  for (let R = 1; R < c.length; R++) {
1715
1715
  const M = c[R];
1716
- b = Math.min(b, M.left), S = Math.min(S, M.top), v = Math.max(v, M.right), C = Math.max(C, M.bottom);
1716
+ b = Math.min(b, M.left), S = Math.min(S, M.top), E = Math.max(E, M.right), C = Math.max(C, M.bottom);
1717
1717
  }
1718
- return new DOMRect(b, S, v - b, C - S);
1719
- }, E = (d) => {
1718
+ return new DOMRect(b, S, E - b, C - S);
1719
+ }, v = (d) => {
1720
1720
  const c = o.get(d);
1721
1721
  return c ? c[0].annotation.rects : [];
1722
1722
  };
1723
1723
  return {
1724
- all: i,
1724
+ all: s,
1725
1725
  clear: a,
1726
1726
  getAt: u,
1727
1727
  getAnnotationBounds: p,
1728
- getAnnotationRects: E,
1728
+ getAnnotationRects: v,
1729
1729
  getIntersecting: (d, c, b, S) => {
1730
- const v = n.search({ minX: d, minY: c, maxX: b, maxY: S }), C = new Set(v.map((R) => R.annotation.id));
1730
+ const E = n.search({ minX: d, minY: c, maxX: b, maxY: S }), C = new Set(E.map((R) => R.annotation.id));
1731
1731
  return Array.from(C).map((R) => ({
1732
1732
  annotation: t.getAnnotation(R),
1733
- rects: E(R)
1733
+ rects: v(R)
1734
1734
  })).filter((R) => !!R.annotation);
1735
1735
  },
1736
1736
  insert: r,
@@ -1741,18 +1741,18 @@ const to = (t, e) => {
1741
1741
  update: f
1742
1742
  };
1743
1743
  }, eo = (t, e) => {
1744
- const n = Ln(), o = to(n, t), s = pn(n);
1745
- s.setUserSelectAction(e);
1746
- const i = fn(n), a = Mn(), r = (d, c = k.LOCAL) => {
1747
- const b = vt(d, t), S = q(b.target.selector);
1744
+ const n = Ln(), o = to(n, t), i = pn(n);
1745
+ i.setUserSelectAction(e);
1746
+ const s = fn(n), a = Mn(), r = (d, c = k.LOCAL) => {
1747
+ const b = Et(d, t), S = q(b.target.selector);
1748
1748
  return S && n.addAnnotation(b, c), S;
1749
1749
  }, l = (d, c = !0, b = k.LOCAL) => {
1750
- const S = d.map((C) => vt(C, t)), v = S.filter((C) => !q(C.target.selector));
1751
- return n.bulkAddAnnotations(S, c, b), v;
1750
+ const S = d.map((C) => Et(C, t)), E = S.filter((C) => !q(C.target.selector));
1751
+ return n.bulkAddAnnotations(S, c, b), E;
1752
1752
  }, f = (d, c = k.LOCAL) => {
1753
- const b = d.map((v) => vt(v, t)), S = b.filter((v) => !q(v.target.selector));
1754
- return b.forEach((v) => {
1755
- n.getAnnotation(v.id) ? n.updateAnnotation(v, c) : n.addAnnotation(v, c);
1753
+ const b = d.map((E) => Et(E, t)), S = b.filter((E) => !q(E.target.selector));
1754
+ return b.forEach((E) => {
1755
+ n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
1756
1756
  }), S;
1757
1757
  }, h = (d, c = k.LOCAL) => {
1758
1758
  const b = At(d, t);
@@ -1762,17 +1762,17 @@ const to = (t, e) => {
1762
1762
  n.bulkUpdateTargets(b, c);
1763
1763
  };
1764
1764
  function p(d, c, b, S) {
1765
- const v = b || !!S, C = o.getAt(d, c, v).map((M) => n.getAnnotation(M)), R = S ? C.filter(S) : C;
1765
+ const E = b || !!S, C = o.getAt(d, c, E).map((M) => n.getAnnotation(M)), R = S ? C.filter(S) : C;
1766
1766
  if (R.length !== 0)
1767
1767
  return b ? R : R[0];
1768
1768
  }
1769
- const E = (d) => {
1769
+ const v = (d) => {
1770
1770
  if (o.getAnnotationRects(d).length !== 0)
1771
1771
  return o.getAnnotationBounds(d);
1772
1772
  }, g = (d, c, b, S) => o.getIntersecting(d, c, b, S), m = (d) => o.getAnnotationRects(d), A = () => o.recalculate();
1773
1773
  return n.observe(({ changes: d }) => {
1774
- const c = (d.deleted || []).filter((v) => q(v.target.selector)), b = (d.created || []).filter((v) => q(v.target.selector)), S = (d.updated || []).filter((v) => q(v.newValue.target.selector));
1775
- (c == null ? void 0 : c.length) > 0 && c.forEach((v) => o.remove(v.target)), b.length > 0 && o.set(b.map((v) => v.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: v }) => o.update(v.target));
1774
+ const c = (d.deleted || []).filter((E) => q(E.target.selector)), b = (d.created || []).filter((E) => q(E.target.selector)), S = (d.updated || []).filter((E) => q(E.newValue.target.selector));
1775
+ (c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), b.length > 0 && o.set(b.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
1776
1776
  }), {
1777
1777
  store: {
1778
1778
  ...n,
@@ -1780,15 +1780,15 @@ const to = (t, e) => {
1780
1780
  bulkAddAnnotation: l,
1781
1781
  bulkUpdateTargets: u,
1782
1782
  bulkUpsertAnnotations: f,
1783
- getAnnotationBounds: E,
1783
+ getAnnotationBounds: v,
1784
1784
  getAnnotationRects: m,
1785
1785
  getIntersecting: g,
1786
1786
  getAt: p,
1787
1787
  recalculatePositions: A,
1788
1788
  updateTarget: h
1789
1789
  },
1790
- selection: s,
1791
- hover: i,
1790
+ selection: i,
1791
+ hover: s,
1792
1792
  viewport: a
1793
1793
  };
1794
1794
  }, no = () => {
@@ -1799,9 +1799,9 @@ const to = (t, e) => {
1799
1799
  }, oo = (t, e = {}) => {
1800
1800
  const n = no(), o = n.getContext("2d");
1801
1801
  document.body.appendChild(n);
1802
- const s = /* @__PURE__ */ new Map(), i = (h) => Array.from(s.entries()).filter(([u, p]) => p.presenceKey === h.presenceKey).map(([u, p]) => u);
1802
+ const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u, p]) => p.presenceKey === h.presenceKey).map(([u, p]) => u);
1803
1803
  return t.on("selectionChange", (h, u) => {
1804
- i(h).forEach((E) => s.delete(E)), u && u.forEach((E) => s.set(E, h));
1804
+ s(h).forEach((v) => i.delete(v)), u && u.forEach((v) => i.set(v, h));
1805
1805
  }), {
1806
1806
  clear: () => {
1807
1807
  const { width: h, height: u } = n;
@@ -1812,13 +1812,13 @@ const to = (t, e) => {
1812
1812
  },
1813
1813
  paint: (h, u, p) => {
1814
1814
  e.font && (o.font = e.font);
1815
- const E = s.get(h.annotation.id);
1816
- if (E) {
1815
+ const v = i.get(h.annotation.id);
1816
+ if (v) {
1817
1817
  const { height: g } = h.rects[0], m = h.rects[0].x + u.left, A = h.rects[0].y + u.top;
1818
- o.fillStyle = E.appearance.color, o.fillRect(m - 2, A - 2.5, 2, g + 5);
1819
- const d = o.measureText(E.appearance.label), c = d.width + 6, b = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
1820
- return o.fillRect(m - 2, A - 2.5 - b, c, b), o.fillStyle = "#fff", o.fillText(E.appearance.label, m + 1, A - S), {
1821
- fill: E.appearance.color,
1818
+ o.fillStyle = v.appearance.color, o.fillRect(m - 2, A - 2.5, 2, g + 5);
1819
+ const d = o.measureText(v.appearance.label), c = d.width + 6, b = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
1820
+ return o.fillRect(m - 2, A - 2.5 - b, c, b), o.fillStyle = "#fff", o.fillText(v.appearance.label, m + 1, A - S), {
1821
+ fill: v.appearance.color,
1822
1822
  fillOpacity: p ? 0.45 : 0.18
1823
1823
  };
1824
1824
  }
@@ -1833,7 +1833,7 @@ const to = (t, e) => {
1833
1833
  function Ut(t, e, n, o) {
1834
1834
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1835
1835
  }
1836
- function st(t, e, n, o) {
1836
+ function ot(t, e, n, o) {
1837
1837
  t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
1838
1838
  }
1839
1839
  function ye(t, e) {
@@ -1849,12 +1849,12 @@ function be(t) {
1849
1849
  e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
1850
1850
  return e;
1851
1851
  }
1852
- function so(t, e) {
1852
+ function io(t, e) {
1853
1853
  const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
1854
- let s = !0;
1855
- for (let i = 0; i < n.length; i++)
1856
- o.indexOf(n[i]) === -1 && (s = !1);
1857
- return s;
1854
+ let i = !0;
1855
+ for (let s = 0; s < n.length; s++)
1856
+ o.indexOf(n[s]) === -1 && (i = !1);
1857
+ return i;
1858
1858
  }
1859
1859
  const lt = {
1860
1860
  backspace: 8,
@@ -1942,7 +1942,7 @@ const lt = {
1942
1942
  for (let t = 1; t < 20; t++)
1943
1943
  lt["f".concat(t)] = 111 + t;
1944
1944
  let _ = [], ct = null, we = "all";
1945
- const W = /* @__PURE__ */ new Map(), ut = (t) => lt[t.toLowerCase()] || z[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), io = (t) => Object.keys(lt).find((e) => lt[e] === t), ro = (t) => Object.keys(z).find((e) => z[e] === t);
1945
+ const W = /* @__PURE__ */ new Map(), ut = (t) => lt[t.toLowerCase()] || z[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), so = (t) => Object.keys(lt).find((e) => lt[e] === t), ro = (t) => Object.keys(z).find((e) => z[e] === t);
1946
1946
  function Ae(t) {
1947
1947
  we = t || "all";
1948
1948
  }
@@ -1953,7 +1953,7 @@ function ao() {
1953
1953
  return _.slice(0);
1954
1954
  }
1955
1955
  function co() {
1956
- return _.map((t) => io(t) || ro(t) || String.fromCharCode(t));
1956
+ return _.map((t) => so(t) || ro(t) || String.fromCharCode(t));
1957
1957
  }
1958
1958
  function lo() {
1959
1959
  const t = [];
@@ -1961,14 +1961,14 @@ function lo() {
1961
1961
  N[e].forEach((n) => {
1962
1962
  let {
1963
1963
  key: o,
1964
- scope: s,
1965
- mods: i,
1964
+ scope: i,
1965
+ mods: s,
1966
1966
  shortcut: a
1967
1967
  } = n;
1968
1968
  t.push({
1969
- scope: s,
1969
+ scope: i,
1970
1970
  shortcut: a,
1971
- mods: i,
1971
+ mods: s,
1972
1972
  keys: o.split("+").map((r) => ut(r))
1973
1973
  });
1974
1974
  });
@@ -1979,8 +1979,8 @@ function uo(t) {
1979
1979
  tagName: n
1980
1980
  } = e;
1981
1981
  let o = !0;
1982
- const s = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
1983
- return (e.isContentEditable || (s || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
1982
+ const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
1983
+ return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
1984
1984
  }
1985
1985
  function fo(t) {
1986
1986
  return typeof t == "string" && (t = ut(t)), _.indexOf(t) !== -1;
@@ -1988,9 +1988,9 @@ function fo(t) {
1988
1988
  function ho(t, e) {
1989
1989
  let n, o;
1990
1990
  t || (t = dt());
1991
- for (const s in N)
1992
- if (Object.prototype.hasOwnProperty.call(N, s))
1993
- for (n = N[s], o = 0; o < n.length; )
1991
+ for (const i in N)
1992
+ if (Object.prototype.hasOwnProperty.call(N, i))
1993
+ for (n = N[i], o = 0; o < n.length; )
1994
1994
  n[o].scope === t ? n.splice(o, 1).forEach((a) => {
1995
1995
  let {
1996
1996
  element: r
@@ -2009,23 +2009,23 @@ function po(t) {
2009
2009
  }
2010
2010
  function xe(t) {
2011
2011
  if (typeof t > "u")
2012
- Object.keys(N).forEach((s) => {
2013
- Array.isArray(N[s]) && N[s].forEach((i) => bt(i)), delete N[s];
2012
+ Object.keys(N).forEach((i) => {
2013
+ Array.isArray(N[i]) && N[i].forEach((s) => bt(s)), delete N[i];
2014
2014
  }), Xt(null);
2015
2015
  else if (Array.isArray(t))
2016
- t.forEach((s) => {
2017
- s.key && bt(s);
2016
+ t.forEach((i) => {
2017
+ i.key && bt(i);
2018
2018
  });
2019
2019
  else if (typeof t == "object")
2020
2020
  t.key && bt(t);
2021
2021
  else if (typeof t == "string") {
2022
2022
  for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
2023
2023
  n[o - 1] = arguments[o];
2024
- let [s, i] = n;
2025
- typeof s == "function" && (i = s, s = ""), bt({
2024
+ let [i, s] = n;
2025
+ typeof i == "function" && (s = i, i = ""), bt({
2026
2026
  key: t,
2027
- scope: s,
2028
- method: i,
2027
+ scope: i,
2028
+ method: s,
2029
2029
  splitKey: "+"
2030
2030
  });
2031
2031
  }
@@ -2035,28 +2035,28 @@ const bt = (t) => {
2035
2035
  key: e,
2036
2036
  scope: n,
2037
2037
  method: o,
2038
- splitKey: s = "+"
2038
+ splitKey: i = "+"
2039
2039
  } = t;
2040
2040
  be(e).forEach((a) => {
2041
- const r = a.split(s), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ut(f);
2041
+ const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ut(f);
2042
2042
  if (!N[h]) return;
2043
2043
  n || (n = dt());
2044
2044
  const u = l > 1 ? ye(z, r) : [], p = [];
2045
- N[h] = N[h].filter((E) => {
2046
- const m = (o ? E.method === o : !0) && E.scope === n && so(E.mods, u);
2047
- return m && p.push(E.element), !m;
2048
- }), p.forEach((E) => Xt(E));
2045
+ N[h] = N[h].filter((v) => {
2046
+ const m = (o ? v.method === o : !0) && v.scope === n && io(v.mods, u);
2047
+ return m && p.push(v.element), !m;
2048
+ }), p.forEach((v) => Xt(v));
2049
2049
  });
2050
2050
  };
2051
2051
  function ne(t, e, n, o) {
2052
2052
  if (e.element !== o)
2053
2053
  return;
2054
- let s;
2054
+ let i;
2055
2055
  if (e.scope === n || e.scope === "all") {
2056
- s = e.mods.length > 0;
2057
- for (const i in X)
2058
- Object.prototype.hasOwnProperty.call(X, i) && (!X[i] && e.mods.indexOf(+i) > -1 || X[i] && e.mods.indexOf(+i) === -1) && (s = !1);
2059
- (e.mods.length === 0 && !X[16] && !X[18] && !X[17] && !X[91] || s || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(_), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2056
+ i = e.mods.length > 0;
2057
+ for (const s in X)
2058
+ Object.prototype.hasOwnProperty.call(X, s) && (!X[s] && e.mods.indexOf(+s) > -1 || X[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2059
+ (e.mods.length === 0 && !X[16] && !X[18] && !X[17] && !X[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(_), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2060
2060
  }
2061
2061
  }
2062
2062
  function oe(t, e) {
@@ -2075,32 +2075,32 @@ function oe(t, e) {
2075
2075
  for (const r in X)
2076
2076
  Object.prototype.hasOwnProperty.call(X, r) && (X[r] = t[wt[r]]);
2077
2077
  t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (_.indexOf(17) === -1 && _.push(17), _.indexOf(18) === -1 && _.push(18), X[17] = !0, X[18] = !0);
2078
- const s = dt();
2078
+ const i = dt();
2079
2079
  if (n)
2080
2080
  for (let r = 0; r < n.length; r++)
2081
- n[r].scope === s && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], s, e);
2081
+ n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], i, e);
2082
2082
  if (!(o in N)) return;
2083
- const i = N[o], a = i.length;
2083
+ const s = N[o], a = s.length;
2084
2084
  for (let r = 0; r < a; r++)
2085
- if ((t.type === "keydown" && i[r].keydown || t.type === "keyup" && i[r].keyup) && i[r].key) {
2086
- const l = i[r], {
2085
+ if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
2086
+ const l = s[r], {
2087
2087
  splitKey: f
2088
2088
  } = l, h = l.key.split(f), u = [];
2089
2089
  for (let p = 0; p < h.length; p++)
2090
2090
  u.push(ut(h[p]));
2091
- u.sort().join("") === _.sort().join("") && ne(t, l, s, e);
2091
+ u.sort().join("") === _.sort().join("") && ne(t, l, i, e);
2092
2092
  }
2093
2093
  }
2094
2094
  function H(t, e, n) {
2095
2095
  _ = [];
2096
2096
  const o = be(t);
2097
- let s = [], i = "all", a = document, r = 0, l = !1, f = !0, h = "+", u = !1, p = !1;
2098
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (i = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (i = e), p && xe(t, i); r < o.length; r++)
2099
- t = o[r].split(h), s = [], t.length > 1 && (s = ye(z, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in N || (N[t] = []), N[t].push({
2097
+ let i = [], s = "all", a = document, r = 0, l = !1, f = !0, h = "+", u = !1, p = !1;
2098
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (s = e), p && xe(t, s); r < o.length; r++)
2099
+ t = o[r].split(h), i = [], t.length > 1 && (i = ye(z, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in N || (N[t] = []), N[t].push({
2100
2100
  keyup: l,
2101
2101
  keydown: f,
2102
- scope: i,
2103
- mods: s,
2102
+ scope: s,
2103
+ mods: i,
2104
2104
  shortcut: o[r],
2105
2105
  method: n,
2106
2106
  key: o[r],
@@ -2109,7 +2109,7 @@ function H(t, e, n) {
2109
2109
  });
2110
2110
  if (typeof a < "u" && window) {
2111
2111
  if (!W.has(a)) {
2112
- const E = function() {
2112
+ const v = function() {
2113
2113
  let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2114
2114
  return oe(m, a);
2115
2115
  }, g = function() {
@@ -2117,27 +2117,27 @@ function H(t, e, n) {
2117
2117
  oe(m, a), po(m);
2118
2118
  };
2119
2119
  W.set(a, {
2120
- keydownListener: E,
2120
+ keydownListener: v,
2121
2121
  keyupListenr: g,
2122
2122
  capture: u
2123
- }), Ut(a, "keydown", E, u), Ut(a, "keyup", g, u);
2123
+ }), Ut(a, "keydown", v, u), Ut(a, "keyup", g, u);
2124
2124
  }
2125
2125
  if (!ct) {
2126
- const E = () => {
2126
+ const v = () => {
2127
2127
  _ = [];
2128
2128
  };
2129
2129
  ct = {
2130
- listener: E,
2130
+ listener: v,
2131
2131
  capture: u
2132
- }, Ut(window, "focus", E, u);
2132
+ }, Ut(window, "focus", v, u);
2133
2133
  }
2134
2134
  }
2135
2135
  }
2136
2136
  function go(t) {
2137
2137
  let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
2138
2138
  Object.keys(N).forEach((n) => {
2139
- N[n].filter((s) => s.scope === e && s.shortcut === t).forEach((s) => {
2140
- s && s.method && s.method();
2139
+ N[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
2140
+ i && i.method && i.method();
2141
2141
  });
2142
2142
  });
2143
2143
  }
@@ -2145,30 +2145,30 @@ function Xt(t) {
2145
2145
  const e = Object.values(N).flat();
2146
2146
  if (e.findIndex((o) => {
2147
2147
  let {
2148
- element: s
2148
+ element: i
2149
2149
  } = o;
2150
- return s === t;
2150
+ return i === t;
2151
2151
  }) < 0) {
2152
2152
  const {
2153
2153
  keydownListener: o,
2154
- keyupListenr: s,
2155
- capture: i
2154
+ keyupListenr: i,
2155
+ capture: s
2156
2156
  } = W.get(t) || {};
2157
- o && s && (st(t, "keyup", s, i), st(t, "keydown", o, i), W.delete(t));
2157
+ o && i && (ot(t, "keyup", i, s), ot(t, "keydown", o, s), W.delete(t));
2158
2158
  }
2159
- if ((e.length <= 0 || W.size <= 0) && (Object.keys(W).forEach((s) => {
2159
+ if ((e.length <= 0 || W.size <= 0) && (Object.keys(W).forEach((i) => {
2160
2160
  const {
2161
- keydownListener: i,
2161
+ keydownListener: s,
2162
2162
  keyupListenr: a,
2163
2163
  capture: r
2164
- } = W.get(s) || {};
2165
- i && a && (st(s, "keyup", a, r), st(s, "keydown", i, r), W.delete(s));
2166
- }), W.clear(), Object.keys(N).forEach((s) => delete N[s]), ct)) {
2164
+ } = W.get(i) || {};
2165
+ s && a && (ot(i, "keyup", a, r), ot(i, "keydown", s, r), W.delete(i));
2166
+ }), W.clear(), Object.keys(N).forEach((i) => delete N[i]), ct)) {
2167
2167
  const {
2168
- listener: s,
2169
- capture: i
2168
+ listener: i,
2169
+ capture: s
2170
2170
  } = ct;
2171
- st(window, "focus", s, i), ct = null;
2171
+ ot(window, "focus", i, s), ct = null;
2172
2172
  }
2173
2173
  }
2174
2174
  const _t = {
@@ -2192,17 +2192,17 @@ if (typeof window < "u") {
2192
2192
  const t = window.hotkeys;
2193
2193
  H.noConflict = (e) => (e && window.hotkeys === H && (window.hotkeys = t), H), window.hotkeys = H;
2194
2194
  }
2195
- const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+a", mo = [
2196
- ...Ee.map((t) => `shift+${t}`),
2197
- ve
2195
+ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+a", mo = [
2196
+ ...ve.map((t) => `shift+${t}`),
2197
+ Ee
2198
2198
  ], yo = (t, e, n) => {
2199
2199
  let o;
2200
- const { annotatingEnabled: s, offsetReferenceSelector: i, selectionMode: a } = n, r = (T) => o = T;
2200
+ const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (T) => o = T;
2201
2201
  let l;
2202
2202
  const f = (T) => l = T, { store: h, selection: u } = e;
2203
- let p, E, g;
2203
+ let p, v, g;
2204
2204
  const m = (T) => {
2205
- console.log("select start!", G(T.target)), E !== !1 && (p = G(T.target) ? void 0 : {
2205
+ v !== !1 && (p = it(T.target) ? void 0 : {
2206
2206
  annotation: fe(),
2207
2207
  selector: [],
2208
2208
  creator: o,
@@ -2212,12 +2212,12 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2212
2212
  const I = document.getSelection();
2213
2213
  if (!(I != null && I.anchorNode))
2214
2214
  return;
2215
- if (G(I.anchorNode)) {
2215
+ if (it(I.anchorNode)) {
2216
2216
  p = void 0;
2217
2217
  return;
2218
2218
  }
2219
2219
  const D = T.timeStamp - ((g == null ? void 0 : g.timeStamp) || T.timeStamp);
2220
- if ((g == null ? void 0 : g.type) === "pointerdown" && (D < 1e3 && !p || I.isCollapsed && D < se) && m(g || T), !p) return;
2220
+ if ((g == null ? void 0 : g.type) === "pointerdown" && (D < 1e3 && !p || I.isCollapsed && D < ie) && m(g || T), !p) return;
2221
2221
  if (I.isCollapsed) {
2222
2222
  h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
2223
2223
  return;
@@ -2230,13 +2230,13 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2230
2230
  return B.toString() !== ((U = p.selector[O]) == null ? void 0 : U.quote);
2231
2231
  })) && (p = {
2232
2232
  ...p,
2233
- selector: w.map((B) => Ve(B, t, i)),
2233
+ selector: w.map((B) => Ve(B, t, s)),
2234
2234
  updated: /* @__PURE__ */ new Date()
2235
2235
  }, h.getAnnotation(p.annotation) ? h.updateTarget(p, k.LOCAL) : u.clear());
2236
2236
  }), d = (T) => {
2237
- console.log("down!", G(T.target)), !G(T.target) && (g = Et(T), E = g.button === 0);
2237
+ it(T.target) || (g = vt(T), v = g.button === 0);
2238
2238
  }, c = (T) => {
2239
- if (console.log("up!", G(T.target)), G(T.target) || !E) return;
2239
+ if (it(T.target) || !v) return;
2240
2240
  const I = () => {
2241
2241
  const { x: y, y: x } = t.getBoundingClientRect(), w = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - y, T.clientY - x, a === "all", l);
2242
2242
  if (w) {
@@ -2247,14 +2247,14 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2247
2247
  }, D = T.timeStamp - g.timeStamp;
2248
2248
  setTimeout(() => {
2249
2249
  const y = document.getSelection();
2250
- y != null && y.isCollapsed && D < se ? (p = void 0, I()) : p && p.selector.length > 0 && (R(), u.userSelect(p.annotation, Et(T)));
2250
+ y != null && y.isCollapsed && D < ie ? (p = void 0, I()) : p && p.selector.length > 0 && (R(), u.userSelect(p.annotation, vt(T)));
2251
2251
  });
2252
2252
  }, b = (T) => {
2253
2253
  const I = document.getSelection();
2254
- I != null && I.isCollapsed || ((!p || p.selector.length === 0) && A(T), R(), u.userSelect(p.annotation, Et(T)));
2254
+ I != null && I.isCollapsed || ((!p || p.selector.length === 0) && A(T), R(), u.userSelect(p.annotation, vt(T)));
2255
2255
  }, S = (T) => {
2256
2256
  T.key === "Shift" && p && (document.getSelection().isCollapsed || (R(), u.userSelect(p.annotation, ft(T))));
2257
- }, v = (T) => {
2257
+ }, E = (T) => {
2258
2258
  const I = () => setTimeout(() => {
2259
2259
  (p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
2260
2260
  id: p.annotation,
@@ -2266,13 +2266,13 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2266
2266
  };
2267
2267
  H(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
2268
2268
  T.repeat || (g = ft(T));
2269
- }), H(ve, { keydown: !0, keyup: !1 }, (T) => {
2270
- g = ft(T), v(T);
2269
+ }), H(Ee, { keydown: !0, keyup: !1 }, (T) => {
2270
+ g = ft(T), E(T);
2271
2271
  });
2272
2272
  const C = (T) => {
2273
2273
  T.repeat || T.target !== t && T.target !== document.body || (p = void 0, u.clear());
2274
2274
  };
2275
- H(Ee.join(","), { keydown: !0, keyup: !1 }, C);
2275
+ H(ve.join(","), { keydown: !0, keyup: !1 }, C);
2276
2276
  const R = () => {
2277
2277
  const T = h.getAnnotation(p.annotation);
2278
2278
  if (!T) {
@@ -2286,7 +2286,7 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2286
2286
  const { target: { updated: I } } = T, { updated: D } = p;
2287
2287
  (!I || !D || I < D) && h.updateTarget(p);
2288
2288
  };
2289
- return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", b), s && (t.addEventListener("keyup", S), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", A)), {
2289
+ return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", b), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", A)), {
2290
2290
  destroy: () => {
2291
2291
  t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", b), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", A), H.unbind();
2292
2292
  },
@@ -2297,14 +2297,14 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2297
2297
  ...t,
2298
2298
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
2299
2299
  user: t.user || e.user
2300
- }), ie = "SPANS", Eo = (t, e = {}) => {
2300
+ }), se = "SPANS", vo = (t, e = {}) => {
2301
2301
  Le(t), Oe(t);
2302
2302
  const n = bo(e, {
2303
2303
  annotatingEnabled: !0,
2304
2304
  user: Yn()
2305
- }), o = eo(t, n.userSelectAction), { selection: s, viewport: i } = o, a = o.store, r = Rn(a), l = Bn(o, r, n.adapter);
2305
+ }), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Rn(a), l = Bn(o, r, n.adapter);
2306
2306
  let f = n.user;
2307
- const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ie : n.renderer || ie, u = h === "SPANS" ? rn(t, o, i) : h === "CSS_HIGHLIGHTS" ? nn(t, o, i) : h === "CANVAS" ? ze(t, o, i) : void 0;
2307
+ const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : se : n.renderer || se, u = h === "SPANS" ? rn(t, o, s) : h === "CSS_HIGHLIGHTS" ? nn(t, o, s) : h === "CANVAS" ? ze(t, o, s) : void 0;
2308
2308
  if (!u)
2309
2309
  throw `Unknown renderer implementation: ${h}`;
2310
2310
  console.debug(`Using ${h} renderer`), n.style && u.setStyle(n.style);
@@ -2324,7 +2324,7 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2324
2324
  f = C, p.setUser(C);
2325
2325
  },
2326
2326
  setSelected: (C) => {
2327
- C ? s.setSelected(C) : s.clear();
2327
+ C ? i.setSelected(C) : i.clear();
2328
2328
  },
2329
2329
  setPresenceProvider: (C) => {
2330
2330
  C && (u.setPainter(oo(C, n.presence)), C.on("selectionChange", () => u.redraw()));
@@ -2338,30 +2338,30 @@ const se = 300, Ee = ["up", "down", "left", "right"], ve = Te ? "⌘+a" : "ctrl+
2338
2338
  };
2339
2339
  export {
2340
2340
  xt as DEFAULT_SELECTED_STYLE,
2341
- Q as DEFAULT_STYLE,
2341
+ G as DEFAULT_STYLE,
2342
2342
  re as NOT_ANNOTATABLE_CLASS,
2343
- nt as NOT_ANNOTATABLE_SELECTOR,
2343
+ et as NOT_ANNOTATABLE_SELECTOR,
2344
2344
  k as Origin,
2345
2345
  yo as SelectionHandler,
2346
2346
  hn as UserSelectAction,
2347
2347
  xo as W3CTextFormat,
2348
2348
  Le as cancelSingleClickEvents,
2349
2349
  ft as cloneKeyboardEvent,
2350
- Et as clonePointerEvent,
2350
+ vt as clonePointerEvent,
2351
2351
  Ao as createBody,
2352
2352
  ze as createCanvasRenderer,
2353
2353
  nn as createHighlightsRenderer,
2354
2354
  oo as createPresencePainter,
2355
2355
  en as createRenderer,
2356
2356
  rn as createSpansRenderer,
2357
- Eo as createTextAnnotator,
2357
+ vo as createTextAnnotator,
2358
2358
  eo as createTextAnnotatorState,
2359
2359
  Dt as debounce,
2360
2360
  bo as fillDefaults,
2361
2361
  Be as getQuoteContext,
2362
2362
  Nt as getRangeAnnotatableContents,
2363
2363
  Te as isMac,
2364
- G as isNotAnnotatable,
2364
+ it as isNotAnnotatable,
2365
2365
  Ce as isRangeAnnotatable,
2366
2366
  q as isRevived,
2367
2367
  Ie as isWhitespaceOrEmpty,
@@ -2370,7 +2370,7 @@ export {
2370
2370
  jn as parseW3CTextAnnotation,
2371
2371
  Oe as programmaticallyFocusable,
2372
2372
  Ve as rangeToSelector,
2373
- vt as reviveAnnotation,
2373
+ Et as reviveAnnotation,
2374
2374
  ae as reviveSelector,
2375
2375
  At as reviveTarget,
2376
2376
  Ye as scrollIntoView,