@soomo/text-annotator 3.1.0-staging.0 → 3.1.0-staging.10

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,21 +1,28 @@
1
- const de = "not-annotatable", j = `.${de}`, Re = (t) => {
1
+ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
2
2
  var n;
3
+ return !!(t instanceof HTMLElement ? t.closest(Z) : (n = t.parentElement) == null ? void 0 : n.closest(Z));
4
+ }, Me = (t) => {
3
5
  const e = t.commonAncestorContainer;
4
- return e instanceof HTMLElement ? !e.closest(j) : !((n = e.parentElement) != null && n.closest(j));
5
- }, Me = function* (t) {
6
+ return !nt(e);
7
+ }, Be = (t) => t.addEventListener("click", (e) => {
8
+ // Allow clicks within not-annotatable elements
9
+ !e.target.closest(Z) && !e.target.closest("a") && e.preventDefault();
10
+ }), ke = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Ie = (t) => {
11
+ !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
12
+ }, Ne = function* (t) {
6
13
  const e = document.createNodeIterator(
7
14
  t.commonAncestorContainer,
8
15
  NodeFilter.SHOW_ELEMENT,
9
- (o) => o instanceof HTMLElement && o.classList.contains(de) && !o.parentElement.closest(j) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
16
+ (o) => o instanceof HTMLElement && o.classList.contains(le) && !o.parentElement.closest(Z) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
10
17
  );
11
18
  let n;
12
19
  for (; n = e.nextNode(); )
13
20
  n instanceof HTMLElement && (yield n);
14
- }, Be = (t) => {
15
- if (!Re(t)) return [];
21
+ }, _e = (t) => {
22
+ if (!Me(t)) return [];
16
23
  const e = [];
17
24
  let n = null;
18
- for (const o of Me(t)) {
25
+ for (const o of Ne(t)) {
19
26
  let i;
20
27
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
21
28
  }
@@ -26,16 +33,8 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
26
33
  return e.length > 0 ? e : [t];
27
34
  }, Dt = (t) => {
28
35
  const e = t.cloneContents();
29
- return e.querySelectorAll(j).forEach((n) => n.remove()), e;
30
- }, ke = (t) => t.addEventListener("click", (e) => {
31
- // Allow clicks within not-annotatable elements
32
- !e.target.closest(j) && !e.target.closest("a") && e.preventDefault();
33
- }), Ie = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), _e = (t) => {
34
- !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
35
- }, Oo = (t) => {
36
- const e = t.cloneContents();
37
- return e.querySelectorAll(j).forEach((n) => n.remove()), e;
38
- }, Ne = (t, e, n = 10, o) => {
36
+ return e.querySelectorAll(Z).forEach((n) => n.remove()), e;
37
+ }, Ue = (t, e, n = 10, o) => {
39
38
  const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
40
39
  s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
41
40
  const r = Dt(s).textContent, a = document.createRange();
@@ -45,7 +44,7 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
45
44
  prefix: r.substring(r.length - n),
46
45
  suffix: d.substring(0, n)
47
46
  };
48
- }, Ue = /^\s*$/, De = (t) => Ue.test(t.toString()), W = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Ve = (t, e) => {
47
+ }, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), De = /^\s*$/, Ve = (t) => De.test(t.toString()), Ke = (t, e) => {
49
48
  const n = (s) => Math.round(s * 10) / 10, o = {
50
49
  top: n(t.top),
51
50
  bottom: n(t.bottom),
@@ -69,17 +68,17 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
69
68
  return "block-contains";
70
69
  } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
71
70
  return "block-is-contained";
72
- }, Ke = (t, e) => {
71
+ }, Ye = (t, e) => {
73
72
  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);
74
73
  return new DOMRect(n, i, o - n, s - i);
75
- }, Ye = (t) => t.reduce((e, n) => {
74
+ }, Xe = (t) => t.reduce((e, n) => {
76
75
  if (n.width === 0 || n.height === 0)
77
76
  return e;
78
77
  let o = [...e], i = !1;
79
78
  for (const s of e) {
80
- const r = Ve(n, s);
79
+ const r = Ke(n, s);
81
80
  if (r === "inline-adjacent") {
82
- o = o.map((a) => a === s ? Ke(n, s) : a), i = !0;
81
+ o = o.map((a) => a === s ? Ye(n, s) : a), i = !0;
83
82
  break;
84
83
  } else if (r === "inline-contains") {
85
84
  o = o.map((a) => a === s ? n : a), i = !0;
@@ -93,26 +92,26 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
93
92
  }
94
93
  }
95
94
  return i ? o : [...o, n];
96
- }, []), To = (t) => ({
95
+ }, []), Mo = (t) => ({
97
96
  length: t.length,
98
97
  item: (e) => t[e],
99
98
  [Symbol.iterator]: function* () {
100
99
  for (let e = 0; e < this.length; e++)
101
100
  yield this.item(e);
102
101
  }
103
- }), Xe = (t, e, n) => {
102
+ }), Pe = (t, e, n) => {
104
103
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
105
104
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
106
105
  const s = Dt(o).textContent, r = t.toString(), a = s.length || 0, d = a + r.length;
107
106
  return n ? { quote: r, start: a, end: d, range: t, offsetReference: i } : { quote: r, start: a, end: d, range: t };
108
- }, ue = (t, e) => {
109
- var f, l;
107
+ }, de = (t, e) => {
108
+ var h, l;
110
109
  const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
111
110
  e,
112
111
  NodeFilter.SHOW_TEXT,
113
112
  (g) => {
114
- var h;
115
- return (h = g.parentElement) != null && h.closest(j) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
113
+ var p;
114
+ return (p = g.parentElement) != null && p.closest(Z) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
116
115
  }
117
116
  );
118
117
  let r = 0;
@@ -122,7 +121,7 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
122
121
  let c = !i;
123
122
  for (; d !== null; ) {
124
123
  if (c || (c = i == null ? void 0 : i.contains(d)), c) {
125
- const g = ((f = d.textContent) == null ? void 0 : f.length) || 0;
124
+ const g = ((h = d.textContent) == null ? void 0 : h.length) || 0;
126
125
  if (r + g > n) {
127
126
  a.setStart(d, n - r);
128
127
  break;
@@ -143,12 +142,22 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
143
142
  ...t,
144
143
  range: a
145
144
  };
146
- }, wt = (t, e) => W(t.selector) ? t : {
145
+ }, wt = (t, e) => F(t.selector) ? t : {
147
146
  ...t,
148
- selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ue(n, e))
149
- }, xt = (t, e) => W(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, $e = (t, e) => {
147
+ selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : de(n, e))
148
+ }, xt = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, ue = (t, e) => {
149
+ if (t.isEqualNode(e))
150
+ return !0;
151
+ for (let n of t.childNodes)
152
+ if (ue(n, e))
153
+ return !0;
154
+ return !1;
155
+ }, $e = (t, e) => {
156
+ const n = t.cloneContents();
157
+ return ue(n, e);
158
+ }, je = (t, e) => {
150
159
  const n = t.cloneRange(), o = e.contains(n.startContainer), i = e.contains(n.endContainer);
151
- return !o && !i ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
160
+ return !o && !i && !$e(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
152
161
  }, Et = (t) => ({
153
162
  ...t,
154
163
  type: t.type,
@@ -191,10 +200,10 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
191
200
  defaultPrevented: t.defaultPrevented,
192
201
  detail: t.detail,
193
202
  timeStamp: t.timeStamp
194
- }), Pe = (t, e) => {
203
+ }), He = (t, e) => {
195
204
  const { left: n, top: o, right: i, bottom: s } = t;
196
205
  return new DOMRect(n - e.left, o - e.top, i - n, s - o);
197
- }, Ro = (t, e) => {
206
+ }, Bo = (t, e) => {
198
207
  const { left: n, top: o, right: i, bottom: s } = t;
199
208
  return new DOMRect(n + e.left, o + e.top, i - n, s - o);
200
209
  }, fe = (t) => {
@@ -202,9 +211,9 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
202
211
  return document.scrollingElement;
203
212
  const { overflowY: e } = window.getComputedStyle(t);
204
213
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : fe(t.parentElement);
205
- }, je = (t, e) => (n) => {
214
+ }, ze = (t, e) => (n) => {
206
215
  const o = typeof n == "string" ? n : n.id, i = (r) => {
207
- const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: l, height: g } = e.getAnnotationBounds(o), h = f.top - a.top, v = f.left - a.left, b = s.parentElement ? s.scrollTop : 0, E = s.parentElement ? s.scrollLeft : 0, m = h + b - (d - g) / 2, u = v + E - (c - l) / 2;
216
+ const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: l, height: g } = e.getAnnotationBounds(o), p = h.top - a.top, v = h.left - a.left, w = s.parentElement ? s.scrollTop : 0, E = s.parentElement ? s.scrollLeft : 0, m = p + w - (d - g) / 2, u = v + E - (c - l) / 2;
208
217
  s.scroll({ top: m, left: u, behavior: "smooth" });
209
218
  }, s = fe(t);
210
219
  if (s) {
@@ -218,18 +227,18 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
218
227
  }
219
228
  }
220
229
  return !1;
221
- }, q = {
230
+ }, W = {
222
231
  fill: "rgb(0, 128, 255)",
223
232
  fillOpacity: 0.18
224
233
  }, vt = {
225
234
  fill: "rgb(0, 128, 255)",
226
235
  fillOpacity: 0.45
227
- }, He = (t, e, n, o, i) => {
236
+ }, Fe = (t, e, n, o, i) => {
228
237
  var r, a;
229
- const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? vt : q) : n : (a = t.state) != null && a.selected ? vt : q;
238
+ const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? vt : W) : n : (a = t.state) != null && a.selected ? vt : W;
230
239
  return o && o.paint(t, e) || s;
231
240
  };
232
- function ze(t) {
241
+ function We(t) {
233
242
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
234
243
  }
235
244
  var Yt = { exports: {} };
@@ -241,19 +250,19 @@ function he(t, e = 100, n = {}) {
241
250
  const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
242
251
  let i, s, r, a, d;
243
252
  function c() {
244
- const g = i, h = s;
245
- return i = void 0, s = void 0, d = t.apply(g, h), d;
253
+ const g = i, p = s;
254
+ return i = void 0, s = void 0, d = t.apply(g, p), d;
246
255
  }
247
- function f() {
256
+ function h() {
248
257
  const g = Date.now() - a;
249
- g < e && g >= 0 ? r = setTimeout(f, e - g) : (r = void 0, o || (d = c()));
258
+ g < e && g >= 0 ? r = setTimeout(h, e - g) : (r = void 0, o || (d = c()));
250
259
  }
251
260
  const l = function(...g) {
252
261
  if (i && this !== i && Object.getPrototypeOf(this) === Object.getPrototypeOf(i))
253
262
  throw new Error("Debounced method called with different contexts of the same prototype.");
254
263
  i = this, s = g, a = Date.now();
255
- const h = o && !r;
256
- return r || (r = setTimeout(f, e)), h && (d = c()), d;
264
+ const p = o && !r;
265
+ return r || (r = setTimeout(h, e)), p && (d = c()), d;
257
266
  };
258
267
  return l.clear = () => {
259
268
  r && (clearTimeout(r), r = void 0);
@@ -265,95 +274,95 @@ function he(t, e = 100, n = {}) {
265
274
  }
266
275
  Yt.exports.debounce = he;
267
276
  Yt.exports = he;
268
- var Fe = Yt.exports;
269
- const Xt = /* @__PURE__ */ ze(Fe), We = (t) => {
277
+ var qe = Yt.exports;
278
+ const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
270
279
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, d = i - e;
271
280
  return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: d };
272
- }, qe = (t) => {
281
+ }, Qe = (t) => {
273
282
  let e = /* @__PURE__ */ new Set();
274
283
  return (o) => {
275
284
  const i = o.map((s) => s.id);
276
285
  (e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
277
286
  };
278
- }, $t = (t, e, n, o) => {
287
+ }, Pt = (t, e, n, o) => {
279
288
  const { store: i, selection: s, hover: r } = e;
280
289
  let a, d, c;
281
- const f = qe(n), l = (T) => {
282
- const { x: S, y: p } = t.getBoundingClientRect(), w = i.getAt(T.clientX - S, T.clientY - p, d);
283
- w ? r.current !== w.id && (t.classList.add("hovered"), r.set(w.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
290
+ const h = Qe(n), l = (O) => {
291
+ const { x: M, y: f } = t.getBoundingClientRect(), y = i.getAt(O.clientX - M, O.clientY - f, d);
292
+ y ? r.current !== y.id && (t.classList.add("hovered"), r.set(y.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
284
293
  };
285
294
  t.addEventListener("pointermove", l);
286
- const g = (T = !1) => {
295
+ const g = (O = !1) => {
287
296
  c && c.clear();
288
- const S = We(t), { minX: p, minY: w, maxX: x, maxY: O } = S, B = d ? i.getIntersecting(p, w, x, O).filter(({ annotation: N }) => d(N)) : i.getIntersecting(p, w, x, O), M = s.selected.map(({ id: N }) => N), D = B.map(({ annotation: N, rects: dt }) => {
289
- const tt = M.includes(N.id), At = N.id === r.current;
290
- return { annotation: N, rects: dt, state: { selected: tt, hover: At } };
297
+ const M = Ge(t), { minX: f, minY: y, maxX: x, maxY: C } = M, B = d ? i.getIntersecting(f, y, x, C).filter(({ annotation: Y }) => d(Y)) : i.getIntersecting(f, y, x, C), R = s.selected.map(({ id: Y }) => Y), K = B.map(({ annotation: Y, rects: At }) => {
298
+ const dt = R.includes(Y.id), Re = Y.id === r.current;
299
+ return { annotation: Y, rects: At, state: { selected: dt, hover: Re } };
291
300
  });
292
- o.redraw(D, S, a, c, T), setTimeout(() => f(B.map(({ annotation: N }) => N)), 1);
293
- }, h = (T) => {
294
- c = T, g();
295
- }, v = (T) => {
296
- a = T, g();
297
- }, b = (T) => {
298
- d = T, g(!1);
301
+ o.redraw(K, M, a, c, O), setTimeout(() => h(B.map(({ annotation: Y }) => Y)), 1);
302
+ }, p = (O) => {
303
+ c = O, g();
304
+ }, v = (O) => {
305
+ a = O, g();
306
+ }, w = (O) => {
307
+ d = O, g(!1);
299
308
  }, E = () => g();
300
309
  i.observe(E);
301
310
  const m = s.subscribe(() => g()), u = () => g(!0);
302
311
  document.addEventListener("scroll", u, { capture: !0, passive: !0 });
303
- const y = Xt(() => {
312
+ const b = Xt(() => {
304
313
  i.recalculatePositions(), c == null || c.reset(), g();
305
314
  }, 10);
306
- window.addEventListener("resize", y);
307
- const C = new ResizeObserver(y);
308
- C.observe(t);
309
- const A = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((T) => {
310
- T.every((p) => p.target === t || t.contains(p.target)) || g(!0);
315
+ window.addEventListener("resize", b);
316
+ const S = new ResizeObserver(b);
317
+ S.observe(t);
318
+ const A = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((O) => {
319
+ O.every((f) => f.target === t || t.contains(f.target)) || g(!0);
311
320
  });
312
321
  return L.observe(document.body, A), {
313
322
  destroy: () => {
314
- t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(E), m(), document.removeEventListener("scroll", u), y.clear(), window.removeEventListener("resize", y), C.disconnect(), L.disconnect();
323
+ t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(E), m(), document.removeEventListener("scroll", u), b.clear(), window.removeEventListener("resize", b), S.disconnect(), L.disconnect();
315
324
  },
316
325
  redraw: g,
317
326
  setStyle: v,
318
- setFilter: b,
319
- setPainter: h,
327
+ setFilter: w,
328
+ setPainter: p,
320
329
  setVisible: o.setVisible
321
330
  };
322
- }, Ge = () => {
331
+ }, Je = () => {
323
332
  const t = document.createElement("canvas");
324
333
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
325
- }, Qe = (t, e) => {
334
+ }, Ze = (t, e) => {
326
335
  t.width = window.innerWidth, t.height = window.innerHeight;
327
- }, Je = (t) => {
336
+ }, tn = (t) => {
328
337
  t.classList.add("r6o-annotatable");
329
- const e = Ge(), n = e.getContext("2d");
338
+ const e = Je(), n = e.getContext("2d");
330
339
  document.body.appendChild(e);
331
- const o = (a, d, c, f) => requestAnimationFrame(() => {
340
+ const o = (a, d, c, h) => requestAnimationFrame(() => {
332
341
  const { width: l, height: g } = e;
333
- n.clearRect(-0.5, -0.5, l + 1, g + 1), f && f.clear();
334
- const { top: h, left: v } = d;
342
+ n.clearRect(-0.5, -0.5, l + 1, g + 1), h && h.clear();
343
+ const { top: p, left: v } = d;
335
344
  [...a].sort((E, m) => {
336
- const { annotation: { target: { created: u } } } = E, { annotation: { target: { created: y } } } = m;
337
- return u.getTime() - y.getTime();
345
+ const { annotation: { target: { created: u } } } = E, { annotation: { target: { created: b } } } = m;
346
+ return u.getTime() - b.getTime();
338
347
  }).forEach((E) => {
339
- var C;
340
- const m = c ? typeof c == "function" ? c(E.annotation, E.state) : c : (C = E.state) != null && C.selected ? vt : q, u = f && f.paint(E, d) || m, y = E.rects.map(({ x: A, y: L, width: R, height: T }) => ({
348
+ var S;
349
+ const m = c ? typeof c == "function" ? c(E.annotation, E.state) : c : (S = E.state) != null && S.selected ? vt : W, u = h && h.paint(E, d) || m, b = E.rects.map(({ x: A, y: L, width: T, height: O }) => ({
341
350
  x: A + v,
342
- y: L + h,
343
- width: R,
344
- height: T
351
+ y: L + p,
352
+ width: T,
353
+ height: O
345
354
  }));
346
- if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, y.forEach(
347
- ({ x: A, y: L, width: R, height: T }) => n.fillRect(A, L, R, T)
355
+ if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, b.forEach(
356
+ ({ x: A, y: L, width: T, height: O }) => n.fillRect(A, L, T, O)
348
357
  ), u.underlineColor) {
349
358
  n.globalAlpha = 1, n.strokeStyle = u.underlineColor, n.lineWidth = u.underlineThickness ?? 1;
350
359
  const A = u.underlineOffset ?? 0;
351
- y.forEach(({ x: L, y: R, width: T, height: S }) => {
352
- n.beginPath(), n.moveTo(L, R + S + A), n.lineTo(L + T, R + S + A), n.stroke();
360
+ b.forEach(({ x: L, y: T, width: O, height: M }) => {
361
+ n.beginPath(), n.moveTo(L, T + M + A), n.lineTo(L + O, T + M + A), n.stroke();
353
362
  });
354
363
  }
355
364
  });
356
- }), i = Xt(() => Qe(e), 10);
365
+ }), i = Xt(() => Ze(e), 10);
357
366
  return window.addEventListener("resize", i), {
358
367
  destroy: () => {
359
368
  e.remove(), i.clear(), window.removeEventListener("resize", i);
@@ -363,20 +372,20 @@ const Xt = /* @__PURE__ */ ze(Fe), We = (t) => {
363
372
  },
364
373
  redraw: o
365
374
  };
366
- }, Ze = (t, e, n) => $t(t, e, n, Je(t));
367
- var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
375
+ }, en = (t, e, n) => Pt(t, e, n, tn(t));
376
+ var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
368
377
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
369
- }, U = function(t, e, n) {
378
+ }, _ = function(t, e, n) {
370
379
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
371
380
  }, X = function(t, e, n) {
372
381
  return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
373
382
  }, pe = function(t) {
374
383
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
375
- }, zt = function(t) {
384
+ }, Ht = function(t) {
376
385
  return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
377
386
  }, St = function(t) {
378
- return { r: U(t.r), g: U(t.g), b: U(t.b), a: U(t.a, 3) };
379
- }, en = /^#([0-9a-f]{3,8})$/i, ft = function(t) {
387
+ return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
388
+ }, on = /^#([0-9a-f]{3,8})$/i, ft = function(t) {
380
389
  var e = t.toString(16);
381
390
  return e.length < 2 ? "0" + e : e;
382
391
  }, ge = function(t) {
@@ -387,72 +396,72 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
387
396
  e = e / 360 * 6, n /= 100, o /= 100;
388
397
  var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), c = s % 6;
389
398
  return { r: 255 * [o, a, r, r, d, o][c], g: 255 * [d, o, o, a, r, r][c], b: 255 * [r, r, d, o, o, a][c], a: i };
390
- }, Ft = function(t) {
399
+ }, zt = function(t) {
391
400
  return { h: pe(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
401
+ }, Ft = function(t) {
402
+ return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
392
403
  }, Wt = function(t) {
393
- return { h: U(t.h), s: U(t.s), l: U(t.l), a: U(t.a, 3) };
394
- }, qt = function(t) {
395
404
  return me((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 }));
396
405
  var e, n, o;
397
406
  }, st = function(t) {
398
407
  return { h: (e = ge(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 };
399
408
  var e, n, o, i;
400
- }, nn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, on = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, sn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Gt = { string: [[function(t) {
401
- var e = en.exec(t);
402
- 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 ? U(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 ? U(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
409
+ }, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qt = { string: [[function(t) {
410
+ var e = on.exec(t);
411
+ 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 ? _(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 ? _(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
403
412
  }, "hex"], [function(t) {
404
- var e = sn.exec(t) || rn.exec(t);
405
- return e ? e[2] !== e[4] || e[4] !== e[6] ? null : zt({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
413
+ var e = an.exec(t) || cn.exec(t);
414
+ return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Ht({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
406
415
  }, "rgb"], [function(t) {
407
- var e = nn.exec(t) || on.exec(t);
416
+ var e = sn.exec(t) || rn.exec(t);
408
417
  if (!e) return null;
409
- var n, o, i = Ft({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (tn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
410
- return qt(i);
418
+ var n, o, i = zt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (nn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
419
+ return Wt(i);
411
420
  }, "hsl"]], object: [[function(t) {
412
421
  var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
413
- return z(e) && z(n) && z(o) ? zt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
422
+ return H(e) && H(n) && H(o) ? Ht({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
414
423
  }, "rgb"], [function(t) {
415
424
  var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
416
- if (!z(e) || !z(n) || !z(o)) return null;
417
- var r = Ft({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
418
- return qt(r);
425
+ if (!H(e) || !H(n) || !H(o)) return null;
426
+ var r = zt({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
427
+ return Wt(r);
419
428
  }, "hsl"], [function(t) {
420
429
  var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
421
- if (!z(e) || !z(n) || !z(o)) return null;
430
+ if (!H(e) || !H(n) || !H(o)) return null;
422
431
  var r = function(a) {
423
432
  return { h: pe(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
424
433
  }({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
425
434
  return me(r);
426
- }, "hsv"]] }, Qt = function(t, e) {
435
+ }, "hsv"]] }, Gt = function(t, e) {
427
436
  for (var n = 0; n < e.length; n++) {
428
437
  var o = e[n][0](t);
429
438
  if (o) return [o, e[n][1]];
430
439
  }
431
440
  return [null, void 0];
432
- }, an = function(t) {
433
- return typeof t == "string" ? Qt(t.trim(), Gt.string) : typeof t == "object" && t !== null ? Qt(t, Gt.object) : [null, void 0];
441
+ }, ln = function(t) {
442
+ return typeof t == "string" ? Gt(t.trim(), qt.string) : typeof t == "object" && t !== null ? Gt(t, qt.object) : [null, void 0];
434
443
  }, Ct = function(t, e) {
435
444
  var n = st(t);
436
445
  return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
437
446
  }, Lt = function(t) {
438
447
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
439
- }, Jt = function(t, e) {
448
+ }, Qt = function(t, e) {
440
449
  var n = st(t);
441
450
  return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
442
- }, Zt = function() {
451
+ }, Jt = function() {
443
452
  function t(e) {
444
- this.parsed = an(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
453
+ this.parsed = ln(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
445
454
  }
446
455
  return t.prototype.isValid = function() {
447
456
  return this.parsed !== null;
448
457
  }, t.prototype.brightness = function() {
449
- return U(Lt(this.rgba), 2);
458
+ return _(Lt(this.rgba), 2);
450
459
  }, t.prototype.isDark = function() {
451
460
  return Lt(this.rgba) < 0.5;
452
461
  }, t.prototype.isLight = function() {
453
462
  return Lt(this.rgba) >= 0.5;
454
463
  }, t.prototype.toHex = function() {
455
- return e = St(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? ft(U(255 * s)) : "", "#" + ft(n) + ft(o) + ft(i) + r;
464
+ return e = St(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? ft(_(255 * s)) : "", "#" + ft(n) + ft(o) + ft(i) + r;
456
465
  var e, n, o, i, s, r;
457
466
  }, t.prototype.toRgb = function() {
458
467
  return St(this.rgba);
@@ -460,47 +469,47 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
460
469
  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 + ")";
461
470
  var e, n, o, i, s;
462
471
  }, t.prototype.toHsl = function() {
463
- return Wt(st(this.rgba));
472
+ return Ft(st(this.rgba));
464
473
  }, t.prototype.toHslString = function() {
465
- return e = Wt(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
474
+ return e = Ft(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
466
475
  var e, n, o, i, s;
467
476
  }, t.prototype.toHsv = function() {
468
- return e = ge(this.rgba), { h: U(e.h), s: U(e.s), v: U(e.v), a: U(e.a, 3) };
477
+ return e = ge(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
469
478
  var e;
470
479
  }, t.prototype.invert = function() {
471
- return P({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
480
+ return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
472
481
  var e;
473
482
  }, t.prototype.saturate = function(e) {
474
- return e === void 0 && (e = 0.1), P(Ct(this.rgba, e));
483
+ return e === void 0 && (e = 0.1), $(Ct(this.rgba, e));
475
484
  }, t.prototype.desaturate = function(e) {
476
- return e === void 0 && (e = 0.1), P(Ct(this.rgba, -e));
485
+ return e === void 0 && (e = 0.1), $(Ct(this.rgba, -e));
477
486
  }, t.prototype.grayscale = function() {
478
- return P(Ct(this.rgba, -1));
487
+ return $(Ct(this.rgba, -1));
479
488
  }, t.prototype.lighten = function(e) {
480
- return e === void 0 && (e = 0.1), P(Jt(this.rgba, e));
489
+ return e === void 0 && (e = 0.1), $(Qt(this.rgba, e));
481
490
  }, t.prototype.darken = function(e) {
482
- return e === void 0 && (e = 0.1), P(Jt(this.rgba, -e));
491
+ return e === void 0 && (e = 0.1), $(Qt(this.rgba, -e));
483
492
  }, t.prototype.rotate = function(e) {
484
493
  return e === void 0 && (e = 15), this.hue(this.hue() + e);
485
494
  }, t.prototype.alpha = function(e) {
486
- return typeof e == "number" ? P({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : U(this.rgba.a, 3);
495
+ return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
487
496
  var n;
488
497
  }, t.prototype.hue = function(e) {
489
498
  var n = st(this.rgba);
490
- return typeof e == "number" ? P({ h: e, s: n.s, l: n.l, a: n.a }) : U(n.h);
499
+ return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
491
500
  }, t.prototype.isEqual = function(e) {
492
- return this.toHex() === P(e).toHex();
501
+ return this.toHex() === $(e).toHex();
493
502
  }, t;
494
- }(), P = function(t) {
495
- return t instanceof Zt ? t : new Zt(t);
503
+ }(), $ = function(t) {
504
+ return t instanceof Jt ? t : new Jt(t);
496
505
  };
497
- const cn = (t) => [
498
- `background-color:${P((t == null ? void 0 : t.fill) || q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? q.fillOpacity : t.fillOpacity).toHex()}`,
506
+ const dn = (t) => [
507
+ `background-color:${$((t == null ? void 0 : t.fill) || W.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? W.fillOpacity : t.fillOpacity).toHex()}`,
499
508
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
500
509
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
501
510
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
502
511
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
503
- ].filter(Boolean).join(";"), ln = () => {
512
+ ].filter(Boolean).join(";"), un = () => {
504
513
  const t = document.createElement("style");
505
514
  document.getElementsByTagName("head")[0].appendChild(t);
506
515
  let e = /* @__PURE__ */ new Set();
@@ -515,20 +524,20 @@ const cn = (t) => [
515
524
  d && d.clear();
516
525
  const c = new Set(s.map((l) => l.annotation.id));
517
526
  Array.from(e).filter((l) => !c.has(l));
518
- const f = s.map((l) => {
527
+ const h = s.map((l) => {
519
528
  var v;
520
- const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (v = l.state) != null && v.selected ? vt : q, h = d && d.paint(l, r) || g;
521
- return `::highlight(_${l.annotation.id}) { ${cn(h)} }`;
529
+ const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (v = l.state) != null && v.selected ? vt : W, p = d && d.paint(l, r) || g;
530
+ return `::highlight(_${l.annotation.id}) { ${dn(p)} }`;
522
531
  });
523
- t.innerHTML = f.join(`
532
+ t.innerHTML = h.join(`
524
533
  `), CSS.highlights.clear(), s.forEach(({ annotation: l }) => {
525
- const g = l.target.selector.map((v) => v.range), h = new Highlight(...g);
526
- CSS.highlights.set(`_${l.id}`, h);
534
+ const g = l.target.selector.map((v) => v.range), p = new Highlight(...g);
535
+ CSS.highlights.set(`_${l.id}`, p);
527
536
  }), e = c;
528
537
  }
529
538
  };
530
- }, dn = (t, e, n) => $t(t, e, n, ln());
531
- var te = Object.prototype.hasOwnProperty;
539
+ }, fn = (t, e, n) => Pt(t, e, n, un());
540
+ var Zt = Object.prototype.hasOwnProperty;
532
541
  function Vt(t, e) {
533
542
  var n, o;
534
543
  if (t === e) return !0;
@@ -543,16 +552,16 @@ function Vt(t, e) {
543
552
  if (!n || typeof t == "object") {
544
553
  o = 0;
545
554
  for (n in t)
546
- if (te.call(t, n) && ++o && !te.call(e, n) || !(n in e) || !Vt(t[n], e[n])) return !1;
555
+ if (Zt.call(t, n) && ++o && !Zt.call(e, n) || !(n in e) || !Vt(t[n], e[n])) return !1;
547
556
  return Object.keys(e).length === o;
548
557
  }
549
558
  }
550
559
  return t !== t && e !== e;
551
560
  }
552
- const un = (t, e) => {
561
+ const hn = (t, e) => {
553
562
  const n = (s, r) => s.x <= r.x + r.width && s.x + s.width >= r.x && s.y <= r.y + r.height && s.y + s.height >= r.y, o = (s) => s.rects.reduce((r, a) => r + a.width, 0), i = e.filter(({ rects: s }) => s.some((r) => n(t, r)));
554
563
  return i.sort((s, r) => o(r) - o(s)), i.findIndex((s) => s.rects.includes(t));
555
- }, fn = (t) => {
564
+ }, pn = (t) => {
556
565
  t.classList.add("r6o-annotatable");
557
566
  const e = document.createElement("div");
558
567
  e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
@@ -561,18 +570,18 @@ const un = (t, e) => {
561
570
  destroy: () => {
562
571
  e.remove();
563
572
  },
564
- redraw: (r, a, d, c, f) => {
565
- const g = !(Vt(n, r) && f);
573
+ redraw: (r, a, d, c, h) => {
574
+ const g = !(Vt(n, r) && h);
566
575
  if (!c && !g) return;
567
- g && (e.innerHTML = ""), [...r].sort((v, b) => {
568
- const { annotation: { target: { created: E } } } = v, { annotation: { target: { created: m } } } = b;
576
+ g && (e.innerHTML = ""), [...r].sort((v, w) => {
577
+ const { annotation: { target: { created: E } } } = v, { annotation: { target: { created: m } } } = w;
569
578
  return E && m ? E.getTime() - m.getTime() : 0;
570
579
  }).forEach((v) => {
571
- v.rects.map((b) => {
572
- const E = un(b, r), m = He(v, a, d, c, E);
580
+ v.rects.map((w) => {
581
+ const E = hn(w, r), m = Fe(v, a, d, c, E);
573
582
  if (g) {
574
583
  const u = document.createElement("span");
575
- u.className = "r6o-annotation", u.dataset.annotation = v.annotation.id, u.style.left = `${b.x}px`, u.style.top = `${b.y}px`, u.style.width = `${b.width}px`, u.style.height = `${b.height}px`, u.style.backgroundColor = P((m == null ? void 0 : m.fill) || q.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? q.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (u.style.borderStyle = m.underlineStyle), m.underlineColor && (u.style.borderColor = m.underlineColor), m.underlineThickness && (u.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (u.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(u);
584
+ u.className = "r6o-annotation", u.dataset.annotation = v.annotation.id, u.style.left = `${w.x}px`, u.style.top = `${w.y}px`, u.style.width = `${w.width}px`, u.style.height = `${w.height}px`, u.style.backgroundColor = $((m == null ? void 0 : m.fill) || W.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? W.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (u.style.borderStyle = m.underlineStyle), m.underlineColor && (u.style.borderColor = m.underlineColor), m.underlineThickness && (u.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (u.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(u);
576
585
  }
577
586
  });
578
587
  }), n = r;
@@ -581,32 +590,32 @@ const un = (t, e) => {
581
590
  r ? e.classList.remove("hidden") : e.classList.add("hidden");
582
591
  }
583
592
  };
584
- }, hn = (t, e, n) => $t(t, e, n, fn(t));
585
- var V = [];
593
+ }, gn = (t, e, n) => Pt(t, e, n, pn(t));
594
+ var U = [];
586
595
  for (var Ot = 0; Ot < 256; ++Ot)
587
- V.push((Ot + 256).toString(16).slice(1));
588
- function pn(t, e = 0) {
589
- return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
596
+ U.push((Ot + 256).toString(16).slice(1));
597
+ function mn(t, e = 0) {
598
+ return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
590
599
  }
591
- var ht, gn = new Uint8Array(16);
592
- function mn() {
600
+ var ht, yn = new Uint8Array(16);
601
+ function bn() {
593
602
  if (!ht && (ht = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ht))
594
603
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
595
- return ht(gn);
604
+ return ht(yn);
596
605
  }
597
- var yn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
598
- const ee = {
599
- randomUUID: yn
606
+ var wn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
607
+ const te = {
608
+ randomUUID: wn
600
609
  };
601
610
  function ye(t, e, n) {
602
- if (ee.randomUUID && !e && !t)
603
- return ee.randomUUID();
611
+ if (te.randomUUID && !e && !t)
612
+ return te.randomUUID();
604
613
  t = t || {};
605
- var o = t.random || (t.rng || mn)();
606
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, pn(o);
614
+ var o = t.random || (t.rng || bn)();
615
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, mn(o);
607
616
  }
608
- var ne = Object.prototype.hasOwnProperty;
609
- function G(t, e) {
617
+ var ee = Object.prototype.hasOwnProperty;
618
+ function q(t, e) {
610
619
  var n, o;
611
620
  if (t === e) return !0;
612
621
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -614,13 +623,13 @@ function G(t, e) {
614
623
  if (n === RegExp) return t.toString() === e.toString();
615
624
  if (n === Array) {
616
625
  if ((o = t.length) === e.length)
617
- for (; o-- && G(t[o], e[o]); ) ;
626
+ for (; o-- && q(t[o], e[o]); ) ;
618
627
  return o === -1;
619
628
  }
620
629
  if (!n || typeof t == "object") {
621
630
  o = 0;
622
631
  for (n in t)
623
- if (ne.call(t, n) && ++o && !ne.call(e, n) || !(n in e) || !G(t[n], e[n])) return !1;
632
+ if (ee.call(t, n) && ++o && !ee.call(e, n) || !(n in e) || !q(t[n], e[n])) return !1;
624
633
  return Object.keys(e).length === o;
625
634
  }
626
635
  }
@@ -628,22 +637,22 @@ function G(t, e) {
628
637
  }
629
638
  function Tt() {
630
639
  }
631
- function bn(t, e) {
640
+ function vn(t, e) {
632
641
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
633
642
  }
634
- const Q = [];
635
- function Pt(t, e = Tt) {
643
+ const G = [];
644
+ function $t(t, e = Tt) {
636
645
  let n;
637
646
  const o = /* @__PURE__ */ new Set();
638
647
  function i(a) {
639
- if (bn(t, a) && (t = a, n)) {
640
- const d = !Q.length;
648
+ if (vn(t, a) && (t = a, n)) {
649
+ const d = !G.length;
641
650
  for (const c of o)
642
- c[1](), Q.push(c, t);
651
+ c[1](), G.push(c, t);
643
652
  if (d) {
644
- for (let c = 0; c < Q.length; c += 2)
645
- Q[c][0](Q[c + 1]);
646
- Q.length = 0;
653
+ for (let c = 0; c < G.length; c += 2)
654
+ G[c][0](G[c + 1]);
655
+ G.length = 0;
647
656
  }
648
657
  }
649
658
  }
@@ -658,8 +667,8 @@ function Pt(t, e = Tt) {
658
667
  }
659
668
  return { set: i, update: s, subscribe: r };
660
669
  }
661
- const wn = (t) => {
662
- const { subscribe: e, set: n } = Pt();
670
+ const An = (t) => {
671
+ const { subscribe: e, set: n } = $t();
663
672
  let o;
664
673
  return e((i) => o = i), t.observe(({ changes: i }) => {
665
674
  if (o) {
@@ -675,53 +684,53 @@ const wn = (t) => {
675
684
  set: n
676
685
  };
677
686
  };
678
- var vn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(vn || {});
679
- const pt = { selected: [] }, An = (t, e, n) => {
680
- const { subscribe: o, set: i } = Pt(pt);
687
+ var xn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(xn || {});
688
+ const pt = { selected: [] }, En = (t, e, n) => {
689
+ const { subscribe: o, set: i } = $t(pt);
681
690
  let s = e, r = pt;
682
691
  o((v) => r = v);
683
692
  const a = () => {
684
- G(r, pt) || i(pt);
693
+ q(r, pt) || i(pt);
685
694
  }, d = () => {
686
695
  var v;
687
696
  return ((v = r.selected) == null ? void 0 : v.length) === 0;
688
697
  }, c = (v) => {
689
698
  if (d())
690
699
  return !1;
691
- const b = typeof v == "string" ? v : v.id;
692
- return r.selected.some((E) => E.id === b);
693
- }, f = (v, b) => {
700
+ const w = typeof v == "string" ? v : v.id;
701
+ return r.selected.some((E) => E.id === w);
702
+ }, h = (v, w) => {
694
703
  const E = t.getAnnotation(v);
695
704
  if (!E) {
696
705
  console.warn("Invalid selection: " + v);
697
706
  return;
698
707
  }
699
- switch (oe(E, s)) {
708
+ switch (ne(E, s)) {
700
709
  case "EDIT":
701
- i({ selected: [{ id: v, editable: !0 }], event: b });
710
+ i({ selected: [{ id: v, editable: !0 }], event: w });
702
711
  break;
703
712
  case "SELECT":
704
- i({ selected: [{ id: v }], event: b });
713
+ i({ selected: [{ id: v }], event: w });
705
714
  break;
706
715
  default:
707
- i({ selected: [], event: b });
716
+ i({ selected: [], event: w });
708
717
  }
709
- }, l = (v, b) => {
718
+ }, l = (v, w) => {
710
719
  const E = Array.isArray(v) ? v : [v], m = E.map((u) => t.getAnnotation(u)).filter((u) => !!u);
711
720
  i({
712
721
  selected: m.map((u) => {
713
- const y = b === void 0 ? oe(u, s) === "EDIT" : b;
714
- return { id: u.id, editable: y };
722
+ const b = w === void 0 ? ne(u, s) === "EDIT" : w;
723
+ return { id: u.id, editable: b };
715
724
  })
716
725
  }), m.length !== E.length && console.warn("Invalid selection", v);
717
726
  }, g = (v) => {
718
727
  if (d())
719
728
  return !1;
720
- const { selected: b } = r;
721
- b.some(({ id: E }) => v.includes(E)) && i({ selected: b.filter(({ id: E }) => !v.includes(E)) });
722
- }, h = (v) => s = v;
729
+ const { selected: w } = r;
730
+ w.some(({ id: E }) => v.includes(E)) && i({ selected: w.filter(({ id: E }) => !v.includes(E)) });
731
+ }, p = (v) => s = v;
723
732
  return t.observe(
724
- ({ changes: v }) => g((v.deleted || []).map((b) => b.id))
733
+ ({ changes: v }) => g((v.deleted || []).map((w) => w.id))
725
734
  ), {
726
735
  get event() {
727
736
  return r ? r.event : null;
@@ -736,33 +745,33 @@ const pt = { selected: [] }, An = (t, e, n) => {
736
745
  isEmpty: d,
737
746
  isSelected: c,
738
747
  setSelected: l,
739
- setUserSelectAction: h,
748
+ setUserSelectAction: p,
740
749
  subscribe: o,
741
- userSelect: f
750
+ userSelect: h
742
751
  };
743
- }, oe = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
744
- var K = [];
752
+ }, ne = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
753
+ var D = [];
745
754
  for (var Rt = 0; Rt < 256; ++Rt)
746
- K.push((Rt + 256).toString(16).slice(1));
747
- function xn(t, e = 0) {
748
- return (K[t[e + 0]] + K[t[e + 1]] + K[t[e + 2]] + K[t[e + 3]] + "-" + K[t[e + 4]] + K[t[e + 5]] + "-" + K[t[e + 6]] + K[t[e + 7]] + "-" + K[t[e + 8]] + K[t[e + 9]] + "-" + K[t[e + 10]] + K[t[e + 11]] + K[t[e + 12]] + K[t[e + 13]] + K[t[e + 14]] + K[t[e + 15]]).toLowerCase();
755
+ D.push((Rt + 256).toString(16).slice(1));
756
+ function Sn(t, e = 0) {
757
+ return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + "-" + D[t[e + 4]] + D[t[e + 5]] + "-" + D[t[e + 6]] + D[t[e + 7]] + "-" + D[t[e + 8]] + D[t[e + 9]] + "-" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();
749
758
  }
750
- var gt, En = new Uint8Array(16);
751
- function Sn() {
759
+ var gt, Cn = new Uint8Array(16);
760
+ function Ln() {
752
761
  if (!gt && (gt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !gt))
753
762
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
754
- return gt(En);
763
+ return gt(Cn);
755
764
  }
756
- var Cn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
757
- const ie = {
758
- randomUUID: Cn
765
+ var On = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
766
+ const oe = {
767
+ randomUUID: On
759
768
  };
760
769
  function be(t, e, n) {
761
- if (ie.randomUUID && !e && !t)
762
- return ie.randomUUID();
770
+ if (oe.randomUUID && !e && !t)
771
+ return oe.randomUUID();
763
772
  t = t || {};
764
- var o = t.random || (t.rng || Sn)();
765
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, xn(o);
773
+ var o = t.random || (t.rng || Ln)();
774
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Sn(o);
766
775
  }
767
776
  const Mt = (t) => {
768
777
  const e = (n) => {
@@ -774,34 +783,34 @@ const Mt = (t) => {
774
783
  bodies: (t.bodies || []).map(e),
775
784
  target: e(t.target)
776
785
  };
777
- }, Mo = (t, e, n, o) => ({
786
+ }, ko = (t, e, n, o) => ({
778
787
  id: be(),
779
788
  annotation: typeof t == "string" ? t : t.id,
780
789
  created: n || /* @__PURE__ */ new Date(),
781
790
  creator: o,
782
791
  ...e
783
- }), Ln = (t, e) => {
792
+ }), Tn = (t, e) => {
784
793
  const n = new Set(t.bodies.map((o) => o.id));
785
794
  return e.bodies.filter((o) => !n.has(o.id));
786
- }, On = (t, e) => {
795
+ }, Rn = (t, e) => {
787
796
  const n = new Set(e.bodies.map((o) => o.id));
788
797
  return t.bodies.filter((o) => !n.has(o.id));
789
- }, Tn = (t, e) => e.bodies.map((n) => {
798
+ }, Mn = (t, e) => e.bodies.map((n) => {
790
799
  const o = t.bodies.find((i) => i.id === n.id);
791
- return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
792
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Rn = (t, e) => !G(t.target, e.target), we = (t, e) => {
793
- const n = Ln(t, e), o = On(t, e), i = Tn(t, e);
800
+ return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
801
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !q(t.target, e.target), we = (t, e) => {
802
+ const n = Tn(t, e), o = Rn(t, e), i = Mn(t, e);
794
803
  return {
795
804
  oldValue: t,
796
805
  newValue: e,
797
806
  bodiesCreated: n.length > 0 ? n : void 0,
798
807
  bodiesDeleted: o.length > 0 ? o : void 0,
799
808
  bodiesUpdated: i.length > 0 ? i : void 0,
800
- targetUpdated: Rn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
809
+ targetUpdated: Bn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
801
810
  };
802
811
  };
803
812
  var k = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(k || {});
804
- const Mn = (t, e) => {
813
+ const kn = (t, e) => {
805
814
  var n, o;
806
815
  const { changes: i, origin: s } = e;
807
816
  if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
@@ -809,7 +818,7 @@ const Mn = (t, e) => {
809
818
  if (t.options.ignore) {
810
819
  const { ignore: r } = t.options, a = (d) => d && d.length > 0;
811
820
  if (!(a(i.created) || a(i.deleted))) {
812
- const d = (n = i.updated) == null ? void 0 : n.some((f) => a(f.bodiesCreated) || a(f.bodiesDeleted) || a(f.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((f) => f.targetUpdated);
821
+ const d = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
813
822
  if (r === "BODY_ONLY" && d && !c || r === "TARGET_ONLY" && c && !d)
814
823
  return !1;
815
824
  }
@@ -823,25 +832,25 @@ const Mn = (t, e) => {
823
832
  return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => r.has(a));
824
833
  } else
825
834
  return !0;
826
- }, Bn = (t, e) => {
835
+ }, In = (t, e) => {
827
836
  const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), s = new Set((e.deleted || []).map((l) => l.id)), r = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), d = [
828
837
  ...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
829
838
  ...e.created || []
830
839
  ], c = [
831
840
  ...(t.deleted || []).filter((l) => !i.has(l.id)),
832
841
  ...(e.deleted || []).filter((l) => !n.has(l.id))
833
- ], f = [
842
+ ], h = [
834
843
  ...(t.updated || []).filter(({ newValue: l }) => !s.has(l.id)).map((l) => {
835
- const { oldValue: g, newValue: h } = l;
836
- if (r.has(h.id)) {
837
- const v = e.updated.find((b) => b.oldValue.id === h.id).newValue;
844
+ const { oldValue: g, newValue: p } = l;
845
+ if (r.has(p.id)) {
846
+ const v = e.updated.find((w) => w.oldValue.id === p.id).newValue;
838
847
  return we(g, v);
839
848
  } else
840
849
  return l;
841
850
  }),
842
851
  ...(e.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
843
852
  ];
844
- return { created: d, deleted: c, updated: f };
853
+ return { created: d, deleted: c, updated: h };
845
854
  }, Bt = (t) => {
846
855
  const e = t.id === void 0 ? be() : t.id;
847
856
  return {
@@ -856,206 +865,206 @@ const Mn = (t, e) => {
856
865
  annotation: e
857
866
  }
858
867
  };
859
- }, kn = (t) => t.id !== void 0, In = () => {
860
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (p, w = {}) => {
861
- n.push({ onChange: p, options: w });
862
- }, i = (p) => {
863
- const w = n.findIndex((x) => x.onChange == p);
864
- w > -1 && n.splice(w, 1);
865
- }, s = (p, w) => {
868
+ }, Nn = (t) => t.id !== void 0, _n = () => {
869
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (f, y = {}) => {
870
+ n.push({ onChange: f, options: y });
871
+ }, i = (f) => {
872
+ const y = n.findIndex((x) => x.onChange == f);
873
+ y > -1 && n.splice(y, 1);
874
+ }, s = (f, y) => {
866
875
  const x = {
867
- origin: p,
876
+ origin: f,
868
877
  changes: {
869
- created: w.created || [],
870
- updated: w.updated || [],
871
- deleted: w.deleted || []
878
+ created: y.created || [],
879
+ updated: y.updated || [],
880
+ deleted: y.deleted || []
872
881
  },
873
882
  state: [...t.values()]
874
883
  };
875
- n.forEach((O) => {
876
- Mn(O, x) && O.onChange(x);
884
+ n.forEach((C) => {
885
+ kn(C, x) && C.onChange(x);
877
886
  });
878
- }, r = (p, w = k.LOCAL) => {
879
- if (p.id && t.get(p.id))
880
- throw Error(`Cannot add annotation ${p.id} - exists already`);
887
+ }, r = (f, y = k.LOCAL) => {
888
+ if (f.id && t.get(f.id))
889
+ throw Error(`Cannot add annotation ${f.id} - exists already`);
881
890
  {
882
- const x = Bt(p);
883
- t.set(x.id, x), x.bodies.forEach((O) => e.set(O.id, x.id)), s(w, { created: [x] });
891
+ const x = Bt(f);
892
+ t.set(x.id, x), x.bodies.forEach((C) => e.set(C.id, x.id)), s(y, { created: [x] });
884
893
  }
885
- }, a = (p, w) => {
886
- const x = Bt(typeof p == "string" ? w : p), O = typeof p == "string" ? p : p.id, B = O && t.get(O);
894
+ }, a = (f, y) => {
895
+ const x = Bt(typeof f == "string" ? y : f), C = typeof f == "string" ? f : f.id, B = C && t.get(C);
887
896
  if (B) {
888
- const M = we(B, x);
889
- return O === x.id ? t.set(O, x) : (t.delete(O), t.set(x.id, x)), B.bodies.forEach((D) => e.delete(D.id)), x.bodies.forEach((D) => e.set(D.id, x.id)), M;
897
+ const R = we(B, x);
898
+ return C === x.id ? t.set(C, x) : (t.delete(C), t.set(x.id, x)), B.bodies.forEach((K) => e.delete(K.id)), x.bodies.forEach((K) => e.set(K.id, x.id)), R;
890
899
  } else
891
- console.warn(`Cannot update annotation ${O} - does not exist`);
892
- }, d = (p, w = k.LOCAL, x = k.LOCAL) => {
893
- const O = kn(w) ? x : w, B = a(p, w);
894
- B && s(O, { updated: [B] });
895
- }, c = (p, w = k.LOCAL) => {
896
- const x = p.reduce((O, B) => {
897
- const M = a(B);
898
- return M ? [...O, M] : O;
900
+ console.warn(`Cannot update annotation ${C} - does not exist`);
901
+ }, d = (f, y = k.LOCAL, x = k.LOCAL) => {
902
+ const C = Nn(y) ? x : y, B = a(f, y);
903
+ B && s(C, { updated: [B] });
904
+ }, c = (f, y = k.LOCAL) => {
905
+ const x = f.reduce((C, B) => {
906
+ const R = a(B);
907
+ return R ? [...C, R] : C;
899
908
  }, []);
900
- x.length > 0 && s(w, { updated: x });
901
- }, f = (p, w = k.LOCAL) => {
902
- const x = t.get(p.annotation);
909
+ x.length > 0 && s(y, { updated: x });
910
+ }, h = (f, y = k.LOCAL) => {
911
+ const x = t.get(f.annotation);
903
912
  if (x) {
904
- const O = {
913
+ const C = {
905
914
  ...x,
906
- bodies: [...x.bodies, p]
915
+ bodies: [...x.bodies, f]
907
916
  };
908
- t.set(x.id, O), e.set(p.id, O.id), s(w, { updated: [{
917
+ t.set(x.id, C), e.set(f.id, C.id), s(y, { updated: [{
909
918
  oldValue: x,
910
- newValue: O,
911
- bodiesCreated: [p]
919
+ newValue: C,
920
+ bodiesCreated: [f]
912
921
  }] });
913
922
  } else
914
- console.warn(`Attempt to add body to missing annotation: ${p.annotation}`);
915
- }, l = () => [...t.values()], g = (p = k.LOCAL) => {
916
- const w = [...t.values()];
917
- t.clear(), e.clear(), s(p, { deleted: w });
918
- }, h = (p, w = !0, x = k.LOCAL) => {
919
- const O = p.map(Bt);
920
- if (w) {
923
+ console.warn(`Attempt to add body to missing annotation: ${f.annotation}`);
924
+ }, l = () => [...t.values()], g = (f = k.LOCAL) => {
925
+ const y = [...t.values()];
926
+ t.clear(), e.clear(), s(f, { deleted: y });
927
+ }, p = (f, y = !0, x = k.LOCAL) => {
928
+ const C = f.map(Bt);
929
+ if (y) {
921
930
  const B = [...t.values()];
922
- t.clear(), e.clear(), O.forEach((M) => {
923
- t.set(M.id, M), M.bodies.forEach((D) => e.set(D.id, M.id));
924
- }), s(x, { created: O, deleted: B });
931
+ t.clear(), e.clear(), C.forEach((R) => {
932
+ t.set(R.id, R), R.bodies.forEach((K) => e.set(K.id, R.id));
933
+ }), s(x, { created: C, deleted: B });
925
934
  } else {
926
- const B = p.reduce((M, D) => {
927
- const N = D.id && t.get(D.id);
928
- return N ? [...M, N] : M;
935
+ const B = f.reduce((R, K) => {
936
+ const Y = K.id && t.get(K.id);
937
+ return Y ? [...R, Y] : R;
929
938
  }, []);
930
939
  if (B.length > 0)
931
- throw Error(`Bulk insert would overwrite the following annotations: ${B.map((M) => M.id).join(", ")}`);
932
- O.forEach((M) => {
933
- t.set(M.id, M), M.bodies.forEach((D) => e.set(D.id, M.id));
934
- }), s(x, { created: O });
940
+ throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
941
+ C.forEach((R) => {
942
+ t.set(R.id, R), R.bodies.forEach((K) => e.set(K.id, R.id));
943
+ }), s(x, { created: C });
935
944
  }
936
- }, v = (p) => {
937
- const w = typeof p == "string" ? p : p.id, x = t.get(w);
945
+ }, v = (f) => {
946
+ const y = typeof f == "string" ? f : f.id, x = t.get(y);
938
947
  if (x)
939
- return t.delete(w), x.bodies.forEach((O) => e.delete(O.id)), x;
940
- console.warn(`Attempt to delete missing annotation: ${w}`);
941
- }, b = (p, w = k.LOCAL) => {
942
- const x = v(p);
943
- x && s(w, { deleted: [x] });
944
- }, E = (p, w = k.LOCAL) => {
945
- const x = p.reduce((O, B) => {
946
- const M = v(B);
947
- return M ? [...O, M] : O;
948
+ return t.delete(y), x.bodies.forEach((C) => e.delete(C.id)), x;
949
+ console.warn(`Attempt to delete missing annotation: ${y}`);
950
+ }, w = (f, y = k.LOCAL) => {
951
+ const x = v(f);
952
+ x && s(y, { deleted: [x] });
953
+ }, E = (f, y = k.LOCAL) => {
954
+ const x = f.reduce((C, B) => {
955
+ const R = v(B);
956
+ return R ? [...C, R] : C;
948
957
  }, []);
949
- x.length > 0 && s(w, { deleted: x });
950
- }, m = (p) => {
951
- const w = t.get(p.annotation);
952
- if (w) {
953
- const x = w.bodies.find((O) => O.id === p.id);
958
+ x.length > 0 && s(y, { deleted: x });
959
+ }, m = (f) => {
960
+ const y = t.get(f.annotation);
961
+ if (y) {
962
+ const x = y.bodies.find((C) => C.id === f.id);
954
963
  if (x) {
955
964
  e.delete(x.id);
956
- const O = {
957
- ...w,
958
- bodies: w.bodies.filter((B) => B.id !== p.id)
965
+ const C = {
966
+ ...y,
967
+ bodies: y.bodies.filter((B) => B.id !== f.id)
959
968
  };
960
- return t.set(w.id, O), {
961
- oldValue: w,
962
- newValue: O,
969
+ return t.set(y.id, C), {
970
+ oldValue: y,
971
+ newValue: C,
963
972
  bodiesDeleted: [x]
964
973
  };
965
974
  } else
966
- console.warn(`Attempt to delete missing body ${p.id} from annotation ${p.annotation}`);
975
+ console.warn(`Attempt to delete missing body ${f.id} from annotation ${f.annotation}`);
967
976
  } else
968
- console.warn(`Attempt to delete body from missing annotation ${p.annotation}`);
969
- }, u = (p, w = k.LOCAL) => {
970
- const x = m(p);
971
- x && s(w, { updated: [x] });
972
- }, y = (p, w = k.LOCAL) => {
973
- const x = p.map((O) => m(O)).filter(Boolean);
974
- x.length > 0 && s(w, { updated: x });
975
- }, C = (p) => {
976
- const w = t.get(p);
977
- return w ? { ...w } : void 0;
978
- }, A = (p) => {
979
- const w = e.get(p);
980
- if (w) {
981
- const x = C(w).bodies.find((O) => O.id === p);
977
+ console.warn(`Attempt to delete body from missing annotation ${f.annotation}`);
978
+ }, u = (f, y = k.LOCAL) => {
979
+ const x = m(f);
980
+ x && s(y, { updated: [x] });
981
+ }, b = (f, y = k.LOCAL) => {
982
+ const x = f.map((C) => m(C)).filter(Boolean);
983
+ x.length > 0 && s(y, { updated: x });
984
+ }, S = (f) => {
985
+ const y = t.get(f);
986
+ return y ? { ...y } : void 0;
987
+ }, A = (f) => {
988
+ const y = e.get(f);
989
+ if (y) {
990
+ const x = S(y).bodies.find((C) => C.id === f);
982
991
  if (x)
983
992
  return x;
984
- console.error(`Store integrity error: body ${p} in index, but not in annotation`);
993
+ console.error(`Store integrity error: body ${f} in index, but not in annotation`);
985
994
  } else
986
- console.warn(`Attempt to retrieve missing body: ${p}`);
987
- }, L = (p, w) => {
988
- if (p.annotation !== w.annotation)
995
+ console.warn(`Attempt to retrieve missing body: ${f}`);
996
+ }, L = (f, y) => {
997
+ if (f.annotation !== y.annotation)
989
998
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
990
- const x = t.get(p.annotation);
999
+ const x = t.get(f.annotation);
991
1000
  if (x) {
992
- const O = x.bodies.find((M) => M.id === p.id), B = {
1001
+ const C = x.bodies.find((R) => R.id === f.id), B = {
993
1002
  ...x,
994
- bodies: x.bodies.map((M) => M.id === O.id ? w : M)
1003
+ bodies: x.bodies.map((R) => R.id === C.id ? y : R)
995
1004
  };
996
- return t.set(x.id, B), O.id !== w.id && (e.delete(O.id), e.set(w.id, B.id)), {
1005
+ return t.set(x.id, B), C.id !== y.id && (e.delete(C.id), e.set(y.id, B.id)), {
997
1006
  oldValue: x,
998
1007
  newValue: B,
999
- bodiesUpdated: [{ oldBody: O, newBody: w }]
1008
+ bodiesUpdated: [{ oldBody: C, newBody: y }]
1000
1009
  };
1001
1010
  } else
1002
- console.warn(`Attempt to add body to missing annotation ${p.annotation}`);
1003
- }, R = (p, w, x = k.LOCAL) => {
1004
- const O = L(p, w);
1005
- O && s(x, { updated: [O] });
1006
- }, T = (p, w = k.LOCAL) => {
1007
- const x = p.map((O) => L({ id: O.id, annotation: O.annotation }, O)).filter(Boolean);
1008
- s(w, { updated: x });
1009
- }, S = (p) => {
1010
- const w = t.get(p.annotation);
1011
- if (w) {
1011
+ console.warn(`Attempt to add body to missing annotation ${f.annotation}`);
1012
+ }, T = (f, y, x = k.LOCAL) => {
1013
+ const C = L(f, y);
1014
+ C && s(x, { updated: [C] });
1015
+ }, O = (f, y = k.LOCAL) => {
1016
+ const x = f.map((C) => L({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
1017
+ s(y, { updated: x });
1018
+ }, M = (f) => {
1019
+ const y = t.get(f.annotation);
1020
+ if (y) {
1012
1021
  const x = {
1013
- ...w,
1022
+ ...y,
1014
1023
  target: {
1015
- ...w.target,
1016
- ...p
1024
+ ...y.target,
1025
+ ...f
1017
1026
  }
1018
1027
  };
1019
- return t.set(w.id, x), {
1020
- oldValue: w,
1028
+ return t.set(y.id, x), {
1029
+ oldValue: y,
1021
1030
  newValue: x,
1022
1031
  targetUpdated: {
1023
- oldTarget: w.target,
1024
- newTarget: p
1032
+ oldTarget: y.target,
1033
+ newTarget: f
1025
1034
  }
1026
1035
  };
1027
1036
  } else
1028
- console.warn(`Attempt to update target on missing annotation: ${p.annotation}`);
1037
+ console.warn(`Attempt to update target on missing annotation: ${f.annotation}`);
1029
1038
  };
1030
1039
  return {
1031
1040
  addAnnotation: r,
1032
- addBody: f,
1041
+ addBody: h,
1033
1042
  all: l,
1034
- bulkAddAnnotation: h,
1043
+ bulkAddAnnotation: p,
1035
1044
  bulkDeleteAnnotation: E,
1036
- bulkDeleteBodies: y,
1045
+ bulkDeleteBodies: b,
1037
1046
  bulkUpdateAnnotation: c,
1038
- bulkUpdateBodies: T,
1039
- bulkUpdateTargets: (p, w = k.LOCAL) => {
1040
- const x = p.map((O) => S(O)).filter(Boolean);
1041
- x.length > 0 && s(w, { updated: x });
1047
+ bulkUpdateBodies: O,
1048
+ bulkUpdateTargets: (f, y = k.LOCAL) => {
1049
+ const x = f.map((C) => M(C)).filter(Boolean);
1050
+ x.length > 0 && s(y, { updated: x });
1042
1051
  },
1043
1052
  clear: g,
1044
- deleteAnnotation: b,
1053
+ deleteAnnotation: w,
1045
1054
  deleteBody: u,
1046
- getAnnotation: C,
1055
+ getAnnotation: S,
1047
1056
  getBody: A,
1048
1057
  observe: o,
1049
1058
  unobserve: i,
1050
1059
  updateAnnotation: d,
1051
- updateBody: R,
1052
- updateTarget: (p, w = k.LOCAL) => {
1053
- const x = S(p);
1054
- x && s(w, { updated: [x] });
1060
+ updateBody: T,
1061
+ updateTarget: (f, y = k.LOCAL) => {
1062
+ const x = M(f);
1063
+ x && s(y, { updated: [x] });
1055
1064
  }
1056
1065
  };
1057
1066
  };
1058
- let _n = () => ({
1067
+ let Un = () => ({
1059
1068
  emit(t, ...e) {
1060
1069
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
1061
1070
  o[n](...e);
@@ -1069,119 +1078,119 @@ let _n = () => ({
1069
1078
  };
1070
1079
  }
1071
1080
  });
1072
- const Nn = 250, Un = (t) => {
1073
- const e = _n(), n = [];
1081
+ const Dn = 250, Vn = (t) => {
1082
+ const e = Un(), n = [];
1074
1083
  let o = -1, i = !1, s = 0;
1075
- const r = (h) => {
1084
+ const r = (p) => {
1076
1085
  if (!i) {
1077
- const { changes: v } = h, b = performance.now();
1078
- if (b - s > Nn)
1086
+ const { changes: v } = p, w = performance.now();
1087
+ if (w - s > Dn)
1079
1088
  n.splice(o + 1), n.push(v), o = n.length - 1;
1080
1089
  else {
1081
1090
  const E = n.length - 1;
1082
- n[E] = Bn(n[E], v);
1091
+ n[E] = In(n[E], v);
1083
1092
  }
1084
- s = b;
1093
+ s = w;
1085
1094
  }
1086
1095
  i = !1;
1087
1096
  };
1088
1097
  t.observe(r, { origin: k.LOCAL });
1089
- const a = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), d = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), c = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: v }) => v)), f = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: v }) => v)), l = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), g = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h);
1098
+ const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), c = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: v }) => v)), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: v }) => v)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1090
1099
  return {
1091
1100
  canRedo: () => n.length - 1 > o,
1092
1101
  canUndo: () => o > -1,
1093
1102
  destroy: () => t.unobserve(r),
1094
- on: (h, v) => e.on(h, v),
1103
+ on: (p, v) => e.on(p, v),
1095
1104
  redo: () => {
1096
1105
  if (n.length - 1 > o) {
1097
1106
  i = !0;
1098
- const { created: h, updated: v, deleted: b } = n[o + 1];
1099
- d(h), f(v), g(b), e.emit("redo", n[o + 1]), o += 1;
1107
+ const { created: p, updated: v, deleted: w } = n[o + 1];
1108
+ d(p), h(v), g(w), e.emit("redo", n[o + 1]), o += 1;
1100
1109
  }
1101
1110
  },
1102
1111
  undo: () => {
1103
1112
  if (o > -1) {
1104
1113
  i = !0;
1105
- const { created: h, updated: v, deleted: b } = n[o];
1106
- a(h), c(v), l(b), e.emit("undo", n[o]), o -= 1;
1114
+ const { created: p, updated: v, deleted: w } = n[o];
1115
+ a(p), c(v), l(w), e.emit("undo", n[o]), o -= 1;
1107
1116
  }
1108
1117
  }
1109
1118
  };
1110
- }, Dn = () => {
1111
- const { subscribe: t, set: e } = Pt([]);
1119
+ }, Kn = () => {
1120
+ const { subscribe: t, set: e } = $t([]);
1112
1121
  return {
1113
1122
  subscribe: t,
1114
1123
  set: e
1115
1124
  };
1116
- }, Vn = (t, e, n, o) => {
1125
+ }, Yn = (t, e, n, o) => {
1117
1126
  const { hover: i, selection: s, store: r, viewport: a } = t, d = /* @__PURE__ */ new Map();
1118
- let c = [], f;
1119
- const l = (b, E) => {
1120
- d.has(b) ? d.get(b).push(E) : d.set(b, [E]);
1121
- }, g = (b, E) => {
1122
- const m = d.get(b);
1127
+ let c = [], h;
1128
+ const l = (w, E) => {
1129
+ d.has(w) ? d.get(w).push(E) : d.set(w, [E]);
1130
+ }, g = (w, E) => {
1131
+ const m = d.get(w);
1123
1132
  if (m) {
1124
1133
  const u = m.indexOf(E);
1125
1134
  u !== -1 && m.splice(u, 1);
1126
1135
  }
1127
- }, h = (b, E, m) => {
1128
- d.has(b) && setTimeout(() => {
1129
- d.get(b).forEach((u) => {
1136
+ }, p = (w, E, m) => {
1137
+ d.has(w) && setTimeout(() => {
1138
+ d.get(w).forEach((u) => {
1130
1139
  if (n) {
1131
- const y = Array.isArray(E) ? E.map((A) => n.serialize(A)) : n.serialize(E), C = m ? m instanceof PointerEvent ? m : n.serialize(m) : void 0;
1132
- u(y, C);
1140
+ const b = Array.isArray(E) ? E.map((A) => n.serialize(A)) : n.serialize(E), S = m ? m instanceof PointerEvent ? m : n.serialize(m) : void 0;
1141
+ u(b, S);
1133
1142
  } else
1134
1143
  u(E, m);
1135
1144
  });
1136
1145
  }, 1);
1137
1146
  };
1138
- s.subscribe(({ selected: b }) => {
1139
- if (!(c.length === 0 && b.length === 0)) {
1140
- if (c.length === 0 && b.length > 0)
1141
- c = b.map(({ id: E }) => r.getAnnotation(E));
1142
- else if (c.length > 0 && b.length === 0)
1147
+ s.subscribe(({ selected: w }) => {
1148
+ if (!(c.length === 0 && w.length === 0)) {
1149
+ if (c.length === 0 && w.length > 0)
1150
+ c = w.map(({ id: E }) => r.getAnnotation(E));
1151
+ else if (c.length > 0 && w.length === 0)
1143
1152
  c.forEach((E) => {
1144
1153
  const m = r.getAnnotation(E.id);
1145
- m && !G(m, E) && h("updateAnnotation", m, E);
1154
+ m && !q(m, E) && p("updateAnnotation", m, E);
1146
1155
  }), c = [];
1147
1156
  else {
1148
- const E = new Set(c.map((u) => u.id)), m = new Set(b.map(({ id: u }) => u));
1157
+ const E = new Set(c.map((u) => u.id)), m = new Set(w.map(({ id: u }) => u));
1149
1158
  c.filter((u) => !m.has(u.id)).forEach((u) => {
1150
- const y = r.getAnnotation(u.id);
1151
- y && !G(y, u) && h("updateAnnotation", y, u);
1159
+ const b = r.getAnnotation(u.id);
1160
+ b && !q(b, u) && p("updateAnnotation", b, u);
1152
1161
  }), c = [
1153
1162
  // Remove annotations that were deselected
1154
1163
  ...c.filter((u) => m.has(u.id)),
1155
1164
  // Add editable annotations that were selected
1156
- ...b.filter(({ id: u }) => !E.has(u)).map(({ id: u }) => r.getAnnotation(u))
1165
+ ...w.filter(({ id: u }) => !E.has(u)).map(({ id: u }) => r.getAnnotation(u))
1157
1166
  ];
1158
1167
  }
1159
- h("selectionChanged", c);
1168
+ p("selectionChanged", c);
1160
1169
  }
1161
- }), i.subscribe((b) => {
1162
- !f && b ? h("mouseEnterAnnotation", r.getAnnotation(b)) : f && !b ? h("mouseLeaveAnnotation", r.getAnnotation(f)) : f && b && (h("mouseLeaveAnnotation", r.getAnnotation(f)), h("mouseEnterAnnotation", r.getAnnotation(b))), f = b;
1163
- }), a == null || a.subscribe((b) => h("viewportIntersect", b.map((E) => r.getAnnotation(E)))), r.observe((b) => {
1164
- const { created: E, deleted: m } = b.changes;
1165
- (E || []).forEach((u) => h("createAnnotation", u)), (m || []).forEach((u) => h("deleteAnnotation", u)), (b.changes.updated || []).filter((u) => [
1170
+ }), i.subscribe((w) => {
1171
+ !h && w ? p("mouseEnterAnnotation", r.getAnnotation(w)) : h && !w ? p("mouseLeaveAnnotation", r.getAnnotation(h)) : h && w && (p("mouseLeaveAnnotation", r.getAnnotation(h)), p("mouseEnterAnnotation", r.getAnnotation(w))), h = w;
1172
+ }), a == null || a.subscribe((w) => p("viewportIntersect", w.map((E) => r.getAnnotation(E)))), r.observe((w) => {
1173
+ const { created: E, deleted: m } = w.changes;
1174
+ (E || []).forEach((u) => p("createAnnotation", u)), (m || []).forEach((u) => p("deleteAnnotation", u)), (w.changes.updated || []).filter((u) => [
1166
1175
  ...u.bodiesCreated || [],
1167
1176
  ...u.bodiesDeleted || [],
1168
1177
  ...u.bodiesUpdated || []
1169
- ].length > 0).forEach(({ oldValue: u, newValue: y }) => {
1170
- const C = c.find((A) => A.id === u.id) || u;
1171
- c = c.map((A) => A.id === u.id ? y : A), h("updateAnnotation", y, C);
1178
+ ].length > 0).forEach(({ oldValue: u, newValue: b }) => {
1179
+ const S = c.find((A) => A.id === u.id) || u;
1180
+ c = c.map((A) => A.id === u.id ? b : A), p("updateAnnotation", b, S);
1172
1181
  });
1173
- }, { origin: k.LOCAL }), r.observe((b) => {
1182
+ }, { origin: k.LOCAL }), r.observe((w) => {
1174
1183
  if (c) {
1175
- const E = new Set(c.map((u) => u.id)), m = (b.changes.updated || []).filter(({ newValue: u }) => E.has(u.id)).map(({ newValue: u }) => u);
1176
- m.length > 0 && (c = c.map((u) => m.find((C) => C.id === u.id) || u));
1184
+ const E = new Set(c.map((u) => u.id)), m = (w.changes.updated || []).filter(({ newValue: u }) => E.has(u.id)).map(({ newValue: u }) => u);
1185
+ m.length > 0 && (c = c.map((u) => m.find((S) => S.id === u.id) || u));
1177
1186
  }
1178
1187
  }, { origin: k.REMOTE });
1179
- const v = (b) => (E) => {
1188
+ const v = (w) => (E) => {
1180
1189
  const { updated: m } = E;
1181
- b ? (m || []).forEach((u) => h("updateAnnotation", u.oldValue, u.newValue)) : (m || []).forEach((u) => h("updateAnnotation", u.newValue, u.oldValue));
1190
+ w ? (m || []).forEach((u) => p("updateAnnotation", u.oldValue, u.newValue)) : (m || []).forEach((u) => p("updateAnnotation", u.newValue, u.oldValue));
1182
1191
  };
1183
- return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: l, off: g, emit: h };
1184
- }, Kn = (t) => (e) => e.reduce((n, o) => {
1192
+ return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: l, off: g, emit: p };
1193
+ }, Xn = (t) => (e) => e.reduce((n, o) => {
1185
1194
  const { parsed: i, error: s } = t.parse(o);
1186
1195
  return s ? {
1187
1196
  parsed: n.parsed,
@@ -1192,21 +1201,21 @@ const Nn = 250, Un = (t) => {
1192
1201
  } : {
1193
1202
  ...n
1194
1203
  };
1195
- }, { parsed: [], failed: [] }), Yn = (t, e, n) => {
1204
+ }, { parsed: [], failed: [] }), Pn = (t, e, n) => {
1196
1205
  const { store: o, selection: i } = t, s = (m) => {
1197
1206
  if (n) {
1198
- const { parsed: u, error: y } = n.parse(m);
1199
- u ? o.addAnnotation(u, k.REMOTE) : console.error(y);
1207
+ const { parsed: u, error: b } = n.parse(m);
1208
+ u ? o.addAnnotation(u, k.REMOTE) : console.error(b);
1200
1209
  } else
1201
1210
  o.addAnnotation(Mt(m), k.REMOTE);
1202
1211
  }, r = () => i.clear(), a = () => o.clear(), d = (m) => {
1203
1212
  const u = o.getAnnotation(m);
1204
1213
  return n && u ? n.serialize(u) : u;
1205
- }, c = () => n ? o.all().map(n.serialize) : o.all(), f = () => {
1214
+ }, c = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1206
1215
  var m;
1207
- const u = (((m = i.selected) == null ? void 0 : m.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
1216
+ const u = (((m = i.selected) == null ? void 0 : m.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
1208
1217
  return n ? u.map(n.serialize) : u;
1209
- }, l = (m, u = !0) => fetch(m).then((y) => y.json()).then((y) => (h(y, u), y)), g = (m) => {
1218
+ }, l = (m, u = !0) => fetch(m).then((b) => b.json()).then((b) => (p(b, u), b)), g = (m) => {
1210
1219
  if (typeof m == "string") {
1211
1220
  const u = o.getAnnotation(m);
1212
1221
  if (o.deleteAnnotation(m), u)
@@ -1216,20 +1225,20 @@ const Nn = 250, Un = (t) => {
1216
1225
  if (u)
1217
1226
  return o.deleteAnnotation(u), m;
1218
1227
  }
1219
- }, h = (m, u = !0) => {
1228
+ }, p = (m, u = !0) => {
1220
1229
  if (n) {
1221
- const y = n.parseAll || Kn(n), { parsed: C, failed: A } = y(m);
1222
- A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(C, u, k.REMOTE);
1230
+ const b = n.parseAll || Xn(n), { parsed: S, failed: A } = b(m);
1231
+ A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(S, u, k.REMOTE);
1223
1232
  } else
1224
1233
  o.bulkAddAnnotation(m.map(Mt), u, k.REMOTE);
1225
1234
  }, v = (m, u) => {
1226
1235
  m ? i.setSelected(m, u) : i.clear();
1227
- }, b = (m) => {
1236
+ }, w = (m) => {
1228
1237
  i.clear(), i.setUserSelectAction(m);
1229
1238
  }, E = (m) => {
1230
1239
  if (n) {
1231
- const u = n.parse(m).parsed, y = n.serialize(o.getAnnotation(u.id));
1232
- return o.updateAnnotation(u), y;
1240
+ const u = n.parse(m).parsed, b = n.serialize(o.getAnnotation(u.id));
1241
+ return o.updateAnnotation(u), b;
1233
1242
  } else {
1234
1243
  const u = o.getAnnotation(m.id);
1235
1244
  return o.updateAnnotation(Mt(m)), u;
@@ -1243,18 +1252,18 @@ const Nn = 250, Un = (t) => {
1243
1252
  clearAnnotations: a,
1244
1253
  getAnnotationById: d,
1245
1254
  getAnnotations: c,
1246
- getSelected: f,
1255
+ getSelected: h,
1247
1256
  loadAnnotations: l,
1248
1257
  redo: e.redo,
1249
1258
  removeAnnotation: g,
1250
- setAnnotations: h,
1259
+ setAnnotations: p,
1251
1260
  setSelected: v,
1252
- setUserSelectAction: b,
1261
+ setUserSelectAction: w,
1253
1262
  undo: e.undo,
1254
1263
  updateAnnotation: E
1255
1264
  };
1256
- }, Xn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1257
- let $n = (t) => crypto.getRandomValues(new Uint8Array(t)), Pn = (t, e, n) => {
1265
+ }, $n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1266
+ let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
1258
1267
  let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
1259
1268
  return (s = e) => {
1260
1269
  let r = "";
@@ -1264,13 +1273,13 @@ let $n = (t) => crypto.getRandomValues(new Uint8Array(t)), Pn = (t, e, n) => {
1264
1273
  if (r += t[a[d] & o] || "", r.length === s) return r;
1265
1274
  }
1266
1275
  };
1267
- }, jn = (t, e = 21) => Pn(t, e, $n), Hn = (t = 21) => {
1276
+ }, zn = (t, e = 21) => Hn(t, e, jn), Fn = (t = 21) => {
1268
1277
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
1269
1278
  for (; t--; )
1270
- e += Xn[n[t] & 63];
1279
+ e += $n[n[t] & 63];
1271
1280
  return e;
1272
1281
  };
1273
- const zn = () => ({ isGuest: !0, id: jn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Fn = (t) => {
1282
+ const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), qn = (t) => {
1274
1283
  const e = JSON.stringify(t);
1275
1284
  let n = 0;
1276
1285
  for (let o = 0, i = e.length; o < i; o++) {
@@ -1278,10 +1287,10 @@ const zn = () => ({ isGuest: !0, id: jn("1234567890abcdefghijklmnopqrstuvwxyzABC
1278
1287
  n = (n << 5) - n + s, n |= 0;
1279
1288
  }
1280
1289
  return `${n}`;
1281
- }, ve = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Wn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1282
- const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...f } = n;
1290
+ }, ve = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Gn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1291
+ const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...h } = n;
1283
1292
  return {
1284
- id: o || `temp-${Fn(n)}`,
1293
+ id: o || `temp-${qn(n)}`,
1285
1294
  annotation: e,
1286
1295
  type: i,
1287
1296
  purpose: s,
@@ -1289,9 +1298,9 @@ const zn = () => ({ isGuest: !0, id: jn("1234567890abcdefghijklmnopqrstuvwxyzABC
1289
1298
  creator: ve(c),
1290
1299
  created: a ? new Date(a) : void 0,
1291
1300
  updated: d ? new Date(d) : void 0,
1292
- ...f
1301
+ ...h
1293
1302
  };
1294
- }), qn = (t) => t.map((e) => {
1303
+ }), Qn = (t) => t.map((e) => {
1295
1304
  var n;
1296
1305
  const { annotation: o, created: i, updated: s, ...r } = e, a = {
1297
1306
  ...r,
@@ -1300,11 +1309,11 @@ const zn = () => ({ isGuest: !0, id: jn("1234567890abcdefghijklmnopqrstuvwxyzABC
1300
1309
  };
1301
1310
  return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
1302
1311
  });
1303
- Hn();
1304
- const Bo = (t, e) => ({
1305
- parse: (n) => Jn(n),
1306
- serialize: (n) => Zn(n, t, e)
1307
- }), Gn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Qn = (t) => {
1312
+ Fn();
1313
+ const Io = (t, e) => ({
1314
+ parse: (n) => to(n),
1315
+ serialize: (n) => eo(n, t, e)
1316
+ }), Jn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Zn = (t) => {
1308
1317
  const {
1309
1318
  id: e,
1310
1319
  creator: n,
@@ -1323,7 +1332,7 @@ const Bo = (t, e) => ({
1323
1332
  styleClass: r[0].styleClass
1324
1333
  };
1325
1334
  for (const d of r) {
1326
- const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, g) => {
1335
+ const h = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, g) => {
1327
1336
  switch (g.type) {
1328
1337
  case "TextQuoteSelector":
1329
1338
  l.quote = g.exact;
@@ -1334,25 +1343,25 @@ const Bo = (t, e) => ({
1334
1343
  }
1335
1344
  return l;
1336
1345
  }, {});
1337
- if (Gn(f))
1338
- a.selector.push({ id: d.id, ...f });
1346
+ if (Jn(h))
1347
+ a.selector.push({ id: d.id, ...h });
1339
1348
  else {
1340
1349
  const l = [
1341
- f.start ? void 0 : "TextPositionSelector",
1342
- f.quote ? void 0 : "TextQuoteSelector"
1350
+ h.start ? void 0 : "TextPositionSelector",
1351
+ h.quote ? void 0 : "TextQuoteSelector"
1343
1352
  ].filter(Boolean);
1344
1353
  return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
1345
1354
  }
1346
1355
  }
1347
1356
  return { parsed: a };
1348
- }, Jn = (t) => {
1357
+ }, to = (t) => {
1349
1358
  const e = t.id || ye(), {
1350
1359
  creator: n,
1351
1360
  created: o,
1352
1361
  modified: i,
1353
1362
  body: s,
1354
1363
  ...r
1355
- } = t, a = Wn(s, e), d = Qn(t);
1364
+ } = t, a = Gn(s, e), d = Zn(t);
1356
1365
  return "error" in d ? { error: d.error } : {
1357
1366
  parsed: {
1358
1367
  ...r,
@@ -1361,29 +1370,29 @@ const Bo = (t, e) => ({
1361
1370
  target: d.parsed
1362
1371
  }
1363
1372
  };
1364
- }, Zn = (t, e, n) => {
1373
+ }, eo = (t, e, n) => {
1365
1374
  const { bodies: o, target: i, ...s } = t, {
1366
1375
  selector: r,
1367
1376
  creator: a,
1368
1377
  created: d,
1369
1378
  updated: c,
1370
- ...f
1379
+ ...h
1371
1380
  } = i, l = r.map((g) => {
1372
- const { quote: h, start: v, end: b, range: E } = g, { prefix: m, suffix: u } = Ne(E, n), y = [{
1381
+ const { quote: p, start: v, end: w, range: E } = g, { prefix: m, suffix: u } = Ue(E, n), b = [{
1373
1382
  type: "TextQuoteSelector",
1374
- exact: h,
1383
+ exact: p,
1375
1384
  prefix: m,
1376
1385
  suffix: u
1377
1386
  }, {
1378
1387
  type: "TextPositionSelector",
1379
1388
  start: v,
1380
- end: b
1389
+ end: w
1381
1390
  }];
1382
1391
  return {
1383
- ...f,
1392
+ ...h,
1384
1393
  id: g.id,
1385
1394
  source: e,
1386
- selector: y
1395
+ selector: b
1387
1396
  };
1388
1397
  });
1389
1398
  return {
@@ -1391,36 +1400,36 @@ const Bo = (t, e) => ({
1391
1400
  "@context": "http://www.w3.org/ns/anno.jsonld",
1392
1401
  id: t.id,
1393
1402
  type: "Annotation",
1394
- body: qn(t.bodies),
1403
+ body: Qn(t.bodies),
1395
1404
  creator: a,
1396
1405
  created: d == null ? void 0 : d.toISOString(),
1397
1406
  modified: c == null ? void 0 : c.toISOString(),
1398
1407
  target: l
1399
1408
  };
1400
1409
  };
1401
- function Ae(t, e, n = 0, o = t.length - 1, i = to) {
1410
+ function Ae(t, e, n = 0, o = t.length - 1, i = no) {
1402
1411
  for (; o > n; ) {
1403
1412
  if (o - n > 600) {
1404
- const d = o - n + 1, c = e - n + 1, f = Math.log(d), l = 0.5 * Math.exp(2 * f / 3), g = 0.5 * Math.sqrt(f * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(e - c * l / d + g)), v = Math.min(o, Math.floor(e + (d - c) * l / d + g));
1405
- Ae(t, e, h, v, i);
1413
+ const d = o - n + 1, c = e - n + 1, h = Math.log(d), l = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - c * l / d + g)), v = Math.min(o, Math.floor(e + (d - c) * l / d + g));
1414
+ Ae(t, e, p, v, i);
1406
1415
  }
1407
1416
  const s = t[e];
1408
1417
  let r = n, a = o;
1409
- for (et(t, n, e), i(t[o], s) > 0 && et(t, n, o); r < a; ) {
1410
- for (et(t, r, a), r++, a--; i(t[r], s) < 0; ) r++;
1418
+ for (tt(t, n, e), i(t[o], s) > 0 && tt(t, n, o); r < a; ) {
1419
+ for (tt(t, r, a), r++, a--; i(t[r], s) < 0; ) r++;
1411
1420
  for (; i(t[a], s) > 0; ) a--;
1412
1421
  }
1413
- i(t[n], s) === 0 ? et(t, n, a) : (a++, et(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);
1422
+ i(t[n], s) === 0 ? tt(t, n, a) : (a++, tt(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);
1414
1423
  }
1415
1424
  }
1416
- function et(t, e, n) {
1425
+ function tt(t, e, n) {
1417
1426
  const o = t[e];
1418
1427
  t[e] = t[n], t[n] = o;
1419
1428
  }
1420
- function to(t, e) {
1429
+ function no(t, e) {
1421
1430
  return t < e ? -1 : t > e ? 1 : 0;
1422
1431
  }
1423
- class eo {
1432
+ class oo {
1424
1433
  constructor(e = 9) {
1425
1434
  this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
1426
1435
  }
@@ -1482,7 +1491,7 @@ class eo {
1482
1491
  return e && this._insert(e, this.data.height - 1), this;
1483
1492
  }
1484
1493
  clear() {
1485
- return this.data = Z([]), this;
1494
+ return this.data = J([]), this;
1486
1495
  }
1487
1496
  remove(e, n) {
1488
1497
  if (!e) return this;
@@ -1491,9 +1500,9 @@ class eo {
1491
1500
  let a, d, c;
1492
1501
  for (; o || s.length; ) {
1493
1502
  if (o || (o = s.pop(), d = s[s.length - 1], a = r.pop(), c = !0), o.leaf) {
1494
- const f = no(e, o.children, n);
1495
- if (f !== -1)
1496
- return o.children.splice(f, 1), s.push(o), this._condense(s), this;
1503
+ const h = io(e, o.children, n);
1504
+ if (h !== -1)
1505
+ return o.children.splice(h, 1), s.push(o), this._condense(s), this;
1497
1506
  }
1498
1507
  !c && !o.leaf && It(o, i) ? (s.push(o), r.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], c = !1) : o = null;
1499
1508
  }
@@ -1524,26 +1533,26 @@ class eo {
1524
1533
  const s = o - n + 1;
1525
1534
  let r = this._maxEntries, a;
1526
1535
  if (s <= r)
1527
- return a = Z(e.slice(n, o + 1)), J(a, this.toBBox), a;
1528
- i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = Z([]), a.leaf = !1, a.height = i;
1536
+ return a = J(e.slice(n, o + 1)), Q(a, this.toBBox), a;
1537
+ i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = J([]), a.leaf = !1, a.height = i;
1529
1538
  const d = Math.ceil(s / r), c = d * Math.ceil(Math.sqrt(r));
1530
- se(e, n, o, c, this.compareMinX);
1531
- for (let f = n; f <= o; f += c) {
1532
- const l = Math.min(f + c - 1, o);
1533
- se(e, f, l, d, this.compareMinY);
1534
- for (let g = f; g <= l; g += d) {
1535
- const h = Math.min(g + d - 1, l);
1536
- a.children.push(this._build(e, g, h, i - 1));
1539
+ ie(e, n, o, c, this.compareMinX);
1540
+ for (let h = n; h <= o; h += c) {
1541
+ const l = Math.min(h + c - 1, o);
1542
+ ie(e, h, l, d, this.compareMinY);
1543
+ for (let g = h; g <= l; g += d) {
1544
+ const p = Math.min(g + d - 1, l);
1545
+ a.children.push(this._build(e, g, p, i - 1));
1537
1546
  }
1538
1547
  }
1539
- return J(a, this.toBBox), a;
1548
+ return Q(a, this.toBBox), a;
1540
1549
  }
1541
1550
  _chooseSubtree(e, n, o, i) {
1542
1551
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1543
1552
  let s = 1 / 0, r = 1 / 0, a;
1544
1553
  for (let d = 0; d < n.children.length; d++) {
1545
- const c = n.children[d], f = kt(c), l = so(e, c) - f;
1546
- l < r ? (r = l, s = f < s ? f : s, a = c) : l === r && f < s && (s = f, a = c);
1554
+ const c = n.children[d], h = kt(c), l = ao(e, c) - h;
1555
+ l < r ? (r = l, s = h < s ? h : s, a = c) : l === r && h < s && (s = h, a = c);
1547
1556
  }
1548
1557
  n = a || n.children[0];
1549
1558
  }
@@ -1559,23 +1568,23 @@ class eo {
1559
1568
  _split(e, n) {
1560
1569
  const o = e[n], i = o.children.length, s = this._minEntries;
1561
1570
  this._chooseSplitAxis(o, s, i);
1562
- const r = this._chooseSplitIndex(o, s, i), a = Z(o.children.splice(r, o.children.length - r));
1563
- a.height = o.height, a.leaf = o.leaf, J(o, this.toBBox), J(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
1571
+ const r = this._chooseSplitIndex(o, s, i), a = J(o.children.splice(r, o.children.length - r));
1572
+ a.height = o.height, a.leaf = o.leaf, Q(o, this.toBBox), Q(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
1564
1573
  }
1565
1574
  _splitRoot(e, n) {
1566
- this.data = Z([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
1575
+ this.data = J([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, Q(this.data, this.toBBox);
1567
1576
  }
1568
1577
  _chooseSplitIndex(e, n, o) {
1569
1578
  let i, s = 1 / 0, r = 1 / 0;
1570
1579
  for (let a = n; a <= o - n; a++) {
1571
- const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), f = ro(d, c), l = kt(d) + kt(c);
1572
- f < s ? (s = f, i = a, r = l < r ? l : r) : f === s && l < r && (r = l, i = a);
1580
+ const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), h = co(d, c), l = kt(d) + kt(c);
1581
+ h < s ? (s = h, i = a, r = l < r ? l : r) : h === s && l < r && (r = l, i = a);
1573
1582
  }
1574
1583
  return i || o - n;
1575
1584
  }
1576
1585
  // sorts node children by the best axis for split
1577
1586
  _chooseSplitAxis(e, n, o) {
1578
- const i = e.leaf ? this.compareMinX : oo, s = e.leaf ? this.compareMinY : io, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
1587
+ const i = e.leaf ? this.compareMinX : so, s = e.leaf ? this.compareMinY : ro, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
1579
1588
  r < a && e.children.sort(i);
1580
1589
  }
1581
1590
  // total margin of all possible split distributions where each node is at least m full
@@ -1584,12 +1593,12 @@ class eo {
1584
1593
  const s = this.toBBox, r = ot(e, 0, n, s), a = ot(e, o - n, o, s);
1585
1594
  let d = mt(r) + mt(a);
1586
1595
  for (let c = n; c < o - n; c++) {
1587
- const f = e.children[c];
1588
- it(r, e.leaf ? s(f) : f), d += mt(r);
1596
+ const h = e.children[c];
1597
+ it(r, e.leaf ? s(h) : h), d += mt(r);
1589
1598
  }
1590
1599
  for (let c = o - n - 1; c >= n; c--) {
1591
- const f = e.children[c];
1592
- it(a, e.leaf ? s(f) : f), d += mt(a);
1600
+ const h = e.children[c];
1601
+ it(a, e.leaf ? s(h) : h), d += mt(a);
1593
1602
  }
1594
1603
  return d;
1595
1604
  }
@@ -1599,20 +1608,20 @@ class eo {
1599
1608
  }
1600
1609
  _condense(e) {
1601
1610
  for (let n = e.length - 1, o; n >= 0; n--)
1602
- e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : J(e[n], this.toBBox);
1611
+ e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : Q(e[n], this.toBBox);
1603
1612
  }
1604
1613
  }
1605
- function no(t, e, n) {
1614
+ function io(t, e, n) {
1606
1615
  if (!n) return e.indexOf(t);
1607
1616
  for (let o = 0; o < e.length; o++)
1608
1617
  if (n(t, e[o])) return o;
1609
1618
  return -1;
1610
1619
  }
1611
- function J(t, e) {
1620
+ function Q(t, e) {
1612
1621
  ot(t, 0, t.children.length, e, t);
1613
1622
  }
1614
1623
  function ot(t, e, n, o, i) {
1615
- i || (i = Z(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1624
+ i || (i = J(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1616
1625
  for (let s = e; s < n; s++) {
1617
1626
  const r = t.children[s];
1618
1627
  it(i, t.leaf ? o(r) : r);
@@ -1622,10 +1631,10 @@ function ot(t, e, n, o, i) {
1622
1631
  function it(t, e) {
1623
1632
  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;
1624
1633
  }
1625
- function oo(t, e) {
1634
+ function so(t, e) {
1626
1635
  return t.minX - e.minX;
1627
1636
  }
1628
- function io(t, e) {
1637
+ function ro(t, e) {
1629
1638
  return t.minY - e.minY;
1630
1639
  }
1631
1640
  function kt(t) {
@@ -1634,10 +1643,10 @@ function kt(t) {
1634
1643
  function mt(t) {
1635
1644
  return t.maxX - t.minX + (t.maxY - t.minY);
1636
1645
  }
1637
- function so(t, e) {
1646
+ function ao(t, e) {
1638
1647
  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));
1639
1648
  }
1640
- function ro(t, e) {
1649
+ function co(t, e) {
1641
1650
  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);
1642
1651
  return Math.max(0, i - n) * Math.max(0, s - o);
1643
1652
  }
@@ -1647,7 +1656,7 @@ function It(t, e) {
1647
1656
  function yt(t, e) {
1648
1657
  return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
1649
1658
  }
1650
- function Z(t) {
1659
+ function J(t) {
1651
1660
  return {
1652
1661
  children: t,
1653
1662
  height: 1,
@@ -1658,7 +1667,7 @@ function Z(t) {
1658
1667
  maxY: -1 / 0
1659
1668
  };
1660
1669
  }
1661
- function se(t, e, n, o, i) {
1670
+ function ie(t, e, n, o, i) {
1662
1671
  const s = [e, n];
1663
1672
  for (; s.length; ) {
1664
1673
  if (n = s.pop(), e = s.pop(), n - e <= o) continue;
@@ -1666,7 +1675,7 @@ function se(t, e, n, o, i) {
1666
1675
  Ae(t, r, e, n, i), s.push(e, r, r, n);
1667
1676
  }
1668
1677
  }
1669
- let ao = () => ({
1678
+ let lo = () => ({
1670
1679
  emit(t, ...e) {
1671
1680
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
1672
1681
  o[n](...e);
@@ -1680,122 +1689,122 @@ let ao = () => ({
1680
1689
  };
1681
1690
  }
1682
1691
  });
1683
- const co = (t, e) => {
1684
- const n = new eo(), o = /* @__PURE__ */ new Map(), i = ao(), s = (y, C) => {
1685
- const A = y.selector.flatMap((R) => {
1686
- const T = W([R]) ? R.range : ue(R, e).range;
1687
- return Array.from(T.getClientRects());
1688
- }), L = Ye(A).map((R) => Pe(R, C));
1689
- return L.map((R) => {
1690
- const { x: T, y: S, width: p, height: w } = R;
1692
+ const uo = (t, e) => {
1693
+ const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (b, S) => {
1694
+ const A = b.selector.flatMap((T) => {
1695
+ const O = F([T]) ? T.range : de(T, e).range;
1696
+ return Array.from(O.getClientRects());
1697
+ }), L = Xe(A).map((T) => He(T, S));
1698
+ return L.map((T) => {
1699
+ const { x: O, y: M, width: f, height: y } = T;
1691
1700
  return {
1692
- minX: T,
1693
- minY: S,
1694
- maxX: T + p,
1695
- maxY: S + w,
1701
+ minX: O,
1702
+ minY: M,
1703
+ maxX: O + f,
1704
+ maxY: M + y,
1696
1705
  annotation: {
1697
- id: y.annotation,
1706
+ id: b.annotation,
1698
1707
  rects: L
1699
1708
  }
1700
1709
  };
1701
1710
  });
1702
1711
  }, r = () => [...o.values()], a = () => {
1703
1712
  n.clear(), o.clear();
1704
- }, d = (y) => {
1705
- const C = s(y, e.getBoundingClientRect());
1706
- C.forEach((A) => n.insert(A)), o.set(y.annotation, C);
1707
- }, c = (y) => {
1708
- const C = o.get(y.annotation);
1709
- C && (C.forEach((A) => n.remove(A)), o.delete(y.annotation));
1710
- }, f = (y) => {
1711
- c(y), d(y);
1712
- }, l = (y, C = !0) => {
1713
- C && a();
1714
- const A = e.getBoundingClientRect(), L = y.map((T) => ({ target: T, rects: s(T, A) }));
1715
- L.forEach(({ target: T, rects: S }) => o.set(T.annotation, S));
1716
- const R = L.flatMap(({ rects: T }) => T);
1717
- n.load(R);
1718
- }, g = (y, C, A = !1) => {
1713
+ }, d = (b) => {
1714
+ const S = s(b, e.getBoundingClientRect());
1715
+ S.forEach((A) => n.insert(A)), o.set(b.annotation, S);
1716
+ }, c = (b) => {
1717
+ const S = o.get(b.annotation);
1718
+ S && (S.forEach((A) => n.remove(A)), o.delete(b.annotation));
1719
+ }, h = (b) => {
1720
+ c(b), d(b);
1721
+ }, l = (b, S = !0) => {
1722
+ S && a();
1723
+ const A = e.getBoundingClientRect(), L = b.map((O) => ({ target: O, rects: s(O, A) }));
1724
+ L.forEach(({ target: O, rects: M }) => o.set(O.annotation, M));
1725
+ const T = L.flatMap(({ rects: O }) => O);
1726
+ n.load(T);
1727
+ }, g = (b, S, A = !1) => {
1719
1728
  const L = n.search({
1720
- minX: y,
1721
- minY: C,
1722
- maxX: y,
1723
- maxY: C
1724
- }), R = (T) => T.annotation.rects.reduce((S, p) => S + p.width * p.height, 0);
1725
- return L.length > 0 ? (L.sort((T, S) => R(T) - R(S)), A ? L.map((T) => T.annotation.id) : [L[0].annotation.id]) : [];
1726
- }, h = (y) => {
1727
- const C = v(y);
1728
- if (C.length === 0)
1729
+ minX: b,
1730
+ minY: S,
1731
+ maxX: b,
1732
+ maxY: S
1733
+ }), T = (O) => O.annotation.rects.reduce((M, f) => M + f.width * f.height, 0);
1734
+ return L.length > 0 ? (L.sort((O, M) => T(O) - T(M)), A ? L.map((O) => O.annotation.id) : [L[0].annotation.id]) : [];
1735
+ }, p = (b) => {
1736
+ const S = v(b);
1737
+ if (S.length === 0)
1729
1738
  return;
1730
- let A = C[0].left, L = C[0].top, R = C[0].right, T = C[0].bottom;
1731
- for (let S = 1; S < C.length; S++) {
1732
- const p = C[S];
1733
- A = Math.min(A, p.left), L = Math.min(L, p.top), R = Math.max(R, p.right), T = Math.max(T, p.bottom);
1739
+ let A = S[0].left, L = S[0].top, T = S[0].right, O = S[0].bottom;
1740
+ for (let M = 1; M < S.length; M++) {
1741
+ const f = S[M];
1742
+ A = Math.min(A, f.left), L = Math.min(L, f.top), T = Math.max(T, f.right), O = Math.max(O, f.bottom);
1734
1743
  }
1735
- return new DOMRect(A, L, R - A, T - L);
1736
- }, v = (y) => {
1737
- const C = o.get(y);
1738
- return C ? C[0].annotation.rects : [];
1744
+ return new DOMRect(A, L, T - A, O - L);
1745
+ }, v = (b) => {
1746
+ const S = o.get(b);
1747
+ return S ? S[0].annotation.rects : [];
1739
1748
  };
1740
1749
  return {
1741
1750
  all: r,
1742
1751
  clear: a,
1743
1752
  getAt: g,
1744
- getAnnotationBounds: h,
1753
+ getAnnotationBounds: p,
1745
1754
  getAnnotationRects: v,
1746
- getIntersecting: (y, C, A, L) => {
1747
- const R = n.search({ minX: y, minY: C, maxX: A, maxY: L }), T = new Set(R.map((S) => S.annotation.id));
1748
- return Array.from(T).map((S) => ({
1749
- annotation: t.getAnnotation(S),
1750
- rects: v(S)
1751
- })).filter((S) => !!S.annotation);
1755
+ getIntersecting: (b, S, A, L) => {
1756
+ const T = n.search({ minX: b, minY: S, maxX: A, maxY: L }), O = new Set(T.map((M) => M.annotation.id));
1757
+ return Array.from(O).map((M) => ({
1758
+ annotation: t.getAnnotation(M),
1759
+ rects: v(M)
1760
+ })).filter((M) => !!M.annotation);
1752
1761
  },
1753
1762
  insert: d,
1754
1763
  recalculate: () => {
1755
- l(t.all().map((y) => y.target), !0), i.emit("recalculate");
1764
+ l(t.all().map((b) => b.target), !0), i.emit("recalculate");
1756
1765
  },
1757
1766
  remove: c,
1758
1767
  set: l,
1759
1768
  size: () => n.all().length,
1760
- update: f,
1761
- on: (y, C) => i.on(y, C)
1769
+ update: h,
1770
+ on: (b, S) => i.on(b, S)
1762
1771
  };
1763
- }, lo = (t, e) => {
1764
- const n = In(), o = co(n, t), i = An(n);
1772
+ }, fo = (t, e) => {
1773
+ const n = _n(), o = uo(n, t), i = En(n);
1765
1774
  i.setUserSelectAction(e);
1766
- const s = wn(n), r = Dn(), a = (u, y = k.LOCAL) => {
1767
- const C = xt(u, t), A = W(C.target.selector);
1768
- return A && n.addAnnotation(C, y), A;
1769
- }, d = (u, y = !0, C = k.LOCAL) => {
1770
- const A = u.map((R) => xt(R, t)), L = A.filter((R) => !W(R.target.selector));
1771
- return L.length > 0 ? (console.warn("Could not revive all targets for these annotations:", L), n.bulkAddAnnotation(A, y, C), L) : (n.bulkAddAnnotation(A, y, C), []);
1772
- }, c = (u, y = k.LOCAL) => {
1773
- const C = u.map((L) => xt(L, t)), A = C.filter((L) => !W(L.target.selector));
1774
- return A.length > 0 && console.warn("Could not revive all targets for these annotations:", A), C.forEach((L) => {
1775
- n.getAnnotation(L.id) ? n.updateAnnotation(L, y) : n.addAnnotation(L, y);
1775
+ const s = An(n), r = Kn(), a = (u, b = k.LOCAL) => {
1776
+ const S = xt(u, t), A = F(S.target.selector);
1777
+ return A && n.addAnnotation(S, b), A;
1778
+ }, d = (u, b = !0, S = k.LOCAL) => {
1779
+ const A = u.map((T) => xt(T, t)), L = A.filter((T) => !F(T.target.selector));
1780
+ return L.length > 0 ? (console.warn("Could not revive all targets for these annotations:", L), n.bulkAddAnnotation(A, b, S), L) : (n.bulkAddAnnotation(A, b, S), []);
1781
+ }, c = (u, b = k.LOCAL) => {
1782
+ const S = u.map((L) => xt(L, t)), A = S.filter((L) => !F(L.target.selector));
1783
+ return A.length > 0 && console.warn("Could not revive all targets for these annotations:", A), S.forEach((L) => {
1784
+ n.getAnnotation(L.id) ? n.updateAnnotation(L, b) : n.addAnnotation(L, b);
1776
1785
  }), A;
1777
- }, f = (u, y = k.LOCAL) => {
1778
- const C = wt(u, t);
1779
- n.updateTarget(C, y);
1780
- }, l = (u, y = k.LOCAL) => {
1781
- const C = u.map((A) => wt(A, t));
1782
- n.bulkUpdateTargets(C, y);
1783
- }, g = (u, y, C) => {
1784
- const A = o.getAt(u, y, !!C).map((R) => n.getAnnotation(R)), L = C ? A.filter(C) : A;
1786
+ }, h = (u, b = k.LOCAL) => {
1787
+ const S = wt(u, t);
1788
+ n.updateTarget(S, b);
1789
+ }, l = (u, b = k.LOCAL) => {
1790
+ const S = u.map((A) => wt(A, t));
1791
+ n.bulkUpdateTargets(S, b);
1792
+ }, g = (u, b, S) => {
1793
+ const A = o.getAt(u, b, !!S).map((T) => n.getAnnotation(T)), L = S ? A.filter(S) : A;
1785
1794
  return L.length > 0 ? L[0] : void 0;
1786
- }, h = (u, y, C, A = 5) => {
1795
+ }, p = (u, b, S, A = 5) => {
1787
1796
  const L = o.getAnnotationRects(u);
1788
1797
  if (L.length !== 0) {
1789
- if (y && C) {
1790
- const R = L.find(({ top: T, right: S, bottom: p, left: w }) => y >= w - A && y <= S + A && C >= T - A && C <= p + A);
1791
- if (R) return R;
1798
+ if (b && S) {
1799
+ const T = L.find(({ top: O, right: M, bottom: f, left: y }) => b >= y - A && b <= M + A && S >= O - A && S <= f + A);
1800
+ if (T) return T;
1792
1801
  }
1793
1802
  return o.getAnnotationBounds(u);
1794
1803
  }
1795
- }, v = (u, y, C, A) => o.getIntersecting(u, y, C, A), b = (u) => o.getAnnotationRects(u), E = () => o.recalculate(), m = (u) => o.on("recalculate", u);
1804
+ }, v = (u, b, S, A) => o.getIntersecting(u, b, S, A), w = (u) => o.getAnnotationRects(u), E = () => o.recalculate(), m = (u) => o.on("recalculate", u);
1796
1805
  return n.observe(({ changes: u }) => {
1797
- const y = (u.deleted || []).filter((L) => W(L.target.selector)), C = (u.created || []).filter((L) => W(L.target.selector)), A = (u.updated || []).filter((L) => W(L.newValue.target.selector));
1798
- (y == null ? void 0 : y.length) > 0 && y.forEach((L) => o.remove(L.target)), C.length > 0 && o.set(C.map((L) => L.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: L }) => o.update(L.target));
1806
+ const b = (u.deleted || []).filter((L) => F(L.target.selector)), S = (u.created || []).filter((L) => F(L.target.selector)), A = (u.updated || []).filter((L) => F(L.newValue.target.selector));
1807
+ (b == null ? void 0 : b.length) > 0 && b.forEach((L) => o.remove(L.target)), S.length > 0 && o.set(S.map((L) => L.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: L }) => o.update(L.target));
1799
1808
  }), {
1800
1809
  store: {
1801
1810
  ...n,
@@ -1803,61 +1812,61 @@ const co = (t, e) => {
1803
1812
  bulkAddAnnotation: d,
1804
1813
  bulkUpdateTargets: l,
1805
1814
  bulkUpsertAnnotations: c,
1806
- getAnnotationBounds: h,
1807
- getAnnotationRects: b,
1815
+ getAnnotationBounds: p,
1816
+ getAnnotationRects: w,
1808
1817
  getIntersecting: v,
1809
1818
  getAt: g,
1810
1819
  recalculatePositions: E,
1811
1820
  onRecalculatePositions: m,
1812
- updateTarget: f
1821
+ updateTarget: h
1813
1822
  },
1814
1823
  selection: i,
1815
1824
  hover: s,
1816
1825
  viewport: r
1817
1826
  };
1818
- }, uo = () => {
1827
+ }, ho = () => {
1819
1828
  const t = document.createElement("canvas");
1820
1829
  t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
1821
1830
  const e = t.getContext("2d");
1822
1831
  return e.scale(2, 2), e.translate(0.5, 0.5), t;
1823
- }, fo = (t, e = {}) => {
1824
- const n = uo(), o = n.getContext("2d");
1832
+ }, po = (t, e = {}) => {
1833
+ const n = ho(), o = n.getContext("2d");
1825
1834
  document.body.appendChild(n);
1826
- const i = /* @__PURE__ */ new Map(), s = (f) => Array.from(i.entries()).filter(([l, g]) => g.presenceKey === f.presenceKey).map(([l, g]) => l);
1827
- return t.on("selectionChange", (f, l) => {
1828
- s(f).forEach((h) => i.delete(h)), l && l.forEach((h) => i.set(h, f));
1835
+ const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([l, g]) => g.presenceKey === h.presenceKey).map(([l, g]) => l);
1836
+ return t.on("selectionChange", (h, l) => {
1837
+ s(h).forEach((p) => i.delete(p)), l && l.forEach((p) => i.set(p, h));
1829
1838
  }), {
1830
1839
  clear: () => {
1831
- const { width: f, height: l } = n;
1832
- o.clearRect(-0.5, -0.5, f + 1, l + 1);
1840
+ const { width: h, height: l } = n;
1841
+ o.clearRect(-0.5, -0.5, h + 1, l + 1);
1833
1842
  },
1834
1843
  destroy: () => {
1835
1844
  n.remove();
1836
1845
  },
1837
- paint: (f, l, g) => {
1846
+ paint: (h, l, g) => {
1838
1847
  e.font && (o.font = e.font);
1839
- const h = i.get(f.annotation.id);
1840
- if (h) {
1841
- const { height: v } = f.rects[0], b = f.rects[0].x + l.left, E = f.rects[0].y + l.top;
1842
- o.fillStyle = h.appearance.color, o.fillRect(b - 2, E - 2.5, 2, v + 5);
1843
- const m = o.measureText(h.appearance.label), u = m.width + 6, y = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, C = m.fontBoundingBoxAscent ? 8 : 6.5;
1844
- return o.fillRect(b - 2, E - 2.5 - y, u, y), o.fillStyle = "#fff", o.fillText(h.appearance.label, b + 1, E - C), {
1845
- fill: h.appearance.color,
1848
+ const p = i.get(h.annotation.id);
1849
+ if (p) {
1850
+ const { height: v } = h.rects[0], w = h.rects[0].x + l.left, E = h.rects[0].y + l.top;
1851
+ o.fillStyle = p.appearance.color, o.fillRect(w - 2, E - 2.5, 2, v + 5);
1852
+ const m = o.measureText(p.appearance.label), u = m.width + 6, b = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, S = m.fontBoundingBoxAscent ? 8 : 6.5;
1853
+ return o.fillRect(w - 2, E - 2.5 - b, u, b), o.fillStyle = "#fff", o.fillText(p.appearance.label, w + 1, E - S), {
1854
+ fill: p.appearance.color,
1846
1855
  fillOpacity: g ? 0.45 : 0.18
1847
1856
  };
1848
1857
  }
1849
1858
  },
1850
1859
  reset: () => {
1851
1860
  n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
1852
- const f = n.getContext("2d");
1853
- f.scale(2, 2), f.translate(0.5, 0.5);
1861
+ const h = n.getContext("2d");
1862
+ h.scale(2, 2), h.translate(0.5, 0.5);
1854
1863
  }
1855
1864
  };
1856
- }, _t = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1857
- function Nt(t, e, n, o) {
1865
+ }, Nt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1866
+ function _t(t, e, n, o) {
1858
1867
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1859
1868
  }
1860
- function nt(t, e, n, o) {
1869
+ function et(t, e, n, o) {
1861
1870
  t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
1862
1871
  }
1863
1872
  function xe(t, e) {
@@ -1873,7 +1882,7 @@ function Ee(t) {
1873
1882
  e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
1874
1883
  return e;
1875
1884
  }
1876
- function ho(t, e) {
1885
+ function go(t, e) {
1877
1886
  const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
1878
1887
  let i = !0;
1879
1888
  for (let s = 0; s < n.length; s++)
@@ -1925,14 +1934,14 @@ const at = {
1925
1934
  ".": 190,
1926
1935
  "/": 191,
1927
1936
  "`": 192,
1928
- "-": _t ? 173 : 189,
1929
- "=": _t ? 61 : 187,
1930
- ";": _t ? 59 : 186,
1937
+ "-": Nt ? 173 : 189,
1938
+ "=": Nt ? 61 : 187,
1939
+ ";": Nt ? 59 : 186,
1931
1940
  "'": 222,
1932
1941
  "[": 219,
1933
1942
  "]": 221,
1934
1943
  "\\": 220
1935
- }, H = {
1944
+ }, j = {
1936
1945
  // shiftKey
1937
1946
  "⇧": 16,
1938
1947
  shift: 16,
@@ -1957,32 +1966,32 @@ const at = {
1957
1966
  ctrlKey: 17,
1958
1967
  altKey: 18,
1959
1968
  metaKey: 91
1960
- }, Y = {
1969
+ }, V = {
1961
1970
  16: !1,
1962
1971
  18: !1,
1963
1972
  17: !1,
1964
1973
  91: !1
1965
- }, _ = {};
1974
+ }, N = {};
1966
1975
  for (let t = 1; t < 20; t++)
1967
1976
  at["f".concat(t)] = 111 + t;
1968
1977
  let I = [], rt = null, Se = "all";
1969
- const F = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), po = (t) => Object.keys(at).find((e) => at[e] === t), go = (t) => Object.keys(H).find((e) => H[e] === t);
1978
+ const z = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), mo = (t) => Object.keys(at).find((e) => at[e] === t), yo = (t) => Object.keys(j).find((e) => j[e] === t);
1970
1979
  function Ce(t) {
1971
1980
  Se = t || "all";
1972
1981
  }
1973
1982
  function ct() {
1974
1983
  return Se || "all";
1975
1984
  }
1976
- function mo() {
1985
+ function bo() {
1977
1986
  return I.slice(0);
1978
1987
  }
1979
- function yo() {
1980
- return I.map((t) => po(t) || go(t) || String.fromCharCode(t));
1988
+ function wo() {
1989
+ return I.map((t) => mo(t) || yo(t) || String.fromCharCode(t));
1981
1990
  }
1982
- function bo() {
1991
+ function vo() {
1983
1992
  const t = [];
1984
- return Object.keys(_).forEach((e) => {
1985
- _[e].forEach((n) => {
1993
+ return Object.keys(N).forEach((e) => {
1994
+ N[e].forEach((n) => {
1986
1995
  let {
1987
1996
  key: o,
1988
1997
  scope: i,
@@ -1998,7 +2007,7 @@ function bo() {
1998
2007
  });
1999
2008
  }), t;
2000
2009
  }
2001
- function wo(t) {
2010
+ function Ao(t) {
2002
2011
  const e = t.target || t.srcElement, {
2003
2012
  tagName: n
2004
2013
  } = e;
@@ -2006,15 +2015,15 @@ function wo(t) {
2006
2015
  const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
2007
2016
  return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
2008
2017
  }
2009
- function vo(t) {
2018
+ function xo(t) {
2010
2019
  return typeof t == "string" && (t = lt(t)), I.indexOf(t) !== -1;
2011
2020
  }
2012
- function Ao(t, e) {
2021
+ function Eo(t, e) {
2013
2022
  let n, o;
2014
2023
  t || (t = ct());
2015
- for (const i in _)
2016
- if (Object.prototype.hasOwnProperty.call(_, i))
2017
- for (n = _[i], o = 0; o < n.length; )
2024
+ for (const i in N)
2025
+ if (Object.prototype.hasOwnProperty.call(N, i))
2026
+ for (n = N[i], o = 0; o < n.length; )
2018
2027
  n[o].scope === t ? n.splice(o, 1).forEach((r) => {
2019
2028
  let {
2020
2029
  element: a
@@ -2023,18 +2032,18 @@ function Ao(t, e) {
2023
2032
  }) : o++;
2024
2033
  ct() === t && Ce(e || "all");
2025
2034
  }
2026
- function xo(t) {
2035
+ function So(t) {
2027
2036
  let e = t.keyCode || t.which || t.charCode;
2028
2037
  const n = I.indexOf(e);
2029
- if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in Y) {
2030
- Y[e] = !1;
2031
- for (const o in H) H[o] === e && ($[o] = !1);
2038
+ if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in V) {
2039
+ V[e] = !1;
2040
+ for (const o in j) j[o] === e && (P[o] = !1);
2032
2041
  }
2033
2042
  }
2034
2043
  function Le(t) {
2035
2044
  if (typeof t > "u")
2036
- Object.keys(_).forEach((i) => {
2037
- Array.isArray(_[i]) && _[i].forEach((s) => bt(s)), delete _[i];
2045
+ Object.keys(N).forEach((i) => {
2046
+ Array.isArray(N[i]) && N[i].forEach((s) => bt(s)), delete N[i];
2038
2047
  }), jt(null);
2039
2048
  else if (Array.isArray(t))
2040
2049
  t.forEach((i) => {
@@ -2062,65 +2071,65 @@ const bt = (t) => {
2062
2071
  splitKey: i = "+"
2063
2072
  } = t;
2064
2073
  Ee(e).forEach((r) => {
2065
- const a = r.split(i), d = a.length, c = a[d - 1], f = c === "*" ? "*" : lt(c);
2066
- if (!_[f]) return;
2074
+ const a = r.split(i), d = a.length, c = a[d - 1], h = c === "*" ? "*" : lt(c);
2075
+ if (!N[h]) return;
2067
2076
  n || (n = ct());
2068
- const l = d > 1 ? xe(H, a) : [], g = [];
2069
- _[f] = _[f].filter((h) => {
2070
- const b = (o ? h.method === o : !0) && h.scope === n && ho(h.mods, l);
2071
- return b && g.push(h.element), !b;
2072
- }), g.forEach((h) => jt(h));
2077
+ const l = d > 1 ? xe(j, a) : [], g = [];
2078
+ N[h] = N[h].filter((p) => {
2079
+ const w = (o ? p.method === o : !0) && p.scope === n && go(p.mods, l);
2080
+ return w && g.push(p.element), !w;
2081
+ }), g.forEach((p) => jt(p));
2073
2082
  });
2074
2083
  };
2075
- function re(t, e, n, o) {
2084
+ function se(t, e, n, o) {
2076
2085
  if (e.element !== o)
2077
2086
  return;
2078
2087
  let i;
2079
2088
  if (e.scope === n || e.scope === "all") {
2080
2089
  i = e.mods.length > 0;
2081
- for (const s in Y)
2082
- Object.prototype.hasOwnProperty.call(Y, s) && (!Y[s] && e.mods.indexOf(+s) > -1 || Y[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2083
- (e.mods.length === 0 && !Y[16] && !Y[18] && !Y[17] && !Y[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2090
+ for (const s in V)
2091
+ Object.prototype.hasOwnProperty.call(V, s) && (!V[s] && e.mods.indexOf(+s) > -1 || V[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2092
+ (e.mods.length === 0 && !V[16] && !V[18] && !V[17] && !V[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2084
2093
  }
2085
2094
  }
2086
- function ae(t, e) {
2087
- const n = _["*"];
2095
+ function re(t, e) {
2096
+ const n = N["*"];
2088
2097
  let o = t.keyCode || t.which || t.charCode;
2089
- if (!$.filter.call(this, t)) return;
2098
+ if (!P.filter.call(this, t)) return;
2090
2099
  if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
2091
2100
  const d = Kt[a];
2092
2101
  t[a] && I.indexOf(d) === -1 ? I.push(d) : !t[a] && I.indexOf(d) > -1 ? I.splice(I.indexOf(d), 1) : a === "metaKey" && t[a] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(d))));
2093
- }), o in Y) {
2094
- Y[o] = !0;
2095
- for (const a in H)
2096
- H[a] === o && ($[a] = !0);
2102
+ }), o in V) {
2103
+ V[o] = !0;
2104
+ for (const a in j)
2105
+ j[a] === o && (P[a] = !0);
2097
2106
  if (!n) return;
2098
2107
  }
2099
- for (const a in Y)
2100
- Object.prototype.hasOwnProperty.call(Y, a) && (Y[a] = t[Kt[a]]);
2101
- t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), Y[17] = !0, Y[18] = !0);
2108
+ for (const a in V)
2109
+ Object.prototype.hasOwnProperty.call(V, a) && (V[a] = t[Kt[a]]);
2110
+ t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), V[17] = !0, V[18] = !0);
2102
2111
  const i = ct();
2103
2112
  if (n)
2104
2113
  for (let a = 0; a < n.length; a++)
2105
- n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && re(t, n[a], i, e);
2106
- if (!(o in _)) return;
2107
- const s = _[o], r = s.length;
2114
+ n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && se(t, n[a], i, e);
2115
+ if (!(o in N)) return;
2116
+ const s = N[o], r = s.length;
2108
2117
  for (let a = 0; a < r; a++)
2109
2118
  if ((t.type === "keydown" && s[a].keydown || t.type === "keyup" && s[a].keyup) && s[a].key) {
2110
2119
  const d = s[a], {
2111
2120
  splitKey: c
2112
- } = d, f = d.key.split(c), l = [];
2113
- for (let g = 0; g < f.length; g++)
2114
- l.push(lt(f[g]));
2115
- l.sort().join("") === I.sort().join("") && re(t, d, i, e);
2121
+ } = d, h = d.key.split(c), l = [];
2122
+ for (let g = 0; g < h.length; g++)
2123
+ l.push(lt(h[g]));
2124
+ l.sort().join("") === I.sort().join("") && se(t, d, i, e);
2116
2125
  }
2117
2126
  }
2118
- function $(t, e, n) {
2127
+ function P(t, e, n) {
2119
2128
  I = [];
2120
2129
  const o = Ee(t);
2121
- let i = [], s = "all", r = document, a = 0, d = !1, c = !0, f = "+", l = !1, g = !1;
2122
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (f = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && Le(t, s); a < o.length; a++)
2123
- t = o[a].split(f), i = [], t.length > 1 && (i = xe(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in _ || (_[t] = []), _[t].push({
2130
+ let i = [], s = "all", r = document, a = 0, d = !1, c = !0, h = "+", l = !1, g = !1;
2131
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && Le(t, s); a < o.length; a++)
2132
+ t = o[a].split(h), i = [], t.length > 1 && (i = xe(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in N || (N[t] = []), N[t].push({
2124
2133
  keyup: d,
2125
2134
  keydown: c,
2126
2135
  scope: s,
@@ -2128,45 +2137,45 @@ function $(t, e, n) {
2128
2137
  shortcut: o[a],
2129
2138
  method: n,
2130
2139
  key: o[a],
2131
- splitKey: f,
2140
+ splitKey: h,
2132
2141
  element: r
2133
2142
  });
2134
2143
  if (typeof r < "u" && window) {
2135
- if (!F.has(r)) {
2136
- const h = function() {
2137
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2138
- return ae(b, r);
2144
+ if (!z.has(r)) {
2145
+ const p = function() {
2146
+ let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2147
+ return re(w, r);
2139
2148
  }, v = function() {
2140
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2141
- ae(b, r), xo(b);
2149
+ let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2150
+ re(w, r), So(w);
2142
2151
  };
2143
- F.set(r, {
2144
- keydownListener: h,
2152
+ z.set(r, {
2153
+ keydownListener: p,
2145
2154
  keyupListenr: v,
2146
2155
  capture: l
2147
- }), Nt(r, "keydown", h, l), Nt(r, "keyup", v, l);
2156
+ }), _t(r, "keydown", p, l), _t(r, "keyup", v, l);
2148
2157
  }
2149
2158
  if (!rt) {
2150
- const h = () => {
2159
+ const p = () => {
2151
2160
  I = [];
2152
2161
  };
2153
2162
  rt = {
2154
- listener: h,
2163
+ listener: p,
2155
2164
  capture: l
2156
- }, Nt(window, "focus", h, l);
2165
+ }, _t(window, "focus", p, l);
2157
2166
  }
2158
2167
  }
2159
2168
  }
2160
- function Eo(t) {
2169
+ function Co(t) {
2161
2170
  let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
2162
- Object.keys(_).forEach((n) => {
2163
- _[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
2171
+ Object.keys(N).forEach((n) => {
2172
+ N[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
2164
2173
  i && i.method && i.method();
2165
2174
  });
2166
2175
  });
2167
2176
  }
2168
2177
  function jt(t) {
2169
- const e = Object.values(_).flat();
2178
+ const e = Object.values(N).flat();
2170
2179
  if (e.findIndex((o) => {
2171
2180
  let {
2172
2181
  element: i
@@ -2177,164 +2186,179 @@ function jt(t) {
2177
2186
  keydownListener: o,
2178
2187
  keyupListenr: i,
2179
2188
  capture: s
2180
- } = F.get(t) || {};
2181
- o && i && (nt(t, "keyup", i, s), nt(t, "keydown", o, s), F.delete(t));
2189
+ } = z.get(t) || {};
2190
+ o && i && (et(t, "keyup", i, s), et(t, "keydown", o, s), z.delete(t));
2182
2191
  }
2183
- if ((e.length <= 0 || F.size <= 0) && (Object.keys(F).forEach((i) => {
2192
+ if ((e.length <= 0 || z.size <= 0) && (Object.keys(z).forEach((i) => {
2184
2193
  const {
2185
2194
  keydownListener: s,
2186
2195
  keyupListenr: r,
2187
2196
  capture: a
2188
- } = F.get(i) || {};
2189
- s && r && (nt(i, "keyup", r, a), nt(i, "keydown", s, a), F.delete(i));
2190
- }), F.clear(), Object.keys(_).forEach((i) => delete _[i]), rt)) {
2197
+ } = z.get(i) || {};
2198
+ s && r && (et(i, "keyup", r, a), et(i, "keydown", s, a), z.delete(i));
2199
+ }), z.clear(), Object.keys(N).forEach((i) => delete N[i]), rt)) {
2191
2200
  const {
2192
2201
  listener: i,
2193
2202
  capture: s
2194
2203
  } = rt;
2195
- nt(window, "focus", i, s), rt = null;
2204
+ et(window, "focus", i, s), rt = null;
2196
2205
  }
2197
2206
  }
2198
2207
  const Ut = {
2199
- getPressedKeyString: yo,
2208
+ getPressedKeyString: wo,
2200
2209
  setScope: Ce,
2201
2210
  getScope: ct,
2202
- deleteScope: Ao,
2203
- getPressedKeyCodes: mo,
2204
- getAllKeyCodes: bo,
2205
- isPressed: vo,
2206
- filter: wo,
2207
- trigger: Eo,
2211
+ deleteScope: Eo,
2212
+ getPressedKeyCodes: bo,
2213
+ getAllKeyCodes: vo,
2214
+ isPressed: xo,
2215
+ filter: Ao,
2216
+ trigger: Co,
2208
2217
  unbind: Le,
2209
2218
  keyMap: at,
2210
- modifier: H,
2219
+ modifier: j,
2211
2220
  modifierMap: Kt
2212
2221
  };
2213
2222
  for (const t in Ut)
2214
- Object.prototype.hasOwnProperty.call(Ut, t) && ($[t] = Ut[t]);
2223
+ Object.prototype.hasOwnProperty.call(Ut, t) && (P[t] = Ut[t]);
2215
2224
  if (typeof window < "u") {
2216
2225
  const t = window.hotkeys;
2217
- $.noConflict = (e) => (e && window.hotkeys === $ && (window.hotkeys = t), $), window.hotkeys = $;
2226
+ P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
2218
2227
  }
2219
- const ce = 300, Oe = ["up", "down", "left", "right"], Te = Ie ? "⌘+a" : "ctrl+a", So = [
2228
+ async function Lo(t, e, n = () => !1) {
2229
+ do {
2230
+ if (await t(), await n()) break;
2231
+ const o = e;
2232
+ await new Promise((i) => setTimeout(i, Math.max(0, o)));
2233
+ } while (!await n());
2234
+ }
2235
+ const ae = 300, Oe = ["up", "down", "left", "right"], Te = ke ? "⌘+a" : "ctrl+a", Oo = [
2220
2236
  ...Oe.map((t) => `shift+${t}`),
2221
2237
  Te
2222
- ], Co = (t, e, n) => {
2238
+ ], To = (t, e, n) => {
2223
2239
  const { store: o, selection: i } = e;
2224
2240
  let s;
2225
- const r = (S) => s = S;
2241
+ const r = (f) => s = f;
2226
2242
  let a;
2227
- const d = (S) => a = S;
2228
- let c, f, l, g = !1, h = !0;
2229
- const v = (S) => {
2230
- h = S, E.clear(), S || (c = void 0, l = void 0, g = !1);
2231
- }, b = (S) => {
2232
- var w;
2233
- if (!h || (g = !1, f === !1)) return;
2234
- c = !((w = S.target.parentElement) != null && w.closest(j)) ? {
2243
+ const d = (f) => a = f;
2244
+ let c, h, l, g = !1, p = !0;
2245
+ const v = (f) => {
2246
+ p = f, E.clear(), f || (c = void 0, l = void 0, g = !1);
2247
+ }, w = (f) => {
2248
+ p && (g = !1, h !== !1 && (c = nt(f.target) ? void 0 : {
2235
2249
  annotation: ye(),
2236
2250
  selector: [],
2237
2251
  creator: s,
2238
2252
  created: /* @__PURE__ */ new Date()
2239
- } : void 0;
2240
- }, E = Xt((S) => {
2241
- var N, dt;
2242
- if (!h) return;
2243
- const p = document.getSelection();
2244
- if (!!((dt = (N = p.anchorNode) == null ? void 0 : N.parentElement) != null && dt.closest(j))) {
2253
+ }));
2254
+ }, E = Xt((f) => {
2255
+ if (!p) return;
2256
+ const y = document.getSelection();
2257
+ if (!(y != null && y.anchorNode))
2258
+ return;
2259
+ if (nt(y.anchorNode)) {
2245
2260
  c = void 0;
2246
2261
  return;
2247
2262
  }
2248
- const x = S.timeStamp - ((l == null ? void 0 : l.timeStamp) || S.timeStamp);
2249
- if ((l == null ? void 0 : l.type) === "pointerdown" && (x < 1e3 && !c || p.isCollapsed && x < ce) && b(l || S), !c) return;
2250
- if (p.isCollapsed) {
2263
+ const x = f.timeStamp - ((l == null ? void 0 : l.timeStamp) || f.timeStamp);
2264
+ if ((l == null ? void 0 : l.type) === "pointerdown" && (x < 1e3 && !c || y.isCollapsed && x < ae) && w(l || f), !c) return;
2265
+ if (y.isCollapsed) {
2251
2266
  o.getAnnotation(c.annotation) && (i.clear(), o.deleteAnnotation(c.annotation));
2252
2267
  return;
2253
2268
  }
2254
- const O = p.getRangeAt(0), B = $e(O, t);
2255
- if (De(B)) return;
2256
- const M = Be(B.cloneRange());
2257
- (M.length !== c.selector.length || M.some((tt, At) => {
2258
- var Ht;
2259
- return tt.toString() !== ((Ht = c.selector[At]) == null ? void 0 : Ht.quote);
2269
+ const C = y.getRangeAt(0), B = je(C, t);
2270
+ if (Ve(B)) return;
2271
+ const R = _e(B.cloneRange());
2272
+ (R.length !== c.selector.length || R.some((Y, At) => {
2273
+ var dt;
2274
+ return Y.toString() !== ((dt = c.selector[At]) == null ? void 0 : dt.quote);
2260
2275
  })) && (c = {
2261
2276
  ...c,
2262
- selector: M.map((tt) => Xe(tt, t, n)),
2277
+ selector: R.map((Y) => Pe(Y, t, n)),
2263
2278
  updated: /* @__PURE__ */ new Date()
2264
- }, o.getAnnotation(c.annotation) && o.updateTarget(c, k.LOCAL));
2265
- }, 10), m = (S) => {
2266
- var w;
2267
- g || (w = S.target.parentElement) != null && w.closest(j) || (l = Et(S), f = l.button === 0);
2279
+ }, o.getAnnotation(c.annotation) ? o.updateTarget(c, k.LOCAL) : i.clear());
2280
+ }, 10), m = (f) => {
2281
+ g || nt(f.target) || (l = Et(f), h = l.button === 0);
2268
2282
  }, u = () => {
2269
2283
  o.getAnnotation(c.annotation) ? o.updateTarget(c) : o.addAnnotation({
2270
2284
  id: c.annotation,
2271
2285
  bodies: [],
2272
2286
  target: c
2273
2287
  });
2274
- }, y = (S) => {
2275
- var O;
2276
- if (g || !!((O = S.target.parentElement) != null && O.closest(j)) || !f) return;
2277
- const w = () => {
2278
- const { x: B, y: M } = t.getBoundingClientRect(), D = S.target instanceof Node && t.contains(S.target) && o.getAt(S.clientX - B, S.clientY - M, a);
2279
- if (D) {
2280
- const { selected: N } = i;
2281
- (N.length !== 1 || N[0].id !== D.id) && i.userSelect(D.id, S);
2282
- } else i.isEmpty() || i.clear();
2283
- }, x = S.timeStamp - l.timeStamp;
2284
- setTimeout(() => {
2285
- const B = document.getSelection();
2286
- B != null && B.isCollapsed && x < ce ? (c = void 0, w()) : c && c.selector.length > 0 && (i.clear(), u(), i.userSelect(c.annotation, Et(S)));
2287
- });
2288
- }, C = (S) => {
2288
+ }, b = async (f) => {
2289
+ if (g || nt(f.target) || !h) return;
2290
+ const y = () => {
2291
+ const { x: C, y: B } = t.getBoundingClientRect(), R = f.target instanceof Node && t.contains(f.target) && o.getAt(f.clientX - C, f.clientY - B, a);
2292
+ if (R) {
2293
+ const { selected: K } = i;
2294
+ (K.length !== 1 || K[0].id !== R.id) && i.userSelect(R.id, f);
2295
+ } else
2296
+ i.clear();
2297
+ };
2298
+ if (f.timeStamp - l.timeStamp < ae) {
2299
+ await S();
2300
+ const C = document.getSelection();
2301
+ if (C != null && C.isCollapsed) {
2302
+ c = void 0, y();
2303
+ return;
2304
+ }
2305
+ }
2306
+ c && c.selector.length > 0 && (i.clear(), u(), i.userSelect(c.annotation, Et(f)));
2307
+ }, S = async () => {
2308
+ const f = document.getSelection();
2309
+ let y = !1, x = f == null ? void 0 : f.isCollapsed;
2310
+ const C = () => x || y, B = 1;
2311
+ return setTimeout(() => y = !0, 50), Lo(() => x = f == null ? void 0 : f.isCollapsed, B, C);
2312
+ }, A = (f) => {
2289
2313
  g = !0;
2290
- const p = document.getSelection();
2291
- p != null && p.isCollapsed || ((!c || c.selector.length === 0) && E(S), u(), i.userSelect(c.annotation, Et(S)));
2292
- }, A = (S) => {
2293
- h && S.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), u(), i.userSelect(c.annotation, ut(S))));
2294
- }, L = (S) => {
2295
- const p = () => setTimeout(() => {
2314
+ const y = document.getSelection();
2315
+ y != null && y.isCollapsed || ((!c || c.selector.length === 0) && E(f), u(), i.userSelect(c.annotation, Et(f)));
2316
+ }, L = (f) => {
2317
+ p && f.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), u(), i.userSelect(c.annotation, ut(f))));
2318
+ }, T = (f) => {
2319
+ const y = () => setTimeout(() => {
2296
2320
  (c == null ? void 0 : c.selector.length) > 0 && (i.clear(), o.addAnnotation({
2297
2321
  id: c.annotation,
2298
2322
  bodies: [],
2299
2323
  target: c
2300
- }), i.userSelect(c.annotation, ut(S))), document.removeEventListener("selectionchange", p);
2324
+ }), i.userSelect(c.annotation, ut(f))), document.removeEventListener("selectionchange", y);
2301
2325
  }, 100);
2302
- document.addEventListener("selectionchange", p), b(S);
2326
+ document.addEventListener("selectionchange", y), w(f);
2303
2327
  };
2304
- $(So.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
2305
- S.repeat || (l = ut(S));
2306
- }), $(Te, { keydown: !0, keyup: !1 }, (S) => {
2307
- l = ut(S), L(S);
2328
+ P(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (f) => {
2329
+ f.repeat || (l = ut(f));
2330
+ }), P(Te, { keydown: !0, keyup: !1 }, (f) => {
2331
+ l = ut(f), T(f);
2308
2332
  });
2309
- const R = (S) => {
2310
- S.repeat || S.target !== t && S.target !== document.body || (c = void 0, i.clear());
2333
+ const O = (f) => {
2334
+ f.repeat || f.target !== t && f.target !== document.body || (c = void 0, i.clear());
2311
2335
  };
2312
- return $(Oe.join(","), { keydown: !0, keyup: !1 }, R), document.addEventListener("pointerdown", m), document.addEventListener("pointerup", y), document.addEventListener("contextmenu", C), t.addEventListener("keyup", A), t.addEventListener("selectstart", b), document.addEventListener("selectionchange", E), {
2336
+ return P(Oe.join(","), { keydown: !0, keyup: !1 }, O), document.addEventListener("pointerdown", m), document.addEventListener("pointerup", b), document.addEventListener("contextmenu", A), t.addEventListener("keyup", L), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", E), {
2313
2337
  destroy: () => {
2314
- c = void 0, f = void 0, l = void 0, g = !1, E.clear(), document.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", y), document.removeEventListener("contextmenu", C), t.removeEventListener("keyup", A), t.removeEventListener("selectstart", b), document.removeEventListener("selectionchange", E), $.unbind();
2338
+ c = void 0, h = void 0, l = void 0, g = !1, E.clear(), document.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", b), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", L), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", E), P.unbind();
2315
2339
  },
2316
2340
  setFilter: d,
2317
2341
  setUser: r,
2318
2342
  setAnnotatingEnabled: v
2319
2343
  };
2320
- }, Lo = (t, e) => ({
2344
+ }, Ro = (t, e) => ({
2321
2345
  ...t,
2322
2346
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
2323
2347
  user: t.user || e.user
2324
- }), le = "SPANS", ko = (t, e = {}) => {
2325
- ke(t), _e(t);
2326
- const n = Lo(e, {
2348
+ }), ce = "SPANS", No = (t, e = {}) => {
2349
+ Be(t), Ie(t);
2350
+ const n = Ro(e, {
2327
2351
  annotatingEnabled: !0,
2328
- user: zn()
2329
- }), o = lo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Un(r), d = Vn(o, a, n.adapter);
2352
+ user: Wn()
2353
+ }), o = fo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Vn(r), d = Yn(o, a, n.adapter);
2330
2354
  let c = n.user;
2331
- const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : le : n.renderer || le, l = f === "SPANS" ? hn(t, o, s) : f === "CSS_HIGHLIGHTS" ? dn(t, o, s) : f === "CANVAS" ? Ze(t, o, s) : void 0;
2355
+ const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ce : n.renderer || ce, l = h === "SPANS" ? gn(t, o, s) : h === "CSS_HIGHLIGHTS" ? fn(t, o, s) : h === "CANVAS" ? en(t, o, s) : void 0;
2332
2356
  if (!l)
2333
- throw `Unknown renderer implementation: ${f}`;
2334
- console.debug(`Using ${f} renderer`), n.style && l.setStyle(n.style);
2335
- const g = Co(t, o, n.offsetReferenceSelector);
2357
+ throw `Unknown renderer implementation: ${h}`;
2358
+ console.debug(`Using ${h} renderer`), n.style && l.setStyle(n.style);
2359
+ const g = To(t, o, n.offsetReferenceSelector);
2336
2360
  g.setUser(c), g.setAnnotatingEnabled(n.annotatingEnabled);
2337
- const h = Yn(o, a, n.adapter), v = () => c, b = (A) => {
2361
+ const p = Pn(o, a, n.adapter), v = () => c, w = (A) => {
2338
2362
  g.setAnnotatingEnabled(
2339
2363
  A === void 0 ? !0 : A
2340
2364
  );
@@ -2343,73 +2367,75 @@ const ce = 300, Oe = ["up", "down", "left", "right"], Te = Ie ? "⌘+a" : "ctrl+
2343
2367
  }, m = (A) => {
2344
2368
  c = A, g.setUser(A);
2345
2369
  }, u = (A) => {
2346
- A && (l.setPainter(fo(A, n.presence)), A.on("selectionChange", () => l.redraw()));
2347
- }, y = (A) => {
2370
+ A && (l.setPainter(po(A, n.presence)), A.on("selectionChange", () => l.redraw()));
2371
+ }, b = (A) => {
2348
2372
  A ? i.setSelected(A) : i.clear();
2349
2373
  };
2350
2374
  return {
2351
- ...h,
2375
+ ...p,
2352
2376
  destroy: () => {
2353
2377
  l.destroy(), g.destroy(), a.destroy();
2354
2378
  },
2355
2379
  element: t,
2356
2380
  getUser: v,
2357
- setAnnotatingEnabled: b,
2381
+ setAnnotatingEnabled: w,
2358
2382
  setFilter: E,
2359
2383
  setStyle: l.setStyle.bind(l),
2360
2384
  redraw: l.redraw.bind(l),
2361
2385
  setUser: m,
2362
- setSelected: y,
2386
+ setSelected: b,
2363
2387
  setPresenceProvider: u,
2364
2388
  setVisible: l.setVisible.bind(l),
2365
2389
  on: d.on,
2366
2390
  off: d.off,
2367
- scrollIntoView: je(t, r),
2391
+ scrollIntoView: ze(t, r),
2368
2392
  state: o
2369
2393
  };
2370
2394
  };
2371
2395
  export {
2372
2396
  vt as DEFAULT_SELECTED_STYLE,
2373
- q as DEFAULT_STYLE,
2374
- de as NOT_ANNOTATABLE_CLASS,
2375
- j as NOT_ANNOTATABLE_SELECTOR,
2397
+ W as DEFAULT_STYLE,
2398
+ le as NOT_ANNOTATABLE_CLASS,
2399
+ Z as NOT_ANNOTATABLE_SELECTOR,
2376
2400
  k as Origin,
2377
- vn as UserSelectAction,
2378
- Bo as W3CTextFormat,
2379
- ke as cancelSingleClickEvents,
2401
+ xn as UserSelectAction,
2402
+ Io as W3CTextFormat,
2403
+ Be as cancelSingleClickEvents,
2380
2404
  ut as cloneKeyboardEvent,
2381
2405
  Et as clonePointerEvent,
2382
- Mo as createBody,
2383
- Ze as createCanvasRenderer,
2384
- dn as createHighlightsRenderer,
2385
- fo as createPresencePainter,
2386
- ln as createRenderer,
2387
- Co as createSelectionHandler,
2388
- hn as createSpansRenderer,
2389
- ko as createTextAnnotator,
2390
- lo as createTextAnnotatorState,
2391
- Ro as denormalizeRectWithOffset,
2392
- Lo as fillDefaults,
2393
- Oo as getAnnotatableFragment,
2394
- Ne as getQuoteContext,
2406
+ ko as createBody,
2407
+ en as createCanvasRenderer,
2408
+ fn as createHighlightsRenderer,
2409
+ po as createPresencePainter,
2410
+ un as createRenderer,
2411
+ To as createSelectionHandler,
2412
+ gn as createSpansRenderer,
2413
+ No as createTextAnnotator,
2414
+ fo as createTextAnnotatorState,
2415
+ Bo as denormalizeRectWithOffset,
2416
+ Ro as fillDefaults,
2417
+ Ue as getQuoteContext,
2395
2418
  Dt as getRangeAnnotatableContents,
2396
- Ie as isMac,
2397
- W as isRevived,
2398
- De as isWhitespaceOrEmpty,
2399
- Ye as mergeClientRects,
2400
- Pe as normalizeRectWithOffset,
2401
- He as paint,
2402
- Jn as parseW3CTextAnnotation,
2403
- _e as programmaticallyFocusable,
2404
- Xe as rangeToSelector,
2419
+ ke as isMac,
2420
+ nt as isNotAnnotatable,
2421
+ Me as isRangeAnnotatable,
2422
+ F as isRevived,
2423
+ Ve as isWhitespaceOrEmpty,
2424
+ Xe as mergeClientRects,
2425
+ He as normalizeRectWithOffset,
2426
+ Fe as paint,
2427
+ to as parseW3CTextAnnotation,
2428
+ Ie as programmaticallyFocusable,
2429
+ $e as rangeContains,
2430
+ Pe as rangeToSelector,
2405
2431
  xt as reviveAnnotation,
2406
- ue as reviveSelector,
2432
+ de as reviveSelector,
2407
2433
  wt as reviveTarget,
2408
- je as scrollIntoView,
2409
- Zn as serializeW3CTextAnnotation,
2410
- Be as splitAnnotatableRanges,
2411
- To as toDomRectList,
2412
- $e as trimRangeToContainer,
2413
- Ue as whitespaceOrEmptyRegex
2434
+ ze as scrollIntoView,
2435
+ eo as serializeW3CTextAnnotation,
2436
+ _e as splitAnnotatableRanges,
2437
+ Mo as toDomRectList,
2438
+ je as trimRangeToContainer,
2439
+ De as whitespaceOrEmptyRegex
2414
2440
  };
2415
2441
  //# sourceMappingURL=text-annotator.es.js.map