@soomo/text-annotator 3.0.0-staging.32 → 3.0.0-staging.33

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.
@@ -37,10 +37,10 @@ const q = {
37
37
  }, Rt = (e) => {
38
38
  const t = e.cloneContents();
39
39
  return t.querySelectorAll(Y).forEach((n) => n.remove()), t;
40
- }, Te = (e) => e.addEventListener("click", (t) => {
40
+ }, Ee = (e) => e.addEventListener("click", (t) => {
41
41
  // Allow clicks within not-annotatable elements
42
42
  !t.target.closest(Y) && !t.target.closest("a") && t.preventDefault();
43
- }), Ee = (e) => {
43
+ }), Te = (e) => {
44
44
  !e.hasAttribute("tabindex") && e.tabIndex < 0 && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
45
45
  }, It = (e, t = 10) => {
46
46
  let n;
@@ -71,31 +71,31 @@ const q = {
71
71
  startOffset: o,
72
72
  endContainer: i,
73
73
  endOffset: r
74
- } = e, s = Array.from(t.childNodes).map((c) => {
75
- const m = c.cloneNode(!0);
76
- return c.nodeName === "CANVAS" ? c : m;
77
- }), a = Dt(n, t), u = Dt(i, t), p = () => {
78
- const c = t;
79
- c.replaceChildren(...s);
80
- const m = yt(a, c), f = yt(u, c);
81
- return e.setStart(m, o), e.setEnd(f, r), e;
82
- }, h = (c) => {
83
- const m = document.createElement("SPAN");
84
- return c.surroundContents(m), m;
74
+ } = e, s = Array.from(t.childNodes).map((l) => {
75
+ const g = l.cloneNode(!0);
76
+ return l.nodeName === "CANVAS" ? l : g;
77
+ }), a = Dt(n, t), f = Dt(i, t), p = () => {
78
+ const l = t;
79
+ l.replaceChildren(...s);
80
+ const g = yt(a, l), d = yt(f, l);
81
+ return e.setStart(g, o), e.setEnd(d, r), e;
82
+ }, h = (l) => {
83
+ const g = document.createElement("SPAN");
84
+ return l.surroundContents(g), g;
85
85
  };
86
86
  if (n === i)
87
87
  throw "Not implemented";
88
88
  {
89
- const c = document.createRange();
90
- c.selectNodeContents(n), c.setStart(n, o);
91
- const m = h(c), f = document.createRange();
92
- f.selectNode(i), f.setEnd(i, r);
93
- const v = h(f), w = Be(e).reverse().map((d) => {
94
- var g;
95
- const l = document.createElement("SPAN");
96
- return (g = d.parentNode) == null || g.insertBefore(l, d), l.appendChild(d), l;
89
+ const l = document.createRange();
90
+ l.selectNodeContents(n), l.setStart(n, o);
91
+ const g = h(l), d = document.createRange();
92
+ d.selectNode(i), d.setEnd(i, r);
93
+ const A = h(d), b = Be(e).reverse().map((u) => {
94
+ var v;
95
+ const c = document.createElement("SPAN");
96
+ return (v = u.parentNode) == null || v.insertBefore(c, u), c.appendChild(u), c;
97
97
  });
98
- return { unwrap: p, nodes: [m, ...w, v] };
98
+ return { unwrap: p, nodes: [g, ...b, A] };
99
99
  }
100
100
  }, Be = (e) => {
101
101
  const {
@@ -121,10 +121,10 @@ const q = {
121
121
  r.setStart(i, 0), r.setEnd(e.startContainer, e.startOffset);
122
122
  const s = Rt(r).textContent, a = document.createRange();
123
123
  a.setStart(e.endContainer, e.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
124
- const u = Rt(a).textContent;
124
+ const f = Rt(a).textContent;
125
125
  return {
126
126
  prefix: s.substring(s.length - n),
127
- suffix: u.substring(0, n)
127
+ suffix: f.substring(0, n)
128
128
  };
129
129
  }, Re = /^\s*$/, Ve = (e) => Re.test(e.toString()), W = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), Oe = (e, t) => {
130
130
  const n = (r) => Math.round(r * 10) / 10, o = {
@@ -184,41 +184,41 @@ const q = {
184
184
  }), Fe = (e, t, n) => {
185
185
  const o = document.createRange(), i = n ? e.startContainer.parentElement.closest(n) : t;
186
186
  o.setStart(i, 0), o.setEnd(e.startContainer, e.startOffset);
187
- const r = Rt(o).textContent, s = e.toString(), a = r.length || 0, u = a + s.length;
188
- return n ? { quote: s, start: a, end: u, range: e, offsetReference: i } : { quote: s, start: a, end: u, range: e };
187
+ const r = Rt(o).textContent, s = e.toString(), a = r.length || 0, f = a + s.length;
188
+ return n ? { quote: s, start: a, end: f, range: e, offsetReference: i } : { quote: s, start: a, end: f, range: e };
189
189
  }, oe = (e, t) => {
190
- var h, c;
190
+ var h, l;
191
191
  const { start: n, end: o } = e, i = e.offsetReference || t, r = document.createNodeIterator(
192
192
  t,
193
193
  NodeFilter.SHOW_TEXT,
194
- (m) => {
195
- var f;
196
- return (f = m.parentElement) != null && f.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
194
+ (g) => {
195
+ var d;
196
+ return (d = g.parentElement) != null && d.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
197
197
  }
198
198
  );
199
199
  let s = 0;
200
200
  const a = document.createRange();
201
- let u = r.nextNode();
202
- u === null && console.error("Could not revive annotation target. Content missing.");
201
+ let f = r.nextNode();
202
+ f === null && console.error("Could not revive annotation target. Content missing.");
203
203
  let p = !i;
204
- for (; u !== null; ) {
205
- if (p || (p = i == null ? void 0 : i.contains(u)), p) {
206
- const m = ((h = u.textContent) == null ? void 0 : h.length) || 0;
207
- if (s + m > n) {
208
- a.setStart(u, n - s);
204
+ for (; f !== null; ) {
205
+ if (p || (p = i == null ? void 0 : i.contains(f)), p) {
206
+ const g = ((h = f.textContent) == null ? void 0 : h.length) || 0;
207
+ if (s + g > n) {
208
+ a.setStart(f, n - s);
209
209
  break;
210
210
  }
211
- s += m;
211
+ s += g;
212
212
  }
213
- u = r.nextNode();
213
+ f = r.nextNode();
214
214
  }
215
- for (; u !== null; ) {
216
- const m = ((c = u.textContent) == null ? void 0 : c.length) || 0;
217
- if (s + m >= o) {
218
- a.setEnd(u, o - s);
215
+ for (; f !== null; ) {
216
+ const g = ((l = f.textContent) == null ? void 0 : l.length) || 0;
217
+ if (s + g >= o) {
218
+ a.setEnd(f, o - s);
219
219
  break;
220
220
  }
221
- s += m, u = r.nextNode();
221
+ s += g, f = r.nextNode();
222
222
  }
223
223
  return {
224
224
  ...e,
@@ -276,8 +276,8 @@ const q = {
276
276
  detail: e.detail,
277
277
  timeStamp: e.timeStamp
278
278
  }), Ue = (e) => {
279
- const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n, u = i - t;
280
- return { top: t, left: n, minX: r, minY: s, maxX: a, maxY: u };
279
+ const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n, f = i - t;
280
+ return { top: t, left: n, minX: r, minY: s, maxX: a, maxY: f };
281
281
  }, He = (e) => {
282
282
  let t = /* @__PURE__ */ new Set();
283
283
  return (o) => {
@@ -286,46 +286,46 @@ const q = {
286
286
  };
287
287
  }, Nt = (e, t, n, o) => {
288
288
  const { store: i, selection: r, hover: s } = t;
289
- let a, u, p;
290
- const h = He(n), c = (B) => {
291
- const { x: N, y: A } = e.getBoundingClientRect(), S = i.getAt(B.clientX - N, B.clientY - A, u);
289
+ let a, f, p;
290
+ const h = He(n), l = (M) => {
291
+ const { x: y, y: w } = e.getBoundingClientRect(), S = i.getAt(M.clientX - y, M.clientY - w, f);
292
292
  S ? s.current !== S.id && (e.classList.add("hovered"), s.set(S.id)) : s.current && (e.classList.remove("hovered"), s.set(null));
293
293
  };
294
- e.addEventListener("pointermove", c);
295
- const m = (B = !1) => {
294
+ e.addEventListener("pointermove", l);
295
+ const g = (M = !1) => {
296
296
  p && p.clear();
297
- const N = Ue(e), { minX: A, minY: S, maxX: C, maxY: L } = N, k = u ? i.getIntersecting(A, S, C, L).filter(({ annotation: $ }) => u($)) : i.getIntersecting(A, S, C, L), I = r.selected.map(({ id: $ }) => $), z = k.map(({ annotation: $, rects: we }) => {
297
+ const y = Ue(e), { minX: w, minY: S, maxX: C, maxY: E } = y, B = f ? i.getIntersecting(w, S, C, E).filter(({ annotation: $ }) => f($)) : i.getIntersecting(w, S, C, E), I = r.selected.map(({ id: $ }) => $), z = B.map(({ annotation: $, rects: we }) => {
298
298
  const Ae = I.includes($.id), ve = $.id === s.current;
299
299
  return { annotation: $, rects: we, state: { selected: Ae, hover: ve } };
300
300
  });
301
- o.redraw(z, N, a, p, B), setTimeout(() => h(k.map(({ annotation: $ }) => $)), 1);
302
- }, f = (B) => {
303
- p = B, m();
304
- }, v = (B) => {
305
- a = B, m();
306
- }, b = (B) => {
307
- u = B, m(!1);
308
- }, w = () => m();
309
- i.observe(w);
310
- const d = r.subscribe(() => m()), l = () => m(!0);
311
- document.addEventListener("scroll", l, { capture: !0, passive: !0 });
312
- const g = It(() => {
313
- i.recalculatePositions(), p && p.reset(), m();
301
+ o.redraw(z, y, a, p, M), setTimeout(() => h(B.map(({ annotation: $ }) => $)), 1);
302
+ }, d = (M) => {
303
+ p = M, g();
304
+ }, A = (M) => {
305
+ a = M, g();
306
+ }, m = (M) => {
307
+ f = M, g(!1);
308
+ }, b = () => g();
309
+ i.observe(b);
310
+ const u = r.subscribe(() => g()), c = () => g(!0);
311
+ document.addEventListener("scroll", c, { capture: !0, passive: !0 });
312
+ const v = It(() => {
313
+ i.recalculatePositions(), p && p.reset(), g();
314
314
  });
315
- window.addEventListener("resize", g);
316
- const x = new ResizeObserver(g);
315
+ window.addEventListener("resize", v);
316
+ const x = new ResizeObserver(v);
317
317
  x.observe(e);
318
- const T = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((B) => {
319
- B.every((A) => A.target === e || e.contains(A.target)) || m(!0);
318
+ const L = { attributes: !0, childList: !0, subtree: !0 }, T = new MutationObserver((M) => {
319
+ M.every((w) => w.target === e || e.contains(w.target)) || g(!0);
320
320
  });
321
- return E.observe(document.body, T), {
321
+ return T.observe(document.body, L), {
322
322
  destroy: () => {
323
- e.removeEventListener("pointermove", c), o.destroy(), i.unobserve(w), d(), document.removeEventListener("scroll", l), window.removeEventListener("resize", g), x.disconnect(), E.disconnect();
323
+ e.removeEventListener("pointermove", l), o.destroy(), i.unobserve(b), u(), document.removeEventListener("scroll", c), window.removeEventListener("resize", v), x.disconnect(), T.disconnect();
324
324
  },
325
- redraw: m,
326
- setStyle: v,
327
- setFilter: b,
328
- setPainter: f,
325
+ redraw: g,
326
+ setStyle: A,
327
+ setFilter: m,
328
+ setPainter: d,
329
329
  setVisible: o.setVisible
330
330
  };
331
331
  }, _e = () => {
@@ -337,28 +337,28 @@ const q = {
337
337
  e.classList.add("r6o-annotatable");
338
338
  const t = _e(), n = t.getContext("2d");
339
339
  document.body.appendChild(t);
340
- const o = (a, u, p, h) => requestAnimationFrame(() => {
341
- const { width: c, height: m } = t;
342
- n.clearRect(-0.5, -0.5, c + 1, m + 1), h && h.clear();
343
- const { top: f, left: v } = u;
344
- [...a].sort((w, d) => {
345
- const { annotation: { target: { created: l } } } = w, { annotation: { target: { created: g } } } = d;
346
- return l.getTime() - g.getTime();
347
- }).forEach((w) => {
340
+ const o = (a, f, p, h) => requestAnimationFrame(() => {
341
+ const { width: l, height: g } = t;
342
+ n.clearRect(-0.5, -0.5, l + 1, g + 1), h && h.clear();
343
+ const { top: d, left: A } = f;
344
+ [...a].sort((b, u) => {
345
+ const { annotation: { target: { created: c } } } = b, { annotation: { target: { created: v } } } = u;
346
+ return c.getTime() - v.getTime();
347
+ }).forEach((b) => {
348
348
  var x;
349
- const d = p ? typeof p == "function" ? p(w.annotation, w.state) : p : (x = w.state) != null && x.selected ? gt : q, l = h && h.paint(w, u) || d, g = w.rects.map(({ x: T, y: E, width: M, height: B }) => ({
350
- x: T + v,
351
- y: E + f,
352
- width: M,
353
- height: B
349
+ const u = p ? typeof p == "function" ? p(b.annotation, b.state) : p : (x = b.state) != null && x.selected ? gt : q, c = h && h.paint(b, f) || u, v = b.rects.map(({ x: L, y: T, width: k, height: M }) => ({
350
+ x: L + A,
351
+ y: T + d,
352
+ width: k,
353
+ height: M
354
354
  }));
355
- if (n.fillStyle = l.fill, n.globalAlpha = l.fillOpacity || 1, g.forEach(
356
- ({ x: T, y: E, width: M, height: B }) => n.fillRect(T, E, M, B)
357
- ), l.underlineColor) {
358
- n.globalAlpha = 1, n.strokeStyle = l.underlineColor, n.lineWidth = l.underlineThickness ?? 1;
359
- const T = l.underlineOffset ?? 0;
360
- g.forEach(({ x: E, y: M, width: B, height: N }) => {
361
- n.beginPath(), n.moveTo(E, M + N + T), n.lineTo(E + B, M + N + T), n.stroke();
355
+ if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, v.forEach(
356
+ ({ x: L, y: T, width: k, height: M }) => n.fillRect(L, T, k, M)
357
+ ), c.underlineColor) {
358
+ n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
359
+ const L = c.underlineOffset ?? 0;
360
+ v.forEach(({ x: T, y: k, width: M, height: y }) => {
361
+ n.beginPath(), n.moveTo(T, k + y + L), n.lineTo(T + M, k + y + L), n.stroke();
362
362
  });
363
363
  }
364
364
  });
@@ -377,7 +377,7 @@ const q = {
377
377
  }, $e = (e, t, n) => Nt(e, t, n, Xe(e));
378
378
  var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
379
379
  return typeof e == "string" ? e.length > 0 : typeof e == "number";
380
- }, F = function(e, t, n) {
380
+ }, N = function(e, t, n) {
381
381
  return t === void 0 && (t = 0), n === void 0 && (n = Math.pow(10, t)), Math.round(n * e) / n + 0;
382
382
  }, H = function(e, t, n) {
383
383
  return t === void 0 && (t = 0), n === void 0 && (n = 1), e > n ? n : e > t ? e : t;
@@ -386,7 +386,7 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
386
386
  }, Ut = function(e) {
387
387
  return { r: H(e.r, 0, 255), g: H(e.g, 0, 255), b: H(e.b, 0, 255), a: H(e.a) };
388
388
  }, wt = function(e) {
389
- return { r: F(e.r), g: F(e.g), b: F(e.b), a: F(e.a, 3) };
389
+ return { r: N(e.r), g: N(e.g), b: N(e.b), a: N(e.a, 3) };
390
390
  }, Ge = /^#([0-9a-f]{3,8})$/i, ct = function(e) {
391
391
  var t = e.toString(16);
392
392
  return t.length < 2 ? "0" + t : t;
@@ -396,12 +396,12 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
396
396
  }, ae = function(e) {
397
397
  var t = e.h, n = e.s, o = e.v, i = e.a;
398
398
  t = t / 360 * 6, n /= 100, o /= 100;
399
- var r = Math.floor(t), s = o * (1 - n), a = o * (1 - (t - r) * n), u = o * (1 - (1 - t + r) * n), p = r % 6;
400
- return { r: 255 * [o, a, s, s, u, o][p], g: 255 * [u, o, o, a, s, s][p], b: 255 * [s, s, u, o, o, a][p], a: i };
399
+ var r = Math.floor(t), s = o * (1 - n), a = o * (1 - (t - r) * n), f = o * (1 - (1 - t + r) * n), p = r % 6;
400
+ return { r: 255 * [o, a, s, s, f, o][p], g: 255 * [f, o, o, a, s, s][p], b: 255 * [s, s, f, o, o, a][p], a: i };
401
401
  }, Ht = function(e) {
402
402
  return { h: ie(e.h), s: H(e.s, 0, 100), l: H(e.l, 0, 100), a: H(e.a) };
403
403
  }, _t = function(e) {
404
- return { h: F(e.h), s: F(e.s), l: F(e.l), a: F(e.a, 3) };
404
+ return { h: N(e.h), s: N(e.s), l: N(e.l), a: N(e.a, 3) };
405
405
  }, Yt = function(e) {
406
406
  return ae((n = (t = e).s, { h: t.h, s: (n *= ((o = t.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: t.a }));
407
407
  var t, n, o;
@@ -410,7 +410,7 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
410
410
  var t, n, o, i;
411
411
  }, We = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ze = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ze = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Xt = { string: [[function(e) {
412
412
  var t = Ge.exec(e);
413
- return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? F(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? F(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
413
+ return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? N(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? N(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
414
414
  }, "hex"], [function(e) {
415
415
  var t = qe.exec(e) || Ze.exec(e);
416
416
  return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Ut({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
@@ -457,13 +457,13 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
457
457
  return e.prototype.isValid = function() {
458
458
  return this.parsed !== null;
459
459
  }, e.prototype.brightness = function() {
460
- return F(vt(this.rgba), 2);
460
+ return N(vt(this.rgba), 2);
461
461
  }, e.prototype.isDark = function() {
462
462
  return vt(this.rgba) < 0.5;
463
463
  }, e.prototype.isLight = function() {
464
464
  return vt(this.rgba) >= 0.5;
465
465
  }, e.prototype.toHex = function() {
466
- return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(F(255 * r)) : "", "#" + ct(n) + ct(o) + ct(i) + s;
466
+ return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(N(255 * r)) : "", "#" + ct(n) + ct(o) + ct(i) + s;
467
467
  var t, n, o, i, r, s;
468
468
  }, e.prototype.toRgb = function() {
469
469
  return wt(this.rgba);
@@ -476,7 +476,7 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
476
476
  return t = _t(it(this.rgba)), n = t.h, o = t.s, i = t.l, (r = t.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
477
477
  var t, n, o, i, r;
478
478
  }, e.prototype.toHsv = function() {
479
- return t = re(this.rgba), { h: F(t.h), s: F(t.s), v: F(t.v), a: F(t.a, 3) };
479
+ return t = re(this.rgba), { h: N(t.h), s: N(t.s), v: N(t.v), a: N(t.a, 3) };
480
480
  var t;
481
481
  }, e.prototype.invert = function() {
482
482
  return _({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
@@ -494,11 +494,11 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
494
494
  }, e.prototype.rotate = function(t) {
495
495
  return t === void 0 && (t = 15), this.hue(this.hue() + t);
496
496
  }, e.prototype.alpha = function(t) {
497
- return typeof t == "number" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) : F(this.rgba.a, 3);
497
+ return typeof t == "number" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) : N(this.rgba.a, 3);
498
498
  var n;
499
499
  }, e.prototype.hue = function(t) {
500
500
  var n = it(this.rgba);
501
- return typeof t == "number" ? _({ h: t, s: n.s, l: n.l, a: n.a }) : F(n.h);
501
+ return typeof t == "number" ? _({ h: t, s: n.s, l: n.l, a: n.a }) : N(n.h);
502
502
  }, e.prototype.isEqual = function(t) {
503
503
  return this.toHex() === _(t).toHex();
504
504
  }, e;
@@ -522,19 +522,19 @@ const Qe = (e) => [
522
522
  setVisible: (r) => {
523
523
  console.log("setVisible not implemented on CSS Custom Highlights renderer");
524
524
  },
525
- redraw: (r, s, a, u) => {
526
- u && u.clear();
527
- const p = new Set(r.map((c) => c.annotation.id));
528
- Array.from(t).filter((c) => !p.has(c));
529
- const h = r.map((c) => {
530
- var v;
531
- const m = a ? typeof a == "function" ? a(c.annotation, c.state) : a : (v = c.state) != null && v.selected ? gt : q, f = u && u.paint(c, s) || m;
532
- return `::highlight(_${c.annotation.id}) { ${Qe(f)} }`;
525
+ redraw: (r, s, a, f) => {
526
+ f && f.clear();
527
+ const p = new Set(r.map((l) => l.annotation.id));
528
+ Array.from(t).filter((l) => !p.has(l));
529
+ const h = r.map((l) => {
530
+ var A;
531
+ const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (A = l.state) != null && A.selected ? gt : q, d = f && f.paint(l, s) || g;
532
+ return `::highlight(_${l.annotation.id}) { ${Qe(d)} }`;
533
533
  });
534
534
  e.innerHTML = h.join(`
535
- `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
536
- const m = c.target.selector.map((v) => v.range), f = new Highlight(...m);
537
- CSS.highlights.set(`_${c.id}`, f);
535
+ `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
536
+ const g = l.target.selector.map((A) => A.range), d = new Highlight(...g);
537
+ CSS.highlights.set(`_${l.id}`, d);
538
538
  }), t = p;
539
539
  }
540
540
  };
@@ -572,14 +572,14 @@ const en = (e, t) => {
572
572
  destroy: () => {
573
573
  t.remove();
574
574
  },
575
- redraw: (s, a, u, p, h) => {
576
- const m = !(Vt(n, s) && h);
577
- !p && !m || (m && (t.innerHTML = ""), s.forEach((f) => {
578
- f.rects.map((v) => {
579
- const b = en(v, s), w = Se(f, a, u, p, b);
580
- if (m) {
581
- const d = document.createElement("span");
582
- d.className = "r6o-annotation", d.dataset.annotation = f.annotation.id, d.style.left = `${v.x}px`, d.style.top = `${v.y}px`, d.style.width = `${v.width}px`, d.style.height = `${v.height}px`, d.style.backgroundColor = _((w == null ? void 0 : w.fill) || q.fill).alpha((w == null ? void 0 : w.fillOpacity) === void 0 ? q.fillOpacity : w.fillOpacity).toHex(), w.underlineStyle && (d.style.borderStyle = w.underlineStyle), w.underlineColor && (d.style.borderColor = w.underlineColor), w.underlineThickness && (d.style.borderBottomWidth = `${w.underlineThickness}px`), w.underlineOffset && (d.style.paddingBottom = `${w.underlineOffset}px`), t.appendChild(d);
575
+ redraw: (s, a, f, p, h) => {
576
+ const g = !(Vt(n, s) && h);
577
+ !p && !g || (g && (t.innerHTML = ""), s.forEach((d) => {
578
+ d.rects.map((A) => {
579
+ const m = en(A, s), b = Se(d, a, f, p, m);
580
+ if (g) {
581
+ const u = document.createElement("span");
582
+ u.className = "r6o-annotation", u.dataset.annotation = d.annotation.id, u.style.left = `${A.x}px`, u.style.top = `${A.y}px`, u.style.width = `${A.width}px`, u.style.height = `${A.height}px`, u.style.backgroundColor = _((b == null ? void 0 : b.fill) || q.fill).alpha((b == null ? void 0 : b.fillOpacity) === void 0 ? q.fillOpacity : b.fillOpacity).toHex(), b.underlineStyle && (u.style.borderStyle = b.underlineStyle), b.underlineColor && (u.style.borderColor = b.underlineColor), b.underlineThickness && (u.style.borderBottomWidth = `${b.underlineThickness}px`), b.underlineOffset && (u.style.paddingBottom = `${b.underlineOffset}px`), t.appendChild(u);
583
583
  }
584
584
  });
585
585
  }), n = s);
@@ -589,11 +589,11 @@ const en = (e, t) => {
589
589
  }
590
590
  };
591
591
  }, on = (e, t, n) => Nt(e, t, n, nn(e));
592
- var P = [];
592
+ var F = [];
593
593
  for (var St = 0; St < 256; ++St)
594
- P.push((St + 256).toString(16).slice(1));
594
+ F.push((St + 256).toString(16).slice(1));
595
595
  function rn(e, t = 0) {
596
- return (P[e[t + 0]] + P[e[t + 1]] + P[e[t + 2]] + P[e[t + 3]] + "-" + P[e[t + 4]] + P[e[t + 5]] + "-" + P[e[t + 6]] + P[e[t + 7]] + "-" + P[e[t + 8]] + P[e[t + 9]] + "-" + P[e[t + 10]] + P[e[t + 11]] + P[e[t + 12]] + P[e[t + 13]] + P[e[t + 14]] + P[e[t + 15]]).toLowerCase();
596
+ return (F[e[t + 0]] + F[e[t + 1]] + F[e[t + 2]] + F[e[t + 3]] + "-" + F[e[t + 4]] + F[e[t + 5]] + "-" + F[e[t + 6]] + F[e[t + 7]] + "-" + F[e[t + 8]] + F[e[t + 9]] + "-" + F[e[t + 10]] + F[e[t + 11]] + F[e[t + 12]] + F[e[t + 13]] + F[e[t + 14]] + F[e[t + 15]]).toLowerCase();
597
597
  }
598
598
  var dt, an = new Uint8Array(16);
599
599
  function sn() {
@@ -644,10 +644,10 @@ function Ft(e, t = Ct) {
644
644
  const o = /* @__PURE__ */ new Set();
645
645
  function i(a) {
646
646
  if (cn(e, a) && (e = a, n)) {
647
- const u = !Z.length;
647
+ const f = !Z.length;
648
648
  for (const p of o)
649
649
  p[1](), Z.push(p, e);
650
- if (u) {
650
+ if (f) {
651
651
  for (let p = 0; p < Z.length; p += 2)
652
652
  Z[p][0](Z[p + 1]);
653
653
  Z.length = 0;
@@ -657,8 +657,8 @@ function Ft(e, t = Ct) {
657
657
  function r(a) {
658
658
  i(a(e));
659
659
  }
660
- function s(a, u = Ct) {
661
- const p = [a, u];
660
+ function s(a, f = Ct) {
661
+ const p = [a, f];
662
662
  return o.add(p), o.size === 1 && (n = t(i, r) || Ct), a(e), () => {
663
663
  o.delete(p), o.size === 0 && n && (n(), n = null);
664
664
  };
@@ -686,47 +686,47 @@ var un = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE =
686
686
  const xt = { selected: [] }, fn = (e, t = "EDIT") => {
687
687
  const { subscribe: n, set: o } = Ft(xt);
688
688
  let i = t, r = xt;
689
- n((f) => r = f);
689
+ n((d) => r = d);
690
690
  const s = () => o(xt), a = () => {
691
- var f;
692
- return ((f = r.selected) == null ? void 0 : f.length) === 0;
693
- }, u = (f) => {
691
+ var d;
692
+ return ((d = r.selected) == null ? void 0 : d.length) === 0;
693
+ }, f = (d) => {
694
694
  if (a())
695
695
  return !1;
696
- const v = typeof f == "string" ? f : f.id;
697
- return r.selected.some((b) => b.id === v);
698
- }, p = (f, v) => {
699
- const b = e.getAnnotation(f);
700
- if (!b) {
701
- console.warn("Invalid selection: " + f);
696
+ const A = typeof d == "string" ? d : d.id;
697
+ return r.selected.some((m) => m.id === A);
698
+ }, p = (d, A) => {
699
+ const m = e.getAnnotation(d);
700
+ if (!m) {
701
+ console.warn("Invalid selection: " + d);
702
702
  return;
703
703
  }
704
- switch (Zt(b, i)) {
704
+ switch (Zt(m, i)) {
705
705
  case "EDIT":
706
- o({ selected: [{ id: f, editable: !0 }], event: v });
706
+ o({ selected: [{ id: d, editable: !0 }], event: A });
707
707
  break;
708
708
  case "SELECT":
709
- o({ selected: [{ id: f }], event: v });
709
+ o({ selected: [{ id: d }], event: A });
710
710
  break;
711
711
  default:
712
- o({ selected: [], event: v });
712
+ o({ selected: [], event: A });
713
713
  }
714
- }, h = (f, v) => {
715
- const b = Array.isArray(f) ? f : [f], w = b.map((d) => e.getAnnotation(d)).filter((d) => !!d);
714
+ }, h = (d, A) => {
715
+ const m = Array.isArray(d) ? d : [d], b = m.map((u) => e.getAnnotation(u)).filter((u) => !!u);
716
716
  o({
717
- selected: w.map((d) => {
718
- const l = v === void 0 ? Zt(d, i) === "EDIT" : v;
719
- return { id: d.id, editable: l };
717
+ selected: b.map((u) => {
718
+ const c = A === void 0 ? Zt(u, i) === "EDIT" : A;
719
+ return { id: u.id, editable: c };
720
720
  })
721
- }), w.length !== b.length && console.warn("Invalid selection", f);
722
- }, c = (f) => {
721
+ }), b.length !== m.length && console.warn("Invalid selection", d);
722
+ }, l = (d) => {
723
723
  if (a())
724
724
  return !1;
725
- const { selected: v } = r;
726
- v.some(({ id: b }) => f.includes(b)) && o({ selected: v.filter(({ id: b }) => !f.includes(b)) });
727
- }, m = (f) => i = f;
725
+ const { selected: A } = r;
726
+ A.some(({ id: m }) => d.includes(m)) && o({ selected: A.filter(({ id: m }) => !d.includes(m)) });
727
+ }, g = (d) => i = d;
728
728
  return e.observe(
729
- ({ changes: f }) => c((f.deleted || []).map((v) => v.id))
729
+ ({ changes: d }) => l((d.deleted || []).map((A) => A.id))
730
730
  ), {
731
731
  get event() {
732
732
  return r ? r.event : null;
@@ -736,18 +736,18 @@ const xt = { selected: [] }, fn = (e, t = "EDIT") => {
736
736
  },
737
737
  clear: s,
738
738
  isEmpty: a,
739
- isSelected: u,
739
+ isSelected: f,
740
740
  setSelected: h,
741
- setUserSelectAction: m,
741
+ setUserSelectAction: g,
742
742
  subscribe: n,
743
743
  userSelect: p
744
744
  };
745
745
  }, Zt = (e, t) => typeof t == "function" ? t(e) : t || "EDIT";
746
- var D = [];
746
+ var P = [];
747
747
  for (var Lt = 0; Lt < 256; ++Lt)
748
- D.push((Lt + 256).toString(16).slice(1));
748
+ P.push((Lt + 256).toString(16).slice(1));
749
749
  function pn(e, t = 0) {
750
- return (D[e[t + 0]] + D[e[t + 1]] + D[e[t + 2]] + D[e[t + 3]] + "-" + D[e[t + 4]] + D[e[t + 5]] + "-" + D[e[t + 6]] + D[e[t + 7]] + "-" + D[e[t + 8]] + D[e[t + 9]] + "-" + D[e[t + 10]] + D[e[t + 11]] + D[e[t + 12]] + D[e[t + 13]] + D[e[t + 14]] + D[e[t + 15]]).toLowerCase();
750
+ return (P[e[t + 0]] + P[e[t + 1]] + P[e[t + 2]] + P[e[t + 3]] + "-" + P[e[t + 4]] + P[e[t + 5]] + "-" + P[e[t + 6]] + P[e[t + 7]] + "-" + P[e[t + 8]] + P[e[t + 9]] + "-" + P[e[t + 10]] + P[e[t + 11]] + P[e[t + 12]] + P[e[t + 13]] + P[e[t + 14]] + P[e[t + 15]]).toLowerCase();
751
751
  }
752
752
  var ut, hn = new Uint8Array(16);
753
753
  function gn() {
@@ -799,10 +799,10 @@ const Cn = (e, t) => {
799
799
  if (!(!e.options.origin || e.options.origin === r))
800
800
  return !1;
801
801
  if (e.options.ignore) {
802
- const { ignore: s } = e.options, a = (u) => u && u.length > 0;
802
+ const { ignore: s } = e.options, a = (f) => f && f.length > 0;
803
803
  if (!(a(i.created) || a(i.deleted))) {
804
- const u = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), p = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
805
- if (s === "BODY_ONLY" && u && !p || s === "TARGET_ONLY" && p && !u)
804
+ const f = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), p = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
805
+ if (s === "BODY_ONLY" && f && !p || s === "TARGET_ONLY" && p && !f)
806
806
  return !1;
807
807
  }
808
808
  }
@@ -816,31 +816,31 @@ const Cn = (e, t) => {
816
816
  } else
817
817
  return !0;
818
818
  }, xn = (e, t) => {
819
- const n = new Set((e.created || []).map((c) => c.id)), o = new Set((e.updated || []).map(({ newValue: c }) => c.id)), i = new Set((t.created || []).map((c) => c.id)), r = new Set((t.deleted || []).map((c) => c.id)), s = new Set((t.updated || []).map(({ oldValue: c }) => c.id)), a = new Set((t.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), u = [
820
- ...(e.created || []).filter((c) => !r.has(c.id)).map((c) => s.has(c.id) ? t.updated.find(({ oldValue: m }) => m.id === c.id).newValue : c),
819
+ const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), i = new Set((t.created || []).map((l) => l.id)), r = new Set((t.deleted || []).map((l) => l.id)), s = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), f = [
820
+ ...(e.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? t.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
821
821
  ...t.created || []
822
822
  ], p = [
823
- ...(e.deleted || []).filter((c) => !i.has(c.id)),
824
- ...(t.deleted || []).filter((c) => !n.has(c.id))
823
+ ...(e.deleted || []).filter((l) => !i.has(l.id)),
824
+ ...(t.deleted || []).filter((l) => !n.has(l.id))
825
825
  ], h = [
826
- ...(e.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
827
- const { oldValue: m, newValue: f } = c;
828
- if (s.has(f.id)) {
829
- const v = t.updated.find((b) => b.oldValue.id === f.id).newValue;
830
- return le(m, v);
826
+ ...(e.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
827
+ const { oldValue: g, newValue: d } = l;
828
+ if (s.has(d.id)) {
829
+ const A = t.updated.find((m) => m.oldValue.id === d.id).newValue;
830
+ return le(g, A);
831
831
  } else
832
- return c;
832
+ return l;
833
833
  }),
834
- ...(t.updated || []).filter(({ oldValue: c }) => !a.has(c.id))
834
+ ...(t.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
835
835
  ];
836
- return { created: u, deleted: p, updated: h };
837
- }, Ln = (e) => e.id !== void 0, Tn = () => {
838
- const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (A, S = {}) => n.push({ onChange: A, options: S }), i = (A) => {
839
- const S = n.findIndex((C) => C.onChange == A);
836
+ return { created: f, deleted: p, updated: h };
837
+ }, Ln = (e) => e.id !== void 0, En = () => {
838
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (w, S = {}) => n.push({ onChange: w, options: S }), i = (w) => {
839
+ const S = n.findIndex((C) => C.onChange == w);
840
840
  S > -1 && n.splice(S, 1);
841
- }, r = (A, S) => {
841
+ }, r = (w, S) => {
842
842
  const C = {
843
- origin: A,
843
+ origin: w,
844
844
  changes: {
845
845
  created: S.created || [],
846
846
  updated: S.updated || [],
@@ -848,144 +848,144 @@ const Cn = (e, t) => {
848
848
  },
849
849
  state: [...e.values()]
850
850
  };
851
- n.forEach((L) => {
852
- Cn(L, C) && L.onChange(C);
851
+ n.forEach((E) => {
852
+ Cn(E, C) && E.onChange(C);
853
853
  });
854
- }, s = (A, S = R.LOCAL) => {
855
- if (e.get(A.id))
856
- throw Error(`Cannot add annotation ${A.id} - exists already`);
857
- e.set(A.id, A), A.bodies.forEach((C) => t.set(C.id, A.id)), r(S, { created: [A] });
858
- }, a = (A, S) => {
859
- const C = typeof A == "string" ? S : A, L = typeof A == "string" ? A : A.id, k = e.get(L);
860
- if (k) {
861
- const I = le(k, C);
862
- return L === C.id ? e.set(L, C) : (e.delete(L), e.set(C.id, C)), k.bodies.forEach((z) => t.delete(z.id)), C.bodies.forEach((z) => t.set(z.id, C.id)), I;
854
+ }, s = (w, S = R.LOCAL) => {
855
+ if (e.get(w.id))
856
+ throw Error(`Cannot add annotation ${w.id} - exists already`);
857
+ e.set(w.id, w), w.bodies.forEach((C) => t.set(C.id, w.id)), r(S, { created: [w] });
858
+ }, a = (w, S) => {
859
+ const C = typeof w == "string" ? S : w, E = typeof w == "string" ? w : w.id, B = e.get(E);
860
+ if (B) {
861
+ const I = le(B, C);
862
+ return E === C.id ? e.set(E, C) : (e.delete(E), e.set(C.id, C)), B.bodies.forEach((z) => t.delete(z.id)), C.bodies.forEach((z) => t.set(z.id, C.id)), I;
863
863
  } else
864
- console.warn(`Cannot update annotation ${L} - does not exist`);
865
- }, u = (A, S = R.LOCAL, C = R.LOCAL) => {
866
- const L = Ln(S) ? C : S, k = a(A, S);
867
- k && r(L, { updated: [k] });
868
- }, p = (A, S = R.LOCAL) => {
869
- const C = A.reduce((L, k) => {
870
- const I = a(k);
871
- return I ? [...L, I] : L;
864
+ console.warn(`Cannot update annotation ${E} - does not exist`);
865
+ }, f = (w, S = R.LOCAL, C = R.LOCAL) => {
866
+ const E = Ln(S) ? C : S, B = a(w, S);
867
+ B && r(E, { updated: [B] });
868
+ }, p = (w, S = R.LOCAL) => {
869
+ const C = w.reduce((E, B) => {
870
+ const I = a(B);
871
+ return I ? [...E, I] : E;
872
872
  }, []);
873
873
  C.length > 0 && r(S, { updated: C });
874
- }, h = (A, S = R.LOCAL) => {
875
- const C = e.get(A.annotation);
874
+ }, h = (w, S = R.LOCAL) => {
875
+ const C = e.get(w.annotation);
876
876
  if (C) {
877
- const L = {
877
+ const E = {
878
878
  ...C,
879
- bodies: [...C.bodies, A]
879
+ bodies: [...C.bodies, w]
880
880
  };
881
- e.set(C.id, L), t.set(A.id, L.id), r(S, { updated: [{
881
+ e.set(C.id, E), t.set(w.id, E.id), r(S, { updated: [{
882
882
  oldValue: C,
883
- newValue: L,
884
- bodiesCreated: [A]
883
+ newValue: E,
884
+ bodiesCreated: [w]
885
885
  }] });
886
886
  } else
887
- console.warn(`Attempt to add body to missing annotation: ${A.annotation}`);
888
- }, c = () => [...e.values()], m = (A = R.LOCAL) => {
887
+ console.warn(`Attempt to add body to missing annotation: ${w.annotation}`);
888
+ }, l = () => [...e.values()], g = (w = R.LOCAL) => {
889
889
  const S = [...e.values()];
890
- e.clear(), t.clear(), r(A, { deleted: S });
891
- }, f = (A, S = !0, C = R.LOCAL) => {
890
+ e.clear(), t.clear(), r(w, { deleted: S });
891
+ }, d = (w, S = !0, C = R.LOCAL) => {
892
892
  if (S) {
893
- const L = [...e.values()];
894
- e.clear(), t.clear(), A.forEach((k) => {
895
- e.set(k.id, k), k.bodies.forEach((I) => t.set(I.id, k.id));
896
- }), r(C, { created: A, deleted: L });
893
+ const E = [...e.values()];
894
+ e.clear(), t.clear(), w.forEach((B) => {
895
+ e.set(B.id, B), B.bodies.forEach((I) => t.set(I.id, B.id));
896
+ }), r(C, { created: w, deleted: E });
897
897
  } else {
898
- const L = A.reduce((k, I) => {
898
+ const E = w.reduce((B, I) => {
899
899
  const z = e.get(I.id);
900
- return z ? [...k, z] : k;
900
+ return z ? [...B, z] : B;
901
901
  }, []);
902
- if (L.length > 0)
903
- throw Error(`Bulk insert would overwrite the following annotations: ${L.map((k) => k.id).join(", ")}`);
904
- A.forEach((k) => {
905
- e.set(k.id, k), k.bodies.forEach((I) => t.set(I.id, k.id));
906
- }), r(C, { created: A });
902
+ if (E.length > 0)
903
+ throw Error(`Bulk insert would overwrite the following annotations: ${E.map((B) => B.id).join(", ")}`);
904
+ w.forEach((B) => {
905
+ e.set(B.id, B), B.bodies.forEach((I) => t.set(I.id, B.id));
906
+ }), r(C, { created: w });
907
907
  }
908
- }, v = (A) => {
909
- const S = typeof A == "string" ? A : A.id, C = e.get(S);
908
+ }, A = (w) => {
909
+ const S = typeof w == "string" ? w : w.id, C = e.get(S);
910
910
  if (C)
911
- return e.delete(S), C.bodies.forEach((L) => t.delete(L.id)), C;
911
+ return e.delete(S), C.bodies.forEach((E) => t.delete(E.id)), C;
912
912
  console.warn(`Attempt to delete missing annotation: ${S}`);
913
- }, b = (A, S = R.LOCAL) => {
914
- const C = v(A);
913
+ }, m = (w, S = R.LOCAL) => {
914
+ const C = A(w);
915
915
  C && r(S, { deleted: [C] });
916
- }, w = (A, S = R.LOCAL) => {
917
- const C = A.reduce((L, k) => {
918
- const I = v(k);
919
- return I ? [...L, I] : L;
916
+ }, b = (w, S = R.LOCAL) => {
917
+ const C = w.reduce((E, B) => {
918
+ const I = A(B);
919
+ return I ? [...E, I] : E;
920
920
  }, []);
921
921
  C.length > 0 && r(S, { deleted: C });
922
- }, d = (A) => {
923
- const S = e.get(A.annotation);
922
+ }, u = (w) => {
923
+ const S = e.get(w.annotation);
924
924
  if (S) {
925
- const C = S.bodies.find((L) => L.id === A.id);
925
+ const C = S.bodies.find((E) => E.id === w.id);
926
926
  if (C) {
927
927
  t.delete(C.id);
928
- const L = {
928
+ const E = {
929
929
  ...S,
930
- bodies: S.bodies.filter((k) => k.id !== A.id)
930
+ bodies: S.bodies.filter((B) => B.id !== w.id)
931
931
  };
932
- return e.set(S.id, L), {
932
+ return e.set(S.id, E), {
933
933
  oldValue: S,
934
- newValue: L,
934
+ newValue: E,
935
935
  bodiesDeleted: [C]
936
936
  };
937
937
  } else
938
- console.warn(`Attempt to delete missing body ${A.id} from annotation ${A.annotation}`);
938
+ console.warn(`Attempt to delete missing body ${w.id} from annotation ${w.annotation}`);
939
939
  } else
940
- console.warn(`Attempt to delete body from missing annotation ${A.annotation}`);
941
- }, l = (A, S = R.LOCAL) => {
942
- const C = d(A);
940
+ console.warn(`Attempt to delete body from missing annotation ${w.annotation}`);
941
+ }, c = (w, S = R.LOCAL) => {
942
+ const C = u(w);
943
943
  C && r(S, { updated: [C] });
944
- }, g = (A, S = R.LOCAL) => {
945
- const C = A.map((L) => d(L)).filter(Boolean);
944
+ }, v = (w, S = R.LOCAL) => {
945
+ const C = w.map((E) => u(E)).filter(Boolean);
946
946
  C.length > 0 && r(S, { updated: C });
947
- }, x = (A) => {
948
- const S = e.get(A);
947
+ }, x = (w) => {
948
+ const S = e.get(w);
949
949
  return S ? { ...S } : void 0;
950
- }, T = (A) => {
951
- const S = t.get(A);
950
+ }, L = (w) => {
951
+ const S = t.get(w);
952
952
  if (S) {
953
- const C = x(S).bodies.find((L) => L.id === A);
953
+ const C = x(S).bodies.find((E) => E.id === w);
954
954
  if (C)
955
955
  return C;
956
- console.error(`Store integrity error: body ${A} in index, but not in annotation`);
956
+ console.error(`Store integrity error: body ${w} in index, but not in annotation`);
957
957
  } else
958
- console.warn(`Attempt to retrieve missing body: ${A}`);
959
- }, E = (A, S) => {
960
- if (A.annotation !== S.annotation)
958
+ console.warn(`Attempt to retrieve missing body: ${w}`);
959
+ }, T = (w, S) => {
960
+ if (w.annotation !== S.annotation)
961
961
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
962
- const C = e.get(A.annotation);
962
+ const C = e.get(w.annotation);
963
963
  if (C) {
964
- const L = C.bodies.find((I) => I.id === A.id), k = {
964
+ const E = C.bodies.find((I) => I.id === w.id), B = {
965
965
  ...C,
966
- bodies: C.bodies.map((I) => I.id === L.id ? S : I)
966
+ bodies: C.bodies.map((I) => I.id === E.id ? S : I)
967
967
  };
968
- return e.set(C.id, k), L.id !== S.id && (t.delete(L.id), t.set(S.id, k.id)), {
968
+ return e.set(C.id, B), E.id !== S.id && (t.delete(E.id), t.set(S.id, B.id)), {
969
969
  oldValue: C,
970
- newValue: k,
971
- bodiesUpdated: [{ oldBody: L, newBody: S }]
970
+ newValue: B,
971
+ bodiesUpdated: [{ oldBody: E, newBody: S }]
972
972
  };
973
973
  } else
974
- console.warn(`Attempt to add body to missing annotation ${A.annotation}`);
975
- }, M = (A, S, C = R.LOCAL) => {
976
- const L = E(A, S);
977
- L && r(C, { updated: [L] });
978
- }, B = (A, S = R.LOCAL) => {
979
- const C = A.map((L) => E({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
974
+ console.warn(`Attempt to add body to missing annotation ${w.annotation}`);
975
+ }, k = (w, S, C = R.LOCAL) => {
976
+ const E = T(w, S);
977
+ E && r(C, { updated: [E] });
978
+ }, M = (w, S = R.LOCAL) => {
979
+ const C = w.map((E) => T({ id: E.id, annotation: E.annotation }, E)).filter(Boolean);
980
980
  r(S, { updated: C });
981
- }, N = (A) => {
982
- const S = e.get(A.annotation);
981
+ }, y = (w) => {
982
+ const S = e.get(w.annotation);
983
983
  if (S) {
984
984
  const C = {
985
985
  ...S,
986
986
  target: {
987
987
  ...S.target,
988
- ...A
988
+ ...w
989
989
  }
990
990
  };
991
991
  return e.set(S.id, C), {
@@ -993,41 +993,41 @@ const Cn = (e, t) => {
993
993
  newValue: C,
994
994
  targetUpdated: {
995
995
  oldTarget: S.target,
996
- newTarget: A
996
+ newTarget: w
997
997
  }
998
998
  };
999
999
  } else
1000
- console.warn(`Attempt to update target on missing annotation: ${A.annotation}`);
1000
+ console.warn(`Attempt to update target on missing annotation: ${w.annotation}`);
1001
1001
  };
1002
1002
  return {
1003
1003
  addAnnotation: s,
1004
1004
  addBody: h,
1005
- all: c,
1006
- bulkAddAnnotation: f,
1007
- bulkDeleteAnnotation: w,
1008
- bulkDeleteBodies: g,
1005
+ all: l,
1006
+ bulkAddAnnotation: d,
1007
+ bulkDeleteAnnotation: b,
1008
+ bulkDeleteBodies: v,
1009
1009
  bulkUpdateAnnotation: p,
1010
- bulkUpdateBodies: B,
1011
- bulkUpdateTargets: (A, S = R.LOCAL) => {
1012
- const C = A.map((L) => N(L)).filter(Boolean);
1010
+ bulkUpdateBodies: M,
1011
+ bulkUpdateTargets: (w, S = R.LOCAL) => {
1012
+ const C = w.map((E) => y(E)).filter(Boolean);
1013
1013
  C.length > 0 && r(S, { updated: C });
1014
1014
  },
1015
- clear: m,
1016
- deleteAnnotation: b,
1017
- deleteBody: l,
1015
+ clear: g,
1016
+ deleteAnnotation: m,
1017
+ deleteBody: c,
1018
1018
  getAnnotation: x,
1019
- getBody: T,
1019
+ getBody: L,
1020
1020
  observe: o,
1021
1021
  unobserve: i,
1022
- updateAnnotation: u,
1023
- updateBody: M,
1024
- updateTarget: (A, S = R.LOCAL) => {
1025
- const C = N(A);
1022
+ updateAnnotation: f,
1023
+ updateBody: k,
1024
+ updateTarget: (w, S = R.LOCAL) => {
1025
+ const C = y(w);
1026
1026
  C && r(S, { updated: [C] });
1027
1027
  }
1028
1028
  };
1029
1029
  };
1030
- let En = () => ({
1030
+ let Tn = () => ({
1031
1031
  emit(e, ...t) {
1032
1032
  for (let n = 0, o = this.events[e] || [], i = o.length; n < i; n++)
1033
1033
  o[n](...t);
@@ -1042,40 +1042,40 @@ let En = () => ({
1042
1042
  }
1043
1043
  });
1044
1044
  const Mn = 250, Bn = (e) => {
1045
- const t = En(), n = [];
1045
+ const t = Tn(), n = [];
1046
1046
  let o = -1, i = !1, r = 0;
1047
- const s = (f) => {
1047
+ const s = (d) => {
1048
1048
  if (!i) {
1049
- const { changes: v } = f, b = performance.now();
1050
- if (b - r > Mn)
1051
- n.splice(o + 1), n.push(v), o = n.length - 1;
1049
+ const { changes: A } = d, m = performance.now();
1050
+ if (m - r > Mn)
1051
+ n.splice(o + 1), n.push(A), o = n.length - 1;
1052
1052
  else {
1053
- const w = n.length - 1;
1054
- n[w] = xn(n[w], v);
1053
+ const b = n.length - 1;
1054
+ n[b] = xn(n[b], A);
1055
1055
  }
1056
- r = b;
1056
+ r = m;
1057
1057
  }
1058
1058
  i = !1;
1059
1059
  };
1060
1060
  e.observe(s, { origin: R.LOCAL });
1061
- const a = (f) => f && f.length > 0 && e.bulkDeleteAnnotation(f), u = (f) => f && f.length > 0 && e.bulkAddAnnotation(f, !1), p = (f) => f && f.length > 0 && e.bulkUpdateAnnotation(f.map(({ oldValue: v }) => v)), h = (f) => f && f.length > 0 && e.bulkUpdateAnnotation(f.map(({ newValue: v }) => v)), c = (f) => f && f.length > 0 && e.bulkAddAnnotation(f, !1), m = (f) => f && f.length > 0 && e.bulkDeleteAnnotation(f);
1061
+ const a = (d) => d && d.length > 0 && e.bulkDeleteAnnotation(d), f = (d) => d && d.length > 0 && e.bulkAddAnnotation(d, !1), p = (d) => d && d.length > 0 && e.bulkUpdateAnnotation(d.map(({ oldValue: A }) => A)), h = (d) => d && d.length > 0 && e.bulkUpdateAnnotation(d.map(({ newValue: A }) => A)), l = (d) => d && d.length > 0 && e.bulkAddAnnotation(d, !1), g = (d) => d && d.length > 0 && e.bulkDeleteAnnotation(d);
1062
1062
  return {
1063
1063
  canRedo: () => n.length - 1 > o,
1064
1064
  canUndo: () => o > -1,
1065
1065
  destroy: () => e.unobserve(s),
1066
- on: (f, v) => t.on(f, v),
1066
+ on: (d, A) => t.on(d, A),
1067
1067
  redo: () => {
1068
1068
  if (n.length - 1 > o) {
1069
1069
  i = !0;
1070
- const { created: f, updated: v, deleted: b } = n[o + 1];
1071
- u(f), h(v), m(b), t.emit("redo", n[o + 1]), o += 1;
1070
+ const { created: d, updated: A, deleted: m } = n[o + 1];
1071
+ f(d), h(A), g(m), t.emit("redo", n[o + 1]), o += 1;
1072
1072
  }
1073
1073
  },
1074
1074
  undo: () => {
1075
1075
  if (o > -1) {
1076
1076
  i = !0;
1077
- const { created: f, updated: v, deleted: b } = n[o];
1078
- a(f), p(v), c(b), t.emit("undo", n[o]), o -= 1;
1077
+ const { created: d, updated: A, deleted: m } = n[o];
1078
+ a(d), p(A), l(m), t.emit("undo", n[o]), o -= 1;
1079
1079
  }
1080
1080
  }
1081
1081
  };
@@ -1086,73 +1086,73 @@ const Mn = 250, Bn = (e) => {
1086
1086
  set: t
1087
1087
  };
1088
1088
  }, Rn = (e, t, n, o) => {
1089
- const { store: i, selection: r, hover: s, viewport: a } = e, u = /* @__PURE__ */ new Map();
1089
+ const { store: i, selection: r, hover: s, viewport: a } = e, f = /* @__PURE__ */ new Map();
1090
1090
  let p = [], h;
1091
- const c = (b, w) => {
1092
- u.has(b) ? u.get(b).push(w) : u.set(b, [w]);
1093
- }, m = (b, w) => {
1094
- const d = u.get(b);
1095
- if (d) {
1096
- const l = d.indexOf(w);
1097
- l !== -1 && d.splice(l, 1);
1091
+ const l = (m, b) => {
1092
+ f.has(m) ? f.get(m).push(b) : f.set(m, [b]);
1093
+ }, g = (m, b) => {
1094
+ const u = f.get(m);
1095
+ if (u) {
1096
+ const c = u.indexOf(b);
1097
+ c !== -1 && u.splice(c, 1);
1098
1098
  }
1099
- }, f = (b, w, d) => {
1100
- u.has(b) && setTimeout(() => {
1101
- u.get(b).forEach((l) => {
1099
+ }, d = (m, b, u) => {
1100
+ f.has(m) && setTimeout(() => {
1101
+ f.get(m).forEach((c) => {
1102
1102
  if (n) {
1103
- const g = Array.isArray(w) ? w.map((T) => n.serialize(T)) : n.serialize(w), x = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1104
- l(g, x);
1103
+ const v = Array.isArray(b) ? b.map((L) => n.serialize(L)) : n.serialize(b), x = u ? u instanceof PointerEvent ? u : n.serialize(u) : void 0;
1104
+ c(v, x);
1105
1105
  } else
1106
- l(w, d);
1106
+ c(b, u);
1107
1107
  });
1108
1108
  }, 1);
1109
1109
  };
1110
- r.subscribe(({ selected: b }) => {
1111
- if (!(p.length === 0 && b.length === 0)) {
1112
- if (p.length === 0 && b.length > 0)
1113
- p = b.map(({ id: w }) => i.getAnnotation(w));
1114
- else if (p.length > 0 && b.length === 0)
1115
- p.forEach((w) => {
1116
- const d = i.getAnnotation(w.id);
1117
- d && !K(d, w) && f("updateAnnotation", d, w);
1110
+ r.subscribe(({ selected: m }) => {
1111
+ if (!(p.length === 0 && m.length === 0)) {
1112
+ if (p.length === 0 && m.length > 0)
1113
+ p = m.map(({ id: b }) => i.getAnnotation(b));
1114
+ else if (p.length > 0 && m.length === 0)
1115
+ p.forEach((b) => {
1116
+ const u = i.getAnnotation(b.id);
1117
+ u && !K(u, b) && d("updateAnnotation", u, b);
1118
1118
  }), p = [];
1119
1119
  else {
1120
- const w = new Set(p.map((l) => l.id)), d = new Set(b.map(({ id: l }) => l));
1121
- p.filter((l) => !d.has(l.id)).forEach((l) => {
1122
- const g = i.getAnnotation(l.id);
1123
- g && !K(g, l) && f("updateAnnotation", g, l);
1120
+ const b = new Set(p.map((c) => c.id)), u = new Set(m.map(({ id: c }) => c));
1121
+ p.filter((c) => !u.has(c.id)).forEach((c) => {
1122
+ const v = i.getAnnotation(c.id);
1123
+ v && !K(v, c) && d("updateAnnotation", v, c);
1124
1124
  }), p = [
1125
1125
  // Remove annotations that were deselected
1126
- ...p.filter((l) => d.has(l.id)),
1126
+ ...p.filter((c) => u.has(c.id)),
1127
1127
  // Add editable annotations that were selected
1128
- ...b.filter(({ id: l }) => !w.has(l)).map(({ id: l }) => i.getAnnotation(l))
1128
+ ...m.filter(({ id: c }) => !b.has(c)).map(({ id: c }) => i.getAnnotation(c))
1129
1129
  ];
1130
1130
  }
1131
- f("selectionChanged", p);
1131
+ d("selectionChanged", p);
1132
1132
  }
1133
- }), s.subscribe((b) => {
1134
- !h && b ? f("mouseEnterAnnotation", i.getAnnotation(b)) : h && !b ? f("mouseLeaveAnnotation", i.getAnnotation(h)) : h && b && (f("mouseLeaveAnnotation", i.getAnnotation(h)), f("mouseEnterAnnotation", i.getAnnotation(b))), h = b;
1135
- }), a == null || a.subscribe((b) => f("viewportIntersect", b.map((w) => i.getAnnotation(w)))), i.observe((b) => {
1136
- const { created: w, deleted: d } = b.changes;
1137
- (w || []).forEach((l) => f("createAnnotation", l)), (d || []).forEach((l) => f("deleteAnnotation", l)), (b.changes.updated || []).filter((l) => [
1138
- ...l.bodiesCreated || [],
1139
- ...l.bodiesDeleted || [],
1140
- ...l.bodiesUpdated || []
1141
- ].length > 0).forEach(({ oldValue: l, newValue: g }) => {
1142
- const x = p.find((T) => T.id === l.id) || l;
1143
- p = p.map((T) => T.id === l.id ? g : T), f("updateAnnotation", g, x);
1133
+ }), s.subscribe((m) => {
1134
+ !h && m ? d("mouseEnterAnnotation", i.getAnnotation(m)) : h && !m ? d("mouseLeaveAnnotation", i.getAnnotation(h)) : h && m && (d("mouseLeaveAnnotation", i.getAnnotation(h)), d("mouseEnterAnnotation", i.getAnnotation(m))), h = m;
1135
+ }), a == null || a.subscribe((m) => d("viewportIntersect", m.map((b) => i.getAnnotation(b)))), i.observe((m) => {
1136
+ const { created: b, deleted: u } = m.changes;
1137
+ (b || []).forEach((c) => d("createAnnotation", c)), (u || []).forEach((c) => d("deleteAnnotation", c)), (m.changes.updated || []).filter((c) => [
1138
+ ...c.bodiesCreated || [],
1139
+ ...c.bodiesDeleted || [],
1140
+ ...c.bodiesUpdated || []
1141
+ ].length > 0).forEach(({ oldValue: c, newValue: v }) => {
1142
+ const x = p.find((L) => L.id === c.id) || c;
1143
+ p = p.map((L) => L.id === c.id ? v : L), d("updateAnnotation", v, x);
1144
1144
  });
1145
- }, { origin: R.LOCAL }), i.observe((b) => {
1145
+ }, { origin: R.LOCAL }), i.observe((m) => {
1146
1146
  if (p) {
1147
- const w = new Set(p.map((l) => l.id)), d = (b.changes.updated || []).filter(({ newValue: l }) => w.has(l.id)).map(({ newValue: l }) => l);
1148
- d.length > 0 && (p = p.map((l) => d.find((x) => x.id === l.id) || l));
1147
+ const b = new Set(p.map((c) => c.id)), u = (m.changes.updated || []).filter(({ newValue: c }) => b.has(c.id)).map(({ newValue: c }) => c);
1148
+ u.length > 0 && (p = p.map((c) => u.find((x) => x.id === c.id) || c));
1149
1149
  }
1150
1150
  }, { origin: R.REMOTE });
1151
- const v = (b) => (w) => {
1152
- const { updated: d } = w;
1153
- b ? (d || []).forEach((l) => f("updateAnnotation", l.oldValue, l.newValue)) : (d || []).forEach((l) => f("updateAnnotation", l.newValue, l.oldValue));
1151
+ const A = (m) => (b) => {
1152
+ const { updated: u } = b;
1153
+ m ? (u || []).forEach((c) => d("updateAnnotation", c.oldValue, c.newValue)) : (u || []).forEach((c) => d("updateAnnotation", c.newValue, c.oldValue));
1154
1154
  };
1155
- return t.on("undo", v(!0)), t.on("redo", v(!1)), { on: c, off: m, emit: f };
1155
+ return t.on("undo", A(!0)), t.on("redo", A(!1)), { on: l, off: g, emit: d };
1156
1156
  }, Vn = (e) => (t) => t.reduce((n, o) => {
1157
1157
  const { parsed: i, error: r } = e.parse(o);
1158
1158
  return r ? {
@@ -1165,46 +1165,46 @@ const Mn = 250, Bn = (e) => {
1165
1165
  ...n
1166
1166
  };
1167
1167
  }, { parsed: [], failed: [] }), On = (e, t, n) => {
1168
- const { store: o, selection: i } = e, r = (d) => {
1168
+ const { store: o, selection: i } = e, r = (u) => {
1169
1169
  if (n) {
1170
- const { parsed: l, error: g } = n.parse(d);
1171
- l ? o.addAnnotation(l, R.REMOTE) : console.error(g);
1170
+ const { parsed: c, error: v } = n.parse(u);
1171
+ c ? o.addAnnotation(c, R.REMOTE) : console.error(v);
1172
1172
  } else
1173
- o.addAnnotation(d, R.REMOTE);
1174
- }, s = () => i.clear(), a = () => o.clear(), u = (d) => {
1175
- const l = o.getAnnotation(d);
1176
- return n && l ? n.serialize(l) : l;
1173
+ o.addAnnotation(u, R.REMOTE);
1174
+ }, s = () => i.clear(), a = () => o.clear(), f = (u) => {
1175
+ const c = o.getAnnotation(u);
1176
+ return n && c ? n.serialize(c) : c;
1177
1177
  }, p = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1178
- var d;
1179
- const l = (((d = i.selected) == null ? void 0 : d.map((g) => g.id)) || []).map((g) => o.getAnnotation(g)).filter(Boolean);
1180
- return n ? l.map(n.serialize) : l;
1181
- }, c = (d, l = !0) => fetch(d).then((g) => g.json()).then((g) => (f(g, l), g)), m = (d) => {
1182
- if (typeof d == "string") {
1183
- const l = o.getAnnotation(d);
1184
- if (o.deleteAnnotation(d), l)
1185
- return n ? n.serialize(l) : l;
1178
+ var u;
1179
+ const c = (((u = i.selected) == null ? void 0 : u.map((v) => v.id)) || []).map((v) => o.getAnnotation(v)).filter(Boolean);
1180
+ return n ? c.map(n.serialize) : c;
1181
+ }, l = (u, c = !0) => fetch(u).then((v) => v.json()).then((v) => (d(v, c), v)), g = (u) => {
1182
+ if (typeof u == "string") {
1183
+ const c = o.getAnnotation(u);
1184
+ if (o.deleteAnnotation(u), c)
1185
+ return n ? n.serialize(c) : c;
1186
1186
  } else {
1187
- const l = n ? n.parse(d).parsed : d;
1188
- if (l)
1189
- return o.deleteAnnotation(l), d;
1187
+ const c = n ? n.parse(u).parsed : u;
1188
+ if (c)
1189
+ return o.deleteAnnotation(c), u;
1190
1190
  }
1191
- }, f = (d, l = !0) => {
1191
+ }, d = (u, c = !0) => {
1192
1192
  if (n) {
1193
- const { parsed: g, failed: x } = Vn(n)(d);
1194
- x.length > 0 && console.warn(`Discarded ${x.length} invalid annotations`, x), o.bulkAddAnnotation(g, l, R.REMOTE);
1193
+ const { parsed: v, failed: x } = Vn(n)(u);
1194
+ x.length > 0 && console.warn(`Discarded ${x.length} invalid annotations`, x), o.bulkAddAnnotation(v, c, R.REMOTE);
1195
1195
  } else
1196
- o.bulkAddAnnotation(d, l, R.REMOTE);
1197
- }, v = (d, l) => {
1198
- d ? i.setSelected(d, l) : i.clear();
1199
- }, b = (d) => {
1200
- i.clear(), i.setUserSelectAction(d);
1201
- }, w = (d) => {
1196
+ o.bulkAddAnnotation(u, c, R.REMOTE);
1197
+ }, A = (u, c) => {
1198
+ u ? i.setSelected(u, c) : i.clear();
1199
+ }, m = (u) => {
1200
+ i.clear(), i.setUserSelectAction(u);
1201
+ }, b = (u) => {
1202
1202
  if (n) {
1203
- const l = n.parse(d).parsed, g = n.serialize(o.getAnnotation(l.id));
1204
- return o.updateAnnotation(l), g;
1203
+ const c = n.parse(u).parsed, v = n.serialize(o.getAnnotation(c.id));
1204
+ return o.updateAnnotation(c), v;
1205
1205
  } else {
1206
- const l = o.getAnnotation(d.id);
1207
- return o.updateAnnotation(d), l;
1206
+ const c = o.getAnnotation(u.id);
1207
+ return o.updateAnnotation(u), c;
1208
1208
  }
1209
1209
  };
1210
1210
  return {
@@ -1213,17 +1213,17 @@ const Mn = 250, Bn = (e) => {
1213
1213
  canRedo: t.canRedo,
1214
1214
  canUndo: t.canUndo,
1215
1215
  clearAnnotations: a,
1216
- getAnnotationById: u,
1216
+ getAnnotationById: f,
1217
1217
  getAnnotations: p,
1218
1218
  getSelected: h,
1219
- loadAnnotations: c,
1219
+ loadAnnotations: l,
1220
1220
  redo: t.redo,
1221
- removeAnnotation: m,
1222
- setAnnotations: f,
1223
- setSelected: v,
1224
- setUserSelectAction: b,
1221
+ removeAnnotation: g,
1222
+ setAnnotations: d,
1223
+ setSelected: A,
1224
+ setUserSelectAction: m,
1225
1225
  undo: t.undo,
1226
- updateAnnotation: w
1226
+ updateAnnotation: b
1227
1227
  };
1228
1228
  }, In = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1229
1229
  let Nn = (e) => crypto.getRandomValues(new Uint8Array(e)), Fn = (e, t, n) => {
@@ -1231,9 +1231,9 @@ let Nn = (e) => crypto.getRandomValues(new Uint8Array(e)), Fn = (e, t, n) => {
1231
1231
  return (r = t) => {
1232
1232
  let s = "";
1233
1233
  for (; ; ) {
1234
- let a = n(i), u = i;
1235
- for (; u--; )
1236
- if (s += e[a[u] & o] || "", s.length === r) return s;
1234
+ let a = n(i), f = i;
1235
+ for (; f--; )
1236
+ if (s += e[a[f] & o] || "", s.length === r) return s;
1237
1237
  }
1238
1238
  };
1239
1239
  }, Pn = (e, t = 21) => Fn(e, t, Nn), Dn = (e = 21) => {
@@ -1251,7 +1251,7 @@ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABC
1251
1251
  }
1252
1252
  return `${n}`;
1253
1253
  }, ce = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Hn = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
1254
- const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: p, ...h } = n;
1254
+ const { id: o, type: i, purpose: r, value: s, created: a, modified: f, creator: p, ...h } = n;
1255
1255
  return {
1256
1256
  id: o || `temp-${Un(n)}`,
1257
1257
  annotation: t,
@@ -1260,7 +1260,7 @@ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABC
1260
1260
  value: s,
1261
1261
  creator: ce(p),
1262
1262
  created: a ? new Date(a) : void 0,
1263
- updated: u ? new Date(u) : void 0,
1263
+ updated: f ? new Date(f) : void 0,
1264
1264
  ...h
1265
1265
  };
1266
1266
  }), _n = (e) => e.map((t) => {
@@ -1294,26 +1294,26 @@ const Lo = (e, t) => ({
1294
1294
  selector: [],
1295
1295
  styleClass: s[0].styleClass
1296
1296
  };
1297
- for (const u of s) {
1298
- const h = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((c, m) => {
1299
- switch (m.type) {
1297
+ for (const f of s) {
1298
+ const h = (Array.isArray(f.selector) ? f.selector : [f.selector]).reduce((l, g) => {
1299
+ switch (g.type) {
1300
1300
  case "TextQuoteSelector":
1301
- c.quote = m.exact;
1301
+ l.quote = g.exact;
1302
1302
  break;
1303
1303
  case "TextPositionSelector":
1304
- c.start = m.start, c.end = m.end;
1304
+ l.start = g.start, l.end = g.end;
1305
1305
  break;
1306
1306
  }
1307
- return c;
1307
+ return l;
1308
1308
  }, {});
1309
1309
  if (Yn(h))
1310
- a.selector.push({ id: u.id, ...h });
1310
+ a.selector.push({ id: f.id, ...h });
1311
1311
  else {
1312
- const c = [
1312
+ const l = [
1313
1313
  h.start ? void 0 : "TextPositionSelector",
1314
1314
  h.quote ? void 0 : "TextQuoteSelector"
1315
1315
  ].filter(Boolean);
1316
- return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${e.id}`) };
1316
+ return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${e.id}`) };
1317
1317
  }
1318
1318
  }
1319
1319
  return { parsed: a };
@@ -1324,38 +1324,38 @@ const Lo = (e, t) => ({
1324
1324
  modified: i,
1325
1325
  body: r,
1326
1326
  ...s
1327
- } = e, a = Hn(r, t), u = Xn(e);
1328
- return "error" in u ? { error: u.error } : {
1327
+ } = e, a = Hn(r, t), f = Xn(e);
1328
+ return "error" in f ? { error: f.error } : {
1329
1329
  parsed: {
1330
1330
  ...s,
1331
1331
  id: t,
1332
1332
  bodies: a,
1333
- target: u.parsed
1333
+ target: f.parsed
1334
1334
  }
1335
1335
  };
1336
1336
  }, jn = (e, t, n) => {
1337
1337
  const { bodies: o, target: i, ...r } = e, {
1338
1338
  selector: s,
1339
1339
  creator: a,
1340
- created: u,
1340
+ created: f,
1341
1341
  updated: p,
1342
1342
  ...h
1343
- } = i, c = s.map((m) => {
1344
- const { quote: f, start: v, end: b, range: w } = m, { prefix: d, suffix: l } = ke(w, n), g = [{
1343
+ } = i, l = s.map((g) => {
1344
+ const { quote: d, start: A, end: m, range: b } = g, { prefix: u, suffix: c } = ke(b, n), v = [{
1345
1345
  type: "TextQuoteSelector",
1346
- exact: f,
1347
- prefix: d,
1348
- suffix: l
1346
+ exact: d,
1347
+ prefix: u,
1348
+ suffix: c
1349
1349
  }, {
1350
1350
  type: "TextPositionSelector",
1351
- start: v,
1352
- end: b
1351
+ start: A,
1352
+ end: m
1353
1353
  }];
1354
1354
  return {
1355
1355
  ...h,
1356
- id: m.id,
1356
+ id: g.id,
1357
1357
  source: t,
1358
- selector: g
1358
+ selector: v
1359
1359
  };
1360
1360
  });
1361
1361
  return {
@@ -1365,9 +1365,9 @@ const Lo = (e, t) => ({
1365
1365
  type: "Annotation",
1366
1366
  body: _n(e.bodies),
1367
1367
  creator: a,
1368
- created: u == null ? void 0 : u.toISOString(),
1368
+ created: f == null ? void 0 : f.toISOString(),
1369
1369
  modified: p == null ? void 0 : p.toISOString(),
1370
- target: c
1370
+ target: l
1371
1371
  };
1372
1372
  };
1373
1373
  function Gn(e, t, n, o, i) {
@@ -1376,15 +1376,15 @@ function Gn(e, t, n, o, i) {
1376
1376
  function de(e, t, n, o, i) {
1377
1377
  for (; o > n; ) {
1378
1378
  if (o - n > 600) {
1379
- var r = o - n + 1, s = t - n + 1, a = Math.log(r), u = 0.5 * Math.exp(2 * a / 3), p = 0.5 * Math.sqrt(a * u * (r - u) / r) * (s - r / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(t - s * u / r + p)), c = Math.min(o, Math.floor(t + (r - s) * u / r + p));
1380
- de(e, t, h, c, i);
1379
+ var r = o - n + 1, s = t - n + 1, a = Math.log(r), f = 0.5 * Math.exp(2 * a / 3), p = 0.5 * Math.sqrt(a * f * (r - f) / r) * (s - r / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(t - s * f / r + p)), l = Math.min(o, Math.floor(t + (r - s) * f / r + p));
1380
+ de(e, t, h, l, i);
1381
1381
  }
1382
- var m = e[t], f = n, v = o;
1383
- for (tt(e, n, t), i(e[o], m) > 0 && tt(e, n, o); f < v; ) {
1384
- for (tt(e, f, v), f++, v--; i(e[f], m) < 0; ) f++;
1385
- for (; i(e[v], m) > 0; ) v--;
1382
+ var g = e[t], d = n, A = o;
1383
+ for (tt(e, n, t), i(e[o], g) > 0 && tt(e, n, o); d < A; ) {
1384
+ for (tt(e, d, A), d++, A--; i(e[d], g) < 0; ) d++;
1385
+ for (; i(e[A], g) > 0; ) A--;
1386
1386
  }
1387
- i(e[n], m) === 0 ? tt(e, n, v) : (v++, tt(e, v, o)), v <= t && (n = v + 1), t <= v && (o = v - 1);
1387
+ i(e[n], g) === 0 ? tt(e, n, A) : (A++, tt(e, A, o)), A <= t && (n = A + 1), t <= A && (o = A - 1);
1388
1388
  }
1389
1389
  }
1390
1390
  function tt(e, t, n) {
@@ -1408,8 +1408,8 @@ class zn {
1408
1408
  const i = this.toBBox, r = [];
1409
1409
  for (; n; ) {
1410
1410
  for (let s = 0; s < n.children.length; s++) {
1411
- const a = n.children[s], u = n.leaf ? i(a) : a;
1412
- pt(t, u) && (n.leaf ? o.push(a) : Et(t, u) ? this._all(a, o) : r.push(a));
1411
+ const a = n.children[s], f = n.leaf ? i(a) : a;
1412
+ pt(t, f) && (n.leaf ? o.push(a) : Tt(t, f) ? this._all(a, o) : r.push(a));
1413
1413
  }
1414
1414
  n = r.pop();
1415
1415
  }
@@ -1423,7 +1423,7 @@ class zn {
1423
1423
  for (let i = 0; i < n.children.length; i++) {
1424
1424
  const r = n.children[i], s = n.leaf ? this.toBBox(r) : r;
1425
1425
  if (pt(t, s)) {
1426
- if (n.leaf || Et(t, s)) return !0;
1426
+ if (n.leaf || Tt(t, s)) return !0;
1427
1427
  o.push(r);
1428
1428
  }
1429
1429
  }
@@ -1462,14 +1462,14 @@ class zn {
1462
1462
  if (!t) return this;
1463
1463
  let o = this.data;
1464
1464
  const i = this.toBBox(t), r = [], s = [];
1465
- let a, u, p;
1465
+ let a, f, p;
1466
1466
  for (; o || r.length; ) {
1467
- if (o || (o = r.pop(), u = r[r.length - 1], a = s.pop(), p = !0), o.leaf) {
1467
+ if (o || (o = r.pop(), f = r[r.length - 1], a = s.pop(), p = !0), o.leaf) {
1468
1468
  const h = qn(t, o.children, n);
1469
1469
  if (h !== -1)
1470
1470
  return o.children.splice(h, 1), r.push(o), this._condense(r), this;
1471
1471
  }
1472
- !p && !o.leaf && Et(o, i) ? (r.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], p = !1) : o = null;
1472
+ !p && !o.leaf && Tt(o, i) ? (r.push(o), s.push(a), a = 0, f = o, o = o.children[0]) : f ? (a++, o = f.children[a], p = !1) : o = null;
1473
1473
  }
1474
1474
  return this;
1475
1475
  }
@@ -1500,14 +1500,14 @@ class zn {
1500
1500
  if (r <= s)
1501
1501
  return a = Q(t.slice(n, o + 1)), J(a, this.toBBox), a;
1502
1502
  i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = Q([]), a.leaf = !1, a.height = i;
1503
- const u = Math.ceil(r / s), p = u * Math.ceil(Math.sqrt(s));
1503
+ const f = Math.ceil(r / s), p = f * Math.ceil(Math.sqrt(s));
1504
1504
  Qt(t, n, o, p, this.compareMinX);
1505
1505
  for (let h = n; h <= o; h += p) {
1506
- const c = Math.min(h + p - 1, o);
1507
- Qt(t, h, c, u, this.compareMinY);
1508
- for (let m = h; m <= c; m += u) {
1509
- const f = Math.min(m + u - 1, c);
1510
- a.children.push(this._build(t, m, f, i - 1));
1506
+ const l = Math.min(h + p - 1, o);
1507
+ Qt(t, h, l, f, this.compareMinY);
1508
+ for (let g = h; g <= l; g += f) {
1509
+ const d = Math.min(g + f - 1, l);
1510
+ a.children.push(this._build(t, g, d, i - 1));
1511
1511
  }
1512
1512
  }
1513
1513
  return J(a, this.toBBox), a;
@@ -1515,9 +1515,9 @@ class zn {
1515
1515
  _chooseSubtree(t, n, o, i) {
1516
1516
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1517
1517
  let r = 1 / 0, s = 1 / 0, a;
1518
- for (let u = 0; u < n.children.length; u++) {
1519
- const p = n.children[u], h = Tt(p), c = Qn(t, p) - h;
1520
- c < s ? (s = c, r = h < r ? h : r, a = p) : c === s && h < r && (r = h, a = p);
1518
+ for (let f = 0; f < n.children.length; f++) {
1519
+ const p = n.children[f], h = Et(p), l = Qn(t, p) - h;
1520
+ l < s ? (s = l, r = h < r ? h : r, a = p) : l === s && h < r && (r = h, a = p);
1521
1521
  }
1522
1522
  n = a || n.children[0];
1523
1523
  }
@@ -1542,8 +1542,8 @@ class zn {
1542
1542
  _chooseSplitIndex(t, n, o) {
1543
1543
  let i, r = 1 / 0, s = 1 / 0;
1544
1544
  for (let a = n; a <= o - n; a++) {
1545
- const u = nt(t, 0, a, this.toBBox), p = nt(t, a, o, this.toBBox), h = Kn(u, p), c = Tt(u) + Tt(p);
1546
- h < r ? (r = h, i = a, s = c < s ? c : s) : h === r && c < s && (s = c, i = a);
1545
+ const f = nt(t, 0, a, this.toBBox), p = nt(t, a, o, this.toBBox), h = Kn(f, p), l = Et(f) + Et(p);
1546
+ h < r ? (r = h, i = a, s = l < s ? l : s) : h === r && l < s && (s = l, i = a);
1547
1547
  }
1548
1548
  return i || o - n;
1549
1549
  }
@@ -1556,16 +1556,16 @@ class zn {
1556
1556
  _allDistMargin(t, n, o, i) {
1557
1557
  t.children.sort(i);
1558
1558
  const r = this.toBBox, s = nt(t, 0, n, r), a = nt(t, o - n, o, r);
1559
- let u = ft(s) + ft(a);
1559
+ let f = ft(s) + ft(a);
1560
1560
  for (let p = n; p < o - n; p++) {
1561
1561
  const h = t.children[p];
1562
- ot(s, t.leaf ? r(h) : h), u += ft(s);
1562
+ ot(s, t.leaf ? r(h) : h), f += ft(s);
1563
1563
  }
1564
1564
  for (let p = o - n - 1; p >= n; p--) {
1565
1565
  const h = t.children[p];
1566
- ot(a, t.leaf ? r(h) : h), u += ft(a);
1566
+ ot(a, t.leaf ? r(h) : h), f += ft(a);
1567
1567
  }
1568
- return u;
1568
+ return f;
1569
1569
  }
1570
1570
  _adjustParentBBoxes(t, n, o) {
1571
1571
  for (let i = o; i >= 0; i--)
@@ -1602,7 +1602,7 @@ function Zn(e, t) {
1602
1602
  function Jn(e, t) {
1603
1603
  return e.minY - t.minY;
1604
1604
  }
1605
- function Tt(e) {
1605
+ function Et(e) {
1606
1606
  return (e.maxX - e.minX) * (e.maxY - e.minY);
1607
1607
  }
1608
1608
  function ft(e) {
@@ -1615,7 +1615,7 @@ function Kn(e, t) {
1615
1615
  const n = Math.max(e.minX, t.minX), o = Math.max(e.minY, t.minY), i = Math.min(e.maxX, t.maxX), r = Math.min(e.maxY, t.maxY);
1616
1616
  return Math.max(0, i - n) * Math.max(0, r - o);
1617
1617
  }
1618
- function Et(e, t) {
1618
+ function Tt(e, t) {
1619
1619
  return e.minX <= t.minX && e.minY <= t.minY && t.maxX <= e.maxX && t.maxY <= e.maxY;
1620
1620
  }
1621
1621
  function pt(e, t) {
@@ -1641,128 +1641,128 @@ function Qt(e, t, n, o, i) {
1641
1641
  }
1642
1642
  }
1643
1643
  const to = (e, t) => {
1644
- const n = new zn(), o = /* @__PURE__ */ new Map(), i = (d, l) => {
1645
- const g = d.selector.flatMap((T) => {
1646
- const E = W([T]) ? T.range : oe(T, t).range;
1647
- return Array.from(E.getClientRects());
1648
- }), x = Ne(g).map((T) => Pe(T, l));
1649
- return x.map((T) => {
1650
- const { x: E, y: M, width: B, height: N } = T;
1644
+ const n = new zn(), o = /* @__PURE__ */ new Map(), i = (u, c) => {
1645
+ const v = u.selector.flatMap((L) => {
1646
+ const T = W([L]) ? L.range : oe(L, t).range;
1647
+ return Array.from(T.getClientRects());
1648
+ }), x = Ne(v).map((L) => Pe(L, c));
1649
+ return x.map((L) => {
1650
+ const { x: T, y: k, width: M, height: y } = L;
1651
1651
  return {
1652
- minX: E,
1653
- minY: M,
1654
- maxX: E + B,
1655
- maxY: M + N,
1652
+ minX: T,
1653
+ minY: k,
1654
+ maxX: T + M,
1655
+ maxY: k + y,
1656
1656
  annotation: {
1657
- id: d.annotation,
1657
+ id: u.annotation,
1658
1658
  rects: x
1659
1659
  }
1660
1660
  };
1661
1661
  });
1662
1662
  }, r = () => [...o.values()], s = () => {
1663
1663
  n.clear(), o.clear();
1664
- }, a = (d) => {
1665
- const l = i(d, t.getBoundingClientRect());
1666
- l.forEach((g) => n.insert(g)), o.set(d.annotation, l);
1667
- }, u = (d) => {
1668
- const l = o.get(d.annotation);
1669
- l && (l.forEach((g) => n.remove(g)), o.delete(d.annotation));
1670
- }, p = (d) => {
1671
- u(d), a(d);
1672
- }, h = (d, l = !0) => {
1673
- l && s();
1674
- const g = t.getBoundingClientRect(), x = d.map((E) => ({ target: E, rects: i(E, g) }));
1675
- x.forEach(({ target: E, rects: M }) => o.set(E.annotation, M));
1676
- const T = x.flatMap(({ rects: E }) => E);
1677
- n.load(T);
1678
- }, c = (d, l, g = !1) => {
1664
+ }, a = (u) => {
1665
+ const c = i(u, t.getBoundingClientRect());
1666
+ c.forEach((v) => n.insert(v)), o.set(u.annotation, c);
1667
+ }, f = (u) => {
1668
+ const c = o.get(u.annotation);
1669
+ c && (c.forEach((v) => n.remove(v)), o.delete(u.annotation));
1670
+ }, p = (u) => {
1671
+ f(u), a(u);
1672
+ }, h = (u, c = !0) => {
1673
+ c && s();
1674
+ const v = t.getBoundingClientRect(), x = u.map((T) => ({ target: T, rects: i(T, v) }));
1675
+ x.forEach(({ target: T, rects: k }) => o.set(T.annotation, k));
1676
+ const L = x.flatMap(({ rects: T }) => T);
1677
+ n.load(L);
1678
+ }, l = (u, c, v = !1) => {
1679
1679
  const x = n.search({
1680
- minX: d,
1681
- minY: l,
1682
- maxX: d,
1683
- maxY: l
1684
- }), T = (E) => E.annotation.rects.reduce((M, B) => M + B.width * B.height, 0);
1685
- return x.length > 0 ? (x.sort((E, M) => T(E) - T(M)), g ? x.map((E) => E.annotation.id) : [x[0].annotation.id]) : [];
1686
- }, m = (d) => {
1687
- const l = f(d);
1688
- if (l.length === 0)
1680
+ minX: u,
1681
+ minY: c,
1682
+ maxX: u,
1683
+ maxY: c
1684
+ }), L = (T) => T.annotation.rects.reduce((k, M) => k + M.width * M.height, 0);
1685
+ return x.length > 0 ? (x.sort((T, k) => L(T) - L(k)), v ? x.map((T) => T.annotation.id) : [x[0].annotation.id]) : [];
1686
+ }, g = (u) => {
1687
+ const c = d(u);
1688
+ if (c.length === 0)
1689
1689
  return;
1690
- let g = l[0].left, x = l[0].top, T = l[0].right, E = l[0].bottom;
1691
- for (let M = 1; M < l.length; M++) {
1692
- const B = l[M];
1693
- g = Math.min(g, B.left), x = Math.min(x, B.top), T = Math.max(T, B.right), E = Math.max(E, B.bottom);
1690
+ let v = c[0].left, x = c[0].top, L = c[0].right, T = c[0].bottom;
1691
+ for (let k = 1; k < c.length; k++) {
1692
+ const M = c[k];
1693
+ v = Math.min(v, M.left), x = Math.min(x, M.top), L = Math.max(L, M.right), T = Math.max(T, M.bottom);
1694
1694
  }
1695
- return new DOMRect(g, x, T - g, E - x);
1696
- }, f = (d) => {
1697
- const l = o.get(d);
1698
- return l ? l[0].annotation.rects : [];
1695
+ return new DOMRect(v, x, L - v, T - x);
1696
+ }, d = (u) => {
1697
+ const c = o.get(u);
1698
+ return c ? c[0].annotation.rects : [];
1699
1699
  };
1700
1700
  return {
1701
1701
  all: r,
1702
1702
  clear: s,
1703
- getAt: c,
1704
- getAnnotationBounds: m,
1705
- getAnnotationRects: f,
1706
- getIntersecting: (d, l, g, x) => {
1707
- const T = n.search({ minX: d, minY: l, maxX: g, maxY: x }), E = new Set(T.map((M) => M.annotation.id));
1708
- return Array.from(E).map((M) => ({
1709
- annotation: e.getAnnotation(M),
1710
- rects: f(M)
1711
- })).filter((M) => !!M.annotation);
1703
+ getAt: l,
1704
+ getAnnotationBounds: g,
1705
+ getAnnotationRects: d,
1706
+ getIntersecting: (u, c, v, x) => {
1707
+ const L = n.search({ minX: u, minY: c, maxX: v, maxY: x }), T = new Set(L.map((k) => k.annotation.id));
1708
+ return Array.from(T).map((k) => ({
1709
+ annotation: e.getAnnotation(k),
1710
+ rects: d(k)
1711
+ })).filter((k) => !!k.annotation);
1712
1712
  },
1713
1713
  insert: a,
1714
- recalculate: () => h(e.all().map((d) => d.target), !0),
1715
- remove: u,
1714
+ recalculate: () => h(e.all().map((u) => u.target), !0),
1715
+ remove: f,
1716
1716
  set: h,
1717
1717
  size: () => n.all().length,
1718
1718
  update: p
1719
1719
  };
1720
1720
  }, eo = (e, t) => {
1721
- const n = Tn(), o = to(n, e), i = fn(n, t), r = dn(n), s = kn(), a = (b, w = R.LOCAL) => {
1722
- const d = bt(b, e), l = W(d.target.selector);
1723
- return l && n.addAnnotation(d, w), l;
1724
- }, u = (b, w = !0, d = R.LOCAL) => {
1725
- const l = b.map((x) => bt(x, e)), g = l.filter((x) => !W(x.target.selector));
1726
- return g.length > 0 ? (console.warn("Could not revive all targets for these annotations:", g), n.bulkAddAnnotation(l, w, d), g) : (n.bulkAddAnnotation(l, w, d), []);
1727
- }, p = (b, w = R.LOCAL) => {
1728
- const d = b.map((g) => bt(g, e)), l = d.filter((g) => !W(g.target.selector));
1729
- return l.length > 0 && console.warn("Could not revive all targets for these annotations:", l), d.forEach((g) => {
1730
- n.getAnnotation(g.id) ? n.updateAnnotation(g, w) : n.addAnnotation(g, w);
1731
- }), l;
1732
- }, h = (b, w = R.LOCAL) => {
1733
- const d = mt(b, e);
1734
- n.updateTarget(d, w);
1735
- }, c = (b, w = R.LOCAL) => {
1736
- const d = b.map((l) => mt(l, e));
1737
- n.bulkUpdateTargets(d, w);
1738
- }, m = (b, w, d) => {
1739
- const l = o.getAt(b, w, !!d).map((x) => n.getAnnotation(x)), g = d ? l.filter(d) : l;
1740
- return g.length > 0 ? g[0] : void 0;
1741
- }, f = (b, w, d, l = 5) => {
1742
- const g = o.getAnnotationRects(b);
1743
- if (g.length !== 0) {
1744
- if (w && d) {
1745
- const x = g.find(({ top: T, right: E, bottom: M, left: B }) => w >= B - l && w <= E + l && d >= T - l && d <= M + l);
1721
+ const n = En(), o = to(n, e), i = fn(n, t), r = dn(n), s = kn(), a = (m, b = R.LOCAL) => {
1722
+ const u = bt(m, e), c = W(u.target.selector);
1723
+ return c && n.addAnnotation(u, b), c;
1724
+ }, f = (m, b = !0, u = R.LOCAL) => {
1725
+ const c = m.map((x) => bt(x, e)), v = c.filter((x) => !W(x.target.selector));
1726
+ return v.length > 0 ? (console.warn("Could not revive all targets for these annotations:", v), n.bulkAddAnnotation(c, b, u), v) : (n.bulkAddAnnotation(c, b, u), []);
1727
+ }, p = (m, b = R.LOCAL) => {
1728
+ const u = m.map((v) => bt(v, e)), c = u.filter((v) => !W(v.target.selector));
1729
+ return c.length > 0 && console.warn("Could not revive all targets for these annotations:", c), u.forEach((v) => {
1730
+ n.getAnnotation(v.id) ? n.updateAnnotation(v, b) : n.addAnnotation(v, b);
1731
+ }), c;
1732
+ }, h = (m, b = R.LOCAL) => {
1733
+ const u = mt(m, e);
1734
+ n.updateTarget(u, b);
1735
+ }, l = (m, b = R.LOCAL) => {
1736
+ const u = m.map((c) => mt(c, e));
1737
+ n.bulkUpdateTargets(u, b);
1738
+ }, g = (m, b, u) => {
1739
+ const c = o.getAt(m, b, !!u).map((x) => n.getAnnotation(x)), v = u ? c.filter(u) : c;
1740
+ return v.length > 0 ? v[0] : void 0;
1741
+ }, d = (m, b, u, c = 5) => {
1742
+ const v = o.getAnnotationRects(m);
1743
+ if (v.length !== 0) {
1744
+ if (b && u) {
1745
+ const x = v.find(({ top: L, right: T, bottom: k, left: M }) => b >= M - c && b <= T + c && u >= L - c && u <= k + c);
1746
1746
  if (x) return x;
1747
1747
  }
1748
- return o.getAnnotationBounds(b);
1748
+ return o.getAnnotationBounds(m);
1749
1749
  }
1750
- }, v = () => o.recalculate();
1751
- return n.observe(({ changes: b }) => {
1752
- const w = (b.deleted || []).filter((g) => W(g.target.selector)), d = (b.created || []).filter((g) => W(g.target.selector)), l = (b.updated || []).filter((g) => W(g.newValue.target.selector));
1753
- (w == null ? void 0 : w.length) > 0 && w.forEach((g) => o.remove(g.target)), d.length > 0 && o.set(d.map((g) => g.target), !1), (l == null ? void 0 : l.length) > 0 && l.forEach(({ newValue: g }) => o.update(g.target));
1750
+ }, A = () => o.recalculate();
1751
+ return n.observe(({ changes: m }) => {
1752
+ const b = (m.deleted || []).filter((v) => W(v.target.selector)), u = (m.created || []).filter((v) => W(v.target.selector)), c = (m.updated || []).filter((v) => W(v.newValue.target.selector));
1753
+ (b == null ? void 0 : b.length) > 0 && b.forEach((v) => o.remove(v.target)), u.length > 0 && o.set(u.map((v) => v.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: v }) => o.update(v.target));
1754
1754
  }), {
1755
1755
  store: {
1756
1756
  ...n,
1757
1757
  addAnnotation: a,
1758
- bulkAddAnnotation: u,
1759
- bulkUpdateTargets: c,
1758
+ bulkAddAnnotation: f,
1759
+ bulkUpdateTargets: l,
1760
1760
  bulkUpsertAnnotations: p,
1761
- getAnnotationBounds: f,
1762
- getAt: m,
1761
+ getAnnotationBounds: d,
1762
+ getAt: g,
1763
1763
  getIntersecting: o.getIntersecting.bind(o),
1764
1764
  getAnnotationRects: o.getAnnotationRects.bind(o),
1765
- recalculatePositions: v,
1765
+ recalculatePositions: A,
1766
1766
  updateTarget: h
1767
1767
  },
1768
1768
  selection: i,
@@ -1777,34 +1777,34 @@ const to = (e, t) => {
1777
1777
  }, oo = (e, t, n = {}) => {
1778
1778
  const o = no(), i = o.getContext("2d");
1779
1779
  document.body.appendChild(o);
1780
- const r = /* @__PURE__ */ new Map(), s = (c) => Array.from(r.entries()).filter(([m, f]) => f.presenceKey === c.presenceKey).map(([m, f]) => m);
1781
- return t.on("selectionChange", (c, m) => {
1782
- s(c).forEach((v) => r.delete(v)), m && m.forEach((v) => r.set(v, c));
1780
+ const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([g, d]) => d.presenceKey === l.presenceKey).map(([g, d]) => g);
1781
+ return t.on("selectionChange", (l, g) => {
1782
+ s(l).forEach((A) => r.delete(A)), g && g.forEach((A) => r.set(A, l));
1783
1783
  }), {
1784
1784
  clear: () => {
1785
- const { width: c, height: m } = o;
1786
- i.clearRect(-0.5, -0.5, c + 1, m + 1);
1785
+ const { width: l, height: g } = o;
1786
+ i.clearRect(-0.5, -0.5, l + 1, g + 1);
1787
1787
  },
1788
1788
  destroy: () => {
1789
1789
  o.remove();
1790
1790
  },
1791
- paint: (c, m, f) => {
1791
+ paint: (l, g, d) => {
1792
1792
  n.font && (i.font = n.font);
1793
- const v = r.get(c.annotation.id);
1794
- if (v) {
1795
- const { height: b } = c.rects[0], w = c.rects[0].x + m.left, d = c.rects[0].y + m.top;
1796
- i.fillStyle = v.appearance.color, i.fillRect(w - 2, d - 2.5, 2, b + 5);
1797
- const l = i.measureText(v.appearance.label), g = l.width + 6, x = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, T = l.fontBoundingBoxAscent ? 8 : 6.5;
1798
- return i.fillRect(w - 2, d - 2.5 - x, g, x), i.fillStyle = "#fff", i.fillText(v.appearance.label, w + 1, d - T), {
1799
- fill: v.appearance.color,
1800
- fillOpacity: f ? 0.45 : 0.18
1793
+ const A = r.get(l.annotation.id);
1794
+ if (A) {
1795
+ const { height: m } = l.rects[0], b = l.rects[0].x + g.left, u = l.rects[0].y + g.top;
1796
+ i.fillStyle = A.appearance.color, i.fillRect(b - 2, u - 2.5, 2, m + 5);
1797
+ const c = i.measureText(A.appearance.label), v = c.width + 6, x = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;
1798
+ return i.fillRect(b - 2, u - 2.5 - x, v, x), i.fillStyle = "#fff", i.fillText(A.appearance.label, b + 1, u - L), {
1799
+ fill: A.appearance.color,
1800
+ fillOpacity: d ? 0.45 : 0.18
1801
1801
  };
1802
1802
  }
1803
1803
  },
1804
1804
  reset: () => {
1805
1805
  o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
1806
- const c = o.getContext("2d");
1807
- c.scale(2, 2), c.translate(0.5, 0.5);
1806
+ const l = o.getContext("2d");
1807
+ l.scale(2, 2), l.translate(0.5, 0.5);
1808
1808
  }
1809
1809
  };
1810
1810
  }, ue = (e) => {
@@ -1814,17 +1814,17 @@ const to = (e, t) => {
1814
1814
  return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e : ue(e.parentElement);
1815
1815
  }, io = (e, t) => (n) => {
1816
1816
  const o = typeof n == "string" ? n : n.id, i = (s) => {
1817
- const a = r.getBoundingClientRect(), u = r.clientHeight, p = r.clientWidth, h = s.selector[0].range.getBoundingClientRect(), { width: c, height: m } = t.getAnnotationBounds(o), f = h.top - a.top, v = h.left - a.left, b = r.parentElement ? r.scrollTop : 0, w = r.parentElement ? r.scrollLeft : 0, d = f + b - (u - m) / 2, l = v + w - (p - c) / 2;
1818
- r.scroll({ top: d, left: l, behavior: "smooth" });
1817
+ const a = r.getBoundingClientRect(), f = r.clientHeight, p = r.clientWidth, h = s.selector[0].range.getBoundingClientRect(), { width: l, height: g } = t.getAnnotationBounds(o), d = h.top - a.top, A = h.left - a.left, m = r.parentElement ? r.scrollTop : 0, b = r.parentElement ? r.scrollLeft : 0, u = d + m - (f - g) / 2, c = A + b - (p - l) / 2;
1818
+ r.scroll({ top: u, left: c, behavior: "smooth" });
1819
1819
  }, r = ue(e);
1820
1820
  if (r) {
1821
1821
  const s = t.getAnnotation(o), { range: a } = s.target.selector[0];
1822
1822
  if (a && !a.collapsed)
1823
1823
  return i(s.target), !0;
1824
1824
  {
1825
- const u = mt(s.target, e), { range: p } = u.selector[0];
1825
+ const f = mt(s.target, e), { range: p } = f.selector[0];
1826
1826
  if (p && !p.collapsed)
1827
- return i(u), !0;
1827
+ return i(f), !0;
1828
1828
  }
1829
1829
  }
1830
1830
  return !1;
@@ -1936,7 +1936,7 @@ const at = {
1936
1936
  ctrlKey: 17,
1937
1937
  altKey: 18,
1938
1938
  metaKey: 91
1939
- }, y = {
1939
+ }, D = {
1940
1940
  16: !1,
1941
1941
  18: !1,
1942
1942
  17: !1,
@@ -2005,8 +2005,8 @@ function go(e, t) {
2005
2005
  function mo(e) {
2006
2006
  let t = e.keyCode || e.which || e.charCode;
2007
2007
  const n = V.indexOf(t);
2008
- if (n >= 0 && V.splice(n, 1), e.key && e.key.toLowerCase() === "meta" && V.splice(0, V.length), (t === 93 || t === 224) && (t = 91), t in y) {
2009
- y[t] = !1;
2008
+ if (n >= 0 && V.splice(n, 1), e.key && e.key.toLowerCase() === "meta" && V.splice(0, V.length), (t === 93 || t === 224) && (t = 91), t in D) {
2009
+ D[t] = !1;
2010
2010
  for (const o in X) X[o] === t && (U[o] = !1);
2011
2011
  }
2012
2012
  }
@@ -2041,14 +2041,14 @@ const ht = (e) => {
2041
2041
  splitKey: i = "+"
2042
2042
  } = e;
2043
2043
  pe(t).forEach((s) => {
2044
- const a = s.split(i), u = a.length, p = a[u - 1], h = p === "*" ? "*" : lt(p);
2044
+ const a = s.split(i), f = a.length, p = a[f - 1], h = p === "*" ? "*" : lt(p);
2045
2045
  if (!O[h]) return;
2046
2046
  n || (n = st());
2047
- const c = u > 1 ? fe(X, a) : [], m = [];
2048
- O[h] = O[h].filter((f) => {
2049
- const b = (o ? f.method === o : !0) && f.scope === n && ao(f.mods, c);
2050
- return b && m.push(f.element), !b;
2051
- }), m.forEach((f) => Pt(f));
2047
+ const l = f > 1 ? fe(X, a) : [], g = [];
2048
+ O[h] = O[h].filter((d) => {
2049
+ const m = (o ? d.method === o : !0) && d.scope === n && ao(d.mods, l);
2050
+ return m && g.push(d.element), !m;
2051
+ }), g.forEach((d) => Pt(d));
2052
2052
  });
2053
2053
  };
2054
2054
  function Kt(e, t, n, o) {
@@ -2057,9 +2057,9 @@ function Kt(e, t, n, o) {
2057
2057
  let i;
2058
2058
  if (t.scope === n || t.scope === "all") {
2059
2059
  i = t.mods.length > 0;
2060
- for (const r in y)
2061
- Object.prototype.hasOwnProperty.call(y, r) && (!y[r] && t.mods.indexOf(+r) > -1 || y[r] && t.mods.indexOf(+r) === -1) && (i = !1);
2062
- (t.mods.length === 0 && !y[16] && !y[18] && !y[17] && !y[91] || i || t.shortcut === "*") && (t.keys = [], t.keys = t.keys.concat(V), t.method(e, t) === !1 && (e.preventDefault ? e.preventDefault() : e.returnValue = !1, e.stopPropagation && e.stopPropagation(), e.cancelBubble && (e.cancelBubble = !0)));
2060
+ for (const r in D)
2061
+ Object.prototype.hasOwnProperty.call(D, r) && (!D[r] && t.mods.indexOf(+r) > -1 || D[r] && t.mods.indexOf(+r) === -1) && (i = !1);
2062
+ (t.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || t.shortcut === "*") && (t.keys = [], t.keys = t.keys.concat(V), t.method(e, t) === !1 && (e.preventDefault ? e.preventDefault() : e.returnValue = !1, e.stopPropagation && e.stopPropagation(), e.cancelBubble && (e.cancelBubble = !0)));
2063
2063
  }
2064
2064
  }
2065
2065
  function te(e, t) {
@@ -2067,17 +2067,17 @@ function te(e, t) {
2067
2067
  let o = e.keyCode || e.which || e.charCode;
2068
2068
  if (!U.filter.call(this, e)) return;
2069
2069
  if ((o === 93 || o === 224) && (o = 91), V.indexOf(o) === -1 && o !== 229 && V.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
2070
- const u = Ot[a];
2071
- e[a] && V.indexOf(u) === -1 ? V.push(u) : !e[a] && V.indexOf(u) > -1 ? V.splice(V.indexOf(u), 1) : a === "metaKey" && e[a] && V.length === 3 && (e.ctrlKey || e.shiftKey || e.altKey || (V = V.slice(V.indexOf(u))));
2072
- }), o in y) {
2073
- y[o] = !0;
2070
+ const f = Ot[a];
2071
+ e[a] && V.indexOf(f) === -1 ? V.push(f) : !e[a] && V.indexOf(f) > -1 ? V.splice(V.indexOf(f), 1) : a === "metaKey" && e[a] && V.length === 3 && (e.ctrlKey || e.shiftKey || e.altKey || (V = V.slice(V.indexOf(f))));
2072
+ }), o in D) {
2073
+ D[o] = !0;
2074
2074
  for (const a in X)
2075
2075
  X[a] === o && (U[a] = !0);
2076
2076
  if (!n) return;
2077
2077
  }
2078
- for (const a in y)
2079
- Object.prototype.hasOwnProperty.call(y, a) && (y[a] = e[Ot[a]]);
2080
- e.getModifierState && !(e.altKey && !e.ctrlKey) && e.getModifierState("AltGraph") && (V.indexOf(17) === -1 && V.push(17), V.indexOf(18) === -1 && V.push(18), y[17] = !0, y[18] = !0);
2078
+ for (const a in D)
2079
+ Object.prototype.hasOwnProperty.call(D, a) && (D[a] = e[Ot[a]]);
2080
+ e.getModifierState && !(e.altKey && !e.ctrlKey) && e.getModifierState("AltGraph") && (V.indexOf(17) === -1 && V.push(17), V.indexOf(18) === -1 && V.push(18), D[17] = !0, D[18] = !0);
2081
2081
  const i = st();
2082
2082
  if (n)
2083
2083
  for (let a = 0; a < n.length; a++)
@@ -2086,21 +2086,21 @@ function te(e, t) {
2086
2086
  const r = O[o], s = r.length;
2087
2087
  for (let a = 0; a < s; a++)
2088
2088
  if ((e.type === "keydown" && r[a].keydown || e.type === "keyup" && r[a].keyup) && r[a].key) {
2089
- const u = r[a], {
2089
+ const f = r[a], {
2090
2090
  splitKey: p
2091
- } = u, h = u.key.split(p), c = [];
2092
- for (let m = 0; m < h.length; m++)
2093
- c.push(lt(h[m]));
2094
- c.sort().join("") === V.sort().join("") && Kt(e, u, i, t);
2091
+ } = f, h = f.key.split(p), l = [];
2092
+ for (let g = 0; g < h.length; g++)
2093
+ l.push(lt(h[g]));
2094
+ l.sort().join("") === V.sort().join("") && Kt(e, f, i, t);
2095
2095
  }
2096
2096
  }
2097
2097
  function U(e, t, n) {
2098
2098
  V = [];
2099
2099
  const o = pe(e);
2100
- let i = [], r = "all", s = document, a = 0, u = !1, p = !0, h = "+", c = !1, m = !1;
2101
- for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (u = t.keyup), t.keydown !== void 0 && (p = t.keydown), t.capture !== void 0 && (c = t.capture), typeof t.splitKey == "string" && (h = t.splitKey), t.single === !0 && (m = !0)), typeof t == "string" && (r = t), m && me(e, r); a < o.length; a++)
2100
+ let i = [], r = "all", s = document, a = 0, f = !1, p = !0, h = "+", l = !1, g = !1;
2101
+ for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (f = t.keyup), t.keydown !== void 0 && (p = t.keydown), t.capture !== void 0 && (l = t.capture), typeof t.splitKey == "string" && (h = t.splitKey), t.single === !0 && (g = !0)), typeof t == "string" && (r = t), g && me(e, r); a < o.length; a++)
2102
2102
  e = o[a].split(h), i = [], e.length > 1 && (i = fe(X, e)), e = e[e.length - 1], e = e === "*" ? "*" : lt(e), e in O || (O[e] = []), O[e].push({
2103
- keyup: u,
2103
+ keyup: f,
2104
2104
  keydown: p,
2105
2105
  scope: r,
2106
2106
  mods: i,
@@ -2112,27 +2112,27 @@ function U(e, t, n) {
2112
2112
  });
2113
2113
  if (typeof s < "u" && window) {
2114
2114
  if (!G.has(s)) {
2115
- const f = function() {
2116
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2117
- return te(b, s);
2118
- }, v = function() {
2119
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2120
- te(b, s), mo(b);
2115
+ const d = function() {
2116
+ let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2117
+ return te(m, s);
2118
+ }, A = function() {
2119
+ let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2120
+ te(m, s), mo(m);
2121
2121
  };
2122
2122
  G.set(s, {
2123
- keydownListener: f,
2124
- keyupListenr: v,
2125
- capture: c
2126
- }), Bt(s, "keydown", f, c), Bt(s, "keyup", v, c);
2123
+ keydownListener: d,
2124
+ keyupListenr: A,
2125
+ capture: l
2126
+ }), Bt(s, "keydown", d, l), Bt(s, "keyup", A, l);
2127
2127
  }
2128
2128
  if (!rt) {
2129
- const f = () => {
2129
+ const d = () => {
2130
2130
  V = [];
2131
2131
  };
2132
2132
  rt = {
2133
- listener: f,
2134
- capture: c
2135
- }, Bt(window, "focus", f, c);
2133
+ listener: d,
2134
+ capture: l
2135
+ }, Bt(window, "focus", d, l);
2136
2136
  }
2137
2137
  }
2138
2138
  }
@@ -2201,122 +2201,129 @@ var be = {};
2201
2201
  t.Unidentified = "Unidentified", t.Alt = "Alt", t.AltGraph = "AltGraph", t.CapsLock = "CapsLock", t.Control = "Control", t.Fn = "Fn", t.FnLock = "FnLock", t.Hyper = "Hyper", t.Meta = "Meta", t.NumLock = "NumLock", t.ScrollLock = "ScrollLock", t.Shift = "Shift", t.Super = "Super", t.Symbol = "Symbol", t.SymbolLock = "SymbolLock", t.Enter = "Enter", t.Tab = "Tab", t.ArrowDown = "ArrowDown", t.ArrowLeft = "ArrowLeft", t.ArrowRight = "ArrowRight", t.ArrowUp = "ArrowUp", t.End = "End", t.Home = "Home", t.PageDown = "PageDown", t.PageUp = "PageUp", t.Backspace = "Backspace", t.Clear = "Clear", t.Copy = "Copy", t.CrSel = "CrSel", t.Cut = "Cut", t.Delete = "Delete", t.EraseEof = "EraseEof", t.ExSel = "ExSel", t.Insert = "Insert", t.Paste = "Paste", t.Redo = "Redo", t.Undo = "Undo", t.Accept = "Accept", t.Again = "Again", t.Attn = "Attn", t.Cancel = "Cancel", t.ContextMenu = "ContextMenu", t.Escape = "Escape", t.Execute = "Execute", t.Find = "Find", t.Finish = "Finish", t.Help = "Help", t.Pause = "Pause", t.Play = "Play", t.Props = "Props", t.Select = "Select", t.ZoomIn = "ZoomIn", t.ZoomOut = "ZoomOut", t.BrightnessDown = "BrightnessDown", t.BrightnessUp = "BrightnessUp", t.Eject = "Eject", t.LogOff = "LogOff", t.Power = "Power", t.PowerOff = "PowerOff", t.PrintScreen = "PrintScreen", t.Hibernate = "Hibernate", t.Standby = "Standby", t.WakeUp = "WakeUp", t.AllCandidates = "AllCandidates", t.Alphanumeric = "Alphanumeric", t.CodeInput = "CodeInput", t.Compose = "Compose", t.Convert = "Convert", t.Dead = "Dead", t.FinalMode = "FinalMode", t.GroupFirst = "GroupFirst", t.GroupLast = "GroupLast", t.GroupNext = "GroupNext", t.GroupPrevious = "GroupPrevious", t.ModeChange = "ModeChange", t.NextCandidate = "NextCandidate", t.NonConvert = "NonConvert", t.PreviousCandidate = "PreviousCandidate", t.Process = "Process", t.SingleCandidate = "SingleCandidate", t.HangulMode = "HangulMode", t.HanjaMode = "HanjaMode", t.JunjaMode = "JunjaMode", t.Eisu = "Eisu", t.Hankaku = "Hankaku", t.Hiragana = "Hiragana", t.HiraganaKatakana = "HiraganaKatakana", t.KanaMode = "KanaMode", t.KanjiMode = "KanjiMode", t.Katakana = "Katakana", t.Romaji = "Romaji", t.Zenkaku = "Zenkaku", t.ZenkakuHanaku = "ZenkakuHanaku", t.F1 = "F1", t.F2 = "F2", t.F3 = "F3", t.F4 = "F4", t.F5 = "F5", t.F6 = "F6", t.F7 = "F7", t.F8 = "F8", t.F9 = "F9", t.F10 = "F10", t.F11 = "F11", t.F12 = "F12", t.F13 = "F13", t.F14 = "F14", t.F15 = "F15", t.F16 = "F16", t.F17 = "F17", t.F18 = "F18", t.F19 = "F19", t.F20 = "F20", t.Soft1 = "Soft1", t.Soft2 = "Soft2", t.Soft3 = "Soft3", t.Soft4 = "Soft4", t.AppSwitch = "AppSwitch", t.Call = "Call", t.Camera = "Camera", t.CameraFocus = "CameraFocus", t.EndCall = "EndCall", t.GoBack = "GoBack", t.GoHome = "GoHome", t.HeadsetHook = "HeadsetHook", t.LastNumberRedial = "LastNumberRedial", t.Notification = "Notification", t.MannerMode = "MannerMode", t.VoiceDial = "VoiceDial", t.ChannelDown = "ChannelDown", t.ChannelUp = "ChannelUp", t.MediaFastForward = "MediaFastForward", t.MediaPause = "MediaPause", t.MediaPlay = "MediaPlay", t.MediaPlayPause = "MediaPlayPause", t.MediaRecord = "MediaRecord", t.MediaRewind = "MediaRewind", t.MediaStop = "MediaStop", t.MediaTrackNext = "MediaTrackNext", t.MediaTrackPrevious = "MediaTrackPrevious", t.AudioBalanceLeft = "AudioBalanceLeft", t.AudioBalanceRight = "AudioBalanceRight", t.AudioBassDown = "AudioBassDown", t.AudioBassBoostDown = "AudioBassBoostDown", t.AudioBassBoostToggle = "AudioBassBoostToggle", t.AudioBassBoostUp = "AudioBassBoostUp", t.AudioBassUp = "AudioBassUp", t.AudioFaderFront = "AudioFaderFront", t.AudioFaderRear = "AudioFaderRear", t.AudioSurroundModeNext = "AudioSurroundModeNext", t.AudioTrebleDown = "AudioTrebleDown", t.AudioTrebleUp = "AudioTrebleUp", t.AudioVolumeDown = "AudioVolumeDown", t.AudioVolumeMute = "AudioVolumeMute", t.AudioVolumeUp = "AudioVolumeUp", t.MicrophoneToggle = "MicrophoneToggle", t.MicrophoneVolumeDown = "MicrophoneVolumeDown", t.MicrophoneVolumeMute = "MicrophoneVolumeMute", t.MicrophoneVolumeUp = "MicrophoneVolumeUp", t.TV = "TV", t.TV3DMode = "TV3DMode", t.TVAntennaCable = "TVAntennaCable", t.TVAudioDescription = "TVAudioDescription", t.TVAudioDescriptionMixDown = "TVAudioDescriptionMixDown", t.TVAudioDescriptionMixUp = "TVAudioDescriptionMixUp", t.TVContentsMenu = "TVContentsMenu", t.TVDataService = "TVDataService", t.TVInput = "TVInput", t.TVInputComponent1 = "TVInputComponent1", t.TVInputComponent2 = "TVInputComponent2", t.TVInputComposite1 = "TVInputComposite1", t.TVInputComposite2 = "TVInputComposite2", t.TVInputHDMI1 = "TVInputHDMI1", t.TVInputHDMI2 = "TVInputHDMI2", t.TVInputHDMI3 = "TVInputHDMI3", t.TVInputHDMI4 = "TVInputHDMI4", t.TVInputVGA1 = "TVInputVGA1", t.TVMediaContext = "TVMediaContext", t.TVNetwork = "TVNetwork", t.TVNumberEntry = "TVNumberEntry", t.TVPower = "TVPower", t.TVRadioService = "TVRadioService", t.TVSatellite = "TVSatellite", t.TVSatelliteBS = "TVSatelliteBS", t.TVSatelliteCS = "TVSatelliteCS", t.TVSatelliteToggle = "TVSatelliteToggle", t.TVTerrestrialAnalog = "TVTerrestrialAnalog", t.TVTerrestrialDigital = "TVTerrestrialDigital", t.TVTimer = "TVTimer", t.AVRInput = "AVRInput", t.AVRPower = "AVRPower", t.ColorF0Red = "ColorF0Red", t.ColorF1Green = "ColorF1Green", t.ColorF2Yellow = "ColorF2Yellow", t.ColorF3Blue = "ColorF3Blue", t.ColorF4Grey = "ColorF4Grey", t.ColorF5Brown = "ColorF5Brown", t.ClosedCaptionToggle = "ClosedCaptionToggle", t.Dimmer = "Dimmer", t.DisplaySwap = "DisplaySwap", t.DVR = "DVR", t.Exit = "Exit", t.FavoriteClear0 = "FavoriteClear0", t.FavoriteClear1 = "FavoriteClear1", t.FavoriteClear2 = "FavoriteClear2", t.FavoriteClear3 = "FavoriteClear3", t.FavoriteRecall0 = "FavoriteRecall0", t.FavoriteRecall1 = "FavoriteRecall1", t.FavoriteRecall2 = "FavoriteRecall2", t.FavoriteRecall3 = "FavoriteRecall3", t.FavoriteStore0 = "FavoriteStore0", t.FavoriteStore1 = "FavoriteStore1", t.FavoriteStore2 = "FavoriteStore2", t.FavoriteStore3 = "FavoriteStore3", t.Guide = "Guide", t.GuideNextDay = "GuideNextDay", t.GuidePreviousDay = "GuidePreviousDay", t.Info = "Info", t.InstantReplay = "InstantReplay", t.Link = "Link", t.ListProgram = "ListProgram", t.LiveContent = "LiveContent", t.Lock = "Lock", t.MediaApps = "MediaApps", t.MediaAudioTrack = "MediaAudioTrack", t.MediaLast = "MediaLast", t.MediaSkipBackward = "MediaSkipBackward", t.MediaSkipForward = "MediaSkipForward", t.MediaStepBackward = "MediaStepBackward", t.MediaStepForward = "MediaStepForward", t.MediaTopMenu = "MediaTopMenu", t.NavigateIn = "NavigateIn", t.NavigateNext = "NavigateNext", t.NavigateOut = "NavigateOut", t.NavigatePrevious = "NavigatePrevious", t.NextFavoriteChannel = "NextFavoriteChannel", t.NextUserProfile = "NextUserProfile", t.OnDemand = "OnDemand", t.Pairing = "Pairing", t.PinPDown = "PinPDown", t.PinPMove = "PinPMove", t.PinPToggle = "PinPToggle", t.PinPUp = "PinPUp", t.PlaySpeedDown = "PlaySpeedDown", t.PlaySpeedReset = "PlaySpeedReset", t.PlaySpeedUp = "PlaySpeedUp", t.RandomToggle = "RandomToggle", t.RcLowBattery = "RcLowBattery", t.RecordSpeedNext = "RecordSpeedNext", t.RfBypass = "RfBypass", t.ScanChannelsToggle = "ScanChannelsToggle", t.ScreenModeNext = "ScreenModeNext", t.Settings = "Settings", t.SplitScreenToggle = "SplitScreenToggle", t.STBInput = "STBInput", t.STBPower = "STBPower", t.Subtitle = "Subtitle", t.Teletext = "Teletext", t.VideoModeNext = "VideoModeNext", t.Wink = "Wink", t.ZoomToggle = "ZoomToggle", t.SpeechCorrectionList = "SpeechCorrectionList", t.SpeechInputToggle = "SpeechInputToggle", t.Close = "Close", t.New = "New", t.Open = "Open", t.Print = "Print", t.Save = "Save", t.SpellCheck = "SpellCheck", t.MailForward = "MailForward", t.MailReply = "MailReply", t.MailSend = "MailSend", t.LaunchCalculator = "LaunchCalculator", t.LaunchCalendar = "LaunchCalendar", t.LaunchContacts = "LaunchContacts", t.LaunchMail = "LaunchMail", t.LaunchMediaPlayer = "LaunchMediaPlayer", t.LaunchMusicPlayer = "LaunchMusicPlayer", t.LaunchMyComputer = "LaunchMyComputer", t.LaunchPhone = "LaunchPhone", t.LaunchScreenSaver = "LaunchScreenSaver", t.LaunchSpreadsheet = "LaunchSpreadsheet", t.LaunchWebBrowser = "LaunchWebBrowser", t.LaunchWebCam = "LaunchWebCam", t.LaunchWordProcessor = "LaunchWordProcessor", t.LaunchApplication1 = "LaunchApplication1", t.LaunchApplication2 = "LaunchApplication2", t.LaunchApplication3 = "LaunchApplication3", t.LaunchApplication4 = "LaunchApplication4", t.LaunchApplication5 = "LaunchApplication5", t.LaunchApplication6 = "LaunchApplication6", t.LaunchApplication7 = "LaunchApplication7", t.LaunchApplication8 = "LaunchApplication8", t.LaunchApplication9 = "LaunchApplication9", t.LaunchApplication10 = "LaunchApplication10", t.LaunchApplication11 = "LaunchApplication11", t.LaunchApplication12 = "LaunchApplication12", t.LaunchApplication13 = "LaunchApplication13", t.LaunchApplication14 = "LaunchApplication14", t.LaunchApplication15 = "LaunchApplication15", t.LaunchApplication16 = "LaunchApplication16", t.BrowserBack = "BrowserBack", t.BrowserFavorites = "BrowserFavorites", t.BrowserForward = "BrowserForward", t.BrowserHome = "BrowserHome", t.BrowserRefresh = "BrowserRefresh", t.BrowserSearch = "BrowserSearch", t.BrowserStop = "BrowserStop", t.Decimal = "Decimal", t.Key11 = "Key11", t.Key12 = "Key12", t.Multiply = "Multiply", t.Add = "Add", t.Divide = "Divide", t.Subtract = "Subtract", t.Separator = "Separator";
2202
2202
  }(e.Key || (e.Key = {}));
2203
2203
  })(be);
2204
- const wo = (e, t, n, o) => {
2205
- let i;
2206
- const r = (g) => i = g;
2207
- let s;
2208
- const a = (g) => s = g, { store: u, selection: p } = t;
2209
- let h, c, m;
2210
- const f = (g) => {
2204
+ const wo = (e, t, n) => {
2205
+ let o;
2206
+ const i = (x) => o = x;
2207
+ let r;
2208
+ const s = (x) => r = x;
2209
+ let a = !0;
2210
+ const f = (x) => a = x, { store: p, selection: h } = t;
2211
+ let l, g, d;
2212
+ const A = (x) => {
2211
2213
  var T;
2212
- if (c === !1)
2214
+ if (!a || g === !1)
2213
2215
  return;
2214
- h = !((T = g.target.parentElement) != null && T.closest(Y)) ? {
2216
+ l = !((T = x.target.parentElement) != null && T.closest(Y)) ? {
2215
2217
  annotation: se(),
2216
2218
  selector: [],
2217
- creator: i,
2219
+ creator: o,
2218
2220
  created: /* @__PURE__ */ new Date()
2219
2221
  } : void 0;
2220
2222
  };
2221
- n && e.addEventListener("selectstart", f);
2222
- const v = It((g) => {
2223
- var N, A;
2224
- const x = document.getSelection();
2225
- if (!!((A = (N = x.anchorNode) == null ? void 0 : N.parentElement) != null && A.closest(Y))) {
2226
- h = void 0;
2223
+ e.addEventListener("selectstart", A);
2224
+ const m = It((x) => {
2225
+ var w, S;
2226
+ if (!a) return;
2227
+ const L = document.getSelection();
2228
+ if (!!((S = (w = L.anchorNode) == null ? void 0 : w.parentElement) != null && S.closest(Y))) {
2229
+ l = void 0;
2227
2230
  return;
2228
2231
  }
2229
- if (g.timeStamp - ((m == null ? void 0 : m.timeStamp) || g.timeStamp) < 1e3 && !h && f(m || g), x.isCollapsed || !h || c === !1)
2232
+ if (x.timeStamp - ((d == null ? void 0 : d.timeStamp) || x.timeStamp) < 1e3 && !l && A(d || x), L.isCollapsed || !l || g === !1)
2230
2233
  return;
2231
- const E = x.getRangeAt(0);
2232
- if (Ve(E)) return;
2233
- const M = Le(E.cloneRange());
2234
- (M.length !== h.selector.length || M.some((S, C) => {
2235
- var L;
2236
- return S.toString() !== ((L = h.selector[C]) == null ? void 0 : L.quote);
2237
- })) && (h = {
2238
- ...h,
2239
- selector: M.map((S) => Fe(S, e, o)),
2234
+ const k = L.getRangeAt(0);
2235
+ if (Ve(k)) return;
2236
+ const M = Le(k.cloneRange());
2237
+ (M.length !== l.selector.length || M.some((C, E) => {
2238
+ var B;
2239
+ return C.toString() !== ((B = l.selector[E]) == null ? void 0 : B.quote);
2240
+ })) && (l = {
2241
+ ...l,
2242
+ selector: M.map((C) => Fe(C, e, n)),
2240
2243
  updated: /* @__PURE__ */ new Date()
2241
- }, u.getAnnotation(h.annotation) ? u.updateTarget(h, R.LOCAL) : (p.clear(), u.addAnnotation({
2242
- id: h.annotation,
2244
+ }, p.getAnnotation(l.annotation) ? p.updateTarget(l, R.LOCAL) : (h.clear(), p.addAnnotation({
2245
+ id: l.annotation,
2243
2246
  bodies: [],
2244
- target: h
2245
- }, R.LOCAL), p.userSelect(h.annotation, m)));
2247
+ target: l
2248
+ }, R.LOCAL), h.userSelect(l.annotation, d)));
2246
2249
  });
2247
- n && document.addEventListener("selectionchange", v);
2248
- const b = (g) => {
2249
- m = De(g), c = m.button === 0;
2250
+ document.addEventListener("selectionchange", m);
2251
+ const b = (x) => {
2252
+ d = De(x), g = d.button === 0;
2250
2253
  };
2251
2254
  e.addEventListener("pointerdown", b);
2252
- const w = (g) => {
2255
+ const u = (x) => {
2253
2256
  var M;
2254
- if (!!((M = g.target.parentElement) != null && M.closest(Y)) || !c)
2257
+ if (!!((M = x.target.parentElement) != null && M.closest(Y)) || !g)
2255
2258
  return;
2256
2259
  const T = () => {
2257
- const { x: B, y: N } = e.getBoundingClientRect(), A = u.getAt(g.clientX - B, g.clientY - N, s);
2258
- if (A) {
2259
- const { selected: S } = p;
2260
- (S.length !== 1 || S[0].id !== A.id) && p.userSelect(A.id, g);
2261
- } else p.isEmpty() || p.clear();
2262
- }, E = g.timeStamp - m.timeStamp;
2263
- document.getSelection().isCollapsed && E < 300 ? (h = void 0, T()) : h && p.userSelect(h.annotation, g);
2260
+ const { x: y, y: w } = e.getBoundingClientRect(), S = p.getAt(x.clientX - y, x.clientY - w, r);
2261
+ if (S) {
2262
+ const { selected: C } = h;
2263
+ (C.length !== 1 || C[0].id !== S.id) && h.userSelect(S.id, x);
2264
+ } else h.isEmpty() || h.clear();
2265
+ }, k = x.timeStamp - d.timeStamp;
2266
+ document.getSelection().isCollapsed && k < 300 ? (l = void 0, T()) : l && h.userSelect(l.annotation, x);
2264
2267
  };
2265
- document.addEventListener("pointerup", w), U("*", { element: e, keyup: !1, keydown: !0 }, (g, x) => {
2266
- g.repeat || (m = ye(g));
2267
- }), U("*", { keyup: !0, keydown: !1 }, (g) => {
2268
- U.shift && g.key === be.Key.Shift && !g.repeat && h && p.userSelect(h.annotation, g);
2268
+ document.addEventListener("pointerup", u), U("*", { element: e, keyup: !1, keydown: !0 }, (x, L) => {
2269
+ x.repeat || (d = ye(x));
2270
+ }), U("*", { keyup: !0, keydown: !1 }, (x) => {
2271
+ U.shift && x.key === be.Key.Shift && !x.repeat && l && h.userSelect(l.annotation, x);
2269
2272
  });
2270
- let d = !1;
2273
+ let c = !1;
2271
2274
  return U("ctrl+a, ⌘+a", { keyup: !1, keydown: !0 }, () => {
2272
- d = !0;
2273
- }), U("*", { keyup: !0, keydown: !1 }, (g) => {
2274
- d && !g.repeat && h && p.userSelect(h.annotation, g), d = !1;
2275
+ c = !0;
2276
+ }), U("*", { keyup: !0, keydown: !1 }, (x) => {
2277
+ c && !x.repeat && l && h.userSelect(l.annotation, x), c = !1;
2275
2278
  }), {
2276
2279
  destroy: () => {
2277
- e.removeEventListener("selectstart", f), document.removeEventListener("selectionchange", v), e.removeEventListener("pointerdown", b), document.removeEventListener("pointerup", w), U.unbind();
2280
+ e.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", m), e.removeEventListener("pointerdown", b), document.removeEventListener("pointerup", u), U.unbind();
2278
2281
  },
2279
- setFilter: a,
2280
- setUser: r
2282
+ setFilter: s,
2283
+ setUser: i,
2284
+ setAnnotatingEnabled: f
2281
2285
  };
2282
- }, ee = "SPANS", To = (e, t = {}) => {
2283
- Te(e), Ee(e);
2286
+ }, ee = "SPANS", Eo = (e, t = {}) => {
2287
+ Ee(e), Te(e);
2284
2288
  const n = ro(t, {
2285
2289
  annotatingEnabled: !0,
2286
2290
  user: yn()
2287
- }), o = eo(e, n.userAction), { selection: i, viewport: r } = o, s = o.store, a = Bn(s), u = Rn(o, a, n.adapter);
2291
+ }), o = eo(e, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = Bn(s), f = Rn(o, a, n.adapter);
2288
2292
  let p = n.user;
2289
- const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee, c = h === "SPANS" ? on(e, o, r) : h === "CSS_HIGHLIGHTS" ? tn(e, o, r) : h === "CANVAS" ? $e(e, o, r) : void 0;
2290
- if (!c)
2293
+ const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee, l = h === "SPANS" ? on(e, o, r) : h === "CSS_HIGHLIGHTS" ? tn(e, o, r) : h === "CANVAS" ? $e(e, o, r) : void 0;
2294
+ if (!l)
2291
2295
  throw `Unknown renderer implementation: ${h}`;
2292
- console.debug(`Using ${h} renderer`), n.style && c.setStyle(n.style);
2293
- const m = wo(e, o, n.annotatingEnabled, n.offsetReferenceSelector);
2294
- m.setUser(p);
2295
- const f = On(o, a, n.adapter), v = () => p, b = (x) => {
2296
- c.setFilter(x), m.setFilter(x);
2297
- }, w = (x) => {
2298
- p = x, m.setUser(x);
2299
- }, d = (x) => {
2300
- x && (c.setPainter(oo(e, x, n.presence)), x.on("selectionChange", () => c.redraw()));
2301
- }, l = (x) => {
2302
- x ? i.setSelected(x) : i.clear();
2296
+ console.debug(`Using ${h} renderer`), n.style && l.setStyle(n.style);
2297
+ const g = wo(e, o, n.offsetReferenceSelector);
2298
+ g.setUser(p), g.setAnnotatingEnabled(n.annotatingEnabled);
2299
+ const d = On(o, a, n.adapter), A = () => p, m = (L) => {
2300
+ g.setAnnotatingEnabled(L);
2301
+ }, b = (L) => {
2302
+ l.setFilter(L), g.setFilter(L);
2303
+ }, u = (L) => {
2304
+ p = L, g.setUser(L);
2305
+ }, c = (L) => {
2306
+ L && (l.setPainter(oo(e, L, n.presence)), L.on("selectionChange", () => l.redraw()));
2307
+ }, v = (L) => {
2308
+ L ? i.setSelected(L) : i.clear();
2303
2309
  };
2304
2310
  return {
2305
- ...f,
2311
+ ...d,
2306
2312
  destroy: () => {
2307
- c.destroy(), m.destroy(), a.destroy();
2313
+ l.destroy(), g.destroy(), a.destroy();
2308
2314
  },
2309
2315
  element: e,
2310
- getUser: v,
2316
+ getUser: A,
2317
+ setAnnotatingEnabled: m,
2311
2318
  setFilter: b,
2312
- setStyle: c.setStyle.bind(c),
2313
- redraw: c.redraw.bind(c),
2314
- setUser: w,
2315
- setSelected: l,
2316
- setPresenceProvider: d,
2317
- setVisible: c.setVisible.bind(c),
2318
- on: u.on,
2319
- off: u.off,
2319
+ setStyle: l.setStyle.bind(l),
2320
+ redraw: l.redraw.bind(l),
2321
+ setUser: u,
2322
+ setSelected: v,
2323
+ setPresenceProvider: c,
2324
+ setVisible: l.setVisible.bind(l),
2325
+ on: f.on,
2326
+ off: f.off,
2320
2327
  scrollIntoView: io(e, s),
2321
2328
  state: o
2322
2329
  };
@@ -2329,7 +2336,7 @@ export {
2329
2336
  R as Origin,
2330
2337
  un as UserSelectAction,
2331
2338
  Lo as W3CTextFormat,
2332
- Te as cancelSingleClickEvents,
2339
+ Ee as cancelSingleClickEvents,
2333
2340
  ye as cloneKeyboardEvent,
2334
2341
  De as clonePointerEvent,
2335
2342
  xo as createBody,
@@ -2337,7 +2344,7 @@ export {
2337
2344
  tn as createHighlightsRenderer,
2338
2345
  Ke as createRenderer,
2339
2346
  on as createSpansRenderer,
2340
- To as createTextAnnotator,
2347
+ Eo as createTextAnnotator,
2341
2348
  eo as createTextAnnotatorState,
2342
2349
  It as debounce,
2343
2350
  Co as denormalizeRectWithOffset,
@@ -2352,7 +2359,7 @@ export {
2352
2359
  Pe as normalizeRectWithOffset,
2353
2360
  Se as paint,
2354
2361
  $n as parseW3CTextAnnotation,
2355
- Ee as programmaticallyFocusable,
2362
+ Te as programmaticallyFocusable,
2356
2363
  Fe as rangeToSelector,
2357
2364
  bt as reviveAnnotation,
2358
2365
  oe as reviveSelector,