@recogito/text-annotator 3.0.0-rc.26 → 3.0.0-rc.28

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