@soomo/text-annotator 3.0.0-staging.50 → 3.0.0-staging.52

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.
Files changed (32) hide show
  1. package/dist/src/SelectionHandler.d.ts +0 -1
  2. package/dist/src/TextAnnotator.d.ts +0 -1
  3. package/dist/src/TextAnnotatorOptions.d.ts +0 -1
  4. package/dist/src/api/scrollIntoView.d.ts +0 -1
  5. package/dist/src/highlight/Highlight.d.ts +0 -1
  6. package/dist/src/highlight/HighlightPainter.d.ts +0 -1
  7. package/dist/src/highlight/HighlightStyle.d.ts +0 -1
  8. package/dist/src/highlight/baseRenderer.d.ts +0 -1
  9. package/dist/src/highlight/canvas/canvasRenderer.d.ts +0 -1
  10. package/dist/src/highlight/highlights/highlightsRenderer.d.ts +0 -1
  11. package/dist/src/highlight/span/spansRenderer.d.ts +0 -1
  12. package/dist/src/highlight/viewport.d.ts +0 -1
  13. package/dist/src/model/core/TextAnnotation.d.ts +0 -1
  14. package/dist/src/model/w3c/W3CTextAnnotation.d.ts +0 -1
  15. package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +0 -1
  16. package/dist/src/presence/PresencePainter.d.ts +0 -1
  17. package/dist/src/state/TextAnnotationStore.d.ts +0 -1
  18. package/dist/src/state/TextAnnotatorState.d.ts +0 -1
  19. package/dist/src/state/spatialTree.d.ts +0 -1
  20. package/dist/src/utils/debounce.d.ts +9 -0
  21. package/dist/src/utils/index.d.ts +1 -0
  22. package/dist/src/utils/isRevived.d.ts +0 -1
  23. package/dist/src/utils/rangeToSelector.d.ts +0 -1
  24. package/dist/src/utils/reviveAnnotation.d.ts +0 -1
  25. package/dist/src/utils/reviveSelector.d.ts +0 -1
  26. package/dist/src/utils/reviveTarget.d.ts +0 -1
  27. package/dist/test/model/w3c/fixtures.d.ts +0 -1
  28. package/dist/text-annotator.es.js +1218 -1185
  29. package/dist/text-annotator.es.js.map +1 -1
  30. package/dist/text-annotator.umd.js +2 -2
  31. package/dist/text-annotator.umd.js.map +1 -1
  32. package/package.json +10 -10
@@ -1,139 +1,411 @@
1
1
  const q = {
2
2
  fill: "rgb(0, 128, 255)",
3
3
  fillOpacity: 0.18
4
- }, mt = {
4
+ }, yt = {
5
5
  fill: "rgb(0, 128, 255)",
6
6
  fillOpacity: 0.45
7
- }, Ae = (t, e, n, o, i) => {
7
+ }, Se = (t, e, n, o, i) => {
8
8
  var a, s;
9
- const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? mt : q) : n : (s = t.state) != null && s.selected ? mt : q;
9
+ const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? yt : q) : n : (s = t.state) != null && s.selected ? yt : q;
10
10
  return o && o.paint(t, e) || r;
11
+ }, Ce = (t) => {
12
+ const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, l = i - e;
13
+ return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: l };
14
+ }, Le = (t) => {
15
+ let e = /* @__PURE__ */ new Set();
16
+ return (o) => {
17
+ const i = o.map((r) => r.id);
18
+ (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
19
+ };
20
+ }, re = "not-annotatable", j = `.${re}`, Oe = (t) => {
21
+ var n;
22
+ const e = t.commonAncestorContainer;
23
+ return e instanceof HTMLElement ? !e.closest(j) : !((n = e.parentElement) != null && n.closest(j));
24
+ }, Te = function* (t) {
25
+ const e = document.createNodeIterator(
26
+ t.commonAncestorContainer,
27
+ NodeFilter.SHOW_ELEMENT,
28
+ (o) => o instanceof HTMLElement && o.classList.contains(re) && !o.parentElement.closest(j) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
29
+ );
30
+ let n;
31
+ for (; n = e.nextNode(); )
32
+ n instanceof HTMLElement && (yield n);
33
+ }, Re = (t) => {
34
+ if (!Oe(t)) return [];
35
+ const e = [];
36
+ let n = null;
37
+ for (const o of Te(t)) {
38
+ let i;
39
+ n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
40
+ }
41
+ if (n) {
42
+ const o = t.cloneRange();
43
+ o.setStartAfter(n), o.collapsed || e.push(o);
44
+ }
45
+ return e.length > 0 ? e : [t];
46
+ }, Nt = (t) => {
47
+ const e = t.cloneContents();
48
+ return e.querySelectorAll(j).forEach((n) => n.remove()), e;
49
+ }, Be = (t) => t.addEventListener("click", (e) => {
50
+ // Allow clicks within not-annotatable elements
51
+ !e.target.closest(j) && !e.target.closest("a") && e.preventDefault();
52
+ }), Me = (t) => {
53
+ !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
54
+ }, Co = (t) => {
55
+ const e = t.cloneContents();
56
+ return e.querySelectorAll(j).forEach((n) => n.remove()), e;
57
+ }, Xt = (t, e) => {
58
+ const n = document.createNodeIterator(e);
59
+ let o = 0, i = n.nextNode();
60
+ for (; i !== null; ) {
61
+ if (i === t)
62
+ return o;
63
+ o += 1, i = n.nextNode();
64
+ }
65
+ }, Yt = (t, e) => {
66
+ const n = document.createNodeIterator(e);
67
+ let o = null;
68
+ for (let i = 0; i < t + 1; i++)
69
+ o = n.nextNode();
70
+ return o;
71
+ }, Ne = (t) => {
72
+ const {
73
+ commonAncestorContainer: e,
74
+ startContainer: n,
75
+ startOffset: o,
76
+ endContainer: i,
77
+ endOffset: r
78
+ } = t, a = Array.from(e.childNodes).map((c) => {
79
+ const f = c.cloneNode(!0);
80
+ return c.nodeName === "CANVAS" ? c : f;
81
+ }), s = Xt(n, e), l = Xt(i, e), u = () => {
82
+ const c = e;
83
+ c.replaceChildren(...a);
84
+ const f = Yt(s, c), h = Yt(l, c);
85
+ return t.setStart(f, o), t.setEnd(h, r), t;
86
+ }, p = (c) => {
87
+ const f = document.createElement("SPAN");
88
+ return c.surroundContents(f), f;
89
+ };
90
+ if (n === i)
91
+ throw "Not implemented";
92
+ {
93
+ const c = document.createRange();
94
+ c.selectNodeContents(n), c.setStart(n, o);
95
+ const f = p(c), h = document.createRange();
96
+ h.selectNode(i), h.setEnd(i, r);
97
+ const x = p(h), b = ke(t).reverse().map((g) => {
98
+ var m;
99
+ const d = document.createElement("SPAN");
100
+ return (m = g.parentNode) == null || m.insertBefore(d, g), d.appendChild(g), d;
101
+ });
102
+ return { unwrap: u, nodes: [f, ...b, x] };
103
+ }
104
+ }, ke = (t) => {
105
+ const {
106
+ commonAncestorContainer: e,
107
+ startContainer: n,
108
+ endContainer: o
109
+ } = t, i = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);
110
+ let r = i.nextNode(), a = !1;
111
+ const s = [];
112
+ for (; r != null; )
113
+ r === o && (a = !1), a && s.push(r), r === n && (a = !0), r = i.nextNode();
114
+ return s;
115
+ }, Lo = (t) => {
116
+ const { startContainer: e, endContainer: n } = t;
117
+ if (e === n)
118
+ return Array.from(t.getClientRects());
119
+ {
120
+ const { unwrap: o, nodes: i } = Ne(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
121
+ return o(), r;
122
+ }
123
+ }, Ie = (t, e, n = 10, o) => {
124
+ const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
125
+ r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
126
+ const a = Nt(r).textContent, s = document.createRange();
127
+ s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
128
+ const l = Nt(s).textContent;
129
+ return {
130
+ prefix: a.substring(a.length - n),
131
+ suffix: l.substring(0, n)
132
+ };
133
+ }, _e = /^\s*$/, Ue = (t) => _e.test(t.toString()), W = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Ve = (t, e) => {
134
+ const n = (r) => Math.round(r * 10) / 10, o = {
135
+ top: n(t.top),
136
+ bottom: n(t.bottom),
137
+ left: n(t.left),
138
+ right: n(t.right)
139
+ }, i = {
140
+ top: n(e.top),
141
+ bottom: n(e.bottom),
142
+ left: n(e.left),
143
+ right: n(e.right)
144
+ };
145
+ if (Math.abs(o.top - i.top) < 0.5 && Math.abs(o.bottom - i.bottom) < 0.5) {
146
+ if (Math.abs(o.left - i.right) < 0.5 || Math.abs(o.right - i.left) < 0.5)
147
+ return "inline-adjacent";
148
+ if (o.left >= i.left && o.right <= i.right)
149
+ return "inline-is-contained";
150
+ if (o.left <= i.left && o.right >= i.right)
151
+ return "inline-contains";
152
+ } else if (o.top <= i.top && o.bottom >= i.bottom) {
153
+ if (o.left <= i.left && o.right >= i.right)
154
+ return "block-contains";
155
+ } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
156
+ return "block-is-contained";
157
+ }, De = (t, e) => {
158
+ const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
159
+ return new DOMRect(n, i, o - n, r - i);
160
+ }, Ke = (t) => t.reduce((e, n) => {
161
+ if (n.width === 0 || n.height === 0)
162
+ return e;
163
+ let o = [...e], i = !1;
164
+ for (const r of e) {
165
+ const a = Ve(n, r);
166
+ if (a === "inline-adjacent") {
167
+ o = o.map((s) => s === r ? De(n, r) : s), i = !0;
168
+ break;
169
+ } else if (a === "inline-contains") {
170
+ o = o.map((s) => s === r ? n : s), i = !0;
171
+ break;
172
+ } else if (a === "inline-is-contained") {
173
+ i = !0;
174
+ break;
175
+ } else if (a === "block-contains" || a === "block-is-contained") {
176
+ n.width < r.width && (o = o.map((s) => s === r ? n : s)), i = !0;
177
+ break;
178
+ }
179
+ }
180
+ return i ? o : [...o, n];
181
+ }, []), Oo = (t) => ({
182
+ length: t.length,
183
+ item: (e) => t[e],
184
+ [Symbol.iterator]: function* () {
185
+ for (let e = 0; e < this.length; e++)
186
+ yield this.item(e);
187
+ }
188
+ }), Xe = (t, e, n) => {
189
+ const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
190
+ o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
191
+ const r = Nt(o).textContent, a = t.toString(), s = r.length || 0, l = s + a.length;
192
+ return n ? { quote: a, start: s, end: l, range: t, offsetReference: i } : { quote: a, start: s, end: l, range: t };
193
+ }, se = (t, e) => {
194
+ var p, c;
195
+ const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
196
+ e,
197
+ NodeFilter.SHOW_TEXT,
198
+ (f) => {
199
+ var h;
200
+ return (h = f.parentElement) != null && h.closest(j) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
201
+ }
202
+ );
203
+ let a = 0;
204
+ const s = document.createRange();
205
+ let l = r.nextNode();
206
+ l === null && console.error("Could not revive annotation target. Content missing.");
207
+ let u = !i;
208
+ for (; l !== null; ) {
209
+ if (u || (u = i == null ? void 0 : i.contains(l)), u) {
210
+ const f = ((p = l.textContent) == null ? void 0 : p.length) || 0;
211
+ if (a + f > n) {
212
+ s.setStart(l, n - a);
213
+ break;
214
+ }
215
+ a += f;
216
+ }
217
+ l = r.nextNode();
218
+ }
219
+ for (; l !== null; ) {
220
+ const f = ((c = l.textContent) == null ? void 0 : c.length) || 0;
221
+ if (a + f >= o) {
222
+ s.setEnd(l, o - a);
223
+ break;
224
+ }
225
+ a += f, l = r.nextNode();
226
+ }
227
+ return {
228
+ ...t,
229
+ range: s
230
+ };
231
+ }, bt = (t, e) => W(t.selector) ? t : {
232
+ ...t,
233
+ selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : se(n, e))
234
+ }, wt = (t, e) => W(t.target.selector) ? t : { ...t, target: bt(t.target, e) }, Ye = (t, e) => {
235
+ const n = t.cloneRange();
236
+ return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
11
237
  };
12
- function Ee(t) {
238
+ function Pe(t) {
13
239
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
14
240
  }
15
- var It = { exports: {} };
16
- function ie(t, e = 100, n = {}) {
241
+ var _t = { exports: {} };
242
+ function ae(t, e = 100, n = {}) {
17
243
  if (typeof t != "function")
18
244
  throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
19
245
  if (e < 0)
20
246
  throw new RangeError("`wait` must not be negative.");
21
247
  const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
22
248
  let i, r, a, s, l;
23
- function f() {
24
- const p = i, u = r;
25
- return i = void 0, r = void 0, l = t.apply(p, u), l;
249
+ function u() {
250
+ const f = i, h = r;
251
+ return i = void 0, r = void 0, l = t.apply(f, h), l;
26
252
  }
27
- function g() {
28
- const p = Date.now() - s;
29
- p < e && p >= 0 ? a = setTimeout(g, e - p) : (a = void 0, o || (l = f()));
253
+ function p() {
254
+ const f = Date.now() - s;
255
+ f < e && f >= 0 ? a = setTimeout(p, e - f) : (a = void 0, o || (l = u()));
30
256
  }
31
- const c = function(...p) {
257
+ const c = function(...f) {
32
258
  if (i && this !== i)
33
259
  throw new Error("Debounced method called with different contexts.");
34
- i = this, r = p, s = Date.now();
35
- const u = o && !a;
36
- return a || (a = setTimeout(g, e)), u && (l = f()), l;
260
+ i = this, r = f, s = Date.now();
261
+ const h = o && !a;
262
+ return a || (a = setTimeout(p, e)), h && (l = u()), l;
37
263
  };
38
264
  return c.clear = () => {
39
265
  a && (clearTimeout(a), a = void 0);
40
266
  }, c.flush = () => {
41
267
  a && c.trigger();
42
268
  }, c.trigger = () => {
43
- l = f(), c.clear();
269
+ l = u(), c.clear();
44
270
  }, c;
45
271
  }
46
- It.exports.debounce = ie;
47
- It.exports = ie;
48
- var Se = It.exports;
49
- const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
50
- const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, l = i - e;
51
- return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: l };
52
- }, Le = (t) => {
53
- let e = /* @__PURE__ */ new Set();
54
- return (o) => {
55
- const i = o.map((r) => r.id);
56
- (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
57
- };
58
- }, Ut = (t, e, n, o) => {
272
+ _t.exports.debounce = ae;
273
+ _t.exports = ae;
274
+ var $e = _t.exports;
275
+ const je = /* @__PURE__ */ Pe($e), Ut = (t, e = 10, n) => {
276
+ const o = je(t, e, n), i = o.bind(void 0);
277
+ Object.getOwnPropertyNames(o).forEach(
278
+ (a) => Object.defineProperty(i, a, Object.getOwnPropertyDescriptor(o, a))
279
+ );
280
+ const r = Object.getPrototypeOf(o);
281
+ return Object.setPrototypeOf(i, r), i;
282
+ }, He = (t, e) => {
283
+ const { left: n, top: o, right: i, bottom: r } = t;
284
+ return new DOMRect(n - e.left, o - e.top, i - n, r - o);
285
+ }, To = (t, e) => {
286
+ const { left: n, top: o, right: i, bottom: r } = t;
287
+ return new DOMRect(n + e.left, o + e.top, i - n, r - o);
288
+ }, ze = (t) => ({
289
+ ...t,
290
+ type: t.type,
291
+ x: t.x,
292
+ y: t.y,
293
+ clientX: t.clientX,
294
+ clientY: t.clientY,
295
+ offsetX: t.offsetX,
296
+ offsetY: t.offsetY,
297
+ screenX: t.screenX,
298
+ screenY: t.screenY,
299
+ isPrimary: t.isPrimary,
300
+ altKey: t.altKey,
301
+ ctrlKey: t.ctrlKey,
302
+ metaKey: t.metaKey,
303
+ shiftKey: t.shiftKey,
304
+ button: t.button,
305
+ buttons: t.buttons,
306
+ currentTarget: t.currentTarget,
307
+ target: t.target,
308
+ defaultPrevented: t.defaultPrevented,
309
+ detail: t.detail,
310
+ eventPhase: t.eventPhase,
311
+ pointerId: t.pointerId,
312
+ pointerType: t.pointerType,
313
+ timeStamp: t.timeStamp
314
+ }), Fe = (t) => ({
315
+ ...t,
316
+ type: t.type,
317
+ key: t.key,
318
+ code: t.code,
319
+ location: t.location,
320
+ repeat: t.repeat,
321
+ altKey: t.altKey,
322
+ ctrlKey: t.ctrlKey,
323
+ metaKey: t.metaKey,
324
+ shiftKey: t.shiftKey,
325
+ currentTarget: t.currentTarget,
326
+ target: t.target,
327
+ defaultPrevented: t.defaultPrevented,
328
+ detail: t.detail,
329
+ timeStamp: t.timeStamp
330
+ }), Vt = (t, e, n, o) => {
59
331
  const { store: i, selection: r, hover: a } = e;
60
- let s, l, f;
61
- const g = Le(n), c = (O) => {
62
- const { x: B, y: m } = t.getBoundingClientRect(), w = i.getAt(O.clientX - B, O.clientY - m, l);
332
+ let s, l, u;
333
+ const p = Le(n), c = (O) => {
334
+ const { x: R, y } = t.getBoundingClientRect(), w = i.getAt(O.clientX - R, O.clientY - y, l);
63
335
  w ? a.current !== w.id && (t.classList.add("hovered"), a.set(w.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
64
336
  };
65
337
  t.addEventListener("pointermove", c);
66
- const p = (O = !1) => {
67
- f && f.clear();
68
- const B = Ce(t), { minX: m, minY: w, maxX: E, maxY: L } = B, T = l ? i.getIntersecting(m, w, E, L).filter(({ annotation: X }) => l(X)) : i.getIntersecting(m, w, E, L), N = r.selected.map(({ id: X }) => X), K = T.map(({ annotation: X, rects: lt }) => {
69
- const xe = N.includes(X.id), ve = X.id === a.current;
70
- return { annotation: X, rects: lt, state: { selected: xe, hover: ve } };
338
+ const f = (O = !1) => {
339
+ u && u.clear();
340
+ const R = Ce(t), { minX: y, minY: w, maxX: v, maxY: L } = R, M = l ? i.getIntersecting(y, w, v, L).filter(({ annotation: X }) => l(X)) : i.getIntersecting(y, w, v, L), B = r.selected.map(({ id: X }) => X), K = M.map(({ annotation: X, rects: lt }) => {
341
+ const Ae = B.includes(X.id), Ee = X.id === a.current;
342
+ return { annotation: X, rects: lt, state: { selected: Ae, hover: Ee } };
71
343
  });
72
- o.redraw(K, B, s, f, O), setTimeout(() => g(T.map(({ annotation: X }) => X)), 1);
73
- }, u = (O) => {
74
- f = O, p();
75
- }, v = (O) => {
76
- s = O, p();
77
- }, b = (O) => {
78
- l = O, p(!1);
79
- }, x = () => p();
80
- i.observe(x);
81
- const h = r.subscribe(() => p()), d = () => p(!0);
344
+ o.redraw(K, R, s, u, O), setTimeout(() => p(M.map(({ annotation: X }) => X)), 1);
345
+ }, h = (O) => {
346
+ u = O, f();
347
+ }, x = (O) => {
348
+ s = O, f();
349
+ }, A = (O) => {
350
+ l = O, f(!1);
351
+ }, b = () => f();
352
+ i.observe(b);
353
+ const g = r.subscribe(() => f()), d = () => f(!0);
82
354
  document.addEventListener("scroll", d, { capture: !0, passive: !0 });
83
- const y = _t(() => {
84
- i.recalculatePositions(), f && f.reset(), p();
85
- }, 10);
86
- window.addEventListener("resize", y);
87
- const A = new ResizeObserver(y);
88
- A.observe(t);
355
+ const m = Ut(() => {
356
+ i.recalculatePositions(), u == null || u.reset(), f();
357
+ });
358
+ window.addEventListener("resize", m);
359
+ const E = new ResizeObserver(m);
360
+ E.observe(t);
89
361
  const C = { attributes: !0, childList: !0, subtree: !0 }, S = new MutationObserver((O) => {
90
- O.every((m) => m.target === t || t.contains(m.target)) || p(!0);
362
+ O.every((y) => y.target === t || t.contains(y.target)) || f(!0);
91
363
  });
92
364
  return S.observe(document.body, C), {
93
365
  destroy: () => {
94
- t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(x), h(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), A.disconnect(), S.disconnect();
366
+ t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(b), g(), document.removeEventListener("scroll", d), m.clear(), window.removeEventListener("resize", m), E.disconnect(), S.disconnect();
95
367
  },
96
- redraw: p,
97
- setStyle: v,
98
- setFilter: b,
99
- setPainter: u,
368
+ redraw: f,
369
+ setStyle: x,
370
+ setFilter: A,
371
+ setPainter: h,
100
372
  setVisible: o.setVisible
101
373
  };
102
- }, Oe = () => {
374
+ }, We = () => {
103
375
  const t = document.createElement("canvas");
104
376
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
105
- }, Te = (t, e) => {
377
+ }, qe = (t, e) => {
106
378
  t.width = window.innerWidth, t.height = window.innerHeight;
107
- }, Re = (t) => {
379
+ }, Ge = (t) => {
108
380
  t.classList.add("r6o-annotatable");
109
- const e = Oe(), n = e.getContext("2d");
381
+ const e = We(), n = e.getContext("2d");
110
382
  document.body.appendChild(e);
111
- const o = (s, l, f, g) => requestAnimationFrame(() => {
112
- const { width: c, height: p } = e;
113
- n.clearRect(-0.5, -0.5, c + 1, p + 1), g && g.clear();
114
- const { top: u, left: v } = l;
115
- [...s].sort((x, h) => {
116
- const { annotation: { target: { created: d } } } = x, { annotation: { target: { created: y } } } = h;
117
- return d.getTime() - y.getTime();
118
- }).forEach((x) => {
119
- var A;
120
- const h = f ? typeof f == "function" ? f(x.annotation, x.state) : f : (A = x.state) != null && A.selected ? mt : q, d = g && g.paint(x, l) || h, y = x.rects.map(({ x: C, y: S, width: R, height: O }) => ({
121
- x: C + v,
122
- y: S + u,
123
- width: R,
383
+ const o = (s, l, u, p) => requestAnimationFrame(() => {
384
+ const { width: c, height: f } = e;
385
+ n.clearRect(-0.5, -0.5, c + 1, f + 1), p && p.clear();
386
+ const { top: h, left: x } = l;
387
+ [...s].sort((b, g) => {
388
+ const { annotation: { target: { created: d } } } = b, { annotation: { target: { created: m } } } = g;
389
+ return d.getTime() - m.getTime();
390
+ }).forEach((b) => {
391
+ var E;
392
+ const g = u ? typeof u == "function" ? u(b.annotation, b.state) : u : (E = b.state) != null && E.selected ? yt : q, d = p && p.paint(b, l) || g, m = b.rects.map(({ x: C, y: S, width: T, height: O }) => ({
393
+ x: C + x,
394
+ y: S + h,
395
+ width: T,
124
396
  height: O
125
397
  }));
126
- if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, y.forEach(
127
- ({ x: C, y: S, width: R, height: O }) => n.fillRect(C, S, R, O)
398
+ if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, m.forEach(
399
+ ({ x: C, y: S, width: T, height: O }) => n.fillRect(C, S, T, O)
128
400
  ), d.underlineColor) {
129
401
  n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
130
402
  const C = d.underlineOffset ?? 0;
131
- y.forEach(({ x: S, y: R, width: O, height: B }) => {
132
- n.beginPath(), n.moveTo(S, R + B + C), n.lineTo(S + O, R + B + C), n.stroke();
403
+ m.forEach(({ x: S, y: T, width: O, height: R }) => {
404
+ n.beginPath(), n.moveTo(S, T + R + C), n.lineTo(S + O, T + R + C), n.stroke();
133
405
  });
134
406
  }
135
407
  });
136
- }), i = _t(() => Te(e), 10);
408
+ }), i = Ut(() => qe(e));
137
409
  return window.addEventListener("resize", i), {
138
410
  destroy: () => {
139
411
  e.remove(), i.clear(), window.removeEventListener("resize", i);
@@ -143,123 +415,123 @@ const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
143
415
  },
144
416
  redraw: o
145
417
  };
146
- }, Be = (t, e, n) => Ut(t, e, n, Re(t));
147
- var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
418
+ }, Qe = (t, e, n) => Vt(t, e, n, Ge(t));
419
+ var Je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
148
420
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
149
421
  }, _ = function(t, e, n) {
150
422
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
151
423
  }, Y = function(t, e, n) {
152
424
  return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
153
- }, re = function(t) {
425
+ }, ce = function(t) {
154
426
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
155
- }, Kt = function(t) {
427
+ }, Pt = function(t) {
156
428
  return { r: Y(t.r, 0, 255), g: Y(t.g, 0, 255), b: Y(t.b, 0, 255), a: Y(t.a) };
157
- }, bt = function(t) {
429
+ }, vt = function(t) {
158
430
  return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
159
- }, ke = /^#([0-9a-f]{3,8})$/i, dt = function(t) {
431
+ }, Ze = /^#([0-9a-f]{3,8})$/i, dt = function(t) {
160
432
  var e = t.toString(16);
161
433
  return e.length < 2 ? "0" + e : e;
162
- }, se = function(t) {
434
+ }, le = function(t) {
163
435
  var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), a = r - Math.min(e, n, o), s = a ? r === e ? (n - o) / a : r === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
164
436
  return { h: 60 * (s < 0 ? s + 6 : s), s: r ? a / r * 100 : 0, v: r / 255 * 100, a: i };
165
- }, ae = function(t) {
437
+ }, de = function(t) {
166
438
  var e = t.h, n = t.s, o = t.v, i = t.a;
167
439
  e = e / 360 * 6, n /= 100, o /= 100;
168
- var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), l = o * (1 - (1 - e + r) * n), f = r % 6;
169
- return { r: 255 * [o, s, a, a, l, o][f], g: 255 * [l, o, o, s, a, a][f], b: 255 * [a, a, l, o, o, s][f], a: i };
170
- }, Yt = function(t) {
171
- return { h: re(t.h), s: Y(t.s, 0, 100), l: Y(t.l, 0, 100), a: Y(t.a) };
172
- }, Xt = function(t) {
440
+ var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), l = o * (1 - (1 - e + r) * n), u = r % 6;
441
+ return { r: 255 * [o, s, a, a, l, o][u], g: 255 * [l, o, o, s, a, a][u], b: 255 * [a, a, l, o, o, s][u], a: i };
442
+ }, $t = function(t) {
443
+ return { h: ce(t.h), s: Y(t.s, 0, 100), l: Y(t.l, 0, 100), a: Y(t.a) };
444
+ }, jt = function(t) {
173
445
  return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
174
- }, Pt = function(t) {
175
- return ae((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 }));
446
+ }, Ht = function(t) {
447
+ return de((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 }));
176
448
  var e, n, o;
177
449
  }, it = function(t) {
178
- return { h: (e = se(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 };
450
+ return { h: (e = le(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 };
179
451
  var e, n, o, i;
180
- }, Ne = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ie = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, _e = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ue = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, $t = { string: [[function(t) {
181
- var e = ke.exec(t);
452
+ }, tn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, en = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, nn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, on = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, zt = { string: [[function(t) {
453
+ var e = Ze.exec(t);
182
454
  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;
183
455
  }, "hex"], [function(t) {
184
- var e = _e.exec(t) || Ue.exec(t);
185
- return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Kt({ 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;
456
+ var e = nn.exec(t) || on.exec(t);
457
+ return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Pt({ 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;
186
458
  }, "rgb"], [function(t) {
187
- var e = Ne.exec(t) || Ie.exec(t);
459
+ var e = tn.exec(t) || en.exec(t);
188
460
  if (!e) return null;
189
- var n, o, i = Yt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Me[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
190
- return Pt(i);
461
+ var n, o, i = $t({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Je[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
462
+ return Ht(i);
191
463
  }, "hsl"]], object: [[function(t) {
192
464
  var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
193
- return z(e) && z(n) && z(o) ? Kt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
465
+ return z(e) && z(n) && z(o) ? Pt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
194
466
  }, "rgb"], [function(t) {
195
467
  var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
196
468
  if (!z(e) || !z(n) || !z(o)) return null;
197
- var a = Yt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
198
- return Pt(a);
469
+ var a = $t({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
470
+ return Ht(a);
199
471
  }, "hsl"], [function(t) {
200
472
  var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
201
473
  if (!z(e) || !z(n) || !z(o)) return null;
202
474
  var a = function(s) {
203
- return { h: re(s.h), s: Y(s.s, 0, 100), v: Y(s.v, 0, 100), a: Y(s.a) };
475
+ return { h: ce(s.h), s: Y(s.s, 0, 100), v: Y(s.v, 0, 100), a: Y(s.a) };
204
476
  }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
205
- return ae(a);
206
- }, "hsv"]] }, Ht = function(t, e) {
477
+ return de(a);
478
+ }, "hsv"]] }, Ft = function(t, e) {
207
479
  for (var n = 0; n < e.length; n++) {
208
480
  var o = e[n][0](t);
209
481
  if (o) return [o, e[n][1]];
210
482
  }
211
483
  return [null, void 0];
212
- }, Ve = function(t) {
213
- return typeof t == "string" ? Ht(t.trim(), $t.string) : typeof t == "object" && t !== null ? Ht(t, $t.object) : [null, void 0];
214
- }, wt = function(t, e) {
484
+ }, rn = function(t) {
485
+ return typeof t == "string" ? Ft(t.trim(), zt.string) : typeof t == "object" && t !== null ? Ft(t, zt.object) : [null, void 0];
486
+ }, xt = function(t, e) {
215
487
  var n = it(t);
216
488
  return { h: n.h, s: Y(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
217
- }, xt = function(t) {
489
+ }, At = function(t) {
218
490
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
219
- }, jt = function(t, e) {
491
+ }, Wt = function(t, e) {
220
492
  var n = it(t);
221
493
  return { h: n.h, s: n.s, l: Y(n.l + 100 * e, 0, 100), a: n.a };
222
- }, zt = function() {
494
+ }, qt = function() {
223
495
  function t(e) {
224
- this.parsed = Ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
496
+ this.parsed = rn(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
225
497
  }
226
498
  return t.prototype.isValid = function() {
227
499
  return this.parsed !== null;
228
500
  }, t.prototype.brightness = function() {
229
- return _(xt(this.rgba), 2);
501
+ return _(At(this.rgba), 2);
230
502
  }, t.prototype.isDark = function() {
231
- return xt(this.rgba) < 0.5;
503
+ return At(this.rgba) < 0.5;
232
504
  }, t.prototype.isLight = function() {
233
- return xt(this.rgba) >= 0.5;
505
+ return At(this.rgba) >= 0.5;
234
506
  }, t.prototype.toHex = function() {
235
- return e = bt(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? dt(_(255 * r)) : "", "#" + dt(n) + dt(o) + dt(i) + a;
507
+ return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? dt(_(255 * r)) : "", "#" + dt(n) + dt(o) + dt(i) + a;
236
508
  var e, n, o, i, r, a;
237
509
  }, t.prototype.toRgb = function() {
238
- return bt(this.rgba);
510
+ return vt(this.rgba);
239
511
  }, t.prototype.toRgbString = function() {
240
- return e = bt(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
512
+ return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
241
513
  var e, n, o, i, r;
242
514
  }, t.prototype.toHsl = function() {
243
- return Xt(it(this.rgba));
515
+ return jt(it(this.rgba));
244
516
  }, t.prototype.toHslString = function() {
245
- return e = Xt(it(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
517
+ return e = jt(it(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
246
518
  var e, n, o, i, r;
247
519
  }, t.prototype.toHsv = function() {
248
- return e = se(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
520
+ return e = le(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
249
521
  var e;
250
522
  }, t.prototype.invert = function() {
251
523
  return P({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
252
524
  var e;
253
525
  }, t.prototype.saturate = function(e) {
254
- return e === void 0 && (e = 0.1), P(wt(this.rgba, e));
526
+ return e === void 0 && (e = 0.1), P(xt(this.rgba, e));
255
527
  }, t.prototype.desaturate = function(e) {
256
- return e === void 0 && (e = 0.1), P(wt(this.rgba, -e));
528
+ return e === void 0 && (e = 0.1), P(xt(this.rgba, -e));
257
529
  }, t.prototype.grayscale = function() {
258
- return P(wt(this.rgba, -1));
530
+ return P(xt(this.rgba, -1));
259
531
  }, t.prototype.lighten = function(e) {
260
- return e === void 0 && (e = 0.1), P(jt(this.rgba, e));
532
+ return e === void 0 && (e = 0.1), P(Wt(this.rgba, e));
261
533
  }, t.prototype.darken = function(e) {
262
- return e === void 0 && (e = 0.1), P(jt(this.rgba, -e));
534
+ return e === void 0 && (e = 0.1), P(Wt(this.rgba, -e));
263
535
  }, t.prototype.rotate = function(e) {
264
536
  return e === void 0 && (e = 15), this.hue(this.hue() + e);
265
537
  }, t.prototype.alpha = function(e) {
@@ -272,15 +544,15 @@ var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
272
544
  return this.toHex() === P(e).toHex();
273
545
  }, t;
274
546
  }(), P = function(t) {
275
- return t instanceof zt ? t : new zt(t);
547
+ return t instanceof qt ? t : new qt(t);
276
548
  };
277
- const De = (t) => [
549
+ const sn = (t) => [
278
550
  `background-color:${P((t == null ? void 0 : t.fill) || q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? q.fillOpacity : t.fillOpacity).toHex()}`,
279
551
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
280
552
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
281
553
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
282
554
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
283
- ].filter(Boolean).join(";"), Ke = () => {
555
+ ].filter(Boolean).join(";"), an = () => {
284
556
  const t = document.createElement("style");
285
557
  document.getElementsByTagName("head")[0].appendChild(t);
286
558
  let e = /* @__PURE__ */ new Set();
@@ -293,23 +565,23 @@ const De = (t) => [
293
565
  },
294
566
  redraw: (r, a, s, l) => {
295
567
  l && l.clear();
296
- const f = new Set(r.map((c) => c.annotation.id));
297
- Array.from(e).filter((c) => !f.has(c));
298
- const g = r.map((c) => {
299
- var v;
300
- const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (v = c.state) != null && v.selected ? mt : q, u = l && l.paint(c, a) || p;
301
- return `::highlight(_${c.annotation.id}) { ${De(u)} }`;
568
+ const u = new Set(r.map((c) => c.annotation.id));
569
+ Array.from(e).filter((c) => !u.has(c));
570
+ const p = r.map((c) => {
571
+ var x;
572
+ const f = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? yt : q, h = l && l.paint(c, a) || f;
573
+ return `::highlight(_${c.annotation.id}) { ${sn(h)} }`;
302
574
  });
303
- t.innerHTML = g.join(`
575
+ t.innerHTML = p.join(`
304
576
  `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
305
- const p = c.target.selector.map((v) => v.range), u = new Highlight(...p);
306
- CSS.highlights.set(`_${c.id}`, u);
307
- }), e = f;
577
+ const f = c.target.selector.map((x) => x.range), h = new Highlight(...f);
578
+ CSS.highlights.set(`_${c.id}`, h);
579
+ }), e = u;
308
580
  }
309
581
  };
310
- }, Ye = (t, e, n) => Ut(t, e, n, Ke());
311
- var Ft = Object.prototype.hasOwnProperty;
312
- function Mt(t, e) {
582
+ }, cn = (t, e, n) => Vt(t, e, n, an());
583
+ var Gt = Object.prototype.hasOwnProperty;
584
+ function kt(t, e) {
313
585
  var n, o;
314
586
  if (t === e) return !0;
315
587
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -317,22 +589,22 @@ function Mt(t, e) {
317
589
  if (n === RegExp) return t.toString() === e.toString();
318
590
  if (n === Array) {
319
591
  if ((o = t.length) === e.length)
320
- for (; o-- && Mt(t[o], e[o]); ) ;
592
+ for (; o-- && kt(t[o], e[o]); ) ;
321
593
  return o === -1;
322
594
  }
323
595
  if (!n || typeof t == "object") {
324
596
  o = 0;
325
597
  for (n in t)
326
- if (Ft.call(t, n) && ++o && !Ft.call(e, n) || !(n in e) || !Mt(t[n], e[n])) return !1;
598
+ if (Gt.call(t, n) && ++o && !Gt.call(e, n) || !(n in e) || !kt(t[n], e[n])) return !1;
327
599
  return Object.keys(e).length === o;
328
600
  }
329
601
  }
330
602
  return t !== t && e !== e;
331
603
  }
332
- const Xe = (t, e) => {
604
+ const ln = (t, e) => {
333
605
  const n = (r, a) => r.x <= a.x + a.width && r.x + r.width >= a.x && r.y <= a.y + a.height && r.y + r.height >= a.y, o = (r) => r.rects.reduce((a, s) => a + s.width, 0), i = e.filter(({ rects: r }) => r.some((a) => n(t, a)));
334
606
  return i.sort((r, a) => o(a) - o(r)), i.findIndex((r) => r.rects.includes(t));
335
- }, Pe = (t) => {
607
+ }, dn = (t) => {
336
608
  t.classList.add("r6o-annotatable");
337
609
  const e = document.createElement("div");
338
610
  e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
@@ -341,18 +613,18 @@ const Xe = (t, e) => {
341
613
  destroy: () => {
342
614
  e.remove();
343
615
  },
344
- redraw: (a, s, l, f, g) => {
345
- const p = !(Mt(n, a) && g);
346
- if (!f && !p) return;
347
- p && (e.innerHTML = ""), [...a].sort((v, b) => {
348
- const { annotation: { target: { created: x } } } = v, { annotation: { target: { created: h } } } = b;
349
- return x.getTime() - h.getTime();
350
- }).forEach((v) => {
351
- v.rects.map((b) => {
352
- const x = Xe(b, a), h = Ae(v, s, l, f, x);
353
- if (p) {
616
+ redraw: (a, s, l, u, p) => {
617
+ const f = !(kt(n, a) && p);
618
+ if (!u && !f) return;
619
+ f && (e.innerHTML = ""), [...a].sort((x, A) => {
620
+ const { annotation: { target: { created: b } } } = x, { annotation: { target: { created: g } } } = A;
621
+ return b.getTime() - g.getTime();
622
+ }).forEach((x) => {
623
+ x.rects.map((A) => {
624
+ const b = ln(A, a), g = Se(x, s, l, u, b);
625
+ if (f) {
354
626
  const d = document.createElement("span");
355
- d.className = "r6o-annotation", d.dataset.annotation = v.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = P((h == null ? void 0 : h.fill) || q.fill).alpha((h == null ? void 0 : h.fillOpacity) === void 0 ? q.fillOpacity : h.fillOpacity).toHex(), h.underlineStyle && (d.style.borderStyle = h.underlineStyle), h.underlineColor && (d.style.borderColor = h.underlineColor), h.underlineThickness && (d.style.borderBottomWidth = `${h.underlineThickness}px`), h.underlineOffset && (d.style.paddingBottom = `${h.underlineOffset}px`), e.appendChild(d);
627
+ d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${A.x}px`, d.style.top = `${A.y}px`, d.style.width = `${A.width}px`, d.style.height = `${A.height}px`, d.style.backgroundColor = P((g == null ? void 0 : g.fill) || q.fill).alpha((g == null ? void 0 : g.fillOpacity) === void 0 ? q.fillOpacity : g.fillOpacity).toHex(), g.underlineStyle && (d.style.borderStyle = g.underlineStyle), g.underlineColor && (d.style.borderColor = g.underlineColor), g.underlineThickness && (d.style.borderBottomWidth = `${g.underlineThickness}px`), g.underlineOffset && (d.style.paddingBottom = `${g.underlineOffset}px`), e.appendChild(d);
356
628
  }
357
629
  });
358
630
  }), n = a;
@@ -361,32 +633,32 @@ const Xe = (t, e) => {
361
633
  a ? e.classList.remove("hidden") : e.classList.add("hidden");
362
634
  }
363
635
  };
364
- }, $e = (t, e, n) => Ut(t, e, n, Pe(t));
636
+ }, un = (t, e, n) => Vt(t, e, n, dn(t));
365
637
  var U = [];
366
- for (var vt = 0; vt < 256; ++vt)
367
- U.push((vt + 256).toString(16).slice(1));
368
- function He(t, e = 0) {
638
+ for (var Et = 0; Et < 256; ++Et)
639
+ U.push((Et + 256).toString(16).slice(1));
640
+ function fn(t, e = 0) {
369
641
  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();
370
642
  }
371
- var ut, je = new Uint8Array(16);
372
- function ze() {
643
+ var ut, hn = new Uint8Array(16);
644
+ function gn() {
373
645
  if (!ut && (ut = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ut))
374
646
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
375
- return ut(je);
647
+ return ut(hn);
376
648
  }
377
- var Fe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
378
- const Wt = {
379
- randomUUID: Fe
649
+ var pn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
650
+ const Qt = {
651
+ randomUUID: pn
380
652
  };
381
- function ce(t, e, n) {
382
- if (Wt.randomUUID && !e && !t)
383
- return Wt.randomUUID();
653
+ function ue(t, e, n) {
654
+ if (Qt.randomUUID && !e && !t)
655
+ return Qt.randomUUID();
384
656
  t = t || {};
385
- var o = t.random || (t.rng || ze)();
386
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, He(o);
657
+ var o = t.random || (t.rng || gn)();
658
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, fn(o);
387
659
  }
388
- var qt = Object.prototype.hasOwnProperty;
389
- function Z(t, e) {
660
+ var Jt = Object.prototype.hasOwnProperty;
661
+ function G(t, e) {
390
662
  var n, o;
391
663
  if (t === e) return !0;
392
664
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -394,52 +666,52 @@ function Z(t, e) {
394
666
  if (n === RegExp) return t.toString() === e.toString();
395
667
  if (n === Array) {
396
668
  if ((o = t.length) === e.length)
397
- for (; o-- && Z(t[o], e[o]); ) ;
669
+ for (; o-- && G(t[o], e[o]); ) ;
398
670
  return o === -1;
399
671
  }
400
672
  if (!n || typeof t == "object") {
401
673
  o = 0;
402
674
  for (n in t)
403
- if (qt.call(t, n) && ++o && !qt.call(e, n) || !(n in e) || !Z(t[n], e[n])) return !1;
675
+ if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !G(t[n], e[n])) return !1;
404
676
  return Object.keys(e).length === o;
405
677
  }
406
678
  }
407
679
  return t !== t && e !== e;
408
680
  }
409
- function At() {
681
+ function St() {
410
682
  }
411
- function We(t, e) {
683
+ function mn(t, e) {
412
684
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
413
685
  }
414
- const G = [];
415
- function Vt(t, e = At) {
686
+ const Q = [];
687
+ function Dt(t, e = St) {
416
688
  let n;
417
689
  const o = /* @__PURE__ */ new Set();
418
690
  function i(s) {
419
- if (We(t, s) && (t = s, n)) {
420
- const l = !G.length;
421
- for (const f of o)
422
- f[1](), G.push(f, t);
691
+ if (mn(t, s) && (t = s, n)) {
692
+ const l = !Q.length;
693
+ for (const u of o)
694
+ u[1](), Q.push(u, t);
423
695
  if (l) {
424
- for (let f = 0; f < G.length; f += 2)
425
- G[f][0](G[f + 1]);
426
- G.length = 0;
696
+ for (let u = 0; u < Q.length; u += 2)
697
+ Q[u][0](Q[u + 1]);
698
+ Q.length = 0;
427
699
  }
428
700
  }
429
701
  }
430
702
  function r(s) {
431
703
  i(s(t));
432
704
  }
433
- function a(s, l = At) {
434
- const f = [s, l];
435
- return o.add(f), o.size === 1 && (n = e(i, r) || At), s(t), () => {
436
- o.delete(f), o.size === 0 && n && (n(), n = null);
705
+ function a(s, l = St) {
706
+ const u = [s, l];
707
+ return o.add(u), o.size === 1 && (n = e(i, r) || St), s(t), () => {
708
+ o.delete(u), o.size === 0 && n && (n(), n = null);
437
709
  };
438
710
  }
439
711
  return { set: i, update: r, subscribe: a };
440
712
  }
441
- const qe = (t) => {
442
- const { subscribe: e, set: n } = Vt();
713
+ const yn = (t) => {
714
+ const { subscribe: e, set: n } = Dt();
443
715
  let o;
444
716
  return e((i) => o = i), t.observe(({ changes: i }) => {
445
717
  if (o) {
@@ -455,118 +727,123 @@ const qe = (t) => {
455
727
  set: n
456
728
  };
457
729
  };
458
- var Ge = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Ge || {});
459
- const Et = { selected: [] }, Qe = (t, e = "EDIT") => {
460
- const { subscribe: n, set: o } = Vt(Et);
461
- let i = e, r = Et;
462
- n((u) => r = u);
463
- const a = () => o(Et), s = () => {
464
- var u;
465
- return ((u = r.selected) == null ? void 0 : u.length) === 0;
466
- }, l = (u) => {
467
- if (s())
730
+ var bn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(bn || {});
731
+ const ft = { selected: [] }, wn = (t) => {
732
+ const { subscribe: e, set: n } = Dt(ft);
733
+ let o, i = ft;
734
+ e((f) => i = f);
735
+ const r = () => {
736
+ G(i, ft) || n(ft);
737
+ }, a = () => {
738
+ var f;
739
+ return ((f = i.selected) == null ? void 0 : f.length) === 0;
740
+ }, s = (f) => {
741
+ if (a())
468
742
  return !1;
469
- const v = typeof u == "string" ? u : u.id;
470
- return r.selected.some((b) => b.id === v);
471
- }, f = (u, v) => {
472
- const b = t.getAnnotation(u);
473
- if (!b) {
474
- console.warn("Invalid selection: " + u);
743
+ const h = typeof f == "string" ? f : f.id;
744
+ return i.selected.some((x) => x.id === h);
745
+ }, l = (f, h) => {
746
+ const x = t.getAnnotation(f);
747
+ if (!x) {
748
+ console.warn("Invalid selection: " + f);
475
749
  return;
476
750
  }
477
- switch (Gt(b, i)) {
751
+ switch (Zt(x, o)) {
478
752
  case "EDIT":
479
- o({ selected: [{ id: u, editable: !0 }], event: v });
753
+ n({ selected: [{ id: f, editable: !0 }], event: h });
480
754
  break;
481
755
  case "SELECT":
482
- o({ selected: [{ id: u }], event: v });
756
+ n({ selected: [{ id: f }], event: h });
483
757
  break;
484
758
  default:
485
- o({ selected: [], event: v });
759
+ n({ selected: [], event: h });
486
760
  }
487
- }, g = (u, v) => {
488
- const b = Array.isArray(u) ? u : [u], x = b.map((h) => t.getAnnotation(h)).filter((h) => !!h);
489
- o({
490
- selected: x.map((h) => {
491
- const d = v === void 0 ? Gt(h, i) === "EDIT" : v;
492
- return { id: h.id, editable: d };
761
+ }, u = (f, h) => {
762
+ const x = Array.isArray(f) ? f : [f], A = x.map((b) => t.getAnnotation(b)).filter((b) => !!b);
763
+ n({
764
+ selected: A.map((b) => {
765
+ const g = h === void 0 ? Zt(b, o) === "EDIT" : h;
766
+ return { id: b.id, editable: g };
493
767
  })
494
- }), x.length !== b.length && console.warn("Invalid selection", u);
495
- }, c = (u) => {
496
- if (s())
768
+ }), A.length !== x.length && console.warn("Invalid selection", f);
769
+ }, p = (f) => {
770
+ if (a())
497
771
  return !1;
498
- const { selected: v } = r;
499
- v.some(({ id: b }) => u.includes(b)) && o({ selected: v.filter(({ id: b }) => !u.includes(b)) });
500
- }, p = (u) => i = u;
772
+ const { selected: h } = i;
773
+ h.some(({ id: x }) => f.includes(x)) && n({ selected: h.filter(({ id: x }) => !f.includes(x)) });
774
+ }, c = (f) => o = f;
501
775
  return t.observe(
502
- ({ changes: u }) => c((u.deleted || []).map((v) => v.id))
776
+ ({ changes: f }) => p((f.deleted || []).map((h) => h.id))
503
777
  ), {
504
778
  get event() {
505
- return r ? r.event : null;
779
+ return i ? i.event : null;
506
780
  },
507
781
  get selected() {
508
- return r ? [...r.selected] : null;
782
+ return i ? [...i.selected] : null;
509
783
  },
510
- clear: a,
511
- isEmpty: s,
512
- isSelected: l,
513
- setSelected: g,
514
- setUserSelectAction: p,
515
- subscribe: n,
516
- userSelect: f
784
+ get userSelectAction() {
785
+ return o;
786
+ },
787
+ clear: r,
788
+ isEmpty: a,
789
+ isSelected: s,
790
+ setSelected: u,
791
+ setUserSelectAction: c,
792
+ subscribe: e,
793
+ userSelect: l
517
794
  };
518
- }, Gt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
795
+ }, Zt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
519
796
  var V = [];
520
- for (var St = 0; St < 256; ++St)
521
- V.push((St + 256).toString(16).slice(1));
522
- function Je(t, e = 0) {
797
+ for (var Ct = 0; Ct < 256; ++Ct)
798
+ V.push((Ct + 256).toString(16).slice(1));
799
+ function vn(t, e = 0) {
523
800
  return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
524
801
  }
525
- var ft, Ze = new Uint8Array(16);
526
- function tn() {
527
- if (!ft && (ft = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ft))
802
+ var ht, xn = new Uint8Array(16);
803
+ function An() {
804
+ if (!ht && (ht = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ht))
528
805
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
529
- return ft(Ze);
806
+ return ht(xn);
530
807
  }
531
- var en = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
532
- const Qt = {
533
- randomUUID: en
808
+ var En = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
809
+ const te = {
810
+ randomUUID: En
534
811
  };
535
- function nn(t, e, n) {
536
- if (Qt.randomUUID && !e && !t)
537
- return Qt.randomUUID();
812
+ function fe(t, e, n) {
813
+ if (te.randomUUID && !e && !t)
814
+ return te.randomUUID();
538
815
  t = t || {};
539
- var o = t.random || (t.rng || tn)();
540
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Je(o);
816
+ var o = t.random || (t.rng || An)();
817
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, vn(o);
541
818
  }
542
- const Eo = (t, e, n, o) => ({
543
- id: nn(),
819
+ const Ro = (t, e, n, o) => ({
820
+ id: fe(),
544
821
  annotation: typeof t == "string" ? t : t.id,
545
822
  created: n || /* @__PURE__ */ new Date(),
546
823
  creator: o,
547
824
  ...e
548
- }), on = (t, e) => {
825
+ }), Sn = (t, e) => {
549
826
  const n = new Set(t.bodies.map((o) => o.id));
550
827
  return e.bodies.filter((o) => !n.has(o.id));
551
- }, rn = (t, e) => {
828
+ }, Cn = (t, e) => {
552
829
  const n = new Set(e.bodies.map((o) => o.id));
553
830
  return t.bodies.filter((o) => !n.has(o.id));
554
- }, sn = (t, e) => e.bodies.map((n) => {
831
+ }, Ln = (t, e) => e.bodies.map((n) => {
555
832
  const o = t.bodies.find((i) => i.id === n.id);
556
- return { newBody: n, oldBody: o && !Z(o, n) ? o : void 0 };
557
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), an = (t, e) => !Z(t.target, e.target), le = (t, e) => {
558
- const n = on(t, e), o = rn(t, e), i = sn(t, e);
833
+ return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
834
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), On = (t, e) => !G(t.target, e.target), he = (t, e) => {
835
+ const n = Sn(t, e), o = Cn(t, e), i = Ln(t, e);
559
836
  return {
560
837
  oldValue: t,
561
838
  newValue: e,
562
839
  bodiesCreated: n.length > 0 ? n : void 0,
563
840
  bodiesDeleted: o.length > 0 ? o : void 0,
564
841
  bodiesUpdated: i.length > 0 ? i : void 0,
565
- targetUpdated: an(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
842
+ targetUpdated: On(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
566
843
  };
567
844
  };
568
- var M = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(M || {});
569
- const cn = (t, e) => {
845
+ var N = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(N || {});
846
+ const Tn = (t, e) => {
570
847
  var n, o;
571
848
  const { changes: i, origin: r } = e;
572
849
  if (!(!t.options.origin || t.options.origin === r))
@@ -574,8 +851,8 @@ const cn = (t, e) => {
574
851
  if (t.options.ignore) {
575
852
  const { ignore: a } = t.options, s = (l) => l && l.length > 0;
576
853
  if (!(s(i.created) || s(i.deleted))) {
577
- const l = (n = i.updated) == null ? void 0 : n.some((g) => s(g.bodiesCreated) || s(g.bodiesDeleted) || s(g.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((g) => g.targetUpdated);
578
- if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
854
+ const l = (n = i.updated) == null ? void 0 : n.some((p) => s(p.bodiesCreated) || s(p.bodiesDeleted) || s(p.bodiesUpdated)), u = (o = i.updated) == null ? void 0 : o.some((p) => p.targetUpdated);
855
+ if (a === "BODY_ONLY" && l && !u || a === "TARGET_ONLY" && u && !l)
579
856
  return !1;
580
857
  }
581
858
  }
@@ -588,32 +865,46 @@ const cn = (t, e) => {
588
865
  return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => a.has(s));
589
866
  } else
590
867
  return !0;
591
- }, ln = (t, e) => {
868
+ }, Rn = (t, e) => {
592
869
  const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), r = new Set((e.deleted || []).map((c) => c.id)), a = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), s = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), l = [
593
- ...(t.created || []).filter((c) => !r.has(c.id)).map((c) => a.has(c.id) ? e.updated.find(({ oldValue: p }) => p.id === c.id).newValue : c),
870
+ ...(t.created || []).filter((c) => !r.has(c.id)).map((c) => a.has(c.id) ? e.updated.find(({ oldValue: f }) => f.id === c.id).newValue : c),
594
871
  ...e.created || []
595
- ], f = [
872
+ ], u = [
596
873
  ...(t.deleted || []).filter((c) => !i.has(c.id)),
597
874
  ...(e.deleted || []).filter((c) => !n.has(c.id))
598
- ], g = [
875
+ ], p = [
599
876
  ...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
600
- const { oldValue: p, newValue: u } = c;
601
- if (a.has(u.id)) {
602
- const v = e.updated.find((b) => b.oldValue.id === u.id).newValue;
603
- return le(p, v);
877
+ const { oldValue: f, newValue: h } = c;
878
+ if (a.has(h.id)) {
879
+ const x = e.updated.find((A) => A.oldValue.id === h.id).newValue;
880
+ return he(f, x);
604
881
  } else
605
882
  return c;
606
883
  }),
607
884
  ...(e.updated || []).filter(({ oldValue: c }) => !s.has(c.id))
608
885
  ];
609
- return { created: l, deleted: f, updated: g };
610
- }, dn = (t) => t.id !== void 0, un = () => {
611
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, w = {}) => n.push({ onChange: m, options: w }), i = (m) => {
612
- const w = n.findIndex((E) => E.onChange == m);
886
+ return { created: l, deleted: u, updated: p };
887
+ }, Lt = (t) => {
888
+ const e = t.id === void 0 ? fe() : t.id;
889
+ return {
890
+ ...t,
891
+ id: e,
892
+ bodies: t.bodies === void 0 ? [] : t.bodies.map((n) => ({
893
+ ...n,
894
+ annotation: e
895
+ })),
896
+ target: {
897
+ ...t.target,
898
+ annotation: e
899
+ }
900
+ };
901
+ }, Bn = (t) => t.id !== void 0, Mn = () => {
902
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (y, w = {}) => n.push({ onChange: y, options: w }), i = (y) => {
903
+ const w = n.findIndex((v) => v.onChange == y);
613
904
  w > -1 && n.splice(w, 1);
614
- }, r = (m, w) => {
615
- const E = {
616
- origin: m,
905
+ }, r = (y, w) => {
906
+ const v = {
907
+ origin: y,
617
908
  changes: {
618
909
  created: w.created || [],
619
910
  updated: w.updated || [],
@@ -622,185 +913,189 @@ const cn = (t, e) => {
622
913
  state: [...t.values()]
623
914
  };
624
915
  n.forEach((L) => {
625
- cn(L, E) && L.onChange(E);
916
+ Tn(L, v) && L.onChange(v);
626
917
  });
627
- }, a = (m, w = M.LOCAL) => {
628
- if (t.get(m.id))
629
- throw Error(`Cannot add annotation ${m.id} - exists already`);
630
- t.set(m.id, m), m.bodies.forEach((E) => e.set(E.id, m.id)), r(w, { created: [m] });
631
- }, s = (m, w) => {
632
- const E = typeof m == "string" ? w : m, L = typeof m == "string" ? m : m.id, T = t.get(L);
633
- if (T) {
634
- const N = le(T, E);
635
- return L === E.id ? t.set(L, E) : (t.delete(L), t.set(E.id, E)), T.bodies.forEach((K) => e.delete(K.id)), E.bodies.forEach((K) => e.set(K.id, E.id)), N;
918
+ }, a = (y, w = N.LOCAL) => {
919
+ if (y.id && t.get(y.id))
920
+ throw Error(`Cannot add annotation ${y.id} - exists already`);
921
+ {
922
+ const v = Lt(y);
923
+ t.set(v.id, v), v.bodies.forEach((L) => e.set(L.id, v.id)), r(w, { created: [v] });
924
+ }
925
+ }, s = (y, w) => {
926
+ const v = Lt(typeof y == "string" ? w : y), L = typeof y == "string" ? y : y.id, M = L && t.get(L);
927
+ if (M) {
928
+ const B = he(M, v);
929
+ return L === v.id ? t.set(L, v) : (t.delete(L), t.set(v.id, v)), M.bodies.forEach((K) => e.delete(K.id)), v.bodies.forEach((K) => e.set(K.id, v.id)), B;
636
930
  } else
637
931
  console.warn(`Cannot update annotation ${L} - does not exist`);
638
- }, l = (m, w = M.LOCAL, E = M.LOCAL) => {
639
- const L = dn(w) ? E : w, T = s(m, w);
640
- T && r(L, { updated: [T] });
641
- }, f = (m, w = M.LOCAL) => {
642
- const E = m.reduce((L, T) => {
643
- const N = s(T);
644
- return N ? [...L, N] : L;
932
+ }, l = (y, w = N.LOCAL, v = N.LOCAL) => {
933
+ const L = Bn(w) ? v : w, M = s(y, w);
934
+ M && r(L, { updated: [M] });
935
+ }, u = (y, w = N.LOCAL) => {
936
+ const v = y.reduce((L, M) => {
937
+ const B = s(M);
938
+ return B ? [...L, B] : L;
645
939
  }, []);
646
- E.length > 0 && r(w, { updated: E });
647
- }, g = (m, w = M.LOCAL) => {
648
- const E = t.get(m.annotation);
649
- if (E) {
940
+ v.length > 0 && r(w, { updated: v });
941
+ }, p = (y, w = N.LOCAL) => {
942
+ const v = t.get(y.annotation);
943
+ if (v) {
650
944
  const L = {
651
- ...E,
652
- bodies: [...E.bodies, m]
945
+ ...v,
946
+ bodies: [...v.bodies, y]
653
947
  };
654
- t.set(E.id, L), e.set(m.id, L.id), r(w, { updated: [{
655
- oldValue: E,
948
+ t.set(v.id, L), e.set(y.id, L.id), r(w, { updated: [{
949
+ oldValue: v,
656
950
  newValue: L,
657
- bodiesCreated: [m]
951
+ bodiesCreated: [y]
658
952
  }] });
659
953
  } else
660
- console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
661
- }, c = () => [...t.values()], p = (m = M.LOCAL) => {
954
+ console.warn(`Attempt to add body to missing annotation: ${y.annotation}`);
955
+ }, c = () => [...t.values()], f = (y = N.LOCAL) => {
662
956
  const w = [...t.values()];
663
- t.clear(), e.clear(), r(m, { deleted: w });
664
- }, u = (m, w = !0, E = M.LOCAL) => {
957
+ t.clear(), e.clear(), r(y, { deleted: w });
958
+ }, h = (y, w = !0, v = N.LOCAL) => {
959
+ const L = y.map(Lt);
665
960
  if (w) {
666
- const L = [...t.values()];
667
- t.clear(), e.clear(), m.forEach((T) => {
668
- t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
669
- }), r(E, { created: m, deleted: L });
961
+ const M = [...t.values()];
962
+ t.clear(), e.clear(), L.forEach((B) => {
963
+ t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
964
+ }), r(v, { created: L, deleted: M });
670
965
  } else {
671
- const L = m.reduce((T, N) => {
672
- const K = t.get(N.id);
673
- return K ? [...T, K] : T;
966
+ const M = y.reduce((B, K) => {
967
+ const X = K.id && t.get(K.id);
968
+ return X ? [...B, X] : B;
674
969
  }, []);
675
- if (L.length > 0)
676
- throw Error(`Bulk insert would overwrite the following annotations: ${L.map((T) => T.id).join(", ")}`);
677
- m.forEach((T) => {
678
- t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
679
- }), r(E, { created: m });
970
+ if (M.length > 0)
971
+ throw Error(`Bulk insert would overwrite the following annotations: ${M.map((B) => B.id).join(", ")}`);
972
+ L.forEach((B) => {
973
+ t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
974
+ }), r(v, { created: L });
680
975
  }
681
- }, v = (m) => {
682
- const w = typeof m == "string" ? m : m.id, E = t.get(w);
683
- if (E)
684
- return t.delete(w), E.bodies.forEach((L) => e.delete(L.id)), E;
976
+ }, x = (y) => {
977
+ const w = typeof y == "string" ? y : y.id, v = t.get(w);
978
+ if (v)
979
+ return t.delete(w), v.bodies.forEach((L) => e.delete(L.id)), v;
685
980
  console.warn(`Attempt to delete missing annotation: ${w}`);
686
- }, b = (m, w = M.LOCAL) => {
687
- const E = v(m);
688
- E && r(w, { deleted: [E] });
689
- }, x = (m, w = M.LOCAL) => {
690
- const E = m.reduce((L, T) => {
691
- const N = v(T);
692
- return N ? [...L, N] : L;
981
+ }, A = (y, w = N.LOCAL) => {
982
+ const v = x(y);
983
+ v && r(w, { deleted: [v] });
984
+ }, b = (y, w = N.LOCAL) => {
985
+ const v = y.reduce((L, M) => {
986
+ const B = x(M);
987
+ return B ? [...L, B] : L;
693
988
  }, []);
694
- E.length > 0 && r(w, { deleted: E });
695
- }, h = (m) => {
696
- const w = t.get(m.annotation);
989
+ v.length > 0 && r(w, { deleted: v });
990
+ }, g = (y) => {
991
+ const w = t.get(y.annotation);
697
992
  if (w) {
698
- const E = w.bodies.find((L) => L.id === m.id);
699
- if (E) {
700
- e.delete(E.id);
993
+ const v = w.bodies.find((L) => L.id === y.id);
994
+ if (v) {
995
+ e.delete(v.id);
701
996
  const L = {
702
997
  ...w,
703
- bodies: w.bodies.filter((T) => T.id !== m.id)
998
+ bodies: w.bodies.filter((M) => M.id !== y.id)
704
999
  };
705
1000
  return t.set(w.id, L), {
706
1001
  oldValue: w,
707
1002
  newValue: L,
708
- bodiesDeleted: [E]
1003
+ bodiesDeleted: [v]
709
1004
  };
710
1005
  } else
711
- console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
1006
+ console.warn(`Attempt to delete missing body ${y.id} from annotation ${y.annotation}`);
712
1007
  } else
713
- console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
714
- }, d = (m, w = M.LOCAL) => {
715
- const E = h(m);
716
- E && r(w, { updated: [E] });
717
- }, y = (m, w = M.LOCAL) => {
718
- const E = m.map((L) => h(L)).filter(Boolean);
719
- E.length > 0 && r(w, { updated: E });
720
- }, A = (m) => {
721
- const w = t.get(m);
1008
+ console.warn(`Attempt to delete body from missing annotation ${y.annotation}`);
1009
+ }, d = (y, w = N.LOCAL) => {
1010
+ const v = g(y);
1011
+ v && r(w, { updated: [v] });
1012
+ }, m = (y, w = N.LOCAL) => {
1013
+ const v = y.map((L) => g(L)).filter(Boolean);
1014
+ v.length > 0 && r(w, { updated: v });
1015
+ }, E = (y) => {
1016
+ const w = t.get(y);
722
1017
  return w ? { ...w } : void 0;
723
- }, C = (m) => {
724
- const w = e.get(m);
1018
+ }, C = (y) => {
1019
+ const w = e.get(y);
725
1020
  if (w) {
726
- const E = A(w).bodies.find((L) => L.id === m);
727
- if (E)
728
- return E;
729
- console.error(`Store integrity error: body ${m} in index, but not in annotation`);
1021
+ const v = E(w).bodies.find((L) => L.id === y);
1022
+ if (v)
1023
+ return v;
1024
+ console.error(`Store integrity error: body ${y} in index, but not in annotation`);
730
1025
  } else
731
- console.warn(`Attempt to retrieve missing body: ${m}`);
732
- }, S = (m, w) => {
733
- if (m.annotation !== w.annotation)
1026
+ console.warn(`Attempt to retrieve missing body: ${y}`);
1027
+ }, S = (y, w) => {
1028
+ if (y.annotation !== w.annotation)
734
1029
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
735
- const E = t.get(m.annotation);
736
- if (E) {
737
- const L = E.bodies.find((N) => N.id === m.id), T = {
738
- ...E,
739
- bodies: E.bodies.map((N) => N.id === L.id ? w : N)
1030
+ const v = t.get(y.annotation);
1031
+ if (v) {
1032
+ const L = v.bodies.find((B) => B.id === y.id), M = {
1033
+ ...v,
1034
+ bodies: v.bodies.map((B) => B.id === L.id ? w : B)
740
1035
  };
741
- return t.set(E.id, T), L.id !== w.id && (e.delete(L.id), e.set(w.id, T.id)), {
742
- oldValue: E,
743
- newValue: T,
1036
+ return t.set(v.id, M), L.id !== w.id && (e.delete(L.id), e.set(w.id, M.id)), {
1037
+ oldValue: v,
1038
+ newValue: M,
744
1039
  bodiesUpdated: [{ oldBody: L, newBody: w }]
745
1040
  };
746
1041
  } else
747
- console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
748
- }, R = (m, w, E = M.LOCAL) => {
749
- const L = S(m, w);
750
- L && r(E, { updated: [L] });
751
- }, O = (m, w = M.LOCAL) => {
752
- const E = m.map((L) => S({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
753
- r(w, { updated: E });
754
- }, B = (m) => {
755
- const w = t.get(m.annotation);
1042
+ console.warn(`Attempt to add body to missing annotation ${y.annotation}`);
1043
+ }, T = (y, w, v = N.LOCAL) => {
1044
+ const L = S(y, w);
1045
+ L && r(v, { updated: [L] });
1046
+ }, O = (y, w = N.LOCAL) => {
1047
+ const v = y.map((L) => S({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
1048
+ r(w, { updated: v });
1049
+ }, R = (y) => {
1050
+ const w = t.get(y.annotation);
756
1051
  if (w) {
757
- const E = {
1052
+ const v = {
758
1053
  ...w,
759
1054
  target: {
760
1055
  ...w.target,
761
- ...m
1056
+ ...y
762
1057
  }
763
1058
  };
764
- return t.set(w.id, E), {
1059
+ return t.set(w.id, v), {
765
1060
  oldValue: w,
766
- newValue: E,
1061
+ newValue: v,
767
1062
  targetUpdated: {
768
1063
  oldTarget: w.target,
769
- newTarget: m
1064
+ newTarget: y
770
1065
  }
771
1066
  };
772
1067
  } else
773
- console.warn(`Attempt to update target on missing annotation: ${m.annotation}`);
1068
+ console.warn(`Attempt to update target on missing annotation: ${y.annotation}`);
774
1069
  };
775
1070
  return {
776
1071
  addAnnotation: a,
777
- addBody: g,
1072
+ addBody: p,
778
1073
  all: c,
779
- bulkAddAnnotation: u,
780
- bulkDeleteAnnotation: x,
781
- bulkDeleteBodies: y,
782
- bulkUpdateAnnotation: f,
1074
+ bulkAddAnnotation: h,
1075
+ bulkDeleteAnnotation: b,
1076
+ bulkDeleteBodies: m,
1077
+ bulkUpdateAnnotation: u,
783
1078
  bulkUpdateBodies: O,
784
- bulkUpdateTargets: (m, w = M.LOCAL) => {
785
- const E = m.map((L) => B(L)).filter(Boolean);
786
- E.length > 0 && r(w, { updated: E });
1079
+ bulkUpdateTargets: (y, w = N.LOCAL) => {
1080
+ const v = y.map((L) => R(L)).filter(Boolean);
1081
+ v.length > 0 && r(w, { updated: v });
787
1082
  },
788
- clear: p,
789
- deleteAnnotation: b,
1083
+ clear: f,
1084
+ deleteAnnotation: A,
790
1085
  deleteBody: d,
791
- getAnnotation: A,
1086
+ getAnnotation: E,
792
1087
  getBody: C,
793
1088
  observe: o,
794
1089
  unobserve: i,
795
1090
  updateAnnotation: l,
796
- updateBody: R,
797
- updateTarget: (m, w = M.LOCAL) => {
798
- const E = B(m);
799
- E && r(w, { updated: [E] });
1091
+ updateBody: T,
1092
+ updateTarget: (y, w = N.LOCAL) => {
1093
+ const v = R(y);
1094
+ v && r(w, { updated: [v] });
800
1095
  }
801
1096
  };
802
1097
  };
803
- let fn = () => ({
1098
+ let Nn = () => ({
804
1099
  emit(t, ...e) {
805
1100
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
806
1101
  o[n](...e);
@@ -814,119 +1109,119 @@ let fn = () => ({
814
1109
  };
815
1110
  }
816
1111
  });
817
- const hn = 250, pn = (t) => {
818
- const e = fn(), n = [];
1112
+ const kn = 250, In = (t) => {
1113
+ const e = Nn(), n = [];
819
1114
  let o = -1, i = !1, r = 0;
820
- const a = (u) => {
1115
+ const a = (h) => {
821
1116
  if (!i) {
822
- const { changes: v } = u, b = performance.now();
823
- if (b - r > hn)
824
- n.splice(o + 1), n.push(v), o = n.length - 1;
1117
+ const { changes: x } = h, A = performance.now();
1118
+ if (A - r > kn)
1119
+ n.splice(o + 1), n.push(x), o = n.length - 1;
825
1120
  else {
826
- const x = n.length - 1;
827
- n[x] = ln(n[x], v);
1121
+ const b = n.length - 1;
1122
+ n[b] = Rn(n[b], x);
828
1123
  }
829
- r = b;
1124
+ r = A;
830
1125
  }
831
1126
  i = !1;
832
1127
  };
833
- t.observe(a, { origin: M.LOCAL });
834
- const s = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u), l = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), f = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ oldValue: v }) => v)), g = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ newValue: v }) => v)), c = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), p = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u);
1128
+ t.observe(a, { origin: N.LOCAL });
1129
+ const s = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), l = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), u = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: x }) => x)), p = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: x }) => x)), c = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), f = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h);
835
1130
  return {
836
1131
  canRedo: () => n.length - 1 > o,
837
1132
  canUndo: () => o > -1,
838
1133
  destroy: () => t.unobserve(a),
839
- on: (u, v) => e.on(u, v),
1134
+ on: (h, x) => e.on(h, x),
840
1135
  redo: () => {
841
1136
  if (n.length - 1 > o) {
842
1137
  i = !0;
843
- const { created: u, updated: v, deleted: b } = n[o + 1];
844
- l(u), g(v), p(b), e.emit("redo", n[o + 1]), o += 1;
1138
+ const { created: h, updated: x, deleted: A } = n[o + 1];
1139
+ l(h), p(x), f(A), e.emit("redo", n[o + 1]), o += 1;
845
1140
  }
846
1141
  },
847
1142
  undo: () => {
848
1143
  if (o > -1) {
849
1144
  i = !0;
850
- const { created: u, updated: v, deleted: b } = n[o];
851
- s(u), f(v), c(b), e.emit("undo", n[o]), o -= 1;
1145
+ const { created: h, updated: x, deleted: A } = n[o];
1146
+ s(h), u(x), c(A), e.emit("undo", n[o]), o -= 1;
852
1147
  }
853
1148
  }
854
1149
  };
855
- }, gn = () => {
856
- const { subscribe: t, set: e } = Vt([]);
1150
+ }, _n = () => {
1151
+ const { subscribe: t, set: e } = Dt([]);
857
1152
  return {
858
1153
  subscribe: t,
859
1154
  set: e
860
1155
  };
861
- }, mn = (t, e, n, o) => {
1156
+ }, Un = (t, e, n, o) => {
862
1157
  const { store: i, selection: r, hover: a, viewport: s } = t, l = /* @__PURE__ */ new Map();
863
- let f = [], g;
864
- const c = (b, x) => {
865
- l.has(b) ? l.get(b).push(x) : l.set(b, [x]);
866
- }, p = (b, x) => {
867
- const h = l.get(b);
868
- if (h) {
869
- const d = h.indexOf(x);
870
- d !== -1 && h.splice(d, 1);
1158
+ let u = [], p;
1159
+ const c = (A, b) => {
1160
+ l.has(A) ? l.get(A).push(b) : l.set(A, [b]);
1161
+ }, f = (A, b) => {
1162
+ const g = l.get(A);
1163
+ if (g) {
1164
+ const d = g.indexOf(b);
1165
+ d !== -1 && g.splice(d, 1);
871
1166
  }
872
- }, u = (b, x, h) => {
873
- l.has(b) && setTimeout(() => {
874
- l.get(b).forEach((d) => {
1167
+ }, h = (A, b, g) => {
1168
+ l.has(A) && setTimeout(() => {
1169
+ l.get(A).forEach((d) => {
875
1170
  if (n) {
876
- const y = Array.isArray(x) ? x.map((C) => n.serialize(C)) : n.serialize(x), A = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
877
- d(y, A);
1171
+ const m = Array.isArray(b) ? b.map((C) => n.serialize(C)) : n.serialize(b), E = g ? g instanceof PointerEvent ? g : n.serialize(g) : void 0;
1172
+ d(m, E);
878
1173
  } else
879
- d(x, h);
1174
+ d(b, g);
880
1175
  });
881
1176
  }, 1);
882
1177
  };
883
- r.subscribe(({ selected: b }) => {
884
- if (!(f.length === 0 && b.length === 0)) {
885
- if (f.length === 0 && b.length > 0)
886
- f = b.map(({ id: x }) => i.getAnnotation(x));
887
- else if (f.length > 0 && b.length === 0)
888
- f.forEach((x) => {
889
- const h = i.getAnnotation(x.id);
890
- h && !Z(h, x) && u("updateAnnotation", h, x);
891
- }), f = [];
1178
+ r.subscribe(({ selected: A }) => {
1179
+ if (!(u.length === 0 && A.length === 0)) {
1180
+ if (u.length === 0 && A.length > 0)
1181
+ u = A.map(({ id: b }) => i.getAnnotation(b));
1182
+ else if (u.length > 0 && A.length === 0)
1183
+ u.forEach((b) => {
1184
+ const g = i.getAnnotation(b.id);
1185
+ g && !G(g, b) && h("updateAnnotation", g, b);
1186
+ }), u = [];
892
1187
  else {
893
- const x = new Set(f.map((d) => d.id)), h = new Set(b.map(({ id: d }) => d));
894
- f.filter((d) => !h.has(d.id)).forEach((d) => {
895
- const y = i.getAnnotation(d.id);
896
- y && !Z(y, d) && u("updateAnnotation", y, d);
897
- }), f = [
1188
+ const b = new Set(u.map((d) => d.id)), g = new Set(A.map(({ id: d }) => d));
1189
+ u.filter((d) => !g.has(d.id)).forEach((d) => {
1190
+ const m = i.getAnnotation(d.id);
1191
+ m && !G(m, d) && h("updateAnnotation", m, d);
1192
+ }), u = [
898
1193
  // Remove annotations that were deselected
899
- ...f.filter((d) => h.has(d.id)),
1194
+ ...u.filter((d) => g.has(d.id)),
900
1195
  // Add editable annotations that were selected
901
- ...b.filter(({ id: d }) => !x.has(d)).map(({ id: d }) => i.getAnnotation(d))
1196
+ ...A.filter(({ id: d }) => !b.has(d)).map(({ id: d }) => i.getAnnotation(d))
902
1197
  ];
903
1198
  }
904
- u("selectionChanged", f);
1199
+ h("selectionChanged", u);
905
1200
  }
906
- }), a.subscribe((b) => {
907
- !g && b ? u("mouseEnterAnnotation", i.getAnnotation(b)) : g && !b ? u("mouseLeaveAnnotation", i.getAnnotation(g)) : g && b && (u("mouseLeaveAnnotation", i.getAnnotation(g)), u("mouseEnterAnnotation", i.getAnnotation(b))), g = b;
908
- }), s == null || s.subscribe((b) => u("viewportIntersect", b.map((x) => i.getAnnotation(x)))), i.observe((b) => {
909
- const { created: x, deleted: h } = b.changes;
910
- (x || []).forEach((d) => u("createAnnotation", d)), (h || []).forEach((d) => u("deleteAnnotation", d)), (b.changes.updated || []).filter((d) => [
1201
+ }), a.subscribe((A) => {
1202
+ !p && A ? h("mouseEnterAnnotation", i.getAnnotation(A)) : p && !A ? h("mouseLeaveAnnotation", i.getAnnotation(p)) : p && A && (h("mouseLeaveAnnotation", i.getAnnotation(p)), h("mouseEnterAnnotation", i.getAnnotation(A))), p = A;
1203
+ }), s == null || s.subscribe((A) => h("viewportIntersect", A.map((b) => i.getAnnotation(b)))), i.observe((A) => {
1204
+ const { created: b, deleted: g } = A.changes;
1205
+ (b || []).forEach((d) => h("createAnnotation", d)), (g || []).forEach((d) => h("deleteAnnotation", d)), (A.changes.updated || []).filter((d) => [
911
1206
  ...d.bodiesCreated || [],
912
1207
  ...d.bodiesDeleted || [],
913
1208
  ...d.bodiesUpdated || []
914
- ].length > 0).forEach(({ oldValue: d, newValue: y }) => {
915
- const A = f.find((C) => C.id === d.id) || d;
916
- f = f.map((C) => C.id === d.id ? y : C), u("updateAnnotation", y, A);
1209
+ ].length > 0).forEach(({ oldValue: d, newValue: m }) => {
1210
+ const E = u.find((C) => C.id === d.id) || d;
1211
+ u = u.map((C) => C.id === d.id ? m : C), h("updateAnnotation", m, E);
917
1212
  });
918
- }, { origin: M.LOCAL }), i.observe((b) => {
919
- if (f) {
920
- const x = new Set(f.map((d) => d.id)), h = (b.changes.updated || []).filter(({ newValue: d }) => x.has(d.id)).map(({ newValue: d }) => d);
921
- h.length > 0 && (f = f.map((d) => h.find((A) => A.id === d.id) || d));
1213
+ }, { origin: N.LOCAL }), i.observe((A) => {
1214
+ if (u) {
1215
+ const b = new Set(u.map((d) => d.id)), g = (A.changes.updated || []).filter(({ newValue: d }) => b.has(d.id)).map(({ newValue: d }) => d);
1216
+ g.length > 0 && (u = u.map((d) => g.find((E) => E.id === d.id) || d));
922
1217
  }
923
- }, { origin: M.REMOTE });
924
- const v = (b) => (x) => {
925
- const { updated: h } = x;
926
- b ? (h || []).forEach((d) => u("updateAnnotation", d.oldValue, d.newValue)) : (h || []).forEach((d) => u("updateAnnotation", d.newValue, d.oldValue));
1218
+ }, { origin: N.REMOTE });
1219
+ const x = (A) => (b) => {
1220
+ const { updated: g } = b;
1221
+ A ? (g || []).forEach((d) => h("updateAnnotation", d.oldValue, d.newValue)) : (g || []).forEach((d) => h("updateAnnotation", d.newValue, d.oldValue));
927
1222
  };
928
- return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: c, off: p, emit: u };
929
- }, yn = (t) => (e) => e.reduce((n, o) => {
1223
+ return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: c, off: f, emit: h };
1224
+ }, Vn = (t) => (e) => e.reduce((n, o) => {
930
1225
  const { parsed: i, error: r } = t.parse(o);
931
1226
  return r ? {
932
1227
  parsed: n.parsed,
@@ -937,47 +1232,47 @@ const hn = 250, pn = (t) => {
937
1232
  } : {
938
1233
  ...n
939
1234
  };
940
- }, { parsed: [], failed: [] }), bn = (t, e, n) => {
941
- const { store: o, selection: i } = t, r = (h) => {
1235
+ }, { parsed: [], failed: [] }), Dn = (t, e, n) => {
1236
+ const { store: o, selection: i } = t, r = (g) => {
942
1237
  if (n) {
943
- const { parsed: d, error: y } = n.parse(h);
944
- d ? o.addAnnotation(d, M.REMOTE) : console.error(y);
1238
+ const { parsed: d, error: m } = n.parse(g);
1239
+ d ? o.addAnnotation(d, N.REMOTE) : console.error(m);
945
1240
  } else
946
- o.addAnnotation(h, M.REMOTE);
947
- }, a = () => i.clear(), s = () => o.clear(), l = (h) => {
948
- const d = o.getAnnotation(h);
1241
+ o.addAnnotation(g, N.REMOTE);
1242
+ }, a = () => i.clear(), s = () => o.clear(), l = (g) => {
1243
+ const d = o.getAnnotation(g);
949
1244
  return n && d ? n.serialize(d) : d;
950
- }, f = () => n ? o.all().map(n.serialize) : o.all(), g = () => {
951
- var h;
952
- const d = (((h = i.selected) == null ? void 0 : h.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
1245
+ }, u = () => n ? o.all().map(n.serialize) : o.all(), p = () => {
1246
+ var g;
1247
+ const d = (((g = i.selected) == null ? void 0 : g.map((m) => m.id)) || []).map((m) => o.getAnnotation(m)).filter(Boolean);
953
1248
  return n ? d.map(n.serialize) : d;
954
- }, c = (h, d = !0) => fetch(h).then((y) => y.json()).then((y) => (u(y, d), y)), p = (h) => {
955
- if (typeof h == "string") {
956
- const d = o.getAnnotation(h);
957
- if (o.deleteAnnotation(h), d)
1249
+ }, c = (g, d = !0) => fetch(g).then((m) => m.json()).then((m) => (h(m, d), m)), f = (g) => {
1250
+ if (typeof g == "string") {
1251
+ const d = o.getAnnotation(g);
1252
+ if (o.deleteAnnotation(g), d)
958
1253
  return n ? n.serialize(d) : d;
959
1254
  } else {
960
- const d = n ? n.parse(h).parsed : h;
1255
+ const d = n ? n.parse(g).parsed : g;
961
1256
  if (d)
962
- return o.deleteAnnotation(d), h;
1257
+ return o.deleteAnnotation(d), g;
963
1258
  }
964
- }, u = (h, d = !0) => {
1259
+ }, h = (g, d = !0) => {
965
1260
  if (n) {
966
- const { parsed: y, failed: A } = yn(n)(h);
967
- A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(y, d, M.REMOTE);
1261
+ const { parsed: m, failed: E } = Vn(n)(g);
1262
+ E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(m, d, N.REMOTE);
968
1263
  } else
969
- o.bulkAddAnnotation(h, d, M.REMOTE);
970
- }, v = (h, d) => {
971
- h ? i.setSelected(h, d) : i.clear();
972
- }, b = (h) => {
973
- i.clear(), i.setUserSelectAction(h);
974
- }, x = (h) => {
1264
+ o.bulkAddAnnotation(g, d, N.REMOTE);
1265
+ }, x = (g, d) => {
1266
+ g ? i.setSelected(g, d) : i.clear();
1267
+ }, A = (g) => {
1268
+ i.clear(), i.setUserSelectAction(g);
1269
+ }, b = (g) => {
975
1270
  if (n) {
976
- const d = n.parse(h).parsed, y = n.serialize(o.getAnnotation(d.id));
977
- return o.updateAnnotation(d), y;
1271
+ const d = n.parse(g).parsed, m = n.serialize(o.getAnnotation(d.id));
1272
+ return o.updateAnnotation(d), m;
978
1273
  } else {
979
- const d = o.getAnnotation(h.id);
980
- return o.updateAnnotation(h), d;
1274
+ const d = o.getAnnotation(g.id);
1275
+ return o.updateAnnotation(g), d;
981
1276
  }
982
1277
  };
983
1278
  return {
@@ -987,19 +1282,19 @@ const hn = 250, pn = (t) => {
987
1282
  canUndo: e.canUndo,
988
1283
  clearAnnotations: s,
989
1284
  getAnnotationById: l,
990
- getAnnotations: f,
991
- getSelected: g,
1285
+ getAnnotations: u,
1286
+ getSelected: p,
992
1287
  loadAnnotations: c,
993
1288
  redo: e.redo,
994
- removeAnnotation: p,
995
- setAnnotations: u,
996
- setSelected: v,
997
- setUserSelectAction: b,
1289
+ removeAnnotation: f,
1290
+ setAnnotations: h,
1291
+ setSelected: x,
1292
+ setUserSelectAction: A,
998
1293
  undo: e.undo,
999
- updateAnnotation: x
1294
+ updateAnnotation: b
1000
1295
  };
1001
- }, wn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1002
- let xn = (t) => crypto.getRandomValues(new Uint8Array(t)), vn = (t, e, n) => {
1296
+ }, Kn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1297
+ let Xn = (t) => crypto.getRandomValues(new Uint8Array(t)), Yn = (t, e, n) => {
1003
1298
  let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
1004
1299
  return (r = e) => {
1005
1300
  let a = "";
@@ -1009,13 +1304,13 @@ let xn = (t) => crypto.getRandomValues(new Uint8Array(t)), vn = (t, e, n) => {
1009
1304
  if (a += t[s[l] & o] || "", a.length === r) return a;
1010
1305
  }
1011
1306
  };
1012
- }, An = (t, e = 21) => vn(t, e, xn), En = (t = 21) => {
1307
+ }, Pn = (t, e = 21) => Yn(t, e, Xn), $n = (t = 21) => {
1013
1308
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
1014
1309
  for (; t--; )
1015
- e += wn[n[t] & 63];
1310
+ e += Kn[n[t] & 63];
1016
1311
  return e;
1017
1312
  };
1018
- const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Cn = (t) => {
1313
+ const jn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Hn = (t) => {
1019
1314
  const e = JSON.stringify(t);
1020
1315
  let n = 0;
1021
1316
  for (let o = 0, i = e.length; o < i; o++) {
@@ -1023,20 +1318,20 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
1023
1318
  n = (n << 5) - n + r, n |= 0;
1024
1319
  }
1025
1320
  return `${n}`;
1026
- }, de = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Ln = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1027
- const { id: o, type: i, purpose: r, value: a, created: s, modified: l, creator: f, ...g } = n;
1321
+ }, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, zn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1322
+ const { id: o, type: i, purpose: r, value: a, created: s, modified: l, creator: u, ...p } = n;
1028
1323
  return {
1029
- id: o || `temp-${Cn(n)}`,
1324
+ id: o || `temp-${Hn(n)}`,
1030
1325
  annotation: e,
1031
1326
  type: i,
1032
1327
  purpose: r,
1033
1328
  value: a,
1034
- creator: de(f),
1329
+ creator: ge(u),
1035
1330
  created: s ? new Date(s) : void 0,
1036
1331
  updated: l ? new Date(l) : void 0,
1037
- ...g
1332
+ ...p
1038
1333
  };
1039
- }), On = (t) => t.map((e) => {
1334
+ }), Fn = (t) => t.map((e) => {
1040
1335
  var n;
1041
1336
  const { annotation: o, created: i, updated: r, ...a } = e, s = {
1042
1337
  ...a,
@@ -1045,276 +1340,11 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
1045
1340
  };
1046
1341
  return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
1047
1342
  });
1048
- En();
1049
- const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
1050
- var n;
1051
- const e = t.commonAncestorContainer;
1052
- return e instanceof HTMLElement ? !e.closest(H) : !((n = e.parentElement) != null && n.closest(H));
1053
- }, Rn = function* (t) {
1054
- const e = document.createNodeIterator(
1055
- t.commonAncestorContainer,
1056
- NodeFilter.SHOW_ELEMENT,
1057
- (o) => o instanceof HTMLElement && o.classList.contains(ue) && !o.parentElement.closest(H) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
1058
- );
1059
- let n;
1060
- for (; n = e.nextNode(); )
1061
- n instanceof HTMLElement && (yield n);
1062
- }, Bn = (t) => {
1063
- if (!Tn(t)) return [];
1064
- const e = [];
1065
- let n = null;
1066
- for (const o of Rn(t)) {
1067
- let i;
1068
- n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
1069
- }
1070
- if (n) {
1071
- const o = t.cloneRange();
1072
- o.setStartAfter(n), o.collapsed || e.push(o);
1073
- }
1074
- return e.length > 0 ? e : [t];
1075
- }, kt = (t) => {
1076
- const e = t.cloneContents();
1077
- return e.querySelectorAll(H).forEach((n) => n.remove()), e;
1078
- }, Mn = (t) => t.addEventListener("click", (e) => {
1079
- // Allow clicks within not-annotatable elements
1080
- !e.target.closest(H) && !e.target.closest("a") && e.preventDefault();
1081
- }), kn = (t) => {
1082
- !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
1083
- }, So = (t) => {
1084
- const e = t.cloneContents();
1085
- return e.querySelectorAll(H).forEach((n) => n.remove()), e;
1086
- }, Jt = (t, e) => {
1087
- const n = document.createNodeIterator(e);
1088
- let o = 0, i = n.nextNode();
1089
- for (; i !== null; ) {
1090
- if (i === t)
1091
- return o;
1092
- o += 1, i = n.nextNode();
1093
- }
1094
- }, Zt = (t, e) => {
1095
- const n = document.createNodeIterator(e);
1096
- let o = null;
1097
- for (let i = 0; i < t + 1; i++)
1098
- o = n.nextNode();
1099
- return o;
1100
- }, Nn = (t) => {
1101
- const {
1102
- commonAncestorContainer: e,
1103
- startContainer: n,
1104
- startOffset: o,
1105
- endContainer: i,
1106
- endOffset: r
1107
- } = t, a = Array.from(e.childNodes).map((c) => {
1108
- const p = c.cloneNode(!0);
1109
- return c.nodeName === "CANVAS" ? c : p;
1110
- }), s = Jt(n, e), l = Jt(i, e), f = () => {
1111
- const c = e;
1112
- c.replaceChildren(...a);
1113
- const p = Zt(s, c), u = Zt(l, c);
1114
- return t.setStart(p, o), t.setEnd(u, r), t;
1115
- }, g = (c) => {
1116
- const p = document.createElement("SPAN");
1117
- return c.surroundContents(p), p;
1118
- };
1119
- if (n === i)
1120
- throw "Not implemented";
1121
- {
1122
- const c = document.createRange();
1123
- c.selectNodeContents(n), c.setStart(n, o);
1124
- const p = g(c), u = document.createRange();
1125
- u.selectNode(i), u.setEnd(i, r);
1126
- const v = g(u), x = In(t).reverse().map((h) => {
1127
- var y;
1128
- const d = document.createElement("SPAN");
1129
- return (y = h.parentNode) == null || y.insertBefore(d, h), d.appendChild(h), d;
1130
- });
1131
- return { unwrap: f, nodes: [p, ...x, v] };
1132
- }
1133
- }, In = (t) => {
1134
- const {
1135
- commonAncestorContainer: e,
1136
- startContainer: n,
1137
- endContainer: o
1138
- } = t, i = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);
1139
- let r = i.nextNode(), a = !1;
1140
- const s = [];
1141
- for (; r != null; )
1142
- r === o && (a = !1), a && s.push(r), r === n && (a = !0), r = i.nextNode();
1143
- return s;
1144
- }, Co = (t) => {
1145
- const { startContainer: e, endContainer: n } = t;
1146
- if (e === n)
1147
- return Array.from(t.getClientRects());
1148
- {
1149
- const { unwrap: o, nodes: i } = Nn(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
1150
- return o(), r;
1151
- }
1152
- }, _n = (t, e, n = 10, o) => {
1153
- const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
1154
- r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
1155
- const a = kt(r).textContent, s = document.createRange();
1156
- s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
1157
- const l = kt(s).textContent;
1158
- return {
1159
- prefix: a.substring(a.length - n),
1160
- suffix: l.substring(0, n)
1161
- };
1162
- }, Un = /^\s*$/, Vn = (t) => Un.test(t.toString()), W = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Dn = (t, e) => {
1163
- const n = (r) => Math.round(r * 10) / 10, o = {
1164
- top: n(t.top),
1165
- bottom: n(t.bottom),
1166
- left: n(t.left),
1167
- right: n(t.right)
1168
- }, i = {
1169
- top: n(e.top),
1170
- bottom: n(e.bottom),
1171
- left: n(e.left),
1172
- right: n(e.right)
1173
- };
1174
- if (Math.abs(o.top - i.top) < 0.5 && Math.abs(o.bottom - i.bottom) < 0.5) {
1175
- if (Math.abs(o.left - i.right) < 0.5 || Math.abs(o.right - i.left) < 0.5)
1176
- return "inline-adjacent";
1177
- if (o.left >= i.left && o.right <= i.right)
1178
- return "inline-is-contained";
1179
- if (o.left <= i.left && o.right >= i.right)
1180
- return "inline-contains";
1181
- } else if (o.top <= i.top && o.bottom >= i.bottom) {
1182
- if (o.left <= i.left && o.right >= i.right)
1183
- return "block-contains";
1184
- } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
1185
- return "block-is-contained";
1186
- }, Kn = (t, e) => {
1187
- const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
1188
- return new DOMRect(n, i, o - n, r - i);
1189
- }, Yn = (t) => t.reduce((e, n) => {
1190
- if (n.width === 0 || n.height === 0)
1191
- return e;
1192
- let o = [...e], i = !1;
1193
- for (const r of e) {
1194
- const a = Dn(n, r);
1195
- if (a === "inline-adjacent") {
1196
- o = o.map((s) => s === r ? Kn(n, r) : s), i = !0;
1197
- break;
1198
- } else if (a === "inline-contains") {
1199
- o = o.map((s) => s === r ? n : s), i = !0;
1200
- break;
1201
- } else if (a === "inline-is-contained") {
1202
- i = !0;
1203
- break;
1204
- } else if (a === "block-contains" || a === "block-is-contained") {
1205
- n.width < r.width && (o = o.map((s) => s === r ? n : s)), i = !0;
1206
- break;
1207
- }
1208
- }
1209
- return i ? o : [...o, n];
1210
- }, []), Lo = (t) => ({
1211
- length: t.length,
1212
- item: (e) => t[e],
1213
- [Symbol.iterator]: function* () {
1214
- for (let e = 0; e < this.length; e++)
1215
- yield this.item(e);
1216
- }
1217
- }), Xn = (t, e, n) => {
1218
- const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
1219
- o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
1220
- const r = kt(o).textContent, a = t.toString(), s = r.length || 0, l = s + a.length;
1221
- return n ? { quote: a, start: s, end: l, range: t, offsetReference: i } : { quote: a, start: s, end: l, range: t };
1222
- }, fe = (t, e) => {
1223
- var g, c;
1224
- const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
1225
- e,
1226
- NodeFilter.SHOW_TEXT,
1227
- (p) => {
1228
- var u;
1229
- return (u = p.parentElement) != null && u.closest(H) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
1230
- }
1231
- );
1232
- let a = 0;
1233
- const s = document.createRange();
1234
- let l = r.nextNode();
1235
- l === null && console.error("Could not revive annotation target. Content missing.");
1236
- let f = !i;
1237
- for (; l !== null; ) {
1238
- if (f || (f = i == null ? void 0 : i.contains(l)), f) {
1239
- const p = ((g = l.textContent) == null ? void 0 : g.length) || 0;
1240
- if (a + p > n) {
1241
- s.setStart(l, n - a);
1242
- break;
1243
- }
1244
- a += p;
1245
- }
1246
- l = r.nextNode();
1247
- }
1248
- for (; l !== null; ) {
1249
- const p = ((c = l.textContent) == null ? void 0 : c.length) || 0;
1250
- if (a + p >= o) {
1251
- s.setEnd(l, o - a);
1252
- break;
1253
- }
1254
- a += p, l = r.nextNode();
1255
- }
1256
- return {
1257
- ...t,
1258
- range: s
1259
- };
1260
- }, yt = (t, e) => W(t.selector) ? t : {
1261
- ...t,
1262
- selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : fe(n, e))
1263
- }, Ct = (t, e) => W(t.target.selector) ? t : { ...t, target: yt(t.target, e) }, Pn = (t, e) => {
1264
- const n = t.cloneRange();
1265
- return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
1266
- }, $n = (t, e) => {
1267
- const { left: n, top: o, right: i, bottom: r } = t;
1268
- return new DOMRect(n - e.left, o - e.top, i - n, r - o);
1269
- }, Oo = (t, e) => {
1270
- const { left: n, top: o, right: i, bottom: r } = t;
1271
- return new DOMRect(n + e.left, o + e.top, i - n, r - o);
1272
- }, Hn = (t) => ({
1273
- ...t,
1274
- type: t.type,
1275
- x: t.x,
1276
- y: t.y,
1277
- clientX: t.clientX,
1278
- clientY: t.clientY,
1279
- offsetX: t.offsetX,
1280
- offsetY: t.offsetY,
1281
- screenX: t.screenX,
1282
- screenY: t.screenY,
1283
- isPrimary: t.isPrimary,
1284
- altKey: t.altKey,
1285
- ctrlKey: t.ctrlKey,
1286
- metaKey: t.metaKey,
1287
- shiftKey: t.shiftKey,
1288
- button: t.button,
1289
- buttons: t.buttons,
1290
- currentTarget: t.currentTarget,
1291
- target: t.target,
1292
- defaultPrevented: t.defaultPrevented,
1293
- detail: t.detail,
1294
- eventPhase: t.eventPhase,
1295
- pointerId: t.pointerId,
1296
- pointerType: t.pointerType,
1297
- timeStamp: t.timeStamp
1298
- }), jn = (t) => ({
1299
- ...t,
1300
- type: t.type,
1301
- key: t.key,
1302
- code: t.code,
1303
- location: t.location,
1304
- repeat: t.repeat,
1305
- altKey: t.altKey,
1306
- ctrlKey: t.ctrlKey,
1307
- metaKey: t.metaKey,
1308
- shiftKey: t.shiftKey,
1309
- currentTarget: t.currentTarget,
1310
- target: t.target,
1311
- defaultPrevented: t.defaultPrevented,
1312
- detail: t.detail,
1313
- timeStamp: t.timeStamp
1314
- }), To = (t, e) => ({
1315
- parse: (n) => Wn(n),
1316
- serialize: (n) => qn(n, t, e)
1317
- }), zn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Fn = (t) => {
1343
+ $n();
1344
+ const Bo = (t, e) => ({
1345
+ parse: (n) => Gn(n),
1346
+ serialize: (n) => Qn(n, t, e)
1347
+ }), Wn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, qn = (t) => {
1318
1348
  const {
1319
1349
  id: e,
1320
1350
  creator: n,
@@ -1325,7 +1355,7 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
1325
1355
  if (a.length === 0)
1326
1356
  return { error: Error(`No targets found for annotation: ${t.id}`) };
1327
1357
  const s = {
1328
- creator: de(n),
1358
+ creator: ge(n),
1329
1359
  created: o ? new Date(o) : void 0,
1330
1360
  updated: i ? new Date(i) : void 0,
1331
1361
  annotation: e,
@@ -1333,36 +1363,36 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
1333
1363
  styleClass: a[0].styleClass
1334
1364
  };
1335
1365
  for (const l of a) {
1336
- const g = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((c, p) => {
1337
- switch (p.type) {
1366
+ const p = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((c, f) => {
1367
+ switch (f.type) {
1338
1368
  case "TextQuoteSelector":
1339
- c.quote = p.exact;
1369
+ c.quote = f.exact;
1340
1370
  break;
1341
1371
  case "TextPositionSelector":
1342
- c.start = p.start, c.end = p.end;
1372
+ c.start = f.start, c.end = f.end;
1343
1373
  break;
1344
1374
  }
1345
1375
  return c;
1346
1376
  }, {});
1347
- if (zn(g))
1348
- s.selector.push({ id: l.id, ...g });
1377
+ if (Wn(p))
1378
+ s.selector.push({ id: l.id, ...p });
1349
1379
  else {
1350
1380
  const c = [
1351
- g.start ? void 0 : "TextPositionSelector",
1352
- g.quote ? void 0 : "TextQuoteSelector"
1381
+ p.start ? void 0 : "TextPositionSelector",
1382
+ p.quote ? void 0 : "TextQuoteSelector"
1353
1383
  ].filter(Boolean);
1354
1384
  return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`) };
1355
1385
  }
1356
1386
  }
1357
1387
  return { parsed: s };
1358
- }, Wn = (t) => {
1359
- const e = t.id || ce(), {
1388
+ }, Gn = (t) => {
1389
+ const e = t.id || ue(), {
1360
1390
  creator: n,
1361
1391
  created: o,
1362
1392
  modified: i,
1363
1393
  body: r,
1364
1394
  ...a
1365
- } = t, s = Ln(r, e), l = Fn(t);
1395
+ } = t, s = zn(r, e), l = qn(t);
1366
1396
  return "error" in l ? { error: l.error } : {
1367
1397
  parsed: {
1368
1398
  ...a,
@@ -1371,29 +1401,29 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
1371
1401
  target: l.parsed
1372
1402
  }
1373
1403
  };
1374
- }, qn = (t, e, n) => {
1404
+ }, Qn = (t, e, n) => {
1375
1405
  const { bodies: o, target: i, ...r } = t, {
1376
1406
  selector: a,
1377
1407
  creator: s,
1378
1408
  created: l,
1379
- updated: f,
1380
- ...g
1381
- } = i, c = a.map((p) => {
1382
- const { quote: u, start: v, end: b, range: x } = p, { prefix: h, suffix: d } = _n(x, n), y = [{
1409
+ updated: u,
1410
+ ...p
1411
+ } = i, c = a.map((f) => {
1412
+ const { quote: h, start: x, end: A, range: b } = f, { prefix: g, suffix: d } = Ie(b, n), m = [{
1383
1413
  type: "TextQuoteSelector",
1384
- exact: u,
1385
- prefix: h,
1414
+ exact: h,
1415
+ prefix: g,
1386
1416
  suffix: d
1387
1417
  }, {
1388
1418
  type: "TextPositionSelector",
1389
- start: v,
1390
- end: b
1419
+ start: x,
1420
+ end: A
1391
1421
  }];
1392
1422
  return {
1393
- ...g,
1394
- id: p.id,
1423
+ ...p,
1424
+ id: f.id,
1395
1425
  source: e,
1396
- selector: y
1426
+ selector: m
1397
1427
  };
1398
1428
  });
1399
1429
  return {
@@ -1401,18 +1431,18 @@ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
1401
1431
  "@context": "http://www.w3.org/ns/anno.jsonld",
1402
1432
  id: t.id,
1403
1433
  type: "Annotation",
1404
- body: On(t.bodies),
1434
+ body: Fn(t.bodies),
1405
1435
  creator: s,
1406
1436
  created: l == null ? void 0 : l.toISOString(),
1407
- modified: f == null ? void 0 : f.toISOString(),
1437
+ modified: u == null ? void 0 : u.toISOString(),
1408
1438
  target: c
1409
1439
  };
1410
1440
  };
1411
- function he(t, e, n = 0, o = t.length - 1, i = Gn) {
1441
+ function pe(t, e, n = 0, o = t.length - 1, i = Jn) {
1412
1442
  for (; o > n; ) {
1413
1443
  if (o - n > 600) {
1414
- const l = o - n + 1, f = e - n + 1, g = Math.log(l), c = 0.5 * Math.exp(2 * g / 3), p = 0.5 * Math.sqrt(g * c * (l - c) / l) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + p)), v = Math.min(o, Math.floor(e + (l - f) * c / l + p));
1415
- he(t, e, u, v, i);
1444
+ const l = o - n + 1, u = e - n + 1, p = Math.log(l), c = 0.5 * Math.exp(2 * p / 3), f = 0.5 * Math.sqrt(p * c * (l - c) / l) * (u - l / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(e - u * c / l + f)), x = Math.min(o, Math.floor(e + (l - u) * c / l + f));
1445
+ pe(t, e, h, x, i);
1416
1446
  }
1417
1447
  const r = t[e];
1418
1448
  let a = n, s = o;
@@ -1427,10 +1457,10 @@ function tt(t, e, n) {
1427
1457
  const o = t[e];
1428
1458
  t[e] = t[n], t[n] = o;
1429
1459
  }
1430
- function Gn(t, e) {
1460
+ function Jn(t, e) {
1431
1461
  return t < e ? -1 : t > e ? 1 : 0;
1432
1462
  }
1433
- class Qn {
1463
+ class Zn {
1434
1464
  constructor(e = 9) {
1435
1465
  this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
1436
1466
  }
@@ -1445,7 +1475,7 @@ class Qn {
1445
1475
  for (; n; ) {
1446
1476
  for (let a = 0; a < n.children.length; a++) {
1447
1477
  const s = n.children[a], l = n.leaf ? i(s) : s;
1448
- pt(e, l) && (n.leaf ? o.push(s) : Ot(e, l) ? this._all(s, o) : r.push(s));
1478
+ pt(e, l) && (n.leaf ? o.push(s) : Tt(e, l) ? this._all(s, o) : r.push(s));
1449
1479
  }
1450
1480
  n = r.pop();
1451
1481
  }
@@ -1459,7 +1489,7 @@ class Qn {
1459
1489
  for (let i = 0; i < n.children.length; i++) {
1460
1490
  const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;
1461
1491
  if (pt(e, a)) {
1462
- if (n.leaf || Ot(e, a)) return !0;
1492
+ if (n.leaf || Tt(e, a)) return !0;
1463
1493
  o.push(r);
1464
1494
  }
1465
1495
  }
@@ -1492,20 +1522,20 @@ class Qn {
1492
1522
  return e && this._insert(e, this.data.height - 1), this;
1493
1523
  }
1494
1524
  clear() {
1495
- return this.data = J([]), this;
1525
+ return this.data = Z([]), this;
1496
1526
  }
1497
1527
  remove(e, n) {
1498
1528
  if (!e) return this;
1499
1529
  let o = this.data;
1500
1530
  const i = this.toBBox(e), r = [], a = [];
1501
- let s, l, f;
1531
+ let s, l, u;
1502
1532
  for (; o || r.length; ) {
1503
- if (o || (o = r.pop(), l = r[r.length - 1], s = a.pop(), f = !0), o.leaf) {
1504
- const g = Jn(e, o.children, n);
1505
- if (g !== -1)
1506
- return o.children.splice(g, 1), r.push(o), this._condense(r), this;
1533
+ if (o || (o = r.pop(), l = r[r.length - 1], s = a.pop(), u = !0), o.leaf) {
1534
+ const p = to(e, o.children, n);
1535
+ if (p !== -1)
1536
+ return o.children.splice(p, 1), r.push(o), this._condense(r), this;
1507
1537
  }
1508
- !f && !o.leaf && Ot(o, i) ? (r.push(o), a.push(s), s = 0, l = o, o = o.children[0]) : l ? (s++, o = l.children[s], f = !1) : o = null;
1538
+ !u && !o.leaf && Tt(o, i) ? (r.push(o), a.push(s), s = 0, l = o, o = o.children[0]) : l ? (s++, o = l.children[s], u = !1) : o = null;
1509
1539
  }
1510
1540
  return this;
1511
1541
  }
@@ -1534,26 +1564,26 @@ class Qn {
1534
1564
  const r = o - n + 1;
1535
1565
  let a = this._maxEntries, s;
1536
1566
  if (r <= a)
1537
- return s = J(e.slice(n, o + 1)), Q(s, this.toBBox), s;
1538
- i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s = J([]), s.leaf = !1, s.height = i;
1539
- const l = Math.ceil(r / a), f = l * Math.ceil(Math.sqrt(a));
1540
- te(e, n, o, f, this.compareMinX);
1541
- for (let g = n; g <= o; g += f) {
1542
- const c = Math.min(g + f - 1, o);
1543
- te(e, g, c, l, this.compareMinY);
1544
- for (let p = g; p <= c; p += l) {
1545
- const u = Math.min(p + l - 1, c);
1546
- s.children.push(this._build(e, p, u, i - 1));
1567
+ return s = Z(e.slice(n, o + 1)), J(s, this.toBBox), s;
1568
+ i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s = Z([]), s.leaf = !1, s.height = i;
1569
+ const l = Math.ceil(r / a), u = l * Math.ceil(Math.sqrt(a));
1570
+ ee(e, n, o, u, this.compareMinX);
1571
+ for (let p = n; p <= o; p += u) {
1572
+ const c = Math.min(p + u - 1, o);
1573
+ ee(e, p, c, l, this.compareMinY);
1574
+ for (let f = p; f <= c; f += l) {
1575
+ const h = Math.min(f + l - 1, c);
1576
+ s.children.push(this._build(e, f, h, i - 1));
1547
1577
  }
1548
1578
  }
1549
- return Q(s, this.toBBox), s;
1579
+ return J(s, this.toBBox), s;
1550
1580
  }
1551
1581
  _chooseSubtree(e, n, o, i) {
1552
1582
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1553
1583
  let r = 1 / 0, a = 1 / 0, s;
1554
1584
  for (let l = 0; l < n.children.length; l++) {
1555
- const f = n.children[l], g = Lt(f), c = eo(e, f) - g;
1556
- c < a ? (a = c, r = g < r ? g : r, s = f) : c === a && g < r && (r = g, s = f);
1585
+ const u = n.children[l], p = Ot(u), c = oo(e, u) - p;
1586
+ c < a ? (a = c, r = p < r ? p : r, s = u) : c === a && p < r && (r = p, s = u);
1557
1587
  }
1558
1588
  n = s || n.children[0];
1559
1589
  }
@@ -1569,37 +1599,37 @@ class Qn {
1569
1599
  _split(e, n) {
1570
1600
  const o = e[n], i = o.children.length, r = this._minEntries;
1571
1601
  this._chooseSplitAxis(o, r, i);
1572
- const a = this._chooseSplitIndex(o, r, i), s = J(o.children.splice(a, o.children.length - a));
1573
- s.height = o.height, s.leaf = o.leaf, Q(o, this.toBBox), Q(s, this.toBBox), n ? e[n - 1].children.push(s) : this._splitRoot(o, s);
1602
+ const a = this._chooseSplitIndex(o, r, i), s = Z(o.children.splice(a, o.children.length - a));
1603
+ s.height = o.height, s.leaf = o.leaf, J(o, this.toBBox), J(s, this.toBBox), n ? e[n - 1].children.push(s) : this._splitRoot(o, s);
1574
1604
  }
1575
1605
  _splitRoot(e, n) {
1576
- this.data = J([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, Q(this.data, this.toBBox);
1606
+ this.data = Z([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
1577
1607
  }
1578
1608
  _chooseSplitIndex(e, n, o) {
1579
1609
  let i, r = 1 / 0, a = 1 / 0;
1580
1610
  for (let s = n; s <= o - n; s++) {
1581
- const l = nt(e, 0, s, this.toBBox), f = nt(e, s, o, this.toBBox), g = no(l, f), c = Lt(l) + Lt(f);
1582
- g < r ? (r = g, i = s, a = c < a ? c : a) : g === r && c < a && (a = c, i = s);
1611
+ const l = nt(e, 0, s, this.toBBox), u = nt(e, s, o, this.toBBox), p = io(l, u), c = Ot(l) + Ot(u);
1612
+ p < r ? (r = p, i = s, a = c < a ? c : a) : p === r && c < a && (a = c, i = s);
1583
1613
  }
1584
1614
  return i || o - n;
1585
1615
  }
1586
1616
  // sorts node children by the best axis for split
1587
1617
  _chooseSplitAxis(e, n, o) {
1588
- const i = e.leaf ? this.compareMinX : Zn, r = e.leaf ? this.compareMinY : to, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
1618
+ const i = e.leaf ? this.compareMinX : eo, r = e.leaf ? this.compareMinY : no, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
1589
1619
  a < s && e.children.sort(i);
1590
1620
  }
1591
1621
  // total margin of all possible split distributions where each node is at least m full
1592
1622
  _allDistMargin(e, n, o, i) {
1593
1623
  e.children.sort(i);
1594
1624
  const r = this.toBBox, a = nt(e, 0, n, r), s = nt(e, o - n, o, r);
1595
- let l = ht(a) + ht(s);
1596
- for (let f = n; f < o - n; f++) {
1597
- const g = e.children[f];
1598
- ot(a, e.leaf ? r(g) : g), l += ht(a);
1625
+ let l = gt(a) + gt(s);
1626
+ for (let u = n; u < o - n; u++) {
1627
+ const p = e.children[u];
1628
+ ot(a, e.leaf ? r(p) : p), l += gt(a);
1599
1629
  }
1600
- for (let f = o - n - 1; f >= n; f--) {
1601
- const g = e.children[f];
1602
- ot(s, e.leaf ? r(g) : g), l += ht(s);
1630
+ for (let u = o - n - 1; u >= n; u--) {
1631
+ const p = e.children[u];
1632
+ ot(s, e.leaf ? r(p) : p), l += gt(s);
1603
1633
  }
1604
1634
  return l;
1605
1635
  }
@@ -1609,20 +1639,20 @@ class Qn {
1609
1639
  }
1610
1640
  _condense(e) {
1611
1641
  for (let n = e.length - 1, o; n >= 0; n--)
1612
- e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : Q(e[n], this.toBBox);
1642
+ e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : J(e[n], this.toBBox);
1613
1643
  }
1614
1644
  }
1615
- function Jn(t, e, n) {
1645
+ function to(t, e, n) {
1616
1646
  if (!n) return e.indexOf(t);
1617
1647
  for (let o = 0; o < e.length; o++)
1618
1648
  if (n(t, e[o])) return o;
1619
1649
  return -1;
1620
1650
  }
1621
- function Q(t, e) {
1651
+ function J(t, e) {
1622
1652
  nt(t, 0, t.children.length, e, t);
1623
1653
  }
1624
1654
  function nt(t, e, n, o, i) {
1625
- i || (i = J(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1655
+ i || (i = Z(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1626
1656
  for (let r = e; r < n; r++) {
1627
1657
  const a = t.children[r];
1628
1658
  ot(i, t.leaf ? o(a) : a);
@@ -1632,32 +1662,32 @@ function nt(t, e, n, o, i) {
1632
1662
  function ot(t, e) {
1633
1663
  return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
1634
1664
  }
1635
- function Zn(t, e) {
1665
+ function eo(t, e) {
1636
1666
  return t.minX - e.minX;
1637
1667
  }
1638
- function to(t, e) {
1668
+ function no(t, e) {
1639
1669
  return t.minY - e.minY;
1640
1670
  }
1641
- function Lt(t) {
1671
+ function Ot(t) {
1642
1672
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1643
1673
  }
1644
- function ht(t) {
1674
+ function gt(t) {
1645
1675
  return t.maxX - t.minX + (t.maxY - t.minY);
1646
1676
  }
1647
- function eo(t, e) {
1677
+ function oo(t, e) {
1648
1678
  return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
1649
1679
  }
1650
- function no(t, e) {
1680
+ function io(t, e) {
1651
1681
  const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);
1652
1682
  return Math.max(0, i - n) * Math.max(0, r - o);
1653
1683
  }
1654
- function Ot(t, e) {
1684
+ function Tt(t, e) {
1655
1685
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1656
1686
  }
1657
1687
  function pt(t, e) {
1658
1688
  return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
1659
1689
  }
1660
- function J(t) {
1690
+ function Z(t) {
1661
1691
  return {
1662
1692
  children: t,
1663
1693
  height: 1,
@@ -1668,15 +1698,15 @@ function J(t) {
1668
1698
  maxY: -1 / 0
1669
1699
  };
1670
1700
  }
1671
- function te(t, e, n, o, i) {
1701
+ function ee(t, e, n, o, i) {
1672
1702
  const r = [e, n];
1673
1703
  for (; r.length; ) {
1674
1704
  if (n = r.pop(), e = r.pop(), n - e <= o) continue;
1675
1705
  const a = e + Math.ceil((n - e) / o / 2) * o;
1676
- he(t, a, e, n, i), r.push(e, a, a, n);
1706
+ pe(t, a, e, n, i), r.push(e, a, a, n);
1677
1707
  }
1678
1708
  }
1679
- let oo = () => ({
1709
+ let ro = () => ({
1680
1710
  emit(t, ...e) {
1681
1711
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
1682
1712
  o[n](...e);
@@ -1690,168 +1720,170 @@ let oo = () => ({
1690
1720
  };
1691
1721
  }
1692
1722
  });
1693
- const io = (t, e) => {
1694
- const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(), r = (y, A) => {
1695
- const C = y.selector.flatMap((R) => {
1696
- const O = W([R]) ? R.range : fe(R, e).range;
1723
+ const so = (t, e) => {
1724
+ const n = new Zn(), o = /* @__PURE__ */ new Map(), i = ro(), r = (m, E) => {
1725
+ const C = m.selector.flatMap((T) => {
1726
+ const O = W([T]) ? T.range : se(T, e).range;
1697
1727
  return Array.from(O.getClientRects());
1698
- }), S = Yn(C).map((R) => $n(R, A));
1699
- return S.map((R) => {
1700
- const { x: O, y: B, width: m, height: w } = R;
1728
+ }), S = Ke(C).map((T) => He(T, E));
1729
+ return S.map((T) => {
1730
+ const { x: O, y: R, width: y, height: w } = T;
1701
1731
  return {
1702
1732
  minX: O,
1703
- minY: B,
1704
- maxX: O + m,
1705
- maxY: B + w,
1733
+ minY: R,
1734
+ maxX: O + y,
1735
+ maxY: R + w,
1706
1736
  annotation: {
1707
- id: y.annotation,
1737
+ id: m.annotation,
1708
1738
  rects: S
1709
1739
  }
1710
1740
  };
1711
1741
  });
1712
1742
  }, a = () => [...o.values()], s = () => {
1713
1743
  n.clear(), o.clear();
1714
- }, l = (y) => {
1715
- const A = r(y, e.getBoundingClientRect());
1716
- A.forEach((C) => n.insert(C)), o.set(y.annotation, A);
1717
- }, f = (y) => {
1718
- const A = o.get(y.annotation);
1719
- A && (A.forEach((C) => n.remove(C)), o.delete(y.annotation));
1720
- }, g = (y) => {
1721
- f(y), l(y);
1722
- }, c = (y, A = !0) => {
1723
- A && s();
1724
- const C = e.getBoundingClientRect(), S = y.map((O) => ({ target: O, rects: r(O, C) }));
1725
- S.forEach(({ target: O, rects: B }) => o.set(O.annotation, B));
1726
- const R = S.flatMap(({ rects: O }) => O);
1727
- n.load(R);
1728
- }, p = (y, A, C = !1) => {
1744
+ }, l = (m) => {
1745
+ const E = r(m, e.getBoundingClientRect());
1746
+ E.forEach((C) => n.insert(C)), o.set(m.annotation, E);
1747
+ }, u = (m) => {
1748
+ const E = o.get(m.annotation);
1749
+ E && (E.forEach((C) => n.remove(C)), o.delete(m.annotation));
1750
+ }, p = (m) => {
1751
+ u(m), l(m);
1752
+ }, c = (m, E = !0) => {
1753
+ E && s();
1754
+ const C = e.getBoundingClientRect(), S = m.map((O) => ({ target: O, rects: r(O, C) }));
1755
+ S.forEach(({ target: O, rects: R }) => o.set(O.annotation, R));
1756
+ const T = S.flatMap(({ rects: O }) => O);
1757
+ n.load(T);
1758
+ }, f = (m, E, C = !1) => {
1729
1759
  const S = n.search({
1730
- minX: y,
1731
- minY: A,
1732
- maxX: y,
1733
- maxY: A
1734
- }), R = (O) => O.annotation.rects.reduce((B, m) => B + m.width * m.height, 0);
1735
- return S.length > 0 ? (S.sort((O, B) => R(O) - R(B)), C ? S.map((O) => O.annotation.id) : [S[0].annotation.id]) : [];
1736
- }, u = (y) => {
1737
- const A = v(y);
1738
- if (A.length === 0)
1760
+ minX: m,
1761
+ minY: E,
1762
+ maxX: m,
1763
+ maxY: E
1764
+ }), T = (O) => O.annotation.rects.reduce((R, y) => R + y.width * y.height, 0);
1765
+ return S.length > 0 ? (S.sort((O, R) => T(O) - T(R)), C ? S.map((O) => O.annotation.id) : [S[0].annotation.id]) : [];
1766
+ }, h = (m) => {
1767
+ const E = x(m);
1768
+ if (E.length === 0)
1739
1769
  return;
1740
- let C = A[0].left, S = A[0].top, R = A[0].right, O = A[0].bottom;
1741
- for (let B = 1; B < A.length; B++) {
1742
- const m = A[B];
1743
- C = Math.min(C, m.left), S = Math.min(S, m.top), R = Math.max(R, m.right), O = Math.max(O, m.bottom);
1770
+ let C = E[0].left, S = E[0].top, T = E[0].right, O = E[0].bottom;
1771
+ for (let R = 1; R < E.length; R++) {
1772
+ const y = E[R];
1773
+ C = Math.min(C, y.left), S = Math.min(S, y.top), T = Math.max(T, y.right), O = Math.max(O, y.bottom);
1744
1774
  }
1745
- return new DOMRect(C, S, R - C, O - S);
1746
- }, v = (y) => {
1747
- const A = o.get(y);
1748
- return A ? A[0].annotation.rects : [];
1775
+ return new DOMRect(C, S, T - C, O - S);
1776
+ }, x = (m) => {
1777
+ const E = o.get(m);
1778
+ return E ? E[0].annotation.rects : [];
1749
1779
  };
1750
1780
  return {
1751
1781
  all: a,
1752
1782
  clear: s,
1753
- getAt: p,
1754
- getAnnotationBounds: u,
1755
- getAnnotationRects: v,
1756
- getIntersecting: (y, A, C, S) => {
1757
- const R = n.search({ minX: y, minY: A, maxX: C, maxY: S }), O = new Set(R.map((B) => B.annotation.id));
1758
- return Array.from(O).map((B) => ({
1759
- annotation: t.getAnnotation(B),
1760
- rects: v(B)
1761
- })).filter((B) => !!B.annotation);
1783
+ getAt: f,
1784
+ getAnnotationBounds: h,
1785
+ getAnnotationRects: x,
1786
+ getIntersecting: (m, E, C, S) => {
1787
+ const T = n.search({ minX: m, minY: E, maxX: C, maxY: S }), O = new Set(T.map((R) => R.annotation.id));
1788
+ return Array.from(O).map((R) => ({
1789
+ annotation: t.getAnnotation(R),
1790
+ rects: x(R)
1791
+ })).filter((R) => !!R.annotation);
1762
1792
  },
1763
1793
  insert: l,
1764
1794
  recalculate: () => {
1765
- c(t.all().map((y) => y.target), !0), i.emit("recalculate");
1795
+ c(t.all().map((m) => m.target), !0), i.emit("recalculate");
1766
1796
  },
1767
- remove: f,
1797
+ remove: u,
1768
1798
  set: c,
1769
1799
  size: () => n.all().length,
1770
- update: g,
1771
- on: (y, A) => i.on(y, A)
1800
+ update: p,
1801
+ on: (m, E) => i.on(m, E)
1772
1802
  };
1773
- }, ro = (t, e) => {
1774
- const n = un(), o = io(n, t), i = Qe(n, e), r = qe(n), a = gn(), s = (x, h = M.LOCAL) => {
1775
- const d = Ct(x, t), y = W(d.target.selector);
1776
- return y && n.addAnnotation(d, h), y;
1777
- }, l = (x, h = !0, d = M.LOCAL) => {
1778
- const y = x.map((C) => Ct(C, t)), A = y.filter((C) => !W(C.target.selector));
1779
- return A.length > 0 ? (console.warn("Could not revive all targets for these annotations:", A), n.bulkAddAnnotation(y, h, d), A) : (n.bulkAddAnnotation(y, h, d), []);
1780
- }, f = (x, h = M.LOCAL) => {
1781
- const d = x.map((A) => Ct(A, t)), y = d.filter((A) => !W(A.target.selector));
1782
- return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y), d.forEach((A) => {
1783
- n.getAnnotation(A.id) ? n.updateAnnotation(A, h) : n.addAnnotation(A, h);
1784
- }), y;
1785
- }, g = (x, h = M.LOCAL) => {
1786
- const d = yt(x, t);
1787
- n.updateTarget(d, h);
1788
- }, c = (x, h = M.LOCAL) => {
1789
- const d = x.map((y) => yt(y, t));
1790
- n.bulkUpdateTargets(d, h);
1791
- }, p = (x, h, d) => {
1792
- const y = o.getAt(x, h, !!d).map((C) => n.getAnnotation(C)), A = d ? y.filter(d) : y;
1793
- return A.length > 0 ? A[0] : void 0;
1794
- }, u = (x, h, d, y = 5) => {
1795
- const A = o.getAnnotationRects(x);
1796
- if (A.length !== 0) {
1797
- if (h && d) {
1798
- const C = A.find(({ top: S, right: R, bottom: O, left: B }) => h >= B - y && h <= R + y && d >= S - y && d <= O + y);
1803
+ }, ao = (t, e) => {
1804
+ const n = Mn(), o = so(n, t), i = wn(n);
1805
+ i.setUserSelectAction(e);
1806
+ const r = yn(n), a = _n(), s = (b, g = N.LOCAL) => {
1807
+ const d = wt(b, t), m = W(d.target.selector);
1808
+ return m && n.addAnnotation(d, g), m;
1809
+ }, l = (b, g = !0, d = N.LOCAL) => {
1810
+ const m = b.map((C) => wt(C, t)), E = m.filter((C) => !W(C.target.selector));
1811
+ return E.length > 0 ? (console.warn("Could not revive all targets for these annotations:", E), n.bulkAddAnnotation(m, g, d), E) : (n.bulkAddAnnotation(m, g, d), []);
1812
+ }, u = (b, g = N.LOCAL) => {
1813
+ const d = b.map((E) => wt(E, t)), m = d.filter((E) => !W(E.target.selector));
1814
+ return m.length > 0 && console.warn("Could not revive all targets for these annotations:", m), d.forEach((E) => {
1815
+ n.getAnnotation(E.id) ? n.updateAnnotation(E, g) : n.addAnnotation(E, g);
1816
+ }), m;
1817
+ }, p = (b, g = N.LOCAL) => {
1818
+ const d = bt(b, t);
1819
+ n.updateTarget(d, g);
1820
+ }, c = (b, g = N.LOCAL) => {
1821
+ const d = b.map((m) => bt(m, t));
1822
+ n.bulkUpdateTargets(d, g);
1823
+ }, f = (b, g, d) => {
1824
+ const m = o.getAt(b, g, !!d).map((C) => n.getAnnotation(C)), E = d ? m.filter(d) : m;
1825
+ return E.length > 0 ? E[0] : void 0;
1826
+ }, h = (b, g, d, m = 5) => {
1827
+ const E = o.getAnnotationRects(b);
1828
+ if (E.length !== 0) {
1829
+ if (g && d) {
1830
+ const C = E.find(({ top: S, right: T, bottom: O, left: R }) => g >= R - m && g <= T + m && d >= S - m && d <= O + m);
1799
1831
  if (C) return C;
1800
1832
  }
1801
- return o.getAnnotationBounds(x);
1833
+ return o.getAnnotationBounds(b);
1802
1834
  }
1803
- }, v = () => o.recalculate(), b = (x) => o.on("recalculate", x);
1804
- return n.observe(({ changes: x }) => {
1805
- const h = (x.deleted || []).filter((A) => W(A.target.selector)), d = (x.created || []).filter((A) => W(A.target.selector)), y = (x.updated || []).filter((A) => W(A.newValue.target.selector));
1806
- (h == null ? void 0 : h.length) > 0 && h.forEach((A) => o.remove(A.target)), d.length > 0 && o.set(d.map((A) => A.target), !1), (y == null ? void 0 : y.length) > 0 && y.forEach(({ newValue: A }) => o.update(A.target));
1835
+ }, x = () => o.recalculate(), A = (b) => o.on("recalculate", b);
1836
+ return n.observe(({ changes: b }) => {
1837
+ const g = (b.deleted || []).filter((E) => W(E.target.selector)), d = (b.created || []).filter((E) => W(E.target.selector)), m = (b.updated || []).filter((E) => W(E.newValue.target.selector));
1838
+ (g == null ? void 0 : g.length) > 0 && g.forEach((E) => o.remove(E.target)), d.length > 0 && o.set(d.map((E) => E.target), !1), (m == null ? void 0 : m.length) > 0 && m.forEach(({ newValue: E }) => o.update(E.target));
1807
1839
  }), {
1808
1840
  store: {
1809
1841
  ...n,
1810
1842
  addAnnotation: s,
1811
1843
  bulkAddAnnotation: l,
1812
1844
  bulkUpdateTargets: c,
1813
- bulkUpsertAnnotations: f,
1814
- getAnnotationBounds: u,
1815
- getAt: p,
1845
+ bulkUpsertAnnotations: u,
1846
+ getAnnotationBounds: h,
1847
+ getAt: f,
1816
1848
  getIntersecting: o.getIntersecting.bind(o),
1817
1849
  getAnnotationRects: o.getAnnotationRects.bind(o),
1818
- recalculatePositions: v,
1819
- onRecalculatePositions: b,
1820
- updateTarget: g
1850
+ recalculatePositions: x,
1851
+ onRecalculatePositions: A,
1852
+ updateTarget: p
1821
1853
  },
1822
1854
  selection: i,
1823
1855
  hover: r,
1824
1856
  viewport: a
1825
1857
  };
1826
- }, so = () => {
1858
+ }, co = () => {
1827
1859
  const t = document.createElement("canvas");
1828
1860
  t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
1829
1861
  const e = t.getContext("2d");
1830
1862
  return e.scale(2, 2), e.translate(0.5, 0.5), t;
1831
- }, ao = (t, e, n = {}) => {
1832
- const o = so(), i = o.getContext("2d");
1863
+ }, lo = (t, e, n = {}) => {
1864
+ const o = co(), i = o.getContext("2d");
1833
1865
  document.body.appendChild(o);
1834
- const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([p, u]) => u.presenceKey === c.presenceKey).map(([p, u]) => p);
1835
- return e.on("selectionChange", (c, p) => {
1836
- a(c).forEach((v) => r.delete(v)), p && p.forEach((v) => r.set(v, c));
1866
+ const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([f, h]) => h.presenceKey === c.presenceKey).map(([f, h]) => f);
1867
+ return e.on("selectionChange", (c, f) => {
1868
+ a(c).forEach((x) => r.delete(x)), f && f.forEach((x) => r.set(x, c));
1837
1869
  }), {
1838
1870
  clear: () => {
1839
- const { width: c, height: p } = o;
1840
- i.clearRect(-0.5, -0.5, c + 1, p + 1);
1871
+ const { width: c, height: f } = o;
1872
+ i.clearRect(-0.5, -0.5, c + 1, f + 1);
1841
1873
  },
1842
1874
  destroy: () => {
1843
1875
  o.remove();
1844
1876
  },
1845
- paint: (c, p, u) => {
1877
+ paint: (c, f, h) => {
1846
1878
  n.font && (i.font = n.font);
1847
- const v = r.get(c.annotation.id);
1848
- if (v) {
1849
- const { height: b } = c.rects[0], x = c.rects[0].x + p.left, h = c.rects[0].y + p.top;
1850
- i.fillStyle = v.appearance.color, i.fillRect(x - 2, h - 2.5, 2, b + 5);
1851
- const d = i.measureText(v.appearance.label), y = d.width + 6, A = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, C = d.fontBoundingBoxAscent ? 8 : 6.5;
1852
- return i.fillRect(x - 2, h - 2.5 - A, y, A), i.fillStyle = "#fff", i.fillText(v.appearance.label, x + 1, h - C), {
1853
- fill: v.appearance.color,
1854
- fillOpacity: u ? 0.45 : 0.18
1879
+ const x = r.get(c.annotation.id);
1880
+ if (x) {
1881
+ const { height: A } = c.rects[0], b = c.rects[0].x + f.left, g = c.rects[0].y + f.top;
1882
+ i.fillStyle = x.appearance.color, i.fillRect(b - 2, g - 2.5, 2, A + 5);
1883
+ const d = i.measureText(x.appearance.label), m = d.width + 6, E = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, C = d.fontBoundingBoxAscent ? 8 : 6.5;
1884
+ return i.fillRect(b - 2, g - 2.5 - E, m, E), i.fillStyle = "#fff", i.fillText(x.appearance.label, b + 1, g - C), {
1885
+ fill: x.appearance.color,
1886
+ fillOpacity: h ? 0.45 : 0.18
1855
1887
  };
1856
1888
  }
1857
1889
  },
@@ -1861,44 +1893,44 @@ const io = (t, e) => {
1861
1893
  c.scale(2, 2), c.translate(0.5, 0.5);
1862
1894
  }
1863
1895
  };
1864
- }, pe = (t) => {
1896
+ }, me = (t) => {
1865
1897
  if (t === null)
1866
1898
  return document.scrollingElement;
1867
1899
  const { overflowY: e } = window.getComputedStyle(t);
1868
- return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : pe(t.parentElement);
1869
- }, co = (t, e) => (n) => {
1900
+ return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : me(t.parentElement);
1901
+ }, uo = (t, e) => (n) => {
1870
1902
  const o = typeof n == "string" ? n : n.id, i = (a) => {
1871
- const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: c, height: p } = e.getAnnotationBounds(o), u = g.top - s.top, v = g.left - s.left, b = r.parentElement ? r.scrollTop : 0, x = r.parentElement ? r.scrollLeft : 0, h = u + b - (l - p) / 2, d = v + x - (f - c) / 2;
1872
- r.scroll({ top: h, left: d, behavior: "smooth" });
1873
- }, r = pe(t);
1903
+ const s = r.getBoundingClientRect(), l = r.clientHeight, u = r.clientWidth, p = a.selector[0].range.getBoundingClientRect(), { width: c, height: f } = e.getAnnotationBounds(o), h = p.top - s.top, x = p.left - s.left, A = r.parentElement ? r.scrollTop : 0, b = r.parentElement ? r.scrollLeft : 0, g = h + A - (l - f) / 2, d = x + b - (u - c) / 2;
1904
+ r.scroll({ top: g, left: d, behavior: "smooth" });
1905
+ }, r = me(t);
1874
1906
  if (r) {
1875
1907
  const a = e.getAnnotation(o), { range: s } = a.target.selector[0];
1876
1908
  if (s && !s.collapsed)
1877
1909
  return i(a.target), !0;
1878
1910
  {
1879
- const l = yt(a.target, t), { range: f } = l.selector[0];
1880
- if (f && !f.collapsed)
1911
+ const l = bt(a.target, t), { range: u } = l.selector[0];
1912
+ if (u && !u.collapsed)
1881
1913
  return i(l), !0;
1882
1914
  }
1883
1915
  }
1884
1916
  return !1;
1885
- }, lo = (t, e) => ({
1917
+ }, fo = (t, e) => ({
1886
1918
  ...t,
1887
1919
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
1888
1920
  user: t.user || e.user
1889
- }), Tt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1890
- function Rt(t, e, n, o) {
1921
+ }), Rt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1922
+ function Bt(t, e, n, o) {
1891
1923
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1892
1924
  }
1893
1925
  function et(t, e, n, o) {
1894
1926
  t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
1895
1927
  }
1896
- function ge(t, e) {
1928
+ function ye(t, e) {
1897
1929
  const n = e.slice(0, e.length - 1);
1898
1930
  for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
1899
1931
  return n;
1900
1932
  }
1901
- function me(t) {
1933
+ function be(t) {
1902
1934
  typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
1903
1935
  const e = t.split(",");
1904
1936
  let n = e.lastIndexOf("");
@@ -1906,7 +1938,7 @@ function me(t) {
1906
1938
  e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
1907
1939
  return e;
1908
1940
  }
1909
- function uo(t, e) {
1941
+ function ho(t, e) {
1910
1942
  const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
1911
1943
  let i = !0;
1912
1944
  for (let r = 0; r < n.length; r++)
@@ -1958,14 +1990,14 @@ const st = {
1958
1990
  ".": 190,
1959
1991
  "/": 191,
1960
1992
  "`": 192,
1961
- "-": Tt ? 173 : 189,
1962
- "=": Tt ? 61 : 187,
1963
- ";": Tt ? 59 : 186,
1993
+ "-": Rt ? 173 : 189,
1994
+ "=": Rt ? 61 : 187,
1995
+ ";": Rt ? 59 : 186,
1964
1996
  "'": 222,
1965
1997
  "[": 219,
1966
1998
  "]": 221,
1967
1999
  "\\": 220
1968
- }, j = {
2000
+ }, H = {
1969
2001
  // shiftKey
1970
2002
  "⇧": 16,
1971
2003
  shift: 16,
@@ -1981,7 +2013,7 @@ const st = {
1981
2013
  "⌘": 91,
1982
2014
  cmd: 91,
1983
2015
  command: 91
1984
- }, Nt = {
2016
+ }, It = {
1985
2017
  16: "shiftKey",
1986
2018
  18: "altKey",
1987
2019
  17: "ctrlKey",
@@ -1998,21 +2030,21 @@ const st = {
1998
2030
  }, I = {};
1999
2031
  for (let t = 1; t < 20; t++)
2000
2032
  st["f".concat(t)] = 111 + t;
2001
- let k = [], rt = null, ye = "all";
2002
- const F = /* @__PURE__ */ new Map(), ct = (t) => st[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), fo = (t) => Object.keys(st).find((e) => st[e] === t), ho = (t) => Object.keys(j).find((e) => j[e] === t);
2003
- function be(t) {
2004
- ye = t || "all";
2033
+ let k = [], rt = null, we = "all";
2034
+ const F = /* @__PURE__ */ new Map(), ct = (t) => st[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), go = (t) => Object.keys(st).find((e) => st[e] === t), po = (t) => Object.keys(H).find((e) => H[e] === t);
2035
+ function ve(t) {
2036
+ we = t || "all";
2005
2037
  }
2006
2038
  function at() {
2007
- return ye || "all";
2039
+ return we || "all";
2008
2040
  }
2009
- function po() {
2041
+ function mo() {
2010
2042
  return k.slice(0);
2011
2043
  }
2012
- function go() {
2013
- return k.map((t) => fo(t) || ho(t) || String.fromCharCode(t));
2044
+ function yo() {
2045
+ return k.map((t) => go(t) || po(t) || String.fromCharCode(t));
2014
2046
  }
2015
- function mo() {
2047
+ function bo() {
2016
2048
  const t = [];
2017
2049
  return Object.keys(I).forEach((e) => {
2018
2050
  I[e].forEach((n) => {
@@ -2031,7 +2063,7 @@ function mo() {
2031
2063
  });
2032
2064
  }), t;
2033
2065
  }
2034
- function yo(t) {
2066
+ function wo(t) {
2035
2067
  const e = t.target || t.srcElement, {
2036
2068
  tagName: n
2037
2069
  } = e;
@@ -2039,10 +2071,10 @@ function yo(t) {
2039
2071
  const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
2040
2072
  return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
2041
2073
  }
2042
- function bo(t) {
2074
+ function vo(t) {
2043
2075
  return typeof t == "string" && (t = ct(t)), k.indexOf(t) !== -1;
2044
2076
  }
2045
- function wo(t, e) {
2077
+ function xo(t, e) {
2046
2078
  let n, o;
2047
2079
  t || (t = at());
2048
2080
  for (const i in I)
@@ -2052,34 +2084,34 @@ function wo(t, e) {
2052
2084
  let {
2053
2085
  element: s
2054
2086
  } = a;
2055
- return Dt(s);
2087
+ return Kt(s);
2056
2088
  }) : o++;
2057
- at() === t && be(e || "all");
2089
+ at() === t && ve(e || "all");
2058
2090
  }
2059
- function xo(t) {
2091
+ function Ao(t) {
2060
2092
  let e = t.keyCode || t.which || t.charCode;
2061
2093
  const n = k.indexOf(e);
2062
2094
  if (n >= 0 && k.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && k.splice(0, k.length), (e === 93 || e === 224) && (e = 91), e in D) {
2063
2095
  D[e] = !1;
2064
- for (const o in j) j[o] === e && ($[o] = !1);
2096
+ for (const o in H) H[o] === e && ($[o] = !1);
2065
2097
  }
2066
2098
  }
2067
- function we(t) {
2099
+ function xe(t) {
2068
2100
  if (typeof t > "u")
2069
2101
  Object.keys(I).forEach((i) => {
2070
- Array.isArray(I[i]) && I[i].forEach((r) => gt(r)), delete I[i];
2071
- }), Dt(null);
2102
+ Array.isArray(I[i]) && I[i].forEach((r) => mt(r)), delete I[i];
2103
+ }), Kt(null);
2072
2104
  else if (Array.isArray(t))
2073
2105
  t.forEach((i) => {
2074
- i.key && gt(i);
2106
+ i.key && mt(i);
2075
2107
  });
2076
2108
  else if (typeof t == "object")
2077
- t.key && gt(t);
2109
+ t.key && mt(t);
2078
2110
  else if (typeof t == "string") {
2079
2111
  for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
2080
2112
  n[o - 1] = arguments[o];
2081
2113
  let [i, r] = n;
2082
- typeof i == "function" && (r = i, i = ""), gt({
2114
+ typeof i == "function" && (r = i, i = ""), mt({
2083
2115
  key: t,
2084
2116
  scope: i,
2085
2117
  method: r,
@@ -2087,25 +2119,25 @@ function we(t) {
2087
2119
  });
2088
2120
  }
2089
2121
  }
2090
- const gt = (t) => {
2122
+ const mt = (t) => {
2091
2123
  let {
2092
2124
  key: e,
2093
2125
  scope: n,
2094
2126
  method: o,
2095
2127
  splitKey: i = "+"
2096
2128
  } = t;
2097
- me(e).forEach((a) => {
2098
- const s = a.split(i), l = s.length, f = s[l - 1], g = f === "*" ? "*" : ct(f);
2099
- if (!I[g]) return;
2129
+ be(e).forEach((a) => {
2130
+ const s = a.split(i), l = s.length, u = s[l - 1], p = u === "*" ? "*" : ct(u);
2131
+ if (!I[p]) return;
2100
2132
  n || (n = at());
2101
- const c = l > 1 ? ge(j, s) : [], p = [];
2102
- I[g] = I[g].filter((u) => {
2103
- const b = (o ? u.method === o : !0) && u.scope === n && uo(u.mods, c);
2104
- return b && p.push(u.element), !b;
2105
- }), p.forEach((u) => Dt(u));
2133
+ const c = l > 1 ? ye(H, s) : [], f = [];
2134
+ I[p] = I[p].filter((h) => {
2135
+ const A = (o ? h.method === o : !0) && h.scope === n && ho(h.mods, c);
2136
+ return A && f.push(h.element), !A;
2137
+ }), f.forEach((h) => Kt(h));
2106
2138
  });
2107
2139
  };
2108
- function ee(t, e, n, o) {
2140
+ function ne(t, e, n, o) {
2109
2141
  if (e.element !== o)
2110
2142
  return;
2111
2143
  let i;
@@ -2116,81 +2148,81 @@ function ee(t, e, n, o) {
2116
2148
  (e.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(k), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2117
2149
  }
2118
2150
  }
2119
- function ne(t, e) {
2151
+ function oe(t, e) {
2120
2152
  const n = I["*"];
2121
2153
  let o = t.keyCode || t.which || t.charCode;
2122
2154
  if (!$.filter.call(this, t)) return;
2123
2155
  if ((o === 93 || o === 224) && (o = 91), k.indexOf(o) === -1 && o !== 229 && k.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((s) => {
2124
- const l = Nt[s];
2156
+ const l = It[s];
2125
2157
  t[s] && k.indexOf(l) === -1 ? k.push(l) : !t[s] && k.indexOf(l) > -1 ? k.splice(k.indexOf(l), 1) : s === "metaKey" && t[s] && k.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (k = k.slice(k.indexOf(l))));
2126
2158
  }), o in D) {
2127
2159
  D[o] = !0;
2128
- for (const s in j)
2129
- j[s] === o && ($[s] = !0);
2160
+ for (const s in H)
2161
+ H[s] === o && ($[s] = !0);
2130
2162
  if (!n) return;
2131
2163
  }
2132
2164
  for (const s in D)
2133
- Object.prototype.hasOwnProperty.call(D, s) && (D[s] = t[Nt[s]]);
2165
+ Object.prototype.hasOwnProperty.call(D, s) && (D[s] = t[It[s]]);
2134
2166
  t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (k.indexOf(17) === -1 && k.push(17), k.indexOf(18) === -1 && k.push(18), D[17] = !0, D[18] = !0);
2135
2167
  const i = at();
2136
2168
  if (n)
2137
2169
  for (let s = 0; s < n.length; s++)
2138
- n[s].scope === i && (t.type === "keydown" && n[s].keydown || t.type === "keyup" && n[s].keyup) && ee(t, n[s], i, e);
2170
+ n[s].scope === i && (t.type === "keydown" && n[s].keydown || t.type === "keyup" && n[s].keyup) && ne(t, n[s], i, e);
2139
2171
  if (!(o in I)) return;
2140
2172
  const r = I[o], a = r.length;
2141
2173
  for (let s = 0; s < a; s++)
2142
2174
  if ((t.type === "keydown" && r[s].keydown || t.type === "keyup" && r[s].keyup) && r[s].key) {
2143
2175
  const l = r[s], {
2144
- splitKey: f
2145
- } = l, g = l.key.split(f), c = [];
2146
- for (let p = 0; p < g.length; p++)
2147
- c.push(ct(g[p]));
2148
- c.sort().join("") === k.sort().join("") && ee(t, l, i, e);
2176
+ splitKey: u
2177
+ } = l, p = l.key.split(u), c = [];
2178
+ for (let f = 0; f < p.length; f++)
2179
+ c.push(ct(p[f]));
2180
+ c.sort().join("") === k.sort().join("") && ne(t, l, i, e);
2149
2181
  }
2150
2182
  }
2151
2183
  function $(t, e, n) {
2152
2184
  k = [];
2153
- const o = me(t);
2154
- let i = [], r = "all", a = document, s = 0, l = !1, f = !0, g = "+", c = !1, p = !1;
2155
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (r = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (c = e.capture), typeof e.splitKey == "string" && (g = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (r = e), p && we(t, r); s < o.length; s++)
2156
- t = o[s].split(g), i = [], t.length > 1 && (i = ge(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : ct(t), t in I || (I[t] = []), I[t].push({
2185
+ const o = be(t);
2186
+ let i = [], r = "all", a = document, s = 0, l = !1, u = !0, p = "+", c = !1, f = !1;
2187
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (r = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (u = e.keydown), e.capture !== void 0 && (c = e.capture), typeof e.splitKey == "string" && (p = e.splitKey), e.single === !0 && (f = !0)), typeof e == "string" && (r = e), f && xe(t, r); s < o.length; s++)
2188
+ t = o[s].split(p), i = [], t.length > 1 && (i = ye(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ct(t), t in I || (I[t] = []), I[t].push({
2157
2189
  keyup: l,
2158
- keydown: f,
2190
+ keydown: u,
2159
2191
  scope: r,
2160
2192
  mods: i,
2161
2193
  shortcut: o[s],
2162
2194
  method: n,
2163
2195
  key: o[s],
2164
- splitKey: g,
2196
+ splitKey: p,
2165
2197
  element: a
2166
2198
  });
2167
2199
  if (typeof a < "u" && window) {
2168
2200
  if (!F.has(a)) {
2169
- const u = function() {
2170
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2171
- return ne(b, a);
2172
- }, v = function() {
2173
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2174
- ne(b, a), xo(b);
2201
+ const h = function() {
2202
+ let A = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2203
+ return oe(A, a);
2204
+ }, x = function() {
2205
+ let A = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2206
+ oe(A, a), Ao(A);
2175
2207
  };
2176
2208
  F.set(a, {
2177
- keydownListener: u,
2178
- keyupListenr: v,
2209
+ keydownListener: h,
2210
+ keyupListenr: x,
2179
2211
  capture: c
2180
- }), Rt(a, "keydown", u, c), Rt(a, "keyup", v, c);
2212
+ }), Bt(a, "keydown", h, c), Bt(a, "keyup", x, c);
2181
2213
  }
2182
2214
  if (!rt) {
2183
- const u = () => {
2215
+ const h = () => {
2184
2216
  k = [];
2185
2217
  };
2186
2218
  rt = {
2187
- listener: u,
2219
+ listener: h,
2188
2220
  capture: c
2189
- }, Rt(window, "focus", u, c);
2221
+ }, Bt(window, "focus", h, c);
2190
2222
  }
2191
2223
  }
2192
2224
  }
2193
- function vo(t) {
2225
+ function Eo(t) {
2194
2226
  let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
2195
2227
  Object.keys(I).forEach((n) => {
2196
2228
  I[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
@@ -2198,7 +2230,7 @@ function vo(t) {
2198
2230
  });
2199
2231
  });
2200
2232
  }
2201
- function Dt(t) {
2233
+ function Kt(t) {
2202
2234
  const e = Object.values(I).flat();
2203
2235
  if (e.findIndex((o) => {
2204
2236
  let {
@@ -2228,205 +2260,206 @@ function Dt(t) {
2228
2260
  et(window, "focus", i, r), rt = null;
2229
2261
  }
2230
2262
  }
2231
- const Bt = {
2232
- getPressedKeyString: go,
2233
- setScope: be,
2263
+ const Mt = {
2264
+ getPressedKeyString: yo,
2265
+ setScope: ve,
2234
2266
  getScope: at,
2235
- deleteScope: wo,
2236
- getPressedKeyCodes: po,
2237
- getAllKeyCodes: mo,
2238
- isPressed: bo,
2239
- filter: yo,
2240
- trigger: vo,
2241
- unbind: we,
2267
+ deleteScope: xo,
2268
+ getPressedKeyCodes: mo,
2269
+ getAllKeyCodes: bo,
2270
+ isPressed: vo,
2271
+ filter: wo,
2272
+ trigger: Eo,
2273
+ unbind: xe,
2242
2274
  keyMap: st,
2243
- modifier: j,
2244
- modifierMap: Nt
2275
+ modifier: H,
2276
+ modifierMap: It
2245
2277
  };
2246
- for (const t in Bt)
2247
- Object.prototype.hasOwnProperty.call(Bt, t) && ($[t] = Bt[t]);
2278
+ for (const t in Mt)
2279
+ Object.prototype.hasOwnProperty.call(Mt, t) && ($[t] = Mt[t]);
2248
2280
  if (typeof window < "u") {
2249
2281
  const t = window.hotkeys;
2250
2282
  $.noConflict = (e) => (e && window.hotkeys === $ && (window.hotkeys = t), $), window.hotkeys = $;
2251
2283
  }
2252
- const Ao = (t, e, n) => {
2284
+ const So = (t, e, n) => {
2253
2285
  let o;
2254
2286
  const i = (S) => o = S;
2255
2287
  let r;
2256
2288
  const a = (S) => r = S;
2257
2289
  let s = !0;
2258
2290
  const l = (S) => {
2259
- s = S, b.clear(), S || (c = void 0, p = void 0, u = void 0);
2260
- }, { store: f, selection: g } = e;
2261
- let c, p, u;
2262
- const v = (S) => {
2291
+ s = S, A.clear(), S || (c = void 0, f = void 0, h = void 0);
2292
+ }, { store: u, selection: p } = e;
2293
+ let c, f, h;
2294
+ const x = (S) => {
2263
2295
  var O;
2264
- if (!s || p === !1)
2296
+ if (!s || f === !1)
2265
2297
  return;
2266
- c = !((O = S.target.parentElement) != null && O.closest(H)) ? {
2267
- annotation: ce(),
2298
+ c = !((O = S.target.parentElement) != null && O.closest(j)) ? {
2299
+ annotation: ue(),
2268
2300
  selector: [],
2269
2301
  creator: o,
2270
2302
  created: /* @__PURE__ */ new Date()
2271
2303
  } : void 0;
2272
2304
  };
2273
- t.addEventListener("selectstart", v);
2274
- const b = _t((S) => {
2275
- var T, N;
2305
+ t.addEventListener("selectstart", x);
2306
+ const A = Ut((S) => {
2307
+ var M, B;
2276
2308
  if (!s) return;
2277
- const R = document.getSelection();
2278
- if (!!((N = (T = R.anchorNode) == null ? void 0 : T.parentElement) != null && N.closest(H))) {
2309
+ const T = document.getSelection();
2310
+ if (!!((B = (M = T.anchorNode) == null ? void 0 : M.parentElement) != null && B.closest(j))) {
2279
2311
  c = void 0;
2280
2312
  return;
2281
2313
  }
2282
- if (S.timeStamp - ((u == null ? void 0 : u.timeStamp) || S.timeStamp) < 1e3 && !c && v(u || S), !c) return;
2283
- if (R.isCollapsed) {
2284
- f.getAnnotation(c.annotation) && (g.clear(), f.deleteAnnotation(c.annotation));
2314
+ if (S.timeStamp - ((h == null ? void 0 : h.timeStamp) || S.timeStamp) < 1e3 && !c && x(h || S), !c) return;
2315
+ if (T.isCollapsed) {
2316
+ u.getAnnotation(c.annotation) && (p.clear(), u.deleteAnnotation(c.annotation));
2285
2317
  return;
2286
2318
  }
2287
- const m = R.getRangeAt(0), w = Pn(m, t);
2288
- if (Vn(w)) return;
2289
- const E = Bn(w.cloneRange());
2290
- (E.length !== c.selector.length || E.some((K, X) => {
2319
+ const y = T.getRangeAt(0), w = Ye(y, t);
2320
+ if (Ue(w)) return;
2321
+ const v = Re(w.cloneRange());
2322
+ (v.length !== c.selector.length || v.some((K, X) => {
2291
2323
  var lt;
2292
2324
  return K.toString() !== ((lt = c.selector[X]) == null ? void 0 : lt.quote);
2293
2325
  })) && (c = {
2294
2326
  ...c,
2295
- selector: E.map((K) => Xn(K, t, n)),
2327
+ selector: v.map((K) => Xe(K, t, n)),
2296
2328
  updated: /* @__PURE__ */ new Date()
2297
- }, f.getAnnotation(c.annotation) ? f.updateTarget(c, M.LOCAL) : (g.clear(), f.addAnnotation({
2329
+ }, u.getAnnotation(c.annotation) ? u.updateTarget(c, N.LOCAL) : (p.clear(), u.addAnnotation({
2298
2330
  id: c.annotation,
2299
2331
  bodies: [],
2300
2332
  target: c
2301
- }, M.LOCAL), g.userSelect(c.annotation, u)));
2302
- }, 10);
2303
- document.addEventListener("selectionchange", b);
2304
- const x = (S) => {
2305
- u = Hn(S), p = u.button === 0, c = void 0;
2333
+ }, N.LOCAL), p.userSelect(c.annotation, h)));
2334
+ });
2335
+ document.addEventListener("selectionchange", A);
2336
+ const b = (S) => {
2337
+ h = ze(S), f = h.button === 0, c = void 0;
2306
2338
  };
2307
- document.addEventListener("pointerdown", x);
2308
- const h = (S) => {
2309
- var m;
2310
- if (!!((m = S.target.parentElement) != null && m.closest(H)) || !p)
2339
+ document.addEventListener("pointerdown", b);
2340
+ const g = (S) => {
2341
+ var y;
2342
+ if (!!((y = S.target.parentElement) != null && y.closest(j)) || !f)
2311
2343
  return;
2312
2344
  const O = () => {
2313
- const { x: w, y: E } = t.getBoundingClientRect(), L = S.target instanceof Node && t.contains(S.target) && f.getAt(S.clientX - w, S.clientY - E, r);
2345
+ const { x: w, y: v } = t.getBoundingClientRect(), L = S.target instanceof Node && t.contains(S.target) && u.getAt(S.clientX - w, S.clientY - v, r);
2314
2346
  if (L) {
2315
- const { selected: T } = g;
2316
- (T.length !== 1 || T[0].id !== L.id) && g.userSelect(L.id, S);
2317
- } else g.isEmpty() || g.clear();
2318
- }, B = S.timeStamp - u.timeStamp;
2347
+ const { selected: M } = p;
2348
+ (M.length !== 1 || M[0].id !== L.id) && p.userSelect(L.id, S);
2349
+ } else p.isEmpty() || p.clear();
2350
+ }, R = S.timeStamp - h.timeStamp;
2319
2351
  setTimeout(() => {
2320
2352
  const w = document.getSelection();
2321
- w != null && w.isCollapsed && B < 300 ? O() : c && g.userSelect(c.annotation, S);
2353
+ w != null && w.isCollapsed && R < 300 ? O() : c && p.userSelect(c.annotation, S);
2322
2354
  });
2323
2355
  };
2324
- document.addEventListener("pointerup", h);
2325
- const d = ["up", "down", "left", "right"], y = [
2356
+ document.addEventListener("pointerup", g);
2357
+ const d = ["up", "down", "left", "right"], m = [
2326
2358
  ...d.map((S) => `shift+${S}`),
2327
2359
  "ctrl+a",
2328
2360
  "⌘+a"
2329
2361
  ];
2330
- $(y.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
2331
- S.repeat || (u = jn(S));
2362
+ $(m.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
2363
+ S.repeat || (h = Fe(S));
2332
2364
  });
2333
- const A = (S) => {
2334
- S.repeat || S.target !== t && S.target !== document.body || (c = void 0, g.clear());
2365
+ const E = (S) => {
2366
+ S.repeat || S.target !== t && S.target !== document.body || (c = void 0, p.clear());
2335
2367
  };
2336
- return $(d.join(","), { keydown: !0, keyup: !1 }, A), {
2368
+ return $(d.join(","), { keydown: !0, keyup: !1 }, E), {
2337
2369
  destroy: () => {
2338
- c = void 0, p = void 0, u = void 0, b.clear(), t.removeEventListener("selectstart", v), document.removeEventListener("selectionchange", b), document.removeEventListener("pointerdown", x), document.removeEventListener("pointerup", h), $.unbind();
2370
+ c = void 0, f = void 0, h = void 0, A.clear(), t.removeEventListener("selectstart", x), document.removeEventListener("selectionchange", A), document.removeEventListener("pointerdown", b), document.removeEventListener("pointerup", g), $.unbind();
2339
2371
  },
2340
2372
  setFilter: a,
2341
2373
  setUser: i,
2342
2374
  setAnnotatingEnabled: l
2343
2375
  };
2344
- }, oe = "SPANS", Ro = (t, e = {}) => {
2345
- Mn(t), kn(t);
2346
- const n = lo(e, {
2376
+ }, ie = "SPANS", Mo = (t, e = {}) => {
2377
+ Be(t), Me(t);
2378
+ const n = fo(e, {
2347
2379
  annotatingEnabled: !0,
2348
- user: Sn()
2349
- }), o = ro(t, n.userSelectAction), { selection: i, viewport: r } = o, a = o.store, s = pn(a), l = mn(o, s, n.adapter);
2350
- let f = n.user;
2351
- const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : oe : n.renderer || oe, c = g === "SPANS" ? $e(t, o, r) : g === "CSS_HIGHLIGHTS" ? Ye(t, o, r) : g === "CANVAS" ? Be(t, o, r) : void 0;
2380
+ user: jn()
2381
+ }), o = ao(t, n.userSelectAction), { selection: i, viewport: r } = o, a = o.store, s = In(a), l = Un(o, s, n.adapter);
2382
+ let u = n.user;
2383
+ const p = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ie : n.renderer || ie, c = p === "SPANS" ? un(t, o, r) : p === "CSS_HIGHLIGHTS" ? cn(t, o, r) : p === "CANVAS" ? Qe(t, o, r) : void 0;
2352
2384
  if (!c)
2353
- throw `Unknown renderer implementation: ${g}`;
2354
- console.debug(`Using ${g} renderer`), n.style && c.setStyle(n.style);
2355
- const p = Ao(t, o, n.offsetReferenceSelector);
2356
- p.setUser(f), p.setAnnotatingEnabled(n.annotatingEnabled);
2357
- const u = bn(o, s, n.adapter), v = () => f, b = (C) => {
2358
- p.setAnnotatingEnabled(
2385
+ throw `Unknown renderer implementation: ${p}`;
2386
+ console.debug(`Using ${p} renderer`), n.style && c.setStyle(n.style);
2387
+ const f = So(t, o, n.offsetReferenceSelector);
2388
+ f.setUser(u), f.setAnnotatingEnabled(n.annotatingEnabled);
2389
+ const h = Dn(o, s, n.adapter), x = () => u, A = (C) => {
2390
+ f.setAnnotatingEnabled(
2359
2391
  C === void 0 ? !0 : C
2360
2392
  );
2361
- }, x = (C) => {
2362
- c.setFilter(C), p.setFilter(C);
2363
- }, h = (C) => {
2364
- f = C, p.setUser(C);
2393
+ }, b = (C) => {
2394
+ c.setFilter(C), f.setFilter(C);
2395
+ }, g = (C) => {
2396
+ u = C, f.setUser(C);
2365
2397
  }, d = (C) => {
2366
- C && (c.setPainter(ao(t, C, n.presence)), C.on("selectionChange", () => c.redraw()));
2367
- }, y = (C) => {
2398
+ C && (c.setPainter(lo(t, C, n.presence)), C.on("selectionChange", () => c.redraw()));
2399
+ }, m = (C) => {
2368
2400
  C ? i.setSelected(C) : i.clear();
2369
2401
  };
2370
2402
  return {
2371
- ...u,
2403
+ ...h,
2372
2404
  destroy: () => {
2373
- c.destroy(), p.destroy(), s.destroy();
2405
+ c.destroy(), f.destroy(), s.destroy();
2374
2406
  },
2375
2407
  element: t,
2376
- getUser: v,
2377
- setAnnotatingEnabled: b,
2378
- setFilter: x,
2408
+ getUser: x,
2409
+ setAnnotatingEnabled: A,
2410
+ setFilter: b,
2379
2411
  setStyle: c.setStyle.bind(c),
2380
2412
  redraw: c.redraw.bind(c),
2381
- setUser: h,
2382
- setSelected: y,
2413
+ setUser: g,
2414
+ setSelected: m,
2383
2415
  setPresenceProvider: d,
2384
2416
  setVisible: c.setVisible.bind(c),
2385
2417
  on: l.on,
2386
2418
  off: l.off,
2387
- scrollIntoView: co(t, a),
2419
+ scrollIntoView: uo(t, a),
2388
2420
  state: o
2389
2421
  };
2390
2422
  };
2391
2423
  export {
2392
- mt as DEFAULT_SELECTED_STYLE,
2424
+ yt as DEFAULT_SELECTED_STYLE,
2393
2425
  q as DEFAULT_STYLE,
2394
- ue as NOT_ANNOTATABLE_CLASS,
2395
- H as NOT_ANNOTATABLE_SELECTOR,
2396
- M as Origin,
2397
- Ge as UserSelectAction,
2398
- To as W3CTextFormat,
2399
- Mn as cancelSingleClickEvents,
2400
- jn as cloneKeyboardEvent,
2401
- Hn as clonePointerEvent,
2402
- Eo as createBody,
2403
- Be as createCanvasRenderer,
2404
- Ye as createHighlightsRenderer,
2405
- Ke as createRenderer,
2406
- $e as createSpansRenderer,
2407
- Ro as createTextAnnotator,
2408
- ro as createTextAnnotatorState,
2409
- Oo as denormalizeRectWithOffset,
2410
- lo as fillDefaults,
2411
- So as getAnnotatableFragment,
2412
- Co as getClientRectsPonyfill,
2413
- _n as getQuoteContext,
2414
- kt as getRangeAnnotatableContents,
2426
+ re as NOT_ANNOTATABLE_CLASS,
2427
+ j as NOT_ANNOTATABLE_SELECTOR,
2428
+ N as Origin,
2429
+ bn as UserSelectAction,
2430
+ Bo as W3CTextFormat,
2431
+ Be as cancelSingleClickEvents,
2432
+ Fe as cloneKeyboardEvent,
2433
+ ze as clonePointerEvent,
2434
+ Ro as createBody,
2435
+ Qe as createCanvasRenderer,
2436
+ cn as createHighlightsRenderer,
2437
+ an as createRenderer,
2438
+ un as createSpansRenderer,
2439
+ Mo as createTextAnnotator,
2440
+ ao as createTextAnnotatorState,
2441
+ Ut as debounce,
2442
+ To as denormalizeRectWithOffset,
2443
+ fo as fillDefaults,
2444
+ Co as getAnnotatableFragment,
2445
+ Lo as getClientRectsPonyfill,
2446
+ Ie as getQuoteContext,
2447
+ Nt as getRangeAnnotatableContents,
2415
2448
  W as isRevived,
2416
- Vn as isWhitespaceOrEmpty,
2417
- Yn as mergeClientRects,
2418
- $n as normalizeRectWithOffset,
2419
- Ae as paint,
2420
- Wn as parseW3CTextAnnotation,
2421
- kn as programmaticallyFocusable,
2422
- Xn as rangeToSelector,
2423
- Ct as reviveAnnotation,
2424
- fe as reviveSelector,
2425
- yt as reviveTarget,
2426
- qn as serializeW3CTextAnnotation,
2427
- Bn as splitAnnotatableRanges,
2428
- Lo as toDomRectList,
2429
- Pn as trimRangeToContainer,
2430
- Un as whitespaceOrEmptyRegex
2449
+ Ue as isWhitespaceOrEmpty,
2450
+ Ke as mergeClientRects,
2451
+ He as normalizeRectWithOffset,
2452
+ Se as paint,
2453
+ Gn as parseW3CTextAnnotation,
2454
+ Me as programmaticallyFocusable,
2455
+ Xe as rangeToSelector,
2456
+ wt as reviveAnnotation,
2457
+ se as reviveSelector,
2458
+ bt as reviveTarget,
2459
+ Qn as serializeW3CTextAnnotation,
2460
+ Re as splitAnnotatableRanges,
2461
+ Oo as toDomRectList,
2462
+ Ye as trimRangeToContainer,
2463
+ _e as whitespaceOrEmptyRegex
2431
2464
  };
2432
2465
  //# sourceMappingURL=text-annotator.es.js.map