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