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