@recogito/text-annotator 3.0.0-rc.23 → 3.0.0-rc.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,37 @@
1
- const $ = {
1
+ const Y = {
2
2
  fill: "rgb(0, 128, 255)",
3
3
  fillOpacity: 0.18
4
- }, ht = {
4
+ }, et = {
5
5
  fill: "rgb(0, 128, 255)",
6
6
  fillOpacity: 0.45
7
- }, jt = (t, e, n, o, i) => {
8
- var a;
9
- const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (a = t.state) != null && a.selected ? ht : $;
7
+ }, qt = (t, e, n, o, i) => {
8
+ var a, s;
9
+ const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? et : Y) : n : (s = t.state) != null && s.selected ? et : Y;
10
10
  return o && o.paint(t, e) || r;
11
11
  }, ft = (t, e = 10) => {
12
12
  let n;
13
13
  return (...o) => {
14
14
  clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
15
15
  };
16
- }, It = "not-annotatable", Y = `.${It}`, Gt = (t) => {
16
+ }, It = "not-annotatable", H = `.${It}`, jt = (t) => {
17
17
  var n;
18
18
  const e = t.commonAncestorContainer;
19
- return e instanceof HTMLElement ? !e.closest(Y) : !((n = e.parentElement) != null && n.closest(Y));
20
- }, Kt = function* (t) {
19
+ return e instanceof HTMLElement ? !e.closest(H) : !((n = e.parentElement) != null && n.closest(H));
20
+ }, Gt = function* (t) {
21
21
  const e = document.createNodeIterator(
22
22
  t.commonAncestorContainer,
23
23
  NodeFilter.SHOW_ELEMENT,
24
- (o) => o instanceof HTMLElement && o.classList.contains(It) && !o.parentElement.closest(Y) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
24
+ (o) => o instanceof HTMLElement && o.classList.contains(It) && !o.parentElement.closest(H) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
25
25
  );
26
26
  let n;
27
27
  for (; n = e.nextNode(); )
28
28
  n instanceof HTMLElement && (yield n);
29
- }, Qt = (t) => {
30
- if (!Gt(t))
29
+ }, Kt = (t) => {
30
+ if (!jt(t))
31
31
  return [];
32
32
  const e = [];
33
33
  let n = null;
34
- for (const o of Kt(t)) {
34
+ for (const o of Gt(t)) {
35
35
  let i;
36
36
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
37
37
  }
@@ -40,12 +40,12 @@ const $ = {
40
40
  o.setStartAfter(n), o.collapsed || e.push(o);
41
41
  }
42
42
  return e.length > 0 ? e : [t];
43
- }, dt = (t) => {
43
+ }, ut = (t) => {
44
44
  const e = t.cloneContents();
45
- return e.querySelectorAll(Y).forEach((n) => n.remove()), e;
46
- }, Ln = (t) => {
45
+ return e.querySelectorAll(H).forEach((n) => n.remove()), e;
46
+ }, Nn = (t) => {
47
47
  const e = t.cloneContents();
48
- return e.querySelectorAll(Y).forEach((n) => n.remove()), e;
48
+ return e.querySelectorAll(H).forEach((n) => n.remove()), e;
49
49
  }, mt = (t, e) => {
50
50
  const n = document.createNodeIterator(e);
51
51
  let o = 0, i = n.nextNode();
@@ -60,7 +60,7 @@ const $ = {
60
60
  for (let i = 0; i < t + 1; i++)
61
61
  o = n.nextNode();
62
62
  return o;
63
- }, Jt = (t) => {
63
+ }, Qt = (t) => {
64
64
  const {
65
65
  commonAncestorContainer: e,
66
66
  startContainer: n,
@@ -86,14 +86,14 @@ const $ = {
86
86
  c.selectNodeContents(n), c.setStart(n, o);
87
87
  const m = b(c), p = document.createRange();
88
88
  p.selectNode(i), p.setEnd(i, r);
89
- const w = b(p), h = Zt(t).reverse().map((d) => {
89
+ const w = b(p), h = Jt(t).reverse().map((d) => {
90
90
  var y;
91
91
  const l = document.createElement("SPAN");
92
92
  return (y = d.parentNode) == null || y.insertBefore(l, d), l.appendChild(d), l;
93
93
  });
94
94
  return { unwrap: f, nodes: [m, ...h, w] };
95
95
  }
96
- }, Zt = (t) => {
96
+ }, Jt = (t) => {
97
97
  const {
98
98
  commonAncestorContainer: e,
99
99
  startContainer: n,
@@ -104,25 +104,25 @@ const $ = {
104
104
  for (; r != null; )
105
105
  r === o && (a = !1), a && s.push(r), r === n && (a = !0), r = i.nextNode();
106
106
  return s;
107
- }, Bn = (t) => {
107
+ }, Ln = (t) => {
108
108
  const { startContainer: e, endContainer: n } = t;
109
109
  if (e === n)
110
110
  return Array.from(t.getClientRects());
111
111
  {
112
- const { unwrap: o, nodes: i } = Jt(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
112
+ const { unwrap: o, nodes: i } = Qt(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
113
113
  return o(), r;
114
114
  }
115
- }, te = (t, e, n = 10, o) => {
115
+ }, Zt = (t, e, n = 10, o) => {
116
116
  const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
117
117
  r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
118
- const a = dt(r).textContent, s = document.createRange();
118
+ const a = ut(r).textContent, s = document.createRange();
119
119
  s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
120
- const u = dt(s).textContent;
120
+ const u = ut(s).textContent;
121
121
  return {
122
122
  prefix: a.substring(a.length - n),
123
123
  suffix: u.substring(0, n)
124
124
  };
125
- }, k = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ee = (t, e) => {
125
+ }, k = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), te = (t, e) => {
126
126
  const n = (r) => Math.round(r * 10) / 10, o = {
127
127
  top: n(t.top),
128
128
  bottom: n(t.bottom),
@@ -146,17 +146,17 @@ const $ = {
146
146
  return "block-contains";
147
147
  } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
148
148
  return "block-is-contained";
149
- }, ne = (t, e) => {
149
+ }, ee = (t, e) => {
150
150
  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);
151
151
  return new DOMRect(n, i, o - n, r - i);
152
- }, oe = (t) => t.reduce((e, n) => {
152
+ }, ne = (t) => t.reduce((e, n) => {
153
153
  if (n.width === 0 || n.height === 0)
154
154
  return e;
155
155
  let o = [...e], i = !1;
156
156
  for (const r of e) {
157
- const a = ee(n, r);
157
+ const a = te(n, r);
158
158
  if (a === "inline-adjacent") {
159
- o = o.map((s) => s === r ? ne(n, r) : s), i = !0;
159
+ o = o.map((s) => s === r ? ee(n, r) : s), i = !0;
160
160
  break;
161
161
  } else if (a === "inline-contains") {
162
162
  o = o.map((s) => s === r ? n : s), i = !0;
@@ -170,10 +170,10 @@ const $ = {
170
170
  }
171
171
  }
172
172
  return i ? o : [...o, n];
173
- }, []), ie = (t, e, n) => {
173
+ }, []), oe = (t, e, n) => {
174
174
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
175
175
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
176
- const r = dt(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;
176
+ const r = ut(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;
177
177
  return n ? { quote: a, start: s, end: u, range: t, offsetReference: i } : { quote: a, start: s, end: u, range: t };
178
178
  }, Mt = (t, e) => {
179
179
  var b, c;
@@ -182,7 +182,7 @@ const $ = {
182
182
  NodeFilter.SHOW_TEXT,
183
183
  (m) => {
184
184
  var p;
185
- return (p = m.parentElement) != null && p.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
185
+ return (p = m.parentElement) != null && p.closest(H) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
186
186
  }
187
187
  );
188
188
  let a = 0;
@@ -213,10 +213,10 @@ const $ = {
213
213
  ...t,
214
214
  range: s
215
215
  };
216
- }, et = (t, e) => k(t.selector) ? t : {
216
+ }, nt = (t, e) => k(t.selector) ? t : {
217
217
  ...t,
218
218
  selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Mt(n, e))
219
- }, nt = (t, e) => k(t.target.selector) ? t : { ...t, target: et(t.target, e) }, re = (t) => {
219
+ }, ot = (t, e) => k(t.target.selector) ? t : { ...t, target: nt(t.target, e) }, ie = (t) => {
220
220
  var i;
221
221
  const { startContainer: e, endContainer: n } = t;
222
222
  if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)
@@ -230,10 +230,10 @@ const $ = {
230
230
  t.setEnd(a, ((i = a == null ? void 0 : a.textContent) == null ? void 0 : i.length) || 0);
231
231
  }
232
232
  return t;
233
- }, se = (t) => {
233
+ }, re = (t) => {
234
234
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, u = i - e;
235
235
  return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: u };
236
- }, ae = (t) => {
236
+ }, se = (t) => {
237
237
  let e = /* @__PURE__ */ new Set();
238
238
  return (o) => {
239
239
  const i = o.map((r) => r.id);
@@ -242,18 +242,18 @@ const $ = {
242
242
  }, pt = (t, e, n, o) => {
243
243
  const { store: i, selection: r, hover: a } = e;
244
244
  let s, u, f;
245
- const b = ae(n), c = (g) => {
245
+ const b = se(n), c = (g) => {
246
246
  const { x: A, y: x } = t.getBoundingClientRect(), S = i.getAt(g.clientX - A, g.clientY - x);
247
247
  S && (!u || u(S)) ? a.current !== S.id && (t.classList.add("hovered"), a.set(S.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
248
248
  };
249
249
  t.addEventListener("pointermove", c);
250
250
  const m = (g = !1) => {
251
251
  f && f.clear();
252
- const A = se(t), { minX: x, minY: S, maxX: N, maxY: B } = A, _ = u ? i.getIntersecting(x, S, N, B).filter(({ annotation: X }) => u(X)) : i.getIntersecting(x, S, N, B), Pt = r.selected.map(({ id: X }) => X), zt = _.map(({ annotation: X, rects: Ft }) => {
253
- const Wt = Pt.includes(X.id), qt = X.id === a.current;
254
- return { annotation: X, rects: Ft, state: { selected: Wt, hover: qt, custom: {} } };
252
+ const A = re(t), { minX: x, minY: S, maxX: N, maxY: B } = A, _ = u ? i.getIntersecting(x, S, N, B).filter(({ annotation: X }) => u(X)) : i.getIntersecting(x, S, N, B), $t = r.selected.map(({ id: X }) => X), Pt = _.map(({ annotation: X, rects: zt }) => {
253
+ const Ft = $t.includes(X.id), Wt = X.id === a.current;
254
+ return { annotation: X, rects: zt, state: { selected: Ft, hover: Wt, custom: {} } };
255
255
  });
256
- o.redraw(zt, A, s, f, g), setTimeout(() => b(_.map(({ annotation: X }) => X)), 1);
256
+ o.redraw(Pt, A, s, f, g), setTimeout(() => b(_.map(({ annotation: X }) => X)), 1);
257
257
  }, p = (g) => {
258
258
  f = g, m();
259
259
  }, w = (g) => {
@@ -268,14 +268,14 @@ const $ = {
268
268
  i.recalculatePositions(), f && f.reset(), m();
269
269
  });
270
270
  window.addEventListener("resize", y);
271
- const C = new ResizeObserver(y);
272
- C.observe(t);
273
- const T = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((g) => {
271
+ const T = new ResizeObserver(y);
272
+ T.observe(t);
273
+ const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((g) => {
274
274
  g.every((x) => x.target === t || t.contains(x.target)) || m(!0);
275
275
  });
276
- return E.observe(document.body, T), {
276
+ return E.observe(document.body, C), {
277
277
  destroy: () => {
278
- t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(h), d(), document.removeEventListener("scroll", l), window.removeEventListener("resize", y), C.disconnect(), E.disconnect();
278
+ t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(h), d(), document.removeEventListener("scroll", l), window.removeEventListener("resize", y), T.disconnect(), E.disconnect();
279
279
  },
280
280
  redraw: m,
281
281
  setStyle: w,
@@ -283,33 +283,46 @@ const $ = {
283
283
  setPainter: p,
284
284
  setVisible: o.setVisible
285
285
  };
286
- }, ce = () => {
286
+ }, ae = () => {
287
287
  const t = document.createElement("canvas");
288
288
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
289
- }, le = (t, e) => {
289
+ }, ce = (t, e) => {
290
290
  t.width = window.innerWidth, t.height = window.innerHeight;
291
- }, de = (t) => {
291
+ }, le = (t) => {
292
292
  t.classList.add("r6o-annotatable");
293
- const e = ce(), n = e.getContext("2d");
293
+ const e = ae(), n = e.getContext("2d");
294
294
  t.insertBefore(e, t.firstChild);
295
295
  const o = (s, u, f, b) => requestAnimationFrame(() => {
296
296
  const { width: c, height: m } = e;
297
297
  n.clearRect(-0.5, -0.5, c + 1, m + 1), b && b.clear();
298
298
  const { top: p, left: w } = u;
299
299
  s.forEach((v) => {
300
- var y;
301
- const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (y = v.state) != null && y.selected ? ht : $, d = b && b.paint(v, u) || h, l = v.rects.map(({ x: C, y: T, width: E, height: R }) => ({
300
+ var T;
301
+ const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (T = v.state) != null && T.selected ? et : Y, d = b && b.paint(v, u) || h, l = v.rects.map(({ x: C, y: E, width: R, height: g }) => ({
302
302
  x: C + w,
303
- y: T + p,
304
- width: E,
305
- height: R
306
- }));
307
- n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, l.forEach(({ x: C, y: T, width: E, height: R }) => n.fillRect(C, T - 2.5, E, R + 5)), d.underlineColor && (n.globalAlpha = 1, n.strokeStyle = d.underlineColor, l.forEach(({ x: C, y: T, width: E, height: R }) => {
308
- n.beginPath(), n.moveTo(C, T + R + 4), n.lineTo(C + E, T + R + 4), n.stroke();
303
+ y: E + p,
304
+ width: R,
305
+ height: g
309
306
  }));
307
+ n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1;
308
+ const y = 5;
309
+ if (l.forEach(
310
+ ({ x: C, y: E, width: R, height: g }) => n.fillRect(
311
+ C,
312
+ E - y / 2,
313
+ R,
314
+ g + y
315
+ )
316
+ ), d.underlineColor) {
317
+ n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
318
+ const C = y / 2 + (d.underlineOffset ?? 0);
319
+ l.forEach(({ x: E, y: R, width: g, height: A }) => {
320
+ n.beginPath(), n.moveTo(E, R + A + C), n.lineTo(E + g, R + A + C), n.stroke();
321
+ });
322
+ }
310
323
  });
311
324
  }), i = ft(() => {
312
- le(e);
325
+ ce(e);
313
326
  });
314
327
  return window.addEventListener("resize", i), {
315
328
  destroy: () => {
@@ -320,8 +333,8 @@ const $ = {
320
333
  },
321
334
  redraw: o
322
335
  };
323
- }, ue = (t, e, n) => pt(t, e, n, de(t));
324
- var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
336
+ }, de = (t, e, n) => pt(t, e, n, le(t));
337
+ var ue = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
325
338
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
326
339
  }, O = function(t, e, n) {
327
340
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
@@ -331,9 +344,9 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
331
344
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
332
345
  }, vt = function(t) {
333
346
  return { r: U(t.r, 0, 255), g: U(t.g, 0, 255), b: U(t.b, 0, 255), a: U(t.a) };
334
- }, ot = function(t) {
347
+ }, it = function(t) {
335
348
  return { r: O(t.r), g: O(t.g), b: O(t.b), a: O(t.a, 3) };
336
- }, fe = /^#([0-9a-f]{3,8})$/i, K = function(t) {
349
+ }, he = /^#([0-9a-f]{3,8})$/i, K = function(t) {
337
350
  var e = t.toString(16);
338
351
  return e.length < 2 ? "0" + e : e;
339
352
  }, Vt = function(t) {
@@ -354,17 +367,17 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
354
367
  }, G = function(t) {
355
368
  return { h: (e = Vt(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 };
356
369
  var e, n, o, i;
357
- }, pe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, 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, At = { string: [[function(t) {
358
- var e = fe.exec(t);
370
+ }, fe = /^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, ge = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, At = { string: [[function(t) {
371
+ var e = he.exec(t);
359
372
  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 ? O(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 ? O(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
360
373
  }, "hex"], [function(t) {
361
- var e = me.exec(t) || be.exec(t);
374
+ var e = ge.exec(t) || me.exec(t);
362
375
  return e ? e[2] !== e[4] || e[4] !== e[6] ? null : vt({ 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;
363
376
  }, "rgb"], [function(t) {
364
- var e = pe.exec(t) || ge.exec(t);
377
+ var e = fe.exec(t) || pe.exec(t);
365
378
  if (!e)
366
379
  return null;
367
- var n, o, i = yt({ 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) });
380
+ var n, o, i = yt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (ue[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
368
381
  return xt(i);
369
382
  }, "hsl"]], object: [[function(t) {
370
383
  var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
@@ -390,35 +403,35 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
390
403
  return [o, e[n][1]];
391
404
  }
392
405
  return [null, void 0];
393
- }, ve = function(t) {
406
+ }, be = function(t) {
394
407
  return typeof t == "string" ? Et(t.trim(), At.string) : typeof t == "object" && t !== null ? Et(t, At.object) : [null, void 0];
395
- }, it = function(t, e) {
408
+ }, rt = function(t, e) {
396
409
  var n = G(t);
397
410
  return { h: n.h, s: U(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
398
- }, rt = function(t) {
411
+ }, st = function(t) {
399
412
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
400
413
  }, St = function(t, e) {
401
414
  var n = G(t);
402
415
  return { h: n.h, s: n.s, l: U(n.l + 100 * e, 0, 100), a: n.a };
403
416
  }, Ct = function() {
404
417
  function t(e) {
405
- this.parsed = ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
418
+ this.parsed = be(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
406
419
  }
407
420
  return t.prototype.isValid = function() {
408
421
  return this.parsed !== null;
409
422
  }, t.prototype.brightness = function() {
410
- return O(rt(this.rgba), 2);
423
+ return O(st(this.rgba), 2);
411
424
  }, t.prototype.isDark = function() {
412
- return rt(this.rgba) < 0.5;
425
+ return st(this.rgba) < 0.5;
413
426
  }, t.prototype.isLight = function() {
414
- return rt(this.rgba) >= 0.5;
427
+ return st(this.rgba) >= 0.5;
415
428
  }, t.prototype.toHex = function() {
416
- return e = ot(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? K(O(255 * r)) : "", "#" + K(n) + K(o) + K(i) + a;
429
+ return e = it(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? K(O(255 * r)) : "", "#" + K(n) + K(o) + K(i) + a;
417
430
  var e, n, o, i, r, a;
418
431
  }, t.prototype.toRgb = function() {
419
- return ot(this.rgba);
432
+ return it(this.rgba);
420
433
  }, t.prototype.toRgbString = function() {
421
- return e = ot(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
434
+ return e = it(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
422
435
  var e, n, o, i, r;
423
436
  }, t.prototype.toHsl = function() {
424
437
  return wt(G(this.rgba));
@@ -432,11 +445,11 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
432
445
  return V({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
433
446
  var e;
434
447
  }, t.prototype.saturate = function(e) {
435
- return e === void 0 && (e = 0.1), V(it(this.rgba, e));
448
+ return e === void 0 && (e = 0.1), V(rt(this.rgba, e));
436
449
  }, t.prototype.desaturate = function(e) {
437
- return e === void 0 && (e = 0.1), V(it(this.rgba, -e));
450
+ return e === void 0 && (e = 0.1), V(rt(this.rgba, -e));
438
451
  }, t.prototype.grayscale = function() {
439
- return V(it(this.rgba, -1));
452
+ return V(rt(this.rgba, -1));
440
453
  }, t.prototype.lighten = function(e) {
441
454
  return e === void 0 && (e = 0.1), V(St(this.rgba, e));
442
455
  }, t.prototype.darken = function(e) {
@@ -455,13 +468,13 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
455
468
  }(), V = function(t) {
456
469
  return t instanceof Ct ? t : new Ct(t);
457
470
  };
458
- const ye = (t) => [
459
- `background-color:${V((t == null ? void 0 : t.fill) || $.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? $.fillOpacity : t.fillOpacity).toHex()}`,
471
+ const ve = (t) => [
472
+ `background-color:${V((t == null ? void 0 : t.fill) || Y.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? Y.fillOpacity : t.fillOpacity).toHex()}`,
460
473
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
461
474
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
462
475
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
463
476
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
464
- ].filter(Boolean).join(";"), we = () => {
477
+ ].filter(Boolean).join(";"), ye = () => {
465
478
  const t = document.createElement("style");
466
479
  document.getElementsByTagName("head")[0].appendChild(t);
467
480
  let e = /* @__PURE__ */ new Set();
@@ -478,8 +491,8 @@ const ye = (t) => [
478
491
  Array.from(e).filter((c) => !f.has(c));
479
492
  const b = r.map((c) => {
480
493
  var w;
481
- const m = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (w = c.state) != null && w.selected ? ht : $, p = u && u.paint(c, a) || m;
482
- return `::highlight(_${c.annotation.id}) { ${ye(p)} }`;
494
+ const m = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (w = c.state) != null && w.selected ? et : Y, p = u && u.paint(c, a) || m;
495
+ return `::highlight(_${c.annotation.id}) { ${ve(p)} }`;
483
496
  });
484
497
  t.innerHTML = b.join(`
485
498
  `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
@@ -488,9 +501,9 @@ const ye = (t) => [
488
501
  }), e = f;
489
502
  }
490
503
  };
491
- }, xe = (t, e, n) => pt(t, e, n, we());
504
+ }, we = (t, e, n) => pt(t, e, n, ye());
492
505
  var Tt = Object.prototype.hasOwnProperty;
493
- function ut(t, e) {
506
+ function ht(t, e) {
494
507
  var n, o;
495
508
  if (t === e)
496
509
  return !0;
@@ -501,24 +514,24 @@ function ut(t, e) {
501
514
  return t.toString() === e.toString();
502
515
  if (n === Array) {
503
516
  if ((o = t.length) === e.length)
504
- for (; o-- && ut(t[o], e[o]); )
517
+ for (; o-- && ht(t[o], e[o]); )
505
518
  ;
506
519
  return o === -1;
507
520
  }
508
521
  if (!n || typeof t == "object") {
509
522
  o = 0;
510
523
  for (n in t)
511
- if (Tt.call(t, n) && ++o && !Tt.call(e, n) || !(n in e) || !ut(t[n], e[n]))
524
+ if (Tt.call(t, n) && ++o && !Tt.call(e, n) || !(n in e) || !ht(t[n], e[n]))
512
525
  return !1;
513
526
  return Object.keys(e).length === o;
514
527
  }
515
528
  }
516
529
  return t !== t && e !== e;
517
530
  }
518
- const Ae = (t, e) => {
531
+ const xe = (t, e) => {
519
532
  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;
520
533
  return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;
521
- }, Ee = (t) => {
534
+ }, Ae = (t) => {
522
535
  t.classList.add("r6o-annotatable");
523
536
  const e = document.createElement("div");
524
537
  e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
@@ -528,7 +541,7 @@ const Ae = (t, e) => {
528
541
  e.remove();
529
542
  },
530
543
  redraw: (a, s, u, f, b) => {
531
- if (ut(n, a) && b)
544
+ if (ht(n, a) && b)
532
545
  return;
533
546
  e.innerHTML = "";
534
547
  const m = a.reduce((p, { rects: w }) => [...p, ...w], []);
@@ -536,7 +549,7 @@ const Ae = (t, e) => {
536
549
  const w = p.rects.map((v) => {
537
550
  const h = document.createElement("span");
538
551
  h.className = "r6o-annotation", h.dataset.annotation = p.annotation.id, h.style.left = `${v.x}px`, h.style.top = `${v.y}px`, h.style.width = `${v.width}px`, h.style.height = `${v.height}px`;
539
- const d = Ae(v, m), l = jt(p, s, u, f, d), y = V((l == null ? void 0 : l.fill) || $.fill).alpha((l == null ? void 0 : l.fillOpacity) === void 0 ? $.fillOpacity : l.fillOpacity).toHex();
552
+ const d = xe(v, m), l = qt(p, s, u, f, d), y = V((l == null ? void 0 : l.fill) || Y.fill).alpha((l == null ? void 0 : l.fillOpacity) === void 0 ? Y.fillOpacity : l.fillOpacity).toHex();
540
553
  return h.style.backgroundColor = y, l.underlineStyle && (h.style.borderStyle = l.underlineStyle), l.underlineColor && (h.style.borderColor = l.underlineColor), l.underlineThickness && (h.style.borderBottomWidth = `${l.underlineThickness}px`), l.underlineOffset && (h.style.paddingBottom = `${l.underlineOffset}px`), e.appendChild(h), h;
541
554
  });
542
555
  return { id: p.annotation.id, spans: w };
@@ -546,29 +559,29 @@ const Ae = (t, e) => {
546
559
  a ? e.classList.remove("hidden") : e.classList.add("hidden");
547
560
  }
548
561
  };
549
- }, Se = (t, e, n) => pt(t, e, n, Ee(t));
562
+ }, Ee = (t, e, n) => pt(t, e, n, Ae(t));
550
563
  let Q;
551
- const Ce = new Uint8Array(16);
552
- function Te() {
564
+ const Se = new Uint8Array(16);
565
+ function Ce() {
553
566
  if (!Q && (Q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Q))
554
567
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
555
- return Q(Ce);
568
+ return Q(Se);
556
569
  }
557
570
  const I = [];
558
571
  for (let t = 0; t < 256; ++t)
559
572
  I.push((t + 256).toString(16).slice(1));
560
- function Re(t, e = 0) {
573
+ function Te(t, e = 0) {
561
574
  return I[t[e + 0]] + I[t[e + 1]] + I[t[e + 2]] + I[t[e + 3]] + "-" + I[t[e + 4]] + I[t[e + 5]] + "-" + I[t[e + 6]] + I[t[e + 7]] + "-" + I[t[e + 8]] + I[t[e + 9]] + "-" + I[t[e + 10]] + I[t[e + 11]] + I[t[e + 12]] + I[t[e + 13]] + I[t[e + 14]] + I[t[e + 15]];
562
575
  }
563
- const Ne = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Rt = {
564
- randomUUID: Ne
576
+ const Re = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Rt = {
577
+ randomUUID: Re
565
578
  };
566
579
  function Xt(t, e, n) {
567
580
  if (Rt.randomUUID && !e && !t)
568
581
  return Rt.randomUUID();
569
582
  t = t || {};
570
- const o = t.random || (t.rng || Te)();
571
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Re(o);
583
+ const o = t.random || (t.rng || Ce)();
584
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Te(o);
572
585
  }
573
586
  var Nt = Object.prototype.hasOwnProperty;
574
587
  function F(t, e) {
@@ -596,39 +609,39 @@ function F(t, e) {
596
609
  }
597
610
  return t !== t && e !== e;
598
611
  }
599
- function st() {
612
+ function at() {
600
613
  }
601
- function Le(t, e) {
614
+ function Ne(t, e) {
602
615
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
603
616
  }
604
- const H = [];
605
- function gt(t, e = st) {
617
+ const $ = [];
618
+ function gt(t, e = at) {
606
619
  let n;
607
620
  const o = /* @__PURE__ */ new Set();
608
621
  function i(s) {
609
- if (Le(t, s) && (t = s, n)) {
610
- const u = !H.length;
622
+ if (Ne(t, s) && (t = s, n)) {
623
+ const u = !$.length;
611
624
  for (const f of o)
612
- f[1](), H.push(f, t);
625
+ f[1](), $.push(f, t);
613
626
  if (u) {
614
- for (let f = 0; f < H.length; f += 2)
615
- H[f][0](H[f + 1]);
616
- H.length = 0;
627
+ for (let f = 0; f < $.length; f += 2)
628
+ $[f][0]($[f + 1]);
629
+ $.length = 0;
617
630
  }
618
631
  }
619
632
  }
620
633
  function r(s) {
621
634
  i(s(t));
622
635
  }
623
- function a(s, u = st) {
636
+ function a(s, u = at) {
624
637
  const f = [s, u];
625
- return o.add(f), o.size === 1 && (n = e(i, r) || st), s(t), () => {
638
+ return o.add(f), o.size === 1 && (n = e(i, r) || at), s(t), () => {
626
639
  o.delete(f), o.size === 0 && n && (n(), n = null);
627
640
  };
628
641
  }
629
642
  return { set: i, update: r, subscribe: a };
630
643
  }
631
- const Be = (t) => {
644
+ const Le = (t) => {
632
645
  const { subscribe: e, set: n } = gt();
633
646
  let o;
634
647
  return e((i) => o = i), t.observe(({ changes: i }) => {
@@ -645,12 +658,12 @@ const Be = (t) => {
645
658
  set: n
646
659
  };
647
660
  };
648
- var Dt = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Dt || {});
649
- const at = { selected: [] }, Oe = (t, e = "EDIT") => {
650
- const { subscribe: n, set: o } = gt(at);
651
- let i = at;
661
+ var Be = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Be || {});
662
+ const ct = { selected: [] }, Oe = (t, e = "EDIT") => {
663
+ const { subscribe: n, set: o } = gt(ct);
664
+ let i = ct;
652
665
  n((c) => i = c);
653
- const r = () => o(at), a = () => {
666
+ const r = () => o(ct), a = () => {
654
667
  var c;
655
668
  return ((c = i.selected) == null ? void 0 : c.length) === 0;
656
669
  }, s = (c) => {
@@ -712,23 +725,23 @@ function Xe(t, e, n) {
712
725
  const o = t.random || (t.rng || Ue)();
713
726
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ve(o);
714
727
  }
715
- const De = (t, e, n, o) => ({
728
+ const Bn = (t, e, n, o) => ({
716
729
  id: Xe(),
717
730
  annotation: t.id,
718
731
  created: n || /* @__PURE__ */ new Date(),
719
732
  creator: o,
720
733
  ...e
721
- }), ke = (t, e) => {
734
+ }), De = (t, e) => {
722
735
  const n = new Set(t.bodies.map((o) => o.id));
723
736
  return e.bodies.filter((o) => !n.has(o.id));
724
- }, Ye = (t, e) => {
737
+ }, ke = (t, e) => {
725
738
  const n = new Set(e.bodies.map((o) => o.id));
726
739
  return t.bodies.filter((o) => !n.has(o.id));
727
- }, $e = (t, e) => e.bodies.map((n) => {
740
+ }, Ye = (t, e) => e.bodies.map((n) => {
728
741
  const o = t.bodies.find((i) => i.id === n.id);
729
742
  return { newBody: n, oldBody: o && !F(o, n) ? o : void 0 };
730
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), He = (t, e) => !F(t.target, e.target), kt = (t, e) => {
731
- const n = ke(t, e), o = Ye(t, e), i = $e(t, e);
743
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), He = (t, e) => !F(t.target, e.target), Dt = (t, e) => {
744
+ const n = De(t, e), o = ke(t, e), i = Ye(t, e);
732
745
  return {
733
746
  oldValue: t,
734
747
  newValue: e,
@@ -739,7 +752,7 @@ const De = (t, e, n, o) => ({
739
752
  };
740
753
  };
741
754
  var L = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(L || {});
742
- const Pe = (t, e) => {
755
+ const $e = (t, e) => {
743
756
  var n, o;
744
757
  const { changes: i, origin: r } = e;
745
758
  if (!(!t.options.origin || t.options.origin === r))
@@ -761,7 +774,7 @@ const Pe = (t, e) => {
761
774
  return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => a.has(s));
762
775
  } else
763
776
  return !0;
764
- }, ze = (t, e) => {
777
+ }, Pe = (t, e) => {
765
778
  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 = [
766
779
  ...(t.created || []).filter((c) => !r.has(c.id)).map((c) => a.has(c.id) ? e.updated.find(({ oldValue: m }) => m.id === c.id).newValue : c),
767
780
  ...e.created || []
@@ -773,14 +786,14 @@ const Pe = (t, e) => {
773
786
  const { oldValue: m, newValue: p } = c;
774
787
  if (a.has(p.id)) {
775
788
  const w = e.updated.find((v) => v.oldValue.id === p.id).newValue;
776
- return kt(m, w);
789
+ return Dt(m, w);
777
790
  } else
778
791
  return c;
779
792
  }),
780
793
  ...(e.updated || []).filter(({ oldValue: c }) => !s.has(c.id))
781
794
  ];
782
795
  return { created: u, deleted: f, updated: b };
783
- }, Fe = (t) => t.id !== void 0, We = () => {
796
+ }, ze = (t) => t.id !== void 0, Fe = () => {
784
797
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (g, A = {}) => n.push({ onChange: g, options: A }), i = (g) => {
785
798
  const A = n.findIndex((x) => x.onChange == g);
786
799
  A > -1 && n.splice(A, 1);
@@ -795,7 +808,7 @@ const Pe = (t, e) => {
795
808
  state: [...t.values()]
796
809
  };
797
810
  n.forEach((S) => {
798
- Pe(S, x) && S.onChange(x);
811
+ $e(S, x) && S.onChange(x);
799
812
  });
800
813
  }, a = (g, A = L.LOCAL) => {
801
814
  if (t.get(g.id))
@@ -804,12 +817,12 @@ const Pe = (t, e) => {
804
817
  }, s = (g, A) => {
805
818
  const x = typeof g == "string" ? A : g, S = typeof g == "string" ? g : g.id, N = t.get(S);
806
819
  if (N) {
807
- const B = kt(N, x);
820
+ const B = Dt(N, x);
808
821
  return S === x.id ? t.set(S, x) : (t.delete(S), t.set(x.id, x)), N.bodies.forEach((_) => e.delete(_.id)), x.bodies.forEach((_) => e.set(_.id, x.id)), B;
809
822
  } else
810
823
  console.warn(`Cannot update annotation ${S} - does not exist`);
811
824
  }, u = (g, A = L.LOCAL, x = L.LOCAL) => {
812
- const S = Fe(A) ? x : A, N = s(g, A);
825
+ const S = ze(A) ? x : A, N = s(g, A);
813
826
  N && r(S, { updated: [N] });
814
827
  }, f = (g, A = L.LOCAL) => {
815
828
  const x = g.reduce((S, N) => {
@@ -896,7 +909,7 @@ const Pe = (t, e) => {
896
909
  console.error(`Store integrity error: body ${g} in index, but not in annotation`);
897
910
  } else
898
911
  console.warn(`Attempt to retrieve missing body: ${g}`);
899
- }, C = (g, A) => {
912
+ }, T = (g, A) => {
900
913
  if (g.annotation !== A.annotation)
901
914
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
902
915
  const x = t.get(g.annotation);
@@ -912,11 +925,11 @@ const Pe = (t, e) => {
912
925
  };
913
926
  } else
914
927
  console.warn(`Attempt to add body to missing annotation ${g.annotation}`);
915
- }, T = (g, A, x = L.LOCAL) => {
916
- const S = C(g, A);
928
+ }, C = (g, A, x = L.LOCAL) => {
929
+ const S = T(g, A);
917
930
  S && r(x, { updated: [S] });
918
931
  }, E = (g, A = L.LOCAL) => {
919
- const x = g.map((S) => C({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
932
+ const x = g.map((S) => T({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
920
933
  r(A, { updated: x });
921
934
  }, R = (g) => {
922
935
  const A = t.get(g.annotation);
@@ -959,14 +972,14 @@ const Pe = (t, e) => {
959
972
  observe: o,
960
973
  unobserve: i,
961
974
  updateAnnotation: u,
962
- updateBody: T,
975
+ updateBody: C,
963
976
  updateTarget: (g, A = L.LOCAL) => {
964
977
  const x = R(g);
965
978
  x && r(A, { updated: [x] });
966
979
  }
967
980
  };
968
981
  };
969
- let qe = () => ({
982
+ let We = () => ({
970
983
  emit(t, ...e) {
971
984
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
972
985
  o[n](...e);
@@ -980,17 +993,17 @@ let qe = () => ({
980
993
  };
981
994
  }
982
995
  });
983
- const je = 250, Ge = (t) => {
984
- const e = qe(), n = [];
996
+ const qe = 250, je = (t) => {
997
+ const e = We(), n = [];
985
998
  let o = -1, i = !1, r = 0;
986
999
  const a = (p) => {
987
1000
  if (!i) {
988
1001
  const { changes: w } = p, v = performance.now();
989
- if (v - r > je)
1002
+ if (v - r > qe)
990
1003
  n.splice(o + 1), n.push(w), o = n.length - 1;
991
1004
  else {
992
1005
  const h = n.length - 1;
993
- n[h] = ze(n[h], w);
1006
+ n[h] = Pe(n[h], w);
994
1007
  }
995
1008
  r = v;
996
1009
  }
@@ -1018,13 +1031,13 @@ const je = 250, Ge = (t) => {
1018
1031
  }
1019
1032
  }
1020
1033
  };
1021
- }, Ke = () => {
1034
+ }, Ge = () => {
1022
1035
  const { subscribe: t, set: e } = gt([]);
1023
1036
  return {
1024
1037
  subscribe: t,
1025
1038
  set: e
1026
1039
  };
1027
- }, Qe = (t, e, n, o) => {
1040
+ }, Ke = (t, e, n, o) => {
1028
1041
  const { store: i, selection: r, hover: a, viewport: s } = t, u = /* @__PURE__ */ new Map();
1029
1042
  let f = [], b;
1030
1043
  const c = (v, h) => {
@@ -1036,8 +1049,8 @@ const je = 250, Ge = (t) => {
1036
1049
  u.has(v) && setTimeout(() => {
1037
1050
  u.get(v).forEach((l) => {
1038
1051
  if (n) {
1039
- const y = Array.isArray(h) ? h.map((T) => n.serialize(T)) : n.serialize(h), C = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1040
- l(y, C);
1052
+ 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;
1053
+ l(y, T);
1041
1054
  } else
1042
1055
  l(h, d);
1043
1056
  });
@@ -1075,13 +1088,13 @@ const je = 250, Ge = (t) => {
1075
1088
  ...l.bodiesDeleted || [],
1076
1089
  ...l.bodiesUpdated || []
1077
1090
  ].length > 0).forEach(({ oldValue: l, newValue: y }) => {
1078
- const C = f.find((T) => T.id === l.id) || l;
1079
- f = f.map((T) => T.id === l.id ? y : T), p("updateAnnotation", y, C);
1091
+ const T = f.find((C) => C.id === l.id) || l;
1092
+ f = f.map((C) => C.id === l.id ? y : C), p("updateAnnotation", y, T);
1080
1093
  });
1081
1094
  }, { origin: L.LOCAL }), i.observe((v) => {
1082
1095
  if (f) {
1083
1096
  const h = new Set(f.map((l) => l.id)), d = (v.changes.updated || []).filter(({ newValue: l }) => h.has(l.id)).map(({ newValue: l }) => l);
1084
- d.length > 0 && (f = f.map((l) => d.find((C) => C.id === l.id) || l));
1097
+ d.length > 0 && (f = f.map((l) => d.find((T) => T.id === l.id) || l));
1085
1098
  }
1086
1099
  }, { origin: L.REMOTE });
1087
1100
  const w = (v) => (h) => {
@@ -1089,7 +1102,7 @@ const je = 250, Ge = (t) => {
1089
1102
  v ? (d || []).forEach((l) => p("updateAnnotation", l.oldValue, l.newValue)) : (d || []).forEach((l) => p("updateAnnotation", l.newValue, l.oldValue));
1090
1103
  };
1091
1104
  return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: c, off: m, emit: p };
1092
- }, Je = (t) => (e) => e.reduce((n, o) => {
1105
+ }, Qe = (t) => (e) => e.reduce((n, o) => {
1093
1106
  const { parsed: i, error: r } = t.parse(o);
1094
1107
  return r ? {
1095
1108
  parsed: n.parsed,
@@ -1100,7 +1113,7 @@ const je = 250, Ge = (t) => {
1100
1113
  } : {
1101
1114
  ...n
1102
1115
  };
1103
- }, { parsed: [], failed: [] }), Ze = (t, e, n) => {
1116
+ }, { parsed: [], failed: [] }), Je = (t, e, n) => {
1104
1117
  const { store: o, selection: i } = t, r = (h) => {
1105
1118
  if (n) {
1106
1119
  const { parsed: d, error: l } = n.parse(h);
@@ -1126,7 +1139,7 @@ const je = 250, Ge = (t) => {
1126
1139
  }
1127
1140
  }, p = (h, d = !0) => {
1128
1141
  if (n) {
1129
- const { parsed: l, failed: y } = Je(n)(h);
1142
+ const { parsed: l, failed: y } = Qe(n)(h);
1130
1143
  y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(l, d, L.REMOTE);
1131
1144
  } else
1132
1145
  o.bulkAddAnnotation(h, d, L.REMOTE);
@@ -1158,8 +1171,8 @@ const je = 250, Ge = (t) => {
1158
1171
  undo: e.undo,
1159
1172
  updateAnnotation: v
1160
1173
  };
1161
- }, tn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1162
- let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
1174
+ }, Ze = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1175
+ let tn = (t) => crypto.getRandomValues(new Uint8Array(t)), en = (t, e, n) => {
1163
1176
  let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
1164
1177
  return (r = e) => {
1165
1178
  let a = "";
@@ -1170,13 +1183,13 @@ let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
1170
1183
  return a;
1171
1184
  }
1172
1185
  };
1173
- }, on = (t, e = 21) => nn(t, e, en), rn = (t = 21) => {
1186
+ }, nn = (t, e = 21) => en(t, e, tn), on = (t = 21) => {
1174
1187
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
1175
1188
  for (; t--; )
1176
- e += tn[n[t] & 63];
1189
+ e += Ze[n[t] & 63];
1177
1190
  return e;
1178
1191
  };
1179
- const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), an = (t) => {
1192
+ const rn = () => ({ isGuest: !0, id: nn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), sn = (t) => {
1180
1193
  const e = JSON.stringify(t);
1181
1194
  let n = 0;
1182
1195
  for (let o = 0, i = e.length; o < i; o++) {
@@ -1184,28 +1197,28 @@ const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABC
1184
1197
  n = (n << 5) - n + r, n |= 0;
1185
1198
  }
1186
1199
  return `${n}`;
1187
- }, Yt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, cn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1200
+ }, kt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, an = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1188
1201
  const { id: o, type: i, purpose: r, value: a, created: s, creator: u, ...f } = n;
1189
1202
  return {
1190
- id: o || `temp-${an(n)}`,
1203
+ id: o || `temp-${sn(n)}`,
1191
1204
  annotation: e,
1192
1205
  type: i,
1193
1206
  purpose: r,
1194
1207
  value: a,
1195
1208
  created: s ? new Date(s) : void 0,
1196
- creator: Yt(u),
1209
+ creator: kt(u),
1197
1210
  ...f
1198
1211
  };
1199
- }), ln = (t) => t.map((e) => {
1212
+ }), cn = (t) => t.map((e) => {
1200
1213
  var n, o;
1201
1214
  const i = { ...e };
1202
1215
  return delete i.annotation, (n = i.id) != null && n.startsWith("temp-") && delete i.id, { ...i, created: (o = i.created) == null ? void 0 : o.toISOString() };
1203
1216
  });
1204
- rn();
1217
+ on();
1205
1218
  const On = (t, e) => ({
1206
- parse: (n) => hn(n),
1207
- serialize: (n) => fn(n, t, e)
1208
- }), dn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, un = (t) => {
1219
+ parse: (n) => un(n),
1220
+ serialize: (n) => hn(n, t, e)
1221
+ }), ln = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, dn = (t) => {
1209
1222
  const {
1210
1223
  id: e,
1211
1224
  creator: n,
@@ -1213,7 +1226,7 @@ const On = (t, e) => ({
1213
1226
  modified: i,
1214
1227
  target: r
1215
1228
  } = t, a = Array.isArray(r) ? r : [r], s = {
1216
- creator: Yt(n),
1229
+ creator: kt(n),
1217
1230
  created: o ? new Date(o) : void 0,
1218
1231
  updated: i ? new Date(i) : void 0,
1219
1232
  annotation: e,
@@ -1231,7 +1244,7 @@ const On = (t, e) => ({
1231
1244
  }
1232
1245
  return c;
1233
1246
  }, {});
1234
- if (dn(b))
1247
+ if (ln(b))
1235
1248
  s.selector.push({ id: u.id, ...b });
1236
1249
  else {
1237
1250
  const c = [
@@ -1242,14 +1255,14 @@ const On = (t, e) => ({
1242
1255
  }
1243
1256
  }
1244
1257
  return { parsed: s };
1245
- }, hn = (t) => {
1258
+ }, un = (t) => {
1246
1259
  const e = t.id || Xt(), {
1247
1260
  creator: n,
1248
1261
  created: o,
1249
1262
  modified: i,
1250
1263
  body: r,
1251
1264
  ...a
1252
- } = t, s = cn(r, e), u = un(t);
1265
+ } = t, s = an(r, e), u = dn(t);
1253
1266
  return "error" in u ? { error: u.error } : {
1254
1267
  parsed: {
1255
1268
  ...a,
@@ -1258,7 +1271,7 @@ const On = (t, e) => ({
1258
1271
  target: u.parsed
1259
1272
  }
1260
1273
  };
1261
- }, fn = (t, e, n) => {
1274
+ }, hn = (t, e, n) => {
1262
1275
  const { bodies: o, target: i, ...r } = t, {
1263
1276
  selector: a,
1264
1277
  creator: s,
@@ -1266,7 +1279,7 @@ const On = (t, e) => ({
1266
1279
  updated: f,
1267
1280
  ...b
1268
1281
  } = i, c = a.map((m) => {
1269
- const { quote: p, start: w, end: v, range: h } = m, { prefix: d, suffix: l } = te(h, n), y = [{
1282
+ const { quote: p, start: w, end: v, range: h } = m, { prefix: d, suffix: l } = Zt(h, n), y = [{
1270
1283
  type: "TextQuoteSelector",
1271
1284
  exact: p,
1272
1285
  prefix: d,
@@ -1288,21 +1301,21 @@ const On = (t, e) => ({
1288
1301
  "@context": "http://www.w3.org/ns/anno.jsonld",
1289
1302
  id: t.id,
1290
1303
  type: "Annotation",
1291
- body: ln(t.bodies),
1304
+ body: cn(t.bodies),
1292
1305
  creator: s,
1293
1306
  created: u == null ? void 0 : u.toISOString(),
1294
1307
  modified: f == null ? void 0 : f.toISOString(),
1295
1308
  target: c
1296
1309
  };
1297
1310
  };
1298
- function pn(t, e, n, o, i) {
1299
- $t(t, e, n || 0, o || t.length - 1, i || gn);
1311
+ function fn(t, e, n, o, i) {
1312
+ Yt(t, e, n || 0, o || t.length - 1, i || pn);
1300
1313
  }
1301
- function $t(t, e, n, o, i) {
1314
+ function Yt(t, e, n, o, i) {
1302
1315
  for (; o > n; ) {
1303
1316
  if (o - n > 600) {
1304
1317
  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), b = Math.max(n, Math.floor(e - a * u / r + f)), c = Math.min(o, Math.floor(e + (r - a) * u / r + f));
1305
- $t(t, e, b, c, i);
1318
+ Yt(t, e, b, c, i);
1306
1319
  }
1307
1320
  var m = t[e], p = n, w = o;
1308
1321
  for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); p < w; ) {
@@ -1318,10 +1331,10 @@ function W(t, e, n) {
1318
1331
  var o = t[e];
1319
1332
  t[e] = t[n], t[n] = o;
1320
1333
  }
1321
- function gn(t, e) {
1334
+ function pn(t, e) {
1322
1335
  return t < e ? -1 : t > e ? 1 : 0;
1323
1336
  }
1324
- class mn {
1337
+ class gn {
1325
1338
  constructor(e = 9) {
1326
1339
  this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
1327
1340
  }
@@ -1337,7 +1350,7 @@ class mn {
1337
1350
  for (; n; ) {
1338
1351
  for (let a = 0; a < n.children.length; a++) {
1339
1352
  const s = n.children[a], u = n.leaf ? i(s) : s;
1340
- tt(e, u) && (n.leaf ? o.push(s) : lt(e, u) ? this._all(s, o) : r.push(s));
1353
+ tt(e, u) && (n.leaf ? o.push(s) : dt(e, u) ? this._all(s, o) : r.push(s));
1341
1354
  }
1342
1355
  n = r.pop();
1343
1356
  }
@@ -1352,7 +1365,7 @@ class mn {
1352
1365
  for (let i = 0; i < n.children.length; i++) {
1353
1366
  const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;
1354
1367
  if (tt(e, a)) {
1355
- if (n.leaf || lt(e, a))
1368
+ if (n.leaf || dt(e, a))
1356
1369
  return !0;
1357
1370
  o.push(r);
1358
1371
  }
@@ -1397,11 +1410,11 @@ class mn {
1397
1410
  let s, u, f;
1398
1411
  for (; o || r.length; ) {
1399
1412
  if (o || (o = r.pop(), u = r[r.length - 1], s = a.pop(), f = !0), o.leaf) {
1400
- const b = bn(e, o.children, n);
1413
+ const b = mn(e, o.children, n);
1401
1414
  if (b !== -1)
1402
1415
  return o.children.splice(b, 1), r.push(o), this._condense(r), this;
1403
1416
  }
1404
- !f && !o.leaf && lt(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;
1417
+ !f && !o.leaf && dt(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;
1405
1418
  }
1406
1419
  return this;
1407
1420
  }
@@ -1448,7 +1461,7 @@ class mn {
1448
1461
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1449
1462
  let r = 1 / 0, a = 1 / 0, s;
1450
1463
  for (let u = 0; u < n.children.length; u++) {
1451
- const f = n.children[u], b = ct(f), c = wn(e, f) - b;
1464
+ const f = n.children[u], b = lt(f), c = yn(e, f) - b;
1452
1465
  c < a ? (a = c, r = b < r ? b : r, s = f) : c === a && b < r && (r = b, s = f);
1453
1466
  }
1454
1467
  n = s || n.children[0];
@@ -1474,14 +1487,14 @@ class mn {
1474
1487
  _chooseSplitIndex(e, n, o) {
1475
1488
  let i, r = 1 / 0, a = 1 / 0;
1476
1489
  for (let s = n; s <= o - n; s++) {
1477
- const u = q(e, 0, s, this.toBBox), f = q(e, s, o, this.toBBox), b = xn(u, f), c = ct(u) + ct(f);
1490
+ const u = q(e, 0, s, this.toBBox), f = q(e, s, o, this.toBBox), b = wn(u, f), c = lt(u) + lt(f);
1478
1491
  b < r ? (r = b, i = s, a = c < a ? c : a) : b === r && c < a && (a = c, i = s);
1479
1492
  }
1480
1493
  return i || o - n;
1481
1494
  }
1482
1495
  // sorts node children by the best axis for split
1483
1496
  _chooseSplitAxis(e, n, o) {
1484
- 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);
1497
+ const i = e.leaf ? this.compareMinX : bn, r = e.leaf ? this.compareMinY : vn, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
1485
1498
  a < s && e.children.sort(i);
1486
1499
  }
1487
1500
  // total margin of all possible split distributions where each node is at least m full
@@ -1508,7 +1521,7 @@ class mn {
1508
1521
  e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : P(e[n], this.toBBox);
1509
1522
  }
1510
1523
  }
1511
- function bn(t, e, n) {
1524
+ function mn(t, e, n) {
1512
1525
  if (!n)
1513
1526
  return e.indexOf(t);
1514
1527
  for (let o = 0; o < e.length; o++)
@@ -1530,26 +1543,26 @@ function q(t, e, n, o, i) {
1530
1543
  function j(t, e) {
1531
1544
  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;
1532
1545
  }
1533
- function vn(t, e) {
1546
+ function bn(t, e) {
1534
1547
  return t.minX - e.minX;
1535
1548
  }
1536
- function yn(t, e) {
1549
+ function vn(t, e) {
1537
1550
  return t.minY - e.minY;
1538
1551
  }
1539
- function ct(t) {
1552
+ function lt(t) {
1540
1553
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1541
1554
  }
1542
1555
  function Z(t) {
1543
1556
  return t.maxX - t.minX + (t.maxY - t.minY);
1544
1557
  }
1545
- function wn(t, e) {
1558
+ function yn(t, e) {
1546
1559
  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));
1547
1560
  }
1548
- function xn(t, e) {
1561
+ function wn(t, e) {
1549
1562
  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);
1550
1563
  return Math.max(0, i - n) * Math.max(0, r - o);
1551
1564
  }
1552
- function lt(t, e) {
1565
+ function dt(t, e) {
1553
1566
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1554
1567
  }
1555
1568
  function tt(t, e) {
@@ -1572,17 +1585,17 @@ function Bt(t, e, n, o, i) {
1572
1585
  if (n = r.pop(), e = r.pop(), n - e <= o)
1573
1586
  continue;
1574
1587
  const a = e + Math.ceil((n - e) / o / 2) * o;
1575
- pn(t, a, e, n, i), r.push(e, a, a, n);
1588
+ fn(t, a, e, n, i), r.push(e, a, a, n);
1576
1589
  }
1577
1590
  }
1578
- const An = (t, e) => {
1579
- const n = new mn(), o = /* @__PURE__ */ new Map(), i = (d, l) => {
1580
- const y = d.selector.flatMap((T) => {
1581
- const R = T.range instanceof Range && !T.range.collapsed && T.range.startContainer.nodeType === Node.TEXT_NODE && T.range.endContainer.nodeType === Node.TEXT_NODE ? T.range : Mt(T, e).range;
1591
+ const xn = (t, e) => {
1592
+ const n = new gn(), o = /* @__PURE__ */ new Map(), i = (d, l) => {
1593
+ const y = d.selector.flatMap((C) => {
1594
+ const R = C.range instanceof Range && !C.range.collapsed && C.range.startContainer.nodeType === Node.TEXT_NODE && C.range.endContainer.nodeType === Node.TEXT_NODE ? C.range : Mt(C, e).range;
1582
1595
  return Array.from(R.getClientRects());
1583
- }), C = oe(y).map(({ left: T, top: E, right: R, bottom: g }) => new DOMRect(T - l.left, E - l.top, R - T, g - E));
1584
- return C.map((T) => {
1585
- const { x: E, y: R, width: g, height: A } = T;
1596
+ }), T = ne(y).map(({ left: C, top: E, right: R, bottom: g }) => new DOMRect(C - l.left, E - l.top, R - C, g - E));
1597
+ return T.map((C) => {
1598
+ const { x: E, y: R, width: g, height: A } = C;
1586
1599
  return {
1587
1600
  minX: E,
1588
1601
  minY: R,
@@ -1590,7 +1603,7 @@ const An = (t, e) => {
1590
1603
  maxY: R + A,
1591
1604
  annotation: {
1592
1605
  id: d.annotation,
1593
- rects: C
1606
+ rects: T
1594
1607
  }
1595
1608
  };
1596
1609
  });
@@ -1606,29 +1619,29 @@ const An = (t, e) => {
1606
1619
  u(d), s(d);
1607
1620
  }, b = (d, l = !0) => {
1608
1621
  l && a();
1609
- const y = e.getBoundingClientRect(), C = d.map((E) => ({ target: E, rects: i(E, y) }));
1610
- C.forEach(({ target: E, rects: R }) => o.set(E.annotation, R));
1611
- const T = C.reduce((E, { rects: R }) => [...E, ...R], []);
1612
- n.load(T);
1622
+ const y = e.getBoundingClientRect(), T = d.map((E) => ({ target: E, rects: i(E, y) }));
1623
+ T.forEach(({ target: E, rects: R }) => o.set(E.annotation, R));
1624
+ const C = T.reduce((E, { rects: R }) => [...E, ...R], []);
1625
+ n.load(C);
1613
1626
  }, c = (d, l) => {
1614
1627
  const y = n.search({
1615
1628
  minX: d,
1616
1629
  minY: l,
1617
1630
  maxX: d,
1618
1631
  maxY: l
1619
- }), C = (T) => T.annotation.rects.reduce((E, R) => E + R.width * R.height, 0);
1632
+ }), T = (C) => C.annotation.rects.reduce((E, R) => E + R.width * R.height, 0);
1620
1633
  if (y.length > 0)
1621
- return y.sort((T, E) => C(T) - C(E)), y[0].annotation.id;
1634
+ return y.sort((C, E) => T(C) - T(E)), y[0].annotation.id;
1622
1635
  }, m = (d) => {
1623
1636
  const l = p(d);
1624
1637
  if (l.length === 0)
1625
1638
  return;
1626
- let y = l[0].left, C = l[0].top, T = l[0].right, E = l[0].bottom;
1639
+ let y = l[0].left, T = l[0].top, C = l[0].right, E = l[0].bottom;
1627
1640
  for (let R = 1; R < l.length; R++) {
1628
1641
  const g = l[R];
1629
- y = Math.min(y, g.left), C = Math.min(C, g.top), T = Math.max(T, g.right), E = Math.max(E, g.bottom);
1642
+ y = Math.min(y, g.left), T = Math.min(T, g.top), C = Math.max(C, g.right), E = Math.max(E, g.bottom);
1630
1643
  }
1631
- return new DOMRect(y, C, T - y, E - C);
1644
+ return new DOMRect(y, T, C - y, E - T);
1632
1645
  }, p = (d) => {
1633
1646
  const l = o.get(d);
1634
1647
  return l ? l[0].annotation.rects : [];
@@ -1639,8 +1652,8 @@ const An = (t, e) => {
1639
1652
  getAt: c,
1640
1653
  getAnnotationBounds: m,
1641
1654
  getAnnotationRects: p,
1642
- getIntersecting: (d, l, y, C) => {
1643
- const T = n.search({ minX: d, minY: l, maxX: y, maxY: C }), E = new Set(T.reduce((R, g) => [...R, g.annotation.id], []));
1655
+ getIntersecting: (d, l, y, T) => {
1656
+ const C = n.search({ minX: d, minY: l, maxX: y, maxY: T }), E = new Set(C.reduce((R, g) => [...R, g.annotation.id], []));
1644
1657
  return Array.from(E).map((R) => ({
1645
1658
  annotation: t.getAnnotation(R),
1646
1659
  rects: p(R)
@@ -1653,23 +1666,23 @@ const An = (t, e) => {
1653
1666
  size: () => n.all().length,
1654
1667
  update: f
1655
1668
  };
1656
- }, En = (t, e) => {
1657
- const n = We(), o = An(n, t), i = Oe(n, e), r = Be(n), a = Ke(), s = (v, h = L.LOCAL) => {
1658
- const d = nt(v, t), l = k(d.target.selector);
1669
+ }, An = (t, e) => {
1670
+ const n = Fe(), o = xn(n, t), i = Oe(n, e), r = Le(n), a = Ge(), s = (v, h = L.LOCAL) => {
1671
+ const d = ot(v, t), l = k(d.target.selector);
1659
1672
  return l && n.addAnnotation(d, h), l;
1660
1673
  }, u = (v, h = !0, d = L.LOCAL) => {
1661
- const l = v.map((C) => nt(C, t)), y = l.filter((C) => !k(C.target.selector));
1674
+ const l = v.map((T) => ot(T, t)), y = l.filter((T) => !k(T.target.selector));
1662
1675
  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), []);
1663
1676
  }, f = (v, h = L.LOCAL) => {
1664
- const d = v.map((y) => nt(y, t)), l = d.filter((y) => !k(y.target.selector));
1677
+ const d = v.map((y) => ot(y, t)), l = d.filter((y) => !k(y.target.selector));
1665
1678
  return l.length > 0 && console.warn("Could not revive all targets for these annotations:", l), d.forEach((y) => {
1666
1679
  n.getAnnotation(y.id) ? n.updateAnnotation(y, h) : n.addAnnotation(y, h);
1667
1680
  }), l;
1668
1681
  }, b = (v, h = L.LOCAL) => {
1669
- const d = et(v, t);
1682
+ const d = nt(v, t);
1670
1683
  n.updateTarget(d, h);
1671
1684
  }, c = (v, h = L.LOCAL) => {
1672
- const d = v.map((l) => et(l, t));
1685
+ const d = v.map((l) => nt(l, t));
1673
1686
  n.bulkUpdateTargets(d, h);
1674
1687
  }, m = (v, h) => {
1675
1688
  const d = o.getAt(v, h);
@@ -1678,9 +1691,9 @@ const An = (t, e) => {
1678
1691
  const y = o.getAnnotationRects(v);
1679
1692
  if (y.length !== 0) {
1680
1693
  if (h && d) {
1681
- const C = y.find(({ top: T, right: E, bottom: R, left: g }) => h >= g - l && h <= E + l && d >= T - l && d <= R + l);
1682
- if (C)
1683
- return C;
1694
+ const T = y.find(({ top: C, right: E, bottom: R, left: g }) => h >= g - l && h <= E + l && d >= C - l && d <= R + l);
1695
+ if (T)
1696
+ return T;
1684
1697
  }
1685
1698
  return o.getAnnotationBounds(v);
1686
1699
  }
@@ -1705,13 +1718,13 @@ const An = (t, e) => {
1705
1718
  hover: r,
1706
1719
  viewport: a
1707
1720
  };
1708
- }, Sn = () => {
1721
+ }, En = () => {
1709
1722
  const t = document.createElement("canvas");
1710
1723
  t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-highlight-layer presence";
1711
1724
  const e = t.getContext("2d");
1712
1725
  return e.scale(2, 2), e.translate(0.5, 0.5), t;
1713
- }, Cn = (t, e, n = {}) => {
1714
- const o = Sn(), i = o.getContext("2d");
1726
+ }, Sn = (t, e, n = {}) => {
1727
+ const o = En(), i = o.getContext("2d");
1715
1728
  t.appendChild(o);
1716
1729
  const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([m, p]) => p.presenceKey === c.presenceKey).map(([m, p]) => m);
1717
1730
  return e.on("selectionChange", (c, m) => {
@@ -1730,8 +1743,8 @@ const An = (t, e) => {
1730
1743
  if (w) {
1731
1744
  const { height: v } = c.rects[0], h = c.rects[0].x + m.left, d = c.rects[0].y + m.top;
1732
1745
  i.fillStyle = w.appearance.color, i.fillRect(h - 2, d - 2.5, 2, v + 5);
1733
- const l = i.measureText(w.appearance.label), y = l.width + 6, C = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, T = l.fontBoundingBoxAscent ? 8 : 6.5;
1734
- return i.fillRect(h - 2, d - 2.5 - C, y, C), i.fillStyle = "#fff", i.fillText(w.appearance.label, h + 1, d - T), {
1746
+ const l = i.measureText(w.appearance.label), y = l.width + 6, T = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, C = l.fontBoundingBoxAscent ? 8 : 6.5;
1747
+ return i.fillRect(h - 2, d - 2.5 - T, y, T), i.fillStyle = "#fff", i.fillText(w.appearance.label, h + 1, d - C), {
1735
1748
  fill: w.appearance.color,
1736
1749
  fillOpacity: p ? 0.45 : 0.18
1737
1750
  };
@@ -1748,7 +1761,7 @@ const An = (t, e) => {
1748
1761
  return document.scrollingElement;
1749
1762
  const { overflowY: e } = window.getComputedStyle(t);
1750
1763
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Ht(t.parentElement);
1751
- }, Tn = (t, e) => (n) => {
1764
+ }, Cn = (t, e) => (n) => {
1752
1765
  const o = (r) => {
1753
1766
  const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: c } = e.getAnnotationBounds(n.id), m = f.top - a.top, p = f.left - a.left, w = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = m + w - (s - c) / 2, d = p + v - (u - b) / 2;
1754
1767
  i.scroll({ top: h, left: d, behavior: "smooth" });
@@ -1758,16 +1771,16 @@ const An = (t, e) => {
1758
1771
  if (a && !a.collapsed)
1759
1772
  return o(r.target), !0;
1760
1773
  {
1761
- const s = et(r.target, t), { range: u } = s.selector[0];
1774
+ const s = nt(r.target, t), { range: u } = s.selector[0];
1762
1775
  if (u && !u.collapsed)
1763
1776
  return o(s), !0;
1764
1777
  }
1765
1778
  }
1766
1779
  return !1;
1767
- }, Rn = (t, e) => ({
1780
+ }, Tn = (t, e) => ({
1768
1781
  ...t,
1769
1782
  annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled
1770
- }), Nn = (t, e, n, o) => {
1783
+ }), Rn = (t, e, n, o) => {
1771
1784
  const { store: i, selection: r } = e;
1772
1785
  let a, s;
1773
1786
  const u = (h) => a = h;
@@ -1776,7 +1789,7 @@ const An = (t, e) => {
1776
1789
  var l;
1777
1790
  if (!f)
1778
1791
  return;
1779
- !((l = h.target.parentElement) != null && l.closest(Y)) ? s = {
1792
+ !((l = h.target.parentElement) != null && l.closest(H)) ? s = {
1780
1793
  annotation: Xt(),
1781
1794
  selector: [],
1782
1795
  creator: a,
@@ -1788,13 +1801,13 @@ const An = (t, e) => {
1788
1801
  const d = document.getSelection();
1789
1802
  if (h.timeStamp - ((b == null ? void 0 : b.timeStamp) || h.timeStamp) < 1e3 && !s && c(b), d.isCollapsed || !f || !s)
1790
1803
  return;
1791
- const l = d.getRangeAt(0), y = re(l.cloneRange()), C = Qt(y);
1792
- (C.length !== s.selector.length || C.some((E, R) => {
1804
+ const l = d.getRangeAt(0), y = ie(l.cloneRange()), T = Kt(y);
1805
+ (T.length !== s.selector.length || T.some((E, R) => {
1793
1806
  var g;
1794
1807
  return E.toString() !== ((g = s.selector[R]) == null ? void 0 : g.quote);
1795
1808
  })) && (s = {
1796
1809
  ...s,
1797
- selector: C.map((E) => ie(E, t, o))
1810
+ selector: T.map((E) => oe(E, t, o))
1798
1811
  }, i.getAnnotation(s.annotation) ? i.updateTarget(s, L.LOCAL) : (i.addAnnotation({
1799
1812
  id: s.annotation,
1800
1813
  bodies: [],
@@ -1803,16 +1816,16 @@ const An = (t, e) => {
1803
1816
  });
1804
1817
  n && document.addEventListener("selectionchange", m);
1805
1818
  const p = (h) => {
1806
- const { target: d, timeStamp: l, offsetX: y, offsetY: C, type: T } = h;
1807
- b = { ...h, target: d, timeStamp: l, offsetX: y, offsetY: C, type: T }, f = h.button === 0;
1819
+ const { target: d, timeStamp: l, offsetX: y, offsetY: T, type: C } = h;
1820
+ b = { ...h, target: d, timeStamp: l, offsetX: y, offsetY: T, type: C }, f = h.button === 0;
1808
1821
  };
1809
1822
  t.addEventListener("pointerdown", p);
1810
1823
  const w = (h) => {
1811
- var C;
1812
- if (!!((C = h.target.parentElement) != null && C.closest(Y)) || !f)
1824
+ var T;
1825
+ if (!!((T = h.target.parentElement) != null && T.closest(H)) || !f)
1813
1826
  return;
1814
1827
  const l = () => {
1815
- const { x: T, y: E } = t.getBoundingClientRect(), R = i.getAt(h.clientX - T, h.clientY - E);
1828
+ const { x: C, y: E } = t.getBoundingClientRect(), R = i.getAt(h.clientX - C, h.clientY - E);
1816
1829
  if (R) {
1817
1830
  const { selected: g } = r;
1818
1831
  (g.length !== 1 || g[0].id !== R.id) && r.clickSelect(R.id, h);
@@ -1829,17 +1842,17 @@ const An = (t, e) => {
1829
1842
  };
1830
1843
  }, Ot = "SPANS", In = (t, e = {}) => {
1831
1844
  t.addEventListener("click", (E) => !E.target.closest("a") && E.preventDefault());
1832
- const n = Rn(e, {
1845
+ const n = Tn(e, {
1833
1846
  annotationEnabled: !0
1834
- }), o = En(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Ge(a), u = Qe(o, s, n.adapter);
1835
- let f = sn();
1836
- const b = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Ot : n.renderer || Ot, c = b === "SPANS" ? Se(t, o, r) : b === "CSS_HIGHLIGHTS" ? xe(t, o, r) : b === "CANVAS" ? ue(t, o, r) : void 0;
1847
+ }), o = An(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = je(a), u = Ke(o, s, n.adapter);
1848
+ let f = rn();
1849
+ const b = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Ot : n.renderer || Ot, c = b === "SPANS" ? Ee(t, o, r) : b === "CSS_HIGHLIGHTS" ? we(t, o, r) : b === "CANVAS" ? de(t, o, r) : void 0;
1837
1850
  if (!c)
1838
1851
  throw `Unknown renderer implementation: ${b}`;
1839
1852
  console.debug(`Using ${b} renderer`), n.style && c.setStyle(n.style);
1840
- const m = Nn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1853
+ const m = Rn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1841
1854
  return m.setUser(f), {
1842
- ...Ze(o, s, n.adapter),
1855
+ ...Je(o, s, n.adapter),
1843
1856
  destroy: () => {
1844
1857
  c.destroy(), m.destroy(), s.destroy();
1845
1858
  },
@@ -1854,46 +1867,46 @@ const An = (t, e) => {
1854
1867
  E ? i.setSelected(E) : i.clear();
1855
1868
  },
1856
1869
  setPresenceProvider: (E) => {
1857
- E && (c.setPainter(Cn(t, E, n.presence)), E.on("selectionChange", () => c.redraw()));
1870
+ E && (c.setPainter(Sn(t, E, n.presence)), E.on("selectionChange", () => c.redraw()));
1858
1871
  },
1859
1872
  setVisible: (E) => c.setVisible(E),
1860
1873
  on: u.on,
1861
1874
  off: u.off,
1862
- scrollIntoView: Tn(t, a),
1875
+ scrollIntoView: Cn(t, a),
1863
1876
  state: o
1864
1877
  };
1865
- }, Mn = Dt, Un = De, Vn = L;
1878
+ };
1866
1879
  export {
1867
- ht as DEFAULT_SELECTED_STYLE,
1868
- $ as DEFAULT_STYLE,
1880
+ et as DEFAULT_SELECTED_STYLE,
1881
+ Y as DEFAULT_STYLE,
1869
1882
  It as NOT_ANNOTATABLE_CLASS,
1870
- Y as NOT_ANNOTATABLE_SELECTOR,
1871
- Vn as Origin,
1872
- Mn as PointerSelectAction,
1883
+ H as NOT_ANNOTATABLE_SELECTOR,
1884
+ L as Origin,
1885
+ Be as PointerSelectAction,
1873
1886
  On as W3CTextFormat,
1874
- Un as createBody,
1875
- ue as createCanvasRenderer,
1876
- xe as createHighlightsRenderer,
1877
- we as createRenderer,
1878
- Se as createSpansRenderer,
1887
+ Bn as createBody,
1888
+ de as createCanvasRenderer,
1889
+ we as createHighlightsRenderer,
1890
+ ye as createRenderer,
1891
+ Ee as createSpansRenderer,
1879
1892
  In as createTextAnnotator,
1880
- En as createTextAnnotatorState,
1893
+ An as createTextAnnotatorState,
1881
1894
  ft as debounce,
1882
- Rn as fillDefaults,
1883
- Ln as getAnnotatableFragment,
1884
- Bn as getClientRectsPonyfill,
1885
- te as getQuoteContext,
1886
- dt as getRangeAnnotatableContents,
1895
+ Tn as fillDefaults,
1896
+ Nn as getAnnotatableFragment,
1897
+ Ln as getClientRectsPonyfill,
1898
+ Zt as getQuoteContext,
1899
+ ut as getRangeAnnotatableContents,
1887
1900
  k as isRevived,
1888
- oe as mergeClientRects,
1889
- jt as paint,
1890
- hn as parseW3CTextAnnotation,
1891
- ie as rangeToSelector,
1892
- nt as reviveAnnotation,
1901
+ ne as mergeClientRects,
1902
+ qt as paint,
1903
+ un as parseW3CTextAnnotation,
1904
+ oe as rangeToSelector,
1905
+ ot as reviveAnnotation,
1893
1906
  Mt as reviveSelector,
1894
- et as reviveTarget,
1895
- fn as serializeW3CTextAnnotation,
1896
- Qt as splitAnnotatableRanges,
1897
- re as trimRange
1907
+ nt as reviveTarget,
1908
+ hn as serializeW3CTextAnnotation,
1909
+ Kt as splitAnnotatableRanges,
1910
+ ie as trimRange
1898
1911
  };
1899
1912
  //# sourceMappingURL=text-annotator.es.js.map