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