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