@recogito/text-annotator 3.0.0-rc.29 → 3.0.0-rc.30

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.
@@ -4,29 +4,29 @@ const P = {
4
4
  }, ot = {
5
5
  fill: "rgb(0, 128, 255)",
6
6
  fillOpacity: 0.45
7
- }, qt = (t, e, n, o, i) => {
7
+ }, Kt = (t, e, n, o, i) => {
8
8
  var a, s;
9
9
  const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? ot : P) : n : (s = t.state) != null && s.selected ? ot : P;
10
10
  return o && o.paint(t, e) || r;
11
- }, Vt = "not-annotatable", X = `.${Vt}`, jt = (t) => {
11
+ }, _t = "not-annotatable", X = `.${_t}`, Qt = (t) => {
12
12
  var n;
13
13
  const e = t.commonAncestorContainer;
14
14
  return e instanceof HTMLElement ? !e.closest(X) : !((n = e.parentElement) != null && n.closest(X));
15
- }, Gt = function* (t) {
15
+ }, Jt = function* (t) {
16
16
  const e = document.createNodeIterator(
17
17
  t.commonAncestorContainer,
18
18
  NodeFilter.SHOW_ELEMENT,
19
- (o) => o instanceof HTMLElement && o.classList.contains(Vt) && !o.parentElement.closest(X) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
19
+ (o) => o instanceof HTMLElement && o.classList.contains(_t) && !o.parentElement.closest(X) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
20
20
  );
21
21
  let n;
22
22
  for (; n = e.nextNode(); )
23
23
  n instanceof HTMLElement && (yield n);
24
- }, Kt = (t) => {
25
- if (!jt(t))
24
+ }, Zt = (t) => {
25
+ if (!Qt(t))
26
26
  return [];
27
27
  const e = [];
28
28
  let n = null;
29
- for (const o of Gt(t)) {
29
+ for (const o of Jt(t)) {
30
30
  let i;
31
31
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
32
32
  }
@@ -35,23 +35,23 @@ const P = {
35
35
  o.setStartAfter(n), o.collapsed || e.push(o);
36
36
  }
37
37
  return e.length > 0 ? e : [t];
38
- }, ft = (t) => {
38
+ }, pt = (t) => {
39
39
  const e = t.cloneContents();
40
40
  return e.querySelectorAll(X).forEach((n) => n.remove()), e;
41
- }, Qt = (t) => {
41
+ }, te = (t) => {
42
42
  t.addEventListener("click", (e) => {
43
43
  // Allow clicks within not-annotatable elements
44
44
  !e.target.closest(X) && !e.target.closest("a") && e.preventDefault();
45
45
  });
46
- }, pt = (t, e = 10) => {
46
+ }, bt = (t, e = 10) => {
47
47
  let n;
48
48
  return (...o) => {
49
49
  clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
50
50
  };
51
- }, Ln = (t) => {
51
+ }, On = (t) => {
52
52
  const e = t.cloneContents();
53
53
  return e.querySelectorAll(X).forEach((n) => n.remove()), e;
54
- }, vt = (t, e) => {
54
+ }, wt = (t, e) => {
55
55
  const n = document.createNodeIterator(e);
56
56
  let o = 0, i = n.nextNode();
57
57
  for (; i !== null; ) {
@@ -59,46 +59,46 @@ const P = {
59
59
  return o;
60
60
  o += 1, i = n.nextNode();
61
61
  }
62
- }, yt = (t, e) => {
62
+ }, xt = (t, e) => {
63
63
  const n = document.createNodeIterator(e);
64
64
  let o = null;
65
65
  for (let i = 0; i < t + 1; i++)
66
66
  o = n.nextNode();
67
67
  return o;
68
- }, Jt = (t) => {
68
+ }, ee = (t) => {
69
69
  const {
70
70
  commonAncestorContainer: e,
71
71
  startContainer: n,
72
72
  startOffset: o,
73
73
  endContainer: i,
74
74
  endOffset: r
75
- } = t, a = Array.from(e.childNodes).map((c) => {
76
- const p = c.cloneNode(!0);
77
- return c.nodeName === "CANVAS" ? c : p;
78
- }), s = vt(n, e), u = vt(i, e), f = () => {
79
- const c = e;
80
- c.replaceChildren(...a);
81
- const p = yt(s, c), g = yt(u, c);
75
+ } = t, a = Array.from(e.childNodes).map((l) => {
76
+ const p = l.cloneNode(!0);
77
+ return l.nodeName === "CANVAS" ? l : p;
78
+ }), s = wt(n, e), u = wt(i, e), f = () => {
79
+ const l = e;
80
+ l.replaceChildren(...a);
81
+ const p = xt(s, l), g = xt(u, l);
82
82
  return t.setStart(p, o), t.setEnd(g, r), t;
83
- }, m = (c) => {
83
+ }, m = (l) => {
84
84
  const p = document.createElement("SPAN");
85
- return c.surroundContents(p), p;
85
+ return l.surroundContents(p), p;
86
86
  };
87
87
  if (n === i)
88
88
  throw "Not implemented";
89
89
  {
90
- const c = document.createRange();
91
- c.selectNodeContents(n), c.setStart(n, o);
92
- const p = m(c), g = document.createRange();
90
+ const l = document.createRange();
91
+ l.selectNodeContents(n), l.setStart(n, o);
92
+ const p = m(l), g = document.createRange();
93
93
  g.selectNode(i), g.setEnd(i, r);
94
- const x = m(g), h = Zt(t).reverse().map((d) => {
94
+ const x = m(g), h = ne(t).reverse().map((d) => {
95
95
  var y;
96
- const l = document.createElement("SPAN");
97
- return (y = d.parentNode) == null || y.insertBefore(l, d), l.appendChild(d), l;
96
+ const c = document.createElement("SPAN");
97
+ return (y = d.parentNode) == null || y.insertBefore(c, d), c.appendChild(d), c;
98
98
  });
99
99
  return { unwrap: f, nodes: [p, ...h, x] };
100
100
  }
101
- }, Zt = (t) => {
101
+ }, ne = (t) => {
102
102
  const {
103
103
  commonAncestorContainer: e,
104
104
  startContainer: n,
@@ -109,25 +109,25 @@ const P = {
109
109
  for (; r != null; )
110
110
  r === o && (a = !1), a && s.push(r), r === n && (a = !0), r = i.nextNode();
111
111
  return s;
112
- }, Bn = (t) => {
112
+ }, Mn = (t) => {
113
113
  const { startContainer: e, endContainer: n } = t;
114
114
  if (e === n)
115
115
  return Array.from(t.getClientRects());
116
116
  {
117
- const { unwrap: o, nodes: i } = Jt(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
117
+ const { unwrap: o, nodes: i } = ee(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
118
118
  return o(), r;
119
119
  }
120
- }, te = (t, e, n = 10, o) => {
120
+ }, oe = (t, e, n = 10, o) => {
121
121
  const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
122
122
  r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
123
- const a = ft(r).textContent, s = document.createRange();
123
+ const a = pt(r).textContent, s = document.createRange();
124
124
  s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
125
- const u = ft(s).textContent;
125
+ const u = pt(s).textContent;
126
126
  return {
127
127
  prefix: a.substring(a.length - n),
128
128
  suffix: u.substring(0, n)
129
129
  };
130
- }, $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ee = (t, e) => {
130
+ }, $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ie = (t, e) => {
131
131
  const n = (r) => Math.round(r * 10) / 10, o = {
132
132
  top: n(t.top),
133
133
  bottom: n(t.bottom),
@@ -151,17 +151,17 @@ const P = {
151
151
  return "block-contains";
152
152
  } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
153
153
  return "block-is-contained";
154
- }, ne = (t, e) => {
154
+ }, re = (t, e) => {
155
155
  const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
156
156
  return new DOMRect(n, i, o - n, r - i);
157
- }, oe = (t) => t.reduce((e, n) => {
157
+ }, se = (t) => t.reduce((e, n) => {
158
158
  if (n.width === 0 || n.height === 0)
159
159
  return e;
160
160
  let o = [...e], i = !1;
161
161
  for (const r of e) {
162
- const a = ee(n, r);
162
+ const a = ie(n, r);
163
163
  if (a === "inline-adjacent") {
164
- o = o.map((s) => s === r ? ne(n, r) : s), i = !0;
164
+ o = o.map((s) => s === r ? re(n, r) : s), i = !0;
165
165
  break;
166
166
  } else if (a === "inline-contains") {
167
167
  o = o.map((s) => s === r ? n : s), i = !0;
@@ -175,13 +175,13 @@ const P = {
175
175
  }
176
176
  }
177
177
  return i ? o : [...o, n];
178
- }, []), ie = (t, e, n) => {
178
+ }, []), ae = (t, e, n) => {
179
179
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
180
180
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
181
- const r = ft(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;
181
+ const r = pt(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;
182
182
  return n ? { quote: a, start: s, end: u, range: t, offsetReference: i } : { quote: a, start: s, end: u, range: t };
183
- }, _t = (t, e) => {
184
- var m, c;
183
+ }, Xt = (t, e) => {
184
+ var m, l;
185
185
  const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
186
186
  e,
187
187
  NodeFilter.SHOW_TEXT,
@@ -207,7 +207,7 @@ const P = {
207
207
  u = r.nextNode();
208
208
  }
209
209
  for (; u !== null; ) {
210
- const p = ((c = u.textContent) == null ? void 0 : c.length) || 0;
210
+ const p = ((l = u.textContent) == null ? void 0 : l.length) || 0;
211
211
  if (a + p >= o) {
212
212
  s.setEnd(u, o - a);
213
213
  break;
@@ -220,8 +220,8 @@ const P = {
220
220
  };
221
221
  }, it = (t, e) => $(t.selector) ? t : {
222
222
  ...t,
223
- selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : _t(n, e))
224
- }, rt = (t, e) => $(t.target.selector) ? t : { ...t, target: it(t.target, e) }, re = (t) => {
223
+ selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Xt(n, e))
224
+ }, rt = (t, e) => $(t.target.selector) ? t : { ...t, target: it(t.target, e) }, ce = (t) => {
225
225
  var i;
226
226
  const { startContainer: e, endContainer: n } = t;
227
227
  if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)
@@ -235,52 +235,52 @@ const P = {
235
235
  t.setEnd(a, ((i = a == null ? void 0 : a.textContent) == null ? void 0 : i.length) || 0);
236
236
  }
237
237
  return t;
238
- }, se = (t) => {
238
+ }, le = (t) => {
239
239
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, u = i - e;
240
240
  return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: u };
241
- }, ae = (t) => {
241
+ }, de = (t) => {
242
242
  let e = /* @__PURE__ */ new Set();
243
243
  return (o) => {
244
244
  const i = o.map((r) => r.id);
245
245
  (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
246
246
  };
247
- }, mt = (t, e, n, o) => {
247
+ }, vt = (t, e, n, o) => {
248
248
  const { store: i, selection: r, hover: a } = e;
249
249
  let s, u, f;
250
- const m = ae(n), c = (R) => {
251
- const { x: O, y: b } = t.getBoundingClientRect(), w = i.getAt(R.clientX - O, R.clientY - b);
250
+ const m = de(n), l = (L) => {
251
+ const { x: O, y: b } = t.getBoundingClientRect(), w = i.getAt(L.clientX - O, L.clientY - b);
252
252
  w && (!u || u(w)) ? a.current !== w.id && (t.classList.add("hovered"), a.set(w.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
253
253
  };
254
- t.addEventListener("pointermove", c);
255
- const p = (R = !1) => {
254
+ t.addEventListener("pointermove", l);
255
+ const p = (L = !1) => {
256
256
  f && f.clear();
257
- const O = se(t), { minX: b, minY: w, maxX: A, maxY: S } = O, L = u ? i.getIntersecting(b, w, A, S).filter(({ annotation: k }) => u(k)) : i.getIntersecting(b, w, A, S), I = r.selected.map(({ id: k }) => k), H = L.map(({ annotation: k, rects: zt }) => {
258
- const Ft = I.includes(k.id), Wt = k.id === a.current;
259
- return { annotation: k, rects: zt, state: { selected: Ft, hover: Wt } };
257
+ const O = le(t), { minX: b, minY: w, maxX: A, maxY: S } = O, R = u ? i.getIntersecting(b, w, A, S).filter(({ annotation: k }) => u(k)) : i.getIntersecting(b, w, A, S), M = r.selected.map(({ id: k }) => k), H = R.map(({ annotation: k, rects: qt }) => {
258
+ const jt = M.includes(k.id), Gt = k.id === a.current;
259
+ return { annotation: k, rects: qt, state: { selected: jt, hover: Gt } };
260
260
  });
261
- o.redraw(H, O, s, f, R), setTimeout(() => m(L.map(({ annotation: k }) => k)), 1);
262
- }, g = (R) => {
263
- f = R, p();
264
- }, x = (R) => {
265
- s = R, p();
266
- }, v = (R) => {
267
- u = R, p(!1);
261
+ o.redraw(H, O, s, f, L), setTimeout(() => m(R.map(({ annotation: k }) => k)), 1);
262
+ }, g = (L) => {
263
+ f = L, p();
264
+ }, x = (L) => {
265
+ s = L, p();
266
+ }, v = (L) => {
267
+ u = L, p(!1);
268
268
  }, h = () => p();
269
269
  i.observe(h);
270
- const d = r.subscribe(() => p()), l = () => p(!0);
271
- document.addEventListener("scroll", l, { capture: !0, passive: !0 });
272
- const y = pt(() => {
270
+ const d = r.subscribe(() => p()), c = () => p(!0);
271
+ document.addEventListener("scroll", c, { capture: !0, passive: !0 });
272
+ const y = bt(() => {
273
273
  i.recalculatePositions(), f && f.reset(), p();
274
274
  });
275
275
  window.addEventListener("resize", y);
276
276
  const T = new ResizeObserver(y);
277
277
  T.observe(t);
278
- const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((R) => {
279
- R.every((b) => b.target === t || t.contains(b.target)) || p(!0);
278
+ const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((L) => {
279
+ L.every((b) => b.target === t || t.contains(b.target)) || p(!0);
280
280
  });
281
281
  return E.observe(document.body, C), {
282
282
  destroy: () => {
283
- t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(h), d(), document.removeEventListener("scroll", l), window.removeEventListener("resize", y), T.disconnect(), E.disconnect();
283
+ t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(h), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", y), T.disconnect(), E.disconnect();
284
284
  },
285
285
  redraw: p,
286
286
  setStyle: x,
@@ -288,49 +288,49 @@ const P = {
288
288
  setPainter: g,
289
289
  setVisible: o.setVisible
290
290
  };
291
- }, ce = () => {
291
+ }, ue = () => {
292
292
  const t = document.createElement("canvas");
293
293
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
294
- }, le = (t, e) => {
294
+ }, he = (t, e) => {
295
295
  t.width = window.innerWidth, t.height = window.innerHeight;
296
- }, de = (t) => {
296
+ }, fe = (t) => {
297
297
  t.classList.add("r6o-annotatable");
298
- const e = ce(), n = e.getContext("2d");
298
+ const e = ue(), n = e.getContext("2d");
299
299
  t.insertBefore(e, t.firstChild);
300
300
  const o = (s, u, f, m) => requestAnimationFrame(() => {
301
- const { width: c, height: p } = e;
302
- n.clearRect(-0.5, -0.5, c + 1, p + 1), m && m.clear();
301
+ const { width: l, height: p } = e;
302
+ n.clearRect(-0.5, -0.5, l + 1, p + 1), m && m.clear();
303
303
  const { top: g, left: x } = u;
304
304
  [...s].sort((h, d) => {
305
- const { annotation: { target: { created: l } } } = h, { annotation: { target: { created: y } } } = d;
306
- return l.getTime() - y.getTime();
305
+ const { annotation: { target: { created: c } } } = h, { annotation: { target: { created: y } } } = d;
306
+ return c.getTime() - y.getTime();
307
307
  }).forEach((h) => {
308
308
  var C;
309
- const d = f ? typeof f == "function" ? f(h.annotation, h.state) : f : (C = h.state) != null && C.selected ? ot : P, l = m && m.paint(h, u) || d, y = h.rects.map(({ x: E, y: N, width: R, height: O }) => ({
309
+ const d = f ? typeof f == "function" ? f(h.annotation, h.state) : f : (C = h.state) != null && C.selected ? ot : P, c = m && m.paint(h, u) || d, y = h.rects.map(({ x: E, y: N, width: L, height: O }) => ({
310
310
  x: E + x,
311
311
  y: N + g,
312
- width: R,
312
+ width: L,
313
313
  height: O
314
314
  }));
315
- n.fillStyle = l.fill, n.globalAlpha = l.fillOpacity || 1;
315
+ n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1;
316
316
  const T = 5;
317
317
  if (y.forEach(
318
- ({ x: E, y: N, width: R, height: O }) => n.fillRect(
318
+ ({ x: E, y: N, width: L, height: O }) => n.fillRect(
319
319
  E,
320
320
  N - T / 2,
321
- R,
321
+ L,
322
322
  O + T
323
323
  )
324
- ), l.underlineColor) {
325
- n.globalAlpha = 1, n.strokeStyle = l.underlineColor, n.lineWidth = l.underlineThickness ?? 1;
326
- const E = T / 2 + (l.underlineOffset ?? 0);
327
- y.forEach(({ x: N, y: R, width: O, height: b }) => {
328
- n.beginPath(), n.moveTo(N, R + b + E), n.lineTo(N + O, R + b + E), n.stroke();
324
+ ), c.underlineColor) {
325
+ n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
326
+ const E = T / 2 + (c.underlineOffset ?? 0);
327
+ y.forEach(({ x: N, y: L, width: O, height: b }) => {
328
+ n.beginPath(), n.moveTo(N, L + b + E), n.lineTo(N + O, L + b + E), n.stroke();
329
329
  });
330
330
  }
331
331
  });
332
- }), i = pt(() => {
333
- le(e);
332
+ }), i = bt(() => {
333
+ he(e);
334
334
  });
335
335
  return window.addEventListener("resize", i), {
336
336
  destroy: () => {
@@ -341,100 +341,100 @@ const P = {
341
341
  },
342
342
  redraw: o
343
343
  };
344
- }, ue = (t, e, n) => mt(t, e, n, de(t));
345
- var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
344
+ }, ge = (t, e, n) => vt(t, e, n, fe(t));
345
+ var pe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
346
346
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
347
- }, M = function(t, e, n) {
347
+ }, I = function(t, e, n) {
348
348
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
349
349
  }, U = function(t, e, n) {
350
350
  return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
351
- }, Ut = function(t) {
351
+ }, kt = function(t) {
352
352
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
353
- }, wt = function(t) {
353
+ }, At = function(t) {
354
354
  return { r: U(t.r, 0, 255), g: U(t.g, 0, 255), b: U(t.b, 0, 255), a: U(t.a) };
355
355
  }, st = function(t) {
356
- return { r: M(t.r), g: M(t.g), b: M(t.b), a: M(t.a, 3) };
357
- }, fe = /^#([0-9a-f]{3,8})$/i, J = function(t) {
356
+ return { r: I(t.r), g: I(t.g), b: I(t.b), a: I(t.a, 3) };
357
+ }, me = /^#([0-9a-f]{3,8})$/i, J = function(t) {
358
358
  var e = t.toString(16);
359
359
  return e.length < 2 ? "0" + e : e;
360
- }, Dt = function(t) {
360
+ }, Yt = function(t) {
361
361
  var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), a = r - Math.min(e, n, o), s = a ? r === e ? (n - o) / a : r === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
362
362
  return { h: 60 * (s < 0 ? s + 6 : s), s: r ? a / r * 100 : 0, v: r / 255 * 100, a: i };
363
- }, Xt = function(t) {
363
+ }, Ht = function(t) {
364
364
  var e = t.h, n = t.s, o = t.v, i = t.a;
365
365
  e = e / 360 * 6, n /= 100, o /= 100;
366
366
  var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), f = r % 6;
367
367
  return { r: 255 * [o, s, a, a, u, o][f], g: 255 * [u, o, o, s, a, a][f], b: 255 * [a, a, u, o, o, s][f], a: i };
368
- }, xt = function(t) {
369
- return { h: Ut(t.h), s: U(t.s, 0, 100), l: U(t.l, 0, 100), a: U(t.a) };
370
- }, At = function(t) {
371
- return { h: M(t.h), s: M(t.s), l: M(t.l), a: M(t.a, 3) };
372
368
  }, Et = function(t) {
373
- return Xt((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
369
+ return { h: kt(t.h), s: U(t.s, 0, 100), l: U(t.l, 0, 100), a: U(t.a) };
370
+ }, St = function(t) {
371
+ return { h: I(t.h), s: I(t.s), l: I(t.l), a: I(t.a, 3) };
372
+ }, Ct = function(t) {
373
+ return Ht((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
374
374
  var e, n, o;
375
375
  }, Q = function(t) {
376
- return { h: (e = Dt(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
376
+ return { h: (e = Yt(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
377
377
  var e, n, o, i;
378
- }, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, pe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, be = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, St = { string: [[function(t) {
379
- var e = fe.exec(t);
380
- return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? M(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? M(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
378
+ }, be = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ve = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ye = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, we = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Tt = { string: [[function(t) {
379
+ var e = me.exec(t);
380
+ return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? I(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? I(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
381
381
  }, "hex"], [function(t) {
382
- var e = me.exec(t) || be.exec(t);
383
- return e ? e[2] !== e[4] || e[4] !== e[6] ? null : wt({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
382
+ var e = ye.exec(t) || we.exec(t);
383
+ return e ? e[2] !== e[4] || e[4] !== e[6] ? null : At({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
384
384
  }, "rgb"], [function(t) {
385
- var e = ge.exec(t) || pe.exec(t);
385
+ var e = be.exec(t) || ve.exec(t);
386
386
  if (!e)
387
387
  return null;
388
- var n, o, i = xt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (he[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
389
- return Et(i);
388
+ var n, o, i = Et({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (pe[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
389
+ return Ct(i);
390
390
  }, "hsl"]], object: [[function(t) {
391
391
  var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
392
- return Y(e) && Y(n) && Y(o) ? wt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
392
+ return Y(e) && Y(n) && Y(o) ? At({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
393
393
  }, "rgb"], [function(t) {
394
394
  var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
395
395
  if (!Y(e) || !Y(n) || !Y(o))
396
396
  return null;
397
- var a = xt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
398
- return Et(a);
397
+ var a = Et({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
398
+ return Ct(a);
399
399
  }, "hsl"], [function(t) {
400
400
  var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
401
401
  if (!Y(e) || !Y(n) || !Y(o))
402
402
  return null;
403
403
  var a = function(s) {
404
- return { h: Ut(s.h), s: U(s.s, 0, 100), v: U(s.v, 0, 100), a: U(s.a) };
404
+ return { h: kt(s.h), s: U(s.s, 0, 100), v: U(s.v, 0, 100), a: U(s.a) };
405
405
  }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
406
- return Xt(a);
407
- }, "hsv"]] }, Ct = function(t, e) {
406
+ return Ht(a);
407
+ }, "hsv"]] }, Nt = function(t, e) {
408
408
  for (var n = 0; n < e.length; n++) {
409
409
  var o = e[n][0](t);
410
410
  if (o)
411
411
  return [o, e[n][1]];
412
412
  }
413
413
  return [null, void 0];
414
- }, ve = function(t) {
415
- return typeof t == "string" ? Ct(t.trim(), St.string) : typeof t == "object" && t !== null ? Ct(t, St.object) : [null, void 0];
414
+ }, xe = function(t) {
415
+ return typeof t == "string" ? Nt(t.trim(), Tt.string) : typeof t == "object" && t !== null ? Nt(t, Tt.object) : [null, void 0];
416
416
  }, at = function(t, e) {
417
417
  var n = Q(t);
418
418
  return { h: n.h, s: U(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
419
419
  }, ct = function(t) {
420
420
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
421
- }, Tt = function(t, e) {
421
+ }, Lt = function(t, e) {
422
422
  var n = Q(t);
423
423
  return { h: n.h, s: n.s, l: U(n.l + 100 * e, 0, 100), a: n.a };
424
- }, Nt = function() {
424
+ }, Rt = function() {
425
425
  function t(e) {
426
- this.parsed = ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
426
+ this.parsed = xe(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
427
427
  }
428
428
  return t.prototype.isValid = function() {
429
429
  return this.parsed !== null;
430
430
  }, t.prototype.brightness = function() {
431
- return M(ct(this.rgba), 2);
431
+ return I(ct(this.rgba), 2);
432
432
  }, t.prototype.isDark = function() {
433
433
  return ct(this.rgba) < 0.5;
434
434
  }, t.prototype.isLight = function() {
435
435
  return ct(this.rgba) >= 0.5;
436
436
  }, t.prototype.toHex = function() {
437
- return e = st(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? J(M(255 * r)) : "", "#" + J(n) + J(o) + J(i) + a;
437
+ return e = st(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? J(I(255 * r)) : "", "#" + J(n) + J(o) + J(i) + a;
438
438
  var e, n, o, i, r, a;
439
439
  }, t.prototype.toRgb = function() {
440
440
  return st(this.rgba);
@@ -442,47 +442,47 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
442
442
  return e = st(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
443
443
  var e, n, o, i, r;
444
444
  }, t.prototype.toHsl = function() {
445
- return At(Q(this.rgba));
445
+ return St(Q(this.rgba));
446
446
  }, t.prototype.toHslString = function() {
447
- return e = At(Q(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
447
+ return e = St(Q(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
448
448
  var e, n, o, i, r;
449
449
  }, t.prototype.toHsv = function() {
450
- return e = Dt(this.rgba), { h: M(e.h), s: M(e.s), v: M(e.v), a: M(e.a, 3) };
450
+ return e = Yt(this.rgba), { h: I(e.h), s: I(e.s), v: I(e.v), a: I(e.a, 3) };
451
451
  var e;
452
452
  }, t.prototype.invert = function() {
453
- return D({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
453
+ return _({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
454
454
  var e;
455
455
  }, t.prototype.saturate = function(e) {
456
- return e === void 0 && (e = 0.1), D(at(this.rgba, e));
456
+ return e === void 0 && (e = 0.1), _(at(this.rgba, e));
457
457
  }, t.prototype.desaturate = function(e) {
458
- return e === void 0 && (e = 0.1), D(at(this.rgba, -e));
458
+ return e === void 0 && (e = 0.1), _(at(this.rgba, -e));
459
459
  }, t.prototype.grayscale = function() {
460
- return D(at(this.rgba, -1));
460
+ return _(at(this.rgba, -1));
461
461
  }, t.prototype.lighten = function(e) {
462
- return e === void 0 && (e = 0.1), D(Tt(this.rgba, e));
462
+ return e === void 0 && (e = 0.1), _(Lt(this.rgba, e));
463
463
  }, t.prototype.darken = function(e) {
464
- return e === void 0 && (e = 0.1), D(Tt(this.rgba, -e));
464
+ return e === void 0 && (e = 0.1), _(Lt(this.rgba, -e));
465
465
  }, t.prototype.rotate = function(e) {
466
466
  return e === void 0 && (e = 15), this.hue(this.hue() + e);
467
467
  }, t.prototype.alpha = function(e) {
468
- return typeof e == "number" ? D({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : M(this.rgba.a, 3);
468
+ return typeof e == "number" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : I(this.rgba.a, 3);
469
469
  var n;
470
470
  }, t.prototype.hue = function(e) {
471
471
  var n = Q(this.rgba);
472
- return typeof e == "number" ? D({ h: e, s: n.s, l: n.l, a: n.a }) : M(n.h);
472
+ return typeof e == "number" ? _({ h: e, s: n.s, l: n.l, a: n.a }) : I(n.h);
473
473
  }, t.prototype.isEqual = function(e) {
474
- return this.toHex() === D(e).toHex();
474
+ return this.toHex() === _(e).toHex();
475
475
  }, t;
476
- }(), D = function(t) {
477
- return t instanceof Nt ? t : new Nt(t);
476
+ }(), _ = function(t) {
477
+ return t instanceof Rt ? t : new Rt(t);
478
478
  };
479
- const ye = (t) => [
480
- `background-color:${D((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
479
+ const Ae = (t) => [
480
+ `background-color:${_((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
481
481
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
482
482
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
483
483
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
484
484
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
485
- ].filter(Boolean).join(";"), we = () => {
485
+ ].filter(Boolean).join(";"), Ee = () => {
486
486
  const t = document.createElement("style");
487
487
  document.getElementsByTagName("head")[0].appendChild(t);
488
488
  let e = /* @__PURE__ */ new Set();
@@ -495,23 +495,23 @@ const ye = (t) => [
495
495
  },
496
496
  redraw: (r, a, s, u) => {
497
497
  u && u.clear();
498
- const f = new Set(r.map((c) => c.annotation.id));
499
- Array.from(e).filter((c) => !f.has(c));
500
- const m = r.map((c) => {
498
+ const f = new Set(r.map((l) => l.annotation.id));
499
+ Array.from(e).filter((l) => !f.has(l));
500
+ const m = r.map((l) => {
501
501
  var x;
502
- const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? ot : P, g = u && u.paint(c, a) || p;
503
- return `::highlight(_${c.annotation.id}) { ${ye(g)} }`;
502
+ const p = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (x = l.state) != null && x.selected ? ot : P, g = u && u.paint(l, a) || p;
503
+ return `::highlight(_${l.annotation.id}) { ${Ae(g)} }`;
504
504
  });
505
505
  t.innerHTML = m.join(`
506
- `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
507
- const p = c.target.selector.map((x) => x.range), g = new Highlight(...p);
508
- CSS.highlights.set(`_${c.id}`, g);
506
+ `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
507
+ const p = l.target.selector.map((x) => x.range), g = new Highlight(...p);
508
+ CSS.highlights.set(`_${l.id}`, g);
509
509
  }), e = f;
510
510
  }
511
511
  };
512
- }, xe = (t, e, n) => mt(t, e, n, we());
513
- var Rt = Object.prototype.hasOwnProperty;
514
- function gt(t, e) {
512
+ }, Se = (t, e, n) => vt(t, e, n, Ee());
513
+ var Bt = Object.prototype.hasOwnProperty;
514
+ function mt(t, e) {
515
515
  var n, o;
516
516
  if (t === e)
517
517
  return !0;
@@ -522,24 +522,24 @@ function gt(t, e) {
522
522
  return t.toString() === e.toString();
523
523
  if (n === Array) {
524
524
  if ((o = t.length) === e.length)
525
- for (; o-- && gt(t[o], e[o]); )
525
+ for (; o-- && mt(t[o], e[o]); )
526
526
  ;
527
527
  return o === -1;
528
528
  }
529
529
  if (!n || typeof t == "object") {
530
530
  o = 0;
531
531
  for (n in t)
532
- if (Rt.call(t, n) && ++o && !Rt.call(e, n) || !(n in e) || !gt(t[n], e[n]))
532
+ if (Bt.call(t, n) && ++o && !Bt.call(e, n) || !(n in e) || !mt(t[n], e[n]))
533
533
  return !1;
534
534
  return Object.keys(e).length === o;
535
535
  }
536
536
  }
537
537
  return t !== t && e !== e;
538
538
  }
539
- const Ae = (t, e) => {
539
+ const Ce = (t, e) => {
540
540
  const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y;
541
541
  return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;
542
- }, Ee = (t) => {
542
+ }, Te = (t) => {
543
543
  t.classList.add("r6o-annotatable");
544
544
  const e = document.createElement("div");
545
545
  e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
@@ -549,19 +549,19 @@ const Ae = (t, e) => {
549
549
  e.remove();
550
550
  },
551
551
  redraw: (a, s, u, f, m) => {
552
- const p = !(gt(n, a) && m);
552
+ const p = !(mt(n, a) && m);
553
553
  if (!f && !p)
554
554
  return;
555
555
  p && (e.innerHTML = "");
556
556
  const g = a.reduce((x, { rects: v }) => [...x, ...v], []);
557
557
  a.forEach((x) => {
558
558
  x.rects.map((v) => {
559
- const h = Ae(v, g), d = qt(x, s, u, f, h);
559
+ const h = Ce(v, g), d = Kt(x, s, u, f, h);
560
560
  if (p) {
561
- const l = document.createElement("span");
562
- l.className = "r6o-annotation", l.dataset.annotation = x.annotation.id, l.style.left = `${v.x}px`, l.style.top = `${v.y}px`, l.style.width = `${v.width}px`, l.style.height = `${v.height}px`;
563
- const y = D((d == null ? void 0 : d.fill) || P.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? P.fillOpacity : d.fillOpacity).toHex();
564
- l.style.backgroundColor = y, d.underlineStyle && (l.style.borderStyle = d.underlineStyle), d.underlineColor && (l.style.borderColor = d.underlineColor), d.underlineThickness && (l.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (l.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(l);
561
+ const c = document.createElement("span");
562
+ c.className = "r6o-annotation", c.dataset.annotation = x.annotation.id, c.style.left = `${v.x}px`, c.style.top = `${v.y}px`, c.style.width = `${v.width}px`, c.style.height = `${v.height}px`;
563
+ const y = _((d == null ? void 0 : d.fill) || P.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? P.fillOpacity : d.fillOpacity).toHex();
564
+ c.style.backgroundColor = y, d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
565
565
  }
566
566
  });
567
567
  }), n = a;
@@ -570,31 +570,31 @@ const Ae = (t, e) => {
570
570
  a ? e.classList.remove("hidden") : e.classList.add("hidden");
571
571
  }
572
572
  };
573
- }, Se = (t, e, n) => mt(t, e, n, Ee(t));
574
- let Z;
575
- const Ce = new Uint8Array(16);
576
- function Te() {
573
+ }, Ne = (t, e, n) => vt(t, e, n, Te(t));
574
+ var V = [];
575
+ for (var lt = 0; lt < 256; ++lt)
576
+ V.push((lt + 256).toString(16).slice(1));
577
+ function Le(t, e = 0) {
578
+ return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
579
+ }
580
+ var Z, Re = new Uint8Array(16);
581
+ function Be() {
577
582
  if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
578
583
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
579
- return Z(Ce);
584
+ return Z(Re);
580
585
  }
581
- const V = [];
582
- for (let t = 0; t < 256; ++t)
583
- V.push((t + 256).toString(16).slice(1));
584
- function Ne(t, e = 0) {
585
- return V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]];
586
- }
587
- const Re = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Lt = {
588
- randomUUID: Re
586
+ var Oe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
587
+ const Ot = {
588
+ randomUUID: Oe
589
589
  };
590
- function kt(t, e, n) {
591
- if (Lt.randomUUID && !e && !t)
592
- return Lt.randomUUID();
590
+ function $t(t, e, n) {
591
+ if (Ot.randomUUID && !e && !t)
592
+ return Ot.randomUUID();
593
593
  t = t || {};
594
- const o = t.random || (t.rng || Te)();
595
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ne(o);
594
+ var o = t.random || (t.rng || Be)();
595
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Le(o);
596
596
  }
597
- var Bt = Object.prototype.hasOwnProperty;
597
+ var Mt = Object.prototype.hasOwnProperty;
598
598
  function q(t, e) {
599
599
  var n, o;
600
600
  if (t === e)
@@ -613,24 +613,24 @@ function q(t, e) {
613
613
  if (!n || typeof t == "object") {
614
614
  o = 0;
615
615
  for (n in t)
616
- if (Bt.call(t, n) && ++o && !Bt.call(e, n) || !(n in e) || !q(t[n], e[n]))
616
+ if (Mt.call(t, n) && ++o && !Mt.call(e, n) || !(n in e) || !q(t[n], e[n]))
617
617
  return !1;
618
618
  return Object.keys(e).length === o;
619
619
  }
620
620
  }
621
621
  return t !== t && e !== e;
622
622
  }
623
- function lt() {
623
+ function dt() {
624
624
  }
625
- function Le(t, e) {
625
+ function Me(t, e) {
626
626
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
627
627
  }
628
628
  const z = [];
629
- function bt(t, e = lt) {
629
+ function yt(t, e = dt) {
630
630
  let n;
631
631
  const o = /* @__PURE__ */ new Set();
632
632
  function i(s) {
633
- if (Le(t, s) && (t = s, n)) {
633
+ if (Me(t, s) && (t = s, n)) {
634
634
  const u = !z.length;
635
635
  for (const f of o)
636
636
  f[1](), z.push(f, t);
@@ -644,16 +644,16 @@ function bt(t, e = lt) {
644
644
  function r(s) {
645
645
  i(s(t));
646
646
  }
647
- function a(s, u = lt) {
647
+ function a(s, u = dt) {
648
648
  const f = [s, u];
649
- return o.add(f), o.size === 1 && (n = e(i, r) || lt), s(t), () => {
649
+ return o.add(f), o.size === 1 && (n = e(i, r) || dt), s(t), () => {
650
650
  o.delete(f), o.size === 0 && n && (n(), n = null);
651
651
  };
652
652
  }
653
653
  return { set: i, update: r, subscribe: a };
654
654
  }
655
- const Be = (t) => {
656
- const { subscribe: e, set: n } = bt();
655
+ const Ie = (t) => {
656
+ const { subscribe: e, set: n } = yt();
657
657
  let o;
658
658
  return e((i) => o = i), t.observe(({ changes: i }) => {
659
659
  if (o) {
@@ -669,36 +669,41 @@ const Be = (t) => {
669
669
  set: n
670
670
  };
671
671
  };
672
- var Oe = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Oe || {});
673
- const dt = { selected: [] }, Ie = (t, e = "EDIT") => {
674
- const { subscribe: n, set: o } = bt(dt);
675
- let i = dt;
676
- n((c) => i = c);
677
- const r = () => o(dt), a = () => {
678
- var c;
679
- return ((c = i.selected) == null ? void 0 : c.length) === 0;
680
- }, s = (c) => {
672
+ var Ve = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Ve || {});
673
+ const ut = { selected: [] }, De = (t, e = "EDIT") => {
674
+ const { subscribe: n, set: o } = yt(ut);
675
+ let i = ut;
676
+ n((l) => i = l);
677
+ const r = () => o(ut), a = () => {
678
+ var l;
679
+ return ((l = i.selected) == null ? void 0 : l.length) === 0;
680
+ }, s = (l) => {
681
681
  if (i.selected.length === 0)
682
682
  return !1;
683
- const p = typeof c == "string" ? c : c.id;
683
+ const p = typeof l == "string" ? l : l.id;
684
684
  return i.selected.some((g) => g.id === p);
685
- }, u = (c, p) => {
686
- const g = t.getAnnotation(c);
685
+ }, u = (l, p) => {
686
+ const g = t.getAnnotation(l);
687
687
  if (g) {
688
- const x = Me(g, e);
689
- o(x === "EDIT" ? { selected: [{ id: c, editable: !0 }], pointerEvent: p } : x === "SELECT" ? { selected: [{ id: c }], pointerEvent: p } : { selected: [], pointerEvent: p });
688
+ const x = It(g, e);
689
+ o(x === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: p } : x === "SELECT" ? { selected: [{ id: l }], pointerEvent: p } : { selected: [], pointerEvent: p });
690
690
  } else
691
- console.warn("Invalid selection: " + c);
692
- }, f = (c, p = !0) => {
693
- const g = Array.isArray(c) ? c : [c], x = g.map((v) => t.getAnnotation(v)).filter(Boolean);
694
- o({ selected: x.map(({ id: v }) => ({ id: v, editable: p })) }), x.length !== g.length && console.warn("Invalid selection", c);
695
- }, m = (c) => {
691
+ console.warn("Invalid selection: " + l);
692
+ }, f = (l, p) => {
693
+ const g = Array.isArray(l) ? l : [l], x = g.map((v) => t.getAnnotation(v)).filter(Boolean);
694
+ o({
695
+ selected: x.map((v) => {
696
+ const h = p === void 0 ? It(v, e) === "EDIT" : p;
697
+ return { id: v.id, editable: h };
698
+ })
699
+ }), x.length !== g.length && console.warn("Invalid selection", l);
700
+ }, m = (l) => {
696
701
  if (i.selected.length === 0)
697
702
  return !1;
698
703
  const { selected: p } = i;
699
- p.filter(({ id: g }) => c.includes(g)).length > 0 && o({ selected: p.filter(({ id: g }) => !c.includes(g)) });
704
+ p.filter(({ id: g }) => l.includes(g)).length > 0 && o({ selected: p.filter(({ id: g }) => !l.includes(g)) });
700
705
  };
701
- return t.observe(({ changes: c }) => m((c.deleted || []).map((p) => p.id))), {
706
+ return t.observe(({ changes: l }) => m((l.deleted || []).map((p) => p.id))), {
702
707
  clear: r,
703
708
  clickSelect: u,
704
709
  get selected() {
@@ -712,58 +717,58 @@ const dt = { selected: [] }, Ie = (t, e = "EDIT") => {
712
717
  setSelected: f,
713
718
  subscribe: n
714
719
  };
715
- }, Me = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT";
716
- let tt;
717
- const Ve = new Uint8Array(16);
718
- function _e() {
720
+ }, It = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT";
721
+ var D = [];
722
+ for (var ht = 0; ht < 256; ++ht)
723
+ D.push((ht + 256).toString(16).slice(1));
724
+ function Ue(t, e = 0) {
725
+ return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + "-" + D[t[e + 4]] + D[t[e + 5]] + "-" + D[t[e + 6]] + D[t[e + 7]] + "-" + D[t[e + 8]] + D[t[e + 9]] + "-" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();
726
+ }
727
+ var tt, _e = new Uint8Array(16);
728
+ function Xe() {
719
729
  if (!tt && (tt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !tt))
720
730
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
721
- return tt(Ve);
731
+ return tt(_e);
722
732
  }
723
- const _ = [];
724
- for (let t = 0; t < 256; ++t)
725
- _.push((t + 256).toString(16).slice(1));
726
- function Ue(t, e = 0) {
727
- return _[t[e + 0]] + _[t[e + 1]] + _[t[e + 2]] + _[t[e + 3]] + "-" + _[t[e + 4]] + _[t[e + 5]] + "-" + _[t[e + 6]] + _[t[e + 7]] + "-" + _[t[e + 8]] + _[t[e + 9]] + "-" + _[t[e + 10]] + _[t[e + 11]] + _[t[e + 12]] + _[t[e + 13]] + _[t[e + 14]] + _[t[e + 15]];
728
- }
729
- const De = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ot = {
730
- randomUUID: De
733
+ var ke = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
734
+ const Vt = {
735
+ randomUUID: ke
731
736
  };
732
- function Xe(t, e, n) {
733
- if (Ot.randomUUID && !e && !t)
734
- return Ot.randomUUID();
737
+ function Ye(t, e, n) {
738
+ if (Vt.randomUUID && !e && !t)
739
+ return Vt.randomUUID();
735
740
  t = t || {};
736
- const o = t.random || (t.rng || _e)();
741
+ var o = t.random || (t.rng || Xe)();
737
742
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ue(o);
738
743
  }
739
- const On = (t, e, n, o) => ({
740
- id: Xe(),
744
+ const In = (t, e, n, o) => ({
745
+ id: Ye(),
741
746
  annotation: t.id,
742
747
  created: n || /* @__PURE__ */ new Date(),
743
748
  creator: o,
744
749
  ...e
745
- }), ke = (t, e) => {
750
+ }), He = (t, e) => {
746
751
  const n = new Set(t.bodies.map((o) => o.id));
747
752
  return e.bodies.filter((o) => !n.has(o.id));
748
- }, Ye = (t, e) => {
753
+ }, $e = (t, e) => {
749
754
  const n = new Set(e.bodies.map((o) => o.id));
750
755
  return t.bodies.filter((o) => !n.has(o.id));
751
- }, He = (t, e) => e.bodies.map((n) => {
756
+ }, Pe = (t, e) => e.bodies.map((n) => {
752
757
  const o = t.bodies.find((i) => i.id === n.id);
753
758
  return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
754
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), $e = (t, e) => !q(t.target, e.target), Yt = (t, e) => {
755
- const n = ke(t, e), o = Ye(t, e), i = He(t, e);
759
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), ze = (t, e) => !q(t.target, e.target), Pt = (t, e) => {
760
+ const n = He(t, e), o = $e(t, e), i = Pe(t, e);
756
761
  return {
757
762
  oldValue: t,
758
763
  newValue: e,
759
764
  bodiesCreated: n.length > 0 ? n : void 0,
760
765
  bodiesDeleted: o.length > 0 ? o : void 0,
761
766
  bodiesUpdated: i.length > 0 ? i : void 0,
762
- targetUpdated: $e(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
767
+ targetUpdated: ze(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
763
768
  };
764
769
  };
765
770
  var B = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(B || {});
766
- const Pe = (t, e) => {
771
+ const Fe = (t, e) => {
767
772
  var n, o;
768
773
  const { changes: i, origin: r } = e;
769
774
  if (!(!t.options.origin || t.options.origin === r))
@@ -785,26 +790,26 @@ const Pe = (t, e) => {
785
790
  return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => a.has(s));
786
791
  } else
787
792
  return !0;
788
- }, ze = (t, e) => {
789
- const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), r = new Set((e.deleted || []).map((c) => c.id)), a = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), s = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), u = [
790
- ...(t.created || []).filter((c) => !r.has(c.id)).map((c) => a.has(c.id) ? e.updated.find(({ oldValue: p }) => p.id === c.id).newValue : c),
793
+ }, We = (t, e) => {
794
+ const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), a = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), s = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), u = [
795
+ ...(t.created || []).filter((l) => !r.has(l.id)).map((l) => a.has(l.id) ? e.updated.find(({ oldValue: p }) => p.id === l.id).newValue : l),
791
796
  ...e.created || []
792
797
  ], f = [
793
- ...(t.deleted || []).filter((c) => !i.has(c.id)),
794
- ...(e.deleted || []).filter((c) => !n.has(c.id))
798
+ ...(t.deleted || []).filter((l) => !i.has(l.id)),
799
+ ...(e.deleted || []).filter((l) => !n.has(l.id))
795
800
  ], m = [
796
- ...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
797
- const { oldValue: p, newValue: g } = c;
801
+ ...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
802
+ const { oldValue: p, newValue: g } = l;
798
803
  if (a.has(g.id)) {
799
804
  const x = e.updated.find((v) => v.oldValue.id === g.id).newValue;
800
- return Yt(p, x);
805
+ return Pt(p, x);
801
806
  } else
802
- return c;
807
+ return l;
803
808
  }),
804
- ...(e.updated || []).filter(({ oldValue: c }) => !s.has(c.id))
809
+ ...(e.updated || []).filter(({ oldValue: l }) => !s.has(l.id))
805
810
  ];
806
811
  return { created: u, deleted: f, updated: m };
807
- }, Fe = (t) => t.id !== void 0, We = () => {
812
+ }, qe = (t) => t.id !== void 0, je = () => {
808
813
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (b, w = {}) => n.push({ onChange: b, options: w }), i = (b) => {
809
814
  const w = n.findIndex((A) => A.onChange == b);
810
815
  w > -1 && n.splice(w, 1);
@@ -819,26 +824,26 @@ const Pe = (t, e) => {
819
824
  state: [...t.values()]
820
825
  };
821
826
  n.forEach((S) => {
822
- Pe(S, A) && S.onChange(A);
827
+ Fe(S, A) && S.onChange(A);
823
828
  });
824
829
  }, a = (b, w = B.LOCAL) => {
825
830
  if (t.get(b.id))
826
831
  throw Error(`Cannot add annotation ${b.id} - exists already`);
827
832
  t.set(b.id, b), b.bodies.forEach((A) => e.set(A.id, b.id)), r(w, { created: [b] });
828
833
  }, s = (b, w) => {
829
- const A = typeof b == "string" ? w : b, S = typeof b == "string" ? b : b.id, L = t.get(S);
830
- if (L) {
831
- const I = Yt(L, A);
832
- return S === A.id ? t.set(S, A) : (t.delete(S), t.set(A.id, A)), L.bodies.forEach((H) => e.delete(H.id)), A.bodies.forEach((H) => e.set(H.id, A.id)), I;
834
+ const A = typeof b == "string" ? w : b, S = typeof b == "string" ? b : b.id, R = t.get(S);
835
+ if (R) {
836
+ const M = Pt(R, A);
837
+ return S === A.id ? t.set(S, A) : (t.delete(S), t.set(A.id, A)), R.bodies.forEach((H) => e.delete(H.id)), A.bodies.forEach((H) => e.set(H.id, A.id)), M;
833
838
  } else
834
839
  console.warn(`Cannot update annotation ${S} - does not exist`);
835
840
  }, u = (b, w = B.LOCAL, A = B.LOCAL) => {
836
- const S = Fe(w) ? A : w, L = s(b, w);
837
- L && r(S, { updated: [L] });
841
+ const S = qe(w) ? A : w, R = s(b, w);
842
+ R && r(S, { updated: [R] });
838
843
  }, f = (b, w = B.LOCAL) => {
839
- const A = b.reduce((S, L) => {
840
- const I = s(L);
841
- return I ? [...S, I] : S;
844
+ const A = b.reduce((S, R) => {
845
+ const M = s(R);
846
+ return M ? [...S, M] : S;
842
847
  }, []);
843
848
  A.length > 0 && r(w, { updated: A });
844
849
  }, m = (b, w = B.LOCAL) => {
@@ -855,24 +860,24 @@ const Pe = (t, e) => {
855
860
  }] });
856
861
  } else
857
862
  console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
858
- }, c = () => [...t.values()], p = (b = B.LOCAL) => {
863
+ }, l = () => [...t.values()], p = (b = B.LOCAL) => {
859
864
  const w = [...t.values()];
860
865
  t.clear(), e.clear(), r(b, { deleted: w });
861
866
  }, g = (b, w = !0, A = B.LOCAL) => {
862
867
  if (w) {
863
868
  const S = [...t.values()];
864
- t.clear(), e.clear(), b.forEach((L) => {
865
- t.set(L.id, L), L.bodies.forEach((I) => e.set(I.id, L.id));
869
+ t.clear(), e.clear(), b.forEach((R) => {
870
+ t.set(R.id, R), R.bodies.forEach((M) => e.set(M.id, R.id));
866
871
  }), r(A, { created: b, deleted: S });
867
872
  } else {
868
- const S = b.reduce((L, I) => {
869
- const H = t.get(I.id);
870
- return H ? [...L, H] : L;
873
+ const S = b.reduce((R, M) => {
874
+ const H = t.get(M.id);
875
+ return H ? [...R, H] : R;
871
876
  }, []);
872
877
  if (S.length > 0)
873
- throw Error(`Bulk insert would overwrite the following annotations: ${S.map((L) => L.id).join(", ")}`);
874
- b.forEach((L) => {
875
- t.set(L.id, L), L.bodies.forEach((I) => e.set(I.id, L.id));
878
+ throw Error(`Bulk insert would overwrite the following annotations: ${S.map((R) => R.id).join(", ")}`);
879
+ b.forEach((R) => {
880
+ t.set(R.id, R), R.bodies.forEach((M) => e.set(M.id, R.id));
876
881
  }), r(A, { created: b });
877
882
  }
878
883
  }, x = (b) => {
@@ -884,9 +889,9 @@ const Pe = (t, e) => {
884
889
  const A = x(b);
885
890
  A && r(w, { deleted: [A] });
886
891
  }, h = (b, w = B.LOCAL) => {
887
- const A = b.reduce((S, L) => {
888
- const I = x(L);
889
- return I ? [...S, I] : S;
892
+ const A = b.reduce((S, R) => {
893
+ const M = x(R);
894
+ return M ? [...S, M] : S;
890
895
  }, []);
891
896
  A.length > 0 && r(w, { deleted: A });
892
897
  }, d = (b) => {
@@ -897,7 +902,7 @@ const Pe = (t, e) => {
897
902
  e.delete(A.id);
898
903
  const S = {
899
904
  ...w,
900
- bodies: w.bodies.filter((L) => L.id !== b.id)
905
+ bodies: w.bodies.filter((R) => R.id !== b.id)
901
906
  };
902
907
  return t.set(w.id, S), {
903
908
  oldValue: w,
@@ -908,7 +913,7 @@ const Pe = (t, e) => {
908
913
  console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
909
914
  } else
910
915
  console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
911
- }, l = (b, w = B.LOCAL) => {
916
+ }, c = (b, w = B.LOCAL) => {
912
917
  const A = d(b);
913
918
  A && r(w, { updated: [A] });
914
919
  }, y = (b, w = B.LOCAL) => {
@@ -931,13 +936,13 @@ const Pe = (t, e) => {
931
936
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
932
937
  const A = t.get(b.annotation);
933
938
  if (A) {
934
- const S = A.bodies.find((I) => I.id === b.id), L = {
939
+ const S = A.bodies.find((M) => M.id === b.id), R = {
935
940
  ...A,
936
- bodies: A.bodies.map((I) => I.id === S.id ? w : I)
941
+ bodies: A.bodies.map((M) => M.id === S.id ? w : M)
937
942
  };
938
- return t.set(A.id, L), S.id !== w.id && (e.delete(S.id), e.set(w.id, L.id)), {
943
+ return t.set(A.id, R), S.id !== w.id && (e.delete(S.id), e.set(w.id, R.id)), {
939
944
  oldValue: A,
940
- newValue: L,
945
+ newValue: R,
941
946
  bodiesUpdated: [{ oldBody: S, newBody: w }]
942
947
  };
943
948
  } else
@@ -945,7 +950,7 @@ const Pe = (t, e) => {
945
950
  }, N = (b, w, A = B.LOCAL) => {
946
951
  const S = E(b, w);
947
952
  S && r(A, { updated: [S] });
948
- }, R = (b, w = B.LOCAL) => {
953
+ }, L = (b, w = B.LOCAL) => {
949
954
  const A = b.map((S) => E({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
950
955
  r(w, { updated: A });
951
956
  }, O = (b) => {
@@ -972,19 +977,19 @@ const Pe = (t, e) => {
972
977
  return {
973
978
  addAnnotation: a,
974
979
  addBody: m,
975
- all: c,
980
+ all: l,
976
981
  bulkAddAnnotation: g,
977
982
  bulkDeleteAnnotation: h,
978
983
  bulkDeleteBodies: y,
979
984
  bulkUpdateAnnotation: f,
980
- bulkUpdateBodies: R,
985
+ bulkUpdateBodies: L,
981
986
  bulkUpdateTargets: (b, w = B.LOCAL) => {
982
987
  const A = b.map((S) => O(S)).filter(Boolean);
983
988
  A.length > 0 && r(w, { updated: A });
984
989
  },
985
990
  clear: p,
986
991
  deleteAnnotation: v,
987
- deleteBody: l,
992
+ deleteBody: c,
988
993
  getAnnotation: T,
989
994
  getBody: C,
990
995
  observe: o,
@@ -997,7 +1002,7 @@ const Pe = (t, e) => {
997
1002
  }
998
1003
  };
999
1004
  };
1000
- let qe = () => ({
1005
+ let Ge = () => ({
1001
1006
  emit(t, ...e) {
1002
1007
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
1003
1008
  o[n](...e);
@@ -1011,24 +1016,24 @@ let qe = () => ({
1011
1016
  };
1012
1017
  }
1013
1018
  });
1014
- const je = 250, Ge = (t) => {
1015
- const e = qe(), n = [];
1019
+ const Ke = 250, Qe = (t) => {
1020
+ const e = Ge(), n = [];
1016
1021
  let o = -1, i = !1, r = 0;
1017
1022
  const a = (g) => {
1018
1023
  if (!i) {
1019
1024
  const { changes: x } = g, v = performance.now();
1020
- if (v - r > je)
1025
+ if (v - r > Ke)
1021
1026
  n.splice(o + 1), n.push(x), o = n.length - 1;
1022
1027
  else {
1023
1028
  const h = n.length - 1;
1024
- n[h] = ze(n[h], x);
1029
+ n[h] = We(n[h], x);
1025
1030
  }
1026
1031
  r = v;
1027
1032
  }
1028
1033
  i = !1;
1029
1034
  };
1030
1035
  t.observe(a, { origin: B.LOCAL });
1031
- const s = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: x }) => x)), m = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: x }) => x)), c = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1036
+ const s = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: x }) => x)), m = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: x }) => x)), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1032
1037
  return {
1033
1038
  canRedo: () => n.length - 1 > o,
1034
1039
  canUndo: () => o > -1,
@@ -1045,32 +1050,32 @@ const je = 250, Ge = (t) => {
1045
1050
  if (o > -1) {
1046
1051
  i = !0;
1047
1052
  const { created: g, updated: x, deleted: v } = n[o];
1048
- s(g), f(x), c(v), e.emit("undo", n[o]), o -= 1;
1053
+ s(g), f(x), l(v), e.emit("undo", n[o]), o -= 1;
1049
1054
  }
1050
1055
  }
1051
1056
  };
1052
- }, Ke = () => {
1053
- const { subscribe: t, set: e } = bt([]);
1057
+ }, Je = () => {
1058
+ const { subscribe: t, set: e } = yt([]);
1054
1059
  return {
1055
1060
  subscribe: t,
1056
1061
  set: e
1057
1062
  };
1058
- }, Qe = (t, e, n, o) => {
1063
+ }, Ze = (t, e, n, o) => {
1059
1064
  const { store: i, selection: r, hover: a, viewport: s } = t, u = /* @__PURE__ */ new Map();
1060
1065
  let f = [], m;
1061
- const c = (v, h) => {
1066
+ const l = (v, h) => {
1062
1067
  u.has(v) ? u.get(v).push(h) : u.set(v, [h]);
1063
1068
  }, p = (v, h) => {
1064
1069
  const d = u.get(v);
1065
1070
  d && d.indexOf(h) > 0 && d.splice(d.indexOf(h), 1);
1066
1071
  }, g = (v, h, d) => {
1067
1072
  u.has(v) && setTimeout(() => {
1068
- u.get(v).forEach((l) => {
1073
+ u.get(v).forEach((c) => {
1069
1074
  if (n) {
1070
1075
  const y = Array.isArray(h) ? h.map((C) => n.serialize(C)) : n.serialize(h), T = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1071
- l(y, T);
1076
+ c(y, T);
1072
1077
  } else
1073
- l(h, d);
1078
+ c(h, d);
1074
1079
  });
1075
1080
  }, 1);
1076
1081
  };
@@ -1084,15 +1089,15 @@ const je = 250, Ge = (t) => {
1084
1089
  d && !q(d, h) && g("updateAnnotation", d, h);
1085
1090
  }), f = [];
1086
1091
  else {
1087
- const h = new Set(f.map((l) => l.id)), d = new Set(v.map(({ id: l }) => l));
1088
- f.filter((l) => !d.has(l.id)).forEach((l) => {
1089
- const y = i.getAnnotation(l.id);
1090
- y && !q(y, l) && g("updateAnnotation", y, l);
1092
+ const h = new Set(f.map((c) => c.id)), d = new Set(v.map(({ id: c }) => c));
1093
+ f.filter((c) => !d.has(c.id)).forEach((c) => {
1094
+ const y = i.getAnnotation(c.id);
1095
+ y && !q(y, c) && g("updateAnnotation", y, c);
1091
1096
  }), f = [
1092
1097
  // Remove annotations that were deselected
1093
- ...f.filter((l) => d.has(l.id)),
1098
+ ...f.filter((c) => d.has(c.id)),
1094
1099
  // Add editable annotations that were selected
1095
- ...v.filter(({ id: l }) => !h.has(l)).map(({ id: l }) => i.getAnnotation(l))
1100
+ ...v.filter(({ id: c }) => !h.has(c)).map(({ id: c }) => i.getAnnotation(c))
1096
1101
  ];
1097
1102
  }
1098
1103
  g("selectionChanged", f);
@@ -1101,26 +1106,26 @@ const je = 250, Ge = (t) => {
1101
1106
  !m && v ? g("mouseEnterAnnotation", i.getAnnotation(v)) : m && !v ? g("mouseLeaveAnnotation", i.getAnnotation(m)) : m && v && (g("mouseLeaveAnnotation", i.getAnnotation(m)), g("mouseEnterAnnotation", i.getAnnotation(v))), m = v;
1102
1107
  }), s == null || s.subscribe((v) => g("viewportIntersect", v.map((h) => i.getAnnotation(h)))), i.observe((v) => {
1103
1108
  const { created: h, deleted: d } = v.changes;
1104
- (h || []).forEach((l) => g("createAnnotation", l)), (d || []).forEach((l) => g("deleteAnnotation", l)), (v.changes.updated || []).filter((l) => [
1105
- ...l.bodiesCreated || [],
1106
- ...l.bodiesDeleted || [],
1107
- ...l.bodiesUpdated || []
1108
- ].length > 0).forEach(({ oldValue: l, newValue: y }) => {
1109
- const T = f.find((C) => C.id === l.id) || l;
1110
- f = f.map((C) => C.id === l.id ? y : C), g("updateAnnotation", y, T);
1109
+ (h || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (v.changes.updated || []).filter((c) => [
1110
+ ...c.bodiesCreated || [],
1111
+ ...c.bodiesDeleted || [],
1112
+ ...c.bodiesUpdated || []
1113
+ ].length > 0).forEach(({ oldValue: c, newValue: y }) => {
1114
+ const T = f.find((C) => C.id === c.id) || c;
1115
+ f = f.map((C) => C.id === c.id ? y : C), g("updateAnnotation", y, T);
1111
1116
  });
1112
1117
  }, { origin: B.LOCAL }), i.observe((v) => {
1113
1118
  if (f) {
1114
- const h = new Set(f.map((l) => l.id)), d = (v.changes.updated || []).filter(({ newValue: l }) => h.has(l.id)).map(({ newValue: l }) => l);
1115
- d.length > 0 && (f = f.map((l) => d.find((T) => T.id === l.id) || l));
1119
+ const h = new Set(f.map((c) => c.id)), d = (v.changes.updated || []).filter(({ newValue: c }) => h.has(c.id)).map(({ newValue: c }) => c);
1120
+ d.length > 0 && (f = f.map((c) => d.find((T) => T.id === c.id) || c));
1116
1121
  }
1117
1122
  }, { origin: B.REMOTE });
1118
1123
  const x = (v) => (h) => {
1119
1124
  const { updated: d } = h;
1120
- v ? (d || []).forEach((l) => g("updateAnnotation", l.oldValue, l.newValue)) : (d || []).forEach((l) => g("updateAnnotation", l.newValue, l.oldValue));
1125
+ v ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
1121
1126
  };
1122
- return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: c, off: p, emit: g };
1123
- }, Je = (t) => (e) => e.reduce((n, o) => {
1127
+ return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: l, off: p, emit: g };
1128
+ }, tn = (t) => (e) => e.reduce((n, o) => {
1124
1129
  const { parsed: i, error: r } = t.parse(o);
1125
1130
  return r ? {
1126
1131
  parsed: n.parsed,
@@ -1131,11 +1136,11 @@ const je = 250, Ge = (t) => {
1131
1136
  } : {
1132
1137
  ...n
1133
1138
  };
1134
- }, { parsed: [], failed: [] }), Ze = (t, e, n) => {
1139
+ }, { parsed: [], failed: [] }), en = (t, e, n) => {
1135
1140
  const { store: o, selection: i } = t, r = (h) => {
1136
1141
  if (n) {
1137
- const { parsed: d, error: l } = n.parse(h);
1138
- d ? o.addAnnotation(d, B.REMOTE) : console.error(l);
1142
+ const { parsed: d, error: c } = n.parse(h);
1143
+ d ? o.addAnnotation(d, B.REMOTE) : console.error(c);
1139
1144
  } else
1140
1145
  o.addAnnotation(h, B.REMOTE);
1141
1146
  }, a = () => i.clear(), s = () => o.clear(), u = (h) => {
@@ -1143,9 +1148,9 @@ const je = 250, Ge = (t) => {
1143
1148
  return n && d ? n.serialize(d) : d;
1144
1149
  }, f = () => n ? o.all().map(n.serialize) : o.all(), m = () => {
1145
1150
  var h;
1146
- const d = (((h = i.selected) == null ? void 0 : h.map((l) => l.id)) || []).map((l) => o.getAnnotation(l)).filter(Boolean);
1151
+ const d = (((h = i.selected) == null ? void 0 : h.map((c) => c.id)) || []).map((c) => o.getAnnotation(c)).filter(Boolean);
1147
1152
  return n ? d.map(n.serialize) : d;
1148
- }, c = (h, d = !0) => fetch(h).then((l) => l.json()).then((l) => (g(l, d), l)), p = (h) => {
1153
+ }, l = (h, d = !0) => fetch(h).then((c) => c.json()).then((c) => (g(c, d), c)), p = (h) => {
1149
1154
  if (typeof h == "string") {
1150
1155
  const d = o.getAnnotation(h);
1151
1156
  if (o.deleteAnnotation(h), d)
@@ -1157,16 +1162,16 @@ const je = 250, Ge = (t) => {
1157
1162
  }
1158
1163
  }, g = (h, d = !0) => {
1159
1164
  if (n) {
1160
- const { parsed: l, failed: y } = Je(n)(h);
1161
- y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(l, d, B.REMOTE);
1165
+ const { parsed: c, failed: y } = tn(n)(h);
1166
+ y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(c, d, B.REMOTE);
1162
1167
  } else
1163
1168
  o.bulkAddAnnotation(h, d, B.REMOTE);
1164
- }, x = (h) => {
1165
- h ? i.setSelected(h) : i.clear();
1169
+ }, x = (h, d) => {
1170
+ h ? i.setSelected(h, d) : i.clear();
1166
1171
  }, v = (h) => {
1167
1172
  if (n) {
1168
- const d = n.parse(h).parsed, l = n.serialize(o.getAnnotation(d.id));
1169
- return o.updateAnnotation(d), l;
1173
+ const d = n.parse(h).parsed, c = n.serialize(o.getAnnotation(d.id));
1174
+ return o.updateAnnotation(d), c;
1170
1175
  } else {
1171
1176
  const d = o.getAnnotation(h.id);
1172
1177
  return o.updateAnnotation(h), d;
@@ -1181,7 +1186,7 @@ const je = 250, Ge = (t) => {
1181
1186
  getAnnotationById: u,
1182
1187
  getAnnotations: f,
1183
1188
  getSelected: m,
1184
- loadAnnotations: c,
1189
+ loadAnnotations: l,
1185
1190
  redo: e.redo,
1186
1191
  removeAnnotation: p,
1187
1192
  setAnnotations: g,
@@ -1189,8 +1194,8 @@ const je = 250, Ge = (t) => {
1189
1194
  undo: e.undo,
1190
1195
  updateAnnotation: v
1191
1196
  };
1192
- }, tn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1193
- let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
1197
+ }, nn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1198
+ let on = (t) => crypto.getRandomValues(new Uint8Array(t)), rn = (t, e, n) => {
1194
1199
  let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
1195
1200
  return (r = e) => {
1196
1201
  let a = "";
@@ -1201,13 +1206,13 @@ let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
1201
1206
  return a;
1202
1207
  }
1203
1208
  };
1204
- }, on = (t, e = 21) => nn(t, e, en), rn = (t = 21) => {
1209
+ }, sn = (t, e = 21) => rn(t, e, on), an = (t = 21) => {
1205
1210
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
1206
1211
  for (; t--; )
1207
- e += tn[n[t] & 63];
1212
+ e += nn[n[t] & 63];
1208
1213
  return e;
1209
1214
  };
1210
- const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), an = (t) => {
1215
+ const cn = () => ({ isGuest: !0, id: sn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), ln = (t) => {
1211
1216
  const e = JSON.stringify(t);
1212
1217
  let n = 0;
1213
1218
  for (let o = 0, i = e.length; o < i; o++) {
@@ -1215,20 +1220,20 @@ const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABC
1215
1220
  n = (n << 5) - n + r, n |= 0;
1216
1221
  }
1217
1222
  return `${n}`;
1218
- }, Ht = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, cn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1223
+ }, zt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, dn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1219
1224
  const { id: o, type: i, purpose: r, value: a, created: s, modified: u, creator: f, ...m } = n;
1220
1225
  return {
1221
- id: o || `temp-${an(n)}`,
1226
+ id: o || `temp-${ln(n)}`,
1222
1227
  annotation: e,
1223
1228
  type: i,
1224
1229
  purpose: r,
1225
1230
  value: a,
1226
- creator: Ht(f),
1231
+ creator: zt(f),
1227
1232
  created: s ? new Date(s) : void 0,
1228
1233
  updated: u ? new Date(u) : void 0,
1229
1234
  ...m
1230
1235
  };
1231
- }), ln = (t) => t.map((e) => {
1236
+ }), un = (t) => t.map((e) => {
1232
1237
  var n;
1233
1238
  const { annotation: o, created: i, updated: r, ...a } = e, s = {
1234
1239
  ...a,
@@ -1237,11 +1242,11 @@ const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABC
1237
1242
  };
1238
1243
  return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
1239
1244
  });
1240
- rn();
1241
- const In = (t, e) => ({
1242
- parse: (n) => hn(n),
1243
- serialize: (n) => fn(n, t, e)
1244
- }), dn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, un = (t) => {
1245
+ an();
1246
+ const Vn = (t, e) => ({
1247
+ parse: (n) => gn(n),
1248
+ serialize: (n) => pn(n, t, e)
1249
+ }), hn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, fn = (t) => {
1245
1250
  const {
1246
1251
  id: e,
1247
1252
  creator: n,
@@ -1249,43 +1254,43 @@ const In = (t, e) => ({
1249
1254
  modified: i,
1250
1255
  target: r
1251
1256
  } = t, a = Array.isArray(r) ? r : [r], s = {
1252
- creator: Ht(n),
1257
+ creator: zt(n),
1253
1258
  created: o ? new Date(o) : void 0,
1254
1259
  updated: i ? new Date(i) : void 0,
1255
1260
  annotation: e,
1256
1261
  selector: []
1257
1262
  };
1258
1263
  for (const u of a) {
1259
- const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((c, p) => {
1264
+ const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l, p) => {
1260
1265
  switch (p.type) {
1261
1266
  case "TextQuoteSelector":
1262
- c.quote = p.exact;
1267
+ l.quote = p.exact;
1263
1268
  break;
1264
1269
  case "TextPositionSelector":
1265
- c.start = p.start, c.end = p.end;
1270
+ l.start = p.start, l.end = p.end;
1266
1271
  break;
1267
1272
  }
1268
- return c;
1273
+ return l;
1269
1274
  }, {});
1270
- if (dn(m))
1275
+ if (hn(m))
1271
1276
  s.selector.push({ id: u.id, ...m });
1272
1277
  else {
1273
- const c = [
1278
+ const l = [
1274
1279
  m.start ? void 0 : "TextPositionSelector",
1275
1280
  m.quote ? void 0 : "TextQuoteSelector"
1276
1281
  ].filter(Boolean);
1277
- return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`) };
1282
+ return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
1278
1283
  }
1279
1284
  }
1280
1285
  return { parsed: s };
1281
- }, hn = (t) => {
1282
- const e = t.id || kt(), {
1286
+ }, gn = (t) => {
1287
+ const e = t.id || $t(), {
1283
1288
  creator: n,
1284
1289
  created: o,
1285
1290
  modified: i,
1286
1291
  body: r,
1287
1292
  ...a
1288
- } = t, s = cn(r, e), u = un(t);
1293
+ } = t, s = dn(r, e), u = fn(t);
1289
1294
  return "error" in u ? { error: u.error } : {
1290
1295
  parsed: {
1291
1296
  ...a,
@@ -1294,19 +1299,19 @@ const In = (t, e) => ({
1294
1299
  target: u.parsed
1295
1300
  }
1296
1301
  };
1297
- }, fn = (t, e, n) => {
1302
+ }, pn = (t, e, n) => {
1298
1303
  const { bodies: o, target: i, ...r } = t, {
1299
1304
  selector: a,
1300
1305
  creator: s,
1301
1306
  created: u,
1302
1307
  updated: f,
1303
1308
  ...m
1304
- } = i, c = a.map((p) => {
1305
- const { quote: g, start: x, end: v, range: h } = p, { prefix: d, suffix: l } = te(h, n), y = [{
1309
+ } = i, l = a.map((p) => {
1310
+ const { quote: g, start: x, end: v, range: h } = p, { prefix: d, suffix: c } = oe(h, n), y = [{
1306
1311
  type: "TextQuoteSelector",
1307
1312
  exact: g,
1308
1313
  prefix: d,
1309
- suffix: l
1314
+ suffix: c
1310
1315
  }, {
1311
1316
  type: "TextPositionSelector",
1312
1317
  start: x,
@@ -1324,21 +1329,21 @@ const In = (t, e) => ({
1324
1329
  "@context": "http://www.w3.org/ns/anno.jsonld",
1325
1330
  id: t.id,
1326
1331
  type: "Annotation",
1327
- body: ln(t.bodies),
1332
+ body: un(t.bodies),
1328
1333
  creator: s,
1329
1334
  created: u == null ? void 0 : u.toISOString(),
1330
1335
  modified: f == null ? void 0 : f.toISOString(),
1331
- target: c
1336
+ target: l
1332
1337
  };
1333
1338
  };
1334
- function gn(t, e, n, o, i) {
1335
- $t(t, e, n || 0, o || t.length - 1, i || pn);
1339
+ function mn(t, e, n, o, i) {
1340
+ Ft(t, e, n || 0, o || t.length - 1, i || bn);
1336
1341
  }
1337
- function $t(t, e, n, o, i) {
1342
+ function Ft(t, e, n, o, i) {
1338
1343
  for (; o > n; ) {
1339
1344
  if (o - n > 600) {
1340
- var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), f = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - a * u / r + f)), c = Math.min(o, Math.floor(e + (r - a) * u / r + f));
1341
- $t(t, e, m, c, i);
1345
+ var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), f = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - a * u / r + f)), l = Math.min(o, Math.floor(e + (r - a) * u / r + f));
1346
+ Ft(t, e, m, l, i);
1342
1347
  }
1343
1348
  var p = t[e], g = n, x = o;
1344
1349
  for (j(t, n, e), i(t[o], p) > 0 && j(t, n, o); g < x; ) {
@@ -1354,10 +1359,10 @@ function j(t, e, n) {
1354
1359
  var o = t[e];
1355
1360
  t[e] = t[n], t[n] = o;
1356
1361
  }
1357
- function pn(t, e) {
1362
+ function bn(t, e) {
1358
1363
  return t < e ? -1 : t > e ? 1 : 0;
1359
1364
  }
1360
- class mn {
1365
+ class vn {
1361
1366
  constructor(e = 9) {
1362
1367
  this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
1363
1368
  }
@@ -1373,7 +1378,7 @@ class mn {
1373
1378
  for (; n; ) {
1374
1379
  for (let a = 0; a < n.children.length; a++) {
1375
1380
  const s = n.children[a], u = n.leaf ? i(s) : s;
1376
- nt(e, u) && (n.leaf ? o.push(s) : ht(e, u) ? this._all(s, o) : r.push(s));
1381
+ nt(e, u) && (n.leaf ? o.push(s) : gt(e, u) ? this._all(s, o) : r.push(s));
1377
1382
  }
1378
1383
  n = r.pop();
1379
1384
  }
@@ -1388,7 +1393,7 @@ class mn {
1388
1393
  for (let i = 0; i < n.children.length; i++) {
1389
1394
  const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;
1390
1395
  if (nt(e, a)) {
1391
- if (n.leaf || ht(e, a))
1396
+ if (n.leaf || gt(e, a))
1392
1397
  return !0;
1393
1398
  o.push(r);
1394
1399
  }
@@ -1433,11 +1438,11 @@ class mn {
1433
1438
  let s, u, f;
1434
1439
  for (; o || r.length; ) {
1435
1440
  if (o || (o = r.pop(), u = r[r.length - 1], s = a.pop(), f = !0), o.leaf) {
1436
- const m = bn(e, o.children, n);
1441
+ const m = yn(e, o.children, n);
1437
1442
  if (m !== -1)
1438
1443
  return o.children.splice(m, 1), r.push(o), this._condense(r), this;
1439
1444
  }
1440
- !f && !o.leaf && ht(o, i) ? (r.push(o), a.push(s), s = 0, u = o, o = o.children[0]) : u ? (s++, o = u.children[s], f = !1) : o = null;
1445
+ !f && !o.leaf && gt(o, i) ? (r.push(o), a.push(s), s = 0, u = o, o = o.children[0]) : u ? (s++, o = u.children[s], f = !1) : o = null;
1441
1446
  }
1442
1447
  return this;
1443
1448
  }
@@ -1469,12 +1474,12 @@ class mn {
1469
1474
  return s = W(e.slice(n, o + 1)), F(s, this.toBBox), s;
1470
1475
  i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s = W([]), s.leaf = !1, s.height = i;
1471
1476
  const u = Math.ceil(r / a), f = u * Math.ceil(Math.sqrt(a));
1472
- It(e, n, o, f, this.compareMinX);
1477
+ Dt(e, n, o, f, this.compareMinX);
1473
1478
  for (let m = n; m <= o; m += f) {
1474
- const c = Math.min(m + f - 1, o);
1475
- It(e, m, c, u, this.compareMinY);
1476
- for (let p = m; p <= c; p += u) {
1477
- const g = Math.min(p + u - 1, c);
1479
+ const l = Math.min(m + f - 1, o);
1480
+ Dt(e, m, l, u, this.compareMinY);
1481
+ for (let p = m; p <= l; p += u) {
1482
+ const g = Math.min(p + u - 1, l);
1478
1483
  s.children.push(this._build(e, p, g, i - 1));
1479
1484
  }
1480
1485
  }
@@ -1484,8 +1489,8 @@ class mn {
1484
1489
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1485
1490
  let r = 1 / 0, a = 1 / 0, s;
1486
1491
  for (let u = 0; u < n.children.length; u++) {
1487
- const f = n.children[u], m = ut(f), c = wn(e, f) - m;
1488
- c < a ? (a = c, r = m < r ? m : r, s = f) : c === a && m < r && (r = m, s = f);
1492
+ const f = n.children[u], m = ft(f), l = An(e, f) - m;
1493
+ l < a ? (a = l, r = m < r ? m : r, s = f) : l === a && m < r && (r = m, s = f);
1489
1494
  }
1490
1495
  n = s || n.children[0];
1491
1496
  }
@@ -1510,14 +1515,14 @@ class mn {
1510
1515
  _chooseSplitIndex(e, n, o) {
1511
1516
  let i, r = 1 / 0, a = 1 / 0;
1512
1517
  for (let s = n; s <= o - n; s++) {
1513
- const u = G(e, 0, s, this.toBBox), f = G(e, s, o, this.toBBox), m = xn(u, f), c = ut(u) + ut(f);
1514
- m < r ? (r = m, i = s, a = c < a ? c : a) : m === r && c < a && (a = c, i = s);
1518
+ const u = G(e, 0, s, this.toBBox), f = G(e, s, o, this.toBBox), m = En(u, f), l = ft(u) + ft(f);
1519
+ m < r ? (r = m, i = s, a = l < a ? l : a) : m === r && l < a && (a = l, i = s);
1515
1520
  }
1516
1521
  return i || o - n;
1517
1522
  }
1518
1523
  // sorts node children by the best axis for split
1519
1524
  _chooseSplitAxis(e, n, o) {
1520
- const i = e.leaf ? this.compareMinX : vn, r = e.leaf ? this.compareMinY : yn, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
1525
+ const i = e.leaf ? this.compareMinX : wn, r = e.leaf ? this.compareMinY : xn, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
1521
1526
  a < s && e.children.sort(i);
1522
1527
  }
1523
1528
  // total margin of all possible split distributions where each node is at least m full
@@ -1544,7 +1549,7 @@ class mn {
1544
1549
  e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : F(e[n], this.toBBox);
1545
1550
  }
1546
1551
  }
1547
- function bn(t, e, n) {
1552
+ function yn(t, e, n) {
1548
1553
  if (!n)
1549
1554
  return e.indexOf(t);
1550
1555
  for (let o = 0; o < e.length; o++)
@@ -1566,26 +1571,26 @@ function G(t, e, n, o, i) {
1566
1571
  function K(t, e) {
1567
1572
  return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
1568
1573
  }
1569
- function vn(t, e) {
1574
+ function wn(t, e) {
1570
1575
  return t.minX - e.minX;
1571
1576
  }
1572
- function yn(t, e) {
1577
+ function xn(t, e) {
1573
1578
  return t.minY - e.minY;
1574
1579
  }
1575
- function ut(t) {
1580
+ function ft(t) {
1576
1581
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1577
1582
  }
1578
1583
  function et(t) {
1579
1584
  return t.maxX - t.minX + (t.maxY - t.minY);
1580
1585
  }
1581
- function wn(t, e) {
1586
+ function An(t, e) {
1582
1587
  return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
1583
1588
  }
1584
- function xn(t, e) {
1589
+ function En(t, e) {
1585
1590
  const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);
1586
1591
  return Math.max(0, i - n) * Math.max(0, r - o);
1587
1592
  }
1588
- function ht(t, e) {
1593
+ function gt(t, e) {
1589
1594
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1590
1595
  }
1591
1596
  function nt(t, e) {
@@ -1602,27 +1607,27 @@ function W(t) {
1602
1607
  maxY: -1 / 0
1603
1608
  };
1604
1609
  }
1605
- function It(t, e, n, o, i) {
1610
+ function Dt(t, e, n, o, i) {
1606
1611
  const r = [e, n];
1607
1612
  for (; r.length; ) {
1608
1613
  if (n = r.pop(), e = r.pop(), n - e <= o)
1609
1614
  continue;
1610
1615
  const a = e + Math.ceil((n - e) / o / 2) * o;
1611
- gn(t, a, e, n, i), r.push(e, a, a, n);
1616
+ mn(t, a, e, n, i), r.push(e, a, a, n);
1612
1617
  }
1613
1618
  }
1614
- const An = (t, e) => {
1615
- const n = new mn(), o = /* @__PURE__ */ new Map(), i = (d, l) => {
1619
+ const Sn = (t, e) => {
1620
+ const n = new vn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
1616
1621
  const y = d.selector.flatMap((C) => {
1617
- const N = C.range instanceof Range && !C.range.collapsed && C.range.startContainer.nodeType === Node.TEXT_NODE && C.range.endContainer.nodeType === Node.TEXT_NODE ? C.range : _t(C, e).range;
1622
+ const N = C.range instanceof Range && !C.range.collapsed && C.range.startContainer.nodeType === Node.TEXT_NODE && C.range.endContainer.nodeType === Node.TEXT_NODE ? C.range : Xt(C, e).range;
1618
1623
  return Array.from(N.getClientRects());
1619
- }), T = oe(y).map(({ left: C, top: E, right: N, bottom: R }) => new DOMRect(C - l.left, E - l.top, N - C, R - E));
1624
+ }), T = se(y).map(({ left: C, top: E, right: N, bottom: L }) => new DOMRect(C - c.left, E - c.top, N - C, L - E));
1620
1625
  return T.map((C) => {
1621
- const { x: E, y: N, width: R, height: O } = C;
1626
+ const { x: E, y: N, width: L, height: O } = C;
1622
1627
  return {
1623
1628
  minX: E,
1624
1629
  minY: N,
1625
- maxX: E + R,
1630
+ maxX: E + L,
1626
1631
  maxY: N + O,
1627
1632
  annotation: {
1628
1633
  id: d.annotation,
@@ -1633,50 +1638,50 @@ const An = (t, e) => {
1633
1638
  }, r = () => [...o.values()], a = () => {
1634
1639
  n.clear(), o.clear();
1635
1640
  }, s = (d) => {
1636
- const l = i(d, e.getBoundingClientRect());
1637
- l.forEach((y) => n.insert(y)), o.set(d.annotation, l);
1641
+ const c = i(d, e.getBoundingClientRect());
1642
+ c.forEach((y) => n.insert(y)), o.set(d.annotation, c);
1638
1643
  }, u = (d) => {
1639
- const l = o.get(d.annotation);
1640
- l && (l.forEach((y) => n.remove(y)), o.delete(d.annotation));
1644
+ const c = o.get(d.annotation);
1645
+ c && (c.forEach((y) => n.remove(y)), o.delete(d.annotation));
1641
1646
  }, f = (d) => {
1642
1647
  u(d), s(d);
1643
- }, m = (d, l = !0) => {
1644
- l && a();
1648
+ }, m = (d, c = !0) => {
1649
+ c && a();
1645
1650
  const y = e.getBoundingClientRect(), T = d.map((E) => ({ target: E, rects: i(E, y) }));
1646
1651
  T.forEach(({ target: E, rects: N }) => o.set(E.annotation, N));
1647
1652
  const C = T.reduce((E, { rects: N }) => [...E, ...N], []);
1648
1653
  n.load(C);
1649
- }, c = (d, l) => {
1654
+ }, l = (d, c) => {
1650
1655
  const y = n.search({
1651
1656
  minX: d,
1652
- minY: l,
1657
+ minY: c,
1653
1658
  maxX: d,
1654
- maxY: l
1659
+ maxY: c
1655
1660
  }), T = (C) => C.annotation.rects.reduce((E, N) => E + N.width * N.height, 0);
1656
1661
  if (y.length > 0)
1657
1662
  return y.sort((C, E) => T(C) - T(E)), y[0].annotation.id;
1658
1663
  }, p = (d) => {
1659
- const l = g(d);
1660
- if (l.length === 0)
1664
+ const c = g(d);
1665
+ if (c.length === 0)
1661
1666
  return;
1662
- let y = l[0].left, T = l[0].top, C = l[0].right, E = l[0].bottom;
1663
- for (let N = 1; N < l.length; N++) {
1664
- const R = l[N];
1665
- y = Math.min(y, R.left), T = Math.min(T, R.top), C = Math.max(C, R.right), E = Math.max(E, R.bottom);
1667
+ let y = c[0].left, T = c[0].top, C = c[0].right, E = c[0].bottom;
1668
+ for (let N = 1; N < c.length; N++) {
1669
+ const L = c[N];
1670
+ y = Math.min(y, L.left), T = Math.min(T, L.top), C = Math.max(C, L.right), E = Math.max(E, L.bottom);
1666
1671
  }
1667
1672
  return new DOMRect(y, T, C - y, E - T);
1668
1673
  }, g = (d) => {
1669
- const l = o.get(d);
1670
- return l ? l[0].annotation.rects : [];
1674
+ const c = o.get(d);
1675
+ return c ? c[0].annotation.rects : [];
1671
1676
  };
1672
1677
  return {
1673
1678
  all: r,
1674
1679
  clear: a,
1675
- getAt: c,
1680
+ getAt: l,
1676
1681
  getAnnotationBounds: p,
1677
1682
  getAnnotationRects: g,
1678
- getIntersecting: (d, l, y, T) => {
1679
- const C = n.search({ minX: d, minY: l, maxX: y, maxY: T }), E = new Set(C.reduce((N, R) => [...N, R.annotation.id], []));
1683
+ getIntersecting: (d, c, y, T) => {
1684
+ const C = n.search({ minX: d, minY: c, maxX: y, maxY: T }), E = new Set(C.reduce((N, L) => [...N, L.annotation.id], []));
1680
1685
  return Array.from(E).map((N) => ({
1681
1686
  annotation: t.getAnnotation(N),
1682
1687
  rects: g(N)
@@ -1689,32 +1694,32 @@ const An = (t, e) => {
1689
1694
  size: () => n.all().length,
1690
1695
  update: f
1691
1696
  };
1692
- }, En = (t, e) => {
1693
- const n = We(), o = An(n, t), i = Ie(n, e), r = Be(n), a = Ke(), s = (v, h = B.LOCAL) => {
1694
- const d = rt(v, t), l = $(d.target.selector);
1695
- return l && n.addAnnotation(d, h), l;
1697
+ }, Cn = (t, e) => {
1698
+ const n = je(), o = Sn(n, t), i = De(n, e), r = Ie(n), a = Je(), s = (v, h = B.LOCAL) => {
1699
+ const d = rt(v, t), c = $(d.target.selector);
1700
+ return c && n.addAnnotation(d, h), c;
1696
1701
  }, u = (v, h = !0, d = B.LOCAL) => {
1697
- const l = v.map((T) => rt(T, t)), y = l.filter((T) => !$(T.target.selector));
1698
- return y.length > 0 ? (console.warn("Could not revive all targets for these annotations:", y), n.bulkAddAnnotation(l, h, d), y) : (n.bulkAddAnnotation(l, h, d), []);
1702
+ const c = v.map((T) => rt(T, t)), y = c.filter((T) => !$(T.target.selector));
1703
+ return y.length > 0 ? (console.warn("Could not revive all targets for these annotations:", y), n.bulkAddAnnotation(c, h, d), y) : (n.bulkAddAnnotation(c, h, d), []);
1699
1704
  }, f = (v, h = B.LOCAL) => {
1700
- const d = v.map((y) => rt(y, t)), l = d.filter((y) => !$(y.target.selector));
1701
- return l.length > 0 && console.warn("Could not revive all targets for these annotations:", l), d.forEach((y) => {
1705
+ const d = v.map((y) => rt(y, t)), c = d.filter((y) => !$(y.target.selector));
1706
+ return c.length > 0 && console.warn("Could not revive all targets for these annotations:", c), d.forEach((y) => {
1702
1707
  n.getAnnotation(y.id) ? n.updateAnnotation(y, h) : n.addAnnotation(y, h);
1703
- }), l;
1708
+ }), c;
1704
1709
  }, m = (v, h = B.LOCAL) => {
1705
1710
  const d = it(v, t);
1706
1711
  n.updateTarget(d, h);
1707
- }, c = (v, h = B.LOCAL) => {
1708
- const d = v.map((l) => it(l, t));
1712
+ }, l = (v, h = B.LOCAL) => {
1713
+ const d = v.map((c) => it(c, t));
1709
1714
  n.bulkUpdateTargets(d, h);
1710
1715
  }, p = (v, h) => {
1711
1716
  const d = o.getAt(v, h);
1712
1717
  return d ? n.getAnnotation(d) : void 0;
1713
- }, g = (v, h, d, l = 5) => {
1718
+ }, g = (v, h, d, c = 5) => {
1714
1719
  const y = o.getAnnotationRects(v);
1715
1720
  if (y.length !== 0) {
1716
1721
  if (h && d) {
1717
- const T = y.find(({ top: C, right: E, bottom: N, left: R }) => h >= R - l && h <= E + l && d >= C - l && d <= N + l);
1722
+ const T = y.find(({ top: C, right: E, bottom: N, left: L }) => h >= L - c && h <= E + c && d >= C - c && d <= N + c);
1718
1723
  if (T)
1719
1724
  return T;
1720
1725
  }
@@ -1722,14 +1727,14 @@ const An = (t, e) => {
1722
1727
  }
1723
1728
  }, x = () => o.recalculate();
1724
1729
  return n.observe(({ changes: v }) => {
1725
- const h = (v.created || []).filter((y) => $(y.target.selector)), d = (v.deleted || []).filter((y) => $(y.target.selector)), l = (v.updated || []).filter((y) => $(y.newValue.target.selector));
1726
- h.length > 0 && o.set(h.map((y) => y.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach((y) => o.remove(y.target)), (l == null ? void 0 : l.length) > 0 && l.forEach(({ newValue: y }) => o.update(y.target));
1730
+ const h = (v.created || []).filter((y) => $(y.target.selector)), d = (v.deleted || []).filter((y) => $(y.target.selector)), c = (v.updated || []).filter((y) => $(y.newValue.target.selector));
1731
+ h.length > 0 && o.set(h.map((y) => y.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach((y) => o.remove(y.target)), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: y }) => o.update(y.target));
1727
1732
  }), {
1728
1733
  store: {
1729
1734
  ...n,
1730
1735
  addAnnotation: s,
1731
1736
  bulkAddAnnotation: u,
1732
- bulkUpdateTargets: c,
1737
+ bulkUpdateTargets: l,
1733
1738
  bulkUpsertAnnotations: f,
1734
1739
  getAnnotationBounds: g,
1735
1740
  getAt: p,
@@ -1741,32 +1746,32 @@ const An = (t, e) => {
1741
1746
  hover: r,
1742
1747
  viewport: a
1743
1748
  };
1744
- }, Sn = () => {
1749
+ }, Tn = () => {
1745
1750
  const t = document.createElement("canvas");
1746
1751
  t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-highlight-layer presence";
1747
1752
  const e = t.getContext("2d");
1748
1753
  return e.scale(2, 2), e.translate(0.5, 0.5), t;
1749
- }, Cn = (t, e, n = {}) => {
1750
- const o = Sn(), i = o.getContext("2d");
1754
+ }, Nn = (t, e, n = {}) => {
1755
+ const o = Tn(), i = o.getContext("2d");
1751
1756
  t.appendChild(o);
1752
- const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([p, g]) => g.presenceKey === c.presenceKey).map(([p, g]) => p);
1753
- return e.on("selectionChange", (c, p) => {
1754
- a(c).forEach((x) => r.delete(x)), p && p.forEach((x) => r.set(x, c));
1757
+ const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([p, g]) => g.presenceKey === l.presenceKey).map(([p, g]) => p);
1758
+ return e.on("selectionChange", (l, p) => {
1759
+ a(l).forEach((x) => r.delete(x)), p && p.forEach((x) => r.set(x, l));
1755
1760
  }), {
1756
1761
  clear: () => {
1757
- const { width: c, height: p } = o;
1758
- i.clearRect(-0.5, -0.5, c + 1, p + 1);
1762
+ const { width: l, height: p } = o;
1763
+ i.clearRect(-0.5, -0.5, l + 1, p + 1);
1759
1764
  },
1760
1765
  destroy: () => {
1761
1766
  o.remove();
1762
1767
  },
1763
- paint: (c, p, g) => {
1768
+ paint: (l, p, g) => {
1764
1769
  n.font && (i.font = n.font);
1765
- const x = r.get(c.annotation.id);
1770
+ const x = r.get(l.annotation.id);
1766
1771
  if (x) {
1767
- const { height: v } = c.rects[0], h = c.rects[0].x + p.left, d = c.rects[0].y + p.top;
1772
+ const { height: v } = l.rects[0], h = l.rects[0].x + p.left, d = l.rects[0].y + p.top;
1768
1773
  i.fillStyle = x.appearance.color, i.fillRect(h - 2, d - 2.5, 2, v + 5);
1769
- const l = i.measureText(x.appearance.label), y = l.width + 6, T = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, C = l.fontBoundingBoxAscent ? 8 : 6.5;
1774
+ const c = i.measureText(x.appearance.label), y = c.width + 6, T = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, C = c.fontBoundingBoxAscent ? 8 : 6.5;
1770
1775
  return i.fillRect(h - 2, d - 2.5 - T, y, T), i.fillStyle = "#fff", i.fillText(x.appearance.label, h + 1, d - C), {
1771
1776
  fill: x.appearance.color,
1772
1777
  fillOpacity: g ? 0.45 : 0.18
@@ -1775,67 +1780,68 @@ const An = (t, e) => {
1775
1780
  },
1776
1781
  reset: () => {
1777
1782
  o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
1778
- const c = o.getContext("2d");
1779
- c.scale(2, 2), c.translate(0.5, 0.5);
1783
+ const l = o.getContext("2d");
1784
+ l.scale(2, 2), l.translate(0.5, 0.5);
1780
1785
  }
1781
1786
  };
1782
- }, Pt = (t) => {
1787
+ }, Wt = (t) => {
1783
1788
  if (t === null)
1784
1789
  return document.scrollingElement;
1785
1790
  const { overflowY: e } = window.getComputedStyle(t);
1786
- return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Pt(t.parentElement);
1787
- }, Tn = (t, e) => (n) => {
1788
- const o = (r) => {
1789
- const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: m, height: c } = e.getAnnotationBounds(n.id), p = f.top - a.top, g = f.left - a.left, x = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = p + x - (s - c) / 2, d = g + v - (u - m) / 2;
1790
- i.scroll({ top: h, left: d, behavior: "smooth" });
1791
- }, i = Pt(t);
1792
- if (i) {
1793
- const r = e.getAnnotation(n.id), { range: a } = r.target.selector[0];
1794
- if (a && !a.collapsed)
1795
- return o(r.target), !0;
1791
+ return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Wt(t.parentElement);
1792
+ }, Ln = (t, e) => (n) => {
1793
+ const o = typeof n == "string" ? n : n.id, i = (a) => {
1794
+ const s = r.getBoundingClientRect(), u = r.clientHeight, f = r.clientWidth, m = a.selector[0].range.getBoundingClientRect(), { width: l, height: p } = e.getAnnotationBounds(o), g = m.top - s.top, x = m.left - s.left, v = r.parentElement ? r.scrollTop : 0, h = r.parentElement ? r.scrollLeft : 0, d = g + v - (u - p) / 2, c = x + h - (f - l) / 2;
1795
+ r.scroll({ top: d, left: c, behavior: "smooth" });
1796
+ }, r = Wt(t);
1797
+ if (r) {
1798
+ const a = e.getAnnotation(o), { range: s } = a.target.selector[0];
1799
+ if (s && !s.collapsed)
1800
+ return i(a.target), !0;
1796
1801
  {
1797
- const s = it(r.target, t), { range: u } = s.selector[0];
1798
- if (u && !u.collapsed)
1799
- return o(s), !0;
1802
+ const u = it(a.target, t), { range: f } = u.selector[0];
1803
+ if (f && !f.collapsed)
1804
+ return i(u), !0;
1800
1805
  }
1801
1806
  }
1802
1807
  return !1;
1803
- }, Nn = (t, e) => ({
1808
+ }, Rn = (t, e) => ({
1804
1809
  ...t,
1805
1810
  annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled
1806
- }), Rn = (t, e, n, o) => {
1811
+ }), Bn = (t, e, n, o) => {
1807
1812
  const { store: i, selection: r } = e;
1808
1813
  let a, s;
1809
1814
  const u = (h) => a = h;
1810
1815
  let f = !1, m;
1811
- const c = (h) => {
1812
- var l;
1816
+ const l = (h) => {
1817
+ var c;
1813
1818
  if (!f)
1814
1819
  return;
1815
- !((l = h.target.parentElement) != null && l.closest(X)) ? s = {
1816
- annotation: kt(),
1820
+ !((c = h.target.parentElement) != null && c.closest(X)) ? s = {
1821
+ annotation: $t(),
1817
1822
  selector: [],
1818
1823
  creator: a,
1819
1824
  created: /* @__PURE__ */ new Date()
1820
1825
  } : s = void 0;
1821
1826
  };
1822
- n && t.addEventListener("selectstart", c);
1823
- const p = pt((h) => {
1824
- var N, R;
1827
+ n && t.addEventListener("selectstart", l);
1828
+ const p = bt((h) => {
1829
+ var N, L;
1825
1830
  const d = document.getSelection();
1826
- if (!!((R = (N = d.anchorNode) == null ? void 0 : N.parentElement) != null && R.closest(X))) {
1831
+ if (!!((L = (N = d.anchorNode) == null ? void 0 : N.parentElement) != null && L.closest(X))) {
1827
1832
  s = void 0;
1828
1833
  return;
1829
1834
  }
1830
- if (h.timeStamp - ((m == null ? void 0 : m.timeStamp) || h.timeStamp) < 1e3 && !s && c(m), d.isCollapsed || !f || !s)
1835
+ if (h.timeStamp - ((m == null ? void 0 : m.timeStamp) || h.timeStamp) < 1e3 && !s && l(m), d.isCollapsed || !f || !s)
1831
1836
  return;
1832
- const y = d.getRangeAt(0), T = re(y.cloneRange()), C = Kt(T);
1837
+ const y = d.getRangeAt(0), T = ce(y.cloneRange()), C = Zt(T);
1833
1838
  (C.length !== s.selector.length || C.some((O, b) => {
1834
1839
  var w;
1835
1840
  return O.toString() !== ((w = s.selector[b]) == null ? void 0 : w.quote);
1836
1841
  })) && (s = {
1837
1842
  ...s,
1838
- selector: C.map((O) => ie(O, t, o))
1843
+ selector: C.map((O) => ae(O, t, o)),
1844
+ updated: /* @__PURE__ */ new Date()
1839
1845
  }, i.getAnnotation(s.annotation) ? i.updateTarget(s, B.LOCAL) : (i.addAnnotation({
1840
1846
  id: s.annotation,
1841
1847
  bodies: [],
@@ -1844,50 +1850,50 @@ const An = (t, e) => {
1844
1850
  });
1845
1851
  n && document.addEventListener("selectionchange", p);
1846
1852
  const g = (h) => {
1847
- const { target: d, timeStamp: l, offsetX: y, offsetY: T, type: C } = h;
1848
- m = { ...h, target: d, timeStamp: l, offsetX: y, offsetY: T, type: C }, f = h.button === 0;
1853
+ const { target: d, timeStamp: c, offsetX: y, offsetY: T, type: C } = h;
1854
+ m = { ...h, target: d, timeStamp: c, offsetX: y, offsetY: T, type: C }, f = h.button === 0;
1849
1855
  };
1850
1856
  t.addEventListener("pointerdown", g);
1851
1857
  const x = (h) => {
1852
1858
  var T;
1853
1859
  if (!!((T = h.target.parentElement) != null && T.closest(X)) || !f)
1854
1860
  return;
1855
- const l = () => {
1861
+ const c = () => {
1856
1862
  const { x: C, y: E } = t.getBoundingClientRect(), N = i.getAt(h.clientX - C, h.clientY - E);
1857
1863
  if (N) {
1858
- const { selected: R } = r;
1859
- (R.length !== 1 || R[0].id !== N.id) && r.clickSelect(N.id, h);
1864
+ const { selected: L } = r;
1865
+ (L.length !== 1 || L[0].id !== N.id) && r.clickSelect(N.id, h);
1860
1866
  } else
1861
1867
  r.isEmpty() || r.clear();
1862
1868
  }, y = h.timeStamp - m.timeStamp;
1863
- document.getSelection().isCollapsed && y < 300 ? (s = void 0, l()) : s && r.clickSelect(s.annotation, h);
1869
+ document.getSelection().isCollapsed && y < 300 ? (s = void 0, c()) : s && r.clickSelect(s.annotation, h);
1864
1870
  };
1865
1871
  return document.addEventListener("pointerup", x), {
1866
1872
  destroy: () => {
1867
- t.removeEventListener("selectstart", c), document.removeEventListener("selectionchange", p), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", x);
1873
+ t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", p), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", x);
1868
1874
  },
1869
1875
  setUser: u
1870
1876
  };
1871
- }, Mt = "SPANS", Mn = (t, e = {}) => {
1872
- Qt(t);
1873
- const n = Nn(e, {
1877
+ }, Ut = "SPANS", Dn = (t, e = {}) => {
1878
+ te(t);
1879
+ const n = Rn(e, {
1874
1880
  annotationEnabled: !0
1875
- }), o = En(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Ge(a), u = Qe(o, s, n.adapter);
1876
- let f = sn();
1877
- const m = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Mt : n.renderer || Mt, c = m === "SPANS" ? Se(t, o, r) : m === "CSS_HIGHLIGHTS" ? xe(t, o, r) : m === "CANVAS" ? ue(t, o, r) : void 0;
1878
- if (!c)
1881
+ }), o = Cn(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Qe(a), u = Ze(o, s, n.adapter);
1882
+ let f = cn();
1883
+ const m = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Ut : n.renderer || Ut, l = m === "SPANS" ? Ne(t, o, r) : m === "CSS_HIGHLIGHTS" ? Se(t, o, r) : m === "CANVAS" ? ge(t, o, r) : void 0;
1884
+ if (!l)
1879
1885
  throw `Unknown renderer implementation: ${m}`;
1880
- console.debug(`Using ${m} renderer`), n.style && c.setStyle(n.style);
1881
- const p = Rn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1886
+ console.debug(`Using ${m} renderer`), n.style && l.setStyle(n.style);
1887
+ const p = Bn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1882
1888
  return p.setUser(f), {
1883
- ...Ze(o, s, n.adapter),
1889
+ ...en(o, s, n.adapter),
1884
1890
  destroy: () => {
1885
- c.destroy(), p.destroy(), s.destroy();
1891
+ l.destroy(), p.destroy(), s.destroy();
1886
1892
  },
1887
1893
  element: t,
1888
1894
  getUser: () => f,
1889
- setFilter: (E) => c.setFilter(E),
1890
- setStyle: (E) => c.setStyle(E),
1895
+ setFilter: (E) => l.setFilter(E),
1896
+ setStyle: (E) => l.setStyle(E),
1891
1897
  setUser: (E) => {
1892
1898
  f = E, p.setUser(E);
1893
1899
  },
@@ -1895,47 +1901,47 @@ const An = (t, e) => {
1895
1901
  E ? i.setSelected(E) : i.clear();
1896
1902
  },
1897
1903
  setPresenceProvider: (E) => {
1898
- E && (c.setPainter(Cn(t, E, n.presence)), E.on("selectionChange", () => c.redraw()));
1904
+ E && (l.setPainter(Nn(t, E, n.presence)), E.on("selectionChange", () => l.redraw()));
1899
1905
  },
1900
- setVisible: (E) => c.setVisible(E),
1906
+ setVisible: (E) => l.setVisible(E),
1901
1907
  on: u.on,
1902
1908
  off: u.off,
1903
- scrollIntoView: Tn(t, a),
1909
+ scrollIntoView: Ln(t, a),
1904
1910
  state: o
1905
1911
  };
1906
1912
  };
1907
1913
  export {
1908
1914
  ot as DEFAULT_SELECTED_STYLE,
1909
1915
  P as DEFAULT_STYLE,
1910
- Vt as NOT_ANNOTATABLE_CLASS,
1916
+ _t as NOT_ANNOTATABLE_CLASS,
1911
1917
  X as NOT_ANNOTATABLE_SELECTOR,
1912
1918
  B as Origin,
1913
- Oe as PointerSelectAction,
1914
- In as W3CTextFormat,
1915
- Qt as cancelSingleClickEvents,
1916
- On as createBody,
1917
- ue as createCanvasRenderer,
1918
- xe as createHighlightsRenderer,
1919
- we as createRenderer,
1920
- Se as createSpansRenderer,
1921
- Mn as createTextAnnotator,
1922
- En as createTextAnnotatorState,
1923
- pt as debounce,
1924
- Nn as fillDefaults,
1925
- Ln as getAnnotatableFragment,
1926
- Bn as getClientRectsPonyfill,
1927
- te as getQuoteContext,
1928
- ft as getRangeAnnotatableContents,
1919
+ Ve as PointerSelectAction,
1920
+ Vn as W3CTextFormat,
1921
+ te as cancelSingleClickEvents,
1922
+ In as createBody,
1923
+ ge as createCanvasRenderer,
1924
+ Se as createHighlightsRenderer,
1925
+ Ee as createRenderer,
1926
+ Ne as createSpansRenderer,
1927
+ Dn as createTextAnnotator,
1928
+ Cn as createTextAnnotatorState,
1929
+ bt as debounce,
1930
+ Rn as fillDefaults,
1931
+ On as getAnnotatableFragment,
1932
+ Mn as getClientRectsPonyfill,
1933
+ oe as getQuoteContext,
1934
+ pt as getRangeAnnotatableContents,
1929
1935
  $ as isRevived,
1930
- oe as mergeClientRects,
1931
- qt as paint,
1932
- hn as parseW3CTextAnnotation,
1933
- ie as rangeToSelector,
1936
+ se as mergeClientRects,
1937
+ Kt as paint,
1938
+ gn as parseW3CTextAnnotation,
1939
+ ae as rangeToSelector,
1934
1940
  rt as reviveAnnotation,
1935
- _t as reviveSelector,
1941
+ Xt as reviveSelector,
1936
1942
  it as reviveTarget,
1937
- fn as serializeW3CTextAnnotation,
1938
- Kt as splitAnnotatableRanges,
1939
- re as trimRange
1943
+ pn as serializeW3CTextAnnotation,
1944
+ Zt as splitAnnotatableRanges,
1945
+ ce as trimRange
1940
1946
  };
1941
1947
  //# sourceMappingURL=text-annotator.es.js.map