@soomo/text-annotator 3.1.0-staging.11 → 3.1.0-staging.12

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,4 +1,4 @@
1
- const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
1
+ const ce = "not-annotatable", Z = `.${ce}`, nt = (t) => {
2
2
  var n;
3
3
  return !!(t instanceof HTMLElement ? t.closest(Z) : (n = t.parentElement) == null ? void 0 : n.closest(Z));
4
4
  }, Me = (t) => {
@@ -13,7 +13,7 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
13
13
  const e = document.createNodeIterator(
14
14
  t.commonAncestorContainer,
15
15
  NodeFilter.SHOW_ELEMENT,
16
- (o) => o instanceof HTMLElement && o.classList.contains(le) && !o.parentElement.closest(Z) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
16
+ (o) => o instanceof HTMLElement && o.classList.contains(ce) && !o.parentElement.closest(Z) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
17
17
  );
18
18
  let n;
19
19
  for (; n = e.nextNode(); )
@@ -31,15 +31,15 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
31
31
  o.setStartAfter(n), o.collapsed || e.push(o);
32
32
  }
33
33
  return e.length > 0 ? e : [t];
34
- }, Dt = (t) => {
34
+ }, Ut = (t) => {
35
35
  const e = t.cloneContents();
36
36
  return e.querySelectorAll(Z).forEach((n) => n.remove()), e;
37
37
  }, Ue = (t, e, n = 10, o) => {
38
38
  const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
39
39
  s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
40
- const r = Dt(s).textContent, a = document.createRange();
40
+ const r = Ut(s).textContent, a = document.createRange();
41
41
  a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
42
- const d = Dt(a).textContent;
42
+ const d = Ut(a).textContent;
43
43
  return {
44
44
  prefix: r.substring(r.length - n),
45
45
  suffix: d.substring(0, n)
@@ -102,16 +102,16 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
102
102
  }), Pe = (t, e, n) => {
103
103
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
104
104
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
105
- const s = Dt(o).textContent, r = t.toString(), a = s.length || 0, d = a + r.length;
105
+ const s = Ut(o).textContent, r = t.toString(), a = s.length || 0, d = a + r.length;
106
106
  return n ? { quote: r, start: a, end: d, range: t, offsetReference: i } : { quote: r, start: a, end: d, range: t };
107
- }, de = (t, e) => {
108
- var h, l;
107
+ }, le = (t, e) => {
108
+ var f, l;
109
109
  const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
110
110
  e,
111
111
  NodeFilter.SHOW_TEXT,
112
- (g) => {
112
+ (m) => {
113
113
  var p;
114
- return (p = g.parentElement) != null && p.closest(Z) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
114
+ return (p = m.parentElement) != null && p.closest(Z) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
115
115
  }
116
116
  );
117
117
  let r = 0;
@@ -121,22 +121,22 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
121
121
  let c = !i;
122
122
  for (; d !== null; ) {
123
123
  if (c || (c = i == null ? void 0 : i.contains(d)), c) {
124
- const g = ((h = d.textContent) == null ? void 0 : h.length) || 0;
125
- if (r + g > n) {
124
+ const m = ((f = d.textContent) == null ? void 0 : f.length) || 0;
125
+ if (r + m > n) {
126
126
  a.setStart(d, n - r);
127
127
  break;
128
128
  }
129
- r += g;
129
+ r += m;
130
130
  }
131
131
  d = s.nextNode();
132
132
  }
133
133
  for (; d !== null; ) {
134
- const g = ((l = d.textContent) == null ? void 0 : l.length) || 0;
135
- if (r + g >= o) {
134
+ const m = ((l = d.textContent) == null ? void 0 : l.length) || 0;
135
+ if (r + m >= o) {
136
136
  a.setEnd(d, o - r);
137
137
  break;
138
138
  }
139
- r += g, d = s.nextNode();
139
+ r += m, d = s.nextNode();
140
140
  }
141
141
  return {
142
142
  ...t,
@@ -144,21 +144,21 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
144
144
  };
145
145
  }, wt = (t, e) => F(t.selector) ? t : {
146
146
  ...t,
147
- selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : de(n, e))
148
- }, xt = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, ue = (t, e) => {
147
+ selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : le(n, e))
148
+ }, At = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, de = (t, e) => {
149
149
  if (t.isEqualNode(e))
150
150
  return !0;
151
151
  for (let n of t.childNodes)
152
- if (ue(n, e))
152
+ if (de(n, e))
153
153
  return !0;
154
154
  return !1;
155
155
  }, $e = (t, e) => {
156
156
  const n = t.cloneContents();
157
- return ue(n, e);
157
+ return de(n, e);
158
158
  }, je = (t, e) => {
159
159
  const n = t.cloneRange(), o = e.contains(n.startContainer), i = e.contains(n.endContainer);
160
160
  return !o && !i && !$e(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
161
- }, Et = (t) => ({
161
+ }, xt = (t) => ({
162
162
  ...t,
163
163
  type: t.type,
164
164
  x: t.x,
@@ -206,16 +206,16 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
206
206
  }, Bo = (t, e) => {
207
207
  const { left: n, top: o, right: i, bottom: s } = t;
208
208
  return new DOMRect(n + e.left, o + e.top, i - n, s - o);
209
- }, fe = (t) => {
209
+ }, ue = (t) => {
210
210
  if (t === null)
211
211
  return document.scrollingElement;
212
212
  const { overflowY: e } = window.getComputedStyle(t);
213
- return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : fe(t.parentElement);
213
+ return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ue(t.parentElement);
214
214
  }, ze = (t, e) => (n) => {
215
215
  const o = typeof n == "string" ? n : n.id, i = (r) => {
216
- const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: l, height: g } = e.getAnnotationBounds(o), p = h.top - a.top, v = h.left - a.left, w = s.parentElement ? s.scrollTop : 0, E = s.parentElement ? s.scrollLeft : 0, m = p + w - (d - g) / 2, u = v + E - (c - l) / 2;
217
- s.scroll({ top: m, left: u, behavior: "smooth" });
218
- }, s = fe(t);
216
+ const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: l, height: m } = e.getAnnotationBounds(o), p = f.top - a.top, w = f.left - a.left, b = s.parentElement ? s.scrollTop : 0, S = s.parentElement ? s.scrollLeft : 0, g = p + b - (d - m) / 2, u = w + S - (c - l) / 2;
217
+ s.scroll({ top: g, left: u, behavior: "smooth" });
218
+ }, s = ue(t);
219
219
  if (s) {
220
220
  const r = e.getAnnotation(o), { range: a } = r.target.selector[0];
221
221
  if (a && !a.collapsed)
@@ -241,8 +241,8 @@ const le = "not-annotatable", Z = `.${le}`, nt = (t) => {
241
241
  function We(t) {
242
242
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
243
243
  }
244
- var Yt = { exports: {} };
245
- function he(t, e = 100, n = {}) {
244
+ var Kt = { exports: {} };
245
+ function fe(t, e = 100, n = {}) {
246
246
  if (typeof t != "function")
247
247
  throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
248
248
  if (e < 0)
@@ -250,19 +250,19 @@ function he(t, e = 100, n = {}) {
250
250
  const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
251
251
  let i, s, r, a, d;
252
252
  function c() {
253
- const g = i, p = s;
254
- return i = void 0, s = void 0, d = t.apply(g, p), d;
253
+ const m = i, p = s;
254
+ return i = void 0, s = void 0, d = t.apply(m, p), d;
255
255
  }
256
- function h() {
257
- const g = Date.now() - a;
258
- g < e && g >= 0 ? r = setTimeout(h, e - g) : (r = void 0, o || (d = c()));
256
+ function f() {
257
+ const m = Date.now() - a;
258
+ m < e && m >= 0 ? r = setTimeout(f, e - m) : (r = void 0, o || (d = c()));
259
259
  }
260
- const l = function(...g) {
260
+ const l = function(...m) {
261
261
  if (i && this !== i && Object.getPrototypeOf(this) === Object.getPrototypeOf(i))
262
262
  throw new Error("Debounced method called with different contexts of the same prototype.");
263
- i = this, s = g, a = Date.now();
263
+ i = this, s = m, a = Date.now();
264
264
  const p = o && !r;
265
- return r || (r = setTimeout(h, e)), p && (d = c()), d;
265
+ return r || (r = setTimeout(f, e)), p && (d = c()), d;
266
266
  };
267
267
  return l.clear = () => {
268
268
  r && (clearTimeout(r), r = void 0);
@@ -272,10 +272,10 @@ function he(t, e = 100, n = {}) {
272
272
  d = c(), l.clear();
273
273
  }, l;
274
274
  }
275
- Yt.exports.debounce = he;
276
- Yt.exports = he;
277
- var qe = Yt.exports;
278
- const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
275
+ Kt.exports.debounce = fe;
276
+ Kt.exports = fe;
277
+ var qe = Kt.exports;
278
+ const Yt = /* @__PURE__ */ We(qe), Ge = (t) => {
279
279
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, d = i - e;
280
280
  return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: d };
281
281
  }, Qe = (t) => {
@@ -284,47 +284,47 @@ const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
284
284
  const i = o.map((s) => s.id);
285
285
  (e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
286
286
  };
287
- }, Pt = (t, e, n, o) => {
287
+ }, Xt = (t, e, n, o) => {
288
288
  const { store: i, selection: s, hover: r } = e;
289
289
  let a, d, c;
290
- const h = Qe(n), l = (O) => {
291
- const { x: M, y: f } = t.getBoundingClientRect(), y = i.getAt(O.clientX - M, O.clientY - f, d);
292
- y ? r.current !== y.id && (t.classList.add("hovered"), r.set(y.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
290
+ const f = Qe(n), l = (T) => {
291
+ const { x, y: h } = t.getBoundingClientRect(), v = i.getAt(T.clientX - x, T.clientY - h, d);
292
+ v ? r.current !== v.id && (t.classList.add("hovered"), r.set(v.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
293
293
  };
294
294
  t.addEventListener("pointermove", l);
295
- const g = (O = !1) => {
295
+ const m = (T = !1) => {
296
296
  c && c.clear();
297
- const M = Ge(t), { minX: f, minY: y, maxX: x, maxY: C } = M, B = d ? i.getIntersecting(f, y, x, C).filter(({ annotation: Y }) => d(Y)) : i.getIntersecting(f, y, x, C), R = s.selected.map(({ id: Y }) => Y), K = B.map(({ annotation: Y, rects: At }) => {
298
- const dt = R.includes(Y.id), Re = Y.id === r.current;
299
- return { annotation: Y, rects: At, state: { selected: dt, hover: Re } };
297
+ const x = Ge(t), { minX: h, minY: v, maxX: A, maxY: L } = x, M = d ? i.getIntersecting(h, v, A, L).filter(({ annotation: Y }) => d(Y)) : i.getIntersecting(h, v, A, L), B = s.selected.map(({ id: Y }) => Y), K = M.map(({ annotation: Y, rects: dt }) => {
298
+ const Te = B.includes(Y.id), Re = Y.id === r.current;
299
+ return { annotation: Y, rects: dt, state: { selected: Te, hover: Re } };
300
300
  });
301
- o.redraw(K, M, a, c, O), setTimeout(() => h(B.map(({ annotation: Y }) => Y)), 1);
302
- }, p = (O) => {
303
- c = O, g();
304
- }, v = (O) => {
305
- a = O, g();
306
- }, w = (O) => {
307
- d = O, g(!1);
308
- }, E = () => g();
309
- i.observe(E);
310
- const m = s.subscribe(() => g()), u = () => g(!0);
301
+ o.redraw(K, x, a, c, T), setTimeout(() => f(M.map(({ annotation: Y }) => Y)), 1);
302
+ }, p = (T) => {
303
+ c = T, m();
304
+ }, w = (T) => {
305
+ a = T, m();
306
+ }, b = (T) => {
307
+ d = T, m(!1);
308
+ }, S = () => m();
309
+ i.observe(S);
310
+ const g = s.subscribe(() => m()), u = () => m(!0);
311
311
  document.addEventListener("scroll", u, { capture: !0, passive: !0 });
312
- const b = Xt(() => {
313
- i.recalculatePositions(), c == null || c.reset(), g();
312
+ const y = Yt(() => {
313
+ i.recalculatePositions(), c == null || c.reset(), m();
314
314
  }, 10);
315
- window.addEventListener("resize", b);
316
- const S = new ResizeObserver(b);
317
- S.observe(t);
318
- const A = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((O) => {
319
- O.every((f) => f.target === t || t.contains(f.target)) || g(!0);
315
+ window.addEventListener("resize", y);
316
+ const C = new ResizeObserver(y);
317
+ C.observe(t);
318
+ const E = { attributes: !0, childList: !0, subtree: !0 }, O = new MutationObserver((T) => {
319
+ T.every((h) => h.target === t || t.contains(h.target)) || m(!0);
320
320
  });
321
- return L.observe(document.body, A), {
321
+ return O.observe(document.body, E), {
322
322
  destroy: () => {
323
- t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(E), m(), document.removeEventListener("scroll", u), b.clear(), window.removeEventListener("resize", b), S.disconnect(), L.disconnect();
323
+ t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(S), g(), document.removeEventListener("scroll", u), y.clear(), window.removeEventListener("resize", y), C.disconnect(), O.disconnect();
324
324
  },
325
- redraw: g,
326
- setStyle: v,
327
- setFilter: w,
325
+ redraw: m,
326
+ setStyle: w,
327
+ setFilter: b,
328
328
  setPainter: p,
329
329
  setVisible: o.setVisible
330
330
  };
@@ -337,32 +337,32 @@ const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
337
337
  t.classList.add("r6o-annotatable");
338
338
  const e = Je(), n = e.getContext("2d");
339
339
  document.body.appendChild(e);
340
- const o = (a, d, c, h) => requestAnimationFrame(() => {
341
- const { width: l, height: g } = e;
342
- n.clearRect(-0.5, -0.5, l + 1, g + 1), h && h.clear();
343
- const { top: p, left: v } = d;
344
- [...a].sort((E, m) => {
345
- const { annotation: { target: { created: u } } } = E, { annotation: { target: { created: b } } } = m;
346
- return u.getTime() - b.getTime();
347
- }).forEach((E) => {
348
- var S;
349
- const m = c ? typeof c == "function" ? c(E.annotation, E.state) : c : (S = E.state) != null && S.selected ? vt : W, u = h && h.paint(E, d) || m, b = E.rects.map(({ x: A, y: L, width: T, height: O }) => ({
350
- x: A + v,
351
- y: L + p,
352
- width: T,
353
- height: O
340
+ const o = (a, d, c, f) => requestAnimationFrame(() => {
341
+ const { width: l, height: m } = e;
342
+ n.clearRect(-0.5, -0.5, l + 1, m + 1), f && f.clear();
343
+ const { top: p, left: w } = d;
344
+ [...a].sort((S, g) => {
345
+ const { annotation: { target: { created: u } } } = S, { annotation: { target: { created: y } } } = g;
346
+ return u.getTime() - y.getTime();
347
+ }).forEach((S) => {
348
+ var C;
349
+ const g = c ? typeof c == "function" ? c(S.annotation, S.state) : c : (C = S.state) != null && C.selected ? vt : W, u = f && f.paint(S, d) || g, y = S.rects.map(({ x: E, y: O, width: R, height: T }) => ({
350
+ x: E + w,
351
+ y: O + p,
352
+ width: R,
353
+ height: T
354
354
  }));
355
- if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, b.forEach(
356
- ({ x: A, y: L, width: T, height: O }) => n.fillRect(A, L, T, O)
355
+ if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, y.forEach(
356
+ ({ x: E, y: O, width: R, height: T }) => n.fillRect(E, O, R, T)
357
357
  ), u.underlineColor) {
358
358
  n.globalAlpha = 1, n.strokeStyle = u.underlineColor, n.lineWidth = u.underlineThickness ?? 1;
359
- const A = u.underlineOffset ?? 0;
360
- b.forEach(({ x: L, y: T, width: O, height: M }) => {
361
- n.beginPath(), n.moveTo(L, T + M + A), n.lineTo(L + O, T + M + A), n.stroke();
359
+ const E = u.underlineOffset ?? 0;
360
+ y.forEach(({ x: O, y: R, width: T, height: x }) => {
361
+ n.beginPath(), n.moveTo(O, R + x + E), n.lineTo(O + T, R + x + E), n.stroke();
362
362
  });
363
363
  }
364
364
  });
365
- }), i = Xt(() => Ze(e), 10);
365
+ }), i = Yt(() => Ze(e), 10);
366
366
  return window.addEventListener("resize", i), {
367
367
  destroy: () => {
368
368
  e.remove(), i.clear(), window.removeEventListener("resize", i);
@@ -372,123 +372,123 @@ const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
372
372
  },
373
373
  redraw: o
374
374
  };
375
- }, en = (t, e, n) => Pt(t, e, n, tn(t));
375
+ }, en = (t, e, n) => Xt(t, e, n, tn(t));
376
376
  var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
377
377
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
378
378
  }, _ = function(t, e, n) {
379
379
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
380
380
  }, X = function(t, e, n) {
381
381
  return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
382
- }, pe = function(t) {
382
+ }, he = function(t) {
383
383
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
384
- }, Ht = function(t) {
384
+ }, jt = function(t) {
385
385
  return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
386
- }, St = function(t) {
386
+ }, Et = function(t) {
387
387
  return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
388
388
  }, on = /^#([0-9a-f]{3,8})$/i, ft = function(t) {
389
389
  var e = t.toString(16);
390
390
  return e.length < 2 ? "0" + e : e;
391
- }, ge = function(t) {
391
+ }, pe = function(t) {
392
392
  var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), r = s - Math.min(e, n, o), a = r ? s === e ? (n - o) / r : s === n ? 2 + (o - e) / r : 4 + (e - n) / r : 0;
393
393
  return { h: 60 * (a < 0 ? a + 6 : a), s: s ? r / s * 100 : 0, v: s / 255 * 100, a: i };
394
- }, me = function(t) {
394
+ }, ge = function(t) {
395
395
  var e = t.h, n = t.s, o = t.v, i = t.a;
396
396
  e = e / 360 * 6, n /= 100, o /= 100;
397
397
  var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), c = s % 6;
398
398
  return { r: 255 * [o, a, r, r, d, o][c], g: 255 * [d, o, o, a, r, r][c], b: 255 * [r, r, d, o, o, a][c], a: i };
399
+ }, Ht = function(t) {
400
+ return { h: he(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
399
401
  }, zt = function(t) {
400
- return { h: pe(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
401
- }, Ft = function(t) {
402
402
  return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
403
- }, Wt = function(t) {
404
- return me((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
403
+ }, Ft = function(t) {
404
+ return ge((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 }));
405
405
  var e, n, o;
406
406
  }, st = function(t) {
407
- return { h: (e = ge(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
407
+ return { h: (e = pe(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 };
408
408
  var e, n, o, i;
409
- }, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qt = { string: [[function(t) {
409
+ }, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Wt = { string: [[function(t) {
410
410
  var e = on.exec(t);
411
411
  return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? _(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? _(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
412
412
  }, "hex"], [function(t) {
413
413
  var e = an.exec(t) || cn.exec(t);
414
- return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Ht({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
414
+ return e ? e[2] !== e[4] || e[4] !== e[6] ? null : jt({ 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;
415
415
  }, "rgb"], [function(t) {
416
416
  var e = sn.exec(t) || rn.exec(t);
417
417
  if (!e) return null;
418
- var n, o, i = zt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (nn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
419
- return Wt(i);
418
+ var n, o, i = Ht({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (nn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
419
+ return Ft(i);
420
420
  }, "hsl"]], object: [[function(t) {
421
421
  var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
422
- return H(e) && H(n) && H(o) ? Ht({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
422
+ return H(e) && H(n) && H(o) ? jt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
423
423
  }, "rgb"], [function(t) {
424
424
  var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
425
425
  if (!H(e) || !H(n) || !H(o)) return null;
426
- var r = zt({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
427
- return Wt(r);
426
+ var r = Ht({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
427
+ return Ft(r);
428
428
  }, "hsl"], [function(t) {
429
429
  var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
430
430
  if (!H(e) || !H(n) || !H(o)) return null;
431
431
  var r = function(a) {
432
- return { h: pe(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
432
+ return { h: he(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
433
433
  }({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
434
- return me(r);
435
- }, "hsv"]] }, Gt = function(t, e) {
434
+ return ge(r);
435
+ }, "hsv"]] }, qt = function(t, e) {
436
436
  for (var n = 0; n < e.length; n++) {
437
437
  var o = e[n][0](t);
438
438
  if (o) return [o, e[n][1]];
439
439
  }
440
440
  return [null, void 0];
441
441
  }, ln = function(t) {
442
- return typeof t == "string" ? Gt(t.trim(), qt.string) : typeof t == "object" && t !== null ? Gt(t, qt.object) : [null, void 0];
443
- }, Ct = function(t, e) {
442
+ return typeof t == "string" ? qt(t.trim(), Wt.string) : typeof t == "object" && t !== null ? qt(t, Wt.object) : [null, void 0];
443
+ }, St = function(t, e) {
444
444
  var n = st(t);
445
445
  return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
446
- }, Lt = function(t) {
446
+ }, Ct = function(t) {
447
447
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
448
- }, Qt = function(t, e) {
448
+ }, Gt = function(t, e) {
449
449
  var n = st(t);
450
450
  return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
451
- }, Jt = function() {
451
+ }, Qt = function() {
452
452
  function t(e) {
453
453
  this.parsed = ln(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
454
454
  }
455
455
  return t.prototype.isValid = function() {
456
456
  return this.parsed !== null;
457
457
  }, t.prototype.brightness = function() {
458
- return _(Lt(this.rgba), 2);
458
+ return _(Ct(this.rgba), 2);
459
459
  }, t.prototype.isDark = function() {
460
- return Lt(this.rgba) < 0.5;
460
+ return Ct(this.rgba) < 0.5;
461
461
  }, t.prototype.isLight = function() {
462
- return Lt(this.rgba) >= 0.5;
462
+ return Ct(this.rgba) >= 0.5;
463
463
  }, t.prototype.toHex = function() {
464
- return e = St(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? ft(_(255 * s)) : "", "#" + ft(n) + ft(o) + ft(i) + r;
464
+ return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? ft(_(255 * s)) : "", "#" + ft(n) + ft(o) + ft(i) + r;
465
465
  var e, n, o, i, s, r;
466
466
  }, t.prototype.toRgb = function() {
467
- return St(this.rgba);
467
+ return Et(this.rgba);
468
468
  }, t.prototype.toRgbString = function() {
469
- return e = St(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
469
+ return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
470
470
  var e, n, o, i, s;
471
471
  }, t.prototype.toHsl = function() {
472
- return Ft(st(this.rgba));
472
+ return zt(st(this.rgba));
473
473
  }, t.prototype.toHslString = function() {
474
- return e = Ft(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
474
+ return e = zt(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
475
475
  var e, n, o, i, s;
476
476
  }, t.prototype.toHsv = function() {
477
- return e = ge(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
477
+ return e = pe(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
478
478
  var e;
479
479
  }, t.prototype.invert = function() {
480
480
  return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
481
481
  var e;
482
482
  }, t.prototype.saturate = function(e) {
483
- return e === void 0 && (e = 0.1), $(Ct(this.rgba, e));
483
+ return e === void 0 && (e = 0.1), $(St(this.rgba, e));
484
484
  }, t.prototype.desaturate = function(e) {
485
- return e === void 0 && (e = 0.1), $(Ct(this.rgba, -e));
485
+ return e === void 0 && (e = 0.1), $(St(this.rgba, -e));
486
486
  }, t.prototype.grayscale = function() {
487
- return $(Ct(this.rgba, -1));
487
+ return $(St(this.rgba, -1));
488
488
  }, t.prototype.lighten = function(e) {
489
- return e === void 0 && (e = 0.1), $(Qt(this.rgba, e));
489
+ return e === void 0 && (e = 0.1), $(Gt(this.rgba, e));
490
490
  }, t.prototype.darken = function(e) {
491
- return e === void 0 && (e = 0.1), $(Qt(this.rgba, -e));
491
+ return e === void 0 && (e = 0.1), $(Gt(this.rgba, -e));
492
492
  }, t.prototype.rotate = function(e) {
493
493
  return e === void 0 && (e = 15), this.hue(this.hue() + e);
494
494
  }, t.prototype.alpha = function(e) {
@@ -501,7 +501,7 @@ var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
501
501
  return this.toHex() === $(e).toHex();
502
502
  }, t;
503
503
  }(), $ = function(t) {
504
- return t instanceof Jt ? t : new Jt(t);
504
+ return t instanceof Qt ? t : new Qt(t);
505
505
  };
506
506
  const dn = (t) => [
507
507
  `background-color:${$((t == null ? void 0 : t.fill) || W.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? W.fillOpacity : t.fillOpacity).toHex()}`,
@@ -524,21 +524,21 @@ const dn = (t) => [
524
524
  d && d.clear();
525
525
  const c = new Set(s.map((l) => l.annotation.id));
526
526
  Array.from(e).filter((l) => !c.has(l));
527
- const h = s.map((l) => {
528
- var v;
529
- const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (v = l.state) != null && v.selected ? vt : W, p = d && d.paint(l, r) || g;
527
+ const f = s.map((l) => {
528
+ var w;
529
+ const m = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (w = l.state) != null && w.selected ? vt : W, p = d && d.paint(l, r) || m;
530
530
  return `::highlight(_${l.annotation.id}) { ${dn(p)} }`;
531
531
  });
532
- t.innerHTML = h.join(`
532
+ t.innerHTML = f.join(`
533
533
  `), CSS.highlights.clear(), s.forEach(({ annotation: l }) => {
534
- const g = l.target.selector.map((v) => v.range), p = new Highlight(...g);
534
+ const m = l.target.selector.map((w) => w.range), p = new Highlight(...m);
535
535
  CSS.highlights.set(`_${l.id}`, p);
536
536
  }), e = c;
537
537
  }
538
538
  };
539
- }, fn = (t, e, n) => Pt(t, e, n, un());
540
- var Zt = Object.prototype.hasOwnProperty;
541
- function Vt(t, e) {
539
+ }, fn = (t, e, n) => Xt(t, e, n, un());
540
+ var Jt = Object.prototype.hasOwnProperty;
541
+ function Dt(t, e) {
542
542
  var n, o;
543
543
  if (t === e) return !0;
544
544
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -546,13 +546,13 @@ function Vt(t, e) {
546
546
  if (n === RegExp) return t.toString() === e.toString();
547
547
  if (n === Array) {
548
548
  if ((o = t.length) === e.length)
549
- for (; o-- && Vt(t[o], e[o]); ) ;
549
+ for (; o-- && Dt(t[o], e[o]); ) ;
550
550
  return o === -1;
551
551
  }
552
552
  if (!n || typeof t == "object") {
553
553
  o = 0;
554
554
  for (n in t)
555
- if (Zt.call(t, n) && ++o && !Zt.call(e, n) || !(n in e) || !Vt(t[n], e[n])) return !1;
555
+ if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !Dt(t[n], e[n])) return !1;
556
556
  return Object.keys(e).length === o;
557
557
  }
558
558
  }
@@ -570,18 +570,18 @@ const hn = (t, e) => {
570
570
  destroy: () => {
571
571
  e.remove();
572
572
  },
573
- redraw: (r, a, d, c, h) => {
574
- const g = !(Vt(n, r) && h);
575
- if (!c && !g) return;
576
- g && (e.innerHTML = ""), [...r].sort((v, w) => {
577
- const { annotation: { target: { created: E } } } = v, { annotation: { target: { created: m } } } = w;
578
- return E && m ? E.getTime() - m.getTime() : 0;
579
- }).forEach((v) => {
580
- v.rects.map((w) => {
581
- const E = hn(w, r), m = Fe(v, a, d, c, E);
582
- if (g) {
573
+ redraw: (r, a, d, c, f) => {
574
+ const m = !(Dt(n, r) && f);
575
+ if (!c && !m) return;
576
+ m && (e.innerHTML = ""), [...r].sort((w, b) => {
577
+ const { annotation: { target: { created: S } } } = w, { annotation: { target: { created: g } } } = b;
578
+ return S && g ? S.getTime() - g.getTime() : 0;
579
+ }).forEach((w) => {
580
+ w.rects.map((b) => {
581
+ const S = hn(b, r), g = Fe(w, a, d, c, S);
582
+ if (m) {
583
583
  const u = document.createElement("span");
584
- u.className = "r6o-annotation", u.dataset.annotation = v.annotation.id, u.style.left = `${w.x}px`, u.style.top = `${w.y}px`, u.style.width = `${w.width}px`, u.style.height = `${w.height}px`, u.style.backgroundColor = $((m == null ? void 0 : m.fill) || W.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? W.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (u.style.borderStyle = m.underlineStyle), m.underlineColor && (u.style.borderColor = m.underlineColor), m.underlineThickness && (u.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (u.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(u);
584
+ u.className = "r6o-annotation", u.dataset.annotation = w.annotation.id, u.style.left = `${b.x}px`, u.style.top = `${b.y}px`, u.style.width = `${b.width}px`, u.style.height = `${b.height}px`, u.style.backgroundColor = $((g == null ? void 0 : g.fill) || W.fill).alpha((g == null ? void 0 : g.fillOpacity) === void 0 ? W.fillOpacity : g.fillOpacity).toHex(), g.underlineStyle && (u.style.borderStyle = g.underlineStyle), g.underlineColor && (u.style.borderColor = g.underlineColor), g.underlineThickness && (u.style.borderBottomWidth = `${g.underlineThickness}px`), g.underlineOffset && (u.style.paddingBottom = `${g.underlineOffset}px`), e.appendChild(u);
585
585
  }
586
586
  });
587
587
  }), n = r;
@@ -590,10 +590,10 @@ const hn = (t, e) => {
590
590
  r ? e.classList.remove("hidden") : e.classList.add("hidden");
591
591
  }
592
592
  };
593
- }, gn = (t, e, n) => Pt(t, e, n, pn(t));
593
+ }, gn = (t, e, n) => Xt(t, e, n, pn(t));
594
594
  var U = [];
595
- for (var Ot = 0; Ot < 256; ++Ot)
596
- U.push((Ot + 256).toString(16).slice(1));
595
+ for (var Lt = 0; Lt < 256; ++Lt)
596
+ U.push((Lt + 256).toString(16).slice(1));
597
597
  function mn(t, e = 0) {
598
598
  return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
599
599
  }
@@ -604,17 +604,17 @@ function bn() {
604
604
  return ht(yn);
605
605
  }
606
606
  var wn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
607
- const te = {
607
+ const Zt = {
608
608
  randomUUID: wn
609
609
  };
610
- function ye(t, e, n) {
611
- if (te.randomUUID && !e && !t)
612
- return te.randomUUID();
610
+ function me(t, e, n) {
611
+ if (Zt.randomUUID && !e && !t)
612
+ return Zt.randomUUID();
613
613
  t = t || {};
614
614
  var o = t.random || (t.rng || bn)();
615
615
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, mn(o);
616
616
  }
617
- var ee = Object.prototype.hasOwnProperty;
617
+ var te = Object.prototype.hasOwnProperty;
618
618
  function q(t, e) {
619
619
  var n, o;
620
620
  if (t === e) return !0;
@@ -629,19 +629,19 @@ function q(t, e) {
629
629
  if (!n || typeof t == "object") {
630
630
  o = 0;
631
631
  for (n in t)
632
- if (ee.call(t, n) && ++o && !ee.call(e, n) || !(n in e) || !q(t[n], e[n])) return !1;
632
+ if (te.call(t, n) && ++o && !te.call(e, n) || !(n in e) || !q(t[n], e[n])) return !1;
633
633
  return Object.keys(e).length === o;
634
634
  }
635
635
  }
636
636
  return t !== t && e !== e;
637
637
  }
638
- function Tt() {
638
+ function Ot() {
639
639
  }
640
640
  function vn(t, e) {
641
641
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
642
642
  }
643
643
  const G = [];
644
- function $t(t, e = Tt) {
644
+ function Pt(t, e = Ot) {
645
645
  let n;
646
646
  const o = /* @__PURE__ */ new Set();
647
647
  function i(a) {
@@ -659,16 +659,16 @@ function $t(t, e = Tt) {
659
659
  function s(a) {
660
660
  i(a(t));
661
661
  }
662
- function r(a, d = Tt) {
662
+ function r(a, d = Ot) {
663
663
  const c = [a, d];
664
- return o.add(c), o.size === 1 && (n = e(i, s) || Tt), a(t), () => {
664
+ return o.add(c), o.size === 1 && (n = e(i, s) || Ot), a(t), () => {
665
665
  o.delete(c), o.size === 0 && n && (n(), n = null);
666
666
  };
667
667
  }
668
668
  return { set: i, update: s, subscribe: r };
669
669
  }
670
670
  const An = (t) => {
671
- const { subscribe: e, set: n } = $t();
671
+ const { subscribe: e, set: n } = Pt();
672
672
  let o;
673
673
  return e((i) => o = i), t.observe(({ changes: i }) => {
674
674
  if (o) {
@@ -686,51 +686,51 @@ const An = (t) => {
686
686
  };
687
687
  var xn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(xn || {});
688
688
  const pt = { selected: [] }, En = (t, e, n) => {
689
- const { subscribe: o, set: i } = $t(pt);
689
+ const { subscribe: o, set: i } = Pt(pt);
690
690
  let s = e, r = pt;
691
- o((v) => r = v);
691
+ o((w) => r = w);
692
692
  const a = () => {
693
693
  q(r, pt) || i(pt);
694
694
  }, d = () => {
695
- var v;
696
- return ((v = r.selected) == null ? void 0 : v.length) === 0;
697
- }, c = (v) => {
695
+ var w;
696
+ return ((w = r.selected) == null ? void 0 : w.length) === 0;
697
+ }, c = (w) => {
698
698
  if (d())
699
699
  return !1;
700
- const w = typeof v == "string" ? v : v.id;
701
- return r.selected.some((E) => E.id === w);
702
- }, h = (v, w) => {
703
- const E = t.getAnnotation(v);
704
- if (!E) {
705
- console.warn("Invalid selection: " + v);
700
+ const b = typeof w == "string" ? w : w.id;
701
+ return r.selected.some((S) => S.id === b);
702
+ }, f = (w, b) => {
703
+ const S = t.getAnnotation(w);
704
+ if (!S) {
705
+ console.warn("Invalid selection: " + w);
706
706
  return;
707
707
  }
708
- switch (ne(E, s)) {
708
+ switch (ee(S, s)) {
709
709
  case "EDIT":
710
- i({ selected: [{ id: v, editable: !0 }], event: w });
710
+ i({ selected: [{ id: w, editable: !0 }], event: b });
711
711
  break;
712
712
  case "SELECT":
713
- i({ selected: [{ id: v }], event: w });
713
+ i({ selected: [{ id: w }], event: b });
714
714
  break;
715
715
  default:
716
- i({ selected: [], event: w });
716
+ i({ selected: [], event: b });
717
717
  }
718
- }, l = (v, w) => {
719
- const E = Array.isArray(v) ? v : [v], m = E.map((u) => t.getAnnotation(u)).filter((u) => !!u);
718
+ }, l = (w, b) => {
719
+ const S = Array.isArray(w) ? w : [w], g = S.map((u) => t.getAnnotation(u)).filter((u) => !!u);
720
720
  i({
721
- selected: m.map((u) => {
722
- const b = w === void 0 ? ne(u, s) === "EDIT" : w;
723
- return { id: u.id, editable: b };
721
+ selected: g.map((u) => {
722
+ const y = b === void 0 ? ee(u, s) === "EDIT" : b;
723
+ return { id: u.id, editable: y };
724
724
  })
725
- }), m.length !== E.length && console.warn("Invalid selection", v);
726
- }, g = (v) => {
725
+ }), g.length !== S.length && console.warn("Invalid selection", w);
726
+ }, m = (w) => {
727
727
  if (d())
728
728
  return !1;
729
- const { selected: w } = r;
730
- w.some(({ id: E }) => v.includes(E)) && i({ selected: w.filter(({ id: E }) => !v.includes(E)) });
731
- }, p = (v) => s = v;
729
+ const { selected: b } = r;
730
+ b.some(({ id: S }) => w.includes(S)) && i({ selected: b.filter(({ id: S }) => !w.includes(S)) });
731
+ }, p = (w) => s = w;
732
732
  return t.observe(
733
- ({ changes: v }) => g((v.deleted || []).map((w) => w.id))
733
+ ({ changes: w }) => m((w.deleted || []).map((b) => b.id))
734
734
  ), {
735
735
  get event() {
736
736
  return r ? r.event : null;
@@ -747,12 +747,12 @@ const pt = { selected: [] }, En = (t, e, n) => {
747
747
  setSelected: l,
748
748
  setUserSelectAction: p,
749
749
  subscribe: o,
750
- userSelect: h
750
+ userSelect: f
751
751
  };
752
- }, ne = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
752
+ }, ee = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
753
753
  var D = [];
754
- for (var Rt = 0; Rt < 256; ++Rt)
755
- D.push((Rt + 256).toString(16).slice(1));
754
+ for (var Tt = 0; Tt < 256; ++Tt)
755
+ D.push((Tt + 256).toString(16).slice(1));
756
756
  function Sn(t, e = 0) {
757
757
  return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + "-" + D[t[e + 4]] + D[t[e + 5]] + "-" + D[t[e + 6]] + D[t[e + 7]] + "-" + D[t[e + 8]] + D[t[e + 9]] + "-" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();
758
758
  }
@@ -763,17 +763,17 @@ function Ln() {
763
763
  return gt(Cn);
764
764
  }
765
765
  var On = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
766
- const oe = {
766
+ const ne = {
767
767
  randomUUID: On
768
768
  };
769
- function be(t, e, n) {
770
- if (oe.randomUUID && !e && !t)
771
- return oe.randomUUID();
769
+ function ye(t, e, n) {
770
+ if (ne.randomUUID && !e && !t)
771
+ return ne.randomUUID();
772
772
  t = t || {};
773
773
  var o = t.random || (t.rng || Ln)();
774
774
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Sn(o);
775
775
  }
776
- const Mt = (t) => {
776
+ const Rt = (t) => {
777
777
  const e = (n) => {
778
778
  const o = { ...n };
779
779
  return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
@@ -784,7 +784,7 @@ const Mt = (t) => {
784
784
  target: e(t.target)
785
785
  };
786
786
  }, ko = (t, e, n, o) => ({
787
- id: be(),
787
+ id: ye(),
788
788
  annotation: typeof t == "string" ? t : t.id,
789
789
  created: n || /* @__PURE__ */ new Date(),
790
790
  creator: o,
@@ -798,7 +798,7 @@ const Mt = (t) => {
798
798
  }, Mn = (t, e) => e.bodies.map((n) => {
799
799
  const o = t.bodies.find((i) => i.id === n.id);
800
800
  return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
801
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !q(t.target, e.target), we = (t, e) => {
801
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !q(t.target, e.target), be = (t, e) => {
802
802
  const n = Tn(t, e), o = Rn(t, e), i = Mn(t, e);
803
803
  return {
804
804
  oldValue: t,
@@ -818,7 +818,7 @@ const kn = (t, e) => {
818
818
  if (t.options.ignore) {
819
819
  const { ignore: r } = t.options, a = (d) => d && d.length > 0;
820
820
  if (!(a(i.created) || a(i.deleted))) {
821
- const d = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
821
+ const d = (n = i.updated) == null ? void 0 : n.some((f) => a(f.bodiesCreated) || a(f.bodiesDeleted) || a(f.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((f) => f.targetUpdated);
822
822
  if (r === "BODY_ONLY" && d && !c || r === "TARGET_ONLY" && c && !d)
823
823
  return !1;
824
824
  }
@@ -834,25 +834,25 @@ const kn = (t, e) => {
834
834
  return !0;
835
835
  }, In = (t, e) => {
836
836
  const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), s = new Set((e.deleted || []).map((l) => l.id)), r = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), d = [
837
- ...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
837
+ ...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue: m }) => m.id === l.id).newValue : l),
838
838
  ...e.created || []
839
839
  ], c = [
840
840
  ...(t.deleted || []).filter((l) => !i.has(l.id)),
841
841
  ...(e.deleted || []).filter((l) => !n.has(l.id))
842
- ], h = [
842
+ ], f = [
843
843
  ...(t.updated || []).filter(({ newValue: l }) => !s.has(l.id)).map((l) => {
844
- const { oldValue: g, newValue: p } = l;
844
+ const { oldValue: m, newValue: p } = l;
845
845
  if (r.has(p.id)) {
846
- const v = e.updated.find((w) => w.oldValue.id === p.id).newValue;
847
- return we(g, v);
846
+ const w = e.updated.find((b) => b.oldValue.id === p.id).newValue;
847
+ return be(m, w);
848
848
  } else
849
849
  return l;
850
850
  }),
851
851
  ...(e.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
852
852
  ];
853
- return { created: d, deleted: c, updated: h };
854
- }, Bt = (t) => {
855
- const e = t.id === void 0 ? be() : t.id;
853
+ return { created: d, deleted: c, updated: f };
854
+ }, Mt = (t) => {
855
+ const e = t.id === void 0 ? ye() : t.id;
856
856
  return {
857
857
  ...t,
858
858
  id: e,
@@ -866,201 +866,201 @@ const kn = (t, e) => {
866
866
  }
867
867
  };
868
868
  }, Nn = (t) => t.id !== void 0, _n = () => {
869
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (f, y = {}) => {
870
- n.push({ onChange: f, options: y });
871
- }, i = (f) => {
872
- const y = n.findIndex((x) => x.onChange == f);
873
- y > -1 && n.splice(y, 1);
874
- }, s = (f, y) => {
875
- const x = {
876
- origin: f,
869
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (h, v = {}) => {
870
+ n.push({ onChange: h, options: v });
871
+ }, i = (h) => {
872
+ const v = n.findIndex((A) => A.onChange == h);
873
+ v > -1 && n.splice(v, 1);
874
+ }, s = (h, v) => {
875
+ const A = {
876
+ origin: h,
877
877
  changes: {
878
- created: y.created || [],
879
- updated: y.updated || [],
880
- deleted: y.deleted || []
878
+ created: v.created || [],
879
+ updated: v.updated || [],
880
+ deleted: v.deleted || []
881
881
  },
882
882
  state: [...t.values()]
883
883
  };
884
- n.forEach((C) => {
885
- kn(C, x) && C.onChange(x);
884
+ n.forEach((L) => {
885
+ kn(L, A) && L.onChange(A);
886
886
  });
887
- }, r = (f, y = k.LOCAL) => {
888
- if (f.id && t.get(f.id))
889
- throw Error(`Cannot add annotation ${f.id} - exists already`);
887
+ }, r = (h, v = k.LOCAL) => {
888
+ if (h.id && t.get(h.id))
889
+ throw Error(`Cannot add annotation ${h.id} - exists already`);
890
890
  {
891
- const x = Bt(f);
892
- t.set(x.id, x), x.bodies.forEach((C) => e.set(C.id, x.id)), s(y, { created: [x] });
891
+ const A = Mt(h);
892
+ t.set(A.id, A), A.bodies.forEach((L) => e.set(L.id, A.id)), s(v, { created: [A] });
893
893
  }
894
- }, a = (f, y) => {
895
- const x = Bt(typeof f == "string" ? y : f), C = typeof f == "string" ? f : f.id, B = C && t.get(C);
896
- if (B) {
897
- const R = we(B, x);
898
- return C === x.id ? t.set(C, x) : (t.delete(C), t.set(x.id, x)), B.bodies.forEach((K) => e.delete(K.id)), x.bodies.forEach((K) => e.set(K.id, x.id)), R;
894
+ }, a = (h, v) => {
895
+ const A = Mt(typeof h == "string" ? v : h), L = typeof h == "string" ? h : h.id, M = L && t.get(L);
896
+ if (M) {
897
+ const B = be(M, A);
898
+ return L === A.id ? t.set(L, A) : (t.delete(L), t.set(A.id, A)), M.bodies.forEach((K) => e.delete(K.id)), A.bodies.forEach((K) => e.set(K.id, A.id)), B;
899
899
  } else
900
- console.warn(`Cannot update annotation ${C} - does not exist`);
901
- }, d = (f, y = k.LOCAL, x = k.LOCAL) => {
902
- const C = Nn(y) ? x : y, B = a(f, y);
903
- B && s(C, { updated: [B] });
904
- }, c = (f, y = k.LOCAL) => {
905
- const x = f.reduce((C, B) => {
906
- const R = a(B);
907
- return R ? [...C, R] : C;
900
+ console.warn(`Cannot update annotation ${L} - does not exist`);
901
+ }, d = (h, v = k.LOCAL, A = k.LOCAL) => {
902
+ const L = Nn(v) ? A : v, M = a(h, v);
903
+ M && s(L, { updated: [M] });
904
+ }, c = (h, v = k.LOCAL) => {
905
+ const A = h.reduce((L, M) => {
906
+ const B = a(M);
907
+ return B ? [...L, B] : L;
908
908
  }, []);
909
- x.length > 0 && s(y, { updated: x });
910
- }, h = (f, y = k.LOCAL) => {
911
- const x = t.get(f.annotation);
912
- if (x) {
913
- const C = {
914
- ...x,
915
- bodies: [...x.bodies, f]
909
+ A.length > 0 && s(v, { updated: A });
910
+ }, f = (h, v = k.LOCAL) => {
911
+ const A = t.get(h.annotation);
912
+ if (A) {
913
+ const L = {
914
+ ...A,
915
+ bodies: [...A.bodies, h]
916
916
  };
917
- t.set(x.id, C), e.set(f.id, C.id), s(y, { updated: [{
918
- oldValue: x,
919
- newValue: C,
920
- bodiesCreated: [f]
917
+ t.set(A.id, L), e.set(h.id, L.id), s(v, { updated: [{
918
+ oldValue: A,
919
+ newValue: L,
920
+ bodiesCreated: [h]
921
921
  }] });
922
922
  } else
923
- console.warn(`Attempt to add body to missing annotation: ${f.annotation}`);
924
- }, l = () => [...t.values()], g = (f = k.LOCAL) => {
925
- const y = [...t.values()];
926
- t.clear(), e.clear(), s(f, { deleted: y });
927
- }, p = (f, y = !0, x = k.LOCAL) => {
928
- const C = f.map(Bt);
929
- if (y) {
930
- const B = [...t.values()];
931
- t.clear(), e.clear(), C.forEach((R) => {
932
- t.set(R.id, R), R.bodies.forEach((K) => e.set(K.id, R.id));
933
- }), s(x, { created: C, deleted: B });
923
+ console.warn(`Attempt to add body to missing annotation: ${h.annotation}`);
924
+ }, l = () => [...t.values()], m = (h = k.LOCAL) => {
925
+ const v = [...t.values()];
926
+ t.clear(), e.clear(), s(h, { deleted: v });
927
+ }, p = (h, v = !0, A = k.LOCAL) => {
928
+ const L = h.map(Mt);
929
+ if (v) {
930
+ const M = [...t.values()];
931
+ t.clear(), e.clear(), L.forEach((B) => {
932
+ t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
933
+ }), s(A, { created: L, deleted: M });
934
934
  } else {
935
- const B = f.reduce((R, K) => {
935
+ const M = h.reduce((B, K) => {
936
936
  const Y = K.id && t.get(K.id);
937
- return Y ? [...R, Y] : R;
937
+ return Y ? [...B, Y] : B;
938
938
  }, []);
939
- if (B.length > 0)
940
- throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
941
- C.forEach((R) => {
942
- t.set(R.id, R), R.bodies.forEach((K) => e.set(K.id, R.id));
943
- }), s(x, { created: C });
939
+ if (M.length > 0)
940
+ throw Error(`Bulk insert would overwrite the following annotations: ${M.map((B) => B.id).join(", ")}`);
941
+ L.forEach((B) => {
942
+ t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
943
+ }), s(A, { created: L });
944
944
  }
945
- }, v = (f) => {
946
- const y = typeof f == "string" ? f : f.id, x = t.get(y);
947
- if (x)
948
- return t.delete(y), x.bodies.forEach((C) => e.delete(C.id)), x;
949
- console.warn(`Attempt to delete missing annotation: ${y}`);
950
- }, w = (f, y = k.LOCAL) => {
951
- const x = v(f);
952
- x && s(y, { deleted: [x] });
953
- }, E = (f, y = k.LOCAL) => {
954
- const x = f.reduce((C, B) => {
955
- const R = v(B);
956
- return R ? [...C, R] : C;
945
+ }, w = (h) => {
946
+ const v = typeof h == "string" ? h : h.id, A = t.get(v);
947
+ if (A)
948
+ return t.delete(v), A.bodies.forEach((L) => e.delete(L.id)), A;
949
+ console.warn(`Attempt to delete missing annotation: ${v}`);
950
+ }, b = (h, v = k.LOCAL) => {
951
+ const A = w(h);
952
+ A && s(v, { deleted: [A] });
953
+ }, S = (h, v = k.LOCAL) => {
954
+ const A = h.reduce((L, M) => {
955
+ const B = w(M);
956
+ return B ? [...L, B] : L;
957
957
  }, []);
958
- x.length > 0 && s(y, { deleted: x });
959
- }, m = (f) => {
960
- const y = t.get(f.annotation);
961
- if (y) {
962
- const x = y.bodies.find((C) => C.id === f.id);
963
- if (x) {
964
- e.delete(x.id);
965
- const C = {
966
- ...y,
967
- bodies: y.bodies.filter((B) => B.id !== f.id)
958
+ A.length > 0 && s(v, { deleted: A });
959
+ }, g = (h) => {
960
+ const v = t.get(h.annotation);
961
+ if (v) {
962
+ const A = v.bodies.find((L) => L.id === h.id);
963
+ if (A) {
964
+ e.delete(A.id);
965
+ const L = {
966
+ ...v,
967
+ bodies: v.bodies.filter((M) => M.id !== h.id)
968
968
  };
969
- return t.set(y.id, C), {
970
- oldValue: y,
971
- newValue: C,
972
- bodiesDeleted: [x]
969
+ return t.set(v.id, L), {
970
+ oldValue: v,
971
+ newValue: L,
972
+ bodiesDeleted: [A]
973
973
  };
974
974
  } else
975
- console.warn(`Attempt to delete missing body ${f.id} from annotation ${f.annotation}`);
975
+ console.warn(`Attempt to delete missing body ${h.id} from annotation ${h.annotation}`);
976
976
  } else
977
- console.warn(`Attempt to delete body from missing annotation ${f.annotation}`);
978
- }, u = (f, y = k.LOCAL) => {
979
- const x = m(f);
980
- x && s(y, { updated: [x] });
981
- }, b = (f, y = k.LOCAL) => {
982
- const x = f.map((C) => m(C)).filter(Boolean);
983
- x.length > 0 && s(y, { updated: x });
984
- }, S = (f) => {
985
- const y = t.get(f);
986
- return y ? { ...y } : void 0;
987
- }, A = (f) => {
988
- const y = e.get(f);
989
- if (y) {
990
- const x = S(y).bodies.find((C) => C.id === f);
991
- if (x)
992
- return x;
993
- console.error(`Store integrity error: body ${f} in index, but not in annotation`);
977
+ console.warn(`Attempt to delete body from missing annotation ${h.annotation}`);
978
+ }, u = (h, v = k.LOCAL) => {
979
+ const A = g(h);
980
+ A && s(v, { updated: [A] });
981
+ }, y = (h, v = k.LOCAL) => {
982
+ const A = h.map((L) => g(L)).filter(Boolean);
983
+ A.length > 0 && s(v, { updated: A });
984
+ }, C = (h) => {
985
+ const v = t.get(h);
986
+ return v ? { ...v } : void 0;
987
+ }, E = (h) => {
988
+ const v = e.get(h);
989
+ if (v) {
990
+ const A = C(v).bodies.find((L) => L.id === h);
991
+ if (A)
992
+ return A;
993
+ console.error(`Store integrity error: body ${h} in index, but not in annotation`);
994
994
  } else
995
- console.warn(`Attempt to retrieve missing body: ${f}`);
996
- }, L = (f, y) => {
997
- if (f.annotation !== y.annotation)
995
+ console.warn(`Attempt to retrieve missing body: ${h}`);
996
+ }, O = (h, v) => {
997
+ if (h.annotation !== v.annotation)
998
998
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
999
- const x = t.get(f.annotation);
1000
- if (x) {
1001
- const C = x.bodies.find((R) => R.id === f.id), B = {
1002
- ...x,
1003
- bodies: x.bodies.map((R) => R.id === C.id ? y : R)
999
+ const A = t.get(h.annotation);
1000
+ if (A) {
1001
+ const L = A.bodies.find((B) => B.id === h.id), M = {
1002
+ ...A,
1003
+ bodies: A.bodies.map((B) => B.id === L.id ? v : B)
1004
1004
  };
1005
- return t.set(x.id, B), C.id !== y.id && (e.delete(C.id), e.set(y.id, B.id)), {
1006
- oldValue: x,
1007
- newValue: B,
1008
- bodiesUpdated: [{ oldBody: C, newBody: y }]
1005
+ return t.set(A.id, M), L.id !== v.id && (e.delete(L.id), e.set(v.id, M.id)), {
1006
+ oldValue: A,
1007
+ newValue: M,
1008
+ bodiesUpdated: [{ oldBody: L, newBody: v }]
1009
1009
  };
1010
1010
  } else
1011
- console.warn(`Attempt to add body to missing annotation ${f.annotation}`);
1012
- }, T = (f, y, x = k.LOCAL) => {
1013
- const C = L(f, y);
1014
- C && s(x, { updated: [C] });
1015
- }, O = (f, y = k.LOCAL) => {
1016
- const x = f.map((C) => L({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
1017
- s(y, { updated: x });
1018
- }, M = (f) => {
1019
- const y = t.get(f.annotation);
1020
- if (y) {
1021
- const x = {
1022
- ...y,
1011
+ console.warn(`Attempt to add body to missing annotation ${h.annotation}`);
1012
+ }, R = (h, v, A = k.LOCAL) => {
1013
+ const L = O(h, v);
1014
+ L && s(A, { updated: [L] });
1015
+ }, T = (h, v = k.LOCAL) => {
1016
+ const A = h.map((L) => O({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
1017
+ s(v, { updated: A });
1018
+ }, x = (h) => {
1019
+ const v = t.get(h.annotation);
1020
+ if (v) {
1021
+ const A = {
1022
+ ...v,
1023
1023
  target: {
1024
- ...y.target,
1025
- ...f
1024
+ ...v.target,
1025
+ ...h
1026
1026
  }
1027
1027
  };
1028
- return t.set(y.id, x), {
1029
- oldValue: y,
1030
- newValue: x,
1028
+ return t.set(v.id, A), {
1029
+ oldValue: v,
1030
+ newValue: A,
1031
1031
  targetUpdated: {
1032
- oldTarget: y.target,
1033
- newTarget: f
1032
+ oldTarget: v.target,
1033
+ newTarget: h
1034
1034
  }
1035
1035
  };
1036
1036
  } else
1037
- console.warn(`Attempt to update target on missing annotation: ${f.annotation}`);
1037
+ console.warn(`Attempt to update target on missing annotation: ${h.annotation}`);
1038
1038
  };
1039
1039
  return {
1040
1040
  addAnnotation: r,
1041
- addBody: h,
1041
+ addBody: f,
1042
1042
  all: l,
1043
1043
  bulkAddAnnotation: p,
1044
- bulkDeleteAnnotation: E,
1045
- bulkDeleteBodies: b,
1044
+ bulkDeleteAnnotation: S,
1045
+ bulkDeleteBodies: y,
1046
1046
  bulkUpdateAnnotation: c,
1047
- bulkUpdateBodies: O,
1048
- bulkUpdateTargets: (f, y = k.LOCAL) => {
1049
- const x = f.map((C) => M(C)).filter(Boolean);
1050
- x.length > 0 && s(y, { updated: x });
1047
+ bulkUpdateBodies: T,
1048
+ bulkUpdateTargets: (h, v = k.LOCAL) => {
1049
+ const A = h.map((L) => x(L)).filter(Boolean);
1050
+ A.length > 0 && s(v, { updated: A });
1051
1051
  },
1052
- clear: g,
1053
- deleteAnnotation: w,
1052
+ clear: m,
1053
+ deleteAnnotation: b,
1054
1054
  deleteBody: u,
1055
- getAnnotation: S,
1056
- getBody: A,
1055
+ getAnnotation: C,
1056
+ getBody: E,
1057
1057
  observe: o,
1058
1058
  unobserve: i,
1059
1059
  updateAnnotation: d,
1060
- updateBody: T,
1061
- updateTarget: (f, y = k.LOCAL) => {
1062
- const x = M(f);
1063
- x && s(y, { updated: [x] });
1060
+ updateBody: R,
1061
+ updateTarget: (h, v = k.LOCAL) => {
1062
+ const A = x(h);
1063
+ A && s(v, { updated: [A] });
1064
1064
  }
1065
1065
  };
1066
1066
  };
@@ -1083,113 +1083,113 @@ const Dn = 250, Vn = (t) => {
1083
1083
  let o = -1, i = !1, s = 0;
1084
1084
  const r = (p) => {
1085
1085
  if (!i) {
1086
- const { changes: v } = p, w = performance.now();
1087
- if (w - s > Dn)
1088
- n.splice(o + 1), n.push(v), o = n.length - 1;
1086
+ const { changes: w } = p, b = performance.now();
1087
+ if (b - s > Dn)
1088
+ n.splice(o + 1), n.push(w), o = n.length - 1;
1089
1089
  else {
1090
- const E = n.length - 1;
1091
- n[E] = In(n[E], v);
1090
+ const S = n.length - 1;
1091
+ n[S] = In(n[S], w);
1092
1092
  }
1093
- s = w;
1093
+ s = b;
1094
1094
  }
1095
1095
  i = !1;
1096
1096
  };
1097
1097
  t.observe(r, { origin: k.LOCAL });
1098
- const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), c = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: v }) => v)), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: v }) => v)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1098
+ const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), c = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: w }) => w)), f = (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);
1099
1099
  return {
1100
1100
  canRedo: () => n.length - 1 > o,
1101
1101
  canUndo: () => o > -1,
1102
1102
  destroy: () => t.unobserve(r),
1103
- on: (p, v) => e.on(p, v),
1103
+ on: (p, w) => e.on(p, w),
1104
1104
  redo: () => {
1105
1105
  if (n.length - 1 > o) {
1106
1106
  i = !0;
1107
- const { created: p, updated: v, deleted: w } = n[o + 1];
1108
- d(p), h(v), g(w), e.emit("redo", n[o + 1]), o += 1;
1107
+ const { created: p, updated: w, deleted: b } = n[o + 1];
1108
+ d(p), f(w), m(b), e.emit("redo", n[o + 1]), o += 1;
1109
1109
  }
1110
1110
  },
1111
1111
  undo: () => {
1112
1112
  if (o > -1) {
1113
1113
  i = !0;
1114
- const { created: p, updated: v, deleted: w } = n[o];
1115
- a(p), c(v), l(w), e.emit("undo", n[o]), o -= 1;
1114
+ const { created: p, updated: w, deleted: b } = n[o];
1115
+ a(p), c(w), l(b), e.emit("undo", n[o]), o -= 1;
1116
1116
  }
1117
1117
  }
1118
1118
  };
1119
1119
  }, Kn = () => {
1120
- const { subscribe: t, set: e } = $t([]);
1120
+ const { subscribe: t, set: e } = Pt([]);
1121
1121
  return {
1122
1122
  subscribe: t,
1123
1123
  set: e
1124
1124
  };
1125
1125
  }, Yn = (t, e, n, o) => {
1126
1126
  const { hover: i, selection: s, store: r, viewport: a } = t, d = /* @__PURE__ */ new Map();
1127
- let c = [], h;
1128
- const l = (w, E) => {
1129
- d.has(w) ? d.get(w).push(E) : d.set(w, [E]);
1130
- }, g = (w, E) => {
1131
- const m = d.get(w);
1132
- if (m) {
1133
- const u = m.indexOf(E);
1134
- u !== -1 && m.splice(u, 1);
1127
+ let c = [], f;
1128
+ const l = (b, S) => {
1129
+ d.has(b) ? d.get(b).push(S) : d.set(b, [S]);
1130
+ }, m = (b, S) => {
1131
+ const g = d.get(b);
1132
+ if (g) {
1133
+ const u = g.indexOf(S);
1134
+ u !== -1 && g.splice(u, 1);
1135
1135
  }
1136
- }, p = (w, E, m) => {
1137
- d.has(w) && setTimeout(() => {
1138
- d.get(w).forEach((u) => {
1136
+ }, p = (b, S, g) => {
1137
+ d.has(b) && setTimeout(() => {
1138
+ d.get(b).forEach((u) => {
1139
1139
  if (n) {
1140
- const b = Array.isArray(E) ? E.map((A) => n.serialize(A)) : n.serialize(E), S = m ? m instanceof PointerEvent ? m : n.serialize(m) : void 0;
1141
- u(b, S);
1140
+ const y = Array.isArray(S) ? S.map((E) => n.serialize(E)) : n.serialize(S), C = g ? g instanceof PointerEvent ? g : n.serialize(g) : void 0;
1141
+ u(y, C);
1142
1142
  } else
1143
- u(E, m);
1143
+ u(S, g);
1144
1144
  });
1145
1145
  }, 1);
1146
1146
  };
1147
- s.subscribe(({ selected: w }) => {
1148
- if (!(c.length === 0 && w.length === 0)) {
1149
- if (c.length === 0 && w.length > 0)
1150
- c = w.map(({ id: E }) => r.getAnnotation(E));
1151
- else if (c.length > 0 && w.length === 0)
1152
- c.forEach((E) => {
1153
- const m = r.getAnnotation(E.id);
1154
- m && !q(m, E) && p("updateAnnotation", m, E);
1147
+ s.subscribe(({ selected: b }) => {
1148
+ if (!(c.length === 0 && b.length === 0)) {
1149
+ if (c.length === 0 && b.length > 0)
1150
+ c = b.map(({ id: S }) => r.getAnnotation(S));
1151
+ else if (c.length > 0 && b.length === 0)
1152
+ c.forEach((S) => {
1153
+ const g = r.getAnnotation(S.id);
1154
+ g && !q(g, S) && p("updateAnnotation", g, S);
1155
1155
  }), c = [];
1156
1156
  else {
1157
- const E = new Set(c.map((u) => u.id)), m = new Set(w.map(({ id: u }) => u));
1158
- c.filter((u) => !m.has(u.id)).forEach((u) => {
1159
- const b = r.getAnnotation(u.id);
1160
- b && !q(b, u) && p("updateAnnotation", b, u);
1157
+ const S = new Set(c.map((u) => u.id)), g = new Set(b.map(({ id: u }) => u));
1158
+ c.filter((u) => !g.has(u.id)).forEach((u) => {
1159
+ const y = r.getAnnotation(u.id);
1160
+ y && !q(y, u) && p("updateAnnotation", y, u);
1161
1161
  }), c = [
1162
1162
  // Remove annotations that were deselected
1163
- ...c.filter((u) => m.has(u.id)),
1163
+ ...c.filter((u) => g.has(u.id)),
1164
1164
  // Add editable annotations that were selected
1165
- ...w.filter(({ id: u }) => !E.has(u)).map(({ id: u }) => r.getAnnotation(u))
1165
+ ...b.filter(({ id: u }) => !S.has(u)).map(({ id: u }) => r.getAnnotation(u))
1166
1166
  ];
1167
1167
  }
1168
1168
  p("selectionChanged", c);
1169
1169
  }
1170
- }), i.subscribe((w) => {
1171
- !h && w ? p("mouseEnterAnnotation", r.getAnnotation(w)) : h && !w ? p("mouseLeaveAnnotation", r.getAnnotation(h)) : h && w && (p("mouseLeaveAnnotation", r.getAnnotation(h)), p("mouseEnterAnnotation", r.getAnnotation(w))), h = w;
1172
- }), a == null || a.subscribe((w) => p("viewportIntersect", w.map((E) => r.getAnnotation(E)))), r.observe((w) => {
1173
- const { created: E, deleted: m } = w.changes;
1174
- (E || []).forEach((u) => p("createAnnotation", u)), (m || []).forEach((u) => p("deleteAnnotation", u)), (w.changes.updated || []).filter((u) => [
1170
+ }), i.subscribe((b) => {
1171
+ !f && b ? p("mouseEnterAnnotation", r.getAnnotation(b)) : f && !b ? p("mouseLeaveAnnotation", r.getAnnotation(f)) : f && b && (p("mouseLeaveAnnotation", r.getAnnotation(f)), p("mouseEnterAnnotation", r.getAnnotation(b))), f = b;
1172
+ }), a == null || a.subscribe((b) => p("viewportIntersect", b.map((S) => r.getAnnotation(S)))), r.observe((b) => {
1173
+ const { created: S, deleted: g } = b.changes;
1174
+ (S || []).forEach((u) => p("createAnnotation", u)), (g || []).forEach((u) => p("deleteAnnotation", u)), (b.changes.updated || []).filter((u) => [
1175
1175
  ...u.bodiesCreated || [],
1176
1176
  ...u.bodiesDeleted || [],
1177
1177
  ...u.bodiesUpdated || []
1178
- ].length > 0).forEach(({ oldValue: u, newValue: b }) => {
1179
- const S = c.find((A) => A.id === u.id) || u;
1180
- c = c.map((A) => A.id === u.id ? b : A), p("updateAnnotation", b, S);
1178
+ ].length > 0).forEach(({ oldValue: u, newValue: y }) => {
1179
+ const C = c.find((E) => E.id === u.id) || u;
1180
+ c = c.map((E) => E.id === u.id ? y : E), p("updateAnnotation", y, C);
1181
1181
  });
1182
- }, { origin: k.LOCAL }), r.observe((w) => {
1182
+ }, { origin: k.LOCAL }), r.observe((b) => {
1183
1183
  if (c) {
1184
- const E = new Set(c.map((u) => u.id)), m = (w.changes.updated || []).filter(({ newValue: u }) => E.has(u.id)).map(({ newValue: u }) => u);
1185
- m.length > 0 && (c = c.map((u) => m.find((S) => S.id === u.id) || u));
1184
+ const S = new Set(c.map((u) => u.id)), g = (b.changes.updated || []).filter(({ newValue: u }) => S.has(u.id)).map(({ newValue: u }) => u);
1185
+ g.length > 0 && (c = c.map((u) => g.find((C) => C.id === u.id) || u));
1186
1186
  }
1187
1187
  }, { origin: k.REMOTE });
1188
- const v = (w) => (E) => {
1189
- const { updated: m } = E;
1190
- w ? (m || []).forEach((u) => p("updateAnnotation", u.oldValue, u.newValue)) : (m || []).forEach((u) => p("updateAnnotation", u.newValue, u.oldValue));
1188
+ const w = (b) => (S) => {
1189
+ const { updated: g } = S;
1190
+ b ? (g || []).forEach((u) => p("updateAnnotation", u.oldValue, u.newValue)) : (g || []).forEach((u) => p("updateAnnotation", u.newValue, u.oldValue));
1191
1191
  };
1192
- return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: l, off: g, emit: p };
1192
+ return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: l, off: m, emit: p };
1193
1193
  }, Xn = (t) => (e) => e.reduce((n, o) => {
1194
1194
  const { parsed: i, error: s } = t.parse(o);
1195
1195
  return s ? {
@@ -1202,46 +1202,46 @@ const Dn = 250, Vn = (t) => {
1202
1202
  ...n
1203
1203
  };
1204
1204
  }, { parsed: [], failed: [] }), Pn = (t, e, n) => {
1205
- const { store: o, selection: i } = t, s = (m) => {
1205
+ const { store: o, selection: i } = t, s = (g) => {
1206
1206
  if (n) {
1207
- const { parsed: u, error: b } = n.parse(m);
1208
- u ? o.addAnnotation(u, k.REMOTE) : console.error(b);
1207
+ const { parsed: u, error: y } = n.parse(g);
1208
+ u ? o.addAnnotation(u, k.REMOTE) : console.error(y);
1209
1209
  } else
1210
- o.addAnnotation(Mt(m), k.REMOTE);
1211
- }, r = () => i.clear(), a = () => o.clear(), d = (m) => {
1212
- const u = o.getAnnotation(m);
1210
+ o.addAnnotation(Rt(g), k.REMOTE);
1211
+ }, r = () => i.clear(), a = () => o.clear(), d = (g) => {
1212
+ const u = o.getAnnotation(g);
1213
1213
  return n && u ? n.serialize(u) : u;
1214
- }, c = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1215
- var m;
1216
- const u = (((m = i.selected) == null ? void 0 : m.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
1214
+ }, c = () => n ? o.all().map(n.serialize) : o.all(), f = () => {
1215
+ var g;
1216
+ const u = (((g = i.selected) == null ? void 0 : g.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
1217
1217
  return n ? u.map(n.serialize) : u;
1218
- }, l = (m, u = !0) => fetch(m).then((b) => b.json()).then((b) => (p(b, u), b)), g = (m) => {
1219
- if (typeof m == "string") {
1220
- const u = o.getAnnotation(m);
1221
- if (o.deleteAnnotation(m), u)
1218
+ }, l = (g, u = !0) => fetch(g).then((y) => y.json()).then((y) => (p(y, u), y)), m = (g) => {
1219
+ if (typeof g == "string") {
1220
+ const u = o.getAnnotation(g);
1221
+ if (o.deleteAnnotation(g), u)
1222
1222
  return n ? n.serialize(u) : u;
1223
1223
  } else {
1224
- const u = n ? n.parse(m).parsed : m;
1224
+ const u = n ? n.parse(g).parsed : g;
1225
1225
  if (u)
1226
- return o.deleteAnnotation(u), m;
1226
+ return o.deleteAnnotation(u), g;
1227
1227
  }
1228
- }, p = (m, u = !0) => {
1228
+ }, p = (g, u = !0) => {
1229
1229
  if (n) {
1230
- const b = n.parseAll || Xn(n), { parsed: S, failed: A } = b(m);
1231
- A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(S, u, k.REMOTE);
1230
+ const y = n.parseAll || Xn(n), { parsed: C, failed: E } = y(g);
1231
+ E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(C, u, k.REMOTE);
1232
1232
  } else
1233
- o.bulkAddAnnotation(m.map(Mt), u, k.REMOTE);
1234
- }, v = (m, u) => {
1235
- m ? i.setSelected(m, u) : i.clear();
1236
- }, w = (m) => {
1237
- i.clear(), i.setUserSelectAction(m);
1238
- }, E = (m) => {
1233
+ o.bulkAddAnnotation(g.map(Rt), u, k.REMOTE);
1234
+ }, w = (g, u) => {
1235
+ g ? i.setSelected(g, u) : i.clear();
1236
+ }, b = (g) => {
1237
+ i.clear(), i.setUserSelectAction(g);
1238
+ }, S = (g) => {
1239
1239
  if (n) {
1240
- const u = n.parse(m).parsed, b = n.serialize(o.getAnnotation(u.id));
1241
- return o.updateAnnotation(u), b;
1240
+ const u = n.parse(g).parsed, y = n.serialize(o.getAnnotation(u.id));
1241
+ return o.updateAnnotation(u), y;
1242
1242
  } else {
1243
- const u = o.getAnnotation(m.id);
1244
- return o.updateAnnotation(Mt(m)), u;
1243
+ const u = o.getAnnotation(g.id);
1244
+ return o.updateAnnotation(Rt(g)), u;
1245
1245
  }
1246
1246
  };
1247
1247
  return {
@@ -1252,15 +1252,15 @@ const Dn = 250, Vn = (t) => {
1252
1252
  clearAnnotations: a,
1253
1253
  getAnnotationById: d,
1254
1254
  getAnnotations: c,
1255
- getSelected: h,
1255
+ getSelected: f,
1256
1256
  loadAnnotations: l,
1257
1257
  redo: e.redo,
1258
- removeAnnotation: g,
1258
+ removeAnnotation: m,
1259
1259
  setAnnotations: p,
1260
- setSelected: v,
1261
- setUserSelectAction: w,
1260
+ setSelected: w,
1261
+ setUserSelectAction: b,
1262
1262
  undo: e.undo,
1263
- updateAnnotation: E
1263
+ updateAnnotation: S
1264
1264
  };
1265
1265
  }, $n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1266
1266
  let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
@@ -1287,18 +1287,18 @@ const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABC
1287
1287
  n = (n << 5) - n + s, n |= 0;
1288
1288
  }
1289
1289
  return `${n}`;
1290
- }, ve = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Gn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1291
- const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...h } = n;
1290
+ }, we = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Gn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1291
+ const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...f } = n;
1292
1292
  return {
1293
1293
  id: o || `temp-${qn(n)}`,
1294
1294
  annotation: e,
1295
1295
  type: i,
1296
1296
  purpose: s,
1297
1297
  value: r,
1298
- creator: ve(c),
1298
+ creator: we(c),
1299
1299
  created: a ? new Date(a) : void 0,
1300
1300
  updated: d ? new Date(d) : void 0,
1301
- ...h
1301
+ ...f
1302
1302
  };
1303
1303
  }), Qn = (t) => t.map((e) => {
1304
1304
  var n;
@@ -1324,7 +1324,7 @@ const Io = (t, e) => ({
1324
1324
  if (r.length === 0)
1325
1325
  return { error: Error(`No targets found for annotation: ${t.id}`) };
1326
1326
  const a = {
1327
- creator: ve(n),
1327
+ creator: we(n),
1328
1328
  created: o ? new Date(o) : void 0,
1329
1329
  updated: i ? new Date(i) : void 0,
1330
1330
  annotation: e,
@@ -1332,30 +1332,30 @@ const Io = (t, e) => ({
1332
1332
  styleClass: r[0].styleClass
1333
1333
  };
1334
1334
  for (const d of r) {
1335
- const h = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, g) => {
1336
- switch (g.type) {
1335
+ const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, m) => {
1336
+ switch (m.type) {
1337
1337
  case "TextQuoteSelector":
1338
- l.quote = g.exact;
1338
+ l.quote = m.exact;
1339
1339
  break;
1340
1340
  case "TextPositionSelector":
1341
- l.start = g.start, l.end = g.end;
1341
+ l.start = m.start, l.end = m.end;
1342
1342
  break;
1343
1343
  }
1344
1344
  return l;
1345
1345
  }, {});
1346
- if (Jn(h))
1347
- a.selector.push({ id: d.id, ...h });
1346
+ if (Jn(f))
1347
+ a.selector.push({ id: d.id, ...f });
1348
1348
  else {
1349
1349
  const l = [
1350
- h.start ? void 0 : "TextPositionSelector",
1351
- h.quote ? void 0 : "TextQuoteSelector"
1350
+ f.start ? void 0 : "TextPositionSelector",
1351
+ f.quote ? void 0 : "TextQuoteSelector"
1352
1352
  ].filter(Boolean);
1353
1353
  return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
1354
1354
  }
1355
1355
  }
1356
1356
  return { parsed: a };
1357
1357
  }, to = (t) => {
1358
- const e = t.id || ye(), {
1358
+ const e = t.id || me(), {
1359
1359
  creator: n,
1360
1360
  created: o,
1361
1361
  modified: i,
@@ -1376,23 +1376,23 @@ const Io = (t, e) => ({
1376
1376
  creator: a,
1377
1377
  created: d,
1378
1378
  updated: c,
1379
- ...h
1380
- } = i, l = r.map((g) => {
1381
- const { quote: p, start: v, end: w, range: E } = g, { prefix: m, suffix: u } = Ue(E, n), b = [{
1379
+ ...f
1380
+ } = i, l = r.map((m) => {
1381
+ const { quote: p, start: w, end: b, range: S } = m, { prefix: g, suffix: u } = Ue(S, n), y = [{
1382
1382
  type: "TextQuoteSelector",
1383
1383
  exact: p,
1384
- prefix: m,
1384
+ prefix: g,
1385
1385
  suffix: u
1386
1386
  }, {
1387
1387
  type: "TextPositionSelector",
1388
- start: v,
1389
- end: w
1388
+ start: w,
1389
+ end: b
1390
1390
  }];
1391
1391
  return {
1392
- ...h,
1393
- id: g.id,
1392
+ ...f,
1393
+ id: m.id,
1394
1394
  source: e,
1395
- selector: b
1395
+ selector: y
1396
1396
  };
1397
1397
  });
1398
1398
  return {
@@ -1407,11 +1407,11 @@ const Io = (t, e) => ({
1407
1407
  target: l
1408
1408
  };
1409
1409
  };
1410
- function Ae(t, e, n = 0, o = t.length - 1, i = no) {
1410
+ function ve(t, e, n = 0, o = t.length - 1, i = no) {
1411
1411
  for (; o > n; ) {
1412
1412
  if (o - n > 600) {
1413
- const d = o - n + 1, c = e - n + 1, h = Math.log(d), l = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - c * l / d + g)), v = Math.min(o, Math.floor(e + (d - c) * l / d + g));
1414
- Ae(t, e, p, v, i);
1413
+ const d = o - n + 1, c = e - n + 1, f = Math.log(d), l = 0.5 * Math.exp(2 * f / 3), m = 0.5 * Math.sqrt(f * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - c * l / d + m)), w = Math.min(o, Math.floor(e + (d - c) * l / d + m));
1414
+ ve(t, e, p, w, i);
1415
1415
  }
1416
1416
  const s = t[e];
1417
1417
  let r = n, a = o;
@@ -1444,7 +1444,7 @@ class oo {
1444
1444
  for (; n; ) {
1445
1445
  for (let r = 0; r < n.children.length; r++) {
1446
1446
  const a = n.children[r], d = n.leaf ? i(a) : a;
1447
- yt(e, d) && (n.leaf ? o.push(a) : It(e, d) ? this._all(a, o) : s.push(a));
1447
+ yt(e, d) && (n.leaf ? o.push(a) : kt(e, d) ? this._all(a, o) : s.push(a));
1448
1448
  }
1449
1449
  n = s.pop();
1450
1450
  }
@@ -1458,7 +1458,7 @@ class oo {
1458
1458
  for (let i = 0; i < n.children.length; i++) {
1459
1459
  const s = n.children[i], r = n.leaf ? this.toBBox(s) : s;
1460
1460
  if (yt(e, r)) {
1461
- if (n.leaf || It(e, r)) return !0;
1461
+ if (n.leaf || kt(e, r)) return !0;
1462
1462
  o.push(s);
1463
1463
  }
1464
1464
  }
@@ -1500,11 +1500,11 @@ class oo {
1500
1500
  let a, d, c;
1501
1501
  for (; o || s.length; ) {
1502
1502
  if (o || (o = s.pop(), d = s[s.length - 1], a = r.pop(), c = !0), o.leaf) {
1503
- const h = io(e, o.children, n);
1504
- if (h !== -1)
1505
- return o.children.splice(h, 1), s.push(o), this._condense(s), this;
1503
+ const f = io(e, o.children, n);
1504
+ if (f !== -1)
1505
+ return o.children.splice(f, 1), s.push(o), this._condense(s), this;
1506
1506
  }
1507
- !c && !o.leaf && It(o, i) ? (s.push(o), r.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], c = !1) : o = null;
1507
+ !c && !o.leaf && kt(o, i) ? (s.push(o), r.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], c = !1) : o = null;
1508
1508
  }
1509
1509
  return this;
1510
1510
  }
@@ -1536,13 +1536,13 @@ class oo {
1536
1536
  return a = J(e.slice(n, o + 1)), Q(a, this.toBBox), a;
1537
1537
  i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = J([]), a.leaf = !1, a.height = i;
1538
1538
  const d = Math.ceil(s / r), c = d * Math.ceil(Math.sqrt(r));
1539
- ie(e, n, o, c, this.compareMinX);
1540
- for (let h = n; h <= o; h += c) {
1541
- const l = Math.min(h + c - 1, o);
1542
- ie(e, h, l, d, this.compareMinY);
1543
- for (let g = h; g <= l; g += d) {
1544
- const p = Math.min(g + d - 1, l);
1545
- a.children.push(this._build(e, g, p, i - 1));
1539
+ oe(e, n, o, c, this.compareMinX);
1540
+ for (let f = n; f <= o; f += c) {
1541
+ const l = Math.min(f + c - 1, o);
1542
+ oe(e, f, l, d, this.compareMinY);
1543
+ for (let m = f; m <= l; m += d) {
1544
+ const p = Math.min(m + d - 1, l);
1545
+ a.children.push(this._build(e, m, p, i - 1));
1546
1546
  }
1547
1547
  }
1548
1548
  return Q(a, this.toBBox), a;
@@ -1551,8 +1551,8 @@ class oo {
1551
1551
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1552
1552
  let s = 1 / 0, r = 1 / 0, a;
1553
1553
  for (let d = 0; d < n.children.length; d++) {
1554
- const c = n.children[d], h = kt(c), l = ao(e, c) - h;
1555
- l < r ? (r = l, s = h < s ? h : s, a = c) : l === r && h < s && (s = h, a = c);
1554
+ const c = n.children[d], f = Bt(c), l = ao(e, c) - f;
1555
+ l < r ? (r = l, s = f < s ? f : s, a = c) : l === r && f < s && (s = f, a = c);
1556
1556
  }
1557
1557
  n = a || n.children[0];
1558
1558
  }
@@ -1577,8 +1577,8 @@ class oo {
1577
1577
  _chooseSplitIndex(e, n, o) {
1578
1578
  let i, s = 1 / 0, r = 1 / 0;
1579
1579
  for (let a = n; a <= o - n; a++) {
1580
- const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), h = co(d, c), l = kt(d) + kt(c);
1581
- h < s ? (s = h, i = a, r = l < r ? l : r) : h === s && l < r && (r = l, i = a);
1580
+ const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), f = co(d, c), l = Bt(d) + Bt(c);
1581
+ f < s ? (s = f, i = a, r = l < r ? l : r) : f === s && l < r && (r = l, i = a);
1582
1582
  }
1583
1583
  return i || o - n;
1584
1584
  }
@@ -1593,12 +1593,12 @@ class oo {
1593
1593
  const s = this.toBBox, r = ot(e, 0, n, s), a = ot(e, o - n, o, s);
1594
1594
  let d = mt(r) + mt(a);
1595
1595
  for (let c = n; c < o - n; c++) {
1596
- const h = e.children[c];
1597
- it(r, e.leaf ? s(h) : h), d += mt(r);
1596
+ const f = e.children[c];
1597
+ it(r, e.leaf ? s(f) : f), d += mt(r);
1598
1598
  }
1599
1599
  for (let c = o - n - 1; c >= n; c--) {
1600
- const h = e.children[c];
1601
- it(a, e.leaf ? s(h) : h), d += mt(a);
1600
+ const f = e.children[c];
1601
+ it(a, e.leaf ? s(f) : f), d += mt(a);
1602
1602
  }
1603
1603
  return d;
1604
1604
  }
@@ -1637,7 +1637,7 @@ function so(t, e) {
1637
1637
  function ro(t, e) {
1638
1638
  return t.minY - e.minY;
1639
1639
  }
1640
- function kt(t) {
1640
+ function Bt(t) {
1641
1641
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1642
1642
  }
1643
1643
  function mt(t) {
@@ -1650,7 +1650,7 @@ function co(t, e) {
1650
1650
  const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
1651
1651
  return Math.max(0, i - n) * Math.max(0, s - o);
1652
1652
  }
1653
- function It(t, e) {
1653
+ function kt(t, e) {
1654
1654
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1655
1655
  }
1656
1656
  function yt(t, e) {
@@ -1667,12 +1667,12 @@ function J(t) {
1667
1667
  maxY: -1 / 0
1668
1668
  };
1669
1669
  }
1670
- function ie(t, e, n, o, i) {
1670
+ function oe(t, e, n, o, i) {
1671
1671
  const s = [e, n];
1672
1672
  for (; s.length; ) {
1673
1673
  if (n = s.pop(), e = s.pop(), n - e <= o) continue;
1674
1674
  const r = e + Math.ceil((n - e) / o / 2) * o;
1675
- Ae(t, r, e, n, i), s.push(e, r, r, n);
1675
+ ve(t, r, e, n, i), s.push(e, r, r, n);
1676
1676
  }
1677
1677
  }
1678
1678
  let lo = () => ({
@@ -1690,121 +1690,121 @@ let lo = () => ({
1690
1690
  }
1691
1691
  });
1692
1692
  const uo = (t, e) => {
1693
- const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (b, S) => {
1694
- const A = b.selector.flatMap((T) => {
1695
- const O = F([T]) ? T.range : de(T, e).range;
1696
- return Array.from(O.getClientRects());
1697
- }), L = Xe(A).map((T) => He(T, S));
1698
- return L.map((T) => {
1699
- const { x: O, y: M, width: f, height: y } = T;
1693
+ const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (y, C) => {
1694
+ const E = y.selector.flatMap((R) => {
1695
+ const T = F([R]) ? R.range : le(R, e).range;
1696
+ return Array.from(T.getClientRects());
1697
+ }), O = Xe(E).map((R) => He(R, C));
1698
+ return O.map((R) => {
1699
+ const { x: T, y: x, width: h, height: v } = R;
1700
1700
  return {
1701
- minX: O,
1702
- minY: M,
1703
- maxX: O + f,
1704
- maxY: M + y,
1701
+ minX: T,
1702
+ minY: x,
1703
+ maxX: T + h,
1704
+ maxY: x + v,
1705
1705
  annotation: {
1706
- id: b.annotation,
1707
- rects: L
1706
+ id: y.annotation,
1707
+ rects: O
1708
1708
  }
1709
1709
  };
1710
1710
  });
1711
1711
  }, r = () => [...o.values()], a = () => {
1712
1712
  n.clear(), o.clear();
1713
- }, d = (b) => {
1714
- const S = s(b, e.getBoundingClientRect());
1715
- S.forEach((A) => n.insert(A)), o.set(b.annotation, S);
1716
- }, c = (b) => {
1717
- const S = o.get(b.annotation);
1718
- S && (S.forEach((A) => n.remove(A)), o.delete(b.annotation));
1719
- }, h = (b) => {
1720
- c(b), d(b);
1721
- }, l = (b, S = !0) => {
1722
- S && a();
1723
- const A = e.getBoundingClientRect(), L = b.map((O) => ({ target: O, rects: s(O, A) }));
1724
- L.forEach(({ target: O, rects: M }) => o.set(O.annotation, M));
1725
- const T = L.flatMap(({ rects: O }) => O);
1726
- n.load(T);
1727
- }, g = (b, S, A = !1) => {
1728
- const L = n.search({
1729
- minX: b,
1730
- minY: S,
1731
- maxX: b,
1732
- maxY: S
1733
- }), T = (O) => O.annotation.rects.reduce((M, f) => M + f.width * f.height, 0);
1734
- return L.length > 0 ? (L.sort((O, M) => T(O) - T(M)), A ? L.map((O) => O.annotation.id) : [L[0].annotation.id]) : [];
1735
- }, p = (b) => {
1736
- const S = v(b);
1737
- if (S.length === 0)
1713
+ }, d = (y) => {
1714
+ const C = s(y, e.getBoundingClientRect());
1715
+ C.forEach((E) => n.insert(E)), o.set(y.annotation, C);
1716
+ }, c = (y) => {
1717
+ const C = o.get(y.annotation);
1718
+ C && (C.forEach((E) => n.remove(E)), o.delete(y.annotation));
1719
+ }, f = (y) => {
1720
+ c(y), d(y);
1721
+ }, l = (y, C = !0) => {
1722
+ C && a();
1723
+ const E = e.getBoundingClientRect(), O = y.map((T) => ({ target: T, rects: s(T, E) }));
1724
+ O.forEach(({ target: T, rects: x }) => o.set(T.annotation, x));
1725
+ const R = O.flatMap(({ rects: T }) => T);
1726
+ n.load(R);
1727
+ }, m = (y, C, E = !1) => {
1728
+ const O = n.search({
1729
+ minX: y,
1730
+ minY: C,
1731
+ maxX: y,
1732
+ maxY: C
1733
+ }), R = (T) => T.annotation.rects.reduce((x, h) => x + h.width * h.height, 0);
1734
+ return O.length > 0 ? (O.sort((T, x) => R(T) - R(x)), E ? O.map((T) => T.annotation.id) : [O[0].annotation.id]) : [];
1735
+ }, p = (y) => {
1736
+ const C = w(y);
1737
+ if (C.length === 0)
1738
1738
  return;
1739
- let A = S[0].left, L = S[0].top, T = S[0].right, O = S[0].bottom;
1740
- for (let M = 1; M < S.length; M++) {
1741
- const f = S[M];
1742
- A = Math.min(A, f.left), L = Math.min(L, f.top), T = Math.max(T, f.right), O = Math.max(O, f.bottom);
1739
+ let E = C[0].left, O = C[0].top, R = C[0].right, T = C[0].bottom;
1740
+ for (let x = 1; x < C.length; x++) {
1741
+ const h = C[x];
1742
+ E = Math.min(E, h.left), O = Math.min(O, h.top), R = Math.max(R, h.right), T = Math.max(T, h.bottom);
1743
1743
  }
1744
- return new DOMRect(A, L, T - A, O - L);
1745
- }, v = (b) => {
1746
- const S = o.get(b);
1747
- return S[0] ? S[0].annotation.rects : [];
1744
+ return new DOMRect(E, O, R - E, T - O);
1745
+ }, w = (y) => {
1746
+ const C = o.get(y);
1747
+ return C[0] ? C[0].annotation.rects : [];
1748
1748
  };
1749
1749
  return {
1750
1750
  all: r,
1751
1751
  clear: a,
1752
- getAt: g,
1752
+ getAt: m,
1753
1753
  getAnnotationBounds: p,
1754
- getAnnotationRects: v,
1755
- getIntersecting: (b, S, A, L) => {
1756
- const T = n.search({ minX: b, minY: S, maxX: A, maxY: L }), O = new Set(T.map((M) => M.annotation.id));
1757
- return Array.from(O).map((M) => ({
1758
- annotation: t.getAnnotation(M),
1759
- rects: v(M)
1760
- })).filter((M) => !!M.annotation);
1754
+ getAnnotationRects: w,
1755
+ getIntersecting: (y, C, E, O) => {
1756
+ const R = n.search({ minX: y, minY: C, maxX: E, maxY: O }), T = new Set(R.map((x) => x.annotation.id));
1757
+ return Array.from(T).map((x) => ({
1758
+ annotation: t.getAnnotation(x),
1759
+ rects: w(x)
1760
+ })).filter((x) => !!x.annotation);
1761
1761
  },
1762
1762
  insert: d,
1763
1763
  recalculate: () => {
1764
- l(t.all().map((b) => b.target), !0), i.emit("recalculate");
1764
+ l(t.all().map((y) => y.target), !0), i.emit("recalculate");
1765
1765
  },
1766
1766
  remove: c,
1767
1767
  set: l,
1768
1768
  size: () => n.all().length,
1769
- update: h,
1770
- on: (b, S) => i.on(b, S)
1769
+ update: f,
1770
+ on: (y, C) => i.on(y, C)
1771
1771
  };
1772
1772
  }, fo = (t, e) => {
1773
1773
  const n = _n(), o = uo(n, t), i = En(n);
1774
1774
  i.setUserSelectAction(e);
1775
- const s = An(n), r = Kn(), a = (u, b = k.LOCAL) => {
1776
- const S = xt(u, t), A = F(S.target.selector);
1777
- return A && n.addAnnotation(S, b), A;
1778
- }, d = (u, b = !0, S = k.LOCAL) => {
1779
- const A = u.map((T) => xt(T, t)), L = A.filter((T) => !F(T.target.selector));
1780
- return L.length > 0 ? (console.warn("Could not revive all targets for these annotations:", L), n.bulkAddAnnotation(A, b, S), L) : (n.bulkAddAnnotation(A, b, S), []);
1781
- }, c = (u, b = k.LOCAL) => {
1782
- const S = u.map((L) => xt(L, t)), A = S.filter((L) => !F(L.target.selector));
1783
- return A.length > 0 && console.warn("Could not revive all targets for these annotations:", A), S.forEach((L) => {
1784
- n.getAnnotation(L.id) ? n.updateAnnotation(L, b) : n.addAnnotation(L, b);
1785
- }), A;
1786
- }, h = (u, b = k.LOCAL) => {
1787
- const S = wt(u, t);
1788
- n.updateTarget(S, b);
1789
- }, l = (u, b = k.LOCAL) => {
1790
- const S = u.map((A) => wt(A, t));
1791
- n.bulkUpdateTargets(S, b);
1792
- }, g = (u, b, S) => {
1793
- const A = o.getAt(u, b, !!S).map((T) => n.getAnnotation(T)), L = S ? A.filter(S) : A;
1794
- return L.length > 0 ? L[0] : void 0;
1795
- }, p = (u, b, S, A = 5) => {
1796
- const L = o.getAnnotationRects(u);
1797
- if (L.length !== 0) {
1798
- if (b && S) {
1799
- const T = L.find(({ top: O, right: M, bottom: f, left: y }) => b >= y - A && b <= M + A && S >= O - A && S <= f + A);
1800
- if (T) return T;
1775
+ const s = An(n), r = Kn(), a = (u, y = k.LOCAL) => {
1776
+ const C = At(u, t), E = F(C.target.selector);
1777
+ return E && n.addAnnotation(C, y), E;
1778
+ }, d = (u, y = !0, C = k.LOCAL) => {
1779
+ const E = u.map((R) => At(R, t)), O = E.filter((R) => !F(R.target.selector));
1780
+ return O.length > 0 ? (console.warn("Could not revive all targets for these annotations:", O), n.bulkAddAnnotation(E, y, C), O) : (n.bulkAddAnnotation(E, y, C), []);
1781
+ }, c = (u, y = k.LOCAL) => {
1782
+ const C = u.map((O) => At(O, t)), E = C.filter((O) => !F(O.target.selector));
1783
+ return E.length > 0 && console.warn("Could not revive all targets for these annotations:", E), C.forEach((O) => {
1784
+ n.getAnnotation(O.id) ? n.updateAnnotation(O, y) : n.addAnnotation(O, y);
1785
+ }), E;
1786
+ }, f = (u, y = k.LOCAL) => {
1787
+ const C = wt(u, t);
1788
+ n.updateTarget(C, y);
1789
+ }, l = (u, y = k.LOCAL) => {
1790
+ const C = u.map((E) => wt(E, t));
1791
+ n.bulkUpdateTargets(C, y);
1792
+ }, m = (u, y, C) => {
1793
+ const E = o.getAt(u, y, !!C).map((R) => n.getAnnotation(R)), O = C ? E.filter(C) : E;
1794
+ return O.length > 0 ? O[0] : void 0;
1795
+ }, p = (u, y, C, E = 5) => {
1796
+ const O = o.getAnnotationRects(u);
1797
+ if (O.length !== 0) {
1798
+ if (y && C) {
1799
+ const R = O.find(({ top: T, right: x, bottom: h, left: v }) => y >= v - E && y <= x + E && C >= T - E && C <= h + E);
1800
+ if (R) return R;
1801
1801
  }
1802
1802
  return o.getAnnotationBounds(u);
1803
1803
  }
1804
- }, v = (u, b, S, A) => o.getIntersecting(u, b, S, A), w = (u) => o.getAnnotationRects(u), E = () => o.recalculate(), m = (u) => o.on("recalculate", u);
1804
+ }, w = (u, y, C, E) => o.getIntersecting(u, y, C, E), b = (u) => o.getAnnotationRects(u), S = () => o.recalculate(), g = (u) => o.on("recalculate", u);
1805
1805
  return n.observe(({ changes: u }) => {
1806
- const b = (u.deleted || []).filter((L) => F(L.target.selector)), S = (u.created || []).filter((L) => F(L.target.selector)), A = (u.updated || []).filter((L) => F(L.newValue.target.selector));
1807
- (b == null ? void 0 : b.length) > 0 && b.forEach((L) => o.remove(L.target)), S.length > 0 && o.set(S.map((L) => L.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: L }) => o.update(L.target));
1806
+ const y = (u.deleted || []).filter((O) => F(O.target.selector)), C = (u.created || []).filter((O) => F(O.target.selector)), E = (u.updated || []).filter((O) => F(O.newValue.target.selector));
1807
+ (y == null ? void 0 : y.length) > 0 && y.forEach((O) => o.remove(O.target)), C.length > 0 && o.set(C.map((O) => O.target), !1), (E == null ? void 0 : E.length) > 0 && E.forEach(({ newValue: O }) => o.update(O.target));
1808
1808
  }), {
1809
1809
  store: {
1810
1810
  ...n,
@@ -1813,12 +1813,12 @@ const uo = (t, e) => {
1813
1813
  bulkUpdateTargets: l,
1814
1814
  bulkUpsertAnnotations: c,
1815
1815
  getAnnotationBounds: p,
1816
- getAnnotationRects: w,
1817
- getIntersecting: v,
1818
- getAt: g,
1819
- recalculatePositions: E,
1820
- onRecalculatePositions: m,
1821
- updateTarget: h
1816
+ getAnnotationRects: b,
1817
+ getIntersecting: w,
1818
+ getAt: m,
1819
+ recalculatePositions: S,
1820
+ onRecalculatePositions: g,
1821
+ updateTarget: f
1822
1822
  },
1823
1823
  selection: i,
1824
1824
  hover: s,
@@ -1832,49 +1832,49 @@ const uo = (t, e) => {
1832
1832
  }, po = (t, e = {}) => {
1833
1833
  const n = ho(), o = n.getContext("2d");
1834
1834
  document.body.appendChild(n);
1835
- const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([l, g]) => g.presenceKey === h.presenceKey).map(([l, g]) => l);
1836
- return t.on("selectionChange", (h, l) => {
1837
- s(h).forEach((p) => i.delete(p)), l && l.forEach((p) => i.set(p, h));
1835
+ const i = /* @__PURE__ */ new Map(), s = (f) => Array.from(i.entries()).filter(([l, m]) => m.presenceKey === f.presenceKey).map(([l, m]) => l);
1836
+ return t.on("selectionChange", (f, l) => {
1837
+ s(f).forEach((p) => i.delete(p)), l && l.forEach((p) => i.set(p, f));
1838
1838
  }), {
1839
1839
  clear: () => {
1840
- const { width: h, height: l } = n;
1841
- o.clearRect(-0.5, -0.5, h + 1, l + 1);
1840
+ const { width: f, height: l } = n;
1841
+ o.clearRect(-0.5, -0.5, f + 1, l + 1);
1842
1842
  },
1843
1843
  destroy: () => {
1844
1844
  n.remove();
1845
1845
  },
1846
- paint: (h, l, g) => {
1846
+ paint: (f, l, m) => {
1847
1847
  e.font && (o.font = e.font);
1848
- const p = i.get(h.annotation.id);
1848
+ const p = i.get(f.annotation.id);
1849
1849
  if (p) {
1850
- const { height: v } = h.rects[0], w = h.rects[0].x + l.left, E = h.rects[0].y + l.top;
1851
- o.fillStyle = p.appearance.color, o.fillRect(w - 2, E - 2.5, 2, v + 5);
1852
- const m = o.measureText(p.appearance.label), u = m.width + 6, b = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, S = m.fontBoundingBoxAscent ? 8 : 6.5;
1853
- return o.fillRect(w - 2, E - 2.5 - b, u, b), o.fillStyle = "#fff", o.fillText(p.appearance.label, w + 1, E - S), {
1850
+ const { height: w } = f.rects[0], b = f.rects[0].x + l.left, S = f.rects[0].y + l.top;
1851
+ o.fillStyle = p.appearance.color, o.fillRect(b - 2, S - 2.5, 2, w + 5);
1852
+ const g = o.measureText(p.appearance.label), u = g.width + 6, y = g.actualBoundingBoxAscent + g.actualBoundingBoxDescent + 8, C = g.fontBoundingBoxAscent ? 8 : 6.5;
1853
+ return o.fillRect(b - 2, S - 2.5 - y, u, y), o.fillStyle = "#fff", o.fillText(p.appearance.label, b + 1, S - C), {
1854
1854
  fill: p.appearance.color,
1855
- fillOpacity: g ? 0.45 : 0.18
1855
+ fillOpacity: m ? 0.45 : 0.18
1856
1856
  };
1857
1857
  }
1858
1858
  },
1859
1859
  reset: () => {
1860
1860
  n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
1861
- const h = n.getContext("2d");
1862
- h.scale(2, 2), h.translate(0.5, 0.5);
1861
+ const f = n.getContext("2d");
1862
+ f.scale(2, 2), f.translate(0.5, 0.5);
1863
1863
  }
1864
1864
  };
1865
- }, Nt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1866
- function _t(t, e, n, o) {
1865
+ }, It = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1866
+ function Nt(t, e, n, o) {
1867
1867
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1868
1868
  }
1869
1869
  function et(t, e, n, o) {
1870
1870
  t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
1871
1871
  }
1872
- function xe(t, e) {
1872
+ function Ae(t, e) {
1873
1873
  const n = e.slice(0, e.length - 1);
1874
1874
  for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
1875
1875
  return n;
1876
1876
  }
1877
- function Ee(t) {
1877
+ function xe(t) {
1878
1878
  typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
1879
1879
  const e = t.split(",");
1880
1880
  let n = e.lastIndexOf("");
@@ -1934,9 +1934,9 @@ const at = {
1934
1934
  ".": 190,
1935
1935
  "/": 191,
1936
1936
  "`": 192,
1937
- "-": Nt ? 173 : 189,
1938
- "=": Nt ? 61 : 187,
1939
- ";": Nt ? 59 : 186,
1937
+ "-": It ? 173 : 189,
1938
+ "=": It ? 61 : 187,
1939
+ ";": It ? 59 : 186,
1940
1940
  "'": 222,
1941
1941
  "[": 219,
1942
1942
  "]": 221,
@@ -1957,7 +1957,7 @@ const at = {
1957
1957
  "⌘": 91,
1958
1958
  cmd: 91,
1959
1959
  command: 91
1960
- }, Kt = {
1960
+ }, Vt = {
1961
1961
  16: "shiftKey",
1962
1962
  18: "altKey",
1963
1963
  17: "ctrlKey",
@@ -1974,13 +1974,13 @@ const at = {
1974
1974
  }, N = {};
1975
1975
  for (let t = 1; t < 20; t++)
1976
1976
  at["f".concat(t)] = 111 + t;
1977
- let I = [], rt = null, Se = "all";
1977
+ let I = [], rt = null, Ee = "all";
1978
1978
  const z = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), mo = (t) => Object.keys(at).find((e) => at[e] === t), yo = (t) => Object.keys(j).find((e) => j[e] === t);
1979
- function Ce(t) {
1980
- Se = t || "all";
1979
+ function Se(t) {
1980
+ Ee = t || "all";
1981
1981
  }
1982
1982
  function ct() {
1983
- return Se || "all";
1983
+ return Ee || "all";
1984
1984
  }
1985
1985
  function bo() {
1986
1986
  return I.slice(0);
@@ -2028,9 +2028,9 @@ function Eo(t, e) {
2028
2028
  let {
2029
2029
  element: a
2030
2030
  } = r;
2031
- return jt(a);
2031
+ return $t(a);
2032
2032
  }) : o++;
2033
- ct() === t && Ce(e || "all");
2033
+ ct() === t && Se(e || "all");
2034
2034
  }
2035
2035
  function So(t) {
2036
2036
  let e = t.keyCode || t.which || t.charCode;
@@ -2040,11 +2040,11 @@ function So(t) {
2040
2040
  for (const o in j) j[o] === e && (P[o] = !1);
2041
2041
  }
2042
2042
  }
2043
- function Le(t) {
2043
+ function Ce(t) {
2044
2044
  if (typeof t > "u")
2045
2045
  Object.keys(N).forEach((i) => {
2046
2046
  Array.isArray(N[i]) && N[i].forEach((s) => bt(s)), delete N[i];
2047
- }), jt(null);
2047
+ }), $t(null);
2048
2048
  else if (Array.isArray(t))
2049
2049
  t.forEach((i) => {
2050
2050
  i.key && bt(i);
@@ -2070,18 +2070,18 @@ const bt = (t) => {
2070
2070
  method: o,
2071
2071
  splitKey: i = "+"
2072
2072
  } = t;
2073
- Ee(e).forEach((r) => {
2074
- const a = r.split(i), d = a.length, c = a[d - 1], h = c === "*" ? "*" : lt(c);
2075
- if (!N[h]) return;
2073
+ xe(e).forEach((r) => {
2074
+ const a = r.split(i), d = a.length, c = a[d - 1], f = c === "*" ? "*" : lt(c);
2075
+ if (!N[f]) return;
2076
2076
  n || (n = ct());
2077
- const l = d > 1 ? xe(j, a) : [], g = [];
2078
- N[h] = N[h].filter((p) => {
2079
- const w = (o ? p.method === o : !0) && p.scope === n && go(p.mods, l);
2080
- return w && g.push(p.element), !w;
2081
- }), g.forEach((p) => jt(p));
2077
+ const l = d > 1 ? Ae(j, a) : [], m = [];
2078
+ N[f] = N[f].filter((p) => {
2079
+ const b = (o ? p.method === o : !0) && p.scope === n && go(p.mods, l);
2080
+ return b && m.push(p.element), !b;
2081
+ }), m.forEach((p) => $t(p));
2082
2082
  });
2083
2083
  };
2084
- function se(t, e, n, o) {
2084
+ function ie(t, e, n, o) {
2085
2085
  if (e.element !== o)
2086
2086
  return;
2087
2087
  let i;
@@ -2092,12 +2092,12 @@ function se(t, e, n, o) {
2092
2092
  (e.mods.length === 0 && !V[16] && !V[18] && !V[17] && !V[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2093
2093
  }
2094
2094
  }
2095
- function re(t, e) {
2095
+ function se(t, e) {
2096
2096
  const n = N["*"];
2097
2097
  let o = t.keyCode || t.which || t.charCode;
2098
2098
  if (!P.filter.call(this, t)) return;
2099
2099
  if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
2100
- const d = Kt[a];
2100
+ const d = Vt[a];
2101
2101
  t[a] && I.indexOf(d) === -1 ? I.push(d) : !t[a] && I.indexOf(d) > -1 ? I.splice(I.indexOf(d), 1) : a === "metaKey" && t[a] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(d))));
2102
2102
  }), o in V) {
2103
2103
  V[o] = !0;
@@ -2106,30 +2106,30 @@ function re(t, e) {
2106
2106
  if (!n) return;
2107
2107
  }
2108
2108
  for (const a in V)
2109
- Object.prototype.hasOwnProperty.call(V, a) && (V[a] = t[Kt[a]]);
2109
+ Object.prototype.hasOwnProperty.call(V, a) && (V[a] = t[Vt[a]]);
2110
2110
  t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), V[17] = !0, V[18] = !0);
2111
2111
  const i = ct();
2112
2112
  if (n)
2113
2113
  for (let a = 0; a < n.length; a++)
2114
- n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && se(t, n[a], i, e);
2114
+ n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && ie(t, n[a], i, e);
2115
2115
  if (!(o in N)) return;
2116
2116
  const s = N[o], r = s.length;
2117
2117
  for (let a = 0; a < r; a++)
2118
2118
  if ((t.type === "keydown" && s[a].keydown || t.type === "keyup" && s[a].keyup) && s[a].key) {
2119
2119
  const d = s[a], {
2120
2120
  splitKey: c
2121
- } = d, h = d.key.split(c), l = [];
2122
- for (let g = 0; g < h.length; g++)
2123
- l.push(lt(h[g]));
2124
- l.sort().join("") === I.sort().join("") && se(t, d, i, e);
2121
+ } = d, f = d.key.split(c), l = [];
2122
+ for (let m = 0; m < f.length; m++)
2123
+ l.push(lt(f[m]));
2124
+ l.sort().join("") === I.sort().join("") && ie(t, d, i, e);
2125
2125
  }
2126
2126
  }
2127
2127
  function P(t, e, n) {
2128
2128
  I = [];
2129
- const o = Ee(t);
2130
- let i = [], s = "all", r = document, a = 0, d = !1, c = !0, h = "+", l = !1, g = !1;
2131
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && Le(t, s); a < o.length; a++)
2132
- t = o[a].split(h), i = [], t.length > 1 && (i = xe(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in N || (N[t] = []), N[t].push({
2129
+ const o = xe(t);
2130
+ let i = [], s = "all", r = document, a = 0, d = !1, c = !0, f = "+", l = !1, m = !1;
2131
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (f = e.splitKey), e.single === !0 && (m = !0)), typeof e == "string" && (s = e), m && Ce(t, s); a < o.length; a++)
2132
+ t = o[a].split(f), i = [], t.length > 1 && (i = Ae(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in N || (N[t] = []), N[t].push({
2133
2133
  keyup: d,
2134
2134
  keydown: c,
2135
2135
  scope: s,
@@ -2137,23 +2137,23 @@ function P(t, e, n) {
2137
2137
  shortcut: o[a],
2138
2138
  method: n,
2139
2139
  key: o[a],
2140
- splitKey: h,
2140
+ splitKey: f,
2141
2141
  element: r
2142
2142
  });
2143
2143
  if (typeof r < "u" && window) {
2144
2144
  if (!z.has(r)) {
2145
2145
  const p = function() {
2146
- let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2147
- return re(w, r);
2148
- }, v = function() {
2149
- let w = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2150
- re(w, r), So(w);
2146
+ let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2147
+ return se(b, r);
2148
+ }, w = function() {
2149
+ let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2150
+ se(b, r), So(b);
2151
2151
  };
2152
2152
  z.set(r, {
2153
2153
  keydownListener: p,
2154
- keyupListenr: v,
2154
+ keyupListenr: w,
2155
2155
  capture: l
2156
- }), _t(r, "keydown", p, l), _t(r, "keyup", v, l);
2156
+ }), Nt(r, "keydown", p, l), Nt(r, "keyup", w, l);
2157
2157
  }
2158
2158
  if (!rt) {
2159
2159
  const p = () => {
@@ -2162,7 +2162,7 @@ function P(t, e, n) {
2162
2162
  rt = {
2163
2163
  listener: p,
2164
2164
  capture: l
2165
- }, _t(window, "focus", p, l);
2165
+ }, Nt(window, "focus", p, l);
2166
2166
  }
2167
2167
  }
2168
2168
  }
@@ -2174,7 +2174,7 @@ function Co(t) {
2174
2174
  });
2175
2175
  });
2176
2176
  }
2177
- function jt(t) {
2177
+ function $t(t) {
2178
2178
  const e = Object.values(N).flat();
2179
2179
  if (e.findIndex((o) => {
2180
2180
  let {
@@ -2204,9 +2204,9 @@ function jt(t) {
2204
2204
  et(window, "focus", i, s), rt = null;
2205
2205
  }
2206
2206
  }
2207
- const Ut = {
2207
+ const _t = {
2208
2208
  getPressedKeyString: wo,
2209
- setScope: Ce,
2209
+ setScope: Se,
2210
2210
  getScope: ct,
2211
2211
  deleteScope: Eo,
2212
2212
  getPressedKeyCodes: bo,
@@ -2214,13 +2214,13 @@ const Ut = {
2214
2214
  isPressed: xo,
2215
2215
  filter: Ao,
2216
2216
  trigger: Co,
2217
- unbind: Le,
2217
+ unbind: Ce,
2218
2218
  keyMap: at,
2219
2219
  modifier: j,
2220
- modifierMap: Kt
2220
+ modifierMap: Vt
2221
2221
  };
2222
- for (const t in Ut)
2223
- Object.prototype.hasOwnProperty.call(Ut, t) && (P[t] = Ut[t]);
2222
+ for (const t in _t)
2223
+ Object.prototype.hasOwnProperty.call(_t, t) && (P[t] = _t[t]);
2224
2224
  if (typeof window < "u") {
2225
2225
  const t = window.hotkeys;
2226
2226
  P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
@@ -2232,158 +2232,157 @@ async function Lo(t, e, n = () => !1) {
2232
2232
  await new Promise((i) => setTimeout(i, Math.max(0, o)));
2233
2233
  } while (!await n());
2234
2234
  }
2235
- const ae = 300, Oe = ["up", "down", "left", "right"], Te = ke ? "⌘+a" : "ctrl+a", Oo = [
2236
- ...Oe.map((t) => `shift+${t}`),
2237
- Te
2235
+ const re = 300, Le = ["up", "down", "left", "right"], Oe = ke ? "⌘+a" : "ctrl+a", Oo = [
2236
+ ...Le.map((t) => `shift+${t}`),
2237
+ Oe
2238
2238
  ], To = (t, e, n) => {
2239
2239
  const { store: o, selection: i } = e;
2240
2240
  let s;
2241
- const r = (f) => s = f;
2241
+ const r = (x) => s = x;
2242
2242
  let a;
2243
- const d = (f) => a = f;
2244
- let c, h, l, g = !1, p = !0;
2245
- const v = (f) => {
2246
- p = f, E.clear(), f || (c = void 0, l = void 0, g = !1);
2247
- }, w = (f) => {
2248
- p && (g = !1, h !== !1 && (c = nt(f.target) ? void 0 : {
2249
- annotation: ye(),
2243
+ const d = (x) => a = x;
2244
+ let c, f, l, m = !0;
2245
+ const p = (x) => {
2246
+ m = x, b.clear(), x || (c = void 0, l = void 0);
2247
+ }, w = (x) => {
2248
+ f !== !1 && (c = nt(x.target) ? void 0 : {
2249
+ annotation: me(),
2250
2250
  selector: [],
2251
2251
  creator: s,
2252
2252
  created: /* @__PURE__ */ new Date()
2253
- }));
2254
- }, E = Xt((f) => {
2255
- if (!p) return;
2256
- const y = document.getSelection();
2257
- if (!(y != null && y.anchorNode))
2253
+ });
2254
+ }, b = Yt((x) => {
2255
+ if (!m) return;
2256
+ const h = document.getSelection();
2257
+ if (!(h != null && h.anchorNode))
2258
2258
  return;
2259
- if (nt(y.anchorNode)) {
2259
+ if (nt(h.anchorNode)) {
2260
2260
  c = void 0;
2261
2261
  return;
2262
2262
  }
2263
- const x = f.timeStamp - ((l == null ? void 0 : l.timeStamp) || f.timeStamp);
2264
- if ((l == null ? void 0 : l.type) === "pointerdown" && (x < 1e3 && !c || y.isCollapsed && x < ae) && w(l || f), !c) return;
2265
- if (y.isCollapsed) {
2263
+ const v = x.timeStamp - ((l == null ? void 0 : l.timeStamp) || x.timeStamp);
2264
+ if ((l == null ? void 0 : l.type) === "pointerdown" && (v < 1e3 && !c || h.isCollapsed && v < re) && w(l || x), !c) return;
2265
+ if (h.isCollapsed) {
2266
2266
  o.getAnnotation(c.annotation) && (i.clear(), o.deleteAnnotation(c.annotation));
2267
2267
  return;
2268
2268
  }
2269
- const C = y.getRangeAt(0), B = je(C, t);
2270
- if (Ve(B)) return;
2271
- const R = _e(B.cloneRange());
2272
- (R.length !== c.selector.length || R.some((Y, At) => {
2269
+ const A = h.getRangeAt(0), L = je(A, t);
2270
+ if (Ve(L)) return;
2271
+ const M = _e(L.cloneRange());
2272
+ (M.length !== c.selector.length || M.some((K, Y) => {
2273
2273
  var dt;
2274
- return Y.toString() !== ((dt = c.selector[At]) == null ? void 0 : dt.quote);
2274
+ return K.toString() !== ((dt = c.selector[Y]) == null ? void 0 : dt.quote);
2275
2275
  })) && (c = {
2276
2276
  ...c,
2277
- selector: R.map((Y) => Pe(Y, t, n)),
2277
+ selector: M.map((K) => Pe(K, t, n)),
2278
2278
  updated: /* @__PURE__ */ new Date()
2279
2279
  }, o.getAnnotation(c.annotation) ? o.updateTarget(c, k.LOCAL) : i.clear());
2280
- }, 10), m = (f) => {
2281
- g || nt(f.target) || (l = Et(f), h = l.button === 0);
2282
- }, u = () => {
2280
+ }, 10), S = (x) => {
2281
+ nt(x.target) || (l = xt(x), f = l.button === 0);
2282
+ }, g = () => {
2283
2283
  o.getAnnotation(c.annotation) ? o.updateTarget(c) : o.addAnnotation({
2284
2284
  id: c.annotation,
2285
2285
  bodies: [],
2286
2286
  target: c
2287
2287
  });
2288
- }, b = async (f) => {
2289
- if (g || nt(f.target) || !h) return;
2290
- const y = () => {
2291
- const { x: C, y: B } = t.getBoundingClientRect(), R = f.target instanceof Node && t.contains(f.target) && o.getAt(f.clientX - C, f.clientY - B, a);
2292
- if (R) {
2293
- const { selected: K } = i;
2294
- (K.length !== 1 || K[0].id !== R.id) && i.userSelect(R.id, f);
2288
+ }, u = async (x) => {
2289
+ if (nt(x.target) || !f) return;
2290
+ const h = () => {
2291
+ const { x: A, y: L } = t.getBoundingClientRect(), M = x.target instanceof Node && t.contains(x.target) && o.getAt(x.clientX - A, x.clientY - L, a);
2292
+ if (M) {
2293
+ const { selected: B } = i;
2294
+ (B.length !== 1 || B[0].id !== M.id) && i.userSelect(M.id, x);
2295
2295
  } else
2296
2296
  i.clear();
2297
2297
  };
2298
- if (f.timeStamp - l.timeStamp < ae) {
2299
- await S();
2300
- const C = document.getSelection();
2301
- if (C != null && C.isCollapsed) {
2302
- c = void 0, y();
2298
+ if (x.timeStamp - l.timeStamp < re) {
2299
+ await y();
2300
+ const A = document.getSelection();
2301
+ if (A != null && A.isCollapsed) {
2302
+ c = void 0, h();
2303
2303
  return;
2304
2304
  }
2305
2305
  }
2306
- c && c.selector.length > 0 && (i.clear(), u(), i.userSelect(c.annotation, Et(f)));
2307
- }, S = async () => {
2308
- const f = document.getSelection();
2309
- let y = !1, x = f == null ? void 0 : f.isCollapsed;
2310
- const C = () => x || y, B = 1;
2311
- return setTimeout(() => y = !0, 50), Lo(() => x = f == null ? void 0 : f.isCollapsed, B, C);
2312
- }, A = (f) => {
2313
- g = !0;
2314
- const y = document.getSelection();
2315
- y != null && y.isCollapsed || ((!c || c.selector.length === 0) && E(f), u(), i.userSelect(c.annotation, Et(f)));
2316
- }, L = (f) => {
2317
- p && f.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), u(), i.userSelect(c.annotation, ut(f))));
2318
- }, T = (f) => {
2319
- const y = () => setTimeout(() => {
2306
+ c && c.selector.length > 0 && (i.clear(), g(), i.userSelect(c.annotation, xt(x)));
2307
+ }, y = async () => {
2308
+ const x = document.getSelection();
2309
+ let h = !1, v = x == null ? void 0 : x.isCollapsed;
2310
+ const A = () => v || h, L = 1;
2311
+ return setTimeout(() => h = !0, 50), Lo(() => v = x == null ? void 0 : x.isCollapsed, L, A);
2312
+ }, C = (x) => {
2313
+ const h = document.getSelection();
2314
+ h != null && h.isCollapsed || ((!c || c.selector.length === 0) && b(x), g(), i.userSelect(c.annotation, xt(x)));
2315
+ }, E = (x) => {
2316
+ m && x.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), g(), i.userSelect(c.annotation, ut(x))));
2317
+ }, O = (x) => {
2318
+ const h = () => setTimeout(() => {
2320
2319
  (c == null ? void 0 : c.selector.length) > 0 && (i.clear(), o.addAnnotation({
2321
2320
  id: c.annotation,
2322
2321
  bodies: [],
2323
2322
  target: c
2324
- }), i.userSelect(c.annotation, ut(f))), document.removeEventListener("selectionchange", y);
2323
+ }), i.userSelect(c.annotation, ut(x))), document.removeEventListener("selectionchange", h);
2325
2324
  }, 100);
2326
- document.addEventListener("selectionchange", y), w(f);
2325
+ document.addEventListener("selectionchange", h), w(x);
2327
2326
  };
2328
- P(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (f) => {
2329
- f.repeat || (l = ut(f));
2330
- }), P(Te, { keydown: !0, keyup: !1 }, (f) => {
2331
- l = ut(f), T(f);
2327
+ P(Oo.join(","), { element: t, keydown: !0, keyup: !1 }, (x) => {
2328
+ x.repeat || (l = ut(x));
2329
+ }), P(Oe, { keydown: !0, keyup: !1 }, (x) => {
2330
+ l = ut(x), O(x);
2332
2331
  });
2333
- const O = (f) => {
2334
- f.repeat || f.target !== t && f.target !== document.body || (c = void 0, i.clear());
2332
+ const R = (x) => {
2333
+ x.repeat || x.target !== t && x.target !== document.body || (c = void 0, i.clear());
2335
2334
  };
2336
- return P(Oe.join(","), { keydown: !0, keyup: !1 }, O), document.addEventListener("pointerdown", m), document.addEventListener("pointerup", b), document.addEventListener("contextmenu", A), t.addEventListener("keyup", L), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", E), {
2335
+ return P(Le.join(","), { keydown: !0, keyup: !1 }, R), document.addEventListener("pointerdown", S), document.addEventListener("pointerup", u), document.addEventListener("contextmenu", C), t.addEventListener("keyup", E), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", b), {
2337
2336
  destroy: () => {
2338
- c = void 0, h = void 0, l = void 0, g = !1, E.clear(), document.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", b), document.removeEventListener("contextmenu", A), t.removeEventListener("keyup", L), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", E), P.unbind();
2337
+ c = void 0, f = void 0, l = void 0, b.clear(), document.removeEventListener("pointerdown", S), document.removeEventListener("pointerup", u), document.removeEventListener("contextmenu", C), t.removeEventListener("keyup", E), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", b), P.unbind();
2339
2338
  },
2340
2339
  setFilter: d,
2341
2340
  setUser: r,
2342
- setAnnotatingEnabled: v
2341
+ setAnnotatingEnabled: p
2343
2342
  };
2344
2343
  }, Ro = (t, e) => ({
2345
2344
  ...t,
2346
2345
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
2347
2346
  user: t.user || e.user
2348
- }), ce = "SPANS", No = (t, e = {}) => {
2347
+ }), ae = "SPANS", No = (t, e = {}) => {
2349
2348
  Be(t), Ie(t);
2350
2349
  const n = Ro(e, {
2351
2350
  annotatingEnabled: !0,
2352
2351
  user: Wn()
2353
2352
  }), o = fo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Vn(r), d = Yn(o, a, n.adapter);
2354
2353
  let c = n.user;
2355
- const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ce : n.renderer || ce, l = h === "SPANS" ? gn(t, o, s) : h === "CSS_HIGHLIGHTS" ? fn(t, o, s) : h === "CANVAS" ? en(t, o, s) : void 0;
2354
+ const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ae : n.renderer || ae, l = f === "SPANS" ? gn(t, o, s) : f === "CSS_HIGHLIGHTS" ? fn(t, o, s) : f === "CANVAS" ? en(t, o, s) : void 0;
2356
2355
  if (!l)
2357
- throw `Unknown renderer implementation: ${h}`;
2358
- console.debug(`Using ${h} renderer`), n.style && l.setStyle(n.style);
2359
- const g = To(t, o, n.offsetReferenceSelector);
2360
- g.setUser(c), g.setAnnotatingEnabled(n.annotatingEnabled);
2361
- const p = Pn(o, a, n.adapter), v = () => c, w = (A) => {
2362
- g.setAnnotatingEnabled(
2363
- A === void 0 ? !0 : A
2356
+ throw `Unknown renderer implementation: ${f}`;
2357
+ console.debug(`Using ${f} renderer`), n.style && l.setStyle(n.style);
2358
+ const m = To(t, o, n.offsetReferenceSelector);
2359
+ m.setUser(c), m.setAnnotatingEnabled(n.annotatingEnabled);
2360
+ const p = Pn(o, a, n.adapter), w = () => c, b = (E) => {
2361
+ m.setAnnotatingEnabled(
2362
+ E === void 0 ? !0 : E
2364
2363
  );
2365
- }, E = (A) => {
2366
- l.setFilter(A), g.setFilter(A);
2367
- }, m = (A) => {
2368
- c = A, g.setUser(A);
2369
- }, u = (A) => {
2370
- A && (l.setPainter(po(A, n.presence)), A.on("selectionChange", () => l.redraw()));
2371
- }, b = (A) => {
2372
- A ? i.setSelected(A) : i.clear();
2364
+ }, S = (E) => {
2365
+ l.setFilter(E), m.setFilter(E);
2366
+ }, g = (E) => {
2367
+ c = E, m.setUser(E);
2368
+ }, u = (E) => {
2369
+ E && (l.setPainter(po(E, n.presence)), E.on("selectionChange", () => l.redraw()));
2370
+ }, y = (E) => {
2371
+ E ? i.setSelected(E) : i.clear();
2373
2372
  };
2374
2373
  return {
2375
2374
  ...p,
2376
2375
  destroy: () => {
2377
- l.destroy(), g.destroy(), a.destroy();
2376
+ l.destroy(), m.destroy(), a.destroy();
2378
2377
  },
2379
2378
  element: t,
2380
- getUser: v,
2381
- setAnnotatingEnabled: w,
2382
- setFilter: E,
2379
+ getUser: w,
2380
+ setAnnotatingEnabled: b,
2381
+ setFilter: S,
2383
2382
  setStyle: l.setStyle.bind(l),
2384
2383
  redraw: l.redraw.bind(l),
2385
- setUser: m,
2386
- setSelected: b,
2384
+ setUser: g,
2385
+ setSelected: y,
2387
2386
  setPresenceProvider: u,
2388
2387
  setVisible: l.setVisible.bind(l),
2389
2388
  on: d.on,
@@ -2395,14 +2394,14 @@ const ae = 300, Oe = ["up", "down", "left", "right"], Te = ke ? "⌘+a" : "ctrl+
2395
2394
  export {
2396
2395
  vt as DEFAULT_SELECTED_STYLE,
2397
2396
  W as DEFAULT_STYLE,
2398
- le as NOT_ANNOTATABLE_CLASS,
2397
+ ce as NOT_ANNOTATABLE_CLASS,
2399
2398
  Z as NOT_ANNOTATABLE_SELECTOR,
2400
2399
  k as Origin,
2401
2400
  xn as UserSelectAction,
2402
2401
  Io as W3CTextFormat,
2403
2402
  Be as cancelSingleClickEvents,
2404
2403
  ut as cloneKeyboardEvent,
2405
- Et as clonePointerEvent,
2404
+ xt as clonePointerEvent,
2406
2405
  ko as createBody,
2407
2406
  en as createCanvasRenderer,
2408
2407
  fn as createHighlightsRenderer,
@@ -2415,7 +2414,7 @@ export {
2415
2414
  Bo as denormalizeRectWithOffset,
2416
2415
  Ro as fillDefaults,
2417
2416
  Ue as getQuoteContext,
2418
- Dt as getRangeAnnotatableContents,
2417
+ Ut as getRangeAnnotatableContents,
2419
2418
  ke as isMac,
2420
2419
  nt as isNotAnnotatable,
2421
2420
  Me as isRangeAnnotatable,
@@ -2428,8 +2427,8 @@ export {
2428
2427
  Ie as programmaticallyFocusable,
2429
2428
  $e as rangeContains,
2430
2429
  Pe as rangeToSelector,
2431
- xt as reviveAnnotation,
2432
- de as reviveSelector,
2430
+ At as reviveAnnotation,
2431
+ le as reviveSelector,
2433
2432
  wt as reviveTarget,
2434
2433
  ze as scrollIntoView,
2435
2434
  eo as serializeW3CTextAnnotation,