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