@soomo/text-annotator 3.0.0-staging.32 → 3.0.0-staging.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/SelectionHandler.d.ts +2 -1
- package/dist/src/TextAnnotator.d.ts +1 -0
- package/dist/src/TextAnnotatorOptions.d.ts +1 -1
- package/dist/src/state/TextAnnotatorState.d.ts +1 -1
- package/dist/text-annotator.es.js +686 -679
- package/dist/text-annotator.es.js.map +1 -1
- package/dist/text-annotator.umd.js +2 -2
- package/dist/text-annotator.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -37,10 +37,10 @@ const q = {
|
|
|
37
37
|
}, Rt = (e) => {
|
|
38
38
|
const t = e.cloneContents();
|
|
39
39
|
return t.querySelectorAll(Y).forEach((n) => n.remove()), t;
|
|
40
|
-
},
|
|
40
|
+
}, Ee = (e) => e.addEventListener("click", (t) => {
|
|
41
41
|
// Allow clicks within not-annotatable elements
|
|
42
42
|
!t.target.closest(Y) && !t.target.closest("a") && t.preventDefault();
|
|
43
|
-
}),
|
|
43
|
+
}), Te = (e) => {
|
|
44
44
|
!e.hasAttribute("tabindex") && e.tabIndex < 0 && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
|
|
45
45
|
}, It = (e, t = 10) => {
|
|
46
46
|
let n;
|
|
@@ -71,31 +71,31 @@ const q = {
|
|
|
71
71
|
startOffset: o,
|
|
72
72
|
endContainer: i,
|
|
73
73
|
endOffset: r
|
|
74
|
-
} = e, s = Array.from(t.childNodes).map((
|
|
75
|
-
const
|
|
76
|
-
return
|
|
77
|
-
}), a = Dt(n, t),
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
return e.setStart(
|
|
82
|
-
}, h = (
|
|
83
|
-
const
|
|
84
|
-
return
|
|
74
|
+
} = e, s = Array.from(t.childNodes).map((l) => {
|
|
75
|
+
const g = l.cloneNode(!0);
|
|
76
|
+
return l.nodeName === "CANVAS" ? l : g;
|
|
77
|
+
}), a = Dt(n, t), f = Dt(i, t), p = () => {
|
|
78
|
+
const l = t;
|
|
79
|
+
l.replaceChildren(...s);
|
|
80
|
+
const g = yt(a, l), d = yt(f, l);
|
|
81
|
+
return e.setStart(g, o), e.setEnd(d, r), e;
|
|
82
|
+
}, h = (l) => {
|
|
83
|
+
const g = document.createElement("SPAN");
|
|
84
|
+
return l.surroundContents(g), g;
|
|
85
85
|
};
|
|
86
86
|
if (n === i)
|
|
87
87
|
throw "Not implemented";
|
|
88
88
|
{
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
return (
|
|
89
|
+
const l = document.createRange();
|
|
90
|
+
l.selectNodeContents(n), l.setStart(n, o);
|
|
91
|
+
const g = h(l), d = document.createRange();
|
|
92
|
+
d.selectNode(i), d.setEnd(i, r);
|
|
93
|
+
const A = h(d), b = Be(e).reverse().map((u) => {
|
|
94
|
+
var v;
|
|
95
|
+
const c = document.createElement("SPAN");
|
|
96
|
+
return (v = u.parentNode) == null || v.insertBefore(c, u), c.appendChild(u), c;
|
|
97
97
|
});
|
|
98
|
-
return { unwrap: p, nodes: [
|
|
98
|
+
return { unwrap: p, nodes: [g, ...b, A] };
|
|
99
99
|
}
|
|
100
100
|
}, Be = (e) => {
|
|
101
101
|
const {
|
|
@@ -121,10 +121,10 @@ const q = {
|
|
|
121
121
|
r.setStart(i, 0), r.setEnd(e.startContainer, e.startOffset);
|
|
122
122
|
const s = Rt(r).textContent, a = document.createRange();
|
|
123
123
|
a.setStart(e.endContainer, e.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
124
|
-
const
|
|
124
|
+
const f = Rt(a).textContent;
|
|
125
125
|
return {
|
|
126
126
|
prefix: s.substring(s.length - n),
|
|
127
|
-
suffix:
|
|
127
|
+
suffix: f.substring(0, n)
|
|
128
128
|
};
|
|
129
129
|
}, Re = /^\s*$/, Ve = (e) => Re.test(e.toString()), W = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), Oe = (e, t) => {
|
|
130
130
|
const n = (r) => Math.round(r * 10) / 10, o = {
|
|
@@ -184,41 +184,41 @@ const q = {
|
|
|
184
184
|
}), Fe = (e, t, n) => {
|
|
185
185
|
const o = document.createRange(), i = n ? e.startContainer.parentElement.closest(n) : t;
|
|
186
186
|
o.setStart(i, 0), o.setEnd(e.startContainer, e.startOffset);
|
|
187
|
-
const r = Rt(o).textContent, s = e.toString(), a = r.length || 0,
|
|
188
|
-
return n ? { quote: s, start: a, end:
|
|
187
|
+
const r = Rt(o).textContent, s = e.toString(), a = r.length || 0, f = a + s.length;
|
|
188
|
+
return n ? { quote: s, start: a, end: f, range: e, offsetReference: i } : { quote: s, start: a, end: f, range: e };
|
|
189
189
|
}, oe = (e, t) => {
|
|
190
|
-
var h,
|
|
190
|
+
var h, l;
|
|
191
191
|
const { start: n, end: o } = e, i = e.offsetReference || t, r = document.createNodeIterator(
|
|
192
192
|
t,
|
|
193
193
|
NodeFilter.SHOW_TEXT,
|
|
194
|
-
(
|
|
195
|
-
var
|
|
196
|
-
return (
|
|
194
|
+
(g) => {
|
|
195
|
+
var d;
|
|
196
|
+
return (d = g.parentElement) != null && d.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
197
197
|
}
|
|
198
198
|
);
|
|
199
199
|
let s = 0;
|
|
200
200
|
const a = document.createRange();
|
|
201
|
-
let
|
|
202
|
-
|
|
201
|
+
let f = r.nextNode();
|
|
202
|
+
f === null && console.error("Could not revive annotation target. Content missing.");
|
|
203
203
|
let p = !i;
|
|
204
|
-
for (;
|
|
205
|
-
if (p || (p = i == null ? void 0 : i.contains(
|
|
206
|
-
const
|
|
207
|
-
if (s +
|
|
208
|
-
a.setStart(
|
|
204
|
+
for (; f !== null; ) {
|
|
205
|
+
if (p || (p = i == null ? void 0 : i.contains(f)), p) {
|
|
206
|
+
const g = ((h = f.textContent) == null ? void 0 : h.length) || 0;
|
|
207
|
+
if (s + g > n) {
|
|
208
|
+
a.setStart(f, n - s);
|
|
209
209
|
break;
|
|
210
210
|
}
|
|
211
|
-
s +=
|
|
211
|
+
s += g;
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
f = r.nextNode();
|
|
214
214
|
}
|
|
215
|
-
for (;
|
|
216
|
-
const
|
|
217
|
-
if (s +
|
|
218
|
-
a.setEnd(
|
|
215
|
+
for (; f !== null; ) {
|
|
216
|
+
const g = ((l = f.textContent) == null ? void 0 : l.length) || 0;
|
|
217
|
+
if (s + g >= o) {
|
|
218
|
+
a.setEnd(f, o - s);
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
|
-
s +=
|
|
221
|
+
s += g, f = r.nextNode();
|
|
222
222
|
}
|
|
223
223
|
return {
|
|
224
224
|
...e,
|
|
@@ -276,8 +276,8 @@ const q = {
|
|
|
276
276
|
detail: e.detail,
|
|
277
277
|
timeStamp: e.timeStamp
|
|
278
278
|
}), Ue = (e) => {
|
|
279
|
-
const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n,
|
|
280
|
-
return { top: t, left: n, minX: r, minY: s, maxX: a, maxY:
|
|
279
|
+
const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n, f = i - t;
|
|
280
|
+
return { top: t, left: n, minX: r, minY: s, maxX: a, maxY: f };
|
|
281
281
|
}, He = (e) => {
|
|
282
282
|
let t = /* @__PURE__ */ new Set();
|
|
283
283
|
return (o) => {
|
|
@@ -286,46 +286,46 @@ const q = {
|
|
|
286
286
|
};
|
|
287
287
|
}, Nt = (e, t, n, o) => {
|
|
288
288
|
const { store: i, selection: r, hover: s } = t;
|
|
289
|
-
let a,
|
|
290
|
-
const h = He(n),
|
|
291
|
-
const { x:
|
|
289
|
+
let a, f, p;
|
|
290
|
+
const h = He(n), l = (M) => {
|
|
291
|
+
const { x: y, y: w } = e.getBoundingClientRect(), S = i.getAt(M.clientX - y, M.clientY - w, f);
|
|
292
292
|
S ? s.current !== S.id && (e.classList.add("hovered"), s.set(S.id)) : s.current && (e.classList.remove("hovered"), s.set(null));
|
|
293
293
|
};
|
|
294
|
-
e.addEventListener("pointermove",
|
|
295
|
-
const
|
|
294
|
+
e.addEventListener("pointermove", l);
|
|
295
|
+
const g = (M = !1) => {
|
|
296
296
|
p && p.clear();
|
|
297
|
-
const
|
|
297
|
+
const y = Ue(e), { minX: w, minY: S, maxX: C, maxY: E } = y, B = f ? i.getIntersecting(w, S, C, E).filter(({ annotation: $ }) => f($)) : i.getIntersecting(w, S, C, E), I = r.selected.map(({ id: $ }) => $), z = B.map(({ annotation: $, rects: we }) => {
|
|
298
298
|
const Ae = I.includes($.id), ve = $.id === s.current;
|
|
299
299
|
return { annotation: $, rects: we, state: { selected: Ae, hover: ve } };
|
|
300
300
|
});
|
|
301
|
-
o.redraw(z,
|
|
302
|
-
},
|
|
303
|
-
p =
|
|
304
|
-
},
|
|
305
|
-
a =
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
i.observe(
|
|
310
|
-
const
|
|
311
|
-
document.addEventListener("scroll",
|
|
312
|
-
const
|
|
313
|
-
i.recalculatePositions(), p && p.reset(),
|
|
301
|
+
o.redraw(z, y, a, p, M), setTimeout(() => h(B.map(({ annotation: $ }) => $)), 1);
|
|
302
|
+
}, d = (M) => {
|
|
303
|
+
p = M, g();
|
|
304
|
+
}, A = (M) => {
|
|
305
|
+
a = M, g();
|
|
306
|
+
}, m = (M) => {
|
|
307
|
+
f = M, g(!1);
|
|
308
|
+
}, b = () => g();
|
|
309
|
+
i.observe(b);
|
|
310
|
+
const u = r.subscribe(() => g()), c = () => g(!0);
|
|
311
|
+
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
312
|
+
const v = It(() => {
|
|
313
|
+
i.recalculatePositions(), p && p.reset(), g();
|
|
314
314
|
});
|
|
315
|
-
window.addEventListener("resize",
|
|
316
|
-
const x = new ResizeObserver(
|
|
315
|
+
window.addEventListener("resize", v);
|
|
316
|
+
const x = new ResizeObserver(v);
|
|
317
317
|
x.observe(e);
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
const L = { attributes: !0, childList: !0, subtree: !0 }, T = new MutationObserver((M) => {
|
|
319
|
+
M.every((w) => w.target === e || e.contains(w.target)) || g(!0);
|
|
320
320
|
});
|
|
321
|
-
return
|
|
321
|
+
return T.observe(document.body, L), {
|
|
322
322
|
destroy: () => {
|
|
323
|
-
e.removeEventListener("pointermove",
|
|
323
|
+
e.removeEventListener("pointermove", l), o.destroy(), i.unobserve(b), u(), document.removeEventListener("scroll", c), window.removeEventListener("resize", v), x.disconnect(), T.disconnect();
|
|
324
324
|
},
|
|
325
|
-
redraw:
|
|
326
|
-
setStyle:
|
|
327
|
-
setFilter:
|
|
328
|
-
setPainter:
|
|
325
|
+
redraw: g,
|
|
326
|
+
setStyle: A,
|
|
327
|
+
setFilter: m,
|
|
328
|
+
setPainter: d,
|
|
329
329
|
setVisible: o.setVisible
|
|
330
330
|
};
|
|
331
331
|
}, _e = () => {
|
|
@@ -337,28 +337,28 @@ const q = {
|
|
|
337
337
|
e.classList.add("r6o-annotatable");
|
|
338
338
|
const t = _e(), n = t.getContext("2d");
|
|
339
339
|
document.body.appendChild(t);
|
|
340
|
-
const o = (a,
|
|
341
|
-
const { width:
|
|
342
|
-
n.clearRect(-0.5, -0.5,
|
|
343
|
-
const { top:
|
|
344
|
-
[...a].sort((
|
|
345
|
-
const { annotation: { target: { created:
|
|
346
|
-
return
|
|
347
|
-
}).forEach((
|
|
340
|
+
const o = (a, f, p, h) => requestAnimationFrame(() => {
|
|
341
|
+
const { width: l, height: g } = t;
|
|
342
|
+
n.clearRect(-0.5, -0.5, l + 1, g + 1), h && h.clear();
|
|
343
|
+
const { top: d, left: A } = f;
|
|
344
|
+
[...a].sort((b, u) => {
|
|
345
|
+
const { annotation: { target: { created: c } } } = b, { annotation: { target: { created: v } } } = u;
|
|
346
|
+
return c.getTime() - v.getTime();
|
|
347
|
+
}).forEach((b) => {
|
|
348
348
|
var x;
|
|
349
|
-
const
|
|
350
|
-
x:
|
|
351
|
-
y:
|
|
352
|
-
width:
|
|
353
|
-
height:
|
|
349
|
+
const u = p ? typeof p == "function" ? p(b.annotation, b.state) : p : (x = b.state) != null && x.selected ? gt : q, c = h && h.paint(b, f) || u, v = b.rects.map(({ x: L, y: T, width: k, height: M }) => ({
|
|
350
|
+
x: L + A,
|
|
351
|
+
y: T + d,
|
|
352
|
+
width: k,
|
|
353
|
+
height: M
|
|
354
354
|
}));
|
|
355
|
-
if (n.fillStyle =
|
|
356
|
-
({ x:
|
|
357
|
-
),
|
|
358
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
n.beginPath(), n.moveTo(
|
|
355
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, v.forEach(
|
|
356
|
+
({ x: L, y: T, width: k, height: M }) => n.fillRect(L, T, k, M)
|
|
357
|
+
), c.underlineColor) {
|
|
358
|
+
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
359
|
+
const L = c.underlineOffset ?? 0;
|
|
360
|
+
v.forEach(({ x: T, y: k, width: M, height: y }) => {
|
|
361
|
+
n.beginPath(), n.moveTo(T, k + y + L), n.lineTo(T + M, k + y + L), n.stroke();
|
|
362
362
|
});
|
|
363
363
|
}
|
|
364
364
|
});
|
|
@@ -377,7 +377,7 @@ const q = {
|
|
|
377
377
|
}, $e = (e, t, n) => Nt(e, t, n, Xe(e));
|
|
378
378
|
var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
379
379
|
return typeof e == "string" ? e.length > 0 : typeof e == "number";
|
|
380
|
-
},
|
|
380
|
+
}, N = function(e, t, n) {
|
|
381
381
|
return t === void 0 && (t = 0), n === void 0 && (n = Math.pow(10, t)), Math.round(n * e) / n + 0;
|
|
382
382
|
}, H = function(e, t, n) {
|
|
383
383
|
return t === void 0 && (t = 0), n === void 0 && (n = 1), e > n ? n : e > t ? e : t;
|
|
@@ -386,7 +386,7 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
386
386
|
}, Ut = function(e) {
|
|
387
387
|
return { r: H(e.r, 0, 255), g: H(e.g, 0, 255), b: H(e.b, 0, 255), a: H(e.a) };
|
|
388
388
|
}, wt = function(e) {
|
|
389
|
-
return { r:
|
|
389
|
+
return { r: N(e.r), g: N(e.g), b: N(e.b), a: N(e.a, 3) };
|
|
390
390
|
}, Ge = /^#([0-9a-f]{3,8})$/i, ct = function(e) {
|
|
391
391
|
var t = e.toString(16);
|
|
392
392
|
return t.length < 2 ? "0" + t : t;
|
|
@@ -396,12 +396,12 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
396
396
|
}, ae = function(e) {
|
|
397
397
|
var t = e.h, n = e.s, o = e.v, i = e.a;
|
|
398
398
|
t = t / 360 * 6, n /= 100, o /= 100;
|
|
399
|
-
var r = Math.floor(t), s = o * (1 - n), a = o * (1 - (t - r) * n),
|
|
400
|
-
return { r: 255 * [o, a, s, s,
|
|
399
|
+
var r = Math.floor(t), s = o * (1 - n), a = o * (1 - (t - r) * n), f = o * (1 - (1 - t + r) * n), p = r % 6;
|
|
400
|
+
return { r: 255 * [o, a, s, s, f, o][p], g: 255 * [f, o, o, a, s, s][p], b: 255 * [s, s, f, o, o, a][p], a: i };
|
|
401
401
|
}, Ht = function(e) {
|
|
402
402
|
return { h: ie(e.h), s: H(e.s, 0, 100), l: H(e.l, 0, 100), a: H(e.a) };
|
|
403
403
|
}, _t = function(e) {
|
|
404
|
-
return { h:
|
|
404
|
+
return { h: N(e.h), s: N(e.s), l: N(e.l), a: N(e.a, 3) };
|
|
405
405
|
}, Yt = function(e) {
|
|
406
406
|
return ae((n = (t = e).s, { h: t.h, s: (n *= ((o = t.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: t.a }));
|
|
407
407
|
var t, n, o;
|
|
@@ -410,7 +410,7 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
410
410
|
var t, n, o, i;
|
|
411
411
|
}, We = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ze = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ze = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Xt = { string: [[function(e) {
|
|
412
412
|
var t = Ge.exec(e);
|
|
413
|
-
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ?
|
|
413
|
+
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? N(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? N(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
414
414
|
}, "hex"], [function(e) {
|
|
415
415
|
var t = qe.exec(e) || Ze.exec(e);
|
|
416
416
|
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Ut({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
|
|
@@ -457,13 +457,13 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
457
457
|
return e.prototype.isValid = function() {
|
|
458
458
|
return this.parsed !== null;
|
|
459
459
|
}, e.prototype.brightness = function() {
|
|
460
|
-
return
|
|
460
|
+
return N(vt(this.rgba), 2);
|
|
461
461
|
}, e.prototype.isDark = function() {
|
|
462
462
|
return vt(this.rgba) < 0.5;
|
|
463
463
|
}, e.prototype.isLight = function() {
|
|
464
464
|
return vt(this.rgba) >= 0.5;
|
|
465
465
|
}, e.prototype.toHex = function() {
|
|
466
|
-
return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(
|
|
466
|
+
return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(N(255 * r)) : "", "#" + ct(n) + ct(o) + ct(i) + s;
|
|
467
467
|
var t, n, o, i, r, s;
|
|
468
468
|
}, e.prototype.toRgb = function() {
|
|
469
469
|
return wt(this.rgba);
|
|
@@ -476,7 +476,7 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
476
476
|
return t = _t(it(this.rgba)), n = t.h, o = t.s, i = t.l, (r = t.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
477
477
|
var t, n, o, i, r;
|
|
478
478
|
}, e.prototype.toHsv = function() {
|
|
479
|
-
return t = re(this.rgba), { h:
|
|
479
|
+
return t = re(this.rgba), { h: N(t.h), s: N(t.s), v: N(t.v), a: N(t.a, 3) };
|
|
480
480
|
var t;
|
|
481
481
|
}, e.prototype.invert = function() {
|
|
482
482
|
return _({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
|
|
@@ -494,11 +494,11 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
494
494
|
}, e.prototype.rotate = function(t) {
|
|
495
495
|
return t === void 0 && (t = 15), this.hue(this.hue() + t);
|
|
496
496
|
}, e.prototype.alpha = function(t) {
|
|
497
|
-
return typeof t == "number" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) :
|
|
497
|
+
return typeof t == "number" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) : N(this.rgba.a, 3);
|
|
498
498
|
var n;
|
|
499
499
|
}, e.prototype.hue = function(t) {
|
|
500
500
|
var n = it(this.rgba);
|
|
501
|
-
return typeof t == "number" ? _({ h: t, s: n.s, l: n.l, a: n.a }) :
|
|
501
|
+
return typeof t == "number" ? _({ h: t, s: n.s, l: n.l, a: n.a }) : N(n.h);
|
|
502
502
|
}, e.prototype.isEqual = function(t) {
|
|
503
503
|
return this.toHex() === _(t).toHex();
|
|
504
504
|
}, e;
|
|
@@ -522,19 +522,19 @@ const Qe = (e) => [
|
|
|
522
522
|
setVisible: (r) => {
|
|
523
523
|
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
524
524
|
},
|
|
525
|
-
redraw: (r, s, a,
|
|
526
|
-
|
|
527
|
-
const p = new Set(r.map((
|
|
528
|
-
Array.from(t).filter((
|
|
529
|
-
const h = r.map((
|
|
530
|
-
var
|
|
531
|
-
const
|
|
532
|
-
return `::highlight(_${
|
|
525
|
+
redraw: (r, s, a, f) => {
|
|
526
|
+
f && f.clear();
|
|
527
|
+
const p = new Set(r.map((l) => l.annotation.id));
|
|
528
|
+
Array.from(t).filter((l) => !p.has(l));
|
|
529
|
+
const h = r.map((l) => {
|
|
530
|
+
var A;
|
|
531
|
+
const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (A = l.state) != null && A.selected ? gt : q, d = f && f.paint(l, s) || g;
|
|
532
|
+
return `::highlight(_${l.annotation.id}) { ${Qe(d)} }`;
|
|
533
533
|
});
|
|
534
534
|
e.innerHTML = h.join(`
|
|
535
|
-
`), CSS.highlights.clear(), r.forEach(({ annotation:
|
|
536
|
-
const
|
|
537
|
-
CSS.highlights.set(`_${
|
|
535
|
+
`), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
|
|
536
|
+
const g = l.target.selector.map((A) => A.range), d = new Highlight(...g);
|
|
537
|
+
CSS.highlights.set(`_${l.id}`, d);
|
|
538
538
|
}), t = p;
|
|
539
539
|
}
|
|
540
540
|
};
|
|
@@ -572,14 +572,14 @@ const en = (e, t) => {
|
|
|
572
572
|
destroy: () => {
|
|
573
573
|
t.remove();
|
|
574
574
|
},
|
|
575
|
-
redraw: (s, a,
|
|
576
|
-
const
|
|
577
|
-
!p && !
|
|
578
|
-
|
|
579
|
-
const
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
|
|
575
|
+
redraw: (s, a, f, p, h) => {
|
|
576
|
+
const g = !(Vt(n, s) && h);
|
|
577
|
+
!p && !g || (g && (t.innerHTML = ""), s.forEach((d) => {
|
|
578
|
+
d.rects.map((A) => {
|
|
579
|
+
const m = en(A, s), b = Se(d, a, f, p, m);
|
|
580
|
+
if (g) {
|
|
581
|
+
const u = document.createElement("span");
|
|
582
|
+
u.className = "r6o-annotation", u.dataset.annotation = d.annotation.id, u.style.left = `${A.x}px`, u.style.top = `${A.y}px`, u.style.width = `${A.width}px`, u.style.height = `${A.height}px`, u.style.backgroundColor = _((b == null ? void 0 : b.fill) || q.fill).alpha((b == null ? void 0 : b.fillOpacity) === void 0 ? q.fillOpacity : b.fillOpacity).toHex(), b.underlineStyle && (u.style.borderStyle = b.underlineStyle), b.underlineColor && (u.style.borderColor = b.underlineColor), b.underlineThickness && (u.style.borderBottomWidth = `${b.underlineThickness}px`), b.underlineOffset && (u.style.paddingBottom = `${b.underlineOffset}px`), t.appendChild(u);
|
|
583
583
|
}
|
|
584
584
|
});
|
|
585
585
|
}), n = s);
|
|
@@ -589,11 +589,11 @@ const en = (e, t) => {
|
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
591
|
}, on = (e, t, n) => Nt(e, t, n, nn(e));
|
|
592
|
-
var
|
|
592
|
+
var F = [];
|
|
593
593
|
for (var St = 0; St < 256; ++St)
|
|
594
|
-
|
|
594
|
+
F.push((St + 256).toString(16).slice(1));
|
|
595
595
|
function rn(e, t = 0) {
|
|
596
|
-
return (
|
|
596
|
+
return (F[e[t + 0]] + F[e[t + 1]] + F[e[t + 2]] + F[e[t + 3]] + "-" + F[e[t + 4]] + F[e[t + 5]] + "-" + F[e[t + 6]] + F[e[t + 7]] + "-" + F[e[t + 8]] + F[e[t + 9]] + "-" + F[e[t + 10]] + F[e[t + 11]] + F[e[t + 12]] + F[e[t + 13]] + F[e[t + 14]] + F[e[t + 15]]).toLowerCase();
|
|
597
597
|
}
|
|
598
598
|
var dt, an = new Uint8Array(16);
|
|
599
599
|
function sn() {
|
|
@@ -644,10 +644,10 @@ function Ft(e, t = Ct) {
|
|
|
644
644
|
const o = /* @__PURE__ */ new Set();
|
|
645
645
|
function i(a) {
|
|
646
646
|
if (cn(e, a) && (e = a, n)) {
|
|
647
|
-
const
|
|
647
|
+
const f = !Z.length;
|
|
648
648
|
for (const p of o)
|
|
649
649
|
p[1](), Z.push(p, e);
|
|
650
|
-
if (
|
|
650
|
+
if (f) {
|
|
651
651
|
for (let p = 0; p < Z.length; p += 2)
|
|
652
652
|
Z[p][0](Z[p + 1]);
|
|
653
653
|
Z.length = 0;
|
|
@@ -657,8 +657,8 @@ function Ft(e, t = Ct) {
|
|
|
657
657
|
function r(a) {
|
|
658
658
|
i(a(e));
|
|
659
659
|
}
|
|
660
|
-
function s(a,
|
|
661
|
-
const p = [a,
|
|
660
|
+
function s(a, f = Ct) {
|
|
661
|
+
const p = [a, f];
|
|
662
662
|
return o.add(p), o.size === 1 && (n = t(i, r) || Ct), a(e), () => {
|
|
663
663
|
o.delete(p), o.size === 0 && n && (n(), n = null);
|
|
664
664
|
};
|
|
@@ -686,47 +686,47 @@ var un = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE =
|
|
|
686
686
|
const xt = { selected: [] }, fn = (e, t = "EDIT") => {
|
|
687
687
|
const { subscribe: n, set: o } = Ft(xt);
|
|
688
688
|
let i = t, r = xt;
|
|
689
|
-
n((
|
|
689
|
+
n((d) => r = d);
|
|
690
690
|
const s = () => o(xt), a = () => {
|
|
691
|
-
var
|
|
692
|
-
return ((
|
|
693
|
-
},
|
|
691
|
+
var d;
|
|
692
|
+
return ((d = r.selected) == null ? void 0 : d.length) === 0;
|
|
693
|
+
}, f = (d) => {
|
|
694
694
|
if (a())
|
|
695
695
|
return !1;
|
|
696
|
-
const
|
|
697
|
-
return r.selected.some((
|
|
698
|
-
}, p = (
|
|
699
|
-
const
|
|
700
|
-
if (!
|
|
701
|
-
console.warn("Invalid selection: " +
|
|
696
|
+
const A = typeof d == "string" ? d : d.id;
|
|
697
|
+
return r.selected.some((m) => m.id === A);
|
|
698
|
+
}, p = (d, A) => {
|
|
699
|
+
const m = e.getAnnotation(d);
|
|
700
|
+
if (!m) {
|
|
701
|
+
console.warn("Invalid selection: " + d);
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
|
-
switch (Zt(
|
|
704
|
+
switch (Zt(m, i)) {
|
|
705
705
|
case "EDIT":
|
|
706
|
-
o({ selected: [{ id:
|
|
706
|
+
o({ selected: [{ id: d, editable: !0 }], event: A });
|
|
707
707
|
break;
|
|
708
708
|
case "SELECT":
|
|
709
|
-
o({ selected: [{ id:
|
|
709
|
+
o({ selected: [{ id: d }], event: A });
|
|
710
710
|
break;
|
|
711
711
|
default:
|
|
712
|
-
o({ selected: [], event:
|
|
712
|
+
o({ selected: [], event: A });
|
|
713
713
|
}
|
|
714
|
-
}, h = (
|
|
715
|
-
const
|
|
714
|
+
}, h = (d, A) => {
|
|
715
|
+
const m = Array.isArray(d) ? d : [d], b = m.map((u) => e.getAnnotation(u)).filter((u) => !!u);
|
|
716
716
|
o({
|
|
717
|
-
selected:
|
|
718
|
-
const
|
|
719
|
-
return { id:
|
|
717
|
+
selected: b.map((u) => {
|
|
718
|
+
const c = A === void 0 ? Zt(u, i) === "EDIT" : A;
|
|
719
|
+
return { id: u.id, editable: c };
|
|
720
720
|
})
|
|
721
|
-
}),
|
|
722
|
-
},
|
|
721
|
+
}), b.length !== m.length && console.warn("Invalid selection", d);
|
|
722
|
+
}, l = (d) => {
|
|
723
723
|
if (a())
|
|
724
724
|
return !1;
|
|
725
|
-
const { selected:
|
|
726
|
-
|
|
727
|
-
},
|
|
725
|
+
const { selected: A } = r;
|
|
726
|
+
A.some(({ id: m }) => d.includes(m)) && o({ selected: A.filter(({ id: m }) => !d.includes(m)) });
|
|
727
|
+
}, g = (d) => i = d;
|
|
728
728
|
return e.observe(
|
|
729
|
-
({ changes:
|
|
729
|
+
({ changes: d }) => l((d.deleted || []).map((A) => A.id))
|
|
730
730
|
), {
|
|
731
731
|
get event() {
|
|
732
732
|
return r ? r.event : null;
|
|
@@ -736,18 +736,18 @@ const xt = { selected: [] }, fn = (e, t = "EDIT") => {
|
|
|
736
736
|
},
|
|
737
737
|
clear: s,
|
|
738
738
|
isEmpty: a,
|
|
739
|
-
isSelected:
|
|
739
|
+
isSelected: f,
|
|
740
740
|
setSelected: h,
|
|
741
|
-
setUserSelectAction:
|
|
741
|
+
setUserSelectAction: g,
|
|
742
742
|
subscribe: n,
|
|
743
743
|
userSelect: p
|
|
744
744
|
};
|
|
745
745
|
}, Zt = (e, t) => typeof t == "function" ? t(e) : t || "EDIT";
|
|
746
|
-
var
|
|
746
|
+
var P = [];
|
|
747
747
|
for (var Lt = 0; Lt < 256; ++Lt)
|
|
748
|
-
|
|
748
|
+
P.push((Lt + 256).toString(16).slice(1));
|
|
749
749
|
function pn(e, t = 0) {
|
|
750
|
-
return (
|
|
750
|
+
return (P[e[t + 0]] + P[e[t + 1]] + P[e[t + 2]] + P[e[t + 3]] + "-" + P[e[t + 4]] + P[e[t + 5]] + "-" + P[e[t + 6]] + P[e[t + 7]] + "-" + P[e[t + 8]] + P[e[t + 9]] + "-" + P[e[t + 10]] + P[e[t + 11]] + P[e[t + 12]] + P[e[t + 13]] + P[e[t + 14]] + P[e[t + 15]]).toLowerCase();
|
|
751
751
|
}
|
|
752
752
|
var ut, hn = new Uint8Array(16);
|
|
753
753
|
function gn() {
|
|
@@ -799,10 +799,10 @@ const Cn = (e, t) => {
|
|
|
799
799
|
if (!(!e.options.origin || e.options.origin === r))
|
|
800
800
|
return !1;
|
|
801
801
|
if (e.options.ignore) {
|
|
802
|
-
const { ignore: s } = e.options, a = (
|
|
802
|
+
const { ignore: s } = e.options, a = (f) => f && f.length > 0;
|
|
803
803
|
if (!(a(i.created) || a(i.deleted))) {
|
|
804
|
-
const
|
|
805
|
-
if (s === "BODY_ONLY" &&
|
|
804
|
+
const f = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), p = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
|
|
805
|
+
if (s === "BODY_ONLY" && f && !p || s === "TARGET_ONLY" && p && !f)
|
|
806
806
|
return !1;
|
|
807
807
|
}
|
|
808
808
|
}
|
|
@@ -816,31 +816,31 @@ const Cn = (e, t) => {
|
|
|
816
816
|
} else
|
|
817
817
|
return !0;
|
|
818
818
|
}, xn = (e, t) => {
|
|
819
|
-
const n = new Set((e.created || []).map((
|
|
820
|
-
...(e.created || []).filter((
|
|
819
|
+
const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), i = new Set((t.created || []).map((l) => l.id)), r = new Set((t.deleted || []).map((l) => l.id)), s = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), f = [
|
|
820
|
+
...(e.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? t.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
|
|
821
821
|
...t.created || []
|
|
822
822
|
], p = [
|
|
823
|
-
...(e.deleted || []).filter((
|
|
824
|
-
...(t.deleted || []).filter((
|
|
823
|
+
...(e.deleted || []).filter((l) => !i.has(l.id)),
|
|
824
|
+
...(t.deleted || []).filter((l) => !n.has(l.id))
|
|
825
825
|
], h = [
|
|
826
|
-
...(e.updated || []).filter(({ newValue:
|
|
827
|
-
const { oldValue:
|
|
828
|
-
if (s.has(
|
|
829
|
-
const
|
|
830
|
-
return le(
|
|
826
|
+
...(e.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
|
|
827
|
+
const { oldValue: g, newValue: d } = l;
|
|
828
|
+
if (s.has(d.id)) {
|
|
829
|
+
const A = t.updated.find((m) => m.oldValue.id === d.id).newValue;
|
|
830
|
+
return le(g, A);
|
|
831
831
|
} else
|
|
832
|
-
return
|
|
832
|
+
return l;
|
|
833
833
|
}),
|
|
834
|
-
...(t.updated || []).filter(({ oldValue:
|
|
834
|
+
...(t.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
|
|
835
835
|
];
|
|
836
|
-
return { created:
|
|
837
|
-
}, Ln = (e) => e.id !== void 0,
|
|
838
|
-
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (
|
|
839
|
-
const S = n.findIndex((C) => C.onChange ==
|
|
836
|
+
return { created: f, deleted: p, updated: h };
|
|
837
|
+
}, Ln = (e) => e.id !== void 0, En = () => {
|
|
838
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (w, S = {}) => n.push({ onChange: w, options: S }), i = (w) => {
|
|
839
|
+
const S = n.findIndex((C) => C.onChange == w);
|
|
840
840
|
S > -1 && n.splice(S, 1);
|
|
841
|
-
}, r = (
|
|
841
|
+
}, r = (w, S) => {
|
|
842
842
|
const C = {
|
|
843
|
-
origin:
|
|
843
|
+
origin: w,
|
|
844
844
|
changes: {
|
|
845
845
|
created: S.created || [],
|
|
846
846
|
updated: S.updated || [],
|
|
@@ -848,144 +848,144 @@ const Cn = (e, t) => {
|
|
|
848
848
|
},
|
|
849
849
|
state: [...e.values()]
|
|
850
850
|
};
|
|
851
|
-
n.forEach((
|
|
852
|
-
Cn(
|
|
851
|
+
n.forEach((E) => {
|
|
852
|
+
Cn(E, C) && E.onChange(C);
|
|
853
853
|
});
|
|
854
|
-
}, s = (
|
|
855
|
-
if (e.get(
|
|
856
|
-
throw Error(`Cannot add annotation ${
|
|
857
|
-
e.set(
|
|
858
|
-
}, a = (
|
|
859
|
-
const C = typeof
|
|
860
|
-
if (
|
|
861
|
-
const I = le(
|
|
862
|
-
return
|
|
854
|
+
}, s = (w, S = R.LOCAL) => {
|
|
855
|
+
if (e.get(w.id))
|
|
856
|
+
throw Error(`Cannot add annotation ${w.id} - exists already`);
|
|
857
|
+
e.set(w.id, w), w.bodies.forEach((C) => t.set(C.id, w.id)), r(S, { created: [w] });
|
|
858
|
+
}, a = (w, S) => {
|
|
859
|
+
const C = typeof w == "string" ? S : w, E = typeof w == "string" ? w : w.id, B = e.get(E);
|
|
860
|
+
if (B) {
|
|
861
|
+
const I = le(B, C);
|
|
862
|
+
return E === C.id ? e.set(E, C) : (e.delete(E), e.set(C.id, C)), B.bodies.forEach((z) => t.delete(z.id)), C.bodies.forEach((z) => t.set(z.id, C.id)), I;
|
|
863
863
|
} else
|
|
864
|
-
console.warn(`Cannot update annotation ${
|
|
865
|
-
},
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
}, p = (
|
|
869
|
-
const C =
|
|
870
|
-
const I = a(
|
|
871
|
-
return I ? [...
|
|
864
|
+
console.warn(`Cannot update annotation ${E} - does not exist`);
|
|
865
|
+
}, f = (w, S = R.LOCAL, C = R.LOCAL) => {
|
|
866
|
+
const E = Ln(S) ? C : S, B = a(w, S);
|
|
867
|
+
B && r(E, { updated: [B] });
|
|
868
|
+
}, p = (w, S = R.LOCAL) => {
|
|
869
|
+
const C = w.reduce((E, B) => {
|
|
870
|
+
const I = a(B);
|
|
871
|
+
return I ? [...E, I] : E;
|
|
872
872
|
}, []);
|
|
873
873
|
C.length > 0 && r(S, { updated: C });
|
|
874
|
-
}, h = (
|
|
875
|
-
const C = e.get(
|
|
874
|
+
}, h = (w, S = R.LOCAL) => {
|
|
875
|
+
const C = e.get(w.annotation);
|
|
876
876
|
if (C) {
|
|
877
|
-
const
|
|
877
|
+
const E = {
|
|
878
878
|
...C,
|
|
879
|
-
bodies: [...C.bodies,
|
|
879
|
+
bodies: [...C.bodies, w]
|
|
880
880
|
};
|
|
881
|
-
e.set(C.id,
|
|
881
|
+
e.set(C.id, E), t.set(w.id, E.id), r(S, { updated: [{
|
|
882
882
|
oldValue: C,
|
|
883
|
-
newValue:
|
|
884
|
-
bodiesCreated: [
|
|
883
|
+
newValue: E,
|
|
884
|
+
bodiesCreated: [w]
|
|
885
885
|
}] });
|
|
886
886
|
} else
|
|
887
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
888
|
-
},
|
|
887
|
+
console.warn(`Attempt to add body to missing annotation: ${w.annotation}`);
|
|
888
|
+
}, l = () => [...e.values()], g = (w = R.LOCAL) => {
|
|
889
889
|
const S = [...e.values()];
|
|
890
|
-
e.clear(), t.clear(), r(
|
|
891
|
-
},
|
|
890
|
+
e.clear(), t.clear(), r(w, { deleted: S });
|
|
891
|
+
}, d = (w, S = !0, C = R.LOCAL) => {
|
|
892
892
|
if (S) {
|
|
893
|
-
const
|
|
894
|
-
e.clear(), t.clear(),
|
|
895
|
-
e.set(
|
|
896
|
-
}), r(C, { created:
|
|
893
|
+
const E = [...e.values()];
|
|
894
|
+
e.clear(), t.clear(), w.forEach((B) => {
|
|
895
|
+
e.set(B.id, B), B.bodies.forEach((I) => t.set(I.id, B.id));
|
|
896
|
+
}), r(C, { created: w, deleted: E });
|
|
897
897
|
} else {
|
|
898
|
-
const
|
|
898
|
+
const E = w.reduce((B, I) => {
|
|
899
899
|
const z = e.get(I.id);
|
|
900
|
-
return z ? [...
|
|
900
|
+
return z ? [...B, z] : B;
|
|
901
901
|
}, []);
|
|
902
|
-
if (
|
|
903
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
904
|
-
|
|
905
|
-
e.set(
|
|
906
|
-
}), r(C, { created:
|
|
902
|
+
if (E.length > 0)
|
|
903
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${E.map((B) => B.id).join(", ")}`);
|
|
904
|
+
w.forEach((B) => {
|
|
905
|
+
e.set(B.id, B), B.bodies.forEach((I) => t.set(I.id, B.id));
|
|
906
|
+
}), r(C, { created: w });
|
|
907
907
|
}
|
|
908
|
-
},
|
|
909
|
-
const S = typeof
|
|
908
|
+
}, A = (w) => {
|
|
909
|
+
const S = typeof w == "string" ? w : w.id, C = e.get(S);
|
|
910
910
|
if (C)
|
|
911
|
-
return e.delete(S), C.bodies.forEach((
|
|
911
|
+
return e.delete(S), C.bodies.forEach((E) => t.delete(E.id)), C;
|
|
912
912
|
console.warn(`Attempt to delete missing annotation: ${S}`);
|
|
913
|
-
},
|
|
914
|
-
const C =
|
|
913
|
+
}, m = (w, S = R.LOCAL) => {
|
|
914
|
+
const C = A(w);
|
|
915
915
|
C && r(S, { deleted: [C] });
|
|
916
|
-
},
|
|
917
|
-
const C =
|
|
918
|
-
const I =
|
|
919
|
-
return I ? [...
|
|
916
|
+
}, b = (w, S = R.LOCAL) => {
|
|
917
|
+
const C = w.reduce((E, B) => {
|
|
918
|
+
const I = A(B);
|
|
919
|
+
return I ? [...E, I] : E;
|
|
920
920
|
}, []);
|
|
921
921
|
C.length > 0 && r(S, { deleted: C });
|
|
922
|
-
},
|
|
923
|
-
const S = e.get(
|
|
922
|
+
}, u = (w) => {
|
|
923
|
+
const S = e.get(w.annotation);
|
|
924
924
|
if (S) {
|
|
925
|
-
const C = S.bodies.find((
|
|
925
|
+
const C = S.bodies.find((E) => E.id === w.id);
|
|
926
926
|
if (C) {
|
|
927
927
|
t.delete(C.id);
|
|
928
|
-
const
|
|
928
|
+
const E = {
|
|
929
929
|
...S,
|
|
930
|
-
bodies: S.bodies.filter((
|
|
930
|
+
bodies: S.bodies.filter((B) => B.id !== w.id)
|
|
931
931
|
};
|
|
932
|
-
return e.set(S.id,
|
|
932
|
+
return e.set(S.id, E), {
|
|
933
933
|
oldValue: S,
|
|
934
|
-
newValue:
|
|
934
|
+
newValue: E,
|
|
935
935
|
bodiesDeleted: [C]
|
|
936
936
|
};
|
|
937
937
|
} else
|
|
938
|
-
console.warn(`Attempt to delete missing body ${
|
|
938
|
+
console.warn(`Attempt to delete missing body ${w.id} from annotation ${w.annotation}`);
|
|
939
939
|
} else
|
|
940
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
941
|
-
},
|
|
942
|
-
const C =
|
|
940
|
+
console.warn(`Attempt to delete body from missing annotation ${w.annotation}`);
|
|
941
|
+
}, c = (w, S = R.LOCAL) => {
|
|
942
|
+
const C = u(w);
|
|
943
943
|
C && r(S, { updated: [C] });
|
|
944
|
-
},
|
|
945
|
-
const C =
|
|
944
|
+
}, v = (w, S = R.LOCAL) => {
|
|
945
|
+
const C = w.map((E) => u(E)).filter(Boolean);
|
|
946
946
|
C.length > 0 && r(S, { updated: C });
|
|
947
|
-
}, x = (
|
|
948
|
-
const S = e.get(
|
|
947
|
+
}, x = (w) => {
|
|
948
|
+
const S = e.get(w);
|
|
949
949
|
return S ? { ...S } : void 0;
|
|
950
|
-
},
|
|
951
|
-
const S = t.get(
|
|
950
|
+
}, L = (w) => {
|
|
951
|
+
const S = t.get(w);
|
|
952
952
|
if (S) {
|
|
953
|
-
const C = x(S).bodies.find((
|
|
953
|
+
const C = x(S).bodies.find((E) => E.id === w);
|
|
954
954
|
if (C)
|
|
955
955
|
return C;
|
|
956
|
-
console.error(`Store integrity error: body ${
|
|
956
|
+
console.error(`Store integrity error: body ${w} in index, but not in annotation`);
|
|
957
957
|
} else
|
|
958
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
959
|
-
},
|
|
960
|
-
if (
|
|
958
|
+
console.warn(`Attempt to retrieve missing body: ${w}`);
|
|
959
|
+
}, T = (w, S) => {
|
|
960
|
+
if (w.annotation !== S.annotation)
|
|
961
961
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
962
|
-
const C = e.get(
|
|
962
|
+
const C = e.get(w.annotation);
|
|
963
963
|
if (C) {
|
|
964
|
-
const
|
|
964
|
+
const E = C.bodies.find((I) => I.id === w.id), B = {
|
|
965
965
|
...C,
|
|
966
|
-
bodies: C.bodies.map((I) => I.id ===
|
|
966
|
+
bodies: C.bodies.map((I) => I.id === E.id ? S : I)
|
|
967
967
|
};
|
|
968
|
-
return e.set(C.id,
|
|
968
|
+
return e.set(C.id, B), E.id !== S.id && (t.delete(E.id), t.set(S.id, B.id)), {
|
|
969
969
|
oldValue: C,
|
|
970
|
-
newValue:
|
|
971
|
-
bodiesUpdated: [{ oldBody:
|
|
970
|
+
newValue: B,
|
|
971
|
+
bodiesUpdated: [{ oldBody: E, newBody: S }]
|
|
972
972
|
};
|
|
973
973
|
} else
|
|
974
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
975
|
-
},
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
},
|
|
979
|
-
const C =
|
|
974
|
+
console.warn(`Attempt to add body to missing annotation ${w.annotation}`);
|
|
975
|
+
}, k = (w, S, C = R.LOCAL) => {
|
|
976
|
+
const E = T(w, S);
|
|
977
|
+
E && r(C, { updated: [E] });
|
|
978
|
+
}, M = (w, S = R.LOCAL) => {
|
|
979
|
+
const C = w.map((E) => T({ id: E.id, annotation: E.annotation }, E)).filter(Boolean);
|
|
980
980
|
r(S, { updated: C });
|
|
981
|
-
},
|
|
982
|
-
const S = e.get(
|
|
981
|
+
}, y = (w) => {
|
|
982
|
+
const S = e.get(w.annotation);
|
|
983
983
|
if (S) {
|
|
984
984
|
const C = {
|
|
985
985
|
...S,
|
|
986
986
|
target: {
|
|
987
987
|
...S.target,
|
|
988
|
-
...
|
|
988
|
+
...w
|
|
989
989
|
}
|
|
990
990
|
};
|
|
991
991
|
return e.set(S.id, C), {
|
|
@@ -993,41 +993,41 @@ const Cn = (e, t) => {
|
|
|
993
993
|
newValue: C,
|
|
994
994
|
targetUpdated: {
|
|
995
995
|
oldTarget: S.target,
|
|
996
|
-
newTarget:
|
|
996
|
+
newTarget: w
|
|
997
997
|
}
|
|
998
998
|
};
|
|
999
999
|
} else
|
|
1000
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
1000
|
+
console.warn(`Attempt to update target on missing annotation: ${w.annotation}`);
|
|
1001
1001
|
};
|
|
1002
1002
|
return {
|
|
1003
1003
|
addAnnotation: s,
|
|
1004
1004
|
addBody: h,
|
|
1005
|
-
all:
|
|
1006
|
-
bulkAddAnnotation:
|
|
1007
|
-
bulkDeleteAnnotation:
|
|
1008
|
-
bulkDeleteBodies:
|
|
1005
|
+
all: l,
|
|
1006
|
+
bulkAddAnnotation: d,
|
|
1007
|
+
bulkDeleteAnnotation: b,
|
|
1008
|
+
bulkDeleteBodies: v,
|
|
1009
1009
|
bulkUpdateAnnotation: p,
|
|
1010
|
-
bulkUpdateBodies:
|
|
1011
|
-
bulkUpdateTargets: (
|
|
1012
|
-
const C =
|
|
1010
|
+
bulkUpdateBodies: M,
|
|
1011
|
+
bulkUpdateTargets: (w, S = R.LOCAL) => {
|
|
1012
|
+
const C = w.map((E) => y(E)).filter(Boolean);
|
|
1013
1013
|
C.length > 0 && r(S, { updated: C });
|
|
1014
1014
|
},
|
|
1015
|
-
clear:
|
|
1016
|
-
deleteAnnotation:
|
|
1017
|
-
deleteBody:
|
|
1015
|
+
clear: g,
|
|
1016
|
+
deleteAnnotation: m,
|
|
1017
|
+
deleteBody: c,
|
|
1018
1018
|
getAnnotation: x,
|
|
1019
|
-
getBody:
|
|
1019
|
+
getBody: L,
|
|
1020
1020
|
observe: o,
|
|
1021
1021
|
unobserve: i,
|
|
1022
|
-
updateAnnotation:
|
|
1023
|
-
updateBody:
|
|
1024
|
-
updateTarget: (
|
|
1025
|
-
const C =
|
|
1022
|
+
updateAnnotation: f,
|
|
1023
|
+
updateBody: k,
|
|
1024
|
+
updateTarget: (w, S = R.LOCAL) => {
|
|
1025
|
+
const C = y(w);
|
|
1026
1026
|
C && r(S, { updated: [C] });
|
|
1027
1027
|
}
|
|
1028
1028
|
};
|
|
1029
1029
|
};
|
|
1030
|
-
let
|
|
1030
|
+
let Tn = () => ({
|
|
1031
1031
|
emit(e, ...t) {
|
|
1032
1032
|
for (let n = 0, o = this.events[e] || [], i = o.length; n < i; n++)
|
|
1033
1033
|
o[n](...t);
|
|
@@ -1042,40 +1042,40 @@ let En = () => ({
|
|
|
1042
1042
|
}
|
|
1043
1043
|
});
|
|
1044
1044
|
const Mn = 250, Bn = (e) => {
|
|
1045
|
-
const t =
|
|
1045
|
+
const t = Tn(), n = [];
|
|
1046
1046
|
let o = -1, i = !1, r = 0;
|
|
1047
|
-
const s = (
|
|
1047
|
+
const s = (d) => {
|
|
1048
1048
|
if (!i) {
|
|
1049
|
-
const { changes:
|
|
1050
|
-
if (
|
|
1051
|
-
n.splice(o + 1), n.push(
|
|
1049
|
+
const { changes: A } = d, m = performance.now();
|
|
1050
|
+
if (m - r > Mn)
|
|
1051
|
+
n.splice(o + 1), n.push(A), o = n.length - 1;
|
|
1052
1052
|
else {
|
|
1053
|
-
const
|
|
1054
|
-
n[
|
|
1053
|
+
const b = n.length - 1;
|
|
1054
|
+
n[b] = xn(n[b], A);
|
|
1055
1055
|
}
|
|
1056
|
-
r =
|
|
1056
|
+
r = m;
|
|
1057
1057
|
}
|
|
1058
1058
|
i = !1;
|
|
1059
1059
|
};
|
|
1060
1060
|
e.observe(s, { origin: R.LOCAL });
|
|
1061
|
-
const a = (
|
|
1061
|
+
const a = (d) => d && d.length > 0 && e.bulkDeleteAnnotation(d), f = (d) => d && d.length > 0 && e.bulkAddAnnotation(d, !1), p = (d) => d && d.length > 0 && e.bulkUpdateAnnotation(d.map(({ oldValue: A }) => A)), h = (d) => d && d.length > 0 && e.bulkUpdateAnnotation(d.map(({ newValue: A }) => A)), l = (d) => d && d.length > 0 && e.bulkAddAnnotation(d, !1), g = (d) => d && d.length > 0 && e.bulkDeleteAnnotation(d);
|
|
1062
1062
|
return {
|
|
1063
1063
|
canRedo: () => n.length - 1 > o,
|
|
1064
1064
|
canUndo: () => o > -1,
|
|
1065
1065
|
destroy: () => e.unobserve(s),
|
|
1066
|
-
on: (
|
|
1066
|
+
on: (d, A) => t.on(d, A),
|
|
1067
1067
|
redo: () => {
|
|
1068
1068
|
if (n.length - 1 > o) {
|
|
1069
1069
|
i = !0;
|
|
1070
|
-
const { created:
|
|
1071
|
-
|
|
1070
|
+
const { created: d, updated: A, deleted: m } = n[o + 1];
|
|
1071
|
+
f(d), h(A), g(m), t.emit("redo", n[o + 1]), o += 1;
|
|
1072
1072
|
}
|
|
1073
1073
|
},
|
|
1074
1074
|
undo: () => {
|
|
1075
1075
|
if (o > -1) {
|
|
1076
1076
|
i = !0;
|
|
1077
|
-
const { created:
|
|
1078
|
-
a(
|
|
1077
|
+
const { created: d, updated: A, deleted: m } = n[o];
|
|
1078
|
+
a(d), p(A), l(m), t.emit("undo", n[o]), o -= 1;
|
|
1079
1079
|
}
|
|
1080
1080
|
}
|
|
1081
1081
|
};
|
|
@@ -1086,73 +1086,73 @@ const Mn = 250, Bn = (e) => {
|
|
|
1086
1086
|
set: t
|
|
1087
1087
|
};
|
|
1088
1088
|
}, Rn = (e, t, n, o) => {
|
|
1089
|
-
const { store: i, selection: r, hover: s, viewport: a } = e,
|
|
1089
|
+
const { store: i, selection: r, hover: s, viewport: a } = e, f = /* @__PURE__ */ new Map();
|
|
1090
1090
|
let p = [], h;
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
},
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1091
|
+
const l = (m, b) => {
|
|
1092
|
+
f.has(m) ? f.get(m).push(b) : f.set(m, [b]);
|
|
1093
|
+
}, g = (m, b) => {
|
|
1094
|
+
const u = f.get(m);
|
|
1095
|
+
if (u) {
|
|
1096
|
+
const c = u.indexOf(b);
|
|
1097
|
+
c !== -1 && u.splice(c, 1);
|
|
1098
1098
|
}
|
|
1099
|
-
},
|
|
1100
|
-
|
|
1101
|
-
|
|
1099
|
+
}, d = (m, b, u) => {
|
|
1100
|
+
f.has(m) && setTimeout(() => {
|
|
1101
|
+
f.get(m).forEach((c) => {
|
|
1102
1102
|
if (n) {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1103
|
+
const v = Array.isArray(b) ? b.map((L) => n.serialize(L)) : n.serialize(b), x = u ? u instanceof PointerEvent ? u : n.serialize(u) : void 0;
|
|
1104
|
+
c(v, x);
|
|
1105
1105
|
} else
|
|
1106
|
-
|
|
1106
|
+
c(b, u);
|
|
1107
1107
|
});
|
|
1108
1108
|
}, 1);
|
|
1109
1109
|
};
|
|
1110
|
-
r.subscribe(({ selected:
|
|
1111
|
-
if (!(p.length === 0 &&
|
|
1112
|
-
if (p.length === 0 &&
|
|
1113
|
-
p =
|
|
1114
|
-
else if (p.length > 0 &&
|
|
1115
|
-
p.forEach((
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1110
|
+
r.subscribe(({ selected: m }) => {
|
|
1111
|
+
if (!(p.length === 0 && m.length === 0)) {
|
|
1112
|
+
if (p.length === 0 && m.length > 0)
|
|
1113
|
+
p = m.map(({ id: b }) => i.getAnnotation(b));
|
|
1114
|
+
else if (p.length > 0 && m.length === 0)
|
|
1115
|
+
p.forEach((b) => {
|
|
1116
|
+
const u = i.getAnnotation(b.id);
|
|
1117
|
+
u && !K(u, b) && d("updateAnnotation", u, b);
|
|
1118
1118
|
}), p = [];
|
|
1119
1119
|
else {
|
|
1120
|
-
const
|
|
1121
|
-
p.filter((
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1120
|
+
const b = new Set(p.map((c) => c.id)), u = new Set(m.map(({ id: c }) => c));
|
|
1121
|
+
p.filter((c) => !u.has(c.id)).forEach((c) => {
|
|
1122
|
+
const v = i.getAnnotation(c.id);
|
|
1123
|
+
v && !K(v, c) && d("updateAnnotation", v, c);
|
|
1124
1124
|
}), p = [
|
|
1125
1125
|
// Remove annotations that were deselected
|
|
1126
|
-
...p.filter((
|
|
1126
|
+
...p.filter((c) => u.has(c.id)),
|
|
1127
1127
|
// Add editable annotations that were selected
|
|
1128
|
-
...
|
|
1128
|
+
...m.filter(({ id: c }) => !b.has(c)).map(({ id: c }) => i.getAnnotation(c))
|
|
1129
1129
|
];
|
|
1130
1130
|
}
|
|
1131
|
-
|
|
1131
|
+
d("selectionChanged", p);
|
|
1132
1132
|
}
|
|
1133
|
-
}), s.subscribe((
|
|
1134
|
-
!h &&
|
|
1135
|
-
}), a == null || a.subscribe((
|
|
1136
|
-
const { created:
|
|
1137
|
-
(
|
|
1138
|
-
...
|
|
1139
|
-
...
|
|
1140
|
-
...
|
|
1141
|
-
].length > 0).forEach(({ oldValue:
|
|
1142
|
-
const x = p.find((
|
|
1143
|
-
p = p.map((
|
|
1133
|
+
}), s.subscribe((m) => {
|
|
1134
|
+
!h && m ? d("mouseEnterAnnotation", i.getAnnotation(m)) : h && !m ? d("mouseLeaveAnnotation", i.getAnnotation(h)) : h && m && (d("mouseLeaveAnnotation", i.getAnnotation(h)), d("mouseEnterAnnotation", i.getAnnotation(m))), h = m;
|
|
1135
|
+
}), a == null || a.subscribe((m) => d("viewportIntersect", m.map((b) => i.getAnnotation(b)))), i.observe((m) => {
|
|
1136
|
+
const { created: b, deleted: u } = m.changes;
|
|
1137
|
+
(b || []).forEach((c) => d("createAnnotation", c)), (u || []).forEach((c) => d("deleteAnnotation", c)), (m.changes.updated || []).filter((c) => [
|
|
1138
|
+
...c.bodiesCreated || [],
|
|
1139
|
+
...c.bodiesDeleted || [],
|
|
1140
|
+
...c.bodiesUpdated || []
|
|
1141
|
+
].length > 0).forEach(({ oldValue: c, newValue: v }) => {
|
|
1142
|
+
const x = p.find((L) => L.id === c.id) || c;
|
|
1143
|
+
p = p.map((L) => L.id === c.id ? v : L), d("updateAnnotation", v, x);
|
|
1144
1144
|
});
|
|
1145
|
-
}, { origin: R.LOCAL }), i.observe((
|
|
1145
|
+
}, { origin: R.LOCAL }), i.observe((m) => {
|
|
1146
1146
|
if (p) {
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1147
|
+
const b = new Set(p.map((c) => c.id)), u = (m.changes.updated || []).filter(({ newValue: c }) => b.has(c.id)).map(({ newValue: c }) => c);
|
|
1148
|
+
u.length > 0 && (p = p.map((c) => u.find((x) => x.id === c.id) || c));
|
|
1149
1149
|
}
|
|
1150
1150
|
}, { origin: R.REMOTE });
|
|
1151
|
-
const
|
|
1152
|
-
const { updated:
|
|
1153
|
-
|
|
1151
|
+
const A = (m) => (b) => {
|
|
1152
|
+
const { updated: u } = b;
|
|
1153
|
+
m ? (u || []).forEach((c) => d("updateAnnotation", c.oldValue, c.newValue)) : (u || []).forEach((c) => d("updateAnnotation", c.newValue, c.oldValue));
|
|
1154
1154
|
};
|
|
1155
|
-
return t.on("undo",
|
|
1155
|
+
return t.on("undo", A(!0)), t.on("redo", A(!1)), { on: l, off: g, emit: d };
|
|
1156
1156
|
}, Vn = (e) => (t) => t.reduce((n, o) => {
|
|
1157
1157
|
const { parsed: i, error: r } = e.parse(o);
|
|
1158
1158
|
return r ? {
|
|
@@ -1165,46 +1165,46 @@ const Mn = 250, Bn = (e) => {
|
|
|
1165
1165
|
...n
|
|
1166
1166
|
};
|
|
1167
1167
|
}, { parsed: [], failed: [] }), On = (e, t, n) => {
|
|
1168
|
-
const { store: o, selection: i } = e, r = (
|
|
1168
|
+
const { store: o, selection: i } = e, r = (u) => {
|
|
1169
1169
|
if (n) {
|
|
1170
|
-
const { parsed:
|
|
1171
|
-
|
|
1170
|
+
const { parsed: c, error: v } = n.parse(u);
|
|
1171
|
+
c ? o.addAnnotation(c, R.REMOTE) : console.error(v);
|
|
1172
1172
|
} else
|
|
1173
|
-
o.addAnnotation(
|
|
1174
|
-
}, s = () => i.clear(), a = () => o.clear(),
|
|
1175
|
-
const
|
|
1176
|
-
return n &&
|
|
1173
|
+
o.addAnnotation(u, R.REMOTE);
|
|
1174
|
+
}, s = () => i.clear(), a = () => o.clear(), f = (u) => {
|
|
1175
|
+
const c = o.getAnnotation(u);
|
|
1176
|
+
return n && c ? n.serialize(c) : c;
|
|
1177
1177
|
}, p = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1178
|
-
var
|
|
1179
|
-
const
|
|
1180
|
-
return n ?
|
|
1181
|
-
},
|
|
1182
|
-
if (typeof
|
|
1183
|
-
const
|
|
1184
|
-
if (o.deleteAnnotation(
|
|
1185
|
-
return n ? n.serialize(
|
|
1178
|
+
var u;
|
|
1179
|
+
const c = (((u = i.selected) == null ? void 0 : u.map((v) => v.id)) || []).map((v) => o.getAnnotation(v)).filter(Boolean);
|
|
1180
|
+
return n ? c.map(n.serialize) : c;
|
|
1181
|
+
}, l = (u, c = !0) => fetch(u).then((v) => v.json()).then((v) => (d(v, c), v)), g = (u) => {
|
|
1182
|
+
if (typeof u == "string") {
|
|
1183
|
+
const c = o.getAnnotation(u);
|
|
1184
|
+
if (o.deleteAnnotation(u), c)
|
|
1185
|
+
return n ? n.serialize(c) : c;
|
|
1186
1186
|
} else {
|
|
1187
|
-
const
|
|
1188
|
-
if (
|
|
1189
|
-
return o.deleteAnnotation(
|
|
1187
|
+
const c = n ? n.parse(u).parsed : u;
|
|
1188
|
+
if (c)
|
|
1189
|
+
return o.deleteAnnotation(c), u;
|
|
1190
1190
|
}
|
|
1191
|
-
},
|
|
1191
|
+
}, d = (u, c = !0) => {
|
|
1192
1192
|
if (n) {
|
|
1193
|
-
const { parsed:
|
|
1194
|
-
x.length > 0 && console.warn(`Discarded ${x.length} invalid annotations`, x), o.bulkAddAnnotation(
|
|
1193
|
+
const { parsed: v, failed: x } = Vn(n)(u);
|
|
1194
|
+
x.length > 0 && console.warn(`Discarded ${x.length} invalid annotations`, x), o.bulkAddAnnotation(v, c, R.REMOTE);
|
|
1195
1195
|
} else
|
|
1196
|
-
o.bulkAddAnnotation(
|
|
1197
|
-
},
|
|
1198
|
-
|
|
1199
|
-
},
|
|
1200
|
-
i.clear(), i.setUserSelectAction(
|
|
1201
|
-
},
|
|
1196
|
+
o.bulkAddAnnotation(u, c, R.REMOTE);
|
|
1197
|
+
}, A = (u, c) => {
|
|
1198
|
+
u ? i.setSelected(u, c) : i.clear();
|
|
1199
|
+
}, m = (u) => {
|
|
1200
|
+
i.clear(), i.setUserSelectAction(u);
|
|
1201
|
+
}, b = (u) => {
|
|
1202
1202
|
if (n) {
|
|
1203
|
-
const
|
|
1204
|
-
return o.updateAnnotation(
|
|
1203
|
+
const c = n.parse(u).parsed, v = n.serialize(o.getAnnotation(c.id));
|
|
1204
|
+
return o.updateAnnotation(c), v;
|
|
1205
1205
|
} else {
|
|
1206
|
-
const
|
|
1207
|
-
return o.updateAnnotation(
|
|
1206
|
+
const c = o.getAnnotation(u.id);
|
|
1207
|
+
return o.updateAnnotation(u), c;
|
|
1208
1208
|
}
|
|
1209
1209
|
};
|
|
1210
1210
|
return {
|
|
@@ -1213,17 +1213,17 @@ const Mn = 250, Bn = (e) => {
|
|
|
1213
1213
|
canRedo: t.canRedo,
|
|
1214
1214
|
canUndo: t.canUndo,
|
|
1215
1215
|
clearAnnotations: a,
|
|
1216
|
-
getAnnotationById:
|
|
1216
|
+
getAnnotationById: f,
|
|
1217
1217
|
getAnnotations: p,
|
|
1218
1218
|
getSelected: h,
|
|
1219
|
-
loadAnnotations:
|
|
1219
|
+
loadAnnotations: l,
|
|
1220
1220
|
redo: t.redo,
|
|
1221
|
-
removeAnnotation:
|
|
1222
|
-
setAnnotations:
|
|
1223
|
-
setSelected:
|
|
1224
|
-
setUserSelectAction:
|
|
1221
|
+
removeAnnotation: g,
|
|
1222
|
+
setAnnotations: d,
|
|
1223
|
+
setSelected: A,
|
|
1224
|
+
setUserSelectAction: m,
|
|
1225
1225
|
undo: t.undo,
|
|
1226
|
-
updateAnnotation:
|
|
1226
|
+
updateAnnotation: b
|
|
1227
1227
|
};
|
|
1228
1228
|
}, In = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1229
1229
|
let Nn = (e) => crypto.getRandomValues(new Uint8Array(e)), Fn = (e, t, n) => {
|
|
@@ -1231,9 +1231,9 @@ let Nn = (e) => crypto.getRandomValues(new Uint8Array(e)), Fn = (e, t, n) => {
|
|
|
1231
1231
|
return (r = t) => {
|
|
1232
1232
|
let s = "";
|
|
1233
1233
|
for (; ; ) {
|
|
1234
|
-
let a = n(i),
|
|
1235
|
-
for (;
|
|
1236
|
-
if (s += e[a[
|
|
1234
|
+
let a = n(i), f = i;
|
|
1235
|
+
for (; f--; )
|
|
1236
|
+
if (s += e[a[f] & o] || "", s.length === r) return s;
|
|
1237
1237
|
}
|
|
1238
1238
|
};
|
|
1239
1239
|
}, Pn = (e, t = 21) => Fn(e, t, Nn), Dn = (e = 21) => {
|
|
@@ -1251,7 +1251,7 @@ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1251
1251
|
}
|
|
1252
1252
|
return `${n}`;
|
|
1253
1253
|
}, ce = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Hn = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
|
|
1254
|
-
const { id: o, type: i, purpose: r, value: s, created: a, modified:
|
|
1254
|
+
const { id: o, type: i, purpose: r, value: s, created: a, modified: f, creator: p, ...h } = n;
|
|
1255
1255
|
return {
|
|
1256
1256
|
id: o || `temp-${Un(n)}`,
|
|
1257
1257
|
annotation: t,
|
|
@@ -1260,7 +1260,7 @@ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1260
1260
|
value: s,
|
|
1261
1261
|
creator: ce(p),
|
|
1262
1262
|
created: a ? new Date(a) : void 0,
|
|
1263
|
-
updated:
|
|
1263
|
+
updated: f ? new Date(f) : void 0,
|
|
1264
1264
|
...h
|
|
1265
1265
|
};
|
|
1266
1266
|
}), _n = (e) => e.map((t) => {
|
|
@@ -1294,26 +1294,26 @@ const Lo = (e, t) => ({
|
|
|
1294
1294
|
selector: [],
|
|
1295
1295
|
styleClass: s[0].styleClass
|
|
1296
1296
|
};
|
|
1297
|
-
for (const
|
|
1298
|
-
const h = (Array.isArray(
|
|
1299
|
-
switch (
|
|
1297
|
+
for (const f of s) {
|
|
1298
|
+
const h = (Array.isArray(f.selector) ? f.selector : [f.selector]).reduce((l, g) => {
|
|
1299
|
+
switch (g.type) {
|
|
1300
1300
|
case "TextQuoteSelector":
|
|
1301
|
-
|
|
1301
|
+
l.quote = g.exact;
|
|
1302
1302
|
break;
|
|
1303
1303
|
case "TextPositionSelector":
|
|
1304
|
-
|
|
1304
|
+
l.start = g.start, l.end = g.end;
|
|
1305
1305
|
break;
|
|
1306
1306
|
}
|
|
1307
|
-
return
|
|
1307
|
+
return l;
|
|
1308
1308
|
}, {});
|
|
1309
1309
|
if (Yn(h))
|
|
1310
|
-
a.selector.push({ id:
|
|
1310
|
+
a.selector.push({ id: f.id, ...h });
|
|
1311
1311
|
else {
|
|
1312
|
-
const
|
|
1312
|
+
const l = [
|
|
1313
1313
|
h.start ? void 0 : "TextPositionSelector",
|
|
1314
1314
|
h.quote ? void 0 : "TextQuoteSelector"
|
|
1315
1315
|
].filter(Boolean);
|
|
1316
|
-
return { error: Error(`Missing selector types: ${
|
|
1316
|
+
return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${e.id}`) };
|
|
1317
1317
|
}
|
|
1318
1318
|
}
|
|
1319
1319
|
return { parsed: a };
|
|
@@ -1324,38 +1324,38 @@ const Lo = (e, t) => ({
|
|
|
1324
1324
|
modified: i,
|
|
1325
1325
|
body: r,
|
|
1326
1326
|
...s
|
|
1327
|
-
} = e, a = Hn(r, t),
|
|
1328
|
-
return "error" in
|
|
1327
|
+
} = e, a = Hn(r, t), f = Xn(e);
|
|
1328
|
+
return "error" in f ? { error: f.error } : {
|
|
1329
1329
|
parsed: {
|
|
1330
1330
|
...s,
|
|
1331
1331
|
id: t,
|
|
1332
1332
|
bodies: a,
|
|
1333
|
-
target:
|
|
1333
|
+
target: f.parsed
|
|
1334
1334
|
}
|
|
1335
1335
|
};
|
|
1336
1336
|
}, jn = (e, t, n) => {
|
|
1337
1337
|
const { bodies: o, target: i, ...r } = e, {
|
|
1338
1338
|
selector: s,
|
|
1339
1339
|
creator: a,
|
|
1340
|
-
created:
|
|
1340
|
+
created: f,
|
|
1341
1341
|
updated: p,
|
|
1342
1342
|
...h
|
|
1343
|
-
} = i,
|
|
1344
|
-
const { quote:
|
|
1343
|
+
} = i, l = s.map((g) => {
|
|
1344
|
+
const { quote: d, start: A, end: m, range: b } = g, { prefix: u, suffix: c } = ke(b, n), v = [{
|
|
1345
1345
|
type: "TextQuoteSelector",
|
|
1346
|
-
exact:
|
|
1347
|
-
prefix:
|
|
1348
|
-
suffix:
|
|
1346
|
+
exact: d,
|
|
1347
|
+
prefix: u,
|
|
1348
|
+
suffix: c
|
|
1349
1349
|
}, {
|
|
1350
1350
|
type: "TextPositionSelector",
|
|
1351
|
-
start:
|
|
1352
|
-
end:
|
|
1351
|
+
start: A,
|
|
1352
|
+
end: m
|
|
1353
1353
|
}];
|
|
1354
1354
|
return {
|
|
1355
1355
|
...h,
|
|
1356
|
-
id:
|
|
1356
|
+
id: g.id,
|
|
1357
1357
|
source: t,
|
|
1358
|
-
selector:
|
|
1358
|
+
selector: v
|
|
1359
1359
|
};
|
|
1360
1360
|
});
|
|
1361
1361
|
return {
|
|
@@ -1365,9 +1365,9 @@ const Lo = (e, t) => ({
|
|
|
1365
1365
|
type: "Annotation",
|
|
1366
1366
|
body: _n(e.bodies),
|
|
1367
1367
|
creator: a,
|
|
1368
|
-
created:
|
|
1368
|
+
created: f == null ? void 0 : f.toISOString(),
|
|
1369
1369
|
modified: p == null ? void 0 : p.toISOString(),
|
|
1370
|
-
target:
|
|
1370
|
+
target: l
|
|
1371
1371
|
};
|
|
1372
1372
|
};
|
|
1373
1373
|
function Gn(e, t, n, o, i) {
|
|
@@ -1376,15 +1376,15 @@ function Gn(e, t, n, o, i) {
|
|
|
1376
1376
|
function de(e, t, n, o, i) {
|
|
1377
1377
|
for (; o > n; ) {
|
|
1378
1378
|
if (o - n > 600) {
|
|
1379
|
-
var r = o - n + 1, s = t - n + 1, a = Math.log(r),
|
|
1380
|
-
de(e, t, h,
|
|
1379
|
+
var r = o - n + 1, s = t - n + 1, a = Math.log(r), f = 0.5 * Math.exp(2 * a / 3), p = 0.5 * Math.sqrt(a * f * (r - f) / r) * (s - r / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(t - s * f / r + p)), l = Math.min(o, Math.floor(t + (r - s) * f / r + p));
|
|
1380
|
+
de(e, t, h, l, i);
|
|
1381
1381
|
}
|
|
1382
|
-
var
|
|
1383
|
-
for (tt(e, n, t), i(e[o],
|
|
1384
|
-
for (tt(e,
|
|
1385
|
-
for (; i(e[
|
|
1382
|
+
var g = e[t], d = n, A = o;
|
|
1383
|
+
for (tt(e, n, t), i(e[o], g) > 0 && tt(e, n, o); d < A; ) {
|
|
1384
|
+
for (tt(e, d, A), d++, A--; i(e[d], g) < 0; ) d++;
|
|
1385
|
+
for (; i(e[A], g) > 0; ) A--;
|
|
1386
1386
|
}
|
|
1387
|
-
i(e[n],
|
|
1387
|
+
i(e[n], g) === 0 ? tt(e, n, A) : (A++, tt(e, A, o)), A <= t && (n = A + 1), t <= A && (o = A - 1);
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
1390
1390
|
function tt(e, t, n) {
|
|
@@ -1408,8 +1408,8 @@ class zn {
|
|
|
1408
1408
|
const i = this.toBBox, r = [];
|
|
1409
1409
|
for (; n; ) {
|
|
1410
1410
|
for (let s = 0; s < n.children.length; s++) {
|
|
1411
|
-
const a = n.children[s],
|
|
1412
|
-
pt(t,
|
|
1411
|
+
const a = n.children[s], f = n.leaf ? i(a) : a;
|
|
1412
|
+
pt(t, f) && (n.leaf ? o.push(a) : Tt(t, f) ? this._all(a, o) : r.push(a));
|
|
1413
1413
|
}
|
|
1414
1414
|
n = r.pop();
|
|
1415
1415
|
}
|
|
@@ -1423,7 +1423,7 @@ class zn {
|
|
|
1423
1423
|
for (let i = 0; i < n.children.length; i++) {
|
|
1424
1424
|
const r = n.children[i], s = n.leaf ? this.toBBox(r) : r;
|
|
1425
1425
|
if (pt(t, s)) {
|
|
1426
|
-
if (n.leaf ||
|
|
1426
|
+
if (n.leaf || Tt(t, s)) return !0;
|
|
1427
1427
|
o.push(r);
|
|
1428
1428
|
}
|
|
1429
1429
|
}
|
|
@@ -1462,14 +1462,14 @@ class zn {
|
|
|
1462
1462
|
if (!t) return this;
|
|
1463
1463
|
let o = this.data;
|
|
1464
1464
|
const i = this.toBBox(t), r = [], s = [];
|
|
1465
|
-
let a,
|
|
1465
|
+
let a, f, p;
|
|
1466
1466
|
for (; o || r.length; ) {
|
|
1467
|
-
if (o || (o = r.pop(),
|
|
1467
|
+
if (o || (o = r.pop(), f = r[r.length - 1], a = s.pop(), p = !0), o.leaf) {
|
|
1468
1468
|
const h = qn(t, o.children, n);
|
|
1469
1469
|
if (h !== -1)
|
|
1470
1470
|
return o.children.splice(h, 1), r.push(o), this._condense(r), this;
|
|
1471
1471
|
}
|
|
1472
|
-
!p && !o.leaf &&
|
|
1472
|
+
!p && !o.leaf && Tt(o, i) ? (r.push(o), s.push(a), a = 0, f = o, o = o.children[0]) : f ? (a++, o = f.children[a], p = !1) : o = null;
|
|
1473
1473
|
}
|
|
1474
1474
|
return this;
|
|
1475
1475
|
}
|
|
@@ -1500,14 +1500,14 @@ class zn {
|
|
|
1500
1500
|
if (r <= s)
|
|
1501
1501
|
return a = Q(t.slice(n, o + 1)), J(a, this.toBBox), a;
|
|
1502
1502
|
i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = Q([]), a.leaf = !1, a.height = i;
|
|
1503
|
-
const
|
|
1503
|
+
const f = Math.ceil(r / s), p = f * Math.ceil(Math.sqrt(s));
|
|
1504
1504
|
Qt(t, n, o, p, this.compareMinX);
|
|
1505
1505
|
for (let h = n; h <= o; h += p) {
|
|
1506
|
-
const
|
|
1507
|
-
Qt(t, h,
|
|
1508
|
-
for (let
|
|
1509
|
-
const
|
|
1510
|
-
a.children.push(this._build(t,
|
|
1506
|
+
const l = Math.min(h + p - 1, o);
|
|
1507
|
+
Qt(t, h, l, f, this.compareMinY);
|
|
1508
|
+
for (let g = h; g <= l; g += f) {
|
|
1509
|
+
const d = Math.min(g + f - 1, l);
|
|
1510
|
+
a.children.push(this._build(t, g, d, i - 1));
|
|
1511
1511
|
}
|
|
1512
1512
|
}
|
|
1513
1513
|
return J(a, this.toBBox), a;
|
|
@@ -1515,9 +1515,9 @@ class zn {
|
|
|
1515
1515
|
_chooseSubtree(t, n, o, i) {
|
|
1516
1516
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1517
1517
|
let r = 1 / 0, s = 1 / 0, a;
|
|
1518
|
-
for (let
|
|
1519
|
-
const p = n.children[
|
|
1520
|
-
|
|
1518
|
+
for (let f = 0; f < n.children.length; f++) {
|
|
1519
|
+
const p = n.children[f], h = Et(p), l = Qn(t, p) - h;
|
|
1520
|
+
l < s ? (s = l, r = h < r ? h : r, a = p) : l === s && h < r && (r = h, a = p);
|
|
1521
1521
|
}
|
|
1522
1522
|
n = a || n.children[0];
|
|
1523
1523
|
}
|
|
@@ -1542,8 +1542,8 @@ class zn {
|
|
|
1542
1542
|
_chooseSplitIndex(t, n, o) {
|
|
1543
1543
|
let i, r = 1 / 0, s = 1 / 0;
|
|
1544
1544
|
for (let a = n; a <= o - n; a++) {
|
|
1545
|
-
const
|
|
1546
|
-
h < r ? (r = h, i = a, s =
|
|
1545
|
+
const f = nt(t, 0, a, this.toBBox), p = nt(t, a, o, this.toBBox), h = Kn(f, p), l = Et(f) + Et(p);
|
|
1546
|
+
h < r ? (r = h, i = a, s = l < s ? l : s) : h === r && l < s && (s = l, i = a);
|
|
1547
1547
|
}
|
|
1548
1548
|
return i || o - n;
|
|
1549
1549
|
}
|
|
@@ -1556,16 +1556,16 @@ class zn {
|
|
|
1556
1556
|
_allDistMargin(t, n, o, i) {
|
|
1557
1557
|
t.children.sort(i);
|
|
1558
1558
|
const r = this.toBBox, s = nt(t, 0, n, r), a = nt(t, o - n, o, r);
|
|
1559
|
-
let
|
|
1559
|
+
let f = ft(s) + ft(a);
|
|
1560
1560
|
for (let p = n; p < o - n; p++) {
|
|
1561
1561
|
const h = t.children[p];
|
|
1562
|
-
ot(s, t.leaf ? r(h) : h),
|
|
1562
|
+
ot(s, t.leaf ? r(h) : h), f += ft(s);
|
|
1563
1563
|
}
|
|
1564
1564
|
for (let p = o - n - 1; p >= n; p--) {
|
|
1565
1565
|
const h = t.children[p];
|
|
1566
|
-
ot(a, t.leaf ? r(h) : h),
|
|
1566
|
+
ot(a, t.leaf ? r(h) : h), f += ft(a);
|
|
1567
1567
|
}
|
|
1568
|
-
return
|
|
1568
|
+
return f;
|
|
1569
1569
|
}
|
|
1570
1570
|
_adjustParentBBoxes(t, n, o) {
|
|
1571
1571
|
for (let i = o; i >= 0; i--)
|
|
@@ -1602,7 +1602,7 @@ function Zn(e, t) {
|
|
|
1602
1602
|
function Jn(e, t) {
|
|
1603
1603
|
return e.minY - t.minY;
|
|
1604
1604
|
}
|
|
1605
|
-
function
|
|
1605
|
+
function Et(e) {
|
|
1606
1606
|
return (e.maxX - e.minX) * (e.maxY - e.minY);
|
|
1607
1607
|
}
|
|
1608
1608
|
function ft(e) {
|
|
@@ -1615,7 +1615,7 @@ function Kn(e, t) {
|
|
|
1615
1615
|
const n = Math.max(e.minX, t.minX), o = Math.max(e.minY, t.minY), i = Math.min(e.maxX, t.maxX), r = Math.min(e.maxY, t.maxY);
|
|
1616
1616
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1617
1617
|
}
|
|
1618
|
-
function
|
|
1618
|
+
function Tt(e, t) {
|
|
1619
1619
|
return e.minX <= t.minX && e.minY <= t.minY && t.maxX <= e.maxX && t.maxY <= e.maxY;
|
|
1620
1620
|
}
|
|
1621
1621
|
function pt(e, t) {
|
|
@@ -1641,128 +1641,128 @@ function Qt(e, t, n, o, i) {
|
|
|
1641
1641
|
}
|
|
1642
1642
|
}
|
|
1643
1643
|
const to = (e, t) => {
|
|
1644
|
-
const n = new zn(), o = /* @__PURE__ */ new Map(), i = (
|
|
1645
|
-
const
|
|
1646
|
-
const
|
|
1647
|
-
return Array.from(
|
|
1648
|
-
}), x = Ne(
|
|
1649
|
-
return x.map((
|
|
1650
|
-
const { x:
|
|
1644
|
+
const n = new zn(), o = /* @__PURE__ */ new Map(), i = (u, c) => {
|
|
1645
|
+
const v = u.selector.flatMap((L) => {
|
|
1646
|
+
const T = W([L]) ? L.range : oe(L, t).range;
|
|
1647
|
+
return Array.from(T.getClientRects());
|
|
1648
|
+
}), x = Ne(v).map((L) => Pe(L, c));
|
|
1649
|
+
return x.map((L) => {
|
|
1650
|
+
const { x: T, y: k, width: M, height: y } = L;
|
|
1651
1651
|
return {
|
|
1652
|
-
minX:
|
|
1653
|
-
minY:
|
|
1654
|
-
maxX:
|
|
1655
|
-
maxY:
|
|
1652
|
+
minX: T,
|
|
1653
|
+
minY: k,
|
|
1654
|
+
maxX: T + M,
|
|
1655
|
+
maxY: k + y,
|
|
1656
1656
|
annotation: {
|
|
1657
|
-
id:
|
|
1657
|
+
id: u.annotation,
|
|
1658
1658
|
rects: x
|
|
1659
1659
|
}
|
|
1660
1660
|
};
|
|
1661
1661
|
});
|
|
1662
1662
|
}, r = () => [...o.values()], s = () => {
|
|
1663
1663
|
n.clear(), o.clear();
|
|
1664
|
-
}, a = (
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
},
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
}, p = (
|
|
1671
|
-
u
|
|
1672
|
-
}, h = (
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1675
|
-
x.forEach(({ target:
|
|
1676
|
-
const
|
|
1677
|
-
n.load(
|
|
1678
|
-
},
|
|
1664
|
+
}, a = (u) => {
|
|
1665
|
+
const c = i(u, t.getBoundingClientRect());
|
|
1666
|
+
c.forEach((v) => n.insert(v)), o.set(u.annotation, c);
|
|
1667
|
+
}, f = (u) => {
|
|
1668
|
+
const c = o.get(u.annotation);
|
|
1669
|
+
c && (c.forEach((v) => n.remove(v)), o.delete(u.annotation));
|
|
1670
|
+
}, p = (u) => {
|
|
1671
|
+
f(u), a(u);
|
|
1672
|
+
}, h = (u, c = !0) => {
|
|
1673
|
+
c && s();
|
|
1674
|
+
const v = t.getBoundingClientRect(), x = u.map((T) => ({ target: T, rects: i(T, v) }));
|
|
1675
|
+
x.forEach(({ target: T, rects: k }) => o.set(T.annotation, k));
|
|
1676
|
+
const L = x.flatMap(({ rects: T }) => T);
|
|
1677
|
+
n.load(L);
|
|
1678
|
+
}, l = (u, c, v = !1) => {
|
|
1679
1679
|
const x = n.search({
|
|
1680
|
-
minX:
|
|
1681
|
-
minY:
|
|
1682
|
-
maxX:
|
|
1683
|
-
maxY:
|
|
1684
|
-
}),
|
|
1685
|
-
return x.length > 0 ? (x.sort((
|
|
1686
|
-
},
|
|
1687
|
-
const
|
|
1688
|
-
if (
|
|
1680
|
+
minX: u,
|
|
1681
|
+
minY: c,
|
|
1682
|
+
maxX: u,
|
|
1683
|
+
maxY: c
|
|
1684
|
+
}), L = (T) => T.annotation.rects.reduce((k, M) => k + M.width * M.height, 0);
|
|
1685
|
+
return x.length > 0 ? (x.sort((T, k) => L(T) - L(k)), v ? x.map((T) => T.annotation.id) : [x[0].annotation.id]) : [];
|
|
1686
|
+
}, g = (u) => {
|
|
1687
|
+
const c = d(u);
|
|
1688
|
+
if (c.length === 0)
|
|
1689
1689
|
return;
|
|
1690
|
-
let
|
|
1691
|
-
for (let
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1690
|
+
let v = c[0].left, x = c[0].top, L = c[0].right, T = c[0].bottom;
|
|
1691
|
+
for (let k = 1; k < c.length; k++) {
|
|
1692
|
+
const M = c[k];
|
|
1693
|
+
v = Math.min(v, M.left), x = Math.min(x, M.top), L = Math.max(L, M.right), T = Math.max(T, M.bottom);
|
|
1694
1694
|
}
|
|
1695
|
-
return new DOMRect(
|
|
1696
|
-
},
|
|
1697
|
-
const
|
|
1698
|
-
return
|
|
1695
|
+
return new DOMRect(v, x, L - v, T - x);
|
|
1696
|
+
}, d = (u) => {
|
|
1697
|
+
const c = o.get(u);
|
|
1698
|
+
return c ? c[0].annotation.rects : [];
|
|
1699
1699
|
};
|
|
1700
1700
|
return {
|
|
1701
1701
|
all: r,
|
|
1702
1702
|
clear: s,
|
|
1703
|
-
getAt:
|
|
1704
|
-
getAnnotationBounds:
|
|
1705
|
-
getAnnotationRects:
|
|
1706
|
-
getIntersecting: (
|
|
1707
|
-
const
|
|
1708
|
-
return Array.from(
|
|
1709
|
-
annotation: e.getAnnotation(
|
|
1710
|
-
rects:
|
|
1711
|
-
})).filter((
|
|
1703
|
+
getAt: l,
|
|
1704
|
+
getAnnotationBounds: g,
|
|
1705
|
+
getAnnotationRects: d,
|
|
1706
|
+
getIntersecting: (u, c, v, x) => {
|
|
1707
|
+
const L = n.search({ minX: u, minY: c, maxX: v, maxY: x }), T = new Set(L.map((k) => k.annotation.id));
|
|
1708
|
+
return Array.from(T).map((k) => ({
|
|
1709
|
+
annotation: e.getAnnotation(k),
|
|
1710
|
+
rects: d(k)
|
|
1711
|
+
})).filter((k) => !!k.annotation);
|
|
1712
1712
|
},
|
|
1713
1713
|
insert: a,
|
|
1714
|
-
recalculate: () => h(e.all().map((
|
|
1715
|
-
remove:
|
|
1714
|
+
recalculate: () => h(e.all().map((u) => u.target), !0),
|
|
1715
|
+
remove: f,
|
|
1716
1716
|
set: h,
|
|
1717
1717
|
size: () => n.all().length,
|
|
1718
1718
|
update: p
|
|
1719
1719
|
};
|
|
1720
1720
|
}, eo = (e, t) => {
|
|
1721
|
-
const n =
|
|
1722
|
-
const
|
|
1723
|
-
return
|
|
1724
|
-
},
|
|
1725
|
-
const
|
|
1726
|
-
return
|
|
1727
|
-
}, p = (
|
|
1728
|
-
const
|
|
1729
|
-
return
|
|
1730
|
-
n.getAnnotation(
|
|
1731
|
-
}),
|
|
1732
|
-
}, h = (
|
|
1733
|
-
const
|
|
1734
|
-
n.updateTarget(
|
|
1735
|
-
},
|
|
1736
|
-
const
|
|
1737
|
-
n.bulkUpdateTargets(
|
|
1738
|
-
},
|
|
1739
|
-
const
|
|
1740
|
-
return
|
|
1741
|
-
},
|
|
1742
|
-
const
|
|
1743
|
-
if (
|
|
1744
|
-
if (
|
|
1745
|
-
const x =
|
|
1721
|
+
const n = En(), o = to(n, e), i = fn(n, t), r = dn(n), s = kn(), a = (m, b = R.LOCAL) => {
|
|
1722
|
+
const u = bt(m, e), c = W(u.target.selector);
|
|
1723
|
+
return c && n.addAnnotation(u, b), c;
|
|
1724
|
+
}, f = (m, b = !0, u = R.LOCAL) => {
|
|
1725
|
+
const c = m.map((x) => bt(x, e)), v = c.filter((x) => !W(x.target.selector));
|
|
1726
|
+
return v.length > 0 ? (console.warn("Could not revive all targets for these annotations:", v), n.bulkAddAnnotation(c, b, u), v) : (n.bulkAddAnnotation(c, b, u), []);
|
|
1727
|
+
}, p = (m, b = R.LOCAL) => {
|
|
1728
|
+
const u = m.map((v) => bt(v, e)), c = u.filter((v) => !W(v.target.selector));
|
|
1729
|
+
return c.length > 0 && console.warn("Could not revive all targets for these annotations:", c), u.forEach((v) => {
|
|
1730
|
+
n.getAnnotation(v.id) ? n.updateAnnotation(v, b) : n.addAnnotation(v, b);
|
|
1731
|
+
}), c;
|
|
1732
|
+
}, h = (m, b = R.LOCAL) => {
|
|
1733
|
+
const u = mt(m, e);
|
|
1734
|
+
n.updateTarget(u, b);
|
|
1735
|
+
}, l = (m, b = R.LOCAL) => {
|
|
1736
|
+
const u = m.map((c) => mt(c, e));
|
|
1737
|
+
n.bulkUpdateTargets(u, b);
|
|
1738
|
+
}, g = (m, b, u) => {
|
|
1739
|
+
const c = o.getAt(m, b, !!u).map((x) => n.getAnnotation(x)), v = u ? c.filter(u) : c;
|
|
1740
|
+
return v.length > 0 ? v[0] : void 0;
|
|
1741
|
+
}, d = (m, b, u, c = 5) => {
|
|
1742
|
+
const v = o.getAnnotationRects(m);
|
|
1743
|
+
if (v.length !== 0) {
|
|
1744
|
+
if (b && u) {
|
|
1745
|
+
const x = v.find(({ top: L, right: T, bottom: k, left: M }) => b >= M - c && b <= T + c && u >= L - c && u <= k + c);
|
|
1746
1746
|
if (x) return x;
|
|
1747
1747
|
}
|
|
1748
|
-
return o.getAnnotationBounds(
|
|
1748
|
+
return o.getAnnotationBounds(m);
|
|
1749
1749
|
}
|
|
1750
|
-
},
|
|
1751
|
-
return n.observe(({ changes:
|
|
1752
|
-
const
|
|
1753
|
-
(
|
|
1750
|
+
}, A = () => o.recalculate();
|
|
1751
|
+
return n.observe(({ changes: m }) => {
|
|
1752
|
+
const b = (m.deleted || []).filter((v) => W(v.target.selector)), u = (m.created || []).filter((v) => W(v.target.selector)), c = (m.updated || []).filter((v) => W(v.newValue.target.selector));
|
|
1753
|
+
(b == null ? void 0 : b.length) > 0 && b.forEach((v) => o.remove(v.target)), u.length > 0 && o.set(u.map((v) => v.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: v }) => o.update(v.target));
|
|
1754
1754
|
}), {
|
|
1755
1755
|
store: {
|
|
1756
1756
|
...n,
|
|
1757
1757
|
addAnnotation: a,
|
|
1758
|
-
bulkAddAnnotation:
|
|
1759
|
-
bulkUpdateTargets:
|
|
1758
|
+
bulkAddAnnotation: f,
|
|
1759
|
+
bulkUpdateTargets: l,
|
|
1760
1760
|
bulkUpsertAnnotations: p,
|
|
1761
|
-
getAnnotationBounds:
|
|
1762
|
-
getAt:
|
|
1761
|
+
getAnnotationBounds: d,
|
|
1762
|
+
getAt: g,
|
|
1763
1763
|
getIntersecting: o.getIntersecting.bind(o),
|
|
1764
1764
|
getAnnotationRects: o.getAnnotationRects.bind(o),
|
|
1765
|
-
recalculatePositions:
|
|
1765
|
+
recalculatePositions: A,
|
|
1766
1766
|
updateTarget: h
|
|
1767
1767
|
},
|
|
1768
1768
|
selection: i,
|
|
@@ -1777,34 +1777,34 @@ const to = (e, t) => {
|
|
|
1777
1777
|
}, oo = (e, t, n = {}) => {
|
|
1778
1778
|
const o = no(), i = o.getContext("2d");
|
|
1779
1779
|
document.body.appendChild(o);
|
|
1780
|
-
const r = /* @__PURE__ */ new Map(), s = (
|
|
1781
|
-
return t.on("selectionChange", (
|
|
1782
|
-
s(
|
|
1780
|
+
const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([g, d]) => d.presenceKey === l.presenceKey).map(([g, d]) => g);
|
|
1781
|
+
return t.on("selectionChange", (l, g) => {
|
|
1782
|
+
s(l).forEach((A) => r.delete(A)), g && g.forEach((A) => r.set(A, l));
|
|
1783
1783
|
}), {
|
|
1784
1784
|
clear: () => {
|
|
1785
|
-
const { width:
|
|
1786
|
-
i.clearRect(-0.5, -0.5,
|
|
1785
|
+
const { width: l, height: g } = o;
|
|
1786
|
+
i.clearRect(-0.5, -0.5, l + 1, g + 1);
|
|
1787
1787
|
},
|
|
1788
1788
|
destroy: () => {
|
|
1789
1789
|
o.remove();
|
|
1790
1790
|
},
|
|
1791
|
-
paint: (
|
|
1791
|
+
paint: (l, g, d) => {
|
|
1792
1792
|
n.font && (i.font = n.font);
|
|
1793
|
-
const
|
|
1794
|
-
if (
|
|
1795
|
-
const { height:
|
|
1796
|
-
i.fillStyle =
|
|
1797
|
-
const
|
|
1798
|
-
return i.fillRect(
|
|
1799
|
-
fill:
|
|
1800
|
-
fillOpacity:
|
|
1793
|
+
const A = r.get(l.annotation.id);
|
|
1794
|
+
if (A) {
|
|
1795
|
+
const { height: m } = l.rects[0], b = l.rects[0].x + g.left, u = l.rects[0].y + g.top;
|
|
1796
|
+
i.fillStyle = A.appearance.color, i.fillRect(b - 2, u - 2.5, 2, m + 5);
|
|
1797
|
+
const c = i.measureText(A.appearance.label), v = c.width + 6, x = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1798
|
+
return i.fillRect(b - 2, u - 2.5 - x, v, x), i.fillStyle = "#fff", i.fillText(A.appearance.label, b + 1, u - L), {
|
|
1799
|
+
fill: A.appearance.color,
|
|
1800
|
+
fillOpacity: d ? 0.45 : 0.18
|
|
1801
1801
|
};
|
|
1802
1802
|
}
|
|
1803
1803
|
},
|
|
1804
1804
|
reset: () => {
|
|
1805
1805
|
o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
|
|
1806
|
-
const
|
|
1807
|
-
|
|
1806
|
+
const l = o.getContext("2d");
|
|
1807
|
+
l.scale(2, 2), l.translate(0.5, 0.5);
|
|
1808
1808
|
}
|
|
1809
1809
|
};
|
|
1810
1810
|
}, ue = (e) => {
|
|
@@ -1814,17 +1814,17 @@ const to = (e, t) => {
|
|
|
1814
1814
|
return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e : ue(e.parentElement);
|
|
1815
1815
|
}, io = (e, t) => (n) => {
|
|
1816
1816
|
const o = typeof n == "string" ? n : n.id, i = (s) => {
|
|
1817
|
-
const a = r.getBoundingClientRect(),
|
|
1818
|
-
r.scroll({ top:
|
|
1817
|
+
const a = r.getBoundingClientRect(), f = r.clientHeight, p = r.clientWidth, h = s.selector[0].range.getBoundingClientRect(), { width: l, height: g } = t.getAnnotationBounds(o), d = h.top - a.top, A = h.left - a.left, m = r.parentElement ? r.scrollTop : 0, b = r.parentElement ? r.scrollLeft : 0, u = d + m - (f - g) / 2, c = A + b - (p - l) / 2;
|
|
1818
|
+
r.scroll({ top: u, left: c, behavior: "smooth" });
|
|
1819
1819
|
}, r = ue(e);
|
|
1820
1820
|
if (r) {
|
|
1821
1821
|
const s = t.getAnnotation(o), { range: a } = s.target.selector[0];
|
|
1822
1822
|
if (a && !a.collapsed)
|
|
1823
1823
|
return i(s.target), !0;
|
|
1824
1824
|
{
|
|
1825
|
-
const
|
|
1825
|
+
const f = mt(s.target, e), { range: p } = f.selector[0];
|
|
1826
1826
|
if (p && !p.collapsed)
|
|
1827
|
-
return i(
|
|
1827
|
+
return i(f), !0;
|
|
1828
1828
|
}
|
|
1829
1829
|
}
|
|
1830
1830
|
return !1;
|
|
@@ -1936,7 +1936,7 @@ const at = {
|
|
|
1936
1936
|
ctrlKey: 17,
|
|
1937
1937
|
altKey: 18,
|
|
1938
1938
|
metaKey: 91
|
|
1939
|
-
},
|
|
1939
|
+
}, D = {
|
|
1940
1940
|
16: !1,
|
|
1941
1941
|
18: !1,
|
|
1942
1942
|
17: !1,
|
|
@@ -2005,8 +2005,8 @@ function go(e, t) {
|
|
|
2005
2005
|
function mo(e) {
|
|
2006
2006
|
let t = e.keyCode || e.which || e.charCode;
|
|
2007
2007
|
const n = V.indexOf(t);
|
|
2008
|
-
if (n >= 0 && V.splice(n, 1), e.key && e.key.toLowerCase() === "meta" && V.splice(0, V.length), (t === 93 || t === 224) && (t = 91), t in
|
|
2009
|
-
|
|
2008
|
+
if (n >= 0 && V.splice(n, 1), e.key && e.key.toLowerCase() === "meta" && V.splice(0, V.length), (t === 93 || t === 224) && (t = 91), t in D) {
|
|
2009
|
+
D[t] = !1;
|
|
2010
2010
|
for (const o in X) X[o] === t && (U[o] = !1);
|
|
2011
2011
|
}
|
|
2012
2012
|
}
|
|
@@ -2041,14 +2041,14 @@ const ht = (e) => {
|
|
|
2041
2041
|
splitKey: i = "+"
|
|
2042
2042
|
} = e;
|
|
2043
2043
|
pe(t).forEach((s) => {
|
|
2044
|
-
const a = s.split(i),
|
|
2044
|
+
const a = s.split(i), f = a.length, p = a[f - 1], h = p === "*" ? "*" : lt(p);
|
|
2045
2045
|
if (!O[h]) return;
|
|
2046
2046
|
n || (n = st());
|
|
2047
|
-
const
|
|
2048
|
-
O[h] = O[h].filter((
|
|
2049
|
-
const
|
|
2050
|
-
return
|
|
2051
|
-
}),
|
|
2047
|
+
const l = f > 1 ? fe(X, a) : [], g = [];
|
|
2048
|
+
O[h] = O[h].filter((d) => {
|
|
2049
|
+
const m = (o ? d.method === o : !0) && d.scope === n && ao(d.mods, l);
|
|
2050
|
+
return m && g.push(d.element), !m;
|
|
2051
|
+
}), g.forEach((d) => Pt(d));
|
|
2052
2052
|
});
|
|
2053
2053
|
};
|
|
2054
2054
|
function Kt(e, t, n, o) {
|
|
@@ -2057,9 +2057,9 @@ function Kt(e, t, n, o) {
|
|
|
2057
2057
|
let i;
|
|
2058
2058
|
if (t.scope === n || t.scope === "all") {
|
|
2059
2059
|
i = t.mods.length > 0;
|
|
2060
|
-
for (const r in
|
|
2061
|
-
Object.prototype.hasOwnProperty.call(
|
|
2062
|
-
(t.mods.length === 0 && !
|
|
2060
|
+
for (const r in D)
|
|
2061
|
+
Object.prototype.hasOwnProperty.call(D, r) && (!D[r] && t.mods.indexOf(+r) > -1 || D[r] && t.mods.indexOf(+r) === -1) && (i = !1);
|
|
2062
|
+
(t.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || t.shortcut === "*") && (t.keys = [], t.keys = t.keys.concat(V), t.method(e, t) === !1 && (e.preventDefault ? e.preventDefault() : e.returnValue = !1, e.stopPropagation && e.stopPropagation(), e.cancelBubble && (e.cancelBubble = !0)));
|
|
2063
2063
|
}
|
|
2064
2064
|
}
|
|
2065
2065
|
function te(e, t) {
|
|
@@ -2067,17 +2067,17 @@ function te(e, t) {
|
|
|
2067
2067
|
let o = e.keyCode || e.which || e.charCode;
|
|
2068
2068
|
if (!U.filter.call(this, e)) return;
|
|
2069
2069
|
if ((o === 93 || o === 224) && (o = 91), V.indexOf(o) === -1 && o !== 229 && V.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
|
|
2070
|
-
const
|
|
2071
|
-
e[a] && V.indexOf(
|
|
2072
|
-
}), o in
|
|
2073
|
-
|
|
2070
|
+
const f = Ot[a];
|
|
2071
|
+
e[a] && V.indexOf(f) === -1 ? V.push(f) : !e[a] && V.indexOf(f) > -1 ? V.splice(V.indexOf(f), 1) : a === "metaKey" && e[a] && V.length === 3 && (e.ctrlKey || e.shiftKey || e.altKey || (V = V.slice(V.indexOf(f))));
|
|
2072
|
+
}), o in D) {
|
|
2073
|
+
D[o] = !0;
|
|
2074
2074
|
for (const a in X)
|
|
2075
2075
|
X[a] === o && (U[a] = !0);
|
|
2076
2076
|
if (!n) return;
|
|
2077
2077
|
}
|
|
2078
|
-
for (const a in
|
|
2079
|
-
Object.prototype.hasOwnProperty.call(
|
|
2080
|
-
e.getModifierState && !(e.altKey && !e.ctrlKey) && e.getModifierState("AltGraph") && (V.indexOf(17) === -1 && V.push(17), V.indexOf(18) === -1 && V.push(18),
|
|
2078
|
+
for (const a in D)
|
|
2079
|
+
Object.prototype.hasOwnProperty.call(D, a) && (D[a] = e[Ot[a]]);
|
|
2080
|
+
e.getModifierState && !(e.altKey && !e.ctrlKey) && e.getModifierState("AltGraph") && (V.indexOf(17) === -1 && V.push(17), V.indexOf(18) === -1 && V.push(18), D[17] = !0, D[18] = !0);
|
|
2081
2081
|
const i = st();
|
|
2082
2082
|
if (n)
|
|
2083
2083
|
for (let a = 0; a < n.length; a++)
|
|
@@ -2086,21 +2086,21 @@ function te(e, t) {
|
|
|
2086
2086
|
const r = O[o], s = r.length;
|
|
2087
2087
|
for (let a = 0; a < s; a++)
|
|
2088
2088
|
if ((e.type === "keydown" && r[a].keydown || e.type === "keyup" && r[a].keyup) && r[a].key) {
|
|
2089
|
-
const
|
|
2089
|
+
const f = r[a], {
|
|
2090
2090
|
splitKey: p
|
|
2091
|
-
} =
|
|
2092
|
-
for (let
|
|
2093
|
-
|
|
2094
|
-
|
|
2091
|
+
} = f, h = f.key.split(p), l = [];
|
|
2092
|
+
for (let g = 0; g < h.length; g++)
|
|
2093
|
+
l.push(lt(h[g]));
|
|
2094
|
+
l.sort().join("") === V.sort().join("") && Kt(e, f, i, t);
|
|
2095
2095
|
}
|
|
2096
2096
|
}
|
|
2097
2097
|
function U(e, t, n) {
|
|
2098
2098
|
V = [];
|
|
2099
2099
|
const o = pe(e);
|
|
2100
|
-
let i = [], r = "all", s = document, a = 0,
|
|
2101
|
-
for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (
|
|
2100
|
+
let i = [], r = "all", s = document, a = 0, f = !1, p = !0, h = "+", l = !1, g = !1;
|
|
2101
|
+
for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (f = t.keyup), t.keydown !== void 0 && (p = t.keydown), t.capture !== void 0 && (l = t.capture), typeof t.splitKey == "string" && (h = t.splitKey), t.single === !0 && (g = !0)), typeof t == "string" && (r = t), g && me(e, r); a < o.length; a++)
|
|
2102
2102
|
e = o[a].split(h), i = [], e.length > 1 && (i = fe(X, e)), e = e[e.length - 1], e = e === "*" ? "*" : lt(e), e in O || (O[e] = []), O[e].push({
|
|
2103
|
-
keyup:
|
|
2103
|
+
keyup: f,
|
|
2104
2104
|
keydown: p,
|
|
2105
2105
|
scope: r,
|
|
2106
2106
|
mods: i,
|
|
@@ -2112,27 +2112,27 @@ function U(e, t, n) {
|
|
|
2112
2112
|
});
|
|
2113
2113
|
if (typeof s < "u" && window) {
|
|
2114
2114
|
if (!G.has(s)) {
|
|
2115
|
-
const
|
|
2116
|
-
let
|
|
2117
|
-
return te(
|
|
2118
|
-
},
|
|
2119
|
-
let
|
|
2120
|
-
te(
|
|
2115
|
+
const d = function() {
|
|
2116
|
+
let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2117
|
+
return te(m, s);
|
|
2118
|
+
}, A = function() {
|
|
2119
|
+
let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2120
|
+
te(m, s), mo(m);
|
|
2121
2121
|
};
|
|
2122
2122
|
G.set(s, {
|
|
2123
|
-
keydownListener:
|
|
2124
|
-
keyupListenr:
|
|
2125
|
-
capture:
|
|
2126
|
-
}), Bt(s, "keydown",
|
|
2123
|
+
keydownListener: d,
|
|
2124
|
+
keyupListenr: A,
|
|
2125
|
+
capture: l
|
|
2126
|
+
}), Bt(s, "keydown", d, l), Bt(s, "keyup", A, l);
|
|
2127
2127
|
}
|
|
2128
2128
|
if (!rt) {
|
|
2129
|
-
const
|
|
2129
|
+
const d = () => {
|
|
2130
2130
|
V = [];
|
|
2131
2131
|
};
|
|
2132
2132
|
rt = {
|
|
2133
|
-
listener:
|
|
2134
|
-
capture:
|
|
2135
|
-
}, Bt(window, "focus",
|
|
2133
|
+
listener: d,
|
|
2134
|
+
capture: l
|
|
2135
|
+
}, Bt(window, "focus", d, l);
|
|
2136
2136
|
}
|
|
2137
2137
|
}
|
|
2138
2138
|
}
|
|
@@ -2201,122 +2201,129 @@ var be = {};
|
|
|
2201
2201
|
t.Unidentified = "Unidentified", t.Alt = "Alt", t.AltGraph = "AltGraph", t.CapsLock = "CapsLock", t.Control = "Control", t.Fn = "Fn", t.FnLock = "FnLock", t.Hyper = "Hyper", t.Meta = "Meta", t.NumLock = "NumLock", t.ScrollLock = "ScrollLock", t.Shift = "Shift", t.Super = "Super", t.Symbol = "Symbol", t.SymbolLock = "SymbolLock", t.Enter = "Enter", t.Tab = "Tab", t.ArrowDown = "ArrowDown", t.ArrowLeft = "ArrowLeft", t.ArrowRight = "ArrowRight", t.ArrowUp = "ArrowUp", t.End = "End", t.Home = "Home", t.PageDown = "PageDown", t.PageUp = "PageUp", t.Backspace = "Backspace", t.Clear = "Clear", t.Copy = "Copy", t.CrSel = "CrSel", t.Cut = "Cut", t.Delete = "Delete", t.EraseEof = "EraseEof", t.ExSel = "ExSel", t.Insert = "Insert", t.Paste = "Paste", t.Redo = "Redo", t.Undo = "Undo", t.Accept = "Accept", t.Again = "Again", t.Attn = "Attn", t.Cancel = "Cancel", t.ContextMenu = "ContextMenu", t.Escape = "Escape", t.Execute = "Execute", t.Find = "Find", t.Finish = "Finish", t.Help = "Help", t.Pause = "Pause", t.Play = "Play", t.Props = "Props", t.Select = "Select", t.ZoomIn = "ZoomIn", t.ZoomOut = "ZoomOut", t.BrightnessDown = "BrightnessDown", t.BrightnessUp = "BrightnessUp", t.Eject = "Eject", t.LogOff = "LogOff", t.Power = "Power", t.PowerOff = "PowerOff", t.PrintScreen = "PrintScreen", t.Hibernate = "Hibernate", t.Standby = "Standby", t.WakeUp = "WakeUp", t.AllCandidates = "AllCandidates", t.Alphanumeric = "Alphanumeric", t.CodeInput = "CodeInput", t.Compose = "Compose", t.Convert = "Convert", t.Dead = "Dead", t.FinalMode = "FinalMode", t.GroupFirst = "GroupFirst", t.GroupLast = "GroupLast", t.GroupNext = "GroupNext", t.GroupPrevious = "GroupPrevious", t.ModeChange = "ModeChange", t.NextCandidate = "NextCandidate", t.NonConvert = "NonConvert", t.PreviousCandidate = "PreviousCandidate", t.Process = "Process", t.SingleCandidate = "SingleCandidate", t.HangulMode = "HangulMode", t.HanjaMode = "HanjaMode", t.JunjaMode = "JunjaMode", t.Eisu = "Eisu", t.Hankaku = "Hankaku", t.Hiragana = "Hiragana", t.HiraganaKatakana = "HiraganaKatakana", t.KanaMode = "KanaMode", t.KanjiMode = "KanjiMode", t.Katakana = "Katakana", t.Romaji = "Romaji", t.Zenkaku = "Zenkaku", t.ZenkakuHanaku = "ZenkakuHanaku", t.F1 = "F1", t.F2 = "F2", t.F3 = "F3", t.F4 = "F4", t.F5 = "F5", t.F6 = "F6", t.F7 = "F7", t.F8 = "F8", t.F9 = "F9", t.F10 = "F10", t.F11 = "F11", t.F12 = "F12", t.F13 = "F13", t.F14 = "F14", t.F15 = "F15", t.F16 = "F16", t.F17 = "F17", t.F18 = "F18", t.F19 = "F19", t.F20 = "F20", t.Soft1 = "Soft1", t.Soft2 = "Soft2", t.Soft3 = "Soft3", t.Soft4 = "Soft4", t.AppSwitch = "AppSwitch", t.Call = "Call", t.Camera = "Camera", t.CameraFocus = "CameraFocus", t.EndCall = "EndCall", t.GoBack = "GoBack", t.GoHome = "GoHome", t.HeadsetHook = "HeadsetHook", t.LastNumberRedial = "LastNumberRedial", t.Notification = "Notification", t.MannerMode = "MannerMode", t.VoiceDial = "VoiceDial", t.ChannelDown = "ChannelDown", t.ChannelUp = "ChannelUp", t.MediaFastForward = "MediaFastForward", t.MediaPause = "MediaPause", t.MediaPlay = "MediaPlay", t.MediaPlayPause = "MediaPlayPause", t.MediaRecord = "MediaRecord", t.MediaRewind = "MediaRewind", t.MediaStop = "MediaStop", t.MediaTrackNext = "MediaTrackNext", t.MediaTrackPrevious = "MediaTrackPrevious", t.AudioBalanceLeft = "AudioBalanceLeft", t.AudioBalanceRight = "AudioBalanceRight", t.AudioBassDown = "AudioBassDown", t.AudioBassBoostDown = "AudioBassBoostDown", t.AudioBassBoostToggle = "AudioBassBoostToggle", t.AudioBassBoostUp = "AudioBassBoostUp", t.AudioBassUp = "AudioBassUp", t.AudioFaderFront = "AudioFaderFront", t.AudioFaderRear = "AudioFaderRear", t.AudioSurroundModeNext = "AudioSurroundModeNext", t.AudioTrebleDown = "AudioTrebleDown", t.AudioTrebleUp = "AudioTrebleUp", t.AudioVolumeDown = "AudioVolumeDown", t.AudioVolumeMute = "AudioVolumeMute", t.AudioVolumeUp = "AudioVolumeUp", t.MicrophoneToggle = "MicrophoneToggle", t.MicrophoneVolumeDown = "MicrophoneVolumeDown", t.MicrophoneVolumeMute = "MicrophoneVolumeMute", t.MicrophoneVolumeUp = "MicrophoneVolumeUp", t.TV = "TV", t.TV3DMode = "TV3DMode", t.TVAntennaCable = "TVAntennaCable", t.TVAudioDescription = "TVAudioDescription", t.TVAudioDescriptionMixDown = "TVAudioDescriptionMixDown", t.TVAudioDescriptionMixUp = "TVAudioDescriptionMixUp", t.TVContentsMenu = "TVContentsMenu", t.TVDataService = "TVDataService", t.TVInput = "TVInput", t.TVInputComponent1 = "TVInputComponent1", t.TVInputComponent2 = "TVInputComponent2", t.TVInputComposite1 = "TVInputComposite1", t.TVInputComposite2 = "TVInputComposite2", t.TVInputHDMI1 = "TVInputHDMI1", t.TVInputHDMI2 = "TVInputHDMI2", t.TVInputHDMI3 = "TVInputHDMI3", t.TVInputHDMI4 = "TVInputHDMI4", t.TVInputVGA1 = "TVInputVGA1", t.TVMediaContext = "TVMediaContext", t.TVNetwork = "TVNetwork", t.TVNumberEntry = "TVNumberEntry", t.TVPower = "TVPower", t.TVRadioService = "TVRadioService", t.TVSatellite = "TVSatellite", t.TVSatelliteBS = "TVSatelliteBS", t.TVSatelliteCS = "TVSatelliteCS", t.TVSatelliteToggle = "TVSatelliteToggle", t.TVTerrestrialAnalog = "TVTerrestrialAnalog", t.TVTerrestrialDigital = "TVTerrestrialDigital", t.TVTimer = "TVTimer", t.AVRInput = "AVRInput", t.AVRPower = "AVRPower", t.ColorF0Red = "ColorF0Red", t.ColorF1Green = "ColorF1Green", t.ColorF2Yellow = "ColorF2Yellow", t.ColorF3Blue = "ColorF3Blue", t.ColorF4Grey = "ColorF4Grey", t.ColorF5Brown = "ColorF5Brown", t.ClosedCaptionToggle = "ClosedCaptionToggle", t.Dimmer = "Dimmer", t.DisplaySwap = "DisplaySwap", t.DVR = "DVR", t.Exit = "Exit", t.FavoriteClear0 = "FavoriteClear0", t.FavoriteClear1 = "FavoriteClear1", t.FavoriteClear2 = "FavoriteClear2", t.FavoriteClear3 = "FavoriteClear3", t.FavoriteRecall0 = "FavoriteRecall0", t.FavoriteRecall1 = "FavoriteRecall1", t.FavoriteRecall2 = "FavoriteRecall2", t.FavoriteRecall3 = "FavoriteRecall3", t.FavoriteStore0 = "FavoriteStore0", t.FavoriteStore1 = "FavoriteStore1", t.FavoriteStore2 = "FavoriteStore2", t.FavoriteStore3 = "FavoriteStore3", t.Guide = "Guide", t.GuideNextDay = "GuideNextDay", t.GuidePreviousDay = "GuidePreviousDay", t.Info = "Info", t.InstantReplay = "InstantReplay", t.Link = "Link", t.ListProgram = "ListProgram", t.LiveContent = "LiveContent", t.Lock = "Lock", t.MediaApps = "MediaApps", t.MediaAudioTrack = "MediaAudioTrack", t.MediaLast = "MediaLast", t.MediaSkipBackward = "MediaSkipBackward", t.MediaSkipForward = "MediaSkipForward", t.MediaStepBackward = "MediaStepBackward", t.MediaStepForward = "MediaStepForward", t.MediaTopMenu = "MediaTopMenu", t.NavigateIn = "NavigateIn", t.NavigateNext = "NavigateNext", t.NavigateOut = "NavigateOut", t.NavigatePrevious = "NavigatePrevious", t.NextFavoriteChannel = "NextFavoriteChannel", t.NextUserProfile = "NextUserProfile", t.OnDemand = "OnDemand", t.Pairing = "Pairing", t.PinPDown = "PinPDown", t.PinPMove = "PinPMove", t.PinPToggle = "PinPToggle", t.PinPUp = "PinPUp", t.PlaySpeedDown = "PlaySpeedDown", t.PlaySpeedReset = "PlaySpeedReset", t.PlaySpeedUp = "PlaySpeedUp", t.RandomToggle = "RandomToggle", t.RcLowBattery = "RcLowBattery", t.RecordSpeedNext = "RecordSpeedNext", t.RfBypass = "RfBypass", t.ScanChannelsToggle = "ScanChannelsToggle", t.ScreenModeNext = "ScreenModeNext", t.Settings = "Settings", t.SplitScreenToggle = "SplitScreenToggle", t.STBInput = "STBInput", t.STBPower = "STBPower", t.Subtitle = "Subtitle", t.Teletext = "Teletext", t.VideoModeNext = "VideoModeNext", t.Wink = "Wink", t.ZoomToggle = "ZoomToggle", t.SpeechCorrectionList = "SpeechCorrectionList", t.SpeechInputToggle = "SpeechInputToggle", t.Close = "Close", t.New = "New", t.Open = "Open", t.Print = "Print", t.Save = "Save", t.SpellCheck = "SpellCheck", t.MailForward = "MailForward", t.MailReply = "MailReply", t.MailSend = "MailSend", t.LaunchCalculator = "LaunchCalculator", t.LaunchCalendar = "LaunchCalendar", t.LaunchContacts = "LaunchContacts", t.LaunchMail = "LaunchMail", t.LaunchMediaPlayer = "LaunchMediaPlayer", t.LaunchMusicPlayer = "LaunchMusicPlayer", t.LaunchMyComputer = "LaunchMyComputer", t.LaunchPhone = "LaunchPhone", t.LaunchScreenSaver = "LaunchScreenSaver", t.LaunchSpreadsheet = "LaunchSpreadsheet", t.LaunchWebBrowser = "LaunchWebBrowser", t.LaunchWebCam = "LaunchWebCam", t.LaunchWordProcessor = "LaunchWordProcessor", t.LaunchApplication1 = "LaunchApplication1", t.LaunchApplication2 = "LaunchApplication2", t.LaunchApplication3 = "LaunchApplication3", t.LaunchApplication4 = "LaunchApplication4", t.LaunchApplication5 = "LaunchApplication5", t.LaunchApplication6 = "LaunchApplication6", t.LaunchApplication7 = "LaunchApplication7", t.LaunchApplication8 = "LaunchApplication8", t.LaunchApplication9 = "LaunchApplication9", t.LaunchApplication10 = "LaunchApplication10", t.LaunchApplication11 = "LaunchApplication11", t.LaunchApplication12 = "LaunchApplication12", t.LaunchApplication13 = "LaunchApplication13", t.LaunchApplication14 = "LaunchApplication14", t.LaunchApplication15 = "LaunchApplication15", t.LaunchApplication16 = "LaunchApplication16", t.BrowserBack = "BrowserBack", t.BrowserFavorites = "BrowserFavorites", t.BrowserForward = "BrowserForward", t.BrowserHome = "BrowserHome", t.BrowserRefresh = "BrowserRefresh", t.BrowserSearch = "BrowserSearch", t.BrowserStop = "BrowserStop", t.Decimal = "Decimal", t.Key11 = "Key11", t.Key12 = "Key12", t.Multiply = "Multiply", t.Add = "Add", t.Divide = "Divide", t.Subtract = "Subtract", t.Separator = "Separator";
|
|
2202
2202
|
}(e.Key || (e.Key = {}));
|
|
2203
2203
|
})(be);
|
|
2204
|
-
const wo = (e, t, n
|
|
2205
|
-
let
|
|
2206
|
-
const
|
|
2207
|
-
let
|
|
2208
|
-
const
|
|
2209
|
-
let
|
|
2210
|
-
const f = (
|
|
2204
|
+
const wo = (e, t, n) => {
|
|
2205
|
+
let o;
|
|
2206
|
+
const i = (x) => o = x;
|
|
2207
|
+
let r;
|
|
2208
|
+
const s = (x) => r = x;
|
|
2209
|
+
let a = !0;
|
|
2210
|
+
const f = (x) => a = x, { store: p, selection: h } = t;
|
|
2211
|
+
let l, g, d;
|
|
2212
|
+
const A = (x) => {
|
|
2211
2213
|
var T;
|
|
2212
|
-
if (
|
|
2214
|
+
if (!a || g === !1)
|
|
2213
2215
|
return;
|
|
2214
|
-
|
|
2216
|
+
l = !((T = x.target.parentElement) != null && T.closest(Y)) ? {
|
|
2215
2217
|
annotation: se(),
|
|
2216
2218
|
selector: [],
|
|
2217
|
-
creator:
|
|
2219
|
+
creator: o,
|
|
2218
2220
|
created: /* @__PURE__ */ new Date()
|
|
2219
2221
|
} : void 0;
|
|
2220
2222
|
};
|
|
2221
|
-
|
|
2222
|
-
const
|
|
2223
|
-
var
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2223
|
+
e.addEventListener("selectstart", A);
|
|
2224
|
+
const m = It((x) => {
|
|
2225
|
+
var w, S;
|
|
2226
|
+
if (!a) return;
|
|
2227
|
+
const L = document.getSelection();
|
|
2228
|
+
if (!!((S = (w = L.anchorNode) == null ? void 0 : w.parentElement) != null && S.closest(Y))) {
|
|
2229
|
+
l = void 0;
|
|
2227
2230
|
return;
|
|
2228
2231
|
}
|
|
2229
|
-
if (
|
|
2232
|
+
if (x.timeStamp - ((d == null ? void 0 : d.timeStamp) || x.timeStamp) < 1e3 && !l && A(d || x), L.isCollapsed || !l || g === !1)
|
|
2230
2233
|
return;
|
|
2231
|
-
const
|
|
2232
|
-
if (Ve(
|
|
2233
|
-
const M = Le(
|
|
2234
|
-
(M.length !==
|
|
2235
|
-
var
|
|
2236
|
-
return
|
|
2237
|
-
})) && (
|
|
2238
|
-
...
|
|
2239
|
-
selector: M.map((
|
|
2234
|
+
const k = L.getRangeAt(0);
|
|
2235
|
+
if (Ve(k)) return;
|
|
2236
|
+
const M = Le(k.cloneRange());
|
|
2237
|
+
(M.length !== l.selector.length || M.some((C, E) => {
|
|
2238
|
+
var B;
|
|
2239
|
+
return C.toString() !== ((B = l.selector[E]) == null ? void 0 : B.quote);
|
|
2240
|
+
})) && (l = {
|
|
2241
|
+
...l,
|
|
2242
|
+
selector: M.map((C) => Fe(C, e, n)),
|
|
2240
2243
|
updated: /* @__PURE__ */ new Date()
|
|
2241
|
-
},
|
|
2242
|
-
id:
|
|
2244
|
+
}, p.getAnnotation(l.annotation) ? p.updateTarget(l, R.LOCAL) : (h.clear(), p.addAnnotation({
|
|
2245
|
+
id: l.annotation,
|
|
2243
2246
|
bodies: [],
|
|
2244
|
-
target:
|
|
2245
|
-
}, R.LOCAL),
|
|
2247
|
+
target: l
|
|
2248
|
+
}, R.LOCAL), h.userSelect(l.annotation, d)));
|
|
2246
2249
|
});
|
|
2247
|
-
|
|
2248
|
-
const b = (
|
|
2249
|
-
|
|
2250
|
+
document.addEventListener("selectionchange", m);
|
|
2251
|
+
const b = (x) => {
|
|
2252
|
+
d = De(x), g = d.button === 0;
|
|
2250
2253
|
};
|
|
2251
2254
|
e.addEventListener("pointerdown", b);
|
|
2252
|
-
const
|
|
2255
|
+
const u = (x) => {
|
|
2253
2256
|
var M;
|
|
2254
|
-
if (!!((M =
|
|
2257
|
+
if (!!((M = x.target.parentElement) != null && M.closest(Y)) || !g)
|
|
2255
2258
|
return;
|
|
2256
2259
|
const T = () => {
|
|
2257
|
-
const { x:
|
|
2258
|
-
if (
|
|
2259
|
-
const { selected:
|
|
2260
|
-
(
|
|
2261
|
-
} else
|
|
2262
|
-
},
|
|
2263
|
-
document.getSelection().isCollapsed &&
|
|
2260
|
+
const { x: y, y: w } = e.getBoundingClientRect(), S = p.getAt(x.clientX - y, x.clientY - w, r);
|
|
2261
|
+
if (S) {
|
|
2262
|
+
const { selected: C } = h;
|
|
2263
|
+
(C.length !== 1 || C[0].id !== S.id) && h.userSelect(S.id, x);
|
|
2264
|
+
} else h.isEmpty() || h.clear();
|
|
2265
|
+
}, k = x.timeStamp - d.timeStamp;
|
|
2266
|
+
document.getSelection().isCollapsed && k < 300 ? (l = void 0, T()) : l && h.userSelect(l.annotation, x);
|
|
2264
2267
|
};
|
|
2265
|
-
document.addEventListener("pointerup",
|
|
2266
|
-
|
|
2267
|
-
}), U("*", { keyup: !0, keydown: !1 }, (
|
|
2268
|
-
U.shift &&
|
|
2268
|
+
document.addEventListener("pointerup", u), U("*", { element: e, keyup: !1, keydown: !0 }, (x, L) => {
|
|
2269
|
+
x.repeat || (d = ye(x));
|
|
2270
|
+
}), U("*", { keyup: !0, keydown: !1 }, (x) => {
|
|
2271
|
+
U.shift && x.key === be.Key.Shift && !x.repeat && l && h.userSelect(l.annotation, x);
|
|
2269
2272
|
});
|
|
2270
|
-
let
|
|
2273
|
+
let c = !1;
|
|
2271
2274
|
return U("ctrl+a, ⌘+a", { keyup: !1, keydown: !0 }, () => {
|
|
2272
|
-
|
|
2273
|
-
}), U("*", { keyup: !0, keydown: !1 }, (
|
|
2274
|
-
|
|
2275
|
+
c = !0;
|
|
2276
|
+
}), U("*", { keyup: !0, keydown: !1 }, (x) => {
|
|
2277
|
+
c && !x.repeat && l && h.userSelect(l.annotation, x), c = !1;
|
|
2275
2278
|
}), {
|
|
2276
2279
|
destroy: () => {
|
|
2277
|
-
e.removeEventListener("selectstart",
|
|
2280
|
+
e.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", m), e.removeEventListener("pointerdown", b), document.removeEventListener("pointerup", u), U.unbind();
|
|
2278
2281
|
},
|
|
2279
|
-
setFilter:
|
|
2280
|
-
setUser:
|
|
2282
|
+
setFilter: s,
|
|
2283
|
+
setUser: i,
|
|
2284
|
+
setAnnotatingEnabled: f
|
|
2281
2285
|
};
|
|
2282
|
-
}, ee = "SPANS",
|
|
2283
|
-
|
|
2286
|
+
}, ee = "SPANS", Eo = (e, t = {}) => {
|
|
2287
|
+
Ee(e), Te(e);
|
|
2284
2288
|
const n = ro(t, {
|
|
2285
2289
|
annotatingEnabled: !0,
|
|
2286
2290
|
user: yn()
|
|
2287
|
-
}), o = eo(e, n.
|
|
2291
|
+
}), o = eo(e, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = Bn(s), f = Rn(o, a, n.adapter);
|
|
2288
2292
|
let p = n.user;
|
|
2289
|
-
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee,
|
|
2290
|
-
if (!
|
|
2293
|
+
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee, l = h === "SPANS" ? on(e, o, r) : h === "CSS_HIGHLIGHTS" ? tn(e, o, r) : h === "CANVAS" ? $e(e, o, r) : void 0;
|
|
2294
|
+
if (!l)
|
|
2291
2295
|
throw `Unknown renderer implementation: ${h}`;
|
|
2292
|
-
console.debug(`Using ${h} renderer`), n.style &&
|
|
2293
|
-
const
|
|
2294
|
-
|
|
2295
|
-
const
|
|
2296
|
-
|
|
2297
|
-
},
|
|
2298
|
-
|
|
2299
|
-
},
|
|
2300
|
-
|
|
2301
|
-
},
|
|
2302
|
-
|
|
2296
|
+
console.debug(`Using ${h} renderer`), n.style && l.setStyle(n.style);
|
|
2297
|
+
const g = wo(e, o, n.offsetReferenceSelector);
|
|
2298
|
+
g.setUser(p), g.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2299
|
+
const d = On(o, a, n.adapter), A = () => p, m = (L) => {
|
|
2300
|
+
g.setAnnotatingEnabled(L);
|
|
2301
|
+
}, b = (L) => {
|
|
2302
|
+
l.setFilter(L), g.setFilter(L);
|
|
2303
|
+
}, u = (L) => {
|
|
2304
|
+
p = L, g.setUser(L);
|
|
2305
|
+
}, c = (L) => {
|
|
2306
|
+
L && (l.setPainter(oo(e, L, n.presence)), L.on("selectionChange", () => l.redraw()));
|
|
2307
|
+
}, v = (L) => {
|
|
2308
|
+
L ? i.setSelected(L) : i.clear();
|
|
2303
2309
|
};
|
|
2304
2310
|
return {
|
|
2305
|
-
...
|
|
2311
|
+
...d,
|
|
2306
2312
|
destroy: () => {
|
|
2307
|
-
|
|
2313
|
+
l.destroy(), g.destroy(), a.destroy();
|
|
2308
2314
|
},
|
|
2309
2315
|
element: e,
|
|
2310
|
-
getUser:
|
|
2316
|
+
getUser: A,
|
|
2317
|
+
setAnnotatingEnabled: m,
|
|
2311
2318
|
setFilter: b,
|
|
2312
|
-
setStyle:
|
|
2313
|
-
redraw:
|
|
2314
|
-
setUser:
|
|
2315
|
-
setSelected:
|
|
2316
|
-
setPresenceProvider:
|
|
2317
|
-
setVisible:
|
|
2318
|
-
on:
|
|
2319
|
-
off:
|
|
2319
|
+
setStyle: l.setStyle.bind(l),
|
|
2320
|
+
redraw: l.redraw.bind(l),
|
|
2321
|
+
setUser: u,
|
|
2322
|
+
setSelected: v,
|
|
2323
|
+
setPresenceProvider: c,
|
|
2324
|
+
setVisible: l.setVisible.bind(l),
|
|
2325
|
+
on: f.on,
|
|
2326
|
+
off: f.off,
|
|
2320
2327
|
scrollIntoView: io(e, s),
|
|
2321
2328
|
state: o
|
|
2322
2329
|
};
|
|
@@ -2329,7 +2336,7 @@ export {
|
|
|
2329
2336
|
R as Origin,
|
|
2330
2337
|
un as UserSelectAction,
|
|
2331
2338
|
Lo as W3CTextFormat,
|
|
2332
|
-
|
|
2339
|
+
Ee as cancelSingleClickEvents,
|
|
2333
2340
|
ye as cloneKeyboardEvent,
|
|
2334
2341
|
De as clonePointerEvent,
|
|
2335
2342
|
xo as createBody,
|
|
@@ -2337,7 +2344,7 @@ export {
|
|
|
2337
2344
|
tn as createHighlightsRenderer,
|
|
2338
2345
|
Ke as createRenderer,
|
|
2339
2346
|
on as createSpansRenderer,
|
|
2340
|
-
|
|
2347
|
+
Eo as createTextAnnotator,
|
|
2341
2348
|
eo as createTextAnnotatorState,
|
|
2342
2349
|
It as debounce,
|
|
2343
2350
|
Co as denormalizeRectWithOffset,
|
|
@@ -2352,7 +2359,7 @@ export {
|
|
|
2352
2359
|
Pe as normalizeRectWithOffset,
|
|
2353
2360
|
Se as paint,
|
|
2354
2361
|
$n as parseW3CTextAnnotation,
|
|
2355
|
-
|
|
2362
|
+
Te as programmaticallyFocusable,
|
|
2356
2363
|
Fe as rangeToSelector,
|
|
2357
2364
|
bt as reviveAnnotation,
|
|
2358
2365
|
oe as reviveSelector,
|