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