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